From d1258fb8428405109c13730bdc435251fbdc196f Mon Sep 17 00:00:00 2001 From: "max.kless@googlemail.com" Date: Tue, 12 Jul 2022 11:24:48 +0200 Subject: [PATCH] refactor(schematics): invert noCMSPrefixing option BREAKING CHANGES: The `cms` schematic's `noCMSPrefixing` option has been renamed to `cmsPrefixing` with an inverted behavior. --- docs/guides/migrations.md | 4 ++++ e2e/test-schematics-normal.sh | 2 +- schematics/src/cms-component/factory.ts | 4 ++-- schematics/src/cms-component/factory_spec.ts | 2 +- schematics/src/cms-component/schema.json | 6 +++--- 5 files changed, 11 insertions(+), 7 deletions(-) diff --git a/docs/guides/migrations.md b/docs/guides/migrations.md index fb74c2ee44..0185f2a821 100644 --- a/docs/guides/migrations.md +++ b/docs/guides/migrations.md @@ -20,6 +20,10 @@ The following official guides might help to migrate custom code as well: - https://ngrx.io/guide/migration/v14 - https://angular.io/guide/typed-forms +Because Angular 14 now uses `yargs` to parse CLI arguments (see [#22778](https://github.com/angular/angular-cli/pull/22778)), schematic options with a `no` prefix are handled differently. +With [#23405](https://github.com/angular/angular-cli/pull/23405), the Angular team has introduced a temporary workaround for this. +In order to reliably maintain compatibility in the future, the `cms` schematic's `noCMSPrefixing` option has been renamed to `cmsPrefixing` with an inverted behavior. + Since the used deferred load library is no longer maintained it is removed and replaced with similar standard browser functionality [`loading="lazy"`](https://developer.mozilla.org/en-US/docs/Web/Performance/Lazy_loading#images_and_iframes). All uses of the `(deferLoad)` directive in custom code need to be replaced. diff --git a/e2e/test-schematics-normal.sh b/e2e/test-schematics-normal.sh index 9d9e8b06bd..f8b3d59917 100644 --- a/e2e/test-schematics-normal.sh +++ b/e2e/test-schematics-normal.sh @@ -89,7 +89,7 @@ test -f src/app/shared/cms/components/cms-inventory/cms-inventory.component.ts grep "CMSInventoryComponent" src/app/shared/cms/cms.module.ts grep "CMSInventoryComponent" src/app/shared/shared.module.ts -npx ng g cms --definition-qualified-name app:component.custom.audio.pagelet2-Component --noCMSPrefixing audio +npx ng g cms --definition-qualified-name app:component.custom.audio.pagelet2-Component --cms-prefixing=false audio test -f src/app/shared/cms/components/audio/audio.component.ts grep "AudioComponent" src/app/shared/cms/cms.module.ts grep "AudioComponent" src/app/shared/shared.module.ts diff --git a/schematics/src/cms-component/factory.ts b/schematics/src/cms-component/factory.ts index 3e5a6cb2c9..c222e3765c 100644 --- a/schematics/src/cms-component/factory.ts +++ b/schematics/src/cms-component/factory.ts @@ -32,11 +32,11 @@ export function createCMSComponent(options: Options): Rule { } options = await detectExtension('cms', host, options); options = await applyNameAndPath('component', host, options); - if (!options.noCMSPrefixing) { + if (options.cmsPrefixing) { options.name = `cms-${options.name}`; } options = determineArtifactName('component', host, options); - if (!options.noCMSPrefixing) { + if (options.cmsPrefixing) { options.artifactName = `CMS${options.artifactName.replace('Cms', '')}`; } options = await generateSelector(host, options); diff --git a/schematics/src/cms-component/factory_spec.ts b/schematics/src/cms-component/factory_spec.ts index 466b413039..94463e9386 100644 --- a/schematics/src/cms-component/factory_spec.ts +++ b/schematics/src/cms-component/factory_spec.ts @@ -74,7 +74,7 @@ describe('CMS Component Schematic', () => { }); it('should create a component in cms module without added name prefix if requested', async () => { - const options = { ...defaultOptions, noCMSPrefixing: true }; + const options = { ...defaultOptions, cmsPrefixing: false }; const tree = await schematicRunner.runSchematicAsync('cms-component', options, appTree).toPromise(); expect(tree.files.filter(x => x.search('cms') >= 0)).toMatchInlineSnapshot(` Array [ diff --git a/schematics/src/cms-component/schema.json b/schematics/src/cms-component/schema.json index 13e947e147..c1e9731991 100644 --- a/schematics/src/cms-component/schema.json +++ b/schematics/src/cms-component/schema.json @@ -83,10 +83,10 @@ "description": "Flag to indicate if a dir is created.", "default": false }, - "noCMSPrefixing": { + "cmsPrefixing": { "type": "boolean", - "description": "Flag to indicate if CMS prefixes should not be added.", - "default": false + "description": "Flag to indicate if CMS prefixes should be added.", + "default": true } } }