openclaw-channels-csdn-setup 0.2.5 → 0.2.6

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/dist/cli.cjs +9 -52
  2. package/package.json +1 -1
package/dist/cli.cjs CHANGED
@@ -53,29 +53,6 @@ function mergeCsdnIntoOpenClawConfig(existing, csdn) {
53
53
  // src/cli.ts
54
54
  var PLUGIN_PACKAGE = "csdn-im";
55
55
  var DEFAULT_API_URL = "https://msg.csdn.net/claw";
56
- function isPlainObject2(v) {
57
- return typeof v === "object" && v !== null && !Array.isArray(v);
58
- }
59
- function hasStalePluginState(cfg, channelId) {
60
- const plugins = isPlainObject2(cfg.plugins) ? cfg.plugins : {};
61
- return isPlainObject2(cfg.channels) && channelId in cfg.channels || isPlainObject2(plugins.entries) && channelId in plugins.entries || isPlainObject2(plugins.installs) && channelId in plugins.installs;
62
- }
63
- function stripChannelFromConfig(cfg, channelId) {
64
- const channels = isPlainObject2(cfg.channels) ? { ...cfg.channels } : {};
65
- delete channels[channelId];
66
- const plugins = isPlainObject2(cfg.plugins) ? { ...cfg.plugins } : {};
67
- if (isPlainObject2(plugins.entries)) {
68
- const entries = { ...plugins.entries };
69
- delete entries[channelId];
70
- plugins.entries = entries;
71
- }
72
- if (isPlainObject2(plugins.installs)) {
73
- const installs = { ...plugins.installs };
74
- delete installs[channelId];
75
- plugins.installs = installs;
76
- }
77
- return { ...cfg, channels, plugins };
78
- }
79
56
  function defaultConfigPath() {
80
57
  return (0, import_node_path.join)((0, import_node_os.homedir)(), ".openclaw", "openclaw.json");
81
58
  }
@@ -121,28 +98,7 @@ function run(argv) {
121
98
  }
122
99
  const apiUrl = parsed.values["api-url"]?.trim() || process.env.CSDN_API_URL?.trim() || DEFAULT_API_URL;
123
100
  const configPath = parsed.values.config?.trim() || defaultConfigPath();
124
- let existing;
125
- if ((0, import_node_fs.existsSync)(configPath)) {
126
- try {
127
- const raw = (0, import_node_fs.readFileSync)(configPath, "utf8");
128
- existing = JSON.parse(raw);
129
- } catch (e) {
130
- console.error(`Error: could not read ${configPath}: ${e}`);
131
- return 1;
132
- }
133
- }
134
101
  if (!parsed.values["skip-install"]) {
135
- if (existing && hasStalePluginState(existing, PLUGIN_PACKAGE)) {
136
- try {
137
- const stripped = stripChannelFromConfig(existing, PLUGIN_PACKAGE);
138
- (0, import_node_fs.mkdirSync)((0, import_node_path.dirname)(configPath), { recursive: true });
139
- (0, import_node_fs.writeFileSync)(configPath, `${JSON.stringify(stripped, null, 2)}
140
- `, "utf8");
141
- } catch (e) {
142
- console.error(`Error: could not pre-strip channel config: ${e}`);
143
- return 1;
144
- }
145
- }
146
102
  const openclaw = (0, import_node_child_process.spawnSync)(
147
103
  "openclaw",
148
104
  ["plugins", "install", PLUGIN_PACKAGE],
@@ -162,14 +118,15 @@ function run(argv) {
162
118
  console.error(`Error: openclaw plugins install exited with code ${openclaw.status}`);
163
119
  return openclaw.status ?? 1;
164
120
  }
165
- if ((0, import_node_fs.existsSync)(configPath)) {
166
- try {
167
- const raw = (0, import_node_fs.readFileSync)(configPath, "utf8");
168
- existing = JSON.parse(raw);
169
- } catch (e) {
170
- console.error(`Error: could not read ${configPath} after install: ${e}`);
171
- return 1;
172
- }
121
+ }
122
+ let existing;
123
+ if ((0, import_node_fs.existsSync)(configPath)) {
124
+ try {
125
+ const raw = (0, import_node_fs.readFileSync)(configPath, "utf8");
126
+ existing = JSON.parse(raw);
127
+ } catch (e) {
128
+ console.error(`Error: could not read ${configPath}: ${e}`);
129
+ return 1;
173
130
  }
174
131
  }
175
132
  const merged = mergeCsdnIntoOpenClawConfig(existing, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openclaw-channels-csdn-setup",
3
- "version": "0.2.5",
3
+ "version": "0.2.6",
4
4
  "description": "One-shot installer: openclaw plugins install csdn-im@latest + merge channels.csdn-im into openclaw.json. Requires OpenClaw peer range as published in csdn-im (see csdn-im package.json openclaw.compatibility).",
5
5
  "type": "module",
6
6
  "license": "MIT",