stera-ui 0.3.1 → 0.3.2

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/dist/cli.js CHANGED
@@ -370,27 +370,39 @@ function hasGlobalsCss(config, projectRoot) {
370
370
  var transforms = [transformImports];
371
371
  async function add(components, options) {
372
372
  const cwd = options.cwd ? path6.resolve(options.cwd) : process.cwd();
373
- for (const name of components) {
374
- const item = await getComponent(name);
375
- if (!item) {
376
- console.error(` Error: Component "${name}" not found in registry.`);
377
- console.error(` Run "stera-ui list" to see available components.`);
378
- process.exit(1);
373
+ const spinner = createSpinner("Fetching registry");
374
+ try {
375
+ for (const name of components) {
376
+ const item = await getComponent(name);
377
+ if (!item) {
378
+ spinner.fail(`Component "${name}" not found in registry.`);
379
+ console.error(` Run "stera-ui list" to see available components.`);
380
+ process.exit(1);
381
+ }
379
382
  }
383
+ } catch (err) {
384
+ spinner.fail("Failed to fetch registry");
385
+ throw err;
380
386
  }
381
387
  const configPath = findConfigPath(cwd);
382
388
  if (!configPath) {
383
- console.error(
384
- ` Error: ${CONFIG_FILE} not found. Run "stera-ui init" first.`
385
- );
389
+ spinner.fail(`${CONFIG_FILE} not found. Run "stera-ui init" first.`);
386
390
  process.exit(1);
387
391
  }
388
392
  const config = loadConfig(cwd);
389
393
  if (!config) {
390
- console.error(` Error: Failed to parse ${CONFIG_FILE}.`);
394
+ spinner.fail(`Failed to parse ${CONFIG_FILE}.`);
391
395
  process.exit(1);
392
396
  }
393
397
  const projectRoot = path6.dirname(configPath);
398
+ let resolved;
399
+ try {
400
+ resolved = await resolveDependencies(components);
401
+ } catch (err) {
402
+ spinner.fail("Failed to fetch registry");
403
+ throw err;
404
+ }
405
+ spinner.succeed("Registry resolved");
394
406
  const isAddingGlobals = components.includes("globals");
395
407
  if (!isAddingGlobals && !hasGlobalsCss(config, projectRoot)) {
396
408
  console.warn(`
@@ -399,7 +411,6 @@ async function add(components, options) {
399
411
  console.warn(` Run "stera-ui add globals" to install base styles.
400
412
  `);
401
413
  }
402
- const resolved = await resolveDependencies(components);
403
414
  for (const item of resolved) {
404
415
  for (const file of item.files ?? []) {
405
416
  if (file.content) {
@@ -1045,16 +1056,23 @@ async function promptFontStrategy(detected, skipPrompts) {
1045
1056
  return strategy;
1046
1057
  }
1047
1058
  async function fetchDefaultFonts() {
1059
+ const spinner = createSpinner("Fetching fonts");
1048
1060
  const fonts = [];
1049
- for (const name of DEFAULT_FONT_NAMES) {
1050
- try {
1051
- const item = await fetchRegistryItem(name);
1052
- if (item.type === "registry:font") {
1053
- fonts.push(item);
1061
+ try {
1062
+ for (const name of DEFAULT_FONT_NAMES) {
1063
+ try {
1064
+ const item = await fetchRegistryItem(name);
1065
+ if (item.type === "registry:font") {
1066
+ fonts.push(item);
1067
+ }
1068
+ } catch {
1054
1069
  }
1055
- } catch {
1056
1070
  }
1071
+ } catch (err) {
1072
+ spinner.fail("Failed to fetch fonts");
1073
+ throw err;
1057
1074
  }
1075
+ spinner.succeed("Fonts resolved");
1058
1076
  return fonts;
1059
1077
  }
1060
1078
  async function executeFontStrategy(strategy, project, detected, config, cwd) {
@@ -1159,8 +1177,16 @@ async function init(options) {
1159
1177
  ` ${CHECK} Stera already initialised ${dim(`(${path10.join(path10.dirname(project.existingCssFile), "stera-ui.css")} exists)`)}`
1160
1178
  );
1161
1179
  } else {
1180
+ const fetchSpinner = createSpinner("Fetching base styles");
1181
+ let globalsItem;
1162
1182
  try {
1163
- const globalsItem = await fetchRegistryItem("globals");
1183
+ globalsItem = await fetchRegistryItem("globals");
1184
+ } catch {
1185
+ fetchSpinner.fail("Base styles not found \u2014 skipping");
1186
+ globalsItem = null;
1187
+ }
1188
+ if (globalsItem) {
1189
+ fetchSpinner.succeed("Base styles resolved");
1164
1190
  const globalsContent = globalsItem.files?.[0]?.content ?? "";
1165
1191
  const { content: steraUiContent, imports } = stripImportLines(globalsContent);
1166
1192
  const steraUiPath = path10.join(cssDir, "stera-ui.css");
@@ -1173,11 +1199,18 @@ async function init(options) {
1173
1199
  }
1174
1200
  insertImportLine(existingCssPath, "@import './stera-ui.css';");
1175
1201
  console.log(` ${CHECK} Added @import to ${project.existingCssFile}`);
1176
- } catch {
1177
1202
  }
1178
1203
  }
1179
1204
  } else {
1180
- const resolved = await resolveDependencies(["globals"]);
1205
+ const fetchSpinner = createSpinner("Fetching base styles");
1206
+ let resolved;
1207
+ try {
1208
+ resolved = await resolveDependencies(["globals"]);
1209
+ } catch (err) {
1210
+ fetchSpinner.fail("Failed to fetch base styles");
1211
+ throw err;
1212
+ }
1213
+ fetchSpinner.succeed("Base styles resolved");
1181
1214
  const filtered = resolved.filter((item) => item.name !== "fonts");
1182
1215
  const { written } = await writeComponentFiles(filtered, config, cwd);
1183
1216
  for (const file of written) {
@@ -1191,14 +1224,21 @@ async function init(options) {
1191
1224
  config,
1192
1225
  cwd
1193
1226
  );
1227
+ const depsSpinner = createSpinner("Fetching package list");
1228
+ let globalsForDeps;
1194
1229
  try {
1195
- const globalsItem = await fetchRegistryItem("globals");
1196
- if (globalsItem.dependencies) {
1197
- const deps = [...new Set(globalsItem.dependencies)].sort();
1230
+ globalsForDeps = await fetchRegistryItem("globals");
1231
+ } catch {
1232
+ depsSpinner.fail("Package list unavailable \u2014 skipping");
1233
+ globalsForDeps = null;
1234
+ }
1235
+ if (globalsForDeps) {
1236
+ depsSpinner.succeed("Package list resolved");
1237
+ if (globalsForDeps.dependencies) {
1238
+ const deps = [...new Set(globalsForDeps.dependencies)].sort();
1198
1239
  console.log("");
1199
1240
  await installDependencies(deps, cwd);
1200
1241
  }
1201
- } catch {
1202
1242
  }
1203
1243
  console.log("");
1204
1244
  console.log(" Next steps:");
@@ -1212,7 +1252,15 @@ async function init(options) {
1212
1252
 
1213
1253
  // src/commands/list.ts
1214
1254
  async function list() {
1215
- const items = await getAllComponents();
1255
+ const spinner = createSpinner("Fetching registry");
1256
+ let items;
1257
+ try {
1258
+ items = await getAllComponents();
1259
+ } catch (err) {
1260
+ spinner.fail("Failed to fetch registry");
1261
+ throw err;
1262
+ }
1263
+ spinner.succeed("Registry resolved");
1216
1264
  const groups = /* @__PURE__ */ new Map();
1217
1265
  for (const item of items) {
1218
1266
  const type = item.type.replace("registry:", "");
@@ -8,13 +8,13 @@ declare const registryItemFileSchema: z.ZodObject<{
8
8
  content: z.ZodOptional<z.ZodString>;
9
9
  target: z.ZodOptional<z.ZodString>;
10
10
  }, "strip", z.ZodTypeAny, {
11
- type: "registry:ui" | "registry:component" | "registry:hook" | "registry:lib" | "registry:style" | "registry:font";
12
11
  path: string;
12
+ type: "registry:ui" | "registry:component" | "registry:hook" | "registry:lib" | "registry:style" | "registry:font";
13
13
  content?: string | undefined;
14
14
  target?: string | undefined;
15
15
  }, {
16
- type: "registry:ui" | "registry:component" | "registry:hook" | "registry:lib" | "registry:style" | "registry:font";
17
16
  path: string;
17
+ type: "registry:ui" | "registry:component" | "registry:hook" | "registry:lib" | "registry:style" | "registry:font";
18
18
  content?: string | undefined;
19
19
  target?: string | undefined;
20
20
  }>;
@@ -88,13 +88,13 @@ declare const registryItemSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
88
88
  content: z.ZodOptional<z.ZodString>;
89
89
  target: z.ZodOptional<z.ZodString>;
90
90
  }, "strip", z.ZodTypeAny, {
91
- type: "registry:ui" | "registry:component" | "registry:hook" | "registry:lib" | "registry:style" | "registry:font";
92
91
  path: string;
92
+ type: "registry:ui" | "registry:component" | "registry:hook" | "registry:lib" | "registry:style" | "registry:font";
93
93
  content?: string | undefined;
94
94
  target?: string | undefined;
95
95
  }, {
96
- type: "registry:ui" | "registry:component" | "registry:hook" | "registry:lib" | "registry:style" | "registry:font";
97
96
  path: string;
97
+ type: "registry:ui" | "registry:component" | "registry:hook" | "registry:lib" | "registry:style" | "registry:font";
98
98
  content?: string | undefined;
99
99
  target?: string | undefined;
100
100
  }>, "many">>;
@@ -114,8 +114,8 @@ declare const registryItemSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
114
114
  dependencies?: string[] | undefined;
115
115
  registryDependencies?: string[] | undefined;
116
116
  files?: {
117
- type: "registry:ui" | "registry:component" | "registry:hook" | "registry:lib" | "registry:style" | "registry:font";
118
117
  path: string;
118
+ type: "registry:ui" | "registry:component" | "registry:hook" | "registry:lib" | "registry:style" | "registry:font";
119
119
  content?: string | undefined;
120
120
  target?: string | undefined;
121
121
  }[] | undefined;
@@ -135,8 +135,8 @@ declare const registryItemSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
135
135
  dependencies?: string[] | undefined;
136
136
  registryDependencies?: string[] | undefined;
137
137
  files?: {
138
- type: "registry:ui" | "registry:component" | "registry:hook" | "registry:lib" | "registry:style" | "registry:font";
139
138
  path: string;
139
+ type: "registry:ui" | "registry:component" | "registry:hook" | "registry:lib" | "registry:style" | "registry:font";
140
140
  content?: string | undefined;
141
141
  target?: string | undefined;
142
142
  }[] | undefined;
@@ -152,13 +152,13 @@ declare const registryItemSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
152
152
  content: z.ZodOptional<z.ZodString>;
153
153
  target: z.ZodOptional<z.ZodString>;
154
154
  }, "strip", z.ZodTypeAny, {
155
- type: "registry:ui" | "registry:component" | "registry:hook" | "registry:lib" | "registry:style" | "registry:font";
156
155
  path: string;
156
+ type: "registry:ui" | "registry:component" | "registry:hook" | "registry:lib" | "registry:style" | "registry:font";
157
157
  content?: string | undefined;
158
158
  target?: string | undefined;
159
159
  }, {
160
- type: "registry:ui" | "registry:component" | "registry:hook" | "registry:lib" | "registry:style" | "registry:font";
161
160
  path: string;
161
+ type: "registry:ui" | "registry:component" | "registry:hook" | "registry:lib" | "registry:style" | "registry:font";
162
162
  content?: string | undefined;
163
163
  target?: string | undefined;
164
164
  }>, "many">;
@@ -166,8 +166,8 @@ declare const registryItemSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
166
166
  type: "registry:ui" | "registry:component" | "registry:hook" | "registry:lib" | "registry:style";
167
167
  name: string;
168
168
  files: {
169
- type: "registry:ui" | "registry:component" | "registry:hook" | "registry:lib" | "registry:style" | "registry:font";
170
169
  path: string;
170
+ type: "registry:ui" | "registry:component" | "registry:hook" | "registry:lib" | "registry:style" | "registry:font";
171
171
  content?: string | undefined;
172
172
  target?: string | undefined;
173
173
  }[];
@@ -177,8 +177,8 @@ declare const registryItemSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
177
177
  type: "registry:ui" | "registry:component" | "registry:hook" | "registry:lib" | "registry:style";
178
178
  name: string;
179
179
  files: {
180
- type: "registry:ui" | "registry:component" | "registry:hook" | "registry:lib" | "registry:style" | "registry:font";
181
180
  path: string;
181
+ type: "registry:ui" | "registry:component" | "registry:hook" | "registry:lib" | "registry:style" | "registry:font";
182
182
  content?: string | undefined;
183
183
  target?: string | undefined;
184
184
  }[];
@@ -231,13 +231,13 @@ declare const registryIndexSchema: z.ZodObject<{
231
231
  content: z.ZodOptional<z.ZodString>;
232
232
  target: z.ZodOptional<z.ZodString>;
233
233
  }, "strip", z.ZodTypeAny, {
234
- type: "registry:ui" | "registry:component" | "registry:hook" | "registry:lib" | "registry:style" | "registry:font";
235
234
  path: string;
235
+ type: "registry:ui" | "registry:component" | "registry:hook" | "registry:lib" | "registry:style" | "registry:font";
236
236
  content?: string | undefined;
237
237
  target?: string | undefined;
238
238
  }, {
239
- type: "registry:ui" | "registry:component" | "registry:hook" | "registry:lib" | "registry:style" | "registry:font";
240
239
  path: string;
240
+ type: "registry:ui" | "registry:component" | "registry:hook" | "registry:lib" | "registry:style" | "registry:font";
241
241
  content?: string | undefined;
242
242
  target?: string | undefined;
243
243
  }>, "many">>;
@@ -257,8 +257,8 @@ declare const registryIndexSchema: z.ZodObject<{
257
257
  dependencies?: string[] | undefined;
258
258
  registryDependencies?: string[] | undefined;
259
259
  files?: {
260
- type: "registry:ui" | "registry:component" | "registry:hook" | "registry:lib" | "registry:style" | "registry:font";
261
260
  path: string;
261
+ type: "registry:ui" | "registry:component" | "registry:hook" | "registry:lib" | "registry:style" | "registry:font";
262
262
  content?: string | undefined;
263
263
  target?: string | undefined;
264
264
  }[] | undefined;
@@ -278,8 +278,8 @@ declare const registryIndexSchema: z.ZodObject<{
278
278
  dependencies?: string[] | undefined;
279
279
  registryDependencies?: string[] | undefined;
280
280
  files?: {
281
- type: "registry:ui" | "registry:component" | "registry:hook" | "registry:lib" | "registry:style" | "registry:font";
282
281
  path: string;
282
+ type: "registry:ui" | "registry:component" | "registry:hook" | "registry:lib" | "registry:style" | "registry:font";
283
283
  content?: string | undefined;
284
284
  target?: string | undefined;
285
285
  }[] | undefined;
@@ -295,13 +295,13 @@ declare const registryIndexSchema: z.ZodObject<{
295
295
  content: z.ZodOptional<z.ZodString>;
296
296
  target: z.ZodOptional<z.ZodString>;
297
297
  }, "strip", z.ZodTypeAny, {
298
- type: "registry:ui" | "registry:component" | "registry:hook" | "registry:lib" | "registry:style" | "registry:font";
299
298
  path: string;
299
+ type: "registry:ui" | "registry:component" | "registry:hook" | "registry:lib" | "registry:style" | "registry:font";
300
300
  content?: string | undefined;
301
301
  target?: string | undefined;
302
302
  }, {
303
- type: "registry:ui" | "registry:component" | "registry:hook" | "registry:lib" | "registry:style" | "registry:font";
304
303
  path: string;
304
+ type: "registry:ui" | "registry:component" | "registry:hook" | "registry:lib" | "registry:style" | "registry:font";
305
305
  content?: string | undefined;
306
306
  target?: string | undefined;
307
307
  }>, "many">;
@@ -309,8 +309,8 @@ declare const registryIndexSchema: z.ZodObject<{
309
309
  type: "registry:ui" | "registry:component" | "registry:hook" | "registry:lib" | "registry:style";
310
310
  name: string;
311
311
  files: {
312
- type: "registry:ui" | "registry:component" | "registry:hook" | "registry:lib" | "registry:style" | "registry:font";
313
312
  path: string;
313
+ type: "registry:ui" | "registry:component" | "registry:hook" | "registry:lib" | "registry:style" | "registry:font";
314
314
  content?: string | undefined;
315
315
  target?: string | undefined;
316
316
  }[];
@@ -320,8 +320,8 @@ declare const registryIndexSchema: z.ZodObject<{
320
320
  type: "registry:ui" | "registry:component" | "registry:hook" | "registry:lib" | "registry:style";
321
321
  name: string;
322
322
  files: {
323
- type: "registry:ui" | "registry:component" | "registry:hook" | "registry:lib" | "registry:style" | "registry:font";
324
323
  path: string;
324
+ type: "registry:ui" | "registry:component" | "registry:hook" | "registry:lib" | "registry:style" | "registry:font";
325
325
  content?: string | undefined;
326
326
  target?: string | undefined;
327
327
  }[];
@@ -346,8 +346,8 @@ declare const registryIndexSchema: z.ZodObject<{
346
346
  dependencies?: string[] | undefined;
347
347
  registryDependencies?: string[] | undefined;
348
348
  files?: {
349
- type: "registry:ui" | "registry:component" | "registry:hook" | "registry:lib" | "registry:style" | "registry:font";
350
349
  path: string;
350
+ type: "registry:ui" | "registry:component" | "registry:hook" | "registry:lib" | "registry:style" | "registry:font";
351
351
  content?: string | undefined;
352
352
  target?: string | undefined;
353
353
  }[] | undefined;
@@ -355,8 +355,8 @@ declare const registryIndexSchema: z.ZodObject<{
355
355
  type: "registry:ui" | "registry:component" | "registry:hook" | "registry:lib" | "registry:style";
356
356
  name: string;
357
357
  files: {
358
- type: "registry:ui" | "registry:component" | "registry:hook" | "registry:lib" | "registry:style" | "registry:font";
359
358
  path: string;
359
+ type: "registry:ui" | "registry:component" | "registry:hook" | "registry:lib" | "registry:style" | "registry:font";
360
360
  content?: string | undefined;
361
361
  target?: string | undefined;
362
362
  }[];
@@ -381,8 +381,8 @@ declare const registryIndexSchema: z.ZodObject<{
381
381
  dependencies?: string[] | undefined;
382
382
  registryDependencies?: string[] | undefined;
383
383
  files?: {
384
- type: "registry:ui" | "registry:component" | "registry:hook" | "registry:lib" | "registry:style" | "registry:font";
385
384
  path: string;
385
+ type: "registry:ui" | "registry:component" | "registry:hook" | "registry:lib" | "registry:style" | "registry:font";
386
386
  content?: string | undefined;
387
387
  target?: string | undefined;
388
388
  }[] | undefined;
@@ -390,8 +390,8 @@ declare const registryIndexSchema: z.ZodObject<{
390
390
  type: "registry:ui" | "registry:component" | "registry:hook" | "registry:lib" | "registry:style";
391
391
  name: string;
392
392
  files: {
393
- type: "registry:ui" | "registry:component" | "registry:hook" | "registry:lib" | "registry:style" | "registry:font";
394
393
  path: string;
394
+ type: "registry:ui" | "registry:component" | "registry:hook" | "registry:lib" | "registry:style" | "registry:font";
395
395
  content?: string | undefined;
396
396
  target?: string | undefined;
397
397
  }[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stera-ui",
3
- "version": "0.3.1",
3
+ "version": "0.3.2",
4
4
  "type": "module",
5
5
  "description": "Add Stera UI components to your project.",
6
6
  "license": "MIT",