@resourcexjs/cli 2.8.0 → 2.9.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.
package/dist/index.js CHANGED
@@ -4855,19 +4855,28 @@ function define(input) {
4855
4855
  }
4856
4856
  function locate(rxm) {
4857
4857
  return {
4858
- registry: rxm.registry,
4859
- path: rxm.path,
4860
- name: rxm.name,
4861
- tag: rxm.tag
4858
+ registry: rxm.definition.registry,
4859
+ path: rxm.definition.path,
4860
+ name: rxm.definition.name,
4861
+ tag: rxm.definition.tag
4862
4862
  };
4863
4863
  }
4864
4864
  function manifest(rxd) {
4865
4865
  return {
4866
- registry: rxd.registry,
4867
- path: rxd.path,
4868
- name: rxd.name,
4869
- type: rxd.type,
4870
- tag: rxd.tag ?? "latest"
4866
+ definition: {
4867
+ name: rxd.name,
4868
+ type: rxd.type,
4869
+ tag: rxd.tag ?? "latest",
4870
+ registry: rxd.registry,
4871
+ path: rxd.path,
4872
+ description: rxd.description,
4873
+ author: rxd.author,
4874
+ license: rxd.license,
4875
+ keywords: rxd.keywords,
4876
+ repository: rxd.repository
4877
+ },
4878
+ archive: {},
4879
+ source: {}
4871
4880
  };
4872
4881
  }
4873
4882
  function resource(rxm, rxa) {
@@ -17273,12 +17282,9 @@ var add = defineCommand({
17273
17282
  consola.success(`Added resource:
17274
17283
  `);
17275
17284
  console.log(` Locator: ${resource2.locator}`);
17276
- console.log(` Name: ${resource2.name}`);
17277
- console.log(` Type: ${resource2.type}`);
17278
- console.log(` Tag: ${resource2.tag}`);
17279
- if (resource2.files?.length) {
17280
- console.log(` Files: ${resource2.files.join(", ")}`);
17281
- }
17285
+ console.log(` Name: ${resource2.definition.name}`);
17286
+ console.log(` Type: ${resource2.definition.type}`);
17287
+ console.log(` Tag: ${resource2.definition.tag}`);
17282
17288
  } catch (error48) {
17283
17289
  consola.error(error48 instanceof Error ? error48.message : "Failed to add resource");
17284
17290
  process.exit(1);
@@ -17393,24 +17399,40 @@ var info = defineCommand({
17393
17399
  try {
17394
17400
  const rx = await getClient();
17395
17401
  const resource2 = await rx.info(args.locator);
17402
+ const { definition, source } = resource2;
17396
17403
  console.log();
17397
- console.log(` ${resource2.name}:${resource2.tag}`);
17404
+ console.log(` ${definition.name}:${definition.tag}`);
17398
17405
  console.log(` ${"\u2500".repeat(40)}`);
17399
17406
  console.log();
17400
17407
  console.log(` Locator: ${resource2.locator}`);
17401
- if (resource2.registry) {
17402
- console.log(` Registry: ${resource2.registry}`);
17408
+ if (definition.registry) {
17409
+ console.log(` Registry: ${definition.registry}`);
17410
+ }
17411
+ if (definition.path) {
17412
+ console.log(` Path: ${definition.path}`);
17403
17413
  }
17404
- if (resource2.path) {
17405
- console.log(` Path: ${resource2.path}`);
17414
+ console.log(` Name: ${definition.name}`);
17415
+ console.log(` Type: ${definition.type}`);
17416
+ console.log(` Tag: ${definition.tag}`);
17417
+ if (definition.description) {
17418
+ console.log(` Desc: ${definition.description}`);
17419
+ }
17420
+ if (definition.author) {
17421
+ console.log(` Author: ${definition.author}`);
17406
17422
  }
17407
- console.log(` Name: ${resource2.name}`);
17408
- console.log(` Type: ${resource2.type}`);
17409
- console.log(` Tag: ${resource2.tag}`);
17410
17423
  console.log();
17411
- if (resource2.files?.length) {
17424
+ if (source.files && Object.keys(source.files).length > 0) {
17412
17425
  console.log(` Files:`);
17413
- printFileTree(resource2.files);
17426
+ printFileTree(source.files);
17427
+ }
17428
+ if (source.preview) {
17429
+ console.log();
17430
+ console.log(` Preview:`);
17431
+ const lines = source.preview.split(`
17432
+ `).slice(0, 5);
17433
+ for (const line of lines) {
17434
+ console.log(` ${line}`);
17435
+ }
17414
17436
  }
17415
17437
  console.log();
17416
17438
  } catch (error48) {
@@ -17419,44 +17441,30 @@ var info = defineCommand({
17419
17441
  }
17420
17442
  }
17421
17443
  });
17422
- function printFileTree(files) {
17423
- const sorted = [...files].sort();
17424
- const tree = {};
17425
- const rootFiles = [];
17426
- for (const file2 of sorted) {
17427
- const parts = file2.split("/");
17428
- if (parts.length === 1) {
17429
- rootFiles.push(file2);
17430
- } else {
17431
- const dir = parts[0];
17432
- const rest = parts.slice(1).join("/");
17433
- if (!tree[dir]) {
17434
- tree[dir] = [];
17435
- }
17436
- tree[dir].push(rest);
17437
- }
17438
- }
17439
- const dirs = Object.keys(tree).sort();
17440
- const allItems = [...dirs, ...rootFiles];
17441
- for (let i2 = 0;i2 < allItems.length; i2++) {
17442
- const item = allItems[i2];
17443
- const isLast = i2 === allItems.length - 1;
17444
+ function isFileEntry(value) {
17445
+ return "size" in value && typeof value.size === "number";
17446
+ }
17447
+ function printFileTree(tree, indent = "") {
17448
+ const entries = Object.entries(tree);
17449
+ for (let i2 = 0;i2 < entries.length; i2++) {
17450
+ const [name, value] = entries[i2];
17451
+ const isLast = i2 === entries.length - 1;
17444
17452
  const prefix = isLast ? "\u2514\u2500\u2500 " : "\u251C\u2500\u2500 ";
17445
- if (tree[item]) {
17446
- console.log(` ${prefix}${item}/`);
17447
- printSubTree(tree[item], isLast ? " " : "\u2502 ");
17453
+ const childIndent = indent + (isLast ? " " : "\u2502 ");
17454
+ if (isFileEntry(value)) {
17455
+ console.log(` ${indent}${prefix}${name} (${formatSize(value.size)})`);
17448
17456
  } else {
17449
- console.log(` ${prefix}${item}`);
17457
+ console.log(` ${indent}${prefix}${name}`);
17458
+ printFileTree(value, childIndent);
17450
17459
  }
17451
17460
  }
17452
17461
  }
17453
- function printSubTree(files, indent) {
17454
- for (let i2 = 0;i2 < files.length; i2++) {
17455
- const file2 = files[i2];
17456
- const isLast = i2 === files.length - 1;
17457
- const prefix = isLast ? "\u2514\u2500\u2500 " : "\u251C\u2500\u2500 ";
17458
- console.log(` ${indent}${prefix}${file2}`);
17459
- }
17462
+ function formatSize(bytes) {
17463
+ if (bytes < 1024)
17464
+ return `${bytes}B`;
17465
+ if (bytes < 1024 * 1024)
17466
+ return `${(bytes / 1024).toFixed(1)}KB`;
17467
+ return `${(bytes / (1024 * 1024)).toFixed(1)}MB`;
17460
17468
  }
17461
17469
 
17462
17470
  // src/commands/list.ts
@@ -17869,4 +17877,4 @@ var main = defineCommand({
17869
17877
  });
17870
17878
  runMain(main);
17871
17879
 
17872
- //# debugId=0E33A1E8B726679564756E2164756E21
17880
+ //# debugId=2A8A66053CB1D89B64756E2164756E21