Skip to content

Commit

Permalink
fix(@schematics/angular): Validate to prevent additional properties
Browse files Browse the repository at this point in the history
  • Loading branch information
Brocco committed May 11, 2018
1 parent 8892745 commit 80f033f
Show file tree
Hide file tree
Showing 20 changed files with 47 additions and 24 deletions.
7 changes: 6 additions & 1 deletion packages/angular/pwa/pwa/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,12 @@ function addServiceWorker(options: PwaOptions): Rule {
return (host: Tree, context: SchematicContext) => {
context.logger.debug('Adding service worker...');

return externalSchematic('@schematics/angular', 'service-worker', options)(host, context);
const swOptions = {
...options,
};
delete swOptions.title;

return externalSchematic('@schematics/angular', 'service-worker', swOptions)(host, context);
};
}

Expand Down
8 changes: 6 additions & 2 deletions packages/schematics/angular/app-shell/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ import {
import * as ts from 'typescript';
import {
WorkspaceProject,
WorkspaceSchema,
WorkspaceTool,
} from '../../../angular_devkit/core/src/workspace/workspace-schema';
import { Schema as ComponentOptions } from '../component/schema';
import { Schema as UniversalOptions } from '../universal/schema';
import {
addImportToModule,
addSymbolToNgModuleMetadata,
Expand Down Expand Up @@ -171,12 +171,16 @@ function addUniversalTarget(options: AppShellOptions): Rule {
// Copy options.
const universalOptions = {
...options,
name: options.universalProject,
};

// Delete non-universal options.
delete universalOptions.universalProject;
delete universalOptions.route;
delete universalOptions.name;
delete universalOptions.outDir;
delete universalOptions.root;
delete universalOptions.index;
delete universalOptions.sourceDir;

return schematic('universal', universalOptions)(host, context);
};
Expand Down
6 changes: 2 additions & 4 deletions packages/schematics/angular/app-shell/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@
"description": "Route path used to produce the app shell.",
"default": "shell"
},



"name": {
"type": "string",
"format": "html-selector",
Expand Down Expand Up @@ -101,5 +98,6 @@
"required": [
"clientProject",
"universalProject"
]
],
"additionalProperties": false
}
3 changes: 2 additions & 1 deletion packages/schematics/angular/application/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,6 @@
"description": "Do not add dependencies to package.json."
}
},
"required": []
"required": [],
"additionalProperties": false
}
3 changes: 2 additions & 1 deletion packages/schematics/angular/class/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,6 @@
"default": ""
}
},
"required": []
"required": [],
"additionalProperties": false
}
3 changes: 2 additions & 1 deletion packages/schematics/angular/component/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,5 +100,6 @@
"description": "Specifies if declaring module exports the component."
}
},
"required": []
"required": [],
"additionalProperties": false
}
3 changes: 2 additions & 1 deletion packages/schematics/angular/directive/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,6 @@
"description": "Specifies if declaring module exports the directive."
}
},
"required": []
"required": [],
"additionalProperties": false
}
3 changes: 2 additions & 1 deletion packages/schematics/angular/e2e/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,6 @@
},
"required": [
"relatedAppName"
]
],
"additionalProperties": false
}
3 changes: 2 additions & 1 deletion packages/schematics/angular/enum/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,6 @@
}
}
},
"required": []
"required": [],
"additionalProperties": false
}
3 changes: 2 additions & 1 deletion packages/schematics/angular/guard/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,6 @@
}
}
},
"required": []
"required": [],
"additionalProperties": false
}
3 changes: 2 additions & 1 deletion packages/schematics/angular/interface/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,6 @@
}
}
},
"required": []
"required": [],
"additionalProperties": false
}
2 changes: 1 addition & 1 deletion packages/schematics/angular/library/index_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ describe('Library Schematic', () => {

it('should set the prefix correctly', () => {
const options = { ...defaultOptions, prefix: 'pre' };
const tree = schematicRunner.runSchematic('application', options, workspaceTree);
const tree = schematicRunner.runSchematic('library', options, workspaceTree);

const workspace = JSON.parse(tree.readContent('/angular.json'));
expect(workspace.projects.foo.prefix).toEqual('pre');
Expand Down
3 changes: 2 additions & 1 deletion packages/schematics/angular/library/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,6 @@
"description": "Do not update tsconfig.json for development experience."
}
},
"required": []
"required": [],
"additionalProperties": false
}
3 changes: 2 additions & 1 deletion packages/schematics/angular/module/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,6 @@
"alias": "m"
}
},
"required": []
"required": [],
"additionalProperties": false
}
3 changes: 2 additions & 1 deletion packages/schematics/angular/ng-new/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -115,5 +115,6 @@
},
"required": [
"version"
]
],
"additionalProperties": false
}
3 changes: 2 additions & 1 deletion packages/schematics/angular/pipe/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,6 @@
"description": "Specifies if declaring module exports the pipe."
}
},
"required": []
"required": [],
"additionalProperties": false
}
3 changes: 2 additions & 1 deletion packages/schematics/angular/service-worker/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@
"default": "production"
}
},
"required": []
"required": [],
"additionalProperties": false
}
3 changes: 2 additions & 1 deletion packages/schematics/angular/service/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,6 @@
"description": "Specifies if a spec file is generated."
}
},
"required": []
"required": [],
"additionalProperties": false
}
3 changes: 2 additions & 1 deletion packages/schematics/angular/universal/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,6 @@
},
"required": [
"clientProject"
]
],
"additionalProperties": false
}
3 changes: 2 additions & 1 deletion packages/schematics/angular/workspace/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,6 @@
"required": [
"name",
"version"
]
],
"additionalProperties": false
}

0 comments on commit 80f033f

Please sign in to comment.