@surreal-ui/cli 0.11.1 → 0.13.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.
Files changed (2) hide show
  1. package/dist/index.js +17 -61
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -5,7 +5,7 @@ import { Command } from "commander";
5
5
  import pc6 from "picocolors";
6
6
 
7
7
  // src/commands/add.ts
8
- import fs4 from "fs";
8
+ import fs3 from "fs";
9
9
  import path4 from "path";
10
10
  import pc from "picocolors";
11
11
  import prompts from "prompts";
@@ -198,27 +198,22 @@ function installDependencies(dependencies, options = {}) {
198
198
  }
199
199
 
200
200
  // src/utils/catalog.ts
201
- import fs3 from "fs";
202
201
  import { createRequire } from "module";
203
202
  import path3 from "path";
204
203
  import {
205
204
  AESTHETICS,
206
- getAesthetic,
207
205
  getComponent,
208
206
  replacementFor
209
207
  } from "@surreal-ui/catalog";
210
- var SOURCE = {
211
- react: { file: "react.tsx", ext: "tsx" },
212
- svelte: { file: "svelte.svelte", ext: "svelte" },
213
- webcomponent: { file: "element.ts", ext: "ts" }
214
- };
208
+ import { catalogRegistryItem } from "@surreal-ui/catalog/node";
215
209
  function catalogDist() {
216
210
  const require2 = createRequire(import.meta.url);
217
211
  return path3.join(path3.dirname(require2.resolve("@surreal-ui/catalog/package.json")), "dist");
218
212
  }
219
213
  function resolveCatalogType(componentId) {
220
214
  const direct = getComponent(componentId);
221
- if (direct && !direct.implements) return { component: direct };
215
+ if (direct && (!direct.implements || direct.implements === direct.id))
216
+ return { component: direct };
222
217
  const pascal = componentId.replace(/(^|-)([a-z0-9])/g, (_, __, c) => c.toUpperCase());
223
218
  const old = replacementFor(componentId) ?? replacementFor(pascal);
224
219
  const component = old && getComponent(old.type);
@@ -226,46 +221,7 @@ function resolveCatalogType(componentId) {
226
221
  }
227
222
  var CATALOG_AESTHETICS = AESTHETICS.map((a) => a.id);
228
223
  function catalogItem(component, framework, aestheticId, dist = catalogDist()) {
229
- const src = SOURCE[framework];
230
- const dir = path3.join(dist, "sources", component.id);
231
- const main = path3.join(dir, src.file);
232
- if (!fs3.existsSync(main)) return null;
233
- if (!getAesthetic(aestheticId))
234
- throw new Error(
235
- `Unknown aesthetic "${aestheticId}". Available: ${CATALOG_AESTHETICS.join(", ")}`
236
- );
237
- const code = fs3.readFileSync(main, "utf8");
238
- const files = [
239
- { path: `${component.export}.${src.ext}`, content: code, type: "registry:ui" }
240
- ];
241
- const style = path3.join(dir, "style.css");
242
- if (fs3.existsSync(style))
243
- files.push({
244
- path: `${component.id}.css`,
245
- content: fs3.readFileSync(style, "utf8"),
246
- type: "registry:ui"
247
- });
248
- files.push({
249
- path: `aesthetic-${aestheticId}.css`,
250
- content: fs3.readFileSync(path3.join(dist, "aesthetics", `${aestheticId}.css`), "utf8"),
251
- type: "registry:ui"
252
- });
253
- const dependencies = /from ['"]@surreal-ui\/catalog/.test(code) ? ["@surreal-ui/catalog"] : [];
254
- return {
255
- name: component.id,
256
- type: "registry:ui",
257
- title: component.name,
258
- description: component.description,
259
- dependencies,
260
- files,
261
- meta: {
262
- aestheticId,
263
- componentTypeId: component.id,
264
- version: "",
265
- framework,
266
- symbolName: component.export
267
- }
268
- };
224
+ return catalogRegistryItem(component, framework, aestheticId, dist);
269
225
  }
270
226
 
271
227
  // src/commands/add.ts
@@ -364,7 +320,7 @@ Fetching ${pc.bold(componentId)} [${aestheticId || "default"}]...`)), await fetc
364
320
  const fileName = path4.basename(file.path);
365
321
  const destPath = path4.join(fullTargetDir, fileName);
366
322
  const relativeDest = path4.relative(cwd, destPath);
367
- if (fs4.existsSync(destPath) && !options.overwrite && !options.yes) {
323
+ if (fs3.existsSync(destPath) && !options.overwrite && !options.yes) {
368
324
  const { overwrite } = await prompts({
369
325
  type: "confirm",
370
326
  name: "overwrite",
@@ -376,8 +332,8 @@ Fetching ${pc.bold(componentId)} [${aestheticId || "default"}]...`)), await fetc
376
332
  continue;
377
333
  }
378
334
  }
379
- fs4.mkdirSync(path4.dirname(destPath), { recursive: true });
380
- fs4.writeFileSync(destPath, file.content, "utf8");
335
+ fs3.mkdirSync(path4.dirname(destPath), { recursive: true });
336
+ fs3.writeFileSync(destPath, file.content, "utf8");
381
337
  console.log(pc.green(`\u2714 Created ${pc.bold(relativeDest)}`));
382
338
  }
383
339
  if (item.dependencies && item.dependencies.length > 0) {
@@ -482,14 +438,14 @@ Add a component: ${pc2.cyan("npx surreal-ui add <component> --aesthetic <style>"
482
438
  }
483
439
 
484
440
  // src/commands/init.ts
485
- import fs5 from "fs";
441
+ import fs4 from "fs";
486
442
  import path5 from "path";
487
443
  import pc3 from "picocolors";
488
444
  import prompts2 from "prompts";
489
445
  async function initCommand(options = {}) {
490
446
  const cwd = options.cwd || process.cwd();
491
447
  const configPath = path5.join(cwd, "surreal.json");
492
- if (fs5.existsSync(configPath) && !options.yes) {
448
+ if (fs4.existsSync(configPath) && !options.yes) {
493
449
  const { overwrite } = await prompts2({
494
450
  type: "confirm",
495
451
  name: "overwrite",
@@ -555,7 +511,7 @@ async function initCommand(options = {}) {
555
511
  ui: componentsPath
556
512
  }
557
513
  };
558
- fs5.writeFileSync(configPath, JSON.stringify(config, null, 2) + "\n", "utf8");
514
+ fs4.writeFileSync(configPath, JSON.stringify(config, null, 2) + "\n", "utf8");
559
515
  console.log(pc3.bold(pc3.green(`
560
516
  \u2714 Configuration saved to ${pc3.bold("surreal.json")}`)));
561
517
  console.log(
@@ -565,7 +521,7 @@ async function initCommand(options = {}) {
565
521
  }
566
522
 
567
523
  // src/commands/diff.ts
568
- import fs6 from "fs";
524
+ import fs5 from "fs";
569
525
  import path6 from "path";
570
526
  import pc4 from "picocolors";
571
527
  async function diffCommand(componentArg, options = {}) {
@@ -595,14 +551,14 @@ async function diffCommand(componentArg, options = {}) {
595
551
  for (const file of item.files) {
596
552
  const fileName = path6.basename(file.path);
597
553
  const destPath = path6.join(fullTargetDir, fileName);
598
- if (!fs6.existsSync(destPath)) {
554
+ if (!fs5.existsSync(destPath)) {
599
555
  console.log(
600
556
  pc4.yellow(`Component file does not exist locally: ${path6.relative(cwd, destPath)}`)
601
557
  );
602
558
  console.log(pc4.gray(`Run 'npx surreal-ui add ${componentId}' to install it.`));
603
559
  continue;
604
560
  }
605
- const localContent = fs6.readFileSync(destPath, "utf8");
561
+ const localContent = fs5.readFileSync(destPath, "utf8");
606
562
  if (localContent.trim() === file.content.trim()) {
607
563
  console.log(
608
564
  pc4.green(
@@ -625,7 +581,7 @@ async function diffCommand(componentArg, options = {}) {
625
581
  }
626
582
 
627
583
  // src/commands/skills.ts
628
- import fs7 from "fs";
584
+ import fs6 from "fs";
629
585
  import path7 from "path";
630
586
  import { pathToFileURL } from "url";
631
587
  import pc5 from "picocolors";
@@ -633,7 +589,7 @@ function findCatalog(cwd) {
633
589
  let dir = path7.resolve(cwd);
634
590
  for (; ; ) {
635
591
  const candidate = path7.join(dir, "node_modules", "@surreal-ui", "catalog");
636
- if (fs7.existsSync(path7.join(candidate, "package.json"))) return fs7.realpathSync(candidate);
592
+ if (fs6.existsSync(path7.join(candidate, "package.json"))) return fs6.realpathSync(candidate);
637
593
  const parent = path7.dirname(dir);
638
594
  if (parent === dir) return void 0;
639
595
  dir = parent;
@@ -646,7 +602,7 @@ async function loadCatalogNode(cwd) {
646
602
  "The skills ship in @surreal-ui/catalog, which this project does not have; install it first (npm install @surreal-ui/catalog)."
647
603
  );
648
604
  const entry = path7.join(catalog, "dist", "node.js");
649
- if (!fs7.existsSync(entry))
605
+ if (!fs6.existsSync(entry))
650
606
  throw new Error(
651
607
  `${catalog} has no skills (dist/node.js); update it (npm install @surreal-ui/catalog@latest).`
652
608
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@surreal-ui/cli",
3
- "version": "0.11.1",
3
+ "version": "0.13.0",
4
4
  "description": "Surreal UI CLI - Add multi-platform UI components directly to your codebase",
5
5
  "license": "MIT",
6
6
  "author": "Pixerate",
@@ -28,7 +28,7 @@
28
28
  "commander": "^13.1.0",
29
29
  "picocolors": "^1.1.1",
30
30
  "prompts": "^2.4.2",
31
- "@surreal-ui/catalog": "0.11.1"
31
+ "@surreal-ui/catalog": "0.13.0"
32
32
  },
33
33
  "devDependencies": {
34
34
  "@types/node": "^20.19.43",