-
Notifications
You must be signed in to change notification settings - Fork 12k
/
Copy pathfactory.ts
52 lines (48 loc) · 1.39 KB
/
factory.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import { strings } from '@angular-devkit/core';
import {
Rule,
apply,
applyTemplates,
mergeWith,
move,
partitionApplyMerge,
url,
} from '@angular-devkit/schematics';
import { NodePackageInstallTask } from '@angular-devkit/schematics/tasks';
import { Schema } from './schema';
export default function (options: Schema): Rule {
const schematicsVersion = require('@angular-devkit/schematics/package.json').version;
const coreVersion = require('@angular-devkit/core/package.json').version;
return (_, context) => {
context.addTask(
new NodePackageInstallTask({
workingDirectory: options.name,
packageManager: options.packageManager,
}),
);
return mergeWith(
apply(url('./files'), [
// The `package.json` name is kept to allow renovate to update the dependency versions
move('package.json', 'package.json.template'),
partitionApplyMerge(
(p) => !/\/src\/.*?\/files\//.test(p),
applyTemplates({
...options,
coreVersion,
schematicsVersion,
dot: '.',
dasherize: strings.dasherize,
}),
),
move(options.name),
]),
);
};
}