rman 0.28.1 → 0.29.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/bin/rman.mjs +1 -1
- package/cjs/cli.js +18 -18
- package/cjs/commands/build-command.js +3 -8
- package/cjs/commands/changed-command.js +6 -9
- package/cjs/commands/ci-command.js +8 -14
- package/cjs/commands/execute-command.js +23 -27
- package/cjs/commands/info-command.js +15 -21
- package/cjs/commands/list-command.js +32 -35
- package/cjs/commands/multi-task-command.js +13 -15
- package/cjs/commands/publish-command.js +24 -26
- package/cjs/commands/run-command.js +34 -34
- package/cjs/commands/version-command.js +35 -37
- package/cjs/core/command.js +19 -24
- package/cjs/core/logger.js +2 -4
- package/cjs/core/package.js +3 -5
- package/cjs/core/repository.js +9 -11
- package/cjs/index.js +2 -15
- package/cjs/utils/exec.js +7 -8
- package/cjs/utils/file-utils.js +10 -10
- package/cjs/utils/get-dirname.js +6 -9
- package/cjs/utils/git-utils.js +10 -10
- package/cjs/utils/npm-run-path.js +6 -9
- package/cjs/utils/npm-utils.js +3 -2
- package/esm/cli.js +12 -9
- package/esm/commands/build-command.js +3 -8
- package/esm/commands/changed-command.js +6 -9
- package/esm/commands/ci-command.js +4 -8
- package/esm/commands/execute-command.js +20 -22
- package/esm/commands/info-command.js +11 -15
- package/esm/commands/list-command.js +27 -28
- package/esm/commands/multi-task-command.js +11 -11
- package/esm/commands/publish-command.js +20 -20
- package/esm/commands/run-command.js +31 -29
- package/esm/commands/version-command.js +29 -29
- package/esm/core/command.js +13 -16
- package/esm/core/repository.js +3 -3
- package/esm/utils/exec.js +6 -6
- package/esm/utils/file-utils.js +4 -1
- package/esm/utils/get-dirname.js +1 -1
- package/esm/utils/git-utils.js +8 -6
- package/esm/utils/npm-utils.js +3 -2
- package/package.json +6 -54
- package/esm/cli.d.ts +0 -4
- package/esm/commands/build-command.d.ts +0 -11
- package/esm/commands/changed-command.d.ts +0 -16
- package/esm/commands/ci-command.d.ts +0 -24
- package/esm/commands/execute-command.d.ts +0 -19
- package/esm/commands/info-command.d.ts +0 -10
- package/esm/commands/list-command.d.ts +0 -38
- package/esm/commands/multi-task-command.d.ts +0 -22
- package/esm/commands/publish-command.d.ts +0 -22
- package/esm/commands/run-command.d.ts +0 -28
- package/esm/commands/version-command.d.ts +0 -25
- package/esm/core/command.d.ts +0 -35
- package/esm/core/constants.d.ts +0 -1
- package/esm/core/logger.d.ts +0 -12
- package/esm/core/package.d.ts +0 -13
- package/esm/core/repository.d.ts +0 -19
- package/esm/index.d.ts +0 -1
- package/esm/utils/exec.d.ts +0 -19
- package/esm/utils/file-utils.d.ts +0 -5
- package/esm/utils/get-dirname.d.ts +0 -2
- package/esm/utils/git-utils.d.ts +0 -25
- package/esm/utils/npm-run-path.d.ts +0 -67
- package/esm/utils/npm-utils.d.ts +0 -12
package/cjs/utils/git-utils.js
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.GitHelper = void 0;
|
|
7
|
-
const
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const path_1 = tslib_1.__importDefault(require("path"));
|
|
8
6
|
const exec_js_1 = require("./exec.js");
|
|
9
7
|
class GitHelper {
|
|
10
8
|
constructor(options) {
|
|
@@ -13,7 +11,7 @@ class GitHelper {
|
|
|
13
11
|
async listDirtyFileStatus(options) {
|
|
14
12
|
const x = await (0, exec_js_1.exec)('git', {
|
|
15
13
|
cwd: this.cwd,
|
|
16
|
-
argv: ['status', '--porcelain']
|
|
14
|
+
argv: ['status', '--porcelain'],
|
|
17
15
|
});
|
|
18
16
|
const result = [];
|
|
19
17
|
const files = x.stdout ? x.stdout.trim().split(/\s*\n\s*/) : [];
|
|
@@ -22,7 +20,7 @@ class GitHelper {
|
|
|
22
20
|
if (m) {
|
|
23
21
|
result.push({
|
|
24
22
|
filename: options?.absolute ? path_1.default.join(this.cwd, m[2]) : m[2],
|
|
25
|
-
status: m[1]
|
|
23
|
+
status: m[1],
|
|
26
24
|
});
|
|
27
25
|
}
|
|
28
26
|
}
|
|
@@ -34,7 +32,7 @@ class GitHelper {
|
|
|
34
32
|
async listCommitSha() {
|
|
35
33
|
const x = await (0, exec_js_1.exec)('git', {
|
|
36
34
|
cwd: this.cwd,
|
|
37
|
-
argv: ['cherry']
|
|
35
|
+
argv: ['cherry'],
|
|
38
36
|
});
|
|
39
37
|
const matches = x.stdout ? x.stdout.matchAll(/([a-f0-9]+)/gi) : [];
|
|
40
38
|
const result = [];
|
|
@@ -45,13 +43,15 @@ class GitHelper {
|
|
|
45
43
|
}
|
|
46
44
|
async listCommittedFiles(options) {
|
|
47
45
|
const shaArr = options?.commits
|
|
48
|
-
?
|
|
46
|
+
? Array.isArray(options?.commits)
|
|
47
|
+
? options?.commits
|
|
48
|
+
: [options?.commits]
|
|
49
49
|
: await this.listCommitSha();
|
|
50
50
|
let result = [];
|
|
51
51
|
for (const s of shaArr) {
|
|
52
52
|
const x = await (0, exec_js_1.exec)('git', {
|
|
53
53
|
cwd: this.cwd,
|
|
54
|
-
argv: ['show', s, '--name-only', '--pretty="format:"']
|
|
54
|
+
argv: ['show', s, '--name-only', '--pretty="format:"'],
|
|
55
55
|
});
|
|
56
56
|
result.push(...(x.stdout ? x.stdout.trim().split(/\s*\n\s*/) : []));
|
|
57
57
|
}
|
|
@@ -62,7 +62,7 @@ class GitHelper {
|
|
|
62
62
|
async readFileLastPublished(filePath, commitSha) {
|
|
63
63
|
const x = await (0, exec_js_1.exec)('git', {
|
|
64
64
|
cwd: this.cwd,
|
|
65
|
-
argv: ['show', (commitSha || 'HEAD') + ':"' + filePath + '"']
|
|
65
|
+
argv: ['show', (commitSha || 'HEAD') + ':"' + filePath + '"'],
|
|
66
66
|
});
|
|
67
67
|
return x.stdout || '';
|
|
68
68
|
}
|
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
3
|
+
exports.npmRunPath = npmRunPath;
|
|
4
|
+
exports.npmRunPathEnv = npmRunPathEnv;
|
|
5
|
+
const tslib_1 = require("tslib");
|
|
7
6
|
/* eslint-disable max-len */
|
|
8
7
|
/**
|
|
9
8
|
* Inspired from [npm-run-path](https://github.com/sindresorhus/npm-run-path)
|
|
10
9
|
*/
|
|
11
|
-
const path_1 = __importDefault(require("path"));
|
|
12
|
-
const path_key_1 = __importDefault(require("path-key"));
|
|
13
|
-
const process_1 = __importDefault(require("process"));
|
|
10
|
+
const path_1 = tslib_1.__importDefault(require("path"));
|
|
11
|
+
const path_key_1 = tslib_1.__importDefault(require("path-key"));
|
|
12
|
+
const process_1 = tslib_1.__importDefault(require("process"));
|
|
14
13
|
/**
|
|
15
14
|
Get your [PATH](https://en.wikipedia.org/wiki/PATH_(variable)) prepended with locally installed binaries.
|
|
16
15
|
@returns The augmented path string.
|
|
@@ -40,7 +39,6 @@ function npmRunPath(options = {}) {
|
|
|
40
39
|
result.push(path_1.default.resolve(cwd, execPath, '..'));
|
|
41
40
|
return [...result, path_].join(path_1.default.delimiter);
|
|
42
41
|
}
|
|
43
|
-
exports.npmRunPath = npmRunPath;
|
|
44
42
|
/**
|
|
45
43
|
@returns The augmented [`process.env`](https://nodejs.org/api/process.html#process_process_env) object.
|
|
46
44
|
@example
|
|
@@ -60,4 +58,3 @@ function npmRunPathEnv(options = {}) {
|
|
|
60
58
|
env[path_] = npmRunPath(opts);
|
|
61
59
|
return env;
|
|
62
60
|
}
|
|
63
|
-
exports.npmRunPathEnv = npmRunPathEnv;
|
package/cjs/utils/npm-utils.js
CHANGED
|
@@ -12,11 +12,12 @@ class NpmHelper {
|
|
|
12
12
|
async getPackageInfo(packageName) {
|
|
13
13
|
const x = await (0, exec_js_1.exec)('npm', {
|
|
14
14
|
cwd: this.cwd,
|
|
15
|
-
argv: ['view', packageName, '--json']
|
|
15
|
+
argv: ['view', packageName, '--json'],
|
|
16
16
|
});
|
|
17
17
|
if (x && x.stdout) {
|
|
18
|
-
if (x.code && x.stdout.includes('404'))
|
|
18
|
+
if (x.code && x.stdout.includes('404')) {
|
|
19
19
|
return new PackageNotFoundError('Package ' + packageName + ' not found in repository');
|
|
20
|
+
}
|
|
20
21
|
const b = x.stdout.indexOf('{');
|
|
21
22
|
const e = x.stdout.lastIndexOf('}');
|
|
22
23
|
const s = x.stdout.substring(b, e + 1);
|
package/esm/cli.js
CHANGED
|
@@ -2,7 +2,7 @@ import chalk from 'chalk';
|
|
|
2
2
|
import fs from 'fs/promises';
|
|
3
3
|
import logger from 'npmlog';
|
|
4
4
|
import path from 'path';
|
|
5
|
-
import yargs from
|
|
5
|
+
import yargs from 'yargs';
|
|
6
6
|
import { BuildCommand } from './commands/build-command.js';
|
|
7
7
|
import { ChangedCommand } from './commands/changed-command.js';
|
|
8
8
|
import { CleanInstallCommand } from './commands/ci-command.js';
|
|
@@ -21,19 +21,23 @@ export async function runCli(options) {
|
|
|
21
21
|
const pkgJson = JSON.parse(await fs.readFile(s, 'utf-8'));
|
|
22
22
|
const repository = Repository.create(options?.cwd);
|
|
23
23
|
const _argv = options?.argv || process.argv.slice(2);
|
|
24
|
-
const globalKeys = Object.keys(Command.globalOptions).concat([
|
|
24
|
+
const globalKeys = Object.keys(Command.globalOptions).concat(['help', 'version']);
|
|
25
25
|
const program = yargs(_argv)
|
|
26
26
|
// .scriptName('rman')
|
|
27
27
|
.strict()
|
|
28
|
-
.version(pkgJson.version || '')
|
|
28
|
+
.version(pkgJson.version || '')
|
|
29
|
+
.alias('version', 'v')
|
|
29
30
|
.usage('$0 <cmd> [options...]')
|
|
30
|
-
.help('help')
|
|
31
|
+
.help('help')
|
|
32
|
+
.alias('help', 'h')
|
|
31
33
|
.showHelpOnFail(false, 'Run with --help for available options')
|
|
32
34
|
.fail((msg, err) => {
|
|
33
35
|
if (!err?.logged) {
|
|
34
|
-
const text =
|
|
36
|
+
const text = msg
|
|
35
37
|
? msg + '\n\n' + chalk.whiteBright('Run with --help for available options')
|
|
36
|
-
:
|
|
38
|
+
: err
|
|
39
|
+
? err.message
|
|
40
|
+
: '';
|
|
37
41
|
// eslint-disable-next-line no-console
|
|
38
42
|
console.log('\n' + chalk.red(text));
|
|
39
43
|
throw msg;
|
|
@@ -43,7 +47,7 @@ export async function runCli(options) {
|
|
|
43
47
|
})
|
|
44
48
|
// group options under "Global Options:" header
|
|
45
49
|
.options(Command.globalOptions)
|
|
46
|
-
.group(globalKeys,
|
|
50
|
+
.group(globalKeys, 'Global Options:');
|
|
47
51
|
InfoCommand.initCli(repository, program);
|
|
48
52
|
ListCommand.initCli(repository, program);
|
|
49
53
|
ChangedCommand.initCli(repository, program);
|
|
@@ -56,8 +60,7 @@ export async function runCli(options) {
|
|
|
56
60
|
if (!_argv.length)
|
|
57
61
|
program.showHelp();
|
|
58
62
|
else
|
|
59
|
-
await program.parseAsync()
|
|
60
|
-
.catch(() => process.exit(1));
|
|
63
|
+
await program.parseAsync().catch(() => process.exit(1));
|
|
61
64
|
}
|
|
62
65
|
catch (e) {
|
|
63
66
|
logger.error('rman', e);
|
|
@@ -12,16 +12,11 @@ BuildCommand.commandName = 'build';
|
|
|
12
12
|
program.command({
|
|
13
13
|
command: 'build [options...]',
|
|
14
14
|
describe: 'Alias for "run build"',
|
|
15
|
-
builder:
|
|
16
|
-
return cmd
|
|
17
|
-
.example("$0 build", "# Builds packages")
|
|
18
|
-
.option(BuildCommand.cliCommandOptions);
|
|
19
|
-
},
|
|
15
|
+
builder: cmd => cmd.example('$0 build', '# Builds packages').option(BuildCommand.cliCommandOptions),
|
|
20
16
|
handler: async (args) => {
|
|
21
17
|
const options = Command.composeOptions(BuildCommand.commandName, args, repository.config);
|
|
22
|
-
await new BuildCommand(repository, options)
|
|
23
|
-
|
|
24
|
-
}
|
|
18
|
+
await new BuildCommand(repository, options).execute();
|
|
19
|
+
},
|
|
25
20
|
});
|
|
26
21
|
}
|
|
27
22
|
BuildCommand.initCli = initCli;
|
|
@@ -17,17 +17,14 @@ ChangedCommand.commandName = 'changed';
|
|
|
17
17
|
program.command({
|
|
18
18
|
command: 'changed [options...]',
|
|
19
19
|
describe: 'List local packages that have changed since the last tagged release',
|
|
20
|
-
builder:
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
.option(ListCommand.cliCommandOptions);
|
|
25
|
-
},
|
|
20
|
+
builder: cmd => cmd
|
|
21
|
+
.example('$0 changed', '# List changed packages')
|
|
22
|
+
.example('$0 changed --json', '# List changed packages in JSON format')
|
|
23
|
+
.option(ListCommand.cliCommandOptions),
|
|
26
24
|
handler: async (args) => {
|
|
27
25
|
const options = Command.composeOptions(ChangedCommand.commandName, args, repository.config);
|
|
28
|
-
await new ChangedCommand(repository, options)
|
|
29
|
-
|
|
30
|
-
}
|
|
26
|
+
await new ChangedCommand(repository, options).execute();
|
|
27
|
+
},
|
|
31
28
|
});
|
|
32
29
|
}
|
|
33
30
|
ChangedCommand.initCli = initCli;
|
|
@@ -22,7 +22,7 @@ export class CleanInstallCommand extends RunCommand {
|
|
|
22
22
|
await this._fsDelete(path.join(dirname, 'yarn-lock.json'));
|
|
23
23
|
logger.info(this.commandName, chalk.yellow('install'), 'Running ' + client + ' install');
|
|
24
24
|
return super._exec(this.repository.rootPackage, client + ' install', {
|
|
25
|
-
stdio: 'inherit'
|
|
25
|
+
stdio: 'inherit',
|
|
26
26
|
});
|
|
27
27
|
}, { exclusive: true }));
|
|
28
28
|
return tasks;
|
|
@@ -50,21 +50,17 @@ export class CleanInstallCommand extends RunCommand {
|
|
|
50
50
|
CleanInstallCommand.commandName = 'ci';
|
|
51
51
|
(function (CleanInstallCommand) {
|
|
52
52
|
CleanInstallCommand.cliCommandOptions = {
|
|
53
|
-
...RunCommand.cliCommandOptions
|
|
53
|
+
...RunCommand.cliCommandOptions,
|
|
54
54
|
};
|
|
55
55
|
function initCli(repository, program) {
|
|
56
56
|
program.command({
|
|
57
57
|
command: 'ci [...options]',
|
|
58
58
|
describe: 'Deletes all dependency modules and re-installs',
|
|
59
|
-
builder:
|
|
60
|
-
return cmd
|
|
61
|
-
.example("$0 ci", '')
|
|
62
|
-
.option(CleanInstallCommand.cliCommandOptions);
|
|
63
|
-
},
|
|
59
|
+
builder: cmd => cmd.example('$0 ci', '').option(CleanInstallCommand.cliCommandOptions),
|
|
64
60
|
handler: async (args) => {
|
|
65
61
|
const options = Command.composeOptions(CleanInstallCommand.commandName, args, repository.config);
|
|
66
62
|
await new CleanInstallCommand(repository, options).execute();
|
|
67
|
-
}
|
|
63
|
+
},
|
|
68
64
|
});
|
|
69
65
|
}
|
|
70
66
|
CleanInstallCommand.initCli = initCli;
|
|
@@ -20,14 +20,14 @@ export class ExecuteCommand extends MultiTaskCommand {
|
|
|
20
20
|
const r = await exec(this.cmd, {
|
|
21
21
|
cwd: p.dirname,
|
|
22
22
|
argv: this.argv,
|
|
23
|
-
stdio: logger.levelIndex < 1000 ? 'inherit' : 'pipe'
|
|
23
|
+
stdio: logger.levelIndex < 1000 ? 'inherit' : 'pipe',
|
|
24
24
|
});
|
|
25
|
-
logger.log(
|
|
25
|
+
logger.log(r.error ? 'error' : 'info', this.commandName, p.name, r.error ? chalk.red.bold('failed') : chalk.green.bold('success'), logger.separator, this.cmd, chalk.yellow(' (' + (Date.now() - t) + ' ms') + ')');
|
|
26
26
|
}, {
|
|
27
27
|
name: p.name,
|
|
28
28
|
dependencies: this.options.parallel ? undefined : p.dependencies,
|
|
29
29
|
bail: this.options.bail,
|
|
30
|
-
concurrency: this.options.concurrency
|
|
30
|
+
concurrency: this.options.concurrency,
|
|
31
31
|
});
|
|
32
32
|
tasks.push(task);
|
|
33
33
|
}
|
|
@@ -37,34 +37,32 @@ export class ExecuteCommand extends MultiTaskCommand {
|
|
|
37
37
|
ExecuteCommand.commandName = 'exec';
|
|
38
38
|
(function (ExecuteCommand) {
|
|
39
39
|
ExecuteCommand.cliCommandOptions = {
|
|
40
|
-
...MultiTaskCommand.cliCommandOptions
|
|
40
|
+
...MultiTaskCommand.cliCommandOptions,
|
|
41
41
|
};
|
|
42
42
|
function initCli(repository, program) {
|
|
43
43
|
program.command({
|
|
44
44
|
command: 'exec [cmd] [args..]',
|
|
45
45
|
describe: 'Execute an arbitrary command in each package',
|
|
46
|
-
builder:
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
.option(ExecuteCommand.cliCommandOptions);
|
|
62
|
-
},
|
|
46
|
+
builder: cmd => cmd
|
|
47
|
+
.example('$0 exec -- ls', '')
|
|
48
|
+
.example('$0 exec -- rm -rf ./node_modules', '')
|
|
49
|
+
.parserConfiguration({
|
|
50
|
+
'populate--': true,
|
|
51
|
+
})
|
|
52
|
+
.positional('cmd', {
|
|
53
|
+
describe: 'The command to execute. Any command flags must be passed after --',
|
|
54
|
+
type: 'string',
|
|
55
|
+
})
|
|
56
|
+
.positional('args', {
|
|
57
|
+
describe: 'Positional arguments to send to command',
|
|
58
|
+
type: 'string',
|
|
59
|
+
})
|
|
60
|
+
.option(ExecuteCommand.cliCommandOptions),
|
|
63
61
|
handler: async (args) => {
|
|
64
62
|
const argv = args['--'] || [];
|
|
65
63
|
const options = Command.composeOptions(ExecuteCommand.commandName, args, repository.config);
|
|
66
64
|
await new ExecuteCommand(repository, '' + argv.shift(), argv, options).execute();
|
|
67
|
-
}
|
|
65
|
+
},
|
|
68
66
|
});
|
|
69
67
|
}
|
|
70
68
|
ExecuteCommand.initCli = initCli;
|
|
@@ -9,27 +9,28 @@ export class InfoCommand extends Command {
|
|
|
9
9
|
Binaries: ['Node', 'Yarn', 'npm'],
|
|
10
10
|
Utilities: ['Git'],
|
|
11
11
|
npmPackages: ['rman', 'typescript'],
|
|
12
|
-
npmGlobalPackages: ['typescript']
|
|
12
|
+
npmGlobalPackages: ['typescript'],
|
|
13
13
|
}, { json: true }));
|
|
14
14
|
if (this.options.json) {
|
|
15
15
|
this.logger.output('', '%j', systemInfo);
|
|
16
16
|
return;
|
|
17
17
|
}
|
|
18
|
-
const maxName = Object.keys(systemInfo).reduce((l, p) => Object.keys(systemInfo[p]).reduce((i, x) => l = Math.max(i, x.length), l), 0);
|
|
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
20
|
this.logger.output('', '', chalk.whiteBright(categoryName) + ':');
|
|
21
21
|
for (const [n, v] of Object.entries(category)) {
|
|
22
|
-
const label = ' ' + chalk.reset(n) +
|
|
23
|
-
' '.repeat(maxName - n.length) + ' :';
|
|
22
|
+
const label = ' ' + chalk.reset(n) + ' '.repeat(maxName - n.length) + ' :';
|
|
24
23
|
if (typeof v === 'string') {
|
|
25
24
|
this.logger.output('', label, chalk.yellowBright(v));
|
|
26
25
|
continue;
|
|
27
26
|
}
|
|
28
|
-
if (v.version)
|
|
29
|
-
this.logger.output('', label, chalk.yellowBright(v.version),
|
|
27
|
+
if (v.version) {
|
|
28
|
+
this.logger.output('', label, chalk.yellowBright(v.version), v.path ? ' ' + chalk.yellow(v.path) : '');
|
|
29
|
+
}
|
|
30
30
|
if (v.installed) {
|
|
31
|
-
if (v.wanted === 'latest' || semver.intersects(v.installed, v.wanted))
|
|
31
|
+
if (v.wanted === 'latest' || semver.intersects(v.installed, v.wanted)) {
|
|
32
32
|
this.logger.output('', label, chalk.yellowBright(v.installed));
|
|
33
|
+
}
|
|
33
34
|
else
|
|
34
35
|
this.logger.output('', label, chalk.red(v.installed), ' => ', chalk.yellowBright(v.wanted));
|
|
35
36
|
}
|
|
@@ -43,16 +44,11 @@ InfoCommand.commandName = 'info';
|
|
|
43
44
|
program.command({
|
|
44
45
|
command: 'info [options...]',
|
|
45
46
|
describe: 'Prints local environment information',
|
|
46
|
-
builder:
|
|
47
|
-
return cmd
|
|
48
|
-
.example("$0 info", "# Prints information")
|
|
49
|
-
.example('$0 info --json', '# Prints information in JSON format');
|
|
50
|
-
},
|
|
47
|
+
builder: cmd => cmd.example('$0 info', '# Prints information').example('$0 info --json', '# Prints information in JSON format'),
|
|
51
48
|
handler: async (args) => {
|
|
52
49
|
const options = Command.composeOptions(InfoCommand.commandName, args, repository.config);
|
|
53
|
-
await new InfoCommand(options)
|
|
54
|
-
|
|
55
|
-
}
|
|
50
|
+
await new InfoCommand(options).execute();
|
|
51
|
+
},
|
|
56
52
|
});
|
|
57
53
|
}
|
|
58
54
|
InfoCommand.initCli = initCli;
|
|
@@ -40,7 +40,7 @@ export class ListCommand extends Command {
|
|
|
40
40
|
location,
|
|
41
41
|
private: p.isPrivate,
|
|
42
42
|
isDirty,
|
|
43
|
-
isCommitted
|
|
43
|
+
isCommitted,
|
|
44
44
|
};
|
|
45
45
|
o = this.onPrepare ? this.onPrepare(p, o) : o;
|
|
46
46
|
if (!o)
|
|
@@ -49,9 +49,12 @@ export class ListCommand extends Command {
|
|
|
49
49
|
count++;
|
|
50
50
|
if (!this.options.json) {
|
|
51
51
|
if (this.options.parseable) {
|
|
52
|
-
const a = [
|
|
53
|
-
|
|
54
|
-
|
|
52
|
+
const a = [
|
|
53
|
+
location,
|
|
54
|
+
p.name,
|
|
55
|
+
p.version,
|
|
56
|
+
p.isPrivate ? 'PRIVATE' : '',
|
|
57
|
+
isDirty ? 'DIRTY' : isCommitted ? ':COMMITTED' : '',
|
|
55
58
|
];
|
|
56
59
|
logger.output('', a.join('::'));
|
|
57
60
|
}
|
|
@@ -65,8 +68,7 @@ export class ListCommand extends Command {
|
|
|
65
68
|
table.cell('Package', chalk.yellowBright(p.name));
|
|
66
69
|
table.cell('Version', chalk.yellow(p.version));
|
|
67
70
|
table.cell('Private', p.isPrivate ? chalk.magentaBright('yes') : '');
|
|
68
|
-
table.cell('Changed', isDirty ? chalk.magenta('dirty') :
|
|
69
|
-
(isCommitted ? chalk.yellow('committed') : ''));
|
|
71
|
+
table.cell('Changed', isDirty ? chalk.magenta('dirty') : isCommitted ? chalk.yellow('committed') : '');
|
|
70
72
|
table.cell('Path', path.relative(repository.dirname, p.dirname));
|
|
71
73
|
table.newRow();
|
|
72
74
|
}
|
|
@@ -77,11 +79,11 @@ export class ListCommand extends Command {
|
|
|
77
79
|
logger.output('', '%j', obj);
|
|
78
80
|
return obj;
|
|
79
81
|
}
|
|
80
|
-
|
|
82
|
+
if (this.options.json) {
|
|
81
83
|
logger.output('', '%j', arr);
|
|
82
84
|
return arr;
|
|
83
85
|
}
|
|
84
|
-
|
|
86
|
+
if (table.rows.length) {
|
|
85
87
|
logger.output('', '%s', table.toString().trim());
|
|
86
88
|
// eslint-disable-next-line no-console
|
|
87
89
|
console.log('');
|
|
@@ -94,41 +96,38 @@ export class ListCommand extends Command {
|
|
|
94
96
|
ListCommand.commandName = 'list';
|
|
95
97
|
(function (ListCommand) {
|
|
96
98
|
ListCommand.cliCommandOptions = {
|
|
97
|
-
|
|
99
|
+
short: {
|
|
98
100
|
alias: 's',
|
|
99
|
-
describe: '# Do not show extended information'
|
|
101
|
+
describe: '# Do not show extended information',
|
|
100
102
|
},
|
|
101
|
-
|
|
103
|
+
parseable: {
|
|
102
104
|
alias: 'p',
|
|
103
|
-
describe: '# Show parseable output'
|
|
105
|
+
describe: '# Show parseable output',
|
|
104
106
|
},
|
|
105
|
-
|
|
107
|
+
toposort: {
|
|
106
108
|
alias: 't',
|
|
107
|
-
describe: '# Sort packages in topological order (dependencies before dependents) instead of lexical by directory'
|
|
109
|
+
describe: '# Sort packages in topological order (dependencies before dependents) instead of lexical by directory',
|
|
108
110
|
},
|
|
109
|
-
|
|
111
|
+
graph: {
|
|
110
112
|
alias: 'g',
|
|
111
|
-
describe: '# Show dependency graph as a JSON-formatted adjacency list'
|
|
112
|
-
}
|
|
113
|
+
describe: '# Show dependency graph as a JSON-formatted adjacency list',
|
|
114
|
+
},
|
|
113
115
|
};
|
|
114
116
|
function initCli(repository, program) {
|
|
115
117
|
program.command({
|
|
116
118
|
command: 'list [options...]',
|
|
117
119
|
describe: 'Lists packages in repository',
|
|
118
120
|
aliases: ['ls'],
|
|
119
|
-
builder:
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
.option(ListCommand.cliCommandOptions);
|
|
126
|
-
},
|
|
121
|
+
builder: cmd => cmd
|
|
122
|
+
.example('$0 list', '# List all packages')
|
|
123
|
+
.example('$0 list --json', '# List all packages in JSON format')
|
|
124
|
+
.conflicts('graph', ['parseable', 'json'])
|
|
125
|
+
.conflicts('short', ['parseable', 'json'])
|
|
126
|
+
.option(ListCommand.cliCommandOptions),
|
|
127
127
|
handler: async (args) => {
|
|
128
128
|
const options = Command.composeOptions(ListCommand.commandName, args, repository.config);
|
|
129
|
-
await new ListCommand(repository, options)
|
|
130
|
-
|
|
131
|
-
}
|
|
129
|
+
await new ListCommand(repository, options).execute();
|
|
130
|
+
},
|
|
132
131
|
});
|
|
133
132
|
}
|
|
134
133
|
ListCommand.initCli = initCli;
|
|
@@ -34,30 +34,30 @@ export class MultiTaskCommand extends Command {
|
|
|
34
34
|
}
|
|
35
35
|
(function (MultiTaskCommand) {
|
|
36
36
|
MultiTaskCommand.cliCommandOptions = {
|
|
37
|
-
|
|
37
|
+
concurrency: {
|
|
38
38
|
describe: '# Set processes count to parallelize tasks. (CPU count if not defined)',
|
|
39
|
-
type: 'number'
|
|
39
|
+
type: 'number',
|
|
40
40
|
},
|
|
41
|
-
|
|
41
|
+
parallel: {
|
|
42
42
|
describe: '# Disregards dependency checking and runs the command for every package at same time.',
|
|
43
|
-
type: 'boolean'
|
|
43
|
+
type: 'boolean',
|
|
44
44
|
},
|
|
45
45
|
'no-bail': {
|
|
46
46
|
describe: '# Continue execution even one fails.',
|
|
47
|
-
type: 'boolean'
|
|
47
|
+
type: 'boolean',
|
|
48
48
|
},
|
|
49
|
-
|
|
49
|
+
bail: {
|
|
50
50
|
hidden: true,
|
|
51
|
-
type: 'boolean'
|
|
51
|
+
type: 'boolean',
|
|
52
52
|
},
|
|
53
53
|
'no-progress': {
|
|
54
|
-
describe:
|
|
54
|
+
describe: 'Disable progress bars',
|
|
55
55
|
type: 'boolean',
|
|
56
56
|
},
|
|
57
|
-
|
|
57
|
+
progress: {
|
|
58
58
|
hidden: true,
|
|
59
59
|
type: 'boolean',
|
|
60
|
-
default: true
|
|
61
|
-
}
|
|
60
|
+
default: true,
|
|
61
|
+
},
|
|
62
62
|
};
|
|
63
63
|
})(MultiTaskCommand || (MultiTaskCommand = {}));
|
|
@@ -9,7 +9,7 @@ export class PublishCommand extends RunCommand {
|
|
|
9
9
|
super(repository, 'publish', {
|
|
10
10
|
...options,
|
|
11
11
|
bail: false,
|
|
12
|
-
parallel: true
|
|
12
|
+
parallel: true,
|
|
13
13
|
});
|
|
14
14
|
this.repository = repository;
|
|
15
15
|
}
|
|
@@ -25,16 +25,17 @@ export class PublishCommand extends RunCommand {
|
|
|
25
25
|
}
|
|
26
26
|
logger.info(this.commandName, logPkgName, logger.separator, `Fetching package information from repository`);
|
|
27
27
|
const npmHelper = new NpmHelper({ cwd: p.dirname });
|
|
28
|
-
promises.push(npmHelper
|
|
28
|
+
promises.push(npmHelper
|
|
29
|
+
.getPackageInfo(p.json.name)
|
|
29
30
|
.then(r => {
|
|
30
31
|
const sameVersion = !!(r && r.version === p.version);
|
|
31
32
|
if (this.options.checkOnly) {
|
|
32
33
|
logger.info(this.commandName, logPkgName, logger.separator, !r.version
|
|
33
34
|
? chalk.yellow('No package information found in repository')
|
|
34
|
-
:
|
|
35
|
+
: sameVersion
|
|
35
36
|
? `No publish needed. Version (${chalk.magenta(p.version)}) same in repository`
|
|
36
|
-
:
|
|
37
|
-
` Version "${chalk.magenta(p.version)}" differs from version in repository (${chalk.magenta(r.version)})`)
|
|
37
|
+
: `Publishing is possible.` +
|
|
38
|
+
` Version "${chalk.magenta(p.version)}" differs from version in repository (${chalk.magenta(r.version)})`);
|
|
38
39
|
return;
|
|
39
40
|
}
|
|
40
41
|
if (r && r.version === p.version) {
|
|
@@ -45,7 +46,8 @@ export class PublishCommand extends RunCommand {
|
|
|
45
46
|
` Version "${chalk.magenta(p.version)}" differs from version in repository (${chalk.magenta(r.version)})`);
|
|
46
47
|
selectedPackages.push(p);
|
|
47
48
|
}
|
|
48
|
-
})
|
|
49
|
+
})
|
|
50
|
+
.catch(e => {
|
|
49
51
|
if (e.name !== 'PackageNotFoundError')
|
|
50
52
|
throw e;
|
|
51
53
|
}));
|
|
@@ -73,36 +75,34 @@ PublishCommand.commandName = 'publish';
|
|
|
73
75
|
(function (PublishCommand) {
|
|
74
76
|
PublishCommand.cliCommandOptions = {
|
|
75
77
|
...RunCommand.cliCommandOptions,
|
|
76
|
-
|
|
78
|
+
contents: {
|
|
77
79
|
describe: '# Subdirectory to publish',
|
|
78
|
-
type: 'string'
|
|
80
|
+
type: 'string',
|
|
79
81
|
},
|
|
80
|
-
|
|
82
|
+
access: {
|
|
81
83
|
describe: '# Tells the registry whether this package should be published as public or restricted. ' +
|
|
82
|
-
|
|
84
|
+
"Only applies to scoped packages, which default to restricted. If you don't have a paid account, " +
|
|
83
85
|
'you must publish with --access public to publish scoped packages.',
|
|
84
86
|
type: 'string',
|
|
85
|
-
choices: ['public', 'restricted']
|
|
87
|
+
choices: ['public', 'restricted'],
|
|
86
88
|
},
|
|
87
89
|
'check-only': {
|
|
88
90
|
describe: '# Only performs version checking and do not apply "publish" to the registry.',
|
|
89
|
-
type: 'boolean'
|
|
90
|
-
}
|
|
91
|
+
type: 'boolean',
|
|
92
|
+
},
|
|
91
93
|
};
|
|
92
94
|
function initCli(repository, program) {
|
|
93
95
|
program.command({
|
|
94
96
|
command: 'publish [...options]',
|
|
95
97
|
describe: 'Publish packages in the current project',
|
|
96
|
-
builder:
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
.option(PublishCommand.cliCommandOptions);
|
|
101
|
-
},
|
|
98
|
+
builder: cmd => cmd
|
|
99
|
+
.example('$0 publish', '')
|
|
100
|
+
.example('$0 publish --contents dist', '# publish package from built directory')
|
|
101
|
+
.option(PublishCommand.cliCommandOptions),
|
|
102
102
|
handler: async (args) => {
|
|
103
103
|
const options = Command.composeOptions(PublishCommand.commandName, args, repository.config);
|
|
104
104
|
await new PublishCommand(repository, options).execute();
|
|
105
|
-
}
|
|
105
|
+
},
|
|
106
106
|
});
|
|
107
107
|
}
|
|
108
108
|
PublishCommand.initCli = initCli;
|