@ztffn/presentation-generator-plugin 1.4.3 → 1.4.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/bin/index.js +55 -9
- package/package.json +1 -1
package/bin/index.js
CHANGED
|
@@ -244,6 +244,23 @@ function cleanOldCacheVersions(keepVersion) {
|
|
|
244
244
|
}
|
|
245
245
|
}
|
|
246
246
|
|
|
247
|
+
function clearInstalledPluginsEntry() {
|
|
248
|
+
// Remove all registry entries for this plugin so `claude plugin install`
|
|
249
|
+
// starts from a clean slate and cannot restore a stale cache path/version.
|
|
250
|
+
const registryPath = path.join(
|
|
251
|
+
os.homedir(), ".claude", "plugins", "installed_plugins.json"
|
|
252
|
+
);
|
|
253
|
+
if (!fs.existsSync(registryPath)) return;
|
|
254
|
+
try {
|
|
255
|
+
const registry = JSON.parse(fs.readFileSync(registryPath, "utf8"));
|
|
256
|
+
const key = `${PLUGIN_NAME}@${MARKETPLACE_NAME}`;
|
|
257
|
+
if (registry.plugins && key in registry.plugins) {
|
|
258
|
+
delete registry.plugins[key];
|
|
259
|
+
fs.writeFileSync(registryPath, JSON.stringify(registry, null, 2) + "\n");
|
|
260
|
+
}
|
|
261
|
+
} catch {}
|
|
262
|
+
}
|
|
263
|
+
|
|
247
264
|
function writeInstalledPluginsJson(version, installDir, scope) {
|
|
248
265
|
// Claude Code's `claude plugin install` writes stale version/installPath data
|
|
249
266
|
// (a known bug: https://github.com/anthropics/claude-code/issues/15642).
|
|
@@ -301,6 +318,19 @@ function registerWithClaude(installDir, scope, version) {
|
|
|
301
318
|
execSync(`claude plugin uninstall ${PLUGIN_NAME}@${MARKETPLACE_NAME} --scope user`, { stdio: "pipe" });
|
|
302
319
|
} catch {}
|
|
303
320
|
|
|
321
|
+
// Directly clear the registry entry regardless of whether the CLI uninstall
|
|
322
|
+
// removed it (the CLI skips entries whose projectPath != cwd).
|
|
323
|
+
clearInstalledPluginsEntry();
|
|
324
|
+
|
|
325
|
+
// Remove stale cache dirs so `claude plugin install` has nothing stale to
|
|
326
|
+
// restore. writeInstalledPluginsJson will recreate the correct version dir.
|
|
327
|
+
const cachePluginDir = path.join(
|
|
328
|
+
os.homedir(), ".claude", "plugins", "cache", MARKETPLACE_NAME, PLUGIN_NAME
|
|
329
|
+
);
|
|
330
|
+
if (fs.existsSync(cachePluginDir)) {
|
|
331
|
+
fs.rmSync(cachePluginDir, { recursive: true, force: true });
|
|
332
|
+
}
|
|
333
|
+
|
|
304
334
|
execSync(`claude plugin marketplace add "${pluginsDir}"`, { stdio: "pipe" });
|
|
305
335
|
|
|
306
336
|
const scopeFlag = scope === "project" ? "--scope project" : "--scope user";
|
|
@@ -329,14 +359,36 @@ function removeFromSettings(settingsPath) {
|
|
|
329
359
|
// ── Commands ──────────────────────────────────────────────────────────────────
|
|
330
360
|
|
|
331
361
|
async function install() {
|
|
362
|
+
// Warn if this installer binary is outdated (npx caches old versions).
|
|
363
|
+
// Stale installers lack bug fixes — users should run with @latest.
|
|
364
|
+
const latestMeta = await getLatestNpmMeta();
|
|
365
|
+
if (latestMeta) {
|
|
366
|
+
const versionLt = (a, b) => {
|
|
367
|
+
const [aMaj, aMin, aPat] = a.split(".").map(Number);
|
|
368
|
+
const [bMaj, bMin, bPat] = b.split(".").map(Number);
|
|
369
|
+
return aMaj < bMaj || (aMaj === bMaj && aMin < bMin) || (aMaj === bMaj && aMin === bMin && aPat < bPat);
|
|
370
|
+
};
|
|
371
|
+
if (versionLt(CURRENT_VERSION, latestMeta.version)) {
|
|
372
|
+
console.log(`\nWarning: installer v${CURRENT_VERSION} is outdated (v${latestMeta.version} available).`);
|
|
373
|
+
console.log(`Run with @latest to get the current installer:`);
|
|
374
|
+
console.log(` npx ${NPM_PACKAGE}@latest install\n`);
|
|
375
|
+
return;
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
const meta = latestMeta;
|
|
380
|
+
if (!meta) {
|
|
381
|
+
console.error("\nCould not fetch latest version from npm registry. Check your internet connection.\n");
|
|
382
|
+
process.exit(1);
|
|
383
|
+
}
|
|
384
|
+
|
|
332
385
|
const globalExists = fs.existsSync(GLOBAL_INSTALL_DIR);
|
|
333
386
|
const projectExists = fs.existsSync(PROJECT_INSTALL_DIR);
|
|
334
387
|
|
|
335
388
|
if (globalExists || projectExists) {
|
|
336
|
-
const meta = await getLatestNpmMeta();
|
|
337
389
|
if (globalExists) {
|
|
338
390
|
const v = getInstalledVersion(GLOBAL_INSTALL_DIR);
|
|
339
|
-
if (
|
|
391
|
+
if (v !== meta.version) {
|
|
340
392
|
console.log(`\nGlobal install found (v${v}). v${meta.version} available — run: npx ${NPM_PACKAGE} update\n`);
|
|
341
393
|
} else {
|
|
342
394
|
console.log(`\nGlobal install already up to date (v${v || "unknown"}).\n`);
|
|
@@ -344,7 +396,7 @@ async function install() {
|
|
|
344
396
|
}
|
|
345
397
|
if (projectExists) {
|
|
346
398
|
const v = getInstalledVersion(PROJECT_INSTALL_DIR);
|
|
347
|
-
if (
|
|
399
|
+
if (v !== meta.version) {
|
|
348
400
|
console.log(`\nProject install found (v${v}). v${meta.version} available — run: npx ${NPM_PACKAGE} update\n`);
|
|
349
401
|
} else {
|
|
350
402
|
console.log(`\nProject install already up to date (v${v || "unknown"}).\n`);
|
|
@@ -353,12 +405,6 @@ async function install() {
|
|
|
353
405
|
return;
|
|
354
406
|
}
|
|
355
407
|
|
|
356
|
-
const meta = await getLatestNpmMeta();
|
|
357
|
-
if (!meta) {
|
|
358
|
-
console.error("\nCould not fetch latest version from npm registry. Check your internet connection.\n");
|
|
359
|
-
process.exit(1);
|
|
360
|
-
}
|
|
361
|
-
|
|
362
408
|
const { installDir, scope } = await resolveInstallTarget();
|
|
363
409
|
|
|
364
410
|
console.log(`\nInstalling presentation-generator plugin...`);
|