I am building an Angular custom schematics. I created the files directory and it looks like this:
I am trying to add this component to the final app.
my index file looks like this:
function addSideNav(options: any) {
return (host: Tree, context: SchematicContext) => {
try {
host.delete('src/app/app.component.html');
const workspace = getWorkspace(host);
if (!options.project) {
options.project = Object.keys(workspace.projects)[0];
}
const project = getProject(host, options.project);
if (options.path === undefined) {
options.path = buildDefaultPath(project);
}
const templateSource = apply(url('./files'), [
template({
...options,
...strings
}),
move(options.path)
]);
// context.logger.log("info", `✅️ Added SideNav to the tree`);
return mergeWith(templateSource);
} catch (e) {
context.logger.log("error", ` Failed to add the SideNav to the tree`);
throw new SchematicsException(`Error detailes: ${e}`);
}};}
afterwards I'm calling this function like this:
export default function (options: any): Rule {
return chain([
addPackageJsonDependencies(),
installPackageJsonDependencies(),
addSideNav(options),
addMaterialStyle(options),
addPolyfillToScripts(options),
addToAppModule(options)
]); }
when I test it with npm link locally - it works great. everything is created just fine.
but when i publish it npm and install it from npm - all of the files are created except for the ts file:
side.nav.component.ts
and I don't get any warnings.
What am I missing here?