@nocobase/cli 2.1.0-alpha.4 → 2.1.0-alpha.40

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 (211) hide show
  1. package/LICENSE.txt +107 -0
  2. package/README.md +393 -19
  3. package/README.zh-CN.md +343 -0
  4. package/bin/run.cmd +3 -0
  5. package/bin/run.js +135 -0
  6. package/bin/session-env.js +39 -0
  7. package/dist/commands/api/resource/create.js +15 -0
  8. package/dist/commands/api/resource/destroy.js +15 -0
  9. package/dist/commands/api/resource/get.js +15 -0
  10. package/dist/commands/api/resource/index.js +20 -0
  11. package/dist/commands/api/resource/list.js +16 -0
  12. package/dist/commands/api/resource/query.js +15 -0
  13. package/dist/commands/api/resource/update.js +15 -0
  14. package/dist/commands/app/down.js +301 -0
  15. package/dist/commands/app/logs.js +114 -0
  16. package/dist/commands/app/restart.js +158 -0
  17. package/dist/commands/app/start.js +305 -0
  18. package/dist/commands/app/stop.js +115 -0
  19. package/dist/commands/app/upgrade.js +636 -0
  20. package/dist/commands/backup/create.js +147 -0
  21. package/dist/commands/backup/index.js +20 -0
  22. package/dist/commands/backup/restore.js +105 -0
  23. package/{src/cli.js → dist/commands/build.js} +4 -11
  24. package/dist/commands/config/delete.js +30 -0
  25. package/dist/commands/config/get.js +29 -0
  26. package/dist/commands/config/index.js +20 -0
  27. package/dist/commands/config/list.js +29 -0
  28. package/dist/commands/config/set.js +35 -0
  29. package/dist/commands/db/check.js +240 -0
  30. package/dist/commands/db/logs.js +85 -0
  31. package/dist/commands/db/ps.js +60 -0
  32. package/dist/commands/db/shared.js +96 -0
  33. package/dist/commands/db/start.js +71 -0
  34. package/dist/commands/db/stop.js +71 -0
  35. package/{templates/plugin/src/client/models/index.ts → dist/commands/dev.js} +4 -4
  36. package/{src/commands/locale/react-js-cron/index.js → dist/commands/down.js} +3 -8
  37. package/dist/commands/download.js +13 -0
  38. package/dist/commands/env/add.js +366 -0
  39. package/dist/commands/env/auth.js +130 -0
  40. package/dist/commands/env/current.js +21 -0
  41. package/dist/commands/env/info.js +157 -0
  42. package/dist/commands/env/list.js +44 -0
  43. package/dist/commands/env/remove.js +84 -0
  44. package/dist/commands/env/shared.js +158 -0
  45. package/dist/commands/env/status.js +90 -0
  46. package/dist/commands/env/update.js +74 -0
  47. package/dist/commands/env/use.js +38 -0
  48. package/dist/commands/examples/prompts-stages.js +150 -0
  49. package/dist/commands/examples/prompts-test.js +181 -0
  50. package/dist/commands/init.js +1092 -0
  51. package/dist/commands/install.js +2378 -0
  52. package/dist/commands/license/activate.js +360 -0
  53. package/dist/commands/license/env.js +94 -0
  54. package/dist/commands/license/generate-id.js +108 -0
  55. package/dist/commands/license/id.js +70 -0
  56. package/dist/commands/license/index.js +20 -0
  57. package/dist/commands/license/plugins/clean.js +115 -0
  58. package/dist/commands/license/plugins/index.js +20 -0
  59. package/dist/commands/license/plugins/list.js +64 -0
  60. package/dist/commands/license/plugins/shared.js +325 -0
  61. package/dist/commands/license/plugins/sync.js +285 -0
  62. package/dist/commands/license/shared.js +423 -0
  63. package/dist/commands/license/status.js +64 -0
  64. package/dist/commands/logs.js +12 -0
  65. package/dist/commands/plugin/disable.js +86 -0
  66. package/dist/commands/plugin/enable.js +86 -0
  67. package/dist/commands/plugin/list.js +82 -0
  68. package/dist/commands/pm/disable.js +12 -0
  69. package/dist/commands/pm/enable.js +12 -0
  70. package/dist/commands/pm/list.js +12 -0
  71. package/dist/commands/restart.js +12 -0
  72. package/dist/commands/scaffold/migration.js +38 -0
  73. package/dist/commands/scaffold/plugin.js +37 -0
  74. package/dist/commands/self/check.js +71 -0
  75. package/dist/commands/self/index.js +20 -0
  76. package/dist/commands/self/update.js +95 -0
  77. package/dist/commands/session/id.js +24 -0
  78. package/dist/commands/session/remove.js +57 -0
  79. package/dist/commands/session/setup.js +62 -0
  80. package/dist/commands/skills/check.js +69 -0
  81. package/dist/commands/skills/index.js +20 -0
  82. package/dist/commands/skills/install.js +80 -0
  83. package/dist/commands/skills/remove.js +80 -0
  84. package/dist/commands/skills/update.js +87 -0
  85. package/dist/commands/source/build.js +58 -0
  86. package/dist/commands/source/dev.js +182 -0
  87. package/dist/commands/source/download.js +880 -0
  88. package/dist/commands/source/publish.js +109 -0
  89. package/dist/commands/source/registry/logs.js +70 -0
  90. package/dist/commands/source/registry/start.js +57 -0
  91. package/dist/commands/source/registry/status.js +33 -0
  92. package/dist/commands/source/registry/stop.js +48 -0
  93. package/dist/commands/source/test.js +477 -0
  94. package/dist/commands/start.js +12 -0
  95. package/dist/commands/stop.js +12 -0
  96. package/dist/commands/test.js +12 -0
  97. package/dist/commands/upgrade.js +12 -0
  98. package/dist/commands/v1.js +210 -0
  99. package/dist/generated/command-registry.js +133 -0
  100. package/dist/help/runtime-help.js +23 -0
  101. package/dist/lib/api-client.js +329 -0
  102. package/dist/lib/app-health.js +126 -0
  103. package/dist/lib/app-managed-resources.js +316 -0
  104. package/dist/lib/app-runtime.js +180 -0
  105. package/dist/lib/auth-store.js +368 -0
  106. package/dist/lib/backup.js +171 -0
  107. package/dist/lib/bootstrap.js +403 -0
  108. package/dist/lib/build-config.js +18 -0
  109. package/dist/lib/builtin-db.js +86 -0
  110. package/dist/lib/cli-config.js +176 -0
  111. package/dist/lib/cli-home.js +47 -0
  112. package/dist/lib/cli-locale.js +129 -0
  113. package/dist/lib/command-discovery.js +39 -0
  114. package/dist/lib/db-connection-check.js +158 -0
  115. package/dist/lib/docker-env-file.js +52 -0
  116. package/dist/lib/docker-image.js +37 -0
  117. package/dist/lib/env-auth.js +873 -0
  118. package/dist/lib/env-config.js +94 -0
  119. package/dist/lib/env-guard.js +62 -0
  120. package/dist/lib/generated-command.js +186 -0
  121. package/dist/lib/http-request.js +49 -0
  122. package/dist/lib/inquirer-theme.js +17 -0
  123. package/dist/lib/inquirer.js +244 -0
  124. package/dist/lib/naming.js +70 -0
  125. package/dist/lib/object-utils.js +76 -0
  126. package/dist/lib/openapi.js +62 -0
  127. package/dist/lib/plugin-storage.js +64 -0
  128. package/dist/lib/post-processors.js +23 -0
  129. package/dist/lib/prompt-catalog-core.js +185 -0
  130. package/dist/lib/prompt-catalog-terminal.js +375 -0
  131. package/{src/index.js → dist/lib/prompt-catalog.js} +2 -6
  132. package/dist/lib/prompt-validators.js +240 -0
  133. package/dist/lib/prompt-web-ui.js +2103 -0
  134. package/dist/lib/resource-command.js +357 -0
  135. package/dist/lib/resource-request.js +104 -0
  136. package/dist/lib/run-npm.js +275 -0
  137. package/dist/lib/runtime-env-vars.js +32 -0
  138. package/dist/lib/runtime-generator.js +498 -0
  139. package/dist/lib/runtime-store.js +56 -0
  140. package/dist/lib/self-manager.js +301 -0
  141. package/dist/lib/session-id.js +17 -0
  142. package/dist/lib/session-integration.js +703 -0
  143. package/dist/lib/session-store.js +118 -0
  144. package/dist/lib/skills-manager.js +360 -0
  145. package/dist/lib/source-publish.js +306 -0
  146. package/dist/lib/source-registry.js +188 -0
  147. package/dist/lib/startup-update.js +285 -0
  148. package/dist/lib/ui.js +155 -0
  149. package/dist/locale/en-US.json +344 -0
  150. package/dist/locale/zh-CN.json +344 -0
  151. package/dist/post-processors/data-modeling.js +84 -0
  152. package/dist/post-processors/data-source-manager.js +138 -0
  153. package/dist/post-processors/index.js +19 -0
  154. package/nocobase-ctl.config.json +388 -0
  155. package/package.json +100 -26
  156. package/LICENSE +0 -661
  157. package/bin/index.js +0 -39
  158. package/nocobase.conf.tpl +0 -95
  159. package/src/commands/benchmark.js +0 -73
  160. package/src/commands/build.js +0 -49
  161. package/src/commands/clean.js +0 -30
  162. package/src/commands/client.js +0 -166
  163. package/src/commands/create-nginx-conf.js +0 -37
  164. package/src/commands/create-plugin.js +0 -33
  165. package/src/commands/dev.js +0 -200
  166. package/src/commands/doc.js +0 -76
  167. package/src/commands/e2e.js +0 -265
  168. package/src/commands/global.js +0 -43
  169. package/src/commands/index.js +0 -45
  170. package/src/commands/instance-id.js +0 -47
  171. package/src/commands/locale/cronstrue.js +0 -122
  172. package/src/commands/locale/react-js-cron/en-US.json +0 -75
  173. package/src/commands/locale/react-js-cron/zh-CN.json +0 -33
  174. package/src/commands/locale/react-js-cron/zh-TW.json +0 -33
  175. package/src/commands/locale.js +0 -81
  176. package/src/commands/p-test.js +0 -88
  177. package/src/commands/perf.js +0 -63
  178. package/src/commands/pkg.js +0 -321
  179. package/src/commands/pm2.js +0 -37
  180. package/src/commands/postinstall.js +0 -88
  181. package/src/commands/start.js +0 -148
  182. package/src/commands/tar.js +0 -36
  183. package/src/commands/test-coverage.js +0 -55
  184. package/src/commands/test.js +0 -107
  185. package/src/commands/umi.js +0 -33
  186. package/src/commands/update-deps.js +0 -72
  187. package/src/commands/upgrade.js +0 -47
  188. package/src/commands/view-license-key.js +0 -44
  189. package/src/license.js +0 -76
  190. package/src/logger.js +0 -75
  191. package/src/plugin-generator.js +0 -80
  192. package/src/util.js +0 -517
  193. package/templates/bundle-status.html +0 -338
  194. package/templates/create-app-package.json +0 -39
  195. package/templates/plugin/.npmignore.tpl +0 -2
  196. package/templates/plugin/README.md.tpl +0 -1
  197. package/templates/plugin/client.d.ts +0 -2
  198. package/templates/plugin/client.js +0 -1
  199. package/templates/plugin/package.json.tpl +0 -11
  200. package/templates/plugin/server.d.ts +0 -2
  201. package/templates/plugin/server.js +0 -1
  202. package/templates/plugin/src/client/client.d.ts +0 -249
  203. package/templates/plugin/src/client/index.tsx.tpl +0 -1
  204. package/templates/plugin/src/client/locale.ts +0 -21
  205. package/templates/plugin/src/client/plugin.tsx.tpl +0 -10
  206. package/templates/plugin/src/index.ts +0 -2
  207. package/templates/plugin/src/locale/en-US.json +0 -1
  208. package/templates/plugin/src/locale/zh-CN.json +0 -1
  209. package/templates/plugin/src/server/collections/.gitkeep +0 -0
  210. package/templates/plugin/src/server/index.ts.tpl +0 -1
  211. package/templates/plugin/src/server/plugin.ts.tpl +0 -19
@@ -0,0 +1,109 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+ import { Command, Flags } from '@oclif/core';
10
+ import { buildSuggestedInitCommand, publishSourceSnapshot } from '../../lib/source-publish.js';
11
+ import { failTask, printInfo, startTask, succeedTask } from '../../lib/ui.js';
12
+ function formatPublishFailure(message) {
13
+ if (message.includes('The specified --cwd does not exist:')
14
+ || message.includes('The specified --cwd is not a directory:')
15
+ || message.includes('Couldn\'t find a NocoBase source project from --cwd:')) {
16
+ return message;
17
+ }
18
+ return [
19
+ 'Couldn\'t publish a source snapshot.',
20
+ 'Check that Docker is running, the target npm registry is reachable, and the current directory is a NocoBase source repo.',
21
+ `Details: ${message}`,
22
+ ].join('\n');
23
+ }
24
+ export default class SourcePublish extends Command {
25
+ static description = 'Publish the current NocoBase source repo as a snapshot version to an npm registry for install testing.';
26
+ static examples = [
27
+ '<%= config.bin %> <%= command.id %> --snapshot',
28
+ '<%= config.bin %> <%= command.id %> --snapshot --no-build',
29
+ '<%= config.bin %> <%= command.id %> --snapshot --build-dts',
30
+ '<%= config.bin %> <%= command.id %> --snapshot --cwd /path/to/nocobase/source',
31
+ '<%= config.bin %> <%= command.id %> --snapshot --npm-registry=http://127.0.0.1:4873',
32
+ '<%= config.bin %> <%= command.id %> --snapshot --json',
33
+ ];
34
+ static flags = {
35
+ snapshot: Flags.boolean({
36
+ description: 'Publish the current source repo as a unique snapshot version',
37
+ required: true,
38
+ default: false,
39
+ }),
40
+ 'npm-registry': Flags.string({
41
+ description: 'npm registry URL to publish to. Defaults to the running local source registry when available',
42
+ required: false,
43
+ }),
44
+ cwd: Flags.string({
45
+ description: 'Source repository path. Defaults to the nearest detected NocoBase source root from the current working directory',
46
+ required: false,
47
+ }),
48
+ 'no-build': Flags.boolean({
49
+ description: 'Skip building the source repo before snapshot versioning and publish',
50
+ default: false,
51
+ }),
52
+ 'build-dts': Flags.boolean({
53
+ description: 'Generate TypeScript declaration files during the source build',
54
+ default: false,
55
+ }),
56
+ json: Flags.boolean({
57
+ description: 'Print the publish result as JSON',
58
+ default: false,
59
+ }),
60
+ verbose: Flags.boolean({
61
+ description: 'Show detailed command output while versioning and publishing the snapshot',
62
+ default: false,
63
+ }),
64
+ };
65
+ async run() {
66
+ const { flags } = await this.parse(SourcePublish);
67
+ if (!flags.snapshot) {
68
+ this.error('`nb source publish` currently requires `--snapshot`.');
69
+ }
70
+ if (!flags.json) {
71
+ startTask('Publishing a source snapshot...');
72
+ }
73
+ try {
74
+ const result = await publishSourceSnapshot({
75
+ cwd: flags.cwd,
76
+ npmRegistry: flags['npm-registry'],
77
+ build: !flags['no-build'],
78
+ buildDts: flags['build-dts'],
79
+ verbose: flags.verbose,
80
+ });
81
+ if (flags.json) {
82
+ this.log(JSON.stringify({
83
+ version: result.version,
84
+ npmRegistry: result.npmRegistry,
85
+ gitSha: result.gitSha,
86
+ projectRoot: result.projectRoot,
87
+ suggestedInitCommand: buildSuggestedInitCommand(result),
88
+ }, null, 2));
89
+ return;
90
+ }
91
+ succeedTask(`Published source snapshot ${result.version} to ${result.npmRegistry}.`);
92
+ printInfo(`Source root: ${result.projectRoot}`);
93
+ printInfo(`Snapshot version: ${result.version}`);
94
+ printInfo(`npm registry: ${result.npmRegistry}`);
95
+ printInfo(`Next: ${buildSuggestedInitCommand(result)}`);
96
+ }
97
+ catch (error) {
98
+ const message = error instanceof Error ? error.message : String(error);
99
+ if (flags.json) {
100
+ this.logToStderr(JSON.stringify({
101
+ error: formatPublishFailure(message),
102
+ }, null, 2));
103
+ this.exit(1);
104
+ }
105
+ failTask('Failed to publish the source snapshot.');
106
+ this.error(formatPublishFailure(message));
107
+ }
108
+ }
109
+ }
@@ -0,0 +1,70 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+ import { Command, Flags } from '@oclif/core';
10
+ import { run } from '../../../lib/run-npm.js';
11
+ import { printInfo } from '../../../lib/ui.js';
12
+ import { getSourceRegistryInfo } from '../../../lib/source-registry.js';
13
+ function formatLogsFailure(message) {
14
+ if (/does not exist/i.test(message)) {
15
+ return [
16
+ 'Can\'t show source registry logs yet.',
17
+ 'The saved source registry container could not be found on this machine.',
18
+ 'Start the registry first with `nb source registry start`.',
19
+ `Details: ${message}`,
20
+ ].join('\n');
21
+ }
22
+ return [
23
+ 'Couldn\'t show source registry logs.',
24
+ 'Check that Docker is installed and the source registry container still exists, then try again.',
25
+ `Details: ${message}`,
26
+ ].join('\n');
27
+ }
28
+ export default class SourceRegistryLogs extends Command {
29
+ static description = 'Show logs for the local Docker-based npm registry used for source tests.';
30
+ static examples = [
31
+ '<%= config.bin %> <%= command.id %>',
32
+ '<%= config.bin %> <%= command.id %> --tail 200',
33
+ '<%= config.bin %> <%= command.id %> --follow',
34
+ ];
35
+ static flags = {
36
+ tail: Flags.integer({
37
+ description: 'Number of recent log lines to show before following',
38
+ default: 100,
39
+ min: 0,
40
+ }),
41
+ follow: Flags.boolean({
42
+ char: 'f',
43
+ description: 'Keep streaming new log lines',
44
+ default: false,
45
+ allowNo: true,
46
+ }),
47
+ };
48
+ async run() {
49
+ const { flags } = await this.parse(SourceRegistryLogs);
50
+ const info = getSourceRegistryInfo();
51
+ printInfo(flags.follow
52
+ ? `Showing source registry logs from "${info.containerName}" (press Ctrl+C to stop).`
53
+ : `Showing recent source registry logs from "${info.containerName}".`);
54
+ const dockerArgs = ['logs', '--tail', String(flags.tail ?? 100)];
55
+ if (flags.follow) {
56
+ dockerArgs.push('--follow');
57
+ }
58
+ dockerArgs.push(info.containerName);
59
+ try {
60
+ await run('docker', dockerArgs, {
61
+ errorName: 'docker logs',
62
+ stdio: 'inherit',
63
+ });
64
+ }
65
+ catch (error) {
66
+ const message = error instanceof Error ? error.message : String(error);
67
+ this.error(formatLogsFailure(message));
68
+ }
69
+ }
70
+ }
@@ -0,0 +1,57 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+ import { Command, Flags } from '@oclif/core';
10
+ import { failTask, startTask, succeedTask } from '../../../lib/ui.js';
11
+ import { getSourceRegistryInfo, startSourceRegistry } from '../../../lib/source-registry.js';
12
+ function formatStartFailure(message) {
13
+ if (/port is already allocated|address already in use/i.test(message)) {
14
+ return [
15
+ 'Can\'t start the source registry.',
16
+ 'Port 4873 is already in use on this machine.',
17
+ 'Stop the conflicting process, or free the port before trying again.',
18
+ `Details: ${message}`,
19
+ ].join('\n');
20
+ }
21
+ return [
22
+ 'Couldn\'t start the source registry.',
23
+ 'Check that Docker is installed and running, then try again.',
24
+ `Details: ${message}`,
25
+ ].join('\n');
26
+ }
27
+ export default class SourceRegistryStart extends Command {
28
+ static description = 'Start the local Docker-based npm registry used for source snapshot publish and install tests.';
29
+ static examples = [
30
+ '<%= config.bin %> <%= command.id %>',
31
+ '<%= config.bin %> <%= command.id %> --verbose',
32
+ ];
33
+ static flags = {
34
+ verbose: Flags.boolean({
35
+ description: 'Show raw Docker output while starting the registry container',
36
+ default: false,
37
+ }),
38
+ };
39
+ async run() {
40
+ const { flags } = await this.parse(SourceRegistryStart);
41
+ const info = getSourceRegistryInfo();
42
+ startTask(`Starting the source registry at ${info.url}...`);
43
+ try {
44
+ const state = await startSourceRegistry({
45
+ stdio: flags.verbose ? 'inherit' : 'ignore',
46
+ });
47
+ succeedTask(state === 'already-running'
48
+ ? `The source registry is already running at ${info.url}.`
49
+ : `The source registry is running at ${info.url}.`);
50
+ }
51
+ catch (error) {
52
+ const message = error instanceof Error ? error.message : String(error);
53
+ failTask('Failed to start the source registry.');
54
+ this.error(formatStartFailure(message));
55
+ }
56
+ }
57
+ }
@@ -0,0 +1,33 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+ import { Command, Flags } from '@oclif/core';
10
+ import { renderTable } from '../../../lib/ui.js';
11
+ import { resolveSourceRegistryInfo } from '../../../lib/source-registry.js';
12
+ export default class SourceRegistryStatus extends Command {
13
+ static description = 'Show the status of the local Docker-based npm registry used for source tests.';
14
+ static examples = [
15
+ '<%= config.bin %> <%= command.id %>',
16
+ '<%= config.bin %> <%= command.id %> --json',
17
+ ];
18
+ static flags = {
19
+ json: Flags.boolean({
20
+ description: 'Print the source registry status as JSON',
21
+ default: false,
22
+ }),
23
+ };
24
+ async run() {
25
+ const { flags } = await this.parse(SourceRegistryStatus);
26
+ const info = await resolveSourceRegistryInfo();
27
+ if (flags.json) {
28
+ this.log(JSON.stringify(info, null, 2));
29
+ return;
30
+ }
31
+ this.log(renderTable(['Container', 'Status', 'URL', 'Storage'], [[info.containerName, info.status, info.url, info.storageDir]]));
32
+ }
33
+ }
@@ -0,0 +1,48 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+ import { Command, Flags } from '@oclif/core';
10
+ import { failTask, startTask, succeedTask } from '../../../lib/ui.js';
11
+ import { stopSourceRegistry } from '../../../lib/source-registry.js';
12
+ function formatStopFailure(message) {
13
+ return [
14
+ 'Couldn\'t stop the source registry.',
15
+ 'Check that Docker is installed and the saved registry container still exists, then try again.',
16
+ `Details: ${message}`,
17
+ ].join('\n');
18
+ }
19
+ export default class SourceRegistryStop extends Command {
20
+ static description = 'Stop the local Docker-based npm registry used for source snapshot tests.';
21
+ static examples = [
22
+ '<%= config.bin %> <%= command.id %>',
23
+ '<%= config.bin %> <%= command.id %> --verbose',
24
+ ];
25
+ static flags = {
26
+ verbose: Flags.boolean({
27
+ description: 'Show raw Docker output while stopping the registry container',
28
+ default: false,
29
+ }),
30
+ };
31
+ async run() {
32
+ const { flags } = await this.parse(SourceRegistryStop);
33
+ startTask('Stopping the source registry...');
34
+ try {
35
+ const state = await stopSourceRegistry({
36
+ stdio: flags.verbose ? 'inherit' : 'ignore',
37
+ });
38
+ succeedTask(state === 'already-stopped'
39
+ ? 'The source registry is already stopped.'
40
+ : 'The source registry has stopped.');
41
+ }
42
+ catch (error) {
43
+ const message = error instanceof Error ? error.message : String(error);
44
+ failTask('Failed to stop the source registry.');
45
+ this.error(formatStopFailure(message));
46
+ }
47
+ }
48
+ }