如何扩展角度示意图属性?

nic*_*ock 5 code-generation angular-cli angular angular-schematics nrwl

我的问题是否可以扩展架构属性?

我试过的:
collection.json

{
  "$schema": "http://schema.angular.io/schematics/collection/2",
  "name": "@my/schematics",
  "description": "my default collection, containing all schematics that are used normally",
  "schematics": {
    "library": {
      "extends": "@nrwl/angular:library", <--- extends nrwl library
      "aliases": [ "lib" ],
      "factory": "./library",
      "description": "Create my library.",
      "schema": "./library/schema.json"
    }
}
Run Code Online (Sandbox Code Playgroud)

图书馆/schema.json

{
  "$schema": "http://schema.angular.io/schematics/collection/2",
  "id": "SchematicsAngularLibrary",
  "title": "Create my library",
  "type": "object",
  "properties": {
    "legacy": {    <--- adds custom property
      "type": "boolean",
      "description": "Legacy mode",
      "default": false
    }
  },
  "required": []
}

Run Code Online (Sandbox Code Playgroud)

和我的简化原理图库/index.ts

import { chain, externalSchematic, Rule, Tree, SchematicContext } from '@angular-devkit/schematics';

export default function(schema: Schema): Rule {
  return function(host: Tree, context: SchematicContext) {
    const isLegacyMode = schema.legacy; // <--- this is what I am trying to achieve

    return chain([
      externalSchematic('@nrwl/angular', 'library', options),
    ])(host, context);
  };
}

Run Code Online (Sandbox Code Playgroud)

但看起来原理图没有扩展,因为当我运行
ng g lib megalib --unitTestRunner=jest --legacy
它时会抛出这个错误:
Unknown option: '--legacy'

为什么我要扩展(而不是复制):当nrwl/angular架构和原理图代码更新时,我也会得到这些更改。

环境:
angular/*9.0.0-rc.8
@nrwl/*8.11.1

更新:

我也尝试与$ref结合使用allOf,但它仅适用于http,请参阅问题。