@lerna-lite/core 1.2.0 → 1.5.0
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/README.md +3 -3
- package/dist/child-process.d.ts +62 -62
- package/dist/child-process.js +165 -165
- package/dist/command.d.ts +37 -35
- package/dist/command.js +262 -262
- package/dist/command.js.map +1 -1
- package/dist/conventional-commits/constants.d.ts +4 -4
- package/dist/conventional-commits/constants.js +12 -12
- package/dist/conventional-commits/get-changelog-config.d.ts +12 -12
- package/dist/conventional-commits/get-changelog-config.js +98 -98
- package/dist/conventional-commits/index.d.ts +6 -6
- package/dist/conventional-commits/index.js +22 -22
- package/dist/conventional-commits/make-bump-only-filter.d.ts +6 -6
- package/dist/conventional-commits/make-bump-only-filter.js +22 -22
- package/dist/conventional-commits/read-existing-changelog.d.ts +7 -7
- package/dist/conventional-commits/read-existing-changelog.js +32 -32
- package/dist/conventional-commits/recommend-version.d.ts +11 -11
- package/dist/conventional-commits/recommend-version.js +86 -86
- package/dist/conventional-commits/update-changelog.d.ts +11 -11
- package/dist/conventional-commits/update-changelog.js +83 -83
- package/dist/git-clients/GitLabClient.d.ts +8 -8
- package/dist/git-clients/GitLabClient.js +39 -39
- package/dist/git-clients/github-client.d.ts +6 -6
- package/dist/git-clients/github-client.js +40 -40
- package/dist/git-clients/gitlab-client.d.ts +6 -6
- package/dist/git-clients/gitlab-client.js +21 -21
- package/dist/git-clients/index.d.ts +2 -2
- package/dist/git-clients/index.js +18 -18
- package/dist/index.d.ts +12 -12
- package/dist/index.js +30 -30
- package/dist/models/command-options.d.ts +214 -0
- package/dist/models/command-options.js +3 -0
- package/dist/models/command-options.js.map +1 -0
- package/dist/models/index.d.ts +2 -186
- package/dist/models/index.js +18 -2
- package/dist/models/index.js.map +1 -1
- package/dist/models/interfaces.d.ts +202 -0
- package/dist/models/interfaces.js +3 -0
- package/dist/models/interfaces.js.map +1 -0
- package/dist/otplease.d.ts +14 -14
- package/dist/otplease.js +108 -108
- package/dist/package-graph/index.d.ts +2 -2
- package/dist/package-graph/index.js +18 -18
- package/dist/package-graph/lib/cyclic-package-graph-node.d.ts +42 -42
- package/dist/package-graph/lib/cyclic-package-graph-node.js +97 -97
- package/dist/package-graph/lib/index.d.ts +3 -3
- package/dist/package-graph/lib/index.js +19 -19
- package/dist/package-graph/lib/package-graph-node.d.ts +33 -33
- package/dist/package-graph/lib/package-graph-node.js +58 -58
- package/dist/package-graph/lib/report-cycles.d.ts +1 -1
- package/dist/package-graph/lib/report-cycles.js +19 -19
- package/dist/package-graph/package-graph.d.ts +79 -79
- package/dist/package-graph/package-graph.js +276 -276
- package/dist/package.d.ts +91 -84
- package/dist/package.js +291 -256
- package/dist/package.js.map +1 -1
- package/dist/project/index.d.ts +2 -2
- package/dist/project/index.js +18 -18
- package/dist/project/lib/apply-extends.d.ts +10 -10
- package/dist/project/lib/apply-extends.js +37 -37
- package/dist/project/lib/index.d.ts +3 -3
- package/dist/project/lib/index.js +19 -19
- package/dist/project/lib/make-file-finder.d.ts +3 -3
- package/dist/project/lib/make-file-finder.js +71 -71
- package/dist/project/lib/shallow-extend.d.ts +11 -11
- package/dist/project/lib/shallow-extend.js +24 -24
- package/dist/project/project.d.ts +45 -45
- package/dist/project/project.js +195 -195
- package/dist/prompt.d.ts +23 -23
- package/dist/prompt.js +75 -75
- package/dist/utils/check-working-tree.d.ts +9 -8
- package/dist/utils/check-working-tree.js +41 -41
- package/dist/utils/check-working-tree.js.map +1 -1
- package/dist/utils/clean-stack.d.ts +5 -5
- package/dist/utils/clean-stack.js +18 -18
- package/dist/utils/collect-uncommitted.d.ts +17 -18
- package/dist/utils/collect-uncommitted.js +40 -40
- package/dist/utils/collect-uncommitted.js.map +1 -1
- package/dist/utils/collect-updates/collect-updates.d.ts +11 -11
- package/dist/utils/collect-updates/collect-updates.js +82 -82
- package/dist/utils/collect-updates/index.d.ts +2 -2
- package/dist/utils/collect-updates/index.js +18 -18
- package/dist/utils/collect-updates/lib/collect-dependents.d.ts +11 -11
- package/dist/utils/collect-updates/lib/collect-dependents.js +45 -45
- package/dist/utils/collect-updates/lib/collect-packages.d.ts +13 -13
- package/dist/utils/collect-updates/lib/collect-packages.js +33 -33
- package/dist/utils/collect-updates/lib/get-packages-for-option.d.ts +5 -5
- package/dist/utils/collect-updates/lib/get-packages-for-option.js +30 -30
- package/dist/utils/collect-updates/lib/has-tags.d.ts +5 -5
- package/dist/utils/collect-updates/lib/has-tags.js +26 -26
- package/dist/utils/collect-updates/lib/index.d.ts +5 -5
- package/dist/utils/collect-updates/lib/index.js +21 -21
- package/dist/utils/collect-updates/lib/make-diff-predicate.d.ts +7 -7
- package/dist/utils/collect-updates/lib/make-diff-predicate.js +64 -64
- package/dist/utils/conf.d.ts +25 -25
- package/dist/utils/conf.js +255 -255
- package/dist/utils/defaults.d.ts +1 -1
- package/dist/utils/defaults.js +182 -182
- package/dist/utils/defaults.js.map +1 -1
- package/dist/utils/describe-ref.d.ts +13 -37
- package/dist/utils/describe-ref.js +80 -80
- package/dist/utils/describe-ref.js.map +1 -1
- package/dist/utils/env-replace.d.ts +1 -1
- package/dist/utils/env-replace.js +22 -22
- package/dist/utils/find-prefix.d.ts +2 -2
- package/dist/utils/find-prefix.js +48 -48
- package/dist/utils/index.d.ts +21 -22
- package/dist/utils/index.js +38 -38
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/log-package-error.d.ts +5 -5
- package/dist/utils/log-package-error.js +35 -35
- package/dist/utils/nerf-dart.d.ts +1 -1
- package/dist/utils/nerf-dart.js +18 -18
- package/dist/utils/npm-conf.d.ts +4 -4
- package/dist/utils/npm-conf.js +56 -55
- package/dist/utils/npm-conf.js.map +1 -1
- package/dist/utils/output.d.ts +1 -1
- package/dist/utils/output.js +13 -13
- package/dist/utils/parse-field.d.ts +1 -1
- package/dist/utils/parse-field.js +65 -65
- package/dist/utils/prerelease-id-from-version.d.ts +5 -5
- package/dist/utils/prerelease-id-from-version.js +15 -15
- package/dist/utils/pulse-till-done.d.ts +1 -1
- package/dist/utils/pulse-till-done.js +40 -40
- package/dist/utils/query-graph.d.ts +36 -36
- package/dist/utils/query-graph.js +77 -77
- package/dist/utils/query-graph.js.map +1 -1
- package/dist/utils/run-lifecycle.d.ts +10 -10
- package/dist/utils/run-lifecycle.js +131 -107
- package/dist/utils/run-lifecycle.js.map +1 -1
- package/dist/utils/run-topologically.d.ts +12 -12
- package/dist/utils/run-topologically.js +36 -36
- package/dist/utils/temp-write.d.ts +13 -0
- package/dist/utils/temp-write.js +50 -0
- package/dist/utils/temp-write.js.map +1 -0
- package/dist/utils/types.d.ts +131 -129
- package/dist/utils/types.js +138 -138
- package/dist/utils/warn-if-hanging.d.ts +1 -1
- package/dist/utils/warn-if-hanging.js +17 -17
- package/dist/utils/write-log-file.d.ts +1 -1
- package/dist/utils/write-log-file.js +32 -32
- package/dist/validation-error.d.ts +4 -4
- package/dist/validation-error.js +18 -18
- package/package.json +16 -12
package/README.md
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
[](https://opensource.org/licenses/MIT)
|
|
2
|
-
[](http://www.typescriptlang.org/)
|
|
3
|
-
[](https://www.npmjs.com/package/@lerna-lite/core)
|
|
4
2
|
[](https://www.npmjs.com/package/@lerna-lite/core)
|
|
5
|
-
[](https://www.npmjs.com/package/@lerna-lite/core)
|
|
6
4
|
|
|
7
5
|
## Lerna-Lite Core
|
|
6
|
+
|
|
8
7
|
#### @lerna-lite/core
|
|
9
8
|
|
|
10
9
|
The Lerna-Lite core & utils, basically the shared code used by all commands.
|
|
11
10
|
|
|
12
11
|
### Installation
|
|
12
|
+
|
|
13
13
|
Follow the instruction provided in the main [README](https://github.com/ghiscoding/lerna-lite#installation) page.
|
package/dist/child-process.d.ts
CHANGED
|
@@ -1,62 +1,62 @@
|
|
|
1
|
-
import execa from 'execa';
|
|
2
|
-
import { Package } from './package';
|
|
3
|
-
/**
|
|
4
|
-
* Execute a command asynchronously, piping stdio by default.
|
|
5
|
-
* @param {string} command
|
|
6
|
-
* @param {string[]} args
|
|
7
|
-
* @param {import("execa").Options} [opts]
|
|
8
|
-
*/
|
|
9
|
-
export declare function exec(command: string, args: string[], opts?: execa.Options & {
|
|
10
|
-
pkg?: Package;
|
|
11
|
-
}, cmdDryRun?: boolean): Promise<any>;
|
|
12
|
-
/**
|
|
13
|
-
* Execute a command synchronously.
|
|
14
|
-
* @param {string} command
|
|
15
|
-
* @param {string[]} args
|
|
16
|
-
* @param {import("execa").SyncOptions} [opts]
|
|
17
|
-
*/
|
|
18
|
-
export declare function execSync(command: string, args?: string[], opts?: execa.SyncOptions<string>, cmdDryRun?: boolean): string;
|
|
19
|
-
/**
|
|
20
|
-
* Spawn a command asynchronously, _always_ inheriting stdio.
|
|
21
|
-
* @param {string} command
|
|
22
|
-
* @param {string[]} args
|
|
23
|
-
* @param {import("execa").Options} [opts]
|
|
24
|
-
*/
|
|
25
|
-
export declare function spawn(command: string, args: string[], opts?: execa.Options & {
|
|
26
|
-
pkg?: Package;
|
|
27
|
-
}, cmdDryRun?: boolean): Promise<any>;
|
|
28
|
-
/**
|
|
29
|
-
* Spawn a command asynchronously, streaming stdio with optional prefix.
|
|
30
|
-
* @param {string} command
|
|
31
|
-
* @param {string[]} args
|
|
32
|
-
* @param {import("execa").Options} [opts]
|
|
33
|
-
* @param {string} [prefix]
|
|
34
|
-
*/
|
|
35
|
-
export declare function spawnStreaming(command: string, args: string[], opts?: execa.Options & {
|
|
36
|
-
pkg?: Package;
|
|
37
|
-
}, prefix?: string | boolean, cmdDryRun?: boolean): Promise<any>;
|
|
38
|
-
export declare function getChildProcessCount(): number;
|
|
39
|
-
export declare function getExitCode(result: any): any;
|
|
40
|
-
/**
|
|
41
|
-
* @param {string} command
|
|
42
|
-
* @param {string[]} args
|
|
43
|
-
* @param {import("execa").Options} opts
|
|
44
|
-
*/
|
|
45
|
-
export declare function spawnProcess(command: string, args: string[], opts: execa.Options & {
|
|
46
|
-
pkg?: Package;
|
|
47
|
-
}, cmdDryRun?: boolean): any;
|
|
48
|
-
/**
|
|
49
|
-
* Spawn a command asynchronously, _always_ inheriting stdio.
|
|
50
|
-
* @param {string} command
|
|
51
|
-
* @param {string[]} args
|
|
52
|
-
* @param {import("execa").Options} [opts]
|
|
53
|
-
*/
|
|
54
|
-
export declare function wrapError(spawned: execa.ExecaChildProcess & {
|
|
55
|
-
pkg?: Package;
|
|
56
|
-
}): Promise<execa.ExecaReturnValue<string>>;
|
|
57
|
-
/**
|
|
58
|
-
* Log the child-process command and its arguments as dry-run (without executing the process)
|
|
59
|
-
* @param {string} command
|
|
60
|
-
* @param {string[]} args
|
|
61
|
-
*/
|
|
62
|
-
export declare function logExecCommand(command: string, args?: string[]): string;
|
|
1
|
+
import execa from 'execa';
|
|
2
|
+
import { Package } from './package';
|
|
3
|
+
/**
|
|
4
|
+
* Execute a command asynchronously, piping stdio by default.
|
|
5
|
+
* @param {string} command
|
|
6
|
+
* @param {string[]} args
|
|
7
|
+
* @param {import("execa").Options} [opts]
|
|
8
|
+
*/
|
|
9
|
+
export declare function exec(command: string, args: string[], opts?: execa.Options & {
|
|
10
|
+
pkg?: Package;
|
|
11
|
+
}, cmdDryRun?: boolean): Promise<any>;
|
|
12
|
+
/**
|
|
13
|
+
* Execute a command synchronously.
|
|
14
|
+
* @param {string} command
|
|
15
|
+
* @param {string[]} args
|
|
16
|
+
* @param {import("execa").SyncOptions} [opts]
|
|
17
|
+
*/
|
|
18
|
+
export declare function execSync(command: string, args?: string[], opts?: execa.SyncOptions<string>, cmdDryRun?: boolean): string;
|
|
19
|
+
/**
|
|
20
|
+
* Spawn a command asynchronously, _always_ inheriting stdio.
|
|
21
|
+
* @param {string} command
|
|
22
|
+
* @param {string[]} args
|
|
23
|
+
* @param {import("execa").Options} [opts]
|
|
24
|
+
*/
|
|
25
|
+
export declare function spawn(command: string, args: string[], opts?: execa.Options & {
|
|
26
|
+
pkg?: Package;
|
|
27
|
+
}, cmdDryRun?: boolean): Promise<any>;
|
|
28
|
+
/**
|
|
29
|
+
* Spawn a command asynchronously, streaming stdio with optional prefix.
|
|
30
|
+
* @param {string} command
|
|
31
|
+
* @param {string[]} args
|
|
32
|
+
* @param {import("execa").Options} [opts]
|
|
33
|
+
* @param {string} [prefix]
|
|
34
|
+
*/
|
|
35
|
+
export declare function spawnStreaming(command: string, args: string[], opts?: execa.Options & {
|
|
36
|
+
pkg?: Package;
|
|
37
|
+
}, prefix?: string | boolean, cmdDryRun?: boolean): Promise<any>;
|
|
38
|
+
export declare function getChildProcessCount(): number;
|
|
39
|
+
export declare function getExitCode(result: any): any;
|
|
40
|
+
/**
|
|
41
|
+
* @param {string} command
|
|
42
|
+
* @param {string[]} args
|
|
43
|
+
* @param {import("execa").Options} opts
|
|
44
|
+
*/
|
|
45
|
+
export declare function spawnProcess(command: string, args: string[], opts: execa.Options & {
|
|
46
|
+
pkg?: Package;
|
|
47
|
+
}, cmdDryRun?: boolean): any;
|
|
48
|
+
/**
|
|
49
|
+
* Spawn a command asynchronously, _always_ inheriting stdio.
|
|
50
|
+
* @param {string} command
|
|
51
|
+
* @param {string[]} args
|
|
52
|
+
* @param {import("execa").Options} [opts]
|
|
53
|
+
*/
|
|
54
|
+
export declare function wrapError(spawned: execa.ExecaChildProcess & {
|
|
55
|
+
pkg?: Package;
|
|
56
|
+
}): Promise<execa.ExecaReturnValue<string>>;
|
|
57
|
+
/**
|
|
58
|
+
* Log the child-process command and its arguments as dry-run (without executing the process)
|
|
59
|
+
* @param {string} command
|
|
60
|
+
* @param {string[]} args
|
|
61
|
+
*/
|
|
62
|
+
export declare function logExecCommand(command: string, args?: string[]): string;
|
package/dist/child-process.js
CHANGED
|
@@ -1,166 +1,166 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.logExecCommand = exports.wrapError = exports.spawnProcess = exports.getExitCode = exports.getChildProcessCount = exports.spawnStreaming = exports.spawn = exports.execSync = exports.exec = void 0;
|
|
7
|
-
const chalk_1 = __importDefault(require("chalk"));
|
|
8
|
-
const execa_1 = __importDefault(require("execa"));
|
|
9
|
-
const npmlog_1 = __importDefault(require("npmlog"));
|
|
10
|
-
const os_1 = __importDefault(require("os"));
|
|
11
|
-
const strong_log_transformer_1 = __importDefault(require("strong-log-transformer"));
|
|
12
|
-
// bookkeeping for spawned processes
|
|
13
|
-
const children = new Set();
|
|
14
|
-
// when streaming processes are spawned, use this color for prefix
|
|
15
|
-
const colorWheel = ['cyan', 'magenta', 'blue', 'yellow', 'green', 'red'];
|
|
16
|
-
const NUM_COLORS = colorWheel.length;
|
|
17
|
-
// ever-increasing index ensures colors are always sequential
|
|
18
|
-
let currentColor = 0;
|
|
19
|
-
/**
|
|
20
|
-
* Execute a command asynchronously, piping stdio by default.
|
|
21
|
-
* @param {string} command
|
|
22
|
-
* @param {string[]} args
|
|
23
|
-
* @param {import("execa").Options} [opts]
|
|
24
|
-
*/
|
|
25
|
-
function exec(command, args, opts, cmdDryRun = false) {
|
|
26
|
-
const options = Object.assign({ stdio: 'pipe' }, opts);
|
|
27
|
-
const spawned = spawnProcess(command, args, options, cmdDryRun);
|
|
28
|
-
return cmdDryRun ? Promise.resolve() : wrapError(spawned);
|
|
29
|
-
}
|
|
30
|
-
exports.exec = exec;
|
|
31
|
-
/**
|
|
32
|
-
* Execute a command synchronously.
|
|
33
|
-
* @param {string} command
|
|
34
|
-
* @param {string[]} args
|
|
35
|
-
* @param {import("execa").SyncOptions} [opts]
|
|
36
|
-
*/
|
|
37
|
-
function execSync(command, args, opts, cmdDryRun = false) {
|
|
38
|
-
return cmdDryRun
|
|
39
|
-
? logExecCommand(command, args)
|
|
40
|
-
: execa_1.default.sync(command, args, opts).stdout;
|
|
41
|
-
}
|
|
42
|
-
exports.execSync = execSync;
|
|
43
|
-
/**
|
|
44
|
-
* Spawn a command asynchronously, _always_ inheriting stdio.
|
|
45
|
-
* @param {string} command
|
|
46
|
-
* @param {string[]} args
|
|
47
|
-
* @param {import("execa").Options} [opts]
|
|
48
|
-
*/
|
|
49
|
-
function spawn(command, args, opts, cmdDryRun = false) {
|
|
50
|
-
const options = Object.assign({}, opts, { stdio: 'inherit' });
|
|
51
|
-
const spawned = spawnProcess(command, args, options, cmdDryRun);
|
|
52
|
-
return wrapError(spawned);
|
|
53
|
-
}
|
|
54
|
-
exports.spawn = spawn;
|
|
55
|
-
/**
|
|
56
|
-
* Spawn a command asynchronously, streaming stdio with optional prefix.
|
|
57
|
-
* @param {string} command
|
|
58
|
-
* @param {string[]} args
|
|
59
|
-
* @param {import("execa").Options} [opts]
|
|
60
|
-
* @param {string} [prefix]
|
|
61
|
-
*/
|
|
62
|
-
// istanbul ignore next
|
|
63
|
-
function spawnStreaming(command, args, opts, prefix, cmdDryRun = false) {
|
|
64
|
-
const options = Object.assign({}, opts);
|
|
65
|
-
options.stdio = ['ignore', 'pipe', 'pipe'];
|
|
66
|
-
const spawned = spawnProcess(command, args, options, cmdDryRun);
|
|
67
|
-
const stdoutOpts = {};
|
|
68
|
-
const stderrOpts = {}; // mergeMultiline causes escaped newlines :P
|
|
69
|
-
if (prefix) {
|
|
70
|
-
const colorName = colorWheel[currentColor % NUM_COLORS];
|
|
71
|
-
const color = chalk_1.default[colorName];
|
|
72
|
-
currentColor += 1;
|
|
73
|
-
stdoutOpts.tag = `${color.bold(prefix)}:`;
|
|
74
|
-
stderrOpts.tag = `${color(prefix)}:`;
|
|
75
|
-
}
|
|
76
|
-
// Avoid 'Possible EventEmitter memory leak detected' warning due to piped stdio
|
|
77
|
-
if (children.size > process.stdout.listenerCount('close')) {
|
|
78
|
-
process.stdout.setMaxListeners(children.size);
|
|
79
|
-
process.stderr.setMaxListeners(children.size);
|
|
80
|
-
}
|
|
81
|
-
spawned.stdout.pipe((0, strong_log_transformer_1.default)(stdoutOpts)).pipe(process.stdout);
|
|
82
|
-
spawned.stderr.pipe((0, strong_log_transformer_1.default)(stderrOpts)).pipe(process.stderr);
|
|
83
|
-
return wrapError(spawned);
|
|
84
|
-
}
|
|
85
|
-
exports.spawnStreaming = spawnStreaming;
|
|
86
|
-
function getChildProcessCount() {
|
|
87
|
-
return children.size;
|
|
88
|
-
}
|
|
89
|
-
exports.getChildProcessCount = getChildProcessCount;
|
|
90
|
-
function getExitCode(result) {
|
|
91
|
-
var _a, _b, _c;
|
|
92
|
-
// https://nodejs.org/docs/latest-v6.x/api/child_process.html#child_process_event_close
|
|
93
|
-
if (typeof result.code === 'number' || typeof result.exitCode === 'number') {
|
|
94
|
-
return (_a = result.code) !== null && _a !== void 0 ? _a : result.exitCode;
|
|
95
|
-
}
|
|
96
|
-
// https://nodejs.org/docs/latest-v6.x/api/errors.html#errors_error_code
|
|
97
|
-
// istanbul ignore else
|
|
98
|
-
if (typeof result.code === 'string' || typeof result.exitCode === 'string') {
|
|
99
|
-
return os_1.default.constants.errno[(_b = result.code) !== null && _b !== void 0 ? _b : result.exitCode];
|
|
100
|
-
}
|
|
101
|
-
// istanbul ignore next: extremely weird
|
|
102
|
-
throw new TypeError(`Received unexpected exit code value ${JSON.stringify((_c = result.code) !== null && _c !== void 0 ? _c : result.exitCode)}`);
|
|
103
|
-
}
|
|
104
|
-
exports.getExitCode = getExitCode;
|
|
105
|
-
/**
|
|
106
|
-
* @param {string} command
|
|
107
|
-
* @param {string[]} args
|
|
108
|
-
* @param {import("execa").Options} opts
|
|
109
|
-
*/
|
|
110
|
-
function spawnProcess(command, args, opts, cmdDryRun = false) {
|
|
111
|
-
if (cmdDryRun) {
|
|
112
|
-
return logExecCommand(command, args);
|
|
113
|
-
}
|
|
114
|
-
const child = (0, execa_1.default)(command, args, opts);
|
|
115
|
-
const drain = (_code, signal) => {
|
|
116
|
-
children.delete(child);
|
|
117
|
-
// don't run repeatedly if this is the error event
|
|
118
|
-
if (signal === undefined) {
|
|
119
|
-
child.removeListener('exit', drain);
|
|
120
|
-
}
|
|
121
|
-
};
|
|
122
|
-
child.once('exit', drain);
|
|
123
|
-
child.once('error', drain);
|
|
124
|
-
if (opts.pkg) {
|
|
125
|
-
child.pkg = opts.pkg;
|
|
126
|
-
}
|
|
127
|
-
children.add(child);
|
|
128
|
-
return child;
|
|
129
|
-
}
|
|
130
|
-
exports.spawnProcess = spawnProcess;
|
|
131
|
-
/**
|
|
132
|
-
* Spawn a command asynchronously, _always_ inheriting stdio.
|
|
133
|
-
* @param {string} command
|
|
134
|
-
* @param {string[]} args
|
|
135
|
-
* @param {import("execa").Options} [opts]
|
|
136
|
-
*/
|
|
137
|
-
function wrapError(spawned) {
|
|
138
|
-
if (spawned.pkg) {
|
|
139
|
-
return spawned.catch((err) => {
|
|
140
|
-
// ensure exit code is always a number
|
|
141
|
-
err.exitCode = getExitCode(err);
|
|
142
|
-
// log non-lerna error cleanly
|
|
143
|
-
err.pkg = spawned.pkg;
|
|
144
|
-
throw err;
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
return spawned;
|
|
148
|
-
}
|
|
149
|
-
exports.wrapError = wrapError;
|
|
150
|
-
/**
|
|
151
|
-
* Log the child-process command and its arguments as dry-run (without executing the process)
|
|
152
|
-
* @param {string} command
|
|
153
|
-
* @param {string[]} args
|
|
154
|
-
*/
|
|
155
|
-
function logExecCommand(command, args) {
|
|
156
|
-
var _a;
|
|
157
|
-
const argStr = (_a = (Array.isArray(args) ? args.join(' ') : args)) !== null && _a !== void 0 ? _a : '';
|
|
158
|
-
const cmdList = [];
|
|
159
|
-
for (const c of [command, argStr]) {
|
|
160
|
-
cmdList.push((Array.isArray(c) ? c.join(' ') : c));
|
|
161
|
-
}
|
|
162
|
-
npmlog_1.default.info('dry-run>', cmdList.join(' '));
|
|
163
|
-
return '';
|
|
164
|
-
}
|
|
165
|
-
exports.logExecCommand = logExecCommand;
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.logExecCommand = exports.wrapError = exports.spawnProcess = exports.getExitCode = exports.getChildProcessCount = exports.spawnStreaming = exports.spawn = exports.execSync = exports.exec = void 0;
|
|
7
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
8
|
+
const execa_1 = __importDefault(require("execa"));
|
|
9
|
+
const npmlog_1 = __importDefault(require("npmlog"));
|
|
10
|
+
const os_1 = __importDefault(require("os"));
|
|
11
|
+
const strong_log_transformer_1 = __importDefault(require("strong-log-transformer"));
|
|
12
|
+
// bookkeeping for spawned processes
|
|
13
|
+
const children = new Set();
|
|
14
|
+
// when streaming processes are spawned, use this color for prefix
|
|
15
|
+
const colorWheel = ['cyan', 'magenta', 'blue', 'yellow', 'green', 'red'];
|
|
16
|
+
const NUM_COLORS = colorWheel.length;
|
|
17
|
+
// ever-increasing index ensures colors are always sequential
|
|
18
|
+
let currentColor = 0;
|
|
19
|
+
/**
|
|
20
|
+
* Execute a command asynchronously, piping stdio by default.
|
|
21
|
+
* @param {string} command
|
|
22
|
+
* @param {string[]} args
|
|
23
|
+
* @param {import("execa").Options} [opts]
|
|
24
|
+
*/
|
|
25
|
+
function exec(command, args, opts, cmdDryRun = false) {
|
|
26
|
+
const options = Object.assign({ stdio: 'pipe' }, opts);
|
|
27
|
+
const spawned = spawnProcess(command, args, options, cmdDryRun);
|
|
28
|
+
return cmdDryRun ? Promise.resolve() : wrapError(spawned);
|
|
29
|
+
}
|
|
30
|
+
exports.exec = exec;
|
|
31
|
+
/**
|
|
32
|
+
* Execute a command synchronously.
|
|
33
|
+
* @param {string} command
|
|
34
|
+
* @param {string[]} args
|
|
35
|
+
* @param {import("execa").SyncOptions} [opts]
|
|
36
|
+
*/
|
|
37
|
+
function execSync(command, args, opts, cmdDryRun = false) {
|
|
38
|
+
return cmdDryRun
|
|
39
|
+
? logExecCommand(command, args)
|
|
40
|
+
: execa_1.default.sync(command, args, opts).stdout;
|
|
41
|
+
}
|
|
42
|
+
exports.execSync = execSync;
|
|
43
|
+
/**
|
|
44
|
+
* Spawn a command asynchronously, _always_ inheriting stdio.
|
|
45
|
+
* @param {string} command
|
|
46
|
+
* @param {string[]} args
|
|
47
|
+
* @param {import("execa").Options} [opts]
|
|
48
|
+
*/
|
|
49
|
+
function spawn(command, args, opts, cmdDryRun = false) {
|
|
50
|
+
const options = Object.assign({}, opts, { stdio: 'inherit' });
|
|
51
|
+
const spawned = spawnProcess(command, args, options, cmdDryRun);
|
|
52
|
+
return wrapError(spawned);
|
|
53
|
+
}
|
|
54
|
+
exports.spawn = spawn;
|
|
55
|
+
/**
|
|
56
|
+
* Spawn a command asynchronously, streaming stdio with optional prefix.
|
|
57
|
+
* @param {string} command
|
|
58
|
+
* @param {string[]} args
|
|
59
|
+
* @param {import("execa").Options} [opts]
|
|
60
|
+
* @param {string} [prefix]
|
|
61
|
+
*/
|
|
62
|
+
// istanbul ignore next
|
|
63
|
+
function spawnStreaming(command, args, opts, prefix, cmdDryRun = false) {
|
|
64
|
+
const options = Object.assign({}, opts);
|
|
65
|
+
options.stdio = ['ignore', 'pipe', 'pipe'];
|
|
66
|
+
const spawned = spawnProcess(command, args, options, cmdDryRun);
|
|
67
|
+
const stdoutOpts = {};
|
|
68
|
+
const stderrOpts = {}; // mergeMultiline causes escaped newlines :P
|
|
69
|
+
if (prefix) {
|
|
70
|
+
const colorName = colorWheel[currentColor % NUM_COLORS];
|
|
71
|
+
const color = chalk_1.default[colorName];
|
|
72
|
+
currentColor += 1;
|
|
73
|
+
stdoutOpts.tag = `${color.bold(prefix)}:`;
|
|
74
|
+
stderrOpts.tag = `${color(prefix)}:`;
|
|
75
|
+
}
|
|
76
|
+
// Avoid 'Possible EventEmitter memory leak detected' warning due to piped stdio
|
|
77
|
+
if (children.size > process.stdout.listenerCount('close')) {
|
|
78
|
+
process.stdout.setMaxListeners(children.size);
|
|
79
|
+
process.stderr.setMaxListeners(children.size);
|
|
80
|
+
}
|
|
81
|
+
spawned.stdout.pipe((0, strong_log_transformer_1.default)(stdoutOpts)).pipe(process.stdout);
|
|
82
|
+
spawned.stderr.pipe((0, strong_log_transformer_1.default)(stderrOpts)).pipe(process.stderr);
|
|
83
|
+
return wrapError(spawned);
|
|
84
|
+
}
|
|
85
|
+
exports.spawnStreaming = spawnStreaming;
|
|
86
|
+
function getChildProcessCount() {
|
|
87
|
+
return children.size;
|
|
88
|
+
}
|
|
89
|
+
exports.getChildProcessCount = getChildProcessCount;
|
|
90
|
+
function getExitCode(result) {
|
|
91
|
+
var _a, _b, _c;
|
|
92
|
+
// https://nodejs.org/docs/latest-v6.x/api/child_process.html#child_process_event_close
|
|
93
|
+
if (typeof result.code === 'number' || typeof result.exitCode === 'number') {
|
|
94
|
+
return (_a = result.code) !== null && _a !== void 0 ? _a : result.exitCode;
|
|
95
|
+
}
|
|
96
|
+
// https://nodejs.org/docs/latest-v6.x/api/errors.html#errors_error_code
|
|
97
|
+
// istanbul ignore else
|
|
98
|
+
if (typeof result.code === 'string' || typeof result.exitCode === 'string') {
|
|
99
|
+
return os_1.default.constants.errno[(_b = result.code) !== null && _b !== void 0 ? _b : result.exitCode];
|
|
100
|
+
}
|
|
101
|
+
// istanbul ignore next: extremely weird
|
|
102
|
+
throw new TypeError(`Received unexpected exit code value ${JSON.stringify((_c = result.code) !== null && _c !== void 0 ? _c : result.exitCode)}`);
|
|
103
|
+
}
|
|
104
|
+
exports.getExitCode = getExitCode;
|
|
105
|
+
/**
|
|
106
|
+
* @param {string} command
|
|
107
|
+
* @param {string[]} args
|
|
108
|
+
* @param {import("execa").Options} opts
|
|
109
|
+
*/
|
|
110
|
+
function spawnProcess(command, args, opts, cmdDryRun = false) {
|
|
111
|
+
if (cmdDryRun) {
|
|
112
|
+
return logExecCommand(command, args);
|
|
113
|
+
}
|
|
114
|
+
const child = (0, execa_1.default)(command, args, opts);
|
|
115
|
+
const drain = (_code, signal) => {
|
|
116
|
+
children.delete(child);
|
|
117
|
+
// don't run repeatedly if this is the error event
|
|
118
|
+
if (signal === undefined) {
|
|
119
|
+
child.removeListener('exit', drain);
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
child.once('exit', drain);
|
|
123
|
+
child.once('error', drain);
|
|
124
|
+
if (opts.pkg) {
|
|
125
|
+
child.pkg = opts.pkg;
|
|
126
|
+
}
|
|
127
|
+
children.add(child);
|
|
128
|
+
return child;
|
|
129
|
+
}
|
|
130
|
+
exports.spawnProcess = spawnProcess;
|
|
131
|
+
/**
|
|
132
|
+
* Spawn a command asynchronously, _always_ inheriting stdio.
|
|
133
|
+
* @param {string} command
|
|
134
|
+
* @param {string[]} args
|
|
135
|
+
* @param {import("execa").Options} [opts]
|
|
136
|
+
*/
|
|
137
|
+
function wrapError(spawned) {
|
|
138
|
+
if (spawned.pkg) {
|
|
139
|
+
return spawned.catch((err) => {
|
|
140
|
+
// ensure exit code is always a number
|
|
141
|
+
err.exitCode = getExitCode(err);
|
|
142
|
+
// log non-lerna error cleanly
|
|
143
|
+
err.pkg = spawned.pkg;
|
|
144
|
+
throw err;
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
return spawned;
|
|
148
|
+
}
|
|
149
|
+
exports.wrapError = wrapError;
|
|
150
|
+
/**
|
|
151
|
+
* Log the child-process command and its arguments as dry-run (without executing the process)
|
|
152
|
+
* @param {string} command
|
|
153
|
+
* @param {string[]} args
|
|
154
|
+
*/
|
|
155
|
+
function logExecCommand(command, args) {
|
|
156
|
+
var _a;
|
|
157
|
+
const argStr = (_a = (Array.isArray(args) ? args.join(' ') : args)) !== null && _a !== void 0 ? _a : '';
|
|
158
|
+
const cmdList = [];
|
|
159
|
+
for (const c of [command, argStr]) {
|
|
160
|
+
cmdList.push((Array.isArray(c) ? c.join(' ') : c));
|
|
161
|
+
}
|
|
162
|
+
npmlog_1.default.info('dry-run>', cmdList.join(' '));
|
|
163
|
+
return '';
|
|
164
|
+
}
|
|
165
|
+
exports.logExecCommand = logExecCommand;
|
|
166
166
|
//# sourceMappingURL=child-process.js.map
|
package/dist/command.d.ts
CHANGED
|
@@ -1,35 +1,37 @@
|
|
|
1
|
-
import { Logger } from 'npmlog';
|
|
2
|
-
import { Project } from './project/project';
|
|
3
|
-
import { CommandType, ExecOpts } from './models';
|
|
4
|
-
import { PackageGraph } from './package-graph/package-graph';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
get
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
1
|
+
import { Logger } from 'npmlog';
|
|
2
|
+
import { Project } from './project/project';
|
|
3
|
+
import { CommandType, ExecCommandOption, ExecOpts, InitCommandOption, ListCommandOption, ProjectConfig, PublishCommandOption, VersionCommandOption } from './models';
|
|
4
|
+
import { PackageGraph } from './package-graph/package-graph';
|
|
5
|
+
declare type AvailableCommandOption = ExecCommandOption | InitCommandOption | ListCommandOption | PublishCommandOption | VersionCommandOption;
|
|
6
|
+
export declare class Command<T extends AvailableCommandOption> {
|
|
7
|
+
argv: any;
|
|
8
|
+
concurrency: number;
|
|
9
|
+
envDefaults: any;
|
|
10
|
+
sort: any;
|
|
11
|
+
toposort?: number;
|
|
12
|
+
execOpts: ExecOpts;
|
|
13
|
+
commandName: CommandType;
|
|
14
|
+
composed: any;
|
|
15
|
+
logger: Logger;
|
|
16
|
+
options: T & ExecOpts & ProjectConfig;
|
|
17
|
+
project: Project;
|
|
18
|
+
packageGraph: PackageGraph;
|
|
19
|
+
runner?: Promise<any>;
|
|
20
|
+
constructor(_argv: AvailableCommandOption);
|
|
21
|
+
then(onResolved: typeof Promise.resolve, onRejected: typeof Promise.reject): Promise<unknown> | undefined;
|
|
22
|
+
catch(onRejected: typeof Promise.reject): Promise<any> | undefined;
|
|
23
|
+
get requiresGit(): boolean;
|
|
24
|
+
get otherCommandConfigs(): string[];
|
|
25
|
+
configureEnvironment(): void;
|
|
26
|
+
configureOptions(): void;
|
|
27
|
+
configureProperties(): void;
|
|
28
|
+
configureLogging(): void;
|
|
29
|
+
enableProgressBar(): void;
|
|
30
|
+
gitInitialized(): boolean;
|
|
31
|
+
runValidations(): void;
|
|
32
|
+
runPreparations(): Promise<any> | void;
|
|
33
|
+
runCommand(): Promise<any>;
|
|
34
|
+
initialize(): any | Promise<any>;
|
|
35
|
+
execute(): any | Promise<any>;
|
|
36
|
+
}
|
|
37
|
+
export {};
|