Skip to content
This repository has been archived by the owner on Apr 9, 2022. It is now read-only.

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 authored and filipesilva committed May 24, 2018
1 parent e570f6b commit 3370c28
Show file tree
Hide file tree
Showing 19 changed files with 40 additions and 23 deletions.
7 changes: 5 additions & 2 deletions packages/schematics/angular/app-shell/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ 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';
Expand Down Expand Up @@ -171,12 +170,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 @@ -105,5 +105,6 @@
"description": "Specifies if the component is an entry component of declaring module."
}
},
"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 @@ -113,5 +113,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 3370c28

Please sign in to comment.