rman 0.30.0 → 0.31.1
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/package.json +3 -0
- package/esm/cli.js +36 -40
- package/esm/commands/build-command.js +5 -9
- package/esm/commands/changed-command.js +6 -10
- package/esm/commands/ci-command.js +23 -28
- package/esm/commands/execute-command.js +15 -20
- package/esm/commands/info-command.js +15 -20
- package/esm/commands/list-command.js +25 -30
- package/esm/commands/multi-task-command.js +11 -16
- package/esm/commands/publish-command.js +23 -28
- package/esm/commands/run-command.js +19 -24
- package/esm/commands/version-command.js +30 -35
- package/esm/core/command.js +18 -23
- package/esm/core/constants.js +1 -4
- package/esm/core/logger.js +2 -5
- package/esm/core/package.js +6 -11
- package/esm/core/repository.js +28 -33
- package/esm/index.js +1 -4
- package/esm/package.json +3 -0
- package/esm/utils/exec.js +7 -10
- package/esm/utils/file-utils.js +11 -17
- package/esm/utils/get-dirname.js +8 -13
- package/esm/utils/git-utils.js +9 -14
- package/esm/utils/npm-run-path.js +15 -20
- package/esm/utils/npm-utils.js +4 -9
- package/package.json +18 -10
- package/types/commands/build-command.d.ts +1 -1
- package/types/commands/changed-command.d.ts +1 -1
- package/types/commands/ci-command.d.ts +1 -1
- package/types/commands/execute-command.d.ts +1 -1
- package/types/commands/info-command.d.ts +1 -1
- package/types/commands/list-command.d.ts +1 -1
- package/types/commands/multi-task-command.d.ts +1 -1
- package/types/commands/publish-command.d.ts +1 -1
- package/types/commands/run-command.d.ts +1 -1
- package/types/commands/version-command.d.ts +1 -1
- package/types/core/command.d.ts +1 -1
package/cjs/package.json
ADDED
package/esm/cli.js
CHANGED
|
@@ -1,32 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const command_js_1 = require("./core/command.js");
|
|
20
|
-
const repository_js_1 = require("./core/repository.js");
|
|
21
|
-
const get_dirname_js_1 = require("./utils/get-dirname.js");
|
|
22
|
-
async function runCli(options) {
|
|
1
|
+
import colors from 'ansi-colors';
|
|
2
|
+
import fs from 'fs/promises';
|
|
3
|
+
import logger from 'npmlog';
|
|
4
|
+
import path from 'path';
|
|
5
|
+
import yargs from 'yargs';
|
|
6
|
+
import { BuildCommand } from './commands/build-command.js';
|
|
7
|
+
import { ChangedCommand } from './commands/changed-command.js';
|
|
8
|
+
import { CleanInstallCommand } from './commands/ci-command.js';
|
|
9
|
+
import { ExecuteCommand } from './commands/execute-command.js';
|
|
10
|
+
import { InfoCommand } from './commands/info-command.js';
|
|
11
|
+
import { ListCommand } from './commands/list-command.js';
|
|
12
|
+
import { PublishCommand } from './commands/publish-command.js';
|
|
13
|
+
import { RunCommand } from './commands/run-command.js';
|
|
14
|
+
import { VersionCommand } from './commands/version-command.js';
|
|
15
|
+
import { Command } from './core/command.js';
|
|
16
|
+
import { Repository } from './core/repository.js';
|
|
17
|
+
import { getDirname } from './utils/get-dirname.js';
|
|
18
|
+
export async function runCli(options) {
|
|
23
19
|
try {
|
|
24
|
-
const s =
|
|
25
|
-
const pkgJson = JSON.parse(await
|
|
26
|
-
const repository =
|
|
20
|
+
const s = path.resolve(getDirname(), '../package.json');
|
|
21
|
+
const pkgJson = JSON.parse(await fs.readFile(s, 'utf-8'));
|
|
22
|
+
const repository = Repository.create(options?.cwd);
|
|
27
23
|
const _argv = options?.argv || process.argv.slice(2);
|
|
28
|
-
const globalKeys = Object.keys(
|
|
29
|
-
const program = (
|
|
24
|
+
const globalKeys = Object.keys(Command.globalOptions).concat(['help', 'version']);
|
|
25
|
+
const program = yargs(_argv)
|
|
30
26
|
// .scriptName('rman')
|
|
31
27
|
.strict()
|
|
32
28
|
.version(pkgJson.version || '')
|
|
@@ -38,35 +34,35 @@ async function runCli(options) {
|
|
|
38
34
|
.fail((msg, err) => {
|
|
39
35
|
if (!err?.logged) {
|
|
40
36
|
const text = msg
|
|
41
|
-
? msg + '\n\n' +
|
|
37
|
+
? msg + '\n\n' + colors.whiteBright('Run with --help for available options')
|
|
42
38
|
: err
|
|
43
39
|
? err.message
|
|
44
40
|
: '';
|
|
45
41
|
// eslint-disable-next-line no-console
|
|
46
|
-
console.log('\n' +
|
|
42
|
+
console.log('\n' + colors.red(text));
|
|
47
43
|
throw msg;
|
|
48
44
|
}
|
|
49
45
|
else
|
|
50
46
|
process.exit(1);
|
|
51
47
|
})
|
|
52
48
|
// group options under "Global Options:" header
|
|
53
|
-
.options(
|
|
49
|
+
.options(Command.globalOptions)
|
|
54
50
|
.group(globalKeys, 'Global Options:');
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
51
|
+
InfoCommand.initCli(repository, program);
|
|
52
|
+
ListCommand.initCli(repository, program);
|
|
53
|
+
ChangedCommand.initCli(repository, program);
|
|
54
|
+
ExecuteCommand.initCli(repository, program);
|
|
55
|
+
RunCommand.initCli(repository, program);
|
|
56
|
+
VersionCommand.initCli(repository, program);
|
|
57
|
+
PublishCommand.initCli(repository, program);
|
|
58
|
+
CleanInstallCommand.initCli(repository, program);
|
|
59
|
+
BuildCommand.initCli(repository, program);
|
|
64
60
|
if (!_argv.length)
|
|
65
61
|
program.showHelp();
|
|
66
62
|
else
|
|
67
63
|
await program.parseAsync().catch(() => process.exit(1));
|
|
68
64
|
}
|
|
69
65
|
catch (e) {
|
|
70
|
-
|
|
66
|
+
logger.error('rman', e);
|
|
71
67
|
}
|
|
72
68
|
}
|
|
@@ -1,15 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const command_js_1 = require("../core/command.js");
|
|
5
|
-
const run_command_js_1 = require("./run-command.js");
|
|
6
|
-
class BuildCommand extends run_command_js_1.RunCommand {
|
|
1
|
+
import { Command } from '../core/command.js';
|
|
2
|
+
import { RunCommand } from './run-command.js';
|
|
3
|
+
export class BuildCommand extends RunCommand {
|
|
7
4
|
constructor(repository, options) {
|
|
8
5
|
super(repository, 'build', options);
|
|
9
6
|
this.repository = repository;
|
|
10
7
|
}
|
|
11
8
|
}
|
|
12
|
-
exports.BuildCommand = BuildCommand;
|
|
13
9
|
BuildCommand.commandName = 'build';
|
|
14
10
|
(function (BuildCommand) {
|
|
15
11
|
function initCli(repository, program) {
|
|
@@ -18,10 +14,10 @@ BuildCommand.commandName = 'build';
|
|
|
18
14
|
describe: 'Alias for "run build"',
|
|
19
15
|
builder: cmd => cmd.example('$0 build', '# Builds packages').option(BuildCommand.cliCommandOptions),
|
|
20
16
|
handler: async (args) => {
|
|
21
|
-
const options =
|
|
17
|
+
const options = Command.composeOptions(BuildCommand.commandName, args, repository.config);
|
|
22
18
|
await new BuildCommand(repository, options).execute();
|
|
23
19
|
},
|
|
24
20
|
});
|
|
25
21
|
}
|
|
26
22
|
BuildCommand.initCli = initCli;
|
|
27
|
-
})(BuildCommand || (
|
|
23
|
+
})(BuildCommand || (BuildCommand = {}));
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const command_js_1 = require("../core/command.js");
|
|
5
|
-
const list_command_js_1 = require("./list-command.js");
|
|
6
|
-
class ChangedCommand extends list_command_js_1.ListCommand {
|
|
1
|
+
import { Command } from '../core/command.js';
|
|
2
|
+
import { ListCommand } from './list-command.js';
|
|
3
|
+
export class ChangedCommand extends ListCommand {
|
|
7
4
|
constructor(repository, options) {
|
|
8
5
|
super(repository, options);
|
|
9
6
|
this.repository = repository;
|
|
@@ -14,7 +11,6 @@ class ChangedCommand extends list_command_js_1.ListCommand {
|
|
|
14
11
|
return !!(inf.isDirty || inf.isCommitted);
|
|
15
12
|
}
|
|
16
13
|
}
|
|
17
|
-
exports.ChangedCommand = ChangedCommand;
|
|
18
14
|
ChangedCommand.commandName = 'changed';
|
|
19
15
|
(function (ChangedCommand) {
|
|
20
16
|
function initCli(repository, program) {
|
|
@@ -24,12 +20,12 @@ ChangedCommand.commandName = 'changed';
|
|
|
24
20
|
builder: cmd => cmd
|
|
25
21
|
.example('$0 changed', '# List changed packages')
|
|
26
22
|
.example('$0 changed --json', '# List changed packages in JSON format')
|
|
27
|
-
.option(
|
|
23
|
+
.option(ListCommand.cliCommandOptions),
|
|
28
24
|
handler: async (args) => {
|
|
29
|
-
const options =
|
|
25
|
+
const options = Command.composeOptions(ChangedCommand.commandName, args, repository.config);
|
|
30
26
|
await new ChangedCommand(repository, options).execute();
|
|
31
27
|
},
|
|
32
28
|
});
|
|
33
29
|
}
|
|
34
30
|
ChangedCommand.initCli = initCli;
|
|
35
|
-
})(ChangedCommand || (
|
|
31
|
+
})(ChangedCommand || (ChangedCommand = {}));
|
|
@@ -1,15 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const command_js_1 = require("../core/command.js");
|
|
10
|
-
const file_utils_js_1 = require("../utils/file-utils.js");
|
|
11
|
-
const run_command_js_1 = require("./run-command.js");
|
|
12
|
-
class CleanInstallCommand extends run_command_js_1.RunCommand {
|
|
1
|
+
import colors from 'ansi-colors';
|
|
2
|
+
import logger from 'npmlog';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import { Task } from 'power-tasks';
|
|
5
|
+
import { Command } from '../core/command.js';
|
|
6
|
+
import { fsDelete, fsExists } from '../utils/file-utils.js';
|
|
7
|
+
import { RunCommand } from './run-command.js';
|
|
8
|
+
export class CleanInstallCommand extends RunCommand {
|
|
13
9
|
constructor(repository, options) {
|
|
14
10
|
super(repository, 'ci', options);
|
|
15
11
|
this.repository = repository;
|
|
@@ -19,12 +15,12 @@ class CleanInstallCommand extends run_command_js_1.RunCommand {
|
|
|
19
15
|
const client = this.repository.config.client || 'npm';
|
|
20
16
|
if (!(client === 'npm' || client === 'yargs'))
|
|
21
17
|
throw new Error(`Invalid npm client "${client}"`);
|
|
22
|
-
tasks.push(new
|
|
18
|
+
tasks.push(new Task(async () => {
|
|
23
19
|
const dirname = this.repository.dirname;
|
|
24
|
-
await this._fsDelete(
|
|
25
|
-
await this._fsDelete(
|
|
26
|
-
await this._fsDelete(
|
|
27
|
-
|
|
20
|
+
await this._fsDelete(path.join(dirname, 'node_modules'));
|
|
21
|
+
await this._fsDelete(path.join(dirname, 'package-lock.json'));
|
|
22
|
+
await this._fsDelete(path.join(dirname, 'yarn-lock.json'));
|
|
23
|
+
logger.info(this.commandName, colors.yellow('install'), 'Running ' + client + ' install');
|
|
28
24
|
return super._exec(this.repository.rootPackage, client + ' install', {
|
|
29
25
|
stdio: 'inherit',
|
|
30
26
|
});
|
|
@@ -35,27 +31,26 @@ class CleanInstallCommand extends run_command_js_1.RunCommand {
|
|
|
35
31
|
if (command === '#') {
|
|
36
32
|
if (pkg === this.repository.rootPackage)
|
|
37
33
|
return { code: 0 };
|
|
38
|
-
|
|
34
|
+
logger.info(this.commandName, 'Clearing ' + pkg.name);
|
|
39
35
|
const cwd = args.cwd || pkg.dirname;
|
|
40
|
-
await this._fsDelete(
|
|
41
|
-
await this._fsDelete(
|
|
42
|
-
await this._fsDelete(
|
|
36
|
+
await this._fsDelete(path.join(cwd, 'node_modules'));
|
|
37
|
+
await this._fsDelete(path.join(cwd, 'package-lock.json'));
|
|
38
|
+
await this._fsDelete(path.join(cwd, 'yarn-lock.json'));
|
|
43
39
|
return { code: 0 };
|
|
44
40
|
}
|
|
45
41
|
return super._exec(pkg, command, args, ctx);
|
|
46
42
|
}
|
|
47
43
|
async _fsDelete(fileOrDir) {
|
|
48
|
-
if (await
|
|
49
|
-
|
|
50
|
-
await
|
|
44
|
+
if (await fsExists(fileOrDir)) {
|
|
45
|
+
logger.info(this.commandName, colors.yellow('rmdir'), path.relative(this.repository.dirname, fileOrDir));
|
|
46
|
+
await fsDelete(fileOrDir);
|
|
51
47
|
}
|
|
52
48
|
}
|
|
53
49
|
}
|
|
54
|
-
exports.CleanInstallCommand = CleanInstallCommand;
|
|
55
50
|
CleanInstallCommand.commandName = 'ci';
|
|
56
51
|
(function (CleanInstallCommand) {
|
|
57
52
|
CleanInstallCommand.cliCommandOptions = {
|
|
58
|
-
...
|
|
53
|
+
...RunCommand.cliCommandOptions,
|
|
59
54
|
};
|
|
60
55
|
function initCli(repository, program) {
|
|
61
56
|
program.command({
|
|
@@ -63,10 +58,10 @@ CleanInstallCommand.commandName = 'ci';
|
|
|
63
58
|
describe: 'Deletes all dependency modules and re-installs',
|
|
64
59
|
builder: cmd => cmd.example('$0 ci', '').option(CleanInstallCommand.cliCommandOptions),
|
|
65
60
|
handler: async (args) => {
|
|
66
|
-
const options =
|
|
61
|
+
const options = Command.composeOptions(CleanInstallCommand.commandName, args, repository.config);
|
|
67
62
|
await new CleanInstallCommand(repository, options).execute();
|
|
68
63
|
},
|
|
69
64
|
});
|
|
70
65
|
}
|
|
71
66
|
CleanInstallCommand.initCli = initCli;
|
|
72
|
-
})(CleanInstallCommand || (
|
|
67
|
+
})(CleanInstallCommand || (CleanInstallCommand = {}));
|
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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 {
|
|
1
|
+
import colors from 'ansi-colors';
|
|
2
|
+
import logger from 'npmlog';
|
|
3
|
+
import { Task } from 'power-tasks';
|
|
4
|
+
import { Command } from '../core/command.js';
|
|
5
|
+
import { exec } from '../utils/exec.js';
|
|
6
|
+
import { MultiTaskCommand } from './multi-task-command.js';
|
|
7
|
+
export class ExecuteCommand extends MultiTaskCommand {
|
|
12
8
|
constructor(repository, cmd, argv, options) {
|
|
13
9
|
super(repository, options);
|
|
14
10
|
this.repository = repository;
|
|
@@ -18,15 +14,15 @@ class ExecuteCommand extends multi_task_command_js_1.MultiTaskCommand {
|
|
|
18
14
|
_prepareTasks(packages) {
|
|
19
15
|
const tasks = [];
|
|
20
16
|
for (const p of packages) {
|
|
21
|
-
const task = new
|
|
17
|
+
const task = new Task(async () => {
|
|
22
18
|
const t = Date.now();
|
|
23
|
-
|
|
24
|
-
const r = await
|
|
19
|
+
logger.verbose(this.commandName, p.name, colors.cyanBright.bold('executing'), logger.separator, this.cmd + ' ' + (this.argv?.join(' ') || ''));
|
|
20
|
+
const r = await exec(this.cmd, {
|
|
25
21
|
cwd: p.dirname,
|
|
26
22
|
argv: this.argv,
|
|
27
|
-
stdio:
|
|
23
|
+
stdio: logger.levelIndex < 1000 ? 'inherit' : 'pipe',
|
|
28
24
|
});
|
|
29
|
-
|
|
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') + ')');
|
|
30
26
|
}, {
|
|
31
27
|
name: p.name,
|
|
32
28
|
dependencies: this.options.parallel ? undefined : p.dependencies,
|
|
@@ -38,11 +34,10 @@ class ExecuteCommand extends multi_task_command_js_1.MultiTaskCommand {
|
|
|
38
34
|
return tasks;
|
|
39
35
|
}
|
|
40
36
|
}
|
|
41
|
-
exports.ExecuteCommand = ExecuteCommand;
|
|
42
37
|
ExecuteCommand.commandName = 'exec';
|
|
43
38
|
(function (ExecuteCommand) {
|
|
44
39
|
ExecuteCommand.cliCommandOptions = {
|
|
45
|
-
...
|
|
40
|
+
...MultiTaskCommand.cliCommandOptions,
|
|
46
41
|
};
|
|
47
42
|
function initCli(repository, program) {
|
|
48
43
|
program.command({
|
|
@@ -65,10 +60,10 @@ ExecuteCommand.commandName = 'exec';
|
|
|
65
60
|
.option(ExecuteCommand.cliCommandOptions),
|
|
66
61
|
handler: async (args) => {
|
|
67
62
|
const argv = args['--'] || [];
|
|
68
|
-
const options =
|
|
63
|
+
const options = Command.composeOptions(ExecuteCommand.commandName, args, repository.config);
|
|
69
64
|
await new ExecuteCommand(repository, '' + argv.shift(), argv, options).execute();
|
|
70
65
|
},
|
|
71
66
|
});
|
|
72
67
|
}
|
|
73
68
|
ExecuteCommand.initCli = initCli;
|
|
74
|
-
})(ExecuteCommand || (
|
|
69
|
+
})(ExecuteCommand || (ExecuteCommand = {}));
|
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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 {
|
|
1
|
+
import colors from 'ansi-colors';
|
|
2
|
+
import envinfo from 'envinfo';
|
|
3
|
+
import semver from 'semver';
|
|
4
|
+
import { Command } from '../core/command.js';
|
|
5
|
+
export class InfoCommand extends Command {
|
|
10
6
|
async _execute() {
|
|
11
|
-
const systemInfo = JSON.parse(await
|
|
7
|
+
const systemInfo = JSON.parse(await envinfo.run({
|
|
12
8
|
System: ['OS', 'CPU', 'Memory', 'Shell'],
|
|
13
9
|
Binaries: ['Node', 'Yarn', 'npm'],
|
|
14
10
|
Utilities: ['Git'],
|
|
@@ -21,28 +17,27 @@ class InfoCommand extends command_js_1.Command {
|
|
|
21
17
|
}
|
|
22
18
|
const maxName = Object.keys(systemInfo).reduce((l, p) => Object.keys(systemInfo[p]).reduce((i, x) => (l = Math.max(i, x.length)), l), 0);
|
|
23
19
|
for (const [categoryName, category] of Object.entries(systemInfo)) {
|
|
24
|
-
this.logger.output('', '',
|
|
20
|
+
this.logger.output('', '', colors.whiteBright(categoryName) + ':');
|
|
25
21
|
for (const [n, v] of Object.entries(category)) {
|
|
26
|
-
const label = ' ' +
|
|
22
|
+
const label = ' ' + colors.reset(n) + ' '.repeat(maxName - n.length) + ' :';
|
|
27
23
|
if (typeof v === 'string') {
|
|
28
|
-
this.logger.output('', label,
|
|
24
|
+
this.logger.output('', label, colors.yellowBright(v));
|
|
29
25
|
continue;
|
|
30
26
|
}
|
|
31
27
|
if (v.version) {
|
|
32
|
-
this.logger.output('', label,
|
|
28
|
+
this.logger.output('', label, colors.yellowBright(v.version), v.path ? ' ' + colors.yellow(v.path) : '');
|
|
33
29
|
}
|
|
34
30
|
if (v.installed) {
|
|
35
|
-
if (v.wanted === 'latest' ||
|
|
36
|
-
this.logger.output('', label,
|
|
31
|
+
if (v.wanted === 'latest' || semver.intersects(v.installed, v.wanted)) {
|
|
32
|
+
this.logger.output('', label, colors.yellowBright(v.installed));
|
|
37
33
|
}
|
|
38
34
|
else
|
|
39
|
-
this.logger.output('', label,
|
|
35
|
+
this.logger.output('', label, colors.red(v.installed), ' => ', colors.yellowBright(v.wanted));
|
|
40
36
|
}
|
|
41
37
|
}
|
|
42
38
|
}
|
|
43
39
|
}
|
|
44
40
|
}
|
|
45
|
-
exports.InfoCommand = InfoCommand;
|
|
46
41
|
InfoCommand.commandName = 'info';
|
|
47
42
|
(function (InfoCommand) {
|
|
48
43
|
function initCli(repository, program) {
|
|
@@ -51,10 +46,10 @@ InfoCommand.commandName = 'info';
|
|
|
51
46
|
describe: 'Prints local environment information',
|
|
52
47
|
builder: cmd => cmd.example('$0 info', '# Prints information').example('$0 info --json', '# Prints information in JSON format'),
|
|
53
48
|
handler: async (args) => {
|
|
54
|
-
const options =
|
|
49
|
+
const options = Command.composeOptions(InfoCommand.commandName, args, repository.config);
|
|
55
50
|
await new InfoCommand(options).execute();
|
|
56
51
|
},
|
|
57
52
|
});
|
|
58
53
|
}
|
|
59
54
|
InfoCommand.initCli = initCli;
|
|
60
|
-
})(InfoCommand || (
|
|
55
|
+
})(InfoCommand || (InfoCommand = {}));
|
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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 {
|
|
1
|
+
import colors from 'ansi-colors';
|
|
2
|
+
import EasyTable from 'easy-table';
|
|
3
|
+
import logger from 'npmlog';
|
|
4
|
+
import path from 'path';
|
|
5
|
+
import { Command } from '../core/command.js';
|
|
6
|
+
import { GitHelper } from '../utils/git-utils.js';
|
|
7
|
+
export class ListCommand extends Command {
|
|
12
8
|
constructor(repository, options) {
|
|
13
9
|
super(options);
|
|
14
10
|
this.repository = repository;
|
|
@@ -20,16 +16,16 @@ class ListCommand extends command_js_1.Command {
|
|
|
20
16
|
async _execute() {
|
|
21
17
|
const { repository } = this;
|
|
22
18
|
const packages = repository.getPackages({ toposort: this.options.toposort });
|
|
23
|
-
const git = new
|
|
19
|
+
const git = new GitHelper({ cwd: repository.dirname });
|
|
24
20
|
const dirtyFiles = await git.listDirtyFiles({ absolute: true });
|
|
25
21
|
const committedFiles = await git.listCommittedFiles({ absolute: true });
|
|
26
|
-
const table = new
|
|
22
|
+
const table = new EasyTable();
|
|
27
23
|
const arr = [];
|
|
28
24
|
const obj = {};
|
|
29
25
|
let count = 0;
|
|
30
26
|
for (const p of packages) {
|
|
31
|
-
const isDirty = !!dirtyFiles.find(f => !
|
|
32
|
-
const isCommitted = !!committedFiles.find(f => !
|
|
27
|
+
const isDirty = !!dirtyFiles.find(f => !path.relative(p.dirname, f).startsWith('..'));
|
|
28
|
+
const isCommitted = !!committedFiles.find(f => !path.relative(p.dirname, f).startsWith('..'));
|
|
33
29
|
if (!this._filter(p, { isDirty, isCommitted }))
|
|
34
30
|
continue;
|
|
35
31
|
if (this.options.graph) {
|
|
@@ -37,7 +33,7 @@ class ListCommand extends command_js_1.Command {
|
|
|
37
33
|
obj[p.name] = [...p.dependencies];
|
|
38
34
|
continue;
|
|
39
35
|
}
|
|
40
|
-
const location =
|
|
36
|
+
const location = path.relative(repository.dirname, p.dirname);
|
|
41
37
|
let o = {
|
|
42
38
|
name: p.name,
|
|
43
39
|
version: p.version,
|
|
@@ -60,44 +56,43 @@ class ListCommand extends command_js_1.Command {
|
|
|
60
56
|
p.isPrivate ? 'PRIVATE' : '',
|
|
61
57
|
isDirty ? 'DIRTY' : isCommitted ? ':COMMITTED' : '',
|
|
62
58
|
];
|
|
63
|
-
|
|
59
|
+
logger.output('', a.join('::'));
|
|
64
60
|
}
|
|
65
61
|
else if (this.options.short) {
|
|
66
|
-
|
|
62
|
+
logger.output('', p.name);
|
|
67
63
|
}
|
|
68
64
|
else {
|
|
69
65
|
if (this.onPrintTable)
|
|
70
66
|
this.onPrintTable(p, o, table);
|
|
71
67
|
else {
|
|
72
|
-
table.cell('Package',
|
|
73
|
-
table.cell('Version',
|
|
74
|
-
table.cell('Private', p.isPrivate ?
|
|
75
|
-
table.cell('Changed', isDirty ?
|
|
76
|
-
table.cell('Path',
|
|
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
|
+
table.cell('Path', path.relative(repository.dirname, p.dirname));
|
|
77
73
|
table.newRow();
|
|
78
74
|
}
|
|
79
75
|
}
|
|
80
76
|
}
|
|
81
77
|
}
|
|
82
78
|
if (this.options.graph) {
|
|
83
|
-
|
|
79
|
+
logger.output('', '%j', obj);
|
|
84
80
|
return obj;
|
|
85
81
|
}
|
|
86
82
|
if (this.options.json) {
|
|
87
|
-
|
|
83
|
+
logger.output('', '%j', arr);
|
|
88
84
|
return arr;
|
|
89
85
|
}
|
|
90
86
|
if (table.rows.length) {
|
|
91
|
-
|
|
87
|
+
logger.output('', '%s', table.toString().trim());
|
|
92
88
|
// eslint-disable-next-line no-console
|
|
93
89
|
console.log('');
|
|
94
|
-
|
|
90
|
+
logger.info('list', '%i Package(s) found', count);
|
|
95
91
|
return arr;
|
|
96
92
|
}
|
|
97
93
|
return arr;
|
|
98
94
|
}
|
|
99
95
|
}
|
|
100
|
-
exports.ListCommand = ListCommand;
|
|
101
96
|
ListCommand.commandName = 'list';
|
|
102
97
|
(function (ListCommand) {
|
|
103
98
|
ListCommand.cliCommandOptions = {
|
|
@@ -130,10 +125,10 @@ ListCommand.commandName = 'list';
|
|
|
130
125
|
.conflicts('short', ['parseable', 'json'])
|
|
131
126
|
.option(ListCommand.cliCommandOptions),
|
|
132
127
|
handler: async (args) => {
|
|
133
|
-
const options =
|
|
128
|
+
const options = Command.composeOptions(ListCommand.commandName, args, repository.config);
|
|
134
129
|
await new ListCommand(repository, options).execute();
|
|
135
130
|
},
|
|
136
131
|
});
|
|
137
132
|
}
|
|
138
133
|
ListCommand.initCli = initCli;
|
|
139
|
-
})(ListCommand || (
|
|
134
|
+
})(ListCommand || (ListCommand = {}));
|
|
@@ -1,20 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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 {
|
|
1
|
+
import os from 'os';
|
|
2
|
+
import { Task } from 'power-tasks';
|
|
3
|
+
import { toNumber } from 'putil-varhelpers';
|
|
4
|
+
import { Command } from '../core/command.js';
|
|
5
|
+
import { isTTY } from '../core/constants.js';
|
|
6
|
+
export class MultiTaskCommand extends Command {
|
|
11
7
|
constructor(repository, options) {
|
|
12
8
|
super(options);
|
|
13
9
|
this.repository = repository;
|
|
14
|
-
if (this.options.ci || !
|
|
10
|
+
if (this.options.ci || !isTTY)
|
|
15
11
|
this.options.progress = false;
|
|
16
12
|
// noinspection SuspiciousTypeOfGuard
|
|
17
|
-
this.options.concurrency =
|
|
13
|
+
this.options.concurrency = toNumber(options?.concurrency);
|
|
18
14
|
if (this.options.bail == null)
|
|
19
15
|
this.options.bail = true;
|
|
20
16
|
}
|
|
@@ -25,9 +21,9 @@ class MultiTaskCommand extends command_js_1.Command {
|
|
|
25
21
|
return;
|
|
26
22
|
}
|
|
27
23
|
// this.enableProgress();
|
|
28
|
-
this._task = new
|
|
24
|
+
this._task = new Task(childTasks, {
|
|
29
25
|
name: '$project-root',
|
|
30
|
-
concurrency: this.options.concurrency ||
|
|
26
|
+
concurrency: this.options.concurrency || os.cpus().length,
|
|
31
27
|
bail: this.options.bail,
|
|
32
28
|
});
|
|
33
29
|
await this._task.toPromise();
|
|
@@ -36,7 +32,6 @@ class MultiTaskCommand extends command_js_1.Command {
|
|
|
36
32
|
return this.repository.getPackages({ toposort: !this.options.parallel });
|
|
37
33
|
}
|
|
38
34
|
}
|
|
39
|
-
exports.MultiTaskCommand = MultiTaskCommand;
|
|
40
35
|
(function (MultiTaskCommand) {
|
|
41
36
|
MultiTaskCommand.cliCommandOptions = {
|
|
42
37
|
concurrency: {
|
|
@@ -65,4 +60,4 @@ exports.MultiTaskCommand = MultiTaskCommand;
|
|
|
65
60
|
default: true,
|
|
66
61
|
},
|
|
67
62
|
};
|
|
68
|
-
})(MultiTaskCommand || (
|
|
63
|
+
})(MultiTaskCommand || (MultiTaskCommand = {}));
|