Repository navigation
feat(ts-sdk): detect & configure package manager - #7864
Conversation
5f74b08 to
050f319
Compare
What issue are you running into with yarn v4? |
It doesn't resolve dependencies correctly and output that |
050f319 to
7fdac0c
Compare
One of the issues is due to the fact that that you aren't using the nodeLinker: node-modulesSince the users module isn't using 'pnp', it will just check in the The 'workspace logic' should only really affect the case where you try to do a (By 'users module', I'm referring to the 'dagger' folder and not the 'sdk' folder) |
Okay, I'll take care of that in a follow up PR then, supporting yarn v4 is something different thant the package manager configuration |
|
Update: on test failing left: My guess is that by resolving the modules differently, it fails to provide the corresponding symbol of the dependencies, I'm trying to find a way to make it work. |
|
Ok the bug should be fixed! There was an issue with the alias resolution. |
7f6e9df to
d244011
Compare
| // determine the package manager to use. Otherwise, it will use the default | ||
| // package manager based on the lock files present in the module. | ||
| // | ||
| // If none of the above works, it will use yarn. |
There was a problem hiding this comment.
This comment doesn't match the code below, since the default case returns an error
There was a problem hiding this comment.
No, the default case is returning yarn, we're going in the default case only if entries packageManager has a value, and if the entry is wrong there, then it will return an error because something is wrong with the user setup
It's not really a The fact that the sdk is using the |
That's strange it's only failing with yarn v4 then? Other package manager works fine |
d244011 to
aaef0d5
Compare
So |
If you set up However, it seems the fix I made on this PR also fixes the issue with yarn v4, it seems the compiler API does not resolve the symbols the same way depending of the package manager, that's pretty funny. |
|
I know it will pick up the other lock file if it's at the root. Wasn't sure if it was going to pick it up from another folder. Yarn patches typescript I believe. Although I never looked into what it actually changed |
Yeah, that's quite strange... but at least this PR will improve the DX :D |
helderco
left a comment
There was a problem hiding this comment.
There's enough comments for now 😅
| With(daggerExec("init", "--name=Package-Detection", "--sdk=typescript", "--source=.")). | ||
| WithoutFile("yarn.lock"). | ||
| WithoutFile("package.json"). | ||
| WithNewFile("package.json", ` | ||
| { | ||
| "dependencies": { | ||
| "typescript": "^5.3.2", | ||
| "@dagger.io/dagger": "./sdk" | ||
| }, | ||
| "packageManager": "[email protected]" | ||
| }`). | ||
| With(daggerExec("develop")) | ||
|
|
There was a problem hiding this comment.
You could also have the runtime not create package.json on init if it's already there. That's what's done in Python:
dagger/sdk/python/runtime/main.go
Lines 246 to 248 in 76859d7
You can see in tests, the customizations are added before init:
dagger/core/integration/module_python_test.go
Lines 318 to 322 in 76859d7
Same for the lock.
There was a problem hiding this comment.
I check if the package json already exist here:
dagger/sdk/typescript/runtime/main.go
Line 266 in 0aefd1c
There was a problem hiding this comment.
Ok, then what I'm saying is that instead of:
- dagger init
- change package.json
- dagger develop
- dagger call
You do:
- Add custom package.json
- dagger init
- dagger call
aaef0d5 to
e88ea31
Compare
|
@helderco I did some improvement in the PR to improve the code readability and steps. I now store module related config in |
|
These fails does not seem related to my changes:
So I think the PR is ready for another review |
f84ff3d to
cdee677
Compare
In my your dagger.json should be at the root of your repo but the source in a sub directory so you do not mixup your dependencies. For example .
.git
dagger.json // -> source ./ci
ci/
--- package.json
--- package-lock.json
--- tsconfig
--- src/index.ts
package.json // your project package.json
xx... rest of your repo |
OK, I've deleted much of my comment because I misread @TomChv's message. For reference, I did this (and I've been doing ci/cd for a while):
@jpadams -- Food for thought based on our call and new user experiences |
|
My case is slightly different than @drmikecrowe , since I have all of my dagger code in a separate repository than my application code. My concerns are centered around the dependencies of the sdk and the rest of my dagger module. (I'm using the node_modules linker for yarn)
How would this fix 'mixing up your dependencies'? Since dagger is referenced as a dependency, calling
I think what we need is a clear explanation of what you think the folder structure should be for both when dagger is in a monorepo and when its in its own repo. |
I now believe this must be our requirement: In short, I think dagger's |
Signed-off-by: Tom Chauveau <[email protected]>
Signed-off-by: Tom Chauveau <[email protected]>
Signed-off-by: Tom Chauveau <[email protected]>
Signed-off-by: Tom Chauveau <[email protected]>
Signed-off-by: Tom Chauveau <[email protected]>
Signed-off-by: Tom Chauveau <[email protected]>
Signed-off-by: Tom Chauveau <[email protected]>
Signed-off-by: Tom Chauveau <[email protected]>
Signed-off-by: Tom Chauveau <[email protected]>
Signed-off-by: Tom Chauveau <[email protected]>
Signed-off-by: Tom Chauveau <[email protected]>
Signed-off-by: Tom Chauveau <[email protected]>
Signed-off-by: Tom Chauveau <[email protected]>
Signed-off-by: Tom Chauveau <[email protected]>
Signed-off-by: Tom Chauveau <[email protected]>
Signed-off-by: Tom Chauveau <[email protected]>
Signed-off-by: Tom Chauveau <[email protected]>
Signed-off-by: Tom Chauveau <[email protected]>
Signed-off-by: Tom Chauveau <[email protected]>
fa322ad to
906fc6e
Compare
Signed-off-by: Tom Chauveau <[email protected]>
Following up on #7852, this PR uses the
packageManagerfield of thepackage.jsonto use the correct package manager.If not, it detect the used lockfile.
This PR also includes a change to generate a lockfile (yarn v1 by default) but it can also generate a lockfile for pnpm or npm with the right version.
Example
{ "packageManager": "[email protected]" // or "[email protected]" or "[email protected]" }Closes #7851