-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Support npm packages as ember new
blueprints
#6789
Conversation
@@ -80,6 +113,30 @@ class InstallBlueprintTask extends Task { | |||
return execa('npm', ['install'], { cwd }); | |||
} | |||
|
|||
_npmInstallModule(module, cwd) { | |||
logger.info(`Running "npm install ${module}" in "${cwd}" ...`); | |||
return execa('npm', ['install', module], { cwd }) |
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.
Should use yarn
if present (or based on the same rules as #6748).
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.
@rwjblue I would like to do something like that in a separate follow-up PR. as you can see a few lines above the existing code of this feature already uses npm exclusively.
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.
gotcha, seems good, can you either confirm this is encompassed by an existing issue or create a new issue (so that we don't loose track)?
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.
_npmInstallModule(module, cwd) { | ||
logger.info(`Running "npm install ${module}" in "${cwd}" ...`); | ||
return execa('npm', ['install', module], { cwd }) | ||
.then(() => path.join(cwd, 'node_modules', module)); |
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.
Should we use path.dirname(resolve('module/package', { baseDir: cwd })
? I'm unsure there are any cases where what you have now is not correct though, feel free to disregard...
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 don't think it's necessary in this case
|
||
_validateNpmModule(modulePath, packageName) { | ||
logger.info(`Checking for "ember-blueprint" keyword in "${packageName}" module ...`); | ||
let pkg = require(path.join(modulePath, 'package.json')); |
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.
require(path.join(modulePath), 'package')
should be enough (no need to include extension for require
).
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, but it's probably faster since the list of extensions won't have to be tried sequentially, right?
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.
True, though speed probably isn't a concern here. As I read this again though, I actually think what you have is easier to grok than what I wrote anyways.
I can see my future self saying "WTF is ${modulePath}/package
?" 😝 (whereas ${modulePath}/package.json
actually makes it clearer)
@homu r+ |
📌 Commit e406454 has been approved by |
⚡ Test exempted - status |
Support npm packages as `ember new` blueprints Closes #6772 - [x] tries to install from NPM if a blueprint with a matching name is not found - [x] only works for `ember new` and `ember addon` - [x] fails if the npm package does not have the `ember-blueprint` keyword - [x] hidden behind `NPM_BLUEPRINTS` experiment flag - [x] has tests 😉
Closes #6772
ember new
andember addon
ember-blueprint
keywordNPM_BLUEPRINTS
experiment flag