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
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const command_js_1 = require("../core/command.js");
|
|
9
|
-
const npm_utils_js_1 = require("../utils/npm-utils.js");
|
|
10
|
-
const run_command_js_1 = require("./run-command.js");
|
|
11
|
-
class PublishCommand extends run_command_js_1.RunCommand {
|
|
1
|
+
import colors from 'ansi-colors';
|
|
2
|
+
import logger from 'npmlog';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import { Command } from '../core/command.js';
|
|
5
|
+
import { NpmHelper } from '../utils/npm-utils.js';
|
|
6
|
+
import { RunCommand } from './run-command.js';
|
|
7
|
+
export class PublishCommand extends RunCommand {
|
|
12
8
|
constructor(repository, options) {
|
|
13
9
|
super(repository, 'publish', {
|
|
14
10
|
...options,
|
|
@@ -22,32 +18,32 @@ class PublishCommand extends run_command_js_1.RunCommand {
|
|
|
22
18
|
const selectedPackages = [];
|
|
23
19
|
const promises = [];
|
|
24
20
|
for (const p of packages) {
|
|
25
|
-
const logPkgName =
|
|
21
|
+
const logPkgName = colors.yellow(p.name);
|
|
26
22
|
if (p.json.private) {
|
|
27
|
-
|
|
23
|
+
logger.info(this.commandName, logPkgName, logger.separator, `Ignored. Package is set to "private"`);
|
|
28
24
|
continue;
|
|
29
25
|
}
|
|
30
|
-
|
|
31
|
-
const npmHelper = new
|
|
26
|
+
logger.info(this.commandName, logPkgName, logger.separator, `Fetching package information from repository`);
|
|
27
|
+
const npmHelper = new NpmHelper({ cwd: p.dirname });
|
|
32
28
|
promises.push(npmHelper
|
|
33
29
|
.getPackageInfo(p.json.name)
|
|
34
30
|
.then(r => {
|
|
35
31
|
const sameVersion = !!(r && r.version === p.version);
|
|
36
32
|
if (this.options.checkOnly) {
|
|
37
|
-
|
|
38
|
-
?
|
|
33
|
+
logger.info(this.commandName, logPkgName, logger.separator, !r.version
|
|
34
|
+
? colors.yellow('No package information found in repository')
|
|
39
35
|
: sameVersion
|
|
40
|
-
? `No publish needed. Version (${
|
|
36
|
+
? `No publish needed. Version (${colors.magenta(p.version)}) same in repository`
|
|
41
37
|
: `Publishing is possible.` +
|
|
42
|
-
` Version "${
|
|
38
|
+
` Version "${colors.magenta(p.version)}" differs from version in repository (${colors.magenta(r.version)})`);
|
|
43
39
|
return;
|
|
44
40
|
}
|
|
45
41
|
if (r && r.version === p.version) {
|
|
46
|
-
|
|
42
|
+
logger.info(this.commandName, logPkgName, logger.separator, `No publish needed. Version (${colors.magenta(p.version)}) same in repository`);
|
|
47
43
|
}
|
|
48
44
|
else {
|
|
49
|
-
|
|
50
|
-
` Version "${
|
|
45
|
+
logger.verbose(this.commandName, logPkgName, logger.separator, `Publishing is possible.` +
|
|
46
|
+
` Version "${colors.magenta(p.version)}" differs from version in repository (${colors.magenta(r.version)})`);
|
|
51
47
|
selectedPackages.push(p);
|
|
52
48
|
}
|
|
53
49
|
})
|
|
@@ -64,22 +60,21 @@ class PublishCommand extends run_command_js_1.RunCommand {
|
|
|
64
60
|
if (pkg === this.repository.rootPackage)
|
|
65
61
|
return { code: 0 };
|
|
66
62
|
const cwd = this.options.contents
|
|
67
|
-
?
|
|
63
|
+
? path.resolve(this.repository.dirname, path.join(this.options.contents, path.basename(pkg.dirname)))
|
|
68
64
|
: pkg.dirname;
|
|
69
65
|
return super._exec(pkg, 'npm publish' + (this.options.access ? ' --access=' + this.options.access : ''), {
|
|
70
66
|
...args,
|
|
71
67
|
cwd,
|
|
72
|
-
stdio:
|
|
68
|
+
stdio: logger.levelIndex < 1000 ? 'inherit' : 'pipe',
|
|
73
69
|
}, options);
|
|
74
70
|
}
|
|
75
71
|
return super._exec(pkg, command, args, options);
|
|
76
72
|
}
|
|
77
73
|
}
|
|
78
|
-
exports.PublishCommand = PublishCommand;
|
|
79
74
|
PublishCommand.commandName = 'publish';
|
|
80
75
|
(function (PublishCommand) {
|
|
81
76
|
PublishCommand.cliCommandOptions = {
|
|
82
|
-
...
|
|
77
|
+
...RunCommand.cliCommandOptions,
|
|
83
78
|
contents: {
|
|
84
79
|
describe: '# Subdirectory to publish',
|
|
85
80
|
type: 'string',
|
|
@@ -105,10 +100,10 @@ PublishCommand.commandName = 'publish';
|
|
|
105
100
|
.example('$0 publish --contents dist', '# publish package from built directory')
|
|
106
101
|
.option(PublishCommand.cliCommandOptions),
|
|
107
102
|
handler: async (args) => {
|
|
108
|
-
const options =
|
|
103
|
+
const options = Command.composeOptions(PublishCommand.commandName, args, repository.config);
|
|
109
104
|
await new PublishCommand(repository, options).execute();
|
|
110
105
|
},
|
|
111
106
|
});
|
|
112
107
|
}
|
|
113
108
|
PublishCommand.initCli = initCli;
|
|
114
|
-
})(PublishCommand || (
|
|
109
|
+
})(PublishCommand || (PublishCommand = {}));
|
|
@@ -1,15 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const command_js_1 = require("../core/command.js");
|
|
10
|
-
const exec_js_1 = require("../utils/exec.js");
|
|
11
|
-
const multi_task_command_js_1 = require("./multi-task-command.js");
|
|
12
|
-
class RunCommand extends multi_task_command_js_1.MultiTaskCommand {
|
|
1
|
+
import parseNpmScript from '@netlify/parse-npm-script';
|
|
2
|
+
import colors from 'ansi-colors';
|
|
3
|
+
import logger from 'npmlog';
|
|
4
|
+
import { Task } from 'power-tasks';
|
|
5
|
+
import { Command } from '../core/command.js';
|
|
6
|
+
import { exec } from '../utils/exec.js';
|
|
7
|
+
import { MultiTaskCommand } from './multi-task-command.js';
|
|
8
|
+
export class RunCommand extends MultiTaskCommand {
|
|
13
9
|
constructor(repository, script, options) {
|
|
14
10
|
super(repository, options);
|
|
15
11
|
this.repository = repository;
|
|
@@ -42,16 +38,16 @@ class RunCommand extends multi_task_command_js_1.MultiTaskCommand {
|
|
|
42
38
|
const json = { ...pkg.json };
|
|
43
39
|
json.scripts = json.scripts || {};
|
|
44
40
|
json.scripts[this.script] = json.scripts[this.script] || '#';
|
|
45
|
-
const scriptInfo = (
|
|
41
|
+
const scriptInfo = parseNpmScript(json, 'npm run ' + this.script);
|
|
46
42
|
if (!(scriptInfo && scriptInfo.raw))
|
|
47
43
|
return;
|
|
48
44
|
const children = [];
|
|
49
45
|
for (const s of scriptInfo.steps) {
|
|
50
46
|
const parsed = Array.isArray(s.parsed) ? s.parsed : [s.parsed];
|
|
51
47
|
for (const cmd of parsed) {
|
|
52
|
-
const task = new
|
|
48
|
+
const task = new Task(async () => await this._exec(pkg, cmd, {
|
|
53
49
|
script: s.name,
|
|
54
|
-
stdio:
|
|
50
|
+
stdio: logger.levelIndex < 1000 ? 'inherit' : 'pipe',
|
|
55
51
|
}, options), {
|
|
56
52
|
name: pkg.name + ':' + s.name,
|
|
57
53
|
dependencies: this.options.parallel || s.name.startsWith('pre') || s.name.startsWith('post')
|
|
@@ -62,7 +58,7 @@ class RunCommand extends multi_task_command_js_1.MultiTaskCommand {
|
|
|
62
58
|
}
|
|
63
59
|
}
|
|
64
60
|
if (children.length) {
|
|
65
|
-
return new
|
|
61
|
+
return new Task(children, {
|
|
66
62
|
name: pkg.name,
|
|
67
63
|
bail: true,
|
|
68
64
|
serial: true,
|
|
@@ -75,17 +71,17 @@ class RunCommand extends multi_task_command_js_1.MultiTaskCommand {
|
|
|
75
71
|
const name = pkg === this.repository.rootPackage ? 'root' : pkg.name;
|
|
76
72
|
const logLevel = args.logLevel == null ? 'info' : args.logLevel;
|
|
77
73
|
if (logLevel) {
|
|
78
|
-
|
|
74
|
+
logger.verbose(this.commandName, colors.cyan(name), logger.separator, colors.cyanBright.bold(args.script || ''), colors.cyanBright.bold('executing'), logger.separator, command);
|
|
79
75
|
}
|
|
80
76
|
const t = Date.now();
|
|
81
77
|
const cwd = args.cwd || pkg.dirname;
|
|
82
|
-
const r = await
|
|
78
|
+
const r = await exec(command, { cwd, stdio: args.stdio, throwOnError: false });
|
|
83
79
|
if (logLevel) {
|
|
84
80
|
if (r.error) {
|
|
85
|
-
|
|
81
|
+
logger.error(this.commandName, colors.cyan(name), logger.separator, colors.cyanBright.bold(args.script || ''), colors.red.bold('failed'), logger.separator, command, logger.separator, r.error.message.trim() + ('\n' + r.stdout).trim());
|
|
86
82
|
}
|
|
87
83
|
else {
|
|
88
|
-
|
|
84
|
+
logger.log(logLevel, this.commandName, colors.cyan(name), logger.separator, colors.cyanBright.bold(args.script || ''), colors.green.bold('success'), logger.separator, command, colors.yellow(' (' + (Date.now() - t) + ' ms)'));
|
|
89
85
|
}
|
|
90
86
|
}
|
|
91
87
|
if (r.error && !args.noThrow)
|
|
@@ -93,11 +89,10 @@ class RunCommand extends multi_task_command_js_1.MultiTaskCommand {
|
|
|
93
89
|
return r;
|
|
94
90
|
}
|
|
95
91
|
}
|
|
96
|
-
exports.RunCommand = RunCommand;
|
|
97
92
|
RunCommand.commandName = 'run';
|
|
98
93
|
(function (RunCommand) {
|
|
99
94
|
RunCommand.cliCommandOptions = {
|
|
100
|
-
...
|
|
95
|
+
...MultiTaskCommand.cliCommandOptions,
|
|
101
96
|
};
|
|
102
97
|
function initCli(repository, program) {
|
|
103
98
|
program.command({
|
|
@@ -119,11 +114,11 @@ RunCommand.commandName = 'run';
|
|
|
119
114
|
}
|
|
120
115
|
});
|
|
121
116
|
}
|
|
122
|
-
const options =
|
|
117
|
+
const options = Command.composeOptions(RunCommand.commandName, args, repository.config);
|
|
123
118
|
const script = '' + args.script;
|
|
124
119
|
await new RunCommand(repository, script, options).execute();
|
|
125
120
|
},
|
|
126
121
|
});
|
|
127
122
|
}
|
|
128
123
|
RunCommand.initCli = initCli;
|
|
129
|
-
})(RunCommand || (
|
|
124
|
+
})(RunCommand || (RunCommand = {}));
|
|
@@ -1,17 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const command_js_1 = require("../core/command.js");
|
|
12
|
-
const git_utils_js_1 = require("../utils/git-utils.js");
|
|
13
|
-
const run_command_js_1 = require("./run-command.js");
|
|
14
|
-
class VersionCommand 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 semver from 'semver';
|
|
6
|
+
import stripColor from 'strip-color';
|
|
7
|
+
import { Command } from '../core/command.js';
|
|
8
|
+
import { GitHelper } from '../utils/git-utils.js';
|
|
9
|
+
import { RunCommand } from './run-command.js';
|
|
10
|
+
export class VersionCommand extends RunCommand {
|
|
15
11
|
constructor(repository, bump, options) {
|
|
16
12
|
super(repository, 'version', options);
|
|
17
13
|
this.repository = repository;
|
|
@@ -20,7 +16,7 @@ class VersionCommand extends run_command_js_1.RunCommand {
|
|
|
20
16
|
}
|
|
21
17
|
async _prepareTasks(packages) {
|
|
22
18
|
const { repository } = this;
|
|
23
|
-
const git = new
|
|
19
|
+
const git = new GitHelper({ cwd: repository.dirname });
|
|
24
20
|
const dirtyFiles = await git.listDirtyFiles();
|
|
25
21
|
const committedFiles = await git.listCommittedFiles();
|
|
26
22
|
const newVersions = {};
|
|
@@ -28,45 +24,45 @@ class VersionCommand extends run_command_js_1.RunCommand {
|
|
|
28
24
|
const selectedPackages = [];
|
|
29
25
|
const dependentPackages = [];
|
|
30
26
|
for (const p of packages) {
|
|
31
|
-
const relDir =
|
|
27
|
+
const relDir = path.relative(repository.dirname, p.dirname);
|
|
32
28
|
let status = '';
|
|
33
29
|
let message = '';
|
|
34
30
|
let newVer = '';
|
|
35
|
-
const logPkgName =
|
|
31
|
+
const logPkgName = colors.yellow(p.name);
|
|
36
32
|
if (!this.options.noTag) {
|
|
37
|
-
const isDirty = dirtyFiles.find(f => !
|
|
33
|
+
const isDirty = dirtyFiles.find(f => !path.relative(relDir, f).startsWith('..'));
|
|
38
34
|
if (isDirty) {
|
|
39
35
|
if (!this.options.ignoreDirty)
|
|
40
36
|
errorCount++;
|
|
41
|
-
status = this.options.ignoreDirty ?
|
|
37
|
+
status = this.options.ignoreDirty ? colors.cyan.bold('skip') : colors.redBright.bold('error');
|
|
42
38
|
message = 'Git directory is not clean';
|
|
43
39
|
}
|
|
44
40
|
}
|
|
45
41
|
if (!status) {
|
|
46
|
-
const isChanged = committedFiles.find(f => !
|
|
42
|
+
const isChanged = committedFiles.find(f => !path.relative(relDir, f).startsWith('..'));
|
|
47
43
|
newVer =
|
|
48
44
|
isChanged || this.options.all || this.options.unified
|
|
49
|
-
?
|
|
45
|
+
? semver.inc(p.version, this.bump)
|
|
50
46
|
: undefined;
|
|
51
47
|
if (newVer)
|
|
52
48
|
newVersions[p.name] = newVer;
|
|
53
49
|
else {
|
|
54
|
-
status =
|
|
50
|
+
status = colors.cyanBright.bold('no-change');
|
|
55
51
|
message = 'No change detected';
|
|
56
52
|
}
|
|
57
53
|
}
|
|
58
54
|
if (status) {
|
|
59
55
|
if (this.options.json) {
|
|
60
|
-
|
|
56
|
+
logger.info(this.commandName, '%j', {
|
|
61
57
|
package: p.name,
|
|
62
58
|
version: p.version,
|
|
63
59
|
newVersion: newVer,
|
|
64
|
-
status: (
|
|
65
|
-
message: (
|
|
60
|
+
status: stripColor(status),
|
|
61
|
+
message: stripColor(message),
|
|
66
62
|
});
|
|
67
63
|
}
|
|
68
64
|
else {
|
|
69
|
-
|
|
65
|
+
logger.log(this.options.ignoreDirty ? 'info' : 'error', this.commandName, logPkgName, colors.whiteBright(p.version), status, logger.separator, message);
|
|
70
66
|
}
|
|
71
67
|
continue;
|
|
72
68
|
}
|
|
@@ -78,7 +74,7 @@ class VersionCommand extends run_command_js_1.RunCommand {
|
|
|
78
74
|
}
|
|
79
75
|
if (errorCount)
|
|
80
76
|
throw new Error('Unable to bump version due to error(s)');
|
|
81
|
-
const maxVer = Object.values(newVersions).reduce((m, v) => (
|
|
77
|
+
const maxVer = Object.values(newVersions).reduce((m, v) => (semver.gt(m, v) ? m : v), '0.0.0');
|
|
82
78
|
if (this.options.unified) {
|
|
83
79
|
Object.keys(newVersions).forEach(k => (newVersions[k] = maxVer));
|
|
84
80
|
}
|
|
@@ -89,18 +85,18 @@ class VersionCommand extends run_command_js_1.RunCommand {
|
|
|
89
85
|
const tasks = await super._prepareTasks(selectedPackages, { newVersions });
|
|
90
86
|
tasks.forEach(t => (t.options.exclusive = true));
|
|
91
87
|
if (!this.options.noTag) {
|
|
92
|
-
tasks.push(new
|
|
88
|
+
tasks.push(new Task(async () => {
|
|
93
89
|
while (this._updatedPackages.size) {
|
|
94
90
|
const filenames = [];
|
|
95
91
|
const [first] = this._updatedPackages;
|
|
96
92
|
for (const pkg of this._updatedPackages) {
|
|
97
93
|
if (pkg.version === first.version) {
|
|
98
|
-
filenames.push(
|
|
94
|
+
filenames.push(path.relative(this.repository.rootPackage.dirname, pkg.jsonFileName));
|
|
99
95
|
this._updatedPackages.delete(pkg);
|
|
100
96
|
}
|
|
101
97
|
}
|
|
102
98
|
await super._exec(this.repository.rootPackage, 'git commit -m "' + first.version + '" ' + filenames.map(s => '"' + s + '"').join(' '), {
|
|
103
|
-
stdio:
|
|
99
|
+
stdio: logger.levelIndex < 1000 ? 'inherit' : 'pipe',
|
|
104
100
|
logLevel: 'silly',
|
|
105
101
|
});
|
|
106
102
|
}
|
|
@@ -108,7 +104,7 @@ class VersionCommand extends run_command_js_1.RunCommand {
|
|
|
108
104
|
try {
|
|
109
105
|
await super._exec(this.repository.rootPackage, 'git tag -a "v' + maxVer + '" -m "version ' + maxVer + '"', {
|
|
110
106
|
cwd: this.repository.dirname,
|
|
111
|
-
stdio:
|
|
107
|
+
stdio: logger.levelIndex < 1000 ? 'inherit' : 'pipe',
|
|
112
108
|
logLevel: 'silly',
|
|
113
109
|
});
|
|
114
110
|
}
|
|
@@ -147,13 +143,12 @@ class VersionCommand extends run_command_js_1.RunCommand {
|
|
|
147
143
|
this._updatedPackages.add(p);
|
|
148
144
|
}
|
|
149
145
|
}
|
|
150
|
-
|
|
146
|
+
logger.info(this.commandName, pkg.name, logger.separator, 'Version changed from ' + colors.cyan(oldVer) + ' to ' + colors.cyan(newVer));
|
|
151
147
|
return { code: 0 };
|
|
152
148
|
}
|
|
153
149
|
return super._exec(pkg, command, args, options);
|
|
154
150
|
}
|
|
155
151
|
}
|
|
156
|
-
exports.VersionCommand = VersionCommand;
|
|
157
152
|
VersionCommand.commandName = 'version';
|
|
158
153
|
(function (VersionCommand) {
|
|
159
154
|
VersionCommand.cliCommandOptions = {
|
|
@@ -189,10 +184,10 @@ VersionCommand.commandName = 'version';
|
|
|
189
184
|
.option(VersionCommand.cliCommandOptions),
|
|
190
185
|
handler: async (args) => {
|
|
191
186
|
const bump = args.bump;
|
|
192
|
-
const options =
|
|
187
|
+
const options = Command.composeOptions(VersionCommand.commandName, args, repository.config);
|
|
193
188
|
await new VersionCommand(repository, bump, options).execute();
|
|
194
189
|
},
|
|
195
190
|
});
|
|
196
191
|
}
|
|
197
192
|
VersionCommand.initCli = initCli;
|
|
198
|
-
})(VersionCommand || (
|
|
193
|
+
})(VersionCommand || (VersionCommand = {}));
|
package/esm/core/command.js
CHANGED
|
@@ -1,29 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const npmlog_1 = tslib_1.__importDefault(require("npmlog"));
|
|
9
|
-
const putil_merge_1 = tslib_1.__importDefault(require("putil-merge"));
|
|
10
|
-
const strict_typed_events_1 = require("strict-typed-events");
|
|
11
|
-
const constants_js_1 = require("./constants.js");
|
|
1
|
+
import './logger.js';
|
|
2
|
+
import colors from 'ansi-colors';
|
|
3
|
+
import isCi from 'is-ci';
|
|
4
|
+
import npmlog from 'npmlog';
|
|
5
|
+
import merge from 'putil-merge';
|
|
6
|
+
import { AsyncEventEmitter, TypedEventEmitterClass } from 'strict-typed-events';
|
|
7
|
+
import { isTTY } from './constants.js';
|
|
12
8
|
const noOp = () => undefined;
|
|
13
9
|
const lineVerticalDashed0 = '┆';
|
|
14
|
-
class Command extends
|
|
10
|
+
export class Command extends TypedEventEmitterClass(AsyncEventEmitter) {
|
|
15
11
|
constructor(options) {
|
|
16
12
|
super();
|
|
17
13
|
this._started = false;
|
|
18
14
|
this._finished = false;
|
|
19
|
-
this.logger =
|
|
15
|
+
this.logger = npmlog;
|
|
20
16
|
this._options = options || {};
|
|
21
|
-
if (
|
|
17
|
+
if (isCi)
|
|
22
18
|
this.options.ci = true;
|
|
23
|
-
this.logger.separator =
|
|
19
|
+
this.logger.separator = colors.gray(lineVerticalDashed0);
|
|
24
20
|
Object.defineProperty(this.logger, 'levelIndex', {
|
|
25
21
|
get() {
|
|
26
|
-
return
|
|
22
|
+
return npmlog.levels[npmlog.level] || 0;
|
|
27
23
|
},
|
|
28
24
|
});
|
|
29
25
|
}
|
|
@@ -45,7 +41,7 @@ class Command extends (0, strict_typed_events_1.TypedEventEmitterClass)(strict_t
|
|
|
45
41
|
this._started = true;
|
|
46
42
|
try {
|
|
47
43
|
this.logger.level = this.options.logLevel || (this.options.ci ? 'error' : 'info');
|
|
48
|
-
if (this.options.ci || !
|
|
44
|
+
if (this.options.ci || !isTTY) {
|
|
49
45
|
this.logger.disableColor();
|
|
50
46
|
this.logger.disableUnicode();
|
|
51
47
|
}
|
|
@@ -85,10 +81,9 @@ class Command extends (0, strict_typed_events_1.TypedEventEmitterClass)(strict_t
|
|
|
85
81
|
//
|
|
86
82
|
}
|
|
87
83
|
async _preExecute() {
|
|
88
|
-
|
|
84
|
+
npmlog.info('rman', `Executing "${this.commandName}" command`);
|
|
89
85
|
}
|
|
90
86
|
}
|
|
91
|
-
exports.Command = Command;
|
|
92
87
|
(function (Command) {
|
|
93
88
|
Command.globalOptions = {
|
|
94
89
|
'log-level': {
|
|
@@ -108,12 +103,12 @@ exports.Command = Command;
|
|
|
108
103
|
},
|
|
109
104
|
};
|
|
110
105
|
function composeOptions(commandName, yargArgs, config) {
|
|
111
|
-
const result = (
|
|
112
|
-
(
|
|
106
|
+
const result = merge({}, config, { filter: (_, key) => key !== 'command' });
|
|
107
|
+
merge(result, yargArgs);
|
|
113
108
|
const cfgCmd = config.command && typeof config.command === 'object' ? config.command[commandName] : undefined;
|
|
114
109
|
if (cfgCmd && typeof cfgCmd === 'object')
|
|
115
|
-
(
|
|
110
|
+
merge(result, cfgCmd);
|
|
116
111
|
return result;
|
|
117
112
|
}
|
|
118
113
|
Command.composeOptions = composeOptions;
|
|
119
|
-
})(Command || (
|
|
114
|
+
})(Command || (Command = {}));
|
package/esm/core/constants.js
CHANGED
|
@@ -1,5 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isTTY = void 0;
|
|
4
1
|
// export const DOTS = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"];
|
|
5
|
-
|
|
2
|
+
export const isTTY = process.stdout.isTTY && process.env.TERM !== 'dumb';
|
package/esm/core/logger.js
CHANGED
|
@@ -1,5 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
const npmlog_1 = tslib_1.__importDefault(require("npmlog"));
|
|
5
|
-
npmlog_1.default.addLevel('output', 3300, {}, '');
|
|
1
|
+
import logger from 'npmlog';
|
|
2
|
+
logger.addLevel('output', 3300, {}, '');
|
package/esm/core/package.js
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const fs_1 = tslib_1.__importDefault(require("fs"));
|
|
6
|
-
const path_1 = tslib_1.__importDefault(require("path"));
|
|
7
|
-
class Package {
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
export class Package {
|
|
8
4
|
constructor(dirname) {
|
|
9
5
|
this.dirname = dirname;
|
|
10
6
|
this.dependencies = [];
|
|
@@ -20,20 +16,19 @@ class Package {
|
|
|
20
16
|
return this._json;
|
|
21
17
|
}
|
|
22
18
|
get jsonFileName() {
|
|
23
|
-
return
|
|
19
|
+
return path.join(this.dirname, 'package.json');
|
|
24
20
|
}
|
|
25
21
|
get isPrivate() {
|
|
26
22
|
return !!this._json.private;
|
|
27
23
|
}
|
|
28
24
|
reloadJson() {
|
|
29
25
|
const f = this.jsonFileName;
|
|
30
|
-
this._json = JSON.parse(
|
|
26
|
+
this._json = JSON.parse(fs.readFileSync(f, 'utf-8'));
|
|
31
27
|
return this._json;
|
|
32
28
|
}
|
|
33
29
|
writeJson() {
|
|
34
30
|
const f = this.jsonFileName;
|
|
35
31
|
const data = JSON.stringify(this._json, undefined, 2);
|
|
36
|
-
|
|
32
|
+
fs.writeFileSync(f, data, 'utf-8');
|
|
37
33
|
}
|
|
38
34
|
}
|
|
39
|
-
exports.Package = Package;
|
package/esm/core/repository.js
CHANGED
|
@@ -1,21 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const putil_merge_1 = tslib_1.__importDefault(require("putil-merge"));
|
|
10
|
-
const get_dirname_js_1 = require("../utils/get-dirname.js");
|
|
11
|
-
const package_js_1 = require("./package.js");
|
|
12
|
-
class Repository extends package_js_1.Package {
|
|
1
|
+
import glob from 'fast-glob';
|
|
2
|
+
import fs from 'fs';
|
|
3
|
+
import yaml from 'js-yaml';
|
|
4
|
+
import path from 'path';
|
|
5
|
+
import merge from 'putil-merge';
|
|
6
|
+
import { getPackageJson } from '../utils/get-dirname.js';
|
|
7
|
+
import { Package } from './package.js';
|
|
8
|
+
export class Repository extends Package {
|
|
13
9
|
constructor(dirname, config, packages) {
|
|
14
10
|
super(dirname);
|
|
15
11
|
this.dirname = dirname;
|
|
16
12
|
this.config = config;
|
|
17
13
|
this.packages = packages;
|
|
18
|
-
this.rootPackage = new
|
|
14
|
+
this.rootPackage = new Package(dirname);
|
|
19
15
|
}
|
|
20
16
|
getPackages(options) {
|
|
21
17
|
const result = [...this.packages];
|
|
@@ -74,10 +70,10 @@ class Repository extends package_js_1.Package {
|
|
|
74
70
|
static create(root, options) {
|
|
75
71
|
let dirname = root || process.cwd();
|
|
76
72
|
let deep = options?.deep ?? 10;
|
|
77
|
-
while (deep-- >= 0 &&
|
|
78
|
-
const f =
|
|
79
|
-
if (
|
|
80
|
-
const pkgJson = JSON.parse(
|
|
73
|
+
while (deep-- >= 0 && fs.existsSync(dirname)) {
|
|
74
|
+
const f = path.join(dirname, 'package.json');
|
|
75
|
+
if (fs.existsSync(f)) {
|
|
76
|
+
const pkgJson = JSON.parse(fs.readFileSync(f, 'utf-8'));
|
|
81
77
|
if (Array.isArray(pkgJson.workspaces)) {
|
|
82
78
|
const packages = this._resolvePackages(dirname, pkgJson.workspaces);
|
|
83
79
|
const config = this._readConfig(dirname);
|
|
@@ -86,48 +82,47 @@ class Repository extends package_js_1.Package {
|
|
|
86
82
|
return repo;
|
|
87
83
|
}
|
|
88
84
|
}
|
|
89
|
-
dirname =
|
|
85
|
+
dirname = path.resolve(dirname, '..');
|
|
90
86
|
}
|
|
91
87
|
throw new Error('No monorepo project detected');
|
|
92
88
|
}
|
|
93
89
|
static _resolvePackages(dirname, patterns) {
|
|
94
90
|
const packages = [];
|
|
95
91
|
for (const pattern of patterns) {
|
|
96
|
-
const dirs =
|
|
92
|
+
const dirs = glob.sync(pattern, {
|
|
97
93
|
cwd: dirname,
|
|
98
94
|
absolute: true,
|
|
99
95
|
deep: 0,
|
|
100
96
|
onlyDirectories: true,
|
|
101
97
|
});
|
|
102
98
|
for (const dir of dirs) {
|
|
103
|
-
const f =
|
|
104
|
-
if (
|
|
105
|
-
packages.push(new
|
|
99
|
+
const f = path.join(dir, 'package.json');
|
|
100
|
+
if (fs.existsSync(f))
|
|
101
|
+
packages.push(new Package(dir));
|
|
106
102
|
}
|
|
107
103
|
}
|
|
108
104
|
return packages;
|
|
109
105
|
}
|
|
110
106
|
static _readConfig(dirname) {
|
|
111
107
|
const result = {};
|
|
112
|
-
const pkgJson =
|
|
108
|
+
const pkgJson = getPackageJson(dirname);
|
|
113
109
|
if (pkgJson && typeof pkgJson.rman === 'object')
|
|
114
|
-
(
|
|
115
|
-
let filename =
|
|
116
|
-
if (
|
|
117
|
-
const obj =
|
|
110
|
+
merge(result, pkgJson.rman, { deep: true });
|
|
111
|
+
let filename = path.resolve(dirname, '.rman.yml');
|
|
112
|
+
if (fs.existsSync(filename)) {
|
|
113
|
+
const obj = yaml.load(fs.readFileSync(filename, 'utf-8'));
|
|
118
114
|
if (obj && typeof obj === 'object')
|
|
119
|
-
(
|
|
115
|
+
merge(result, obj, { deep: true });
|
|
120
116
|
}
|
|
121
|
-
filename =
|
|
122
|
-
if (
|
|
123
|
-
const obj = JSON.parse(
|
|
117
|
+
filename = path.resolve(dirname, '.rmanrc');
|
|
118
|
+
if (fs.existsSync(filename)) {
|
|
119
|
+
const obj = JSON.parse(fs.readFileSync(filename, 'utf-8'));
|
|
124
120
|
if (obj && typeof obj === 'object')
|
|
125
|
-
(
|
|
121
|
+
merge(result, obj, { deep: true });
|
|
126
122
|
}
|
|
127
123
|
return result;
|
|
128
124
|
}
|
|
129
125
|
}
|
|
130
|
-
exports.Repository = Repository;
|
|
131
126
|
function topoSortPackages(packages) {
|
|
132
127
|
packages.sort((a, b) => {
|
|
133
128
|
if (b.dependencies.includes(a.name))
|
package/esm/index.js
CHANGED
package/esm/package.json
ADDED