My question is it possible to extend schema properties?
What I tried:
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"
}
}
library/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": []
}
and my simplified schematic library/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);
};
}
But it looks like schematic was not extended, because when I run
ng g lib megalib --unitTestRunner=jest --legacy
it throws this error:
Unknown option: '--legacy'
Why I want to extend (not to copy): when nrwl/angular
schema and schematic code will be updated, I will get these changes too.
Environment:
angular/*
9.0.0-rc.8
@nrwl/*
8.11.1
UPD:
Also I tried to use $ref
in combination with allOf
, but it works only with http
, see this issue.