rman 0.29.0 → 0.30.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 +40 -36
- package/esm/commands/build-command.js +9 -5
- package/esm/commands/changed-command.js +10 -6
- package/esm/commands/ci-command.js +28 -23
- package/esm/commands/execute-command.js +20 -15
- package/esm/commands/info-command.js +20 -15
- package/esm/commands/list-command.js +30 -25
- package/esm/commands/multi-task-command.js +16 -11
- package/esm/commands/publish-command.js +28 -23
- package/esm/commands/run-command.js +24 -19
- package/esm/commands/version-command.js +35 -30
- package/esm/core/command.js +24 -19
- package/esm/core/constants.js +4 -1
- package/esm/core/logger.js +5 -2
- package/esm/core/package.js +11 -6
- package/esm/core/repository.js +33 -28
- package/esm/index.js +4 -1
- package/esm/utils/exec.js +10 -7
- package/esm/utils/file-utils.js +17 -11
- package/esm/utils/get-dirname.js +13 -8
- package/esm/utils/git-utils.js +14 -9
- package/esm/utils/npm-run-path.js +30 -16
- package/esm/utils/npm-utils.js +9 -4
- package/package.json +35 -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
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ExecuteCommand = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const ansi_colors_1 = tslib_1.__importDefault(require("ansi-colors"));
|
|
6
|
+
const npmlog_1 = tslib_1.__importDefault(require("npmlog"));
|
|
7
|
+
const power_tasks_1 = require("power-tasks");
|
|
8
|
+
const command_js_1 = require("../core/command.js");
|
|
9
|
+
const exec_js_1 = require("../utils/exec.js");
|
|
10
|
+
const multi_task_command_js_1 = require("./multi-task-command.js");
|
|
11
|
+
class ExecuteCommand extends multi_task_command_js_1.MultiTaskCommand {
|
|
8
12
|
constructor(repository, cmd, argv, options) {
|
|
9
13
|
super(repository, options);
|
|
10
14
|
this.repository = repository;
|
|
@@ -14,15 +18,15 @@ export class ExecuteCommand extends MultiTaskCommand {
|
|
|
14
18
|
_prepareTasks(packages) {
|
|
15
19
|
const tasks = [];
|
|
16
20
|
for (const p of packages) {
|
|
17
|
-
const task = new Task(async () => {
|
|
21
|
+
const task = new power_tasks_1.Task(async () => {
|
|
18
22
|
const t = Date.now();
|
|
19
|
-
|
|
20
|
-
const r = await exec(this.cmd, {
|
|
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
|
+
const r = await (0, exec_js_1.exec)(this.cmd, {
|
|
21
25
|
cwd: p.dirname,
|
|
22
26
|
argv: this.argv,
|
|
23
|
-
stdio:
|
|
27
|
+
stdio: npmlog_1.default.levelIndex < 1000 ? 'inherit' : 'pipe',
|
|
24
28
|
});
|
|
25
|
-
|
|
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') + ')');
|
|
26
30
|
}, {
|
|
27
31
|
name: p.name,
|
|
28
32
|
dependencies: this.options.parallel ? undefined : p.dependencies,
|
|
@@ -34,10 +38,11 @@ export class ExecuteCommand extends MultiTaskCommand {
|
|
|
34
38
|
return tasks;
|
|
35
39
|
}
|
|
36
40
|
}
|
|
41
|
+
exports.ExecuteCommand = ExecuteCommand;
|
|
37
42
|
ExecuteCommand.commandName = 'exec';
|
|
38
43
|
(function (ExecuteCommand) {
|
|
39
44
|
ExecuteCommand.cliCommandOptions = {
|
|
40
|
-
...MultiTaskCommand.cliCommandOptions,
|
|
45
|
+
...multi_task_command_js_1.MultiTaskCommand.cliCommandOptions,
|
|
41
46
|
};
|
|
42
47
|
function initCli(repository, program) {
|
|
43
48
|
program.command({
|
|
@@ -60,10 +65,10 @@ ExecuteCommand.commandName = 'exec';
|
|
|
60
65
|
.option(ExecuteCommand.cliCommandOptions),
|
|
61
66
|
handler: async (args) => {
|
|
62
67
|
const argv = args['--'] || [];
|
|
63
|
-
const options = Command.composeOptions(ExecuteCommand.commandName, args, repository.config);
|
|
68
|
+
const options = command_js_1.Command.composeOptions(ExecuteCommand.commandName, args, repository.config);
|
|
64
69
|
await new ExecuteCommand(repository, '' + argv.shift(), argv, options).execute();
|
|
65
70
|
},
|
|
66
71
|
});
|
|
67
72
|
}
|
|
68
73
|
ExecuteCommand.initCli = initCli;
|
|
69
|
-
})(ExecuteCommand || (ExecuteCommand = {}));
|
|
74
|
+
})(ExecuteCommand || (exports.ExecuteCommand = ExecuteCommand = {}));
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InfoCommand = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const ansi_colors_1 = tslib_1.__importDefault(require("ansi-colors"));
|
|
6
|
+
const envinfo_1 = tslib_1.__importDefault(require("envinfo"));
|
|
7
|
+
const semver_1 = tslib_1.__importDefault(require("semver"));
|
|
8
|
+
const command_js_1 = require("../core/command.js");
|
|
9
|
+
class InfoCommand extends command_js_1.Command {
|
|
6
10
|
async _execute() {
|
|
7
|
-
const systemInfo = JSON.parse(await
|
|
11
|
+
const systemInfo = JSON.parse(await envinfo_1.default.run({
|
|
8
12
|
System: ['OS', 'CPU', 'Memory', 'Shell'],
|
|
9
13
|
Binaries: ['Node', 'Yarn', 'npm'],
|
|
10
14
|
Utilities: ['Git'],
|
|
@@ -17,27 +21,28 @@ export class InfoCommand extends Command {
|
|
|
17
21
|
}
|
|
18
22
|
const maxName = Object.keys(systemInfo).reduce((l, p) => Object.keys(systemInfo[p]).reduce((i, x) => (l = Math.max(i, x.length)), l), 0);
|
|
19
23
|
for (const [categoryName, category] of Object.entries(systemInfo)) {
|
|
20
|
-
this.logger.output('', '',
|
|
24
|
+
this.logger.output('', '', ansi_colors_1.default.whiteBright(categoryName) + ':');
|
|
21
25
|
for (const [n, v] of Object.entries(category)) {
|
|
22
|
-
const label = ' ' +
|
|
26
|
+
const label = ' ' + ansi_colors_1.default.reset(n) + ' '.repeat(maxName - n.length) + ' :';
|
|
23
27
|
if (typeof v === 'string') {
|
|
24
|
-
this.logger.output('', label,
|
|
28
|
+
this.logger.output('', label, ansi_colors_1.default.yellowBright(v));
|
|
25
29
|
continue;
|
|
26
30
|
}
|
|
27
31
|
if (v.version) {
|
|
28
|
-
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) : '');
|
|
29
33
|
}
|
|
30
34
|
if (v.installed) {
|
|
31
|
-
if (v.wanted === 'latest' ||
|
|
32
|
-
this.logger.output('', label,
|
|
35
|
+
if (v.wanted === 'latest' || semver_1.default.intersects(v.installed, v.wanted)) {
|
|
36
|
+
this.logger.output('', label, ansi_colors_1.default.yellowBright(v.installed));
|
|
33
37
|
}
|
|
34
38
|
else
|
|
35
|
-
this.logger.output('', label,
|
|
39
|
+
this.logger.output('', label, ansi_colors_1.default.red(v.installed), ' => ', ansi_colors_1.default.yellowBright(v.wanted));
|
|
36
40
|
}
|
|
37
41
|
}
|
|
38
42
|
}
|
|
39
43
|
}
|
|
40
44
|
}
|
|
45
|
+
exports.InfoCommand = InfoCommand;
|
|
41
46
|
InfoCommand.commandName = 'info';
|
|
42
47
|
(function (InfoCommand) {
|
|
43
48
|
function initCli(repository, program) {
|
|
@@ -46,10 +51,10 @@ InfoCommand.commandName = 'info';
|
|
|
46
51
|
describe: 'Prints local environment information',
|
|
47
52
|
builder: cmd => cmd.example('$0 info', '# Prints information').example('$0 info --json', '# Prints information in JSON format'),
|
|
48
53
|
handler: async (args) => {
|
|
49
|
-
const options = Command.composeOptions(InfoCommand.commandName, args, repository.config);
|
|
54
|
+
const options = command_js_1.Command.composeOptions(InfoCommand.commandName, args, repository.config);
|
|
50
55
|
await new InfoCommand(options).execute();
|
|
51
56
|
},
|
|
52
57
|
});
|
|
53
58
|
}
|
|
54
59
|
InfoCommand.initCli = initCli;
|
|
55
|
-
})(InfoCommand || (InfoCommand = {}));
|
|
60
|
+
})(InfoCommand || (exports.InfoCommand = InfoCommand = {}));
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ListCommand = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const ansi_colors_1 = tslib_1.__importDefault(require("ansi-colors"));
|
|
6
|
+
const easy_table_1 = tslib_1.__importDefault(require("easy-table"));
|
|
7
|
+
const npmlog_1 = tslib_1.__importDefault(require("npmlog"));
|
|
8
|
+
const path_1 = tslib_1.__importDefault(require("path"));
|
|
9
|
+
const command_js_1 = require("../core/command.js");
|
|
10
|
+
const git_utils_js_1 = require("../utils/git-utils.js");
|
|
11
|
+
class ListCommand extends command_js_1.Command {
|
|
8
12
|
constructor(repository, options) {
|
|
9
13
|
super(options);
|
|
10
14
|
this.repository = repository;
|
|
@@ -16,16 +20,16 @@ export class ListCommand extends Command {
|
|
|
16
20
|
async _execute() {
|
|
17
21
|
const { repository } = this;
|
|
18
22
|
const packages = repository.getPackages({ toposort: this.options.toposort });
|
|
19
|
-
const git = new GitHelper({ cwd: repository.dirname });
|
|
23
|
+
const git = new git_utils_js_1.GitHelper({ cwd: repository.dirname });
|
|
20
24
|
const dirtyFiles = await git.listDirtyFiles({ absolute: true });
|
|
21
25
|
const committedFiles = await git.listCommittedFiles({ absolute: true });
|
|
22
|
-
const table = new
|
|
26
|
+
const table = new easy_table_1.default();
|
|
23
27
|
const arr = [];
|
|
24
28
|
const obj = {};
|
|
25
29
|
let count = 0;
|
|
26
30
|
for (const p of packages) {
|
|
27
|
-
const isDirty = !!dirtyFiles.find(f => !
|
|
28
|
-
const isCommitted = !!committedFiles.find(f => !
|
|
31
|
+
const isDirty = !!dirtyFiles.find(f => !path_1.default.relative(p.dirname, f).startsWith('..'));
|
|
32
|
+
const isCommitted = !!committedFiles.find(f => !path_1.default.relative(p.dirname, f).startsWith('..'));
|
|
29
33
|
if (!this._filter(p, { isDirty, isCommitted }))
|
|
30
34
|
continue;
|
|
31
35
|
if (this.options.graph) {
|
|
@@ -33,7 +37,7 @@ export class ListCommand extends Command {
|
|
|
33
37
|
obj[p.name] = [...p.dependencies];
|
|
34
38
|
continue;
|
|
35
39
|
}
|
|
36
|
-
const location =
|
|
40
|
+
const location = path_1.default.relative(repository.dirname, p.dirname);
|
|
37
41
|
let o = {
|
|
38
42
|
name: p.name,
|
|
39
43
|
version: p.version,
|
|
@@ -56,43 +60,44 @@ export class ListCommand extends Command {
|
|
|
56
60
|
p.isPrivate ? 'PRIVATE' : '',
|
|
57
61
|
isDirty ? 'DIRTY' : isCommitted ? ':COMMITTED' : '',
|
|
58
62
|
];
|
|
59
|
-
|
|
63
|
+
npmlog_1.default.output('', a.join('::'));
|
|
60
64
|
}
|
|
61
65
|
else if (this.options.short) {
|
|
62
|
-
|
|
66
|
+
npmlog_1.default.output('', p.name);
|
|
63
67
|
}
|
|
64
68
|
else {
|
|
65
69
|
if (this.onPrintTable)
|
|
66
70
|
this.onPrintTable(p, o, table);
|
|
67
71
|
else {
|
|
68
|
-
table.cell('Package',
|
|
69
|
-
table.cell('Version',
|
|
70
|
-
table.cell('Private', p.isPrivate ?
|
|
71
|
-
table.cell('Changed', isDirty ?
|
|
72
|
-
table.cell('Path',
|
|
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
|
+
table.cell('Path', path_1.default.relative(repository.dirname, p.dirname));
|
|
73
77
|
table.newRow();
|
|
74
78
|
}
|
|
75
79
|
}
|
|
76
80
|
}
|
|
77
81
|
}
|
|
78
82
|
if (this.options.graph) {
|
|
79
|
-
|
|
83
|
+
npmlog_1.default.output('', '%j', obj);
|
|
80
84
|
return obj;
|
|
81
85
|
}
|
|
82
86
|
if (this.options.json) {
|
|
83
|
-
|
|
87
|
+
npmlog_1.default.output('', '%j', arr);
|
|
84
88
|
return arr;
|
|
85
89
|
}
|
|
86
90
|
if (table.rows.length) {
|
|
87
|
-
|
|
91
|
+
npmlog_1.default.output('', '%s', table.toString().trim());
|
|
88
92
|
// eslint-disable-next-line no-console
|
|
89
93
|
console.log('');
|
|
90
|
-
|
|
94
|
+
npmlog_1.default.info('list', '%i Package(s) found', count);
|
|
91
95
|
return arr;
|
|
92
96
|
}
|
|
93
97
|
return arr;
|
|
94
98
|
}
|
|
95
99
|
}
|
|
100
|
+
exports.ListCommand = ListCommand;
|
|
96
101
|
ListCommand.commandName = 'list';
|
|
97
102
|
(function (ListCommand) {
|
|
98
103
|
ListCommand.cliCommandOptions = {
|
|
@@ -125,10 +130,10 @@ ListCommand.commandName = 'list';
|
|
|
125
130
|
.conflicts('short', ['parseable', 'json'])
|
|
126
131
|
.option(ListCommand.cliCommandOptions),
|
|
127
132
|
handler: async (args) => {
|
|
128
|
-
const options = Command.composeOptions(ListCommand.commandName, args, repository.config);
|
|
133
|
+
const options = command_js_1.Command.composeOptions(ListCommand.commandName, args, repository.config);
|
|
129
134
|
await new ListCommand(repository, options).execute();
|
|
130
135
|
},
|
|
131
136
|
});
|
|
132
137
|
}
|
|
133
138
|
ListCommand.initCli = initCli;
|
|
134
|
-
})(ListCommand || (ListCommand = {}));
|
|
139
|
+
})(ListCommand || (exports.ListCommand = ListCommand = {}));
|
|
@@ -1,16 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MultiTaskCommand = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const os_1 = tslib_1.__importDefault(require("os"));
|
|
6
|
+
const power_tasks_1 = require("power-tasks");
|
|
7
|
+
const putil_varhelpers_1 = require("putil-varhelpers");
|
|
8
|
+
const command_js_1 = require("../core/command.js");
|
|
9
|
+
const constants_js_1 = require("../core/constants.js");
|
|
10
|
+
class MultiTaskCommand extends command_js_1.Command {
|
|
7
11
|
constructor(repository, options) {
|
|
8
12
|
super(options);
|
|
9
13
|
this.repository = repository;
|
|
10
|
-
if (this.options.ci || !isTTY)
|
|
14
|
+
if (this.options.ci || !constants_js_1.isTTY)
|
|
11
15
|
this.options.progress = false;
|
|
12
16
|
// noinspection SuspiciousTypeOfGuard
|
|
13
|
-
this.options.concurrency = toNumber(options?.concurrency);
|
|
17
|
+
this.options.concurrency = (0, putil_varhelpers_1.toNumber)(options?.concurrency);
|
|
14
18
|
if (this.options.bail == null)
|
|
15
19
|
this.options.bail = true;
|
|
16
20
|
}
|
|
@@ -21,9 +25,9 @@ export class MultiTaskCommand extends Command {
|
|
|
21
25
|
return;
|
|
22
26
|
}
|
|
23
27
|
// this.enableProgress();
|
|
24
|
-
this._task = new Task(childTasks, {
|
|
28
|
+
this._task = new power_tasks_1.Task(childTasks, {
|
|
25
29
|
name: '$project-root',
|
|
26
|
-
concurrency: this.options.concurrency ||
|
|
30
|
+
concurrency: this.options.concurrency || os_1.default.cpus().length,
|
|
27
31
|
bail: this.options.bail,
|
|
28
32
|
});
|
|
29
33
|
await this._task.toPromise();
|
|
@@ -32,6 +36,7 @@ export class MultiTaskCommand extends Command {
|
|
|
32
36
|
return this.repository.getPackages({ toposort: !this.options.parallel });
|
|
33
37
|
}
|
|
34
38
|
}
|
|
39
|
+
exports.MultiTaskCommand = MultiTaskCommand;
|
|
35
40
|
(function (MultiTaskCommand) {
|
|
36
41
|
MultiTaskCommand.cliCommandOptions = {
|
|
37
42
|
concurrency: {
|
|
@@ -60,4 +65,4 @@ export class MultiTaskCommand extends Command {
|
|
|
60
65
|
default: true,
|
|
61
66
|
},
|
|
62
67
|
};
|
|
63
|
-
})(MultiTaskCommand || (MultiTaskCommand = {}));
|
|
68
|
+
})(MultiTaskCommand || (exports.MultiTaskCommand = MultiTaskCommand = {}));
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PublishCommand = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const ansi_colors_1 = tslib_1.__importDefault(require("ansi-colors"));
|
|
6
|
+
const npmlog_1 = tslib_1.__importDefault(require("npmlog"));
|
|
7
|
+
const path_1 = tslib_1.__importDefault(require("path"));
|
|
8
|
+
const command_js_1 = require("../core/command.js");
|
|
9
|
+
const npm_utils_js_1 = require("../utils/npm-utils.js");
|
|
10
|
+
const run_command_js_1 = require("./run-command.js");
|
|
11
|
+
class PublishCommand extends run_command_js_1.RunCommand {
|
|
8
12
|
constructor(repository, options) {
|
|
9
13
|
super(repository, 'publish', {
|
|
10
14
|
...options,
|
|
@@ -18,32 +22,32 @@ export class PublishCommand extends RunCommand {
|
|
|
18
22
|
const selectedPackages = [];
|
|
19
23
|
const promises = [];
|
|
20
24
|
for (const p of packages) {
|
|
21
|
-
const logPkgName =
|
|
25
|
+
const logPkgName = ansi_colors_1.default.yellow(p.name);
|
|
22
26
|
if (p.json.private) {
|
|
23
|
-
|
|
27
|
+
npmlog_1.default.info(this.commandName, logPkgName, npmlog_1.default.separator, `Ignored. Package is set to "private"`);
|
|
24
28
|
continue;
|
|
25
29
|
}
|
|
26
|
-
|
|
27
|
-
const npmHelper = new NpmHelper({ cwd: p.dirname });
|
|
30
|
+
npmlog_1.default.info(this.commandName, logPkgName, npmlog_1.default.separator, `Fetching package information from repository`);
|
|
31
|
+
const npmHelper = new npm_utils_js_1.NpmHelper({ cwd: p.dirname });
|
|
28
32
|
promises.push(npmHelper
|
|
29
33
|
.getPackageInfo(p.json.name)
|
|
30
34
|
.then(r => {
|
|
31
35
|
const sameVersion = !!(r && r.version === p.version);
|
|
32
36
|
if (this.options.checkOnly) {
|
|
33
|
-
|
|
34
|
-
?
|
|
37
|
+
npmlog_1.default.info(this.commandName, logPkgName, npmlog_1.default.separator, !r.version
|
|
38
|
+
? ansi_colors_1.default.yellow('No package information found in repository')
|
|
35
39
|
: sameVersion
|
|
36
|
-
? `No publish needed. Version (${
|
|
40
|
+
? `No publish needed. Version (${ansi_colors_1.default.magenta(p.version)}) same in repository`
|
|
37
41
|
: `Publishing is possible.` +
|
|
38
|
-
` Version "${
|
|
42
|
+
` Version "${ansi_colors_1.default.magenta(p.version)}" differs from version in repository (${ansi_colors_1.default.magenta(r.version)})`);
|
|
39
43
|
return;
|
|
40
44
|
}
|
|
41
45
|
if (r && r.version === p.version) {
|
|
42
|
-
|
|
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`);
|
|
43
47
|
}
|
|
44
48
|
else {
|
|
45
|
-
|
|
46
|
-
` Version "${
|
|
49
|
+
npmlog_1.default.verbose(this.commandName, logPkgName, npmlog_1.default.separator, `Publishing is possible.` +
|
|
50
|
+
` Version "${ansi_colors_1.default.magenta(p.version)}" differs from version in repository (${ansi_colors_1.default.magenta(r.version)})`);
|
|
47
51
|
selectedPackages.push(p);
|
|
48
52
|
}
|
|
49
53
|
})
|
|
@@ -60,21 +64,22 @@ export class PublishCommand extends RunCommand {
|
|
|
60
64
|
if (pkg === this.repository.rootPackage)
|
|
61
65
|
return { code: 0 };
|
|
62
66
|
const cwd = this.options.contents
|
|
63
|
-
?
|
|
67
|
+
? path_1.default.resolve(this.repository.dirname, path_1.default.join(this.options.contents, path_1.default.basename(pkg.dirname)))
|
|
64
68
|
: pkg.dirname;
|
|
65
69
|
return super._exec(pkg, 'npm publish' + (this.options.access ? ' --access=' + this.options.access : ''), {
|
|
66
70
|
...args,
|
|
67
71
|
cwd,
|
|
68
|
-
stdio:
|
|
72
|
+
stdio: npmlog_1.default.levelIndex < 1000 ? 'inherit' : 'pipe',
|
|
69
73
|
}, options);
|
|
70
74
|
}
|
|
71
75
|
return super._exec(pkg, command, args, options);
|
|
72
76
|
}
|
|
73
77
|
}
|
|
78
|
+
exports.PublishCommand = PublishCommand;
|
|
74
79
|
PublishCommand.commandName = 'publish';
|
|
75
80
|
(function (PublishCommand) {
|
|
76
81
|
PublishCommand.cliCommandOptions = {
|
|
77
|
-
...RunCommand.cliCommandOptions,
|
|
82
|
+
...run_command_js_1.RunCommand.cliCommandOptions,
|
|
78
83
|
contents: {
|
|
79
84
|
describe: '# Subdirectory to publish',
|
|
80
85
|
type: 'string',
|
|
@@ -100,10 +105,10 @@ PublishCommand.commandName = 'publish';
|
|
|
100
105
|
.example('$0 publish --contents dist', '# publish package from built directory')
|
|
101
106
|
.option(PublishCommand.cliCommandOptions),
|
|
102
107
|
handler: async (args) => {
|
|
103
|
-
const options = Command.composeOptions(PublishCommand.commandName, args, repository.config);
|
|
108
|
+
const options = command_js_1.Command.composeOptions(PublishCommand.commandName, args, repository.config);
|
|
104
109
|
await new PublishCommand(repository, options).execute();
|
|
105
110
|
},
|
|
106
111
|
});
|
|
107
112
|
}
|
|
108
113
|
PublishCommand.initCli = initCli;
|
|
109
|
-
})(PublishCommand || (PublishCommand = {}));
|
|
114
|
+
})(PublishCommand || (exports.PublishCommand = PublishCommand = {}));
|
|
@@ -1,11 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RunCommand = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const parse_npm_script_1 = tslib_1.__importDefault(require("@netlify/parse-npm-script"));
|
|
6
|
+
const ansi_colors_1 = tslib_1.__importDefault(require("ansi-colors"));
|
|
7
|
+
const npmlog_1 = tslib_1.__importDefault(require("npmlog"));
|
|
8
|
+
const power_tasks_1 = require("power-tasks");
|
|
9
|
+
const command_js_1 = require("../core/command.js");
|
|
10
|
+
const exec_js_1 = require("../utils/exec.js");
|
|
11
|
+
const multi_task_command_js_1 = require("./multi-task-command.js");
|
|
12
|
+
class RunCommand extends multi_task_command_js_1.MultiTaskCommand {
|
|
9
13
|
constructor(repository, script, options) {
|
|
10
14
|
super(repository, options);
|
|
11
15
|
this.repository = repository;
|
|
@@ -38,16 +42,16 @@ export class RunCommand extends MultiTaskCommand {
|
|
|
38
42
|
const json = { ...pkg.json };
|
|
39
43
|
json.scripts = json.scripts || {};
|
|
40
44
|
json.scripts[this.script] = json.scripts[this.script] || '#';
|
|
41
|
-
const scriptInfo =
|
|
45
|
+
const scriptInfo = (0, parse_npm_script_1.default)(json, 'npm run ' + this.script);
|
|
42
46
|
if (!(scriptInfo && scriptInfo.raw))
|
|
43
47
|
return;
|
|
44
48
|
const children = [];
|
|
45
49
|
for (const s of scriptInfo.steps) {
|
|
46
50
|
const parsed = Array.isArray(s.parsed) ? s.parsed : [s.parsed];
|
|
47
51
|
for (const cmd of parsed) {
|
|
48
|
-
const task = new Task(async () => await this._exec(pkg, cmd, {
|
|
52
|
+
const task = new power_tasks_1.Task(async () => await this._exec(pkg, cmd, {
|
|
49
53
|
script: s.name,
|
|
50
|
-
stdio:
|
|
54
|
+
stdio: npmlog_1.default.levelIndex < 1000 ? 'inherit' : 'pipe',
|
|
51
55
|
}, options), {
|
|
52
56
|
name: pkg.name + ':' + s.name,
|
|
53
57
|
dependencies: this.options.parallel || s.name.startsWith('pre') || s.name.startsWith('post')
|
|
@@ -58,7 +62,7 @@ export class RunCommand extends MultiTaskCommand {
|
|
|
58
62
|
}
|
|
59
63
|
}
|
|
60
64
|
if (children.length) {
|
|
61
|
-
return new Task(children, {
|
|
65
|
+
return new power_tasks_1.Task(children, {
|
|
62
66
|
name: pkg.name,
|
|
63
67
|
bail: true,
|
|
64
68
|
serial: true,
|
|
@@ -71,17 +75,17 @@ export class RunCommand extends MultiTaskCommand {
|
|
|
71
75
|
const name = pkg === this.repository.rootPackage ? 'root' : pkg.name;
|
|
72
76
|
const logLevel = args.logLevel == null ? 'info' : args.logLevel;
|
|
73
77
|
if (logLevel) {
|
|
74
|
-
|
|
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);
|
|
75
79
|
}
|
|
76
80
|
const t = Date.now();
|
|
77
81
|
const cwd = args.cwd || pkg.dirname;
|
|
78
|
-
const r = await exec(command, { cwd, stdio: args.stdio, throwOnError: false });
|
|
82
|
+
const r = await (0, exec_js_1.exec)(command, { cwd, stdio: args.stdio, throwOnError: false });
|
|
79
83
|
if (logLevel) {
|
|
80
84
|
if (r.error) {
|
|
81
|
-
|
|
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());
|
|
82
86
|
}
|
|
83
87
|
else {
|
|
84
|
-
|
|
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)'));
|
|
85
89
|
}
|
|
86
90
|
}
|
|
87
91
|
if (r.error && !args.noThrow)
|
|
@@ -89,10 +93,11 @@ export class RunCommand extends MultiTaskCommand {
|
|
|
89
93
|
return r;
|
|
90
94
|
}
|
|
91
95
|
}
|
|
96
|
+
exports.RunCommand = RunCommand;
|
|
92
97
|
RunCommand.commandName = 'run';
|
|
93
98
|
(function (RunCommand) {
|
|
94
99
|
RunCommand.cliCommandOptions = {
|
|
95
|
-
...MultiTaskCommand.cliCommandOptions,
|
|
100
|
+
...multi_task_command_js_1.MultiTaskCommand.cliCommandOptions,
|
|
96
101
|
};
|
|
97
102
|
function initCli(repository, program) {
|
|
98
103
|
program.command({
|
|
@@ -114,11 +119,11 @@ RunCommand.commandName = 'run';
|
|
|
114
119
|
}
|
|
115
120
|
});
|
|
116
121
|
}
|
|
117
|
-
const options = Command.composeOptions(RunCommand.commandName, args, repository.config);
|
|
122
|
+
const options = command_js_1.Command.composeOptions(RunCommand.commandName, args, repository.config);
|
|
118
123
|
const script = '' + args.script;
|
|
119
124
|
await new RunCommand(repository, script, options).execute();
|
|
120
125
|
},
|
|
121
126
|
});
|
|
122
127
|
}
|
|
123
128
|
RunCommand.initCli = initCli;
|
|
124
|
-
})(RunCommand || (RunCommand = {}));
|
|
129
|
+
})(RunCommand || (exports.RunCommand = RunCommand = {}));
|