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