supacloud 0.3.0 → 0.5.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 (3) hide show
  1. package/README.md +26 -27
  2. package/dist/index.js +23 -21
  3. package/package.json +6 -6
package/README.md CHANGED
@@ -1,43 +1,43 @@
1
1
  # supacloud
2
2
 
3
- Unified entrypoint that bundles both SupaCloud CLIs behind a single `supacloud` command.
3
+ Unified entrypoint that bundles both SupaCloud CLIs behind a single `supacloudctl` command.
4
4
 
5
5
  ```
6
- supacloud cli → @supacloud/cli (project-scoped developer tools)
7
- supacloud admin → @supacloud/admin (platform operations: install / SSH / tenant management)
6
+ supacloudctl cli → @supacloud/cli (project-scoped developer tools)
7
+ supacloudctl admin → @supacloud/admin (platform operations: install / SSH / tenant management)
8
8
  ```
9
9
 
10
10
  ## 安装
11
11
 
12
12
  ```bash
13
13
  npm install -g supacloud
14
- supacloud --help
14
+ supacloudctl --help
15
15
  ```
16
16
 
17
17
  One-off execution:
18
18
 
19
19
  ```bash
20
- npx supacloud cli status
21
- npx supacloud admin status
20
+ npx --package supacloud supacloudctl cli status
21
+ npx --package supacloud supacloudctl admin status
22
22
  ```
23
23
 
24
24
  `supacloud` depends on both `@supacloud/cli` and `@supacloud/admin`, so installing
25
25
  it gives you the full toolset. You can still install either CLI on its own
26
26
  (`@supacloud/cli` exposes `supacloud-cli`, `@supacloud/admin` exposes `supacloud-admin`).
27
27
 
28
- ## 自动更新
28
+ ## 更新提示
29
29
 
30
- `supacloud cli ...` and `supacloud admin ...` check the npm `latest` dist-tag before dispatch.
31
- When a newer `@supacloud/cli` or `@supacloud/admin` version exists, the dispatcher runs it with
32
- `npm exec --package <pkg>@<latest> -- <bin> ...args`. If the registry is unavailable, it falls
33
- back to the dependency version bundled with the installed `supacloud` package.
30
+ `supacloudctl cli ...` and `supacloudctl admin ...` check the npm `latest` dist-tag before dispatch.
31
+ When a newer package exists, the dispatcher prints an update notice but still runs the dependency
32
+ version bundled with the installed `supacloud` package. It never downloads or executes a newer
33
+ operator CLI implicitly.
34
34
 
35
35
  Disable the latest check when you need a pinned local version:
36
36
 
37
37
  ```bash
38
- SUPACLOUD_NO_AUTO_UPDATE=1 supacloud cli status
38
+ SUPACLOUD_NO_AUTO_UPDATE=1 supacloudctl cli status
39
39
  # or
40
- SUPACLOUD_AUTO_UPDATE=0 supacloud admin status
40
+ SUPACLOUD_AUTO_UPDATE=0 supacloudctl admin status
41
41
  ```
42
42
 
43
43
  Use `SUPACLOUD_NPM_REGISTRY` or `npm_config_registry` to point the check at a registry mirror.
@@ -45,35 +45,34 @@ Use `SUPACLOUD_NPM_REGISTRY` or `npm_config_registry` to point the check at a re
45
45
  ## 用法
46
46
 
47
47
  ```bash
48
- supacloud cli status
49
- supacloud cli project get
50
- supacloud cli gateway routes --ref <ref>
48
+ supacloudctl cli status
49
+ supacloudctl cli project get
50
+ supacloudctl cli gateway routes --ref <ref>
51
51
 
52
- supacloud admin status
53
- supacloud admin project list
54
- supacloud admin ssh ping
52
+ supacloudctl admin status
53
+ supacloudctl admin project list
54
+ supacloudctl admin ssh ping
55
55
  ```
56
56
 
57
57
  Each subcommand accepts its own `--help`:
58
58
 
59
59
  ```bash
60
- supacloud cli --help
61
- supacloud admin --help
60
+ supacloudctl cli --help
61
+ supacloudctl admin --help
62
62
  ```
63
63
 
64
64
  ## 上下文
65
65
 
66
- `supacloud cli` auto-links the current project from `.env`:
66
+ `supacloudctl cli` auto-links the current project from `.env`:
67
67
 
68
68
  - `SUPABASE_URL` / `SUPACLOUD_API_URL`
69
69
  - `SUPABASE_SERVICE_ROLE_KEY` / `SUPACLOUD_API_TOKEN`
70
70
 
71
- `supacloud admin` expects platform context:
71
+ `supacloudctl admin` expects platform context:
72
72
 
73
73
  - `SUPACLOUD_HOST` + `SUPACLOUD_SSH_KEY` / `SUPACLOUD_SSH_PASS`
74
74
  - `SUPACLOUD_API_URL` + `SUPACLOUD_API_TOKEN`
75
75
 
76
- > Note: on hosts where SupaCloud is installed as a server, `/usr/local/bin/supacloud`
77
- > is the compiled management-api binary (the server process). This npm package's
78
- > `supacloud` command targets developer/operator workflows and is meant for your
79
- > local machine, not the server's process namespace.
76
+ > Note: `/usr/local/bin/supacloud` is the compiled management-api server binary.
77
+ > This npm package exposes only `supacloudctl`; it does not install a `supacloud`
78
+ > compatibility alias and should normally be used on an operator's local machine.
package/dist/index.js CHANGED
@@ -2,14 +2,14 @@
2
2
 
3
3
  // src/index.ts
4
4
  import { spawn } from "node:child_process";
5
- import { existsSync, readFileSync } from "node:fs";
5
+ import { existsSync, readFileSync, realpathSync } from "node:fs";
6
6
  import { createRequire } from "node:module";
7
7
  import { dirname, join, parse } from "node:path";
8
8
  import { fileURLToPath } from "node:url";
9
9
  var require2 = createRequire(import.meta.url);
10
10
  var SUBCOMMANDS = {
11
- cli: { pkg: "@supacloud/cli", bin: "supacloud-cli", desc: "项目级 CLI(开发者工具)" },
12
- admin: { pkg: "@supacloud/admin", bin: "supacloud-admin", desc: "平台运维 CLI(安装/SSH/租户管理)" }
11
+ cli: { pkg: "@supacloud/cli", bin: "supacloud-cli", desc: "@supacloud/cli 项目级开发工具" },
12
+ admin: { pkg: "@supacloud/admin", bin: "supacloud-admin", desc: "@supacloud/admin 平台运维工具" }
13
13
  };
14
14
  function resolveSubpackageEntry(pkgName) {
15
15
  try {
@@ -18,7 +18,7 @@ function resolveSubpackageEntry(pkgName) {
18
18
  return null;
19
19
  }
20
20
  }
21
- var COMMAND = "supacloud";
21
+ var COMMAND = "supacloudctl";
22
22
  var DEFAULT_NPM_REGISTRY = "https://registry.npmjs.org/";
23
23
  var AUTO_UPDATE_TIMEOUT_MS = 2000;
24
24
  function isRecord(value) {
@@ -144,25 +144,22 @@ async function createLaunchPlan(target, forwardedArgs, options = {}) {
144
144
  const resolveInstalled = options.resolveInstalled ?? resolveInstalledPackage;
145
145
  const fetchLatest = options.fetchLatest ?? fetchLatestVersion;
146
146
  const installed = resolveInstalled(target.pkg);
147
+ let updateNotice;
147
148
  if (!isAutoUpdateDisabled(env)) {
148
149
  const latestVersion = await fetchLatest(target.pkg, env);
149
150
  if (latestVersion && isNewerVersion(latestVersion, installed?.version ?? null)) {
150
- return {
151
- mode: "latest",
152
- command: options.npmCommand ?? "npm",
153
- args: ["exec", "--yes", "--package", `${target.pkg}@${latestVersion}`, "--", target.bin, ...forwardedArgs],
154
- shell: (options.platform ?? process.platform) === "win32"
155
- };
151
+ updateNotice = installed?.version ? `${target.pkg} ${latestVersion} 可用;当前固定使用已安装版本 ${installed.version}。请显式运行包管理器更新。` : `${target.pkg} ${latestVersion} 可用;请先通过包管理器显式安装。`;
156
152
  }
157
153
  }
158
154
  if (!installed) {
159
- throw new Error(`${target.pkg} 未安装,且无法从 npm registry 获取最新版。`);
155
+ throw new Error(`${target.pkg} 未安装。请先通过包管理器显式安装固定版本。`);
160
156
  }
161
157
  return {
162
158
  mode: "local",
163
159
  command: options.nodePath ?? process.execPath,
164
160
  args: [installed.entry, ...forwardedArgs],
165
- shell: false
161
+ shell: false,
162
+ ...updateNotice ? { updateNotice } : {}
166
163
  };
167
164
  }
168
165
  function buildHelp() {
@@ -170,7 +167,7 @@ function buildHelp() {
170
167
  `);
171
168
  return `
172
169
  ╔═══════════════════════════════════════════════════════════╗
173
- ║ supacloud ║
170
+ ║ supacloudctl ║
174
171
  ║ 统一入口 · 路由到项目级 CLI 与平台运维 CLI ║
175
172
  ╚═══════════════════════════════════════════════════════════╝
176
173
 
@@ -192,9 +189,8 @@ ${subs}
192
189
  ${COMMAND} admin project list
193
190
  ${COMMAND} admin ssh ping
194
191
 
195
- 每次执行子命令时默认检查 npm latest;发现 @supacloud/cli 或
196
- @supacloud/admin 有新版本时会自动通过 npm exec 运行最新版。
197
- 离线时回退到本地依赖。设置 SUPACLOUD_NO_AUTO_UPDATE=1 可禁用。
192
+ 每次执行子命令时默认检查 npm latest;发现新版本时只输出更新提示,
193
+ 始终运行已安装的固定版本。设置 SUPACLOUD_NO_AUTO_UPDATE=1 可禁用检查。
198
194
  `;
199
195
  }
200
196
  async function run(args) {
@@ -211,6 +207,9 @@ async function run(args) {
211
207
  process.exit(1);
212
208
  }
213
209
  const plan = await createLaunchPlan(target, args.slice(1));
210
+ if (plan.updateNotice) {
211
+ console.error(`ℹ️ ${plan.updateNotice}`);
212
+ }
214
213
  const child = spawn(plan.command, plan.args, {
215
214
  stdio: "inherit",
216
215
  shell: plan.shell
@@ -221,17 +220,19 @@ async function run(args) {
221
220
  process.exit(1);
222
221
  });
223
222
  }
224
- var isMainEntry = (() => {
223
+ function isMainModule(moduleUrl, argvEntry = process.argv[1]) {
224
+ if (!argvEntry)
225
+ return false;
225
226
  try {
226
- return fileURLToPath(import.meta.url) === process.argv[1];
227
+ return realpathSync(fileURLToPath(moduleUrl)) === realpathSync(argvEntry);
227
228
  } catch {
228
229
  return false;
229
230
  }
230
- })();
231
- if (isMainEntry) {
231
+ }
232
+ if (isMainModule(import.meta.url)) {
232
233
  run(process.argv.slice(2)).catch((err) => {
233
234
  const message = err instanceof Error ? err.message : String(err);
234
- console.error(`❌ supacloud 启动失败: ${message}`);
235
+ console.error(`❌ supacloudctl 启动失败: ${message}`);
235
236
  process.exit(1);
236
237
  });
237
238
  }
@@ -239,6 +240,7 @@ export {
239
240
  resolveSubpackageEntry,
240
241
  resolveInstalledPackage,
241
242
  isNewerVersion,
243
+ isMainModule,
242
244
  isAutoUpdateDisabled,
243
245
  getNpmRegistry,
244
246
  fetchLatestVersion,
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "supacloud",
3
- "version": "0.3.0",
4
- "description": "Unified entrypoint: `supacloud cli` and `supacloud admin` in one command",
3
+ "version": "0.5.2",
4
+ "description": "Unified entrypoint: `supacloudctl cli` and `supacloudctl admin` in one command",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
7
  "bin": {
8
- "supacloud": "dist/index.js"
8
+ "supacloudctl": "dist/index.js"
9
9
  },
10
10
  "files": [
11
11
  "dist",
@@ -31,11 +31,11 @@
31
31
  "directory": "packages/supacloud"
32
32
  },
33
33
  "dependencies": {
34
- "@supacloud/cli": "^0.8.0",
35
- "@supacloud/admin": "^0.2.0"
34
+ "@supacloud/cli": "^0.9.1",
35
+ "@supacloud/admin": "^0.3.1"
36
36
  },
37
37
  "devDependencies": {
38
38
  "@types/bun": "^1.3.14",
39
- "typescript": "^6.0.3"
39
+ "typescript": "^7.0.2"
40
40
  }
41
41
  }