@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.
- package/LICENSE +22 -0
- package/README.md +68 -0
- package/index.d.ts +14 -0
- package/index.js +18 -0
- package/migrations.json +18 -0
- package/ngcli-adapter.d.ts +4 -0
- package/ngcli-adapter.js +11 -0
- package/nx.d.ts +1 -0
- package/nx.js +19 -0
- package/package.json +50 -0
- package/public-api.d.ts +78 -0
- package/public-api.js +100 -0
- package/src/executors/parse-target-string.d.ts +44 -0
- package/src/executors/parse-target-string.js +55 -0
- package/src/executors/read-target-options.d.ts +8 -0
- package/src/executors/read-target-options.js +38 -0
- package/src/generators/add-build-target-defaults.d.ts +2 -0
- package/src/generators/add-build-target-defaults.js +18 -0
- package/src/generators/artifact-name-and-directory-utils.d.ts +48 -0
- package/src/generators/artifact-name-and-directory-utils.js +239 -0
- package/src/generators/executor-options-utils.d.ts +21 -0
- package/src/generators/executor-options-utils.js +49 -0
- package/src/generators/format-files.d.ts +6 -0
- package/src/generators/format-files.js +91 -0
- package/src/generators/generate-files.d.ts +26 -0
- package/src/generators/generate-files.js +91 -0
- package/src/generators/project-name-and-root-utils.d.ts +47 -0
- package/src/generators/project-name-and-root-utils.js +298 -0
- package/src/generators/run-tasks-in-serial.d.ts +7 -0
- package/src/generators/run-tasks-in-serial.js +16 -0
- package/src/generators/to-js.d.ts +11 -0
- package/src/generators/to-js.js +24 -0
- package/src/generators/typescript/insert-import.d.ts +1 -0
- package/src/generators/typescript/insert-import.js +5 -0
- package/src/generators/typescript/insert-statement.d.ts +1 -0
- package/src/generators/typescript/insert-statement.js +5 -0
- package/src/generators/update-ts-configs-to-js.d.ts +4 -0
- package/src/generators/update-ts-configs-to-js.js +49 -0
- package/src/generators/visit-not-ignored-files.d.ts +5 -0
- package/src/generators/visit-not-ignored-files.js +41 -0
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.d.ts +2 -0
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js +9 -0
- package/src/migrations/update-16-9-0/migrate-mf-util-usage.d.ts +4 -0
- package/src/migrations/update-16-9-0/migrate-mf-util-usage.js +201 -0
- package/src/tasks/install-packages-task.d.ts +10 -0
- package/src/tasks/install-packages-task.js +41 -0
- package/src/utils/async-iterable/combine-async-iterables.d.ts +3 -0
- package/src/utils/async-iterable/combine-async-iterables.js +58 -0
- package/src/utils/async-iterable/create-async-iterable.d.ts +6 -0
- package/src/utils/async-iterable/create-async-iterable.js +58 -0
- package/src/utils/async-iterable/index.d.ts +4 -0
- package/src/utils/async-iterable/index.js +7 -0
- package/src/utils/async-iterable/map-async-iteratable.d.ts +1 -0
- package/src/utils/async-iterable/map-async-iteratable.js +18 -0
- package/src/utils/async-iterable/tap-async-iteratable.d.ts +1 -0
- package/src/utils/async-iterable/tap-async-iteratable.js +11 -0
- package/src/utils/binary-extensions.d.ts +1 -0
- package/src/utils/binary-extensions.js +275 -0
- package/src/utils/calculate-hash-for-create-nodes.d.ts +2 -0
- package/src/utils/calculate-hash-for-create-nodes.js +16 -0
- package/src/utils/config-utils.d.ts +4 -0
- package/src/utils/config-utils.js +75 -0
- package/src/utils/convert-nx-executor.d.ts +7 -0
- package/src/utils/convert-nx-executor.js +89 -0
- package/src/utils/get-named-inputs.d.ts +8 -0
- package/src/utils/get-named-inputs.js +26 -0
- package/src/utils/get-workspace-layout.d.ts +24 -0
- package/src/utils/get-workspace-layout.js +52 -0
- package/src/utils/invoke-nx-generator.d.ts +6 -0
- package/src/utils/invoke-nx-generator.js +172 -0
- package/src/utils/log-show-project-command.d.ts +1 -0
- package/src/utils/log-show-project-command.js +14 -0
- package/src/utils/move-dir.d.ts +5 -0
- package/src/utils/move-dir.js +28 -0
- package/src/utils/names.d.ts +18 -0
- package/src/utils/names.js +63 -0
- package/src/utils/offset-from-root.d.ts +13 -0
- package/src/utils/offset-from-root.js +29 -0
- package/src/utils/package-json.d.ts +78 -0
- package/src/utils/package-json.js +375 -0
- package/src/utils/replace-package.d.ts +2 -0
- package/src/utils/replace-package.js +125 -0
- package/src/utils/replace-project-configuration-with-plugin.d.ts +3 -0
- package/src/utils/replace-project-configuration-with-plugin.js +136 -0
- package/src/utils/rxjs-for-await.d.ts +109 -0
- package/src/utils/rxjs-for-await.js +363 -0
- package/src/utils/semver.d.ts +1 -0
- package/src/utils/semver.js +18 -0
- package/src/utils/string-change.d.ts +62 -0
- package/src/utils/string-change.js +109 -0
- package/src/utils/string-utils.d.ts +95 -0
- package/src/utils/string-utils.js +147 -0
- package/src/utils/update-package-scripts.d.ts +3 -0
- package/src/utils/update-package-scripts.js +175 -0
- package/src/utils/versions.d.ts +1 -0
- package/src/utils/versions.js +4 -0
- package/testing.d.ts +1 -0
- package/testing.js +5 -0
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts a camelized string into all lower case separated by underscores.
|
|
3
|
+
*
|
|
4
|
+
```javascript
|
|
5
|
+
decamelize('innerHTML'); // 'inner_html'
|
|
6
|
+
decamelize('action_name'); // 'action_name'
|
|
7
|
+
decamelize('css-class-name'); // 'css-class-name'
|
|
8
|
+
decamelize('my favorite items'); // 'my favorite items'
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
@method decamelize
|
|
12
|
+
@param {String} str The string to decamelize.
|
|
13
|
+
@return {String} the decamelized string.
|
|
14
|
+
*/
|
|
15
|
+
export declare function decamelize(str: string): string;
|
|
16
|
+
/**
|
|
17
|
+
Replaces underscores, spaces, periods, or camelCase with dashes.
|
|
18
|
+
|
|
19
|
+
```javascript
|
|
20
|
+
dasherize('innerHTML'); // 'inner-html'
|
|
21
|
+
dasherize('action_name'); // 'action-name'
|
|
22
|
+
dasherize('css-class-name'); // 'css-class-name'
|
|
23
|
+
dasherize('my favorite items'); // 'my-favorite-items'
|
|
24
|
+
dasherize('nrwl.io'); // 'nrwl-io'
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
@method dasherize
|
|
28
|
+
@param {String} str The string to dasherize.
|
|
29
|
+
@return {String} the dasherized string.
|
|
30
|
+
*/
|
|
31
|
+
export declare function dasherize(str?: string): string;
|
|
32
|
+
/**
|
|
33
|
+
Returns the lowerCamelCase form of a string.
|
|
34
|
+
|
|
35
|
+
```javascript
|
|
36
|
+
camelize('innerHTML'); // 'innerHTML'
|
|
37
|
+
camelize('action_name'); // 'actionName'
|
|
38
|
+
camelize('css-class-name'); // 'cssClassName'
|
|
39
|
+
camelize('my favorite items'); // 'myFavoriteItems'
|
|
40
|
+
camelize('My Favorite Items'); // 'myFavoriteItems'
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
@method camelize
|
|
44
|
+
@param {String} str The string to camelize.
|
|
45
|
+
@return {String} the camelized string.
|
|
46
|
+
*/
|
|
47
|
+
export declare function camelize(str: string): string;
|
|
48
|
+
/**
|
|
49
|
+
Returns the UpperCamelCase form of a string.
|
|
50
|
+
|
|
51
|
+
```javascript
|
|
52
|
+
'innerHTML'.classify(); // 'InnerHTML'
|
|
53
|
+
'action_name'.classify(); // 'ActionName'
|
|
54
|
+
'css-class-name'.classify(); // 'CssClassName'
|
|
55
|
+
'my favorite items'.classify(); // 'MyFavoriteItems'
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
@method classify
|
|
59
|
+
@param {String} str the string to classify
|
|
60
|
+
@return {String} the classified string
|
|
61
|
+
*/
|
|
62
|
+
export declare function classify(str: string): string;
|
|
63
|
+
/**
|
|
64
|
+
More general than decamelize. Returns the lower\_case\_and\_underscored
|
|
65
|
+
form of a string.
|
|
66
|
+
|
|
67
|
+
```javascript
|
|
68
|
+
'innerHTML'.underscore(); // 'inner_html'
|
|
69
|
+
'action_name'.underscore(); // 'action_name'
|
|
70
|
+
'css-class-name'.underscore(); // 'css_class_name'
|
|
71
|
+
'my favorite items'.underscore(); // 'my_favorite_items'
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
@method underscore
|
|
75
|
+
@param {String} str The string to underscore.
|
|
76
|
+
@return {String} the underscored string.
|
|
77
|
+
*/
|
|
78
|
+
export declare function underscore(str: string): string;
|
|
79
|
+
/**
|
|
80
|
+
Returns the Capitalized form of a string
|
|
81
|
+
|
|
82
|
+
```javascript
|
|
83
|
+
'innerHTML'.capitalize() // 'InnerHTML'
|
|
84
|
+
'action_name'.capitalize() // 'Action_name'
|
|
85
|
+
'css-class-name'.capitalize() // 'Css-class-name'
|
|
86
|
+
'my favorite items'.capitalize() // 'My favorite items'
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
@method capitalize
|
|
90
|
+
@param {String} str The string to capitalize.
|
|
91
|
+
@return {String} The capitalized string.
|
|
92
|
+
*/
|
|
93
|
+
export declare function capitalize(str: string): string;
|
|
94
|
+
export declare function group(name: string, group: string | undefined): string;
|
|
95
|
+
export declare function featurePath(group: boolean | undefined, flat: boolean | undefined, path: string, name: string): string;
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.featurePath = exports.group = exports.capitalize = exports.underscore = exports.classify = exports.camelize = exports.dasherize = exports.decamelize = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* @license
|
|
6
|
+
* Copyright Google Inc. All Rights Reserved.
|
|
7
|
+
*
|
|
8
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
9
|
+
* found in the LICENSE file at https://angular.io/license
|
|
10
|
+
*/
|
|
11
|
+
const STRING_DASHERIZE_REGEXP = /[ _.]/g;
|
|
12
|
+
const STRING_DECAMELIZE_REGEXP = /([a-z\d])([A-Z])/g;
|
|
13
|
+
const STRING_CAMELIZE_REGEXP = /(-|_|\.|\s)+(.)?/g;
|
|
14
|
+
const STRING_UNDERSCORE_REGEXP_1 = /([a-z\d])([A-Z]+)/g;
|
|
15
|
+
const STRING_UNDERSCORE_REGEXP_2 = /-|\s+/g;
|
|
16
|
+
/**
|
|
17
|
+
* Converts a camelized string into all lower case separated by underscores.
|
|
18
|
+
*
|
|
19
|
+
```javascript
|
|
20
|
+
decamelize('innerHTML'); // 'inner_html'
|
|
21
|
+
decamelize('action_name'); // 'action_name'
|
|
22
|
+
decamelize('css-class-name'); // 'css-class-name'
|
|
23
|
+
decamelize('my favorite items'); // 'my favorite items'
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
@method decamelize
|
|
27
|
+
@param {String} str The string to decamelize.
|
|
28
|
+
@return {String} the decamelized string.
|
|
29
|
+
*/
|
|
30
|
+
function decamelize(str) {
|
|
31
|
+
return str.replace(STRING_DECAMELIZE_REGEXP, '$1_$2').toLowerCase();
|
|
32
|
+
}
|
|
33
|
+
exports.decamelize = decamelize;
|
|
34
|
+
/**
|
|
35
|
+
Replaces underscores, spaces, periods, or camelCase with dashes.
|
|
36
|
+
|
|
37
|
+
```javascript
|
|
38
|
+
dasherize('innerHTML'); // 'inner-html'
|
|
39
|
+
dasherize('action_name'); // 'action-name'
|
|
40
|
+
dasherize('css-class-name'); // 'css-class-name'
|
|
41
|
+
dasherize('my favorite items'); // 'my-favorite-items'
|
|
42
|
+
dasherize('nrwl.io'); // 'nrwl-io'
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
@method dasherize
|
|
46
|
+
@param {String} str The string to dasherize.
|
|
47
|
+
@return {String} the dasherized string.
|
|
48
|
+
*/
|
|
49
|
+
function dasherize(str) {
|
|
50
|
+
return decamelize(str || '').replace(STRING_DASHERIZE_REGEXP, '-');
|
|
51
|
+
}
|
|
52
|
+
exports.dasherize = dasherize;
|
|
53
|
+
/**
|
|
54
|
+
Returns the lowerCamelCase form of a string.
|
|
55
|
+
|
|
56
|
+
```javascript
|
|
57
|
+
camelize('innerHTML'); // 'innerHTML'
|
|
58
|
+
camelize('action_name'); // 'actionName'
|
|
59
|
+
camelize('css-class-name'); // 'cssClassName'
|
|
60
|
+
camelize('my favorite items'); // 'myFavoriteItems'
|
|
61
|
+
camelize('My Favorite Items'); // 'myFavoriteItems'
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
@method camelize
|
|
65
|
+
@param {String} str The string to camelize.
|
|
66
|
+
@return {String} the camelized string.
|
|
67
|
+
*/
|
|
68
|
+
function camelize(str) {
|
|
69
|
+
return str
|
|
70
|
+
.replace(STRING_CAMELIZE_REGEXP, (_match, _separator, chr) => {
|
|
71
|
+
return chr ? chr.toUpperCase() : '';
|
|
72
|
+
})
|
|
73
|
+
.replace(/^([A-Z])/, (match) => match.toLowerCase());
|
|
74
|
+
}
|
|
75
|
+
exports.camelize = camelize;
|
|
76
|
+
/**
|
|
77
|
+
Returns the UpperCamelCase form of a string.
|
|
78
|
+
|
|
79
|
+
```javascript
|
|
80
|
+
'innerHTML'.classify(); // 'InnerHTML'
|
|
81
|
+
'action_name'.classify(); // 'ActionName'
|
|
82
|
+
'css-class-name'.classify(); // 'CssClassName'
|
|
83
|
+
'my favorite items'.classify(); // 'MyFavoriteItems'
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
@method classify
|
|
87
|
+
@param {String} str the string to classify
|
|
88
|
+
@return {String} the classified string
|
|
89
|
+
*/
|
|
90
|
+
function classify(str) {
|
|
91
|
+
return str
|
|
92
|
+
.split('.')
|
|
93
|
+
.map((part) => capitalize(camelize(part)))
|
|
94
|
+
.join('.');
|
|
95
|
+
}
|
|
96
|
+
exports.classify = classify;
|
|
97
|
+
/**
|
|
98
|
+
More general than decamelize. Returns the lower\_case\_and\_underscored
|
|
99
|
+
form of a string.
|
|
100
|
+
|
|
101
|
+
```javascript
|
|
102
|
+
'innerHTML'.underscore(); // 'inner_html'
|
|
103
|
+
'action_name'.underscore(); // 'action_name'
|
|
104
|
+
'css-class-name'.underscore(); // 'css_class_name'
|
|
105
|
+
'my favorite items'.underscore(); // 'my_favorite_items'
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
@method underscore
|
|
109
|
+
@param {String} str The string to underscore.
|
|
110
|
+
@return {String} the underscored string.
|
|
111
|
+
*/
|
|
112
|
+
function underscore(str) {
|
|
113
|
+
return str
|
|
114
|
+
.replace(STRING_UNDERSCORE_REGEXP_1, '$1_$2')
|
|
115
|
+
.replace(STRING_UNDERSCORE_REGEXP_2, '_')
|
|
116
|
+
.toLowerCase();
|
|
117
|
+
}
|
|
118
|
+
exports.underscore = underscore;
|
|
119
|
+
/**
|
|
120
|
+
Returns the Capitalized form of a string
|
|
121
|
+
|
|
122
|
+
```javascript
|
|
123
|
+
'innerHTML'.capitalize() // 'InnerHTML'
|
|
124
|
+
'action_name'.capitalize() // 'Action_name'
|
|
125
|
+
'css-class-name'.capitalize() // 'Css-class-name'
|
|
126
|
+
'my favorite items'.capitalize() // 'My favorite items'
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
@method capitalize
|
|
130
|
+
@param {String} str The string to capitalize.
|
|
131
|
+
@return {String} The capitalized string.
|
|
132
|
+
*/
|
|
133
|
+
function capitalize(str) {
|
|
134
|
+
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
135
|
+
}
|
|
136
|
+
exports.capitalize = capitalize;
|
|
137
|
+
function group(name, group) {
|
|
138
|
+
return group ? `${group}/${name}` : name;
|
|
139
|
+
}
|
|
140
|
+
exports.group = group;
|
|
141
|
+
function featurePath(group, flat, path, name) {
|
|
142
|
+
if (group && !flat) {
|
|
143
|
+
return `../../${path}/${name}/`;
|
|
144
|
+
}
|
|
145
|
+
return group ? `../${path}/` : './';
|
|
146
|
+
}
|
|
147
|
+
exports.featurePath = featurePath;
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.updatePackageScripts = void 0;
|
|
4
|
+
const path_1 = require("path");
|
|
5
|
+
const yargs = require("yargs-parser");
|
|
6
|
+
const nx_1 = require("../../nx");
|
|
7
|
+
const { glob, readJson, readNxJson, workspaceRoot, writeJson } = (0, nx_1.requireNx)();
|
|
8
|
+
async function updatePackageScripts(tree, createNodesTuple) {
|
|
9
|
+
const nxJson = readNxJson(tree);
|
|
10
|
+
const [pattern, createNodes] = createNodesTuple;
|
|
11
|
+
const files = glob(tree, [pattern]);
|
|
12
|
+
for (const file of files) {
|
|
13
|
+
const projectRoot = getProjectRootFromConfigFile(file);
|
|
14
|
+
await processProject(tree, projectRoot, file, createNodes, nxJson);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.updatePackageScripts = updatePackageScripts;
|
|
18
|
+
async function processProject(tree, projectRoot, projectConfigurationFile, createNodesFunction, nxJsonConfiguration) {
|
|
19
|
+
const packageJsonPath = `${projectRoot}/package.json`;
|
|
20
|
+
if (!tree.exists(packageJsonPath)) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
const packageJson = readJson(tree, packageJsonPath);
|
|
24
|
+
if (!packageJson.scripts || !Object.keys(packageJson.scripts).length) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
const result = await createNodesFunction(projectConfigurationFile, {}, { nxJsonConfiguration, workspaceRoot });
|
|
28
|
+
const targetCommands = getInferredTargetCommands(result);
|
|
29
|
+
if (!targetCommands.length) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
const replacedTargets = new Set();
|
|
33
|
+
for (const targetCommand of targetCommands) {
|
|
34
|
+
const { command, target, configuration } = targetCommand;
|
|
35
|
+
const targetCommandRegex = new RegExp(`(?<=^|&)((?: )*(?:[^&\\r\\n\\s]+ )*)(${command})((?: [^&\\r\\n\\s]+)*(?: )*)(?=$|&)`, 'g');
|
|
36
|
+
for (const scriptName of Object.keys(packageJson.scripts)) {
|
|
37
|
+
const script = packageJson.scripts[scriptName];
|
|
38
|
+
// quick check for exact match within the script
|
|
39
|
+
if (targetCommandRegex.test(script)) {
|
|
40
|
+
packageJson.scripts[scriptName] = script.replace(targetCommandRegex, configuration
|
|
41
|
+
? `$1nx ${target} --configuration=${configuration}$3`
|
|
42
|
+
: `$1nx ${target}$3`);
|
|
43
|
+
replacedTargets.add(target);
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
/**
|
|
47
|
+
* Parse script and command to handle the following:
|
|
48
|
+
* - if command doesn't match script => don't replace
|
|
49
|
+
* - if command has more args => don't replace
|
|
50
|
+
* - if command has same args, regardless of order => replace removing args
|
|
51
|
+
* - if command has less args or with different value => replace leaving args
|
|
52
|
+
*/
|
|
53
|
+
const parsedCommand = yargs(command, {
|
|
54
|
+
configuration: { 'strip-dashed': true },
|
|
55
|
+
});
|
|
56
|
+
// this assumes there are no positional args in the command, everything is a command or subcommand
|
|
57
|
+
const commandCommand = parsedCommand._.join(' ');
|
|
58
|
+
const commandRegex = new RegExp(`(?<=^|&)((?: )*(?:[^&\\r\\n\\s]+ )*)(${commandCommand})((?: [^&\\r\\n\\s]+)*( )*)(?=$|&)`, 'g');
|
|
59
|
+
const matches = script.match(commandRegex);
|
|
60
|
+
if (!matches) {
|
|
61
|
+
// the command doesn't match the script, don't replace
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
for (const match of matches) {
|
|
65
|
+
// parse the matched command within the script
|
|
66
|
+
const parsedScript = yargs(match, {
|
|
67
|
+
configuration: { 'strip-dashed': true },
|
|
68
|
+
});
|
|
69
|
+
let hasArgsWithDifferentValues = false;
|
|
70
|
+
let scriptHasExtraArgs = false;
|
|
71
|
+
let commandHasExtraArgs = false;
|
|
72
|
+
for (const [key, value] of Object.entries(parsedCommand)) {
|
|
73
|
+
if (key === '_') {
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
if (parsedScript[key] === undefined) {
|
|
77
|
+
commandHasExtraArgs = true;
|
|
78
|
+
break;
|
|
79
|
+
}
|
|
80
|
+
if (parsedScript[key] !== value) {
|
|
81
|
+
hasArgsWithDifferentValues = true;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
if (commandHasExtraArgs) {
|
|
85
|
+
// the command has extra args, don't replace
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
for (const key of Object.keys(parsedScript)) {
|
|
89
|
+
if (key === '_') {
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
if (!parsedCommand[key]) {
|
|
93
|
+
scriptHasExtraArgs = true;
|
|
94
|
+
break;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
if (!hasArgsWithDifferentValues && !scriptHasExtraArgs) {
|
|
98
|
+
// they are the same, replace with the command removing the args
|
|
99
|
+
packageJson.scripts[scriptName] = packageJson.scripts[scriptName].replace(match, match.replace(commandRegex, configuration
|
|
100
|
+
? `$1nx ${target} --configuration=${configuration}$4`
|
|
101
|
+
: `$1nx ${target}$4`));
|
|
102
|
+
replacedTargets.add(target);
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
// there are different args or the script has extra args, replace with the command leaving the args
|
|
106
|
+
packageJson.scripts[scriptName] = packageJson.scripts[scriptName].replace(match, match.replace(commandRegex, configuration
|
|
107
|
+
? `$1nx ${target} --configuration=${configuration}$3`
|
|
108
|
+
: `$1nx ${target}$3`));
|
|
109
|
+
replacedTargets.add(target);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
packageJson.nx ??= {};
|
|
116
|
+
if (process.env.NX_RUNNING_NX_INIT === 'true') {
|
|
117
|
+
// running `nx init` so we want to exclude everything by default
|
|
118
|
+
packageJson.nx.includedScripts = [];
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
/**
|
|
122
|
+
* Running `nx add`. In this case we want to:
|
|
123
|
+
* - if `includedScripts` is already set: exclude scripts that match inferred targets that were used to replace a script
|
|
124
|
+
* - if `includedScripts` is not set: set `includedScripts` with all scripts except the ones that match an inferred target that was used to replace a script
|
|
125
|
+
*/
|
|
126
|
+
packageJson.nx.includedScripts ??= Object.keys(packageJson.scripts);
|
|
127
|
+
packageJson.nx.includedScripts = packageJson.nx.includedScripts.filter((s) => !replacedTargets.has(s));
|
|
128
|
+
}
|
|
129
|
+
writeJson(tree, packageJsonPath, packageJson);
|
|
130
|
+
}
|
|
131
|
+
function getInferredTargetCommands(result) {
|
|
132
|
+
const targetCommands = [];
|
|
133
|
+
for (const project of Object.values(result.projects ?? {})) {
|
|
134
|
+
for (const [targetName, target] of Object.entries(project.targets ?? {})) {
|
|
135
|
+
if (target.command) {
|
|
136
|
+
targetCommands.push({ command: target.command, target: targetName });
|
|
137
|
+
}
|
|
138
|
+
else if (target.executor === 'nx:run-commands' &&
|
|
139
|
+
target.options?.command) {
|
|
140
|
+
targetCommands.push({
|
|
141
|
+
command: target.options.command,
|
|
142
|
+
target: targetName,
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
if (!target.configurations) {
|
|
146
|
+
continue;
|
|
147
|
+
}
|
|
148
|
+
for (const [configurationName, configuration] of Object.entries(target.configurations)) {
|
|
149
|
+
if (configuration.command) {
|
|
150
|
+
targetCommands.push({
|
|
151
|
+
command: configuration.command,
|
|
152
|
+
target: targetName,
|
|
153
|
+
configuration: configurationName,
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
else if (target.executor === 'nx:run-commands' &&
|
|
157
|
+
configuration.options?.command) {
|
|
158
|
+
targetCommands.push({
|
|
159
|
+
command: configuration.options.command,
|
|
160
|
+
target: targetName,
|
|
161
|
+
configuration: configurationName,
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
return targetCommands;
|
|
168
|
+
}
|
|
169
|
+
function getProjectRootFromConfigFile(file) {
|
|
170
|
+
let projectRoot = (0, path_1.dirname)(file);
|
|
171
|
+
if ((0, path_1.basename)(projectRoot) === '.storybook') {
|
|
172
|
+
projectRoot = (0, path_1.dirname)(projectRoot);
|
|
173
|
+
}
|
|
174
|
+
return projectRoot;
|
|
175
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const typescriptVersion = "~5.3.2";
|
package/testing.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from 'nx/src/devkit-testing-exports';
|
package/testing.js
ADDED