Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(@angular-devkit/core): remove deprecated schema id handling #21542

Merged
merged 2 commits into from
Aug 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 0 additions & 19 deletions packages/angular_devkit/core/src/json/schema/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,6 @@ export class CoreSchemaRegistry implements SchemaRegistry {
}

private async _flatten(schema: JsonObject): Promise<JsonObject> {
this._replaceDeprecatedSchemaIdKeyword(schema);
this._ajv.removeSchema(schema);

this._currentCompilationSchemaInfo = undefined;
Expand Down Expand Up @@ -294,8 +293,6 @@ export class CoreSchemaRegistry implements SchemaRegistry {
return async (data) => ({ success: schema, data });
}

this._replaceDeprecatedSchemaIdKeyword(schema);

const schemaInfo: SchemaInfo = {
smartDefaultRecord: new Map<string, JsonObject>(),
promptDefinitions: [],
Expand Down Expand Up @@ -680,22 +677,6 @@ export class CoreSchemaRegistry implements SchemaRegistry {
});
}

/**
* Workaround to avoid a breaking change in downstream schematics.
* @deprecated will be removed in version 13.
*/
private _replaceDeprecatedSchemaIdKeyword(schema: JsonObject): void {
if (typeof schema.id === 'string') {
schema.$id = schema.id;
delete schema.id;

// eslint-disable-next-line no-console
console.warn(
`"${schema.$id}" schema is using the keyword "id" which its support is deprecated. Use "$id" for schema ID.`,
);
}
}

private normalizeDataPathArr(it: SchemaObjCxt): (number | string)[] {
return it.dataPathArr
.slice(1, it.dataLevel + 1)
Expand Down
9 changes: 4 additions & 5 deletions tests/legacy-cli/e2e/tests/commands/add/version-specifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@ import { uninstallPackage } from '../../../utils/packages';
import { ng } from '../../../utils/process';
import { isPrereleaseCli } from '../../../utils/project';


export default async function () {
// forcibly remove in case another test doesn't clean itself up.
await rimraf('node_modules/@angular/localize');

const tag = await isPrereleaseCli() ? '@next' : '';
const tag = (await isPrereleaseCli()) ? '@next' : '';

await ng('add', `@angular/localize${tag}`, '--skip-confirmation');
await ng('add', `@angular/localize${tag}`, '--skip-confirmation');
await expectFileToMatch('package.json', /@angular\/localize/);

const output1 = await ng('add', '@angular/localize', '--skip-confirmation');
Expand All @@ -23,12 +22,12 @@ export default async function () {
throw new Error('Installation should not have been skipped');
}

const output3 = await ng('add', '@angular/localize@10.0.0', '--skip-confirmation');
const output3 = await ng('add', '@angular/localize@12.0.0', '--skip-confirmation');
if (output3.stdout.includes('Skipping installation: Package already installed')) {
throw new Error('Installation should not have been skipped');
}

const output4 = await ng('add', '@angular/localize@10', '--skip-confirmation');
const output4 = await ng('add', '@angular/localize@12', '--skip-confirmation');
if (!output4.stdout.includes('Skipping installation: Package already installed')) {
throw new Error('Installation was not skipped');
}
Expand Down