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

Add --minimal flag to enable barebones project. #12498

Merged
merged 1 commit into from
Oct 10, 2018
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
20 changes: 19 additions & 1 deletion packages/schematics/angular/application/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,14 @@ function addAppToWorkspaceFile(options: ApplicationOptions, workspace: Workspace
return addProjectToWorkspace(workspace, options.name, project);
}

function minimalPathFilter(path: string): boolean {
const toRemoveList: RegExp[] = [/e2e\//, /editorconfig/, /README/, /karma.conf.js/,
/protractor.conf.js/, /test.ts/, /tsconfig.spec.json/,
/tslint.json/, /favicon.ico/];

return !toRemoveList.some(re => re.test(path));
}

export default function (options: ApplicationOptions): Rule {
return (host: Tree, context: SchematicContext) => {
if (!options.name) {
Expand All @@ -248,12 +256,19 @@ export default function (options: ApplicationOptions): Rule {
validateProjectName(options.name);
const prefix = options.prefix || 'app';
const appRootSelector = `${prefix}-root`;
const componentOptions = {
const componentOptions = !options.minimal ?
{
inlineStyle: options.inlineStyle,
inlineTemplate: options.inlineTemplate,
spec: !options.skipTests,
styleext: options.style,
viewEncapsulation: options.viewEncapsulation,
} :
{
inlineStyle: true,
InlineTemplate: true,
spec: false,
styleext: options.style,
};

const workspace = getWorkspace(host);
Expand Down Expand Up @@ -287,6 +302,7 @@ export default function (options: ApplicationOptions): Rule {
options.skipPackageJson ? noop() : addDependenciesToPackageJson(),
mergeWith(
apply(url('./files/src'), [
options.minimal ? filter(minimalPathFilter) : noop(),
template({
utils: strings,
...options,
Expand All @@ -297,6 +313,7 @@ export default function (options: ApplicationOptions): Rule {
])),
mergeWith(
apply(url('./files/root'), [
options.minimal ? filter(minimalPathFilter) : noop(),
template({
utils: strings,
...options,
Expand All @@ -308,6 +325,7 @@ export default function (options: ApplicationOptions): Rule {
])),
mergeWith(
apply(url('./files/lint'), [
options.minimal ? filter(minimalPathFilter) : noop(),
template({
utils: strings,
...options,
Expand Down
5 changes: 5 additions & 0 deletions packages/schematics/angular/application/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@
"type": "boolean",
"default": false,
"description": "Do not add dependencies to package.json."
},
"minimal": {
"description": "Create a barebones project without any testing frameworks",
rsarky marked this conversation as resolved.
Show resolved Hide resolved
"type": "boolean",
"default": false
}
},
"required": [
Expand Down
1 change: 1 addition & 0 deletions packages/schematics/angular/ng-new/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export default function (options: NgNewOptions): Rule {
version: options.version,
experimentalAngularNext: options.experimentalIvy,
newProjectRoot: options.newProjectRoot || 'projects',
minimal: options.minimal,
};
const applicationOptions: ApplicationOptions = {
projectRoot: '',
Expand Down
5 changes: 5 additions & 0 deletions packages/schematics/angular/ng-new/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,11 @@
"description": "Flag to toggle creation of an application in the new workspace.",
"type": "boolean",
"default": true
},
"minimal": {
"description": "Create a barebones project without any testing frameworks",
"type": "boolean",
"default": false
}
},
"required": [
Expand Down
6 changes: 3 additions & 3 deletions packages/schematics/angular/workspace/files/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
"@angular/cli": "<%= experimentalAngularNext ? 'next' : '~' + version %>",
"@angular/compiler-cli": "<%= experimentalAngularNext ? 'next' : latestVersions.Angular %>",
"@angular/language-service": "<%= experimentalAngularNext ? 'next' : latestVersions.Angular %>",
"@types/jasmine": "~2.8.8",
"@types/jasminewd2": "~2.0.3",
"@types/node": "~8.9.4",
<% if (!minimal) { %>"@types/jasmine": "~2.8.8",
"@types/jasminewd2": "~2.0.3",
"codelyzer": "~4.3.0",
"jasmine-core": "~2.99.1",
"jasmine-spec-reporter": "~4.2.1",
Expand All @@ -39,7 +39,7 @@
"karma-coverage-istanbul-reporter": "~2.0.1",
"karma-jasmine": "~1.1.2",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.4.0",
"protractor": "~5.4.0",<% } %>
"ts-node": "~7.0.0",
"tslint": "~5.11.0",
"typescript": "<%= latestVersions.TypeScript %>"
Expand Down
5 changes: 5 additions & 0 deletions packages/schematics/angular/workspace/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@
"$default": {
"$source": "ng-cli-version"
}
},
"minimal": {
"description": "Create a barebones project without any testing frameworks",
rsarky marked this conversation as resolved.
Show resolved Hide resolved
"type": "boolean",
"default": false
}
},
"required": [
Expand Down
1 change: 0 additions & 1 deletion tests/legacy-cli/e2e_runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ const allTests = glob.sync(path.join(e2eRoot, testGlob), { nodir: true, ignore:
// Replace windows slashes.
.map(name => name.replace(/\\/g, '/'))
.filter(name => !name.endsWith('/build-app-shell-with-schematic.ts'))
.filter(name => !name.endsWith('/new-minimal.ts'))
// IS this test still valid? \/
.filter(name => !name.endsWith('/module-id.ts'))
// Do we want to support this?
Expand Down