Skip to content
This repository has been archived by the owner on Jan 13, 2023. It is now read-only.

Move postInstall commands to their own script; add command to kill metro #247

Merged
merged 2 commits into from
Sep 16, 2019

Conversation

bryanstearns
Copy link
Member

This is an alternative to #245, which I think will work better for the long term.

This adds a new bin/postInstall script to do all the yarn or npm postInstall steps; it can be
smarter about what steps to run on which platforms, more generally than #245 did.

I've also added a new postInstall step: it kills any running instance of the Metro bundler when you install packages. I've had problems when I forget to do this, and it takes virtually no time. Note that it only does this on Mac or Linux because I haven't worked out the equivalent Windows incantation; HELP WANTED if a Windows person wants to try!

I've tested ignite new MyApp -b ./bowser on Mac and Windows.

Like the other implementation, this should fix #243 and maybe #244.

Copy link
Member

@jamonholmgren jamonholmgren left a comment

Choose a reason for hiding this comment

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

brilliant

Copy link
Member

@robinheinze robinheinze left a comment

Choose a reason for hiding this comment

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

Really awesome! Also, moving postInstall to a custom bin command was brilliant. Much easier to read than all the inline things we had in there before.

@kfrp
Copy link

kfrp commented Aug 22, 2019

Reporting the following error from Windows 10 x64 install attempt:

{ Error: Command failed: yarn
'bin\postInstall' is not recognized as an internal or external command,
operable program or batch file.
error Command failed with exit code 1.

    at ChildProcess.exithandler (child_process.js:294:12)
    at ChildProcess.emit (events.js:198:13)
    at maybeClose (internal/child_process.js:982:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
  killed: false,
  code: 1,
  signal: null,
  cmd: 'yarn',
  stderr:
   '\'bin\\postInstall\' is not recognized as an internal or external command,\r\noperable program or batch file.\r\nerror Command failed with exit code 1.\n' }
error installing boilerplate

PS: Came here from the pod was unexpected at this time issue.

Edited to add: the fix-postinstall-windows branch worked for me.

Also, fix the Windows platform name.
@bryanstearns
Copy link
Member Author

bryanstearns commented Aug 22, 2019

@COSMOPHILE Thanks for testing this and letting me know about this problem! I've found and fixed that problem (helped by this 2014 (!) blog post from @shapeshed -- https://shapeshed.com/writing-cross-platform-node/#scripts-in-package-json)

Does it work for you now?

@kfrp
Copy link

kfrp commented Aug 23, 2019

Not for me, still getting the same error...

@bryanstearns
Copy link
Member Author

@COSMOPHILE I just tested again on Windows 10 and it's working for me.

I'm surprised that you're seeing the same error as before, since that error ('bin\postInstall' is not recognized as an internal or external command, operable program or batch file.) indicates that Windows is trying to run bin\postInstall as a command, but in the latest version (4387965) the package.json postInstall command is now node bin/postInstall, which should give you a different error message if it can't be run. Is there any possibility that you didn't test the very latest version?

To be sure, I just tried changing the command to xxnode bin/postInstall and got this error:

an error occured while installing ignite-bowser boilerplate.
Error: Command failed: yarn
'xxnode' is not recognized as an internal or external command,
operable program or batch file.
error Command failed with exit code 1.

and also tried changing it to node bin/xxpostInstall and got this:

an error occured while installing ignite-bowser boilerplate.
Error: Command failed: yarn
internal/modules/cjs/loader.js:716
    throw err;
    ^

Error: Cannot find module 'C:\Users\bryan\Code\MyApp\MyApp\bin\xxpostInstall'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:713:15)
    at Function.Module._load (internal/modules/cjs/loader.js:618:27)
    at Function.Module.runMain (internal/modules/cjs/loader.js:931:10)
    at internal/main/run_main_module.js:17:11 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}
error Command failed with exit code 1.

Neither of these are the same as the previous error, so could you please double-check that you've pulled this branch, through commit 4387965? and see whether some other part of the error message changed (between an error occured while installing ignite-bowser boilerplate. and error Command failed with exit code 1.) -- and if so, paste it here?

Again, I really appreciate the help testing this!

@kfrp
Copy link

kfrp commented Aug 23, 2019

Hey @bryanstearns, really appreciate your investigating this. I double checked my version and it's up to date with your branch, and the error is also only slightly different to reflect that (lastish line):

an error occured while installing ignite-bowser boilerplate.
{ Error: Command failed: yarn
'.\bin\postInstall' is not recognized as an internal or external command,
operable program or batch file.
error Command failed with exit code 1.

    at ChildProcess.exithandler (child_process.js:294:12)
    at ChildProcess.emit (events.js:198:13)
    at maybeClose (internal/child_process.js:982:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
  killed: false,
  code: 1,
  signal: null,
  cmd: 'yarn',
  stderr:
   '\'.\\bin\\postInstall\' is not recognized as an internal or external command,\r\noperable program or batch file.\r\nerror Command failed with exit code 1.\n' }
error installing boilerplate

So I don't know why it's reading the changed string "./bin/postInstall", as a command instead of looking for the file. Could it be a problem with my Windows set up? Or is the replace string making the string all messed up and unreadable as a location?

I wish I knew more about the OS to know where to troubleshoot this... Thanks again.

@zucchinho
Copy link

can you not just merge #245 as a patch and plan this approach for a future release? the current boilerplate does not work on windows, you have a patch that works, you can then surely iron out the kinks for this more sustainable solution for the next minor release?

@bryanstearns
Copy link
Member Author

I'd like us to merge this: it works for me on Windows, which is better than what's released now, and if it doesn't work for you, maybe you could dig into why it's not working and include that in the issue you open? 🤞

@jamonholmgren jamonholmgren merged commit d5e878d into master Sep 16, 2019
@jamonholmgren jamonholmgren deleted the postinstall-script branch September 16, 2019 16:51
@jamonholmgren
Copy link
Member

Looks like CI is breaking -- looking at it

@jamonholmgren
Copy link
Member

It appears related to this issue: storybookjs/storybook#8083

infinitered-circleci pushed a commit that referenced this pull request Sep 16, 2019
## [4.6.3](v4.6.2...v4.6.3) (2019-09-16)

### Bug Fixes

* **deps:** Locking storybook version to avoid Storybook issue storybookjs/storybook#8083 ([3aa472a](3aa472a))
* **windows:** Move postInstall commands to their own script; add command to kill metro ([#247](#247) by [@bryanstearns](https://github.com/bryanstearns)) ([d5e878d](d5e878d))
@infinitered-circleci
Copy link

🎉 This PR is included in version 4.6.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

win32/bowser@4.6.1: "pod was unexpected at this time" while igniting new app
6 participants