@astralkit/cli 3.0.3 → 3.0.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/package.json +1 -1
- package/src/commands/add.js +24 -2
package/package.json
CHANGED
package/src/commands/add.js
CHANGED
|
@@ -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,27 @@ async function addComponent(componentSlug, options) {
|
|
|
233
235
|
const spinner = ora(`Fetching ${componentSlug} (${FRAMEWORK_LABELS[framework] || framework})...`).start();
|
|
234
236
|
|
|
235
237
|
try {
|
|
236
|
-
|
|
238
|
+
let data;
|
|
239
|
+
try {
|
|
240
|
+
data = await getComponent(componentSlug, framework);
|
|
241
|
+
} catch (fetchErr) {
|
|
242
|
+
// Pro required for React/Next.js — fall back to HTML for free users
|
|
243
|
+
if (fetchErr.code === 'PRO_REQUIRED' && framework !== 'html') {
|
|
244
|
+
spinner.warn(`${FRAMEWORK_LABELS[framework] || framework} requires a Pro subscription.`);
|
|
245
|
+
console.log(chalk.gray(' Fetching HTML version instead (free tier).'));
|
|
246
|
+
const htmlSpinner = ora(`Fetching ${componentSlug} (HTML)...`).start();
|
|
247
|
+
try {
|
|
248
|
+
data = await getComponent(componentSlug, 'html');
|
|
249
|
+
htmlSpinner.succeed(`Fetched ${componentSlug} (HTML)`);
|
|
250
|
+
} catch (htmlErr) {
|
|
251
|
+
htmlSpinner.fail(`Failed to add component.`);
|
|
252
|
+
console.log(chalk.yellow(htmlErr.message));
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
255
|
+
} else {
|
|
256
|
+
throw fetchErr;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
237
259
|
|
|
238
260
|
if (!data.files || data.files.length === 0) {
|
|
239
261
|
spinner.fail(`No ${framework} code available for "${componentSlug}".`);
|