@resourcexjs/cli 2.14.1 → 2.16.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 +95 -568
- package/dist/index.js.map +4 -4
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -1,6 +1,21 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
// @bun
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
3
5
|
var __defProp = Object.defineProperty;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __toESM = (mod, isNodeMode, target) => {
|
|
9
|
+
target = mod != null ? __create(__getProtoOf(mod)) : {};
|
|
10
|
+
const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
11
|
+
for (let key of __getOwnPropNames(mod))
|
|
12
|
+
if (!__hasOwnProp.call(to, key))
|
|
13
|
+
__defProp(to, key, {
|
|
14
|
+
get: () => mod[key],
|
|
15
|
+
enumerable: true
|
|
16
|
+
});
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
4
19
|
var __export = (target, all) => {
|
|
5
20
|
for (var name in all)
|
|
6
21
|
__defProp(target, name, {
|
|
@@ -774,374 +789,9 @@ import { promisify } from "util";
|
|
|
774
789
|
import { gzip } from "zlib";
|
|
775
790
|
import { promisify as promisify2 } from "util";
|
|
776
791
|
import { gunzip } from "zlib";
|
|
777
|
-
import { readdir, readFile, stat } from "fs/promises";
|
|
778
|
-
import { join, relative } from "path";
|
|
779
792
|
import { readdir as readdir2, readFile as readFile2, stat as stat2 } from "fs/promises";
|
|
780
793
|
import { join as join2, relative as relative2 } from "path";
|
|
781
794
|
import { createHash } from "crypto";
|
|
782
|
-
function writeString(view, offset, size, value) {
|
|
783
|
-
if (value)
|
|
784
|
-
encoder.encodeInto(value, view.subarray(offset, offset + size));
|
|
785
|
-
}
|
|
786
|
-
function writeOctal(view, offset, size, value) {
|
|
787
|
-
if (value === undefined)
|
|
788
|
-
return;
|
|
789
|
-
const octalString = value.toString(8).padStart(size - 1, "0");
|
|
790
|
-
encoder.encodeInto(octalString, view.subarray(offset, offset + size - 1));
|
|
791
|
-
}
|
|
792
|
-
async function normalizeBody(body) {
|
|
793
|
-
if (body === null || body === undefined)
|
|
794
|
-
return EMPTY;
|
|
795
|
-
if (body instanceof Uint8Array)
|
|
796
|
-
return body;
|
|
797
|
-
if (typeof body === "string")
|
|
798
|
-
return encoder.encode(body);
|
|
799
|
-
if (body instanceof ArrayBuffer)
|
|
800
|
-
return new Uint8Array(body);
|
|
801
|
-
if (body instanceof Blob)
|
|
802
|
-
return new Uint8Array(await body.arrayBuffer());
|
|
803
|
-
throw new TypeError("Unsupported content type for entry body.");
|
|
804
|
-
}
|
|
805
|
-
function writeChecksum(block) {
|
|
806
|
-
block.fill(CHECKSUM_SPACE, USTAR_CHECKSUM_OFFSET, USTAR_CHECKSUM_OFFSET + USTAR_CHECKSUM_SIZE);
|
|
807
|
-
let checksum = 0;
|
|
808
|
-
for (const byte of block)
|
|
809
|
-
checksum += byte;
|
|
810
|
-
for (let i2 = USTAR_CHECKSUM_OFFSET + 6 - 1;i2 >= USTAR_CHECKSUM_OFFSET; i2--) {
|
|
811
|
-
block[i2] = (checksum & 7) + ASCII_ZERO;
|
|
812
|
-
checksum >>= 3;
|
|
813
|
-
}
|
|
814
|
-
block[USTAR_CHECKSUM_OFFSET + 6] = 0;
|
|
815
|
-
block[USTAR_CHECKSUM_OFFSET + 7] = CHECKSUM_SPACE;
|
|
816
|
-
}
|
|
817
|
-
function generatePax(header) {
|
|
818
|
-
const paxRecords = {};
|
|
819
|
-
if (header.name.length > USTAR_NAME_SIZE) {
|
|
820
|
-
if (findUstarSplit(header.name) === null)
|
|
821
|
-
paxRecords.path = header.name;
|
|
822
|
-
}
|
|
823
|
-
if (header.linkname && header.linkname.length > USTAR_NAME_SIZE)
|
|
824
|
-
paxRecords.linkpath = header.linkname;
|
|
825
|
-
if (header.uname && header.uname.length > USTAR_UNAME_SIZE)
|
|
826
|
-
paxRecords.uname = header.uname;
|
|
827
|
-
if (header.gname && header.gname.length > USTAR_GNAME_SIZE)
|
|
828
|
-
paxRecords.gname = header.gname;
|
|
829
|
-
if (header.uid != null && header.uid > USTAR_MAX_UID_GID)
|
|
830
|
-
paxRecords.uid = String(header.uid);
|
|
831
|
-
if (header.gid != null && header.gid > USTAR_MAX_UID_GID)
|
|
832
|
-
paxRecords.gid = String(header.gid);
|
|
833
|
-
if (header.size != null && header.size > USTAR_MAX_SIZE)
|
|
834
|
-
paxRecords.size = String(header.size);
|
|
835
|
-
if (header.pax)
|
|
836
|
-
Object.assign(paxRecords, header.pax);
|
|
837
|
-
const paxEntries = Object.entries(paxRecords);
|
|
838
|
-
if (paxEntries.length === 0)
|
|
839
|
-
return null;
|
|
840
|
-
const paxBody = encoder.encode(paxEntries.map(([key, value]) => {
|
|
841
|
-
const record = `${key}=${value}
|
|
842
|
-
`;
|
|
843
|
-
const partLength = encoder.encode(record).length + 1;
|
|
844
|
-
let totalLength = partLength + String(partLength).length;
|
|
845
|
-
totalLength = partLength + String(totalLength).length;
|
|
846
|
-
return `${totalLength} ${record}`;
|
|
847
|
-
}).join(""));
|
|
848
|
-
return {
|
|
849
|
-
paxHeader: createTarHeader({
|
|
850
|
-
name: decoder.decode(encoder.encode(`PaxHeader/${header.name}`).slice(0, 100)),
|
|
851
|
-
size: paxBody.length,
|
|
852
|
-
type: "pax-header",
|
|
853
|
-
mode: 420,
|
|
854
|
-
mtime: header.mtime,
|
|
855
|
-
uname: header.uname,
|
|
856
|
-
gname: header.gname,
|
|
857
|
-
uid: header.uid,
|
|
858
|
-
gid: header.gid
|
|
859
|
-
}),
|
|
860
|
-
paxBody
|
|
861
|
-
};
|
|
862
|
-
}
|
|
863
|
-
function findUstarSplit(path) {
|
|
864
|
-
if (path.length <= USTAR_NAME_SIZE)
|
|
865
|
-
return null;
|
|
866
|
-
const minSlashIndex = path.length - USTAR_NAME_SIZE - 1;
|
|
867
|
-
const slashIndex = path.lastIndexOf("/", USTAR_PREFIX_SIZE);
|
|
868
|
-
if (slashIndex > 0 && slashIndex >= minSlashIndex)
|
|
869
|
-
return {
|
|
870
|
-
prefix: path.slice(0, slashIndex),
|
|
871
|
-
name: path.slice(slashIndex + 1)
|
|
872
|
-
};
|
|
873
|
-
return null;
|
|
874
|
-
}
|
|
875
|
-
function createTarHeader(header) {
|
|
876
|
-
const view = new Uint8Array(BLOCK_SIZE);
|
|
877
|
-
const size = isBodyless(header) ? 0 : header.size ?? 0;
|
|
878
|
-
let name = header.name;
|
|
879
|
-
let prefix = "";
|
|
880
|
-
if (!header.pax?.path) {
|
|
881
|
-
const split = findUstarSplit(name);
|
|
882
|
-
if (split) {
|
|
883
|
-
name = split.name;
|
|
884
|
-
prefix = split.prefix;
|
|
885
|
-
}
|
|
886
|
-
}
|
|
887
|
-
writeString(view, USTAR_NAME_OFFSET, USTAR_NAME_SIZE, name);
|
|
888
|
-
writeOctal(view, USTAR_MODE_OFFSET, USTAR_MODE_SIZE, header.mode ?? (header.type === DIRECTORY ? DEFAULT_DIR_MODE : DEFAULT_FILE_MODE));
|
|
889
|
-
writeOctal(view, USTAR_UID_OFFSET, USTAR_UID_SIZE, header.uid ?? 0);
|
|
890
|
-
writeOctal(view, USTAR_GID_OFFSET, USTAR_GID_SIZE, header.gid ?? 0);
|
|
891
|
-
writeOctal(view, USTAR_SIZE_OFFSET, USTAR_SIZE_SIZE, size);
|
|
892
|
-
writeOctal(view, USTAR_MTIME_OFFSET, USTAR_MTIME_SIZE, Math.floor((header.mtime?.getTime() ?? Date.now()) / 1000));
|
|
893
|
-
writeString(view, USTAR_TYPEFLAG_OFFSET, USTAR_TYPEFLAG_SIZE, TYPEFLAG[header.type ?? FILE]);
|
|
894
|
-
writeString(view, USTAR_LINKNAME_OFFSET, USTAR_LINKNAME_SIZE, header.linkname);
|
|
895
|
-
writeString(view, USTAR_MAGIC_OFFSET, USTAR_MAGIC_SIZE, "ustar\x00");
|
|
896
|
-
writeString(view, USTAR_VERSION_OFFSET, USTAR_VERSION_SIZE, USTAR_VERSION);
|
|
897
|
-
writeString(view, USTAR_UNAME_OFFSET, USTAR_UNAME_SIZE, header.uname);
|
|
898
|
-
writeString(view, USTAR_GNAME_OFFSET, USTAR_GNAME_SIZE, header.gname);
|
|
899
|
-
writeString(view, USTAR_PREFIX_OFFSET, USTAR_PREFIX_SIZE, prefix);
|
|
900
|
-
writeChecksum(view);
|
|
901
|
-
return view;
|
|
902
|
-
}
|
|
903
|
-
function getHeaderBlocks(header) {
|
|
904
|
-
const base = createTarHeader(header);
|
|
905
|
-
const pax = generatePax(header);
|
|
906
|
-
if (!pax)
|
|
907
|
-
return [base];
|
|
908
|
-
const paxPadding = -pax.paxBody.length & BLOCK_SIZE_MASK;
|
|
909
|
-
const paddingBlocks = paxPadding > 0 ? [ZERO_BLOCK.subarray(0, paxPadding)] : [];
|
|
910
|
-
return [
|
|
911
|
-
pax.paxHeader,
|
|
912
|
-
pax.paxBody,
|
|
913
|
-
...paddingBlocks,
|
|
914
|
-
base
|
|
915
|
-
];
|
|
916
|
-
}
|
|
917
|
-
function createTarPacker(onData, onError, onFinalize) {
|
|
918
|
-
let currentHeader = null;
|
|
919
|
-
let bytesWritten = 0;
|
|
920
|
-
let finalized = false;
|
|
921
|
-
return {
|
|
922
|
-
add(header) {
|
|
923
|
-
if (finalized) {
|
|
924
|
-
const error = /* @__PURE__ */ new Error("No new tar entries after finalize.");
|
|
925
|
-
onError(error);
|
|
926
|
-
throw error;
|
|
927
|
-
}
|
|
928
|
-
if (currentHeader !== null) {
|
|
929
|
-
const error = /* @__PURE__ */ new Error("Previous entry must be completed before adding a new one");
|
|
930
|
-
onError(error);
|
|
931
|
-
throw error;
|
|
932
|
-
}
|
|
933
|
-
try {
|
|
934
|
-
const size = isBodyless(header) ? 0 : header.size ?? 0;
|
|
935
|
-
const headerBlocks = getHeaderBlocks({
|
|
936
|
-
...header,
|
|
937
|
-
size
|
|
938
|
-
});
|
|
939
|
-
for (const block of headerBlocks)
|
|
940
|
-
onData(block);
|
|
941
|
-
currentHeader = {
|
|
942
|
-
...header,
|
|
943
|
-
size
|
|
944
|
-
};
|
|
945
|
-
bytesWritten = 0;
|
|
946
|
-
} catch (error) {
|
|
947
|
-
onError(error);
|
|
948
|
-
}
|
|
949
|
-
},
|
|
950
|
-
write(chunk) {
|
|
951
|
-
if (!currentHeader) {
|
|
952
|
-
const error = /* @__PURE__ */ new Error("No active tar entry.");
|
|
953
|
-
onError(error);
|
|
954
|
-
throw error;
|
|
955
|
-
}
|
|
956
|
-
if (finalized) {
|
|
957
|
-
const error = /* @__PURE__ */ new Error("Cannot write data after finalize.");
|
|
958
|
-
onError(error);
|
|
959
|
-
throw error;
|
|
960
|
-
}
|
|
961
|
-
const newTotal = bytesWritten + chunk.length;
|
|
962
|
-
if (newTotal > currentHeader.size) {
|
|
963
|
-
const error = /* @__PURE__ */ new Error(`"${currentHeader.name}" exceeds given size of ${currentHeader.size} bytes.`);
|
|
964
|
-
onError(error);
|
|
965
|
-
throw error;
|
|
966
|
-
}
|
|
967
|
-
try {
|
|
968
|
-
bytesWritten = newTotal;
|
|
969
|
-
onData(chunk);
|
|
970
|
-
} catch (error) {
|
|
971
|
-
onError(error);
|
|
972
|
-
}
|
|
973
|
-
},
|
|
974
|
-
endEntry() {
|
|
975
|
-
if (!currentHeader) {
|
|
976
|
-
const error = /* @__PURE__ */ new Error("No active entry to end.");
|
|
977
|
-
onError(error);
|
|
978
|
-
throw error;
|
|
979
|
-
}
|
|
980
|
-
if (finalized) {
|
|
981
|
-
const error = /* @__PURE__ */ new Error("Cannot end entry after finalize.");
|
|
982
|
-
onError(error);
|
|
983
|
-
throw error;
|
|
984
|
-
}
|
|
985
|
-
try {
|
|
986
|
-
if (bytesWritten !== currentHeader.size) {
|
|
987
|
-
const error = /* @__PURE__ */ new Error(`Size mismatch for "${currentHeader.name}".`);
|
|
988
|
-
onError(error);
|
|
989
|
-
throw error;
|
|
990
|
-
}
|
|
991
|
-
const paddingSize = -currentHeader.size & BLOCK_SIZE_MASK;
|
|
992
|
-
if (paddingSize > 0)
|
|
993
|
-
onData(new Uint8Array(paddingSize));
|
|
994
|
-
currentHeader = null;
|
|
995
|
-
bytesWritten = 0;
|
|
996
|
-
} catch (error) {
|
|
997
|
-
onError(error);
|
|
998
|
-
throw error;
|
|
999
|
-
}
|
|
1000
|
-
},
|
|
1001
|
-
finalize() {
|
|
1002
|
-
if (finalized) {
|
|
1003
|
-
const error = /* @__PURE__ */ new Error("Archive has already been finalized");
|
|
1004
|
-
onError(error);
|
|
1005
|
-
throw error;
|
|
1006
|
-
}
|
|
1007
|
-
if (currentHeader !== null) {
|
|
1008
|
-
const error = /* @__PURE__ */ new Error("Cannot finalize while an entry is still active");
|
|
1009
|
-
onError(error);
|
|
1010
|
-
throw error;
|
|
1011
|
-
}
|
|
1012
|
-
try {
|
|
1013
|
-
onData(EOF_BUFFER);
|
|
1014
|
-
finalized = true;
|
|
1015
|
-
if (onFinalize)
|
|
1016
|
-
onFinalize();
|
|
1017
|
-
} catch (error) {
|
|
1018
|
-
onError(error);
|
|
1019
|
-
}
|
|
1020
|
-
}
|
|
1021
|
-
};
|
|
1022
|
-
}
|
|
1023
|
-
function createTarPacker2() {
|
|
1024
|
-
let streamController;
|
|
1025
|
-
let packer;
|
|
1026
|
-
return {
|
|
1027
|
-
readable: new ReadableStream({ start(controller) {
|
|
1028
|
-
streamController = controller;
|
|
1029
|
-
packer = createTarPacker(controller.enqueue.bind(controller), controller.error.bind(controller), controller.close.bind(controller));
|
|
1030
|
-
} }),
|
|
1031
|
-
controller: {
|
|
1032
|
-
add(header) {
|
|
1033
|
-
const bodyless = isBodyless(header);
|
|
1034
|
-
const h2 = { ...header };
|
|
1035
|
-
if (bodyless)
|
|
1036
|
-
h2.size = 0;
|
|
1037
|
-
packer.add(h2);
|
|
1038
|
-
if (bodyless)
|
|
1039
|
-
packer.endEntry();
|
|
1040
|
-
return new WritableStream({
|
|
1041
|
-
write(chunk) {
|
|
1042
|
-
packer.write(chunk);
|
|
1043
|
-
},
|
|
1044
|
-
close() {
|
|
1045
|
-
if (!bodyless)
|
|
1046
|
-
packer.endEntry();
|
|
1047
|
-
},
|
|
1048
|
-
abort(reason) {
|
|
1049
|
-
streamController.error(reason);
|
|
1050
|
-
}
|
|
1051
|
-
});
|
|
1052
|
-
},
|
|
1053
|
-
finalize() {
|
|
1054
|
-
packer.finalize();
|
|
1055
|
-
},
|
|
1056
|
-
error(err) {
|
|
1057
|
-
streamController.error(err);
|
|
1058
|
-
}
|
|
1059
|
-
}
|
|
1060
|
-
};
|
|
1061
|
-
}
|
|
1062
|
-
async function streamToBuffer(stream) {
|
|
1063
|
-
const chunks = [];
|
|
1064
|
-
const reader = stream.getReader();
|
|
1065
|
-
let totalLength = 0;
|
|
1066
|
-
try {
|
|
1067
|
-
while (true) {
|
|
1068
|
-
const { done, value } = await reader.read();
|
|
1069
|
-
if (done)
|
|
1070
|
-
break;
|
|
1071
|
-
chunks.push(value);
|
|
1072
|
-
totalLength += value.length;
|
|
1073
|
-
}
|
|
1074
|
-
const result = new Uint8Array(totalLength);
|
|
1075
|
-
let offset = 0;
|
|
1076
|
-
for (const chunk of chunks) {
|
|
1077
|
-
result.set(chunk, offset);
|
|
1078
|
-
offset += chunk.length;
|
|
1079
|
-
}
|
|
1080
|
-
return result;
|
|
1081
|
-
} finally {
|
|
1082
|
-
reader.releaseLock();
|
|
1083
|
-
}
|
|
1084
|
-
}
|
|
1085
|
-
async function packTar(entries) {
|
|
1086
|
-
const { readable, controller } = createTarPacker2();
|
|
1087
|
-
await (async () => {
|
|
1088
|
-
for (const entry of entries) {
|
|
1089
|
-
const entryStream = controller.add(entry.header);
|
|
1090
|
-
const body = "body" in entry ? entry.body : entry.data;
|
|
1091
|
-
if (!body) {
|
|
1092
|
-
await entryStream.close();
|
|
1093
|
-
continue;
|
|
1094
|
-
}
|
|
1095
|
-
if (body instanceof ReadableStream)
|
|
1096
|
-
await body.pipeTo(entryStream);
|
|
1097
|
-
else if (body instanceof Blob)
|
|
1098
|
-
await body.stream().pipeTo(entryStream);
|
|
1099
|
-
else
|
|
1100
|
-
try {
|
|
1101
|
-
const chunk = await normalizeBody(body);
|
|
1102
|
-
if (chunk.length > 0) {
|
|
1103
|
-
const writer = entryStream.getWriter();
|
|
1104
|
-
await writer.write(chunk);
|
|
1105
|
-
await writer.close();
|
|
1106
|
-
} else
|
|
1107
|
-
await entryStream.close();
|
|
1108
|
-
} catch {
|
|
1109
|
-
throw new TypeError(`Unsupported content type for entry "${entry.header.name}".`);
|
|
1110
|
-
}
|
|
1111
|
-
}
|
|
1112
|
-
})().then(() => controller.finalize()).catch((err) => controller.error(err));
|
|
1113
|
-
return new Uint8Array(await streamToBuffer(readable));
|
|
1114
|
-
}
|
|
1115
|
-
|
|
1116
|
-
class RXAImpl {
|
|
1117
|
-
_buffer;
|
|
1118
|
-
constructor(buffer) {
|
|
1119
|
-
this._buffer = buffer;
|
|
1120
|
-
}
|
|
1121
|
-
get stream() {
|
|
1122
|
-
const buffer = this._buffer;
|
|
1123
|
-
return new ReadableStream({
|
|
1124
|
-
start(controller) {
|
|
1125
|
-
controller.enqueue(new Uint8Array(buffer));
|
|
1126
|
-
controller.close();
|
|
1127
|
-
}
|
|
1128
|
-
});
|
|
1129
|
-
}
|
|
1130
|
-
async buffer() {
|
|
1131
|
-
return this._buffer;
|
|
1132
|
-
}
|
|
1133
|
-
}
|
|
1134
|
-
async function archive(files) {
|
|
1135
|
-
const entries = Object.entries(files).map(([name, content]) => {
|
|
1136
|
-
return {
|
|
1137
|
-
header: { name, size: content.length, type: "file" },
|
|
1138
|
-
body: new Uint8Array(content)
|
|
1139
|
-
};
|
|
1140
|
-
});
|
|
1141
|
-
const tarBuffer = await packTar(entries);
|
|
1142
|
-
const gzipBuffer = await gzipAsync(Buffer.from(tarBuffer));
|
|
1143
|
-
return new RXAImpl(gzipBuffer);
|
|
1144
|
-
}
|
|
1145
795
|
function $constructor(name, initializer, params) {
|
|
1146
796
|
function init2(inst, def) {
|
|
1147
797
|
if (!inst._zod) {
|
|
@@ -4829,121 +4479,6 @@ function bigint3(params) {
|
|
|
4829
4479
|
function date4(params) {
|
|
4830
4480
|
return _coercedDate(ZodDate, params);
|
|
4831
4481
|
}
|
|
4832
|
-
function define(input) {
|
|
4833
|
-
if (input === null || typeof input !== "object") {
|
|
4834
|
-
throw new DefinitionError("definition must be an object");
|
|
4835
|
-
}
|
|
4836
|
-
let validated;
|
|
4837
|
-
try {
|
|
4838
|
-
validated = RXDSchema.parse(input);
|
|
4839
|
-
} catch (e2) {
|
|
4840
|
-
throw new DefinitionError(`Invalid definition: ${e2 instanceof Error ? e2.message : String(e2)}`);
|
|
4841
|
-
}
|
|
4842
|
-
const rxd = Object.assign(Object.create(null), {
|
|
4843
|
-
name: validated.name,
|
|
4844
|
-
type: validated.type,
|
|
4845
|
-
tag: validated.tag ?? validated.version ?? undefined,
|
|
4846
|
-
registry: validated.registry,
|
|
4847
|
-
path: validated.path,
|
|
4848
|
-
description: validated.description,
|
|
4849
|
-
author: validated.author,
|
|
4850
|
-
license: validated.license,
|
|
4851
|
-
keywords: validated.keywords,
|
|
4852
|
-
repository: validated.repository
|
|
4853
|
-
});
|
|
4854
|
-
return rxd;
|
|
4855
|
-
}
|
|
4856
|
-
function locate(rxm) {
|
|
4857
|
-
return {
|
|
4858
|
-
registry: rxm.definition.registry,
|
|
4859
|
-
path: rxm.definition.path,
|
|
4860
|
-
name: rxm.definition.name,
|
|
4861
|
-
tag: rxm.definition.tag
|
|
4862
|
-
};
|
|
4863
|
-
}
|
|
4864
|
-
function manifest(rxd) {
|
|
4865
|
-
return {
|
|
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: {}
|
|
4880
|
-
};
|
|
4881
|
-
}
|
|
4882
|
-
function resource(rxm, rxa) {
|
|
4883
|
-
const rxi = locate(rxm);
|
|
4884
|
-
return {
|
|
4885
|
-
identifier: rxi,
|
|
4886
|
-
manifest: rxm,
|
|
4887
|
-
archive: rxa
|
|
4888
|
-
};
|
|
4889
|
-
}
|
|
4890
|
-
|
|
4891
|
-
class FolderLoader {
|
|
4892
|
-
async canLoad(source) {
|
|
4893
|
-
try {
|
|
4894
|
-
const stats = await stat(source);
|
|
4895
|
-
if (!stats.isDirectory()) {
|
|
4896
|
-
return false;
|
|
4897
|
-
}
|
|
4898
|
-
const manifestPath = join(source, "resource.json");
|
|
4899
|
-
const manifestStats = await stat(manifestPath);
|
|
4900
|
-
return manifestStats.isFile();
|
|
4901
|
-
} catch {
|
|
4902
|
-
return false;
|
|
4903
|
-
}
|
|
4904
|
-
}
|
|
4905
|
-
async load(folderPath) {
|
|
4906
|
-
const resourceJsonPath = join(folderPath, "resource.json");
|
|
4907
|
-
let resourceJson;
|
|
4908
|
-
try {
|
|
4909
|
-
resourceJson = await readFile(resourceJsonPath, "utf-8");
|
|
4910
|
-
} catch (error48) {
|
|
4911
|
-
throw new ResourceXError(`Failed to read resource.json: ${error48 instanceof Error ? error48.message : String(error48)}`);
|
|
4912
|
-
}
|
|
4913
|
-
let json2;
|
|
4914
|
-
try {
|
|
4915
|
-
json2 = JSON.parse(resourceJson);
|
|
4916
|
-
} catch (error48) {
|
|
4917
|
-
throw new ResourceXError(`Invalid JSON in resource.json: ${error48 instanceof Error ? error48.message : String(error48)}`);
|
|
4918
|
-
}
|
|
4919
|
-
const rxd = define(json2);
|
|
4920
|
-
const files = await this.readFolderFiles(folderPath);
|
|
4921
|
-
if (Object.keys(files).length === 0) {
|
|
4922
|
-
throw new ResourceXError("No content files found in resource folder");
|
|
4923
|
-
}
|
|
4924
|
-
const rxm = manifest(rxd);
|
|
4925
|
-
const rxa = await archive(files);
|
|
4926
|
-
return resource(rxm, rxa);
|
|
4927
|
-
}
|
|
4928
|
-
async readFolderFiles(folderPath, basePath = folderPath) {
|
|
4929
|
-
const files = {};
|
|
4930
|
-
const entries = await readdir(folderPath, { withFileTypes: true });
|
|
4931
|
-
for (const entry of entries) {
|
|
4932
|
-
const fullPath = join(folderPath, entry.name);
|
|
4933
|
-
const relativePath = relative(basePath, fullPath);
|
|
4934
|
-
if (relativePath === "resource.json") {
|
|
4935
|
-
continue;
|
|
4936
|
-
}
|
|
4937
|
-
if (entry.isFile()) {
|
|
4938
|
-
files[relativePath] = await readFile(fullPath);
|
|
4939
|
-
} else if (entry.isDirectory()) {
|
|
4940
|
-
const subFiles = await this.readFolderFiles(fullPath, basePath);
|
|
4941
|
-
Object.assign(files, subFiles);
|
|
4942
|
-
}
|
|
4943
|
-
}
|
|
4944
|
-
return files;
|
|
4945
|
-
}
|
|
4946
|
-
}
|
|
4947
4482
|
|
|
4948
4483
|
class FolderSourceLoader {
|
|
4949
4484
|
async canLoad(source) {
|
|
@@ -4962,31 +4497,6 @@ class FolderSourceLoader {
|
|
|
4962
4497
|
const files = await this.readFolderFiles(source);
|
|
4963
4498
|
return { source, files };
|
|
4964
4499
|
}
|
|
4965
|
-
async isFresh(source, cachedAt) {
|
|
4966
|
-
try {
|
|
4967
|
-
const maxMtime = await this.getMaxMtime(source);
|
|
4968
|
-
return maxMtime <= cachedAt;
|
|
4969
|
-
} catch {
|
|
4970
|
-
return false;
|
|
4971
|
-
}
|
|
4972
|
-
}
|
|
4973
|
-
async getMaxMtime(folderPath) {
|
|
4974
|
-
let max = new Date(0);
|
|
4975
|
-
const entries = await readdir2(folderPath, { withFileTypes: true });
|
|
4976
|
-
for (const entry of entries) {
|
|
4977
|
-
const fullPath = join2(folderPath, entry.name);
|
|
4978
|
-
if (entry.isFile()) {
|
|
4979
|
-
const stats = await stat2(fullPath);
|
|
4980
|
-
if (stats.mtime > max)
|
|
4981
|
-
max = stats.mtime;
|
|
4982
|
-
} else if (entry.isDirectory()) {
|
|
4983
|
-
const subMax = await this.getMaxMtime(fullPath);
|
|
4984
|
-
if (subMax > max)
|
|
4985
|
-
max = subMax;
|
|
4986
|
-
}
|
|
4987
|
-
}
|
|
4988
|
-
return max;
|
|
4989
|
-
}
|
|
4990
4500
|
async readFolderFiles(folderPath, basePath = folderPath) {
|
|
4991
4501
|
const files = {};
|
|
4992
4502
|
const entries = await readdir2(folderPath, { withFileTypes: true });
|
|
@@ -5187,7 +4697,7 @@ var __defProp2, __export2 = (target, all) => {
|
|
|
5187
4697
|
configurable: true,
|
|
5188
4698
|
set: (newValue) => all[name] = () => newValue
|
|
5189
4699
|
});
|
|
5190
|
-
}, BLOCK_SIZE = 512,
|
|
4700
|
+
}, BLOCK_SIZE = 512, ZERO_BLOCK, EMPTY, encoder, decoder, EOF_BUFFER, gzipAsync, exports_external, exports_core2, NEVER, $brand, $ZodAsyncError, $ZodEncodeError, globalConfig, exports_util, EVALUATING, captureStackTrace, allowsEval, getParsedType = (data) => {
|
|
5191
4701
|
const t2 = typeof data;
|
|
5192
4702
|
switch (t2) {
|
|
5193
4703
|
case "undefined":
|
|
@@ -10865,22 +10375,9 @@ var __defProp2, __export2 = (target, all) => {
|
|
|
10865
10375
|
Codec: ZodCodec,
|
|
10866
10376
|
Boolean: ZodBoolean,
|
|
10867
10377
|
String: ZodString
|
|
10868
|
-
}, ...args), ZodIssueCode, ZodFirstPartyTypeKind, z2, RECOGNIZED_KEYS, exports_coerce, ResourceXError,
|
|
10378
|
+
}, ...args), ZodIssueCode, ZodFirstPartyTypeKind, z2, RECOGNIZED_KEYS, exports_coerce, ResourceXError, RXDSchema, gunzipAsync, RegistryError, textType, jsonType, binaryType, skillType, prototypeType, builtinTypes, ResourceTypeError;
|
|
10869
10379
|
var init_dist = __esm(() => {
|
|
10870
10380
|
__defProp2 = Object.defineProperty;
|
|
10871
|
-
TYPEFLAG = {
|
|
10872
|
-
file: "0",
|
|
10873
|
-
link: "1",
|
|
10874
|
-
symlink: "2",
|
|
10875
|
-
"character-device": "3",
|
|
10876
|
-
"block-device": "4",
|
|
10877
|
-
directory: "5",
|
|
10878
|
-
fifo: "6",
|
|
10879
|
-
"pax-header": "x",
|
|
10880
|
-
"pax-global-header": "g",
|
|
10881
|
-
"gnu-long-name": "L",
|
|
10882
|
-
"gnu-long-link-name": "K"
|
|
10883
|
-
};
|
|
10884
10381
|
ZERO_BLOCK = new Uint8Array(BLOCK_SIZE);
|
|
10885
10382
|
EMPTY = new Uint8Array(0);
|
|
10886
10383
|
encoder = new TextEncoder;
|
|
@@ -14854,17 +14351,10 @@ var init_dist = __esm(() => {
|
|
|
14854
14351
|
this.name = "ResourceXError";
|
|
14855
14352
|
}
|
|
14856
14353
|
};
|
|
14857
|
-
DefinitionError = class DefinitionError extends ResourceXError {
|
|
14858
|
-
constructor(message) {
|
|
14859
|
-
super(message);
|
|
14860
|
-
this.name = "DefinitionError";
|
|
14861
|
-
}
|
|
14862
|
-
};
|
|
14863
14354
|
RXDSchema = exports_external.object({
|
|
14864
14355
|
name: exports_external.string().min(1).max(128),
|
|
14865
14356
|
type: exports_external.string().min(1).max(64),
|
|
14866
14357
|
tag: exports_external.string().max(64).optional(),
|
|
14867
|
-
version: exports_external.string().max(64).optional(),
|
|
14868
14358
|
registry: exports_external.string().max(256).optional(),
|
|
14869
14359
|
path: exports_external.string().max(256).optional(),
|
|
14870
14360
|
description: exports_external.string().max(1024).optional(),
|
|
@@ -14966,7 +14456,47 @@ var skill_type_default = {
|
|
|
14966
14456
|
}
|
|
14967
14457
|
}
|
|
14968
14458
|
};
|
|
14969
|
-
|
|
14459
|
+
prototypeType = {
|
|
14460
|
+
name: "prototype",
|
|
14461
|
+
description: "Instruction set for materializing roles and organizations",
|
|
14462
|
+
code: `// @resolver: prototype_type_default
|
|
14463
|
+
var prototype_type_default = {
|
|
14464
|
+
async resolve(ctx) {
|
|
14465
|
+
var protoFile = ctx.files["prototype.json"];
|
|
14466
|
+
if (!protoFile) throw new Error("Prototype resource must contain a prototype.json file");
|
|
14467
|
+
var decoder = new TextDecoder();
|
|
14468
|
+
var instructions = JSON.parse(decoder.decode(protoFile));
|
|
14469
|
+
if (!Array.isArray(instructions)) {
|
|
14470
|
+
throw new Error("prototype.json must be a JSON array of instructions");
|
|
14471
|
+
}
|
|
14472
|
+
var resolved = instructions.map(function(instr) {
|
|
14473
|
+
var resolvedArgs = {};
|
|
14474
|
+
var keys = Object.keys(instr.args || {});
|
|
14475
|
+
for (var i = 0; i < keys.length; i++) {
|
|
14476
|
+
var key = keys[i];
|
|
14477
|
+
var value = instr.args[key];
|
|
14478
|
+
if (typeof value === "string" && value.startsWith("@")) {
|
|
14479
|
+
var filename = value.slice(1);
|
|
14480
|
+
var file = ctx.files[filename];
|
|
14481
|
+
if (!file) throw new Error("Referenced file not found: " + filename);
|
|
14482
|
+
resolvedArgs[key] = decoder.decode(file);
|
|
14483
|
+
} else {
|
|
14484
|
+
resolvedArgs[key] = value;
|
|
14485
|
+
}
|
|
14486
|
+
}
|
|
14487
|
+
return { op: instr.op, args: resolvedArgs };
|
|
14488
|
+
});
|
|
14489
|
+
return { id: ctx.manifest.name, instructions: resolved };
|
|
14490
|
+
}
|
|
14491
|
+
};`
|
|
14492
|
+
};
|
|
14493
|
+
builtinTypes = [
|
|
14494
|
+
textType,
|
|
14495
|
+
jsonType,
|
|
14496
|
+
binaryType,
|
|
14497
|
+
skillType,
|
|
14498
|
+
prototypeType
|
|
14499
|
+
];
|
|
14970
14500
|
ResourceTypeError = class ResourceTypeError extends ResourceXError {
|
|
14971
14501
|
constructor(message) {
|
|
14972
14502
|
super(message);
|
|
@@ -14984,13 +14514,13 @@ __export(exports_dist, {
|
|
|
14984
14514
|
});
|
|
14985
14515
|
import { createHash as createHash2 } from "crypto";
|
|
14986
14516
|
import { createReadStream } from "fs";
|
|
14987
|
-
import { mkdir, readdir
|
|
14988
|
-
import { join
|
|
14989
|
-
import { mkdir as mkdir2, readdir as readdir22, readFile
|
|
14517
|
+
import { mkdir, readdir, stat, unlink, writeFile } from "fs/promises";
|
|
14518
|
+
import { join } from "path";
|
|
14519
|
+
import { mkdir as mkdir2, readdir as readdir22, readFile, rm, stat as stat22, unlink as unlink2, writeFile as writeFile2 } from "fs/promises";
|
|
14990
14520
|
import { join as join22 } from "path";
|
|
14991
14521
|
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
|
|
14992
14522
|
import { homedir } from "os";
|
|
14993
|
-
import { dirname, join as
|
|
14523
|
+
import { dirname, join as join3 } from "path";
|
|
14994
14524
|
|
|
14995
14525
|
class FileSystemRXAStore {
|
|
14996
14526
|
basePath;
|
|
@@ -14999,7 +14529,7 @@ class FileSystemRXAStore {
|
|
|
14999
14529
|
}
|
|
15000
14530
|
getPath(digest) {
|
|
15001
14531
|
const prefix = digest.substring(7, 9);
|
|
15002
|
-
return
|
|
14532
|
+
return join(this.basePath, prefix, digest);
|
|
15003
14533
|
}
|
|
15004
14534
|
async get(digest) {
|
|
15005
14535
|
if (!isValidDigest(digest)) {
|
|
@@ -15031,7 +14561,7 @@ class FileSystemRXAStore {
|
|
|
15031
14561
|
if (await this.has(digest)) {
|
|
15032
14562
|
return digest;
|
|
15033
14563
|
}
|
|
15034
|
-
const dir =
|
|
14564
|
+
const dir = join(path, "..");
|
|
15035
14565
|
await mkdir(dir, { recursive: true });
|
|
15036
14566
|
await writeFile(path, data);
|
|
15037
14567
|
return digest;
|
|
@@ -15039,7 +14569,7 @@ class FileSystemRXAStore {
|
|
|
15039
14569
|
async has(digest) {
|
|
15040
14570
|
const path = this.getPath(digest);
|
|
15041
14571
|
try {
|
|
15042
|
-
await
|
|
14572
|
+
await stat(path);
|
|
15043
14573
|
return true;
|
|
15044
14574
|
} catch {
|
|
15045
14575
|
return false;
|
|
@@ -15054,11 +14584,11 @@ class FileSystemRXAStore {
|
|
|
15054
14584
|
async list() {
|
|
15055
14585
|
const digests = [];
|
|
15056
14586
|
try {
|
|
15057
|
-
const prefixes = await
|
|
14587
|
+
const prefixes = await readdir(this.basePath);
|
|
15058
14588
|
for (const prefix of prefixes) {
|
|
15059
|
-
const prefixPath =
|
|
14589
|
+
const prefixPath = join(this.basePath, prefix);
|
|
15060
14590
|
try {
|
|
15061
|
-
const files = await
|
|
14591
|
+
const files = await readdir(prefixPath);
|
|
15062
14592
|
for (const file2 of files) {
|
|
15063
14593
|
if (file2.startsWith("sha256:")) {
|
|
15064
14594
|
digests.push(file2);
|
|
@@ -15086,17 +14616,17 @@ class FileSystemRXMStore {
|
|
|
15086
14616
|
async get(name, tag, registry2) {
|
|
15087
14617
|
const path = this.getPath(name, tag, registry2);
|
|
15088
14618
|
try {
|
|
15089
|
-
const data = await
|
|
14619
|
+
const data = await readFile(path, "utf-8");
|
|
15090
14620
|
return JSON.parse(data);
|
|
15091
14621
|
} catch {
|
|
15092
14622
|
return null;
|
|
15093
14623
|
}
|
|
15094
14624
|
}
|
|
15095
|
-
async put(
|
|
15096
|
-
const path = this.getPath(
|
|
14625
|
+
async put(manifest) {
|
|
14626
|
+
const path = this.getPath(manifest.name, manifest.tag, manifest.registry);
|
|
15097
14627
|
const dir = join22(path, "..");
|
|
15098
14628
|
await mkdir2(dir, { recursive: true });
|
|
15099
|
-
await writeFile2(path, JSON.stringify(
|
|
14629
|
+
await writeFile2(path, JSON.stringify(manifest, null, 2), "utf-8");
|
|
15100
14630
|
}
|
|
15101
14631
|
async has(name, tag, registry2) {
|
|
15102
14632
|
const path = this.getPath(name, tag, registry2);
|
|
@@ -15134,7 +14664,7 @@ class FileSystemRXMStore {
|
|
|
15134
14664
|
async getLatest(name, registry2) {
|
|
15135
14665
|
const dir = this.getDir(name, registry2);
|
|
15136
14666
|
try {
|
|
15137
|
-
return (await
|
|
14667
|
+
return (await readFile(join22(dir, LATEST_FILE), "utf-8")).trim();
|
|
15138
14668
|
} catch {
|
|
15139
14669
|
return null;
|
|
15140
14670
|
}
|
|
@@ -15188,9 +14718,9 @@ class FileSystemRXMStore {
|
|
|
15188
14718
|
for (const file2 of files) {
|
|
15189
14719
|
if (file2.endsWith(".json")) {
|
|
15190
14720
|
const filePath = join22(namePath, file2);
|
|
15191
|
-
const data = await
|
|
15192
|
-
const
|
|
15193
|
-
results.push(
|
|
14721
|
+
const data = await readFile(filePath, "utf-8");
|
|
14722
|
+
const manifest = JSON.parse(data);
|
|
14723
|
+
results.push(manifest);
|
|
15194
14724
|
}
|
|
15195
14725
|
}
|
|
15196
14726
|
} catch {}
|
|
@@ -15216,13 +14746,10 @@ class NodeProvider {
|
|
|
15216
14746
|
createStores(config2) {
|
|
15217
14747
|
const basePath = config2.path ?? DEFAULT_BASE_PATH;
|
|
15218
14748
|
return {
|
|
15219
|
-
rxaStore: new FileSystemRXAStore(
|
|
15220
|
-
rxmStore: new FileSystemRXMStore(
|
|
14749
|
+
rxaStore: new FileSystemRXAStore(join3(basePath, "blobs")),
|
|
14750
|
+
rxmStore: new FileSystemRXMStore(join3(basePath, "manifests"))
|
|
15221
14751
|
};
|
|
15222
14752
|
}
|
|
15223
|
-
createLoader(_config) {
|
|
15224
|
-
return new FolderLoader;
|
|
15225
|
-
}
|
|
15226
14753
|
createSourceLoader(_config) {
|
|
15227
14754
|
return new FolderSourceLoader;
|
|
15228
14755
|
}
|
|
@@ -15232,7 +14759,7 @@ class NodeProvider {
|
|
|
15232
14759
|
return { registry: envRegistry };
|
|
15233
14760
|
}
|
|
15234
14761
|
const basePath = config2.path ?? DEFAULT_BASE_PATH;
|
|
15235
|
-
const configPath =
|
|
14762
|
+
const configPath = join3(basePath, "config.json");
|
|
15236
14763
|
try {
|
|
15237
14764
|
if (existsSync(configPath)) {
|
|
15238
14765
|
const raw = JSON.parse(readFileSync(configPath, "utf-8"));
|
|
@@ -15249,7 +14776,7 @@ class NodeProvider {
|
|
|
15249
14776
|
}
|
|
15250
14777
|
configPath(config2) {
|
|
15251
14778
|
const basePath = config2.path ?? DEFAULT_BASE_PATH;
|
|
15252
|
-
return
|
|
14779
|
+
return join3(basePath, "config.json");
|
|
15253
14780
|
}
|
|
15254
14781
|
readConfig(config2) {
|
|
15255
14782
|
const configPath = this.configPath(config2);
|
|
@@ -17252,14 +16779,14 @@ import { createResourceX, setProvider } from "resourcexjs";
|
|
|
17252
16779
|
|
|
17253
16780
|
// src/lib/paths.ts
|
|
17254
16781
|
import { homedir as homedir2 } from "os";
|
|
17255
|
-
import { join as
|
|
17256
|
-
var RX_HOME = process.env.RESOURCEX_HOME || process.env.RX_HOME ||
|
|
16782
|
+
import { join as join4 } from "path";
|
|
16783
|
+
var RX_HOME = process.env.RESOURCEX_HOME || process.env.RX_HOME || join4(homedir2(), ".deepractice", "resourcex");
|
|
17257
16784
|
var PATHS = {
|
|
17258
16785
|
root: RX_HOME,
|
|
17259
|
-
config:
|
|
17260
|
-
local:
|
|
17261
|
-
cache:
|
|
17262
|
-
linked:
|
|
16786
|
+
config: join4(RX_HOME, "config.json"),
|
|
16787
|
+
local: join4(RX_HOME, "local"),
|
|
16788
|
+
cache: join4(RX_HOME, "cache"),
|
|
16789
|
+
linked: join4(RX_HOME, "linked")
|
|
17263
16790
|
};
|
|
17264
16791
|
|
|
17265
16792
|
// src/lib/config.ts
|
|
@@ -17389,13 +16916,13 @@ var add = defineCommand({
|
|
|
17389
16916
|
async run({ args }) {
|
|
17390
16917
|
try {
|
|
17391
16918
|
const rx = await getClient();
|
|
17392
|
-
const
|
|
16919
|
+
const resource = await rx.add(args.path);
|
|
17393
16920
|
consola.success(`Added resource:
|
|
17394
16921
|
`);
|
|
17395
|
-
console.log(` Locator: ${
|
|
17396
|
-
console.log(` Name: ${
|
|
17397
|
-
console.log(` Type: ${
|
|
17398
|
-
console.log(` Tag: ${
|
|
16922
|
+
console.log(` Locator: ${resource.locator}`);
|
|
16923
|
+
console.log(` Name: ${resource.definition.name}`);
|
|
16924
|
+
console.log(` Type: ${resource.definition.type}`);
|
|
16925
|
+
console.log(` Tag: ${resource.definition.tag}`);
|
|
17399
16926
|
} catch (error48) {
|
|
17400
16927
|
consola.error(error48 instanceof Error ? error48.message : "Failed to add resource");
|
|
17401
16928
|
process.exit(1);
|
|
@@ -17509,13 +17036,13 @@ var info = defineCommand({
|
|
|
17509
17036
|
async run({ args }) {
|
|
17510
17037
|
try {
|
|
17511
17038
|
const rx = await getClient();
|
|
17512
|
-
const
|
|
17513
|
-
const { definition, source } =
|
|
17039
|
+
const resource = await rx.info(args.locator);
|
|
17040
|
+
const { definition, source } = resource;
|
|
17514
17041
|
console.log();
|
|
17515
17042
|
console.log(` ${definition.name}:${definition.tag}`);
|
|
17516
17043
|
console.log(` ${"\u2500".repeat(40)}`);
|
|
17517
17044
|
console.log();
|
|
17518
|
-
console.log(` Locator: ${
|
|
17045
|
+
console.log(` Locator: ${resource.locator}`);
|
|
17519
17046
|
if (definition.registry) {
|
|
17520
17047
|
console.log(` Registry: ${definition.registry}`);
|
|
17521
17048
|
}
|
|
@@ -17988,4 +17515,4 @@ var main = defineCommand({
|
|
|
17988
17515
|
});
|
|
17989
17516
|
runMain(main);
|
|
17990
17517
|
|
|
17991
|
-
//# debugId=
|
|
17518
|
+
//# debugId=AA7C8D804CBA334B64756E2164756E21
|