@clawrise/clawrise-cli 0.1.0-alpha.4

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.
package/README.md ADDED
@@ -0,0 +1,11 @@
1
+ # @clawrise/clawrise-cli
2
+
3
+ 通过 npm 分发的 Clawrise CLI 根包。
4
+
5
+ 用户安装方式:
6
+
7
+ ```bash
8
+ npm install -g @clawrise/clawrise-cli
9
+ ```
10
+
11
+ 安装后会自动选择当前平台对应的预编译二进制,并携带第一方 `feishu` / `notion` provider plugin。
@@ -0,0 +1,35 @@
1
+ #!/usr/bin/env node
2
+
3
+ 'use strict';
4
+
5
+ const childProcess = require('child_process');
6
+ const path = require('path');
7
+ const { resolvePlatformPackage } = require('../lib/platform');
8
+
9
+ const platformPackage = resolvePlatformPackage();
10
+ const pluginPath = path.join(platformPackage.dir, 'plugins');
11
+ const nextEnv = { ...process.env };
12
+
13
+ nextEnv.CLAWRISE_PLUGIN_PATHS = nextEnv.CLAWRISE_PLUGIN_PATHS
14
+ ? `${pluginPath}${path.delimiter}${nextEnv.CLAWRISE_PLUGIN_PATHS}`
15
+ : pluginPath;
16
+
17
+ const result = childProcess.spawnSync(platformPackage.binaryPath, process.argv.slice(2), {
18
+ stdio: 'inherit',
19
+ env: nextEnv,
20
+ });
21
+
22
+ if (result.error) {
23
+ console.error(result.error.message);
24
+ process.exit(1);
25
+ }
26
+
27
+ if (typeof result.status === 'number') {
28
+ process.exit(result.status);
29
+ }
30
+
31
+ if (result.signal) {
32
+ process.kill(process.pid, result.signal);
33
+ }
34
+
35
+ process.exit(1);
@@ -0,0 +1,41 @@
1
+ 'use strict';
2
+
3
+ const path = require('path');
4
+
5
+ const packageMap = {
6
+ 'darwin:arm64': 'clawrise-cli-darwin-arm64',
7
+ 'darwin:x64': 'clawrise-cli-darwin-x64',
8
+ 'linux:arm64': 'clawrise-cli-linux-arm64',
9
+ 'linux:x64': 'clawrise-cli-linux-x64',
10
+ 'win32:arm64': 'clawrise-cli-win32-arm64',
11
+ 'win32:x64': 'clawrise-cli-win32-x64',
12
+ };
13
+
14
+ function resolvePlatformPackage() {
15
+ const platformKey = `${process.platform}:${process.arch}`;
16
+ const packageName = packageMap[platformKey];
17
+
18
+ if (!packageName) {
19
+ throw new Error(`当前平台暂不支持: ${process.platform}/${process.arch}`);
20
+ }
21
+
22
+ let packageJSONPath;
23
+ try {
24
+ packageJSONPath = require.resolve(`${packageName}/package.json`);
25
+ } catch (error) {
26
+ throw new Error(`未找到当前平台对应的二进制包 ${packageName},请重新执行 npm install clawrise-cli。`);
27
+ }
28
+
29
+ const packageDir = path.dirname(packageJSONPath);
30
+ const binaryName = process.platform === 'win32' ? 'clawrise.exe' : 'clawrise';
31
+
32
+ return {
33
+ packageName,
34
+ dir: packageDir,
35
+ binaryPath: path.join(packageDir, 'bin', binaryName),
36
+ };
37
+ }
38
+
39
+ module.exports = {
40
+ resolvePlatformPackage,
41
+ };
package/package.json ADDED
@@ -0,0 +1,30 @@
1
+ {
2
+ "name": "@clawrise/clawrise-cli",
3
+ "version": "0.1.0-alpha.4",
4
+ "description": "Clawrise CLI with bundled first-party provider plugins.",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/repothread/clawrise-cli.git"
9
+ },
10
+ "bugs": {
11
+ "url": "https://github.com/repothread/clawrise-cli/issues"
12
+ },
13
+ "homepage": "https://github.com/repothread/clawrise-cli#readme",
14
+ "bin": {
15
+ "clawrise": "bin/clawrise.js"
16
+ },
17
+ "files": [
18
+ "bin",
19
+ "lib",
20
+ "README.md"
21
+ ],
22
+ "optionalDependencies": {
23
+ "@clawrise/clawrise-cli-darwin-arm64": "0.1.0-alpha.4",
24
+ "@clawrise/clawrise-cli-darwin-x64": "0.1.0-alpha.4",
25
+ "@clawrise/clawrise-cli-linux-arm64": "0.1.0-alpha.4",
26
+ "@clawrise/clawrise-cli-linux-x64": "0.1.0-alpha.4",
27
+ "@clawrise/clawrise-cli-win32-arm64": "0.1.0-alpha.4",
28
+ "@clawrise/clawrise-cli-win32-x64": "0.1.0-alpha.4"
29
+ }
30
+ }