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 support for specifying a path for the generate command #9387
Add support for specifying a path for the generate command #9387
Conversation
e63895b
to
37837d9
Compare
Some high level feedback: instead of a second arg, you could use the same one? |
37837d9
to
39a2f90
Compare
39a2f90
to
bac7d7e
Compare
Just tried this in a monorepo, and it was succesful: ❯ ember g ../../../node_modules/ember-source/blueprints/component my-component-via-path
installing component
create addon/components/my-component-via-path/index.hbs
skip addon/components/my-component-via-path/index.js
tip to add a class, run `ember generate component-class my-component-via-path`
installing component-test
create tests/integration/components/my-component-via-path-test.js
installing component-addon
create app/components/my-component-via-path.js
❯ ember d ../../../node_modules/ember-source/blueprints/component my-component-via-path
uninstalling component
remove addon/components/my-component-via-path/index.hbs
uninstalling component-test
remove tests/integration/components/my-component-via-path-test.js
uninstalling component-addon
remove app/components/my-component-via-path.js |
bac7d7e
to
7410ef0
Compare
Related: emberjs/rfcs#699 |
@@ -1279,6 +1279,23 @@ let Blueprint = CoreObject.extend({ | |||
Blueprint.lookup = function (name, options) { | |||
options = options || {}; | |||
|
|||
if (name.includes(path.sep)) { | |||
let blueprintPath = path.resolve(name); |
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.
could we add check for relative/absolute paths, is cwd = curren project dir?
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.
This seems OK to land, we just need to rebase and make sure tests still pass.
rather than relying on blueprint lookup/resolver rules
7410ef0
to
97c456c
Compare
This is needed for this project:
Which has these remaining TODOs before the idea can even work
afterInstall
(not the focus of this PR)new
can use a path to a local blueprint,rather than rely on the name resolution system currently in place.
this is useful, for wanting to chain blueprint executions, as is the focus of ember-codemod-blueprint
(what this PR is focused on)
I'm open to advice on approach here, but those two bullets are what I need to be able to build more straightforward and extensible blueprint in user-space.
I'm kind of thinking about blueprints being like this at a high level (after the above work):
actual api in https://github.com/NullVoxPopuli/ember-codemod-blueprint -- main difference is no pipes, and you'd want to work with specific file paths, rather than whatever the blueprint output is.
So a snippet from ember-codemod-blueprint,
This approach should work for app-generation as well, but the
transform
hook may be much bigger, depending on how different your team's default app is from the base blueprint