rman 1.3.0 → 2.0.0-beta.3

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 (187) hide show
  1. package/README.md +65 -31
  2. package/builtins/platforms/node/augmentation/rmanrc.augmentation.d.ts +83 -0
  3. package/builtins/platforms/node/augmentation/system-info.augmentation.d.ts +26 -0
  4. package/builtins/platforms/node/augmentation/system-info.augmentation.js +79 -0
  5. package/builtins/platforms/node/commands/ci.command.d.ts +133 -0
  6. package/builtins/platforms/node/commands/ci.command.js +60 -0
  7. package/builtins/platforms/node/commands/clean.command.d.ts +185 -0
  8. package/builtins/platforms/node/commands/clean.command.js +74 -0
  9. package/builtins/platforms/node/index.d.ts +8 -0
  10. package/builtins/platforms/node/index.js +8 -0
  11. package/builtins/platforms/node/node-config.interface.d.ts +76 -0
  12. package/builtins/platforms/node/node-config.interface.js +7 -0
  13. package/builtins/platforms/node/node-manifest.provider.d.ts +68 -0
  14. package/builtins/platforms/node/node-manifest.provider.js +125 -0
  15. package/builtins/platforms/node/node.platform.d.ts +53 -0
  16. package/builtins/platforms/node/node.platform.js +134 -0
  17. package/builtins/platforms/node/services/ci.service.d.ts +47 -0
  18. package/builtins/platforms/node/services/ci.service.js +213 -0
  19. package/builtins/platforms/node/services/clean.service.d.ts +53 -0
  20. package/builtins/platforms/node/services/clean.service.js +237 -0
  21. package/builtins/platforms/node/services/publish.service.d.ts +114 -0
  22. package/builtins/platforms/node/services/publish.service.js +371 -0
  23. package/builtins/platforms/node/services/version-plan.service.d.ts +44 -0
  24. package/builtins/platforms/node/services/version-plan.service.js +58 -0
  25. package/builtins/platforms/node/utils/workspace-range.d.ts +26 -0
  26. package/builtins/platforms/node/utils/workspace-range.js +28 -0
  27. package/builtins/presets/index.d.ts +15 -0
  28. package/builtins/presets/index.js +57 -0
  29. package/builtins/presets/node.d.ts +16 -0
  30. package/builtins/presets/node.js +57 -0
  31. package/{services → builtins/publish-targets/docker}/docker-publish.service.d.ts +52 -31
  32. package/{services → builtins/publish-targets/docker}/docker-publish.service.js +49 -26
  33. package/builtins/publish-targets/docker/docker.target.d.ts +54 -0
  34. package/builtins/publish-targets/docker/docker.target.js +40 -0
  35. package/builtins/publish-targets/docker/index.d.ts +2 -0
  36. package/builtins/publish-targets/docker/index.js +2 -0
  37. package/builtins/publish-targets/npm/index.d.ts +2 -0
  38. package/builtins/publish-targets/npm/index.js +2 -0
  39. package/builtins/publish-targets/npm/npm-publish-target.d.ts +73 -0
  40. package/builtins/publish-targets/npm/npm-publish-target.js +95 -0
  41. package/builtins/publish-targets/npm/npm-view.d.ts +48 -0
  42. package/builtins/publish-targets/npm/npm-view.js +71 -0
  43. package/cli.d.ts +8 -0
  44. package/cli.js +228 -93
  45. package/commands/build.command.d.ts +177 -3
  46. package/commands/build.command.js +20 -10
  47. package/commands/changelog.command.d.ts +296 -3
  48. package/commands/changelog.command.js +127 -43
  49. package/commands/config.command.d.ts +44 -3
  50. package/commands/config.command.js +53 -24
  51. package/commands/diff.command.d.ts +37 -3
  52. package/commands/diff.command.js +25 -16
  53. package/commands/exec.command.d.ts +193 -3
  54. package/commands/exec.command.js +60 -58
  55. package/commands/github-release.command.d.ts +154 -3
  56. package/commands/github-release.command.js +67 -37
  57. package/commands/import.command.d.ts +36 -3
  58. package/commands/import.command.js +28 -20
  59. package/commands/info.command.d.ts +35 -7
  60. package/commands/info.command.js +36 -30
  61. package/commands/lint.command.d.ts +176 -0
  62. package/commands/lint.command.js +34 -0
  63. package/commands/list.command.d.ts +163 -3
  64. package/commands/list.command.js +109 -71
  65. package/commands/publish.command.d.ts +231 -0
  66. package/commands/publish.command.js +304 -0
  67. package/commands/run.command.d.ts +186 -6
  68. package/commands/run.command.js +26 -72
  69. package/commands/test.command.d.ts +173 -3
  70. package/commands/test.command.js +16 -10
  71. package/commands/version.command.d.ts +330 -3
  72. package/commands/version.command.js +292 -78
  73. package/commands.d.ts +32 -0
  74. package/commands.js +28 -0
  75. package/constants.js +1 -1
  76. package/core/application.d.ts +116 -0
  77. package/core/application.js +160 -0
  78. package/core/classes/package.d.ts +219 -0
  79. package/core/classes/package.js +214 -0
  80. package/core/classes/registry.d.ts +30 -0
  81. package/core/classes/registry.js +47 -0
  82. package/core/{repository.d.ts → classes/repository.d.ts} +69 -20
  83. package/core/{repository.js → classes/repository.js} +195 -75
  84. package/core/classes/service.d.ts +49 -0
  85. package/core/classes/service.js +40 -0
  86. package/core/{version-scheme.d.ts → classes/version-scheme.d.ts} +23 -1
  87. package/core/{version-scheme.js → classes/version-scheme.js} +29 -1
  88. package/core/classes/workspace.d.ts +275 -0
  89. package/core/classes/workspace.js +537 -0
  90. package/core/command-builder.d.ts +14 -0
  91. package/core/command-builder.js +94 -0
  92. package/core/config/config-file-scope.d.ts +107 -0
  93. package/core/config/config-file-scope.js +226 -0
  94. package/core/config/config-interpolator.d.ts +164 -0
  95. package/core/config/config-interpolator.js +577 -0
  96. package/core/config/config-paths.d.ts +65 -0
  97. package/core/config/config-paths.js +78 -0
  98. package/core/config/config-reader.d.ts +192 -0
  99. package/core/config/config-reader.js +727 -0
  100. package/core/{merge-config.d.ts → config/merge-config.d.ts} +33 -34
  101. package/core/config/merge-config.js +260 -0
  102. package/core/{resolve-target.d.ts → config/resolve-config-target.d.ts} +1 -1
  103. package/core/{resolve-target.js → config/resolve-config-target.js} +1 -1
  104. package/core/{custom-command.d.ts → interfaces/custom-command.d.ts} +46 -10
  105. package/core/{custom-command.js → interfaces/custom-command.js} +44 -17
  106. package/core/{manifest.d.ts → interfaces/manifest.d.ts} +49 -27
  107. package/core/interfaces/manifest.js +132 -0
  108. package/core/interfaces/plugin.d.ts +174 -0
  109. package/core/interfaces/plugin.js +124 -0
  110. package/core/interfaces/publish-target.d.ts +136 -0
  111. package/core/interfaces/publish-target.js +43 -0
  112. package/core/{run-step.d.ts → interfaces/run-step.d.ts} +4 -4
  113. package/core/interfaces/run-step.js +1 -0
  114. package/core/plugin-loader.d.ts +25 -0
  115. package/core/plugin-loader.js +53 -0
  116. package/index.d.ts +122 -24
  117. package/index.js +66 -16
  118. package/interfaces/config-scope.interface.d.ts +223 -0
  119. package/interfaces/config-scope.interface.js +1 -0
  120. package/interfaces/rman-config.interface.d.ts +821 -203
  121. package/interfaces/rman-config.interface.js +78 -1
  122. package/package.json +3 -1
  123. package/services/change-hash.service.d.ts +42 -8
  124. package/services/change-hash.service.js +92 -13
  125. package/services/changelog.service.d.ts +91 -52
  126. package/services/changelog.service.js +460 -74
  127. package/services/config-service.d.ts +8 -0
  128. package/services/config-service.js +3 -0
  129. package/services/exec.service.d.ts +23 -12
  130. package/services/exec.service.js +14 -9
  131. package/services/github-release.service.d.ts +45 -34
  132. package/services/github-release.service.js +15 -12
  133. package/services/import.service.d.ts +25 -14
  134. package/services/import.service.js +9 -5
  135. package/services/list.service.d.ts +67 -13
  136. package/services/list.service.js +62 -15
  137. package/services/run.service.d.ts +35 -22
  138. package/services/run.service.js +316 -233
  139. package/services/system-info.d.ts +1 -1
  140. package/services/version-plan.service.d.ts +35 -8
  141. package/services/version-plan.service.js +96 -36
  142. package/services/version.service.d.ts +34 -14
  143. package/services/version.service.js +35 -16
  144. package/services.d.ts +1 -1
  145. package/services.js +1 -1
  146. package/utils/bin-path.d.ts +6 -7
  147. package/utils/bin-path.js +7 -18
  148. package/utils/branch-guard.d.ts +30 -1
  149. package/utils/branch-guard.js +31 -0
  150. package/utils/color-yaml.d.ts +8 -0
  151. package/utils/color-yaml.js +86 -0
  152. package/utils/exec.d.ts +10 -0
  153. package/utils/exec.js +1 -1
  154. package/utils/git.d.ts +26 -0
  155. package/utils/git.js +65 -0
  156. package/utils/logger.d.ts +2 -2
  157. package/utils/logger.js +1 -1
  158. package/utils/package-filter.d.ts +135 -8
  159. package/utils/package-filter.js +204 -16
  160. package/utils/printable-config.d.ts +9 -1
  161. package/utils/printable-config.js +46 -1
  162. package/utils/progress-panel.d.ts +9 -0
  163. package/utils/progress-panel.js +23 -1
  164. package/utils/release-version.d.ts +1 -1
  165. package/utils/run-bin.d.ts +10 -0
  166. package/utils/run-bin.js +1 -1
  167. package/utils/run-options.d.ts +97 -0
  168. package/utils/run-options.js +81 -0
  169. package/utils/version-group.d.ts +31 -0
  170. package/utils/version-group.js +43 -0
  171. package/utils/version-stamp.d.ts +1 -1
  172. package/utils/version-stamp.js +1 -1
  173. package/commands/changed.command.d.ts +0 -3
  174. package/commands/changed.command.js +0 -29
  175. package/core/config.d.ts +0 -409
  176. package/core/config.js +0 -939
  177. package/core/extends-config.d.ts +0 -27
  178. package/core/extends-config.js +0 -89
  179. package/core/manifest.js +0 -150
  180. package/core/merge-config.js +0 -219
  181. package/core/package.d.ts +0 -83
  182. package/core/package.js +0 -106
  183. package/core/plugin.d.ts +0 -112
  184. package/core/plugin.js +0 -189
  185. package/core/workspace.d.ts +0 -68
  186. package/core/workspace.js +0 -83
  187. /package/{core/run-step.js → builtins/platforms/node/augmentation/rmanrc.augmentation.js} +0 -0
@@ -1,26 +1,39 @@
1
1
  import path from 'node:path';
2
2
  import colors from 'ansi-colors';
3
3
  import * as yaml from 'js-yaml';
4
- import { DEFERRED_PATHS } from '../core/config.js';
5
- import { applyRootOption, readRootOption } from '../utils/package-filter.js';
6
- import { printableConfig } from '../utils/printable-config.js';
7
- export function initCli(repository, program) {
8
- program.command({
9
- command: 'config',
4
+ import { DEFERRED_PATHS } from '../core/config/config-paths.js';
5
+ import { ConfigReader } from '../core/config/config-reader.js';
6
+ import { registerCommand } from '../interfaces/rman-config.interface.js';
7
+ import { colorYaml } from '../utils/color-yaml.js';
8
+ import { fromRootOption, readFromRootOption } from '../utils/package-filter.js';
9
+ import { printableConfig, withoutContributions } from '../utils/printable-config.js';
10
+ const COMMAND = 'config';
11
+ const config = {
12
+ ...fromRootOption('Print the config for'),
13
+ json: {
14
+ target: 'cli',
15
+ describe: 'Print as JSON instead of YAML - nothing else on stdout, so it can be piped.',
16
+ type: 'boolean',
17
+ default: false,
18
+ },
19
+ };
20
+ /** Prints config; declares none of its own, so it contributes nothing to `RmanConfig`. */
21
+ const configCommand = registerCommand(app => {
22
+ const repository = app.repository;
23
+ return {
24
+ command: COMMAND,
10
25
  describe: 'Prints the effective .rmanrc config for the package of the current directory',
11
- builder: cmd => applyRootOption(cmd, 'Print the config for')
12
- .example('$0 config', '# The config of the package you are standing in')
13
- .example('$0 config --root', "# The repository root's own config instead")
14
- .example('$0 config --json | jq .version', '# Machine-readable')
15
- .option('json', {
16
- describe: 'Print as JSON instead of YAML - nothing else on stdout, so it can be piped.',
17
- type: 'boolean',
18
- default: false,
19
- }),
20
- handler: args => {
21
- const target = (!readRootOption(args) && repository.currentPackage) || repository.rootPackage;
26
+ config,
27
+ examples: [
28
+ { command: '$0 config', description: '# The config of the package you are standing in' },
29
+ { command: '$0 config --from-root', description: "# The repository root's own config instead" },
30
+ { command: '$0 config --json | jq .version', description: '# Machine-readable' },
31
+ ],
32
+ handler: (args) => {
33
+ const target = (!readFromRootOption(args) && repository.currentPackage) || repository.rootPackage;
34
+ const settings = withoutContributions(target.config);
22
35
  if (args.json) {
23
- console.log(JSON.stringify(printableConfig(target.config), undefined, 2));
36
+ console.log(JSON.stringify(printableConfig(settings), undefined, 2));
24
37
  return;
25
38
  }
26
39
  /**
@@ -31,18 +44,34 @@ export function initCli(repository, program) {
31
44
  * itself off for a pipe here). The repository's own convention for this is
32
45
  * `process.stdout.isTTY`, as `run`/`exec`'s progress panel uses.
33
46
  */
34
- const comment = (text) => (process.stdout.isTTY ? colors.gray(text) : text);
47
+ const tty = !!process.stdout.isTTY;
48
+ const comment = (text) => (tty ? colors.gray(text) : text);
35
49
  const relativeDir = path.relative(repository.dirname, target.dirname) || '.';
50
+ /**
51
+ * **The file you would open to change this**, headed first because that is the next thing a
52
+ * reader wants. Omitted for a directory that declares none - naming a file that is not there
53
+ * would send them to create one when the answer is a level above.
54
+ *
55
+ * It is the package's **own** file and the printed config is more than it: the directory
56
+ * chain above, every `extends` base and each `"[selector]"` block are all in there. The
57
+ * per-key answer is `ORIGINS`, which is what a failing expression's message already names -
58
+ * this line is the starting point, not the whole provenance.
59
+ */
60
+ const source = new ConfigReader().findConfigSource(target.dirname);
61
+ if (source)
62
+ console.log(comment(`# ${path.basename(source)}`));
36
63
  console.log(comment(`# ${target.name} (${relativeDir})`));
37
64
  for (const note of deferredNotes(target))
38
65
  console.log(comment(`# ${note}`));
39
66
  /** `noRefs`: a value appearing twice in the config is the *same object* after merging, and
40
67
  * js-yaml would otherwise emit the second as an `*anchor` reference - valid YAML that reads
41
68
  * as a mistake in something meant to be looked at. */
42
- console.log(yaml.dump(printableConfig(target.config), { noRefs: true, lineWidth: 100 }).trimEnd());
69
+ const body = yaml.dump(printableConfig(settings), { noRefs: true, lineWidth: 100 }).trimEnd();
70
+ console.log(tty ? colorYaml(body) : body);
43
71
  },
44
- });
45
- }
72
+ };
73
+ });
74
+ export default configCommand;
46
75
  /**
47
76
  * The one honest caveat about this output: **`version.before`/`.exec`/`.after` are printed raw**,
48
77
  * expressions and all, because they are the paths in `DEFERRED_PATHS` - `${{ pkg.targetVersion }}`
@@ -56,6 +85,6 @@ function deferredNotes(pkg) {
56
85
  return [];
57
86
  return [`${raw.join(', ')}: printed raw - evaluated by "version" itself, once it knows the target version`];
58
87
  }
59
- function valueAt(config, dotted) {
60
- return dotted.split('.').reduce((node, key) => (node == null ? undefined : node[key]), config);
88
+ function valueAt(node, dotted) {
89
+ return dotted.split('.').reduce((current, key) => (current == null ? undefined : current[key]), node);
61
90
  }
@@ -1,3 +1,37 @@
1
- import type { Argv } from 'yargs';
2
- import type { Repository } from '../core/repository.js';
3
- export declare function initCli(repository: Repository, program: Argv): void;
1
+ import { type RmanConfig } from '../interfaces/rman-config.interface.js';
2
+ declare const COMMAND: "diff [package]";
3
+ declare const config: {
4
+ fromRoot: {
5
+ target: "cli";
6
+ cliName: string;
7
+ alias: string;
8
+ describe: string;
9
+ type: "boolean";
10
+ };
11
+ };
12
+ type Args = RmanConfig.ArgsOf<typeof config, typeof COMMAND>;
13
+ declare const diffCommand: (app: import("../index.js").RmanApplication) => {
14
+ command: "diff [package]";
15
+ describe: string;
16
+ config: {
17
+ fromRoot: {
18
+ target: "cli";
19
+ cliName: string;
20
+ alias: string;
21
+ describe: string;
22
+ type: "boolean";
23
+ };
24
+ };
25
+ positionals: {
26
+ package: {
27
+ describe: string;
28
+ type: "string";
29
+ };
30
+ };
31
+ examples: {
32
+ command: string;
33
+ description: string;
34
+ }[];
35
+ handler: (args: Args) => Promise<void>;
36
+ };
37
+ export default diffCommand;
@@ -1,21 +1,29 @@
1
1
  import path from 'node:path';
2
2
  import colors from 'ansi-colors';
3
+ import { registerCommand } from '../interfaces/rman-config.interface.js';
3
4
  import { ChangeHashService } from '../services/change-hash.service.js';
4
5
  import { GitHelper } from '../utils/git.js';
5
- import { applyRootOption, readRootOption } from '../utils/package-filter.js';
6
- export function initCli(repository, program) {
7
- program.command({
8
- command: 'diff [package]',
6
+ import { fromRootOption, readFromRootOption } from '../utils/package-filter.js';
7
+ const COMMAND = 'diff [package]';
8
+ const config = fromRootOption('Diff');
9
+ const diffCommand = registerCommand(app => {
10
+ const repository = app.repository;
11
+ return {
12
+ command: COMMAND,
9
13
  describe: "Shows the git diff since a package's (or the whole repository's) last release tag",
10
- builder: cmd => applyRootOption(cmd, 'Diff')
11
- .example('$0 diff', "# Since the repository's own last tag")
12
- .example('$0 diff pkg-a', "# Since pkg-a's own last tag, scoped to its directory")
13
- .example('$0 diff --root', '# The whole repository, from inside a package')
14
- .positional('package', {
15
- describe: 'Package name - diffs just that package, since its own last tag. Omit to diff the whole ' +
16
- "repository since its own last tag (or the current directory's package, if standing inside one).",
17
- type: 'string',
18
- }),
14
+ config,
15
+ positionals: {
16
+ package: {
17
+ describe: 'Package name - diffs just that package, since its own last tag. Omit to diff the whole ' +
18
+ "repository since its own last tag (or the current directory's package, if standing inside one).",
19
+ type: 'string',
20
+ },
21
+ },
22
+ examples: [
23
+ { command: '$0 diff', description: "# Since the repository's own last tag" },
24
+ { command: '$0 diff pkg-a', description: "# Since pkg-a's own last tag, scoped to its directory" },
25
+ { command: '$0 diff --from-root', description: '# The whole repository, from inside a package' },
26
+ ],
19
27
  handler: async (args) => {
20
28
  const git = new GitHelper({ cwd: repository.dirname });
21
29
  const packageName = args.package;
@@ -33,7 +41,7 @@ export function initCli(repository, program) {
33
41
  target = pkg;
34
42
  pathspec = path.relative(repository.dirname, pkg.dirname);
35
43
  }
36
- else if (!readRootOption(args) && repository.currentPackage) {
44
+ else if (!readFromRootOption(args) && repository.currentPackage) {
37
45
  /** The measured gap this closes: `diff` narrowed to the current package like `run` and
38
46
  * `changelog` do, but offered no way to say "the whole repository" without naming a
39
47
  * package - and no package name means the repository, so there was nothing to type. */
@@ -52,5 +60,6 @@ export function initCli(repository, program) {
52
60
  }
53
61
  console.log(text);
54
62
  },
55
- });
56
- }
63
+ };
64
+ });
65
+ export default diffCommand;
@@ -1,3 +1,193 @@
1
- import type { Argv } from 'yargs';
2
- import type { Repository } from '../core/repository.js';
3
- export declare function initCli(repository: Repository, program: Argv): void;
1
+ import { type RmanConfig } from '../interfaces/rman-config.interface.js';
2
+ declare const COMMAND: "exec [command..]";
3
+ /**
4
+ * `runOptions` with three texts replaced - the override case the spread order exists for.
5
+ *
6
+ * `exec` takes the same scheduling flags as `run`, but not the same *explanations*: `run`'s mention
7
+ * `.rmanrc run.<script>.bail` and friends, and `exec` runs no script, so there is no such block to
8
+ * point at. The declarations are shared; only the sentences that would be untrue differ.
9
+ */
10
+ declare const config: {
11
+ bail: {
12
+ target: "cli";
13
+ describe: string;
14
+ type: "boolean";
15
+ };
16
+ topo: {
17
+ target: "cli";
18
+ describe: string;
19
+ type: "boolean";
20
+ };
21
+ progress: {
22
+ target: "cli";
23
+ describe: string;
24
+ type: "boolean";
25
+ };
26
+ parallel: {
27
+ target: "cli";
28
+ describe: string;
29
+ coerce: (v: unknown) => boolean | number | undefined;
30
+ };
31
+ changed: {
32
+ target: "cli";
33
+ alias: string;
34
+ describe: string;
35
+ type: "boolean";
36
+ };
37
+ changedSince: {
38
+ target: "cli";
39
+ cliName: string;
40
+ describe: string;
41
+ type: "string";
42
+ conflicts: string;
43
+ };
44
+ fromRoot: {
45
+ target: "cli";
46
+ cliName: string;
47
+ alias: string;
48
+ describe: string;
49
+ type: "boolean";
50
+ };
51
+ allowBranch: {
52
+ target: "cli";
53
+ cliName: string;
54
+ describe: string;
55
+ type: "string";
56
+ };
57
+ ignoreBranch: {
58
+ target: "cli";
59
+ cliName: string;
60
+ describe: string;
61
+ type: "string";
62
+ };
63
+ scope: {
64
+ target: "cli";
65
+ describe: string;
66
+ type: "string";
67
+ };
68
+ ignore: {
69
+ target: "cli";
70
+ describe: string;
71
+ type: "string";
72
+ };
73
+ platform: {
74
+ target: "cli";
75
+ describe: string;
76
+ type: "string";
77
+ };
78
+ deps: {
79
+ target: "cli";
80
+ describe: string;
81
+ type: "boolean";
82
+ };
83
+ dependents: {
84
+ target: "cli";
85
+ describe: string;
86
+ type: "boolean";
87
+ };
88
+ };
89
+ type Args = RmanConfig.ArgsOf<typeof config, typeof COMMAND>;
90
+ declare const execCommand: (app: import("../index.js").RmanApplication) => {
91
+ command: "exec [command..]";
92
+ describe: string;
93
+ /**
94
+ * The two parser switches this command cannot work without: `populate--` keeps everything after
95
+ * `--` out of `exec`'s own options, and `unknown-options-as-args` passes the flags of the command
96
+ * being run through untouched.
97
+ */
98
+ parserConfiguration: {
99
+ 'populate--': true;
100
+ 'unknown-options-as-args': true;
101
+ };
102
+ config: {
103
+ bail: {
104
+ target: "cli";
105
+ describe: string;
106
+ type: "boolean";
107
+ };
108
+ topo: {
109
+ target: "cli";
110
+ describe: string;
111
+ type: "boolean";
112
+ };
113
+ progress: {
114
+ target: "cli";
115
+ describe: string;
116
+ type: "boolean";
117
+ };
118
+ parallel: {
119
+ target: "cli";
120
+ describe: string;
121
+ coerce: (v: unknown) => boolean | number | undefined;
122
+ };
123
+ changed: {
124
+ target: "cli";
125
+ alias: string;
126
+ describe: string;
127
+ type: "boolean";
128
+ };
129
+ changedSince: {
130
+ target: "cli";
131
+ cliName: string;
132
+ describe: string;
133
+ type: "string";
134
+ conflicts: string;
135
+ };
136
+ fromRoot: {
137
+ target: "cli";
138
+ cliName: string;
139
+ alias: string;
140
+ describe: string;
141
+ type: "boolean";
142
+ };
143
+ allowBranch: {
144
+ target: "cli";
145
+ cliName: string;
146
+ describe: string;
147
+ type: "string";
148
+ };
149
+ ignoreBranch: {
150
+ target: "cli";
151
+ cliName: string;
152
+ describe: string;
153
+ type: "string";
154
+ };
155
+ scope: {
156
+ target: "cli";
157
+ describe: string;
158
+ type: "string";
159
+ };
160
+ ignore: {
161
+ target: "cli";
162
+ describe: string;
163
+ type: "string";
164
+ };
165
+ platform: {
166
+ target: "cli";
167
+ describe: string;
168
+ type: "string";
169
+ };
170
+ deps: {
171
+ target: "cli";
172
+ describe: string;
173
+ type: "boolean";
174
+ };
175
+ dependents: {
176
+ target: "cli";
177
+ describe: string;
178
+ type: "boolean";
179
+ };
180
+ };
181
+ positionals: {
182
+ command: {
183
+ describe: string;
184
+ type: "string";
185
+ };
186
+ };
187
+ examples: {
188
+ command: string;
189
+ description: string;
190
+ }[];
191
+ handler: (args: Args) => Promise<void>;
192
+ };
193
+ export default execCommand;
@@ -1,67 +1,68 @@
1
- import { ExecService } from '../services/exec.service.js';
2
- import { applyBranchGuardOptions, assertAllowedBranch, readBranchGuardOptions } from '../utils/branch-guard.js';
3
- import { applyPackageFilterOptions, applyRootOption, readPackageFilterOptions } from '../utils/package-filter.js';
4
- export function initCli(repository, program) {
5
- program.command({
6
- command: 'exec [command..]',
1
+ import { registerCommand } from '../interfaces/rman-config.interface.js';
2
+ import { assertAllowedBranch, readBranchGuardOptions } from '../utils/branch-guard.js';
3
+ import { readPackageFilterOptions } from '../utils/package-filter.js';
4
+ import { runOptions } from '../utils/run-options.js';
5
+ const COMMAND = 'exec [command..]';
6
+ /**
7
+ * `runOptions` with three texts replaced - the override case the spread order exists for.
8
+ *
9
+ * `exec` takes the same scheduling flags as `run`, but not the same *explanations*: `run`'s mention
10
+ * `.rmanrc run.<script>.bail` and friends, and `exec` runs no script, so there is no such block to
11
+ * point at. The declarations are shared; only the sentences that would be untrue differ.
12
+ */
13
+ const config = {
14
+ ...runOptions,
15
+ bail: { target: 'cli', describe: 'Stop on first failure (default: true)', type: 'boolean' },
16
+ topo: {
17
+ target: 'cli',
18
+ describe: 'Respect package dependency order: a package waits for its dependencies and is skipped if one ' +
19
+ 'fails. Set false to run in every matching package independently, alphabetically. Default: true.',
20
+ type: 'boolean',
21
+ },
22
+ progress: {
23
+ target: 'cli',
24
+ describe: 'Show a live progress panel (default: true; auto-disabled when not a TTY)',
25
+ type: 'boolean',
26
+ },
27
+ };
28
+ const execCommand = registerCommand(app => {
29
+ const repository = app.repository;
30
+ return {
31
+ command: COMMAND,
7
32
  describe: 'Runs an arbitrary shell command in each package - unlike run, not tied to any npm script',
8
- builder: cmd => applyRootOption(applyBranchGuardOptions(applyPackageFilterOptions(cmd)), 'Run')
9
- .parserConfiguration({ 'populate--': true, 'unknown-options-as-args': true })
10
- .example('$0 exec rm -rf dist', '# Not an npm script - runs directly in every package')
11
- .example('$0 exec --scope pkg-a -- ls -la', '# "--" needed only if the command shares a flag name with exec\'s own')
12
- .positional('command', {
13
- describe: "The command (and its own arguments) to run in each package - its own flags don't need to be " +
14
- 'escaped unless one happens to share a name with one of these options below, in which case put ' +
15
- '"--" first',
16
- type: 'string',
17
- })
18
- .option('parallel', {
19
- describe: 'Max packages at once: omit/true for CPU count, a number for that many, false to run serially. ' +
20
- 'Packages always run in dependency order unless --no-topo.',
21
- coerce: (v) => {
22
- if (v === undefined)
23
- return undefined;
24
- if (v === 'false' || v === false)
25
- return false;
26
- if (v === 'true' || v === true)
27
- return true;
28
- const n = Number(v);
29
- return Number.isFinite(n) ? n : true;
33
+ /**
34
+ * The two parser switches this command cannot work without: `populate--` keeps everything after
35
+ * `--` out of `exec`'s own options, and `unknown-options-as-args` passes the flags of the command
36
+ * being run through untouched.
37
+ */
38
+ parserConfiguration: { 'populate--': true, 'unknown-options-as-args': true },
39
+ config,
40
+ positionals: {
41
+ command: {
42
+ describe: "The command (and its own arguments) to run in each package - its own flags don't need to be " +
43
+ 'escaped unless one happens to share a name with one of these options below, in which case put ' +
44
+ '"--" first',
45
+ type: 'string',
30
46
  },
31
- })
32
- .option('bail', {
33
- describe: 'Stop on first failure (default: true)',
34
- type: 'boolean',
35
- })
36
- .option('topo', {
37
- describe: 'Respect package dependency order: a package waits for its dependencies and is skipped if one ' +
38
- 'fails. Set false to run in every matching package independently, alphabetically. Default: true.',
39
- type: 'boolean',
40
- })
41
- .option('progress', {
42
- describe: 'Show a live progress panel (default: true; auto-disabled when not a TTY)',
43
- type: 'boolean',
44
- })
45
- .option('changed', {
46
- alias: 'c',
47
- describe: 'Only run in packages that have changed since the last publish',
48
- type: 'boolean',
49
- })
50
- .option('changed-since', {
51
- describe: 'Only run in packages that have changed since the given git commit/hash',
52
- type: 'string',
53
- })
54
- .conflicts('changed', 'changed-since'),
47
+ },
48
+ examples: [
49
+ { command: '$0 exec rm -rf dist', description: '# Not an npm script - runs directly in every package' },
50
+ {
51
+ command: '$0 exec --scope pkg-a -- ls -la',
52
+ description: '# "--" needed only if the command shares a flag name with exec\'s own',
53
+ },
54
+ ],
55
55
  handler: async (args) => {
56
56
  await assertAllowedBranch(repository, readBranchGuardOptions(args));
57
57
  const afterDashDash = args['--'];
58
- const tokens = afterDashDash?.length ? afterDashDash : args.command;
58
+ /** `command` is variadic (`[command..]`), so it arrives as a list - `ArgsOf` reads that off the
59
+ * command string rather than being told. */
60
+ const tokens = afterDashDash?.length ? afterDashDash.map(String) : args.command;
59
61
  if (!tokens?.length) {
60
62
  const err = new Error('No command given - e.g. "rman exec ls" or "rman exec -- eslint --bail"');
61
63
  throw err;
62
64
  }
63
- const command = tokens.join(' ');
64
- await ExecService.exec(repository, command, {
65
+ await app.getService('exec').exec(tokens.join(' '), {
65
66
  ...readPackageFilterOptions(args),
66
67
  parallel: args.parallel,
67
68
  topo: args.topo,
@@ -70,8 +71,9 @@ export function initCli(repository, program) {
70
71
  changed: args.changed,
71
72
  changedSince: args.changedSince,
72
73
  logLevel: args.logLevel,
73
- root: args.root,
74
+ fromRoot: args.fromRoot,
74
75
  });
75
76
  },
76
- });
77
- }
77
+ };
78
+ });
79
+ export default execCommand;