@nstudio/xplat 15.0.2 → 15.0.4-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/migrations/update-12-4-3/update-12-4-3.js +31 -33
- package/migrations/update-13-0-0/update-13-0-0.js +38 -40
- package/migrations.json +0 -66
- package/package.json +3 -3
- package/src/schematics/feature/index.spec.js +2 -2
- package/src/utils/ast.d.ts +4 -76
- package/src/utils/ast.js +19 -304
- package/src/utils/general.d.ts +35 -6
- package/src/utils/general.js +155 -11
- package/src/utils/versions.js +1 -1
- package/src/utils/xplat.js +16 -7
- package/migrations/update-10-2-0/update-10-2-0.d.ts +0 -2
- package/migrations/update-10-2-0/update-10-2-0.js +0 -11
- package/migrations/update-11-0-0/clean-old-dirs.d.ts +0 -2
- package/migrations/update-11-0-0/clean-old-dirs.js +0 -57
- package/migrations/update-11-0-0/update-11-0-0.d.ts +0 -5
- package/migrations/update-11-0-0/update-11-0-0.js +0 -594
- package/migrations/update-11-0-0/update-to-11-env-base.d.ts +0 -5
- package/migrations/update-11-0-0/update-to-11-env-base.js +0 -289
- package/migrations/update-11-0-0/update-to-11-imports.d.ts +0 -6
- package/migrations/update-11-0-0/update-to-11-imports.js +0 -173
@@ -1,57 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
const schematics_1 = require("@angular-devkit/schematics");
|
4
|
-
const xplat_utils_1 = require("@nstudio/xplat-utils");
|
5
|
-
const xplat_1 = require("@nstudio/xplat");
|
6
|
-
function default_1() {
|
7
|
-
return (0, schematics_1.chain)([
|
8
|
-
(0, xplat_utils_1.prerun)({
|
9
|
-
framework: 'angular',
|
10
|
-
}, true),
|
11
|
-
// cleanup old dirs
|
12
|
-
(tree, context) => {
|
13
|
-
try {
|
14
|
-
let deleteXplatFolder = true;
|
15
|
-
const nonSupportedPlatforms = [];
|
16
|
-
const xplatDir = tree.getDir('xplat');
|
17
|
-
if (xplatDir) {
|
18
|
-
for (const platform of xplatDir.subdirs) {
|
19
|
-
if (!xplat_utils_1.supportedPlatforms.includes(platform)) {
|
20
|
-
nonSupportedPlatforms.push(platform);
|
21
|
-
// user had manually created a non supported platform
|
22
|
-
// ensure entire xplat folder is not deleted
|
23
|
-
deleteXplatFolder = false;
|
24
|
-
}
|
25
|
-
}
|
26
|
-
}
|
27
|
-
if (deleteXplatFolder) {
|
28
|
-
tree.delete('xplat');
|
29
|
-
}
|
30
|
-
else {
|
31
|
-
// only delete supported platform folders
|
32
|
-
for (const platform of xplat_utils_1.supportedPlatforms) {
|
33
|
-
tree.delete(`xplat/${platform}`);
|
34
|
-
}
|
35
|
-
if (nonSupportedPlatforms.length) {
|
36
|
-
// note to user about the untouched custom folder
|
37
|
-
xplat_1.output.log({
|
38
|
-
title: `The following folders have been left alone. You may want to create a Nx library for them manually. The migration can only handle known supported platforms (${xplat_utils_1.supportedPlatforms.join(', ')}):`,
|
39
|
-
bodyLines: nonSupportedPlatforms.map((p) => `xplat/${p}`),
|
40
|
-
});
|
41
|
-
}
|
42
|
-
}
|
43
|
-
if (tree.exists('/testing/test.libs.ts') ||
|
44
|
-
tree.exists('/testing/jest.libs.config.js')) {
|
45
|
-
tree.delete('testing');
|
46
|
-
}
|
47
|
-
tree.delete('libs/core');
|
48
|
-
tree.delete('libs/features');
|
49
|
-
tree.delete('libs/scss');
|
50
|
-
tree.delete('libs/utils');
|
51
|
-
}
|
52
|
-
catch (err) { }
|
53
|
-
return tree;
|
54
|
-
},
|
55
|
-
]);
|
56
|
-
}
|
57
|
-
exports.default = default_1;
|
@@ -1,594 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
const schematics_1 = require("@angular-devkit/schematics");
|
4
|
-
const workspace_1 = require("@nrwl/workspace");
|
5
|
-
const xplat_utils_1 = require("@nstudio/xplat-utils");
|
6
|
-
const xplat_1 = require("@nstudio/xplat");
|
7
|
-
const path_1 = require("path");
|
8
|
-
const fs = require("fs");
|
9
|
-
const options = {};
|
10
|
-
const oldDirectoriesToMove = [];
|
11
|
-
const newDirectoriesToEmpty = [];
|
12
|
-
let platforms;
|
13
|
-
function default_1() {
|
14
|
-
return (0, schematics_1.chain)([
|
15
|
-
(0, xplat_utils_1.prerun)({
|
16
|
-
framework: 'angular',
|
17
|
-
}, true),
|
18
|
-
// generate new xplat libs
|
19
|
-
// NOTE: this did not work with Nx 11 -
|
20
|
-
// calling externalSchematic's from outside collections do not seem to work (not sure if expected or not from running Nx migrations)
|
21
|
-
// This may have worked better being split into a migration by itself with no other rules in the chain
|
22
|
-
// (tree: Tree, context: SchematicContext) => {
|
23
|
-
// platforms = getCurrentlyUsedPlatforms(tree);
|
24
|
-
// console.log('generating libs for platforms:', platforms);
|
25
|
-
// if (platforms.length) {
|
26
|
-
// return xplatAngular({
|
27
|
-
// platforms: platforms.join(','),
|
28
|
-
// framework: 'angular',
|
29
|
-
// npmScope: getNpmScope(),
|
30
|
-
// prefix: getPrefix(),
|
31
|
-
// skipFormat: true,
|
32
|
-
// useXplat: true,
|
33
|
-
// groupByName: getGroupByName(),
|
34
|
-
// });
|
35
|
-
// } else {
|
36
|
-
// return noop()(tree, context);
|
37
|
-
// }
|
38
|
-
// },
|
39
|
-
// clear the new libs and prepare to move existing into it
|
40
|
-
emptyNewStructure(),
|
41
|
-
// move old structure into new
|
42
|
-
moveOldStructureToNew(),
|
43
|
-
// update apps
|
44
|
-
updateAppConfigs(),
|
45
|
-
// update root deps
|
46
|
-
updateRootDeps(),
|
47
|
-
// cleanup gitignore
|
48
|
-
cleanupGitIgnore(),
|
49
|
-
// remove old nx projects
|
50
|
-
(tree) => {
|
51
|
-
const path = 'nx.json';
|
52
|
-
const nxJson = (0, xplat_utils_1.getJsonFromFile)(tree, path);
|
53
|
-
if (nxJson && nxJson.projects) {
|
54
|
-
delete nxJson.projects['libs'];
|
55
|
-
delete nxJson.projects['xplat'];
|
56
|
-
return (0, xplat_utils_1.updateJsonFile)(tree, path, nxJson);
|
57
|
-
}
|
58
|
-
else {
|
59
|
-
return (0, schematics_1.noop)();
|
60
|
-
}
|
61
|
-
},
|
62
|
-
// remove old workspace projects
|
63
|
-
(tree) => {
|
64
|
-
const workspacePath = (0, workspace_1.getWorkspacePath)(tree);
|
65
|
-
const workspaceJson = (0, xplat_utils_1.getJsonFromFile)(tree, workspacePath);
|
66
|
-
if (workspaceJson && workspaceJson.projects) {
|
67
|
-
delete workspaceJson.projects['libs'];
|
68
|
-
delete workspaceJson.projects['xplat'];
|
69
|
-
return (0, xplat_utils_1.updateJsonFile)(tree, workspacePath, workspaceJson);
|
70
|
-
}
|
71
|
-
else {
|
72
|
-
return (0, schematics_1.noop)();
|
73
|
-
}
|
74
|
-
},
|
75
|
-
// remove old tsconfig settings
|
76
|
-
(tree, context) => {
|
77
|
-
return (0, xplat_1.updateTsConfig)(tree, (tsConfig) => {
|
78
|
-
if (tsConfig) {
|
79
|
-
if (!tsConfig.compilerOptions) {
|
80
|
-
tsConfig.compilerOptions = {};
|
81
|
-
}
|
82
|
-
const npmScope = (0, xplat_utils_1.getNpmScope)();
|
83
|
-
delete tsConfig.compilerOptions.paths[`@${npmScope}/*`];
|
84
|
-
delete tsConfig.compilerOptions.paths[`@${npmScope}/electron`];
|
85
|
-
delete tsConfig.compilerOptions.paths[`@${npmScope}/electron/*`];
|
86
|
-
delete tsConfig.compilerOptions.paths[`@${npmScope}/ionic`];
|
87
|
-
delete tsConfig.compilerOptions.paths[`@${npmScope}/ionic/*`];
|
88
|
-
delete tsConfig.compilerOptions.paths[`@${npmScope}/nativescript`];
|
89
|
-
delete tsConfig.compilerOptions.paths[`@${npmScope}/nativescript/*`];
|
90
|
-
delete tsConfig.compilerOptions.paths[`@${npmScope}/web`];
|
91
|
-
delete tsConfig.compilerOptions.paths[`@${npmScope}/web/*`];
|
92
|
-
if (tsConfig.includes && tsConfig.includes.length) {
|
93
|
-
// find index of xplat entries
|
94
|
-
const xplatIndex = tsConfig.includes.findIndex((v) => v.indexOf('xplat') > -1);
|
95
|
-
if (xplatIndex > -1) {
|
96
|
-
tsConfig.includes.splice(xplatIndex, 1);
|
97
|
-
}
|
98
|
-
}
|
99
|
-
if (tsConfig.exclude && tsConfig.exclude.length) {
|
100
|
-
// find index of xplat entries
|
101
|
-
const xplatIndex = tsConfig.exclude.findIndex((v) => v.indexOf('nativescript') > -1);
|
102
|
-
if (xplatIndex > -1) {
|
103
|
-
tsConfig.exclude.splice(xplatIndex, 1);
|
104
|
-
}
|
105
|
-
}
|
106
|
-
}
|
107
|
-
});
|
108
|
-
},
|
109
|
-
]);
|
110
|
-
}
|
111
|
-
exports.default = default_1;
|
112
|
-
function emptyNewStructure() {
|
113
|
-
return (tree, context) => {
|
114
|
-
platforms = getCurrentlyUsedPlatforms(tree);
|
115
|
-
newDirectoriesToEmpty
|
116
|
-
.map((dir) => tree.getDir(dir))
|
117
|
-
.forEach((projectDir) => {
|
118
|
-
projectDir.visit((file) => {
|
119
|
-
// console.log('emptyNewStructure', ' DELETE ', file);
|
120
|
-
tree.delete(file);
|
121
|
-
});
|
122
|
-
});
|
123
|
-
return tree;
|
124
|
-
};
|
125
|
-
}
|
126
|
-
function moveOldStructureToNew() {
|
127
|
-
return (tree, context) => {
|
128
|
-
oldDirectoriesToMove
|
129
|
-
.map((dir) => tree.getDir(dir))
|
130
|
-
.forEach((projectDir) => {
|
131
|
-
projectDir.visit((file) => {
|
132
|
-
let moveTo;
|
133
|
-
let srcTarget = '/src';
|
134
|
-
if (file.indexOf('/scss') === -1) {
|
135
|
-
srcTarget += '/lib';
|
136
|
-
}
|
137
|
-
if (file.indexOf('/libs') === 0) {
|
138
|
-
const pathTarget = projectDir.path.split('/').pop();
|
139
|
-
moveTo = file.replace(projectDir.path, `/libs/xplat/${pathTarget}${srcTarget}`);
|
140
|
-
}
|
141
|
-
else if (file.indexOf('/xplat') === 0) {
|
142
|
-
if (file.indexOf('/plugins') > -1) {
|
143
|
-
moveTo = file.replace(projectDir.path, `/libs${projectDir.path}`);
|
144
|
-
}
|
145
|
-
else {
|
146
|
-
moveTo = file.replace(projectDir.path, `/libs${projectDir.path}${srcTarget}`);
|
147
|
-
}
|
148
|
-
}
|
149
|
-
// console.log('moveOldStructureToNew', ' rename ', file);
|
150
|
-
// console.log('moveOldStructureToNew', ' moveTo ', moveTo);
|
151
|
-
tree.rename(file, moveTo);
|
152
|
-
});
|
153
|
-
});
|
154
|
-
return tree;
|
155
|
-
};
|
156
|
-
}
|
157
|
-
function updateRootDeps() {
|
158
|
-
return (tree, context) => {
|
159
|
-
if (tree.exists('tsconfig.json')) {
|
160
|
-
tree.delete('tsconfig.json');
|
161
|
-
}
|
162
|
-
const packagePath = 'package.json';
|
163
|
-
const packageJson = (0, xplat_utils_1.getJsonFromFile)(tree, packagePath);
|
164
|
-
const npmScope = (0, xplat_utils_1.getNpmScope)();
|
165
|
-
delete packageJson.dependencies[`@${npmScope}/scss`];
|
166
|
-
packageJson.dependencies[`@${npmScope}/xplat-scss`] =
|
167
|
-
'file:libs/xplat/scss/src';
|
168
|
-
delete packageJson.devDependencies[`node-sass`];
|
169
|
-
packageJson.devDependencies['sass'] = '~1.30.0';
|
170
|
-
// look for file ref'd plugins from xplat and update path
|
171
|
-
for (const packageName of Object.keys(packageJson.dependencies)) {
|
172
|
-
const packageVersion = packageJson.dependencies[packageName];
|
173
|
-
if (packageVersion && packageVersion.indexOf('file:xplat') > -1) {
|
174
|
-
packageJson.dependencies[packageName] = packageVersion.replace('file:xplat', 'file:libs/xplat');
|
175
|
-
}
|
176
|
-
}
|
177
|
-
return (0, xplat_utils_1.updateJsonFile)(tree, packagePath, packageJson);
|
178
|
-
};
|
179
|
-
}
|
180
|
-
function updateAppConfigs() {
|
181
|
-
return (tree, context) => {
|
182
|
-
const webAppsPaths = (0, xplat_utils_1.getAppPaths)(tree, 'web');
|
183
|
-
for (const dirPath of webAppsPaths) {
|
184
|
-
const relativePath = dirPath
|
185
|
-
.split('/')
|
186
|
-
.filter((p) => !!p)
|
187
|
-
.map((p) => '..')
|
188
|
-
.join('/');
|
189
|
-
let customOptionsAppend = '';
|
190
|
-
if (tree.exists(`${dirPath}/tsconfig.json`)) {
|
191
|
-
const tsConfig = (0, xplat_utils_1.getJsonFromFile)(tree, `${dirPath}/tsconfig.json`);
|
192
|
-
if (tsConfig.angularCompilerOptions) {
|
193
|
-
customOptionsAppend = `,\n"angularCompilerOptions": ${JSON.stringify(tsConfig.angularCompilerOptions)}`;
|
194
|
-
}
|
195
|
-
}
|
196
|
-
(0, workspace_1.createOrUpdate)(tree, `${dirPath}/tsconfig.json`, `{
|
197
|
-
"extends": "${relativePath}/tsconfig.base.json",
|
198
|
-
"files": [],
|
199
|
-
"include": [],
|
200
|
-
"references": [
|
201
|
-
{
|
202
|
-
"path": "./tsconfig.app.json"
|
203
|
-
},
|
204
|
-
{
|
205
|
-
"path": "./tsconfig.spec.json"
|
206
|
-
},
|
207
|
-
{
|
208
|
-
"path": "./tsconfig.editor.json"
|
209
|
-
}
|
210
|
-
]
|
211
|
-
}`);
|
212
|
-
(0, workspace_1.createOrUpdate)(tree, `${dirPath}/tsconfig.app.json`, `{
|
213
|
-
"extends": "./tsconfig.json",
|
214
|
-
"compilerOptions": {
|
215
|
-
"outDir": "${relativePath}/dist/out-tsc",
|
216
|
-
"types": []
|
217
|
-
},
|
218
|
-
"files": [
|
219
|
-
"src/main.ts",
|
220
|
-
"src/polyfills.ts"
|
221
|
-
],
|
222
|
-
"include": [
|
223
|
-
"src/test.ts"
|
224
|
-
],
|
225
|
-
"exclude": [
|
226
|
-
"src/test-setup.ts",
|
227
|
-
"**/*.spec.ts"
|
228
|
-
]${customOptionsAppend}
|
229
|
-
}
|
230
|
-
`);
|
231
|
-
(0, workspace_1.createOrUpdate)(tree, `${dirPath}/tsconfig.editor.json`, `{
|
232
|
-
"extends": "./tsconfig.json",
|
233
|
-
"include": ["**/*.ts"],
|
234
|
-
"compilerOptions": {
|
235
|
-
"types": ["jest", "node"]
|
236
|
-
}
|
237
|
-
}
|
238
|
-
`);
|
239
|
-
(0, workspace_1.createOrUpdate)(tree, `${dirPath}/tsconfig.spec.json`, `{
|
240
|
-
"extends": "./tsconfig.json",
|
241
|
-
"compilerOptions": {
|
242
|
-
"outDir": "${relativePath}/dist/out-tsc",
|
243
|
-
"module": "commonjs",
|
244
|
-
"types": ["jest", "node"]
|
245
|
-
},
|
246
|
-
"files": ["src/test-setup.ts"],
|
247
|
-
"include": ["**/*.spec.ts", "**/*.d.ts"]
|
248
|
-
}
|
249
|
-
`);
|
250
|
-
}
|
251
|
-
const nativeScriptAppsPaths = (0, xplat_utils_1.getAppPaths)(tree, 'nativescript');
|
252
|
-
const npmScope = (0, xplat_utils_1.getNpmScope)();
|
253
|
-
// update {N} apps and configs
|
254
|
-
for (const dirPath of nativeScriptAppsPaths) {
|
255
|
-
// console.log(dir);
|
256
|
-
// console.log('{N} appDir:', dirPath);
|
257
|
-
const relativePath = dirPath
|
258
|
-
.split('/')
|
259
|
-
.filter((p) => !!p)
|
260
|
-
.map((p) => '..')
|
261
|
-
.join('/');
|
262
|
-
const cwd = process.cwd();
|
263
|
-
const webpackConfigPath = (0, path_1.join)(cwd, 'node_modules/@nstudio/nativescript-angular/src/schematics/application/_files/webpack.config.js');
|
264
|
-
// console.log('webpackConfigPath:', webpackConfigPath);
|
265
|
-
const webpackConfig = fs.readFileSync(webpackConfigPath, {
|
266
|
-
encoding: 'utf-8',
|
267
|
-
});
|
268
|
-
(0, workspace_1.createOrUpdate)(tree, `${dirPath}/webpack.config.js`, webpackConfig.replace('<%= pathOffset %>', relativePath));
|
269
|
-
// update {N} app deps
|
270
|
-
const packagePath = `${dirPath}/package.json`;
|
271
|
-
const packageJson = (0, xplat_utils_1.getJsonFromFile)(tree, packagePath);
|
272
|
-
if (packageJson) {
|
273
|
-
packageJson.dependencies = packageJson.dependencies || {};
|
274
|
-
delete packageJson.dependencies[`@${npmScope}/scss`];
|
275
|
-
delete packageJson.dependencies[`@${npmScope}/nativescript-scss`];
|
276
|
-
delete packageJson.dependencies[`@${npmScope}/nativescript`];
|
277
|
-
const updatedDeps = {};
|
278
|
-
updatedDeps[`@${npmScope}/xplat-nativescript-scss`] = `file:${relativePath}/libs/xplat/nativescript/scss/src`;
|
279
|
-
updatedDeps[`@${npmScope}/xplat-scss`] = `file:${relativePath}/libs/xplat/scss/src`;
|
280
|
-
packageJson.dependencies = Object.assign(Object.assign({}, packageJson.dependencies), updatedDeps);
|
281
|
-
// look for file ref'd plugins from xplat and update path
|
282
|
-
for (const packageName of Object.keys(packageJson.dependencies)) {
|
283
|
-
const packageVersion = packageJson.dependencies[packageName];
|
284
|
-
if (packageVersion && packageVersion.indexOf('../xplat') > -1) {
|
285
|
-
packageJson.dependencies[packageName] = packageVersion.replace('../xplat', '../libs/xplat');
|
286
|
-
}
|
287
|
-
}
|
288
|
-
// console.log('path:',path);
|
289
|
-
// console.log('packageJson overwrite:', JSON.stringify(packageJson));
|
290
|
-
tree = (0, xplat_utils_1.updateJsonFile)(tree, packagePath, packageJson);
|
291
|
-
}
|
292
|
-
const gitIgnorePath = `${dirPath}/.gitignore`;
|
293
|
-
let gitIgnore = tree.get(gitIgnorePath).content.toString();
|
294
|
-
if (gitIgnore) {
|
295
|
-
gitIgnore = gitIgnore.replace('*.js', '*.js\n!jest.config.js');
|
296
|
-
tree.overwrite(gitIgnorePath, gitIgnore);
|
297
|
-
}
|
298
|
-
if (tree.exists(`${dirPath}/src/app.android.scss`)) {
|
299
|
-
let scssUpdate = tree
|
300
|
-
.read(`${dirPath}/src/app.android.scss`)
|
301
|
-
.toString('utf-8');
|
302
|
-
scssUpdate = scssUpdate.replace('/nativescript-scss', '/xplat-nativescript-scss');
|
303
|
-
(0, workspace_1.createOrUpdate)(tree, `${dirPath}/src/app.android.scss`, scssUpdate);
|
304
|
-
}
|
305
|
-
if (tree.exists(`${dirPath}/src/app.ios.scss`)) {
|
306
|
-
let scssUpdate = tree
|
307
|
-
.read(`${dirPath}/src/app.ios.scss`)
|
308
|
-
.toString('utf-8');
|
309
|
-
scssUpdate = scssUpdate.replace('/nativescript-scss', '/xplat-nativescript-scss');
|
310
|
-
(0, workspace_1.createOrUpdate)(tree, `${dirPath}/src/app.ios.scss`, scssUpdate);
|
311
|
-
}
|
312
|
-
if (tree.exists(`${dirPath}/tsconfig.env.json`)) {
|
313
|
-
tree.delete(`${dirPath}/tsconfig.env.json`);
|
314
|
-
}
|
315
|
-
(0, workspace_1.createOrUpdate)(tree, `${dirPath}/tsconfig.app.json`, `{
|
316
|
-
"extends": "./tsconfig.json",
|
317
|
-
"compilerOptions": {
|
318
|
-
"outDir": "${relativePath}/dist/out-tsc",
|
319
|
-
"types": []
|
320
|
-
},
|
321
|
-
"files": [
|
322
|
-
"./references.d.ts",
|
323
|
-
"./src/main.ts"
|
324
|
-
]
|
325
|
-
}`);
|
326
|
-
(0, workspace_1.createOrUpdate)(tree, `${dirPath}/tsconfig.editor.json`, `{
|
327
|
-
"extends": "./tsconfig.json",
|
328
|
-
"include": ["**/*.ts"],
|
329
|
-
"compilerOptions": {
|
330
|
-
"types": ["jest", "node"]
|
331
|
-
}
|
332
|
-
}
|
333
|
-
`);
|
334
|
-
(0, workspace_1.createOrUpdate)(tree, `${dirPath}/tsconfig.json`, `{
|
335
|
-
"extends": "${relativePath}/tsconfig.base.json",
|
336
|
-
"files": [],
|
337
|
-
"include": [],
|
338
|
-
"references": [
|
339
|
-
{
|
340
|
-
"path": "./tsconfig.app.json"
|
341
|
-
},
|
342
|
-
{
|
343
|
-
"path": "./tsconfig.spec.json"
|
344
|
-
},
|
345
|
-
{
|
346
|
-
"path": "./tsconfig.editor.json"
|
347
|
-
}
|
348
|
-
]
|
349
|
-
}
|
350
|
-
`);
|
351
|
-
(0, workspace_1.createOrUpdate)(tree, `${dirPath}/tsconfig.spec.json`, `{
|
352
|
-
"extends": "./tsconfig.json",
|
353
|
-
"compilerOptions": {
|
354
|
-
"outDir": "${relativePath}/dist/out-tsc",
|
355
|
-
"module": "commonjs",
|
356
|
-
"types": ["jest", "node"]
|
357
|
-
},
|
358
|
-
"files": ["src/test-setup.ts"],
|
359
|
-
"include": ["**/*.spec.ts", "**/*.d.ts"]
|
360
|
-
}
|
361
|
-
`);
|
362
|
-
(0, workspace_1.createOrUpdate)(tree, `${dirPath}/src/test-setup.ts`, `import 'jest-preset-angular';`);
|
363
|
-
(0, workspace_1.createOrUpdate)(tree, `${dirPath}/references.d.ts`, `/// <reference path="${relativePath}/references.d.ts" />`);
|
364
|
-
(0, workspace_1.createOrUpdate)(tree, `${dirPath}/jest.config.js`, `module.exports = {
|
365
|
-
preset: '${relativePath}/jest.preset.js',
|
366
|
-
setupFilesAfterEnv: ['<rootDir>/src/test-setup.ts'],
|
367
|
-
globals: {
|
368
|
-
'ts-jest': {
|
369
|
-
tsConfig: '<rootDir>/tsconfig.spec.json',
|
370
|
-
stringifyContentPathRegex: '\\.(html|svg)$',
|
371
|
-
astTransformers: [
|
372
|
-
'jest-preset-angular/build/InlineFilesTransformer',
|
373
|
-
'jest-preset-angular/build/StripStylesTransformer'
|
374
|
-
]
|
375
|
-
}
|
376
|
-
},
|
377
|
-
coverageDirectory: '${relativePath}/coverage${dirPath}',
|
378
|
-
snapshotSerializers: [
|
379
|
-
'jest-preset-angular/build/AngularNoNgAttributesSnapshotSerializer.js',
|
380
|
-
'jest-preset-angular/build/AngularSnapshotSerializer.js',
|
381
|
-
'jest-preset-angular/build/HTMLCommentSerializer.js'
|
382
|
-
],
|
383
|
-
displayName: '${dirPath.split('/').pop()}'
|
384
|
-
};
|
385
|
-
`);
|
386
|
-
(0, workspace_1.createOrUpdate)(tree, `${dirPath}/.eslintrc.json`, `{
|
387
|
-
"extends": "${relativePath}/.eslintrc.json",
|
388
|
-
"ignorePatterns": [
|
389
|
-
"!**/*"
|
390
|
-
],
|
391
|
-
"overrides": [
|
392
|
-
{
|
393
|
-
"files": [
|
394
|
-
"*.ts"
|
395
|
-
],
|
396
|
-
"extends": [
|
397
|
-
"plugin:@nrwl/nx/angular",
|
398
|
-
"plugin:@angular-eslint/template/process-inline-templates"
|
399
|
-
],
|
400
|
-
"parserOptions": {
|
401
|
-
"project": [
|
402
|
-
"${dirPath}/tsconfig.*?.json"
|
403
|
-
]
|
404
|
-
},
|
405
|
-
"rules": {
|
406
|
-
"@angular-eslint/directive-selector": [
|
407
|
-
"error",
|
408
|
-
{
|
409
|
-
"type": "attribute",
|
410
|
-
"prefix": "nar",
|
411
|
-
"style": "camelCase"
|
412
|
-
}
|
413
|
-
],
|
414
|
-
"@angular-eslint/component-selector": [
|
415
|
-
"error",
|
416
|
-
{
|
417
|
-
"type": "element",
|
418
|
-
"prefix": "nar",
|
419
|
-
"style": "kebab-case"
|
420
|
-
}
|
421
|
-
]
|
422
|
-
}
|
423
|
-
},
|
424
|
-
{
|
425
|
-
"files": [
|
426
|
-
"*.html"
|
427
|
-
],
|
428
|
-
"extends": [
|
429
|
-
"plugin:@nrwl/nx/angular-template"
|
430
|
-
],
|
431
|
-
"rules": {}
|
432
|
-
}
|
433
|
-
]
|
434
|
-
}
|
435
|
-
`);
|
436
|
-
}
|
437
|
-
return tree;
|
438
|
-
};
|
439
|
-
}
|
440
|
-
function cleanupGitIgnore() {
|
441
|
-
return (tree) => {
|
442
|
-
const gitIgnorePath = '.gitignore';
|
443
|
-
let gitIgnore = tree.get(gitIgnorePath).content.toString();
|
444
|
-
if (gitIgnore) {
|
445
|
-
gitIgnore = gitIgnore.replace('# libs', '');
|
446
|
-
gitIgnore = gitIgnore.replace('libs/**/*.js', '');
|
447
|
-
gitIgnore = gitIgnore.replace('libs/**/*.map', '');
|
448
|
-
gitIgnore = gitIgnore.replace('libs/**/*.d.ts', '');
|
449
|
-
gitIgnore = gitIgnore.replace('libs/**/*.metadata.json', '');
|
450
|
-
gitIgnore = gitIgnore.replace('libs/**/*.ngfactory.ts', '');
|
451
|
-
gitIgnore = gitIgnore.replace('libs/**/*.ngsummary.json', '');
|
452
|
-
gitIgnore = gitIgnore.replace('xplat/**/*.js', '');
|
453
|
-
gitIgnore = gitIgnore.replace('xplat/**/*.map', '');
|
454
|
-
gitIgnore = gitIgnore.replace('xplat/**/*.d.ts', '');
|
455
|
-
gitIgnore = gitIgnore.replace('xplat/**/*.metadata.json', '');
|
456
|
-
gitIgnore = gitIgnore.replace('xplat/**/*.ngfactory.ts', '');
|
457
|
-
gitIgnore = gitIgnore.replace('xplat/**/*.ngsummary.json', '');
|
458
|
-
}
|
459
|
-
return (0, xplat_utils_1.updateFile)(tree, gitIgnorePath, gitIgnore);
|
460
|
-
};
|
461
|
-
}
|
462
|
-
function getCurrentlyUsedPlatforms(tree) {
|
463
|
-
const platforms = [];
|
464
|
-
if (tree.exists('/libs/core/index.ts') &&
|
465
|
-
tree.exists('/libs/features/index.ts')) {
|
466
|
-
const npmScope = (0, xplat_utils_1.getNpmScope)();
|
467
|
-
if (!oldDirectoriesToMove.includes('/libs/core')) {
|
468
|
-
oldDirectoriesToMove.push('/libs/core');
|
469
|
-
newDirectoriesToEmpty.push('/libs/xplat/core/src/lib');
|
470
|
-
}
|
471
|
-
if (!oldDirectoriesToMove.includes('/libs/features')) {
|
472
|
-
oldDirectoriesToMove.push('/libs/features');
|
473
|
-
newDirectoriesToEmpty.push('/libs/xplat/features/src/lib');
|
474
|
-
}
|
475
|
-
if (!oldDirectoriesToMove.includes('/libs/scss')) {
|
476
|
-
oldDirectoriesToMove.push('/libs/scss');
|
477
|
-
newDirectoriesToEmpty.push('/libs/xplat/scss/src');
|
478
|
-
(0, workspace_1.createOrUpdate)(tree, `/libs/scss/package.json`, `{
|
479
|
-
"name": "@${npmScope}/xplat-scss",
|
480
|
-
"version": "1.0.0"
|
481
|
-
}`);
|
482
|
-
}
|
483
|
-
if (!oldDirectoriesToMove.includes('/libs/utils')) {
|
484
|
-
oldDirectoriesToMove.push('/libs/utils');
|
485
|
-
newDirectoriesToEmpty.push('/libs/xplat/utils/src/lib');
|
486
|
-
}
|
487
|
-
// collect which platforms were currently used
|
488
|
-
if (tree.exists('/xplat/electron/index.ts')) {
|
489
|
-
if (!platforms.includes('electron')) {
|
490
|
-
platforms.push('electron');
|
491
|
-
}
|
492
|
-
if (!oldDirectoriesToMove.includes('/xplat/electron')) {
|
493
|
-
oldDirectoriesToMove.push('/xplat/electron');
|
494
|
-
newDirectoriesToEmpty.push('/libs/xplat/electron/core/src/lib');
|
495
|
-
}
|
496
|
-
}
|
497
|
-
if (tree.exists('/xplat/ionic/index.ts')) {
|
498
|
-
if (!platforms.includes('ionic')) {
|
499
|
-
platforms.push('ionic');
|
500
|
-
}
|
501
|
-
if (!oldDirectoriesToMove.includes('/xplat/ionic/core')) {
|
502
|
-
oldDirectoriesToMove.push('/xplat/ionic/core');
|
503
|
-
newDirectoriesToEmpty.push('/libs/xplat/ionic/core/src/lib');
|
504
|
-
}
|
505
|
-
if (!oldDirectoriesToMove.includes('/xplat/ionic/features')) {
|
506
|
-
oldDirectoriesToMove.push('/xplat/ionic/features');
|
507
|
-
newDirectoriesToEmpty.push('/libs/xplat/ionic/features/src/lib');
|
508
|
-
}
|
509
|
-
if (!oldDirectoriesToMove.includes('/xplat/ionic/scss')) {
|
510
|
-
oldDirectoriesToMove.push('/xplat/ionic/scss');
|
511
|
-
newDirectoriesToEmpty.push('/libs/xplat/ionic/scss/src');
|
512
|
-
(0, workspace_1.createOrUpdate)(tree, `/xplat/ionic/scss/package.json`, `{
|
513
|
-
"name": "@${npmScope}/xplat-ionic-scss",
|
514
|
-
"version": "1.0.0"
|
515
|
-
}`);
|
516
|
-
if (tree.exists(`/xplat/ionic/scss/_index.scss`)) {
|
517
|
-
let scssUpdate = tree
|
518
|
-
.read(`/xplat/ionic/scss/_index.scss`)
|
519
|
-
.toString('utf-8');
|
520
|
-
scssUpdate = scssUpdate.replace(`@${npmScope}/scss/index`, `@${npmScope}/xplat-scss/index`);
|
521
|
-
(0, workspace_1.createOrUpdate)(tree, `/xplat/ionic/scss/_index.scss`, scssUpdate);
|
522
|
-
}
|
523
|
-
}
|
524
|
-
}
|
525
|
-
if (tree.exists('/xplat/nativescript/index.ts')) {
|
526
|
-
if (!platforms.includes('nativescript')) {
|
527
|
-
platforms.push('nativescript');
|
528
|
-
}
|
529
|
-
if (!oldDirectoriesToMove.includes('/xplat/nativescript/core')) {
|
530
|
-
oldDirectoriesToMove.push('/xplat/nativescript/core');
|
531
|
-
newDirectoriesToEmpty.push('/libs/xplat/nativescript/core/src/lib');
|
532
|
-
}
|
533
|
-
if (!oldDirectoriesToMove.includes('/xplat/nativescript/features')) {
|
534
|
-
oldDirectoriesToMove.push('/xplat/nativescript/features');
|
535
|
-
newDirectoriesToEmpty.push('/libs/xplat/nativescript/features/src/lib');
|
536
|
-
}
|
537
|
-
if (!oldDirectoriesToMove.includes('/xplat/nativescript/plugins')) {
|
538
|
-
oldDirectoriesToMove.push('/xplat/nativescript/plugins');
|
539
|
-
}
|
540
|
-
if (!oldDirectoriesToMove.includes('/xplat/nativescript/scss')) {
|
541
|
-
oldDirectoriesToMove.push('/xplat/nativescript/scss');
|
542
|
-
newDirectoriesToEmpty.push('/libs/xplat/nativescript/scss/src');
|
543
|
-
(0, workspace_1.createOrUpdate)(tree, `/xplat/nativescript/scss/package.json`, `{
|
544
|
-
"name": "@${npmScope}/xplat-nativescript-scss",
|
545
|
-
"version": "1.0.0"
|
546
|
-
}`);
|
547
|
-
if (tree.exists(`/xplat/nativescript/scss/_common.scss`)) {
|
548
|
-
let scssUpdate = tree
|
549
|
-
.read(`/xplat/nativescript/scss/_common.scss`)
|
550
|
-
.toString('utf-8');
|
551
|
-
scssUpdate = scssUpdate.replace(`@${npmScope}/scss/index`, `@${npmScope}/xplat-scss/index`);
|
552
|
-
(0, workspace_1.createOrUpdate)(tree, `/xplat/nativescript/scss/_common.scss`, scssUpdate);
|
553
|
-
}
|
554
|
-
}
|
555
|
-
if (!oldDirectoriesToMove.includes('/xplat/nativescript/utils')) {
|
556
|
-
oldDirectoriesToMove.push('/xplat/nativescript/utils');
|
557
|
-
newDirectoriesToEmpty.push('/libs/xplat/nativescript/utils/src/lib');
|
558
|
-
}
|
559
|
-
}
|
560
|
-
if (tree.exists('/xplat/web/index.ts')) {
|
561
|
-
if (!platforms.includes('web')) {
|
562
|
-
platforms.push('web');
|
563
|
-
}
|
564
|
-
if (!oldDirectoriesToMove.includes('/xplat/web/core')) {
|
565
|
-
oldDirectoriesToMove.push('/xplat/web/core');
|
566
|
-
newDirectoriesToEmpty.push('/libs/xplat/web/core/src/lib');
|
567
|
-
}
|
568
|
-
if (!oldDirectoriesToMove.includes('/xplat/web/features')) {
|
569
|
-
oldDirectoriesToMove.push('/xplat/web/features');
|
570
|
-
newDirectoriesToEmpty.push('/libs/xplat/web/features/src/lib');
|
571
|
-
}
|
572
|
-
if (!oldDirectoriesToMove.includes('/xplat/web/plugins')) {
|
573
|
-
oldDirectoriesToMove.push('/xplat/web/plugins');
|
574
|
-
}
|
575
|
-
if (!oldDirectoriesToMove.includes('/xplat/web/scss')) {
|
576
|
-
oldDirectoriesToMove.push('/xplat/web/scss');
|
577
|
-
newDirectoriesToEmpty.push('/libs/xplat/web/scss/src');
|
578
|
-
(0, workspace_1.createOrUpdate)(tree, `/xplat/web/scss/package.json`, `{
|
579
|
-
"name": "@${npmScope}/xplat-web-scss",
|
580
|
-
"version": "1.0.0"
|
581
|
-
}`);
|
582
|
-
if (tree.exists(`/xplat/web/scss/_index.scss`)) {
|
583
|
-
let scssUpdate = tree
|
584
|
-
.read(`/xplat/web/scss/_index.scss`)
|
585
|
-
.toString('utf-8');
|
586
|
-
scssUpdate = scssUpdate.replace(`@${npmScope}/scss/index`, `@${npmScope}/xplat-scss/index`);
|
587
|
-
(0, workspace_1.createOrUpdate)(tree, `/xplat/web/scss/_index.scss`, scssUpdate);
|
588
|
-
}
|
589
|
-
}
|
590
|
-
}
|
591
|
-
return platforms;
|
592
|
-
}
|
593
|
-
return platforms;
|
594
|
-
}
|
@@ -1,5 +0,0 @@
|
|
1
|
-
import { Rule, SchematicContext, Tree } from '@angular-devkit/schematics';
|
2
|
-
export default function (): Rule;
|
3
|
-
export declare function addEnvBase(): (tree: Tree, _context: SchematicContext) => void;
|
4
|
-
export declare function updateEnvsForNativeScript(): (tree: Tree, _context: SchematicContext) => void;
|
5
|
-
export declare function updateWorkspaceFileReplacements(): (tree: Tree, _context: SchematicContext) => import("@angular-devkit/schematics/src/tree/interface").Tree | Rule;
|