rman 0.38.0 → 1.0.2
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/README.md +371 -21
- package/cli.js +51 -29
- package/commands/build.command.d.ts +3 -0
- package/commands/build.command.js +14 -0
- package/commands/changed.command.d.ts +3 -0
- package/commands/changed.command.js +29 -0
- package/commands/changelog.command.d.ts +3 -0
- package/commands/changelog.command.js +63 -0
- package/commands/ci.command.d.ts +3 -0
- package/commands/ci.command.js +30 -0
- package/commands/clean.command.d.ts +3 -0
- package/commands/clean.command.js +36 -0
- package/commands/diff.command.d.ts +3 -0
- package/commands/diff.command.js +51 -0
- package/commands/exec.command.d.ts +3 -0
- package/commands/exec.command.js +83 -0
- package/commands/import.command.d.ts +3 -0
- package/commands/import.command.js +27 -0
- package/commands/info.command.d.ts +3 -0
- package/commands/info.command.js +61 -0
- package/commands/list.command.d.ts +3 -0
- package/commands/list.command.js +113 -0
- package/commands/publish.command.d.ts +3 -0
- package/commands/publish.command.js +147 -0
- package/commands/run.command.d.ts +6 -0
- package/commands/run.command.js +80 -0
- package/commands/test.command.d.ts +3 -0
- package/commands/test.command.js +14 -0
- package/commands/version.command.d.ts +3 -0
- package/commands/version.command.js +125 -0
- package/constants.js +1 -1
- package/core/config.d.ts +13 -0
- package/core/config.js +61 -0
- package/core/package.d.ts +2 -0
- package/core/package.js +2 -0
- package/core/repository.d.ts +36 -3
- package/core/repository.js +90 -45
- package/index.d.ts +17 -1
- package/index.js +15 -1
- package/package.json +8 -4
- package/rmanrc.schema.json +202 -0
- package/services/changelog.service.d.ts +99 -0
- package/services/changelog.service.js +272 -0
- package/services/ci.service.d.ts +40 -0
- package/services/ci.service.js +204 -0
- package/services/clean.service.d.ts +42 -0
- package/services/clean.service.js +226 -0
- package/services/exec.service.d.ts +35 -0
- package/services/exec.service.js +114 -0
- package/services/import.service.d.ts +30 -0
- package/services/import.service.js +84 -0
- package/services/list.service.d.ts +27 -0
- package/services/list.service.js +25 -0
- package/services/publish.service.d.ts +79 -0
- package/services/publish.service.js +199 -0
- package/services/run.service.d.ts +99 -0
- package/services/run.service.js +432 -0
- package/services/system-info.d.ts +16 -0
- package/services/system-info.js +25 -0
- package/services/version.service.d.ts +95 -0
- package/services/version.service.js +450 -0
- package/services.d.ts +10 -0
- package/services.js +10 -0
- package/utils/branch-guard.d.ts +25 -0
- package/utils/branch-guard.js +61 -0
- package/utils/change-hash.d.ts +55 -0
- package/utils/change-hash.js +80 -0
- package/utils/conventional-commits.d.ts +39 -0
- package/utils/conventional-commits.js +43 -0
- package/utils/exec.d.ts +5 -6
- package/utils/exec.js +45 -59
- package/utils/git.d.ts +86 -0
- package/utils/git.js +276 -0
- package/utils/live-region.d.ts +16 -0
- package/utils/live-region.js +59 -0
- package/utils/logger.d.ts +24 -0
- package/utils/logger.js +39 -0
- package/utils/npm-run-path.d.ts +1 -1
- package/utils/npm-run-path.js +10 -10
- package/utils/package-filter.d.ts +32 -0
- package/utils/package-filter.js +73 -0
- package/utils/progress-panel.d.ts +59 -0
- package/utils/progress-panel.js +149 -0
- package/utils/workspace-range.d.ts +17 -0
- package/utils/workspace-range.js +28 -0
- package/commands/build-command.d.ts +0 -11
- package/commands/build-command.js +0 -26
- package/commands/changed-command.d.ts +0 -16
- package/commands/changed-command.js +0 -35
- package/commands/ci-command.d.ts +0 -24
- package/commands/ci-command.js +0 -71
- package/commands/execute-command.d.ts +0 -19
- package/commands/execute-command.js +0 -75
- package/commands/info-command.d.ts +0 -10
- package/commands/info-command.js +0 -57
- package/commands/list-command.d.ts +0 -38
- package/commands/list-command.js +0 -137
- package/commands/multi-task-command.d.ts +0 -22
- package/commands/multi-task-command.js +0 -68
- package/commands/publish-command.d.ts +0 -24
- package/commands/publish-command.js +0 -135
- package/commands/run-command.d.ts +0 -28
- package/commands/run-command.js +0 -134
- package/commands/version-command.d.ts +0 -25
- package/commands/version-command.js +0 -198
- package/core/command.d.ts +0 -35
- package/core/command.js +0 -117
- package/core/constants.d.ts +0 -1
- package/core/constants.js +0 -2
- package/core/logger.d.ts +0 -12
- package/core/logger.js +0 -2
- package/utils/file-utils.d.ts +0 -4
- package/utils/file-utils.js +0 -29
- package/utils/git-utils.d.ts +0 -25
- package/utils/git-utils.js +0 -66
- package/utils/npm-utils.d.ts +0 -11
- package/utils/npm-utils.js +0 -33
- package/utils/package-not-found-error.d.ts +0 -2
- package/utils/package-not-found-error.js +0 -2
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import colors from 'ansi-colors';
|
|
2
|
+
import { LiveRegion } from './live-region.js';
|
|
3
|
+
export function formatDuration(ms) {
|
|
4
|
+
return (ms / 1000).toFixed(1) + 's';
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Shared live progress panel for any command that fans work out across packages: a spinner
|
|
8
|
+
* header (progress bar, running/failed counts, elapsed time) plus one or two lines per
|
|
9
|
+
* currently-running item, redrawn in place instead of scrolling - the same panel `run`/`build`
|
|
10
|
+
* use, pulled out so other package-fanning commands (e.g. `ci`) can reuse it instead of
|
|
11
|
+
* reimplementing it.
|
|
12
|
+
*
|
|
13
|
+
* Renders nothing when `enabled` is false (a non-TTY, or a command's own `--no-progress`) -
|
|
14
|
+
* callers are expected to fall back to their own plain logging in that case, the way `run`
|
|
15
|
+
* falls back to its "classic" per-step log.
|
|
16
|
+
*/
|
|
17
|
+
export class ProgressPanel {
|
|
18
|
+
title;
|
|
19
|
+
live;
|
|
20
|
+
items = new Map();
|
|
21
|
+
renderLoop;
|
|
22
|
+
spinnerFrame = 0;
|
|
23
|
+
startedAt = 0;
|
|
24
|
+
constructor(title, enabled) {
|
|
25
|
+
this.title = title;
|
|
26
|
+
this.live = new LiveRegion(enabled);
|
|
27
|
+
}
|
|
28
|
+
get enabled() {
|
|
29
|
+
return this.live.enabled;
|
|
30
|
+
}
|
|
31
|
+
/** Registers an item and returns it - callers mutate the returned object directly (`status`,
|
|
32
|
+
* `currentStep`, `lastLine`, ...) to drive the next render tick. */
|
|
33
|
+
addItem(name, stepsTotal) {
|
|
34
|
+
const item = { name, status: 'pending', stepsTotal, log: [] };
|
|
35
|
+
this.items.set(name, item);
|
|
36
|
+
return item;
|
|
37
|
+
}
|
|
38
|
+
/** Starts the redraw loop. No-op (and no timer) when disabled. */
|
|
39
|
+
start() {
|
|
40
|
+
this.startedAt = Date.now();
|
|
41
|
+
if (!this.live.enabled)
|
|
42
|
+
return;
|
|
43
|
+
this.renderLoop = setInterval(() => this.render(), 100);
|
|
44
|
+
}
|
|
45
|
+
render() {
|
|
46
|
+
this.spinnerFrame = (this.spinnerFrame + 1) % SPINNER_FRAMES.length;
|
|
47
|
+
const spinner = colors.cyan(SPINNER_FRAMES[this.spinnerFrame]);
|
|
48
|
+
const total = this.items.size;
|
|
49
|
+
let running = 0;
|
|
50
|
+
let done = 0;
|
|
51
|
+
let failedSoFar = 0;
|
|
52
|
+
for (const item of this.items.values()) {
|
|
53
|
+
if (item.status === 'running')
|
|
54
|
+
running++;
|
|
55
|
+
else if (item.status !== 'pending')
|
|
56
|
+
done++;
|
|
57
|
+
if (item.status === 'failed')
|
|
58
|
+
failedSoFar++;
|
|
59
|
+
}
|
|
60
|
+
const header = colors.bgCyan.black.bold(` ${this.title} `);
|
|
61
|
+
const bar = renderProgressBar(done, total);
|
|
62
|
+
const totalElapsed = formatDuration(Date.now() - this.startedAt);
|
|
63
|
+
const failedText = failedSoFar > 0 ? colors.red.bold(`${failedSoFar} failed`) : colors.gray(`${failedSoFar} failed`);
|
|
64
|
+
const lines = [
|
|
65
|
+
`${header} ${bar} ${colors.bold(`${done}/${total}`)} ${colors.cyan(`${running} running`)} ${failedText} ${colors.yellow(totalElapsed)}`,
|
|
66
|
+
];
|
|
67
|
+
const runningList = [...this.items.values()].filter(i => i.status === 'running');
|
|
68
|
+
/** Leave room for the header, a safety margin, and a possible "N more running" line - a
|
|
69
|
+
* block taller than the terminal breaks cursor-up math (the terminal scrolls instead of
|
|
70
|
+
* the cursor moving, so redraws land in the wrong place and pile up). */
|
|
71
|
+
const budget = Math.max(0, (process.stdout.rows || 24) - 3);
|
|
72
|
+
let used = 0;
|
|
73
|
+
let shown = 0;
|
|
74
|
+
for (const item of runningList) {
|
|
75
|
+
const elapsed = item.startedAt ? formatDuration(Date.now() - item.startedAt) : '';
|
|
76
|
+
const step = item.stepsTotal && item.stepsTotal > 1 && item.stepIndex != null
|
|
77
|
+
? `${item.currentStep} (${item.stepIndex + 1}/${item.stepsTotal})`
|
|
78
|
+
: item.currentStep || '';
|
|
79
|
+
const group = [`${spinner} ${colors.bold(item.name)} ${colors.gray(step)} ${colors.yellow(elapsed)}`];
|
|
80
|
+
if (item.lastLine)
|
|
81
|
+
group.push(` ${colors.dim(item.lastLine)}`);
|
|
82
|
+
if (used + group.length > budget)
|
|
83
|
+
break;
|
|
84
|
+
lines.push(...group);
|
|
85
|
+
used += group.length;
|
|
86
|
+
shown++;
|
|
87
|
+
}
|
|
88
|
+
const remaining = runningList.length - shown;
|
|
89
|
+
if (remaining > 0)
|
|
90
|
+
lines.push(colors.gray(`… and ${remaining} more running`));
|
|
91
|
+
this.live.render(lines);
|
|
92
|
+
}
|
|
93
|
+
/** Stops the redraw loop and erases the panel, leaving the cursor where it started. */
|
|
94
|
+
stop() {
|
|
95
|
+
if (this.renderLoop)
|
|
96
|
+
clearInterval(this.renderLoop);
|
|
97
|
+
this.renderLoop = undefined;
|
|
98
|
+
this.live.clear();
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Prints the final per-item recap (✓/X/○) and the "N succeeded, M failed (Xs)" summary line,
|
|
102
|
+
* and returns the tally. Any item still 'pending' is counted (and printed) as 'skipped'. The
|
|
103
|
+
* per-item recap lines are only printed when the live panel was actually on - with it off, the
|
|
104
|
+
* caller's own plain logging already showed each item's outcome as it happened.
|
|
105
|
+
*/
|
|
106
|
+
printSummary() {
|
|
107
|
+
let successCount = 0;
|
|
108
|
+
let failedCount = 0;
|
|
109
|
+
let skippedCount = 0;
|
|
110
|
+
for (const item of this.items.values()) {
|
|
111
|
+
if (item.status === 'pending')
|
|
112
|
+
item.status = 'skipped';
|
|
113
|
+
const duration = item.startedAt && item.finishedAt ? colors.gray(formatDuration(item.finishedAt - item.startedAt)) : '';
|
|
114
|
+
if (item.status === 'success') {
|
|
115
|
+
successCount++;
|
|
116
|
+
if (this.live.enabled)
|
|
117
|
+
console.log(colors.green('✓'), item.name, duration);
|
|
118
|
+
}
|
|
119
|
+
else if (item.status === 'failed') {
|
|
120
|
+
failedCount++;
|
|
121
|
+
if (this.live.enabled) {
|
|
122
|
+
console.log(colors.red.bold('X'), item.name, duration);
|
|
123
|
+
if (item.log.length)
|
|
124
|
+
console.log(colors.red(item.log.join('\n')));
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
skippedCount++;
|
|
129
|
+
if (this.live.enabled)
|
|
130
|
+
console.log(colors.gray('○'), item.name, colors.gray('skipped'));
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
const totalElapsed = formatDuration(Date.now() - this.startedAt);
|
|
134
|
+
const summary = [
|
|
135
|
+
colors.green(`${successCount} succeeded`),
|
|
136
|
+
failedCount > 0 ? colors.red(`${failedCount} failed`) : colors.gray(`${failedCount} failed`),
|
|
137
|
+
];
|
|
138
|
+
if (skippedCount)
|
|
139
|
+
summary.push(colors.gray(`${skippedCount} skipped`));
|
|
140
|
+
console.log(summary.join(colors.gray(', ')), colors.gray(`(${totalElapsed})`));
|
|
141
|
+
return { successCount, failedCount, skippedCount };
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
/** Classic braille "dots" spinner (cli-spinners' default), one frame per render tick. */
|
|
145
|
+
const SPINNER_FRAMES = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];
|
|
146
|
+
function renderProgressBar(done, total, width = 24) {
|
|
147
|
+
const filled = total ? Math.round((done / total) * width) : 0;
|
|
148
|
+
return colors.green('█'.repeat(filled)) + colors.gray('░'.repeat(width - filled));
|
|
149
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export interface ParsedWorkspaceRange {
|
|
2
|
+
/** `'*'`/`'^'`/`'~'` for the bare selector forms; `'explicit'` when the protocol is followed by
|
|
3
|
+
* a concrete semver version/range instead (e.g. `"workspace:^1.0.0"`, `"workspace:1.0.0"`). */
|
|
4
|
+
selector: '*' | '^' | '~' | 'explicit';
|
|
5
|
+
/** Only set when `selector === 'explicit'` - the literal range following `"workspace:"`. */
|
|
6
|
+
range?: string;
|
|
7
|
+
}
|
|
8
|
+
/** Parses a dependency range value for the pnpm/yarn `"workspace:"` protocol - `undefined` when
|
|
9
|
+
* `value` isn't a workspace range at all (a plain semver range, or not a string). */
|
|
10
|
+
export declare function parseWorkspaceRange(value: unknown): ParsedWorkspaceRange | undefined;
|
|
11
|
+
/**
|
|
12
|
+
* Resolves a parsed workspace range against `version` (the dependency's actual current version)
|
|
13
|
+
* into the real range a registry consumer would need - the same substitution pnpm/yarn's own
|
|
14
|
+
* publish performs: `"*"` pins the exact version (no operator), `"^"`/`"~"` prepend themselves to
|
|
15
|
+
* it, and an explicit range is used verbatim (it was already a real range, just workspace-prefixed).
|
|
16
|
+
*/
|
|
17
|
+
export declare function resolveWorkspaceRange(parsed: ParsedWorkspaceRange, version: string): string;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/** Parses a dependency range value for the pnpm/yarn `"workspace:"` protocol - `undefined` when
|
|
2
|
+
* `value` isn't a workspace range at all (a plain semver range, or not a string). */
|
|
3
|
+
export function parseWorkspaceRange(value) {
|
|
4
|
+
if (typeof value !== 'string' || !value.startsWith('workspace:'))
|
|
5
|
+
return undefined;
|
|
6
|
+
const rest = value.slice('workspace:'.length);
|
|
7
|
+
if (rest === '*' || rest === '^' || rest === '~')
|
|
8
|
+
return { selector: rest };
|
|
9
|
+
return { selector: 'explicit', range: rest };
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Resolves a parsed workspace range against `version` (the dependency's actual current version)
|
|
13
|
+
* into the real range a registry consumer would need - the same substitution pnpm/yarn's own
|
|
14
|
+
* publish performs: `"*"` pins the exact version (no operator), `"^"`/`"~"` prepend themselves to
|
|
15
|
+
* it, and an explicit range is used verbatim (it was already a real range, just workspace-prefixed).
|
|
16
|
+
*/
|
|
17
|
+
export function resolveWorkspaceRange(parsed, version) {
|
|
18
|
+
switch (parsed.selector) {
|
|
19
|
+
case '*':
|
|
20
|
+
return version;
|
|
21
|
+
case '^':
|
|
22
|
+
return `^${version}`;
|
|
23
|
+
case '~':
|
|
24
|
+
return `~${version}`;
|
|
25
|
+
case 'explicit':
|
|
26
|
+
return parsed.range;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import * as yargs from 'yargs';
|
|
2
|
-
import { Repository } from '../core/repository.js';
|
|
3
|
-
import { RunCommand } from './run-command.js';
|
|
4
|
-
export declare class BuildCommand extends RunCommand<any> {
|
|
5
|
-
readonly repository: Repository;
|
|
6
|
-
static commandName: string;
|
|
7
|
-
constructor(repository: Repository, options?: RunCommand.Options);
|
|
8
|
-
}
|
|
9
|
-
export declare namespace BuildCommand {
|
|
10
|
-
function initCli(repository: Repository, program: yargs.Argv): void;
|
|
11
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import * as yargs from 'yargs';
|
|
2
|
-
import { Command } from '../core/command.js';
|
|
3
|
-
import { Repository } from '../core/repository.js';
|
|
4
|
-
import { RunCommand } from './run-command.js';
|
|
5
|
-
export class BuildCommand extends RunCommand {
|
|
6
|
-
repository;
|
|
7
|
-
static commandName = 'build';
|
|
8
|
-
constructor(repository, options) {
|
|
9
|
-
super(repository, 'build', options);
|
|
10
|
-
this.repository = repository;
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
(function (BuildCommand) {
|
|
14
|
-
function initCli(repository, program) {
|
|
15
|
-
program.command({
|
|
16
|
-
command: 'build [options...]',
|
|
17
|
-
describe: 'Alias for "run build"',
|
|
18
|
-
builder: cmd => cmd.example('$0 build', '# Builds packages').option(BuildCommand.cliCommandOptions),
|
|
19
|
-
handler: async (args) => {
|
|
20
|
-
const options = Command.composeOptions(BuildCommand.commandName, args, repository.config);
|
|
21
|
-
await new BuildCommand(repository, options).execute();
|
|
22
|
-
},
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
BuildCommand.initCli = initCli;
|
|
26
|
-
})(BuildCommand || (BuildCommand = {}));
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import * as yargs from 'yargs';
|
|
2
|
-
import { Package } from '../core/package.js';
|
|
3
|
-
import { Repository } from '../core/repository.js';
|
|
4
|
-
import { ListCommand } from './list-command.js';
|
|
5
|
-
export declare class ChangedCommand extends ListCommand {
|
|
6
|
-
readonly repository: Repository;
|
|
7
|
-
static commandName: string;
|
|
8
|
-
constructor(repository: Repository, options?: ListCommand.Options);
|
|
9
|
-
protected _filter(pkg: Package, inf: {
|
|
10
|
-
isDirty?: boolean;
|
|
11
|
-
isCommitted?: boolean;
|
|
12
|
-
}): boolean;
|
|
13
|
-
}
|
|
14
|
-
export declare namespace ChangedCommand {
|
|
15
|
-
function initCli(repository: Repository, program: yargs.Argv): void;
|
|
16
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import * as yargs from 'yargs';
|
|
2
|
-
import { Command } from '../core/command.js';
|
|
3
|
-
import { Package } from '../core/package.js';
|
|
4
|
-
import { Repository } from '../core/repository.js';
|
|
5
|
-
import { ListCommand } from './list-command.js';
|
|
6
|
-
export class ChangedCommand extends ListCommand {
|
|
7
|
-
repository;
|
|
8
|
-
static commandName = 'changed';
|
|
9
|
-
constructor(repository, options) {
|
|
10
|
-
super(repository, options);
|
|
11
|
-
this.repository = repository;
|
|
12
|
-
}
|
|
13
|
-
_filter(pkg, inf) {
|
|
14
|
-
if (!super._filter(pkg, inf))
|
|
15
|
-
return false;
|
|
16
|
-
return !!(inf.isDirty || inf.isCommitted);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
(function (ChangedCommand) {
|
|
20
|
-
function initCli(repository, program) {
|
|
21
|
-
program.command({
|
|
22
|
-
command: 'changed [options...]',
|
|
23
|
-
describe: 'List local packages that have changed since the last tagged release',
|
|
24
|
-
builder: cmd => cmd
|
|
25
|
-
.example('$0 changed', '# List changed packages')
|
|
26
|
-
.example('$0 changed --json', '# List changed packages in JSON format')
|
|
27
|
-
.option(ListCommand.cliCommandOptions),
|
|
28
|
-
handler: async (args) => {
|
|
29
|
-
const options = Command.composeOptions(ChangedCommand.commandName, args, repository.config);
|
|
30
|
-
await new ChangedCommand(repository, options).execute();
|
|
31
|
-
},
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
ChangedCommand.initCli = initCli;
|
|
35
|
-
})(ChangedCommand || (ChangedCommand = {}));
|
package/commands/ci-command.d.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { Task } from 'power-tasks';
|
|
2
|
-
import * as yargs from 'yargs';
|
|
3
|
-
import { Package } from '../core/package.js';
|
|
4
|
-
import { Repository } from '../core/repository.js';
|
|
5
|
-
import type { ExecuteCommandResult } from '../utils/exec.js';
|
|
6
|
-
import { RunCommand } from './run-command.js';
|
|
7
|
-
export declare class CleanInstallCommand extends RunCommand<CleanInstallCommand.Options> {
|
|
8
|
-
readonly repository: Repository;
|
|
9
|
-
static commandName: string;
|
|
10
|
-
constructor(repository: Repository, options?: CleanInstallCommand.Options);
|
|
11
|
-
protected _prepareTasks(packages: Package[]): Promise<Task[]>;
|
|
12
|
-
protected _exec(pkg: Package, command: string, args: {
|
|
13
|
-
cwd?: string;
|
|
14
|
-
dependencies?: string[];
|
|
15
|
-
command: string;
|
|
16
|
-
}, ctx?: any): Promise<ExecuteCommandResult>;
|
|
17
|
-
protected _fsDelete(fileOrDir: string): Promise<void>;
|
|
18
|
-
}
|
|
19
|
-
export declare namespace CleanInstallCommand {
|
|
20
|
-
interface Options extends RunCommand.Options {
|
|
21
|
-
}
|
|
22
|
-
const cliCommandOptions: Record<string, yargs.Options>;
|
|
23
|
-
function initCli(repository: Repository, program: yargs.Argv): void;
|
|
24
|
-
}
|
package/commands/ci-command.js
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import colors from 'ansi-colors';
|
|
2
|
-
import logger from 'npmlog';
|
|
3
|
-
import path from 'path';
|
|
4
|
-
import { Task } from 'power-tasks';
|
|
5
|
-
import * as yargs from 'yargs';
|
|
6
|
-
import { Command } from '../core/command.js';
|
|
7
|
-
import { Package } from '../core/package.js';
|
|
8
|
-
import { Repository } from '../core/repository.js';
|
|
9
|
-
import { fsDelete, fsExists } from '../utils/file-utils.js';
|
|
10
|
-
import { RunCommand } from './run-command.js';
|
|
11
|
-
export class CleanInstallCommand extends RunCommand {
|
|
12
|
-
repository;
|
|
13
|
-
static commandName = 'ci';
|
|
14
|
-
constructor(repository, options) {
|
|
15
|
-
super(repository, 'ci', options);
|
|
16
|
-
this.repository = repository;
|
|
17
|
-
}
|
|
18
|
-
async _prepareTasks(packages) {
|
|
19
|
-
const tasks = await super._prepareTasks(packages);
|
|
20
|
-
const client = this.repository.config.client || 'npm';
|
|
21
|
-
if (!(client === 'npm' || client === 'yargs'))
|
|
22
|
-
throw new Error(`Invalid npm client "${client}"`);
|
|
23
|
-
tasks.push(new Task(async () => {
|
|
24
|
-
const dirname = this.repository.dirname;
|
|
25
|
-
await this._fsDelete(path.join(dirname, 'node_modules'));
|
|
26
|
-
await this._fsDelete(path.join(dirname, 'package-lock.json'));
|
|
27
|
-
await this._fsDelete(path.join(dirname, 'yarn-lock.json'));
|
|
28
|
-
logger.info(this.commandName, colors.yellow('install'), 'Running ' + client + ' install');
|
|
29
|
-
return super._exec(this.repository.rootPackage, client + ' install', {
|
|
30
|
-
stdio: 'inherit',
|
|
31
|
-
});
|
|
32
|
-
}, { exclusive: true }));
|
|
33
|
-
return tasks;
|
|
34
|
-
}
|
|
35
|
-
async _exec(pkg, command, args, ctx) {
|
|
36
|
-
if (command === '#') {
|
|
37
|
-
if (pkg === this.repository.rootPackage)
|
|
38
|
-
return { code: 0 };
|
|
39
|
-
logger.info(this.commandName, 'Clearing ' + pkg.name);
|
|
40
|
-
const cwd = args.cwd || pkg.dirname;
|
|
41
|
-
await this._fsDelete(path.join(cwd, 'node_modules'));
|
|
42
|
-
await this._fsDelete(path.join(cwd, 'package-lock.json'));
|
|
43
|
-
await this._fsDelete(path.join(cwd, 'yarn-lock.json'));
|
|
44
|
-
return { code: 0 };
|
|
45
|
-
}
|
|
46
|
-
return super._exec(pkg, command, args, ctx);
|
|
47
|
-
}
|
|
48
|
-
async _fsDelete(fileOrDir) {
|
|
49
|
-
if (await fsExists(fileOrDir)) {
|
|
50
|
-
logger.info(this.commandName, colors.yellow('rmdir'), path.relative(this.repository.dirname, fileOrDir));
|
|
51
|
-
await fsDelete(fileOrDir);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
(function (CleanInstallCommand) {
|
|
56
|
-
CleanInstallCommand.cliCommandOptions = {
|
|
57
|
-
...RunCommand.cliCommandOptions,
|
|
58
|
-
};
|
|
59
|
-
function initCli(repository, program) {
|
|
60
|
-
program.command({
|
|
61
|
-
command: 'ci [...options]',
|
|
62
|
-
describe: 'Deletes all dependency modules and re-installs',
|
|
63
|
-
builder: cmd => cmd.example('$0 ci', '').option(CleanInstallCommand.cliCommandOptions),
|
|
64
|
-
handler: async (args) => {
|
|
65
|
-
const options = Command.composeOptions(CleanInstallCommand.commandName, args, repository.config);
|
|
66
|
-
await new CleanInstallCommand(repository, options).execute();
|
|
67
|
-
},
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
CleanInstallCommand.initCli = initCli;
|
|
71
|
-
})(CleanInstallCommand || (CleanInstallCommand = {}));
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { Task } from 'power-tasks';
|
|
2
|
-
import * as yargs from 'yargs';
|
|
3
|
-
import { Package } from '../core/package.js';
|
|
4
|
-
import { Repository } from '../core/repository.js';
|
|
5
|
-
import { MultiTaskCommand } from './multi-task-command.js';
|
|
6
|
-
export declare class ExecuteCommand extends MultiTaskCommand<ExecuteCommand.Options> {
|
|
7
|
-
readonly repository: Repository;
|
|
8
|
-
cmd: string;
|
|
9
|
-
argv?: string[] | undefined;
|
|
10
|
-
static commandName: string;
|
|
11
|
-
constructor(repository: Repository, cmd: string, argv?: string[] | undefined, options?: ExecuteCommand.Options);
|
|
12
|
-
protected _prepareTasks(packages: Package[]): Task[];
|
|
13
|
-
}
|
|
14
|
-
export declare namespace ExecuteCommand {
|
|
15
|
-
interface Options extends MultiTaskCommand.Options {
|
|
16
|
-
}
|
|
17
|
-
const cliCommandOptions: Record<string, yargs.Options>;
|
|
18
|
-
function initCli(repository: Repository, program: yargs.Argv): void;
|
|
19
|
-
}
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import colors from 'ansi-colors';
|
|
2
|
-
import logger from 'npmlog';
|
|
3
|
-
import { Task } from 'power-tasks';
|
|
4
|
-
import * as yargs from 'yargs';
|
|
5
|
-
import { Command } from '../core/command.js';
|
|
6
|
-
import { Package } from '../core/package.js';
|
|
7
|
-
import { Repository } from '../core/repository.js';
|
|
8
|
-
import { exec } from '../utils/exec.js';
|
|
9
|
-
import { MultiTaskCommand } from './multi-task-command.js';
|
|
10
|
-
export class ExecuteCommand extends MultiTaskCommand {
|
|
11
|
-
repository;
|
|
12
|
-
cmd;
|
|
13
|
-
argv;
|
|
14
|
-
static commandName = 'exec';
|
|
15
|
-
constructor(repository, cmd, argv, options) {
|
|
16
|
-
super(repository, options);
|
|
17
|
-
this.repository = repository;
|
|
18
|
-
this.cmd = cmd;
|
|
19
|
-
this.argv = argv;
|
|
20
|
-
}
|
|
21
|
-
_prepareTasks(packages) {
|
|
22
|
-
const tasks = [];
|
|
23
|
-
for (const p of packages) {
|
|
24
|
-
const task = new Task(async () => {
|
|
25
|
-
const t = Date.now();
|
|
26
|
-
logger.verbose(this.commandName, p.name, colors.cyanBright.bold('executing'), logger.separator, this.cmd + ' ' + (this.argv?.join(' ') || ''));
|
|
27
|
-
const r = await exec(this.cmd, {
|
|
28
|
-
cwd: p.dirname,
|
|
29
|
-
argv: this.argv,
|
|
30
|
-
stdio: 'inherit', //logger.levelIndex < 1000 ? 'inherit' : 'pipe',
|
|
31
|
-
});
|
|
32
|
-
logger.log(r.error ? 'error' : 'info', this.commandName, p.name, r.error ? colors.red.bold('failed') : colors.green.bold('success'), logger.separator, this.cmd, colors.yellow(' (' + (Date.now() - t) + ' ms') + ')');
|
|
33
|
-
}, {
|
|
34
|
-
name: p.name,
|
|
35
|
-
dependencies: this.options.parallel ? undefined : p.dependencies,
|
|
36
|
-
bail: this.options.bail,
|
|
37
|
-
concurrency: this.options.concurrency,
|
|
38
|
-
});
|
|
39
|
-
tasks.push(task);
|
|
40
|
-
}
|
|
41
|
-
return tasks;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
(function (ExecuteCommand) {
|
|
45
|
-
ExecuteCommand.cliCommandOptions = {
|
|
46
|
-
...MultiTaskCommand.cliCommandOptions,
|
|
47
|
-
};
|
|
48
|
-
function initCli(repository, program) {
|
|
49
|
-
program.command({
|
|
50
|
-
command: 'exec [cmd] [args..]',
|
|
51
|
-
describe: 'Execute an arbitrary command in each package',
|
|
52
|
-
builder: cmd => cmd
|
|
53
|
-
.example('$0 exec -- ls', '')
|
|
54
|
-
.example('$0 exec -- rm -rf ./node_modules', '')
|
|
55
|
-
.parserConfiguration({
|
|
56
|
-
'populate--': true,
|
|
57
|
-
})
|
|
58
|
-
.positional('cmd', {
|
|
59
|
-
describe: 'The command to execute. Any command flags must be passed after --',
|
|
60
|
-
type: 'string',
|
|
61
|
-
})
|
|
62
|
-
.positional('args', {
|
|
63
|
-
describe: 'Positional arguments to send to command',
|
|
64
|
-
type: 'string',
|
|
65
|
-
})
|
|
66
|
-
.option(ExecuteCommand.cliCommandOptions),
|
|
67
|
-
handler: async (args) => {
|
|
68
|
-
const argv = args['--'] || [];
|
|
69
|
-
const options = Command.composeOptions(ExecuteCommand.commandName, args, repository.config);
|
|
70
|
-
await new ExecuteCommand(repository, '' + argv.shift(), argv, options).execute();
|
|
71
|
-
},
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
ExecuteCommand.initCli = initCli;
|
|
75
|
-
})(ExecuteCommand || (ExecuteCommand = {}));
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import * as yargs from 'yargs';
|
|
2
|
-
import { Command } from '../core/command.js';
|
|
3
|
-
import { Repository } from '../core/repository.js';
|
|
4
|
-
export declare class InfoCommand extends Command {
|
|
5
|
-
static commandName: string;
|
|
6
|
-
protected _execute(): Promise<any>;
|
|
7
|
-
}
|
|
8
|
-
export declare namespace InfoCommand {
|
|
9
|
-
function initCli(repository: Repository, program: yargs.Argv): void;
|
|
10
|
-
}
|
package/commands/info-command.js
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import colors from 'ansi-colors';
|
|
2
|
-
import envinfo from 'envinfo';
|
|
3
|
-
import semver from 'semver';
|
|
4
|
-
import * as yargs from 'yargs';
|
|
5
|
-
import { Command } from '../core/command.js';
|
|
6
|
-
import { Repository } from '../core/repository.js';
|
|
7
|
-
export class InfoCommand extends Command {
|
|
8
|
-
static commandName = 'info';
|
|
9
|
-
async _execute() {
|
|
10
|
-
const systemInfo = JSON.parse(await envinfo.run({
|
|
11
|
-
System: ['OS', 'CPU', 'Memory', 'Shell'],
|
|
12
|
-
Binaries: ['Node', 'Yarn', 'npm'],
|
|
13
|
-
Utilities: ['Git'],
|
|
14
|
-
npmPackages: ['rman', 'typescript'],
|
|
15
|
-
npmGlobalPackages: ['typescript'],
|
|
16
|
-
}, { json: true }));
|
|
17
|
-
if (this.options.json) {
|
|
18
|
-
this.logger.output('', '%j', systemInfo);
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
const maxName = Object.keys(systemInfo).reduce((l, p) => Object.keys(systemInfo[p]).reduce((i, x) => (l = Math.max(i, x.length)), l), 0);
|
|
22
|
-
for (const [categoryName, category] of Object.entries(systemInfo)) {
|
|
23
|
-
this.logger.output('', '', colors.whiteBright(categoryName) + ':');
|
|
24
|
-
for (const [n, v] of Object.entries(category)) {
|
|
25
|
-
const label = ' ' + colors.reset(n) + ' '.repeat(maxName - n.length) + ' :';
|
|
26
|
-
if (typeof v === 'string') {
|
|
27
|
-
this.logger.output('', label, colors.yellowBright(v));
|
|
28
|
-
continue;
|
|
29
|
-
}
|
|
30
|
-
if (v.version) {
|
|
31
|
-
this.logger.output('', label, colors.yellowBright(v.version), v.path ? ' ' + colors.yellow(v.path) : '');
|
|
32
|
-
}
|
|
33
|
-
if (v.installed) {
|
|
34
|
-
if (v.wanted === 'latest' || semver.intersects(v.installed, v.wanted)) {
|
|
35
|
-
this.logger.output('', label, colors.yellowBright(v.installed));
|
|
36
|
-
}
|
|
37
|
-
else
|
|
38
|
-
this.logger.output('', label, colors.red(v.installed), ' => ', colors.yellowBright(v.wanted));
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
(function (InfoCommand) {
|
|
45
|
-
function initCli(repository, program) {
|
|
46
|
-
program.command({
|
|
47
|
-
command: 'info [options...]',
|
|
48
|
-
describe: 'Prints local environment information',
|
|
49
|
-
builder: cmd => cmd.example('$0 info', '# Prints information').example('$0 info --json', '# Prints information in JSON format'),
|
|
50
|
-
handler: async (args) => {
|
|
51
|
-
const options = Command.composeOptions(InfoCommand.commandName, args, repository.config);
|
|
52
|
-
await new InfoCommand(options).execute();
|
|
53
|
-
},
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
InfoCommand.initCli = initCli;
|
|
57
|
-
})(InfoCommand || (InfoCommand = {}));
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import EasyTable from 'easy-table';
|
|
2
|
-
import * as yargs from 'yargs';
|
|
3
|
-
import { Command } from '../core/command.js';
|
|
4
|
-
import { Package } from '../core/package.js';
|
|
5
|
-
import { Repository } from '../core/repository.js';
|
|
6
|
-
export declare class ListCommand<TOptions extends ListCommand.Options = ListCommand.Options> extends Command<TOptions> {
|
|
7
|
-
readonly repository: Repository;
|
|
8
|
-
static commandName: string;
|
|
9
|
-
onPrepare?(pkg: Package, data: ListCommand.PackageOutput): ListCommand.PackageOutput;
|
|
10
|
-
onPrintTable?(pkg: Package, data: ListCommand.PackageOutput, table: EasyTable): ListCommand.PackageOutput;
|
|
11
|
-
constructor(repository: Repository, options?: TOptions);
|
|
12
|
-
protected _filter(pkg: Package, inf: {
|
|
13
|
-
isDirty?: boolean;
|
|
14
|
-
isCommitted?: boolean;
|
|
15
|
-
}): boolean;
|
|
16
|
-
protected _execute(): Promise<any>;
|
|
17
|
-
}
|
|
18
|
-
export declare namespace ListCommand {
|
|
19
|
-
interface Options {
|
|
20
|
-
json?: boolean;
|
|
21
|
-
parseable?: boolean;
|
|
22
|
-
short?: boolean;
|
|
23
|
-
toposort?: boolean;
|
|
24
|
-
graph?: boolean;
|
|
25
|
-
changed?: boolean;
|
|
26
|
-
filter?: string | ((pkg: Package) => boolean);
|
|
27
|
-
}
|
|
28
|
-
interface PackageOutput {
|
|
29
|
-
name: string;
|
|
30
|
-
version?: string;
|
|
31
|
-
location?: string;
|
|
32
|
-
private?: boolean;
|
|
33
|
-
isDirty?: boolean;
|
|
34
|
-
isCommitted?: boolean;
|
|
35
|
-
}
|
|
36
|
-
const cliCommandOptions: Record<string, yargs.Options>;
|
|
37
|
-
function initCli(repository: Repository, program: yargs.Argv): void;
|
|
38
|
-
}
|