@resourcexjs/cli 2.16.1 → 2.17.1

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
@@ -780,6 +780,8 @@ import { promisify as promisify2 } from "util";
780
780
  import { gunzip } from "zlib";
781
781
  import { readdir as readdir2, readFile as readFile2, stat as stat2 } from "fs/promises";
782
782
  import { join as join2, relative as relative2 } from "path";
783
+ import { dirname, join as join3 } from "path";
784
+ import { fileURLToPath, pathToFileURL } from "url";
783
785
  import { createHash } from "crypto";
784
786
  function __exportSetter2(name, newValue) {
785
787
  this[name] = __returnValue2.bind(null, newValue);
@@ -4505,6 +4507,34 @@ class FolderSourceLoader {
4505
4507
  return files;
4506
4508
  }
4507
4509
  }
4510
+
4511
+ class NpmSourceLoader {
4512
+ folder = new FolderSourceLoader;
4513
+ canLoad(source) {
4514
+ return source.startsWith(NPM_PREFIX);
4515
+ }
4516
+ async load(source) {
4517
+ if (!this.canLoad(source)) {
4518
+ throw new ResourceXError(`Not an npm source: ${source}`);
4519
+ }
4520
+ const packageName = source.slice(NPM_PREFIX.length);
4521
+ if (!packageName) {
4522
+ throw new ResourceXError(`Empty package name in npm source: ${source}`);
4523
+ }
4524
+ const packageDir = this.resolvePackageDir(packageName);
4525
+ const rxs = await this.folder.load(packageDir);
4526
+ return { source, files: rxs.files };
4527
+ }
4528
+ resolvePackageDir(packageName) {
4529
+ const parent = pathToFileURL(join3(process.cwd(), "noop.js")).href;
4530
+ try {
4531
+ const url2 = import.meta.resolve(`${packageName}/package.json`, parent);
4532
+ return dirname(fileURLToPath(url2));
4533
+ } catch {
4534
+ throw new ResourceXError(`Cannot resolve npm package: ${packageName}`);
4535
+ }
4536
+ }
4537
+ }
4508
4538
  function computeDigest(data) {
4509
4539
  const hash2 = createHash("sha256").update(data).digest("hex");
4510
4540
  return `sha256:${hash2}`;
@@ -10367,7 +10397,7 @@ var __defProp2, __returnValue2 = (v2) => v2, __export2 = (target, all) => {
10367
10397
  Codec: ZodCodec,
10368
10398
  Boolean: ZodBoolean,
10369
10399
  String: ZodString
10370
- }, ...args), ZodIssueCode, ZodFirstPartyTypeKind, z2, RECOGNIZED_KEYS, exports_coerce, ResourceXError, RXDSchema, gunzipAsync, RegistryError, textType, jsonType, binaryType, skillType, prototypeType, builtinTypes, ResourceTypeError;
10400
+ }, ...args), ZodIssueCode, ZodFirstPartyTypeKind, z2, RECOGNIZED_KEYS, exports_coerce, ResourceXError, RXDSchema, gunzipAsync, NPM_PREFIX = "npm:", RegistryError, textType, jsonType, binaryType, skillType, prototypeType, builtinTypes, ResourceTypeError;
10371
10401
  var init_dist = __esm(() => {
10372
10402
  __defProp2 = Object.defineProperty;
10373
10403
  ZERO_BLOCK = new Uint8Array(BLOCK_SIZE);
@@ -14512,7 +14542,7 @@ import { mkdir as mkdir2, readdir as readdir22, readFile, rm, stat as stat22, un
14512
14542
  import { join as join22 } from "path";
14513
14543
  import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
14514
14544
  import { homedir } from "os";
14515
- import { dirname, join as join3 } from "path";
14545
+ import { dirname as dirname2, join as join32 } from "path";
14516
14546
 
14517
14547
  class FileSystemRXAStore {
14518
14548
  basePath;
@@ -14738,8 +14768,8 @@ class NodeProvider {
14738
14768
  createStores(config2) {
14739
14769
  const basePath = config2.path ?? DEFAULT_BASE_PATH;
14740
14770
  return {
14741
- rxaStore: new FileSystemRXAStore(join3(basePath, "blobs")),
14742
- rxmStore: new FileSystemRXMStore(join3(basePath, "manifests"))
14771
+ rxaStore: new FileSystemRXAStore(join32(basePath, "blobs")),
14772
+ rxmStore: new FileSystemRXMStore(join32(basePath, "manifests"))
14743
14773
  };
14744
14774
  }
14745
14775
  createSourceLoader(_config) {
@@ -14751,7 +14781,7 @@ class NodeProvider {
14751
14781
  return { registry: envRegistry };
14752
14782
  }
14753
14783
  const basePath = config2.path ?? DEFAULT_BASE_PATH;
14754
- const configPath = join3(basePath, "config.json");
14784
+ const configPath = join32(basePath, "config.json");
14755
14785
  try {
14756
14786
  if (existsSync(configPath)) {
14757
14787
  const raw = JSON.parse(readFileSync(configPath, "utf-8"));
@@ -14768,7 +14798,7 @@ class NodeProvider {
14768
14798
  }
14769
14799
  configPath(config2) {
14770
14800
  const basePath = config2.path ?? DEFAULT_BASE_PATH;
14771
- return join3(basePath, "config.json");
14801
+ return join32(basePath, "config.json");
14772
14802
  }
14773
14803
  readConfig(config2) {
14774
14804
  const configPath = this.configPath(config2);
@@ -14786,7 +14816,7 @@ class NodeProvider {
14786
14816
  }
14787
14817
  writeConfig(config2, data) {
14788
14818
  const configPath = this.configPath(config2);
14789
- mkdirSync(dirname(configPath), { recursive: true });
14819
+ mkdirSync(dirname2(configPath), { recursive: true });
14790
14820
  writeFileSync(configPath, JSON.stringify(data, null, 2));
14791
14821
  }
14792
14822
  getRegistries(config2) {
@@ -17507,4 +17537,4 @@ var main = defineCommand({
17507
17537
  });
17508
17538
  runMain(main);
17509
17539
 
17510
- //# debugId=E7512FDD8523B92864756E2164756E21
17540
+ //# debugId=5C2365966C6E552164756E2164756E21