-
-
Notifications
You must be signed in to change notification settings - Fork 795
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
[legacy-framework] [#330] Fix new app command order #367
Conversation
} else { | ||
console.error('Failed to run git add') | ||
} | ||
if (gitInitResult.status === 0) { |
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.
Curious on the motivation behind not failing if the git
commands fail. If we want to i am happy to make them throw error here as well as the other commands inside this generator.
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'm not super set on failing if git init fails just because it's not a mandatory part of the setup process. I'll open an issue to discuss this more though, thanks for bringing it up!
await generator.run() | ||
} catch (e) { | ||
expect(e).toEqual(new Error('Failed to yarn install')) | ||
} |
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.
Tried hard to make this work with toThrow
, but seems to be a known issue.
jestjs/jest#1700
packages/cli/src/generators/app.ts
Outdated
@@ -64,7 +68,7 @@ class AppGenerator extends Generator<AppGeneratorOptions> { | |||
|
|||
const result = spawn.sync(this.options.yarn ? 'yarn' : 'npm', ['install'], {stdio: 'inherit'}) | |||
if (result.status !== 0) { | |||
throw new Error() | |||
throw new Error(`Failed to ${this.options.yarn ? 'yarn' : 'npm'} install`) | |||
} | |||
|
|||
console.log(chalk.hex(themeColor).bold('\nDependencies successfully installed.')) |
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.
Curious why we are using log
helper and/or console.log|console.error
. Should it be unified?
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've been incrementally migrating to the @blitzjs/server/utils/log
helper as I touch relelvant lines. We haven't touched the app generator meaningfully in a bit so I haven't had a chance to migrate these log lines. If you want to migrate these to use the main logging utility it would be a huge help!!
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.
Done c31ba55
Thanks so much for the PR! I hadn't noticed this, great find + fix!
This is a known issue, the tests run in parallel in the prepush hook but there's a race condition there :( Since we reuqire a successful build to merge and the CI build runs the tests serially it's ok to ignore them locally, there's no chance it'll make it into the canary branch. |
packages/cli/src/generators/app.ts
Outdated
@@ -64,7 +68,7 @@ class AppGenerator extends Generator<AppGeneratorOptions> { | |||
|
|||
const result = spawn.sync(this.options.yarn ? 'yarn' : 'npm', ['install'], {stdio: 'inherit'}) | |||
if (result.status !== 0) { | |||
throw new Error() | |||
throw new Error(`Failed to ${this.options.yarn ? 'yarn' : 'npm'} install`) |
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.
Since we now use the yarn/npm split in a few places, would it be possible to pull that logic out into a constant? It'll prevent any chance of us (most likely me 😬) messing it up in the future
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.
Done 77d4a5c
@@ -0,0 +1,237 @@ | |||
import * as fs from 'fs-extra' |
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.
Thank you so much for adding some test scaffolding here! I think @dajinchu added an in-memory filesystem to Jest in the server package, maybe we could follow a similar pattern here so we could actually generate the app for real to make sure things work ok?
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 focused on unit tests here so I tried to mock all the external integrations. I believe we may want to have a good amount of both unit and integration tests.
However, we could add those integrations tests in a different suit file to not conflict setup etc. What do you think of us having some sort of app.int.test.ts
(I am bad at naming) or even a different folder cli/test/integration
?
I am happy to add these as a new PR so we incrementally improve the quality of the tests.
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.
Yeah we used mock-fs
which worked pretty well.
packages/cli/src/generators/app.ts
Outdated
for (let command of commands) { | ||
const result = spawn.sync(...command) | ||
if (result.status !== 0) { | ||
console.error(`Fialed to run command ${command[0]} with ${command[1].join(' ')} options.`) |
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.
console.error(`Fialed to run command ${command[0]} with ${command[1].join(' ')} options.`) | |
console.error(`Failed to run command ${command[0]} with ${command[1].join(' ')} options.`) |
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.
Done 77d4a5c
New changes were added while this PR is being reviewed, I will take a time to rebase and fix the conflicts. |
Thank you @peaonunes! I'll mark as draft — mark it as ready for review once it's updated. @all-contributors add @peaonunes for code |
I've put up a pull request to add @peaonunes! 🎉 |
Hey @flybayer thanks, I've updated now. Unfortunately seems like a lot have changed from when I started adding tests and refactoring some calls. So I had to undo those. In order to avoid this happening again I've only made the change needed on this PR and added tests related to it. Happy on refactor again portions of this code in the future. |
@peaonunes did you see your tests are failing? |
Hey yeah. Trying to figure out why, its complaining about using wothBrand. My changes have nothing to do with the failing point, but at the same time the code is up to date with canary. I might start fresh from canary again in a few hours. |
Type: bug fix
Closes: blitz-js/legacy-framework#506
What are the changes and their implications? ⚙️
AppGenerator
.Checklist
packages/server/src/log.ts
Breaking change: no
Other information
I've took the opportunity to add tests as there were none before. I had to do some tricky mocks though, not super happy.
Locally when I run
yarn test
in the root folder in the project thecli
tests fail. However, when running inside thecd packages/cli && yarn test
everything is green. Does anyone know what is the issue?I had to ignore the test hooks because they were not allowing me to push the code.