Angular ng更新未运行migration.json原理图 版本

Angular ng更新未运行migration.json原理图 版本,angular,angular-cli,angular-upgrade,angular-schematics,Angular,Angular Cli,Angular Upgrade,Angular Schematics,节点——版本 v8.11.3 npm——版本 6.4.1 复制步骤 我有一个私人项目,所以我无法分享回购协议,所以提前表示歉意。我有一个angular项目,我添加了原理图支持,因此我可以使用ng update更新它。因此,我有一个带有migration.json文件的schematics文件夹: { "$schema": "../../../node_modules/@angular-devkit/schematics/collection-schema.json", "schemati

节点——版本 v8.11.3

npm——版本 6.4.1

复制步骤 我有一个私人项目,所以我无法分享回购协议,所以提前表示歉意。我有一个angular项目,我添加了原理图支持,因此我可以使用
ng update
更新它。因此,我有一个带有
migration.json
文件的schematics文件夹:

{
  "$schema": "../../../node_modules/@angular-devkit/schematics/collection-schema.json",
  "schematics": {
    "migration01": {
      "version": "1.0.0-nav-menu-with-migration.3",
      "description": "Update",
      "factory": "./src/ng-update/index"
    }
  }
}
tsconfig.schematics.json

{
  "compilerOptions": {
    "target": "es2015",
    "module": "commonjs",
    "moduleResolution": "node",
    "declaration": true,
    "sourceMap": true,
    "lib": [
      "dom",
      "es2017",
      "esnext.asynciterable"
    ]
  },
  "exclude": [
    "**/files/*.ts",
    "**/*.spec.ts"
  ]
}
{
  "compilerOptions": {
    "module": "commonjs",
    "target": "es2015",
    "moduleResolution": "node",
    "types": [
      "jasmine",
      "node"
    ],
    "lib": [
        "es2017",
        "dom"
    ],
    "declaration": false
  },
  "include": [
    "./spec/**/*.spec.ts"
  ]
}
import { Rule, SchematicContext, SchematicsException, Tree } from "@angular-devkit/schematics";

export default function(): Rule {
  return (tree: Tree, context: SchematicContext) => {
    context.logger.warn("it's happening!");

    const pkgPath = "/package.json";
    const buffer = tree.read(pkgPath);
    if (buffer == null) {
      throw new SchematicsException("Could not read package.json");
    }
    const content = buffer.toString();
    const pkg = JSON.parse(content);

    if (pkg === null || typeof pkg !== "object" || Array.isArray(pkg)) {
      throw new SchematicsException("Error reading package.json");
    }

    if (!pkg.dependencies) {
      pkg.dependencies = {};
    }

    if (pkg.dependencies["@solarwinds/nav-menu-with-migration"]) {
      pkg.dependencies["ngx-perfect-scrollbar"] = `^7.0.0`;
      pkg.dependencies["ngx-device-detector"] = null;

      tree.overwrite(pkgPath, JSON.stringify(pkg, null, 2));
    }

    return tree;
  };
}
tsconfig.schematics.spec.json

{
  "compilerOptions": {
    "target": "es2015",
    "module": "commonjs",
    "moduleResolution": "node",
    "declaration": true,
    "sourceMap": true,
    "lib": [
      "dom",
      "es2017",
      "esnext.asynciterable"
    ]
  },
  "exclude": [
    "**/files/*.ts",
    "**/*.spec.ts"
  ]
}
{
  "compilerOptions": {
    "module": "commonjs",
    "target": "es2015",
    "moduleResolution": "node",
    "types": [
      "jasmine",
      "node"
    ],
    "lib": [
        "es2017",
        "dom"
    ],
    "declaration": false
  },
  "include": [
    "./spec/**/*.spec.ts"
  ]
}
import { Rule, SchematicContext, SchematicsException, Tree } from "@angular-devkit/schematics";

export default function(): Rule {
  return (tree: Tree, context: SchematicContext) => {
    context.logger.warn("it's happening!");

    const pkgPath = "/package.json";
    const buffer = tree.read(pkgPath);
    if (buffer == null) {
      throw new SchematicsException("Could not read package.json");
    }
    const content = buffer.toString();
    const pkg = JSON.parse(content);

    if (pkg === null || typeof pkg !== "object" || Array.isArray(pkg)) {
      throw new SchematicsException("Error reading package.json");
    }

    if (!pkg.dependencies) {
      pkg.dependencies = {};
    }

    if (pkg.dependencies["@solarwinds/nav-menu-with-migration"]) {
      pkg.dependencies["ngx-perfect-scrollbar"] = `^7.0.0`;
      pkg.dependencies["ngx-device-detector"] = null;

      tree.overwrite(pkgPath, JSON.stringify(pkg, null, 2));
    }

    return tree;
  };
}
jasmine.json

{
  "spec_dir": "projects/nav-menu/schematics/spec",
  "spec_files": [
    "**/*.spec.js"
  ],
  "helpers": [
    "projects/nav-menu/schematics/spec/helpers/**/*.js"
  ],
  "stopSpecOnExpectationFailure": false,
  "random": false
}
我有一个
ng update
文件夹,其中有
index.ts

{
  "compilerOptions": {
    "target": "es2015",
    "module": "commonjs",
    "moduleResolution": "node",
    "declaration": true,
    "sourceMap": true,
    "lib": [
      "dom",
      "es2017",
      "esnext.asynciterable"
    ]
  },
  "exclude": [
    "**/files/*.ts",
    "**/*.spec.ts"
  ]
}
{
  "compilerOptions": {
    "module": "commonjs",
    "target": "es2015",
    "moduleResolution": "node",
    "types": [
      "jasmine",
      "node"
    ],
    "lib": [
        "es2017",
        "dom"
    ],
    "declaration": false
  },
  "include": [
    "./spec/**/*.spec.ts"
  ]
}
import { Rule, SchematicContext, SchematicsException, Tree } from "@angular-devkit/schematics";

export default function(): Rule {
  return (tree: Tree, context: SchematicContext) => {
    context.logger.warn("it's happening!");

    const pkgPath = "/package.json";
    const buffer = tree.read(pkgPath);
    if (buffer == null) {
      throw new SchematicsException("Could not read package.json");
    }
    const content = buffer.toString();
    const pkg = JSON.parse(content);

    if (pkg === null || typeof pkg !== "object" || Array.isArray(pkg)) {
      throw new SchematicsException("Error reading package.json");
    }

    if (!pkg.dependencies) {
      pkg.dependencies = {};
    }

    if (pkg.dependencies["@solarwinds/nav-menu-with-migration"]) {
      pkg.dependencies["ngx-perfect-scrollbar"] = `^7.0.0`;
      pkg.dependencies["ngx-device-detector"] = null;

      tree.overwrite(pkgPath, JSON.stringify(pkg, null, 2));
    }

    return tree;
  };
}
package.json
用于我的导航菜单项目:

{
  "name": "@solarwinds/nav-menu-with-migration",
  "version": "0.0.1",
  "peerDependencies": {
    "css-element-queries": "~0.4.0",
    "ngx-perfect-scrollbar": "^7.0.0",
    "web-animations-js": "^2.3.1",
    "@angular/cdk": "^6.0.2",
    "@angular/common": "^6.0.7",
    "@angular/core": "^6.0.7",
    "@angular/router": "^6.0.7",
    "@solarwinds/nova-xui": "6.3.0-alpha.10.1322",
    "rxjs": "^6.0.0",
    "zone.js": "^0.8.26"
  },
  "schematics": "./schematics/collection.json",
  "ng-update": {
    "migrations": "./schematics/migration.json"
  }
}
一旦我发布了我的软件包,我会尝试在使用此软件包的另一个应用程序中更新
nav menu
。我尝试了许多不同的命令,其中没有一个命令似乎在
ng update
上运行
migration.json
原理图。所以我试过:

ng update@solarwinds/nav menu with migration--to=1.0.0-nav-menu-with-migration.3--migrate only

Package "@solarwinds/nova-xui" has an incompatible peer dependency to "rxjs" (requires "6.2.2", would install "6.3.3").
                  Package "@solarwinds/nova-xui" has an incompatible peer dependency to "@angular/cdk" (requires "6.3.3", would install "6.4.7").
                  Package "@angular/platform-browser-dynamic" has an incompatible peer dependency to "@angular/core" (requires "6.1.0" (extended), would install "6.1.10").
                  Package "@angular/router" has an incompatible peer dependency to "@angular/platform-browser" (requires "6.1.10", would install "6.1.0")
                  Package "@solarwinds/nova-xui" has an incompatible peer dependency to "@angular/router" (requires "6.1.4" (extended), would install "6.1.10").
                  Package "@angular/platform-browser-dynamic" has an incompatible peer dependency to "@angular/common" (requires "6.1.0" (extended), would install "6.1.10").
    Updating package.json with dependency rxjs @ "6.3.3" (was "6.2.2")...
    Updating package.json with dependency @angular/cdk @ "6.4.7" (was "6.4.3")...
    Updating package.json with dependency @angular/core @ "6.1.10" (was "6.1.0")...
    Updating package.json with dependency @angular/router @ "6.1.10" (was "6.1.0")...
    Updating package.json with dependency @angular/common @ "6.1.10" (was "6.1.0")...
我得到了以下错误:
发现了不兼容的对等依赖项。见上文

Package "@solarwinds/nova-xui" has an incompatible peer dependency to "@angular/cdk" (requires "6.3.3", would install "6.4.7").
                  Package "@angular/http" has an incompatible peer dependency to "@angular/core" (requires "6.1.0" (extended), wouldinstall "6.1.10").
                  Package "@angular/platform-browser-dynamic" has an incompatible peer dependency to "@angular/common" (requires "6.1.0" (extended), would install "6.1.10").
                  Package "@angular/router" has an incompatible peer dependency to "@angular/platform-browser" (requires "6.1.10", would install "6.1.0")
                  Package "@solarwinds/nova-xui" has an incompatible peer dependency to "@angular/router" (requires "6.1.4" (extended), would install "6.1.10").
                  Package "@solarwinds/nova-xui" has an incompatible peer dependency to "rxjs" (requires "6.2.2", would install "6.3.3").
Incompatible peer dependencies found. See above.
因此,我尝试使用
--force
标志,我确实更新了
包.json
文件,但我从未看到运行
迁移.json
原理图

g update@solarwinds/nav menu with migration--to=1.0.0-nav-menu-with-migration.3--force--migration only

Package "@solarwinds/nova-xui" has an incompatible peer dependency to "rxjs" (requires "6.2.2", would install "6.3.3").
                  Package "@solarwinds/nova-xui" has an incompatible peer dependency to "@angular/cdk" (requires "6.3.3", would install "6.4.7").
                  Package "@angular/platform-browser-dynamic" has an incompatible peer dependency to "@angular/core" (requires "6.1.0" (extended), would install "6.1.10").
                  Package "@angular/router" has an incompatible peer dependency to "@angular/platform-browser" (requires "6.1.10", would install "6.1.0")
                  Package "@solarwinds/nova-xui" has an incompatible peer dependency to "@angular/router" (requires "6.1.4" (extended), would install "6.1.10").
                  Package "@angular/platform-browser-dynamic" has an incompatible peer dependency to "@angular/common" (requires "6.1.0" (extended), would install "6.1.10").
    Updating package.json with dependency rxjs @ "6.3.3" (was "6.2.2")...
    Updating package.json with dependency @angular/cdk @ "6.4.7" (was "6.4.3")...
    Updating package.json with dependency @angular/core @ "6.1.10" (was "6.1.0")...
    Updating package.json with dependency @angular/router @ "6.1.10" (was "6.1.0")...
    Updating package.json with dependency @angular/common @ "6.1.10" (was "6.1.0")...
我不确定为什么我的
ng update
命令没有运行。我想测试我的
migration.json
原理图,所以我将我的
collection.json
指向
ng update/index
,这样当我运行
ng add@solarwinds/nav菜单时-migration@1.0.0-带有migration.3的导航菜单
我可以查看我的
ng更新
代码是否正常工作,它是否按预期工作(注意:这只是为了测试目的,我不打算使用
ng add
来运行迁移)。以下是输出:

TREHMAN-MB:web-application-seed tanzeel.rehman$ ng add @solarwinds/nav-menu-with-migration@1.0.0-nav-menu-with-migration.3Installing packages for tooling via npm.
npm WARN @solarwinds/nav-menu@2.2.0 requires a peer of @solarwinds/nova-xui@6.3.0-alpha.10.1322 but none is installed. You must install peer dependencies yourself.
npm WARN @solarwinds/nova-xui@6.3.0-alpha.12.1825 requires a peer of @angular/animations@6.1.4 but none is installed. You must install peer dependencies yourself.
npm WARN @solarwinds/nova-xui@6.3.0-alpha.12.1825 requires a peer of @angular/cdk@6.3.3 but none is installed. You must install peerdependencies yourself.
npm WARN @solarwinds/nova-xui@6.3.0-alpha.12.1825 requires a peer of @angular/common@6.1.4 but none is installed. You must install peer dependencies yourself.
npm WARN @solarwinds/nova-xui@6.3.0-alpha.12.1825 requires a peer of @angular/compiler@6.1.4 but none is installed. You must installpeer dependencies yourself.
npm WARN @solarwinds/nova-xui@6.3.0-alpha.12.1825 requires a peer of @angular/core@6.1.4 but none is installed. You must install peer dependencies yourself.
npm WARN @solarwinds/nova-xui@6.3.0-alpha.12.1825 requires a peer of @angular/forms@6.1.4 but none is installed. You must install peer dependencies yourself.
npm WARN @solarwinds/nova-xui@6.3.0-alpha.12.1825 requires a peer of @angular/http@6.1.4 but none is installed. You must install peer dependencies yourself.
npm WARN @solarwinds/nova-xui@6.3.0-alpha.12.1825 requires a peer of @angular/platform-browser@6.1.4 but none is installed. You mustinstall peer dependencies yourself.
npm WARN @solarwinds/nova-xui@6.3.0-alpha.12.1825 requires a peer of @angular/platform-browser-dynamic@6.1.4 but none is installed. You must install peer dependencies yourself.
npm WARN @solarwinds/nova-xui@6.3.0-alpha.12.1825 requires a peer of @angular/router@6.1.4 but none is installed. You must install peer dependencies yourself.
npm WARN tsickle@0.30.0 requires a peer of typescript@>=2.4.2 <2.9 but none is installed. You must install peer dependencies yourself.
npm WARN @solarwinds/nav-menu-with-migration@1.0.0-nav-menu-with-migration.3 requires a peer of ngx-perfect-scrollbar@^7.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN @solarwinds/nav-menu-with-migration@1.0.0-nav-menu-with-migration.3 requires a peer of @solarwinds/nova-xui@6.3.0-alpha.10.1322 but none is installed. You must install peer dependencies yourself.

+ @solarwinds/nav-menu-with-migration@1.0.0-nav-menu-with-migration.3
updated 1 package and audited 40530 packages in 16.964s
found 10 vulnerabilities (3 low, 5 moderate, 2 high)
  run `npm audit fix` to fix them, or `npm audit` for details
Installed packages for tooling via npm.
    it's happening!
UPDATE package.json (4250 bytes)
TREHMAN-MB:web应用程序seed tanzeel.rehman$ng add@solarwinds/nav菜单-migration@1.0.0-nav-menu-with-migration.3通过npm安装工具包。
太阳风/导航时的npm警告-menu@2.2.0需要@solarwinds/nova的对等方-xui@6.3.0-alpha.10.1322,但未安装。您必须自己安装对等依赖项。
太阳风/新星npm警告-xui@6.3.0-alpha.12.1825需要@angular的对等点/animations@6.1.4但未安装任何组件。您必须自己安装对等依赖项。
太阳风/新星npm警告-xui@6.3.0-alpha.12.1825需要@angular的对等点/cdk@6.3.3但是没有安装。您必须自己安装peerdependencies。
太阳风/新星npm警告-xui@6.3.0-alpha.12.1825需要@angular的对等点/common@6.1.4但未安装任何组件。您必须自己安装对等依赖项。
太阳风/新星npm警告-xui@6.3.0-alpha.12.1825需要@angular的对等点/compiler@6.1.4但是没有安装。您必须自己安装对等依赖项。
太阳风/新星npm警告-xui@6.3.0-alpha.12.1825需要@angular的对等点/core@6.1.4但未安装任何组件。您必须自己安装对等依赖项。
太阳风/新星npm警告-xui@6.3.0-alpha.12.1825需要@angular的对等点/forms@6.1.4但未安装任何组件。您必须自己安装对等依赖项。
太阳风/新星npm警告-xui@6.3.0-alpha.12.1825需要@angular的对等点/http@6.1.4但未安装任何组件。您必须自己安装对等依赖项。
太阳风/新星npm警告-xui@6.3.0-alpha.12.1825需要一个@angular/平台的对等点-browser@6.1.4但是没有安装。您必须自己安装对等依赖项。
太阳风/新星npm警告-xui@6.3.0-alpha.12.1825需要一个@angular/platform浏览器的对等节点-dynamic@6.1.4但未安装任何组件。您必须自己安装对等依赖项。
太阳风/新星npm警告-xui@6.3.0-alpha.12.1825需要@angular的对等点/router@6.1.4但未安装任何组件。您必须自己安装对等依赖项。
npm警告tsickle@0.30.0需要类型为script@>=2.4.2的对等方