@ztffn/presentation-generator-plugin 1.0.4 → 1.0.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.
Files changed (2) hide show
  1. package/bin/index.js +21 -22
  2. package/package.json +1 -1
package/bin/index.js CHANGED
@@ -63,20 +63,19 @@ function downloadFile(url, dest) {
63
63
  });
64
64
  }
65
65
 
66
- async function getLatestNpmVersion() {
66
+ async function getLatestNpmMeta() {
67
67
  try {
68
68
  const data = await fetchJson(
69
69
  `https://registry.npmjs.org/${NPM_PACKAGE}/latest`
70
70
  );
71
- return data.version || null;
71
+ if (!data.version || !data.dist?.tarball) return null;
72
+ return { version: data.version, tarball: data.dist.tarball };
72
73
  } catch {
73
74
  return null;
74
75
  }
75
76
  }
76
77
 
77
- async function downloadAndExtract(version) {
78
- const pkgSlug = NPM_PACKAGE.replace("@", "").replace("/", "-");
79
- const tarballUrl = `https://registry.npmjs.org/${NPM_PACKAGE}/-/${pkgSlug}-${version}.tgz`;
78
+ async function downloadAndExtract(version, tarballUrl) {
80
79
  const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "claude-plugin-"));
81
80
  const tarball = path.join(tmpDir, "plugin.tgz");
82
81
 
@@ -148,14 +147,15 @@ function registerPlugin() {
148
147
  // ── Commands ──────────────────────────────────────────────────────────────────
149
148
 
150
149
  async function install() {
150
+ const meta = await getLatestNpmMeta();
151
+
151
152
  if (fs.existsSync(INSTALL_DIR)) {
152
153
  const installed = getInstalledVersion();
153
- const latest = await getLatestNpmVersion();
154
154
 
155
- if (latest && installed && installed !== latest) {
155
+ if (meta && installed && installed !== meta.version) {
156
156
  console.log(`\nPlugin already installed (v${installed}).`);
157
157
  console.log(
158
- `v${latest} is available — run: npx ${NPM_PACKAGE} update\n`
158
+ `v${meta.version} is available — run: npx ${NPM_PACKAGE} update\n`
159
159
  );
160
160
  } else {
161
161
  console.log(
@@ -168,16 +168,15 @@ async function install() {
168
168
 
169
169
  console.log(`\nInstalling presentation-generator plugin...`);
170
170
 
171
- const version = await getLatestNpmVersion();
172
- if (!version) {
171
+ if (!meta) {
173
172
  console.error(
174
173
  "\nCould not fetch latest version from npm registry. Check your internet connection.\n"
175
174
  );
176
175
  process.exit(1);
177
176
  }
178
177
 
179
- await downloadAndExtract(version);
180
- console.log(`\nInstalled v${version} to: ${INSTALL_DIR}`);
178
+ await downloadAndExtract(meta.version, meta.tarball);
179
+ console.log(`\nInstalled v${meta.version} to: ${INSTALL_DIR}`);
181
180
  registerPlugin();
182
181
  }
183
182
 
@@ -189,26 +188,26 @@ async function update() {
189
188
  }
190
189
 
191
190
  const before = getInstalledVersion();
192
- const latest = await getLatestNpmVersion();
191
+ const meta = await getLatestNpmMeta();
193
192
 
194
- if (!latest) {
193
+ if (!meta) {
195
194
  console.error(
196
195
  "\nCould not fetch latest version from npm registry. Check your internet connection.\n"
197
196
  );
198
197
  process.exit(1);
199
198
  }
200
199
 
201
- if (before === latest) {
200
+ if (before === meta.version) {
202
201
  console.log(`\nAlready up to date (v${before}) ✓`);
203
202
  registerPlugin();
204
203
  return;
205
204
  }
206
205
 
207
206
  console.log(
208
- `\nUpdating presentation-generator plugin (v${before || "unknown"} → v${latest})...`
207
+ `\nUpdating presentation-generator plugin (v${before || "unknown"} → v${meta.version})...`
209
208
  );
210
- await downloadAndExtract(latest);
211
- console.log(`\nUpdated to v${latest} ✓`);
209
+ await downloadAndExtract(meta.version, meta.tarball);
210
+ console.log(`\nUpdated to v${meta.version} ✓`);
212
211
  registerPlugin();
213
212
  }
214
213
 
@@ -219,19 +218,19 @@ async function checkUpdate() {
219
218
  }
220
219
 
221
220
  const installed = getInstalledVersion();
222
- const latest = await getLatestNpmVersion();
221
+ const meta = await getLatestNpmMeta();
223
222
 
224
- if (!latest) {
223
+ if (!meta) {
225
224
  console.log(
226
225
  `\nInstalled: v${installed || "unknown"} (could not reach npm registry)\n`
227
226
  );
228
227
  return;
229
228
  }
230
229
 
231
- if (installed === latest) {
230
+ if (installed === meta.version) {
232
231
  console.log(`\nUp to date: v${installed} ✓\n`);
233
232
  } else {
234
- console.log(`\nUpdate available: v${installed} → v${latest}`);
233
+ console.log(`\nUpdate available: v${installed} → v${meta.version}`);
235
234
  console.log(`Run: npx ${NPM_PACKAGE} update\n`);
236
235
  }
237
236
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ztffn/presentation-generator-plugin",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "description": "Claude Code plugin for generating graph-based presentations",
5
5
  "bin": {
6
6
  "presentation-generator-plugin": "bin/index.js"