rman 0.37.4 → 1.0.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.
Files changed (120) hide show
  1. package/README.md +364 -21
  2. package/cli.d.ts +1 -0
  3. package/cli.js +52 -28
  4. package/commands/build.command.d.ts +3 -0
  5. package/commands/build.command.js +14 -0
  6. package/commands/changed.command.d.ts +3 -0
  7. package/commands/changed.command.js +29 -0
  8. package/commands/changelog.command.d.ts +3 -0
  9. package/commands/changelog.command.js +63 -0
  10. package/commands/ci.command.d.ts +3 -0
  11. package/commands/ci.command.js +30 -0
  12. package/commands/clean.command.d.ts +3 -0
  13. package/commands/clean.command.js +36 -0
  14. package/commands/diff.command.d.ts +3 -0
  15. package/commands/diff.command.js +51 -0
  16. package/commands/exec.command.d.ts +3 -0
  17. package/commands/exec.command.js +83 -0
  18. package/commands/import.command.d.ts +3 -0
  19. package/commands/import.command.js +27 -0
  20. package/commands/info.command.d.ts +3 -0
  21. package/commands/info.command.js +61 -0
  22. package/commands/list.command.d.ts +3 -0
  23. package/commands/list.command.js +113 -0
  24. package/commands/publish.command.d.ts +3 -0
  25. package/commands/publish.command.js +147 -0
  26. package/commands/run.command.d.ts +6 -0
  27. package/commands/run.command.js +80 -0
  28. package/commands/test.command.d.ts +3 -0
  29. package/commands/test.command.js +14 -0
  30. package/commands/version.command.d.ts +3 -0
  31. package/commands/version.command.js +125 -0
  32. package/constants.js +1 -1
  33. package/core/config.d.ts +13 -0
  34. package/core/config.js +61 -0
  35. package/core/package.d.ts +2 -0
  36. package/core/package.js +2 -0
  37. package/core/repository.d.ts +36 -3
  38. package/core/repository.js +90 -45
  39. package/index.d.ts +17 -1
  40. package/index.js +15 -1
  41. package/package.json +11 -8
  42. package/services/changelog.service.d.ts +99 -0
  43. package/services/changelog.service.js +272 -0
  44. package/services/ci.service.d.ts +40 -0
  45. package/services/ci.service.js +204 -0
  46. package/services/clean.service.d.ts +42 -0
  47. package/services/clean.service.js +226 -0
  48. package/services/exec.service.d.ts +35 -0
  49. package/services/exec.service.js +114 -0
  50. package/services/import.service.d.ts +30 -0
  51. package/services/import.service.js +84 -0
  52. package/services/list.service.d.ts +27 -0
  53. package/services/list.service.js +25 -0
  54. package/services/publish.service.d.ts +79 -0
  55. package/services/publish.service.js +199 -0
  56. package/services/run.service.d.ts +99 -0
  57. package/services/run.service.js +432 -0
  58. package/services/system-info.d.ts +16 -0
  59. package/services/system-info.js +25 -0
  60. package/services/version.service.d.ts +95 -0
  61. package/services/version.service.js +450 -0
  62. package/services.d.ts +10 -0
  63. package/services.js +10 -0
  64. package/utils/branch-guard.d.ts +25 -0
  65. package/utils/branch-guard.js +61 -0
  66. package/utils/change-hash.d.ts +55 -0
  67. package/utils/change-hash.js +80 -0
  68. package/utils/conventional-commits.d.ts +39 -0
  69. package/utils/conventional-commits.js +43 -0
  70. package/utils/exec.d.ts +5 -6
  71. package/utils/exec.js +46 -60
  72. package/utils/git.d.ts +86 -0
  73. package/utils/git.js +276 -0
  74. package/utils/live-region.d.ts +16 -0
  75. package/utils/live-region.js +59 -0
  76. package/utils/logger.d.ts +24 -0
  77. package/utils/logger.js +39 -0
  78. package/utils/npm-run-path.d.ts +1 -1
  79. package/utils/npm-run-path.js +10 -10
  80. package/utils/package-filter.d.ts +32 -0
  81. package/utils/package-filter.js +73 -0
  82. package/utils/progress-panel.d.ts +59 -0
  83. package/utils/progress-panel.js +149 -0
  84. package/utils/workspace-range.d.ts +17 -0
  85. package/utils/workspace-range.js +28 -0
  86. package/bin/rman.mjs +0 -4
  87. package/commands/build-command.d.ts +0 -11
  88. package/commands/build-command.js +0 -24
  89. package/commands/changed-command.d.ts +0 -16
  90. package/commands/changed-command.js +0 -32
  91. package/commands/ci-command.d.ts +0 -24
  92. package/commands/ci-command.js +0 -68
  93. package/commands/execute-command.d.ts +0 -19
  94. package/commands/execute-command.js +0 -72
  95. package/commands/info-command.d.ts +0 -10
  96. package/commands/info-command.js +0 -55
  97. package/commands/list-command.d.ts +0 -38
  98. package/commands/list-command.js +0 -134
  99. package/commands/multi-task-command.d.ts +0 -22
  100. package/commands/multi-task-command.js +0 -65
  101. package/commands/publish-command.d.ts +0 -24
  102. package/commands/publish-command.js +0 -131
  103. package/commands/run-command.d.ts +0 -28
  104. package/commands/run-command.js +0 -131
  105. package/commands/version-command.d.ts +0 -25
  106. package/commands/version-command.js +0 -195
  107. package/core/command.d.ts +0 -35
  108. package/core/command.js +0 -116
  109. package/core/constants.d.ts +0 -1
  110. package/core/constants.js +0 -2
  111. package/core/logger.d.ts +0 -12
  112. package/core/logger.js +0 -2
  113. package/utils/file-utils.d.ts +0 -4
  114. package/utils/file-utils.js +0 -28
  115. package/utils/git-utils.d.ts +0 -25
  116. package/utils/git-utils.js +0 -66
  117. package/utils/npm-utils.d.ts +0 -11
  118. package/utils/npm-utils.js +0 -33
  119. package/utils/package-not-found-error.d.ts +0 -2
  120. package/utils/package-not-found-error.js +0 -2
@@ -1,134 +0,0 @@
1
- import colors from 'ansi-colors';
2
- import EasyTable from 'easy-table';
3
- import logger from 'npmlog';
4
- import path from 'path';
5
- import { Command } from '../core/command.js';
6
- import { GitHelper } from '../utils/git-utils.js';
7
- export class ListCommand extends Command {
8
- repository;
9
- static commandName = 'list';
10
- constructor(repository, options) {
11
- super(options);
12
- this.repository = repository;
13
- }
14
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
15
- _filter(pkg, inf) {
16
- return true;
17
- }
18
- async _execute() {
19
- const { repository } = this;
20
- const packages = repository.getPackages({ toposort: this.options.toposort });
21
- const git = new GitHelper({ cwd: repository.dirname });
22
- const dirtyFiles = await git.listDirtyFiles({ absolute: true });
23
- const committedFiles = await git.listCommittedFiles({ absolute: true });
24
- const table = new EasyTable();
25
- const arr = [];
26
- const obj = {};
27
- let count = 0;
28
- for (const p of packages) {
29
- const isDirty = !!dirtyFiles.find(f => !path.relative(p.dirname, f).startsWith('..'));
30
- const isCommitted = !!committedFiles.find(f => !path.relative(p.dirname, f).startsWith('..'));
31
- if (!this._filter(p, { isDirty, isCommitted }))
32
- continue;
33
- if (this.options.graph) {
34
- count++;
35
- obj[p.name] = [...p.dependencies];
36
- continue;
37
- }
38
- const location = path.relative(repository.dirname, p.dirname);
39
- let o = {
40
- name: p.name,
41
- version: p.version,
42
- location,
43
- private: p.isPrivate,
44
- isDirty,
45
- isCommitted,
46
- };
47
- o = this.onPrepare ? this.onPrepare(p, o) : o;
48
- if (!o)
49
- continue;
50
- arr.push(o);
51
- count++;
52
- if (!this.options.json) {
53
- if (this.options.parseable) {
54
- const a = [
55
- location,
56
- p.name,
57
- p.version,
58
- p.isPrivate ? 'PRIVATE' : '',
59
- isDirty ? 'DIRTY' : isCommitted ? ':COMMITTED' : '',
60
- ];
61
- logger.output('', a.join('::'));
62
- }
63
- else if (this.options.short) {
64
- logger.output('', p.name);
65
- }
66
- else {
67
- if (this.onPrintTable)
68
- this.onPrintTable(p, o, table);
69
- else {
70
- table.cell('Package', colors.yellowBright(p.name));
71
- table.cell('Version', colors.yellow(p.version));
72
- table.cell('Private', p.isPrivate ? colors.magentaBright('yes') : '');
73
- table.cell('Changed', isDirty ? colors.magenta('dirty') : isCommitted ? colors.yellow('committed') : '');
74
- table.cell('Path', path.relative(repository.dirname, p.dirname));
75
- table.newRow();
76
- }
77
- }
78
- }
79
- }
80
- if (this.options.graph) {
81
- logger.output('', '%j', obj);
82
- return obj;
83
- }
84
- if (this.options.json) {
85
- logger.output('', '%j', arr);
86
- return arr;
87
- }
88
- if (table.rows.length) {
89
- logger.output('', '%s', table.toString().trim());
90
- console.log('');
91
- logger.info('list', '%i Package(s) found', count);
92
- return arr;
93
- }
94
- return arr;
95
- }
96
- }
97
- (function (ListCommand) {
98
- ListCommand.cliCommandOptions = {
99
- short: {
100
- alias: 's',
101
- describe: '# Do not show extended information',
102
- },
103
- parseable: {
104
- alias: 'p',
105
- describe: '# Show parseable output',
106
- },
107
- toposort: {
108
- alias: 't',
109
- describe: '# Sort packages in topological order (dependencies before dependents) instead of lexical by directory',
110
- },
111
- graph: {
112
- alias: 'g',
113
- describe: '# Show dependency graph as a JSON-formatted adjacency list',
114
- },
115
- };
116
- function initCli(repository, program) {
117
- program.command({
118
- command: 'list [options...]',
119
- describe: 'Lists packages in repository',
120
- aliases: ['ls'],
121
- builder: cmd => cmd
122
- .example('$0 list', '# List all packages')
123
- .example('$0 list --json', '# List all packages in JSON format')
124
- .conflicts('graph', ['parseable', 'json'])
125
- .conflicts('short', ['parseable', 'json'])
126
- .option(ListCommand.cliCommandOptions),
127
- handler: async (args) => {
128
- const options = Command.composeOptions(ListCommand.commandName, args, repository.config);
129
- await new ListCommand(repository, options).execute();
130
- },
131
- });
132
- }
133
- ListCommand.initCli = initCli;
134
- })(ListCommand || (ListCommand = {}));
@@ -1,22 +0,0 @@
1
- import { Task } from 'power-tasks';
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 abstract class MultiTaskCommand<TOptions extends MultiTaskCommand.Options = MultiTaskCommand.Options> extends Command<TOptions> {
7
- readonly repository: Repository;
8
- protected _task?: Task;
9
- protected constructor(repository: Repository, options?: TOptions);
10
- protected _execute(): Promise<any>;
11
- protected _getPackages(): Promise<Package[]>;
12
- protected abstract _prepareTasks(packages: Package[]): Task[] | Promise<Task[]> | void;
13
- }
14
- export declare namespace MultiTaskCommand {
15
- interface Options extends Command.GlobalOptions {
16
- concurrency?: number;
17
- parallel?: boolean;
18
- bail?: boolean;
19
- progress?: boolean;
20
- }
21
- const cliCommandOptions: Record<string, yargs.Options>;
22
- }
@@ -1,65 +0,0 @@
1
- import os from 'os';
2
- import { Task } from 'power-tasks';
3
- import { toNumber } from 'putil-varhelpers';
4
- import { Command } from '../core/command.js';
5
- import { isTTY } from '../core/constants.js';
6
- export class MultiTaskCommand extends Command {
7
- repository;
8
- _task;
9
- constructor(repository, options) {
10
- super(options);
11
- this.repository = repository;
12
- if (this.options.ci || !isTTY)
13
- this.options.progress = false;
14
- // noinspection SuspiciousTypeOfGuard
15
- this.options.concurrency = toNumber(options?.concurrency);
16
- if (this.options.bail == null)
17
- this.options.bail = true;
18
- }
19
- async _execute() {
20
- const packages = await this._getPackages();
21
- const childTasks = await this._prepareTasks(packages);
22
- if (!(childTasks && childTasks.length)) {
23
- return;
24
- }
25
- // this.enableProgress();
26
- this._task = new Task(childTasks, {
27
- name: '$project-root',
28
- concurrency: this.options.concurrency || os.cpus().length,
29
- bail: this.options.bail,
30
- });
31
- await this._task.toPromise();
32
- }
33
- async _getPackages() {
34
- return this.repository.getPackages({ toposort: !this.options.parallel });
35
- }
36
- }
37
- (function (MultiTaskCommand) {
38
- MultiTaskCommand.cliCommandOptions = {
39
- concurrency: {
40
- describe: '# Set processes count to parallelize tasks. (CPU count if not defined)',
41
- type: 'number',
42
- },
43
- parallel: {
44
- describe: '# Disregards dependency checking and runs the command for every package at same time.',
45
- type: 'boolean',
46
- },
47
- 'no-bail': {
48
- describe: '# Continue execution even one fails.',
49
- type: 'boolean',
50
- },
51
- bail: {
52
- hidden: true,
53
- type: 'boolean',
54
- },
55
- 'no-progress': {
56
- describe: 'Disable progress bars',
57
- type: 'boolean',
58
- },
59
- progress: {
60
- hidden: true,
61
- type: 'boolean',
62
- default: true,
63
- },
64
- };
65
- })(MultiTaskCommand || (MultiTaskCommand = {}));
@@ -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 { ExecuteCommandResult } from '../utils/exec.js';
6
- import { RunCommand } from './run-command.js';
7
- export declare class PublishCommand extends RunCommand<PublishCommand.Options> {
8
- readonly repository: Repository;
9
- static commandName: string;
10
- constructor(repository: Repository, options?: PublishCommand.Options);
11
- protected _prepareTasks(packages: Package[]): Promise<Task[]>;
12
- protected _exec(pkg: Package, command: string, args: {}, options?: any): Promise<ExecuteCommandResult>;
13
- }
14
- export declare namespace PublishCommand {
15
- interface Options extends RunCommand.Options {
16
- contents?: string;
17
- access?: string;
18
- tag?: string;
19
- checkOnly?: boolean;
20
- userconfig?: string;
21
- }
22
- const cliCommandOptions: Record<string, yargs.Options>;
23
- function initCli(repository: Repository, program: yargs.Argv): void;
24
- }
@@ -1,131 +0,0 @@
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 { PackageNotFoundError } from '../utils/package-not-found-error.js';
7
- import { RunCommand } from './run-command.js';
8
- export class PublishCommand extends RunCommand {
9
- repository;
10
- static commandName = 'publish';
11
- constructor(repository, options) {
12
- super(repository, 'publish', {
13
- ...options,
14
- bail: false,
15
- parallel: true,
16
- });
17
- this.repository = repository;
18
- }
19
- async _prepareTasks(packages) {
20
- const newVersions = {};
21
- const selectedPackages = [];
22
- const promises = [];
23
- for (const p of packages) {
24
- const logPkgName = colors.yellow(p.name);
25
- if (p.json.private) {
26
- logger.info(this.commandName, logPkgName, logger.separator, `Ignored. Package is set to "private"`);
27
- continue;
28
- }
29
- logger.info(this.commandName, logPkgName, logger.separator, `Fetching package information from repository`);
30
- const npmHelper = new NpmHelper({ cwd: p.dirname, userconfig: this.options.userconfig });
31
- promises.push(npmHelper
32
- .getPackageInfo(p.json.name)
33
- .then(r => {
34
- const fetchedVersion = r.version;
35
- const sameVersion = fetchedVersion === p.version;
36
- logger.info(this.commandName, logPkgName, logger.separator, sameVersion
37
- ? `No publish needed. Version (${colors.magenta(p.version)}) same in repository`
38
- : `Publishing is possible.` +
39
- ` Version "${colors.magenta(p.version)}" differs from version in repository (${colors.magenta(fetchedVersion)})`);
40
- if (!sameVersion) {
41
- selectedPackages.push(p);
42
- }
43
- })
44
- .catch(e => {
45
- if (e instanceof PackageNotFoundError) {
46
- logger.info(this.commandName, logPkgName, logger.separator, 'Publishing is possible. No package information found in repository');
47
- selectedPackages.push(p);
48
- }
49
- else
50
- throw e;
51
- }));
52
- }
53
- await Promise.all(promises);
54
- if (this.options.checkOnly)
55
- logger.verbose(this.commandName, '', logger.separator, `${selectedPackages.length} packages can be be published`);
56
- else
57
- logger.verbose(this.commandName, '', logger.separator, `${selectedPackages.length} packages will be published`);
58
- selectedPackages.forEach(p => {
59
- p.json.scripts = p.json.scripts || {};
60
- p.json.scripts.publish = '#';
61
- });
62
- return super._prepareTasks(selectedPackages, { newVersions });
63
- }
64
- async _exec(pkg, command, args, options) {
65
- if (command === '#') {
66
- if (pkg === this.repository.rootPackage)
67
- return { code: 0 };
68
- let cwd = pkg.dirname;
69
- if (this.options.contents) {
70
- const contents = this.options.contents.replaceAll('${package.basename}', pkg.basename);
71
- if (contents.startsWith('/'))
72
- cwd = path.join(this.repository.dirname, contents);
73
- else
74
- cwd = path.join(pkg.dirname, contents);
75
- }
76
- const npmHelper = new NpmHelper({ cwd: pkg.dirname, userconfig: this.options.userconfig });
77
- return super._exec(pkg, 'npm publish' +
78
- (this.options.access ? ' --access=' + this.options.access : '') +
79
- (this.options.tag ? ' --tag=' + this.options.tag : '') +
80
- (npmHelper.userconfig ? ` --userconfig="${npmHelper.userconfig}"` : ''), {
81
- ...args,
82
- cwd,
83
- stdio: logger.levelIndex < 1000 ? 'inherit' : 'pipe',
84
- }, options);
85
- }
86
- return super._exec(pkg, command, args, options);
87
- }
88
- }
89
- (function (PublishCommand) {
90
- PublishCommand.cliCommandOptions = {
91
- ...RunCommand.cliCommandOptions,
92
- contents: {
93
- describe: '# Subdirectory to publish',
94
- type: 'string',
95
- },
96
- access: {
97
- describe: '# Tells the registry whether this package should be published as public or restricted. ' +
98
- "Only applies to scoped packages, which default to restricted. If you don't have a paid account, " +
99
- 'you must publish with --access public to publish scoped packages.',
100
- type: 'string',
101
- choices: ['public', 'restricted'],
102
- },
103
- tag: {
104
- describe: '',
105
- type: 'string',
106
- },
107
- userconfig: {
108
- describe: '# Path of .npmrc file to use for authentication',
109
- type: 'string',
110
- },
111
- 'check-only': {
112
- describe: '# Only performs version checking and do not apply "publish" to the registry.',
113
- type: 'boolean',
114
- },
115
- };
116
- function initCli(repository, program) {
117
- program.command({
118
- command: 'publish [...options]',
119
- describe: 'Publish packages in the current project',
120
- builder: cmd => cmd
121
- .example('$0 publish', '')
122
- .example('$0 publish --contents dist', '# publish package from built directory')
123
- .option(PublishCommand.cliCommandOptions),
124
- handler: async (args) => {
125
- const options = Command.composeOptions(PublishCommand.commandName, args, repository.config);
126
- await new PublishCommand(repository, options).execute();
127
- },
128
- });
129
- }
130
- PublishCommand.initCli = initCli;
131
- })(PublishCommand || (PublishCommand = {}));
@@ -1,28 +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 { ExecuteCommandResult } from '../utils/exec.js';
6
- import { MultiTaskCommand } from './multi-task-command.js';
7
- export declare class RunCommand<TOptions extends RunCommand.Options> extends MultiTaskCommand<TOptions> {
8
- readonly repository: Repository;
9
- script: string;
10
- static commandName: string;
11
- constructor(repository: Repository, script: string, options?: TOptions);
12
- protected _prepareTasks(packages: Package[], options?: any): Task[] | Promise<Task[]>;
13
- protected _prepareScriptTask(pkg: Package, options?: any): Task | undefined;
14
- protected _exec(pkg: Package, command: string, args: {
15
- stdio?: 'inherit' | 'pipe';
16
- cwd?: string;
17
- json?: any;
18
- logLevel?: string;
19
- noThrow?: boolean;
20
- script?: string;
21
- }, options?: any): Promise<ExecuteCommandResult>;
22
- }
23
- export declare namespace RunCommand {
24
- interface Options extends MultiTaskCommand.Options {
25
- }
26
- const cliCommandOptions: Record<string, yargs.Options>;
27
- function initCli(repository: Repository, program: yargs.Argv): void;
28
- }
@@ -1,131 +0,0 @@
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 {
9
- repository;
10
- script;
11
- static commandName = 'run';
12
- constructor(repository, script, options) {
13
- super(repository, options);
14
- this.repository = repository;
15
- this.script = script;
16
- }
17
- _prepareTasks(packages, options) {
18
- const packageTasks = [];
19
- for (const p of packages) {
20
- if (p.json.scripts) {
21
- const childTask = this._prepareScriptTask(p, options);
22
- if (childTask) {
23
- packageTasks.push(childTask);
24
- }
25
- }
26
- }
27
- const rootTask = this._prepareScriptTask(this.repository.rootPackage);
28
- const children = rootTask?.options.children;
29
- if (!children)
30
- return packageTasks;
31
- const tasks = [];
32
- const pre = children.filter(t => t.name?.endsWith(':pre' + this.script));
33
- const post = children.filter(t => t.name?.endsWith(':post' + this.script));
34
- pre.forEach(t => (t.options.exclusive = true));
35
- post.forEach(t => (t.options.exclusive = true));
36
- tasks.push(...pre);
37
- tasks.push(...packageTasks);
38
- tasks.push(...post);
39
- return tasks;
40
- }
41
- _prepareScriptTask(pkg, options) {
42
- const json = { ...pkg.json };
43
- json.scripts = json.scripts || {};
44
- json.scripts[this.script] = json.scripts[this.script] || '#';
45
- const scriptInfo = parseNpmScript(json, 'npm run ' + this.script);
46
- if (!(scriptInfo && scriptInfo.raw))
47
- return;
48
- const children = [];
49
- for (const s of scriptInfo.steps) {
50
- const parsed = Array.isArray(s.parsed) ? s.parsed : [s.parsed];
51
- for (const cmd of parsed) {
52
- const task = new Task(async () => await this._exec(pkg, cmd, {
53
- script: s.name,
54
- stdio: logger.levelIndex < 1000 ? 'inherit' : 'pipe',
55
- }, options), {
56
- name: pkg.name + ':' + s.name,
57
- dependencies: this.options.parallel || s.name.startsWith('pre') || s.name.startsWith('post')
58
- ? undefined
59
- : pkg.dependencies,
60
- });
61
- children.push(task);
62
- }
63
- }
64
- if (children.length) {
65
- return new Task(children, {
66
- name: pkg.name,
67
- bail: true,
68
- serial: true,
69
- });
70
- }
71
- }
72
- async _exec(pkg, command, args,
73
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
74
- options) {
75
- const name = pkg === this.repository.rootPackage ? 'root' : pkg.name;
76
- const logLevel = args.logLevel == null ? 'info' : args.logLevel;
77
- if (logLevel) {
78
- logger.verbose(this.commandName, colors.cyan(name), logger.separator, colors.cyanBright.bold(args.script || ''), colors.cyanBright.bold('executing'), logger.separator, command);
79
- }
80
- const t = Date.now();
81
- const cwd = args.cwd || pkg.dirname;
82
- const r = await exec(command, {
83
- cwd,
84
- stdio: args.stdio,
85
- throwOnError: false,
86
- });
87
- if (logLevel) {
88
- if (r.error) {
89
- 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());
90
- }
91
- else {
92
- 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)'));
93
- }
94
- }
95
- if (r.error && !args.noThrow)
96
- throw r.error;
97
- return r;
98
- }
99
- }
100
- (function (RunCommand) {
101
- RunCommand.cliCommandOptions = {
102
- ...MultiTaskCommand.cliCommandOptions,
103
- };
104
- function initCli(repository, program) {
105
- program.command({
106
- command: 'run <script>',
107
- describe: 'Execute an arbitrary script in each package',
108
- builder: cmd => cmd
109
- .example('$0 run build', '')
110
- .positional('script', {
111
- describe: '# The script to execute. Any command flags must be passed after --',
112
- type: 'string',
113
- })
114
- .option(RunCommand.cliCommandOptions),
115
- handler: async (args) => {
116
- const runCfg = repository.config?.command?.run;
117
- if (args.script && runCfg && typeof runCfg === 'object') {
118
- ['parallel', 'bail', 'progress'].forEach(n => {
119
- if (typeof runCfg[n] === 'string') {
120
- runCfg[n] = runCfg[n].split(/\s*,\s*/).includes(String(args.script));
121
- }
122
- });
123
- }
124
- const options = Command.composeOptions(RunCommand.commandName, args, repository.config);
125
- const script = '' + args.script;
126
- await new RunCommand(repository, script, options).execute();
127
- },
128
- });
129
- }
130
- RunCommand.initCli = initCli;
131
- })(RunCommand || (RunCommand = {}));
@@ -1,25 +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 { ExecuteCommandResult } from '../utils/exec.js';
6
- import { RunCommand } from './run-command.js';
7
- export declare class VersionCommand extends RunCommand<VersionCommand.Options> {
8
- readonly repository: Repository;
9
- bump: string;
10
- static commandName: string;
11
- private _updatedPackages;
12
- constructor(repository: Repository, bump: string, options?: VersionCommand.Options);
13
- protected _prepareTasks(packages: Package[]): Promise<Task[]>;
14
- protected _exec(pkg: Package, command: string, args: {}, options?: any): Promise<ExecuteCommandResult>;
15
- }
16
- export declare namespace VersionCommand {
17
- interface Options extends RunCommand.Options {
18
- unified?: boolean;
19
- all?: boolean;
20
- ignoreDirty?: boolean;
21
- noTag?: boolean;
22
- }
23
- const cliCommandOptions: Record<string, yargs.Options>;
24
- function initCli(repository: Repository, program: yargs.Argv): void;
25
- }