/
index.ts
53 lines (52 loc) · 1.29 KB
/
index.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
53
import {
chain,
externalSchematic,
branchAndMerge,
SchematicContext,
Tree,
noop,
mergeWith,
apply,
url,
move,
template
} from '@angular-devkit/schematics';
import {
XplatHelpers,
prerun,
getDefaultTemplateOptions
} from '@nstudio/xplat';
import { XplatWebHelpers } from '../../utils/xplat';
export default function(options: XplatHelpers.Schema) {
return chain([
prerun(options),
(tree: Tree, context: SchematicContext) => {
if (tree.exists('/libs/scss/_index.scss')) {
// may have already generated support
return noop()(tree, context);
} else {
return branchAndMerge(
mergeWith(
apply(url(`./_lib_files`), [
template({
...(options as any),
...getDefaultTemplateOptions()
}),
move(`libs`)
])
)
)(tree, context);
}
},
(tree: Tree, context: SchematicContext) => {
if (tree.exists('/xplat/web/scss/_index.scss')) {
// may have already generated support
return noop()(tree, context);
} else {
return XplatHelpers.addPlatformFiles(options, 'web')(tree, context);
}
},
XplatHelpers.updateTsConfigPaths(options),
XplatWebHelpers.updateRootDeps(options)
]);
}