Skip to content

Commit

Permalink
refactor(schematics): invert noCMSPrefixing option
Browse files Browse the repository at this point in the history
BREAKING CHANGES: The `cms` schematic's `noCMSPrefixing` option has been renamed to `cmsPrefixing` with an inverted behavior.
  • Loading branch information
MaxKless authored and SGrueber committed Jul 19, 2022
1 parent c216537 commit d1258fb
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 7 deletions.
4 changes: 4 additions & 0 deletions docs/guides/migrations.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
2 changes: 1 addition & 1 deletion e2e/test-schematics-normal.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions schematics/src/cms-component/factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion schematics/src/cms-component/factory_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 [
Expand Down
6 changes: 3 additions & 3 deletions schematics/src/cms-component/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}

0 comments on commit d1258fb

Please sign in to comment.