Skip to content

Commit 36eba0c

Browse files
Alan AgiusKeen Yee Liau
Alan Agius
authored and
Keen Yee Liau
committed
refactor: use .template suffix for all schematic files
Currently when using `ivy-ngcc` it will print out a warning ``` Failed to read entry point info from //node_modules/@schematics/angular/workspace/files/package.json with error SyntaxError: Unexpected token < in JSON at position 1121. ``` Fixes #13378
1 parent 7d15c5d commit 36eba0c

File tree

84 files changed

+54
-50
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+54
-50
lines changed

packages/schematics/angular/application/index.ts

+12-8
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ import {
2121
SchematicsException,
2222
Tree,
2323
apply,
24+
applyTemplates,
2425
chain,
2526
filter,
2627
mergeWith,
2728
move,
2829
noop,
2930
schematic,
30-
template,
3131
url,
3232
} from '@angular-devkit/schematics';
3333
import { NodePackageInstallTask } from '@angular-devkit/schematics/tasks';
@@ -292,7 +292,7 @@ function addAppToWorkspaceFile(options: ApplicationOptions, workspace: Workspace
292292
}
293293

294294
function minimalPathFilter(path: string): boolean {
295-
const toRemoveList = /(test.ts|tsconfig.spec.json|karma.conf.js)$/;
295+
const toRemoveList = /(test.ts|tsconfig.spec.json|karma.conf.js).template$/;
296296

297297
return !toRemoveList.test(path);
298298
}
@@ -351,7 +351,7 @@ export default function (options: ApplicationOptions): Rule {
351351
mergeWith(
352352
apply(url('./files/src'), [
353353
options.minimal ? filter(minimalPathFilter) : noop(),
354-
template({
354+
applyTemplates({
355355
utils: strings,
356356
...options,
357357
'dot': '.',
@@ -362,7 +362,7 @@ export default function (options: ApplicationOptions): Rule {
362362
mergeWith(
363363
apply(url('./files/root'), [
364364
options.minimal ? filter(minimalPathFilter) : noop(),
365-
template({
365+
applyTemplates({
366366
utils: strings,
367367
...options,
368368
'dot': '.',
@@ -374,7 +374,7 @@ export default function (options: ApplicationOptions): Rule {
374374
])),
375375
options.minimal ? noop() : mergeWith(
376376
apply(url('./files/lint'), [
377-
template({
377+
applyTemplates({
378378
utils: strings,
379379
...options,
380380
tsLintRoot,
@@ -406,9 +406,13 @@ export default function (options: ApplicationOptions): Rule {
406406
}),
407407
mergeWith(
408408
apply(url('./other-files'), [
409-
componentOptions.inlineTemplate ? filter(path => !path.endsWith('.html')) : noop(),
410-
componentOptions.skipTests ? filter(path => !/[.|-]spec.ts$/.test(path)) : noop(),
411-
template({
409+
componentOptions.inlineTemplate
410+
? filter(path => !path.endsWith('.html.template'))
411+
: noop(),
412+
componentOptions.skipTests
413+
? filter(path => !/[.|-]spec.ts.template$/.test(path))
414+
: noop(),
415+
applyTemplates({
412416
utils: strings,
413417
...options as any, // tslint:disable-line:no-any
414418
selector: appRootSelector,

packages/schematics/angular/class/index.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ import {
1212
SchematicsException,
1313
Tree,
1414
apply,
15+
applyTemplates,
1516
branchAndMerge,
1617
chain,
1718
filter,
1819
mergeWith,
1920
move,
2021
noop,
21-
template,
2222
url,
2323
} from '@angular-devkit/schematics';
2424
import { applyLintFix } from '../utility/lint-fix';
@@ -48,8 +48,8 @@ export default function (options: ClassOptions): Rule {
4848
options.skipTests = options.skipTests || !options.spec;
4949

5050
const templateSource = apply(url('./files'), [
51-
options.skipTests ? filter(path => !path.endsWith('.spec.ts')) : noop(),
52-
template({
51+
options.skipTests ? filter(path => !path.endsWith('.spec.ts.template')) : noop(),
52+
applyTemplates({
5353
...strings,
5454
...options,
5555
}),

packages/schematics/angular/component/index.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ import {
1111
SchematicsException,
1212
Tree,
1313
apply,
14+
applyTemplates,
1415
branchAndMerge,
1516
chain,
1617
filter,
1718
mergeWith,
1819
move,
1920
noop,
20-
template,
2121
url,
2222
} from '@angular-devkit/schematics';
2323
import * as ts from 'typescript';
@@ -154,10 +154,10 @@ export default function (options: ComponentOptions): Rule {
154154
validateHtmlSelector(options.selector);
155155

156156
const templateSource = apply(url('./files'), [
157-
options.skipTests ? filter(path => !path.endsWith('.spec.ts')) : noop(),
158-
options.inlineStyle ? filter(path => !path.endsWith('.__style__')) : noop(),
159-
options.inlineTemplate ? filter(path => !path.endsWith('.html')) : noop(),
160-
template({
157+
options.skipTests ? filter(path => !path.endsWith('.spec.ts.template')) : noop(),
158+
options.inlineStyle ? filter(path => !path.endsWith('.__style__.template')) : noop(),
159+
options.inlineTemplate ? filter(path => !path.endsWith('.html.template')) : noop(),
160+
applyTemplates({
161161
...strings,
162162
'if-flat': (s: string) => options.flat ? '' : s,
163163
...options,

packages/schematics/angular/directive/index.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ import {
1111
SchematicsException,
1212
Tree,
1313
apply,
14+
applyTemplates,
1415
branchAndMerge,
1516
chain,
1617
filter,
1718
mergeWith,
1819
move,
1920
noop,
20-
template,
2121
url,
2222
} from '@angular-devkit/schematics';
2323
import * as ts from 'typescript';
@@ -125,8 +125,8 @@ export default function (options: DirectiveOptions): Rule {
125125
options.skipTests = options.skipTests || !options.spec;
126126

127127
const templateSource = apply(url('./files'), [
128-
options.skipTests ? filter(path => !path.endsWith('.spec.ts')) : noop(),
129-
template({
128+
options.skipTests ? filter(path => !path.endsWith('.spec.ts.template')) : noop(),
129+
applyTemplates({
130130
...strings,
131131
'if-flat': (s: string) => options.flat ? '' : s,
132132
...options,

packages/schematics/angular/e2e/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ import {
1212
SchematicsException,
1313
Tree,
1414
apply,
15+
applyTemplates,
1516
chain,
1617
mergeWith,
1718
move,
18-
template,
1919
url,
2020
} from '@angular-devkit/schematics';
2121
import { getWorkspace, updateWorkspace } from '../utility/config';
@@ -127,7 +127,7 @@ export default function (options: E2eOptions): Rule {
127127
addAppToWorkspaceFile(options, workspace),
128128
mergeWith(
129129
apply(url('./files'), [
130-
template({
130+
applyTemplates({
131131
utils: strings,
132132
...options,
133133
'dot': '.',

packages/schematics/angular/enum/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ import {
1212
SchematicsException,
1313
Tree,
1414
apply,
15+
applyTemplates,
1516
branchAndMerge,
1617
chain,
1718
mergeWith,
1819
move,
1920
noop,
20-
template,
2121
url,
2222
} from '@angular-devkit/schematics';
2323
import { applyLintFix } from '../utility/lint-fix';
@@ -42,7 +42,7 @@ export default function (options: EnumOptions): Rule {
4242
options.path = parsedPath.path;
4343

4444
const templateSource = apply(url('./files'), [
45-
template({
45+
applyTemplates({
4646
...strings,
4747
...options,
4848
}),

packages/schematics/angular/guard/index.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ import {
1111
SchematicsException,
1212
Tree,
1313
apply,
14+
applyTemplates,
1415
branchAndMerge,
1516
chain,
1617
filter,
1718
mergeWith,
1819
move,
1920
noop,
20-
template,
2121
url,
2222
} from '@angular-devkit/schematics';
2323
import { applyLintFix } from '../utility/lint-fix';
@@ -59,8 +59,8 @@ export default function (options: GuardOptions): Rule {
5959
options.skipTests = options.skipTests || !options.spec;
6060

6161
const templateSource = apply(url('./files'), [
62-
options.skipTests ? filter(path => !path.endsWith('.spec.ts')) : noop(),
63-
template({
62+
options.skipTests ? filter(path => !path.endsWith('.spec.ts.template')) : noop(),
63+
applyTemplates({
6464
implementations,
6565
implementationImports,
6666
...strings,

packages/schematics/angular/interface/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ import {
1111
SchematicsException,
1212
Tree,
1313
apply,
14+
applyTemplates,
1415
branchAndMerge,
1516
chain,
1617
mergeWith,
1718
move,
1819
noop,
19-
template,
2020
url,
2121
} from '@angular-devkit/schematics';
2222
import { applyLintFix } from '../utility/lint-fix';
@@ -44,7 +44,7 @@ export default function (options: InterfaceOptions): Rule {
4444
options.type = !!options.type ? `.${options.type}` : '';
4545

4646
const templateSource = apply(url('./files'), [
47-
template({
47+
applyTemplates({
4848
...strings,
4949
...options,
5050
}),

packages/schematics/angular/library/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ import {
1212
SchematicsException,
1313
Tree,
1414
apply,
15+
applyTemplates,
1516
branchAndMerge,
1617
chain,
1718
mergeWith,
1819
noop,
1920
schematic,
20-
template,
2121
url,
2222
} from '@angular-devkit/schematics';
2323
import { NodePackageInstallTask } from '@angular-devkit/schematics/tasks';
@@ -204,7 +204,7 @@ export default function (options: LibraryOptions): Rule {
204204
const relativePathToWorkspaceRoot = projectRoot.split('/').map(x => '..').join('/');
205205

206206
const templateSource = apply(url('./files'), [
207-
template({
207+
applyTemplates({
208208
...strings,
209209
...options,
210210
packageName,

packages/schematics/angular/module/index.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ import {
1111
SchematicsException,
1212
Tree,
1313
apply,
14+
applyTemplates,
1415
branchAndMerge,
1516
chain,
1617
filter,
1718
mergeWith,
1819
move,
1920
noop,
20-
template,
2121
url,
2222
} from '@angular-devkit/schematics';
2323
import * as ts from 'typescript';
@@ -89,8 +89,8 @@ export default function (options: ModuleOptions): Rule {
8989
options.path = parsedPath.path;
9090

9191
const templateSource = apply(url('./files'), [
92-
options.routing ? noop() : filter(path => !path.endsWith('-routing.module.ts')),
93-
template({
92+
options.routing ? noop() : filter(path => !path.endsWith('-routing.module.ts.template')),
93+
applyTemplates({
9494
...strings,
9595
'if-flat': (s: string) => options.flat ? '' : s,
9696
...options,

packages/schematics/angular/pipe/index.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ import {
1111
SchematicsException,
1212
Tree,
1313
apply,
14+
applyTemplates,
1415
branchAndMerge,
1516
chain,
1617
filter,
1718
mergeWith,
1819
move,
1920
noop,
20-
template,
2121
url,
2222
} from '@angular-devkit/schematics';
2323
import * as ts from 'typescript';
@@ -106,8 +106,8 @@ export default function (options: PipeOptions): Rule {
106106
options.skipTests = options.skipTests || !options.spec;
107107

108108
const templateSource = apply(url('./files'), [
109-
options.skipTests ? filter(path => !path.endsWith('.spec.ts')) : noop(),
110-
template({
109+
options.skipTests ? filter(path => !path.endsWith('.spec.ts.template')) : noop(),
110+
applyTemplates({
111111
...strings,
112112
'if-flat': (s: string) => options.flat ? '' : s,
113113
...options,

packages/schematics/angular/service-worker/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ import {
1111
SchematicsException,
1212
Tree,
1313
apply,
14+
applyTemplates,
1415
chain,
1516
mergeWith,
1617
move,
17-
template,
1818
url,
1919
} from '@angular-devkit/schematics';
2020
import { NodePackageInstallTask } from '@angular-devkit/schematics/tasks';
@@ -176,7 +176,7 @@ export default function (options: ServiceWorkerOptions): Rule {
176176

177177
const root = project.root || project.sourceRoot || '';
178178
const templateSource = apply(url('./files'), [
179-
template({ ...options, resourcesOutputPath }),
179+
applyTemplates({ ...options, resourcesOutputPath }),
180180
move(root),
181181
]);
182182

packages/schematics/angular/service/index.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ import {
1111
SchematicsException,
1212
Tree,
1313
apply,
14+
applyTemplates,
1415
chain,
1516
filter,
1617
mergeWith,
1718
move,
1819
noop,
19-
template,
2020
url,
2121
} from '@angular-devkit/schematics';
2222
import { applyLintFix } from '../utility/lint-fix';
@@ -43,8 +43,8 @@ export default function (options: ServiceOptions): Rule {
4343
options.skipTests = options.skipTests || !options.spec;
4444

4545
const templateSource = apply(url('./files'), [
46-
options.skipTests ? filter(path => !path.endsWith('.spec.ts')) : noop(),
47-
template({
46+
options.skipTests ? filter(path => !path.endsWith('.spec.ts.template')) : noop(),
47+
applyTemplates({
4848
...strings,
4949
'if-flat': (s: string) => options.flat ? '' : s,
5050
...options,

packages/schematics/angular/universal/index.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ import {
2020
SchematicsException,
2121
Tree,
2222
apply,
23+
applyTemplates,
2324
chain,
2425
mergeWith,
2526
move,
26-
template,
2727
url,
2828
} from '@angular-devkit/schematics';
2929
import {
@@ -257,7 +257,7 @@ export default function (options: UniversalOptions): Rule {
257257
}
258258

259259
const templateSource = apply(url('./files/src'), [
260-
template({
260+
applyTemplates({
261261
...strings,
262262
...options as object,
263263
stripTsExtension: (s: string) => s.replace(/\.ts$/, ''),
@@ -266,7 +266,7 @@ export default function (options: UniversalOptions): Rule {
266266
]);
267267

268268
const rootSource = apply(url('./files/root'), [
269-
template({
269+
applyTemplates({
270270
...strings,
271271
...options as object,
272272
stripTsExtension: (s: string) => s.replace(/\.ts$/, ''),

0 commit comments

Comments
 (0)