rman 0.16.0 → 0.17.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 +43 -37
- package/cjs/commands/multi-task-command.js +1 -3
- package/cjs/commands/publish-command.js +29 -9
- package/cjs/commands/run-command.js +1 -1
- package/cjs/core/command.js +3 -4
- package/cjs/{utils → core}/constants.js +0 -0
- package/cjs/core/repository.js +2 -2
- package/cjs/debug.js +2 -2
- package/cjs/utils/file-utils.js +1 -2
- package/cjs/{utils.js → utils/get-dirname.js} +0 -0
- package/esm/cli.js +60 -0
- package/esm/commands/{build-command.mjs → build-command.js} +2 -2
- package/esm/commands/{changed-command.mjs → changed-command.js} +2 -2
- package/esm/commands/{ci-command.mjs → ci-command.js} +3 -3
- package/esm/commands/{execute-command.mjs → execute-command.js} +3 -3
- package/esm/commands/{info-command.mjs → info-command.js} +1 -1
- package/esm/commands/{list-command.mjs → list-command.js} +2 -2
- package/esm/commands/{multi-task-command.mjs → multi-task-command.js} +2 -4
- package/esm/commands/publish-command.d.ts +1 -0
- package/esm/commands/{publish-command.mjs → publish-command.js} +32 -12
- package/esm/commands/{run-command.mjs → run-command.js} +4 -4
- package/esm/commands/{version-command.mjs → version-command.js} +3 -3
- package/esm/core/{command.mjs → command.js} +4 -5
- package/esm/{utils → core}/constants.d.ts +0 -0
- package/esm/{utils/constants.mjs → core/constants.js} +0 -0
- package/esm/core/{logger.mjs → logger.js} +0 -0
- package/esm/core/{package.mjs → package.js} +0 -0
- package/esm/core/{repository.mjs → repository.js} +2 -2
- package/esm/core/{types.mjs → types.js} +0 -0
- package/esm/debug.js +3 -0
- package/esm/index.js +1 -0
- package/esm/utils/{exec.mjs → exec.js} +1 -1
- package/esm/utils/file-utils.d.ts +0 -2
- package/esm/utils/{file-utils.mjs → file-utils.js} +0 -1
- package/esm/{utils.d.ts → utils/get-dirname.d.ts} +0 -0
- package/esm/{utils.mjs → utils/get-dirname.js} +0 -0
- package/esm/utils/{git-utils.mjs → git-utils.js} +1 -1
- package/esm/utils/{npm-run-path.mjs → npm-run-path.js} +0 -0
- package/esm/utils/{npm-utils.mjs → npm-utils.js} +1 -1
- package/package.json +33 -29
- package/cjs/core/config.js +0 -73
- package/esm/cli.mjs +0 -54
- package/esm/core/config.d.ts +0 -9
- package/esm/core/config.mjs +0 -66
- package/esm/debug.mjs +0 -3
- package/esm/index.mjs +0 -1
package/cjs/cli.js
CHANGED
|
@@ -8,7 +8,8 @@ const path_1 = __importDefault(require("path"));
|
|
|
8
8
|
const promises_1 = __importDefault(require("fs/promises"));
|
|
9
9
|
const yargs_1 = __importDefault(require("yargs"));
|
|
10
10
|
const chalk_1 = __importDefault(require("chalk"));
|
|
11
|
-
const
|
|
11
|
+
const npmlog_1 = __importDefault(require("npmlog"));
|
|
12
|
+
const get_dirname_js_1 = require("./utils/get-dirname.js");
|
|
12
13
|
const repository_1 = require("./core/repository");
|
|
13
14
|
const info_command_1 = require("./commands/info-command");
|
|
14
15
|
const command_1 = require("./core/command");
|
|
@@ -21,41 +22,46 @@ const publish_command_1 = require("./commands/publish-command");
|
|
|
21
22
|
const ci_command_1 = require("./commands/ci-command");
|
|
22
23
|
const build_command_1 = require("./commands/build-command");
|
|
23
24
|
async function runCli(options) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
.
|
|
25
|
+
try {
|
|
26
|
+
const s = path_1.default.resolve((0, get_dirname_js_1.getDirname)(), '../package.json');
|
|
27
|
+
const pkgJson = JSON.parse(await promises_1.default.readFile(s, 'utf-8'));
|
|
28
|
+
const repository = repository_1.Repository.create(options?.cwd);
|
|
29
|
+
const _argv = options?.argv || process.argv.slice(2);
|
|
30
|
+
const globalKeys = Object.keys(command_1.Command.globalOptions).concat(["help", "version"]);
|
|
31
|
+
const program = (0, yargs_1.default)(_argv)
|
|
32
|
+
// .scriptName('rman')
|
|
33
|
+
.strict()
|
|
34
|
+
.version(pkgJson.version || '').alias('version', 'v')
|
|
35
|
+
.usage('$0 <cmd> [options...]')
|
|
36
|
+
.help('help').alias('help', 'h')
|
|
37
|
+
.showHelpOnFail(false, 'Run with --help for available options')
|
|
38
|
+
.fail((msg, err) => {
|
|
39
|
+
const text = (msg
|
|
40
|
+
? msg + '\n\n' + chalk_1.default.whiteBright('Run with --help for available options')
|
|
41
|
+
: (err ? err.message : ''));
|
|
42
|
+
console.log('\n' + chalk_1.default.red(text));
|
|
43
|
+
throw msg;
|
|
44
|
+
})
|
|
45
|
+
// group options under "Global Options:" header
|
|
46
|
+
.options(command_1.Command.globalOptions)
|
|
47
|
+
.group(globalKeys, "Global Options:");
|
|
48
|
+
info_command_1.InfoCommand.initCli(repository, program);
|
|
49
|
+
list_command_1.ListCommand.initCli(repository, program);
|
|
50
|
+
changed_command_1.ChangedCommand.initCli(repository, program);
|
|
51
|
+
execute_command_1.ExecuteCommand.initCli(repository, program);
|
|
52
|
+
run_command_1.RunCommand.initCli(repository, program);
|
|
53
|
+
version_command_1.VersionCommand.initCli(repository, program);
|
|
54
|
+
publish_command_1.PublishCommand.initCli(repository, program);
|
|
55
|
+
ci_command_1.CleanInstallCommand.initCli(repository, program);
|
|
56
|
+
build_command_1.BuildCommand.initCli(repository, program);
|
|
57
|
+
if (!_argv.length)
|
|
58
|
+
program.showHelp();
|
|
59
|
+
else
|
|
60
|
+
await program.parseAsync()
|
|
61
|
+
.catch(() => false);
|
|
62
|
+
}
|
|
63
|
+
catch (e) {
|
|
64
|
+
npmlog_1.default.error('rman', e);
|
|
65
|
+
}
|
|
60
66
|
}
|
|
61
67
|
exports.runCli = runCli;
|
|
@@ -5,11 +5,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.MultiTaskCommand = void 0;
|
|
7
7
|
const os_1 = __importDefault(require("os"));
|
|
8
|
-
const npmlog_1 = __importDefault(require("npmlog"));
|
|
9
8
|
const power_tasks_1 = require("power-tasks");
|
|
10
9
|
const putil_varhelpers_1 = require("putil-varhelpers");
|
|
11
10
|
const command_1 = require("../core/command");
|
|
12
|
-
const constants_1 = require("../
|
|
11
|
+
const constants_1 = require("../core/constants");
|
|
13
12
|
class MultiTaskCommand extends command_1.Command {
|
|
14
13
|
constructor(repository, options) {
|
|
15
14
|
super(options);
|
|
@@ -25,7 +24,6 @@ class MultiTaskCommand extends command_1.Command {
|
|
|
25
24
|
const packages = await this._getPackages();
|
|
26
25
|
const childTasks = await this._prepareTasks(packages);
|
|
27
26
|
if (!(childTasks && childTasks.length)) {
|
|
28
|
-
npmlog_1.default.info(this.commandName, '', 'There is no task to process');
|
|
29
27
|
return;
|
|
30
28
|
}
|
|
31
29
|
// this.enableProgress();
|
|
@@ -12,12 +12,17 @@ const path_1 = __importDefault(require("path"));
|
|
|
12
12
|
const npm_utils_1 = require("../utils/npm-utils");
|
|
13
13
|
class PublishCommand extends run_command_1.RunCommand {
|
|
14
14
|
constructor(repository, options) {
|
|
15
|
-
super(repository, 'publish',
|
|
15
|
+
super(repository, 'publish', {
|
|
16
|
+
...options,
|
|
17
|
+
bail: false,
|
|
18
|
+
parallel: true
|
|
19
|
+
});
|
|
16
20
|
this.repository = repository;
|
|
17
21
|
}
|
|
18
22
|
async _prepareTasks(packages) {
|
|
19
23
|
const newVersions = {};
|
|
20
24
|
const selectedPackages = [];
|
|
25
|
+
const promises = [];
|
|
21
26
|
for (const p of packages) {
|
|
22
27
|
const logPkgName = chalk_1.default.yellow(p.name);
|
|
23
28
|
if (p.json.private) {
|
|
@@ -25,20 +30,31 @@ class PublishCommand extends run_command_1.RunCommand {
|
|
|
25
30
|
continue;
|
|
26
31
|
}
|
|
27
32
|
npmlog_1.default.info(this.commandName, logPkgName, npmlog_1.default.separator, `Fetching package information from repository`);
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
33
|
+
const npmHelper = new npm_utils_1.NpmHelper({ cwd: p.dirname });
|
|
34
|
+
promises.push(npmHelper.getPackageInfo(p.json.name)
|
|
35
|
+
.then(r => {
|
|
36
|
+
const sameVersion = !!(r && r.version === p.version);
|
|
37
|
+
if (this.options.checkOnly) {
|
|
38
|
+
npmlog_1.default.info(this.commandName, logPkgName, npmlog_1.default.separator, !r.version
|
|
39
|
+
? chalk_1.default.yellow('No package information found in repository')
|
|
40
|
+
: (sameVersion
|
|
41
|
+
? `Version "${chalk_1.default.magenta(p.version)}" same in repository`
|
|
42
|
+
: `Version "${chalk_1.default.magenta(p.version)}" differs from version in repository (${chalk_1.default.magenta(r.version)})`));
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
31
45
|
if (r && r.version === p.version) {
|
|
32
46
|
npmlog_1.default.info(this.commandName, logPkgName, npmlog_1.default.separator, `Ignored. Same version (${p.version}) in repository`);
|
|
33
|
-
continue;
|
|
34
47
|
}
|
|
35
|
-
|
|
36
|
-
|
|
48
|
+
else {
|
|
49
|
+
npmlog_1.default.info(this.commandName, logPkgName, npmlog_1.default.separator, `Version (${r.version}) in repository`);
|
|
50
|
+
selectedPackages.push(p);
|
|
51
|
+
}
|
|
52
|
+
}).catch(e => {
|
|
37
53
|
if (e.name !== 'PackageNotFoundError')
|
|
38
54
|
throw e;
|
|
39
|
-
}
|
|
40
|
-
selectedPackages.push(p);
|
|
55
|
+
}));
|
|
41
56
|
}
|
|
57
|
+
await Promise.all(promises);
|
|
42
58
|
return super._prepareTasks(selectedPackages, { newVersions });
|
|
43
59
|
}
|
|
44
60
|
async _exec(args, options) {
|
|
@@ -75,6 +91,10 @@ PublishCommand.commandName = 'publish';
|
|
|
75
91
|
'you must publish with --access public to publish scoped packages.',
|
|
76
92
|
type: 'string',
|
|
77
93
|
choices: ['public', 'restricted']
|
|
94
|
+
},
|
|
95
|
+
'check-only': {
|
|
96
|
+
describe: '# Only performs version checking and do not apply "publish" to the registry.',
|
|
97
|
+
type: 'boolean'
|
|
78
98
|
}
|
|
79
99
|
};
|
|
80
100
|
function initCli(repository, program) {
|
|
@@ -93,7 +93,7 @@ class RunCommand extends multi_task_command_1.MultiTaskCommand {
|
|
|
93
93
|
if (logLevel)
|
|
94
94
|
npmlog_1.default.verbose(this.commandName, chalk_1.default.cyan(args.name), chalk_1.default.cyanBright.bold('executing'), npmlog_1.default.separator, args.command);
|
|
95
95
|
const t = Date.now();
|
|
96
|
-
const r = await (0, exec_1.exec)(args.command, { cwd: args.cwd, stdio: args.stdio });
|
|
96
|
+
const r = await (0, exec_1.exec)(args.command, { cwd: args.cwd, stdio: args.stdio, throwOnError: false });
|
|
97
97
|
if (logLevel)
|
|
98
98
|
if (r.error) {
|
|
99
99
|
npmlog_1.default.error(this.commandName, chalk_1.default.cyan(args.name), chalk_1.default.red.bold('failed'), npmlog_1.default.separator, args.command, npmlog_1.default.separator, r.error.message.trim() + ('\n' + r.stdout).trim());
|
package/cjs/core/command.js
CHANGED
|
@@ -9,10 +9,9 @@ const npmlog_1 = __importDefault(require("npmlog"));
|
|
|
9
9
|
const is_ci_1 = __importDefault(require("is-ci"));
|
|
10
10
|
const putil_merge_1 = __importDefault(require("putil-merge"));
|
|
11
11
|
require("./logger");
|
|
12
|
-
const constants_1 = require("
|
|
12
|
+
const constants_1 = require("./constants");
|
|
13
13
|
const chalk_1 = __importDefault(require("chalk"));
|
|
14
14
|
const figures_1 = __importDefault(require("figures"));
|
|
15
|
-
const npmlog_2 = __importDefault(require("npmlog"));
|
|
16
15
|
const noOp = () => void (0);
|
|
17
16
|
class Command extends (0, strict_typed_events_1.TypedEventEmitterClass)(strict_typed_events_1.AsyncEventEmitter) {
|
|
18
17
|
constructor(options) {
|
|
@@ -26,7 +25,7 @@ class Command extends (0, strict_typed_events_1.TypedEventEmitterClass)(strict_t
|
|
|
26
25
|
this.logger.separator = chalk_1.default.gray(figures_1.default.lineVerticalDashed0);
|
|
27
26
|
Object.defineProperty(this.logger, 'levelIndex', {
|
|
28
27
|
get() {
|
|
29
|
-
return
|
|
28
|
+
return npmlog_1.default.levels[npmlog_1.default.level] || 0;
|
|
30
29
|
}
|
|
31
30
|
});
|
|
32
31
|
}
|
|
@@ -88,7 +87,7 @@ class Command extends (0, strict_typed_events_1.TypedEventEmitterClass)(strict_t
|
|
|
88
87
|
//
|
|
89
88
|
}
|
|
90
89
|
async _preExecute() {
|
|
91
|
-
|
|
90
|
+
npmlog_1.default.info('rman', `Executing "${this.commandName}" command`);
|
|
92
91
|
}
|
|
93
92
|
}
|
|
94
93
|
exports.Command = Command;
|
|
File without changes
|
package/cjs/core/repository.js
CHANGED
|
@@ -10,7 +10,7 @@ const fast_glob_1 = __importDefault(require("fast-glob"));
|
|
|
10
10
|
const putil_merge_1 = __importDefault(require("putil-merge"));
|
|
11
11
|
const js_yaml_1 = __importDefault(require("js-yaml"));
|
|
12
12
|
const package_1 = require("./package");
|
|
13
|
-
const
|
|
13
|
+
const get_dirname_1 = require("../utils/get-dirname");
|
|
14
14
|
class Repository extends package_1.Package {
|
|
15
15
|
constructor(dirname, config, packages) {
|
|
16
16
|
super(dirname);
|
|
@@ -103,7 +103,7 @@ class Repository extends package_1.Package {
|
|
|
103
103
|
}
|
|
104
104
|
static _readConfig(dirname) {
|
|
105
105
|
const result = {};
|
|
106
|
-
const pkgJson = (0,
|
|
106
|
+
const pkgJson = (0, get_dirname_1.getPackageJson)(dirname);
|
|
107
107
|
if (pkgJson && typeof pkgJson.rman === 'object')
|
|
108
108
|
(0, putil_merge_1.default)(result, pkgJson.rman, { deep: true });
|
|
109
109
|
let filename = path_1.default.resolve(dirname, '.rman.yml');
|
package/cjs/debug.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
4
|
-
(0,
|
|
3
|
+
const cli_js_1 = require("./cli.js");
|
|
4
|
+
(0, cli_js_1.runCli)({ cwd: '/Users/ehanoglu/Yazilim/js/opra' })
|
|
5
5
|
.catch(() => 0);
|
package/cjs/utils/file-utils.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.fsDelete = exports.
|
|
6
|
+
exports.fsDelete = exports.tryStat = exports.fsExists = void 0;
|
|
7
7
|
const promises_1 = __importDefault(require("fs/promises"));
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
9
|
async function fsExists(s) {
|
|
@@ -14,7 +14,6 @@ async function tryStat(s) {
|
|
|
14
14
|
return promises_1.default.lstat(s).catch(() => undefined);
|
|
15
15
|
}
|
|
16
16
|
exports.tryStat = tryStat;
|
|
17
|
-
exports.fsReadFile = promises_1.default.readFile;
|
|
18
17
|
async function fsDelete(fileOrDir) {
|
|
19
18
|
const stat = await tryStat(fileOrDir);
|
|
20
19
|
if (stat) {
|
|
File without changes
|
package/esm/cli.js
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import fs from 'fs/promises';
|
|
3
|
+
import yargs from "yargs";
|
|
4
|
+
import chalk from 'chalk';
|
|
5
|
+
import logger from 'npmlog';
|
|
6
|
+
import { getDirname } from './utils/get-dirname.js';
|
|
7
|
+
import { Repository } from './core/repository';
|
|
8
|
+
import { InfoCommand } from './commands/info-command';
|
|
9
|
+
import { Command } from './core/command';
|
|
10
|
+
import { ListCommand } from './commands/list-command';
|
|
11
|
+
import { ChangedCommand } from './commands/changed-command';
|
|
12
|
+
import { ExecuteCommand } from './commands/execute-command';
|
|
13
|
+
import { RunCommand } from './commands/run-command';
|
|
14
|
+
import { VersionCommand } from './commands/version-command';
|
|
15
|
+
import { PublishCommand } from './commands/publish-command';
|
|
16
|
+
import { CleanInstallCommand } from './commands/ci-command';
|
|
17
|
+
import { BuildCommand } from './commands/build-command';
|
|
18
|
+
export async function runCli(options) {
|
|
19
|
+
try {
|
|
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);
|
|
23
|
+
const _argv = options?.argv || process.argv.slice(2);
|
|
24
|
+
const globalKeys = Object.keys(Command.globalOptions).concat(["help", "version"]);
|
|
25
|
+
const program = yargs(_argv)
|
|
26
|
+
// .scriptName('rman')
|
|
27
|
+
.strict()
|
|
28
|
+
.version(pkgJson.version || '').alias('version', 'v')
|
|
29
|
+
.usage('$0 <cmd> [options...]')
|
|
30
|
+
.help('help').alias('help', 'h')
|
|
31
|
+
.showHelpOnFail(false, 'Run with --help for available options')
|
|
32
|
+
.fail((msg, err) => {
|
|
33
|
+
const text = (msg
|
|
34
|
+
? msg + '\n\n' + chalk.whiteBright('Run with --help for available options')
|
|
35
|
+
: (err ? err.message : ''));
|
|
36
|
+
console.log('\n' + chalk.red(text));
|
|
37
|
+
throw msg;
|
|
38
|
+
})
|
|
39
|
+
// group options under "Global Options:" header
|
|
40
|
+
.options(Command.globalOptions)
|
|
41
|
+
.group(globalKeys, "Global Options:");
|
|
42
|
+
InfoCommand.initCli(repository, program);
|
|
43
|
+
ListCommand.initCli(repository, program);
|
|
44
|
+
ChangedCommand.initCli(repository, program);
|
|
45
|
+
ExecuteCommand.initCli(repository, program);
|
|
46
|
+
RunCommand.initCli(repository, program);
|
|
47
|
+
VersionCommand.initCli(repository, program);
|
|
48
|
+
PublishCommand.initCli(repository, program);
|
|
49
|
+
CleanInstallCommand.initCli(repository, program);
|
|
50
|
+
BuildCommand.initCli(repository, program);
|
|
51
|
+
if (!_argv.length)
|
|
52
|
+
program.showHelp();
|
|
53
|
+
else
|
|
54
|
+
await program.parseAsync()
|
|
55
|
+
.catch(() => false);
|
|
56
|
+
}
|
|
57
|
+
catch (e) {
|
|
58
|
+
logger.error('rman', e);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Command } from '
|
|
2
|
-
import { RunCommand } from './run-command
|
|
1
|
+
import { Command } from '../core/command';
|
|
2
|
+
import { RunCommand } from './run-command';
|
|
3
3
|
export class BuildCommand extends RunCommand {
|
|
4
4
|
constructor(repository, options) {
|
|
5
5
|
super(repository, 'build', options);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ListCommand } from './list-command
|
|
2
|
-
import { Command } from '
|
|
1
|
+
import { ListCommand } from './list-command';
|
|
2
|
+
import { Command } from '../core/command';
|
|
3
3
|
export class ChangedCommand extends ListCommand {
|
|
4
4
|
constructor(repository, options) {
|
|
5
5
|
super(repository, options);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Task } from 'power-tasks';
|
|
2
2
|
import chalk from 'chalk';
|
|
3
3
|
import logger from 'npmlog';
|
|
4
|
-
import { Command } from '
|
|
5
|
-
import { RunCommand } from './run-command
|
|
6
|
-
import { fsDelete, fsExists } from '
|
|
4
|
+
import { Command } from '../core/command';
|
|
5
|
+
import { RunCommand } from './run-command';
|
|
6
|
+
import { fsDelete, fsExists } from '../utils/file-utils';
|
|
7
7
|
import path from 'path';
|
|
8
8
|
export class CleanInstallCommand extends RunCommand {
|
|
9
9
|
constructor(repository, options) {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import logger from 'npmlog';
|
|
2
2
|
import chalk from 'chalk';
|
|
3
|
-
import { MultiTaskCommand } from './multi-task-command
|
|
3
|
+
import { MultiTaskCommand } from './multi-task-command';
|
|
4
4
|
import { Task } from 'power-tasks';
|
|
5
|
-
import { exec } from '
|
|
6
|
-
import { Command } from '
|
|
5
|
+
import { exec } from '../utils/exec';
|
|
6
|
+
import { Command } from '../core/command';
|
|
7
7
|
export class ExecuteCommand extends MultiTaskCommand {
|
|
8
8
|
constructor(repository, cmd, argv, options) {
|
|
9
9
|
super(repository, options);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import chalk from 'chalk';
|
|
2
2
|
import envinfo from 'envinfo';
|
|
3
3
|
import semver from 'semver';
|
|
4
|
-
import { Command } from '
|
|
4
|
+
import { Command } from '../core/command';
|
|
5
5
|
export class InfoCommand extends Command {
|
|
6
6
|
async _execute() {
|
|
7
7
|
const systemInfo = JSON.parse(await envinfo.run({
|
|
@@ -2,8 +2,8 @@ import path from 'path';
|
|
|
2
2
|
import chalk from 'chalk';
|
|
3
3
|
import EasyTable from 'easy-table';
|
|
4
4
|
import logger from 'npmlog';
|
|
5
|
-
import { Command } from '
|
|
6
|
-
import { GitHelper } from '
|
|
5
|
+
import { Command } from '../core/command';
|
|
6
|
+
import { GitHelper } from '../utils/git-utils';
|
|
7
7
|
export class ListCommand extends Command {
|
|
8
8
|
constructor(repository, options) {
|
|
9
9
|
super(options);
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import os from 'os';
|
|
2
|
-
import logger from 'npmlog';
|
|
3
2
|
import { Task } from 'power-tasks';
|
|
4
3
|
import { toNumber } from 'putil-varhelpers';
|
|
5
|
-
import { Command } from '
|
|
6
|
-
import { isTTY } from '
|
|
4
|
+
import { Command } from '../core/command';
|
|
5
|
+
import { isTTY } from '../core/constants';
|
|
7
6
|
export class MultiTaskCommand extends Command {
|
|
8
7
|
constructor(repository, options) {
|
|
9
8
|
super(options);
|
|
@@ -19,7 +18,6 @@ export class MultiTaskCommand extends Command {
|
|
|
19
18
|
const packages = await this._getPackages();
|
|
20
19
|
const childTasks = await this._prepareTasks(packages);
|
|
21
20
|
if (!(childTasks && childTasks.length)) {
|
|
22
|
-
logger.info(this.commandName, '', 'There is no task to process');
|
|
23
21
|
return;
|
|
24
22
|
}
|
|
25
23
|
// this.enableProgress();
|
|
@@ -21,6 +21,7 @@ export declare namespace PublishCommand {
|
|
|
21
21
|
interface Options extends RunCommand.Options {
|
|
22
22
|
contents?: string;
|
|
23
23
|
access?: string;
|
|
24
|
+
checkOnly?: boolean;
|
|
24
25
|
}
|
|
25
26
|
const cliCommandOptions: Record<string, yargs.Options>;
|
|
26
27
|
function initCli(repository: Repository, program: yargs.Argv): void;
|
|
@@ -1,17 +1,22 @@
|
|
|
1
1
|
import chalk from 'chalk';
|
|
2
2
|
import logger from 'npmlog';
|
|
3
|
-
import { Command } from '
|
|
4
|
-
import { RunCommand } from './run-command
|
|
3
|
+
import { Command } from '../core/command';
|
|
4
|
+
import { RunCommand } from './run-command';
|
|
5
5
|
import path from 'path';
|
|
6
|
-
import { NpmHelper } from '
|
|
6
|
+
import { NpmHelper } from '../utils/npm-utils';
|
|
7
7
|
export class PublishCommand extends RunCommand {
|
|
8
8
|
constructor(repository, options) {
|
|
9
|
-
super(repository, 'publish',
|
|
9
|
+
super(repository, 'publish', {
|
|
10
|
+
...options,
|
|
11
|
+
bail: false,
|
|
12
|
+
parallel: true
|
|
13
|
+
});
|
|
10
14
|
this.repository = repository;
|
|
11
15
|
}
|
|
12
16
|
async _prepareTasks(packages) {
|
|
13
17
|
const newVersions = {};
|
|
14
18
|
const selectedPackages = [];
|
|
19
|
+
const promises = [];
|
|
15
20
|
for (const p of packages) {
|
|
16
21
|
const logPkgName = chalk.yellow(p.name);
|
|
17
22
|
if (p.json.private) {
|
|
@@ -19,20 +24,31 @@ export class PublishCommand extends RunCommand {
|
|
|
19
24
|
continue;
|
|
20
25
|
}
|
|
21
26
|
logger.info(this.commandName, logPkgName, logger.separator, `Fetching package information from repository`);
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
27
|
+
const npmHelper = new NpmHelper({ cwd: p.dirname });
|
|
28
|
+
promises.push(npmHelper.getPackageInfo(p.json.name)
|
|
29
|
+
.then(r => {
|
|
30
|
+
const sameVersion = !!(r && r.version === p.version);
|
|
31
|
+
if (this.options.checkOnly) {
|
|
32
|
+
logger.info(this.commandName, logPkgName, logger.separator, !r.version
|
|
33
|
+
? chalk.yellow('No package information found in repository')
|
|
34
|
+
: (sameVersion
|
|
35
|
+
? `Version "${chalk.magenta(p.version)}" same in repository`
|
|
36
|
+
: `Version "${chalk.magenta(p.version)}" differs from version in repository (${chalk.magenta(r.version)})`));
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
25
39
|
if (r && r.version === p.version) {
|
|
26
40
|
logger.info(this.commandName, logPkgName, logger.separator, `Ignored. Same version (${p.version}) in repository`);
|
|
27
|
-
continue;
|
|
28
41
|
}
|
|
29
|
-
|
|
30
|
-
|
|
42
|
+
else {
|
|
43
|
+
logger.info(this.commandName, logPkgName, logger.separator, `Version (${r.version}) in repository`);
|
|
44
|
+
selectedPackages.push(p);
|
|
45
|
+
}
|
|
46
|
+
}).catch(e => {
|
|
31
47
|
if (e.name !== 'PackageNotFoundError')
|
|
32
48
|
throw e;
|
|
33
|
-
}
|
|
34
|
-
selectedPackages.push(p);
|
|
49
|
+
}));
|
|
35
50
|
}
|
|
51
|
+
await Promise.all(promises);
|
|
36
52
|
return super._prepareTasks(selectedPackages, { newVersions });
|
|
37
53
|
}
|
|
38
54
|
async _exec(args, options) {
|
|
@@ -68,6 +84,10 @@ PublishCommand.commandName = 'publish';
|
|
|
68
84
|
'you must publish with --access public to publish scoped packages.',
|
|
69
85
|
type: 'string',
|
|
70
86
|
choices: ['public', 'restricted']
|
|
87
|
+
},
|
|
88
|
+
'check-only': {
|
|
89
|
+
describe: '# Only performs version checking and do not apply "publish" to the registry.',
|
|
90
|
+
type: 'boolean'
|
|
71
91
|
}
|
|
72
92
|
};
|
|
73
93
|
function initCli(repository, program) {
|
|
@@ -2,9 +2,9 @@ import logger from 'npmlog';
|
|
|
2
2
|
import { Task } from 'power-tasks';
|
|
3
3
|
import chalk from 'chalk';
|
|
4
4
|
import parseNpmScript from '@netlify/parse-npm-script';
|
|
5
|
-
import { MultiTaskCommand } from './multi-task-command
|
|
6
|
-
import { Command } from '
|
|
7
|
-
import { exec } from '
|
|
5
|
+
import { MultiTaskCommand } from './multi-task-command';
|
|
6
|
+
import { Command } from '../core/command';
|
|
7
|
+
import { exec } from '../utils/exec';
|
|
8
8
|
export class RunCommand extends MultiTaskCommand {
|
|
9
9
|
constructor(repository, script, options) {
|
|
10
10
|
super(repository, options);
|
|
@@ -87,7 +87,7 @@ export class RunCommand extends MultiTaskCommand {
|
|
|
87
87
|
if (logLevel)
|
|
88
88
|
logger.verbose(this.commandName, chalk.cyan(args.name), chalk.cyanBright.bold('executing'), logger.separator, args.command);
|
|
89
89
|
const t = Date.now();
|
|
90
|
-
const r = await exec(args.command, { cwd: args.cwd, stdio: args.stdio });
|
|
90
|
+
const r = await exec(args.command, { cwd: args.cwd, stdio: args.stdio, throwOnError: false });
|
|
91
91
|
if (logLevel)
|
|
92
92
|
if (r.error) {
|
|
93
93
|
logger.error(this.commandName, chalk.cyan(args.name), chalk.red.bold('failed'), logger.separator, args.command, logger.separator, r.error.message.trim() + ('\n' + r.stdout).trim());
|
|
@@ -4,9 +4,9 @@ import semver from 'semver';
|
|
|
4
4
|
import logger from 'npmlog';
|
|
5
5
|
import stripColor from 'strip-color';
|
|
6
6
|
import { Task } from 'power-tasks';
|
|
7
|
-
import { RunCommand } from './run-command
|
|
8
|
-
import { GitHelper } from '
|
|
9
|
-
import { Command } from '
|
|
7
|
+
import { RunCommand } from './run-command';
|
|
8
|
+
import { GitHelper } from '../utils/git-utils';
|
|
9
|
+
import { Command } from '../core/command';
|
|
10
10
|
import fs from 'fs/promises';
|
|
11
11
|
export class VersionCommand extends RunCommand {
|
|
12
12
|
constructor(repository, bump, options) {
|
|
@@ -2,11 +2,10 @@ import { AsyncEventEmitter, TypedEventEmitterClass } from 'strict-typed-events';
|
|
|
2
2
|
import npmlog from 'npmlog';
|
|
3
3
|
import isCi from 'is-ci';
|
|
4
4
|
import merge from 'putil-merge';
|
|
5
|
-
import './logger
|
|
6
|
-
import { isTTY } from '
|
|
5
|
+
import './logger';
|
|
6
|
+
import { isTTY } from './constants';
|
|
7
7
|
import chalk from 'chalk';
|
|
8
8
|
import figures from 'figures';
|
|
9
|
-
import logger from 'npmlog';
|
|
10
9
|
const noOp = () => void (0);
|
|
11
10
|
export class Command extends TypedEventEmitterClass(AsyncEventEmitter) {
|
|
12
11
|
constructor(options) {
|
|
@@ -20,7 +19,7 @@ export class Command extends TypedEventEmitterClass(AsyncEventEmitter) {
|
|
|
20
19
|
this.logger.separator = chalk.gray(figures.lineVerticalDashed0);
|
|
21
20
|
Object.defineProperty(this.logger, 'levelIndex', {
|
|
22
21
|
get() {
|
|
23
|
-
return
|
|
22
|
+
return npmlog.levels[npmlog.level] || 0;
|
|
24
23
|
}
|
|
25
24
|
});
|
|
26
25
|
}
|
|
@@ -82,7 +81,7 @@ export class Command extends TypedEventEmitterClass(AsyncEventEmitter) {
|
|
|
82
81
|
//
|
|
83
82
|
}
|
|
84
83
|
async _preExecute() {
|
|
85
|
-
|
|
84
|
+
npmlog.info('rman', `Executing "${this.commandName}" command`);
|
|
86
85
|
}
|
|
87
86
|
}
|
|
88
87
|
(function (Command) {
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -3,8 +3,8 @@ import path from 'path';
|
|
|
3
3
|
import glob from 'fast-glob';
|
|
4
4
|
import merge from 'putil-merge';
|
|
5
5
|
import yaml from 'js-yaml';
|
|
6
|
-
import { Package } from './package
|
|
7
|
-
import { getPackageJson } from '
|
|
6
|
+
import { Package } from './package';
|
|
7
|
+
import { getPackageJson } from '../utils/get-dirname';
|
|
8
8
|
export class Repository extends Package {
|
|
9
9
|
constructor(dirname, config, packages) {
|
|
10
10
|
super(dirname);
|
|
File without changes
|
package/esm/debug.js
ADDED
package/esm/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './core/repository';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { spawn } from 'child_process';
|
|
2
2
|
import onExit from 'signal-exit';
|
|
3
|
-
import { npmRunPathEnv } from './npm-run-path
|
|
3
|
+
import { npmRunPathEnv } from './npm-run-path';
|
|
4
4
|
const runningChildren = new Map();
|
|
5
5
|
export async function exec(command, options) {
|
|
6
6
|
const opts = {
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import fsa from 'fs/promises';
|
|
3
2
|
import { Stats } from 'node:fs';
|
|
4
3
|
export declare function fsExists(s: string): Promise<boolean>;
|
|
5
4
|
export declare function tryStat(s: any): Promise<Stats | undefined>;
|
|
6
|
-
export declare const fsReadFile: typeof fsa.readFile;
|
|
7
5
|
export declare function fsDelete(fileOrDir: string): Promise<boolean>;
|
|
@@ -6,7 +6,6 @@ export async function fsExists(s) {
|
|
|
6
6
|
export async function tryStat(s) {
|
|
7
7
|
return fsa.lstat(s).catch(() => undefined);
|
|
8
8
|
}
|
|
9
|
-
export const fsReadFile = fsa.readFile;
|
|
10
9
|
export async function fsDelete(fileOrDir) {
|
|
11
10
|
const stat = await tryStat(fileOrDir);
|
|
12
11
|
if (stat) {
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rman",
|
|
3
3
|
"description": "Monorepo repository manager",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.17.0",
|
|
5
5
|
"author": "Panates",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"contributors": [
|
|
@@ -36,48 +36,52 @@
|
|
|
36
36
|
"chalk": "^5.0.1",
|
|
37
37
|
"easy-table": "^1.2.0",
|
|
38
38
|
"envinfo": "^7.8.1",
|
|
39
|
-
"fast-glob": "^3.2.
|
|
40
|
-
"figures": "^
|
|
41
|
-
"ini": "^
|
|
39
|
+
"fast-glob": "^3.2.12",
|
|
40
|
+
"figures": "^5.0.0",
|
|
41
|
+
"ini": "^3.0.1",
|
|
42
42
|
"is-ci": "^3.0.1",
|
|
43
43
|
"js-yaml": "^4.1.0",
|
|
44
|
-
"npmlog": "^6.0.
|
|
44
|
+
"npmlog": "^6.0.2",
|
|
45
45
|
"path-key": "^4.0.0",
|
|
46
|
-
"power-tasks": "^0.
|
|
46
|
+
"power-tasks": "^0.8.0",
|
|
47
47
|
"putil-merge": "^3.8.0",
|
|
48
|
-
"putil-varhelpers": "^1.6.
|
|
49
|
-
"semver": "^7.3.
|
|
48
|
+
"putil-varhelpers": "^1.6.4",
|
|
49
|
+
"semver": "^7.3.7",
|
|
50
50
|
"signal-exit": "^3.0.7",
|
|
51
|
-
"strict-typed-events": "^2.
|
|
51
|
+
"strict-typed-events": "^2.2.0",
|
|
52
52
|
"strip-color": "^0.1.0",
|
|
53
|
-
"yargs": "^17.
|
|
53
|
+
"yargs": "^17.5.1"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
|
-
"@babel/eslint-parser": "^7.
|
|
56
|
+
"@babel/eslint-parser": "^7.18.9",
|
|
57
57
|
"@types/envinfo": "^7.8.1",
|
|
58
58
|
"@types/ini": "^1.3.31",
|
|
59
59
|
"@types/is-ci": "^3.0.0",
|
|
60
|
-
"@types/jest": "^
|
|
60
|
+
"@types/jest": "^29.0.2",
|
|
61
61
|
"@types/js-yaml": "^4.0.5",
|
|
62
|
-
"@types/node": "^
|
|
62
|
+
"@types/node": "^18.7.18",
|
|
63
63
|
"@types/npmlog": "^4.1.4",
|
|
64
|
-
"@types/semver": "^7.3.
|
|
64
|
+
"@types/semver": "^7.3.12",
|
|
65
65
|
"@types/signal-exit": "^3.0.1",
|
|
66
66
|
"@types/strip-color": "^0.1.0",
|
|
67
|
-
"@types/yargs": "^17.0.
|
|
68
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
69
|
-
"@typescript-eslint/parser": "^5.
|
|
70
|
-
"eslint": "
|
|
67
|
+
"@types/yargs": "^17.0.12",
|
|
68
|
+
"@typescript-eslint/eslint-plugin": "^5.37.0",
|
|
69
|
+
"@typescript-eslint/parser": "^5.37.0",
|
|
70
|
+
"eslint": "8.21.0",
|
|
71
71
|
"eslint-config-google": "^0.14.0",
|
|
72
|
-
"
|
|
73
|
-
"
|
|
74
|
-
"
|
|
75
|
-
"
|
|
76
|
-
"
|
|
77
|
-
"
|
|
78
|
-
"
|
|
79
|
-
"
|
|
80
|
-
"
|
|
72
|
+
"eslint-plugin-import": "^2.26.0",
|
|
73
|
+
"eslint-plugin-security": "^1.5.0",
|
|
74
|
+
"eslint-plugin-simple-import-sort": "^8.0.0",
|
|
75
|
+
"eslint-plugin-unused-imports": "^2.0.0",
|
|
76
|
+
"jest": "^29.0.3",
|
|
77
|
+
"prettier": "^2.7.1",
|
|
78
|
+
"ts-cleanup": "^0.2.5",
|
|
79
|
+
"ts-gems": "^2.2.0",
|
|
80
|
+
"ts-jest": "^29.0.1",
|
|
81
|
+
"ts-loader": "^9.3.1",
|
|
82
|
+
"ts-node": "^10.9.1",
|
|
83
|
+
"tsconfig-paths": "^4.1.0",
|
|
84
|
+
"typescript": "^4.8.3"
|
|
81
85
|
},
|
|
82
86
|
"engines": {
|
|
83
87
|
"node": ">=14.0",
|
|
@@ -98,8 +102,8 @@
|
|
|
98
102
|
"clean:src": "ts-cleanup -s src --all | ts-cleanup -s test",
|
|
99
103
|
"prebuild": "npm run clean:dist && npm run lint",
|
|
100
104
|
"build": "npm run build:cjs && npm run build:esm",
|
|
101
|
-
"build:cjs": "tsc -b tsconfig
|
|
102
|
-
"build:esm": "tsc -b tsconfig
|
|
105
|
+
"build:cjs": "tsc -b tsconfig-build-cjs.json",
|
|
106
|
+
"build:esm": "tsc -b tsconfig-build-esm.json",
|
|
103
107
|
"postbuild": "cp package.cjs.json ./cjs/package.json",
|
|
104
108
|
"test": "jest",
|
|
105
109
|
"cover": "rimraf coverage",
|
package/cjs/core/config.js
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.Config = void 0;
|
|
7
|
-
const path_1 = __importDefault(require("path"));
|
|
8
|
-
const fs_1 = __importDefault(require("fs"));
|
|
9
|
-
const js_yaml_1 = __importDefault(require("js-yaml"));
|
|
10
|
-
const putil_merge_1 = __importDefault(require("putil-merge"));
|
|
11
|
-
const utils_1 = require("../utils");
|
|
12
|
-
class Config {
|
|
13
|
-
constructor(data) {
|
|
14
|
-
this.data = data;
|
|
15
|
-
}
|
|
16
|
-
getObject(key, def) {
|
|
17
|
-
const v = this.get(key);
|
|
18
|
-
if (v != null && typeof v === 'object')
|
|
19
|
-
return v;
|
|
20
|
-
return def;
|
|
21
|
-
}
|
|
22
|
-
getString(key, def) {
|
|
23
|
-
const v = this.get(key);
|
|
24
|
-
if (v != null && typeof v !== 'object')
|
|
25
|
-
return '' + v;
|
|
26
|
-
return def;
|
|
27
|
-
}
|
|
28
|
-
getNumber(key, def) {
|
|
29
|
-
const v = this.get(key);
|
|
30
|
-
if (v != null && typeof v !== 'object') {
|
|
31
|
-
const n = parseFloat(v);
|
|
32
|
-
if (!isNaN(n))
|
|
33
|
-
return n;
|
|
34
|
-
}
|
|
35
|
-
return def;
|
|
36
|
-
}
|
|
37
|
-
get(key) {
|
|
38
|
-
const keys = key.split('.');
|
|
39
|
-
let o = this.data;
|
|
40
|
-
for (let i = 0; i < keys.length; i++) {
|
|
41
|
-
const k = keys[i];
|
|
42
|
-
if (o.hasOwnProperty(k)) {
|
|
43
|
-
if (i === keys.length - 1)
|
|
44
|
-
return o[k];
|
|
45
|
-
if (o[k] && typeof o[k] === 'object') {
|
|
46
|
-
o = o[k];
|
|
47
|
-
}
|
|
48
|
-
else
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
static resolve(dirname) {
|
|
54
|
-
const data = {};
|
|
55
|
-
const pkgJson = (0, utils_1.getPackageJson)(dirname);
|
|
56
|
-
if (pkgJson && typeof pkgJson.rman === 'object')
|
|
57
|
-
(0, putil_merge_1.default)(data, pkgJson.rman, { deep: true });
|
|
58
|
-
let filename = path_1.default.resolve(dirname, '.rman.yml');
|
|
59
|
-
if (fs_1.default.existsSync(filename)) {
|
|
60
|
-
const obj = js_yaml_1.default.load(fs_1.default.readFileSync(filename, 'utf-8'));
|
|
61
|
-
if (obj && typeof obj === 'object')
|
|
62
|
-
(0, putil_merge_1.default)(data, obj, { deep: true });
|
|
63
|
-
}
|
|
64
|
-
filename = path_1.default.resolve(dirname, '.rmanrc');
|
|
65
|
-
if (fs_1.default.existsSync(filename)) {
|
|
66
|
-
const obj = JSON.parse(fs_1.default.readFileSync(filename, 'utf-8'));
|
|
67
|
-
if (obj && typeof obj === 'object')
|
|
68
|
-
(0, putil_merge_1.default)(data, obj, { deep: true });
|
|
69
|
-
}
|
|
70
|
-
return new Config(data);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
exports.Config = Config;
|
package/esm/cli.mjs
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import path from 'path';
|
|
2
|
-
import fs from 'fs/promises';
|
|
3
|
-
import yargs from "yargs";
|
|
4
|
-
import chalk from 'chalk';
|
|
5
|
-
import { getDirname } from './utils.mjs';
|
|
6
|
-
import { Repository } from './core/repository.mjs';
|
|
7
|
-
import { InfoCommand } from './commands/info-command.mjs';
|
|
8
|
-
import { Command } from './core/command.mjs';
|
|
9
|
-
import { ListCommand } from './commands/list-command.mjs';
|
|
10
|
-
import { ChangedCommand } from './commands/changed-command.mjs';
|
|
11
|
-
import { ExecuteCommand } from './commands/execute-command.mjs';
|
|
12
|
-
import { RunCommand } from './commands/run-command.mjs';
|
|
13
|
-
import { VersionCommand } from './commands/version-command.mjs';
|
|
14
|
-
import { PublishCommand } from './commands/publish-command.mjs';
|
|
15
|
-
import { CleanInstallCommand } from './commands/ci-command.mjs';
|
|
16
|
-
import { BuildCommand } from './commands/build-command.mjs';
|
|
17
|
-
export async function runCli(options) {
|
|
18
|
-
const s = path.resolve(getDirname(), '../package.json');
|
|
19
|
-
const pkgJson = JSON.parse(await fs.readFile(s, 'utf-8'));
|
|
20
|
-
const repository = Repository.create(options?.cwd);
|
|
21
|
-
const _argv = options?.argv || process.argv.slice(2);
|
|
22
|
-
const globalKeys = Object.keys(Command.globalOptions).concat(["help", "version"]);
|
|
23
|
-
const program = yargs(_argv)
|
|
24
|
-
// .scriptName('rman')
|
|
25
|
-
.strict()
|
|
26
|
-
.version(pkgJson.version || '').alias('version', 'v')
|
|
27
|
-
.usage('$0 <cmd> [options...]')
|
|
28
|
-
.help('help').alias('help', 'h')
|
|
29
|
-
.showHelpOnFail(false, 'Run with --help for available options')
|
|
30
|
-
.fail((msg, err) => {
|
|
31
|
-
const text = (msg
|
|
32
|
-
? msg + '\n\n' + chalk.whiteBright('Run with --help for available options')
|
|
33
|
-
: (err ? err.message : ''));
|
|
34
|
-
console.log('\n' + chalk.red(text));
|
|
35
|
-
throw msg;
|
|
36
|
-
})
|
|
37
|
-
// group options under "Global Options:" header
|
|
38
|
-
.options(Command.globalOptions)
|
|
39
|
-
.group(globalKeys, "Global Options:");
|
|
40
|
-
InfoCommand.initCli(repository, program);
|
|
41
|
-
ListCommand.initCli(repository, program);
|
|
42
|
-
ChangedCommand.initCli(repository, program);
|
|
43
|
-
ExecuteCommand.initCli(repository, program);
|
|
44
|
-
RunCommand.initCli(repository, program);
|
|
45
|
-
VersionCommand.initCli(repository, program);
|
|
46
|
-
PublishCommand.initCli(repository, program);
|
|
47
|
-
CleanInstallCommand.initCli(repository, program);
|
|
48
|
-
BuildCommand.initCli(repository, program);
|
|
49
|
-
if (!_argv.length)
|
|
50
|
-
program.showHelp();
|
|
51
|
-
else
|
|
52
|
-
await program.parseAsync()
|
|
53
|
-
.catch(() => false);
|
|
54
|
-
}
|
package/esm/core/config.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export declare class Config {
|
|
2
|
-
data: any;
|
|
3
|
-
constructor(data: any);
|
|
4
|
-
getObject(key: string, def?: any): any | undefined;
|
|
5
|
-
getString(key: string, def?: string): string | undefined;
|
|
6
|
-
getNumber(key: string, def?: number): number | undefined;
|
|
7
|
-
get(key: string): any;
|
|
8
|
-
static resolve(dirname: string): Config;
|
|
9
|
-
}
|
package/esm/core/config.mjs
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import path from 'path';
|
|
2
|
-
import fs from 'fs';
|
|
3
|
-
import yaml from 'js-yaml';
|
|
4
|
-
import merge from 'putil-merge';
|
|
5
|
-
import { getPackageJson } from './../utils.mjs';
|
|
6
|
-
export class Config {
|
|
7
|
-
constructor(data) {
|
|
8
|
-
this.data = data;
|
|
9
|
-
}
|
|
10
|
-
getObject(key, def) {
|
|
11
|
-
const v = this.get(key);
|
|
12
|
-
if (v != null && typeof v === 'object')
|
|
13
|
-
return v;
|
|
14
|
-
return def;
|
|
15
|
-
}
|
|
16
|
-
getString(key, def) {
|
|
17
|
-
const v = this.get(key);
|
|
18
|
-
if (v != null && typeof v !== 'object')
|
|
19
|
-
return '' + v;
|
|
20
|
-
return def;
|
|
21
|
-
}
|
|
22
|
-
getNumber(key, def) {
|
|
23
|
-
const v = this.get(key);
|
|
24
|
-
if (v != null && typeof v !== 'object') {
|
|
25
|
-
const n = parseFloat(v);
|
|
26
|
-
if (!isNaN(n))
|
|
27
|
-
return n;
|
|
28
|
-
}
|
|
29
|
-
return def;
|
|
30
|
-
}
|
|
31
|
-
get(key) {
|
|
32
|
-
const keys = key.split('.');
|
|
33
|
-
let o = this.data;
|
|
34
|
-
for (let i = 0; i < keys.length; i++) {
|
|
35
|
-
const k = keys[i];
|
|
36
|
-
if (o.hasOwnProperty(k)) {
|
|
37
|
-
if (i === keys.length - 1)
|
|
38
|
-
return o[k];
|
|
39
|
-
if (o[k] && typeof o[k] === 'object') {
|
|
40
|
-
o = o[k];
|
|
41
|
-
}
|
|
42
|
-
else
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
static resolve(dirname) {
|
|
48
|
-
const data = {};
|
|
49
|
-
const pkgJson = getPackageJson(dirname);
|
|
50
|
-
if (pkgJson && typeof pkgJson.rman === 'object')
|
|
51
|
-
merge(data, pkgJson.rman, { deep: true });
|
|
52
|
-
let filename = path.resolve(dirname, '.rman.yml');
|
|
53
|
-
if (fs.existsSync(filename)) {
|
|
54
|
-
const obj = yaml.load(fs.readFileSync(filename, 'utf-8'));
|
|
55
|
-
if (obj && typeof obj === 'object')
|
|
56
|
-
merge(data, obj, { deep: true });
|
|
57
|
-
}
|
|
58
|
-
filename = path.resolve(dirname, '.rmanrc');
|
|
59
|
-
if (fs.existsSync(filename)) {
|
|
60
|
-
const obj = JSON.parse(fs.readFileSync(filename, 'utf-8'));
|
|
61
|
-
if (obj && typeof obj === 'object')
|
|
62
|
-
merge(data, obj, { deep: true });
|
|
63
|
-
}
|
|
64
|
-
return new Config(data);
|
|
65
|
-
}
|
|
66
|
-
}
|
package/esm/debug.mjs
DELETED
package/esm/index.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './core/repository.mjs';
|