@nx/devkit 16.0.0-beta.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 (138) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/LICENSE +22 -0
  3. package/README.md +63 -0
  4. package/index.d.ts +19 -0
  5. package/index.js +27 -0
  6. package/migrations.json +12 -0
  7. package/ngcli-adapter.d.ts +4 -0
  8. package/ngcli-adapter.js +13 -0
  9. package/ngcli-adapter.js.map +1 -0
  10. package/nx-reexports-pre16.d.ts +127 -0
  11. package/nx-reexports-pre16.js +141 -0
  12. package/nx-reexports-pre16.js.map +1 -0
  13. package/nx.d.ts +1 -0
  14. package/nx.js +13 -0
  15. package/nx.js.map +1 -0
  16. package/package.json +49 -0
  17. package/public-api.d.ts +82 -0
  18. package/public-api.js +114 -0
  19. package/public-api.js.map +1 -0
  20. package/src/executors/parse-target-string.d.ts +31 -0
  21. package/src/executors/parse-target-string.js +36 -0
  22. package/src/executors/parse-target-string.js.map +1 -0
  23. package/src/executors/read-target-options.d.ts +8 -0
  24. package/src/executors/read-target-options.js +24 -0
  25. package/src/executors/read-target-options.js.map +1 -0
  26. package/src/generators/executor-options-utils.d.ts +21 -0
  27. package/src/generators/executor-options-utils.js +50 -0
  28. package/src/generators/executor-options-utils.js.map +1 -0
  29. package/src/generators/format-files.d.ts +6 -0
  30. package/src/generators/format-files.js +75 -0
  31. package/src/generators/format-files.js.map +1 -0
  32. package/src/generators/generate-files.d.ts +26 -0
  33. package/src/generators/generate-files.js +120 -0
  34. package/src/generators/generate-files.js.map +1 -0
  35. package/src/generators/run-tasks-in-serial.d.ts +7 -0
  36. package/src/generators/run-tasks-in-serial.js +18 -0
  37. package/src/generators/run-tasks-in-serial.js.map +1 -0
  38. package/src/generators/to-js.d.ts +5 -0
  39. package/src/generators/to-js.js +25 -0
  40. package/src/generators/to-js.js.map +1 -0
  41. package/src/generators/typescript/insert-import.d.ts +1 -0
  42. package/src/generators/typescript/insert-import.js +6 -0
  43. package/src/generators/typescript/insert-import.js.map +1 -0
  44. package/src/generators/typescript/insert-statement.d.ts +1 -0
  45. package/src/generators/typescript/insert-statement.js +6 -0
  46. package/src/generators/typescript/insert-statement.js.map +1 -0
  47. package/src/generators/update-ts-configs-to-js.d.ts +4 -0
  48. package/src/generators/update-ts-configs-to-js.js +50 -0
  49. package/src/generators/update-ts-configs-to-js.js.map +1 -0
  50. package/src/generators/visit-not-ignored-files.d.ts +5 -0
  51. package/src/generators/visit-not-ignored-files.js +37 -0
  52. package/src/generators/visit-not-ignored-files.js.map +1 -0
  53. package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.d.ts +2 -0
  54. package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js +13 -0
  55. package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js.map +1 -0
  56. package/src/tasks/install-packages-task.d.ts +10 -0
  57. package/src/tasks/install-packages-task.js +35 -0
  58. package/src/tasks/install-packages-task.js.map +1 -0
  59. package/src/utils/async-iterable/combine-async-iterables.d.ts +3 -0
  60. package/src/utils/async-iterable/combine-async-iterables.js +82 -0
  61. package/src/utils/async-iterable/combine-async-iterables.js.map +1 -0
  62. package/src/utils/async-iterable/create-async-iterable.d.ts +6 -0
  63. package/src/utils/async-iterable/create-async-iterable.js +62 -0
  64. package/src/utils/async-iterable/create-async-iterable.js.map +1 -0
  65. package/src/utils/async-iterable/index.d.ts +4 -0
  66. package/src/utils/async-iterable/index.js +8 -0
  67. package/src/utils/async-iterable/index.js.map +1 -0
  68. package/src/utils/async-iterable/map-async-iteratable.d.ts +1 -0
  69. package/src/utils/async-iterable/map-async-iteratable.js +24 -0
  70. package/src/utils/async-iterable/map-async-iteratable.js.map +1 -0
  71. package/src/utils/async-iterable/tap-async-iteratable.d.ts +1 -0
  72. package/src/utils/async-iterable/tap-async-iteratable.js +15 -0
  73. package/src/utils/async-iterable/tap-async-iteratable.js.map +1 -0
  74. package/src/utils/convert-nx-executor.d.ts +7 -0
  75. package/src/utils/convert-nx-executor.js +88 -0
  76. package/src/utils/convert-nx-executor.js.map +1 -0
  77. package/src/utils/get-workspace-layout.d.ts +25 -0
  78. package/src/utils/get-workspace-layout.js +53 -0
  79. package/src/utils/get-workspace-layout.js.map +1 -0
  80. package/src/utils/invoke-nx-generator.d.ts +6 -0
  81. package/src/utils/invoke-nx-generator.js +174 -0
  82. package/src/utils/invoke-nx-generator.js.map +1 -0
  83. package/src/utils/module-federation/dependencies.d.ts +6 -0
  84. package/src/utils/module-federation/dependencies.js +47 -0
  85. package/src/utils/module-federation/dependencies.js.map +1 -0
  86. package/src/utils/module-federation/index.d.ts +5 -0
  87. package/src/utils/module-federation/index.js +9 -0
  88. package/src/utils/module-federation/index.js.map +1 -0
  89. package/src/utils/module-federation/models/index.d.ts +39 -0
  90. package/src/utils/module-federation/models/index.js +3 -0
  91. package/src/utils/module-federation/models/index.js.map +1 -0
  92. package/src/utils/module-federation/package-json.d.ts +8 -0
  93. package/src/utils/module-federation/package-json.js +15 -0
  94. package/src/utils/module-federation/package-json.js.map +1 -0
  95. package/src/utils/module-federation/remotes.d.ts +19 -0
  96. package/src/utils/module-federation/remotes.js +59 -0
  97. package/src/utils/module-federation/remotes.js.map +1 -0
  98. package/src/utils/module-federation/secondary-entry-points.d.ts +12 -0
  99. package/src/utils/module-federation/secondary-entry-points.js +106 -0
  100. package/src/utils/module-federation/secondary-entry-points.js.map +1 -0
  101. package/src/utils/module-federation/share.d.ts +48 -0
  102. package/src/utils/module-federation/share.js +187 -0
  103. package/src/utils/module-federation/share.js.map +1 -0
  104. package/src/utils/module-federation/typescript.d.ts +3 -0
  105. package/src/utils/module-federation/typescript.js +39 -0
  106. package/src/utils/module-federation/typescript.js.map +1 -0
  107. package/src/utils/move-dir.d.ts +5 -0
  108. package/src/utils/move-dir.js +29 -0
  109. package/src/utils/move-dir.js.map +1 -0
  110. package/src/utils/names.d.ts +18 -0
  111. package/src/utils/names.js +63 -0
  112. package/src/utils/names.js.map +1 -0
  113. package/src/utils/offset-from-root.d.ts +13 -0
  114. package/src/utils/offset-from-root.js +30 -0
  115. package/src/utils/offset-from-root.js.map +1 -0
  116. package/src/utils/package-json.d.ts +74 -0
  117. package/src/utils/package-json.js +305 -0
  118. package/src/utils/package-json.js.map +1 -0
  119. package/src/utils/replace-package.d.ts +2 -0
  120. package/src/utils/replace-package.js +107 -0
  121. package/src/utils/replace-package.js.map +1 -0
  122. package/src/utils/rxjs-for-await.d.ts +109 -0
  123. package/src/utils/rxjs-for-await.js +373 -0
  124. package/src/utils/rxjs-for-await.js.map +1 -0
  125. package/src/utils/semver.d.ts +1 -0
  126. package/src/utils/semver.js +19 -0
  127. package/src/utils/semver.js.map +1 -0
  128. package/src/utils/string-change.d.ts +62 -0
  129. package/src/utils/string-change.js +110 -0
  130. package/src/utils/string-change.js.map +1 -0
  131. package/src/utils/string-utils.d.ts +95 -0
  132. package/src/utils/string-utils.js +148 -0
  133. package/src/utils/string-utils.js.map +1 -0
  134. package/testing-pre16.d.ts +2 -0
  135. package/testing-pre16.js +10 -0
  136. package/testing-pre16.js.map +1 -0
  137. package/testing.d.ts +2 -0
  138. package/testing.js +9 -0
package/public-api.js ADDED
@@ -0,0 +1,114 @@
1
+ "use strict";
2
+ /**
3
+ * Note to developers: STOP! This is the Public API of @nrwl/devkit.
4
+ * @nrwl/devkit should be compatible with versions of Nx 1 major version prior.
5
+ * This is so that plugins can use the latest @nrwl/devkit while their users may use versions +/- 1 of Nx.
6
+ *
7
+ * 1. Try hard to not add to this API to reduce the surface area we need to maintain.
8
+ * 2. Do not add newly created paths from the nx package to this file as they will not be available in older versions of Nx.
9
+ * a. We might need to duplicate code instead of importing from nx until all supported versions of nx contain the file.
10
+ */
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.readRootPackageJson = exports.getDependentPackagesForProject = exports.sharePackages = exports.shareWorkspaceLibraries = exports.getNpmPackageSharedConfig = exports.mapRemotesForSSR = exports.mapRemotes = exports.applyAdditionalShared = exports.applySharedFunction = exports.moveFilesToNewDirectory = exports.convertNxExecutor = exports.convertNxGenerator = exports.offsetFromRoot = exports.ChangeType = exports.applyChangesToString = exports.extractLayoutDirectory = exports.getWorkspaceLayout = exports.names = exports.installPackagesTask = exports.NX_VERSION = exports.removeDependenciesFromPackageJson = exports.ensurePackage = exports.addDependenciesToPackageJson = exports.readTargetOptions = exports.targetToTargetString = exports.parseTargetString = exports.visitNotIgnoredFiles = exports.runTasksInSerial = exports.updateTsConfigsToJs = exports.toJS = exports.generateFiles = exports.formatFiles = void 0;
13
+ /**
14
+ * @category Generators
15
+ */
16
+ var format_files_1 = require("./src/generators/format-files");
17
+ Object.defineProperty(exports, "formatFiles", { enumerable: true, get: function () { return format_files_1.formatFiles; } });
18
+ /**
19
+ * @category Generators
20
+ */
21
+ var generate_files_1 = require("./src/generators/generate-files");
22
+ Object.defineProperty(exports, "generateFiles", { enumerable: true, get: function () { return generate_files_1.generateFiles; } });
23
+ /**
24
+ * @category Generators
25
+ */
26
+ var to_js_1 = require("./src/generators/to-js");
27
+ Object.defineProperty(exports, "toJS", { enumerable: true, get: function () { return to_js_1.toJS; } });
28
+ /**
29
+ * @category Generators
30
+ */
31
+ var update_ts_configs_to_js_1 = require("./src/generators/update-ts-configs-to-js");
32
+ Object.defineProperty(exports, "updateTsConfigsToJs", { enumerable: true, get: function () { return update_ts_configs_to_js_1.updateTsConfigsToJs; } });
33
+ /**
34
+ * @category Generators
35
+ */
36
+ var run_tasks_in_serial_1 = require("./src/generators/run-tasks-in-serial");
37
+ Object.defineProperty(exports, "runTasksInSerial", { enumerable: true, get: function () { return run_tasks_in_serial_1.runTasksInSerial; } });
38
+ /**
39
+ * @category Generators
40
+ */
41
+ var visit_not_ignored_files_1 = require("./src/generators/visit-not-ignored-files");
42
+ Object.defineProperty(exports, "visitNotIgnoredFiles", { enumerable: true, get: function () { return visit_not_ignored_files_1.visitNotIgnoredFiles; } });
43
+ var parse_target_string_1 = require("./src/executors/parse-target-string");
44
+ Object.defineProperty(exports, "parseTargetString", { enumerable: true, get: function () { return parse_target_string_1.parseTargetString; } });
45
+ Object.defineProperty(exports, "targetToTargetString", { enumerable: true, get: function () { return parse_target_string_1.targetToTargetString; } });
46
+ /**
47
+ * @category Executors
48
+ */
49
+ var read_target_options_1 = require("./src/executors/read-target-options");
50
+ Object.defineProperty(exports, "readTargetOptions", { enumerable: true, get: function () { return read_target_options_1.readTargetOptions; } });
51
+ /**
52
+ * @category Utils
53
+ */
54
+ var package_json_1 = require("./src/utils/package-json");
55
+ Object.defineProperty(exports, "addDependenciesToPackageJson", { enumerable: true, get: function () { return package_json_1.addDependenciesToPackageJson; } });
56
+ Object.defineProperty(exports, "ensurePackage", { enumerable: true, get: function () { return package_json_1.ensurePackage; } });
57
+ Object.defineProperty(exports, "removeDependenciesFromPackageJson", { enumerable: true, get: function () { return package_json_1.removeDependenciesFromPackageJson; } });
58
+ Object.defineProperty(exports, "NX_VERSION", { enumerable: true, get: function () { return package_json_1.NX_VERSION; } });
59
+ /**
60
+ * @category Utils
61
+ */
62
+ var install_packages_task_1 = require("./src/tasks/install-packages-task");
63
+ Object.defineProperty(exports, "installPackagesTask", { enumerable: true, get: function () { return install_packages_task_1.installPackagesTask; } });
64
+ /**
65
+ * @category Utils
66
+ */
67
+ var names_1 = require("./src/utils/names");
68
+ Object.defineProperty(exports, "names", { enumerable: true, get: function () { return names_1.names; } });
69
+ /**
70
+ * @category Utils
71
+ */
72
+ var get_workspace_layout_1 = require("./src/utils/get-workspace-layout");
73
+ Object.defineProperty(exports, "getWorkspaceLayout", { enumerable: true, get: function () { return get_workspace_layout_1.getWorkspaceLayout; } });
74
+ Object.defineProperty(exports, "extractLayoutDirectory", { enumerable: true, get: function () { return get_workspace_layout_1.extractLayoutDirectory; } });
75
+ /**
76
+ * @category Utils
77
+ */
78
+ var string_change_1 = require("./src/utils/string-change");
79
+ Object.defineProperty(exports, "applyChangesToString", { enumerable: true, get: function () { return string_change_1.applyChangesToString; } });
80
+ Object.defineProperty(exports, "ChangeType", { enumerable: true, get: function () { return string_change_1.ChangeType; } });
81
+ /**
82
+ * @category Utils
83
+ */
84
+ var offset_from_root_1 = require("./src/utils/offset-from-root");
85
+ Object.defineProperty(exports, "offsetFromRoot", { enumerable: true, get: function () { return offset_from_root_1.offsetFromRoot; } });
86
+ /**
87
+ * @category Utils
88
+ */
89
+ var invoke_nx_generator_1 = require("./src/utils/invoke-nx-generator");
90
+ Object.defineProperty(exports, "convertNxGenerator", { enumerable: true, get: function () { return invoke_nx_generator_1.convertNxGenerator; } });
91
+ /**
92
+ * @category Utils
93
+ */
94
+ var convert_nx_executor_1 = require("./src/utils/convert-nx-executor");
95
+ Object.defineProperty(exports, "convertNxExecutor", { enumerable: true, get: function () { return convert_nx_executor_1.convertNxExecutor; } });
96
+ /**
97
+ * @category Utils
98
+ */
99
+ var move_dir_1 = require("./src/utils/move-dir");
100
+ Object.defineProperty(exports, "moveFilesToNewDirectory", { enumerable: true, get: function () { return move_dir_1.moveFilesToNewDirectory; } });
101
+ /**
102
+ * @category Utils
103
+ */
104
+ var module_federation_1 = require("./src/utils/module-federation");
105
+ Object.defineProperty(exports, "applySharedFunction", { enumerable: true, get: function () { return module_federation_1.applySharedFunction; } });
106
+ Object.defineProperty(exports, "applyAdditionalShared", { enumerable: true, get: function () { return module_federation_1.applyAdditionalShared; } });
107
+ Object.defineProperty(exports, "mapRemotes", { enumerable: true, get: function () { return module_federation_1.mapRemotes; } });
108
+ Object.defineProperty(exports, "mapRemotesForSSR", { enumerable: true, get: function () { return module_federation_1.mapRemotesForSSR; } });
109
+ Object.defineProperty(exports, "getNpmPackageSharedConfig", { enumerable: true, get: function () { return module_federation_1.getNpmPackageSharedConfig; } });
110
+ Object.defineProperty(exports, "shareWorkspaceLibraries", { enumerable: true, get: function () { return module_federation_1.shareWorkspaceLibraries; } });
111
+ Object.defineProperty(exports, "sharePackages", { enumerable: true, get: function () { return module_federation_1.sharePackages; } });
112
+ Object.defineProperty(exports, "getDependentPackagesForProject", { enumerable: true, get: function () { return module_federation_1.getDependentPackagesForProject; } });
113
+ Object.defineProperty(exports, "readRootPackageJson", { enumerable: true, get: function () { return module_federation_1.readRootPackageJson; } });
114
+ //# sourceMappingURL=public-api.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"public-api.js","sourceRoot":"","sources":["../../../packages/devkit/public-api.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;AAEH;;GAEG;AACH,8DAA4D;AAAnD,2GAAA,WAAW,OAAA;AAEpB;;GAEG;AACH,kEAAgE;AAAvD,+GAAA,aAAa,OAAA;AAEtB;;GAEG;AACH,gDAA8C;AAArC,6FAAA,IAAI,OAAA;AAEb;;GAEG;AACH,oFAA+E;AAAtE,8HAAA,mBAAmB,OAAA;AAE5B;;GAEG;AACH,4EAAwE;AAA/D,uHAAA,gBAAgB,OAAA;AAEzB;;GAEG;AACH,oFAAgF;AAAvE,+HAAA,oBAAoB,OAAA;AAE7B,2EAG6C;AAF3C,wHAAA,iBAAiB,OAAA;AACjB,2HAAA,oBAAoB,OAAA;AAGtB;;GAEG;AACH,2EAAwE;AAA/D,wHAAA,iBAAiB,OAAA;AAE1B;;GAEG;AACH,yDAKkC;AAJhC,4HAAA,4BAA4B,OAAA;AAC5B,6GAAA,aAAa,OAAA;AACb,iIAAA,iCAAiC,OAAA;AACjC,0GAAA,UAAU,OAAA;AAGZ;;GAEG;AACH,2EAAwE;AAA/D,4HAAA,mBAAmB,OAAA;AAE5B;;GAEG;AACH,2CAA0C;AAAjC,8FAAA,KAAK,OAAA;AAEd;;GAEG;AACH,yEAG0C;AAFxC,0HAAA,kBAAkB,OAAA;AAClB,8HAAA,sBAAsB,OAAA;AAYxB;;GAEG;AACH,2DAA6E;AAApE,qHAAA,oBAAoB,OAAA;AAAE,2GAAA,UAAU,OAAA;AAEzC;;GAEG;AACH,iEAA8D;AAArD,kHAAA,cAAc,OAAA;AAEvB;;GAEG;AACH,uEAAqE;AAA5D,yHAAA,kBAAkB,OAAA;AAE3B;;GAEG;AACH,uEAAoE;AAA3D,wHAAA,iBAAiB,OAAA;AAE1B;;GAEG;AACH,iDAA+D;AAAtD,mHAAA,uBAAuB,OAAA;AAEhC;;GAEG;AACH,mEAmBuC;AAfrC,wHAAA,mBAAmB,OAAA;AACnB,0HAAA,qBAAqB,OAAA;AACrB,+GAAA,UAAU,OAAA;AACV,qHAAA,gBAAgB,OAAA;AAChB,8HAAA,yBAAyB,OAAA;AACzB,4HAAA,uBAAuB,OAAA;AACvB,kHAAA,aAAa,OAAA;AACb,mIAAA,8BAA8B,OAAA;AAG9B,wHAAA,mBAAmB,OAAA"}
@@ -0,0 +1,31 @@
1
+ import type { Target } from 'nx/src/command-line/run';
2
+ import type { ProjectGraph } from 'nx/src/config/project-graph';
3
+ /**
4
+ * @deprecated(v17) A project graph should be passed to parseTargetString for best accuracy.
5
+ */
6
+ export declare function parseTargetString(targetString: string): Target;
7
+ /**
8
+ * Parses a target string into {project, target, configuration}
9
+ *
10
+ * Examples:
11
+ * ```typescript
12
+ * parseTargetString("proj:test", graph) // returns { project: "proj", target: "test" }
13
+ * parseTargetString("proj:test:production", graph) // returns { project: "proj", target: "test", configuration: "production" }
14
+ * ```
15
+ *
16
+ * @param targetString - target reference
17
+ */
18
+ export declare function parseTargetString(targetString: string, projectGraph: ProjectGraph): Target;
19
+ /**
20
+ * Returns a string in the format "project:target[:configuration]" for the target
21
+ *
22
+ * @param target - target object
23
+ *
24
+ * Examples:
25
+ *
26
+ * ```typescript
27
+ * targetToTargetString({ project: "proj", target: "test" }) // returns "proj:test"
28
+ * targetToTargetString({ project: "proj", target: "test", configuration: "production" }) // returns "proj:test:production"
29
+ * ```
30
+ */
31
+ export declare function targetToTargetString({ project, target, configuration, }: Target): string;
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.targetToTargetString = exports.parseTargetString = void 0;
4
+ // eslint-disable-next-line @typescript-eslint/no-restricted-imports
5
+ const split_target_1 = require("nx/src/utils/split-target");
6
+ const nx_1 = require("../../nx");
7
+ const { readCachedProjectGraph } = (0, nx_1.requireNx)();
8
+ function parseTargetString(targetString, projectGraph = readCachedProjectGraph()) {
9
+ const [project, target, configuration] = (0, split_target_1.splitTarget)(targetString, projectGraph);
10
+ if (!project || !target) {
11
+ throw new Error(`Invalid Target String: ${targetString}`);
12
+ }
13
+ return {
14
+ project,
15
+ target,
16
+ configuration,
17
+ };
18
+ }
19
+ exports.parseTargetString = parseTargetString;
20
+ /**
21
+ * Returns a string in the format "project:target[:configuration]" for the target
22
+ *
23
+ * @param target - target object
24
+ *
25
+ * Examples:
26
+ *
27
+ * ```typescript
28
+ * targetToTargetString({ project: "proj", target: "test" }) // returns "proj:test"
29
+ * targetToTargetString({ project: "proj", target: "test", configuration: "production" }) // returns "proj:test:production"
30
+ * ```
31
+ */
32
+ function targetToTargetString({ project, target, configuration, }) {
33
+ return `${project}:${target.indexOf(':') > -1 ? `"${target}"` : target}${configuration !== undefined ? ':' + configuration : ''}`;
34
+ }
35
+ exports.targetToTargetString = targetToTargetString;
36
+ //# sourceMappingURL=parse-target-string.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parse-target-string.js","sourceRoot":"","sources":["../../../../../packages/devkit/src/executors/parse-target-string.ts"],"names":[],"mappings":";;;AAEA,oEAAoE;AACpE,4DAAwD;AACxD,iCAAqC;AAErC,MAAM,EAAE,sBAAsB,EAAE,GAAG,IAAA,cAAS,GAAE,CAAC;AAqB/C,SAAgB,iBAAiB,CAC/B,YAAoB,EACpB,YAAY,GAAG,sBAAsB,EAAE;IAEvC,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,aAAa,CAAC,GAAG,IAAA,0BAAW,EAClD,YAAY,EACZ,YAAY,CACb,CAAC;IACF,IAAI,CAAC,OAAO,IAAI,CAAC,MAAM,EAAE;QACvB,MAAM,IAAI,KAAK,CAAC,0BAA0B,YAAY,EAAE,CAAC,CAAC;KAC3D;IACD,OAAO;QACL,OAAO;QACP,MAAM;QACN,aAAa;KACd,CAAC;AACJ,CAAC;AAhBD,8CAgBC;AAED;;;;;;;;;;;GAWG;AACH,SAAgB,oBAAoB,CAAC,EACnC,OAAO,EACP,MAAM,EACN,aAAa,GACN;IACP,OAAO,GAAG,OAAO,IAAI,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,MAAM,GAAG,CAAC,CAAC,CAAC,MAAM,GACpE,aAAa,KAAK,SAAS,CAAC,CAAC,CAAC,GAAG,GAAG,aAAa,CAAC,CAAC,CAAC,EACtD,EAAE,CAAC;AACL,CAAC;AARD,oDAQC"}
@@ -0,0 +1,8 @@
1
+ import type { Target } from 'nx/src/command-line/run';
2
+ import type { ExecutorContext } from 'nx/src/config/misc-interfaces';
3
+ /**
4
+ * Reads and combines options for a given target.
5
+ *
6
+ * Works as if you invoked the target yourself without passing any command lint overrides.
7
+ */
8
+ export declare function readTargetOptions<T = any>({ project, target, configuration }: Target, context: ExecutorContext): T;
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.readTargetOptions = void 0;
4
+ // eslint-disable-next-line @typescript-eslint/no-restricted-imports
5
+ const params_1 = require("nx/src/utils/params");
6
+ const nx_1 = require("../../nx");
7
+ const { Workspaces } = (0, nx_1.requireNx)();
8
+ /**
9
+ * Reads and combines options for a given target.
10
+ *
11
+ * Works as if you invoked the target yourself without passing any command lint overrides.
12
+ */
13
+ function readTargetOptions({ project, target, configuration }, context) {
14
+ var _a;
15
+ const projectConfiguration = context.workspace.projects[project];
16
+ const targetConfiguration = projectConfiguration.targets[target];
17
+ const ws = new Workspaces(context.root);
18
+ const [nodeModule, executorName] = targetConfiguration.executor.split(':');
19
+ const { schema } = ws.readExecutor(nodeModule, executorName);
20
+ const defaultProject = ws.calculateDefaultProjectName(context.cwd, { version: 2, projects: context.workspace.projects }, context.nxJsonConfiguration);
21
+ return (0, params_1.combineOptionsForExecutor)({}, (_a = configuration !== null && configuration !== void 0 ? configuration : targetConfiguration.defaultConfiguration) !== null && _a !== void 0 ? _a : '', targetConfiguration, schema, defaultProject, ws.relativeCwd(context.cwd));
22
+ }
23
+ exports.readTargetOptions = readTargetOptions;
24
+ //# sourceMappingURL=read-target-options.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"read-target-options.js","sourceRoot":"","sources":["../../../../../packages/devkit/src/executors/read-target-options.ts"],"names":[],"mappings":";;;AAEA,oEAAoE;AACpE,gDAAgE;AAChE,iCAAqC;AAErC,MAAM,EAAE,UAAU,EAAE,GAAG,IAAA,cAAS,GAAE,CAAC;AAEnC;;;;GAIG;AACH,SAAgB,iBAAiB,CAC/B,EAAE,OAAO,EAAE,MAAM,EAAE,aAAa,EAAU,EAC1C,OAAwB;;IAExB,MAAM,oBAAoB,GAAG,OAAO,CAAC,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IACjE,MAAM,mBAAmB,GAAG,oBAAoB,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAEjE,MAAM,EAAE,GAAG,IAAI,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACxC,MAAM,CAAC,UAAU,EAAE,YAAY,CAAC,GAAG,mBAAmB,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC3E,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC;IAE7D,MAAM,cAAc,GAAG,EAAE,CAAC,2BAA2B,CACnD,OAAO,CAAC,GAAG,EACX,EAAE,OAAO,EAAE,CAAC,EAAE,QAAQ,EAAE,OAAO,CAAC,SAAS,CAAC,QAAQ,EAAE,EACpD,OAAO,CAAC,mBAAmB,CAC5B,CAAC;IAEF,OAAO,IAAA,kCAAyB,EAC9B,EAAE,EACF,MAAA,aAAa,aAAb,aAAa,cAAb,aAAa,GAAI,mBAAmB,CAAC,oBAAoB,mCAAI,EAAE,EAC/D,mBAAmB,EACnB,MAAM,EACN,cAAc,EACd,EAAE,CAAC,WAAW,CAAC,OAAO,CAAC,GAAG,CAAC,CACvB,CAAC;AACT,CAAC;AAzBD,8CAyBC"}
@@ -0,0 +1,21 @@
1
+ import type { Tree } from 'nx/src/generators/tree';
2
+ import type { ProjectGraph } from 'nx/src/config/project-graph';
3
+ type CallBack<T> = (currentValue: T, project: string, target: string, configuration?: string) => void;
4
+ /**
5
+ * Calls a function for each different options that an executor is configured with
6
+ */
7
+ export declare function forEachExecutorOptions<Options>(tree: Tree,
8
+ /**
9
+ * Name of the executor to update options for
10
+ */
11
+ executorName: string,
12
+ /**
13
+ * Callback that is called for each options configured for a builder
14
+ */
15
+ callback: CallBack<Options>): void;
16
+ /**
17
+ * Calls a function for each different options that an executor is configured with via the project graph
18
+ * this is helpful when you need to get the expaned configuration options from the nx.json
19
+ **/
20
+ export declare function forEachExecutorOptionsInGraph<Options>(graph: ProjectGraph, executorName: string, callback: CallBack<Options>): void;
21
+ export {};
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.forEachExecutorOptionsInGraph = exports.forEachExecutorOptions = void 0;
4
+ const nx_1 = require("../../nx");
5
+ const { getProjects } = (0, nx_1.requireNx)();
6
+ /**
7
+ * Calls a function for each different options that an executor is configured with
8
+ */
9
+ function forEachExecutorOptions(tree,
10
+ /**
11
+ * Name of the executor to update options for
12
+ */
13
+ executorName,
14
+ /**
15
+ * Callback that is called for each options configured for a builder
16
+ */
17
+ callback) {
18
+ forEachProjectConfig(getProjects(tree), executorName, callback);
19
+ }
20
+ exports.forEachExecutorOptions = forEachExecutorOptions;
21
+ /**
22
+ * Calls a function for each different options that an executor is configured with via the project graph
23
+ * this is helpful when you need to get the expaned configuration options from the nx.json
24
+ **/
25
+ function forEachExecutorOptionsInGraph(graph, executorName, callback) {
26
+ const projects = new Map();
27
+ Object.values(graph.nodes).forEach((p) => projects.set(p.name, p.data));
28
+ forEachProjectConfig(projects, executorName, callback);
29
+ }
30
+ exports.forEachExecutorOptionsInGraph = forEachExecutorOptionsInGraph;
31
+ function forEachProjectConfig(projects, executorName, callback) {
32
+ for (const [projectName, project] of projects) {
33
+ for (const [targetName, target] of Object.entries(project.targets || {})) {
34
+ if (executorName !== target.executor) {
35
+ continue;
36
+ }
37
+ if (target.options) {
38
+ callback(target.options, projectName, targetName);
39
+ }
40
+ if (!target.configurations) {
41
+ continue;
42
+ }
43
+ Object.entries(target.configurations).forEach(([configName, options]) => {
44
+ callback(options, projectName, targetName, configName);
45
+ });
46
+ }
47
+ }
48
+ }
49
+ // TODO: add a method for updating options
50
+ //# sourceMappingURL=executor-options-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"executor-options-utils.js","sourceRoot":"","sources":["../../../../../packages/devkit/src/generators/executor-options-utils.ts"],"names":[],"mappings":";;;AAGA,iCAAqC;AAErC,MAAM,EAAE,WAAW,EAAE,GAAG,IAAA,cAAS,GAAE,CAAC;AASpC;;GAEG;AACH,SAAgB,sBAAsB,CACpC,IAAU;AACV;;GAEG;AACH,YAAoB;AACpB;;GAEG;AACH,QAA2B;IAE3B,oBAAoB,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,YAAY,EAAE,QAAQ,CAAC,CAAC;AAClE,CAAC;AAZD,wDAYC;AAED;;;IAGI;AACJ,SAAgB,6BAA6B,CAC3C,KAAmB,EACnB,YAAoB,EACpB,QAA2B;IAE3B,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAgC,CAAC;IACzD,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;IAExE,oBAAoB,CAAU,QAAQ,EAAE,YAAY,EAAE,QAAQ,CAAC,CAAC;AAClE,CAAC;AATD,sEASC;AAED,SAAS,oBAAoB,CAC3B,QAA2C,EAC3C,YAAoB,EACpB,QAA2B;IAE3B,KAAK,MAAM,CAAC,WAAW,EAAE,OAAO,CAAC,IAAI,QAAQ,EAAE;QAC7C,KAAK,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,IAAI,EAAE,CAAC,EAAE;YACxE,IAAI,YAAY,KAAK,MAAM,CAAC,QAAQ,EAAE;gBACpC,SAAS;aACV;YAED,IAAI,MAAM,CAAC,OAAO,EAAE;gBAClB,QAAQ,CAAC,MAAM,CAAC,OAAO,EAAE,WAAW,EAAE,UAAU,CAAC,CAAC;aACnD;YAED,IAAI,CAAC,MAAM,CAAC,cAAc,EAAE;gBAC1B,SAAS;aACV;YACD,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,UAAU,EAAE,OAAO,CAAC,EAAE,EAAE;gBACtE,QAAQ,CAAC,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC;YACzD,CAAC,CAAC,CAAC;SACJ;KACF;AACH,CAAC;AAED,0CAA0C"}
@@ -0,0 +1,6 @@
1
+ import type { Tree } from 'nx/src/generators/tree';
2
+ /**
3
+ * Formats all the created or updated files using Prettier
4
+ * @param tree - the file system tree
5
+ */
6
+ export declare function formatFiles(tree: Tree): Promise<void>;
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.formatFiles = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const path = require("path");
6
+ // eslint-disable-next-line @typescript-eslint/no-restricted-imports
7
+ const object_sort_1 = require("nx/src/utils/object-sort");
8
+ const nx_1 = require("../../nx");
9
+ const { updateJson, readJson } = (0, nx_1.requireNx)();
10
+ /**
11
+ * Formats all the created or updated files using Prettier
12
+ * @param tree - the file system tree
13
+ */
14
+ function formatFiles(tree) {
15
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
16
+ let prettier;
17
+ try {
18
+ prettier = yield Promise.resolve().then(() => require('prettier'));
19
+ }
20
+ catch (_a) { }
21
+ sortTsConfig(tree);
22
+ if (!prettier)
23
+ return;
24
+ const files = new Set(tree.listChanges().filter((file) => file.type !== 'DELETE'));
25
+ yield Promise.all(Array.from(files).map((file) => tslib_1.__awaiter(this, void 0, void 0, function* () {
26
+ const systemPath = path.join(tree.root, file.path);
27
+ const resolvedOptions = yield prettier.resolveConfig(systemPath, {
28
+ editorconfig: true,
29
+ });
30
+ let optionsFromTree;
31
+ if (!resolvedOptions) {
32
+ try {
33
+ optionsFromTree = readJson(tree, '.prettierrc');
34
+ }
35
+ catch (_b) { }
36
+ }
37
+ const options = Object.assign({ filepath: systemPath }, (resolvedOptions !== null && resolvedOptions !== void 0 ? resolvedOptions : optionsFromTree));
38
+ if (file.path.endsWith('.swcrc')) {
39
+ options.parser = 'json';
40
+ }
41
+ const support = yield prettier.getFileInfo(systemPath, options);
42
+ if (support.ignored || !support.inferredParser) {
43
+ return;
44
+ }
45
+ try {
46
+ tree.write(file.path, prettier.format(file.content.toString('utf-8'), options));
47
+ }
48
+ catch (e) {
49
+ console.warn(`Could not format ${file.path}. Error: "${e.message}"`);
50
+ }
51
+ })));
52
+ });
53
+ }
54
+ exports.formatFiles = formatFiles;
55
+ function sortTsConfig(tree) {
56
+ try {
57
+ const tsConfigPath = getRootTsConfigPath(tree);
58
+ if (!tsConfigPath) {
59
+ return;
60
+ }
61
+ updateJson(tree, tsConfigPath, (tsconfig) => (Object.assign(Object.assign({}, tsconfig), { compilerOptions: Object.assign(Object.assign({}, tsconfig.compilerOptions), { paths: (0, object_sort_1.sortObjectByKeys)(tsconfig.compilerOptions.paths) }) })));
62
+ }
63
+ catch (e) {
64
+ // catch noop
65
+ }
66
+ }
67
+ function getRootTsConfigPath(tree) {
68
+ for (const path of ['tsconfig.base.json', 'tsconfig.json']) {
69
+ if (tree.exists(path)) {
70
+ return path;
71
+ }
72
+ }
73
+ return null;
74
+ }
75
+ //# sourceMappingURL=format-files.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"format-files.js","sourceRoot":"","sources":["../../../../../packages/devkit/src/generators/format-files.ts"],"names":[],"mappings":";;;;AACA,6BAA6B;AAE7B,oEAAoE;AACpE,0DAA4D;AAC5D,iCAAqC;AAErC,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAG,IAAA,cAAS,GAAE,CAAC;AAE7C;;;GAGG;AACH,SAAsB,WAAW,CAAC,IAAU;;QAC1C,IAAI,QAAyB,CAAC;QAC9B,IAAI;YACF,QAAQ,GAAG,2CAAa,UAAU,EAAC,CAAC;SACrC;QAAC,WAAM,GAAE;QAEV,YAAY,CAAC,IAAI,CAAC,CAAC;QAEnB,IAAI,CAAC,QAAQ;YAAE,OAAO;QAEtB,MAAM,KAAK,GAAG,IAAI,GAAG,CACnB,IAAI,CAAC,WAAW,EAAE,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,KAAK,QAAQ,CAAC,CAC5D,CAAC;QAEF,MAAM,OAAO,CAAC,GAAG,CACf,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAO,IAAI,EAAE,EAAE;YACnC,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;YAEnD,MAAM,eAAe,GAAG,MAAM,QAAQ,CAAC,aAAa,CAAC,UAAU,EAAE;gBAC/D,YAAY,EAAE,IAAI;aACnB,CAAC,CAAC;YAEH,IAAI,eAAe,CAAC;YACpB,IAAI,CAAC,eAAe,EAAE;gBACpB,IAAI;oBACF,eAAe,GAAG,QAAQ,CAAC,IAAI,EAAE,aAAa,CAA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,SAAS,mBAAmB,CAAC,IAAU;IACrC,KAAK,MAAM,IAAI,IAAI,CAAC,oBAAoB,EAAE,eAAe,CAAC,EAAE;QAC1D,IAAI,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE;YACrB,OAAO,IAAI,CAAC;SACb;KACF;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,26 @@
1
+ import type { Tree } from 'nx/src/generators/tree';
2
+ /**
3
+ * Generates a folder of files based on provided templates.
4
+ *
5
+ * While doing so it performs two substitutions:
6
+ * - Substitutes segments of file names surrounded by __
7
+ * - Uses ejs to substitute values in templates
8
+ *
9
+ * Examples:
10
+ * ```typescript
11
+ * generateFiles(tree, path.join(__dirname , 'files'), './tools/scripts', {tmpl: '', name: 'myscript'})
12
+ * ```
13
+ * This command will take all the files from the `files` directory next to the place where the command is invoked from.
14
+ * It will replace all `__tmpl__` with '' and all `__name__` with 'myscript' in the file names, and will replace all
15
+ * `<%= name %>` with `myscript` in the files themselves.
16
+ * `tmpl: ''` is a common pattern. With it you can name files like this: `index.ts__tmpl__`, so your editor
17
+ * doesn't get confused about incorrect TypeScript files.
18
+ *
19
+ * @param tree - the file system tree
20
+ * @param srcFolder - the source folder of files (absolute path)
21
+ * @param target - the target folder (relative to the tree root)
22
+ * @param substitutions - an object of key-value pairs
23
+ */
24
+ export declare function generateFiles(tree: Tree, srcFolder: string, target: string, substitutions: {
25
+ [k: string]: any;
26
+ }): void;
@@ -0,0 +1,120 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.generateFiles = void 0;
4
+ const fs_1 = require("fs");
5
+ const path = require("path");
6
+ const nx_1 = require("../../nx");
7
+ const { logger } = (0, nx_1.requireNx)();
8
+ const binaryExts = new Set([
9
+ // // Image types originally from https://github.com/sindresorhus/image-type/blob/5541b6a/index.js
10
+ '.jpg',
11
+ '.jpeg',
12
+ '.png',
13
+ '.gif',
14
+ '.webp',
15
+ '.flif',
16
+ '.cr2',
17
+ '.tif',
18
+ '.bmp',
19
+ '.jxr',
20
+ '.psd',
21
+ '.ico',
22
+ '.bpg',
23
+ '.jp2',
24
+ '.jpm',
25
+ '.jpx',
26
+ '.heic',
27
+ '.cur',
28
+ '.tgz',
29
+ // Java files
30
+ '.jar',
31
+ '.keystore',
32
+ // Font files
33
+ '.ttf',
34
+ '.otf',
35
+ '.woff',
36
+ '.woff2',
37
+ '.eot',
38
+ ]);
39
+ /**
40
+ * Generates a folder of files based on provided templates.
41
+ *
42
+ * While doing so it performs two substitutions:
43
+ * - Substitutes segments of file names surrounded by __
44
+ * - Uses ejs to substitute values in templates
45
+ *
46
+ * Examples:
47
+ * ```typescript
48
+ * generateFiles(tree, path.join(__dirname , 'files'), './tools/scripts', {tmpl: '', name: 'myscript'})
49
+ * ```
50
+ * This command will take all the files from the `files` directory next to the place where the command is invoked from.
51
+ * It will replace all `__tmpl__` with '' and all `__name__` with 'myscript' in the file names, and will replace all
52
+ * `<%= name %>` with `myscript` in the files themselves.
53
+ * `tmpl: ''` is a common pattern. With it you can name files like this: `index.ts__tmpl__`, so your editor
54
+ * doesn't get confused about incorrect TypeScript files.
55
+ *
56
+ * @param tree - the file system tree
57
+ * @param srcFolder - the source folder of files (absolute path)
58
+ * @param target - the target folder (relative to the tree root)
59
+ * @param substitutions - an object of key-value pairs
60
+ */
61
+ function generateFiles(tree, srcFolder, target, substitutions) {
62
+ const ejs = require('ejs');
63
+ const files = allFilesInDir(srcFolder);
64
+ if (files.length === 0) {
65
+ throw new Error(`generateFiles: No files found in "${srcFolder}". Are you sure you specified the correct path?`);
66
+ }
67
+ else {
68
+ files.forEach((filePath) => {
69
+ let newContent;
70
+ const computedPath = computePath(srcFolder, target, filePath, substitutions);
71
+ if (binaryExts.has(path.extname(filePath))) {
72
+ newContent = (0, fs_1.readFileSync)(filePath);
73
+ }
74
+ else {
75
+ const template = (0, fs_1.readFileSync)(filePath, 'utf-8');
76
+ try {
77
+ newContent = ejs.render(template, substitutions, {});
78
+ }
79
+ catch (e) {
80
+ logger.error(`Error in ${filePath.replace(`${tree.root}/`, '')}:`);
81
+ throw e;
82
+ }
83
+ }
84
+ tree.write(computedPath, newContent);
85
+ });
86
+ }
87
+ }
88
+ exports.generateFiles = generateFiles;
89
+ function computePath(srcFolder, target, filePath, substitutions) {
90
+ const relativeFromSrcFolder = path.relative(srcFolder, filePath);
91
+ let computedPath = path.join(target, relativeFromSrcFolder);
92
+ if (computedPath.endsWith('.template')) {
93
+ computedPath = computedPath.substring(0, computedPath.length - 9);
94
+ }
95
+ Object.entries(substitutions).forEach(([propertyName, value]) => {
96
+ computedPath = computedPath.split(`__${propertyName}__`).join(value);
97
+ });
98
+ return computedPath;
99
+ }
100
+ function allFilesInDir(parent) {
101
+ let res = [];
102
+ try {
103
+ (0, fs_1.readdirSync)(parent).forEach((c) => {
104
+ const child = path.join(parent, c);
105
+ try {
106
+ const s = (0, fs_1.statSync)(child);
107
+ if (!s.isDirectory()) {
108
+ res.push(child);
109
+ }
110
+ else if (s.isDirectory()) {
111
+ res = [...res, ...allFilesInDir(child)];
112
+ }
113
+ }
114
+ catch (_a) { }
115
+ });
116
+ }
117
+ catch (_a) { }
118
+ return res;
119
+ }
120
+ //# sourceMappingURL=generate-files.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate-files.js","sourceRoot":"","sources":["../../../../../packages/devkit/src/generators/generate-files.ts"],"names":[],"mappings":";;;AAAA,2BAAyD;AACzD,6BAA6B;AAE7B,iCAAqC;AAErC,MAAM,EAAE,MAAM,EAAE,GAAG,IAAA,cAAS,GAAE,CAAC;AAE/B,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC;IACzB,kGAAkG;IAClG,MAAM;IACN,OAAO;IACP,MAAM;IACN,MAAM;IACN,OAAO;IACP,OAAO;IACP,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,OAAO;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AAC,KAAK,CAAC,CAAC,CAAC;iBACzC;aACF;YAAC,WAAM,GAAE;QACZ,CAAC,CAAC,CAAC;KACJ;IAAC,WAAM,GAAE;IACV,OAAO,GAAG,CAAC;AACb,CAAC"}
@@ -0,0 +1,7 @@
1
+ import type { GeneratorCallback } from 'nx/src/config/misc-interfaces';
2
+ /**
3
+ * Run tasks in serial
4
+ *
5
+ * @param tasks The tasks to run in serial.
6
+ */
7
+ export declare function runTasksInSerial(...tasks: GeneratorCallback[]): GeneratorCallback;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.runTasksInSerial = void 0;
4
+ const tslib_1 = require("tslib");
5
+ /**
6
+ * Run tasks in serial
7
+ *
8
+ * @param tasks The tasks to run in serial.
9
+ */
10
+ function runTasksInSerial(...tasks) {
11
+ return () => tslib_1.__awaiter(this, void 0, void 0, function* () {
12
+ for (const task of tasks) {
13
+ yield task();
14
+ }
15
+ });
16
+ }
17
+ exports.runTasksInSerial = runTasksInSerial;
18
+ //# sourceMappingURL=run-tasks-in-serial.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run-tasks-in-serial.js","sourceRoot":"","sources":["../../../../../packages/devkit/src/generators/run-tasks-in-serial.ts"],"names":[],"mappings":";;;;AAEA;;;;GAIG;AACH,SAAgB,gBAAgB,CAC9B,GAAG,KAA0B;IAE7B,OAAO,GAAS,EAAE;QAChB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;YACxB,MAAM,IAAI,EAAE,CAAC;SACd;IACH,CAAC,CAAA,CAAC;AACJ,CAAC;AARD,4CAQC"}
@@ -0,0 +1,5 @@
1
+ import type { Tree } from 'nx/src/generators/tree';
2
+ /**
3
+ * Rename and transpile any new typescript files created to javascript files
4
+ */
5
+ export declare function toJS(tree: Tree): void;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.toJS = void 0;
4
+ // eslint-disable-next-line @typescript-eslint/no-restricted-imports
5
+ const versions_1 = require("nx/src/utils/versions");
6
+ const package_json_1 = require("../utils/package-json");
7
+ /**
8
+ * Rename and transpile any new typescript files created to javascript files
9
+ */
10
+ function toJS(tree) {
11
+ const { JsxEmit, ScriptTarget, transpile } = (0, package_json_1.ensurePackage)('typescript', versions_1.typescriptVersion);
12
+ for (const c of tree.listChanges()) {
13
+ if ((c.path.endsWith('.ts') || c.path.endsWith('tsx')) &&
14
+ c.type === 'CREATE') {
15
+ tree.write(c.path, transpile(c.content.toString('utf-8'), {
16
+ allowJs: true,
17
+ jsx: JsxEmit.Preserve,
18
+ target: ScriptTarget.ESNext,
19
+ }));
20
+ tree.rename(c.path, c.path.replace(/\.tsx?$/, '.js'));
21
+ }
22
+ }
23
+ }
24
+ exports.toJS = toJS;
25
+ //# sourceMappingURL=to-js.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"to-js.js","sourceRoot":"","sources":["../../../../../packages/devkit/src/generators/to-js.ts"],"names":[],"mappings":";;;AACA,oEAAoE;AACpE,oDAA0D;AAC1D,wDAAsD;AAEtD;;GAEG;AACH,SAAgB,IAAI,CAAC,IAAU;IAC7B,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,GAAG,IAAA,4BAAa,EACxD,YAAY,EACZ,4BAAiB,CAClB,CAAC;IAEF,KAAK,MAAM,CAAC,IAAI,IAAI,CAAC,WAAW,EAAE,EAAE;QAClC,IACE,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;YAClD,CAAC,CAAC,IAAI,KAAK,QAAQ,EACnB;YACA,IAAI,CAAC,KAAK,CACR,CAAC,CAAC,IAAI,EACN,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE;gBACrC,OAAO,EAAE,IAAI;gBACb,GAAG,EAAE,OAAO,CAAC,QAAQ;gBACrB,MAAM,EAAE,YAAY,CAAC,MAAM;aAC5B,CAAC,CACH,CAAC;YACF,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC,CAAC;SACvD;KACF;AACH,CAAC;AAtBD,oBAsBC"}
@@ -0,0 +1 @@
1
+ export declare function insertImport(): void;
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.insertImport = void 0;
4
+ function insertImport() { }
5
+ exports.insertImport = insertImport;
6
+ //# sourceMappingURL=insert-import.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"insert-import.js","sourceRoot":"","sources":["../../../../../../packages/devkit/src/generators/typescript/insert-import.ts"],"names":[],"mappings":";;;AAAA,SAAgB,YAAY,KAAU,CAAC;AAAvC,oCAAuC"}