plugin-updater 1.0.11 → 1.0.13

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/index.js +21 -18
  2. package/package.json +2 -1
package/index.js CHANGED
@@ -1,7 +1,7 @@
1
- const fs = require('fs');
2
- const path = require('path');
3
- const os = require('os');
4
- const { execSync } = require('child_process');
1
+ import fs from 'fs';
2
+ import path from 'path';
3
+ import os from 'os';
4
+ import { execSync } from 'child_process';
5
5
 
6
6
  let EARLY_LAUNCH_CONFIG_DIR = null;
7
7
 
@@ -22,16 +22,16 @@ function writeLog(message, isError = false) {
22
22
  const isClaude = process.argv.join(' ').includes('claude');
23
23
  const appName = isClaude ? "claude" : "opencode";
24
24
  const configDir = getAppConfigDir(appName);
25
-
25
+
26
26
  const logsDir = path.join(configDir, "logs", dateStr);
27
27
  if (!fs.existsSync(logsDir)) {
28
28
  fs.mkdirSync(logsDir, { recursive: true });
29
29
  }
30
-
30
+
31
31
  const logFile = path.join(logsDir, `updater-${dateStr}.log`);
32
32
  const prefix = isError ? "[ERROR]" : "[INFO]";
33
33
  const logMsg = `[${date.toISOString()}] ${prefix} ${message}\n`;
34
-
34
+
35
35
  fs.appendFileSync(logFile, logMsg);
36
36
  } catch (e) {
37
37
  // Silent fallback if logging fails
@@ -68,7 +68,7 @@ const updaterAPI = {
68
68
  updatePlugin: function(pluginName, gitUrl, branch = null, commitHash = null) {
69
69
  const reposDir = getReposDir();
70
70
  const targetDir = path.join(reposDir, pluginName);
71
-
71
+
72
72
  if (!fs.existsSync(targetDir)) {
73
73
  if (!fs.existsSync(reposDir)) fs.mkdirSync(reposDir, { recursive: true });
74
74
  const branchFlag = branch ? `--branch ${branch}` : "";
@@ -99,14 +99,13 @@ const updaterAPI = {
99
99
  writeLog(`Running npm install for ${pluginName}`);
100
100
  execSync("npm install", { cwd: sourceDir, stdio: "ignore" });
101
101
  writeLog(`Finished npm install for ${pluginName}`);
102
-
103
- // Safely check if a build script exists before executing
102
+
104
103
  const pkg = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
105
104
  if (pkg.scripts && pkg.scripts.build) {
106
- execSync("npm run build", { cwd: sourceDir, stdio: "ignore" });
107
- writeLog(`Finished npm run build for ${pluginName}`);
105
+ execSync("npm run build", { cwd: sourceDir, stdio: "ignore" });
106
+ writeLog(`Finished npm run build for ${pluginName}`);
108
107
  } else {
109
- writeLog(`Skipped npm run build for ${pluginName} (no build script found)`);
108
+ writeLog(`Skipped npm run build for ${pluginName} (no build script found)`);
110
109
  }
111
110
  } catch (error) {
112
111
  writeLog(`Build/Install failed for ${pluginName}: ${error.message}`, true);
@@ -179,7 +178,7 @@ const updaterAPI = {
179
178
 
180
179
  const pluginUpdaterEntry = async function(input) {
181
180
  const configDir = (input && input.configDir) ? input.configDir : path.dirname(getReposDir());
182
-
181
+
183
182
  // 1. GUARANTEE BASE DIRECTORIES EXIST ON LAUNCH
184
183
  const reposDir = path.join(configDir, "repos");
185
184
  const pluginsDir = path.join(configDir, "plugin");
@@ -209,8 +208,12 @@ const pluginUpdaterEntry = async function(input) {
209
208
  return {};
210
209
  };
211
210
 
212
- const apiMethods = { ...updaterAPI };
213
- delete apiMethods.name;
214
- Object.assign(pluginUpdaterEntry, apiMethods);
211
+ // Attach API methods to the entry function (skip 'name' — conflicts with Function.name)
212
+ for (const [key, value] of Object.entries(updaterAPI)) {
213
+ if (key !== 'name') {
214
+ pluginUpdaterEntry[key] = value;
215
+ }
216
+ }
217
+ pluginUpdaterEntry.pluginName = updaterAPI.name;
215
218
 
216
- module.exports = pluginUpdaterEntry;
219
+ export default pluginUpdaterEntry;
package/package.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "plugin-updater",
3
- "version": "1.0.11",
3
+ "version": "1.0.13",
4
4
  "description": "Plugin lifecycle manager for OpenCode and Claude Code launchers",
5
+ "type": "module",
5
6
  "main": "index.js",
6
7
  "license": "MIT",
7
8
  "author": "intisy",