-
Notifications
You must be signed in to change notification settings - Fork 24
Remove unsupported yarn install option. Default to use Yarn berry #96
Conversation
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.
Please check some comments on the code and please take a look at the comment on the original issue #95
@sio4 I pushed fixes addressing your comments 62585b4. I also added The resulting enableGlobalCache: true
logFilters:
- code: YN0013
level: discard
yarnPath: .yarn/releases/yarn-3.2.0.cjs |
Thank you for your update @saurori ! I think we need to check the .dockerignore file part, meanwhile, I will check the updated branch and will add a comment soon (maybe tomorrow)! |
@sio4 any other changes? Are you able to approve the workflow (tests)? |
I'm not sure what is causing tests failures: === RUN Test_InstallOldBuffaloCMD/existing_version
testhelpers_test.go:63:
Error Trace: testhelpers_test.go:63
Error: Received unexpected error:
unknown gobuffalo cli version v0.18.1
Test: Test_InstallOldBuffaloCMD/existing_version
=== RUN Test_InstallOldBuffaloCMD/existing_old_version
testhelpers_test.go:63:
Error Trace: testhelpers_test.go:63
Error: Received unexpected error:
unknown gobuffalo cli version v0.16.27
Test: Test_InstallOldBuffaloCMD/existing_old_version |
Sorry for the delay. I was somewhat busy. It seems like testing was done now. I will check if there is something more and will also check the test failure. |
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.
LGTM
I found the reason for the failure by PRing #110. The issue was, I guess, the underlying API call for the test case has a rate limit and we sent too many API calls to api.github.com. Working on it. |
This could be tested again once #110 is merged into |
@saurori can you please rebase your branch with development? Thanks in advance |
@paganotoni rebased |
I am not 100% sure why this failed: === RUN TestBuild/skipop
...
DEBU[2022-03-10T21:34:17Z] Exec: yarnpkg install
DEBU[2022-03-10T21:34:17Z] ➤ YN0028: The lockfile would have been created by this install, which is explicitly forbidden.
DEBU[2022-03-10T21:34:17Z] ➤ YN0000: Failed with errors in 0s 10ms Running integration tests locally passes. The error doesn't make sense for a first time
My local Yarn: $ yarnpkg --version
2.4.3 |
I also am not sure currently. From the log, I can see the following line from the failed test (for ubuntu): 2022-03-10T21:34:31.0041349Z YN0000: Retrieving https://repo.yarnpkg.com/3.2.0/packages/yarnpkg-cli/bin/yarn.js This output format (YNnnnn) is the format of the berry so I think the running command is the berry. I guess you mentioned version 1.22.17 since the version is on the test log. If you scroll up the log, then you can find the test is for 0.18.0 which is the original version before your PR. 2022-03-10T21:35:10.5828054Z === RUN TestFix_v0_18_0/web
<...>
2022-03-10T21:35:11.7651292Z DEBU[2022-03-10T21:35:11Z] yarn install v1.22.17 I ran the failed test with your recent branch and it worked fine, so I guess there could be a side effect of the other test or test sequence. I am trying to find the missing point or if the environment or test case itself has any issue. While I was testing it, I found one bug related to |
Oh, I found the direct cause: As you say, this symptom is about immutable and I found that:
This behavior of berry is annoying. It seems like there is no opposite option of Here is my quick patch which covers immutable issue, yarnrc.yml version issue when system yarn is still classic, and consolidate them in a single function. Could you please take a look at this and try applying it if you want? Or I will PR to your branch later. (I have no enough time today) diff --git a/internal/genny/assets/webpack/templates/dot-yarnrc.yml.tmpl b/internal/genny/assets/webpack/templates/dot-yarnrc.yml.tmpl
deleted file mode 100644
index ba06a62..0000000
--- a/internal/genny/assets/webpack/templates/dot-yarnrc.yml.tmpl
+++ /dev/null
@@ -1,4 +0,0 @@
-enableGlobalCache: true
-logFilters:
- - code: YN0013
- level: discard
diff --git a/internal/genny/assets/webpack/webpack.go b/internal/genny/assets/webpack/webpack.go
index 0c0fe5c..68fbb55 100644
--- a/internal/genny/assets/webpack/webpack.go
+++ b/internal/genny/assets/webpack/webpack.go
@@ -13,6 +13,8 @@ import (
"github.com/gobuffalo/genny/v2/gogen"
)
+const YARN = "yarnpkg"
+
//go:embed templates/* templates/assets/css/_buffalo.scss.tmpl
var templates embed.FS
@@ -41,7 +43,7 @@ func New(opts *Options) (*genny.Generator, error) {
g.RunFn(func(r *genny.Runner) error {
if opts.App.WithYarn {
- if _, err := r.LookPath("yarnpkg"); err == nil {
+ if _, err := r.LookPath(YARN); err == nil {
return nil
}
// If yarn is not installed, it still can be installed with npm.
@@ -87,7 +89,7 @@ func New(opts *Options) (*genny.Generator, error) {
}
func installPkgs(r *genny.Runner, opts *Options) error {
- command := "yarnpkg"
+ command := YARN
args := []string{"install"}
if !opts.App.WithYarn {
@@ -97,11 +99,12 @@ func installPkgs(r *genny.Runner, opts *Options) error {
if err := installYarn(r); err != nil {
return err
}
- if err := r.Exec(exec.Command(command, []string{"set", "version", "berry"}...)); err != nil {
+ if err := setupYarnBerry(r); err != nil {
return err
}
}
+ r.Exec(exec.Command(command, "--version"))
c := exec.Command(command, args...)
c.Stdout = yarnWriter{
fn: r.Logger.Debug,
@@ -123,9 +126,31 @@ func (y yarnWriter) Write(p []byte) (int, error) {
func installYarn(r *genny.Runner) error {
// if there's no yarn, install it!
- if _, err := r.LookPath("yarnpkg"); err == nil {
+ if _, err := r.LookPath(YARN); err == nil {
return nil
}
yargs := []string{"install", "-g", "yarn"}
return r.Exec(exec.Command("npm", yargs...))
}
+
+func setupYarnBerry(r *genny.Runner) error {
+ if err := r.Exec(exec.Command(YARN, "--version")); err != nil {
+ return err
+ }
+ if err := r.Exec(exec.Command(YARN, "set", "version", "berry")); err != nil {
+ return err
+ }
+ // the .yarnrc.yml format is different between classic and berry so
+ // it should be configured after installation (set version)
+ if err := r.Exec(exec.Command(YARN, "config", "set", "enableGlobalCache", "true")); err != nil {
+ return err
+ }
+ // can we enable this only for testing? :-(
+ if err := r.Exec(exec.Command(YARN, "config", "set", "enableImmutableInstalls", "true")); err != nil {
+ return err
+ }
+ if err := r.Exec(exec.Command(YARN, "config", "set", "logFilters", "--json", `[{"code":"YN0013","level":"discard"}]`)); err != nil {
+ return err
+ }
+ return nil
+} |
I made a PR to your branch (saurori/cli/pull/1) Please take a look at the PR. |
@paganotoni if you could re-run the CI with the latest change, thanks! |
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.
Please consider the situation when if user's version is classic.
… vs template file
Seems to be passing the tests now 🥳 :) |
Yeah, to be clarified, the routine added now into cli is only for the new app with berry, so this is not about compatibility with the classic version. The The classic version had no [1] yarnpkg/yarn@f381c5f |
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.
lgtm!
Resolves this Issue: #95
Yarn 2+ (berry) is not supported on
buffalo new
. These changes allow for Yarn 1.x (classic) and 2.x+ (berry) to work, and also defaults to using the latest Yarn berry on setup.