@resourcexjs/cli 2.16.1 → 2.17.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
@@ -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 } from "path";
784
+ import { fileURLToPath } 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,33 @@ 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
+ try {
4530
+ const url2 = import.meta.resolve(`${packageName}/package.json`);
4531
+ return dirname(fileURLToPath(url2));
4532
+ } catch {
4533
+ throw new ResourceXError(`Cannot resolve npm package: ${packageName}`);
4534
+ }
4535
+ }
4536
+ }
4508
4537
  function computeDigest(data) {
4509
4538
  const hash2 = createHash("sha256").update(data).digest("hex");
4510
4539
  return `sha256:${hash2}`;
@@ -10367,7 +10396,7 @@ var __defProp2, __returnValue2 = (v2) => v2, __export2 = (target, all) => {
10367
10396
  Codec: ZodCodec,
10368
10397
  Boolean: ZodBoolean,
10369
10398
  String: ZodString
10370
- }, ...args), ZodIssueCode, ZodFirstPartyTypeKind, z2, RECOGNIZED_KEYS, exports_coerce, ResourceXError, RXDSchema, gunzipAsync, RegistryError, textType, jsonType, binaryType, skillType, prototypeType, builtinTypes, ResourceTypeError;
10399
+ }, ...args), ZodIssueCode, ZodFirstPartyTypeKind, z2, RECOGNIZED_KEYS, exports_coerce, ResourceXError, RXDSchema, gunzipAsync, NPM_PREFIX = "npm:", RegistryError, textType, jsonType, binaryType, skillType, prototypeType, builtinTypes, ResourceTypeError;
10371
10400
  var init_dist = __esm(() => {
10372
10401
  __defProp2 = Object.defineProperty;
10373
10402
  ZERO_BLOCK = new Uint8Array(BLOCK_SIZE);
@@ -14512,7 +14541,7 @@ import { mkdir as mkdir2, readdir as readdir22, readFile, rm, stat as stat22, un
14512
14541
  import { join as join22 } from "path";
14513
14542
  import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
14514
14543
  import { homedir } from "os";
14515
- import { dirname, join as join3 } from "path";
14544
+ import { dirname as dirname2, join as join3 } from "path";
14516
14545
 
14517
14546
  class FileSystemRXAStore {
14518
14547
  basePath;
@@ -14786,7 +14815,7 @@ class NodeProvider {
14786
14815
  }
14787
14816
  writeConfig(config2, data) {
14788
14817
  const configPath = this.configPath(config2);
14789
- mkdirSync(dirname(configPath), { recursive: true });
14818
+ mkdirSync(dirname2(configPath), { recursive: true });
14790
14819
  writeFileSync(configPath, JSON.stringify(data, null, 2));
14791
14820
  }
14792
14821
  getRegistries(config2) {
@@ -17507,4 +17536,4 @@ var main = defineCommand({
17507
17536
  });
17508
17537
  runMain(main);
17509
17538
 
17510
- //# debugId=E7512FDD8523B92864756E2164756E21
17539
+ //# debugId=0BEF2903254EFD9764756E2164756E21