Include ScopedTree in the public API of @angular-devkit/schematics
🚀 Feature request
Command (mark with an x)
- [ ] new
- [ ] build
- [ ] serve
- [ ] test
- [ ] e2e
- [ ] generate
- [ ] add
- [ ] update
- [ ] lint
- [ ] xi18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc
Description
While creating schematics for a project on top of the ng-new and ng-add I needed to execute a sequence of rules scoped to a subfolder in the workspace. I noticed that there is a ScopedTree in the schematics package, but it is not exposed in the public API. I used it to create a scopedToDir utility:
export function scopedToDir(dir: string, rule: Rule): Rule {
return (tree: Tree, context: SchematicContext) => {
return callRule(rule, of(new ScopedTree(tree, dir)), context).pipe(
map(() => tree));
};
}
Which can then be used like this:
scopedToDir(dir, chain([
createSomeFiles(),
modifySomeFiles(),
foo()
]))
Describe the solution you'd like
If you have a solution in mind, please describe it.It would be nice if the ScopedTree would be exported in the public API as it offers useful functionality.
Describe alternatives you've considered
Have you considered any alternative solutions or workarounds?Currently, I'm importing like this:
import { ScopedTree } from '@angular-devkit/schematics/src/tree/scoped';
But I think this is like relying on undocumented functionality, which may change at any time, without warning.
It’s intentionally not public as it is considered internal infrastructure.
There is also a rule designed to provide the functionality shown above: “applyToSubtree” (https://github.com/angular/angular-cli/blob/master/packages/angular_devkit/schematics/src/rules/base.ts#L163).
Yeah, that makes sense. Didn't know about that rule. Thanks!
This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.