stera-ui 0.5.0 → 0.6.0

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.
@@ -0,0 +1,44 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ createSpinner,
4
+ getAllComponents
5
+ } from "./chunk-KKUJRJ2N.js";
6
+ import {
7
+ LOGO,
8
+ dim
9
+ } from "./chunk-KGMF6UW4.js";
10
+
11
+ // src/commands/list.ts
12
+ async function list() {
13
+ const spinner = createSpinner("Fetching registry");
14
+ let items;
15
+ try {
16
+ items = await getAllComponents();
17
+ } catch (err) {
18
+ spinner.fail("Failed to fetch registry");
19
+ throw err;
20
+ }
21
+ spinner.succeed("Registry resolved");
22
+ const groups = /* @__PURE__ */ new Map();
23
+ for (const item of items) {
24
+ const type = item.type.replace("registry:", "");
25
+ if (!groups.has(type)) groups.set(type, []);
26
+ groups.get(type).push(item);
27
+ }
28
+ console.log(`
29
+ ${LOGO} Available components
30
+ `);
31
+ for (const [type, groupItems] of groups) {
32
+ console.log(` ${type}`);
33
+ for (const item of groupItems) {
34
+ const deps = item.registryDependencies?.length ? dim(` (depends on: ${item.registryDependencies.join(", ")})`) : "";
35
+ console.log(` ${item.name}${deps}`);
36
+ }
37
+ console.log("");
38
+ }
39
+ console.log(` ${dim(`${items.length} components available`)}
40
+ `);
41
+ }
42
+ export {
43
+ list
44
+ };
@@ -1,16 +1,15 @@
1
- import { RegistryItem } from '../schema/index.js';
1
+ import { RegistryIndexEntry, RegistryItem } from '../schema/index.js';
2
2
  import 'zod';
3
3
 
4
- interface RegistryIndexItem {
5
- name: string;
6
- type: string;
7
- dependencies?: string[];
8
- registryDependencies?: string[];
4
+ /** Thrown when requested components (or their dependencies) are not in the registry. */
5
+ declare class ComponentNotFoundError extends Error {
6
+ readonly components: string[];
7
+ constructor(components: string[]);
9
8
  }
10
9
  /**
11
10
  * Fetch the registry index (component list without file contents).
12
11
  */
13
- declare function fetchRegistryIndex(): Promise<RegistryIndexItem[]>;
12
+ declare function fetchRegistryIndex(): Promise<RegistryIndexEntry[]>;
14
13
  /**
15
14
  * Fetch a single registry item with its file contents.
16
15
  */
@@ -18,15 +17,22 @@ declare function fetchRegistryItem(name: string): Promise<RegistryItem>;
18
17
  /**
19
18
  * Get a component from the registry index (no file contents).
20
19
  */
21
- declare function getComponent(name: string): Promise<RegistryIndexItem | undefined>;
20
+ declare function getComponent(name: string): Promise<RegistryIndexEntry | undefined>;
22
21
  /**
23
22
  * Get all components from the registry index.
24
23
  */
25
- declare function getAllComponents(): Promise<RegistryIndexItem[]>;
24
+ declare function getAllComponents(): Promise<RegistryIndexEntry[]>;
26
25
  /**
27
26
  * Resolve all dependencies for the given component names.
28
27
  * Fetches full registry items (with file contents) for each.
28
+ *
29
+ * The dependency graph is walked using the registry index (a single cached
30
+ * request), then all needed items are fetched in one parallel batch.
31
+ * Order is preserved: requested components first, then dependencies.
32
+ *
33
+ * @throws ComponentNotFoundError when any name (requested or transitive)
34
+ * is missing from the registry index.
29
35
  */
30
36
  declare function resolveDependencies(names: string[]): Promise<RegistryItem[]>;
31
37
 
32
- export { RegistryItem, fetchRegistryIndex, fetchRegistryItem, getAllComponents, getComponent, resolveDependencies };
38
+ export { ComponentNotFoundError, RegistryIndexEntry, RegistryItem, fetchRegistryIndex, fetchRegistryItem, getAllComponents, getComponent, resolveDependencies };
@@ -1,11 +1,14 @@
1
1
  import {
2
+ ComponentNotFoundError,
2
3
  fetchRegistryIndex,
3
4
  fetchRegistryItem,
4
5
  getAllComponents,
5
6
  getComponent,
6
7
  resolveDependencies
7
- } from "../chunk-T3QWOVJR.js";
8
+ } from "../chunk-BJNLGEZJ.js";
9
+ import "../chunk-4E46BULJ.js";
8
10
  export {
11
+ ComponentNotFoundError,
9
12
  fetchRegistryIndex,
10
13
  fetchRegistryItem,
11
14
  getAllComponents,
@@ -189,215 +189,57 @@ type RegistryItem = z.infer<typeof registryItemSchema>;
189
189
  type RegistryFontItem = Extract<RegistryItem, {
190
190
  type: "registry:font";
191
191
  }>;
192
+ declare const registryIndexEntrySchema: z.ZodObject<{
193
+ name: z.ZodString;
194
+ type: z.ZodString;
195
+ dependencies: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
196
+ registryDependencies: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
197
+ }, "strip", z.ZodTypeAny, {
198
+ type: string;
199
+ name: string;
200
+ dependencies?: string[] | undefined;
201
+ registryDependencies?: string[] | undefined;
202
+ }, {
203
+ type: string;
204
+ name: string;
205
+ dependencies?: string[] | undefined;
206
+ registryDependencies?: string[] | undefined;
207
+ }>;
208
+ type RegistryIndexEntry = z.infer<typeof registryIndexEntrySchema>;
192
209
  declare const registryIndexSchema: z.ZodObject<{
193
210
  name: z.ZodString;
194
- items: z.ZodArray<z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
195
- name: z.ZodString;
196
- dependencies: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
197
- registryDependencies: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
198
- } & {
199
- type: z.ZodLiteral<"registry:font">;
200
- font: z.ZodObject<{
201
- family: z.ZodString;
202
- provider: z.ZodLiteral<"google">;
203
- import: z.ZodString;
204
- variable: z.ZodString;
205
- weight: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
206
- subsets: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
207
- selector: z.ZodOptional<z.ZodString>;
208
- dependency: z.ZodOptional<z.ZodString>;
209
- }, "strip", z.ZodTypeAny, {
210
- family: string;
211
- provider: "google";
212
- import: string;
213
- variable: string;
214
- weight?: string[] | undefined;
215
- subsets?: string[] | undefined;
216
- selector?: string | undefined;
217
- dependency?: string | undefined;
218
- }, {
219
- family: string;
220
- provider: "google";
221
- import: string;
222
- variable: string;
223
- weight?: string[] | undefined;
224
- subsets?: string[] | undefined;
225
- selector?: string | undefined;
226
- dependency?: string | undefined;
227
- }>;
228
- files: z.ZodOptional<z.ZodArray<z.ZodObject<{
229
- path: z.ZodString;
230
- type: z.ZodEnum<["registry:ui", "registry:component", "registry:hook", "registry:lib", "registry:style", "registry:font"]>;
231
- content: z.ZodOptional<z.ZodString>;
232
- target: z.ZodOptional<z.ZodString>;
233
- }, "strip", z.ZodTypeAny, {
234
- path: string;
235
- type: "registry:ui" | "registry:component" | "registry:hook" | "registry:lib" | "registry:style" | "registry:font";
236
- content?: string | undefined;
237
- target?: string | undefined;
238
- }, {
239
- path: string;
240
- type: "registry:ui" | "registry:component" | "registry:hook" | "registry:lib" | "registry:style" | "registry:font";
241
- content?: string | undefined;
242
- target?: string | undefined;
243
- }>, "many">>;
244
- }, "strip", z.ZodTypeAny, {
245
- type: "registry:font";
246
- name: string;
247
- font: {
248
- family: string;
249
- provider: "google";
250
- import: string;
251
- variable: string;
252
- weight?: string[] | undefined;
253
- subsets?: string[] | undefined;
254
- selector?: string | undefined;
255
- dependency?: string | undefined;
256
- };
257
- dependencies?: string[] | undefined;
258
- registryDependencies?: string[] | undefined;
259
- files?: {
260
- path: string;
261
- type: "registry:ui" | "registry:component" | "registry:hook" | "registry:lib" | "registry:style" | "registry:font";
262
- content?: string | undefined;
263
- target?: string | undefined;
264
- }[] | undefined;
265
- }, {
266
- type: "registry:font";
267
- name: string;
268
- font: {
269
- family: string;
270
- provider: "google";
271
- import: string;
272
- variable: string;
273
- weight?: string[] | undefined;
274
- subsets?: string[] | undefined;
275
- selector?: string | undefined;
276
- dependency?: string | undefined;
277
- };
278
- dependencies?: string[] | undefined;
279
- registryDependencies?: string[] | undefined;
280
- files?: {
281
- path: string;
282
- type: "registry:ui" | "registry:component" | "registry:hook" | "registry:lib" | "registry:style" | "registry:font";
283
- content?: string | undefined;
284
- target?: string | undefined;
285
- }[] | undefined;
286
- }>, z.ZodObject<{
211
+ items: z.ZodArray<z.ZodObject<{
287
212
  name: z.ZodString;
213
+ type: z.ZodString;
288
214
  dependencies: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
289
215
  registryDependencies: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
290
- } & {
291
- type: z.ZodEnum<["registry:ui", "registry:component", "registry:hook", "registry:lib", "registry:style"]>;
292
- files: z.ZodArray<z.ZodObject<{
293
- path: z.ZodString;
294
- type: z.ZodEnum<["registry:ui", "registry:component", "registry:hook", "registry:lib", "registry:style", "registry:font"]>;
295
- content: z.ZodOptional<z.ZodString>;
296
- target: z.ZodOptional<z.ZodString>;
297
- }, "strip", z.ZodTypeAny, {
298
- path: string;
299
- type: "registry:ui" | "registry:component" | "registry:hook" | "registry:lib" | "registry:style" | "registry:font";
300
- content?: string | undefined;
301
- target?: string | undefined;
302
- }, {
303
- path: string;
304
- type: "registry:ui" | "registry:component" | "registry:hook" | "registry:lib" | "registry:style" | "registry:font";
305
- content?: string | undefined;
306
- target?: string | undefined;
307
- }>, "many">;
308
216
  }, "strip", z.ZodTypeAny, {
309
- type: "registry:ui" | "registry:component" | "registry:hook" | "registry:lib" | "registry:style";
217
+ type: string;
310
218
  name: string;
311
- files: {
312
- path: string;
313
- type: "registry:ui" | "registry:component" | "registry:hook" | "registry:lib" | "registry:style" | "registry:font";
314
- content?: string | undefined;
315
- target?: string | undefined;
316
- }[];
317
219
  dependencies?: string[] | undefined;
318
220
  registryDependencies?: string[] | undefined;
319
221
  }, {
320
- type: "registry:ui" | "registry:component" | "registry:hook" | "registry:lib" | "registry:style";
222
+ type: string;
321
223
  name: string;
322
- files: {
323
- path: string;
324
- type: "registry:ui" | "registry:component" | "registry:hook" | "registry:lib" | "registry:style" | "registry:font";
325
- content?: string | undefined;
326
- target?: string | undefined;
327
- }[];
328
224
  dependencies?: string[] | undefined;
329
225
  registryDependencies?: string[] | undefined;
330
- }>]>, "many">;
226
+ }>, "many">;
331
227
  }, "strip", z.ZodTypeAny, {
332
228
  name: string;
333
- items: ({
334
- type: "registry:font";
229
+ items: {
230
+ type: string;
335
231
  name: string;
336
- font: {
337
- family: string;
338
- provider: "google";
339
- import: string;
340
- variable: string;
341
- weight?: string[] | undefined;
342
- subsets?: string[] | undefined;
343
- selector?: string | undefined;
344
- dependency?: string | undefined;
345
- };
346
232
  dependencies?: string[] | undefined;
347
233
  registryDependencies?: string[] | undefined;
348
- files?: {
349
- path: string;
350
- type: "registry:ui" | "registry:component" | "registry:hook" | "registry:lib" | "registry:style" | "registry:font";
351
- content?: string | undefined;
352
- target?: string | undefined;
353
- }[] | undefined;
354
- } | {
355
- type: "registry:ui" | "registry:component" | "registry:hook" | "registry:lib" | "registry:style";
356
- name: string;
357
- files: {
358
- path: string;
359
- type: "registry:ui" | "registry:component" | "registry:hook" | "registry:lib" | "registry:style" | "registry:font";
360
- content?: string | undefined;
361
- target?: string | undefined;
362
- }[];
363
- dependencies?: string[] | undefined;
364
- registryDependencies?: string[] | undefined;
365
- })[];
234
+ }[];
366
235
  }, {
367
236
  name: string;
368
- items: ({
369
- type: "registry:font";
237
+ items: {
238
+ type: string;
370
239
  name: string;
371
- font: {
372
- family: string;
373
- provider: "google";
374
- import: string;
375
- variable: string;
376
- weight?: string[] | undefined;
377
- subsets?: string[] | undefined;
378
- selector?: string | undefined;
379
- dependency?: string | undefined;
380
- };
381
240
  dependencies?: string[] | undefined;
382
241
  registryDependencies?: string[] | undefined;
383
- files?: {
384
- path: string;
385
- type: "registry:ui" | "registry:component" | "registry:hook" | "registry:lib" | "registry:style" | "registry:font";
386
- content?: string | undefined;
387
- target?: string | undefined;
388
- }[] | undefined;
389
- } | {
390
- type: "registry:ui" | "registry:component" | "registry:hook" | "registry:lib" | "registry:style";
391
- name: string;
392
- files: {
393
- path: string;
394
- type: "registry:ui" | "registry:component" | "registry:hook" | "registry:lib" | "registry:style" | "registry:font";
395
- content?: string | undefined;
396
- target?: string | undefined;
397
- }[];
398
- dependencies?: string[] | undefined;
399
- registryDependencies?: string[] | undefined;
400
- })[];
242
+ }[];
401
243
  }>;
402
244
  type RegistryIndex = z.infer<typeof registryIndexSchema>;
403
245
  declare const configSchema: z.ZodObject<{
@@ -466,4 +308,4 @@ declare const configSchema: z.ZodObject<{
466
308
  }>;
467
309
  type SteraConfig = z.infer<typeof configSchema>;
468
310
 
469
- export { type RegistryFontItem, type RegistryIndex, type RegistryItem, type RegistryItemFile, type RegistryItemFont, type RegistryItemType, type SteraConfig, configSchema, registryIndexSchema, registryItemFileSchema, registryItemFontSchema, registryItemSchema, registryItemTypeSchema };
311
+ export { type RegistryFontItem, type RegistryIndex, type RegistryIndexEntry, type RegistryItem, type RegistryItemFile, type RegistryItemFont, type RegistryItemType, type SteraConfig, configSchema, registryIndexEntrySchema, registryIndexSchema, registryItemFileSchema, registryItemFontSchema, registryItemSchema, registryItemTypeSchema };
@@ -1,13 +1,15 @@
1
1
  import {
2
2
  configSchema,
3
+ registryIndexEntrySchema,
3
4
  registryIndexSchema,
4
5
  registryItemFileSchema,
5
6
  registryItemFontSchema,
6
7
  registryItemSchema,
7
8
  registryItemTypeSchema
8
- } from "../chunk-3KADOWKC.js";
9
+ } from "../chunk-4E46BULJ.js";
9
10
  export {
10
11
  configSchema,
12
+ registryIndexEntrySchema,
11
13
  registryIndexSchema,
12
14
  registryItemFileSchema,
13
15
  registryItemFontSchema,
@@ -119,9 +119,14 @@ declare function installDependencies(deps: string[], cwd: string): Promise<void>
119
119
  interface WriteOptions {
120
120
  overwrite?: boolean;
121
121
  }
122
+ interface SkippedFile {
123
+ path: string;
124
+ /** "unchanged" — identical content on disk; "declined" — user kept their version. */
125
+ reason: "unchanged" | "declined";
126
+ }
122
127
  interface WriteResult {
123
128
  written: string[];
124
- skipped: string[];
129
+ skipped: SkippedFile[];
125
130
  }
126
131
  /**
127
132
  * Write component files to the consumer's project.
@@ -167,4 +172,4 @@ declare function updateFonts(fonts: RegistryFontItem[], project: ProjectInfo, cw
167
172
  silent?: boolean;
168
173
  }): Promise<void>;
169
174
 
170
- export { CHECK, CONFIG_FILE, CROSS, LEGACY_CONFIG_FILE, LOGO, type ProjectInfo, type TransformContext, type TransformFn, WARN, type WriteOptions, type WriteResult, type WriteSteraCssResult, applyTransforms, brand, createSpinner, detectAliasPrefix, detectPackageManager, detectProject, dim, findConfigPath, insertImportLine, installDependencies, loadConfig, massageTreeForFonts, resolveOutputPath, transformImports, updateFonts, writeComponentFiles, writeSteraUiCss };
175
+ export { CHECK, CONFIG_FILE, CROSS, LEGACY_CONFIG_FILE, LOGO, type ProjectInfo, type SkippedFile, type TransformContext, type TransformFn, WARN, type WriteOptions, type WriteResult, type WriteSteraCssResult, applyTransforms, brand, createSpinner, detectAliasPrefix, detectPackageManager, detectProject, dim, findConfigPath, insertImportLine, installDependencies, loadConfig, massageTreeForFonts, resolveOutputPath, transformImports, updateFonts, writeComponentFiles, writeSteraUiCss };
@@ -22,8 +22,9 @@ import {
22
22
  updateFonts,
23
23
  writeComponentFiles,
24
24
  writeSteraUiCss
25
- } from "../chunk-F4NT3JC6.js";
26
- import "../chunk-T3QWOVJR.js";
25
+ } from "../chunk-SIXUH4HI.js";
26
+ import "../chunk-BJNLGEZJ.js";
27
+ import "../chunk-4E46BULJ.js";
27
28
  export {
28
29
  CHECK,
29
30
  CONFIG_FILE,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stera-ui",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "type": "module",
5
5
  "description": "Add Stera UI components to your project.",
6
6
  "license": "MIT",
@@ -18,7 +18,7 @@
18
18
  ],
19
19
  "homepage": "https://ui.stera.sh",
20
20
  "engines": {
21
- "node": ">=18"
21
+ "node": ">=20"
22
22
  },
23
23
  "bin": {
24
24
  "stera-ui": "./dist/cli.js"
@@ -1,60 +0,0 @@
1
- // src/registry/index.ts
2
- var REGISTRY_URL = process.env.REGISTRY_URL ?? "https://ui.stera.sh/r";
3
- var _indexCache = null;
4
- async function fetchJSON(url) {
5
- const res = await fetch(url);
6
- if (!res.ok) {
7
- throw new Error(`Failed to fetch ${url}: ${res.status} ${res.statusText}`);
8
- }
9
- return res.json();
10
- }
11
- async function fetchRegistryIndex() {
12
- if (_indexCache) return _indexCache;
13
- const data = await fetchJSON(
14
- `${REGISTRY_URL}/index.json`
15
- );
16
- _indexCache = data.items;
17
- return _indexCache;
18
- }
19
- async function fetchRegistryItem(name) {
20
- return fetchJSON(`${REGISTRY_URL}/${name}.json`);
21
- }
22
- async function getComponent(name) {
23
- const index = await fetchRegistryIndex();
24
- return index.find((item) => item.name === name);
25
- }
26
- async function getAllComponents() {
27
- return fetchRegistryIndex();
28
- }
29
- async function resolveDependencies(names) {
30
- const resolved = /* @__PURE__ */ new Map();
31
- const queue = [...names];
32
- while (queue.length > 0) {
33
- const name = queue.shift();
34
- if (resolved.has(name)) continue;
35
- let item;
36
- try {
37
- item = await fetchRegistryItem(name);
38
- } catch {
39
- console.error(`Component "${name}" not found in registry.`);
40
- process.exit(1);
41
- }
42
- resolved.set(name, item);
43
- if (item.registryDependencies) {
44
- for (const dep of item.registryDependencies) {
45
- if (!resolved.has(dep)) {
46
- queue.push(dep);
47
- }
48
- }
49
- }
50
- }
51
- return Array.from(resolved.values());
52
- }
53
-
54
- export {
55
- fetchRegistryIndex,
56
- fetchRegistryItem,
57
- getComponent,
58
- getAllComponents,
59
- resolveDependencies
60
- };