I've created an angular schematic for the purposes of creating boilerplate code with an ng generate command, however despite all the articles I've read through and messing about, I cannot get the files to create.
I've the following code in my schematic factory:
export function createComponent(_options: any): Rule {
return (tree: Tree, _context: SchematicContext) => {
setupOptions(tree, _options);
const movePath = normalize(_options.path + '/' + strings.dasherize(_options.name));
const templateSource = apply(url('./files'), [
template({
...strings,
..._options,
}),
move(movePath)
]);
return mergeWith(templateSource);
};
}
In the same directory as this is a files directory containing my "__name@dasherize__.component.ts" template which I'm expecting to get pulled in as part of the url('./files') function but I'm not sure this is happening.
My template file is as follows:
import { Component } from '@angular/core';
@Component({
selector: 'wx-<%= dasherize(componentName) %>'
})
export class <%= classify(componentName) %>Component {
}
I'd expect a 'CREATE' to appear when I run the schematic but all I get is 'Nothing to be done.'
Oddly enough using tree.create() is successfully running to create files so I wonder if the url() or apply() functions are not running as expected.