@nstudio/xplat 15.0.3 → 15.0.4-rc.1

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/README.md CHANGED
@@ -42,10 +42,12 @@ You are now ready to create apps:
42
42
  nx g app
43
43
  ```
44
44
 
45
- **NOTE:** If you encounter any issue, you can try creating an Nx workspace with version specified, for example:
45
+ **NOTE:** If you encounter any issue, you can try creating an Nx workspace with a version specified.
46
+
47
+ We have tested with the following, for example:
46
48
 
47
49
  ```
48
- npx create-nx-workspace@14.1.7
50
+ npx create-nx-workspace@15.9.2
49
51
  ```
50
52
 
51
53
  ## App generation examples
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const schematics_1 = require("@angular-devkit/schematics");
4
4
  const path_1 = require("path");
5
5
  const fs = require("fs");
6
- const workspace_1 = require("@nrwl/workspace");
7
6
  const xplat_1 = require("@nstudio/xplat");
8
7
  const xplat_utils_1 = require("@nstudio/xplat-utils");
9
8
  const angularVersion = '^12.0.0';
@@ -54,7 +53,7 @@ function updateNativeScriptApps(tree, context) {
54
53
  const webpackConfig = fs.readFileSync(webpackConfigPath, {
55
54
  encoding: 'utf-8',
56
55
  });
57
- (0, workspace_1.createOrUpdate)(tree, `${dirPath}/webpack.config.js`, webpackConfig
56
+ (0, xplat_utils_1.updateFile)(tree, `${dirPath}/webpack.config.js`, webpackConfig
58
57
  .replace(/<%= pathOffset %>/gi, relativePath + '/')
59
58
  .replace(/<%= npmScope %>/gi, npmScope));
60
59
  // update {N} app deps
@@ -101,7 +100,7 @@ function updateNativeScriptApps(tree, context) {
101
100
  if (tree.exists(`${dirPath}/tsconfig.tns.json`)) {
102
101
  tree.delete(`${dirPath}/tsconfig.tns.json`);
103
102
  }
104
- (0, workspace_1.createOrUpdate)(tree, `${dirPath}/tools/xplat-postinstall.js`, `//#!/usr/bin/env node
103
+ (0, xplat_utils_1.updateFile)(tree, `${dirPath}/tools/xplat-postinstall.js`, `//#!/usr/bin/env node
105
104
 
106
105
  const fs = require('fs-extra');
107
106
  const path = require('path');
@@ -125,7 +124,7 @@ child.on('close', (code) => {
125
124
 
126
125
  });
127
126
  `);
128
- (0, workspace_1.createOrUpdate)(tree, `${dirPath}/tsconfig.app.json`, `{
127
+ (0, xplat_utils_1.updateFile)(tree, `${dirPath}/tsconfig.app.json`, `{
129
128
  "extends": "./tsconfig.json",
130
129
  "compilerOptions": {
131
130
  "outDir": "${relativePath}/dist/out-tsc",
@@ -141,7 +140,7 @@ child.on('close', (code) => {
141
140
  "./src/polyfills.ts"
142
141
  ]
143
142
  }`);
144
- (0, workspace_1.createOrUpdate)(tree, `${dirPath}/tsconfig.editor.json`, `{
143
+ (0, xplat_utils_1.updateFile)(tree, `${dirPath}/tsconfig.editor.json`, `{
145
144
  "extends": "./tsconfig.json",
146
145
  "include": ["**/*.ts"],
147
146
  "compilerOptions": {
@@ -149,7 +148,7 @@ child.on('close', (code) => {
149
148
  }
150
149
  }
151
150
  `);
152
- (0, workspace_1.createOrUpdate)(tree, `${dirPath}/tsconfig.json`, `{
151
+ (0, xplat_utils_1.updateFile)(tree, `${dirPath}/tsconfig.json`, `{
153
152
  "extends": "${relativePath}/tsconfig.base.json",
154
153
  "files": [],
155
154
  "include": [],
@@ -166,7 +165,7 @@ child.on('close', (code) => {
166
165
  ]
167
166
  }
168
167
  `);
169
- (0, workspace_1.createOrUpdate)(tree, `${dirPath}/tsconfig.spec.json`, `{
168
+ (0, xplat_utils_1.updateFile)(tree, `${dirPath}/tsconfig.spec.json`, `{
170
169
  "extends": "./tsconfig.json",
171
170
  "compilerOptions": {
172
171
  "outDir": "${relativePath}/dist/out-tsc",
@@ -177,8 +176,8 @@ child.on('close', (code) => {
177
176
  "include": ["**/*.spec.ts", "**/*.d.ts"]
178
177
  }
179
178
  `);
180
- (0, workspace_1.createOrUpdate)(tree, `${dirPath}/src/test-setup.ts`, `import 'jest-preset-angular';`);
181
- (0, workspace_1.createOrUpdate)(tree, `${dirPath}/src/polyfills.ts`, `/**
179
+ (0, xplat_utils_1.updateFile)(tree, `${dirPath}/src/test-setup.ts`, `import 'jest-preset-angular';`);
180
+ (0, xplat_utils_1.updateFile)(tree, `${dirPath}/src/polyfills.ts`, `/**
182
181
  * NativeScript Polyfills
183
182
  */
184
183
 
@@ -199,7 +198,7 @@ import 'zone.js';
199
198
  // Add NativeScript specific Zone JS patches
200
199
  import '@nativescript/zone-js';
201
200
  `);
202
- (0, workspace_1.createOrUpdate)(tree, `${dirPath}/.eslintrc.json`, `{
201
+ (0, xplat_utils_1.updateFile)(tree, `${dirPath}/.eslintrc.json`, `{
203
202
  "extends": "${relativePath}/.eslintrc.json",
204
203
  "ignorePatterns": [
205
204
  "!**/*"
@@ -264,29 +263,28 @@ import '@nativescript/zone-js';
264
263
  return tree;
265
264
  }
266
265
  function updateRootPackage(tree, context) {
267
- return (0, workspace_1.updateJsonInTree)('package.json', (json) => {
268
- json.scripts = json.scripts || {};
269
- const nativeScriptDeps = {
270
- '@nativescript/angular': nsNgScopedVersion,
271
- '@nativescript/core': nsCoreVersion,
272
- };
273
- const nativeScriptDevDeps = {
274
- '@nativescript/types': nsCoreVersion,
275
- '@nativescript/webpack': nsWebpackVersion,
276
- };
277
- json.scripts.clean =
278
- 'npx rimraf hooks node_modules package-lock.json && yarn config set ignore-engines true && yarn';
279
- json.dependencies = json.dependencies || {};
280
- json.dependencies = Object.assign(Object.assign(Object.assign(Object.assign({}, json.dependencies), ngDeps), (hasNativeScriptApps ? nativeScriptDeps : {})), { '@ngx-translate/core': ngxTranslateVersion, rxjs: rxjsVersion, 'zone.js': zoneJsVersion });
281
- delete json.dependencies['nativescript-angular'];
282
- delete json.dependencies['tns-core-modules'];
283
- delete json.devDependencies['tns-core-modules'];
284
- delete json.dependencies['tns-platform-declarations'];
285
- delete json.devDependencies['tns-platform-declarations'];
286
- json.devDependencies = json.devDependencies || {};
287
- json.devDependencies = Object.assign(Object.assign(Object.assign(Object.assign({}, json.devDependencies), { '@angular-devkit/architect': '^0.1200.0', '@angular-devkit/build-angular': angularVersion, '@angular-devkit/core': angularVersion, '@angular-devkit/schematics': angularVersion, '@angular/compiler-cli': angularVersion, '@angular/language-service': angularVersion }), (hasNativeScriptApps ? nativeScriptDevDeps : {})), { typescript: typescriptVersion });
288
- return json;
289
- })(tree, context);
266
+ const json = (0, xplat_utils_1.getJsonFromFile)(tree, 'package.json');
267
+ json.scripts = json.scripts || {};
268
+ const nativeScriptDeps = {
269
+ '@nativescript/angular': nsNgScopedVersion,
270
+ '@nativescript/core': nsCoreVersion,
271
+ };
272
+ const nativeScriptDevDeps = {
273
+ '@nativescript/types': nsCoreVersion,
274
+ '@nativescript/webpack': nsWebpackVersion,
275
+ };
276
+ json.scripts.clean =
277
+ 'npx rimraf hooks node_modules package-lock.json && yarn config set ignore-engines true && yarn';
278
+ json.dependencies = json.dependencies || {};
279
+ json.dependencies = Object.assign(Object.assign(Object.assign(Object.assign({}, json.dependencies), ngDeps), (hasNativeScriptApps ? nativeScriptDeps : {})), { '@ngx-translate/core': ngxTranslateVersion, rxjs: rxjsVersion, 'zone.js': zoneJsVersion });
280
+ delete json.dependencies['nativescript-angular'];
281
+ delete json.dependencies['tns-core-modules'];
282
+ delete json.devDependencies['tns-core-modules'];
283
+ delete json.dependencies['tns-platform-declarations'];
284
+ delete json.devDependencies['tns-platform-declarations'];
285
+ json.devDependencies = json.devDependencies || {};
286
+ json.devDependencies = Object.assign(Object.assign(Object.assign(Object.assign({}, json.devDependencies), { '@angular-devkit/architect': '^0.1200.0', '@angular-devkit/build-angular': angularVersion, '@angular-devkit/core': angularVersion, '@angular-devkit/schematics': angularVersion, '@angular/compiler-cli': angularVersion, '@angular/language-service': angularVersion }), (hasNativeScriptApps ? nativeScriptDevDeps : {})), { typescript: typescriptVersion });
287
+ return (0, xplat_utils_1.updateJsonFile)(tree, 'package.json', json);
290
288
  }
291
289
  function default_1() {
292
290
  return (0, schematics_1.chain)([
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const schematics_1 = require("@angular-devkit/schematics");
4
- const workspace_1 = require("@nrwl/workspace");
5
4
  const xplat_1 = require("@nstudio/xplat");
6
5
  const xplat_utils_1 = require("@nstudio/xplat-utils");
7
6
  const angularVersion = '^12.2.0';
@@ -71,7 +70,7 @@ function updateNativeScriptApps(tree, context) {
71
70
  if (tree.exists(`${dirPath}/tsconfig.tns.json`)) {
72
71
  tree.delete(`${dirPath}/tsconfig.tns.json`);
73
72
  }
74
- (0, workspace_1.createOrUpdate)(tree, `${dirPath}/tools/xplat-postinstall.js`, `//#!/usr/bin/env node
73
+ (0, xplat_utils_1.updateFile)(tree, `${dirPath}/tools/xplat-postinstall.js`, `//#!/usr/bin/env node
75
74
 
76
75
  const fs = require('fs-extra');
77
76
  const path = require('path');
@@ -111,7 +110,7 @@ child.stdout.on('data', function (data) {
111
110
  });
112
111
 
113
112
  `);
114
- (0, workspace_1.createOrUpdate)(tree, `${dirPath}/tsconfig.app.json`, `{
113
+ (0, xplat_utils_1.updateFile)(tree, `${dirPath}/tsconfig.app.json`, `{
115
114
  "extends": "./tsconfig.json",
116
115
  "compilerOptions": {
117
116
  "outDir": "${relativePath}/dist/out-tsc",
@@ -127,7 +126,7 @@ child.stdout.on('data', function (data) {
127
126
  "./src/polyfills.ts"
128
127
  ]
129
128
  }`);
130
- (0, workspace_1.createOrUpdate)(tree, `${dirPath}/tsconfig.editor.json`, `{
129
+ (0, xplat_utils_1.updateFile)(tree, `${dirPath}/tsconfig.editor.json`, `{
131
130
  "extends": "./tsconfig.json",
132
131
  "include": ["**/*.ts"],
133
132
  "compilerOptions": {
@@ -135,7 +134,7 @@ child.stdout.on('data', function (data) {
135
134
  }
136
135
  }
137
136
  `);
138
- (0, workspace_1.createOrUpdate)(tree, `${dirPath}/tsconfig.json`, `{
137
+ (0, xplat_utils_1.updateFile)(tree, `${dirPath}/tsconfig.json`, `{
139
138
  "extends": "${relativePath}/tsconfig.base.json",
140
139
  "files": [],
141
140
  "include": [],
@@ -152,7 +151,7 @@ child.stdout.on('data', function (data) {
152
151
  ]
153
152
  }
154
153
  `);
155
- (0, workspace_1.createOrUpdate)(tree, `${dirPath}/tsconfig.spec.json`, `{
154
+ (0, xplat_utils_1.updateFile)(tree, `${dirPath}/tsconfig.spec.json`, `{
156
155
  "extends": "./tsconfig.json",
157
156
  "compilerOptions": {
158
157
  "outDir": "${relativePath}/dist/out-tsc",
@@ -163,8 +162,8 @@ child.stdout.on('data', function (data) {
163
162
  "include": ["**/*.spec.ts", "**/*.d.ts"]
164
163
  }
165
164
  `);
166
- (0, workspace_1.createOrUpdate)(tree, `${dirPath}/src/test-setup.ts`, `import 'jest-preset-angular/setup-jest';`);
167
- (0, workspace_1.createOrUpdate)(tree, `${dirPath}/src/polyfills.ts`, `/**
165
+ (0, xplat_utils_1.updateFile)(tree, `${dirPath}/src/test-setup.ts`, `import 'jest-preset-angular/setup-jest';`);
166
+ (0, xplat_utils_1.updateFile)(tree, `${dirPath}/src/polyfills.ts`, `/**
168
167
  * NativeScript Polyfills
169
168
  */
170
169
 
@@ -185,7 +184,7 @@ import 'zone.js';
185
184
  // Add NativeScript specific Zone JS patches
186
185
  import '@nativescript/zone-js';
187
186
  `);
188
- (0, workspace_1.createOrUpdate)(tree, `${dirPath}/.eslintrc.json`, `{
187
+ (0, xplat_utils_1.updateFile)(tree, `${dirPath}/.eslintrc.json`, `{
189
188
  "extends": "${relativePath}/.eslintrc.json",
190
189
  "ignorePatterns": [
191
190
  "!**/*"
@@ -250,37 +249,36 @@ import '@nativescript/zone-js';
250
249
  return tree;
251
250
  }
252
251
  function updateRootPackage(tree, context) {
253
- return (0, workspace_1.updateJsonInTree)('package.json', (json) => {
254
- json.scripts = json.scripts || {};
255
- const nativeScriptDeps = {
256
- '@nativescript/angular': nsNgScopedVersion,
257
- '@nativescript/core': nsCoreVersion,
258
- };
259
- const nativeScriptDevDeps = {
260
- '@nativescript/types': nsCoreVersion,
261
- '@nativescript/webpack': nsWebpackVersion,
262
- };
263
- json.dependencies = json.dependencies || {};
264
- json.dependencies = Object.assign(Object.assign(Object.assign({}, json.dependencies), (hasNativeScriptApps ? nativeScriptDeps : {})), { '@ngx-translate/core': ngxTranslateVersion });
265
- let ngToolsDeps = {
266
- '@ngtools/webpack': angularVersion
267
- };
268
- if (json.dependencies['@angular/core']) {
269
- // make sure in sync with current angular versions
270
- ngToolsDeps['@ngtools/webpack'] = json.dependencies['@angular/core'];
271
- }
272
- else {
273
- ngToolsDeps = null;
274
- }
275
- delete json.dependencies['nativescript-angular'];
276
- delete json.dependencies['tns-core-modules'];
277
- delete json.devDependencies['tns-core-modules'];
278
- delete json.dependencies['tns-platform-declarations'];
279
- delete json.devDependencies['tns-platform-declarations'];
280
- json.devDependencies = json.devDependencies || {};
281
- json.devDependencies = Object.assign(Object.assign(Object.assign({}, json.devDependencies), (hasNativeScriptApps ? nativeScriptDevDeps : {})), (ngToolsDeps ? ngToolsDeps : {}));
282
- return json;
283
- })(tree, context);
252
+ const json = (0, xplat_utils_1.getJsonFromFile)(tree, 'package.json');
253
+ json.scripts = json.scripts || {};
254
+ const nativeScriptDeps = {
255
+ '@nativescript/angular': nsNgScopedVersion,
256
+ '@nativescript/core': nsCoreVersion,
257
+ };
258
+ const nativeScriptDevDeps = {
259
+ '@nativescript/types': nsCoreVersion,
260
+ '@nativescript/webpack': nsWebpackVersion,
261
+ };
262
+ json.dependencies = json.dependencies || {};
263
+ json.dependencies = Object.assign(Object.assign(Object.assign({}, json.dependencies), (hasNativeScriptApps ? nativeScriptDeps : {})), { '@ngx-translate/core': ngxTranslateVersion });
264
+ let ngToolsDeps = {
265
+ '@ngtools/webpack': angularVersion,
266
+ };
267
+ if (json.dependencies['@angular/core']) {
268
+ // make sure in sync with current angular versions
269
+ ngToolsDeps['@ngtools/webpack'] = json.dependencies['@angular/core'];
270
+ }
271
+ else {
272
+ ngToolsDeps = null;
273
+ }
274
+ delete json.dependencies['nativescript-angular'];
275
+ delete json.dependencies['tns-core-modules'];
276
+ delete json.devDependencies['tns-core-modules'];
277
+ delete json.dependencies['tns-platform-declarations'];
278
+ delete json.devDependencies['tns-platform-declarations'];
279
+ json.devDependencies = json.devDependencies || {};
280
+ json.devDependencies = Object.assign(Object.assign(Object.assign({}, json.devDependencies), (hasNativeScriptApps ? nativeScriptDevDeps : {})), (ngToolsDeps ? ngToolsDeps : {}));
281
+ return (0, xplat_utils_1.updateJsonFile)(tree, 'package.json', json);
284
282
  }
285
283
  function default_1() {
286
284
  return (0, schematics_1.chain)([
@@ -291,7 +289,7 @@ function default_1() {
291
289
  updateRootPackage,
292
290
  (tree) => {
293
291
  return (0, schematics_1.externalSchematic)('@nrwl/workspace', 'convert-to-nx-project', {
294
- all: true
292
+ all: true,
295
293
  });
296
294
  },
297
295
  ]);
package/migrations.json CHANGED
@@ -1,30 +1,5 @@
1
1
  {
2
2
  "schematics": {
3
- "update-to-10.2.0": {
4
- "version": "10.2.0",
5
- "description": "Migrate workspace to 10.2.0",
6
- "factory": "./migrations/update-10-2-0/update-10-2-0"
7
- },
8
- "update-to-11.0.0": {
9
- "version": "11.0.21",
10
- "description": "Migrate workspace to 11.0.0",
11
- "factory": "./migrations/update-11-0-0/update-11-0-0"
12
- },
13
- "update-to-11-imports": {
14
- "version": "11.0.21",
15
- "description": "Migrate workspace to use v11 import barrels",
16
- "factory": "./migrations/update-11-0-0/update-to-11-imports"
17
- },
18
- "update-to-11-env-base": {
19
- "version": "11.0.21",
20
- "description": "Migrate workspace to use v11 env base option",
21
- "factory": "./migrations/update-11-0-0/update-to-11-env-base"
22
- },
23
- "update-to-11-clean-old-dirs": {
24
- "version": "11.0.21",
25
- "description": "Remove old dirs",
26
- "factory": "./migrations/update-11-0-0/clean-old-dirs"
27
- },
28
3
  "update-to-12.4.3": {
29
4
  "version": "12.4.3",
30
5
  "description": "Migrate workspace to 12.4.3",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nstudio/xplat",
3
- "version": "15.0.3",
3
+ "version": "15.0.4-rc.1",
4
4
  "description": "Cross-platform (xplat) tools for Nx workspaces.",
5
5
  "homepage": "https://nstudio.io/xplat",
6
6
  "repository": {
@@ -41,8 +41,8 @@
41
41
  "postinstall": "node src/utils/postinstall.js"
42
42
  },
43
43
  "dependencies": {
44
- "@nstudio/focus": "15.0.3",
45
- "@nstudio/xplat-utils": "15.0.3"
44
+ "@nstudio/focus": "15.0.4-rc.1",
45
+ "@nstudio/xplat-utils": "15.0.4-rc.1"
46
46
  },
47
47
  "author": "Nathan Walker",
48
48
  "license": "MIT",
@@ -11,9 +11,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.sandboxHomeSetup = void 0;
13
13
  const schematics_1 = require("@angular-devkit/schematics");
14
- const workspace_1 = require("@nrwl/workspace");
15
14
  const testing_utils_1 = require("../../utils/testing-utils");
16
15
  const testing_1 = require("../../utils/testing");
16
+ const xplat_utils_1 = require("@nstudio/xplat-utils");
17
17
  xdescribe('feature schematic', () => {
18
18
  let appTree;
19
19
  const defaultOptions = {
@@ -327,7 +327,7 @@ xdescribe('feature schematic', () => {
327
327
  appTree = (0, testing_utils_1.createXplatWithNativeScriptWeb)(appTree, true);
328
328
  // manually update home.component to prep for sandobx
329
329
  const homeCmpPath = `/apps/nativescript-viewer/src/features/home/components/home.component.html`;
330
- (0, workspace_1.createOrUpdate)(appTree, homeCmpPath, sandboxHomeSetup());
330
+ (0, xplat_utils_1.updateFile)(appTree, homeCmpPath, sandboxHomeSetup());
331
331
  // console.log('homecmp:', getFileContent(tree, homeCmpPath));
332
332
  options.onlyProject = true;
333
333
  options.adjustSandbox = true;
@@ -1,5 +1,9 @@
1
- import { Tree } from '@angular-devkit/schematics';
1
+ /// <reference types="node" />
2
+ /// <reference types="node" />
3
+ import { Tree as NgTree } from '@angular-devkit/schematics';
2
4
  import { PlatformTypes, FrameworkTypes, ITargetPlatforms } from '@nstudio/xplat-utils';
5
+ import type { Mode } from 'fs';
6
+ import type { FileChange, Tree as DevKitTree, TreeWriteOptions } from 'nx/src/generators/tree';
3
7
  export interface NodeDependency {
4
8
  name: string;
5
9
  version: string;
@@ -29,11 +33,10 @@ export declare function hasFrontendPlatform(targetPlatforms: ITargetPlatforms):
29
33
  * @param targetPlatforms
30
34
  */
31
35
  export declare function hasWebPlatform(targetPlatforms: ITargetPlatforms): boolean;
32
- export declare function updatePackageForNgrx(tree: Tree, packagePath?: string): import("@angular-devkit/schematics/src/tree/interface").Tree;
33
- export declare function updateTsConfig(tree: Tree, callback: (data: any) => void, targetSuffix?: string, prefixPath?: string): import("@angular-devkit/schematics/src/tree/interface").Tree;
34
- export declare function updatePackageScripts(tree: Tree, scripts: any): import("@angular-devkit/schematics/src/tree/interface").Tree;
35
- export declare function readWorkspaceJson(tree: Tree): any;
36
- export declare function updateWorkspace(updates: any): any;
36
+ export declare function updatePackageForNgrx(tree: NgTree, packagePath?: string): import("@angular-devkit/schematics/src/tree/interface").Tree;
37
+ export declare function updateTsConfig(tree: NgTree, callback: (data: any) => void, targetSuffix?: string, prefixPath?: string): import("@angular-devkit/schematics/src/tree/interface").Tree;
38
+ export declare function updatePackageScripts(tree: NgTree, scripts: any): import("@angular-devkit/schematics/src/tree/interface").Tree;
39
+ export declare function readWorkspaceJson(tree: NgTree): any;
37
40
  export declare function getPrefixWarning(prefix: string): string;
38
41
  export declare function getDefaultTemplateOptions(): {
39
42
  tmpl: string;
@@ -81,3 +84,29 @@ export declare const stringUtils: {
81
84
  };
82
85
  export declare const toComponentClassName: (name: string) => string;
83
86
  export declare const toNgModuleClassName: (name: string) => string;
87
+ export declare const actionToFileChangeMap: {
88
+ c: string;
89
+ o: string;
90
+ d: string;
91
+ };
92
+ export declare function convertNgTreeToDevKit(tree: NgTree, context: any): DevkitTreeFromAngularDevkitTree;
93
+ export declare class DevkitTreeFromAngularDevkitTree implements DevKitTree {
94
+ tree: NgTree;
95
+ private _root;
96
+ private skipWritingConfigInOldFormat?;
97
+ private configFileName;
98
+ constructor(tree: NgTree, _root: any, skipWritingConfigInOldFormat?: boolean);
99
+ get root(): any;
100
+ children(dirPath: string): string[];
101
+ delete(filePath: string): void;
102
+ exists(filePath: string): boolean;
103
+ isFile(filePath: string): boolean;
104
+ listChanges(): FileChange[];
105
+ private normalize;
106
+ read(filePath: string): Buffer;
107
+ read(filePath: string, encoding: BufferEncoding): string;
108
+ rename(from: string, to: string): void;
109
+ write(filePath: string, content: Buffer | string, options?: TreeWriteOptions): void;
110
+ changePermissions(filePath: string, mode: Mode): void;
111
+ private warnUnsupportedFilePermissionsChange;
112
+ }
@@ -1,8 +1,18 @@
1
1
  "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
2
11
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.toNgModuleClassName = exports.toComponentClassName = exports.stringUtils = exports.sanitize = exports.getDefaultTemplateOptions = exports.getPrefixWarning = exports.updateWorkspace = exports.readWorkspaceJson = exports.updatePackageScripts = exports.updateTsConfig = exports.updatePackageForNgrx = exports.hasWebPlatform = exports.hasFrontendPlatform = exports.supportedSandboxPlatforms = exports.supportedHelpers = void 0;
12
+ exports.DevkitTreeFromAngularDevkitTree = exports.convertNgTreeToDevKit = exports.actionToFileChangeMap = exports.toNgModuleClassName = exports.toComponentClassName = exports.stringUtils = exports.sanitize = exports.getDefaultTemplateOptions = exports.getPrefixWarning = exports.readWorkspaceJson = exports.updatePackageScripts = exports.updateTsConfig = exports.updatePackageForNgrx = exports.hasWebPlatform = exports.hasFrontendPlatform = exports.supportedSandboxPlatforms = exports.supportedHelpers = void 0;
4
13
  const workspace_1 = require("@nrwl/workspace");
5
14
  const xplat_utils_1 = require("@nstudio/xplat-utils");
15
+ const path_1 = require("path");
6
16
  // list of all supported helpers
7
17
  // TODO: add more convenient helpers (like firebase or Travis ci support files)
8
18
  exports.supportedHelpers = ['imports', 'applitools'];
@@ -83,18 +93,9 @@ function updatePackageScripts(tree, scripts) {
83
93
  }
84
94
  exports.updatePackageScripts = updatePackageScripts;
85
95
  function readWorkspaceJson(tree) {
86
- return (0, workspace_1.readJsonInTree)(tree, (0, workspace_1.getWorkspacePath)(tree));
96
+ return (0, xplat_utils_1.getJsonFromFile)(tree, 'workspace.json');
87
97
  }
88
98
  exports.readWorkspaceJson = readWorkspaceJson;
89
- function updateWorkspace(updates) {
90
- return (0, workspace_1.updateWorkspaceInTree)((json) => {
91
- for (const key in updates) {
92
- json[key] = Object.assign(Object.assign({}, (json[key] || {})), updates[key]);
93
- }
94
- return json;
95
- });
96
- }
97
- exports.updateWorkspace = updateWorkspace;
98
99
  // export function persistPrefix(prefix: string) {
99
100
  // return (tree: Tree) => {
100
101
  // const nxConfig = getNxWorkspaceConfig(tree);
@@ -142,3 +143,146 @@ const toComponentClassName = (name) => `${exports.stringUtils.classify(name)}Com
142
143
  exports.toComponentClassName = toComponentClassName;
143
144
  const toNgModuleClassName = (name) => `${exports.stringUtils.classify(name)}Module`;
144
145
  exports.toNgModuleClassName = toNgModuleClassName;
146
+ exports.actionToFileChangeMap = {
147
+ c: 'CREATE',
148
+ o: 'UPDATE',
149
+ d: 'DELETE',
150
+ };
151
+ class RunCallbackTask {
152
+ constructor(callback) {
153
+ this.callback = callback;
154
+ }
155
+ toConfiguration() {
156
+ return {
157
+ name: 'RunCallback',
158
+ options: {
159
+ callback: this.callback,
160
+ },
161
+ };
162
+ }
163
+ }
164
+ function createRunCallbackTask() {
165
+ return {
166
+ name: 'RunCallback',
167
+ create: () => {
168
+ return Promise.resolve(({ callback }) => __awaiter(this, void 0, void 0, function* () {
169
+ yield callback();
170
+ }));
171
+ },
172
+ };
173
+ }
174
+ function convertNgTreeToDevKit(tree, context) {
175
+ if (context.engine.workflow) {
176
+ const engineHost = context.engine.workflow.engineHost;
177
+ engineHost.registerTaskExecutor(createRunCallbackTask());
178
+ }
179
+ const root = context.engine.workflow && context.engine.workflow.engineHost.paths
180
+ ? context.engine.workflow.engineHost.paths[1]
181
+ : tree.root.path;
182
+ return new DevkitTreeFromAngularDevkitTree(tree, root, true);
183
+ }
184
+ exports.convertNgTreeToDevKit = convertNgTreeToDevKit;
185
+ class DevkitTreeFromAngularDevkitTree {
186
+ constructor(tree, _root, skipWritingConfigInOldFormat) {
187
+ this.tree = tree;
188
+ this._root = _root;
189
+ this.skipWritingConfigInOldFormat = skipWritingConfigInOldFormat;
190
+ /**
191
+ * When using the UnitTestTree from @angular-devkit/schematics/testing, the root is just `/`.
192
+ * This causes a massive issue if `getProjects()` is used in the underlying generator because it
193
+ * causes fast-glob to be set to work on the user's entire file system.
194
+ *
195
+ * Therefore, in this case, patch the root to match what Nx Devkit does and use /virtual instead.
196
+ */
197
+ try {
198
+ const { UnitTestTree } = require('@angular-devkit/schematics/testing');
199
+ if (tree instanceof UnitTestTree && _root === '/') {
200
+ this._root = '/virtual';
201
+ }
202
+ }
203
+ catch (_a) { }
204
+ }
205
+ get root() {
206
+ return this._root;
207
+ }
208
+ children(dirPath) {
209
+ const { subdirs, subfiles } = this.tree.getDir(dirPath);
210
+ return [...subdirs, ...subfiles];
211
+ }
212
+ delete(filePath) {
213
+ this.tree.delete(filePath);
214
+ }
215
+ exists(filePath) {
216
+ if (this.isFile(filePath)) {
217
+ return this.tree.exists(filePath);
218
+ }
219
+ else {
220
+ return this.children(filePath).length > 0;
221
+ }
222
+ }
223
+ isFile(filePath) {
224
+ return this.tree.exists(filePath) && !!this.tree.read(filePath);
225
+ }
226
+ listChanges() {
227
+ const fileChanges = [];
228
+ for (const action of this.tree.actions) {
229
+ if (action.kind === 'r') {
230
+ fileChanges.push({
231
+ path: this.normalize(action.to),
232
+ type: 'CREATE',
233
+ content: this.read(action.to),
234
+ });
235
+ fileChanges.push({
236
+ path: this.normalize(action.path),
237
+ type: 'DELETE',
238
+ content: null,
239
+ });
240
+ }
241
+ else if (action.kind === 'c' || action.kind === 'o') {
242
+ fileChanges.push({
243
+ path: this.normalize(action.path),
244
+ type: exports.actionToFileChangeMap[action.kind],
245
+ content: action.content,
246
+ });
247
+ }
248
+ else {
249
+ fileChanges.push({
250
+ path: this.normalize(action.path),
251
+ type: 'DELETE',
252
+ content: null,
253
+ });
254
+ }
255
+ }
256
+ return fileChanges;
257
+ }
258
+ normalize(path) {
259
+ return (0, path_1.relative)(this.root, (0, path_1.join)(this.root, path));
260
+ }
261
+ read(filePath, encoding) {
262
+ return encoding
263
+ ? this.tree.read(filePath).toString(encoding)
264
+ : this.tree.read(filePath);
265
+ }
266
+ rename(from, to) {
267
+ this.tree.rename(from, to);
268
+ }
269
+ write(filePath, content, options) {
270
+ if (options === null || options === void 0 ? void 0 : options.mode) {
271
+ this.warnUnsupportedFilePermissionsChange(filePath, options.mode);
272
+ }
273
+ if (this.tree.exists(filePath)) {
274
+ this.tree.overwrite(filePath, content);
275
+ }
276
+ else {
277
+ this.tree.create(filePath, content);
278
+ }
279
+ }
280
+ changePermissions(filePath, mode) {
281
+ this.warnUnsupportedFilePermissionsChange(filePath, mode);
282
+ }
283
+ warnUnsupportedFilePermissionsChange(filePath, mode) {
284
+ console.log(`The Angular DevKit tree does not support changing a file permissions.
285
+ Ignoring changing ${filePath} permissions to ${mode}.`);
286
+ }
287
+ }
288
+ exports.DevkitTreeFromAngularDevkitTree = DevkitTreeFromAngularDevkitTree;
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.nxVersion = exports.xplatVersion = void 0;
4
- exports.xplatVersion = '15.0.3';
4
+ exports.xplatVersion = '15.0.4-rc.1';
5
5
  exports.nxVersion = '^15.0.0';
@@ -5,7 +5,6 @@ const schematics_1 = require("@angular-devkit/schematics");
5
5
  const typescript_1 = require("typescript");
6
6
  const general_1 = require("./general");
7
7
  const xplat_utils_1 = require("@nstudio/xplat-utils");
8
- const workspace_1 = require("@nrwl/workspace");
9
8
  const ast_1 = require("./ast");
10
9
  const errors_1 = require("./errors");
11
10
  const tasks_1 = require("@angular-devkit/schematics/tasks");
@@ -43,7 +42,8 @@ var XplatHelpers;
43
42
  */
44
43
  function addPackageWithNgAdd(packageName, options, callSchematicIfAdded) {
45
44
  return (host) => {
46
- const { dependencies, devDependencies } = (0, workspace_1.readJsonInTree)(host, 'package.json');
45
+ const json = (0, xplat_utils_1.getJsonFromFile)(host, 'package.json');
46
+ const { dependencies, devDependencies } = json;
47
47
  return dependencies[packageName] || devDependencies[packageName]
48
48
  ? callSchematicIfAdded
49
49
  ? (0, schematics_1.externalSchematic)(packageName, callSchematicIfAdded, options, {
@@ -1,2 +0,0 @@
1
- import { Rule } from '@angular-devkit/schematics';
2
- export default function (): Rule;
@@ -1,11 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const schematics_1 = require("@angular-devkit/schematics");
4
- function default_1() {
5
- return (0, schematics_1.chain)([
6
- (tree, context) => {
7
- return (0, schematics_1.noop)();
8
- },
9
- ]);
10
- }
11
- exports.default = default_1;