如何使用 Angular Schematics 修改 app.module.ts

问题描述

我目前正在尝试构建我公司使用的 Angular 原理图,该原理图将自动生成并设置必要的配置。

我想修改应用原理图的目标 Angular 项目中的 app.module.ts 文件

目前我只是使用原理图规则删除预先存在的 app.module.ts 文件并将 app.module.ts 文件从我的原理图复制到目标项目工作区。然而,当我运行我的原理图时,文件似乎被遗漏了并且没有被复制。所有其他文件都被正确复制。带有 .ts 扩展名的文件会被忽略吗?

function createLandingPageFiles(_options: any): Rule {
  return (tree: Tree,context: SchematicContext) => {
    if (tree.exists('src/styles.css')) {
      tree.delete('src/styles.css');
    }

    if (tree.exists('src/index.html')) {
      tree.delete('src/index.html');
    }

    if (tree.exists('src/app/app.component.css')) {
      tree.delete('src/app/app.component.css');
    }

    if (tree.exists('src/app/app.component.html')) {
      tree.delete('src/app/app.component.html');
    }

    if (tree.exists('src/app/app.module.ts')) {
      tree.delete('src/app/app.module.ts');
    }
    
    const templateSource = apply(url('./files'),[
      template({}),move('src')
    ]);

    const rule = chain([
      branchAndMerge(chain([
        mergeWith(templateSource,MergeStrategy.Default)
      ]))
    ]);

    return rule(tree,context);

  };
}

我的原理图/文件目录中有文件,其中包含要复制的所有替换文件

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...