@powerbase/cli 0.1.0 → 0.1.1

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.
@@ -0,0 +1,75 @@
1
+ 'use strict';
2
+
3
+ // `npx -y @powerbase/cli@latest install` 的一键安装向导:
4
+ // 1) 全局安装 CLI 2) 安装 AI 技能 3) 预置连接 4) 浏览器登录(如未登录)
5
+
6
+ const fs = require('node:fs');
7
+ const path = require('node:path');
8
+ const { spawnSync } = require('node:child_process');
9
+
10
+ const PLATFORM_PACKAGES = {
11
+ 'win32-x64': '@powerbase/cli-win32-x64',
12
+ 'win32-arm64': '@powerbase/cli-win32-arm64',
13
+ 'darwin-arm64': '@powerbase/cli-darwin-arm64',
14
+ 'darwin-x64': '@powerbase/cli-darwin-x64',
15
+ };
16
+
17
+ function resolveBinary() {
18
+ const pkg = PLATFORM_PACKAGES[`${process.platform}-${process.arch}`];
19
+ if (!pkg) return null;
20
+ try {
21
+ const pkgJson = require.resolve(`${pkg}/package.json`);
22
+ const exe = process.platform === 'win32' ? 'powerbase.exe' : 'powerbase';
23
+ return path.join(path.dirname(pkgJson), 'bin', exe);
24
+ } catch {
25
+ return null;
26
+ }
27
+ }
28
+
29
+ function loadConfig() {
30
+ try {
31
+ return JSON.parse(fs.readFileSync(path.join(__dirname, '..', 'install-config.json'), 'utf8'));
32
+ } catch {
33
+ return {};
34
+ }
35
+ }
36
+
37
+ function run(cmd, args) {
38
+ return spawnSync(cmd, args, { stdio: 'inherit', shell: true });
39
+ }
40
+
41
+ function main() {
42
+ const { serverHost, webHost } = loadConfig();
43
+ const skillsUrl = webHost || serverHost;
44
+ console.log('正在安装 PowerBase CLI...');
45
+
46
+ const installed = run('npm', ['install', '-g', '@powerbase/cli@latest']);
47
+ if (installed.status !== 0) {
48
+ console.error('全局安装失败。请重试:npm install -g @powerbase/cli');
49
+ return 1;
50
+ }
51
+
52
+ if (skillsUrl) {
53
+ console.log('正在安装 AI 技能...');
54
+ const skills = run('npx', ['-y', 'skills', 'add', skillsUrl, '--skill', 'powerbase', '-y', '-g']);
55
+ if (skills.status !== 0) {
56
+ console.warn(`技能安装失败。可稍后手动执行:npx -y skills add ${skillsUrl} --skill powerbase -y -g`);
57
+ }
58
+ }
59
+
60
+ const binary = resolveBinary();
61
+ if (binary && serverHost) {
62
+ spawnSync(binary, ['profile', 'add', 'powerbase', '--host', serverHost, '--use'], { stdio: 'ignore' });
63
+ const status = spawnSync(binary, ['auth', 'status'], { stdio: 'ignore' });
64
+ if (status.status !== 0) {
65
+ console.log('接下来需要在浏览器中完成登录授权...');
66
+ spawnSync(binary, ['auth', 'login'], { stdio: 'inherit' });
67
+ }
68
+ }
69
+
70
+ console.log('安装完成!重启你的 AI 助手即可使用。');
71
+ console.log('升级命令:npx -y @powerbase/cli@latest install');
72
+ return 0;
73
+ }
74
+
75
+ process.exit(main());
package/bin/powerbase.js CHANGED
@@ -11,6 +11,11 @@ const PLATFORM_PACKAGES = {
11
11
  'darwin-x64': '@powerbase/cli-darwin-x64',
12
12
  };
13
13
 
14
+ if (process.argv[2] === 'install') {
15
+ require('./install-wizard.js');
16
+ return;
17
+ }
18
+
14
19
  function resolveBinary() {
15
20
  const key = `${process.platform}-${process.arch}`;
16
21
  const pkg = PLATFORM_PACKAGES[key];
@@ -1,3 +1,4 @@
1
1
  {
2
- "serverHost": "http://192.168.5.66:2447"
2
+ "serverHost": "http://192.168.5.66:2447",
3
+ "webHost": "http://192.168.5.66:2446"
3
4
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@powerbase/cli",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "PowerBase CLI - query and manage PowerBase knowledge bases from the terminal",
5
5
  "license": "MIT",
6
6
  "bin": {
@@ -19,9 +19,9 @@
19
19
  "node": "\u003e=18"
20
20
  },
21
21
  "optionalDependencies": {
22
- "@powerbase/cli-win32-x64": "0.1.0",
23
- "@powerbase/cli-win32-arm64": "0.1.0",
24
- "@powerbase/cli-darwin-arm64": "0.1.0",
25
- "@powerbase/cli-darwin-x64": "0.1.0"
22
+ "@powerbase/cli-win32-x64": "0.1.1",
23
+ "@powerbase/cli-win32-arm64": "0.1.1",
24
+ "@powerbase/cli-darwin-arm64": "0.1.1",
25
+ "@powerbase/cli-darwin-x64": "0.1.1"
26
26
  }
27
27
  }