Skip to content

Commit

Permalink
feat: show warning on deprecated option usage
Browse files Browse the repository at this point in the history
  • Loading branch information
alan-agius4 committed Aug 14, 2020
1 parent 8b2a2bd commit 551a4d9
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/lib/ng-package/discover-packages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,22 @@ async function resolveUserPackage(folderPathOrFilePath: string, isSecondary = fa
const _ajv = ajv({
schemaId: 'auto',
useDefaults: true,
jsonPointers: true,
});

const validate = _ajv.compile(ngPackageSchemaJson);
// Add handler for x-deprecated fields
_ajv.addKeyword('x-deprecated', {
validate: (schema, _data, _parentSchema, _dataPath, _parentDataObject, propertyName) => {
if (schema) {
log.warn(`Option "${propertyName}" is deprecated${typeof schema == 'string' ? ': ' + schema : '.'}`);
}

return true;
},
errors: false,
});

const isValid = validate(ngPackageJson);
if (!isValid) {
throw new Error(
Expand Down Expand Up @@ -134,10 +147,7 @@ async function findSecondaryPackagesPaths(directoryPath: string, excludeFolder:
* @param primary The primary entry point.
* @param userPackage The user package for the secondary entry point.
*/
function secondaryEntryPoint(
primary: NgEntryPoint,
userPackage: UserPackage,
): NgEntryPoint {
function secondaryEntryPoint(primary: NgEntryPoint, userPackage: UserPackage): NgEntryPoint {
const { packageJson, ngPackageJson, basePath } = userPackage;
if (path.resolve(basePath) === path.resolve(primary.basePath)) {
log.error(`Cannot read secondary entry point. It's already a primary entry point. Path: ${basePath}`);
Expand Down

0 comments on commit 551a4d9

Please sign in to comment.