Skip to content
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

Add postinstall script for apps under cfgov-refresh #3831

Merged
merged 1 commit into from
Feb 28, 2018

Conversation

anselmbradford
Copy link
Member

Additions

  • Adds scripts/npm/apps-install/index.js script for running npm install on ./cfgov/unprocessed/apps/[app namespace]/package.json.

Testing

  1. Throw out ./cfgov/unprocessed/apps/[app namespace]/node_modules
  2. Run gulp build, get App dependencies not installed… message. (Do not follow message.)
  3. Run npm install from the project root.
  4. Re-run gulp build and check that ./cfgov/unprocessed/apps/[app namespace]/node_modules exists.

@sebworks
Copy link
Contributor

sebworks commented Feb 28, 2018


nvm, it makes more sense to be a post install step.

@@ -101,7 +101,8 @@
"wcag": "0.3.0"
},
"scripts": {
"test": "snyk test"
"test": "snyk test",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated to this, PR, but this should probably be changed to run our actual test suites.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah we have #3576 and #2303 that overlap with that.

@anselmbradford anselmbradford merged commit 8634846 into master Feb 28, 2018
@anselmbradford anselmbradford deleted the app_npm_install branch February 28, 2018 16:15
@sebworks sebworks mentioned this pull request Feb 28, 2018
11 tasks
@Scotchester
Copy link
Contributor

Also not directly related to this PR: Is there a way to bubble the App dependencies not installed, please run from project root: npm --prefix ./cfgov/unprocessed/apps/owning-a-home install ./cfgov/unprocessed/apps/owning-a-home message down to the bottom when the script completes? If you're looking away while gulp build runs, it's easy to miss.

// eslint-disable-next-line no-sync
let apps = fs.readdirSync( `${ paths.unprocessed }/apps/` );

// Filter out .DS_STORE directory.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trivial: This could be more broadly stated "Filter out hidden directories"

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in #3834

// Filter out .DS_STORE directory.
apps = apps.filter( dir => dir.charAt( 0 ) !== '.' );

// Run each application's JS through webpack and store the gulp streams.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this actually happening? Looks like all it's doing is running npm install

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in #3834

@@ -0,0 +1,3 @@
{
"lockfileVersion": 1
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The creation of this file appears to be a mistake.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it should be created. I'm not sure why it's empty though.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Look at the path; it's in the wrong location.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in #3834

exec( `npm --prefix ${ appsPath } install ${ appsPath }`,
( error, stdout, stderr ) => {
// eslint-disable-next-line no-console
console.log( 'App\'s npm output: ' + stdout );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to use app in these logs to have it say what app it's actually referring to, here? Could get hard to figure things out if this is ever installing multiple apps' stuff.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great idea!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in #3834

// eslint-disable-next-line no-console
console.log( 'App\'s npm output: ' + stdout );
// eslint-disable-next-line no-console
console.log( 'App\'s npm errors: ' + stderr );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there always errors/warnings? Should this get a condition check like error below?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in #3834

// Run each application's JS through webpack and store the gulp streams.
apps.forEach( app => {
/* Check if node_modules directory exists in a particular app's folder.
If it doesn't log the command to add it and don't process the scripts. */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trivial: Could use a comma after "doesn't" for clarity.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in #3834

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants