@nocobase/cli 2.1.0-beta.9 → 2.1.0-rc.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 (250) hide show
  1. package/bin/run.cmd +3 -0
  2. package/bin/run.js +145 -0
  3. package/bin/session-env.js +39 -0
  4. package/dist/commands/api/resource/create.js +15 -0
  5. package/dist/commands/api/resource/destroy.js +15 -0
  6. package/dist/commands/api/resource/get.js +15 -0
  7. package/dist/commands/api/resource/index.js +20 -0
  8. package/dist/commands/api/resource/list.js +16 -0
  9. package/dist/commands/api/resource/query.js +15 -0
  10. package/dist/commands/api/resource/update.js +15 -0
  11. package/dist/commands/app/autostart/disable.js +55 -0
  12. package/dist/commands/app/autostart/enable.js +55 -0
  13. package/dist/commands/app/autostart/list.js +37 -0
  14. package/dist/commands/app/autostart/run.js +84 -0
  15. package/dist/commands/app/autostart/shared.js +49 -0
  16. package/dist/commands/app/destroy.js +234 -0
  17. package/dist/commands/app/down.js +71 -0
  18. package/dist/commands/app/logs.js +115 -0
  19. package/dist/commands/app/restart.js +229 -0
  20. package/dist/commands/app/shared.js +123 -0
  21. package/dist/commands/app/start.js +416 -0
  22. package/dist/commands/app/stop.js +183 -0
  23. package/dist/commands/app/upgrade.js +523 -0
  24. package/dist/commands/backup/create.js +147 -0
  25. package/dist/commands/backup/index.js +20 -0
  26. package/dist/commands/backup/restore.js +105 -0
  27. package/{src/cli.js → dist/commands/build.js} +4 -11
  28. package/dist/commands/config/delete.js +42 -0
  29. package/dist/commands/config/get.js +39 -0
  30. package/dist/commands/config/index.js +20 -0
  31. package/dist/commands/config/list.js +29 -0
  32. package/dist/commands/config/set.js +49 -0
  33. package/dist/commands/db/check.js +240 -0
  34. package/dist/commands/db/logs.js +85 -0
  35. package/dist/commands/db/ps.js +47 -0
  36. package/dist/commands/db/shared.js +96 -0
  37. package/dist/commands/db/start.js +86 -0
  38. package/dist/commands/db/stop.js +71 -0
  39. package/{templates/plugin/src/client/models/index.ts → dist/commands/dev.js} +4 -4
  40. package/{src/commands/locale/react-js-cron/index.js → dist/commands/down.js} +3 -8
  41. package/dist/commands/download.js +13 -0
  42. package/dist/commands/env/add.js +406 -0
  43. package/dist/commands/env/auth.js +189 -0
  44. package/dist/commands/env/current.js +21 -0
  45. package/dist/commands/env/info.js +202 -0
  46. package/dist/commands/env/list.js +43 -0
  47. package/dist/commands/env/remove.js +174 -0
  48. package/dist/commands/env/shared.js +204 -0
  49. package/dist/commands/env/status.js +93 -0
  50. package/dist/commands/env/update.js +448 -0
  51. package/dist/commands/env/use.js +38 -0
  52. package/dist/commands/examples/prompts-stages.js +150 -0
  53. package/dist/commands/examples/prompts-test.js +181 -0
  54. package/dist/commands/init.js +1390 -0
  55. package/dist/commands/install.js +2609 -0
  56. package/dist/commands/license/activate.js +179 -0
  57. package/dist/commands/license/env.js +94 -0
  58. package/dist/commands/license/generate-id.js +108 -0
  59. package/dist/commands/license/id.js +70 -0
  60. package/dist/commands/license/index.js +20 -0
  61. package/dist/commands/license/plugins/clean.js +115 -0
  62. package/dist/commands/license/plugins/index.js +20 -0
  63. package/dist/commands/license/plugins/list.js +64 -0
  64. package/dist/commands/license/plugins/shared.js +382 -0
  65. package/dist/commands/license/plugins/sync.js +314 -0
  66. package/dist/commands/license/shared.js +423 -0
  67. package/dist/commands/license/status.js +64 -0
  68. package/dist/commands/logs.js +12 -0
  69. package/dist/commands/plugin/disable.js +86 -0
  70. package/dist/commands/plugin/enable.js +86 -0
  71. package/dist/commands/plugin/import.js +108 -0
  72. package/dist/commands/plugin/list.js +82 -0
  73. package/dist/commands/pm/disable.js +12 -0
  74. package/dist/commands/pm/enable.js +12 -0
  75. package/dist/commands/pm/list.js +12 -0
  76. package/dist/commands/proxy/caddy/current.js +17 -0
  77. package/dist/commands/proxy/caddy/generate.js +69 -0
  78. package/dist/commands/proxy/caddy/index.js +28 -0
  79. package/dist/commands/proxy/caddy/info.js +31 -0
  80. package/dist/commands/proxy/caddy/reload.js +30 -0
  81. package/dist/commands/proxy/caddy/restart.js +28 -0
  82. package/dist/commands/proxy/caddy/start.js +30 -0
  83. package/dist/commands/proxy/caddy/status.js +19 -0
  84. package/dist/commands/proxy/caddy/stop.js +30 -0
  85. package/dist/commands/proxy/caddy/use.js +26 -0
  86. package/dist/commands/proxy/index.js +28 -0
  87. package/dist/commands/proxy/nginx/current.js +18 -0
  88. package/dist/commands/proxy/nginx/generate.js +68 -0
  89. package/dist/commands/proxy/nginx/index.js +28 -0
  90. package/dist/commands/proxy/nginx/info.js +34 -0
  91. package/dist/commands/proxy/nginx/reload.js +30 -0
  92. package/dist/commands/proxy/nginx/restart.js +28 -0
  93. package/dist/commands/proxy/nginx/start.js +30 -0
  94. package/dist/commands/proxy/nginx/status.js +19 -0
  95. package/dist/commands/proxy/nginx/stop.js +30 -0
  96. package/dist/commands/proxy/nginx/use.js +31 -0
  97. package/dist/commands/restart.js +12 -0
  98. package/dist/commands/revision/create.js +118 -0
  99. package/dist/commands/scaffold/migration.js +38 -0
  100. package/dist/commands/scaffold/plugin.js +37 -0
  101. package/dist/commands/self/check.js +71 -0
  102. package/dist/commands/self/index.js +20 -0
  103. package/dist/commands/self/update.js +152 -0
  104. package/dist/commands/session/id.js +24 -0
  105. package/dist/commands/session/remove.js +57 -0
  106. package/dist/commands/session/setup.js +62 -0
  107. package/dist/commands/skills/check.js +69 -0
  108. package/dist/commands/skills/index.js +20 -0
  109. package/dist/commands/skills/install.js +80 -0
  110. package/dist/commands/skills/remove.js +80 -0
  111. package/dist/commands/skills/update.js +87 -0
  112. package/dist/commands/source/build.js +58 -0
  113. package/dist/commands/source/dev.js +182 -0
  114. package/dist/commands/source/download.js +883 -0
  115. package/dist/commands/source/publish.js +109 -0
  116. package/dist/commands/source/registry/logs.js +70 -0
  117. package/dist/commands/source/registry/start.js +57 -0
  118. package/dist/commands/source/registry/status.js +33 -0
  119. package/dist/commands/source/registry/stop.js +48 -0
  120. package/dist/commands/source/test.js +476 -0
  121. package/dist/commands/start.js +12 -0
  122. package/dist/commands/stop.js +12 -0
  123. package/dist/commands/test.js +12 -0
  124. package/dist/commands/upgrade.js +12 -0
  125. package/dist/commands/v1.js +210 -0
  126. package/dist/generated/command-registry.js +134 -0
  127. package/dist/help/runtime-help.js +23 -0
  128. package/dist/lib/api-client.js +335 -0
  129. package/dist/lib/api-command-compat.js +641 -0
  130. package/dist/lib/app-health.js +139 -0
  131. package/dist/lib/app-managed-resources.js +337 -0
  132. package/dist/lib/app-public-path.js +80 -0
  133. package/dist/lib/app-runtime.js +189 -0
  134. package/dist/lib/auth-store.js +528 -0
  135. package/dist/lib/backup.js +171 -0
  136. package/dist/lib/bootstrap.js +409 -0
  137. package/dist/lib/build-config.js +18 -0
  138. package/dist/lib/builtin-db.js +86 -0
  139. package/dist/lib/cli-config.js +569 -0
  140. package/dist/lib/cli-entry-error.js +52 -0
  141. package/dist/lib/cli-home.js +47 -0
  142. package/dist/lib/cli-locale.js +141 -0
  143. package/dist/lib/command-discovery.js +39 -0
  144. package/dist/lib/command-log.js +284 -0
  145. package/dist/lib/db-connection-check.js +219 -0
  146. package/dist/lib/docker-env-file.js +60 -0
  147. package/dist/lib/docker-image.js +37 -0
  148. package/dist/lib/docker-log-stream.js +45 -0
  149. package/dist/lib/env-auth.js +963 -0
  150. package/dist/lib/env-command-config.js +45 -0
  151. package/dist/lib/env-config.js +108 -0
  152. package/dist/lib/env-guard.js +61 -0
  153. package/dist/lib/env-paths.js +101 -0
  154. package/dist/lib/env-proxy.js +1325 -0
  155. package/dist/lib/generated-command.js +203 -0
  156. package/dist/lib/http-request.js +49 -0
  157. package/dist/lib/inquirer-theme.js +17 -0
  158. package/dist/lib/inquirer.js +243 -0
  159. package/dist/lib/managed-env-file.js +101 -0
  160. package/dist/lib/managed-init-env.js +32 -0
  161. package/dist/lib/naming.js +70 -0
  162. package/dist/lib/object-utils.js +76 -0
  163. package/dist/lib/openapi.js +62 -0
  164. package/dist/lib/plugin-import.js +279 -0
  165. package/dist/lib/plugin-storage.js +64 -0
  166. package/dist/lib/post-processors.js +23 -0
  167. package/dist/lib/prompt-catalog-core.js +186 -0
  168. package/dist/lib/prompt-catalog-terminal.js +374 -0
  169. package/{src/index.js → dist/lib/prompt-catalog.js} +2 -6
  170. package/dist/lib/prompt-validators.js +278 -0
  171. package/dist/lib/prompt-web-ui.js +2234 -0
  172. package/dist/lib/proxy-caddy.js +274 -0
  173. package/dist/lib/proxy-nginx.js +330 -0
  174. package/dist/lib/resource-command.js +357 -0
  175. package/dist/lib/resource-request.js +104 -0
  176. package/dist/lib/run-npm.js +429 -0
  177. package/dist/lib/runtime-env-vars.js +32 -0
  178. package/dist/lib/runtime-generator.js +498 -0
  179. package/dist/lib/runtime-store.js +56 -0
  180. package/dist/lib/self-manager.js +301 -0
  181. package/dist/lib/session-id.js +17 -0
  182. package/dist/lib/session-integration.js +703 -0
  183. package/dist/lib/session-store.js +118 -0
  184. package/dist/lib/skills-manager.js +438 -0
  185. package/dist/lib/source-publish.js +326 -0
  186. package/dist/lib/source-registry.js +188 -0
  187. package/dist/lib/startup-update.js +309 -0
  188. package/dist/lib/ui.js +159 -0
  189. package/dist/locale/en-US.json +526 -0
  190. package/dist/locale/zh-CN.json +526 -0
  191. package/dist/post-processors/data-modeling.js +84 -0
  192. package/dist/post-processors/data-source-manager.js +138 -0
  193. package/dist/post-processors/index.js +19 -0
  194. package/nocobase-ctl.config.json +388 -0
  195. package/package.json +133 -25
  196. package/bin/index.js +0 -39
  197. package/nocobase.conf.tpl +0 -95
  198. package/src/commands/benchmark.js +0 -73
  199. package/src/commands/build.js +0 -49
  200. package/src/commands/clean.js +0 -30
  201. package/src/commands/client.js +0 -166
  202. package/src/commands/create-nginx-conf.js +0 -37
  203. package/src/commands/create-plugin.js +0 -33
  204. package/src/commands/dev.js +0 -200
  205. package/src/commands/doc.js +0 -76
  206. package/src/commands/e2e.js +0 -265
  207. package/src/commands/global.js +0 -43
  208. package/src/commands/index.js +0 -45
  209. package/src/commands/instance-id.js +0 -47
  210. package/src/commands/locale/cronstrue.js +0 -122
  211. package/src/commands/locale/react-js-cron/en-US.json +0 -75
  212. package/src/commands/locale/react-js-cron/zh-CN.json +0 -33
  213. package/src/commands/locale/react-js-cron/zh-TW.json +0 -33
  214. package/src/commands/locale.js +0 -81
  215. package/src/commands/p-test.js +0 -88
  216. package/src/commands/perf.js +0 -63
  217. package/src/commands/pkg.js +0 -321
  218. package/src/commands/pm2.js +0 -37
  219. package/src/commands/postinstall.js +0 -88
  220. package/src/commands/start.js +0 -148
  221. package/src/commands/tar.js +0 -36
  222. package/src/commands/test-coverage.js +0 -55
  223. package/src/commands/test.js +0 -107
  224. package/src/commands/umi.js +0 -33
  225. package/src/commands/update-deps.js +0 -72
  226. package/src/commands/upgrade.js +0 -47
  227. package/src/commands/view-license-key.js +0 -44
  228. package/src/license.js +0 -76
  229. package/src/logger.js +0 -75
  230. package/src/plugin-generator.js +0 -80
  231. package/src/util.js +0 -517
  232. package/templates/bundle-status.html +0 -338
  233. package/templates/create-app-package.json +0 -39
  234. package/templates/plugin/.npmignore.tpl +0 -2
  235. package/templates/plugin/README.md.tpl +0 -1
  236. package/templates/plugin/client.d.ts +0 -2
  237. package/templates/plugin/client.js +0 -1
  238. package/templates/plugin/package.json.tpl +0 -11
  239. package/templates/plugin/server.d.ts +0 -2
  240. package/templates/plugin/server.js +0 -1
  241. package/templates/plugin/src/client/client.d.ts +0 -249
  242. package/templates/plugin/src/client/index.tsx.tpl +0 -1
  243. package/templates/plugin/src/client/locale.ts +0 -21
  244. package/templates/plugin/src/client/plugin.tsx.tpl +0 -10
  245. package/templates/plugin/src/index.ts +0 -2
  246. package/templates/plugin/src/locale/en-US.json +0 -1
  247. package/templates/plugin/src/locale/zh-CN.json +0 -1
  248. package/templates/plugin/src/server/collections/.gitkeep +0 -0
  249. package/templates/plugin/src/server/index.ts.tpl +0 -1
  250. package/templates/plugin/src/server/plugin.ts.tpl +0 -19
@@ -0,0 +1,108 @@
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 { Args, Command, Flags } from '@oclif/core';
10
+ import { formatMissingManagedAppEnvMessage, resolveManagedAppRuntime } from '../../lib/app-runtime.js';
11
+ import { ensureCrossEnvConfirmed, hasExplicitEnvSelection } from '../../lib/env-guard.js';
12
+ import { importPluginSource } from '../../lib/plugin-import.js';
13
+ import { announceTargetEnv } from '../../lib/ui.js';
14
+ export default class PluginImport extends Command {
15
+ static hidden = false;
16
+ static args = {
17
+ archive: Args.string({
18
+ required: true,
19
+ description: 'Plugin source to import. Accepts a local .tgz path, a remote http(s) URL, or an npm package spec.',
20
+ }),
21
+ };
22
+ static summary = 'Import a packaged plugin into storage/plugins for the selected env';
23
+ static description = 'Download or read a packaged plugin source and extract it into the selected env storage/plugins directory without enabling it.';
24
+ static examples = [
25
+ '<%= config.bin %> <%= command.id %> https://github.com/nocobase/plugin-auth-cas/releases/download/v1.4.0/plugin-auth-cas-1.4.0.tgz',
26
+ '<%= config.bin %> <%= command.id %> /your/path/plugin-auth-cas-1.4.0.tgz',
27
+ '<%= config.bin %> <%= command.id %> @nocobase/plugin-acl@beta',
28
+ '<%= config.bin %> <%= command.id %> @nocobase/plugin-acl@beta --npm-registry=https://registry.npmjs.org',
29
+ '<%= config.bin %> <%= command.id %> --env app1 ./plugin-auth-cas-1.4.0.tgz',
30
+ '<%= config.bin %> <%= command.id %> --storage-path ./storage ./plugin-auth-cas-1.4.0.tgz',
31
+ ];
32
+ static flags = {
33
+ env: Flags.string({
34
+ char: 'e',
35
+ description: 'CLI env name to import the plugin into. Defaults to the current env when omitted',
36
+ }),
37
+ yes: Flags.boolean({
38
+ char: 'y',
39
+ description: 'Confirm using --env when it targets a different env than the current env',
40
+ default: false,
41
+ }),
42
+ 'storage-path': Flags.string({
43
+ description: 'Override the env storage root path. Imported plugins are written into <storage-path>/plugins',
44
+ }),
45
+ 'npm-registry': Flags.string({
46
+ description: 'npm registry to use when the import source is an npm package spec.',
47
+ }),
48
+ };
49
+ async run() {
50
+ const { args, flags } = await this.parse(PluginImport);
51
+ const requestedEnv = flags.env?.trim() || undefined;
52
+ const storagePathOverride = flags['storage-path']?.trim() || undefined;
53
+ const explicitEnvSelection = Boolean(requestedEnv && hasExplicitEnvSelection(this.argv));
54
+ if (explicitEnvSelection) {
55
+ const confirmed = await ensureCrossEnvConfirmed({
56
+ command: this,
57
+ requestedEnv,
58
+ yes: flags.yes,
59
+ });
60
+ if (!confirmed) {
61
+ return;
62
+ }
63
+ }
64
+ const archiveSource = args.archive?.trim();
65
+ if (!archiveSource) {
66
+ this.error('Pass a plugin archive path, URL, or npm package spec.');
67
+ }
68
+ const shouldResolveTargetEnv = Boolean(requestedEnv || !storagePathOverride);
69
+ const runtime = await resolveManagedAppRuntime(shouldResolveTargetEnv ? requestedEnv : undefined);
70
+ if (shouldResolveTargetEnv && !runtime) {
71
+ this.error(formatMissingManagedAppEnvMessage(requestedEnv));
72
+ }
73
+ if (runtime && shouldResolveTargetEnv && runtime.kind === 'http') {
74
+ this.error([
75
+ `Can't import plugins for "${runtime.envName}" yet.`,
76
+ 'HTTP envs do not expose a writable storage/plugins path to the CLI.',
77
+ 'Use a local or Docker env for plugin imports right now.',
78
+ ].join('\n'));
79
+ }
80
+ if (runtime && shouldResolveTargetEnv && runtime.kind === 'ssh') {
81
+ this.error([
82
+ `Can't import plugins for "${runtime.envName}" yet.`,
83
+ 'SSH env support is reserved but not implemented yet.',
84
+ 'Use a local or Docker env for plugin imports right now.',
85
+ ].join('\n'));
86
+ }
87
+ if (runtime && shouldResolveTargetEnv) {
88
+ announceTargetEnv(runtime.envName);
89
+ }
90
+ const runtimeForDefaults = runtime && runtime.kind !== 'http' && runtime.kind !== 'ssh' ? runtime : undefined;
91
+ const npmRegistry = flags['npm-registry']?.trim() || String(runtimeForDefaults?.env.config.npmRegistry ?? '').trim() || undefined;
92
+ const storagePath = storagePathOverride || runtimeForDefaults?.env.storagePath;
93
+ const result = await importPluginSource(archiveSource, {
94
+ storagePath,
95
+ npmRegistry,
96
+ });
97
+ const label = result.action === 'updated' ? 'Updated' : 'Imported';
98
+ const versionSuffix = result.packageVersion ? `@${result.packageVersion}` : '';
99
+ this.log(`${label} ${result.packageName}${versionSuffix} into ${result.outputDir}`);
100
+ this.log(`Plugin storage path: ${result.storagePluginsPath}`);
101
+ if (runtime && shouldResolveTargetEnv) {
102
+ this.log(`Restart the app before enabling or using the plugin: \`nb app restart --env ${runtime.envName}\`.`);
103
+ }
104
+ else {
105
+ this.log('Restart the app that uses this plugin storage path before enabling or using the plugin.');
106
+ }
107
+ }
108
+ }
@@ -0,0 +1,82 @@
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 { formatMissingManagedAppEnvMessage, resolveManagedAppRuntime, runDockerNocoBaseCommand, runLocalNocoBaseCommand, } from '../../lib/app-runtime.js';
11
+ import { ensureCrossEnvConfirmed, hasExplicitEnvSelection } from '../../lib/env-guard.js';
12
+ export default class PluginList extends Command {
13
+ static hidden = false;
14
+ static args = {};
15
+ static summary = 'List plugins for the selected env';
16
+ static description = 'List installed plugins in the selected env (npm/git runs locally, Docker runs inside the saved app container, HTTP envs fall back to the API)';
17
+ static examples = [
18
+ '<%= config.bin %> <%= command.id %>',
19
+ '<%= config.bin %> <%= command.id %> -e local',
20
+ '<%= config.bin %> <%= command.id %> -e local-docker',
21
+ ];
22
+ static flags = {
23
+ env: Flags.string({
24
+ char: 'e',
25
+ description: 'CLI env name to inspect plugins for. Defaults to the current env when omitted',
26
+ }),
27
+ yes: Flags.boolean({
28
+ char: 'y',
29
+ description: 'Confirm using --env when it targets a different env than the current env',
30
+ default: false,
31
+ }),
32
+ };
33
+ async run() {
34
+ const { flags } = await this.parse(PluginList);
35
+ const requestedEnv = flags.env?.trim() || undefined;
36
+ const explicitEnvSelection = Boolean(requestedEnv && hasExplicitEnvSelection(this.argv));
37
+ if (explicitEnvSelection) {
38
+ const confirmed = await ensureCrossEnvConfirmed({
39
+ command: this,
40
+ requestedEnv,
41
+ yes: flags.yes,
42
+ });
43
+ if (!confirmed) {
44
+ return;
45
+ }
46
+ }
47
+ const runtime = await resolveManagedAppRuntime(requestedEnv);
48
+ if (!runtime) {
49
+ this.error(formatMissingManagedAppEnvMessage(requestedEnv));
50
+ }
51
+ if (runtime.kind === 'local') {
52
+ try {
53
+ await runLocalNocoBaseCommand(runtime, ['pm', 'list']);
54
+ }
55
+ catch (error) {
56
+ const message = error instanceof Error ? error.message : String(error);
57
+ this.error(message);
58
+ }
59
+ return;
60
+ }
61
+ if (runtime.kind === 'docker') {
62
+ try {
63
+ await runDockerNocoBaseCommand(runtime.containerName, ['pm', 'list']);
64
+ }
65
+ catch (error) {
66
+ const message = error instanceof Error ? error.message : String(error);
67
+ this.error(message);
68
+ }
69
+ return;
70
+ }
71
+ if (runtime.kind === 'ssh') {
72
+ this.error([
73
+ `Can't list plugins for "${runtime.envName}" yet.`,
74
+ 'SSH env support is reserved but not implemented yet.',
75
+ 'Use a local, Docker, or HTTP env for plugin inspection right now.',
76
+ ].join('\n'));
77
+ }
78
+ await this.config.runCommand('api:pm:list', explicitEnvSelection
79
+ ? ['--mode=summary', '--env', runtime.envName, '--yes']
80
+ : ['--mode=summary']);
81
+ }
82
+ }
@@ -0,0 +1,12 @@
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 PluginDisable from '../plugin/disable.js';
10
+ export default class PmDisable extends PluginDisable {
11
+ static hidden = true;
12
+ }
@@ -0,0 +1,12 @@
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 PluginEnable from '../plugin/enable.js';
10
+ export default class PmEnable extends PluginEnable {
11
+ static hidden = true;
12
+ }
@@ -0,0 +1,12 @@
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 PluginList from '../plugin/list.js';
10
+ export default class PmList extends PluginList {
11
+ static hidden = true;
12
+ }
@@ -0,0 +1,17 @@
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 } from '@oclif/core';
10
+ import { getCaddyProxyDriver } from '../../../lib/proxy-caddy.js';
11
+ export default class ProxyCaddyCurrent extends Command {
12
+ static summary = 'Print the current caddy runtime driver';
13
+ async run() {
14
+ await this.parse(ProxyCaddyCurrent);
15
+ this.log(await getCaddyProxyDriver());
16
+ }
17
+ }
@@ -0,0 +1,69 @@
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 { formatMissingManagedAppEnvMessage, resolveManagedAppRuntime, } from '../../../lib/app-runtime.js';
11
+ import { getCaddyProxyDriver, writeCaddyProxyBundle, resolveCaddyProxyRuntimeContext, } from '../../../lib/proxy-caddy.js';
12
+ import { normalizeProxyListenPort } from '../../../lib/proxy-nginx.js';
13
+ import { announceTargetEnv, failTask, startTask, succeedTask } from '../../../lib/ui.js';
14
+ export default class ProxyCaddyGenerate extends Command {
15
+ static summary = 'Generate caddy proxy files for one managed env';
16
+ static examples = [
17
+ '<%= config.bin %> proxy caddy generate --env app1 --host app1.example.com',
18
+ '<%= config.bin %> proxy caddy generate --env app1 --host app1.example.com --port 8080',
19
+ ];
20
+ static flags = {
21
+ env: Flags.string({
22
+ char: 'e',
23
+ description: 'CLI env name to generate proxy files for',
24
+ required: true,
25
+ }),
26
+ host: Flags.string({
27
+ description: 'Host exposed by the caddy site block, such as example.com or localhost',
28
+ }),
29
+ port: Flags.string({
30
+ description: 'Port exposed by the caddy site block, not the upstream NocoBase app port',
31
+ }),
32
+ };
33
+ async run() {
34
+ const { flags } = await this.parse(ProxyCaddyGenerate);
35
+ const requestedEnv = flags.env?.trim() || undefined;
36
+ const requestedPort = flags.port?.trim() || undefined;
37
+ const normalizedPort = normalizeProxyListenPort(requestedPort);
38
+ if (requestedPort && !normalizedPort) {
39
+ this.error(`Invalid proxy entry port "${requestedPort}". Use an integer between 1 and 65535.`);
40
+ }
41
+ const runtime = await resolveManagedAppRuntime(requestedEnv);
42
+ if (!runtime) {
43
+ this.error(formatMissingManagedAppEnvMessage(requestedEnv));
44
+ }
45
+ if (runtime.kind === 'http') {
46
+ this.error(`Can't generate a caddy proxy config for "${runtime.envName}" from this machine because the env only has an API connection.`);
47
+ }
48
+ if (runtime.kind === 'ssh') {
49
+ this.error(`Can't generate a caddy proxy config for "${runtime.envName}" yet because SSH envs are not implemented.`);
50
+ }
51
+ const driver = await getCaddyProxyDriver();
52
+ const runtimeContext = await resolveCaddyProxyRuntimeContext();
53
+ announceTargetEnv(runtime.envName);
54
+ startTask(`Generating caddy proxy config for env "${runtime.envName}" with the ${driver} driver...`);
55
+ try {
56
+ const { bundle, status } = await writeCaddyProxyBundle(runtime, {
57
+ host: flags.host?.trim() || undefined,
58
+ port: normalizedPort,
59
+ }, runtimeContext);
60
+ succeedTask(status === 'created'
61
+ ? `Saved caddy proxy files for env "${runtime.envName}" under ${bundle.entryDir}, and created app.caddy at ${bundle.appConfigPath}.`
62
+ : `Saved caddy proxy files for env "${runtime.envName}" under ${bundle.entryDir}, and refreshed app.caddy at ${bundle.appConfigPath}.`);
63
+ }
64
+ catch (error) {
65
+ failTask(`Failed to generate caddy proxy config for env "${runtime.envName}".`);
66
+ this.error(error instanceof Error ? error.message : String(error));
67
+ }
68
+ }
69
+ }
@@ -0,0 +1,28 @@
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, loadHelpClass } from '@oclif/core';
10
+ export default class ProxyCaddy extends Command {
11
+ static summary = 'Manage caddy proxy generation and runtime selection';
12
+ static examples = [
13
+ '<%= config.bin %> proxy caddy current',
14
+ '<%= config.bin %> proxy caddy use local',
15
+ '<%= config.bin %> proxy caddy generate --env app1 --host app1.example.com',
16
+ '<%= config.bin %> proxy caddy start',
17
+ '<%= config.bin %> proxy caddy status',
18
+ '<%= config.bin %> proxy caddy info',
19
+ ];
20
+ async run() {
21
+ await this.parse(ProxyCaddy);
22
+ const Help = await loadHelpClass(this.config);
23
+ await new Help(this.config, this.config.pjson.oclif.helpOptions ?? this.config.pjson.helpOptions).showHelp([
24
+ this.id ?? 'proxy caddy',
25
+ ...this.argv,
26
+ ]);
27
+ }
28
+ }
@@ -0,0 +1,31 @@
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 } from '@oclif/core';
10
+ import { getCliConfigValue } from '../../../lib/cli-config.js';
11
+ import { mapProxyPathFromCliRoot, resolveEnvProxyMainOutputPath } from '../../../lib/env-proxy.js';
12
+ import { formatCaddyProxyInfoLines, resolveCaddyProxyContainerName, resolveCaddyProxyImage, resolveCaddyProxyRuntimeContext, } from '../../../lib/proxy-caddy.js';
13
+ export default class ProxyCaddyInfo extends Command {
14
+ static summary = 'Show current caddy proxy driver and generated path info';
15
+ async run() {
16
+ await this.parse(ProxyCaddyInfo);
17
+ const runtimeContext = await resolveCaddyProxyRuntimeContext();
18
+ const lines = formatCaddyProxyInfoLines({
19
+ driver: runtimeContext.driver,
20
+ configFile: await mapProxyPathFromCliRoot(resolveEnvProxyMainOutputPath({ provider: 'caddy' }), {
21
+ runtimeCliRoot: runtimeContext.runtimeCliRoot,
22
+ }),
23
+ upstreamHost: runtimeContext.upstreamHost,
24
+ caddyBinary: await getCliConfigValue('bin.caddy'),
25
+ runtimeRoot: runtimeContext.runtimeCliRoot,
26
+ containerName: await resolveCaddyProxyContainerName(),
27
+ image: resolveCaddyProxyImage(),
28
+ });
29
+ this.log(lines.join('\n'));
30
+ }
31
+ }
@@ -0,0 +1,30 @@
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 } from '@oclif/core';
10
+ import { getCaddyProxyDriver, reloadCaddyProxy, resolveCaddyProxyRuntimeContext } from '../../../lib/proxy-caddy.js';
11
+ import { failTask, startTask, succeedTask } from '../../../lib/ui.js';
12
+ export default class ProxyCaddyReload extends Command {
13
+ static summary = 'Reload the managed caddy proxy';
14
+ async run() {
15
+ await this.parse(ProxyCaddyReload);
16
+ const driver = await getCaddyProxyDriver();
17
+ const runtimeContext = await resolveCaddyProxyRuntimeContext();
18
+ startTask(`Reloading caddy proxy with the ${driver} driver...`);
19
+ try {
20
+ const result = await reloadCaddyProxy(runtimeContext);
21
+ succeedTask(result === 'started'
22
+ ? `Caddy proxy started with the ${driver} driver using the latest config.`
23
+ : `Caddy proxy reloaded with the ${driver} driver.`);
24
+ }
25
+ catch (error) {
26
+ failTask(`Failed to reload caddy proxy with the ${driver} driver.`);
27
+ this.error(error instanceof Error ? error.message : String(error));
28
+ }
29
+ }
30
+ }
@@ -0,0 +1,28 @@
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 } from '@oclif/core';
10
+ import { getCaddyProxyDriver, resolveCaddyProxyRuntimeContext, restartCaddyProxy } from '../../../lib/proxy-caddy.js';
11
+ import { failTask, startTask, succeedTask } from '../../../lib/ui.js';
12
+ export default class ProxyCaddyRestart extends Command {
13
+ static summary = 'Restart the managed caddy proxy';
14
+ async run() {
15
+ await this.parse(ProxyCaddyRestart);
16
+ const driver = await getCaddyProxyDriver();
17
+ const runtimeContext = await resolveCaddyProxyRuntimeContext();
18
+ startTask(`Restarting caddy proxy with the ${driver} driver...`);
19
+ try {
20
+ await restartCaddyProxy(runtimeContext);
21
+ succeedTask(`Caddy proxy restarted with the ${driver} driver.`);
22
+ }
23
+ catch (error) {
24
+ failTask(`Failed to restart caddy proxy with the ${driver} driver.`);
25
+ this.error(error instanceof Error ? error.message : String(error));
26
+ }
27
+ }
28
+ }
@@ -0,0 +1,30 @@
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 } from '@oclif/core';
10
+ import { getCaddyProxyDriver, resolveCaddyProxyRuntimeContext, startCaddyProxy } from '../../../lib/proxy-caddy.js';
11
+ import { failTask, startTask, succeedTask } from '../../../lib/ui.js';
12
+ export default class ProxyCaddyStart extends Command {
13
+ static summary = 'Start the managed caddy proxy';
14
+ async run() {
15
+ await this.parse(ProxyCaddyStart);
16
+ const driver = await getCaddyProxyDriver();
17
+ const runtimeContext = await resolveCaddyProxyRuntimeContext();
18
+ startTask(`Starting caddy proxy with the ${driver} driver...`);
19
+ try {
20
+ const result = await startCaddyProxy(runtimeContext);
21
+ succeedTask(result === 'already-running'
22
+ ? `Caddy proxy is already running with the ${driver} driver.`
23
+ : `Caddy proxy started with the ${driver} driver.`);
24
+ }
25
+ catch (error) {
26
+ failTask(`Failed to start caddy proxy with the ${driver} driver.`);
27
+ this.error(error instanceof Error ? error.message : String(error));
28
+ }
29
+ }
30
+ }
@@ -0,0 +1,19 @@
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 } from '@oclif/core';
10
+ import { formatCaddyProxyStatusLines, getCaddyProxyStatus, resolveCaddyProxyRuntimeContext, } from '../../../lib/proxy-caddy.js';
11
+ export default class ProxyCaddyStatus extends Command {
12
+ static summary = 'Show the current caddy proxy runtime status';
13
+ async run() {
14
+ await this.parse(ProxyCaddyStatus);
15
+ const runtimeContext = await resolveCaddyProxyRuntimeContext();
16
+ const status = await getCaddyProxyStatus(runtimeContext);
17
+ this.log(formatCaddyProxyStatusLines(status).join('\n'));
18
+ }
19
+ }
@@ -0,0 +1,30 @@
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 } from '@oclif/core';
10
+ import { getCaddyProxyDriver, resolveCaddyProxyRuntimeContext, stopCaddyProxy } from '../../../lib/proxy-caddy.js';
11
+ import { failTask, startTask, succeedTask } from '../../../lib/ui.js';
12
+ export default class ProxyCaddyStop extends Command {
13
+ static summary = 'Stop the managed caddy proxy';
14
+ async run() {
15
+ await this.parse(ProxyCaddyStop);
16
+ const driver = await getCaddyProxyDriver();
17
+ const runtimeContext = await resolveCaddyProxyRuntimeContext();
18
+ startTask(`Stopping caddy proxy with the ${driver} driver...`);
19
+ try {
20
+ const result = await stopCaddyProxy(runtimeContext);
21
+ succeedTask(result === 'already-stopped'
22
+ ? `Caddy proxy is already stopped with the ${driver} driver.`
23
+ : `Caddy proxy stopped with the ${driver} driver.`);
24
+ }
25
+ catch (error) {
26
+ failTask(`Failed to stop caddy proxy with the ${driver} driver.`);
27
+ this.error(error instanceof Error ? error.message : String(error));
28
+ }
29
+ }
30
+ }
@@ -0,0 +1,26 @@
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 { Args, Command } from '@oclif/core';
10
+ import { CADDY_PROXY_DRIVER_OPTIONS } from '../../../lib/cli-config.js';
11
+ import { setCaddyProxyDriver } from '../../../lib/proxy-caddy.js';
12
+ export default class ProxyCaddyUse extends Command {
13
+ static summary = 'Select the caddy runtime driver';
14
+ static args = {
15
+ driver: Args.string({
16
+ description: 'caddy runtime driver',
17
+ options: [...CADDY_PROXY_DRIVER_OPTIONS],
18
+ required: true,
19
+ }),
20
+ };
21
+ async run() {
22
+ const { args } = await this.parse(ProxyCaddyUse);
23
+ const driver = await setCaddyProxyDriver(args.driver);
24
+ this.log(driver);
25
+ }
26
+ }
@@ -0,0 +1,28 @@
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, loadHelpClass } from '@oclif/core';
10
+ export default class Proxy extends Command {
11
+ static summary = 'Manage reverse proxy providers for CLI-managed apps';
12
+ static description = 'Use `nb proxy nginx` or `nb proxy caddy` to manage reverse proxy workflows.';
13
+ static examples = [
14
+ '<%= config.bin %> proxy nginx current',
15
+ '<%= config.bin %> proxy nginx use docker',
16
+ '<%= config.bin %> proxy nginx generate --env app1 --host app1.example.com',
17
+ '<%= config.bin %> proxy caddy current',
18
+ '<%= config.bin %> proxy caddy use docker',
19
+ ];
20
+ async run() {
21
+ await this.parse(Proxy);
22
+ const Help = await loadHelpClass(this.config);
23
+ await new Help(this.config, this.config.pjson.oclif.helpOptions ?? this.config.pjson.helpOptions).showHelp([
24
+ this.id ?? 'proxy',
25
+ ...this.argv,
26
+ ]);
27
+ }
28
+ }
@@ -0,0 +1,18 @@
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 } from '@oclif/core';
10
+ import { getNginxProxyDriver } from '../../../lib/proxy-nginx.js';
11
+ export default class ProxyNginxCurrent extends Command {
12
+ static summary = 'Print the current nginx runtime driver';
13
+ async run() {
14
+ await this.parse(ProxyNginxCurrent);
15
+ const driver = await getNginxProxyDriver();
16
+ this.log(driver);
17
+ }
18
+ }