@chbo297/infoflow 2026.5.7-beta.2 → 2026.5.7-beta.3

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 (2) hide show
  1. package/package.json +2 -2
  2. package/dist/src/cli.js +0 -157
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chbo297/infoflow",
3
- "version": "2026.5.7-beta.2",
3
+ "version": "2026.5.7-beta.3",
4
4
  "description": "OpenClaw Infoflow (如流) channel plugin for Baidu enterprise messaging",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -45,7 +45,7 @@
45
45
  }
46
46
  },
47
47
  "scripts": {
48
- "build": "tsc -p tsconfig.build.json",
48
+ "build": "rm -rf dist && tsc -p tsconfig.build.json",
49
49
  "typecheck": "tsc --noEmit",
50
50
  "test": "vitest run"
51
51
  },
package/dist/src/cli.js DELETED
@@ -1,157 +0,0 @@
1
- #!/usr/bin/env node
2
- import { mkdtempSync, readFileSync, rmSync } from "node:fs";
3
- import { homedir, tmpdir } from "node:os";
4
- import { dirname, join, resolve } from "node:path";
5
- import { fileURLToPath } from "node:url";
6
- import { spawnSync } from "node:child_process";
7
- const DEFAULT_REGISTRY = "http://registry.npm.baidu-int.com";
8
- function printHelp() {
9
- console.log(`Usage:
10
- npx -y @chbo297/infoflow update [options]
11
-
12
- Commands:
13
- update Download and install/update Infoflow plugin
14
-
15
- Options:
16
- --version <version> Package version (default: latest)
17
- --registry <url> npm registry URL (default: npm_config_registry or ${DEFAULT_REGISTRY})
18
- --channel-id <id> OpenClaw channel/plugin id (default: infoflow)
19
- --dry-run Print commands without changing system
20
- --source-dir <path> Internal use: deploy directly from local source directory
21
- -h, --help Show help
22
- `);
23
- }
24
- function runOrFail(command, args, cwd, dryRun) {
25
- const line = [command, ...args].join(" ");
26
- console.log(`$ (${cwd}) ${line}`);
27
- if (dryRun)
28
- return;
29
- const result = spawnSync(command, args, { cwd, stdio: "inherit" });
30
- if (result.status !== 0) {
31
- process.exit(result.status ?? 1);
32
- }
33
- }
34
- function runAndCollect(command, args, cwd) {
35
- const result = spawnSync(command, args, { cwd, encoding: "utf8" });
36
- if (result.status !== 0) {
37
- if (result.stdout)
38
- process.stdout.write(result.stdout);
39
- if (result.stderr)
40
- process.stderr.write(result.stderr);
41
- process.exit(result.status ?? 1);
42
- }
43
- return result.stdout ?? "";
44
- }
45
- function parseArgs(argv) {
46
- const args = [...argv];
47
- const command = args.shift() ?? "";
48
- const options = {
49
- version: "latest",
50
- registry: process.env.npm_config_registry || DEFAULT_REGISTRY,
51
- channelId: "infoflow",
52
- dryRun: false,
53
- };
54
- for (let i = 0; i < args.length; i += 1) {
55
- const value = args[i];
56
- if (value === "--version")
57
- options.version = args[++i] ?? options.version;
58
- else if (value === "--registry")
59
- options.registry = args[++i] ?? options.registry;
60
- else if (value === "--channel-id")
61
- options.channelId = args[++i] ?? options.channelId;
62
- else if (value === "--source-dir")
63
- options.sourceDir = args[++i];
64
- else if (value === "--dry-run")
65
- options.dryRun = true;
66
- else if (value === "-h" || value === "--help") {
67
- printHelp();
68
- process.exit(0);
69
- }
70
- else {
71
- console.error(`Unknown option: ${value}`);
72
- printHelp();
73
- process.exit(1);
74
- }
75
- }
76
- return { command, options };
77
- }
78
- function installFromRegistry(options, packageName, pluginDir) {
79
- const tempRoot = mkdtempSync(join(tmpdir(), "infoflow-update-"));
80
- try {
81
- const spec = `${packageName}@${options.version}`;
82
- let tarball = "";
83
- if (options.dryRun) {
84
- console.log(`$ (${tempRoot}) npm pack ${spec} --registry ${options.registry} --json`);
85
- tarball = "<generated-by-npm-pack>.tgz";
86
- }
87
- else {
88
- const output = runAndCollect("npm", ["pack", spec, "--registry", options.registry, "--json"], tempRoot);
89
- const parsed = JSON.parse(output);
90
- tarball = parsed[0]?.filename ?? "";
91
- if (!tarball) {
92
- console.error("Unable to resolve packed tarball filename from npm pack output.");
93
- process.exit(1);
94
- }
95
- }
96
- runOrFail("tar", ["-xzf", tarball], tempRoot, options.dryRun);
97
- runOrFail("mkdir", ["-p", pluginDir], tempRoot, options.dryRun);
98
- runOrFail("rsync", ["-av", "--delete", `${join(tempRoot, "package")}/`, `${pluginDir}/`, "--exclude", "node_modules"], tempRoot, options.dryRun);
99
- }
100
- finally {
101
- if (!options.dryRun)
102
- rmSync(tempRoot, { recursive: true, force: true });
103
- }
104
- }
105
- function installFromSource(options, pluginDir) {
106
- const sourceDir = resolve(options.sourceDir);
107
- runOrFail("mkdir", ["-p", pluginDir], sourceDir, options.dryRun);
108
- runOrFail("rsync", [
109
- "-av",
110
- "--delete",
111
- `${sourceDir}/`,
112
- `${pluginDir}/`,
113
- "--exclude",
114
- "node_modules",
115
- "--exclude",
116
- "dist",
117
- "--exclude",
118
- ".git",
119
- ], sourceDir, options.dryRun);
120
- }
121
- function main() {
122
- const { command, options } = parseArgs(process.argv.slice(2));
123
- if (!command) {
124
- printHelp();
125
- process.exit(0);
126
- }
127
- if (command !== "update") {
128
- console.error(`Unknown command: ${command}`);
129
- printHelp();
130
- process.exit(1);
131
- }
132
- const filePath = fileURLToPath(import.meta.url);
133
- const packageDir = resolve(dirname(filePath), "..", "..");
134
- const pkg = JSON.parse(readFileSync(resolve(packageDir, "package.json"), "utf8"));
135
- const packageName = pkg.name || "@chbo297/infoflow";
136
- const pluginDir = resolve(process.env.HOME || homedir(), ".openclaw", "extensions", options.channelId);
137
- if (options.sourceDir) {
138
- installFromSource(options, pluginDir);
139
- }
140
- else {
141
- installFromRegistry(options, packageName, pluginDir);
142
- }
143
- const commonScriptPath = join(pluginDir, "scripts", "lib", "deploy-common.sh");
144
- runOrFail("bash", [
145
- commonScriptPath,
146
- "--plugin-dir",
147
- pluginDir,
148
- "--plugin-id",
149
- options.channelId,
150
- "--config-file",
151
- resolve(process.env.HOME || homedir(), ".openclaw", "openclaw.json"),
152
- "--baidu-registry",
153
- options.registry,
154
- ...(options.dryRun ? ["--dry-run"] : []),
155
- ], pluginDir, options.dryRun);
156
- }
157
- main();