-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix package.json version when building npm packages #179
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -4,6 +4,7 @@ import ( | |||||
"context" | ||||||
"errors" | ||||||
"fmt" | ||||||
"strings" | ||||||
|
||||||
"dagger.io/dagger" | ||||||
) | ||||||
|
@@ -16,16 +17,19 @@ func NodeVersion(d *dagger.Client, src *dagger.Directory) *dagger.Container { | |||||
WithExec([]string{"cat", ".nvmrc"}) | ||||||
} | ||||||
|
||||||
func CompileFrontend(d *dagger.Client, platform dagger.Platform, src *dagger.Directory, opts *YarnCacheOpts, nodeVersion string) *dagger.Directory { | ||||||
func CompileFrontend(d *dagger.Client, platform dagger.Platform, src *dagger.Directory, opts *YarnCacheOpts, version, nodeVersion string) *dagger.Directory { | ||||||
c := NodeContainer(d, NodeImage(nodeVersion), platform). | ||||||
WithDirectory("/src", src). | ||||||
WithWorkdir("/src") | ||||||
|
||||||
c = WithYarnCache(c, opts) | ||||||
|
||||||
ersion := strings.TrimPrefix(version, "v") | ||||||
|
||||||
// Get the node version from the 'src' directories '.nvmrc' file. | ||||||
public := c. | ||||||
WithExec([]string{"yarn", "install", "--immutable"}). | ||||||
WithExec([]string{"npm", "version", ersion, "--no-git-tag-version"}). | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
WithExec([]string{"yarn", "run", "build"}). | ||||||
WithExec([]string{"yarn", "run", "plugins:build-bundled"}). | ||||||
Directory("/src/public") | ||||||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -2,6 +2,7 @@ package containers | |||||
|
||||||
import ( | ||||||
"fmt" | ||||||
"strings" | ||||||
|
||||||
"dagger.io/dagger" | ||||||
) | ||||||
|
@@ -14,10 +15,13 @@ func NPMPackages(d *dagger.Client, platform dagger.Platform, src *dagger.Directo | |||||
|
||||||
c = WithYarnCache(c, opts) | ||||||
|
||||||
ersion := strings.TrimPrefix(version, "v") | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
c = c.WithExec([]string{"mkdir", "npm-packages"}). | ||||||
WithExec([]string{"yarn", "install", "--immutable"}). | ||||||
WithExec([]string{"yarn", "run", "packages:build"}). | ||||||
// TODO: We should probably start reusing the yarn pnp map if we can figure that out isntead of rerunning yarn install everywhere. | ||||||
// TODO: We should probably start reusing the yarn pnp map if we can figure that out instead of rerunning yarn install everywhere. | ||||||
WithExec([]string{"yarn", "run", "lerna", "version", ersion, "--exact", "--no-git-tag-version", "--no-push", "--force-publish", "-y"}). | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You have to do a yarn install to update the lockfile at this point I believe, because if you don't, then later steps that do There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think there are any later steps that do There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hmmmmm. Since it's containerized and not using a shared volume I actually don't know if doing that would update it for everything afterwards without exporting that file so maybe for now we should just leave it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if it becomes a problem later then i guess we can resolve it at that point There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
WithExec([]string{"yarn", "lerna", "exec", "--no-private", "--", "yarn", "pack", "--out", fmt.Sprintf("/src/npm-packages/%%s-%v.tgz", version)}) | ||||||
|
||||||
return c.Directory("./npm-packages") | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that's intentional because it's "version" without the "v" ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lol, maybe
trimmedVersion
is better 😂There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know that this is not a big deal but I actually think
ersion
is pretty descriptive. It does look like a typo but it more concisely describes how the version is trimmed. Essentially, it is the exact same asversion
just with thev
removed. Plus we have been using it in a lot of different places so it's probably good to keep it here for consistency.