rman 0.29.1 → 0.31.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/cjs/cli.js +3 -3
- package/cjs/commands/ci-command.js +3 -3
- package/cjs/commands/execute-command.js +3 -3
- package/cjs/commands/info-command.js +7 -7
- package/cjs/commands/list-command.js +5 -5
- package/cjs/commands/publish-command.js +7 -7
- package/cjs/commands/run-command.js +4 -4
- package/cjs/commands/version-command.js +6 -6
- package/cjs/core/command.js +3 -3
- package/cjs/utils/npm-run-path.js +14 -5
- package/esm/cli.js +3 -3
- package/esm/commands/ci-command.js +3 -3
- package/esm/commands/execute-command.js +3 -3
- package/esm/commands/info-command.js +7 -7
- package/esm/commands/list-command.js +5 -5
- package/esm/commands/publish-command.js +7 -7
- package/esm/commands/run-command.js +4 -4
- package/esm/commands/version-command.js +6 -6
- package/esm/core/command.js +3 -3
- package/esm/utils/npm-run-path.js +12 -3
- package/package.json +34 -35
- package/types/cli.d.ts +4 -0
- package/types/commands/build-command.d.ts +11 -0
- package/types/commands/changed-command.d.ts +16 -0
- package/types/commands/ci-command.d.ts +24 -0
- package/types/commands/execute-command.d.ts +19 -0
- package/types/commands/info-command.d.ts +10 -0
- package/types/commands/list-command.d.ts +38 -0
- package/types/commands/multi-task-command.d.ts +22 -0
- package/types/commands/publish-command.d.ts +22 -0
- package/types/commands/run-command.d.ts +28 -0
- package/types/commands/version-command.d.ts +25 -0
- package/types/core/command.d.ts +35 -0
- package/types/core/constants.d.ts +1 -0
- package/types/core/logger.d.ts +12 -0
- package/types/core/package.d.ts +13 -0
- package/types/core/repository.d.ts +19 -0
- package/types/index.d.ts +1 -0
- package/types/utils/exec.d.ts +18 -0
- package/types/utils/file-utils.d.ts +4 -0
- package/types/utils/get-dirname.d.ts +2 -0
- package/types/utils/git-utils.d.ts +25 -0
- package/types/utils/npm-run-path.d.ts +67 -0
- package/types/utils/npm-utils.d.ts +11 -0
- package/cjs/package.json +0 -3
package/cjs/cli.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.runCli = runCli;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const
|
|
5
|
+
const ansi_colors_1 = tslib_1.__importDefault(require("ansi-colors"));
|
|
6
6
|
const promises_1 = tslib_1.__importDefault(require("fs/promises"));
|
|
7
7
|
const npmlog_1 = tslib_1.__importDefault(require("npmlog"));
|
|
8
8
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
@@ -38,12 +38,12 @@ async function runCli(options) {
|
|
|
38
38
|
.fail((msg, err) => {
|
|
39
39
|
if (!err?.logged) {
|
|
40
40
|
const text = msg
|
|
41
|
-
? msg + '\n\n' +
|
|
41
|
+
? msg + '\n\n' + ansi_colors_1.default.whiteBright('Run with --help for available options')
|
|
42
42
|
: err
|
|
43
43
|
? err.message
|
|
44
44
|
: '';
|
|
45
45
|
// eslint-disable-next-line no-console
|
|
46
|
-
console.log('\n' +
|
|
46
|
+
console.log('\n' + ansi_colors_1.default.red(text));
|
|
47
47
|
throw msg;
|
|
48
48
|
}
|
|
49
49
|
else
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CleanInstallCommand = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const
|
|
5
|
+
const ansi_colors_1 = tslib_1.__importDefault(require("ansi-colors"));
|
|
6
6
|
const npmlog_1 = tslib_1.__importDefault(require("npmlog"));
|
|
7
7
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
8
8
|
const power_tasks_1 = require("power-tasks");
|
|
@@ -24,7 +24,7 @@ class CleanInstallCommand extends run_command_js_1.RunCommand {
|
|
|
24
24
|
await this._fsDelete(path_1.default.join(dirname, 'node_modules'));
|
|
25
25
|
await this._fsDelete(path_1.default.join(dirname, 'package-lock.json'));
|
|
26
26
|
await this._fsDelete(path_1.default.join(dirname, 'yarn-lock.json'));
|
|
27
|
-
npmlog_1.default.info(this.commandName,
|
|
27
|
+
npmlog_1.default.info(this.commandName, ansi_colors_1.default.yellow('install'), 'Running ' + client + ' install');
|
|
28
28
|
return super._exec(this.repository.rootPackage, client + ' install', {
|
|
29
29
|
stdio: 'inherit',
|
|
30
30
|
});
|
|
@@ -46,7 +46,7 @@ class CleanInstallCommand extends run_command_js_1.RunCommand {
|
|
|
46
46
|
}
|
|
47
47
|
async _fsDelete(fileOrDir) {
|
|
48
48
|
if (await (0, file_utils_js_1.fsExists)(fileOrDir)) {
|
|
49
|
-
npmlog_1.default.info(this.commandName,
|
|
49
|
+
npmlog_1.default.info(this.commandName, ansi_colors_1.default.yellow('rmdir'), path_1.default.relative(this.repository.dirname, fileOrDir));
|
|
50
50
|
await (0, file_utils_js_1.fsDelete)(fileOrDir);
|
|
51
51
|
}
|
|
52
52
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ExecuteCommand = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const
|
|
5
|
+
const ansi_colors_1 = tslib_1.__importDefault(require("ansi-colors"));
|
|
6
6
|
const npmlog_1 = tslib_1.__importDefault(require("npmlog"));
|
|
7
7
|
const power_tasks_1 = require("power-tasks");
|
|
8
8
|
const command_js_1 = require("../core/command.js");
|
|
@@ -20,13 +20,13 @@ class ExecuteCommand extends multi_task_command_js_1.MultiTaskCommand {
|
|
|
20
20
|
for (const p of packages) {
|
|
21
21
|
const task = new power_tasks_1.Task(async () => {
|
|
22
22
|
const t = Date.now();
|
|
23
|
-
npmlog_1.default.verbose(this.commandName, p.name,
|
|
23
|
+
npmlog_1.default.verbose(this.commandName, p.name, ansi_colors_1.default.cyanBright.bold('executing'), npmlog_1.default.separator, this.cmd + ' ' + (this.argv?.join(' ') || ''));
|
|
24
24
|
const r = await (0, exec_js_1.exec)(this.cmd, {
|
|
25
25
|
cwd: p.dirname,
|
|
26
26
|
argv: this.argv,
|
|
27
27
|
stdio: npmlog_1.default.levelIndex < 1000 ? 'inherit' : 'pipe',
|
|
28
28
|
});
|
|
29
|
-
npmlog_1.default.log(r.error ? 'error' : 'info', this.commandName, p.name, r.error ?
|
|
29
|
+
npmlog_1.default.log(r.error ? 'error' : 'info', this.commandName, p.name, r.error ? ansi_colors_1.default.red.bold('failed') : ansi_colors_1.default.green.bold('success'), npmlog_1.default.separator, this.cmd, ansi_colors_1.default.yellow(' (' + (Date.now() - t) + ' ms') + ')');
|
|
30
30
|
}, {
|
|
31
31
|
name: p.name,
|
|
32
32
|
dependencies: this.options.parallel ? undefined : p.dependencies,
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.InfoCommand = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const
|
|
5
|
+
const ansi_colors_1 = tslib_1.__importDefault(require("ansi-colors"));
|
|
6
6
|
const envinfo_1 = tslib_1.__importDefault(require("envinfo"));
|
|
7
7
|
const semver_1 = tslib_1.__importDefault(require("semver"));
|
|
8
8
|
const command_js_1 = require("../core/command.js");
|
|
@@ -21,22 +21,22 @@ class InfoCommand extends command_js_1.Command {
|
|
|
21
21
|
}
|
|
22
22
|
const maxName = Object.keys(systemInfo).reduce((l, p) => Object.keys(systemInfo[p]).reduce((i, x) => (l = Math.max(i, x.length)), l), 0);
|
|
23
23
|
for (const [categoryName, category] of Object.entries(systemInfo)) {
|
|
24
|
-
this.logger.output('', '',
|
|
24
|
+
this.logger.output('', '', ansi_colors_1.default.whiteBright(categoryName) + ':');
|
|
25
25
|
for (const [n, v] of Object.entries(category)) {
|
|
26
|
-
const label = ' ' +
|
|
26
|
+
const label = ' ' + ansi_colors_1.default.reset(n) + ' '.repeat(maxName - n.length) + ' :';
|
|
27
27
|
if (typeof v === 'string') {
|
|
28
|
-
this.logger.output('', label,
|
|
28
|
+
this.logger.output('', label, ansi_colors_1.default.yellowBright(v));
|
|
29
29
|
continue;
|
|
30
30
|
}
|
|
31
31
|
if (v.version) {
|
|
32
|
-
this.logger.output('', label,
|
|
32
|
+
this.logger.output('', label, ansi_colors_1.default.yellowBright(v.version), v.path ? ' ' + ansi_colors_1.default.yellow(v.path) : '');
|
|
33
33
|
}
|
|
34
34
|
if (v.installed) {
|
|
35
35
|
if (v.wanted === 'latest' || semver_1.default.intersects(v.installed, v.wanted)) {
|
|
36
|
-
this.logger.output('', label,
|
|
36
|
+
this.logger.output('', label, ansi_colors_1.default.yellowBright(v.installed));
|
|
37
37
|
}
|
|
38
38
|
else
|
|
39
|
-
this.logger.output('', label,
|
|
39
|
+
this.logger.output('', label, ansi_colors_1.default.red(v.installed), ' => ', ansi_colors_1.default.yellowBright(v.wanted));
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ListCommand = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const
|
|
5
|
+
const ansi_colors_1 = tslib_1.__importDefault(require("ansi-colors"));
|
|
6
6
|
const easy_table_1 = tslib_1.__importDefault(require("easy-table"));
|
|
7
7
|
const npmlog_1 = tslib_1.__importDefault(require("npmlog"));
|
|
8
8
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
@@ -69,10 +69,10 @@ class ListCommand extends command_js_1.Command {
|
|
|
69
69
|
if (this.onPrintTable)
|
|
70
70
|
this.onPrintTable(p, o, table);
|
|
71
71
|
else {
|
|
72
|
-
table.cell('Package',
|
|
73
|
-
table.cell('Version',
|
|
74
|
-
table.cell('Private', p.isPrivate ?
|
|
75
|
-
table.cell('Changed', isDirty ?
|
|
72
|
+
table.cell('Package', ansi_colors_1.default.yellowBright(p.name));
|
|
73
|
+
table.cell('Version', ansi_colors_1.default.yellow(p.version));
|
|
74
|
+
table.cell('Private', p.isPrivate ? ansi_colors_1.default.magentaBright('yes') : '');
|
|
75
|
+
table.cell('Changed', isDirty ? ansi_colors_1.default.magenta('dirty') : isCommitted ? ansi_colors_1.default.yellow('committed') : '');
|
|
76
76
|
table.cell('Path', path_1.default.relative(repository.dirname, p.dirname));
|
|
77
77
|
table.newRow();
|
|
78
78
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PublishCommand = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const
|
|
5
|
+
const ansi_colors_1 = tslib_1.__importDefault(require("ansi-colors"));
|
|
6
6
|
const npmlog_1 = tslib_1.__importDefault(require("npmlog"));
|
|
7
7
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
8
8
|
const command_js_1 = require("../core/command.js");
|
|
@@ -22,7 +22,7 @@ class PublishCommand extends run_command_js_1.RunCommand {
|
|
|
22
22
|
const selectedPackages = [];
|
|
23
23
|
const promises = [];
|
|
24
24
|
for (const p of packages) {
|
|
25
|
-
const logPkgName =
|
|
25
|
+
const logPkgName = ansi_colors_1.default.yellow(p.name);
|
|
26
26
|
if (p.json.private) {
|
|
27
27
|
npmlog_1.default.info(this.commandName, logPkgName, npmlog_1.default.separator, `Ignored. Package is set to "private"`);
|
|
28
28
|
continue;
|
|
@@ -35,19 +35,19 @@ class PublishCommand extends run_command_js_1.RunCommand {
|
|
|
35
35
|
const sameVersion = !!(r && r.version === p.version);
|
|
36
36
|
if (this.options.checkOnly) {
|
|
37
37
|
npmlog_1.default.info(this.commandName, logPkgName, npmlog_1.default.separator, !r.version
|
|
38
|
-
?
|
|
38
|
+
? ansi_colors_1.default.yellow('No package information found in repository')
|
|
39
39
|
: sameVersion
|
|
40
|
-
? `No publish needed. Version (${
|
|
40
|
+
? `No publish needed. Version (${ansi_colors_1.default.magenta(p.version)}) same in repository`
|
|
41
41
|
: `Publishing is possible.` +
|
|
42
|
-
` Version "${
|
|
42
|
+
` Version "${ansi_colors_1.default.magenta(p.version)}" differs from version in repository (${ansi_colors_1.default.magenta(r.version)})`);
|
|
43
43
|
return;
|
|
44
44
|
}
|
|
45
45
|
if (r && r.version === p.version) {
|
|
46
|
-
npmlog_1.default.info(this.commandName, logPkgName, npmlog_1.default.separator, `No publish needed. Version (${
|
|
46
|
+
npmlog_1.default.info(this.commandName, logPkgName, npmlog_1.default.separator, `No publish needed. Version (${ansi_colors_1.default.magenta(p.version)}) same in repository`);
|
|
47
47
|
}
|
|
48
48
|
else {
|
|
49
49
|
npmlog_1.default.verbose(this.commandName, logPkgName, npmlog_1.default.separator, `Publishing is possible.` +
|
|
50
|
-
` Version "${
|
|
50
|
+
` Version "${ansi_colors_1.default.magenta(p.version)}" differs from version in repository (${ansi_colors_1.default.magenta(r.version)})`);
|
|
51
51
|
selectedPackages.push(p);
|
|
52
52
|
}
|
|
53
53
|
})
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.RunCommand = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const parse_npm_script_1 = tslib_1.__importDefault(require("@netlify/parse-npm-script"));
|
|
6
|
-
const
|
|
6
|
+
const ansi_colors_1 = tslib_1.__importDefault(require("ansi-colors"));
|
|
7
7
|
const npmlog_1 = tslib_1.__importDefault(require("npmlog"));
|
|
8
8
|
const power_tasks_1 = require("power-tasks");
|
|
9
9
|
const command_js_1 = require("../core/command.js");
|
|
@@ -75,17 +75,17 @@ class RunCommand extends multi_task_command_js_1.MultiTaskCommand {
|
|
|
75
75
|
const name = pkg === this.repository.rootPackage ? 'root' : pkg.name;
|
|
76
76
|
const logLevel = args.logLevel == null ? 'info' : args.logLevel;
|
|
77
77
|
if (logLevel) {
|
|
78
|
-
npmlog_1.default.verbose(this.commandName,
|
|
78
|
+
npmlog_1.default.verbose(this.commandName, ansi_colors_1.default.cyan(name), npmlog_1.default.separator, ansi_colors_1.default.cyanBright.bold(args.script || ''), ansi_colors_1.default.cyanBright.bold('executing'), npmlog_1.default.separator, command);
|
|
79
79
|
}
|
|
80
80
|
const t = Date.now();
|
|
81
81
|
const cwd = args.cwd || pkg.dirname;
|
|
82
82
|
const r = await (0, exec_js_1.exec)(command, { cwd, stdio: args.stdio, throwOnError: false });
|
|
83
83
|
if (logLevel) {
|
|
84
84
|
if (r.error) {
|
|
85
|
-
npmlog_1.default.error(this.commandName,
|
|
85
|
+
npmlog_1.default.error(this.commandName, ansi_colors_1.default.cyan(name), npmlog_1.default.separator, ansi_colors_1.default.cyanBright.bold(args.script || ''), ansi_colors_1.default.red.bold('failed'), npmlog_1.default.separator, command, npmlog_1.default.separator, r.error.message.trim() + ('\n' + r.stdout).trim());
|
|
86
86
|
}
|
|
87
87
|
else {
|
|
88
|
-
npmlog_1.default.log(logLevel, this.commandName,
|
|
88
|
+
npmlog_1.default.log(logLevel, this.commandName, ansi_colors_1.default.cyan(name), npmlog_1.default.separator, ansi_colors_1.default.cyanBright.bold(args.script || ''), ansi_colors_1.default.green.bold('success'), npmlog_1.default.separator, command, ansi_colors_1.default.yellow(' (' + (Date.now() - t) + ' ms)'));
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
91
|
if (r.error && !args.noThrow)
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.VersionCommand = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const
|
|
5
|
+
const ansi_colors_1 = tslib_1.__importDefault(require("ansi-colors"));
|
|
6
6
|
const npmlog_1 = tslib_1.__importDefault(require("npmlog"));
|
|
7
7
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
8
8
|
const power_tasks_1 = require("power-tasks");
|
|
@@ -32,13 +32,13 @@ class VersionCommand extends run_command_js_1.RunCommand {
|
|
|
32
32
|
let status = '';
|
|
33
33
|
let message = '';
|
|
34
34
|
let newVer = '';
|
|
35
|
-
const logPkgName =
|
|
35
|
+
const logPkgName = ansi_colors_1.default.yellow(p.name);
|
|
36
36
|
if (!this.options.noTag) {
|
|
37
37
|
const isDirty = dirtyFiles.find(f => !path_1.default.relative(relDir, f).startsWith('..'));
|
|
38
38
|
if (isDirty) {
|
|
39
39
|
if (!this.options.ignoreDirty)
|
|
40
40
|
errorCount++;
|
|
41
|
-
status = this.options.ignoreDirty ?
|
|
41
|
+
status = this.options.ignoreDirty ? ansi_colors_1.default.cyan.bold('skip') : ansi_colors_1.default.redBright.bold('error');
|
|
42
42
|
message = 'Git directory is not clean';
|
|
43
43
|
}
|
|
44
44
|
}
|
|
@@ -51,7 +51,7 @@ class VersionCommand extends run_command_js_1.RunCommand {
|
|
|
51
51
|
if (newVer)
|
|
52
52
|
newVersions[p.name] = newVer;
|
|
53
53
|
else {
|
|
54
|
-
status =
|
|
54
|
+
status = ansi_colors_1.default.cyanBright.bold('no-change');
|
|
55
55
|
message = 'No change detected';
|
|
56
56
|
}
|
|
57
57
|
}
|
|
@@ -66,7 +66,7 @@ class VersionCommand extends run_command_js_1.RunCommand {
|
|
|
66
66
|
});
|
|
67
67
|
}
|
|
68
68
|
else {
|
|
69
|
-
npmlog_1.default.log(this.options.ignoreDirty ? 'info' : 'error', this.commandName, logPkgName,
|
|
69
|
+
npmlog_1.default.log(this.options.ignoreDirty ? 'info' : 'error', this.commandName, logPkgName, ansi_colors_1.default.whiteBright(p.version), status, npmlog_1.default.separator, message);
|
|
70
70
|
}
|
|
71
71
|
continue;
|
|
72
72
|
}
|
|
@@ -147,7 +147,7 @@ class VersionCommand extends run_command_js_1.RunCommand {
|
|
|
147
147
|
this._updatedPackages.add(p);
|
|
148
148
|
}
|
|
149
149
|
}
|
|
150
|
-
npmlog_1.default.info(this.commandName, pkg.name, npmlog_1.default.separator, 'Version changed from ' +
|
|
150
|
+
npmlog_1.default.info(this.commandName, pkg.name, npmlog_1.default.separator, 'Version changed from ' + ansi_colors_1.default.cyan(oldVer) + ' to ' + ansi_colors_1.default.cyan(newVer));
|
|
151
151
|
return { code: 0 };
|
|
152
152
|
}
|
|
153
153
|
return super._exec(pkg, command, args, options);
|
package/cjs/core/command.js
CHANGED
|
@@ -3,14 +3,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.Command = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
require("./logger.js");
|
|
6
|
-
const
|
|
7
|
-
const figures_1 = tslib_1.__importDefault(require("figures"));
|
|
6
|
+
const ansi_colors_1 = tslib_1.__importDefault(require("ansi-colors"));
|
|
8
7
|
const is_ci_1 = tslib_1.__importDefault(require("is-ci"));
|
|
9
8
|
const npmlog_1 = tslib_1.__importDefault(require("npmlog"));
|
|
10
9
|
const putil_merge_1 = tslib_1.__importDefault(require("putil-merge"));
|
|
11
10
|
const strict_typed_events_1 = require("strict-typed-events");
|
|
12
11
|
const constants_js_1 = require("./constants.js");
|
|
13
12
|
const noOp = () => undefined;
|
|
13
|
+
const lineVerticalDashed0 = '┆';
|
|
14
14
|
class Command extends (0, strict_typed_events_1.TypedEventEmitterClass)(strict_typed_events_1.AsyncEventEmitter) {
|
|
15
15
|
constructor(options) {
|
|
16
16
|
super();
|
|
@@ -20,7 +20,7 @@ class Command extends (0, strict_typed_events_1.TypedEventEmitterClass)(strict_t
|
|
|
20
20
|
this._options = options || {};
|
|
21
21
|
if (is_ci_1.default)
|
|
22
22
|
this.options.ci = true;
|
|
23
|
-
this.logger.separator =
|
|
23
|
+
this.logger.separator = ansi_colors_1.default.gray(lineVerticalDashed0);
|
|
24
24
|
Object.defineProperty(this.logger, 'levelIndex', {
|
|
25
25
|
get() {
|
|
26
26
|
return npmlog_1.default.levels[npmlog_1.default.level] || 0;
|
|
@@ -8,7 +8,6 @@ const tslib_1 = require("tslib");
|
|
|
8
8
|
* Inspired from [npm-run-path](https://github.com/sindresorhus/npm-run-path)
|
|
9
9
|
*/
|
|
10
10
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
11
|
-
const path_key_1 = tslib_1.__importDefault(require("path-key"));
|
|
12
11
|
const process_1 = tslib_1.__importDefault(require("process"));
|
|
13
12
|
/**
|
|
14
13
|
Get your [PATH](https://en.wikipedia.org/wiki/PATH_(variable)) prepended with locally installed binaries.
|
|
@@ -25,7 +24,7 @@ const process_1 = tslib_1.__importDefault(require("process"));
|
|
|
25
24
|
*/
|
|
26
25
|
function npmRunPath(options = {}) {
|
|
27
26
|
const cwd = options.cwd || process_1.default.cwd();
|
|
28
|
-
const path_ = options.path || process_1.default.env[(
|
|
27
|
+
const path_ = options.path || process_1.default.env[pathKey()];
|
|
29
28
|
const execPath = options.execPath || process_1.default.execPath;
|
|
30
29
|
let previous;
|
|
31
30
|
let cwdPath = path_1.default.resolve(cwd);
|
|
@@ -39,6 +38,16 @@ function npmRunPath(options = {}) {
|
|
|
39
38
|
result.push(path_1.default.resolve(cwd, execPath, '..'));
|
|
40
39
|
return [...result, path_].join(path_1.default.delimiter);
|
|
41
40
|
}
|
|
41
|
+
function pathKey(options) {
|
|
42
|
+
const env = options?.env || process_1.default.env;
|
|
43
|
+
const platform = options?.platform || process_1.default.platform;
|
|
44
|
+
if (platform !== 'win32') {
|
|
45
|
+
return 'PATH';
|
|
46
|
+
}
|
|
47
|
+
return (Object.keys(env)
|
|
48
|
+
.reverse()
|
|
49
|
+
.find(key => key.toUpperCase() === 'PATH') || 'Path');
|
|
50
|
+
}
|
|
42
51
|
/**
|
|
43
52
|
@returns The augmented [`process.env`](https://nodejs.org/api/process.html#process_process_env) object.
|
|
44
53
|
@example
|
|
@@ -47,13 +56,13 @@ function npmRunPath(options = {}) {
|
|
|
47
56
|
import {npmRunPathEnv} from 'npm-run-path';
|
|
48
57
|
// `foo` is a locally installed binary
|
|
49
58
|
childProcess.execFileSync('foo', {
|
|
50
|
-
|
|
51
|
-
});
|
|
59
|
+
env: npmRunPathEnv()
|
|
60
|
+
});
|
|
52
61
|
```
|
|
53
62
|
*/
|
|
54
63
|
function npmRunPathEnv(options = {}) {
|
|
55
64
|
const env = { ...(options.env || process_1.default.env) };
|
|
56
|
-
const path_ = (
|
|
65
|
+
const path_ = pathKey({ env });
|
|
57
66
|
const opts = { ...options, path: env[path_] };
|
|
58
67
|
env[path_] = npmRunPath(opts);
|
|
59
68
|
return env;
|
package/esm/cli.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import colors from 'ansi-colors';
|
|
2
2
|
import fs from 'fs/promises';
|
|
3
3
|
import logger from 'npmlog';
|
|
4
4
|
import path from 'path';
|
|
@@ -34,12 +34,12 @@ export async function runCli(options) {
|
|
|
34
34
|
.fail((msg, err) => {
|
|
35
35
|
if (!err?.logged) {
|
|
36
36
|
const text = msg
|
|
37
|
-
? msg + '\n\n' +
|
|
37
|
+
? msg + '\n\n' + colors.whiteBright('Run with --help for available options')
|
|
38
38
|
: err
|
|
39
39
|
? err.message
|
|
40
40
|
: '';
|
|
41
41
|
// eslint-disable-next-line no-console
|
|
42
|
-
console.log('\n' +
|
|
42
|
+
console.log('\n' + colors.red(text));
|
|
43
43
|
throw msg;
|
|
44
44
|
}
|
|
45
45
|
else
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import colors from 'ansi-colors';
|
|
2
2
|
import logger from 'npmlog';
|
|
3
3
|
import path from 'path';
|
|
4
4
|
import { Task } from 'power-tasks';
|
|
@@ -20,7 +20,7 @@ export class CleanInstallCommand extends RunCommand {
|
|
|
20
20
|
await this._fsDelete(path.join(dirname, 'node_modules'));
|
|
21
21
|
await this._fsDelete(path.join(dirname, 'package-lock.json'));
|
|
22
22
|
await this._fsDelete(path.join(dirname, 'yarn-lock.json'));
|
|
23
|
-
logger.info(this.commandName,
|
|
23
|
+
logger.info(this.commandName, colors.yellow('install'), 'Running ' + client + ' install');
|
|
24
24
|
return super._exec(this.repository.rootPackage, client + ' install', {
|
|
25
25
|
stdio: 'inherit',
|
|
26
26
|
});
|
|
@@ -42,7 +42,7 @@ export class CleanInstallCommand extends RunCommand {
|
|
|
42
42
|
}
|
|
43
43
|
async _fsDelete(fileOrDir) {
|
|
44
44
|
if (await fsExists(fileOrDir)) {
|
|
45
|
-
logger.info(this.commandName,
|
|
45
|
+
logger.info(this.commandName, colors.yellow('rmdir'), path.relative(this.repository.dirname, fileOrDir));
|
|
46
46
|
await fsDelete(fileOrDir);
|
|
47
47
|
}
|
|
48
48
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import colors from 'ansi-colors';
|
|
2
2
|
import logger from 'npmlog';
|
|
3
3
|
import { Task } from 'power-tasks';
|
|
4
4
|
import { Command } from '../core/command.js';
|
|
@@ -16,13 +16,13 @@ export class ExecuteCommand extends MultiTaskCommand {
|
|
|
16
16
|
for (const p of packages) {
|
|
17
17
|
const task = new Task(async () => {
|
|
18
18
|
const t = Date.now();
|
|
19
|
-
logger.verbose(this.commandName, p.name,
|
|
19
|
+
logger.verbose(this.commandName, p.name, colors.cyanBright.bold('executing'), logger.separator, this.cmd + ' ' + (this.argv?.join(' ') || ''));
|
|
20
20
|
const r = await exec(this.cmd, {
|
|
21
21
|
cwd: p.dirname,
|
|
22
22
|
argv: this.argv,
|
|
23
23
|
stdio: logger.levelIndex < 1000 ? 'inherit' : 'pipe',
|
|
24
24
|
});
|
|
25
|
-
logger.log(r.error ? 'error' : 'info', this.commandName, p.name, r.error ?
|
|
25
|
+
logger.log(r.error ? 'error' : 'info', this.commandName, p.name, r.error ? colors.red.bold('failed') : colors.green.bold('success'), logger.separator, this.cmd, colors.yellow(' (' + (Date.now() - t) + ' ms') + ')');
|
|
26
26
|
}, {
|
|
27
27
|
name: p.name,
|
|
28
28
|
dependencies: this.options.parallel ? undefined : p.dependencies,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import colors from 'ansi-colors';
|
|
2
2
|
import envinfo from 'envinfo';
|
|
3
3
|
import semver from 'semver';
|
|
4
4
|
import { Command } from '../core/command.js';
|
|
@@ -17,22 +17,22 @@ export class InfoCommand extends Command {
|
|
|
17
17
|
}
|
|
18
18
|
const maxName = Object.keys(systemInfo).reduce((l, p) => Object.keys(systemInfo[p]).reduce((i, x) => (l = Math.max(i, x.length)), l), 0);
|
|
19
19
|
for (const [categoryName, category] of Object.entries(systemInfo)) {
|
|
20
|
-
this.logger.output('', '',
|
|
20
|
+
this.logger.output('', '', colors.whiteBright(categoryName) + ':');
|
|
21
21
|
for (const [n, v] of Object.entries(category)) {
|
|
22
|
-
const label = ' ' +
|
|
22
|
+
const label = ' ' + colors.reset(n) + ' '.repeat(maxName - n.length) + ' :';
|
|
23
23
|
if (typeof v === 'string') {
|
|
24
|
-
this.logger.output('', label,
|
|
24
|
+
this.logger.output('', label, colors.yellowBright(v));
|
|
25
25
|
continue;
|
|
26
26
|
}
|
|
27
27
|
if (v.version) {
|
|
28
|
-
this.logger.output('', label,
|
|
28
|
+
this.logger.output('', label, colors.yellowBright(v.version), v.path ? ' ' + colors.yellow(v.path) : '');
|
|
29
29
|
}
|
|
30
30
|
if (v.installed) {
|
|
31
31
|
if (v.wanted === 'latest' || semver.intersects(v.installed, v.wanted)) {
|
|
32
|
-
this.logger.output('', label,
|
|
32
|
+
this.logger.output('', label, colors.yellowBright(v.installed));
|
|
33
33
|
}
|
|
34
34
|
else
|
|
35
|
-
this.logger.output('', label,
|
|
35
|
+
this.logger.output('', label, colors.red(v.installed), ' => ', colors.yellowBright(v.wanted));
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import colors from 'ansi-colors';
|
|
2
2
|
import EasyTable from 'easy-table';
|
|
3
3
|
import logger from 'npmlog';
|
|
4
4
|
import path from 'path';
|
|
@@ -65,10 +65,10 @@ export class ListCommand extends Command {
|
|
|
65
65
|
if (this.onPrintTable)
|
|
66
66
|
this.onPrintTable(p, o, table);
|
|
67
67
|
else {
|
|
68
|
-
table.cell('Package',
|
|
69
|
-
table.cell('Version',
|
|
70
|
-
table.cell('Private', p.isPrivate ?
|
|
71
|
-
table.cell('Changed', isDirty ?
|
|
68
|
+
table.cell('Package', colors.yellowBright(p.name));
|
|
69
|
+
table.cell('Version', colors.yellow(p.version));
|
|
70
|
+
table.cell('Private', p.isPrivate ? colors.magentaBright('yes') : '');
|
|
71
|
+
table.cell('Changed', isDirty ? colors.magenta('dirty') : isCommitted ? colors.yellow('committed') : '');
|
|
72
72
|
table.cell('Path', path.relative(repository.dirname, p.dirname));
|
|
73
73
|
table.newRow();
|
|
74
74
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import colors from 'ansi-colors';
|
|
2
2
|
import logger from 'npmlog';
|
|
3
3
|
import path from 'path';
|
|
4
4
|
import { Command } from '../core/command.js';
|
|
@@ -18,7 +18,7 @@ export class PublishCommand extends RunCommand {
|
|
|
18
18
|
const selectedPackages = [];
|
|
19
19
|
const promises = [];
|
|
20
20
|
for (const p of packages) {
|
|
21
|
-
const logPkgName =
|
|
21
|
+
const logPkgName = colors.yellow(p.name);
|
|
22
22
|
if (p.json.private) {
|
|
23
23
|
logger.info(this.commandName, logPkgName, logger.separator, `Ignored. Package is set to "private"`);
|
|
24
24
|
continue;
|
|
@@ -31,19 +31,19 @@ export class PublishCommand extends RunCommand {
|
|
|
31
31
|
const sameVersion = !!(r && r.version === p.version);
|
|
32
32
|
if (this.options.checkOnly) {
|
|
33
33
|
logger.info(this.commandName, logPkgName, logger.separator, !r.version
|
|
34
|
-
?
|
|
34
|
+
? colors.yellow('No package information found in repository')
|
|
35
35
|
: sameVersion
|
|
36
|
-
? `No publish needed. Version (${
|
|
36
|
+
? `No publish needed. Version (${colors.magenta(p.version)}) same in repository`
|
|
37
37
|
: `Publishing is possible.` +
|
|
38
|
-
` Version "${
|
|
38
|
+
` Version "${colors.magenta(p.version)}" differs from version in repository (${colors.magenta(r.version)})`);
|
|
39
39
|
return;
|
|
40
40
|
}
|
|
41
41
|
if (r && r.version === p.version) {
|
|
42
|
-
logger.info(this.commandName, logPkgName, logger.separator, `No publish needed. Version (${
|
|
42
|
+
logger.info(this.commandName, logPkgName, logger.separator, `No publish needed. Version (${colors.magenta(p.version)}) same in repository`);
|
|
43
43
|
}
|
|
44
44
|
else {
|
|
45
45
|
logger.verbose(this.commandName, logPkgName, logger.separator, `Publishing is possible.` +
|
|
46
|
-
` Version "${
|
|
46
|
+
` Version "${colors.magenta(p.version)}" differs from version in repository (${colors.magenta(r.version)})`);
|
|
47
47
|
selectedPackages.push(p);
|
|
48
48
|
}
|
|
49
49
|
})
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import parseNpmScript from '@netlify/parse-npm-script';
|
|
2
|
-
import
|
|
2
|
+
import colors from 'ansi-colors';
|
|
3
3
|
import logger from 'npmlog';
|
|
4
4
|
import { Task } from 'power-tasks';
|
|
5
5
|
import { Command } from '../core/command.js';
|
|
@@ -71,17 +71,17 @@ export class RunCommand extends MultiTaskCommand {
|
|
|
71
71
|
const name = pkg === this.repository.rootPackage ? 'root' : pkg.name;
|
|
72
72
|
const logLevel = args.logLevel == null ? 'info' : args.logLevel;
|
|
73
73
|
if (logLevel) {
|
|
74
|
-
logger.verbose(this.commandName,
|
|
74
|
+
logger.verbose(this.commandName, colors.cyan(name), logger.separator, colors.cyanBright.bold(args.script || ''), colors.cyanBright.bold('executing'), logger.separator, command);
|
|
75
75
|
}
|
|
76
76
|
const t = Date.now();
|
|
77
77
|
const cwd = args.cwd || pkg.dirname;
|
|
78
78
|
const r = await exec(command, { cwd, stdio: args.stdio, throwOnError: false });
|
|
79
79
|
if (logLevel) {
|
|
80
80
|
if (r.error) {
|
|
81
|
-
logger.error(this.commandName,
|
|
81
|
+
logger.error(this.commandName, colors.cyan(name), logger.separator, colors.cyanBright.bold(args.script || ''), colors.red.bold('failed'), logger.separator, command, logger.separator, r.error.message.trim() + ('\n' + r.stdout).trim());
|
|
82
82
|
}
|
|
83
83
|
else {
|
|
84
|
-
logger.log(logLevel, this.commandName,
|
|
84
|
+
logger.log(logLevel, this.commandName, colors.cyan(name), logger.separator, colors.cyanBright.bold(args.script || ''), colors.green.bold('success'), logger.separator, command, colors.yellow(' (' + (Date.now() - t) + ' ms)'));
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
87
|
if (r.error && !args.noThrow)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import colors from 'ansi-colors';
|
|
2
2
|
import logger from 'npmlog';
|
|
3
3
|
import path from 'path';
|
|
4
4
|
import { Task } from 'power-tasks';
|
|
@@ -28,13 +28,13 @@ export class VersionCommand extends RunCommand {
|
|
|
28
28
|
let status = '';
|
|
29
29
|
let message = '';
|
|
30
30
|
let newVer = '';
|
|
31
|
-
const logPkgName =
|
|
31
|
+
const logPkgName = colors.yellow(p.name);
|
|
32
32
|
if (!this.options.noTag) {
|
|
33
33
|
const isDirty = dirtyFiles.find(f => !path.relative(relDir, f).startsWith('..'));
|
|
34
34
|
if (isDirty) {
|
|
35
35
|
if (!this.options.ignoreDirty)
|
|
36
36
|
errorCount++;
|
|
37
|
-
status = this.options.ignoreDirty ?
|
|
37
|
+
status = this.options.ignoreDirty ? colors.cyan.bold('skip') : colors.redBright.bold('error');
|
|
38
38
|
message = 'Git directory is not clean';
|
|
39
39
|
}
|
|
40
40
|
}
|
|
@@ -47,7 +47,7 @@ export class VersionCommand extends RunCommand {
|
|
|
47
47
|
if (newVer)
|
|
48
48
|
newVersions[p.name] = newVer;
|
|
49
49
|
else {
|
|
50
|
-
status =
|
|
50
|
+
status = colors.cyanBright.bold('no-change');
|
|
51
51
|
message = 'No change detected';
|
|
52
52
|
}
|
|
53
53
|
}
|
|
@@ -62,7 +62,7 @@ export class VersionCommand extends RunCommand {
|
|
|
62
62
|
});
|
|
63
63
|
}
|
|
64
64
|
else {
|
|
65
|
-
logger.log(this.options.ignoreDirty ? 'info' : 'error', this.commandName, logPkgName,
|
|
65
|
+
logger.log(this.options.ignoreDirty ? 'info' : 'error', this.commandName, logPkgName, colors.whiteBright(p.version), status, logger.separator, message);
|
|
66
66
|
}
|
|
67
67
|
continue;
|
|
68
68
|
}
|
|
@@ -143,7 +143,7 @@ export class VersionCommand extends RunCommand {
|
|
|
143
143
|
this._updatedPackages.add(p);
|
|
144
144
|
}
|
|
145
145
|
}
|
|
146
|
-
logger.info(this.commandName, pkg.name, logger.separator, 'Version changed from ' +
|
|
146
|
+
logger.info(this.commandName, pkg.name, logger.separator, 'Version changed from ' + colors.cyan(oldVer) + ' to ' + colors.cyan(newVer));
|
|
147
147
|
return { code: 0 };
|
|
148
148
|
}
|
|
149
149
|
return super._exec(pkg, command, args, options);
|
package/esm/core/command.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import './logger.js';
|
|
2
|
-
import
|
|
3
|
-
import figures from 'figures';
|
|
2
|
+
import colors from 'ansi-colors';
|
|
4
3
|
import isCi from 'is-ci';
|
|
5
4
|
import npmlog from 'npmlog';
|
|
6
5
|
import merge from 'putil-merge';
|
|
7
6
|
import { AsyncEventEmitter, TypedEventEmitterClass } from 'strict-typed-events';
|
|
8
7
|
import { isTTY } from './constants.js';
|
|
9
8
|
const noOp = () => undefined;
|
|
9
|
+
const lineVerticalDashed0 = '┆';
|
|
10
10
|
export class Command extends TypedEventEmitterClass(AsyncEventEmitter) {
|
|
11
11
|
constructor(options) {
|
|
12
12
|
super();
|
|
@@ -16,7 +16,7 @@ export class Command extends TypedEventEmitterClass(AsyncEventEmitter) {
|
|
|
16
16
|
this._options = options || {};
|
|
17
17
|
if (isCi)
|
|
18
18
|
this.options.ci = true;
|
|
19
|
-
this.logger.separator =
|
|
19
|
+
this.logger.separator = colors.gray(lineVerticalDashed0);
|
|
20
20
|
Object.defineProperty(this.logger, 'levelIndex', {
|
|
21
21
|
get() {
|
|
22
22
|
return npmlog.levels[npmlog.level] || 0;
|