@nx/devkit 16.8.0-beta.3 → 16.8.0-beta.5
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/nx.js +8 -4
- package/package.json +3 -3
- package/src/executors/parse-target-string.js +1 -1
- package/src/executors/read-target-options.js +3 -3
- package/src/generators/format-files.js +43 -36
- package/src/generators/generate-files.js +2 -2
- package/src/generators/project-name-and-root-utils.js +64 -67
- package/src/generators/run-tasks-in-serial.js +3 -4
- package/src/generators/visit-not-ignored-files.js +3 -3
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js +3 -6
- package/src/utils/async-iterable/combine-async-iterables.js +37 -55
- package/src/utils/async-iterable/create-async-iterable.js +3 -6
- package/src/utils/async-iterable/map-async-iteratable.js +12 -17
- package/src/utils/async-iterable/tap-async-iteratable.js +4 -7
- package/src/utils/convert-nx-executor.js +3 -4
- package/src/utils/get-workspace-layout.js +5 -4
- package/src/utils/invoke-nx-generator.js +9 -10
- package/src/utils/module-federation/dependencies.js +1 -2
- package/src/utils/module-federation/secondary-entry-points.js +6 -5
- package/src/utils/module-federation/share.js +10 -10
- package/src/utils/module-federation/typescript.js +3 -5
- package/src/utils/package-json.js +30 -18
- package/src/utils/replace-package.js +9 -12
- package/src/utils/rxjs-for-await.js +217 -226
package/nx.js
CHANGED
|
@@ -6,14 +6,18 @@ exports.requireNx = void 0;
|
|
|
6
6
|
// - import {} from 'nx/src/devkit-internals'
|
|
7
7
|
function requireNx() {
|
|
8
8
|
try {
|
|
9
|
-
let result =
|
|
9
|
+
let result = { ...require('nx/src/devkit-exports') };
|
|
10
10
|
try {
|
|
11
|
-
result =
|
|
11
|
+
result = {
|
|
12
|
+
...result,
|
|
13
|
+
// Remove in Nx v18, devkit should not support Nx v16.0.2 at that point.
|
|
14
|
+
...require('nx/src/devkit-internals'),
|
|
15
|
+
};
|
|
12
16
|
}
|
|
13
|
-
catch
|
|
17
|
+
catch { }
|
|
14
18
|
return result;
|
|
15
19
|
}
|
|
16
|
-
catch
|
|
20
|
+
catch {
|
|
17
21
|
// Remove in Nx V17, devkit should not support Nx < 16 at that point.
|
|
18
22
|
return require('./nx-reexports-pre16');
|
|
19
23
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/devkit",
|
|
3
|
-
"version": "16.8.0-beta.
|
|
3
|
+
"version": "16.8.0-beta.5",
|
|
4
4
|
"private": false,
|
|
5
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.",
|
|
6
6
|
"repository": {
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
},
|
|
29
29
|
"homepage": "https://nx.dev",
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@nrwl/devkit": "16.8.0-beta.
|
|
31
|
+
"@nrwl/devkit": "16.8.0-beta.5",
|
|
32
32
|
"ejs": "^3.1.7",
|
|
33
33
|
"enquirer": "~2.3.6",
|
|
34
34
|
"ignore": "^5.0.4",
|
|
@@ -46,5 +46,5 @@
|
|
|
46
46
|
"migrations": "./migrations.json"
|
|
47
47
|
},
|
|
48
48
|
"type": "commonjs",
|
|
49
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "ad2d1e8a55b2d1b358bb5e7483343d9757ff2c53"
|
|
50
50
|
}
|
|
@@ -4,7 +4,7 @@ exports.targetToTargetString = exports.parseTargetString = void 0;
|
|
|
4
4
|
const nx_1 = require("../../nx");
|
|
5
5
|
let { readCachedProjectGraph, splitTarget } = (0, nx_1.requireNx)();
|
|
6
6
|
// TODO: Remove this in Nx 18 when Nx 16.7.0 is no longer supported
|
|
7
|
-
splitTarget = splitTarget
|
|
7
|
+
splitTarget = splitTarget ?? require('nx/src/utils/split-target').splitTarget;
|
|
8
8
|
function parseTargetString(targetString, projectGraph) {
|
|
9
9
|
if (!projectGraph) {
|
|
10
10
|
try {
|
|
@@ -6,14 +6,14 @@ const path_1 = require("path");
|
|
|
6
6
|
let { Workspaces, getExecutorInformation, calculateDefaultProjectName, combineOptionsForExecutor, } = (0, nx_1.requireNx)();
|
|
7
7
|
// TODO: Remove this in Nx 18 when Nx 16.7.0 is no longer supported
|
|
8
8
|
combineOptionsForExecutor =
|
|
9
|
-
combineOptionsForExecutor
|
|
9
|
+
combineOptionsForExecutor ??
|
|
10
|
+
require('nx/src/utils/params').combineOptionsForExecutor;
|
|
10
11
|
/**
|
|
11
12
|
* Reads and combines options for a given target.
|
|
12
13
|
*
|
|
13
14
|
* Works as if you invoked the target yourself without passing any command lint overrides.
|
|
14
15
|
*/
|
|
15
16
|
function readTargetOptions({ project, target, configuration }, context) {
|
|
16
|
-
var _a;
|
|
17
17
|
const projectConfiguration = (context.workspace || context.projectsConfigurations).projects[project];
|
|
18
18
|
const targetConfiguration = projectConfiguration.targets[target];
|
|
19
19
|
// TODO(v18): remove Workspaces.
|
|
@@ -27,6 +27,6 @@ function readTargetOptions({ project, target, configuration }, context) {
|
|
|
27
27
|
? calculateDefaultProjectName(context.cwd, context.root, { version: 2, projects: context.projectsConfigurations.projects }, context.nxJsonConfiguration)
|
|
28
28
|
: // TODO(v18): remove calculateDefaultProjectName. This is to be backwards compatible with Nx 16.5 and below.
|
|
29
29
|
ws.calculateDefaultProjectName(context.cwd, { version: 2, projects: context.projectsConfigurations.projects }, context.nxJsonConfiguration);
|
|
30
|
-
return combineOptionsForExecutor({},
|
|
30
|
+
return combineOptionsForExecutor({}, configuration ?? targetConfiguration.defaultConfiguration ?? '', targetConfiguration, schema, defaultProject, (0, path_1.relative)(context.cwd, context.root));
|
|
31
31
|
}
|
|
32
32
|
exports.readTargetOptions = readTargetOptions;
|
|
@@ -1,52 +1,53 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.formatFiles = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
4
|
const path = require("path");
|
|
6
5
|
const nx_1 = require("../../nx");
|
|
7
6
|
let { updateJson, readJson, sortObjectByKeys } = (0, nx_1.requireNx)();
|
|
8
7
|
// TODO: Remove this in Nx 18 when Nx 16.7.0 is no longer supported
|
|
9
8
|
sortObjectByKeys =
|
|
10
|
-
sortObjectByKeys
|
|
9
|
+
sortObjectByKeys ?? require('nx/src/utils/object-sort').sortObjectByKeys;
|
|
11
10
|
/**
|
|
12
11
|
* Formats all the created or updated files using Prettier
|
|
13
12
|
* @param tree - the file system tree
|
|
14
13
|
*/
|
|
15
|
-
function formatFiles(tree) {
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
async function formatFiles(tree) {
|
|
15
|
+
let prettier;
|
|
16
|
+
try {
|
|
17
|
+
prettier = await Promise.resolve().then(() => require('prettier'));
|
|
18
|
+
}
|
|
19
|
+
catch { }
|
|
20
|
+
sortTsConfig(tree);
|
|
21
|
+
if (!prettier)
|
|
22
|
+
return;
|
|
23
|
+
const files = new Set(tree.listChanges().filter((file) => file.type !== 'DELETE'));
|
|
24
|
+
const changedPrettierInTree = getChangedPrettierConfigInTree(tree);
|
|
25
|
+
await Promise.all(Array.from(files).map(async (file) => {
|
|
18
26
|
try {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
const resolvedOptions = yield prettier.resolveConfig(systemPath, {
|
|
31
|
-
editorconfig: true,
|
|
32
|
-
});
|
|
33
|
-
const options = Object.assign(Object.assign(Object.assign({}, resolvedOptions), changedPrettierInTree), { filepath: systemPath });
|
|
34
|
-
if (file.path.endsWith('.swcrc')) {
|
|
35
|
-
options.parser = 'json';
|
|
36
|
-
}
|
|
37
|
-
const support = yield prettier.getFileInfo(systemPath, options);
|
|
38
|
-
if (support.ignored || !support.inferredParser) {
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
tree.write(file.path,
|
|
42
|
-
// In prettier v3 the format result is a promise
|
|
43
|
-
yield prettier.format(file.content.toString('utf-8'), options));
|
|
27
|
+
const systemPath = path.join(tree.root, file.path);
|
|
28
|
+
const resolvedOptions = await prettier.resolveConfig(systemPath, {
|
|
29
|
+
editorconfig: true,
|
|
30
|
+
});
|
|
31
|
+
const options = {
|
|
32
|
+
...resolvedOptions,
|
|
33
|
+
...changedPrettierInTree,
|
|
34
|
+
filepath: systemPath,
|
|
35
|
+
};
|
|
36
|
+
if (file.path.endsWith('.swcrc')) {
|
|
37
|
+
options.parser = 'json';
|
|
44
38
|
}
|
|
45
|
-
|
|
46
|
-
|
|
39
|
+
const support = await prettier.getFileInfo(systemPath, options);
|
|
40
|
+
if (support.ignored || !support.inferredParser) {
|
|
41
|
+
return;
|
|
47
42
|
}
|
|
48
|
-
|
|
49
|
-
|
|
43
|
+
tree.write(file.path,
|
|
44
|
+
// In prettier v3 the format result is a promise
|
|
45
|
+
await prettier.format(file.content.toString('utf-8'), options));
|
|
46
|
+
}
|
|
47
|
+
catch (e) {
|
|
48
|
+
console.warn(`Could not format ${file.path}. Error: "${e.message}"`);
|
|
49
|
+
}
|
|
50
|
+
}));
|
|
50
51
|
}
|
|
51
52
|
exports.formatFiles = formatFiles;
|
|
52
53
|
function sortTsConfig(tree) {
|
|
@@ -55,7 +56,13 @@ function sortTsConfig(tree) {
|
|
|
55
56
|
if (!tsConfigPath) {
|
|
56
57
|
return;
|
|
57
58
|
}
|
|
58
|
-
updateJson(tree, tsConfigPath, (tsconfig) => (
|
|
59
|
+
updateJson(tree, tsConfigPath, (tsconfig) => ({
|
|
60
|
+
...tsconfig,
|
|
61
|
+
compilerOptions: {
|
|
62
|
+
...tsconfig.compilerOptions,
|
|
63
|
+
paths: sortObjectByKeys(tsconfig.compilerOptions.paths),
|
|
64
|
+
},
|
|
65
|
+
}));
|
|
59
66
|
}
|
|
60
67
|
catch (e) {
|
|
61
68
|
// catch noop
|
|
@@ -74,7 +81,7 @@ function getChangedPrettierConfigInTree(tree) {
|
|
|
74
81
|
try {
|
|
75
82
|
return readJson(tree, '.prettierrc');
|
|
76
83
|
}
|
|
77
|
-
catch
|
|
84
|
+
catch {
|
|
78
85
|
return null;
|
|
79
86
|
}
|
|
80
87
|
}
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.determineProjectNameAndRootOptions = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
4
|
const enquirer_1 = require("enquirer");
|
|
6
5
|
const nx_1 = require("../../nx");
|
|
7
6
|
const get_workspace_layout_1 = require("../utils/get-workspace-layout");
|
|
8
7
|
const names_1 = require("../utils/names");
|
|
9
8
|
const { joinPathFragments, normalizePath, logger, readJson, readNxJson, updateNxJson, stripIndents, } = (0, nx_1.requireNx)();
|
|
10
|
-
function determineProjectNameAndRootOptions(tree, options) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
9
|
+
async function determineProjectNameAndRootOptions(tree, options) {
|
|
10
|
+
validateName(options.name, options.projectNameAndRootFormat);
|
|
11
|
+
const formats = getProjectNameAndRootFormats(tree, options);
|
|
12
|
+
const format = options.projectNameAndRootFormat ??
|
|
13
|
+
(await determineFormat(tree, formats, options.callingGenerator));
|
|
14
|
+
return {
|
|
15
|
+
...formats[format],
|
|
16
|
+
projectNameAndRootFormat: format,
|
|
17
|
+
};
|
|
18
18
|
}
|
|
19
19
|
exports.determineProjectNameAndRootOptions = determineProjectNameAndRootOptions;
|
|
20
20
|
function validateName(name, projectNameAndRootFormat) {
|
|
@@ -37,70 +37,65 @@ function validateName(name, projectNameAndRootFormat) {
|
|
|
37
37
|
throw new Error(`The project name should match the pattern "${pattern}". The provided value "${name}" does not match.`);
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
|
-
function determineFormat(tree, formats, callingGenerator) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
return 'derived';
|
|
49
|
-
}
|
|
50
|
-
const asProvidedDescription = `As provided:
|
|
40
|
+
async function determineFormat(tree, formats, callingGenerator) {
|
|
41
|
+
if (!formats.derived) {
|
|
42
|
+
return 'as-provided';
|
|
43
|
+
}
|
|
44
|
+
if (process.env.NX_INTERACTIVE !== 'true' || !isTTY()) {
|
|
45
|
+
return 'derived';
|
|
46
|
+
}
|
|
47
|
+
const asProvidedDescription = `As provided:
|
|
51
48
|
Name: ${formats['as-provided'].projectName}
|
|
52
49
|
Root: ${formats['as-provided'].projectRoot}`;
|
|
53
|
-
|
|
54
|
-
|
|
50
|
+
const asProvidedSelectedValue = `${formats['as-provided'].projectName} @ ${formats['as-provided'].projectRoot}`;
|
|
51
|
+
const derivedDescription = `Derived:
|
|
55
52
|
Name: ${formats['derived'].projectName}
|
|
56
53
|
Root: ${formats['derived'].projectRoot}`;
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
54
|
+
const derivedSelectedValue = `${formats['derived'].projectName} @ ${formats['derived'].projectRoot}`;
|
|
55
|
+
const result = await (0, enquirer_1.prompt)({
|
|
56
|
+
type: 'select',
|
|
57
|
+
name: 'format',
|
|
58
|
+
message: 'What should be the project name and where should it be generated?',
|
|
59
|
+
choices: [
|
|
60
|
+
{
|
|
61
|
+
message: asProvidedDescription,
|
|
62
|
+
name: asProvidedSelectedValue,
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
message: derivedDescription,
|
|
66
|
+
name: derivedSelectedValue,
|
|
67
|
+
},
|
|
68
|
+
],
|
|
69
|
+
initial: 'as-provided',
|
|
70
|
+
}).then(({ format }) => format === asProvidedSelectedValue ? 'as-provided' : 'derived');
|
|
71
|
+
const deprecationWarning = stripIndents `
|
|
75
72
|
In Nx 18, generating projects will no longer derive the name and root.
|
|
76
73
|
Please provide the exact project name and root in the future.`;
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
}
|
|
91
|
-
else {
|
|
92
|
-
logger.warn(deprecationWarning);
|
|
93
|
-
}
|
|
74
|
+
if (result === 'as-provided' && callingGenerator) {
|
|
75
|
+
const { saveDefault } = await (0, enquirer_1.prompt)({
|
|
76
|
+
type: 'confirm',
|
|
77
|
+
message: `Would you like to configure Nx to always take project name and root as provided for ${callingGenerator}?`,
|
|
78
|
+
name: 'saveDefault',
|
|
79
|
+
initial: true,
|
|
80
|
+
});
|
|
81
|
+
if (saveDefault) {
|
|
82
|
+
const nxJson = readNxJson(tree);
|
|
83
|
+
nxJson.generators ??= {};
|
|
84
|
+
nxJson.generators[callingGenerator] ??= {};
|
|
85
|
+
nxJson.generators[callingGenerator].projectNameAndRootFormat = result;
|
|
86
|
+
updateNxJson(tree, nxJson);
|
|
94
87
|
}
|
|
95
88
|
else {
|
|
96
|
-
|
|
97
|
-
logger.warn(deprecationWarning + '\n' + example);
|
|
89
|
+
logger.warn(deprecationWarning);
|
|
98
90
|
}
|
|
99
|
-
|
|
100
|
-
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
const example = `Example: nx g ${callingGenerator} ${formats[result].projectName} --directory ${formats[result].projectRoot}`;
|
|
94
|
+
logger.warn(deprecationWarning + '\n' + example);
|
|
95
|
+
}
|
|
96
|
+
return result;
|
|
101
97
|
}
|
|
102
98
|
function getProjectNameAndRootFormats(tree, options) {
|
|
103
|
-
var _a, _b, _c;
|
|
104
99
|
const name = (0, names_1.names)(options.name).fileName;
|
|
105
100
|
const directory = options.directory
|
|
106
101
|
? normalizePath(options.directory.replace(/^\.?\//, ''))
|
|
@@ -120,7 +115,7 @@ function getProjectNameAndRootFormats(tree, options) {
|
|
|
120
115
|
projectSimpleName: nameWithoutScope,
|
|
121
116
|
projectFileName: nameWithoutScope,
|
|
122
117
|
},
|
|
123
|
-
importPath:
|
|
118
|
+
importPath: options.importPath ?? asProvidedProjectName,
|
|
124
119
|
projectRoot: asProvidedProjectDirectory,
|
|
125
120
|
},
|
|
126
121
|
};
|
|
@@ -133,7 +128,8 @@ function getProjectNameAndRootFormats(tree, options) {
|
|
|
133
128
|
npmScope = getNpmScope(tree);
|
|
134
129
|
asProvidedImportPath =
|
|
135
130
|
asProvidedProjectDirectory === '.'
|
|
136
|
-
?
|
|
131
|
+
? readJson(tree, 'package.json').name ??
|
|
132
|
+
getImportPath(npmScope, asProvidedProjectName)
|
|
137
133
|
: getImportPath(npmScope, asProvidedProjectName);
|
|
138
134
|
}
|
|
139
135
|
}
|
|
@@ -159,7 +155,8 @@ function getProjectNameAndRootFormats(tree, options) {
|
|
|
159
155
|
if (!derivedImportPath) {
|
|
160
156
|
derivedImportPath =
|
|
161
157
|
derivedProjectDirectory === '.'
|
|
162
|
-
?
|
|
158
|
+
? readJson(tree, 'package.json').name ??
|
|
159
|
+
getImportPath(npmScope, derivedProjectName)
|
|
163
160
|
: getImportPath(npmScope, derivedProjectDirectoryWithoutLayout);
|
|
164
161
|
}
|
|
165
162
|
}
|
|
@@ -198,13 +195,13 @@ function getImportPath(npmScope, name) {
|
|
|
198
195
|
function getNpmScope(tree) {
|
|
199
196
|
const nxJson = readNxJson(tree);
|
|
200
197
|
// TODO(v17): Remove reading this from nx.json
|
|
201
|
-
if (nxJson
|
|
198
|
+
if (nxJson?.npmScope) {
|
|
202
199
|
return nxJson.npmScope;
|
|
203
200
|
}
|
|
204
201
|
const { name } = tree.exists('package.json')
|
|
205
202
|
? readJson(tree, 'package.json')
|
|
206
203
|
: { name: null };
|
|
207
|
-
return
|
|
204
|
+
return name?.startsWith('@') ? name.split('/')[0].substring(1) : undefined;
|
|
208
205
|
}
|
|
209
206
|
function isTTY() {
|
|
210
207
|
return !!process.stdout.isTTY && process.env['CI'] !== 'true';
|
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.runTasksInSerial = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
4
|
/**
|
|
6
5
|
* Run tasks in serial
|
|
7
6
|
*
|
|
8
7
|
* @param tasks The tasks to run in serial.
|
|
9
8
|
*/
|
|
10
9
|
function runTasksInSerial(...tasks) {
|
|
11
|
-
return () =>
|
|
10
|
+
return async () => {
|
|
12
11
|
for (const task of tasks) {
|
|
13
|
-
|
|
12
|
+
await task();
|
|
14
13
|
}
|
|
15
|
-
}
|
|
14
|
+
};
|
|
16
15
|
}
|
|
17
16
|
exports.runTasksInSerial = runTasksInSerial;
|
|
@@ -15,16 +15,16 @@ function visitNotIgnoredFiles(tree, dirPath = tree.root, visitor) {
|
|
|
15
15
|
ig.add(tree.read('.gitignore', 'utf-8'));
|
|
16
16
|
}
|
|
17
17
|
if (tree.exists('.nxignore')) {
|
|
18
|
-
ig
|
|
18
|
+
ig ??= (0, ignore_1.default)();
|
|
19
19
|
ig.add(tree.read('.nxignore', 'utf-8'));
|
|
20
20
|
}
|
|
21
21
|
dirPath = normalizePathRelativeToRoot(dirPath, tree.root);
|
|
22
|
-
if (dirPath !== '' &&
|
|
22
|
+
if (dirPath !== '' && ig?.ignores(dirPath)) {
|
|
23
23
|
return;
|
|
24
24
|
}
|
|
25
25
|
for (const child of tree.children(dirPath)) {
|
|
26
26
|
const fullPath = (0, path_1.join)(dirPath, child);
|
|
27
|
-
if (ig
|
|
27
|
+
if (ig?.ignores(fullPath)) {
|
|
28
28
|
continue;
|
|
29
29
|
}
|
|
30
30
|
if (tree.isFile(fullPath)) {
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
3
|
const format_files_1 = require("../../generators/format-files");
|
|
5
4
|
const replace_package_1 = require("../../utils/replace-package");
|
|
6
|
-
function replacePackage(tree) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
yield (0, format_files_1.formatFiles)(tree);
|
|
10
|
-
});
|
|
5
|
+
async function replacePackage(tree) {
|
|
6
|
+
await (0, replace_package_1.replaceNrwlPackageWithNxPackage)(tree, '@nrwl/devkit', '@nx/devkit');
|
|
7
|
+
await (0, format_files_1.formatFiles)(tree);
|
|
11
8
|
}
|
|
12
9
|
exports.default = replacePackage;
|
|
@@ -1,69 +1,51 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.combineAsyncIterables = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
if (typeof it['next'] === 'function') {
|
|
11
|
-
return it;
|
|
12
|
-
}
|
|
13
|
-
else {
|
|
14
|
-
return (function wrapped() {
|
|
15
|
-
return tslib_1.__asyncGenerator(this, arguments, function* wrapped_1() {
|
|
16
|
-
var _a, e_1, _b, _c;
|
|
17
|
-
try {
|
|
18
|
-
for (var _d = true, it_1 = tslib_1.__asyncValues(it), it_1_1; it_1_1 = yield tslib_1.__await(it_1.next()), _a = it_1_1.done, !_a; _d = true) {
|
|
19
|
-
_c = it_1_1.value;
|
|
20
|
-
_d = false;
|
|
21
|
-
const val = _c;
|
|
22
|
-
yield yield tslib_1.__await(val);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
26
|
-
finally {
|
|
27
|
-
try {
|
|
28
|
-
if (!_d && !_a && (_b = it_1.return)) yield tslib_1.__await(_b.call(it_1));
|
|
29
|
-
}
|
|
30
|
-
finally { if (e_1) throw e_1.error; }
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
})();
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
let [options] = iterators;
|
|
37
|
-
if (typeof options.next === 'function') {
|
|
38
|
-
options = Object.create(null);
|
|
4
|
+
async function* combineAsyncIterables(..._iterators) {
|
|
5
|
+
// Convert iterables into iterators with next, return, throws methods.
|
|
6
|
+
// If it's already an iterator, keep it.
|
|
7
|
+
const iterators = _iterators.map((it) => {
|
|
8
|
+
if (typeof it['next'] === 'function') {
|
|
9
|
+
return it;
|
|
39
10
|
}
|
|
40
11
|
else {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
try {
|
|
45
|
-
const asyncIteratorsValues = new Map(iterators.map((it, idx) => [idx, getNextAsyncIteratorValue(it, idx)]));
|
|
46
|
-
do {
|
|
47
|
-
const { iterator, index } = yield tslib_1.__await(Promise.race(asyncIteratorsValues.values()));
|
|
48
|
-
if (iterator.done) {
|
|
49
|
-
asyncIteratorsValues.delete(index);
|
|
50
|
-
}
|
|
51
|
-
else {
|
|
52
|
-
yield yield tslib_1.__await(iterator.value);
|
|
53
|
-
asyncIteratorsValues.set(index, getNextAsyncIteratorValue(iterators[index], index));
|
|
12
|
+
return (async function* wrapped() {
|
|
13
|
+
for await (const val of it) {
|
|
14
|
+
yield val;
|
|
54
15
|
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
finally {
|
|
58
|
-
yield tslib_1.__await(Promise.allSettled(iterators.map((it) => { var _a; return (_a = it['return']) === null || _a === void 0 ? void 0 : _a.call(it); })));
|
|
16
|
+
})();
|
|
59
17
|
}
|
|
60
18
|
});
|
|
19
|
+
let [options] = iterators;
|
|
20
|
+
if (typeof options.next === 'function') {
|
|
21
|
+
options = Object.create(null);
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
iterators.shift();
|
|
25
|
+
}
|
|
26
|
+
const getNextAsyncIteratorValue = getNextAsyncIteratorFactory(options);
|
|
27
|
+
try {
|
|
28
|
+
const asyncIteratorsValues = new Map(iterators.map((it, idx) => [idx, getNextAsyncIteratorValue(it, idx)]));
|
|
29
|
+
do {
|
|
30
|
+
const { iterator, index } = await Promise.race(asyncIteratorsValues.values());
|
|
31
|
+
if (iterator.done) {
|
|
32
|
+
asyncIteratorsValues.delete(index);
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
yield iterator.value;
|
|
36
|
+
asyncIteratorsValues.set(index, getNextAsyncIteratorValue(iterators[index], index));
|
|
37
|
+
}
|
|
38
|
+
} while (asyncIteratorsValues.size > 0);
|
|
39
|
+
}
|
|
40
|
+
finally {
|
|
41
|
+
await Promise.allSettled(iterators.map((it) => it['return']?.()));
|
|
42
|
+
}
|
|
61
43
|
}
|
|
62
44
|
exports.combineAsyncIterables = combineAsyncIterables;
|
|
63
45
|
function getNextAsyncIteratorFactory(options) {
|
|
64
|
-
return (asyncIterator, index) =>
|
|
46
|
+
return async (asyncIterator, index) => {
|
|
65
47
|
try {
|
|
66
|
-
const iterator =
|
|
48
|
+
const iterator = await asyncIterator.next();
|
|
67
49
|
return { index, iterator };
|
|
68
50
|
}
|
|
69
51
|
catch (err) {
|
|
@@ -72,5 +54,5 @@ function getNextAsyncIteratorFactory(options) {
|
|
|
72
54
|
}
|
|
73
55
|
return Promise.reject(err);
|
|
74
56
|
}
|
|
75
|
-
}
|
|
57
|
+
};
|
|
76
58
|
}
|
|
@@ -10,29 +10,26 @@ function createAsyncIterable(listener) {
|
|
|
10
10
|
[Symbol.asyncIterator]() {
|
|
11
11
|
listener({
|
|
12
12
|
next: (value) => {
|
|
13
|
-
var _a;
|
|
14
13
|
if (done || error)
|
|
15
14
|
return;
|
|
16
15
|
if (pullQueue.length > 0) {
|
|
17
|
-
|
|
16
|
+
pullQueue.shift()?.[0]({ value, done: false });
|
|
18
17
|
}
|
|
19
18
|
else {
|
|
20
19
|
pushQueue.push(value);
|
|
21
20
|
}
|
|
22
21
|
},
|
|
23
22
|
error: (err) => {
|
|
24
|
-
var _a;
|
|
25
23
|
if (done || error)
|
|
26
24
|
return;
|
|
27
25
|
if (pullQueue.length > 0) {
|
|
28
|
-
|
|
26
|
+
pullQueue.shift()?.[1](err);
|
|
29
27
|
}
|
|
30
28
|
error = err;
|
|
31
29
|
},
|
|
32
30
|
done: () => {
|
|
33
|
-
var _a;
|
|
34
31
|
if (pullQueue.length > 0) {
|
|
35
|
-
|
|
32
|
+
pullQueue.shift()?.[0]({ value: undefined, done: true });
|
|
36
33
|
}
|
|
37
34
|
done = true;
|
|
38
35
|
},
|
|
@@ -1,23 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.mapAsyncIterable = void 0;
|
|
4
|
-
|
|
5
|
-
function
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
yield yield tslib_1.__await(yield tslib_1.__await(transform(yield tslib_1.__await(item.value), index, data)));
|
|
15
|
-
index++;
|
|
16
|
-
item = yield tslib_1.__await(iterator.next());
|
|
17
|
-
}
|
|
18
|
-
});
|
|
4
|
+
async function* mapAsyncIterable(data, transform) {
|
|
5
|
+
async function* f() {
|
|
6
|
+
const generator = data[Symbol.asyncIterator] || data[Symbol.iterator];
|
|
7
|
+
const iterator = generator.call(data);
|
|
8
|
+
let index = 0;
|
|
9
|
+
let item = await iterator.next();
|
|
10
|
+
while (!item.done) {
|
|
11
|
+
yield await transform(await item.value, index, data);
|
|
12
|
+
index++;
|
|
13
|
+
item = await iterator.next();
|
|
19
14
|
}
|
|
20
|
-
|
|
21
|
-
|
|
15
|
+
}
|
|
16
|
+
return yield* f();
|
|
22
17
|
}
|
|
23
18
|
exports.mapAsyncIterable = mapAsyncIterable;
|