The nrwl schematics are a great start, and our organization would like to tailor them slightly to fit our needs. The first use case I'm working with is to automate the process where we first run a schematic to create an empty workspace (this is actually the 'application' collection), then cd into that directory and immediately run the lib collection. I'd like to create my own schematic that calls both of these by chaining externalSchematic() but it seems like the lib collection assumes it will be passed a Tree whose root is one level deeper than the Tree created by the application collection.
In my collection I'm doing this:
return chain([
externalSchematic('@nrwl/schematics', 'application', options),
externalSchematic('@nrwl/schematics', 'lib', libOptions)
]);
And that is producing the following error:
Error: Cannot find .angular-cli.json
at readJsonInTree (/Users/matt/Projects/git/schematics/node_modules/@nrwl/schematics/src/utils/ast-utils.js:396:15)
I've logged the Tree after the application Rule has run on it, and the lib collection is expecting .angular-cli.json at the root of the Tree but it is at myapp/.
One possible solution is before I call the lib collection, I need to scope the tree to the myapp directory. A few articles I've read say that this is possible, but I have not been able to find any concrete examples.
It seems like the lib schematic assumes it will always be run from inside the directory of a workspace. If this is the case, to support creating a workspace and library inside it in one schematic, it would need an optional baseDir option.
Should all schematics support being able to be run within the rest of their package (or context, for lack of a better word) as well as being able to stand on their own and be used as building blocks for custom schematics?
The nrwl schematics are a great start, and our organization would like to tailor them slightly to fit our needs. The first use case I'm working with is to automate the process where we first run a schematic to create an empty workspace (this is actually the 'application' collection), then
cdinto that directory and immediately run thelibcollection. I'd like to create my own schematic that calls both of these by chainingexternalSchematic()but it seems like thelibcollection assumes it will be passed aTreewhose root is one level deeper than theTreecreated by theapplicationcollection.In my collection I'm doing this:
And that is producing the following error:
I've logged the
Treeafter the applicationRulehas run on it, and thelibcollection is expecting.angular-cli.jsonat the root of theTreebut it is atmyapp/.One possible solution is before I call the lib collection, I need to scope the tree to the
myappdirectory. A few articles I've read say that this is possible, but I have not been able to find any concrete examples.It seems like the lib schematic assumes it will always be run from inside the directory of a workspace. If this is the case, to support creating a workspace and library inside it in one schematic, it would need an optional baseDir option.
Should all schematics support being able to be run within the rest of their package (or context, for lack of a better word) as well as being able to stand on their own and be used as building blocks for custom schematics?