Skip to content
This repository was archived by the owner on Apr 4, 2025. It is now read-only.

Commit 6b8a6e8

Browse files
committed
fix(@schematics/angular): add schematics defaults to app instead of workspace
1 parent a6767dc commit 6b8a6e8

File tree

1 file changed

+27
-28
lines changed
  • packages/schematics/angular/application

1 file changed

+27
-28
lines changed

packages/schematics/angular/application/index.ts

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,38 @@ function addAppToWorkspaceFile(options: ApplicationOptions, workspace: Workspace
106106
? projectRoot
107107
: projectRoot + 'src/';
108108

109+
const schematics: JsonObject = {};
110+
111+
if (options.inlineTemplate === true
112+
|| options.inlineStyle === true
113+
|| options.style !== 'css') {
114+
schematics['@schematics/angular:component'] = {};
115+
if (options.inlineTemplate === true) {
116+
(schematics['@schematics/angular:component'] as JsonObject).inlineTemplate = true;
117+
}
118+
if (options.inlineStyle === true) {
119+
(schematics['@schematics/angular:component'] as JsonObject).inlineStyle = true;
120+
}
121+
if (options.style && options.style !== 'css') {
122+
(schematics['@schematics/angular:component'] as JsonObject).styleext = options.style;
123+
}
124+
}
125+
126+
if (options.skipTests === true) {
127+
['class', 'component', 'directive', 'guard', 'module', 'pipe', 'service'].forEach((type) => {
128+
if (!(`@schematics/angular:${type}` in schematics)) {
129+
schematics[`@schematics/angular:${type}`] = {};
130+
}
131+
(schematics[`@schematics/angular:${type}`] as JsonObject).spec = false;
132+
});
133+
}
134+
109135
// tslint:disable-next-line:no-any
110136
const project: any = {
111137
root: projectRoot,
112138
projectType: 'application',
113139
prefix: options.prefix || 'app',
140+
schematics,
114141
architect: {
115142
build: {
116143
builder: '@angular-devkit/build-angular:browser',
@@ -221,34 +248,6 @@ function addAppToWorkspaceFile(options: ApplicationOptions, workspace: Workspace
221248

222249
workspace.projects[options.name] = project;
223250

224-
const schematics: JsonObject = {};
225-
226-
if (options.inlineTemplate === true
227-
|| options.inlineStyle === true
228-
|| options.style !== 'css') {
229-
schematics['@schematics/angular:component'] = {};
230-
if (options.inlineTemplate === true) {
231-
(schematics['@schematics/angular:component'] as JsonObject).inlineTemplate = true;
232-
}
233-
if (options.inlineStyle === true) {
234-
(schematics['@schematics/angular:component'] as JsonObject).inlineStyle = true;
235-
}
236-
if (options.style && options.style !== 'css') {
237-
(schematics['@schematics/angular:component'] as JsonObject).styleext = options.style;
238-
}
239-
}
240-
241-
if (options.skipTests === true) {
242-
['class', 'component', 'directive', 'guard', 'module', 'pipe', 'service'].forEach((type) => {
243-
if (!(`@schematics/angular:${type}` in schematics)) {
244-
schematics[`@schematics/angular:${type}`] = {};
245-
}
246-
(schematics[`@schematics/angular:${type}`] as JsonObject).spec = false;
247-
});
248-
}
249-
250-
workspace.schematics = schematics;
251-
252251
host.overwrite(getWorkspacePath(host), JSON.stringify(workspace, null, 2));
253252
};
254253
}

0 commit comments

Comments
 (0)