@astralkit/cli 3.0.3 → 3.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astralkit/cli",
3
- "version": "3.0.3",
3
+ "version": "3.0.5",
4
4
  "description": "AstralKit CLI — Install and manage UI components in your project",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "bin": {
@@ -138,7 +138,9 @@ async function tryFetch(type, slug, options) {
138
138
  await getWorkflow(slug, framework);
139
139
  }
140
140
  return true;
141
- } catch {
141
+ } catch (err) {
142
+ // 403 = exists but user doesn't have access — still counts as "found"
143
+ if (err.code === 'PRO_REQUIRED') return true;
142
144
  return false;
143
145
  }
144
146
  }
@@ -233,7 +235,29 @@ async function addComponent(componentSlug, options) {
233
235
  const spinner = ora(`Fetching ${componentSlug} (${FRAMEWORK_LABELS[framework] || framework})...`).start();
234
236
 
235
237
  try {
236
- const data = await getComponent(componentSlug, framework);
238
+ let data;
239
+ let actualFramework = framework;
240
+ try {
241
+ data = await getComponent(componentSlug, framework);
242
+ } catch (fetchErr) {
243
+ // Pro required for React/Next.js — fall back to HTML for free users
244
+ if (fetchErr.code === 'PRO_REQUIRED' && framework !== 'html') {
245
+ spinner.warn(`${FRAMEWORK_LABELS[framework] || framework} requires a Pro subscription.`);
246
+ console.log(chalk.gray(' Fetching HTML version instead (free tier).'));
247
+ actualFramework = 'html';
248
+ const htmlSpinner = ora(`Fetching ${componentSlug} (HTML)...`).start();
249
+ try {
250
+ data = await getComponent(componentSlug, 'html');
251
+ htmlSpinner.succeed(`Fetched ${componentSlug} (HTML)`);
252
+ } catch (htmlErr) {
253
+ htmlSpinner.fail(`Failed to add component.`);
254
+ console.log(chalk.yellow(htmlErr.message));
255
+ return;
256
+ }
257
+ } else {
258
+ throw fetchErr;
259
+ }
260
+ }
237
261
 
238
262
  if (!data.files || data.files.length === 0) {
239
263
  spinner.fail(`No ${framework} code available for "${componentSlug}".`);
@@ -267,7 +291,7 @@ async function addComponent(componentSlug, options) {
267
291
  fs.writeFileSync(filePath, file.content);
268
292
  }
269
293
 
270
- spinner.succeed(`Added ${chalk.cyan(data.name || componentSlug)} (${FRAMEWORK_LABELS[framework] || framework})`);
294
+ spinner.succeed(`Added ${chalk.cyan(data.name || componentSlug)} (${FRAMEWORK_LABELS[actualFramework] || actualFramework})`);
271
295
 
272
296
  console.log(chalk.gray(` ${componentsDir}/`));
273
297
  for (const file of data.files) {
@@ -275,7 +299,7 @@ async function addComponent(componentSlug, options) {
275
299
  }
276
300
 
277
301
  // Post-install checks for react/nextjs
278
- if (framework !== 'html') {
302
+ if (actualFramework !== 'html') {
279
303
  console.log();
280
304
 
281
305
  if (!isAstralkitInstalled()) {