@nstudio/xplat 12.7.0 → 13.4.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.
Files changed (34) hide show
  1. package/README.md +5 -5
  2. package/migrations/update-10-2-0/update-10-2-0.js +2 -2
  3. package/migrations/update-11-0-0/clean-old-dirs.js +2 -2
  4. package/migrations/update-11-0-0/update-11-0-0.js +48 -46
  5. package/migrations/update-11-0-0/update-to-11-env-base.js +33 -27
  6. package/migrations/update-11-0-0/update-to-11-imports.js +5 -5
  7. package/migrations/update-12-4-3/update-12-4-3.js +19 -19
  8. package/migrations/update-13-0-0/update-13-0-0.d.ts +2 -0
  9. package/migrations/update-13-0-0/update-13-0-0.js +299 -0
  10. package/migrations.json +46 -0
  11. package/package.json +3 -7
  12. package/src/schematics/app-generate/index.js +3 -3
  13. package/src/schematics/application/index.js +1 -1
  14. package/src/schematics/application/index.spec.js +13 -13
  15. package/src/schematics/component/index.js +1 -1
  16. package/src/schematics/component/index.spec.js +22 -22
  17. package/src/schematics/feature/index.js +3 -3
  18. package/src/schematics/feature/index.spec.js +37 -37
  19. package/src/schematics/helpers/index.js +7 -7
  20. package/src/schematics/helpers/index.spec.js +4 -4
  21. package/src/schematics/init/index.js +15 -14
  22. package/src/schematics/init/index.spec.js +8 -9
  23. package/src/schematics/mode/index.js +3 -3
  24. package/src/schematics/ng-add/index.js +3 -3
  25. package/src/utils/ast.js +1 -1
  26. package/src/utils/general.d.ts +0 -1
  27. package/src/utils/general.js +11 -19
  28. package/src/utils/helpers.js +1 -1
  29. package/src/utils/postinstall.js +9 -9
  30. package/src/utils/testing-utils.js +2 -2
  31. package/src/utils/testing.js +2 -2
  32. package/src/utils/versions.d.ts +1 -1
  33. package/src/utils/versions.js +2 -2
  34. package/src/utils/xplat.js +65 -65
@@ -15,7 +15,7 @@ const testing_1 = require("@nstudio/xplat/testing");
15
15
  const testing_2 = require("../../utils/testing");
16
16
  const utils_1 = require("../../utils");
17
17
  const testing_3 = require("@nrwl/workspace/testing");
18
- xplat_utils_1.setTest();
18
+ (0, xplat_utils_1.setTest)();
19
19
  describe('xplat init', () => {
20
20
  let appTree;
21
21
  const defaultOptions = {
@@ -24,16 +24,16 @@ describe('xplat init', () => {
24
24
  isTesting: true,
25
25
  };
26
26
  beforeEach(() => {
27
- appTree = testing_1.createEmptyWorkspace(schematics_1.Tree.empty());
27
+ appTree = (0, testing_1.createEmptyWorkspace)(schematics_1.Tree.empty());
28
28
  });
29
29
  it('should init default xplat deps', () => __awaiter(void 0, void 0, void 0, function* () {
30
30
  const options = Object.assign({}, defaultOptions);
31
31
  options.platforms = 'web';
32
32
  options.framework = 'angular';
33
- const tree = yield testing_2.runSchematic('init', options, appTree);
33
+ const tree = yield (0, testing_2.runSchematic)('init', options, appTree);
34
34
  const files = tree.files;
35
35
  // console.log('files:', files);
36
- let packageJson = JSON.parse(testing_3.getFileContent(tree, 'package.json'));
36
+ let packageJson = JSON.parse((0, testing_3.getFileContent)(tree, 'package.json'));
37
37
  // console.log(packageJson);
38
38
  const devDeps = [
39
39
  '@nrwl/angular',
@@ -44,7 +44,6 @@ describe('xplat init', () => {
44
44
  '@angular/compiler-cli',
45
45
  '@angular/language-service',
46
46
  '@angular-devkit/build-angular',
47
- 'codelyzer',
48
47
  ];
49
48
  for (const dep of devDeps) {
50
49
  expect(packageJson.devDependencies[dep]).toBeDefined();
@@ -54,28 +53,28 @@ describe('xplat init', () => {
54
53
  const options = Object.assign({}, defaultOptions);
55
54
  options.platforms = 'web,nativescript';
56
55
  options.framework = 'angular';
57
- const tree = yield testing_2.runSchematic('init', options, appTree);
56
+ const tree = yield (0, testing_2.runSchematic)('init', options, appTree);
58
57
  // const files = tree.files;
59
58
  // console.log('files:', files);
60
59
  expect(tree.exists('/libs/xplat/web/core/src/lib/index.ts')).toBeTruthy();
61
60
  expect(tree.exists('/libs/xplat/nativescript/core/src/lib/index.ts')).toBeTruthy();
62
61
  expect(tree.exists('/libs/xplat/web-angular/core/src/lib/index.ts')).toBeFalsy();
63
62
  expect(tree.exists('/libs/xplat/nativescript-angular/core/src/lib/index.ts')).toBeFalsy();
64
- let packageJson = JSON.parse(testing_3.getFileContent(tree, 'package.json'));
63
+ let packageJson = JSON.parse((0, testing_3.getFileContent)(tree, 'package.json'));
65
64
  // console.log(packageJson);
66
65
  expect(packageJson.xplat.framework).toBe('angular');
67
66
  }));
68
67
  it('should NOT create unsupported platform xplat option and throw', () => __awaiter(void 0, void 0, void 0, function* () {
69
68
  const options = Object.assign({}, defaultOptions);
70
69
  options.platforms = 'desktop';
71
- yield expect(testing_2.runSchematic('init', options, appTree)).rejects.toThrow(`desktop is currently not a supported platform. Supported at the moment: ${xplat_utils_1.supportedPlatforms}. Please request support for this platform if you'd like and/or submit a PR which we would greatly appreciate.`);
70
+ yield expect((0, testing_2.runSchematic)('init', options, appTree)).rejects.toThrow(`desktop is currently not a supported platform. Supported at the moment: ${xplat_utils_1.supportedPlatforms}. Please request support for this platform if you'd like and/or submit a PR which we would greatly appreciate.`);
72
71
  }));
73
72
  it('should NOT create unsupported framework xplat option and throw', () => __awaiter(void 0, void 0, void 0, function* () {
74
73
  const options = Object.assign({}, defaultOptions);
75
74
  options.platforms = 'web';
76
75
  options.framework = 'blah';
77
76
  let tree;
78
- yield expect(testing_2.runSchematic('init', options, appTree)).rejects.toThrow(`blah is currently not a supported framework. Supported at the moment: ${xplat_utils_1.supportedFrameworks.map((f) => utils_1.stringUtils.capitalize(f))}. Please request support for this framework if you'd like and/or submit a PR which we would greatly appreciate.`);
77
+ yield expect((0, testing_2.runSchematic)('init', options, appTree)).rejects.toThrow(`blah is currently not a supported framework. Supported at the moment: ${xplat_utils_1.supportedFrameworks.map((f) => utils_1.stringUtils.capitalize(f))}. Please request support for this framework if you'd like and/or submit a PR which we would greatly appreciate.`);
79
78
  }));
80
79
  /**
81
80
  * TODO: This passes when run with "fdescribe" only
@@ -3,9 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const schematics_1 = require("@angular-devkit/schematics");
4
4
  const xplat_utils_1 = require("@nstudio/xplat-utils");
5
5
  function default_1(options) {
6
- return schematics_1.chain([
7
- xplat_utils_1.prerun(options, true),
8
- (tree, context) => schematics_1.externalSchematic('@nstudio/focus', 'mode', options),
6
+ return (0, schematics_1.chain)([
7
+ (0, xplat_utils_1.prerun)(options, true),
8
+ (tree, context) => (0, schematics_1.externalSchematic)('@nstudio/focus', 'mode', options),
9
9
  ]);
10
10
  }
11
11
  exports.default = default_1;
@@ -3,9 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const schematics_1 = require("@angular-devkit/schematics");
4
4
  const xplat_utils_1 = require("@nstudio/xplat-utils");
5
5
  function default_1(options) {
6
- return schematics_1.chain([
7
- xplat_utils_1.prerun(options, true),
8
- (tree, context) => schematics_1.externalSchematic('@nstudio/xplat', 'init', options),
6
+ return (0, schematics_1.chain)([
7
+ (0, xplat_utils_1.prerun)(options, true),
8
+ (tree, context) => (0, schematics_1.externalSchematic)('@nstudio/xplat', 'init', options),
9
9
  ]);
10
10
  }
11
11
  exports.default = default_1;
package/src/utils/ast.js CHANGED
@@ -283,7 +283,7 @@ function insert(host, modulePath, changes) {
283
283
  }
284
284
  exports.insert = insert;
285
285
  function getProjectConfig(tree, name) {
286
- const workspaceJson = general_1.readWorkspaceJson(tree);
286
+ const workspaceJson = (0, general_1.readWorkspaceJson)(tree);
287
287
  const projectConfig = workspaceJson.projects[name];
288
288
  if (!projectConfig) {
289
289
  throw new Error(`Cannot find project '${name}'`);
@@ -34,7 +34,6 @@ export declare function updateTsConfig(tree: Tree, callback: (data: any) => void
34
34
  export declare function updatePackageScripts(tree: Tree, scripts: any): import("@angular-devkit/schematics/src/tree/interface").Tree;
35
35
  export declare function readWorkspaceJson(tree: Tree): any;
36
36
  export declare function updateWorkspace(updates: any): any;
37
- export declare function updateNxProjects(tree: Tree, projects: any): import("@angular-devkit/schematics/src/tree/interface").Tree;
38
37
  export declare function getPrefixWarning(prefix: string): string;
39
38
  export declare function getDefaultTemplateOptions(): {
40
39
  tmpl: string;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.toNgModuleClassName = exports.toComponentClassName = exports.stringUtils = exports.sanitize = exports.getDefaultTemplateOptions = exports.getPrefixWarning = exports.updateNxProjects = exports.updateWorkspace = exports.readWorkspaceJson = exports.updatePackageScripts = exports.updateTsConfig = exports.updatePackageForNgrx = exports.hasWebPlatform = exports.hasFrontendPlatform = exports.supportedSandboxPlatforms = exports.supportedHelpers = void 0;
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;
4
4
  const workspace_1 = require("@nrwl/workspace");
5
5
  const xplat_utils_1 = require("@nstudio/xplat-utils");
6
6
  // list of all supported helpers
@@ -35,7 +35,7 @@ function hasWebPlatform(targetPlatforms) {
35
35
  exports.hasWebPlatform = hasWebPlatform;
36
36
  function updatePackageForNgrx(tree, packagePath = 'package.json') {
37
37
  if (tree.exists(packagePath)) {
38
- const packageJson = xplat_utils_1.getJsonFromFile(tree, packagePath);
38
+ const packageJson = (0, xplat_utils_1.getJsonFromFile)(tree, packagePath);
39
39
  if (packageJson) {
40
40
  // sync version with what user has store set at
41
41
  let rootNgrxVersion = packageJson.dependencies
@@ -47,7 +47,7 @@ function updatePackageForNgrx(tree, packagePath = 'package.json') {
47
47
  };
48
48
  packageJson.dependencies = Object.assign(Object.assign({}, (packageJson.dependencies || {})), dependencies);
49
49
  packageJson.devDependencies = Object.assign(Object.assign({}, (packageJson.devDependencies || {})), devDependencies);
50
- return xplat_utils_1.updateJsonFile(tree, packagePath, packageJson);
50
+ return (0, xplat_utils_1.updateJsonFile)(tree, packagePath, packageJson);
51
51
  }
52
52
  }
53
53
  return tree;
@@ -69,25 +69,25 @@ function updateTsConfig(tree, callback, targetSuffix = '', prefixPath = '') {
69
69
  }
70
70
  }
71
71
  // console.log('tsConfigPath:', tsConfigPath)
72
- const tsConfig = xplat_utils_1.getJsonFromFile(tree, tsConfigPath);
72
+ const tsConfig = (0, xplat_utils_1.getJsonFromFile)(tree, tsConfigPath);
73
73
  callback(tsConfig);
74
- return xplat_utils_1.updateJsonFile(tree, tsConfigPath, tsConfig);
74
+ return (0, xplat_utils_1.updateJsonFile)(tree, tsConfigPath, tsConfig);
75
75
  }
76
76
  exports.updateTsConfig = updateTsConfig;
77
77
  function updatePackageScripts(tree, scripts) {
78
78
  const path = 'package.json';
79
- const packageJson = xplat_utils_1.getJsonFromFile(tree, path);
79
+ const packageJson = (0, xplat_utils_1.getJsonFromFile)(tree, path);
80
80
  const scriptsMap = Object.assign({}, packageJson.scripts);
81
81
  packageJson.scripts = Object.assign(scriptsMap, scripts);
82
- return xplat_utils_1.updateJsonFile(tree, path, packageJson);
82
+ return (0, xplat_utils_1.updateJsonFile)(tree, path, packageJson);
83
83
  }
84
84
  exports.updatePackageScripts = updatePackageScripts;
85
85
  function readWorkspaceJson(tree) {
86
- return workspace_1.readJsonInTree(tree, workspace_1.getWorkspacePath(tree));
86
+ return (0, workspace_1.readJsonInTree)(tree, (0, workspace_1.getWorkspacePath)(tree));
87
87
  }
88
88
  exports.readWorkspaceJson = readWorkspaceJson;
89
89
  function updateWorkspace(updates) {
90
- return workspace_1.updateWorkspaceInTree((json) => {
90
+ return (0, workspace_1.updateWorkspaceInTree)((json) => {
91
91
  for (const key in updates) {
92
92
  json[key] = Object.assign(Object.assign({}, (json[key] || {})), updates[key]);
93
93
  }
@@ -95,14 +95,6 @@ function updateWorkspace(updates) {
95
95
  });
96
96
  }
97
97
  exports.updateWorkspace = updateWorkspace;
98
- function updateNxProjects(tree, projects) {
99
- const path = 'nx.json';
100
- const nxJson = xplat_utils_1.getJsonFromFile(tree, path);
101
- const projectsMap = Object.assign({}, nxJson.projects);
102
- nxJson.projects = Object.assign(projectsMap, projects);
103
- return xplat_utils_1.updateJsonFile(tree, path, nxJson);
104
- }
105
- exports.updateNxProjects = updateNxProjects;
106
98
  // export function persistPrefix(prefix: string) {
107
99
  // return (tree: Tree) => {
108
100
  // const nxConfig = getNxWorkspaceConfig(tree);
@@ -119,8 +111,8 @@ function getDefaultTemplateOptions() {
119
111
  return {
120
112
  tmpl: '',
121
113
  utils: exports.stringUtils,
122
- npmScope: xplat_utils_1.getNpmScope(),
123
- prefix: xplat_utils_1.getPrefix(),
114
+ npmScope: (0, xplat_utils_1.getNpmScope)(),
115
+ prefix: (0, xplat_utils_1.getPrefix)(),
124
116
  dot: '.',
125
117
  };
126
118
  }
@@ -6,7 +6,7 @@ const errors_1 = require("./errors");
6
6
  function buildHelperChain(helper, options, config, helperChain) {
7
7
  // throw if target required and it's missing
8
8
  if (config.requiresTarget && !options.target) {
9
- throw new schematics_1.SchematicsException(errors_1.helperTargetError(helper));
9
+ throw new schematics_1.SchematicsException((0, errors_1.helperTargetError)(helper));
10
10
  }
11
11
  if (config.addHelperFiles) {
12
12
  // add files for the helper
@@ -13,9 +13,9 @@ exports.updateConfig = void 0;
13
13
  const fs = require("fs");
14
14
  const path = require("path");
15
15
  const util_1 = require("util");
16
- const fsExists = util_1.promisify(fs.exists);
17
- const fsWriteFile = util_1.promisify(fs.writeFile);
18
- const fsReadFile = util_1.promisify(fs.readFile);
16
+ const fsExists = (0, util_1.promisify)(fs.exists);
17
+ const fsWriteFile = (0, util_1.promisify)(fs.writeFile);
18
+ const fsReadFile = (0, util_1.promisify)(fs.readFile);
19
19
  function updateConfig() {
20
20
  return __awaiter(this, void 0, void 0, function* () {
21
21
  const cwd = process.cwd();
@@ -26,16 +26,16 @@ function updateConfig() {
26
26
  return;
27
27
  }
28
28
  // console.log(process.cwd());
29
- let configFilename = 'workspace.json';
30
- let workspaceConfigPath = path.join(process.cwd(), '/../../..', configFilename);
31
- if (!fs.existsSync(workspaceConfigPath)) {
29
+ let configFilename = 'nx.json';
30
+ let nxConfigPath = path.join(process.cwd(), '/../../..', configFilename);
31
+ if (!fs.existsSync(nxConfigPath)) {
32
32
  configFilename = 'angular.json';
33
- workspaceConfigPath = path.join(process.cwd(), '/../../..', configFilename);
33
+ nxConfigPath = path.join(process.cwd(), '/../../..', configFilename);
34
34
  }
35
35
  // console.log(workspaceConfigPath);
36
36
  try {
37
37
  let ngCli;
38
- let config = fs.readFileSync(workspaceConfigPath, { encoding: 'utf-8' });
38
+ let config = fs.readFileSync(nxConfigPath, { encoding: 'utf-8' });
39
39
  if (config) {
40
40
  ngCli = JSON.parse(config);
41
41
  // update default
@@ -52,7 +52,7 @@ function updateConfig() {
52
52
  },
53
53
  };
54
54
  }
55
- fs.writeFileSync(workspaceConfigPath, JSON.stringify(ngCli, null, 2));
55
+ fs.writeFileSync(nxConfigPath, JSON.stringify(ngCli, null, 2));
56
56
  }
57
57
  catch (err) {
58
58
  console.warn(`An issue was detected during installation: ${configFilename} does not exist.`);
@@ -353,9 +353,9 @@ function createNativeScriptAngularApp(tree, withRouting) {
353
353
  }
354
354
  }
355
355
  exports.createNativeScriptAngularApp = createNativeScriptAngularApp;
356
- const isInModuleMetadata = (moduleName, property, value, inArray) => exports.isInDecoratorMetadata(moduleName, property, value, 'NgModule', inArray);
356
+ const isInModuleMetadata = (moduleName, property, value, inArray) => (0, exports.isInDecoratorMetadata)(moduleName, property, value, 'NgModule', inArray);
357
357
  exports.isInModuleMetadata = isInModuleMetadata;
358
- const isInComponentMetadata = (componentName, property, value, inArray) => exports.isInDecoratorMetadata(componentName, property, value, 'Component', inArray);
358
+ const isInComponentMetadata = (componentName, property, value, inArray) => (0, exports.isInDecoratorMetadata)(componentName, property, value, 'Component', inArray);
359
359
  exports.isInComponentMetadata = isInComponentMetadata;
360
360
  const isInDecoratorMetadata = (moduleName, property, value, decoratorName, inArray) => new RegExp(`@${decoratorName}\\(\\{([^}]*)` +
361
361
  objectContaining(property, value, inArray) +
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.runMigration = exports.callRule = exports.runSchematic = void 0;
4
4
  const path_1 = require("path");
5
5
  const testing_1 = require("@angular-devkit/schematics/testing");
6
- const testRunner = new testing_1.SchematicTestRunner('@nstudio/xplat', path_1.join(__dirname, '../../collection.json'));
7
- const migrationTestRunner = new testing_1.SchematicTestRunner('@nstudio/xplat/migrations', path_1.join(__dirname, '../../migrations.json'));
6
+ const testRunner = new testing_1.SchematicTestRunner('@nstudio/xplat', (0, path_1.join)(__dirname, '../../collection.json'));
7
+ const migrationTestRunner = new testing_1.SchematicTestRunner('@nstudio/xplat/migrations', (0, path_1.join)(__dirname, '../../migrations.json'));
8
8
  function runSchematic(schematicName, options, tree) {
9
9
  return testRunner.runSchematicAsync(schematicName, options, tree).toPromise();
10
10
  }
@@ -1,2 +1,2 @@
1
1
  export declare const xplatVersion = "*";
2
- export declare const nxVersion = "^12.0.0";
2
+ export declare const nxVersion = "^13.0.0";
@@ -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 = '12.7.0';
5
- exports.nxVersion = '^12.0.0';
4
+ exports.xplatVersion = '13.4.1';
5
+ exports.nxVersion = '^13.0.0';