@nx/devkit 0.0.0-pr-22179-271588f

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 (98) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +68 -0
  3. package/index.d.ts +14 -0
  4. package/index.js +18 -0
  5. package/migrations.json +18 -0
  6. package/ngcli-adapter.d.ts +4 -0
  7. package/ngcli-adapter.js +11 -0
  8. package/nx.d.ts +1 -0
  9. package/nx.js +19 -0
  10. package/package.json +50 -0
  11. package/public-api.d.ts +78 -0
  12. package/public-api.js +100 -0
  13. package/src/executors/parse-target-string.d.ts +44 -0
  14. package/src/executors/parse-target-string.js +55 -0
  15. package/src/executors/read-target-options.d.ts +8 -0
  16. package/src/executors/read-target-options.js +38 -0
  17. package/src/generators/add-build-target-defaults.d.ts +2 -0
  18. package/src/generators/add-build-target-defaults.js +18 -0
  19. package/src/generators/artifact-name-and-directory-utils.d.ts +48 -0
  20. package/src/generators/artifact-name-and-directory-utils.js +239 -0
  21. package/src/generators/executor-options-utils.d.ts +21 -0
  22. package/src/generators/executor-options-utils.js +49 -0
  23. package/src/generators/format-files.d.ts +6 -0
  24. package/src/generators/format-files.js +91 -0
  25. package/src/generators/generate-files.d.ts +26 -0
  26. package/src/generators/generate-files.js +91 -0
  27. package/src/generators/project-name-and-root-utils.d.ts +47 -0
  28. package/src/generators/project-name-and-root-utils.js +298 -0
  29. package/src/generators/run-tasks-in-serial.d.ts +7 -0
  30. package/src/generators/run-tasks-in-serial.js +16 -0
  31. package/src/generators/to-js.d.ts +11 -0
  32. package/src/generators/to-js.js +24 -0
  33. package/src/generators/typescript/insert-import.d.ts +1 -0
  34. package/src/generators/typescript/insert-import.js +5 -0
  35. package/src/generators/typescript/insert-statement.d.ts +1 -0
  36. package/src/generators/typescript/insert-statement.js +5 -0
  37. package/src/generators/update-ts-configs-to-js.d.ts +4 -0
  38. package/src/generators/update-ts-configs-to-js.js +49 -0
  39. package/src/generators/visit-not-ignored-files.d.ts +5 -0
  40. package/src/generators/visit-not-ignored-files.js +41 -0
  41. package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.d.ts +2 -0
  42. package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js +9 -0
  43. package/src/migrations/update-16-9-0/migrate-mf-util-usage.d.ts +4 -0
  44. package/src/migrations/update-16-9-0/migrate-mf-util-usage.js +201 -0
  45. package/src/tasks/install-packages-task.d.ts +10 -0
  46. package/src/tasks/install-packages-task.js +41 -0
  47. package/src/utils/async-iterable/combine-async-iterables.d.ts +3 -0
  48. package/src/utils/async-iterable/combine-async-iterables.js +58 -0
  49. package/src/utils/async-iterable/create-async-iterable.d.ts +6 -0
  50. package/src/utils/async-iterable/create-async-iterable.js +58 -0
  51. package/src/utils/async-iterable/index.d.ts +4 -0
  52. package/src/utils/async-iterable/index.js +7 -0
  53. package/src/utils/async-iterable/map-async-iteratable.d.ts +1 -0
  54. package/src/utils/async-iterable/map-async-iteratable.js +18 -0
  55. package/src/utils/async-iterable/tap-async-iteratable.d.ts +1 -0
  56. package/src/utils/async-iterable/tap-async-iteratable.js +11 -0
  57. package/src/utils/binary-extensions.d.ts +1 -0
  58. package/src/utils/binary-extensions.js +275 -0
  59. package/src/utils/calculate-hash-for-create-nodes.d.ts +2 -0
  60. package/src/utils/calculate-hash-for-create-nodes.js +16 -0
  61. package/src/utils/config-utils.d.ts +4 -0
  62. package/src/utils/config-utils.js +75 -0
  63. package/src/utils/convert-nx-executor.d.ts +7 -0
  64. package/src/utils/convert-nx-executor.js +89 -0
  65. package/src/utils/get-named-inputs.d.ts +8 -0
  66. package/src/utils/get-named-inputs.js +26 -0
  67. package/src/utils/get-workspace-layout.d.ts +24 -0
  68. package/src/utils/get-workspace-layout.js +52 -0
  69. package/src/utils/invoke-nx-generator.d.ts +6 -0
  70. package/src/utils/invoke-nx-generator.js +172 -0
  71. package/src/utils/log-show-project-command.d.ts +1 -0
  72. package/src/utils/log-show-project-command.js +14 -0
  73. package/src/utils/move-dir.d.ts +5 -0
  74. package/src/utils/move-dir.js +28 -0
  75. package/src/utils/names.d.ts +18 -0
  76. package/src/utils/names.js +63 -0
  77. package/src/utils/offset-from-root.d.ts +13 -0
  78. package/src/utils/offset-from-root.js +29 -0
  79. package/src/utils/package-json.d.ts +78 -0
  80. package/src/utils/package-json.js +375 -0
  81. package/src/utils/replace-package.d.ts +2 -0
  82. package/src/utils/replace-package.js +125 -0
  83. package/src/utils/replace-project-configuration-with-plugin.d.ts +3 -0
  84. package/src/utils/replace-project-configuration-with-plugin.js +136 -0
  85. package/src/utils/rxjs-for-await.d.ts +109 -0
  86. package/src/utils/rxjs-for-await.js +363 -0
  87. package/src/utils/semver.d.ts +1 -0
  88. package/src/utils/semver.js +18 -0
  89. package/src/utils/string-change.d.ts +62 -0
  90. package/src/utils/string-change.js +109 -0
  91. package/src/utils/string-utils.d.ts +95 -0
  92. package/src/utils/string-utils.js +147 -0
  93. package/src/utils/update-package-scripts.d.ts +3 -0
  94. package/src/utils/update-package-scripts.js +175 -0
  95. package/src/utils/versions.d.ts +1 -0
  96. package/src/utils/versions.js +4 -0
  97. package/testing.d.ts +1 -0
  98. package/testing.js +5 -0
package/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ (The MIT License)
2
+
3
+ Copyright (c) 2017-2023 Narwhal Technologies Inc.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ 'Software'), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,68 @@
1
+ <p style="text-align: center;">
2
+ <picture>
3
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-dark.svg">
4
+ <img alt="Nx - Smart Monorepos · Fast CI" src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-light.svg" width="100%">
5
+ </picture>
6
+ </p>
7
+
8
+ <div style="text-align: center;">
9
+
10
+ [![CircleCI](https://circleci.com/gh/nrwl/nx.svg?style=svg)](https://circleci.com/gh/nrwl/nx)
11
+ [![License](https://img.shields.io/npm/l/@nx/workspace.svg?style=flat-square)]()
12
+ [![NPM Version](https://badge.fury.io/js/%40nrwl%2Fworkspace.svg)](https://www.npmjs.com/@nx/workspace)
13
+ [![Semantic Release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=flat-square)]()
14
+ [![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)
15
+ [![Join the chat at https://gitter.im/nrwl-nx/community](https://badges.gitter.im/nrwl-nx/community.svg)](https://gitter.im/nrwl-nx/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
16
+ [![Join us on the Official Nx Discord Server](https://img.shields.io/discord/1143497901675401286?label=discord)](https://go.nx.dev/community)
17
+
18
+ </div>
19
+
20
+
21
+ <hr>
22
+
23
+ # Nx: Smart Monorepos · Fast CI
24
+
25
+ Nx is a build system with built-in tooling and advanced CI capabilities. It helps you maintain and scale monorepos, both locally and on CI.
26
+
27
+ This package contains a set of utilities for creating Nx plugins.
28
+
29
+ ## Getting Started
30
+
31
+ ### Creating an Nx Workspace
32
+
33
+ **Using `npx`**
34
+
35
+ ```bash
36
+ npx create-nx-workspace
37
+ ```
38
+
39
+ **Using `npm init`**
40
+
41
+ ```bash
42
+ npm init nx-workspace
43
+ ```
44
+
45
+ **Using `yarn create`**
46
+
47
+ ```bash
48
+ yarn create nx-workspace
49
+ ```
50
+
51
+ ### Adding Nx to an Existing Repository
52
+
53
+ Run:
54
+
55
+ ```bash
56
+ npx nx@latest init
57
+ ```
58
+
59
+ ## Documentation & Resources
60
+
61
+ - [Nx.Dev: Documentation, Guides, Tutorials](https://nx.dev)
62
+ - [Intro to Nx](https://nx.dev/getting-started/intro)
63
+ - [Official Nx YouTube Channel](https://www.youtube.com/@NxDevtools)
64
+ - [Blog Posts About Nx](https://blog.nrwl.io/nx/home)
65
+
66
+ <p style="text-align: center;"><a href="https://nx.dev/#learning-materials" target="_blank" rel="noreferrer"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-courses-and-videos.svg"
67
+ width="100%" alt="Nx - Smart Monorepos · Fast CI"></a></p>
68
+
package/index.d.ts ADDED
@@ -0,0 +1,14 @@
1
+ /**
2
+ * The Nx Devkit is the underlying technology used to customize Nx to support
3
+ * different technologies and custom use-cases. It contains many utility
4
+ * functions for reading and writing files, updating configuration,
5
+ * working with Abstract Syntax Trees(ASTs), and more.
6
+ *
7
+ * As with most things in Nx, the core of Nx Devkit is very simple.
8
+ * It only uses language primitives and immutable objects
9
+ * (the tree being the only exception).
10
+ *
11
+ * @module @nx/devkit
12
+ */
13
+ export * from 'nx/src/devkit-exports';
14
+ export * from './public-api';
package/index.js ADDED
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ /**
3
+ * The Nx Devkit is the underlying technology used to customize Nx to support
4
+ * different technologies and custom use-cases. It contains many utility
5
+ * functions for reading and writing files, updating configuration,
6
+ * working with Abstract Syntax Trees(ASTs), and more.
7
+ *
8
+ * As with most things in Nx, the core of Nx Devkit is very simple.
9
+ * It only uses language primitives and immutable objects
10
+ * (the tree being the only exception).
11
+ *
12
+ * @module @nx/devkit
13
+ */
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ const tslib_1 = require("tslib");
16
+ // eslint-disable-next-line @typescript-eslint/no-restricted-imports
17
+ tslib_1.__exportStar(require("nx/src/devkit-exports"), exports);
18
+ tslib_1.__exportStar(require("./public-api"), exports);
@@ -0,0 +1,18 @@
1
+ {
2
+ "generators": {
3
+ "update-16-0-0-add-nx-packages": {
4
+ "cli": "nx",
5
+ "version": "16.0.0-beta.1",
6
+ "description": "Replace @nrwl/devkit with @nx/devkit",
7
+ "implementation": "./src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages"
8
+ },
9
+ "update-16-9-0-migrate-mf-usage-to-webpack": {
10
+ "cli": "nx",
11
+ "version": "16.9.0-beta.1",
12
+ "description": "Replace imports of Module Federation utils frm @nx/devkit to @nx/webpack",
13
+ "implementation": "./src/migrations/update-16-9-0/migrate-mf-util-usage"
14
+ }
15
+ },
16
+ "packageJsonUpdates": {},
17
+ "version": "0.1"
18
+ }
@@ -0,0 +1,4 @@
1
+ /**
2
+ * @category Ng CLI Adapter
3
+ */
4
+ export { wrapAngularDevkitSchematic, mockSchematicsForTesting, NxScopedHost, } from 'nx/src/adapter/ngcli-adapter';
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NxScopedHost = exports.mockSchematicsForTesting = exports.wrapAngularDevkitSchematic = void 0;
4
+ /**
5
+ * @category Ng CLI Adapter
6
+ */
7
+ // eslint-disable-next-line @typescript-eslint/no-restricted-imports
8
+ var ngcli_adapter_1 = require("nx/src/adapter/ngcli-adapter");
9
+ Object.defineProperty(exports, "wrapAngularDevkitSchematic", { enumerable: true, get: function () { return ngcli_adapter_1.wrapAngularDevkitSchematic; } });
10
+ Object.defineProperty(exports, "mockSchematicsForTesting", { enumerable: true, get: function () { return ngcli_adapter_1.mockSchematicsForTesting; } });
11
+ Object.defineProperty(exports, "NxScopedHost", { enumerable: true, get: function () { return ngcli_adapter_1.NxScopedHost; } });
package/nx.d.ts ADDED
@@ -0,0 +1 @@
1
+ export declare function requireNx(): typeof import('nx/src/devkit-exports') & Partial<typeof import('nx/src/devkit-internals')>;
package/nx.js ADDED
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.requireNx = void 0;
4
+ // After Nx v19, this can be removed and replaced with either:
5
+ // - import {} from 'nx/src/devkit-exports'
6
+ // - import {} from 'nx/src/devkit-internals'
7
+ function requireNx() {
8
+ let result = { ...require('nx/src/devkit-exports') };
9
+ try {
10
+ result = {
11
+ ...result,
12
+ // Remove in Nx v19, devkit should not support Nx v16.0.2 at that point.
13
+ ...require('nx/src/devkit-internals'),
14
+ };
15
+ }
16
+ catch { }
17
+ return result;
18
+ }
19
+ exports.requireNx = requireNx;
package/package.json ADDED
@@ -0,0 +1,50 @@
1
+ {
2
+ "name": "@nx/devkit",
3
+ "version": "0.0.0-pr-22179-271588f",
4
+ "private": false,
5
+ "description": "The Nx Devkit is used to customize Nx for different technologies and use cases. It contains many utility functions for reading and writing files, updating configuration, working with Abstract Syntax Trees(ASTs), and more. Learn more about [extending Nx by leveraging the Nx Devkit](https://nx.dev/extending-nx/intro/getting-started) on our docs.",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/nrwl/nx.git",
9
+ "directory": "packages/devkit"
10
+ },
11
+ "keywords": [
12
+ "Monorepo",
13
+ "Angular",
14
+ "React",
15
+ "Web",
16
+ "Node",
17
+ "Nest",
18
+ "Jest",
19
+ "Cypress",
20
+ "CLI"
21
+ ],
22
+ "main": "./index.js",
23
+ "typings": "./index.d.ts",
24
+ "author": "Victor Savkin",
25
+ "license": "MIT",
26
+ "bugs": {
27
+ "url": "https://github.com/nrwl/nx/issues"
28
+ },
29
+ "homepage": "https://nx.dev",
30
+ "dependencies": {
31
+ "ejs": "^3.1.7",
32
+ "enquirer": "~2.3.6",
33
+ "ignore": "^5.0.4",
34
+ "tmp": "~0.2.1",
35
+ "tslib": "^2.3.0",
36
+ "semver": "^7.5.3",
37
+ "yargs-parser": "21.1.1",
38
+ "@nrwl/devkit": "0.0.0-pr-22179-271588f"
39
+ },
40
+ "peerDependencies": {
41
+ "nx": ">= 16 <= 18"
42
+ },
43
+ "publishConfig": {
44
+ "access": "public"
45
+ },
46
+ "nx-migrations": {
47
+ "migrations": "./migrations.json"
48
+ },
49
+ "type": "commonjs"
50
+ }
@@ -0,0 +1,78 @@
1
+ /**
2
+ * Note to developers: STOP! This is the Public API of @nx/devkit.
3
+ * @nx/devkit should be compatible with versions of Nx 1 major version prior.
4
+ * This is so that plugins can use the latest @nx/devkit while their users may use versions +/- 1 of Nx.
5
+ *
6
+ * 1. Try hard to not add to this API to reduce the surface area we need to maintain.
7
+ * 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.
8
+ * a. We might need to duplicate code instead of importing from nx until all supported versions of nx contain the file.
9
+ */
10
+ /**
11
+ * @category Generators
12
+ */
13
+ export { formatFiles } from './src/generators/format-files';
14
+ /**
15
+ * @category Generators
16
+ */
17
+ export { generateFiles } from './src/generators/generate-files';
18
+ /**
19
+ * @category Generators
20
+ */
21
+ export { toJS, ToJSOptions } from './src/generators/to-js';
22
+ /**
23
+ * @category Generators
24
+ */
25
+ export { updateTsConfigsToJs } from './src/generators/update-ts-configs-to-js';
26
+ /**
27
+ * @category Generators
28
+ */
29
+ export { runTasksInSerial } from './src/generators/run-tasks-in-serial';
30
+ /**
31
+ * @category Generators
32
+ */
33
+ export { visitNotIgnoredFiles } from './src/generators/visit-not-ignored-files';
34
+ export { parseTargetString, targetToTargetString, } from './src/executors/parse-target-string';
35
+ /**
36
+ * @category Executors
37
+ */
38
+ export { readTargetOptions } from './src/executors/read-target-options';
39
+ /**
40
+ * @category Utils
41
+ */
42
+ export { addDependenciesToPackageJson, ensurePackage, removeDependenciesFromPackageJson, NX_VERSION, } from './src/utils/package-json';
43
+ /**
44
+ * @category Utils
45
+ */
46
+ export { installPackagesTask } from './src/tasks/install-packages-task';
47
+ /**
48
+ * @category Utils
49
+ */
50
+ export { names } from './src/utils/names';
51
+ /**
52
+ * @category Utils
53
+ */
54
+ export { getWorkspaceLayout, extractLayoutDirectory, } from './src/utils/get-workspace-layout';
55
+ /**
56
+ * @category Utils
57
+ */
58
+ export type { StringChange, StringDeletion, StringInsertion, } from './src/utils/string-change';
59
+ /**
60
+ * @category Utils
61
+ */
62
+ export { applyChangesToString, ChangeType } from './src/utils/string-change';
63
+ /**
64
+ * @category Utils
65
+ */
66
+ export { offsetFromRoot } from './src/utils/offset-from-root';
67
+ /**
68
+ * @category Utils
69
+ */
70
+ export { convertNxGenerator } from './src/utils/invoke-nx-generator';
71
+ /**
72
+ * @category Utils
73
+ */
74
+ export { convertNxExecutor } from './src/utils/convert-nx-executor';
75
+ /**
76
+ * @category Utils
77
+ */
78
+ export { moveFilesToNewDirectory } from './src/utils/move-dir';
package/public-api.js ADDED
@@ -0,0 +1,100 @@
1
+ "use strict";
2
+ /**
3
+ * Note to developers: STOP! This is the Public API of @nx/devkit.
4
+ * @nx/devkit should be compatible with versions of Nx 1 major version prior.
5
+ * This is so that plugins can use the latest @nx/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.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; } });
@@ -0,0 +1,44 @@
1
+ import type { Target } from 'nx/src/command-line/run/run';
2
+ import type { ProjectGraph } from 'nx/src/config/project-graph';
3
+ import type { ExecutorContext } from 'nx/src/devkit-exports';
4
+ /**
5
+ * @deprecated(v17) A project graph should be passed to parseTargetString for best accuracy.
6
+ */
7
+ export declare function parseTargetString(targetString: string): Target;
8
+ /**
9
+ * Parses a target string into {project, target, configuration}
10
+ *
11
+ * Examples:
12
+ * ```typescript
13
+ * parseTargetString("proj:test", graph) // returns { project: "proj", target: "test" }
14
+ * parseTargetString("proj:test:production", graph) // returns { project: "proj", target: "test", configuration: "production" }
15
+ * ```
16
+ *
17
+ * @param targetString - target reference
18
+ */
19
+ export declare function parseTargetString(targetString: string, projectGraph: ProjectGraph): Target;
20
+ /**
21
+ * Parses a target string into {project, target, configuration}. Passing a full
22
+ * {@link ExecutorContext} enables the targetString to reference the current project.
23
+ *
24
+ * Examples:
25
+ * ```typescript
26
+ * parseTargetString("test", executorContext) // returns { project: "proj", target: "test" }
27
+ * parseTargetString("proj:test", executorContext) // returns { project: "proj", target: "test" }
28
+ * parseTargetString("proj:test:production", executorContext) // returns { project: "proj", target: "test", configuration: "production" }
29
+ * ```
30
+ */
31
+ export declare function parseTargetString(targetString: string, ctx: ExecutorContext): Target;
32
+ /**
33
+ * Returns a string in the format "project:target[:configuration]" for the target
34
+ *
35
+ * @param target - target object
36
+ *
37
+ * Examples:
38
+ *
39
+ * ```typescript
40
+ * targetToTargetString({ project: "proj", target: "test" }) // returns "proj:test"
41
+ * targetToTargetString({ project: "proj", target: "test", configuration: "production" }) // returns "proj:test:production"
42
+ * ```
43
+ */
44
+ export declare function targetToTargetString({ project, target, configuration, }: Target): string;
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.targetToTargetString = exports.parseTargetString = void 0;
4
+ const nx_1 = require("../../nx");
5
+ let { readCachedProjectGraph, splitTarget, splitByColons } = (0, nx_1.requireNx)();
6
+ // TODO: Remove this in Nx 19 when Nx 16.7.0 is no longer supported
7
+ splitTarget = splitTarget ?? require('nx/src/utils/split-target').splitTarget;
8
+ splitByColons =
9
+ splitByColons ?? ((s) => s.split(':'));
10
+ function parseTargetString(targetString, projectGraphOrCtx) {
11
+ let projectGraph = projectGraphOrCtx && 'projectGraph' in projectGraphOrCtx
12
+ ? projectGraphOrCtx.projectGraph
13
+ : projectGraphOrCtx;
14
+ if (!projectGraph) {
15
+ try {
16
+ projectGraph = readCachedProjectGraph();
17
+ }
18
+ catch (e) {
19
+ projectGraph = { nodes: {} };
20
+ }
21
+ }
22
+ const [maybeProject] = splitByColons(targetString);
23
+ if (!projectGraph.nodes[maybeProject] &&
24
+ projectGraphOrCtx &&
25
+ 'projectName' in projectGraphOrCtx &&
26
+ maybeProject !== projectGraphOrCtx.projectName) {
27
+ targetString = `${projectGraphOrCtx.projectName}:${targetString}`;
28
+ }
29
+ const [project, target, configuration] = splitTarget(targetString, projectGraph);
30
+ if (!project || !target) {
31
+ throw new Error(`Invalid Target String: ${targetString}`);
32
+ }
33
+ return {
34
+ project,
35
+ target,
36
+ configuration,
37
+ };
38
+ }
39
+ exports.parseTargetString = parseTargetString;
40
+ /**
41
+ * Returns a string in the format "project:target[:configuration]" for the target
42
+ *
43
+ * @param target - target object
44
+ *
45
+ * Examples:
46
+ *
47
+ * ```typescript
48
+ * targetToTargetString({ project: "proj", target: "test" }) // returns "proj:test"
49
+ * targetToTargetString({ project: "proj", target: "test", configuration: "production" }) // returns "proj:test:production"
50
+ * ```
51
+ */
52
+ function targetToTargetString({ project, target, configuration, }) {
53
+ return `${project}:${target.indexOf(':') > -1 ? `"${target}"` : target}${configuration !== undefined ? ':' + configuration : ''}`;
54
+ }
55
+ exports.targetToTargetString = targetToTargetString;
@@ -0,0 +1,8 @@
1
+ import type { Target } from 'nx/src/command-line/run/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,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.readTargetOptions = void 0;
4
+ const nx_1 = require("../../nx");
5
+ const path_1 = require("path");
6
+ let { Workspaces, getExecutorInformation, calculateDefaultProjectName, combineOptionsForExecutor, } = (0, nx_1.requireNx)();
7
+ // TODO: Remove this in Nx 19 when Nx 16.7.0 is no longer supported
8
+ combineOptionsForExecutor =
9
+ combineOptionsForExecutor ??
10
+ require('nx/src/utils/params').combineOptionsForExecutor;
11
+ /**
12
+ * Reads and combines options for a given target.
13
+ *
14
+ * Works as if you invoked the target yourself without passing any command lint overrides.
15
+ */
16
+ function readTargetOptions({ project, target, configuration }, context) {
17
+ const projectConfiguration = (context.workspace || context.projectsConfigurations).projects[project];
18
+ if (!projectConfiguration) {
19
+ throw new Error(`Unable to find project ${project}`);
20
+ }
21
+ const targetConfiguration = projectConfiguration.targets[target];
22
+ if (!targetConfiguration) {
23
+ throw new Error(`Unable to find target ${target} for project ${project}`);
24
+ }
25
+ // TODO(v19): remove Workspaces.
26
+ const ws = new Workspaces(context.root);
27
+ const [nodeModule, executorName] = targetConfiguration.executor.split(':');
28
+ const { schema } = getExecutorInformation
29
+ ? getExecutorInformation(nodeModule, executorName, context.root, context.projectsConfigurations?.projects ?? context.workspace.projects)
30
+ : // TODO(v19): remove readExecutor. This is to be backwards compatible with Nx 16.5 and below.
31
+ ws.readExecutor(nodeModule, executorName);
32
+ const defaultProject = calculateDefaultProjectName
33
+ ? calculateDefaultProjectName(context.cwd, context.root, { version: 2, projects: context.projectsConfigurations.projects }, context.nxJsonConfiguration)
34
+ : // TODO(v19): remove calculateDefaultProjectName. This is to be backwards compatible with Nx 16.5 and below.
35
+ ws.calculateDefaultProjectName(context.cwd, { version: 2, projects: context.projectsConfigurations.projects }, context.nxJsonConfiguration);
36
+ return combineOptionsForExecutor({}, configuration ?? targetConfiguration.defaultConfiguration ?? '', targetConfiguration, schema, defaultProject, (0, path_1.relative)(context.root, context.cwd));
37
+ }
38
+ exports.readTargetOptions = readTargetOptions;
@@ -0,0 +1,2 @@
1
+ import type { Tree } from 'nx/src/devkit-exports';
2
+ export declare function addBuildTargetDefaults(tree: Tree, executorName: string, buildTargetName?: string): void;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.addBuildTargetDefaults = void 0;
4
+ const nx_1 = require("../../nx");
5
+ const { readNxJson, updateNxJson } = (0, nx_1.requireNx)();
6
+ function addBuildTargetDefaults(tree, executorName, buildTargetName = 'build') {
7
+ const nxJson = readNxJson(tree);
8
+ nxJson.targetDefaults ??= {};
9
+ nxJson.targetDefaults[executorName] ??= {
10
+ cache: true,
11
+ dependsOn: [`^${buildTargetName}`],
12
+ inputs: nxJson.namedInputs && 'production' in nxJson.namedInputs
13
+ ? ['production', '^production']
14
+ : ['default', '^default'],
15
+ };
16
+ updateNxJson(tree, nxJson);
17
+ }
18
+ exports.addBuildTargetDefaults = addBuildTargetDefaults;
@@ -0,0 +1,48 @@
1
+ import type { Tree } from 'nx/src/generators/tree';
2
+ export type NameAndDirectoryFormat = 'as-provided' | 'derived';
3
+ export type ArtifactGenerationOptions = {
4
+ artifactType: string;
5
+ callingGenerator: string | null;
6
+ name: string;
7
+ directory?: string;
8
+ disallowPathInNameForDerived?: boolean;
9
+ fileExtension?: 'js' | 'jsx' | 'ts' | 'tsx' | 'vue';
10
+ fileName?: string;
11
+ flat?: boolean;
12
+ nameAndDirectoryFormat?: NameAndDirectoryFormat;
13
+ pascalCaseDirectory?: boolean;
14
+ pascalCaseFile?: boolean;
15
+ project?: string;
16
+ suffix?: string;
17
+ derivedDirectory?: string;
18
+ };
19
+ export type NameAndDirectoryOptions = {
20
+ /**
21
+ * Normalized artifact name.
22
+ */
23
+ artifactName: string;
24
+ /**
25
+ * Normalized directory path where the artifact will be generated.
26
+ */
27
+ directory: string;
28
+ /**
29
+ * Normalized file name of the artifact without the extension.
30
+ */
31
+ fileName: string;
32
+ /**
33
+ * Normalized full file path of the artifact.
34
+ */
35
+ filePath: string;
36
+ /**
37
+ * Project name where the artifact will be generated.
38
+ */
39
+ project: string;
40
+ };
41
+ export declare function determineArtifactNameAndDirectoryOptions(tree: Tree, options: ArtifactGenerationOptions): Promise<NameAndDirectoryOptions & {
42
+ nameAndDirectoryFormat: NameAndDirectoryFormat;
43
+ }>;
44
+ export declare function getRelativeCwd(): string;
45
+ /**
46
+ * Function for setting cwd during testing
47
+ */
48
+ export declare function setCwd(path: string): void;