rman 1.2.5 → 2.0.0-beta.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 (153) hide show
  1. package/README.md +63 -19
  2. package/cli.d.ts +5 -0
  3. package/cli.js +214 -88
  4. package/commands/build.command.d.ts +177 -3
  5. package/commands/build.command.js +20 -10
  6. package/commands/changed.command.d.ts +80 -3
  7. package/commands/changed.command.js +19 -12
  8. package/commands/changelog.command.d.ts +192 -3
  9. package/commands/changelog.command.js +87 -43
  10. package/commands/config.command.d.ts +44 -3
  11. package/commands/config.command.js +30 -19
  12. package/commands/diff.command.d.ts +37 -3
  13. package/commands/diff.command.js +25 -16
  14. package/commands/exec.command.d.ts +193 -3
  15. package/commands/exec.command.js +60 -58
  16. package/commands/github-release.command.d.ts +154 -3
  17. package/commands/github-release.command.js +67 -37
  18. package/commands/import.command.d.ts +36 -3
  19. package/commands/import.command.js +28 -20
  20. package/commands/info.command.d.ts +35 -7
  21. package/commands/info.command.js +36 -30
  22. package/commands/list.command.d.ts +163 -3
  23. package/commands/list.command.js +109 -71
  24. package/commands/publish.command.d.ts +231 -0
  25. package/commands/publish.command.js +304 -0
  26. package/commands/run.command.d.ts +186 -6
  27. package/commands/run.command.js +26 -72
  28. package/commands/test.command.d.ts +173 -3
  29. package/commands/test.command.js +16 -10
  30. package/commands/version.command.d.ts +317 -3
  31. package/commands/version.command.js +149 -69
  32. package/commands.d.ts +32 -0
  33. package/commands.js +28 -0
  34. package/constants.js +1 -1
  35. package/core/application.d.ts +116 -0
  36. package/core/application.js +143 -0
  37. package/core/command-builder.d.ts +14 -0
  38. package/core/command-builder.js +78 -0
  39. package/core/config.d.ts +180 -50
  40. package/core/config.js +332 -153
  41. package/core/core-services.d.ts +14 -0
  42. package/core/core-services.js +30 -0
  43. package/core/core-targets.d.ts +14 -0
  44. package/core/core-targets.js +16 -0
  45. package/core/custom-command.d.ts +42 -6
  46. package/core/custom-command.js +44 -17
  47. package/core/extends-config.d.ts +13 -5
  48. package/core/extends-config.js +52 -12
  49. package/core/load-config-module.d.ts +28 -0
  50. package/core/load-config-module.js +42 -0
  51. package/core/manifest.d.ts +47 -25
  52. package/core/manifest.js +51 -69
  53. package/core/merge-config.d.ts +33 -34
  54. package/core/merge-config.js +138 -93
  55. package/core/package.d.ts +145 -17
  56. package/core/package.js +128 -36
  57. package/core/plugin-loader.d.ts +65 -0
  58. package/core/plugin-loader.js +234 -0
  59. package/core/plugin.d.ts +135 -90
  60. package/core/plugin.js +70 -173
  61. package/core/publish-target.d.ts +124 -0
  62. package/core/publish-target.js +30 -0
  63. package/core/registry.d.ts +30 -0
  64. package/core/registry.js +47 -0
  65. package/core/repository.d.ts +72 -9
  66. package/core/repository.js +293 -43
  67. package/core/resolve-target.d.ts +1 -1
  68. package/core/resolve-target.js +1 -1
  69. package/core/service.d.ts +49 -0
  70. package/core/service.js +40 -0
  71. package/core/version-scheme.d.ts +23 -1
  72. package/core/version-scheme.js +29 -1
  73. package/core/workspace.d.ts +84 -33
  74. package/core/workspace.js +63 -22
  75. package/index.d.ts +111 -14
  76. package/index.js +85 -9
  77. package/interfaces/rman-config.interface.d.ts +739 -212
  78. package/interfaces/rman-config.interface.js +61 -1
  79. package/package.json +2 -1
  80. package/plugins/builtins.d.ts +44 -0
  81. package/plugins/builtins.js +33 -0
  82. package/plugins/detect.d.ts +78 -0
  83. package/plugins/detect.js +70 -0
  84. package/plugins/node/augmentation/rman.augmentation.d.ts +84 -0
  85. package/plugins/node/augmentation/rman.augmentation.js +1 -0
  86. package/plugins/node/augmentation/system-info.augmentation.d.ts +26 -0
  87. package/plugins/node/augmentation/system-info.augmentation.js +79 -0
  88. package/plugins/node/commands/ci.command.d.ts +131 -0
  89. package/plugins/node/commands/ci.command.js +59 -0
  90. package/plugins/node/commands/clean.command.d.ts +183 -0
  91. package/plugins/node/commands/clean.command.js +73 -0
  92. package/plugins/node/index.d.ts +29 -0
  93. package/plugins/node/index.js +40 -0
  94. package/plugins/node/node-config.interface.d.ts +77 -0
  95. package/plugins/node/node-config.interface.js +7 -0
  96. package/plugins/node/node-manifest.provider.d.ts +68 -0
  97. package/plugins/node/node-manifest.provider.js +125 -0
  98. package/plugins/node/node.platform.d.ts +53 -0
  99. package/plugins/node/node.platform.js +134 -0
  100. package/plugins/node/npm-publish-target.d.ts +73 -0
  101. package/plugins/node/npm-publish-target.js +96 -0
  102. package/plugins/node/services/ci.service.d.ts +47 -0
  103. package/plugins/node/services/ci.service.js +213 -0
  104. package/plugins/node/services/clean.service.d.ts +53 -0
  105. package/plugins/node/services/clean.service.js +237 -0
  106. package/plugins/node/services/publish.service.d.ts +114 -0
  107. package/plugins/node/services/publish.service.js +371 -0
  108. package/plugins/node/services/version-plan.service.d.ts +44 -0
  109. package/plugins/node/services/version-plan.service.js +58 -0
  110. package/plugins/node/utils/npm-view.d.ts +48 -0
  111. package/plugins/node/utils/npm-view.js +71 -0
  112. package/plugins/node/utils/workspace-range.d.ts +26 -0
  113. package/plugins/node/utils/workspace-range.js +28 -0
  114. package/services/change-hash.service.d.ts +2 -2
  115. package/services/change-hash.service.js +2 -2
  116. package/services/changelog.service.d.ts +62 -51
  117. package/services/changelog.service.js +14 -11
  118. package/services/docker-publish.service.d.ts +50 -29
  119. package/services/docker-publish.service.js +43 -20
  120. package/services/exec.service.d.ts +23 -12
  121. package/services/exec.service.js +14 -9
  122. package/services/github-release.service.d.ts +44 -33
  123. package/services/github-release.service.js +13 -10
  124. package/services/import.service.d.ts +25 -14
  125. package/services/import.service.js +9 -5
  126. package/services/list.service.d.ts +62 -10
  127. package/services/list.service.js +62 -15
  128. package/services/run.service.d.ts +22 -13
  129. package/services/run.service.js +262 -223
  130. package/services/version-plan.service.d.ts +27 -4
  131. package/services/version-plan.service.js +42 -15
  132. package/services/version.service.d.ts +31 -11
  133. package/services/version.service.js +29 -13
  134. package/targets/docker.target.d.ts +53 -0
  135. package/targets/docker.target.js +40 -0
  136. package/utils/bin-path.d.ts +6 -7
  137. package/utils/bin-path.js +7 -18
  138. package/utils/branch-guard.d.ts +29 -0
  139. package/utils/branch-guard.js +31 -0
  140. package/utils/exec.d.ts +10 -0
  141. package/utils/exec.js +1 -1
  142. package/utils/logger.d.ts +1 -1
  143. package/utils/logger.js +1 -1
  144. package/utils/package-filter.d.ts +127 -7
  145. package/utils/package-filter.js +197 -16
  146. package/utils/printable-config.d.ts +1 -1
  147. package/utils/printable-config.js +1 -1
  148. package/utils/run-bin.d.ts +10 -0
  149. package/utils/run-bin.js +1 -1
  150. package/utils/run-options.d.ts +97 -0
  151. package/utils/run-options.js +81 -0
  152. package/utils/version-stamp.d.ts +1 -1
  153. package/utils/version-stamp.js +1 -1
@@ -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;
@@ -1,3 +1,154 @@
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: "github-release";
3
+ declare const config: {
4
+ yes: {
5
+ target: "cli";
6
+ alias: string;
7
+ describe: string;
8
+ type: "boolean";
9
+ };
10
+ dryRun: {
11
+ target: "cli";
12
+ cliName: string;
13
+ describe: string;
14
+ type: "boolean";
15
+ };
16
+ json: {
17
+ target: "cli";
18
+ alias: string;
19
+ describe: string;
20
+ type: "boolean";
21
+ };
22
+ ignoreDirty: {
23
+ target: "cli";
24
+ cliName: string;
25
+ describe: string;
26
+ type: "boolean";
27
+ };
28
+ repository: {
29
+ target: "both";
30
+ describe: string;
31
+ type: "string";
32
+ };
33
+ /** Config-only: details of the release, with no reason to be a flag. `target: 'config'` is what
34
+ * says so, and it is the whole point of the field - a key can exist in `.rmanrc` without
35
+ * existing on the command line. */
36
+ draft: {
37
+ target: "config";
38
+ describe: string;
39
+ type: "boolean";
40
+ };
41
+ prerelease: {
42
+ target: "config";
43
+ describe: string;
44
+ type: "boolean";
45
+ };
46
+ assets: {
47
+ target: "config";
48
+ describe: string;
49
+ /** `type: 'string'` plus `array: true`, not `type: 'array'`: the latter loses the element type
50
+ * and the contribution would read `unknown[]`. This is what keeps `assets` a `string[]` and is
51
+ * why the key needs no `Extra`. */
52
+ type: "string";
53
+ array: true;
54
+ };
55
+ allowBranch: {
56
+ target: "cli";
57
+ cliName: string;
58
+ describe: string;
59
+ type: "string";
60
+ };
61
+ ignoreBranch: {
62
+ target: "cli";
63
+ cliName: string;
64
+ describe: string;
65
+ type: "string";
66
+ };
67
+ };
68
+ type Args = RmanConfig.ArgsOf<typeof config, typeof COMMAND>;
69
+ declare const githubReleaseCommand: (app: import("../index.js").RmanApplication) => {
70
+ command: "github-release";
71
+ /** `githubRelease`, not `github-release`: a config key is camelCase and a command name is
72
+ * hyphenated, and this is the one command out of the whole set where the two differ. */
73
+ configKey: "githubRelease";
74
+ describe: string;
75
+ /** Read, not owned - the release tag's pattern is `version`'s key. */
76
+ configKeys: string[];
77
+ config: {
78
+ yes: {
79
+ target: "cli";
80
+ alias: string;
81
+ describe: string;
82
+ type: "boolean";
83
+ };
84
+ dryRun: {
85
+ target: "cli";
86
+ cliName: string;
87
+ describe: string;
88
+ type: "boolean";
89
+ };
90
+ json: {
91
+ target: "cli";
92
+ alias: string;
93
+ describe: string;
94
+ type: "boolean";
95
+ };
96
+ ignoreDirty: {
97
+ target: "cli";
98
+ cliName: string;
99
+ describe: string;
100
+ type: "boolean";
101
+ };
102
+ repository: {
103
+ target: "both";
104
+ describe: string;
105
+ type: "string";
106
+ };
107
+ /** Config-only: details of the release, with no reason to be a flag. `target: 'config'` is what
108
+ * says so, and it is the whole point of the field - a key can exist in `.rmanrc` without
109
+ * existing on the command line. */
110
+ draft: {
111
+ target: "config";
112
+ describe: string;
113
+ type: "boolean";
114
+ };
115
+ prerelease: {
116
+ target: "config";
117
+ describe: string;
118
+ type: "boolean";
119
+ };
120
+ assets: {
121
+ target: "config";
122
+ describe: string;
123
+ /** `type: 'string'` plus `array: true`, not `type: 'array'`: the latter loses the element type
124
+ * and the contribution would read `unknown[]`. This is what keeps `assets` a `string[]` and is
125
+ * why the key needs no `Extra`. */
126
+ type: "string";
127
+ array: true;
128
+ };
129
+ allowBranch: {
130
+ target: "cli";
131
+ cliName: string;
132
+ describe: string;
133
+ type: "string";
134
+ };
135
+ ignoreBranch: {
136
+ target: "cli";
137
+ cliName: string;
138
+ describe: string;
139
+ type: "string";
140
+ };
141
+ };
142
+ examples: {
143
+ command: string;
144
+ description: string;
145
+ }[];
146
+ handler: (args: Args) => Promise<void>;
147
+ };
148
+ export default githubReleaseCommand;
149
+ declare module '../interfaces/rman-config.interface.js' {
150
+ namespace RmanConfig {
151
+ interface CommandConfigs extends RmanConfig.CommandContribution<ReturnType<typeof githubReleaseCommand>> {
152
+ }
153
+ }
154
+ }
@@ -1,44 +1,73 @@
1
1
  import readline from 'node:readline/promises';
2
2
  import colors from 'ansi-colors';
3
- import { GithubReleaseService } from '../services/github-release.service.js';
4
- import { applyBranchGuardOptions, assertAllowedBranch, readBranchGuardOptions } from '../utils/branch-guard.js';
5
- export function initCli(repository, program) {
6
- program.command({
7
- command: 'github-release',
8
- configKeys: ['githubRelease', 'version.releaseTagPattern'],
3
+ import { registerCommand } from '../interfaces/rman-config.interface.js';
4
+ import { assertAllowedBranch, branchGuardOptions, readBranchGuardOptions } from '../utils/branch-guard.js';
5
+ const COMMAND = 'github-release';
6
+ const config = {
7
+ ...branchGuardOptions,
8
+ yes: {
9
+ target: 'cli',
10
+ alias: 'y',
11
+ describe: 'Skip the confirmation prompt and create the release immediately',
12
+ type: 'boolean',
13
+ },
14
+ dryRun: {
15
+ target: 'cli',
16
+ cliName: 'dry-run',
17
+ describe: 'Only show the plan - never creates anything, regardless of --yes',
18
+ type: 'boolean',
19
+ },
20
+ json: { target: 'cli', alias: 'j', describe: 'Print the plan as JSON instead of text', type: 'boolean' },
21
+ ignoreDirty: {
22
+ target: 'cli',
23
+ cliName: 'ignore-dirty',
24
+ describe: 'Release anyway when the working tree has uncommitted changes, instead of aborting',
25
+ type: 'boolean',
26
+ },
27
+ repository: {
28
+ target: 'both',
29
+ describe: 'The "owner/repo" the release is created in - default: .rmanrc "githubRelease.repository", ' +
30
+ 'falling back to the "origin" remote.',
31
+ type: 'string',
32
+ },
33
+ /** Config-only: details of the release, with no reason to be a flag. `target: 'config'` is what
34
+ * says so, and it is the whole point of the field - a key can exist in `.rmanrc` without
35
+ * existing on the command line. */
36
+ draft: { target: 'config', describe: 'Create the release as a draft', type: 'boolean' },
37
+ prerelease: { target: 'config', describe: 'Mark the release as a prerelease', type: 'boolean' },
38
+ assets: {
39
+ target: 'config',
40
+ describe: "Files to attach to the release, as glob patterns relative to the package's own directory " +
41
+ '(e.g. ["dist/*.tar.gz"]). Read from every package, since one release covers the whole ' +
42
+ 'source tree. A release with no assets at all is still perfectly valid.',
43
+ /** `type: 'string'` plus `array: true`, not `type: 'array'`: the latter loses the element type
44
+ * and the contribution would read `unknown[]`. This is what keeps `assets` a `string[]` and is
45
+ * why the key needs no `Extra`. */
46
+ type: 'string',
47
+ array: true,
48
+ },
49
+ };
50
+ const githubReleaseCommand = registerCommand(app => {
51
+ const repository = app.repository;
52
+ return {
53
+ command: COMMAND,
54
+ /** `githubRelease`, not `github-release`: a config key is camelCase and a command name is
55
+ * hyphenated, and this is the one command out of the whole set where the two differ. */
56
+ configKey: 'githubRelease',
9
57
  describe: "Creates the repository's GitHub Release for the version that just shipped",
10
- builder: cmd => applyBranchGuardOptions(cmd)
11
- .example('$0 github-release', '# Show what would be released, then ask for confirmation')
12
- .example('$0 github-release --yes', '# Create it immediately, no confirmation (CI)')
13
- .example('$0 github-release --dry-run', '# Only show the plan')
14
- .option('yes', {
15
- alias: 'y',
16
- describe: 'Skip the confirmation prompt and create the release immediately',
17
- type: 'boolean',
18
- })
19
- .option('dry-run', {
20
- describe: 'Only show the plan - never creates anything, regardless of --yes',
21
- type: 'boolean',
22
- })
23
- .option('json', {
24
- alias: 'j',
25
- describe: 'Print the plan as JSON instead of text',
26
- type: 'boolean',
27
- })
28
- .option('repository', {
29
- describe: 'The "owner/repo" the release is created in - default: .rmanrc "githubRelease.repository", ' +
30
- 'falling back to the "origin" remote.',
31
- type: 'string',
32
- })
33
- .option('ignore-dirty', {
34
- describe: 'Release anyway when the working tree has uncommitted changes, instead of aborting',
35
- type: 'boolean',
36
- }),
58
+ /** Read, not owned - the release tag's pattern is `version`'s key. */
59
+ configKeys: ['version.releaseTagPattern'],
60
+ config,
61
+ examples: [
62
+ { command: '$0 github-release', description: '# Show what would be released, then ask for confirmation' },
63
+ { command: '$0 github-release --yes', description: '# Create it immediately, no confirmation (CI)' },
64
+ { command: '$0 github-release --dry-run', description: '# Only show the plan' },
65
+ ],
37
66
  handler: async (args) => {
38
67
  await assertAllowedBranch(repository, readBranchGuardOptions(args));
39
68
  // No package filtering: a release belongs to the repository, not to a package, so there is
40
69
  // nothing for --scope/--ignore to narrow down.
41
- const plan = await GithubReleaseService.getPlan(repository, {
70
+ const plan = await app.getService('githubRelease').getPlan({
42
71
  ignoreDirty: args.ignoreDirty,
43
72
  repository: args.repository,
44
73
  });
@@ -93,7 +122,7 @@ export function initCli(repository, program) {
93
122
  }
94
123
  if (!proceed)
95
124
  return;
96
- const applied = await GithubReleaseService.applyPlan(repository, plan);
125
+ const applied = await app.getService('githubRelease').applyPlan(plan);
97
126
  const failed = applied.find(e => e.status === 'error');
98
127
  if (failed) {
99
128
  console.log(colors.red('failed'), colors.cyan(failed.tag ?? ''), colors.red(failed.reason ?? ''));
@@ -106,8 +135,9 @@ export function initCli(repository, program) {
106
135
  console.log(colors.green('released'), colors.cyan(e.tag ?? ''));
107
136
  }
108
137
  },
109
- });
110
- }
138
+ };
139
+ });
140
+ export default githubReleaseCommand;
111
141
  async function confirm(question) {
112
142
  const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
113
143
  try {
@@ -1,3 +1,36 @@
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: "import <path>";
3
+ declare const config: {
4
+ dest: {
5
+ target: "cli";
6
+ describe: string;
7
+ type: "string";
8
+ };
9
+ };
10
+ type Args = RmanConfig.ArgsOf<typeof config, typeof COMMAND>;
11
+ declare const importCommand: (app: import("../index.js").RmanApplication) => {
12
+ command: "import <path>";
13
+ describe: string;
14
+ config: {
15
+ dest: {
16
+ target: "cli";
17
+ describe: string;
18
+ type: "string";
19
+ };
20
+ };
21
+ positionals: {
22
+ path: {
23
+ describe: string;
24
+ type: "string";
25
+ };
26
+ };
27
+ examples: ({
28
+ command: string;
29
+ description?: undefined;
30
+ } | {
31
+ command: string;
32
+ description: string;
33
+ })[];
34
+ handler: (args: Args) => Promise<void>;
35
+ };
36
+ export default importCommand;
@@ -1,27 +1,35 @@
1
1
  import path from 'node:path';
2
2
  import colors from 'ansi-colors';
3
- import { ImportService } from '../services/import.service.js';
4
- export function initCli(repository, program) {
5
- program.command({
6
- command: 'import <path>',
3
+ import { registerCommand } from '../interfaces/rman-config.interface.js';
4
+ const COMMAND = 'import <path>';
5
+ const config = {
6
+ dest: {
7
+ target: 'cli',
8
+ describe: 'Subdirectory the new package is placed under (default: "packages")',
9
+ type: 'string',
10
+ },
11
+ };
12
+ const importCommand = registerCommand(app => {
13
+ const repository = app.repository;
14
+ return {
15
+ command: COMMAND,
7
16
  describe: 'Imports an external git repository as a new package, preserving its full commit history',
8
- builder: cmd => cmd
9
- .example('$0 import ../my-old-repo', '')
10
- .example('$0 import ../my-old-repo --dest libs', '# Under libs/ instead of packages/')
11
- .positional('path', {
12
- describe: 'Path to a local clone of the repository to import (not a URL - clone it first)',
13
- type: 'string',
14
- })
15
- .option('dest', {
16
- describe: 'Subdirectory the new package is placed under (default: "packages")',
17
- type: 'string',
18
- }),
17
+ config,
18
+ positionals: {
19
+ path: {
20
+ describe: 'Path to a local clone of the repository to import (not a URL - clone it first)',
21
+ type: 'string',
22
+ },
23
+ },
24
+ examples: [
25
+ { command: '$0 import ../my-old-repo' },
26
+ { command: '$0 import ../my-old-repo --dest libs', description: '# Under libs/ instead of packages/' },
27
+ ],
19
28
  handler: async (args) => {
20
- const result = await ImportService.importRepo(repository, args.path, {
21
- dest: args.dest,
22
- });
29
+ const result = await app.getService('import').importRepo(args.path, { dest: args.dest });
23
30
  console.log(colors.green('imported'), colors.cyan(result.name), '->', path.relative(repository.dirname, result.targetDir), colors.gray(`(${result.commitCount} commit(s))`));
24
31
  console.log(colors.gray('Add it to your workspaces glob if it is not already covered, then reinstall ("ci").'));
25
32
  },
26
- });
27
- }
33
+ };
34
+ });
35
+ export default importCommand;
@@ -1,12 +1,40 @@
1
- import type { Argv } from 'yargs';
2
- import type { Repository } from '../core/repository.js';
1
+ import { type RmanConfig } from '../interfaces/rman-config.interface.js';
2
+ declare const COMMAND: "info";
3
+ declare const config: {
4
+ json: {
5
+ target: "cli";
6
+ alias: string;
7
+ describe: string;
8
+ type: "boolean";
9
+ };
10
+ };
11
+ type Args = RmanConfig.ArgsOf<typeof config, typeof COMMAND>;
12
+ /** Reports; declares no config key of its own. */
13
+ declare const infoCommand: (app: import("../index.js").RmanApplication) => {
14
+ command: "info";
15
+ describe: string;
16
+ config: {
17
+ json: {
18
+ target: "cli";
19
+ alias: string;
20
+ describe: string;
21
+ type: "boolean";
22
+ };
23
+ };
24
+ examples: {
25
+ command: string;
26
+ description: string;
27
+ }[];
28
+ handler: (args: Args) => Promise<void>;
29
+ };
30
+ export default infoCommand;
3
31
  /**
4
32
  * `rman info` - environment and repository, and back in the core because most of what it reports
5
33
  * (OS, CPU, shell, git, the repository's own shape) is true of any repository.
6
34
  *
7
- * The Node half is not here at all: installing `rman-node` augments `SystemInfo` and the package
8
- * manager, `npmPackages` and this plugin's own version start appearing. Without it nothing
9
- * npm-shaped is asked for or printed, which is the right answer for a repository in any other
10
- * language.
35
+ * The Node half is not written here: registering the `node` built-in augments `SystemInfo` in
36
+ * place, and the package manager and `npmPackages` start appearing. A repository that never names
37
+ * it - or that detection reads as something else - asks for and prints nothing npm-shaped, which is
38
+ * the right answer in any other language. **Bundled is not the same as on**: the built-in ships
39
+ * inside rman, and this is one of the places that difference is visible.
11
40
  */
12
- export declare function initCli(repository: Repository, program: Argv): void;
@@ -1,6 +1,37 @@
1
1
  import colors from 'ansi-colors';
2
2
  import semver from 'semver';
3
+ import { registerCommand } from '../interfaces/rman-config.interface.js';
3
4
  import { SystemInfo } from '../services/system-info.js';
5
+ const COMMAND = 'info';
6
+ const config = {
7
+ json: { target: 'cli', alias: 'j', describe: 'Print output as JSON', type: 'boolean' },
8
+ };
9
+ /** Reports; declares no config key of its own. */
10
+ const infoCommand = registerCommand(app => {
11
+ const repository = app.repository;
12
+ return {
13
+ command: COMMAND,
14
+ describe: 'Prints local environment and repository information',
15
+ config,
16
+ examples: [
17
+ { command: '$0 info', description: '# Prints information' },
18
+ { command: '$0 info --json', description: '# Prints information in JSON format' },
19
+ ],
20
+ handler: async (args) => {
21
+ /** Only the repository - which package manager to report, if any, is a question the core
22
+ * cannot ask. `rman-node`'s augmentation reads `.rmanrc "packageManager"` off this. */
23
+ const systemInfo = await SystemInfo.getSystemInfo({ repository });
24
+ const repositoryInfo = SystemInfo.getRepositoryInfo(repository);
25
+ if (args.json) {
26
+ console.log(JSON.stringify({ ...systemInfo, repository: repositoryInfo }, undefined, 2));
27
+ return;
28
+ }
29
+ printSystemInfo(systemInfo);
30
+ printRepositoryInfo(repositoryInfo);
31
+ },
32
+ };
33
+ });
34
+ export default infoCommand;
4
35
  function printSystemInfo(systemInfo) {
5
36
  const maxName = Object.keys(systemInfo).reduce((l, p) => Object.keys(systemInfo[p]).reduce((i, x) => Math.max(i, x.length), l), 0);
6
37
  for (const [categoryName, category] of Object.entries(systemInfo)) {
@@ -39,34 +70,9 @@ function printRepositoryInfo(info) {
39
70
  * `rman info` - environment and repository, and back in the core because most of what it reports
40
71
  * (OS, CPU, shell, git, the repository's own shape) is true of any repository.
41
72
  *
42
- * The Node half is not here at all: installing `rman-node` augments `SystemInfo` and the package
43
- * manager, `npmPackages` and this plugin's own version start appearing. Without it nothing
44
- * npm-shaped is asked for or printed, which is the right answer for a repository in any other
45
- * language.
73
+ * The Node half is not written here: registering the `node` built-in augments `SystemInfo` in
74
+ * place, and the package manager and `npmPackages` start appearing. A repository that never names
75
+ * it - or that detection reads as something else - asks for and prints nothing npm-shaped, which is
76
+ * the right answer in any other language. **Bundled is not the same as on**: the built-in ships
77
+ * inside rman, and this is one of the places that difference is visible.
46
78
  */
47
- export function initCli(repository, program) {
48
- program.command({
49
- command: 'info',
50
- describe: 'Prints local environment and repository information',
51
- builder: cmd => cmd
52
- .example('$0 info', '# Prints information')
53
- .example('$0 info --json', '# Prints information in JSON format')
54
- .option('json', {
55
- alias: 'j',
56
- describe: 'Print output as JSON',
57
- type: 'boolean',
58
- }),
59
- handler: async (args) => {
60
- /** Only the repository - which package manager to report, if any, is a question the core
61
- * cannot ask. `rman-node`'s augmentation reads `.rmanrc "packageManager"` off this. */
62
- const systemInfo = await SystemInfo.getSystemInfo({ repository });
63
- const repositoryInfo = SystemInfo.getRepositoryInfo(repository);
64
- if (args.json) {
65
- console.log(JSON.stringify({ ...systemInfo, repository: repositoryInfo }, undefined, 2));
66
- return;
67
- }
68
- printSystemInfo(systemInfo);
69
- printRepositoryInfo(repositoryInfo);
70
- },
71
- });
72
- }