plugin-updater 1.3.4 → 1.3.5

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/dist/index.js CHANGED
@@ -8,11 +8,13 @@ import { syncPluginsAcrossApps } from "./syncbridge.js";
8
8
  // @ts-ignore — generated bundle, no .d.ts
9
9
  import { maybeRunCli, deployUpdaterCommands } from "./commands.js";
10
10
  // @ts-ignore — generated bundle, no .d.ts
11
- import { ensureConfig } from "../lib/core.js";
11
+ import { defineConfig } from "../lib/core.js";
12
12
  import path from "path";
13
13
  import fs from "fs";
14
14
  // `node dist/index.js config …` (from the /plugin-updater-config command) runs the
15
15
  // config CLI and exits, before the self-activation/updater sequence below.
16
+ // Register config defaults BEFORE the CLI guard so `config schema` sees them (no write).
17
+ defineConfig("plugin-updater", { logging: true });
16
18
  if (await maybeRunCli()) {
17
19
  process.exit(0);
18
20
  }
@@ -72,10 +74,6 @@ export async function earlyLaunch(configDir, plugins) {
72
74
  deployUpdaterCommands();
73
75
  }
74
76
  catch { /* best-effort */ }
75
- try {
76
- ensureConfig("plugin-updater", { logging: true });
77
- }
78
- catch { /* best-effort */ }
79
77
  // pull in any `sync: true` plugins from the other app BEFORE building, then
80
78
  // re-read the list so a freshly-synced-in plugin is cloned/built this pass.
81
79
  await syncPluginsAcrossApps(configDir);
package/lib/core.js CHANGED
@@ -83,19 +83,13 @@ function loadConfig(name, configDir = getAppConfigDir()) {
83
83
  CACHE[key] = data && typeof data === "object" && !Array.isArray(data) ? data : {};
84
84
  return CACHE[key];
85
85
  }
86
- function ensureConfig(name, defaults, configDir = getAppConfigDir()) {
87
- const trivial = Object.keys(defaults).every((k) => k === "logging");
88
- const preferred = join2(configDir, "config", `${name}.json`);
89
- const fallback = join2(configDir, `${name}.json`);
90
- if (!trivial && !existsSync3(preferred) && !existsSync3(fallback)) {
91
- try {
92
- writeJson(preferred, defaults);
93
- } catch {
94
- }
95
- CACHE[configDir + "::" + name] = { ...defaults };
96
- return CACHE[configDir + "::" + name];
97
- }
98
- return { ...defaults, ...loadConfig(name, configDir) };
86
+ var DEFAULTS = {};
87
+ function defineConfig(name, defaults, configDir = getAppConfigDir()) {
88
+ DEFAULTS[name] = { ...DEFAULTS[name] ?? {}, ...defaults };
89
+ return { ...DEFAULTS[name], ...loadConfig(name, configDir) };
90
+ }
91
+ function getConfigDefaults(name) {
92
+ return { ...DEFAULTS[name] ?? {} };
99
93
  }
100
94
  function getConfigValue(name, key, configDir = getAppConfigDir()) {
101
95
  let node = loadConfig(name, configDir);
@@ -243,14 +237,22 @@ function configCommand(pluginName, commandName = `${pluginName}-config`) {
243
237
  // core/src/configcli.ts
244
238
  function runConfigCli(pluginName, argv) {
245
239
  const [action, key, ...rest] = argv;
240
+ if (action === "schema") {
241
+ console.log(JSON.stringify({ name: pluginName, defaults: getConfigDefaults(pluginName), current: listConfig(pluginName) }));
242
+ return;
243
+ }
246
244
  if (!action || action === "list") {
247
- const cfg = listConfig(pluginName);
248
- const keys = Object.keys(cfg);
245
+ const defaults = getConfigDefaults(pluginName);
246
+ const current = listConfig(pluginName);
247
+ const keys = Object.keys({ ...defaults, ...current });
249
248
  if (!keys.length) {
250
- console.log(`${pluginName}: no config set (using defaults).`);
249
+ console.log(`${pluginName}: no configurable settings.`);
251
250
  return;
252
251
  }
253
- for (const k of keys) console.log(`${k} = ${JSON.stringify(cfg[k])}`);
252
+ for (const k of keys) {
253
+ const isSet = Object.prototype.hasOwnProperty.call(current, k);
254
+ console.log(`${k} = ${JSON.stringify(isSet ? current[k] : defaults[k])}${isSet ? "" : " (default)"}`);
255
+ }
254
256
  return;
255
257
  }
256
258
  if (action === "get") {
@@ -271,7 +273,7 @@ function runConfigCli(pluginName, argv) {
271
273
  console.log(`set ${key} = ${JSON.stringify(value)}`);
272
274
  return;
273
275
  }
274
- console.log(`${pluginName} config \u2014 usage: list | get <key> | set <key> <value>`);
276
+ console.log(`${pluginName} config \u2014 usage: list | get <key> | set <key> <value> | schema`);
275
277
  }
276
278
  function maybeRunConfigCli(pluginName) {
277
279
  const argv = process.argv.slice(2);
@@ -289,13 +291,14 @@ export {
289
291
  configCommand,
290
292
  configPath,
291
293
  createLogger,
294
+ defineConfig,
292
295
  deployCommands,
293
- ensureConfig,
294
296
  ensureDir,
295
297
  existingApps,
296
298
  existingConfigDirs,
297
299
  getApp,
298
300
  getAppConfigDir,
301
+ getConfigDefaults,
299
302
  getConfigValue,
300
303
  globalSetting,
301
304
  isClaude,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "plugin-updater",
3
- "version": "1.3.4",
3
+ "version": "1.3.5",
4
4
  "description": "Plugin lifecycle manager for OpenCode and Claude Code launchers",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",