@nestjs/schematics 8.0.2 → 8.0.6

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 (37) hide show
  1. package/dist/collection.json +34 -17
  2. package/dist/index.js +1 -1
  3. package/dist/lib/application/application.factory.js +6 -6
  4. package/dist/lib/application/files/js/package.json +11 -11
  5. package/dist/lib/application/files/ts/package.json +7 -6
  6. package/dist/lib/application/files/ts/tsconfig.json +6 -1
  7. package/dist/lib/application/schema.json +6 -1
  8. package/dist/lib/class/class.factory.js +6 -6
  9. package/dist/lib/client-app/angular/angular.factory.js +9 -9
  10. package/dist/lib/configuration/configuration.factory.js +4 -4
  11. package/dist/lib/controller/controller.factory.js +8 -8
  12. package/dist/lib/decorator/decorator.factory.js +5 -5
  13. package/dist/lib/filter/filter.factory.js +6 -6
  14. package/dist/lib/gateway/gateway.factory.js +8 -8
  15. package/dist/lib/guard/guard.factory.js +6 -6
  16. package/dist/lib/interceptor/interceptor.factory.js +6 -6
  17. package/dist/lib/interface/interface.factory.js +5 -5
  18. package/dist/lib/library/library.factory.js +19 -18
  19. package/dist/lib/middleware/middleware.factory.js +6 -6
  20. package/dist/lib/module/module.factory.js +7 -7
  21. package/dist/lib/pipe/pipe.factory.js +6 -6
  22. package/dist/lib/provider/provider.factory.js +8 -8
  23. package/dist/lib/resolver/resolver.factory.js +8 -8
  24. package/dist/lib/resource/resource.factory.js +13 -13
  25. package/dist/lib/service/service.factory.js +9 -9
  26. package/dist/lib/sub-app/files/ts/test/app.e2e-spec.ts +1 -1
  27. package/dist/lib/sub-app/sub-app.factory.js +28 -27
  28. package/dist/utils/index.js +1 -1
  29. package/dist/utils/json-file.util.js +7 -7
  30. package/dist/utils/metadata.manager.js +1 -1
  31. package/dist/utils/module-import.declarator.js +2 -2
  32. package/dist/utils/module.declarator.js +2 -2
  33. package/dist/utils/module.finder.js +1 -1
  34. package/dist/utils/name.parser.js +3 -3
  35. package/dist/utils/path.solver.js +2 -2
  36. package/dist/utils/source-root.helpers.js +2 -2
  37. package/package.json +18 -18
@@ -3,15 +3,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.main = void 0;
4
4
  const core_1 = require("@angular-devkit/core");
5
5
  const schematics_1 = require("@angular-devkit/schematics");
6
+ const jsonc_parser_1 = require("jsonc-parser");
6
7
  const defaults_1 = require("../defaults");
7
8
  function main(options) {
8
9
  options = transform(options);
9
- return schematics_1.chain([
10
+ return (0, schematics_1.chain)([
10
11
  addLibraryToCliOptions(options.path, options.name),
11
12
  updatePackageJson(options),
12
13
  updateJestEndToEnd(options),
13
14
  updateTsConfig(options.name, options.prefix, options.path),
14
- schematics_1.branchAndMerge(schematics_1.mergeWith(generate(options))),
15
+ (0, schematics_1.branchAndMerge)((0, schematics_1.mergeWith)(generate(options))),
15
16
  ]);
16
17
  }
17
18
  exports.main = main;
@@ -25,8 +26,8 @@ function transform(options) {
25
26
  target.name = core_1.strings.dasherize(target.name);
26
27
  target.path =
27
28
  target.path !== undefined
28
- ? core_1.join(core_1.normalize(defaultSourceRoot), target.path)
29
- : core_1.normalize(defaultSourceRoot);
29
+ ? (0, core_1.join)((0, core_1.normalize)(defaultSourceRoot), target.path)
30
+ : (0, core_1.normalize)(defaultSourceRoot);
30
31
  target.prefix = target.prefix || '@app';
31
32
  return target;
32
33
  }
@@ -35,7 +36,7 @@ function updatePackageJson(options) {
35
36
  if (!host.exists('package.json')) {
36
37
  return host;
37
38
  }
38
- const distRoot = core_1.join(options.path, options.name, 'src');
39
+ const distRoot = (0, core_1.join)(options.path, options.name, 'src');
39
40
  const packageKey = options.prefix
40
41
  ? options.prefix + '/' + options.name
41
42
  : options.name;
@@ -65,8 +66,8 @@ function updateJestConfig(jestOptions, options, packageKey, distRoot) {
65
66
  jestOptions.moduleNameMapper = {};
66
67
  }
67
68
  const packageKeyRegex = '^' + packageKey + '(|/.*)$';
68
- const packageRoot = core_1.join('<rootDir>', distRoot);
69
- jestOptions.moduleNameMapper[packageKeyRegex] = core_1.join(packageRoot, '$1');
69
+ const packageRoot = (0, core_1.join)('<rootDir>', distRoot);
70
+ jestOptions.moduleNameMapper[packageKeyRegex] = (0, core_1.join)(packageRoot, '$1');
70
71
  }
71
72
  function updateNpmScripts(scripts, options) {
72
73
  if (!scripts) {
@@ -84,11 +85,11 @@ function updateNpmScripts(scripts, options) {
84
85
  }
85
86
  function updateJestEndToEnd(options) {
86
87
  return (host) => {
87
- const pathToFile = core_1.join('test', 'jest-e2e.json');
88
+ const pathToFile = (0, core_1.join)('test', 'jest-e2e.json');
88
89
  if (!host.exists(pathToFile)) {
89
90
  return host;
90
91
  }
91
- const distRoot = core_1.join(options.path, options.name, 'src');
92
+ const distRoot = (0, core_1.join)(options.path, options.name, 'src');
92
93
  const packageKey = options.prefix
93
94
  ? options.prefix + '/' + options.name
94
95
  : options.name;
@@ -107,7 +108,7 @@ function updateJsonFile(host, path, callback) {
107
108
  const source = host.read(path);
108
109
  if (source) {
109
110
  const sourceText = source.toString('utf-8');
110
- const json = core_1.parseJson(sourceText);
111
+ const json = (0, jsonc_parser_1.parse)(sourceText);
111
112
  callback(json);
112
113
  host.overwrite(path, JSON.stringify(json, null, 2));
113
114
  }
@@ -118,7 +119,7 @@ function updateTsConfig(packageName, packagePrefix, root) {
118
119
  if (!host.exists('tsconfig.json')) {
119
120
  return host;
120
121
  }
121
- const distRoot = core_1.join(root, packageName, 'src');
122
+ const distRoot = (0, core_1.join)(root, packageName, 'src');
122
123
  const packageKey = packagePrefix
123
124
  ? packagePrefix + '/' + packageName
124
125
  : packageName;
@@ -145,14 +146,14 @@ function updateTsConfig(packageName, packagePrefix, root) {
145
146
  };
146
147
  }
147
148
  function addLibraryToCliOptions(projectRoot, projectName) {
148
- const rootPath = core_1.join(projectRoot, projectName);
149
+ const rootPath = (0, core_1.join)(projectRoot, projectName);
149
150
  const project = {
150
151
  type: defaults_1.PROJECT_TYPE.LIBRARY,
151
152
  root: rootPath,
152
153
  entryFile: 'index',
153
- sourceRoot: core_1.join(rootPath, 'src'),
154
+ sourceRoot: (0, core_1.join)(rootPath, 'src'),
154
155
  compilerOptions: {
155
- tsConfigPath: core_1.join(rootPath, 'tsconfig.lib.json'),
156
+ tsConfigPath: (0, core_1.join)(rootPath, 'tsconfig.lib.json'),
156
157
  },
157
158
  };
158
159
  return (host) => {
@@ -180,9 +181,9 @@ function addLibraryToCliOptions(projectRoot, projectName) {
180
181
  };
181
182
  }
182
183
  function generate(options) {
183
- const path = core_1.join(options.path, options.name);
184
- return schematics_1.apply(schematics_1.url(core_1.join('./files', options.language)), [
185
- schematics_1.template(Object.assign(Object.assign({}, core_1.strings), options)),
186
- schematics_1.move(path),
184
+ const path = (0, core_1.join)(options.path, options.name);
185
+ return (0, schematics_1.apply)((0, schematics_1.url)((0, core_1.join)('./files', options.language)), [
186
+ (0, schematics_1.template)(Object.assign(Object.assign({}, core_1.strings), options)),
187
+ (0, schematics_1.move)(path),
187
188
  ]);
188
189
  }
@@ -7,7 +7,7 @@ const name_parser_1 = require("../../utils/name.parser");
7
7
  const source_root_helpers_1 = require("../../utils/source-root.helpers");
8
8
  function main(options) {
9
9
  options = transform(options);
10
- return schematics_1.chain([source_root_helpers_1.mergeSourceRoot(options), schematics_1.mergeWith(generate(options))]);
10
+ return (0, schematics_1.chain)([(0, source_root_helpers_1.mergeSourceRoot)(options), (0, schematics_1.mergeWith)(generate(options))]);
11
11
  }
12
12
  exports.main = main;
13
13
  function transform(options) {
@@ -21,13 +21,13 @@ function transform(options) {
21
21
  target.language = target.language !== undefined ? target.language : 'ts';
22
22
  target.path = target.flat
23
23
  ? target.path
24
- : core_1.join(target.path, target.name);
24
+ : (0, core_1.join)(target.path, target.name);
25
25
  return target;
26
26
  }
27
27
  function generate(options) {
28
- return (context) => schematics_1.apply(schematics_1.url(core_1.join('./files', options.language)), [
29
- options.spec ? schematics_1.noop() : schematics_1.filter(path => !path.endsWith('.spec.ts')),
30
- schematics_1.template(Object.assign(Object.assign({}, core_1.strings), options)),
31
- schematics_1.move(options.path),
28
+ return (context) => (0, schematics_1.apply)((0, schematics_1.url)((0, core_1.join)('./files', options.language)), [
29
+ options.spec ? (0, schematics_1.noop)() : (0, schematics_1.filter)(path => !path.endsWith('.spec.ts')),
30
+ (0, schematics_1.template)(Object.assign(Object.assign({}, core_1.strings), options)),
31
+ (0, schematics_1.move)(options.path),
32
32
  ])(context);
33
33
  }
@@ -10,10 +10,10 @@ const source_root_helpers_1 = require("../../utils/source-root.helpers");
10
10
  function main(options) {
11
11
  options = transform(options);
12
12
  return (tree, context) => {
13
- return schematics_1.branchAndMerge(schematics_1.chain([
14
- source_root_helpers_1.mergeSourceRoot(options),
13
+ return (0, schematics_1.branchAndMerge)((0, schematics_1.chain)([
14
+ (0, source_root_helpers_1.mergeSourceRoot)(options),
15
15
  addDeclarationToModule(options),
16
- schematics_1.mergeWith(generate(options)),
16
+ (0, schematics_1.mergeWith)(generate(options)),
17
17
  ]))(tree, context);
18
18
  };
19
19
  }
@@ -28,13 +28,13 @@ function transform(source) {
28
28
  target.path = core_1.strings.dasherize(location.path);
29
29
  target.path = target.flat
30
30
  ? target.path
31
- : core_1.join(target.path, target.name);
31
+ : (0, core_1.join)(target.path, target.name);
32
32
  return target;
33
33
  }
34
34
  function generate(options) {
35
- return (context) => schematics_1.apply(schematics_1.url(core_1.join('./files', options.language)), [
36
- schematics_1.template(Object.assign(Object.assign({}, core_1.strings), options)),
37
- schematics_1.move(options.path),
35
+ return (context) => (0, schematics_1.apply)((0, schematics_1.url)((0, core_1.join)('./files', options.language)), [
36
+ (0, schematics_1.template)(Object.assign(Object.assign({}, core_1.strings), options)),
37
+ (0, schematics_1.move)(options.path),
38
38
  ])(context);
39
39
  }
40
40
  function addDeclarationToModule(options) {
@@ -7,7 +7,7 @@ const name_parser_1 = require("../../utils/name.parser");
7
7
  const source_root_helpers_1 = require("../../utils/source-root.helpers");
8
8
  function main(options) {
9
9
  options = transform(options);
10
- return schematics_1.chain([source_root_helpers_1.mergeSourceRoot(options), schematics_1.mergeWith(generate(options))]);
10
+ return (0, schematics_1.chain)([(0, source_root_helpers_1.mergeSourceRoot)(options), (0, schematics_1.mergeWith)(generate(options))]);
11
11
  }
12
12
  exports.main = main;
13
13
  function transform(options) {
@@ -21,13 +21,13 @@ function transform(options) {
21
21
  target.language = target.language !== undefined ? target.language : 'ts';
22
22
  target.path = target.flat
23
23
  ? target.path
24
- : core_1.join(target.path, target.name);
24
+ : (0, core_1.join)(target.path, target.name);
25
25
  return target;
26
26
  }
27
27
  function generate(options) {
28
- return (context) => schematics_1.apply(schematics_1.url(core_1.join('./files', options.language)), [
29
- options.spec ? schematics_1.noop() : schematics_1.filter(path => !path.endsWith('.spec.ts')),
30
- schematics_1.template(Object.assign(Object.assign({}, core_1.strings), options)),
31
- schematics_1.move(options.path),
28
+ return (context) => (0, schematics_1.apply)((0, schematics_1.url)((0, core_1.join)('./files', options.language)), [
29
+ options.spec ? (0, schematics_1.noop)() : (0, schematics_1.filter)(path => !path.endsWith('.spec.ts')),
30
+ (0, schematics_1.template)(Object.assign(Object.assign({}, core_1.strings), options)),
31
+ (0, schematics_1.move)(options.path),
32
32
  ])(context);
33
33
  }
@@ -10,10 +10,10 @@ const source_root_helpers_1 = require("../../utils/source-root.helpers");
10
10
  function main(options) {
11
11
  options = transform(options);
12
12
  return (tree, context) => {
13
- return schematics_1.branchAndMerge(schematics_1.chain([
14
- source_root_helpers_1.mergeSourceRoot(options),
13
+ return (0, schematics_1.branchAndMerge)((0, schematics_1.chain)([
14
+ (0, source_root_helpers_1.mergeSourceRoot)(options),
15
15
  addDeclarationToModule(options),
16
- schematics_1.mergeWith(generate(options)),
16
+ (0, schematics_1.mergeWith)(generate(options)),
17
17
  ]))(tree, context);
18
18
  };
19
19
  }
@@ -36,14 +36,14 @@ function transform(options) {
36
36
  target.language = target.language !== undefined ? target.language : 'ts';
37
37
  target.path = target.flat
38
38
  ? target.path
39
- : core_1.join(target.path, target.name);
39
+ : (0, core_1.join)(target.path, target.name);
40
40
  return target;
41
41
  }
42
42
  function generate(options) {
43
- return (context) => schematics_1.apply(schematics_1.url(core_1.join('./files', options.language)), [
44
- options.spec ? schematics_1.noop() : schematics_1.filter((path) => !path.endsWith('.spec.ts')),
45
- schematics_1.template(Object.assign(Object.assign({}, core_1.strings), options)),
46
- schematics_1.move(options.path),
43
+ return (context) => (0, schematics_1.apply)((0, schematics_1.url)((0, core_1.join)('./files', options.language)), [
44
+ options.spec ? (0, schematics_1.noop)() : (0, schematics_1.filter)((path) => !path.endsWith('.spec.ts')),
45
+ (0, schematics_1.template)(Object.assign(Object.assign({}, core_1.strings), options)),
46
+ (0, schematics_1.move)(options.path),
47
47
  ])(context);
48
48
  }
49
49
  function addDeclarationToModule(options) {
@@ -10,10 +10,10 @@ const source_root_helpers_1 = require("../../utils/source-root.helpers");
10
10
  function main(options) {
11
11
  options = transform(options);
12
12
  return (tree, context) => {
13
- return schematics_1.branchAndMerge(schematics_1.chain([
14
- source_root_helpers_1.mergeSourceRoot(options),
13
+ return (0, schematics_1.branchAndMerge)((0, schematics_1.chain)([
14
+ (0, source_root_helpers_1.mergeSourceRoot)(options),
15
15
  addDeclarationToModule(options),
16
- schematics_1.mergeWith(generate(options)),
16
+ (0, schematics_1.mergeWith)(generate(options)),
17
17
  ]))(tree, context);
18
18
  };
19
19
  }
@@ -31,14 +31,14 @@ function transform(options) {
31
31
  target.language = target.language !== undefined ? target.language : 'ts';
32
32
  target.path = target.flat
33
33
  ? target.path
34
- : core_1.join(target.path, target.name);
34
+ : (0, core_1.join)(target.path, target.name);
35
35
  return target;
36
36
  }
37
37
  function generate(options) {
38
- return (context) => schematics_1.apply(schematics_1.url(core_1.join('./files', options.language)), [
39
- options.spec ? schematics_1.noop() : schematics_1.filter(path => !path.endsWith('.spec.ts')),
40
- schematics_1.template(Object.assign(Object.assign({}, core_1.strings), options)),
41
- schematics_1.move(options.path),
38
+ return (context) => (0, schematics_1.apply)((0, schematics_1.url)((0, core_1.join)('./files', options.language)), [
39
+ options.spec ? (0, schematics_1.noop)() : (0, schematics_1.filter)(path => !path.endsWith('.spec.ts')),
40
+ (0, schematics_1.template)(Object.assign(Object.assign({}, core_1.strings), options)),
41
+ (0, schematics_1.move)(options.path),
42
42
  ])(context);
43
43
  }
44
44
  function addDeclarationToModule(options) {
@@ -13,11 +13,11 @@ const tasks_1 = require("@angular-devkit/schematics/tasks");
13
13
  function main(options) {
14
14
  options = transform(options);
15
15
  return (tree, context) => {
16
- return schematics_1.branchAndMerge(schematics_1.chain([
16
+ return (0, schematics_1.branchAndMerge)((0, schematics_1.chain)([
17
17
  addMappedTypesDependencyIfApplies(options),
18
- source_root_helpers_1.mergeSourceRoot(options),
18
+ (0, source_root_helpers_1.mergeSourceRoot)(options),
19
19
  addDeclarationToModule(options),
20
- schematics_1.mergeWith(generate(options)),
20
+ (0, schematics_1.mergeWith)(generate(options)),
21
21
  ]))(tree, context);
22
22
  };
23
23
  }
@@ -38,13 +38,13 @@ function transform(options) {
38
38
  }
39
39
  target.path = target.flat
40
40
  ? target.path
41
- : core_1.join(target.path, target.name);
41
+ : (0, core_1.join)(target.path, target.name);
42
42
  target.isSwaggerInstalled = (_a = options.isSwaggerInstalled) !== null && _a !== void 0 ? _a : false;
43
43
  return target;
44
44
  }
45
45
  function generate(options) {
46
- return (context) => schematics_1.apply(schematics_1.url(core_1.join('./files', options.language)), [
47
- schematics_1.filter((path) => {
46
+ return (context) => (0, schematics_1.apply)((0, schematics_1.url)((0, core_1.join)('./files', options.language)), [
47
+ (0, schematics_1.filter)((path) => {
48
48
  if (path.endsWith('.dto.ts')) {
49
49
  return (options.type !== 'graphql-code-first' &&
50
50
  options.type !== 'graphql-schema-first' &&
@@ -75,12 +75,12 @@ function generate(options) {
75
75
  }
76
76
  return true;
77
77
  }),
78
- options.spec ? schematics_1.noop() : schematics_1.filter((path) => !path.endsWith('.spec.ts')),
79
- schematics_1.template(Object.assign(Object.assign(Object.assign({}, core_1.strings), options), { lowercased: (name) => {
80
- const classifiedName = strings_1.classify(name);
78
+ options.spec ? (0, schematics_1.noop)() : (0, schematics_1.filter)((path) => !path.endsWith('.spec.ts')),
79
+ (0, schematics_1.template)(Object.assign(Object.assign(Object.assign({}, core_1.strings), options), { lowercased: (name) => {
80
+ const classifiedName = (0, strings_1.classify)(name);
81
81
  return (classifiedName.charAt(0).toLowerCase() + classifiedName.slice(1));
82
82
  }, singular: (name) => pluralize.singular(name), ent: (name) => name + '.entity' })),
83
- schematics_1.move(options.path),
83
+ (0, schematics_1.move)(options.path),
84
84
  ])(context);
85
85
  }
86
86
  function addDeclarationToModule(options) {
@@ -108,15 +108,15 @@ function addMappedTypesDependencyIfApplies(options) {
108
108
  return;
109
109
  }
110
110
  if (options.type === 'rest') {
111
- const nodeDependencyRef = dependencies_utils_1.getPackageJsonDependency(host, '@nestjs/swagger');
111
+ const nodeDependencyRef = (0, dependencies_utils_1.getPackageJsonDependency)(host, '@nestjs/swagger');
112
112
  if (nodeDependencyRef) {
113
113
  options.isSwaggerInstalled = true;
114
114
  return;
115
115
  }
116
116
  }
117
- const nodeDependencyRef = dependencies_utils_1.getPackageJsonDependency(host, '@nestjs/mapped-types');
117
+ const nodeDependencyRef = (0, dependencies_utils_1.getPackageJsonDependency)(host, '@nestjs/mapped-types');
118
118
  if (!nodeDependencyRef) {
119
- dependencies_utils_1.addPackageJsonDependency(host, {
119
+ (0, dependencies_utils_1.addPackageJsonDependency)(host, {
120
120
  type: dependencies_utils_1.NodeDependencyType.Default,
121
121
  name: '@nestjs/mapped-types',
122
122
  version: '*',
@@ -11,10 +11,10 @@ const source_root_helpers_1 = require("../../utils/source-root.helpers");
11
11
  function main(options) {
12
12
  options = transform(options);
13
13
  return (tree, context) => {
14
- return schematics_1.branchAndMerge(schematics_1.chain([
15
- source_root_helpers_1.mergeSourceRoot(options),
14
+ return (0, schematics_1.branchAndMerge)((0, schematics_1.chain)([
15
+ (0, source_root_helpers_1.mergeSourceRoot)(options),
16
16
  addDeclarationToModule(options),
17
- schematics_1.mergeWith(generate(options)),
17
+ (0, schematics_1.mergeWith)(generate(options)),
18
18
  ]))(tree, context);
19
19
  };
20
20
  }
@@ -23,7 +23,7 @@ function transform(source) {
23
23
  const target = Object.assign({}, source);
24
24
  target.metadata = 'providers';
25
25
  target.type = 'service';
26
- if (util_1.isNullOrUndefined(target.name)) {
26
+ if ((0, util_1.isNullOrUndefined)(target.name)) {
27
27
  throw new schematics_1.SchematicsException('Option (name) is required.');
28
28
  }
29
29
  const location = new name_parser_1.NameParser().parse(target);
@@ -32,14 +32,14 @@ function transform(source) {
32
32
  target.language = target.language !== undefined ? target.language : 'ts';
33
33
  target.path = target.flat
34
34
  ? target.path
35
- : core_1.join(target.path, target.name);
35
+ : (0, core_1.join)(target.path, target.name);
36
36
  return target;
37
37
  }
38
38
  function generate(options) {
39
- return (context) => schematics_1.apply(schematics_1.url(core_1.join('./files', options.language)), [
40
- options.spec ? schematics_1.noop() : schematics_1.filter(path => !path.endsWith('.spec.ts')),
41
- schematics_1.template(Object.assign(Object.assign({}, core_1.strings), options)),
42
- schematics_1.move(options.path),
39
+ return (context) => (0, schematics_1.apply)((0, schematics_1.url)((0, core_1.join)('./files', options.language)), [
40
+ options.spec ? (0, schematics_1.noop)() : (0, schematics_1.filter)(path => !path.endsWith('.spec.ts')),
41
+ (0, schematics_1.template)(Object.assign(Object.assign({}, core_1.strings), options)),
42
+ (0, schematics_1.move)(options.path),
43
43
  ])(context);
44
44
  }
45
45
  function addDeclarationToModule(options) {
@@ -1,7 +1,7 @@
1
1
  import { Test, TestingModule } from '@nestjs/testing';
2
2
  import { INestApplication } from '@nestjs/common';
3
3
  import * as request from 'supertest';
4
- import { <%= classify(name)%>Module } from './../src/<%= classify(name)%>.module';
4
+ import { <%= classify(name)%>Module } from './../src/<%= name %>.module';
5
5
 
6
6
  describe('<%= classify(name)%>Controller (e2e)', () => {
7
7
  let app: INestApplication;
@@ -3,22 +3,23 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.main = void 0;
4
4
  const core_1 = require("@angular-devkit/core");
5
5
  const schematics_1 = require("@angular-devkit/schematics");
6
+ const jsonc_parser_1 = require("jsonc-parser");
6
7
  const fse = require("fs-extra");
7
8
  const defaults_1 = require("../defaults");
8
9
  function main(options) {
9
10
  const appName = getAppNameFromPackageJson();
10
11
  options = transform(options);
11
- return schematics_1.chain([
12
+ return (0, schematics_1.chain)([
12
13
  updateTsConfig(),
13
14
  updatePackageJson(options, appName),
14
15
  (tree, context) => isMonorepo(tree)
15
- ? schematics_1.noop()(tree, context)
16
- : schematics_1.chain([
17
- schematics_1.branchAndMerge(schematics_1.mergeWith(generateWorkspace(options, appName))),
16
+ ? (0, schematics_1.noop)()(tree, context)
17
+ : (0, schematics_1.chain)([
18
+ (0, schematics_1.branchAndMerge)((0, schematics_1.mergeWith)(generateWorkspace(options, appName))),
18
19
  moveDefaultAppToApps(options.path, appName, options.sourceRoot),
19
20
  ])(tree, context),
20
21
  addAppsToCliOptions(options.path, options.name, appName),
21
- schematics_1.branchAndMerge(schematics_1.mergeWith(generate(options))),
22
+ (0, schematics_1.branchAndMerge)((0, schematics_1.mergeWith)(generate(options))),
22
23
  ]);
23
24
  }
24
25
  exports.main = main;
@@ -49,8 +50,8 @@ function transform(options) {
49
50
  target.name = core_1.strings.dasherize(target.name);
50
51
  target.path =
51
52
  target.path !== undefined
52
- ? core_1.join(core_1.normalize(defaultSourceRoot), target.path)
53
- : core_1.normalize(defaultSourceRoot);
53
+ ? (0, core_1.join)((0, core_1.normalize)(defaultSourceRoot), target.path)
54
+ : (0, core_1.normalize)(defaultSourceRoot);
54
55
  return target;
55
56
  }
56
57
  function isMonorepo(host) {
@@ -65,14 +66,14 @@ function isMonorepo(host) {
65
66
  return false;
66
67
  }
67
68
  const sourceText = source.toString('utf-8');
68
- const optionsObj = core_1.parseJson(sourceText);
69
+ const optionsObj = (0, jsonc_parser_1.parse)(sourceText);
69
70
  return !!optionsObj.monorepo;
70
71
  }
71
72
  function updateJsonFile(host, path, callback) {
72
73
  const source = host.read(path);
73
74
  if (source) {
74
75
  const sourceText = source.toString('utf-8');
75
- const json = core_1.parseJson(sourceText);
76
+ const json = (0, jsonc_parser_1.parse)(sourceText);
76
77
  callback(json);
77
78
  host.overwrite(path, JSON.stringify(json, null, 2));
78
79
  }
@@ -119,7 +120,7 @@ function updateNpmScripts(scripts, options, defaultAppName) {
119
120
  if (scripts[defaultTestScriptName] &&
120
121
  scripts[defaultTestScriptName].indexOf(options.path) < 0) {
121
122
  const defaultTestDir = 'test';
122
- const newTestDir = core_1.join(options.path, defaultAppName, defaultTestDir);
123
+ const newTestDir = (0, core_1.join)(options.path, defaultAppName, defaultTestDir);
123
124
  scripts[defaultTestScriptName] = scripts[defaultTestScriptName].replace(defaultTestDir, newTestDir);
124
125
  }
125
126
  if (scripts[defaultFormatScriptName] &&
@@ -157,11 +158,11 @@ function moveDefaultAppToApps(projectRoot, appName, sourceRoot = defaults_1.DEFA
157
158
  }
158
159
  try {
159
160
  if (fse.existsSync(sourceRoot)) {
160
- fse.moveSync(sourceRoot, core_1.join(projectRoot, appName, sourceRoot));
161
+ fse.moveSync(sourceRoot, (0, core_1.join)(projectRoot, appName, sourceRoot));
161
162
  }
162
163
  const testDir = 'test';
163
164
  if (fse.existsSync(testDir)) {
164
- fse.moveSync(testDir, core_1.join(projectRoot, appName, testDir));
165
+ fse.moveSync(testDir, (0, core_1.join)(projectRoot, appName, testDir));
165
166
  }
166
167
  }
167
168
  catch (err) {
@@ -171,14 +172,14 @@ function moveDefaultAppToApps(projectRoot, appName, sourceRoot = defaults_1.DEFA
171
172
  };
172
173
  }
173
174
  function addAppsToCliOptions(projectRoot, projectName, appName) {
174
- const rootPath = core_1.join(projectRoot, projectName);
175
+ const rootPath = (0, core_1.join)(projectRoot, projectName);
175
176
  const project = {
176
177
  type: defaults_1.PROJECT_TYPE.APPLICATION,
177
178
  root: rootPath,
178
179
  entryFile: 'main',
179
- sourceRoot: core_1.join(rootPath, defaults_1.DEFAULT_PATH_NAME),
180
+ sourceRoot: (0, core_1.join)(rootPath, defaults_1.DEFAULT_PATH_NAME),
180
181
  compilerOptions: {
181
- tsConfigPath: core_1.join(rootPath, 'tsconfig.app.json'),
182
+ tsConfigPath: (0, core_1.join)(rootPath, 'tsconfig.app.json'),
182
183
  },
183
184
  };
184
185
  return (host) => {
@@ -204,11 +205,11 @@ function updateMainAppOptions(optionsFile, projectRoot, appName) {
204
205
  if (optionsFile.monorepo) {
205
206
  return;
206
207
  }
207
- const rootFilePath = core_1.join(projectRoot, appName);
208
- const tsConfigPath = core_1.join(rootFilePath, 'tsconfig.app.json');
208
+ const rootFilePath = (0, core_1.join)(projectRoot, appName);
209
+ const tsConfigPath = (0, core_1.join)(rootFilePath, 'tsconfig.app.json');
209
210
  optionsFile.monorepo = true;
210
211
  optionsFile.root = rootFilePath;
211
- optionsFile.sourceRoot = core_1.join(projectRoot, appName, optionsFile.sourceRoot || defaults_1.DEFAULT_PATH_NAME);
212
+ optionsFile.sourceRoot = (0, core_1.join)(projectRoot, appName, optionsFile.sourceRoot || defaults_1.DEFAULT_PATH_NAME);
212
213
  if (!optionsFile.compilerOptions) {
213
214
  optionsFile.compilerOptions = {};
214
215
  }
@@ -221,23 +222,23 @@ function updateMainAppOptions(optionsFile, projectRoot, appName) {
221
222
  type: defaults_1.PROJECT_TYPE.APPLICATION,
222
223
  root: rootFilePath,
223
224
  entryFile: optionsFile.entryFile || 'main',
224
- sourceRoot: core_1.join(rootFilePath, defaults_1.DEFAULT_PATH_NAME),
225
+ sourceRoot: (0, core_1.join)(rootFilePath, defaults_1.DEFAULT_PATH_NAME),
225
226
  compilerOptions: {
226
227
  tsConfigPath,
227
228
  },
228
229
  };
229
230
  }
230
231
  function generateWorkspace(options, appName) {
231
- const path = core_1.join(options.path, appName);
232
- return schematics_1.apply(schematics_1.url(core_1.join('./workspace', options.language)), [
233
- schematics_1.template(Object.assign(Object.assign(Object.assign({}, core_1.strings), options), { name: appName })),
234
- schematics_1.move(path),
232
+ const path = (0, core_1.join)(options.path, appName);
233
+ return (0, schematics_1.apply)((0, schematics_1.url)((0, core_1.join)('./workspace', options.language)), [
234
+ (0, schematics_1.template)(Object.assign(Object.assign(Object.assign({}, core_1.strings), options), { name: appName })),
235
+ (0, schematics_1.move)(path),
235
236
  ]);
236
237
  }
237
238
  function generate(options) {
238
- const path = core_1.join(options.path, options.name);
239
- return schematics_1.apply(schematics_1.url(core_1.join('./files', options.language)), [
240
- schematics_1.template(Object.assign(Object.assign({}, core_1.strings), options)),
241
- schematics_1.move(path),
239
+ const path = (0, core_1.join)(options.path, options.name);
240
+ return (0, schematics_1.apply)((0, schematics_1.url)((0, core_1.join)('./files', options.language)), [
241
+ (0, schematics_1.template)(Object.assign(Object.assign({}, core_1.strings), options)),
242
+ (0, schematics_1.move)(path),
242
243
  ]);
243
244
  }
@@ -7,7 +7,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
7
7
  o[k2] = m[k];
8
8
  }));
9
9
  var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
- for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
10
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
11
  };
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
13
  __exportStar(require("./metadata.manager"), exports);
@@ -19,12 +19,12 @@ class JSONFile {
19
19
  return this._jsonAst;
20
20
  }
21
21
  const errors = [];
22
- this._jsonAst = jsonc_parser_1.parseTree(this.content, errors, {
22
+ this._jsonAst = (0, jsonc_parser_1.parseTree)(this.content, errors, {
23
23
  allowTrailingComma: true,
24
24
  });
25
25
  if (errors.length) {
26
26
  const { error, offset } = errors[0];
27
- throw new Error(`Failed to parse "${this.path}" as JSON AST Object. ${jsonc_parser_1.printParseErrorCode(error)} at location: ${offset}.`);
27
+ throw new Error(`Failed to parse "${this.path}" as JSON AST Object. ${(0, jsonc_parser_1.printParseErrorCode)(error)} at location: ${offset}.`);
28
28
  }
29
29
  return this._jsonAst;
30
30
  }
@@ -34,10 +34,10 @@ class JSONFile {
34
34
  return undefined;
35
35
  }
36
36
  if (jsonPath.length === 0) {
37
- return jsonc_parser_1.getNodeValue(jsonAstNode);
37
+ return (0, jsonc_parser_1.getNodeValue)(jsonAstNode);
38
38
  }
39
- const node = jsonc_parser_1.findNodeAtLocation(jsonAstNode, jsonPath);
40
- return node === undefined ? undefined : jsonc_parser_1.getNodeValue(node);
39
+ const node = (0, jsonc_parser_1.findNodeAtLocation)(jsonAstNode, jsonPath);
40
+ return node === undefined ? undefined : (0, jsonc_parser_1.getNodeValue)(node);
41
41
  }
42
42
  modify(jsonPath, value, insertInOrder) {
43
43
  let getInsertionIndex;
@@ -48,14 +48,14 @@ class JSONFile {
48
48
  else if (insertInOrder !== false) {
49
49
  getInsertionIndex = insertInOrder;
50
50
  }
51
- const edits = jsonc_parser_1.modify(this.content, jsonPath, value, {
51
+ const edits = (0, jsonc_parser_1.modify)(this.content, jsonPath, value, {
52
52
  getInsertionIndex,
53
53
  formattingOptions: {
54
54
  insertSpaces: true,
55
55
  tabSize: 2,
56
56
  },
57
57
  });
58
- this.content = jsonc_parser_1.applyEdits(this.content, edits);
58
+ this.content = (0, jsonc_parser_1.applyEdits)(this.content, edits);
59
59
  this.host.overwrite(this.path, this.content);
60
60
  this._jsonAst = undefined;
61
61
  }
@@ -7,7 +7,7 @@ class MetadataManager {
7
7
  this.content = content;
8
8
  }
9
9
  insert(metadata, symbol, staticOptions) {
10
- const source = typescript_1.createSourceFile('filename.ts', this.content, typescript_1.ScriptTarget.ES2017);
10
+ const source = (0, typescript_1.createSourceFile)('filename.ts', this.content, typescript_1.ScriptTarget.ES2017);
11
11
  const decoratorNodes = this.getDecoratorMetadata(source, '@Module');
12
12
  const node = decoratorNodes[0];
13
13
  const matchingProperties = node.properties
@@ -28,10 +28,10 @@ class ModuleImportDeclarator {
28
28
  computeRelativePath(options) {
29
29
  let importModulePath;
30
30
  if (options.type !== undefined) {
31
- importModulePath = core_1.normalize(`/${options.path}/${options.name}.${options.type}`);
31
+ importModulePath = (0, core_1.normalize)(`/${options.path}/${options.name}.${options.type}`);
32
32
  }
33
33
  else {
34
- importModulePath = core_1.normalize(`/${options.path}/${options.name}`);
34
+ importModulePath = (0, core_1.normalize)(`/${options.path}/${options.name}`);
35
35
  }
36
36
  return this.solver.relative(options.module, importModulePath);
37
37
  }
@@ -21,10 +21,10 @@ class ModuleDeclarator {
21
21
  target.symbol = options.className;
22
22
  }
23
23
  else if (options.type !== undefined) {
24
- target.symbol = strings_1.classify(options.name).concat(strings_1.capitalize(options.type));
24
+ target.symbol = (0, strings_1.classify)(options.name).concat((0, strings_1.capitalize)(options.type));
25
25
  }
26
26
  else {
27
- target.symbol = strings_1.classify(options.name);
27
+ target.symbol = (0, strings_1.classify)(options.name);
28
28
  }
29
29
  return target;
30
30
  }
@@ -17,7 +17,7 @@ class ModuleFinder {
17
17
  }
18
18
  const moduleFilename = directory.subfiles.find(filename => /\.module\.(t|j)s$/.test(filename));
19
19
  return moduleFilename !== undefined
20
- ? core_1.join(directory.path, moduleFilename.valueOf())
20
+ ? (0, core_1.join)(directory.path, moduleFilename.valueOf())
21
21
  : this.findIn(directory.parent);
22
22
  }
23
23
  }