@struktoai/mirage-node 0.0.2 → 0.0.3
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/README.md +1 -1
- package/dist/{aliyun-TMZRUYCG.js → aliyun-JMJ3PFYY.js} +3 -3
- package/dist/{backblaze-OHW57DLK.js → backblaze-TDFD23QO.js} +3 -3
- package/dist/{box-UXTCAFOZ.js → box-GQ2U2R6R.js} +2 -2
- package/dist/{ceph-TNN4I2FT.js → ceph-S2VOYO6G.js} +3 -3
- package/dist/{chunk-FXFDBF3P.js → chunk-3WIO7NBR.js} +2 -2
- package/dist/{chunk-O7ODGJYL.js → chunk-47AVIIOT.js} +2 -2
- package/dist/{chunk-Q6CDMOM6.js → chunk-7CW3BMPH.js} +2 -2
- package/dist/{chunk-E7RW3SBV.js → chunk-A7IVFIOP.js} +2 -2
- package/dist/chunk-A7IVFIOP.js.map +1 -0
- package/dist/{chunk-3T3RMDNX.js → chunk-AUHSTJJ3.js} +2 -2
- package/dist/{chunk-PJBQKMCD.js → chunk-DM4GSE26.js} +2 -2
- package/dist/{chunk-5DLOHQJ2.js → chunk-EM4J5EQS.js} +2 -2
- package/dist/chunk-EM4J5EQS.js.map +1 -0
- package/dist/{chunk-ABTEGAFB.js → chunk-EZQ5HBAC.js} +2 -2
- package/dist/chunk-EZQ5HBAC.js.map +1 -0
- package/dist/{chunk-KTNDT45N.js → chunk-FQ33BYFR.js} +2 -2
- package/dist/{chunk-YAVGCQUP.js → chunk-G2WCEUQL.js} +2 -2
- package/dist/chunk-G2WCEUQL.js.map +1 -0
- package/dist/{chunk-RLGWMJD3.js → chunk-GCFYZSVR.js} +133 -3
- package/dist/chunk-GCFYZSVR.js.map +1 -0
- package/dist/{chunk-NHS7WLEQ.js → chunk-GS5AUKUO.js} +2 -2
- package/dist/chunk-GS5AUKUO.js.map +1 -0
- package/dist/{chunk-BYTU2YC3.js → chunk-HGCRXJGP.js} +2 -2
- package/dist/{chunk-G5BZE7UA.js → chunk-HJJMP6IX.js} +2 -2
- package/dist/{chunk-IQVNVTOP.js → chunk-I5THIMPP.js} +2 -2
- package/dist/chunk-IDYHQQOH.js +1095 -0
- package/dist/chunk-IDYHQQOH.js.map +1 -0
- package/dist/{chunk-C6NHFMIP.js → chunk-IK2L4EN3.js} +2 -2
- package/dist/{chunk-LYDMMNL2.js → chunk-JAGJTM3Q.js} +2 -2
- package/dist/chunk-JAGJTM3Q.js.map +1 -0
- package/dist/{chunk-A7X4L4JM.js → chunk-JCC4CU2I.js} +2 -2
- package/dist/chunk-JCC4CU2I.js.map +1 -0
- package/dist/{chunk-AJICZLHT.js → chunk-KPULTUOK.js} +2 -2
- package/dist/{chunk-YPT4JBUY.js → chunk-LV2G7VHL.js} +2 -2
- package/dist/chunk-LV2G7VHL.js.map +1 -0
- package/dist/{chunk-C6NHEDHY.js → chunk-M5FVUIYP.js} +2 -2
- package/dist/chunk-M5FVUIYP.js.map +1 -0
- package/dist/{chunk-HEHERHQ5.js → chunk-MPCCRRE6.js} +2 -2
- package/dist/chunk-MPCCRRE6.js.map +1 -0
- package/dist/{chunk-RQYEEA2O.js → chunk-N5FSLVKO.js} +2 -2
- package/dist/{chunk-CASCUFK2.js → chunk-NOHWIBRX.js} +2 -2
- package/dist/chunk-NOHWIBRX.js.map +1 -0
- package/dist/{chunk-TRTUHCS4.js → chunk-QCZ2XUKH.js} +2 -2
- package/dist/chunk-QCZ2XUKH.js.map +1 -0
- package/dist/{chunk-3IJSIVKT.js → chunk-QQBJC2FQ.js} +2 -2
- package/dist/{chunk-JZQHKDSY.js → chunk-RNQN2FOU.js} +2 -2
- package/dist/chunk-RNQN2FOU.js.map +1 -0
- package/dist/{chunk-DTAY7LPC.js → chunk-S5OVP467.js} +2 -2
- package/dist/chunk-S5OVP467.js.map +1 -0
- package/dist/{chunk-5YOCVEUB.js → chunk-SWCDFEUK.js} +2 -2
- package/dist/chunk-SWCDFEUK.js.map +1 -0
- package/dist/{chunk-MHCMHKM6.js → chunk-TA3WMOMU.js} +2 -2
- package/dist/chunk-TA3WMOMU.js.map +1 -0
- package/dist/{chunk-WSGEIVY3.js → chunk-TURD42QO.js} +101 -85
- package/dist/chunk-TURD42QO.js.map +1 -0
- package/dist/{chunk-WL7HS7EM.js → chunk-UINQOUZR.js} +2 -2
- package/dist/{chunk-A4Z6DZ22.js → chunk-VWKUT4CW.js} +2 -2
- package/dist/chunk-VWKUT4CW.js.map +1 -0
- package/dist/{chunk-ERELJ7BS.js → chunk-WAR4Q2NM.js} +2 -2
- package/dist/chunk-WAR4Q2NM.js.map +1 -0
- package/dist/{chunk-5HCVKTP3.js → chunk-WHFUWWI6.js} +92 -81
- package/dist/chunk-WHFUWWI6.js.map +1 -0
- package/dist/{chunk-HQ4KWN76.js → chunk-X3G37FXT.js} +2 -2
- package/dist/{chunk-OYV2DN66.js → chunk-X5HF2OFP.js} +2 -2
- package/dist/chunk-XWVDS66D.js +963 -0
- package/dist/chunk-XWVDS66D.js.map +1 -0
- package/dist/{chunk-L6JPBJAS.js → chunk-YAHRT6MB.js} +2 -2
- package/dist/{chunk-XRU5WXZX.js → chunk-ZEGAMJO2.js} +2 -2
- package/dist/chunk-ZEGAMJO2.js.map +1 -0
- package/dist/{chunk-B6SXRCBO.js → chunk-ZGSER5TG.js} +2 -2
- package/dist/databricks_volume-7XOUYSTY.js +7 -0
- package/dist/{digitalocean-6SPR4S7V.js → digitalocean-3CQ4CPPZ.js} +3 -3
- package/dist/{discord-SAV2RBJV.js → discord-BG7OSRJG.js} +2 -2
- package/dist/{disk-POACMF4G.js → disk-XVLBCVKE.js} +2 -2
- package/dist/{dropbox-CQ7MTYX2.js → dropbox-74GYLV3R.js} +2 -2
- package/dist/{email-KBQ7CXS7.js → email-5IZ7OBQ4.js} +2 -2
- package/dist/{gcs-SMIE4VMT.js → gcs-EMEYU2XT.js} +3 -3
- package/dist/{gdocs-X5Y2SIQX.js → gdocs-R67TDPON.js} +2 -2
- package/dist/{gdrive-SIQPRIGI.js → gdrive-PRN2ALRK.js} +2 -2
- package/dist/{github-KBHWANKQ.js → github-DV7E6OFV.js} +2 -2
- package/dist/{github_ci-HPITNK37.js → github_ci-Q554V5PA.js} +2 -2
- package/dist/{gmail-DKHAGJNX.js → gmail-OLN2LT4O.js} +2 -2
- package/dist/{gsheets-ZSUDIWGK.js → gsheets-H4RYMQJ5.js} +2 -2
- package/dist/{gslides-GYXM7IMJ.js → gslides-YLCHKJOM.js} +2 -2
- package/dist/{hf_buckets-RIOMV7WG.js → hf_buckets-DTKXKKFF.js} +3 -3
- package/dist/{hf_datasets-QF4BQ3OK.js → hf_datasets-55C4APKR.js} +3 -3
- package/dist/{hf_models-62GC2HPZ.js → hf_models-RO5JR36V.js} +3 -3
- package/dist/{hf_spaces-NVSMUNRM.js → hf_spaces-ZVZ3EDRX.js} +3 -3
- package/dist/index.d.ts +110 -44
- package/dist/index.js +520 -232
- package/dist/index.js.map +1 -1
- package/dist/{langfuse-HUAYVPHF.js → langfuse-ACASJZ7O.js} +2 -2
- package/dist/{linear-2MM55KBC.js → linear-IC37LZV7.js} +2 -2
- package/dist/{minio-L3XE6PQS.js → minio-HZ576XFQ.js} +3 -3
- package/dist/mongodb-JVR62OIO.js +7 -0
- package/dist/{notion-UK4GTMT4.js → notion-HKRPQMJS.js} +2 -2
- package/dist/{oci-NURLWPL2.js → oci-ZLVECXTW.js} +3 -3
- package/dist/postgres-P36Z2YN4.js +7 -0
- package/dist/{qingstor-W55D5YFO.js → qingstor-YLP6K3L4.js} +3 -3
- package/dist/{r2-FSZK7IFI.js → r2-RPK25ANI.js} +3 -3
- package/dist/{redis-S6GIPA4Z.js → redis-V5ULXULL.js} +2 -2
- package/dist/{s3-GMPUJ65D.js → s3-4OIOCAAT.js} +2 -2
- package/dist/{scaleway-5VM55Y6D.js → scaleway-CCWCLUHB.js} +3 -3
- package/dist/{seaweedfs-J3EPUEPE.js → seaweedfs-QSWKF2FN.js} +3 -3
- package/dist/{slack-FVBXY7KD.js → slack-YPS7PII3.js} +2 -2
- package/dist/{ssh-GCXETJ3Z.js → ssh-YFP3SMTJ.js} +2 -2
- package/dist/{supabase-HLWNHBBE.js → supabase-6CFTOKGZ.js} +3 -3
- package/dist/{tencent-YDO73XBD.js → tencent-IWZZOSQ4.js} +3 -3
- package/dist/{trello-CQ53BQUL.js → trello-XYKWZD6P.js} +2 -2
- package/dist/{wasabi-SOZKPMRQ.js → wasabi-6Z4DC5S5.js} +3 -3
- package/package.json +7 -5
- package/dist/chunk-5DLOHQJ2.js.map +0 -1
- package/dist/chunk-5HCVKTP3.js.map +0 -1
- package/dist/chunk-5YOCVEUB.js.map +0 -1
- package/dist/chunk-A4Z6DZ22.js.map +0 -1
- package/dist/chunk-A7X4L4JM.js.map +0 -1
- package/dist/chunk-ABTEGAFB.js.map +0 -1
- package/dist/chunk-C6NHEDHY.js.map +0 -1
- package/dist/chunk-CASCUFK2.js.map +0 -1
- package/dist/chunk-DTAY7LPC.js.map +0 -1
- package/dist/chunk-E7RW3SBV.js.map +0 -1
- package/dist/chunk-ERELJ7BS.js.map +0 -1
- package/dist/chunk-HEHERHQ5.js.map +0 -1
- package/dist/chunk-JZQHKDSY.js.map +0 -1
- package/dist/chunk-LYDMMNL2.js.map +0 -1
- package/dist/chunk-MHCMHKM6.js.map +0 -1
- package/dist/chunk-N72CAZEH.js +0 -1990
- package/dist/chunk-N72CAZEH.js.map +0 -1
- package/dist/chunk-NHS7WLEQ.js.map +0 -1
- package/dist/chunk-PBBG7VFT.js +0 -1896
- package/dist/chunk-PBBG7VFT.js.map +0 -1
- package/dist/chunk-RLGWMJD3.js.map +0 -1
- package/dist/chunk-TRTUHCS4.js.map +0 -1
- package/dist/chunk-WSGEIVY3.js.map +0 -1
- package/dist/chunk-XRU5WXZX.js.map +0 -1
- package/dist/chunk-YAVGCQUP.js.map +0 -1
- package/dist/chunk-YPT4JBUY.js.map +0 -1
- package/dist/databricks_volume-HNQ4DJVJ.js +0 -7
- package/dist/mongodb-ZOX4FRHJ.js +0 -7
- package/dist/postgres-JNFMPAO2.js +0 -7
- /package/dist/{aliyun-TMZRUYCG.js.map → aliyun-JMJ3PFYY.js.map} +0 -0
- /package/dist/{backblaze-OHW57DLK.js.map → backblaze-TDFD23QO.js.map} +0 -0
- /package/dist/{box-UXTCAFOZ.js.map → box-GQ2U2R6R.js.map} +0 -0
- /package/dist/{ceph-TNN4I2FT.js.map → ceph-S2VOYO6G.js.map} +0 -0
- /package/dist/{chunk-FXFDBF3P.js.map → chunk-3WIO7NBR.js.map} +0 -0
- /package/dist/{chunk-O7ODGJYL.js.map → chunk-47AVIIOT.js.map} +0 -0
- /package/dist/{chunk-Q6CDMOM6.js.map → chunk-7CW3BMPH.js.map} +0 -0
- /package/dist/{chunk-3T3RMDNX.js.map → chunk-AUHSTJJ3.js.map} +0 -0
- /package/dist/{chunk-PJBQKMCD.js.map → chunk-DM4GSE26.js.map} +0 -0
- /package/dist/{chunk-KTNDT45N.js.map → chunk-FQ33BYFR.js.map} +0 -0
- /package/dist/{chunk-BYTU2YC3.js.map → chunk-HGCRXJGP.js.map} +0 -0
- /package/dist/{chunk-G5BZE7UA.js.map → chunk-HJJMP6IX.js.map} +0 -0
- /package/dist/{chunk-IQVNVTOP.js.map → chunk-I5THIMPP.js.map} +0 -0
- /package/dist/{chunk-C6NHFMIP.js.map → chunk-IK2L4EN3.js.map} +0 -0
- /package/dist/{chunk-AJICZLHT.js.map → chunk-KPULTUOK.js.map} +0 -0
- /package/dist/{chunk-RQYEEA2O.js.map → chunk-N5FSLVKO.js.map} +0 -0
- /package/dist/{chunk-3IJSIVKT.js.map → chunk-QQBJC2FQ.js.map} +0 -0
- /package/dist/{chunk-WL7HS7EM.js.map → chunk-UINQOUZR.js.map} +0 -0
- /package/dist/{chunk-HQ4KWN76.js.map → chunk-X3G37FXT.js.map} +0 -0
- /package/dist/{chunk-OYV2DN66.js.map → chunk-X5HF2OFP.js.map} +0 -0
- /package/dist/{chunk-L6JPBJAS.js.map → chunk-YAHRT6MB.js.map} +0 -0
- /package/dist/{chunk-B6SXRCBO.js.map → chunk-ZGSER5TG.js.map} +0 -0
- /package/dist/{databricks_volume-HNQ4DJVJ.js.map → databricks_volume-7XOUYSTY.js.map} +0 -0
- /package/dist/{digitalocean-6SPR4S7V.js.map → digitalocean-3CQ4CPPZ.js.map} +0 -0
- /package/dist/{discord-SAV2RBJV.js.map → discord-BG7OSRJG.js.map} +0 -0
- /package/dist/{disk-POACMF4G.js.map → disk-XVLBCVKE.js.map} +0 -0
- /package/dist/{dropbox-CQ7MTYX2.js.map → dropbox-74GYLV3R.js.map} +0 -0
- /package/dist/{email-KBQ7CXS7.js.map → email-5IZ7OBQ4.js.map} +0 -0
- /package/dist/{gcs-SMIE4VMT.js.map → gcs-EMEYU2XT.js.map} +0 -0
- /package/dist/{gdocs-X5Y2SIQX.js.map → gdocs-R67TDPON.js.map} +0 -0
- /package/dist/{gdrive-SIQPRIGI.js.map → gdrive-PRN2ALRK.js.map} +0 -0
- /package/dist/{github-KBHWANKQ.js.map → github-DV7E6OFV.js.map} +0 -0
- /package/dist/{github_ci-HPITNK37.js.map → github_ci-Q554V5PA.js.map} +0 -0
- /package/dist/{gmail-DKHAGJNX.js.map → gmail-OLN2LT4O.js.map} +0 -0
- /package/dist/{gsheets-ZSUDIWGK.js.map → gsheets-H4RYMQJ5.js.map} +0 -0
- /package/dist/{gslides-GYXM7IMJ.js.map → gslides-YLCHKJOM.js.map} +0 -0
- /package/dist/{hf_buckets-RIOMV7WG.js.map → hf_buckets-DTKXKKFF.js.map} +0 -0
- /package/dist/{hf_datasets-QF4BQ3OK.js.map → hf_datasets-55C4APKR.js.map} +0 -0
- /package/dist/{hf_models-62GC2HPZ.js.map → hf_models-RO5JR36V.js.map} +0 -0
- /package/dist/{hf_spaces-NVSMUNRM.js.map → hf_spaces-ZVZ3EDRX.js.map} +0 -0
- /package/dist/{langfuse-HUAYVPHF.js.map → langfuse-ACASJZ7O.js.map} +0 -0
- /package/dist/{linear-2MM55KBC.js.map → linear-IC37LZV7.js.map} +0 -0
- /package/dist/{minio-L3XE6PQS.js.map → minio-HZ576XFQ.js.map} +0 -0
- /package/dist/{mongodb-ZOX4FRHJ.js.map → mongodb-JVR62OIO.js.map} +0 -0
- /package/dist/{notion-UK4GTMT4.js.map → notion-HKRPQMJS.js.map} +0 -0
- /package/dist/{oci-NURLWPL2.js.map → oci-ZLVECXTW.js.map} +0 -0
- /package/dist/{postgres-JNFMPAO2.js.map → postgres-P36Z2YN4.js.map} +0 -0
- /package/dist/{qingstor-W55D5YFO.js.map → qingstor-YLP6K3L4.js.map} +0 -0
- /package/dist/{r2-FSZK7IFI.js.map → r2-RPK25ANI.js.map} +0 -0
- /package/dist/{redis-S6GIPA4Z.js.map → redis-V5ULXULL.js.map} +0 -0
- /package/dist/{s3-GMPUJ65D.js.map → s3-4OIOCAAT.js.map} +0 -0
- /package/dist/{scaleway-5VM55Y6D.js.map → scaleway-CCWCLUHB.js.map} +0 -0
- /package/dist/{seaweedfs-J3EPUEPE.js.map → seaweedfs-QSWKF2FN.js.map} +0 -0
- /package/dist/{slack-FVBXY7KD.js.map → slack-YPS7PII3.js.map} +0 -0
- /package/dist/{ssh-GCXETJ3Z.js.map → ssh-YFP3SMTJ.js.map} +0 -0
- /package/dist/{supabase-HLWNHBBE.js.map → supabase-6CFTOKGZ.js.map} +0 -0
- /package/dist/{tencent-YDO73XBD.js.map → tencent-IWZZOSQ4.js.map} +0 -0
- /package/dist/{trello-CQ53BQUL.js.map → trello-XYKWZD6P.js.map} +0 -0
- /package/dist/{wasabi-SOZKPMRQ.js.map → wasabi-6Z4DC5S5.js.map} +0 -0
package/dist/chunk-PBBG7VFT.js
DELETED
|
@@ -1,1896 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
SCOPE_ERROR
|
|
3
|
-
} from "./chunk-U6QSXTUS.js";
|
|
4
|
-
|
|
5
|
-
// src/resource/disk/disk.ts
|
|
6
|
-
import { mkdir as mkdir5, readdir as readdir4, readFile as readFile3, writeFile as writeFile3 } from "fs/promises";
|
|
7
|
-
import path8 from "path";
|
|
8
|
-
import {
|
|
9
|
-
BaseResource,
|
|
10
|
-
PathSpec as PathSpec2,
|
|
11
|
-
ResourceName as ResourceName83
|
|
12
|
-
} from "@struktoai/mirage-core";
|
|
13
|
-
|
|
14
|
-
// src/commands/builtin/disk/index.ts
|
|
15
|
-
import { makeFiletypeCommands, ResourceName as ResourceName67 } from "@struktoai/mirage-core";
|
|
16
|
-
|
|
17
|
-
// src/core/disk/read.ts
|
|
18
|
-
import { readFile } from "fs/promises";
|
|
19
|
-
import { enoent, record, ResourceName } from "@struktoai/mirage-core";
|
|
20
|
-
|
|
21
|
-
// src/core/disk/utils.ts
|
|
22
|
-
import path from "path";
|
|
23
|
-
import { lstripSlash } from "@struktoai/mirage-core";
|
|
24
|
-
import { norm, parent, gnuBasename } from "@struktoai/mirage-core";
|
|
25
|
-
function resolveSafe(root, virtual) {
|
|
26
|
-
const relative = lstripSlash(virtual);
|
|
27
|
-
const resolved = path.resolve(root, relative);
|
|
28
|
-
const rootResolved = path.resolve(root);
|
|
29
|
-
if (resolved !== rootResolved && !resolved.startsWith(rootResolved + path.sep)) {
|
|
30
|
-
throw new Error(`path escapes root: ${virtual}`);
|
|
31
|
-
}
|
|
32
|
-
return resolved;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
// src/core/disk/read.ts
|
|
36
|
-
async function read(accessor, path9) {
|
|
37
|
-
const start = performance.now();
|
|
38
|
-
const virtual = path9.stripPrefix;
|
|
39
|
-
const full = resolveSafe(accessor.root, virtual);
|
|
40
|
-
let data;
|
|
41
|
-
try {
|
|
42
|
-
data = await readFile(full);
|
|
43
|
-
} catch (err) {
|
|
44
|
-
if (err.code === "ENOENT") {
|
|
45
|
-
throw enoent(path9);
|
|
46
|
-
}
|
|
47
|
-
throw err;
|
|
48
|
-
}
|
|
49
|
-
record("read", virtual, ResourceName.DISK, data.byteLength, start);
|
|
50
|
-
return new Uint8Array(data.buffer, data.byteOffset, data.byteLength);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
// src/core/disk/stat.ts
|
|
54
|
-
import { stat as fsStat } from "fs/promises";
|
|
55
|
-
import path2 from "path";
|
|
56
|
-
import { enoent as enoent2, FileStat, FileType, guessType } from "@struktoai/mirage-core";
|
|
57
|
-
async function stat(accessor, p) {
|
|
58
|
-
const virtual = p.stripPrefix;
|
|
59
|
-
const full = resolveSafe(accessor.root, virtual);
|
|
60
|
-
let st;
|
|
61
|
-
try {
|
|
62
|
-
st = await fsStat(full);
|
|
63
|
-
} catch (err) {
|
|
64
|
-
if (err.code === "ENOENT") {
|
|
65
|
-
throw enoent2(p);
|
|
66
|
-
}
|
|
67
|
-
throw err;
|
|
68
|
-
}
|
|
69
|
-
const modified = st.mtime.toISOString();
|
|
70
|
-
const name = path2.basename(full);
|
|
71
|
-
if (st.isDirectory()) {
|
|
72
|
-
return new FileStat({
|
|
73
|
-
name,
|
|
74
|
-
size: null,
|
|
75
|
-
modified,
|
|
76
|
-
type: FileType.DIRECTORY
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
return new FileStat({
|
|
80
|
-
name,
|
|
81
|
-
size: st.size,
|
|
82
|
-
modified,
|
|
83
|
-
fingerprint: modified,
|
|
84
|
-
type: guessType(name)
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
// src/commands/builtin/disk/awk.ts
|
|
89
|
-
import { ResourceName as ResourceName3, awkGeneric, command, specOf } from "@struktoai/mirage-core";
|
|
90
|
-
|
|
91
|
-
// src/core/disk/stream.ts
|
|
92
|
-
import { createReadStream } from "fs";
|
|
93
|
-
import { enoent as enoent3, recordStream, ResourceName as ResourceName2 } from "@struktoai/mirage-core";
|
|
94
|
-
async function* stream(accessor, path9) {
|
|
95
|
-
const virtual = path9.stripPrefix;
|
|
96
|
-
const full = resolveSafe(accessor.root, virtual);
|
|
97
|
-
const rec = recordStream("read", virtual, ResourceName2.DISK);
|
|
98
|
-
const rs = createReadStream(full, { highWaterMark: 65536 });
|
|
99
|
-
try {
|
|
100
|
-
for await (const chunk of rs) {
|
|
101
|
-
const buf = chunk;
|
|
102
|
-
const u8 = new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
103
|
-
if (rec !== null) rec.bytes += u8.byteLength;
|
|
104
|
-
yield u8;
|
|
105
|
-
}
|
|
106
|
-
} catch (err) {
|
|
107
|
-
if (err.code === "ENOENT") {
|
|
108
|
-
throw enoent3(path9);
|
|
109
|
-
}
|
|
110
|
-
throw err;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
// src/commands/builtin/disk/awk.ts
|
|
115
|
-
var DISK_AWK = command({
|
|
116
|
-
name: "awk",
|
|
117
|
-
resource: ResourceName3.DISK,
|
|
118
|
-
spec: specOf("awk"),
|
|
119
|
-
fn: (accessor, paths, texts, opts) => awkGeneric(paths, texts, opts, (p) => stream(accessor, p))
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
// src/commands/builtin/disk/base64_cmd.ts
|
|
123
|
-
import { ResourceName as ResourceName4, command as command2, specOf as specOf2, base64Generic } from "@struktoai/mirage-core";
|
|
124
|
-
var DISK_BASE64 = command2({
|
|
125
|
-
name: "base64",
|
|
126
|
-
resource: ResourceName4.DISK,
|
|
127
|
-
spec: specOf2("base64"),
|
|
128
|
-
fn: (accessor, paths, _texts, opts) => base64Generic(paths, opts, (p) => stream(accessor, p))
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
// src/commands/builtin/disk/basename.ts
|
|
132
|
-
import { ResourceName as ResourceName5, command as command3, specOf as specOf3, basenameFn } from "@struktoai/mirage-core";
|
|
133
|
-
var DISK_BASENAME = command3({
|
|
134
|
-
name: "basename",
|
|
135
|
-
resource: ResourceName5.DISK,
|
|
136
|
-
spec: specOf3("basename"),
|
|
137
|
-
fn: basenameFn
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
// src/commands/builtin/disk/cat/cat.ts
|
|
141
|
-
import {
|
|
142
|
-
ResourceName as ResourceName6,
|
|
143
|
-
catGeneric,
|
|
144
|
-
catProvisionGeneric,
|
|
145
|
-
command as command4,
|
|
146
|
-
concatAggregate,
|
|
147
|
-
specOf as specOf4
|
|
148
|
-
} from "@struktoai/mirage-core";
|
|
149
|
-
var DISK_CAT = command4({
|
|
150
|
-
name: "cat",
|
|
151
|
-
resource: ResourceName6.DISK,
|
|
152
|
-
spec: specOf4("cat"),
|
|
153
|
-
fn: (accessor, paths, texts, opts) => catGeneric(
|
|
154
|
-
paths,
|
|
155
|
-
texts,
|
|
156
|
-
opts,
|
|
157
|
-
(p) => stat(accessor, p),
|
|
158
|
-
(p) => stream(accessor, p)
|
|
159
|
-
),
|
|
160
|
-
provision: (accessor, paths, _texts, _opts) => catProvisionGeneric(paths, (p) => stat(accessor, p)),
|
|
161
|
-
aggregate: concatAggregate
|
|
162
|
-
});
|
|
163
|
-
|
|
164
|
-
// src/commands/builtin/disk/cmp.ts
|
|
165
|
-
import { ResourceName as ResourceName7, command as command5, specOf as specOf5, cmpGeneric } from "@struktoai/mirage-core";
|
|
166
|
-
var DISK_CMP = command5({
|
|
167
|
-
name: "cmp",
|
|
168
|
-
resource: ResourceName7.DISK,
|
|
169
|
-
spec: specOf5("cmp"),
|
|
170
|
-
fn: (accessor, paths, _texts, opts) => cmpGeneric(paths, opts, (p) => stream(accessor, p))
|
|
171
|
-
});
|
|
172
|
-
|
|
173
|
-
// src/commands/builtin/disk/column.ts
|
|
174
|
-
import { ResourceName as ResourceName8, command as command6, specOf as specOf6, columnGeneric } from "@struktoai/mirage-core";
|
|
175
|
-
var DISK_COLUMN = command6({
|
|
176
|
-
name: "column",
|
|
177
|
-
resource: ResourceName8.DISK,
|
|
178
|
-
spec: specOf6("column"),
|
|
179
|
-
fn: (accessor, paths, _texts, opts) => columnGeneric(paths, opts, (p) => stream(accessor, p))
|
|
180
|
-
});
|
|
181
|
-
|
|
182
|
-
// src/commands/builtin/disk/comm.ts
|
|
183
|
-
import { ResourceName as ResourceName9, command as command7, specOf as specOf7, commGeneric } from "@struktoai/mirage-core";
|
|
184
|
-
var DISK_COMM = command7({
|
|
185
|
-
name: "comm",
|
|
186
|
-
resource: ResourceName9.DISK,
|
|
187
|
-
spec: specOf7("comm"),
|
|
188
|
-
fn: (accessor, paths, _texts, opts) => commGeneric(paths, opts, (p) => stream(accessor, p))
|
|
189
|
-
});
|
|
190
|
-
|
|
191
|
-
// src/commands/builtin/disk/cp.ts
|
|
192
|
-
import {
|
|
193
|
-
IOResult,
|
|
194
|
-
ResourceName as ResourceName10,
|
|
195
|
-
command as command8,
|
|
196
|
-
cpGeneric,
|
|
197
|
-
specOf as specOf8
|
|
198
|
-
} from "@struktoai/mirage-core";
|
|
199
|
-
|
|
200
|
-
// src/core/disk/copy.ts
|
|
201
|
-
import { copyFile, mkdir } from "fs/promises";
|
|
202
|
-
import path3 from "path";
|
|
203
|
-
import { enoent as enoent4 } from "@struktoai/mirage-core";
|
|
204
|
-
async function copy(accessor, src, dst) {
|
|
205
|
-
const s = resolveSafe(accessor.root, src.stripPrefix);
|
|
206
|
-
const d = resolveSafe(accessor.root, dst.stripPrefix);
|
|
207
|
-
await mkdir(path3.dirname(d), { recursive: true });
|
|
208
|
-
try {
|
|
209
|
-
await copyFile(s, d);
|
|
210
|
-
} catch (err) {
|
|
211
|
-
if (err.code === "ENOENT") {
|
|
212
|
-
throw enoent4(src);
|
|
213
|
-
}
|
|
214
|
-
throw err;
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
// src/core/disk/find.ts
|
|
219
|
-
import { readdir, stat as stat2 } from "fs/promises";
|
|
220
|
-
import path4 from "path";
|
|
221
|
-
import { buildTree, keep } from "@struktoai/mirage-core";
|
|
222
|
-
async function walk(ctx, full, current, depth) {
|
|
223
|
-
const opts = ctx.options;
|
|
224
|
-
if (opts.maxDepth !== null && opts.maxDepth !== void 0 && depth > opts.maxDepth) return;
|
|
225
|
-
let entries;
|
|
226
|
-
try {
|
|
227
|
-
entries = await readdir(full, { withFileTypes: true });
|
|
228
|
-
} catch {
|
|
229
|
-
return;
|
|
230
|
-
}
|
|
231
|
-
for (const e of entries) {
|
|
232
|
-
const kind = e.isDirectory() ? "d" : "f";
|
|
233
|
-
const entryPath = current === "/" ? `/${e.name}` : `${current}/${e.name}`;
|
|
234
|
-
const entryName = e.name;
|
|
235
|
-
const entrySlashCount = (entryPath.match(/\//g) ?? []).length;
|
|
236
|
-
const entryDepth = entrySlashCount - ctx.baseDepth;
|
|
237
|
-
let accept = true;
|
|
238
|
-
if (opts.maxDepth !== null && opts.maxDepth !== void 0 && entryDepth > opts.maxDepth) {
|
|
239
|
-
accept = false;
|
|
240
|
-
}
|
|
241
|
-
let isEmpty = null;
|
|
242
|
-
if (accept && opts.empty === true) {
|
|
243
|
-
try {
|
|
244
|
-
isEmpty = kind === "f" ? (await stat2(path4.join(full, e.name))).size === 0 : (await readdir(path4.join(full, e.name))).length === 0;
|
|
245
|
-
} catch {
|
|
246
|
-
isEmpty = null;
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
if (accept && !keep(
|
|
250
|
-
{ key: entryPath, name: entryName, kind, depth: entryDepth, isEmpty },
|
|
251
|
-
ctx.tree,
|
|
252
|
-
opts.minDepth
|
|
253
|
-
)) {
|
|
254
|
-
accept = false;
|
|
255
|
-
}
|
|
256
|
-
if (accept && kind === "f" && (opts.minSize !== null || opts.maxSize !== null || opts.mtimeMin !== null || opts.mtimeMax !== null)) {
|
|
257
|
-
try {
|
|
258
|
-
const st = await stat2(path4.join(full, e.name));
|
|
259
|
-
if (opts.minSize !== null && opts.minSize !== void 0 && st.size < opts.minSize)
|
|
260
|
-
accept = false;
|
|
261
|
-
if (opts.maxSize !== null && opts.maxSize !== void 0 && st.size > opts.maxSize)
|
|
262
|
-
accept = false;
|
|
263
|
-
if (accept && (opts.mtimeMin !== void 0 || opts.mtimeMax !== void 0)) {
|
|
264
|
-
const mtime = st.mtime.getTime() / 1e3;
|
|
265
|
-
if (opts.mtimeMin !== null && opts.mtimeMin !== void 0 && mtime < opts.mtimeMin)
|
|
266
|
-
accept = false;
|
|
267
|
-
if (opts.mtimeMax !== null && opts.mtimeMax !== void 0 && mtime > opts.mtimeMax)
|
|
268
|
-
accept = false;
|
|
269
|
-
}
|
|
270
|
-
} catch {
|
|
271
|
-
accept = false;
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
if (accept) ctx.results.push(entryPath);
|
|
275
|
-
if (kind === "d") {
|
|
276
|
-
await walk(ctx, path4.join(full, e.name), entryPath, depth + 1);
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
async function find(accessor, p, options = {}) {
|
|
281
|
-
const virtual = norm(p.stripPrefix);
|
|
282
|
-
const full = resolveSafe(accessor.root, virtual);
|
|
283
|
-
const baseDepth = virtual === "/" ? 0 : (virtual.match(/\//g) ?? []).length;
|
|
284
|
-
const results = [];
|
|
285
|
-
const tree = options.tree ?? buildTree({
|
|
286
|
-
name: options.name,
|
|
287
|
-
iname: options.iname,
|
|
288
|
-
pathPattern: options.pathPattern,
|
|
289
|
-
type: options.type,
|
|
290
|
-
nameExclude: options.nameExclude,
|
|
291
|
-
orNames: options.orNames,
|
|
292
|
-
empty: options.empty
|
|
293
|
-
});
|
|
294
|
-
if (virtual !== "/" && (options.maxDepth == null || options.maxDepth >= 0)) {
|
|
295
|
-
let isDir = false;
|
|
296
|
-
try {
|
|
297
|
-
isDir = (await stat2(full)).isDirectory();
|
|
298
|
-
} catch {
|
|
299
|
-
isDir = false;
|
|
300
|
-
}
|
|
301
|
-
let rootEmpty = null;
|
|
302
|
-
if (isDir && options.empty === true) {
|
|
303
|
-
try {
|
|
304
|
-
rootEmpty = (await readdir(full)).length === 0;
|
|
305
|
-
} catch {
|
|
306
|
-
rootEmpty = null;
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
if (isDir && keep(
|
|
310
|
-
{
|
|
311
|
-
key: virtual,
|
|
312
|
-
name: virtual.slice(virtual.lastIndexOf("/") + 1),
|
|
313
|
-
kind: "d",
|
|
314
|
-
depth: 0,
|
|
315
|
-
isEmpty: rootEmpty
|
|
316
|
-
},
|
|
317
|
-
tree,
|
|
318
|
-
options.minDepth
|
|
319
|
-
)) {
|
|
320
|
-
results.push(virtual);
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
await walk({ accessor, base: virtual, baseDepth, options, tree, results }, full, virtual, 0);
|
|
324
|
-
results.sort();
|
|
325
|
-
return results;
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
// src/commands/builtin/disk/cp.ts
|
|
329
|
-
function cpCommand(accessor, paths, _texts, opts) {
|
|
330
|
-
if (paths.length < 2) {
|
|
331
|
-
return Promise.resolve([
|
|
332
|
-
null,
|
|
333
|
-
new IOResult({ exitCode: 1, stderr: new TextEncoder().encode("cp: missing operand\n") })
|
|
334
|
-
]);
|
|
335
|
-
}
|
|
336
|
-
const recursive = opts.flags.r === true || opts.flags.R === true || opts.flags.a === true;
|
|
337
|
-
return cpGeneric(
|
|
338
|
-
paths,
|
|
339
|
-
(src, target) => copy(accessor, src, target),
|
|
340
|
-
(src, options) => find(accessor, src, options),
|
|
341
|
-
(p) => stat(accessor, p),
|
|
342
|
-
recursive,
|
|
343
|
-
opts.flags.n === true,
|
|
344
|
-
opts.flags.v === true,
|
|
345
|
-
opts.index ?? void 0
|
|
346
|
-
);
|
|
347
|
-
}
|
|
348
|
-
var DISK_CP = command8({
|
|
349
|
-
name: "cp",
|
|
350
|
-
resource: ResourceName10.DISK,
|
|
351
|
-
spec: specOf8("cp"),
|
|
352
|
-
fn: cpCommand,
|
|
353
|
-
write: true
|
|
354
|
-
});
|
|
355
|
-
|
|
356
|
-
// src/commands/builtin/disk/csplit.ts
|
|
357
|
-
import { ResourceName as ResourceName12, command as command9, specOf as specOf9, csplitGeneric } from "@struktoai/mirage-core";
|
|
358
|
-
|
|
359
|
-
// src/core/disk/write.ts
|
|
360
|
-
import { mkdir as mkdir2, writeFile } from "fs/promises";
|
|
361
|
-
import path5 from "path";
|
|
362
|
-
import { record as record2, ResourceName as ResourceName11 } from "@struktoai/mirage-core";
|
|
363
|
-
async function writeBytes(accessor, p, data) {
|
|
364
|
-
const start = performance.now();
|
|
365
|
-
const virtual = p.stripPrefix;
|
|
366
|
-
const full = resolveSafe(accessor.root, virtual);
|
|
367
|
-
await mkdir2(path5.dirname(full), { recursive: true });
|
|
368
|
-
await writeFile(full, data);
|
|
369
|
-
record2("write", virtual, ResourceName11.DISK, data.byteLength, start);
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
// src/commands/builtin/disk/csplit.ts
|
|
373
|
-
var DISK_CSPLIT = command9({
|
|
374
|
-
name: "csplit",
|
|
375
|
-
resource: ResourceName12.DISK,
|
|
376
|
-
spec: specOf9("csplit"),
|
|
377
|
-
fn: (accessor, paths, texts, opts) => csplitGeneric(
|
|
378
|
-
paths,
|
|
379
|
-
texts,
|
|
380
|
-
opts,
|
|
381
|
-
(p) => stream(accessor, p),
|
|
382
|
-
(p, d) => writeBytes(accessor, p, d)
|
|
383
|
-
),
|
|
384
|
-
write: true
|
|
385
|
-
});
|
|
386
|
-
|
|
387
|
-
// src/commands/builtin/disk/cut/cut.ts
|
|
388
|
-
import { ResourceName as ResourceName13, command as command10, cutGeneric, specOf as specOf10 } from "@struktoai/mirage-core";
|
|
389
|
-
var DISK_CUT = command10({
|
|
390
|
-
name: "cut",
|
|
391
|
-
resource: ResourceName13.DISK,
|
|
392
|
-
spec: specOf10("cut"),
|
|
393
|
-
fn: (accessor, paths, _texts, opts) => cutGeneric(paths, opts, (p) => stream(accessor, p))
|
|
394
|
-
});
|
|
395
|
-
|
|
396
|
-
// src/commands/builtin/disk/diff.ts
|
|
397
|
-
import { ResourceName as ResourceName14, command as command11, diffGeneric, specOf as specOf11 } from "@struktoai/mirage-core";
|
|
398
|
-
var DISK_DIFF = command11({
|
|
399
|
-
name: "diff",
|
|
400
|
-
resource: ResourceName14.DISK,
|
|
401
|
-
spec: specOf11("diff"),
|
|
402
|
-
fn: (accessor, paths, _texts, opts) => diffGeneric(paths, opts, (p) => stream(accessor, p))
|
|
403
|
-
});
|
|
404
|
-
|
|
405
|
-
// src/commands/builtin/disk/dirname.ts
|
|
406
|
-
import { ResourceName as ResourceName15, command as command12, specOf as specOf12, dirnameFn } from "@struktoai/mirage-core";
|
|
407
|
-
var DISK_DIRNAME = command12({
|
|
408
|
-
name: "dirname",
|
|
409
|
-
resource: ResourceName15.DISK,
|
|
410
|
-
spec: specOf12("dirname"),
|
|
411
|
-
fn: dirnameFn
|
|
412
|
-
});
|
|
413
|
-
|
|
414
|
-
// src/commands/builtin/disk/du.ts
|
|
415
|
-
import { ResourceName as ResourceName16, command as command13, duGeneric, specOf as specOf13 } from "@struktoai/mirage-core";
|
|
416
|
-
|
|
417
|
-
// src/core/disk/du.ts
|
|
418
|
-
import { readdir as readdir2, stat as stat3 } from "fs/promises";
|
|
419
|
-
import path6 from "path";
|
|
420
|
-
async function walkSizes(full) {
|
|
421
|
-
let total = 0;
|
|
422
|
-
let st;
|
|
423
|
-
try {
|
|
424
|
-
st = await stat3(full);
|
|
425
|
-
} catch {
|
|
426
|
-
return 0;
|
|
427
|
-
}
|
|
428
|
-
if (st.isFile()) return st.size;
|
|
429
|
-
if (!st.isDirectory()) return 0;
|
|
430
|
-
const entries = await readdir2(full, { withFileTypes: true });
|
|
431
|
-
for (const e of entries) {
|
|
432
|
-
const child = path6.join(full, e.name);
|
|
433
|
-
if (e.isDirectory()) total += await walkSizes(child);
|
|
434
|
-
else if (e.isFile()) {
|
|
435
|
-
try {
|
|
436
|
-
const cst = await stat3(child);
|
|
437
|
-
total += cst.size;
|
|
438
|
-
} catch {
|
|
439
|
-
}
|
|
440
|
-
}
|
|
441
|
-
}
|
|
442
|
-
return total;
|
|
443
|
-
}
|
|
444
|
-
async function walkAll(accessor, full, entries) {
|
|
445
|
-
let total = 0;
|
|
446
|
-
let st;
|
|
447
|
-
try {
|
|
448
|
-
st = await stat3(full);
|
|
449
|
-
} catch {
|
|
450
|
-
return 0;
|
|
451
|
-
}
|
|
452
|
-
if (st.isFile()) {
|
|
453
|
-
const rel = "/" + path6.relative(accessor.root, full).split(path6.sep).join("/");
|
|
454
|
-
entries.push([rel, st.size]);
|
|
455
|
-
return st.size;
|
|
456
|
-
}
|
|
457
|
-
if (!st.isDirectory()) return 0;
|
|
458
|
-
const children = await readdir2(full, { withFileTypes: true });
|
|
459
|
-
for (const e of children) {
|
|
460
|
-
const child = path6.join(full, e.name);
|
|
461
|
-
if (e.isDirectory()) {
|
|
462
|
-
total += await walkAll(accessor, child, entries);
|
|
463
|
-
} else if (e.isFile()) {
|
|
464
|
-
try {
|
|
465
|
-
const cst = await stat3(child);
|
|
466
|
-
const rel = "/" + path6.relative(accessor.root, child).split(path6.sep).join("/");
|
|
467
|
-
entries.push([rel, cst.size]);
|
|
468
|
-
total += cst.size;
|
|
469
|
-
} catch {
|
|
470
|
-
}
|
|
471
|
-
}
|
|
472
|
-
}
|
|
473
|
-
return total;
|
|
474
|
-
}
|
|
475
|
-
async function du(accessor, p) {
|
|
476
|
-
const virtual = p.stripPrefix;
|
|
477
|
-
const full = resolveSafe(accessor.root, virtual);
|
|
478
|
-
return walkSizes(full);
|
|
479
|
-
}
|
|
480
|
-
async function duAll(accessor, p) {
|
|
481
|
-
const virtual = norm(p.stripPrefix);
|
|
482
|
-
const full = resolveSafe(accessor.root, virtual);
|
|
483
|
-
const entries = [];
|
|
484
|
-
const total = await walkAll(accessor, full, entries);
|
|
485
|
-
entries.sort((a, b) => a[0] < b[0] ? -1 : a[0] > b[0] ? 1 : 0);
|
|
486
|
-
return [entries, total];
|
|
487
|
-
}
|
|
488
|
-
|
|
489
|
-
// src/commands/builtin/disk/du.ts
|
|
490
|
-
var DISK_DU = command13({
|
|
491
|
-
name: "du",
|
|
492
|
-
resource: ResourceName16.DISK,
|
|
493
|
-
spec: specOf13("du"),
|
|
494
|
-
fn: (accessor, paths, _texts, opts) => duGeneric(
|
|
495
|
-
paths,
|
|
496
|
-
opts,
|
|
497
|
-
(p) => du(accessor, p),
|
|
498
|
-
(p) => duAll(accessor, p)
|
|
499
|
-
)
|
|
500
|
-
});
|
|
501
|
-
|
|
502
|
-
// src/commands/builtin/disk/expand.ts
|
|
503
|
-
import { ResourceName as ResourceName17, command as command14, specOf as specOf14, expandGeneric } from "@struktoai/mirage-core";
|
|
504
|
-
var DISK_EXPAND = command14({
|
|
505
|
-
name: "expand",
|
|
506
|
-
resource: ResourceName17.DISK,
|
|
507
|
-
spec: specOf14("expand"),
|
|
508
|
-
fn: (accessor, paths, _texts, opts) => expandGeneric(paths, opts, (p) => stream(accessor, p))
|
|
509
|
-
});
|
|
510
|
-
|
|
511
|
-
// src/commands/builtin/disk/file/file.ts
|
|
512
|
-
import { ResourceName as ResourceName18, command as command15, fileGeneric, specOf as specOf15 } from "@struktoai/mirage-core";
|
|
513
|
-
var DISK_FILE = command15({
|
|
514
|
-
name: "file",
|
|
515
|
-
resource: ResourceName18.DISK,
|
|
516
|
-
spec: specOf15("file"),
|
|
517
|
-
fn: (accessor, paths, _texts, opts) => fileGeneric(
|
|
518
|
-
paths,
|
|
519
|
-
opts,
|
|
520
|
-
(p) => stat(accessor, p),
|
|
521
|
-
(p) => read(accessor, p)
|
|
522
|
-
)
|
|
523
|
-
});
|
|
524
|
-
|
|
525
|
-
// src/commands/builtin/disk/find.ts
|
|
526
|
-
import { ResourceName as ResourceName19, command as command16, findGeneric, specOf as specOf16 } from "@struktoai/mirage-core";
|
|
527
|
-
var DISK_FIND = command16({
|
|
528
|
-
name: "find",
|
|
529
|
-
resource: ResourceName19.DISK,
|
|
530
|
-
spec: specOf16("find"),
|
|
531
|
-
fn: (accessor, paths, texts, opts) => findGeneric(paths, texts, opts, (root, options) => find(accessor, root, options))
|
|
532
|
-
});
|
|
533
|
-
|
|
534
|
-
// src/commands/builtin/disk/fmt.ts
|
|
535
|
-
import {
|
|
536
|
-
ResourceName as ResourceName20,
|
|
537
|
-
command as command17,
|
|
538
|
-
fmtGeneric,
|
|
539
|
-
specOf as specOf17
|
|
540
|
-
} from "@struktoai/mirage-core";
|
|
541
|
-
async function fmtCommand(accessor, paths, _texts, opts) {
|
|
542
|
-
return fmtGeneric(paths, opts, (p) => stream(accessor, p));
|
|
543
|
-
}
|
|
544
|
-
var DISK_FMT = command17({
|
|
545
|
-
name: "fmt",
|
|
546
|
-
resource: ResourceName20.DISK,
|
|
547
|
-
spec: specOf17("fmt"),
|
|
548
|
-
fn: fmtCommand
|
|
549
|
-
});
|
|
550
|
-
|
|
551
|
-
// src/commands/builtin/disk/fold.ts
|
|
552
|
-
import { ResourceName as ResourceName21, command as command18, specOf as specOf18, foldGeneric } from "@struktoai/mirage-core";
|
|
553
|
-
var DISK_FOLD = command18({
|
|
554
|
-
name: "fold",
|
|
555
|
-
resource: ResourceName21.DISK,
|
|
556
|
-
spec: specOf18("fold"),
|
|
557
|
-
fn: (accessor, paths, _texts, opts) => foldGeneric(paths, opts, (p) => stream(accessor, p))
|
|
558
|
-
});
|
|
559
|
-
|
|
560
|
-
// src/commands/builtin/disk/grep/grep.ts
|
|
561
|
-
import { ResourceName as ResourceName22, command as command19, grepGeneric, prefixAggregate, specOf as specOf19 } from "@struktoai/mirage-core";
|
|
562
|
-
|
|
563
|
-
// src/core/disk/readdir.ts
|
|
564
|
-
import { readdir as fsReaddir } from "fs/promises";
|
|
565
|
-
import {
|
|
566
|
-
enotdir,
|
|
567
|
-
IndexEntry,
|
|
568
|
-
ResourceType
|
|
569
|
-
} from "@struktoai/mirage-core";
|
|
570
|
-
async function readdir3(accessor, path9, index) {
|
|
571
|
-
const virtual = path9.pattern !== null ? path9.directory : path9.stripPrefix;
|
|
572
|
-
const mountPrefix = path9.prefix;
|
|
573
|
-
const virtualKey = mountPrefix + virtual;
|
|
574
|
-
if (index !== void 0) {
|
|
575
|
-
const cached = await index.listDir(virtualKey);
|
|
576
|
-
if (cached.entries !== void 0 && cached.entries !== null) {
|
|
577
|
-
return cached.entries;
|
|
578
|
-
}
|
|
579
|
-
}
|
|
580
|
-
const full = resolveSafe(accessor.root, virtual);
|
|
581
|
-
let entries;
|
|
582
|
-
try {
|
|
583
|
-
entries = await fsReaddir(full);
|
|
584
|
-
} catch (err) {
|
|
585
|
-
const code = err.code;
|
|
586
|
-
if (code === "ENOTDIR") throw enotdir(path9);
|
|
587
|
-
if (code === "ENOENT") throw enotdir(path9);
|
|
588
|
-
throw err;
|
|
589
|
-
}
|
|
590
|
-
const base = norm(virtual);
|
|
591
|
-
const dirPrefix = base === "/" ? "/" : `${base}/`;
|
|
592
|
-
const sorted = [...entries].sort();
|
|
593
|
-
const virtualEntries = sorted.map((e) => `${mountPrefix}${dirPrefix}${e}`);
|
|
594
|
-
if (index !== void 0) {
|
|
595
|
-
const indexEntries = sorted.map((name) => [
|
|
596
|
-
name,
|
|
597
|
-
new IndexEntry({
|
|
598
|
-
id: `${dirPrefix}${name}`,
|
|
599
|
-
name,
|
|
600
|
-
resourceType: ResourceType.FILE
|
|
601
|
-
})
|
|
602
|
-
]);
|
|
603
|
-
await index.setDir(virtualKey, indexEntries);
|
|
604
|
-
}
|
|
605
|
-
return virtualEntries;
|
|
606
|
-
}
|
|
607
|
-
|
|
608
|
-
// src/commands/builtin/disk/grep/grep.ts
|
|
609
|
-
var DISK_GREP = command19({
|
|
610
|
-
name: "grep",
|
|
611
|
-
resource: ResourceName22.DISK,
|
|
612
|
-
spec: specOf19("grep"),
|
|
613
|
-
fn: (accessor, paths, texts, opts) => grepGeneric(
|
|
614
|
-
"grep",
|
|
615
|
-
paths,
|
|
616
|
-
texts,
|
|
617
|
-
opts,
|
|
618
|
-
(p) => stat(accessor, p),
|
|
619
|
-
(p) => readdir3(accessor, p),
|
|
620
|
-
(p) => stream(accessor, p)
|
|
621
|
-
),
|
|
622
|
-
aggregate: prefixAggregate
|
|
623
|
-
});
|
|
624
|
-
|
|
625
|
-
// src/commands/builtin/disk/gunzip.ts
|
|
626
|
-
import { ResourceName as ResourceName23, command as command20, specOf as specOf20, gunzipGeneric } from "@struktoai/mirage-core";
|
|
627
|
-
|
|
628
|
-
// src/core/disk/unlink.ts
|
|
629
|
-
import { unlink as fsUnlink } from "fs/promises";
|
|
630
|
-
async function unlink(accessor, path9) {
|
|
631
|
-
const full = resolveSafe(accessor.root, path9.stripPrefix);
|
|
632
|
-
try {
|
|
633
|
-
await fsUnlink(full);
|
|
634
|
-
} catch (err) {
|
|
635
|
-
if (err.code === "ENOENT") return;
|
|
636
|
-
throw err;
|
|
637
|
-
}
|
|
638
|
-
}
|
|
639
|
-
|
|
640
|
-
// src/commands/builtin/disk/gunzip.ts
|
|
641
|
-
var DISK_GUNZIP = command20({
|
|
642
|
-
name: "gunzip",
|
|
643
|
-
resource: ResourceName23.DISK,
|
|
644
|
-
spec: specOf20("gunzip"),
|
|
645
|
-
fn: (accessor, paths, _texts, opts) => gunzipGeneric(
|
|
646
|
-
paths,
|
|
647
|
-
opts,
|
|
648
|
-
(p) => stream(accessor, p),
|
|
649
|
-
(p, d) => writeBytes(accessor, p, d),
|
|
650
|
-
(p) => unlink(accessor, p)
|
|
651
|
-
),
|
|
652
|
-
write: true
|
|
653
|
-
});
|
|
654
|
-
|
|
655
|
-
// src/commands/builtin/disk/gzip.ts
|
|
656
|
-
import { ResourceName as ResourceName24, command as command21, specOf as specOf21, gzipGeneric } from "@struktoai/mirage-core";
|
|
657
|
-
var DISK_GZIP = command21({
|
|
658
|
-
name: "gzip",
|
|
659
|
-
resource: ResourceName24.DISK,
|
|
660
|
-
spec: specOf21("gzip"),
|
|
661
|
-
fn: (accessor, paths, _texts, opts) => gzipGeneric(
|
|
662
|
-
paths,
|
|
663
|
-
opts,
|
|
664
|
-
(p) => stream(accessor, p),
|
|
665
|
-
(p, d) => writeBytes(accessor, p, d),
|
|
666
|
-
(p) => unlink(accessor, p)
|
|
667
|
-
),
|
|
668
|
-
write: true
|
|
669
|
-
});
|
|
670
|
-
|
|
671
|
-
// src/commands/builtin/disk/head/head.ts
|
|
672
|
-
import {
|
|
673
|
-
ResourceName as ResourceName25,
|
|
674
|
-
command as command22,
|
|
675
|
-
headGeneric,
|
|
676
|
-
headProvisionGeneric,
|
|
677
|
-
headerAggregate,
|
|
678
|
-
specOf as specOf22
|
|
679
|
-
} from "@struktoai/mirage-core";
|
|
680
|
-
var DISK_HEAD = command22({
|
|
681
|
-
name: "head",
|
|
682
|
-
resource: ResourceName25.DISK,
|
|
683
|
-
spec: specOf22("head"),
|
|
684
|
-
fn: (accessor, paths, texts, opts) => headGeneric(
|
|
685
|
-
paths,
|
|
686
|
-
texts,
|
|
687
|
-
opts,
|
|
688
|
-
(p) => stat(accessor, p),
|
|
689
|
-
(p) => stream(accessor, p)
|
|
690
|
-
),
|
|
691
|
-
provision: (accessor, paths, texts, opts) => headProvisionGeneric(paths, texts, opts, (p) => stat(accessor, p)),
|
|
692
|
-
aggregate: headerAggregate
|
|
693
|
-
});
|
|
694
|
-
|
|
695
|
-
// src/commands/builtin/disk/iconv.ts
|
|
696
|
-
import { ResourceName as ResourceName26, command as command23, specOf as specOf23, iconvGeneric } from "@struktoai/mirage-core";
|
|
697
|
-
var DISK_ICONV = command23({
|
|
698
|
-
name: "iconv",
|
|
699
|
-
resource: ResourceName26.DISK,
|
|
700
|
-
spec: specOf23("iconv"),
|
|
701
|
-
fn: (accessor, paths, _texts, opts) => iconvGeneric(
|
|
702
|
-
paths,
|
|
703
|
-
opts,
|
|
704
|
-
(p) => stream(accessor, p),
|
|
705
|
-
(p, d) => writeBytes(accessor, p, d)
|
|
706
|
-
),
|
|
707
|
-
write: true
|
|
708
|
-
});
|
|
709
|
-
|
|
710
|
-
// src/commands/builtin/disk/join.ts
|
|
711
|
-
import { ResourceName as ResourceName27, command as command24, specOf as specOf24, joinGeneric } from "@struktoai/mirage-core";
|
|
712
|
-
var DISK_JOIN = command24({
|
|
713
|
-
name: "join",
|
|
714
|
-
resource: ResourceName27.DISK,
|
|
715
|
-
spec: specOf24("join"),
|
|
716
|
-
fn: (accessor, paths, _texts, opts) => joinGeneric(paths, opts, (p) => stream(accessor, p))
|
|
717
|
-
});
|
|
718
|
-
|
|
719
|
-
// src/commands/builtin/disk/jq.ts
|
|
720
|
-
import {
|
|
721
|
-
ResourceName as ResourceName28,
|
|
722
|
-
command as command25,
|
|
723
|
-
jqGeneric,
|
|
724
|
-
jqProvisionGeneric,
|
|
725
|
-
specOf as specOf25
|
|
726
|
-
} from "@struktoai/mirage-core";
|
|
727
|
-
var DISK_JQ = command25({
|
|
728
|
-
name: "jq",
|
|
729
|
-
resource: ResourceName28.DISK,
|
|
730
|
-
spec: specOf25("jq"),
|
|
731
|
-
fn: (accessor, paths, texts, opts) => jqGeneric(paths, texts, opts, (p) => stream(accessor, p)),
|
|
732
|
-
provision: (accessor, paths, texts, _opts) => jqProvisionGeneric(paths, texts, (p) => stat(accessor, p))
|
|
733
|
-
});
|
|
734
|
-
|
|
735
|
-
// src/commands/builtin/disk/ln.ts
|
|
736
|
-
import {
|
|
737
|
-
IOResult as IOResult2,
|
|
738
|
-
ResourceName as ResourceName29,
|
|
739
|
-
command as command26,
|
|
740
|
-
materialize,
|
|
741
|
-
specOf as specOf26
|
|
742
|
-
} from "@struktoai/mirage-core";
|
|
743
|
-
|
|
744
|
-
// src/core/disk/exists.ts
|
|
745
|
-
import { access } from "fs/promises";
|
|
746
|
-
async function exists(accessor, path9) {
|
|
747
|
-
const full = resolveSafe(accessor.root, path9.stripPrefix);
|
|
748
|
-
try {
|
|
749
|
-
await access(full);
|
|
750
|
-
return true;
|
|
751
|
-
} catch {
|
|
752
|
-
return false;
|
|
753
|
-
}
|
|
754
|
-
}
|
|
755
|
-
|
|
756
|
-
// src/commands/builtin/disk/ln.ts
|
|
757
|
-
var ENC = new TextEncoder();
|
|
758
|
-
async function lnCommand(accessor, paths, texts, opts) {
|
|
759
|
-
if (paths.length < 2) {
|
|
760
|
-
return [
|
|
761
|
-
null,
|
|
762
|
-
new IOResult2({ exitCode: 1, stderr: ENC.encode("ln: usage: ln [-s] [-f] source dest\n") })
|
|
763
|
-
];
|
|
764
|
-
}
|
|
765
|
-
const source = paths[0];
|
|
766
|
-
const dest = paths[1];
|
|
767
|
-
if (source === void 0 || dest === void 0) return [null, new IOResult2()];
|
|
768
|
-
if (opts.flags.n === true && await exists(accessor, dest)) {
|
|
769
|
-
return [null, new IOResult2()];
|
|
770
|
-
}
|
|
771
|
-
const data = await materialize(stream(accessor, source));
|
|
772
|
-
await writeBytes(accessor, dest, data);
|
|
773
|
-
const out = opts.flags.v === true ? ENC.encode(`'${source.original}' -> '${dest.original}'
|
|
774
|
-
`) : null;
|
|
775
|
-
return [out, new IOResult2({ writes: { [dest.stripPrefix]: data } })];
|
|
776
|
-
}
|
|
777
|
-
var DISK_LN = command26({
|
|
778
|
-
name: "ln",
|
|
779
|
-
resource: ResourceName29.DISK,
|
|
780
|
-
spec: specOf26("ln"),
|
|
781
|
-
fn: lnCommand,
|
|
782
|
-
write: true
|
|
783
|
-
});
|
|
784
|
-
|
|
785
|
-
// src/commands/builtin/disk/look.ts
|
|
786
|
-
import { ResourceName as ResourceName30, command as command27, specOf as specOf27, lookGeneric } from "@struktoai/mirage-core";
|
|
787
|
-
var DISK_LOOK = command27({
|
|
788
|
-
name: "look",
|
|
789
|
-
resource: ResourceName30.DISK,
|
|
790
|
-
spec: specOf27("look"),
|
|
791
|
-
fn: (accessor, paths, texts, opts) => lookGeneric(paths, texts, opts, (p) => stream(accessor, p))
|
|
792
|
-
});
|
|
793
|
-
|
|
794
|
-
// src/commands/builtin/disk/ls/ls.ts
|
|
795
|
-
import { ResourceName as ResourceName31, command as command28, lsGeneric, specOf as specOf28 } from "@struktoai/mirage-core";
|
|
796
|
-
var DISK_LS = command28({
|
|
797
|
-
name: "ls",
|
|
798
|
-
resource: ResourceName31.DISK,
|
|
799
|
-
spec: specOf28("ls"),
|
|
800
|
-
fn: (accessor, paths, _texts, opts) => lsGeneric(
|
|
801
|
-
paths,
|
|
802
|
-
opts,
|
|
803
|
-
(p) => readdir3(accessor, p),
|
|
804
|
-
(p) => stat(accessor, p)
|
|
805
|
-
)
|
|
806
|
-
});
|
|
807
|
-
|
|
808
|
-
// src/commands/builtin/disk/md5.ts
|
|
809
|
-
import { ResourceName as ResourceName32, command as command29, specOf as specOf29, md5Generic } from "@struktoai/mirage-core";
|
|
810
|
-
var DISK_MD5 = command29({
|
|
811
|
-
name: "md5",
|
|
812
|
-
resource: ResourceName32.DISK,
|
|
813
|
-
spec: specOf29("md5"),
|
|
814
|
-
fn: (accessor, paths, _texts, opts) => md5Generic(paths, opts, (p) => stream(accessor, p))
|
|
815
|
-
});
|
|
816
|
-
|
|
817
|
-
// src/commands/builtin/disk/mkdir.ts
|
|
818
|
-
import {
|
|
819
|
-
IOResult as IOResult3,
|
|
820
|
-
ResourceName as ResourceName33,
|
|
821
|
-
command as command30,
|
|
822
|
-
specOf as specOf30
|
|
823
|
-
} from "@struktoai/mirage-core";
|
|
824
|
-
|
|
825
|
-
// src/core/disk/mkdir.ts
|
|
826
|
-
import { mkdir as fsMkdir } from "fs/promises";
|
|
827
|
-
async function mkdir3(accessor, path9, parents = false) {
|
|
828
|
-
const full = resolveSafe(accessor.root, path9.stripPrefix);
|
|
829
|
-
if (parents) {
|
|
830
|
-
await fsMkdir(full, { recursive: true });
|
|
831
|
-
return;
|
|
832
|
-
}
|
|
833
|
-
try {
|
|
834
|
-
await fsMkdir(full);
|
|
835
|
-
} catch (err) {
|
|
836
|
-
const code = err.code;
|
|
837
|
-
if (code === "EEXIST") return;
|
|
838
|
-
if (code === "ENOENT") {
|
|
839
|
-
throw new Error(`parent directory does not exist: ${path9.stripPrefix}`);
|
|
840
|
-
}
|
|
841
|
-
throw err;
|
|
842
|
-
}
|
|
843
|
-
}
|
|
844
|
-
|
|
845
|
-
// src/commands/builtin/disk/mkdir.ts
|
|
846
|
-
async function mkdirCommand(accessor, paths, _texts, opts) {
|
|
847
|
-
const parents = opts.flags.p === true;
|
|
848
|
-
const verbose = opts.flags.v === true;
|
|
849
|
-
if (paths.length === 0) {
|
|
850
|
-
return [
|
|
851
|
-
null,
|
|
852
|
-
new IOResult3({
|
|
853
|
-
exitCode: 1,
|
|
854
|
-
stderr: new TextEncoder().encode("mkdir: missing operand\n")
|
|
855
|
-
})
|
|
856
|
-
];
|
|
857
|
-
}
|
|
858
|
-
const lines = [];
|
|
859
|
-
for (const p of paths) {
|
|
860
|
-
await mkdir3(accessor, p, parents);
|
|
861
|
-
if (verbose) lines.push(`mkdir: created directory '${p.original}'`);
|
|
862
|
-
}
|
|
863
|
-
const out = lines.length > 0 ? new TextEncoder().encode(lines.join("\n") + "\n") : null;
|
|
864
|
-
return [out, new IOResult3()];
|
|
865
|
-
}
|
|
866
|
-
var DISK_MKDIR = command30({
|
|
867
|
-
name: "mkdir",
|
|
868
|
-
resource: ResourceName33.DISK,
|
|
869
|
-
spec: specOf30("mkdir"),
|
|
870
|
-
fn: mkdirCommand,
|
|
871
|
-
write: true
|
|
872
|
-
});
|
|
873
|
-
|
|
874
|
-
// src/commands/builtin/disk/mktemp.ts
|
|
875
|
-
import { ResourceName as ResourceName34, command as command31, mktempGeneric, specOf as specOf31 } from "@struktoai/mirage-core";
|
|
876
|
-
var DISK_MKTEMP = command31({
|
|
877
|
-
name: "mktemp",
|
|
878
|
-
resource: ResourceName34.DISK,
|
|
879
|
-
spec: specOf31("mktemp"),
|
|
880
|
-
fn: (accessor, _paths, texts, opts) => mktempGeneric(
|
|
881
|
-
texts,
|
|
882
|
-
opts,
|
|
883
|
-
(p, parents) => mkdir3(accessor, p, parents),
|
|
884
|
-
(p, d) => writeBytes(accessor, p, d)
|
|
885
|
-
),
|
|
886
|
-
write: true
|
|
887
|
-
});
|
|
888
|
-
|
|
889
|
-
// src/commands/builtin/disk/mv.ts
|
|
890
|
-
import {
|
|
891
|
-
IOResult as IOResult4,
|
|
892
|
-
ResourceName as ResourceName35,
|
|
893
|
-
command as command32,
|
|
894
|
-
mvGeneric,
|
|
895
|
-
specOf as specOf32
|
|
896
|
-
} from "@struktoai/mirage-core";
|
|
897
|
-
|
|
898
|
-
// src/core/disk/rename.ts
|
|
899
|
-
import { rename as fsRename } from "fs/promises";
|
|
900
|
-
import { enoent as enoent5 } from "@struktoai/mirage-core";
|
|
901
|
-
async function rename(accessor, src, dst) {
|
|
902
|
-
const s = resolveSafe(accessor.root, src.stripPrefix);
|
|
903
|
-
const d = resolveSafe(accessor.root, dst.stripPrefix);
|
|
904
|
-
try {
|
|
905
|
-
await fsRename(s, d);
|
|
906
|
-
} catch (err) {
|
|
907
|
-
if (err.code === "ENOENT") {
|
|
908
|
-
throw enoent5(src);
|
|
909
|
-
}
|
|
910
|
-
throw err;
|
|
911
|
-
}
|
|
912
|
-
}
|
|
913
|
-
|
|
914
|
-
// src/commands/builtin/disk/mv.ts
|
|
915
|
-
function mvCommand(accessor, paths, _texts, opts) {
|
|
916
|
-
if (paths.length < 2) {
|
|
917
|
-
return Promise.resolve([
|
|
918
|
-
null,
|
|
919
|
-
new IOResult4({ exitCode: 1, stderr: new TextEncoder().encode("mv: missing operand\n") })
|
|
920
|
-
]);
|
|
921
|
-
}
|
|
922
|
-
return mvGeneric(
|
|
923
|
-
paths,
|
|
924
|
-
(src, target) => rename(accessor, src, target),
|
|
925
|
-
(p) => stat(accessor, p),
|
|
926
|
-
opts.flags.n === true,
|
|
927
|
-
opts.flags.v === true,
|
|
928
|
-
opts.index ?? void 0
|
|
929
|
-
);
|
|
930
|
-
}
|
|
931
|
-
var DISK_MV = command32({
|
|
932
|
-
name: "mv",
|
|
933
|
-
resource: ResourceName35.DISK,
|
|
934
|
-
spec: specOf32("mv"),
|
|
935
|
-
fn: mvCommand,
|
|
936
|
-
write: true
|
|
937
|
-
});
|
|
938
|
-
|
|
939
|
-
// src/commands/builtin/disk/nl.ts
|
|
940
|
-
import { ResourceName as ResourceName36, command as command33, specOf as specOf33, nlGeneric } from "@struktoai/mirage-core";
|
|
941
|
-
var DISK_NL = command33({
|
|
942
|
-
name: "nl",
|
|
943
|
-
resource: ResourceName36.DISK,
|
|
944
|
-
spec: specOf33("nl"),
|
|
945
|
-
fn: (accessor, paths, _texts, opts) => nlGeneric(paths, opts, (p) => stream(accessor, p))
|
|
946
|
-
});
|
|
947
|
-
|
|
948
|
-
// src/commands/builtin/disk/paste.ts
|
|
949
|
-
import { ResourceName as ResourceName37, command as command34, specOf as specOf34, pasteGeneric } from "@struktoai/mirage-core";
|
|
950
|
-
var DISK_PASTE = command34({
|
|
951
|
-
name: "paste",
|
|
952
|
-
resource: ResourceName37.DISK,
|
|
953
|
-
spec: specOf34("paste"),
|
|
954
|
-
fn: (accessor, paths, _texts, opts) => pasteGeneric(paths, opts, (p) => stream(accessor, p))
|
|
955
|
-
});
|
|
956
|
-
|
|
957
|
-
// src/commands/builtin/disk/patch.ts
|
|
958
|
-
import { ResourceName as ResourceName38, command as command35, specOf as specOf35, patchGeneric } from "@struktoai/mirage-core";
|
|
959
|
-
var DISK_PATCH = command35({
|
|
960
|
-
name: "patch",
|
|
961
|
-
resource: ResourceName38.DISK,
|
|
962
|
-
spec: specOf35("patch"),
|
|
963
|
-
fn: (accessor, paths, _texts, opts) => patchGeneric(
|
|
964
|
-
paths,
|
|
965
|
-
opts,
|
|
966
|
-
(p) => stream(accessor, p),
|
|
967
|
-
(p, d) => writeBytes(accessor, p, d)
|
|
968
|
-
),
|
|
969
|
-
write: true
|
|
970
|
-
});
|
|
971
|
-
|
|
972
|
-
// src/commands/builtin/disk/readlink.ts
|
|
973
|
-
import {
|
|
974
|
-
ResourceName as ResourceName39,
|
|
975
|
-
command as command36,
|
|
976
|
-
readlinkGeneric,
|
|
977
|
-
specOf as specOf36
|
|
978
|
-
} from "@struktoai/mirage-core";
|
|
979
|
-
var DISK_READLINK = command36({
|
|
980
|
-
name: "readlink",
|
|
981
|
-
resource: ResourceName39.DISK,
|
|
982
|
-
spec: specOf36("readlink"),
|
|
983
|
-
fn: (_accessor, paths, texts, opts) => readlinkGeneric(paths, texts, opts)
|
|
984
|
-
});
|
|
985
|
-
|
|
986
|
-
// src/commands/builtin/disk/realpath.ts
|
|
987
|
-
import { ResourceName as ResourceName40, command as command37, realpathGeneric, specOf as specOf37 } from "@struktoai/mirage-core";
|
|
988
|
-
var DISK_REALPATH = command37({
|
|
989
|
-
name: "realpath",
|
|
990
|
-
resource: ResourceName40.DISK,
|
|
991
|
-
spec: specOf37("realpath"),
|
|
992
|
-
fn: (accessor, paths, texts, opts) => realpathGeneric(paths, texts, opts, (p) => stat(accessor, p))
|
|
993
|
-
});
|
|
994
|
-
|
|
995
|
-
// src/commands/builtin/disk/rev.ts
|
|
996
|
-
import { ResourceName as ResourceName41, command as command38, specOf as specOf38, revGeneric } from "@struktoai/mirage-core";
|
|
997
|
-
var DISK_REV = command38({
|
|
998
|
-
name: "rev",
|
|
999
|
-
resource: ResourceName41.DISK,
|
|
1000
|
-
spec: specOf38("rev"),
|
|
1001
|
-
fn: (accessor, paths, _texts, opts) => revGeneric(paths, opts, (p) => stream(accessor, p))
|
|
1002
|
-
});
|
|
1003
|
-
|
|
1004
|
-
// src/commands/builtin/disk/rg.ts
|
|
1005
|
-
import { ResourceName as ResourceName42, command as command39, rgGeneric, specOf as specOf39 } from "@struktoai/mirage-core";
|
|
1006
|
-
var DISK_RG = command39({
|
|
1007
|
-
name: "rg",
|
|
1008
|
-
resource: ResourceName42.DISK,
|
|
1009
|
-
spec: specOf39("rg"),
|
|
1010
|
-
fn: (accessor, paths, texts, opts) => rgGeneric(
|
|
1011
|
-
paths,
|
|
1012
|
-
texts,
|
|
1013
|
-
opts,
|
|
1014
|
-
(p) => stat(accessor, p),
|
|
1015
|
-
(p) => readdir3(accessor, p),
|
|
1016
|
-
(p) => stream(accessor, p)
|
|
1017
|
-
)
|
|
1018
|
-
});
|
|
1019
|
-
|
|
1020
|
-
// src/commands/builtin/disk/rm.ts
|
|
1021
|
-
import {
|
|
1022
|
-
FileType as FileType2,
|
|
1023
|
-
IOResult as IOResult5,
|
|
1024
|
-
ResourceName as ResourceName43,
|
|
1025
|
-
command as command40,
|
|
1026
|
-
specOf as specOf40,
|
|
1027
|
-
formatRecords
|
|
1028
|
-
} from "@struktoai/mirage-core";
|
|
1029
|
-
|
|
1030
|
-
// src/core/disk/rmdir.ts
|
|
1031
|
-
import { rmdir as fsRmdir } from "fs/promises";
|
|
1032
|
-
async function rmdir(accessor, path9) {
|
|
1033
|
-
const full = resolveSafe(accessor.root, path9.stripPrefix);
|
|
1034
|
-
try {
|
|
1035
|
-
await fsRmdir(full);
|
|
1036
|
-
} catch (err) {
|
|
1037
|
-
if (err.code === "ENOENT") return;
|
|
1038
|
-
throw err;
|
|
1039
|
-
}
|
|
1040
|
-
}
|
|
1041
|
-
|
|
1042
|
-
// src/core/disk/rm.ts
|
|
1043
|
-
import { rm } from "fs/promises";
|
|
1044
|
-
async function rmR(accessor, path9) {
|
|
1045
|
-
const full = resolveSafe(accessor.root, path9.stripPrefix);
|
|
1046
|
-
await rm(full, { recursive: true, force: true });
|
|
1047
|
-
}
|
|
1048
|
-
|
|
1049
|
-
// src/commands/builtin/disk/rm.ts
|
|
1050
|
-
async function rmCommand(accessor, paths, _texts, opts) {
|
|
1051
|
-
if (paths.length === 0) {
|
|
1052
|
-
return [
|
|
1053
|
-
null,
|
|
1054
|
-
new IOResult5({
|
|
1055
|
-
exitCode: 1,
|
|
1056
|
-
stderr: new TextEncoder().encode("rm: missing operand\n")
|
|
1057
|
-
})
|
|
1058
|
-
];
|
|
1059
|
-
}
|
|
1060
|
-
const recursive = opts.flags.r === true || opts.flags.R === true;
|
|
1061
|
-
const force = opts.flags.f === true;
|
|
1062
|
-
const verbose = opts.flags.v === true;
|
|
1063
|
-
const lines = [];
|
|
1064
|
-
for (const p of paths) {
|
|
1065
|
-
let isDir = false;
|
|
1066
|
-
try {
|
|
1067
|
-
const st = await stat(accessor, p);
|
|
1068
|
-
isDir = st.type === FileType2.DIRECTORY;
|
|
1069
|
-
} catch {
|
|
1070
|
-
if (force) continue;
|
|
1071
|
-
throw new Error(`rm: cannot remove '${p.original}': No such file or directory`);
|
|
1072
|
-
}
|
|
1073
|
-
if (isDir) {
|
|
1074
|
-
if (recursive) {
|
|
1075
|
-
await rmR(accessor, p);
|
|
1076
|
-
} else {
|
|
1077
|
-
await rmdir(accessor, p);
|
|
1078
|
-
}
|
|
1079
|
-
} else {
|
|
1080
|
-
await unlink(accessor, p);
|
|
1081
|
-
}
|
|
1082
|
-
if (verbose) lines.push(`removed '${p.original}'`);
|
|
1083
|
-
}
|
|
1084
|
-
const out = lines.length > 0 ? formatRecords(lines) : null;
|
|
1085
|
-
return [out, new IOResult5()];
|
|
1086
|
-
}
|
|
1087
|
-
var DISK_RM = command40({
|
|
1088
|
-
name: "rm",
|
|
1089
|
-
resource: ResourceName43.DISK,
|
|
1090
|
-
spec: specOf40("rm"),
|
|
1091
|
-
fn: rmCommand,
|
|
1092
|
-
write: true
|
|
1093
|
-
});
|
|
1094
|
-
|
|
1095
|
-
// src/commands/builtin/disk/sed.ts
|
|
1096
|
-
import { ResourceName as ResourceName44, command as command41, specOf as specOf41, sedGeneric } from "@struktoai/mirage-core";
|
|
1097
|
-
var DISK_SED = command41({
|
|
1098
|
-
name: "sed",
|
|
1099
|
-
resource: ResourceName44.DISK,
|
|
1100
|
-
spec: specOf41("sed"),
|
|
1101
|
-
fn: (accessor, paths, texts, opts) => sedGeneric(
|
|
1102
|
-
paths,
|
|
1103
|
-
texts,
|
|
1104
|
-
opts,
|
|
1105
|
-
(p) => stream(accessor, p),
|
|
1106
|
-
(p, d) => writeBytes(accessor, p, d)
|
|
1107
|
-
)
|
|
1108
|
-
});
|
|
1109
|
-
|
|
1110
|
-
// src/commands/builtin/disk/sha256sum.ts
|
|
1111
|
-
import { ResourceName as ResourceName45, command as command42, sha256sumGeneric, specOf as specOf42 } from "@struktoai/mirage-core";
|
|
1112
|
-
var DISK_SHA256SUM = command42({
|
|
1113
|
-
name: "sha256sum",
|
|
1114
|
-
resource: ResourceName45.DISK,
|
|
1115
|
-
spec: specOf42("sha256sum"),
|
|
1116
|
-
fn: (accessor, paths, _texts, opts) => sha256sumGeneric(paths, opts, (p) => stream(accessor, p))
|
|
1117
|
-
});
|
|
1118
|
-
|
|
1119
|
-
// src/commands/builtin/disk/shuf.ts
|
|
1120
|
-
import { ResourceName as ResourceName46, command as command43, specOf as specOf43, shufGeneric } from "@struktoai/mirage-core";
|
|
1121
|
-
var DISK_SHUF = command43({
|
|
1122
|
-
name: "shuf",
|
|
1123
|
-
resource: ResourceName46.DISK,
|
|
1124
|
-
spec: specOf43("shuf"),
|
|
1125
|
-
fn: (accessor, paths, texts, opts) => shufGeneric(paths, texts, opts, (p) => stream(accessor, p))
|
|
1126
|
-
});
|
|
1127
|
-
|
|
1128
|
-
// src/commands/builtin/disk/sort.ts
|
|
1129
|
-
import { ResourceName as ResourceName47, command as command44, specOf as specOf44, sortGeneric } from "@struktoai/mirage-core";
|
|
1130
|
-
var DISK_SORT = command44({
|
|
1131
|
-
name: "sort",
|
|
1132
|
-
resource: ResourceName47.DISK,
|
|
1133
|
-
spec: specOf44("sort"),
|
|
1134
|
-
fn: (accessor, paths, _texts, opts) => sortGeneric(paths, opts, (p) => stream(accessor, p))
|
|
1135
|
-
});
|
|
1136
|
-
|
|
1137
|
-
// src/commands/builtin/disk/split.ts
|
|
1138
|
-
import { ResourceName as ResourceName48, command as command45, specOf as specOf45, splitGeneric } from "@struktoai/mirage-core";
|
|
1139
|
-
var DISK_SPLIT = command45({
|
|
1140
|
-
name: "split",
|
|
1141
|
-
resource: ResourceName48.DISK,
|
|
1142
|
-
spec: specOf45("split"),
|
|
1143
|
-
fn: (accessor, paths, _texts, opts) => splitGeneric(
|
|
1144
|
-
paths,
|
|
1145
|
-
opts,
|
|
1146
|
-
(p) => stream(accessor, p),
|
|
1147
|
-
(p, d) => writeBytes(accessor, p, d)
|
|
1148
|
-
),
|
|
1149
|
-
write: true
|
|
1150
|
-
});
|
|
1151
|
-
|
|
1152
|
-
// src/commands/builtin/disk/stat/stat.ts
|
|
1153
|
-
import {
|
|
1154
|
-
ResourceName as ResourceName49,
|
|
1155
|
-
command as command46,
|
|
1156
|
-
specOf as specOf46,
|
|
1157
|
-
statGeneric,
|
|
1158
|
-
statProvisionGeneric
|
|
1159
|
-
} from "@struktoai/mirage-core";
|
|
1160
|
-
var DISK_STAT = command46({
|
|
1161
|
-
name: "stat",
|
|
1162
|
-
resource: ResourceName49.DISK,
|
|
1163
|
-
spec: specOf46("stat"),
|
|
1164
|
-
fn: (accessor, paths, _texts, opts) => statGeneric(paths, opts, (p) => stat(accessor, p)),
|
|
1165
|
-
provision: statProvisionGeneric
|
|
1166
|
-
});
|
|
1167
|
-
|
|
1168
|
-
// src/commands/builtin/disk/strings.ts
|
|
1169
|
-
import { ResourceName as ResourceName50, command as command47, specOf as specOf47, stringsGeneric } from "@struktoai/mirage-core";
|
|
1170
|
-
var DISK_STRINGS = command47({
|
|
1171
|
-
name: "strings",
|
|
1172
|
-
resource: ResourceName50.DISK,
|
|
1173
|
-
spec: specOf47("strings"),
|
|
1174
|
-
fn: (accessor, paths, _texts, opts) => stringsGeneric(paths, opts, (p) => stream(accessor, p))
|
|
1175
|
-
});
|
|
1176
|
-
|
|
1177
|
-
// src/commands/builtin/disk/tac.ts
|
|
1178
|
-
import { ResourceName as ResourceName51, command as command48, specOf as specOf48, tacGeneric } from "@struktoai/mirage-core";
|
|
1179
|
-
var DISK_TAC = command48({
|
|
1180
|
-
name: "tac",
|
|
1181
|
-
resource: ResourceName51.DISK,
|
|
1182
|
-
spec: specOf48("tac"),
|
|
1183
|
-
fn: (accessor, paths, _texts, opts) => tacGeneric(paths, opts, (p) => stream(accessor, p))
|
|
1184
|
-
});
|
|
1185
|
-
|
|
1186
|
-
// src/commands/builtin/disk/tail/tail.ts
|
|
1187
|
-
import { ResourceName as ResourceName52, command as command49, headerAggregate as headerAggregate2, specOf as specOf49, tailGeneric } from "@struktoai/mirage-core";
|
|
1188
|
-
var DISK_TAIL = command49({
|
|
1189
|
-
name: "tail",
|
|
1190
|
-
resource: ResourceName52.DISK,
|
|
1191
|
-
spec: specOf49("tail"),
|
|
1192
|
-
fn: (accessor, paths, texts, opts) => tailGeneric(paths, texts, opts, (p) => stream(accessor, p)),
|
|
1193
|
-
aggregate: headerAggregate2
|
|
1194
|
-
});
|
|
1195
|
-
|
|
1196
|
-
// src/commands/builtin/disk/tar.ts
|
|
1197
|
-
import { ResourceName as ResourceName53, command as command50, specOf as specOf50, tarGeneric } from "@struktoai/mirage-core";
|
|
1198
|
-
var DISK_TAR = command50({
|
|
1199
|
-
name: "tar",
|
|
1200
|
-
resource: ResourceName53.DISK,
|
|
1201
|
-
spec: specOf50("tar"),
|
|
1202
|
-
fn: (accessor, paths, _texts, opts) => tarGeneric(
|
|
1203
|
-
paths,
|
|
1204
|
-
opts,
|
|
1205
|
-
(p) => stream(accessor, p),
|
|
1206
|
-
(p, data) => writeBytes(accessor, p, data),
|
|
1207
|
-
(p) => mkdir3(accessor, p)
|
|
1208
|
-
),
|
|
1209
|
-
write: true
|
|
1210
|
-
});
|
|
1211
|
-
|
|
1212
|
-
// src/commands/builtin/disk/tee.ts
|
|
1213
|
-
import { ResourceName as ResourceName54, command as command51, specOf as specOf51, teeGeneric } from "@struktoai/mirage-core";
|
|
1214
|
-
var DISK_TEE = command51({
|
|
1215
|
-
name: "tee",
|
|
1216
|
-
resource: ResourceName54.DISK,
|
|
1217
|
-
spec: specOf51("tee"),
|
|
1218
|
-
fn: (accessor, paths, texts, opts) => teeGeneric(
|
|
1219
|
-
paths,
|
|
1220
|
-
texts,
|
|
1221
|
-
opts,
|
|
1222
|
-
(p) => stream(accessor, p),
|
|
1223
|
-
(p, d) => writeBytes(accessor, p, d)
|
|
1224
|
-
),
|
|
1225
|
-
write: true
|
|
1226
|
-
});
|
|
1227
|
-
|
|
1228
|
-
// src/commands/builtin/disk/touch.ts
|
|
1229
|
-
import {
|
|
1230
|
-
IOResult as IOResult6,
|
|
1231
|
-
ResourceName as ResourceName55,
|
|
1232
|
-
command as command52,
|
|
1233
|
-
specOf as specOf52
|
|
1234
|
-
} from "@struktoai/mirage-core";
|
|
1235
|
-
var ENC2 = new TextEncoder();
|
|
1236
|
-
async function touchCommand(accessor, paths, texts, opts) {
|
|
1237
|
-
if (paths.length === 0) {
|
|
1238
|
-
return [null, new IOResult6({ exitCode: 1, stderr: ENC2.encode("touch: missing operand\n") })];
|
|
1239
|
-
}
|
|
1240
|
-
const createOnly = opts.flags.c === true;
|
|
1241
|
-
for (const p of paths) {
|
|
1242
|
-
if (createOnly) continue;
|
|
1243
|
-
if (!await exists(accessor, p)) {
|
|
1244
|
-
await writeBytes(accessor, p, new Uint8Array(0));
|
|
1245
|
-
}
|
|
1246
|
-
}
|
|
1247
|
-
return [null, new IOResult6()];
|
|
1248
|
-
}
|
|
1249
|
-
var DISK_TOUCH = command52({
|
|
1250
|
-
name: "touch",
|
|
1251
|
-
resource: ResourceName55.DISK,
|
|
1252
|
-
spec: specOf52("touch"),
|
|
1253
|
-
fn: touchCommand,
|
|
1254
|
-
write: true
|
|
1255
|
-
});
|
|
1256
|
-
|
|
1257
|
-
// src/commands/builtin/disk/tr.ts
|
|
1258
|
-
import { ResourceName as ResourceName56, command as command53, specOf as specOf53, trGeneric } from "@struktoai/mirage-core";
|
|
1259
|
-
var DISK_TR = command53({
|
|
1260
|
-
name: "tr",
|
|
1261
|
-
resource: ResourceName56.DISK,
|
|
1262
|
-
spec: specOf53("tr"),
|
|
1263
|
-
fn: (accessor, paths, texts, opts) => trGeneric(paths, texts, opts, (p) => stream(accessor, p))
|
|
1264
|
-
});
|
|
1265
|
-
|
|
1266
|
-
// src/commands/builtin/disk/tree.ts
|
|
1267
|
-
import { ResourceName as ResourceName57, command as command54, specOf as specOf54, treeGeneric } from "@struktoai/mirage-core";
|
|
1268
|
-
var DISK_TREE = command54({
|
|
1269
|
-
name: "tree",
|
|
1270
|
-
resource: ResourceName57.DISK,
|
|
1271
|
-
spec: specOf54("tree"),
|
|
1272
|
-
fn: (accessor, paths, _texts, opts) => treeGeneric(
|
|
1273
|
-
paths,
|
|
1274
|
-
opts,
|
|
1275
|
-
(p) => readdir3(accessor, p),
|
|
1276
|
-
(p) => stat(accessor, p)
|
|
1277
|
-
)
|
|
1278
|
-
});
|
|
1279
|
-
|
|
1280
|
-
// src/commands/builtin/disk/tsort.ts
|
|
1281
|
-
import { ResourceName as ResourceName58, command as command55, specOf as specOf55, tsortGeneric } from "@struktoai/mirage-core";
|
|
1282
|
-
var DISK_TSORT = command55({
|
|
1283
|
-
name: "tsort",
|
|
1284
|
-
resource: ResourceName58.DISK,
|
|
1285
|
-
spec: specOf55("tsort"),
|
|
1286
|
-
fn: (accessor, paths, _texts, opts) => tsortGeneric(paths, opts, (p) => stream(accessor, p))
|
|
1287
|
-
});
|
|
1288
|
-
|
|
1289
|
-
// src/commands/builtin/disk/unexpand.ts
|
|
1290
|
-
import { ResourceName as ResourceName59, command as command56, specOf as specOf56, unexpandGeneric } from "@struktoai/mirage-core";
|
|
1291
|
-
var DISK_UNEXPAND = command56({
|
|
1292
|
-
name: "unexpand",
|
|
1293
|
-
resource: ResourceName59.DISK,
|
|
1294
|
-
spec: specOf56("unexpand"),
|
|
1295
|
-
fn: (accessor, paths, _texts, opts) => unexpandGeneric(paths, opts, (p) => stream(accessor, p))
|
|
1296
|
-
});
|
|
1297
|
-
|
|
1298
|
-
// src/commands/builtin/disk/uniq.ts
|
|
1299
|
-
import { ResourceName as ResourceName60, command as command57, specOf as specOf57, uniqGeneric } from "@struktoai/mirage-core";
|
|
1300
|
-
var DISK_UNIQ = command57({
|
|
1301
|
-
name: "uniq",
|
|
1302
|
-
resource: ResourceName60.DISK,
|
|
1303
|
-
spec: specOf57("uniq"),
|
|
1304
|
-
fn: (accessor, paths, _texts, opts) => uniqGeneric(paths, opts, (p) => stream(accessor, p))
|
|
1305
|
-
});
|
|
1306
|
-
|
|
1307
|
-
// src/commands/builtin/disk/unzip.ts
|
|
1308
|
-
import { ResourceName as ResourceName61, command as command58, specOf as specOf58, unzipGeneric } from "@struktoai/mirage-core";
|
|
1309
|
-
var DISK_UNZIP = command58({
|
|
1310
|
-
name: "unzip",
|
|
1311
|
-
resource: ResourceName61.DISK,
|
|
1312
|
-
spec: specOf58("unzip"),
|
|
1313
|
-
fn: (accessor, paths, _texts, opts) => unzipGeneric(
|
|
1314
|
-
paths,
|
|
1315
|
-
opts,
|
|
1316
|
-
(p) => stream(accessor, p),
|
|
1317
|
-
(p, d) => writeBytes(accessor, p, d),
|
|
1318
|
-
(p, parents) => mkdir3(accessor, p, parents)
|
|
1319
|
-
),
|
|
1320
|
-
write: true
|
|
1321
|
-
});
|
|
1322
|
-
|
|
1323
|
-
// src/commands/builtin/disk/wc/wc.ts
|
|
1324
|
-
import { ResourceName as ResourceName62, command as command59, specOf as specOf59, wcAggregate, wcGeneric } from "@struktoai/mirage-core";
|
|
1325
|
-
var DISK_WC = command59({
|
|
1326
|
-
name: "wc",
|
|
1327
|
-
resource: ResourceName62.DISK,
|
|
1328
|
-
spec: specOf59("wc"),
|
|
1329
|
-
fn: (accessor, paths, texts, opts) => wcGeneric(paths, texts, opts, (p) => stream(accessor, p)),
|
|
1330
|
-
aggregate: wcAggregate
|
|
1331
|
-
});
|
|
1332
|
-
|
|
1333
|
-
// src/commands/builtin/disk/xxd.ts
|
|
1334
|
-
import { ResourceName as ResourceName63, command as command60, specOf as specOf60, xxdGeneric } from "@struktoai/mirage-core";
|
|
1335
|
-
var DISK_XXD = command60({
|
|
1336
|
-
name: "xxd",
|
|
1337
|
-
resource: ResourceName63.DISK,
|
|
1338
|
-
spec: specOf60("xxd"),
|
|
1339
|
-
fn: (accessor, paths, _texts, opts) => xxdGeneric(paths, opts, (p) => stream(accessor, p))
|
|
1340
|
-
});
|
|
1341
|
-
|
|
1342
|
-
// src/commands/builtin/disk/zcat.ts
|
|
1343
|
-
import { ResourceName as ResourceName64, command as command61, specOf as specOf61, zcatGeneric } from "@struktoai/mirage-core";
|
|
1344
|
-
var DISK_ZCAT = command61({
|
|
1345
|
-
name: "zcat",
|
|
1346
|
-
resource: ResourceName64.DISK,
|
|
1347
|
-
spec: specOf61("zcat"),
|
|
1348
|
-
fn: (accessor, paths, _texts, opts) => zcatGeneric(paths, opts, (p) => stream(accessor, p))
|
|
1349
|
-
});
|
|
1350
|
-
|
|
1351
|
-
// src/commands/builtin/disk/zgrep.ts
|
|
1352
|
-
import { ResourceName as ResourceName65, command as command62, specOf as specOf62, zgrepGeneric } from "@struktoai/mirage-core";
|
|
1353
|
-
var DISK_ZGREP = command62({
|
|
1354
|
-
name: "zgrep",
|
|
1355
|
-
resource: ResourceName65.DISK,
|
|
1356
|
-
spec: specOf62("zgrep"),
|
|
1357
|
-
fn: (accessor, paths, texts, opts) => zgrepGeneric(paths, texts, opts, (p) => stream(accessor, p))
|
|
1358
|
-
});
|
|
1359
|
-
|
|
1360
|
-
// src/commands/builtin/disk/zip_cmd.ts
|
|
1361
|
-
import { ResourceName as ResourceName66, command as command63, specOf as specOf63, zipGeneric } from "@struktoai/mirage-core";
|
|
1362
|
-
var DISK_ZIP = command63({
|
|
1363
|
-
name: "zip",
|
|
1364
|
-
resource: ResourceName66.DISK,
|
|
1365
|
-
spec: specOf63("zip"),
|
|
1366
|
-
fn: (accessor, paths, _texts, opts) => zipGeneric(
|
|
1367
|
-
paths,
|
|
1368
|
-
opts,
|
|
1369
|
-
(p) => stream(accessor, p),
|
|
1370
|
-
(p, d) => writeBytes(accessor, p, d)
|
|
1371
|
-
),
|
|
1372
|
-
write: true
|
|
1373
|
-
});
|
|
1374
|
-
|
|
1375
|
-
// src/commands/builtin/disk/index.ts
|
|
1376
|
-
var DISK_COMMANDS = [
|
|
1377
|
-
...makeFiletypeCommands({
|
|
1378
|
-
resource: ResourceName67.DISK,
|
|
1379
|
-
readBytes: read,
|
|
1380
|
-
statEntry: stat
|
|
1381
|
-
}),
|
|
1382
|
-
...DISK_AWK,
|
|
1383
|
-
...DISK_BASE64,
|
|
1384
|
-
...DISK_BASENAME,
|
|
1385
|
-
...DISK_CAT,
|
|
1386
|
-
...DISK_CMP,
|
|
1387
|
-
...DISK_COLUMN,
|
|
1388
|
-
...DISK_COMM,
|
|
1389
|
-
...DISK_CP,
|
|
1390
|
-
...DISK_CSPLIT,
|
|
1391
|
-
...DISK_CUT,
|
|
1392
|
-
...DISK_DIFF,
|
|
1393
|
-
...DISK_DIRNAME,
|
|
1394
|
-
...DISK_DU,
|
|
1395
|
-
...DISK_EXPAND,
|
|
1396
|
-
...DISK_FILE,
|
|
1397
|
-
...DISK_FIND,
|
|
1398
|
-
...DISK_FMT,
|
|
1399
|
-
...DISK_FOLD,
|
|
1400
|
-
...DISK_GREP,
|
|
1401
|
-
...DISK_GUNZIP,
|
|
1402
|
-
...DISK_GZIP,
|
|
1403
|
-
...DISK_HEAD,
|
|
1404
|
-
...DISK_ICONV,
|
|
1405
|
-
...DISK_JOIN,
|
|
1406
|
-
...DISK_JQ,
|
|
1407
|
-
...DISK_LN,
|
|
1408
|
-
...DISK_LOOK,
|
|
1409
|
-
...DISK_LS,
|
|
1410
|
-
...DISK_MD5,
|
|
1411
|
-
...DISK_MKDIR,
|
|
1412
|
-
...DISK_MKTEMP,
|
|
1413
|
-
...DISK_MV,
|
|
1414
|
-
...DISK_NL,
|
|
1415
|
-
...DISK_PASTE,
|
|
1416
|
-
...DISK_PATCH,
|
|
1417
|
-
...DISK_READLINK,
|
|
1418
|
-
...DISK_REALPATH,
|
|
1419
|
-
...DISK_REV,
|
|
1420
|
-
...DISK_RG,
|
|
1421
|
-
...DISK_RM,
|
|
1422
|
-
...DISK_SED,
|
|
1423
|
-
...DISK_SHA256SUM,
|
|
1424
|
-
...DISK_SHUF,
|
|
1425
|
-
...DISK_SORT,
|
|
1426
|
-
...DISK_SPLIT,
|
|
1427
|
-
...DISK_STAT,
|
|
1428
|
-
...DISK_STRINGS,
|
|
1429
|
-
...DISK_TAC,
|
|
1430
|
-
...DISK_TAIL,
|
|
1431
|
-
...DISK_TAR,
|
|
1432
|
-
...DISK_TEE,
|
|
1433
|
-
...DISK_TOUCH,
|
|
1434
|
-
...DISK_TR,
|
|
1435
|
-
...DISK_TREE,
|
|
1436
|
-
...DISK_TSORT,
|
|
1437
|
-
...DISK_UNEXPAND,
|
|
1438
|
-
...DISK_UNIQ,
|
|
1439
|
-
...DISK_UNZIP,
|
|
1440
|
-
...DISK_WC,
|
|
1441
|
-
...DISK_XXD,
|
|
1442
|
-
...DISK_ZCAT,
|
|
1443
|
-
...DISK_ZGREP,
|
|
1444
|
-
...DISK_ZIP
|
|
1445
|
-
];
|
|
1446
|
-
|
|
1447
|
-
// src/core/disk/append.ts
|
|
1448
|
-
import { appendFile, mkdir as mkdir4 } from "fs/promises";
|
|
1449
|
-
import path7 from "path";
|
|
1450
|
-
import { record as record3, ResourceName as ResourceName68 } from "@struktoai/mirage-core";
|
|
1451
|
-
async function appendBytes(accessor, p, data) {
|
|
1452
|
-
const start = performance.now();
|
|
1453
|
-
const virtual = p.stripPrefix;
|
|
1454
|
-
const full = resolveSafe(accessor.root, virtual);
|
|
1455
|
-
await mkdir4(path7.dirname(full), { recursive: true });
|
|
1456
|
-
await appendFile(full, data);
|
|
1457
|
-
record3("append", virtual, ResourceName68.DISK, data.byteLength, start);
|
|
1458
|
-
}
|
|
1459
|
-
|
|
1460
|
-
// src/core/disk/create.ts
|
|
1461
|
-
function create(accessor, path9) {
|
|
1462
|
-
return writeBytes(accessor, path9, new Uint8Array());
|
|
1463
|
-
}
|
|
1464
|
-
|
|
1465
|
-
// src/core/disk/glob.ts
|
|
1466
|
-
import { PathSpec } from "@struktoai/mirage-core";
|
|
1467
|
-
import { fnmatch } from "@struktoai/mirage-core";
|
|
1468
|
-
import { gnuBasename as gnuBasename2 } from "@struktoai/mirage-core";
|
|
1469
|
-
async function resolveGlob(accessor, paths, index) {
|
|
1470
|
-
const result = [];
|
|
1471
|
-
for (const p of paths) {
|
|
1472
|
-
if (p.resolved) {
|
|
1473
|
-
result.push(p);
|
|
1474
|
-
} else if (p.pattern !== null) {
|
|
1475
|
-
const dirSpec = new PathSpec({
|
|
1476
|
-
original: p.directory,
|
|
1477
|
-
directory: p.directory,
|
|
1478
|
-
resolved: true,
|
|
1479
|
-
prefix: p.prefix
|
|
1480
|
-
});
|
|
1481
|
-
const entries = await readdir3(accessor, dirSpec, index);
|
|
1482
|
-
const matched = [];
|
|
1483
|
-
for (const e of entries) {
|
|
1484
|
-
if (fnmatch(gnuBasename2(e), p.pattern)) {
|
|
1485
|
-
matched.push(
|
|
1486
|
-
new PathSpec({
|
|
1487
|
-
original: e,
|
|
1488
|
-
directory: p.directory,
|
|
1489
|
-
resolved: true,
|
|
1490
|
-
prefix: p.prefix
|
|
1491
|
-
})
|
|
1492
|
-
);
|
|
1493
|
-
}
|
|
1494
|
-
}
|
|
1495
|
-
if (matched.length > SCOPE_ERROR) matched.length = SCOPE_ERROR;
|
|
1496
|
-
result.push(...matched);
|
|
1497
|
-
} else {
|
|
1498
|
-
result.push(p);
|
|
1499
|
-
}
|
|
1500
|
-
}
|
|
1501
|
-
return result;
|
|
1502
|
-
}
|
|
1503
|
-
|
|
1504
|
-
// src/core/disk/truncate.ts
|
|
1505
|
-
import { readFile as readFile2, writeFile as writeFile2 } from "fs/promises";
|
|
1506
|
-
async function truncate(accessor, path9, length) {
|
|
1507
|
-
const full = resolveSafe(accessor.root, path9.stripPrefix);
|
|
1508
|
-
let data;
|
|
1509
|
-
try {
|
|
1510
|
-
data = await readFile2(full);
|
|
1511
|
-
} catch (err) {
|
|
1512
|
-
if (err.code === "ENOENT") {
|
|
1513
|
-
data = Buffer.alloc(0);
|
|
1514
|
-
} else {
|
|
1515
|
-
throw err;
|
|
1516
|
-
}
|
|
1517
|
-
}
|
|
1518
|
-
const out = new Uint8Array(length);
|
|
1519
|
-
out.set(data.subarray(0, Math.min(data.byteLength, length)));
|
|
1520
|
-
await writeFile2(full, out);
|
|
1521
|
-
}
|
|
1522
|
-
|
|
1523
|
-
// src/accessor/disk.ts
|
|
1524
|
-
import { Accessor } from "@struktoai/mirage-core";
|
|
1525
|
-
var DiskAccessor = class extends Accessor {
|
|
1526
|
-
root;
|
|
1527
|
-
constructor(root) {
|
|
1528
|
-
super();
|
|
1529
|
-
this.root = root;
|
|
1530
|
-
}
|
|
1531
|
-
};
|
|
1532
|
-
|
|
1533
|
-
// src/ops/disk/append.ts
|
|
1534
|
-
import { ResourceName as ResourceName69 } from "@struktoai/mirage-core";
|
|
1535
|
-
var appendOp = {
|
|
1536
|
-
name: "append",
|
|
1537
|
-
resource: ResourceName69.DISK,
|
|
1538
|
-
filetype: null,
|
|
1539
|
-
write: true,
|
|
1540
|
-
fn: (accessor, path9, args) => {
|
|
1541
|
-
const data = args[0];
|
|
1542
|
-
if (!(data instanceof Uint8Array)) {
|
|
1543
|
-
throw new TypeError("append op requires a Uint8Array as the first arg");
|
|
1544
|
-
}
|
|
1545
|
-
return appendBytes(accessor, path9, data);
|
|
1546
|
-
}
|
|
1547
|
-
};
|
|
1548
|
-
|
|
1549
|
-
// src/ops/disk/create.ts
|
|
1550
|
-
import { ResourceName as ResourceName70 } from "@struktoai/mirage-core";
|
|
1551
|
-
var createOp = {
|
|
1552
|
-
name: "create",
|
|
1553
|
-
resource: ResourceName70.DISK,
|
|
1554
|
-
filetype: null,
|
|
1555
|
-
write: true,
|
|
1556
|
-
fn: (accessor, path9) => {
|
|
1557
|
-
return create(accessor, path9);
|
|
1558
|
-
}
|
|
1559
|
-
};
|
|
1560
|
-
|
|
1561
|
-
// src/ops/disk/mkdir.ts
|
|
1562
|
-
import { ResourceName as ResourceName71 } from "@struktoai/mirage-core";
|
|
1563
|
-
var mkdirOp = {
|
|
1564
|
-
name: "mkdir",
|
|
1565
|
-
resource: ResourceName71.DISK,
|
|
1566
|
-
filetype: null,
|
|
1567
|
-
write: true,
|
|
1568
|
-
fn: (accessor, path9) => {
|
|
1569
|
-
return mkdir3(accessor, path9, true);
|
|
1570
|
-
}
|
|
1571
|
-
};
|
|
1572
|
-
|
|
1573
|
-
// src/ops/disk/read.ts
|
|
1574
|
-
import { ResourceName as ResourceName72 } from "@struktoai/mirage-core";
|
|
1575
|
-
var readOp = {
|
|
1576
|
-
name: "read",
|
|
1577
|
-
resource: ResourceName72.DISK,
|
|
1578
|
-
filetype: null,
|
|
1579
|
-
write: false,
|
|
1580
|
-
fn: (accessor, path9) => {
|
|
1581
|
-
return read(accessor, path9);
|
|
1582
|
-
}
|
|
1583
|
-
};
|
|
1584
|
-
|
|
1585
|
-
// src/ops/disk/read_feather.ts
|
|
1586
|
-
import { featherCat, ResourceName as ResourceName73 } from "@struktoai/mirage-core";
|
|
1587
|
-
var readFeatherOp = {
|
|
1588
|
-
name: "read",
|
|
1589
|
-
resource: ResourceName73.DISK,
|
|
1590
|
-
filetype: ".feather",
|
|
1591
|
-
write: false,
|
|
1592
|
-
fn: async (accessor, path9) => {
|
|
1593
|
-
const raw = await read(accessor, path9);
|
|
1594
|
-
return featherCat(raw);
|
|
1595
|
-
}
|
|
1596
|
-
};
|
|
1597
|
-
|
|
1598
|
-
// src/ops/disk/read_hdf5.ts
|
|
1599
|
-
import { hdf5Cat, ResourceName as ResourceName74 } from "@struktoai/mirage-core";
|
|
1600
|
-
var readHdf5Op = {
|
|
1601
|
-
name: "read",
|
|
1602
|
-
resource: ResourceName74.DISK,
|
|
1603
|
-
filetype: ".hdf5",
|
|
1604
|
-
write: false,
|
|
1605
|
-
fn: async (accessor, path9) => {
|
|
1606
|
-
const raw = await read(accessor, path9);
|
|
1607
|
-
return hdf5Cat(raw);
|
|
1608
|
-
}
|
|
1609
|
-
};
|
|
1610
|
-
|
|
1611
|
-
// src/ops/disk/read_parquet.ts
|
|
1612
|
-
import { parquetCat, ResourceName as ResourceName75 } from "@struktoai/mirage-core";
|
|
1613
|
-
var readParquetOp = {
|
|
1614
|
-
name: "read",
|
|
1615
|
-
resource: ResourceName75.DISK,
|
|
1616
|
-
filetype: ".parquet",
|
|
1617
|
-
write: false,
|
|
1618
|
-
fn: async (accessor, path9) => {
|
|
1619
|
-
const raw = await read(accessor, path9);
|
|
1620
|
-
return parquetCat(raw);
|
|
1621
|
-
}
|
|
1622
|
-
};
|
|
1623
|
-
|
|
1624
|
-
// src/ops/disk/readdir.ts
|
|
1625
|
-
import { ResourceName as ResourceName76 } from "@struktoai/mirage-core";
|
|
1626
|
-
var readdirOp = {
|
|
1627
|
-
name: "readdir",
|
|
1628
|
-
resource: ResourceName76.DISK,
|
|
1629
|
-
filetype: null,
|
|
1630
|
-
write: false,
|
|
1631
|
-
fn: (accessor, path9) => {
|
|
1632
|
-
return readdir3(accessor, path9);
|
|
1633
|
-
}
|
|
1634
|
-
};
|
|
1635
|
-
|
|
1636
|
-
// src/ops/disk/rename.ts
|
|
1637
|
-
import { ResourceName as ResourceName77 } from "@struktoai/mirage-core";
|
|
1638
|
-
var renameOp = {
|
|
1639
|
-
name: "rename",
|
|
1640
|
-
resource: ResourceName77.DISK,
|
|
1641
|
-
filetype: null,
|
|
1642
|
-
write: true,
|
|
1643
|
-
fn: (accessor, path9, args) => {
|
|
1644
|
-
const dst = args[0];
|
|
1645
|
-
if (dst === void 0 || dst === null || typeof dst !== "object" || !("original" in dst)) {
|
|
1646
|
-
throw new TypeError("rename op requires a PathSpec destination as the first arg");
|
|
1647
|
-
}
|
|
1648
|
-
return rename(accessor, path9, dst);
|
|
1649
|
-
}
|
|
1650
|
-
};
|
|
1651
|
-
|
|
1652
|
-
// src/ops/disk/rmdir.ts
|
|
1653
|
-
import { ResourceName as ResourceName78 } from "@struktoai/mirage-core";
|
|
1654
|
-
var rmdirOp = {
|
|
1655
|
-
name: "rmdir",
|
|
1656
|
-
resource: ResourceName78.DISK,
|
|
1657
|
-
filetype: null,
|
|
1658
|
-
write: true,
|
|
1659
|
-
fn: (accessor, path9) => {
|
|
1660
|
-
return rmdir(accessor, path9);
|
|
1661
|
-
}
|
|
1662
|
-
};
|
|
1663
|
-
|
|
1664
|
-
// src/ops/disk/stat.ts
|
|
1665
|
-
import { ResourceName as ResourceName79 } from "@struktoai/mirage-core";
|
|
1666
|
-
var statOp = {
|
|
1667
|
-
name: "stat",
|
|
1668
|
-
resource: ResourceName79.DISK,
|
|
1669
|
-
filetype: null,
|
|
1670
|
-
write: false,
|
|
1671
|
-
fn: (accessor, path9) => {
|
|
1672
|
-
return stat(accessor, path9);
|
|
1673
|
-
}
|
|
1674
|
-
};
|
|
1675
|
-
|
|
1676
|
-
// src/ops/disk/truncate.ts
|
|
1677
|
-
import { ResourceName as ResourceName80 } from "@struktoai/mirage-core";
|
|
1678
|
-
var truncateOp = {
|
|
1679
|
-
name: "truncate",
|
|
1680
|
-
resource: ResourceName80.DISK,
|
|
1681
|
-
filetype: null,
|
|
1682
|
-
write: true,
|
|
1683
|
-
fn: (accessor, path9, args) => {
|
|
1684
|
-
const length = args[0];
|
|
1685
|
-
if (typeof length !== "number") {
|
|
1686
|
-
throw new TypeError("truncate op requires a number length as the first arg");
|
|
1687
|
-
}
|
|
1688
|
-
return truncate(accessor, path9, length);
|
|
1689
|
-
}
|
|
1690
|
-
};
|
|
1691
|
-
|
|
1692
|
-
// src/ops/disk/unlink.ts
|
|
1693
|
-
import { ResourceName as ResourceName81 } from "@struktoai/mirage-core";
|
|
1694
|
-
var unlinkOp = {
|
|
1695
|
-
name: "unlink",
|
|
1696
|
-
resource: ResourceName81.DISK,
|
|
1697
|
-
filetype: null,
|
|
1698
|
-
write: true,
|
|
1699
|
-
fn: (accessor, path9) => {
|
|
1700
|
-
return unlink(accessor, path9);
|
|
1701
|
-
}
|
|
1702
|
-
};
|
|
1703
|
-
|
|
1704
|
-
// src/ops/disk/write.ts
|
|
1705
|
-
import { extractWriteData } from "@struktoai/mirage-core";
|
|
1706
|
-
import { ResourceName as ResourceName82 } from "@struktoai/mirage-core";
|
|
1707
|
-
var writeOp = {
|
|
1708
|
-
name: "write",
|
|
1709
|
-
resource: ResourceName82.DISK,
|
|
1710
|
-
filetype: null,
|
|
1711
|
-
write: true,
|
|
1712
|
-
fn: (accessor, path9, args) => {
|
|
1713
|
-
const data = extractWriteData(args);
|
|
1714
|
-
return writeBytes(accessor, path9, data);
|
|
1715
|
-
}
|
|
1716
|
-
};
|
|
1717
|
-
|
|
1718
|
-
// src/ops/disk/index.ts
|
|
1719
|
-
var DISK_OPS = [
|
|
1720
|
-
appendOp,
|
|
1721
|
-
createOp,
|
|
1722
|
-
mkdirOp,
|
|
1723
|
-
readOp,
|
|
1724
|
-
readFeatherOp,
|
|
1725
|
-
readHdf5Op,
|
|
1726
|
-
readParquetOp,
|
|
1727
|
-
readdirOp,
|
|
1728
|
-
renameOp,
|
|
1729
|
-
rmdirOp,
|
|
1730
|
-
statOp,
|
|
1731
|
-
truncateOp,
|
|
1732
|
-
unlinkOp,
|
|
1733
|
-
writeOp
|
|
1734
|
-
];
|
|
1735
|
-
|
|
1736
|
-
// src/resource/disk/prompt.ts
|
|
1737
|
-
var DISK_PROMPT = `{prefix}
|
|
1738
|
-
Local disk filesystem. Mirrors the configured root directory.
|
|
1739
|
-
Standard commands: ls, cat, head, tail, grep, wc, find, tree, mkdir, touch, cp, mv, rm, tee.`;
|
|
1740
|
-
|
|
1741
|
-
// src/resource/disk/disk.ts
|
|
1742
|
-
async function walkFiles(root, current, out) {
|
|
1743
|
-
const entries = await readdir4(current, { withFileTypes: true });
|
|
1744
|
-
for (const e of entries) {
|
|
1745
|
-
const child = path8.join(current, e.name);
|
|
1746
|
-
if (e.isDirectory()) {
|
|
1747
|
-
await walkFiles(root, child, out);
|
|
1748
|
-
} else if (e.isFile()) {
|
|
1749
|
-
out.push(child);
|
|
1750
|
-
}
|
|
1751
|
-
}
|
|
1752
|
-
}
|
|
1753
|
-
var DiskResource = class extends BaseResource {
|
|
1754
|
-
kind = ResourceName83.DISK;
|
|
1755
|
-
isRemote = false;
|
|
1756
|
-
indexTtl = 60;
|
|
1757
|
-
prompt = DISK_PROMPT;
|
|
1758
|
-
root;
|
|
1759
|
-
accessor;
|
|
1760
|
-
opsMap = {
|
|
1761
|
-
read_bytes: read,
|
|
1762
|
-
write: writeBytes,
|
|
1763
|
-
readdir: readdir3,
|
|
1764
|
-
stat,
|
|
1765
|
-
unlink,
|
|
1766
|
-
rmdir,
|
|
1767
|
-
copy,
|
|
1768
|
-
rename,
|
|
1769
|
-
mkdir: mkdir3,
|
|
1770
|
-
read_stream: stream,
|
|
1771
|
-
rm_recursive: rmR,
|
|
1772
|
-
du_total: du,
|
|
1773
|
-
du_all: duAll,
|
|
1774
|
-
create,
|
|
1775
|
-
truncate,
|
|
1776
|
-
exists,
|
|
1777
|
-
find_flat: find,
|
|
1778
|
-
append: appendBytes
|
|
1779
|
-
};
|
|
1780
|
-
constructor(options) {
|
|
1781
|
-
super();
|
|
1782
|
-
this.root = path8.resolve(options.root);
|
|
1783
|
-
this.accessor = new DiskAccessor(this.root);
|
|
1784
|
-
}
|
|
1785
|
-
async open() {
|
|
1786
|
-
await mkdir5(this.root, { recursive: true });
|
|
1787
|
-
}
|
|
1788
|
-
close() {
|
|
1789
|
-
return Promise.resolve();
|
|
1790
|
-
}
|
|
1791
|
-
ops() {
|
|
1792
|
-
return DISK_OPS;
|
|
1793
|
-
}
|
|
1794
|
-
commands() {
|
|
1795
|
-
return DISK_COMMANDS;
|
|
1796
|
-
}
|
|
1797
|
-
streamPath(p) {
|
|
1798
|
-
return stream(this.accessor, p);
|
|
1799
|
-
}
|
|
1800
|
-
readFile(p) {
|
|
1801
|
-
return read(this.accessor, p);
|
|
1802
|
-
}
|
|
1803
|
-
writeFile(p, data) {
|
|
1804
|
-
return writeBytes(this.accessor, p, data);
|
|
1805
|
-
}
|
|
1806
|
-
appendFile(p, data) {
|
|
1807
|
-
return appendBytes(this.accessor, p, data);
|
|
1808
|
-
}
|
|
1809
|
-
readdir(p) {
|
|
1810
|
-
return readdir3(this.accessor, p, this.index);
|
|
1811
|
-
}
|
|
1812
|
-
stat(p) {
|
|
1813
|
-
return stat(this.accessor, p);
|
|
1814
|
-
}
|
|
1815
|
-
exists(p) {
|
|
1816
|
-
return exists(this.accessor, p);
|
|
1817
|
-
}
|
|
1818
|
-
mkdir(p, options) {
|
|
1819
|
-
return mkdir3(this.accessor, p, options?.recursive === true);
|
|
1820
|
-
}
|
|
1821
|
-
rmdir(p) {
|
|
1822
|
-
return rmdir(this.accessor, p);
|
|
1823
|
-
}
|
|
1824
|
-
unlink(p) {
|
|
1825
|
-
return unlink(this.accessor, p);
|
|
1826
|
-
}
|
|
1827
|
-
rename(src, dst) {
|
|
1828
|
-
return rename(this.accessor, src, dst);
|
|
1829
|
-
}
|
|
1830
|
-
truncate(p, length) {
|
|
1831
|
-
return truncate(this.accessor, p, length);
|
|
1832
|
-
}
|
|
1833
|
-
copy(src, dst) {
|
|
1834
|
-
return copy(this.accessor, src, dst);
|
|
1835
|
-
}
|
|
1836
|
-
rmR(p) {
|
|
1837
|
-
return rmR(this.accessor, p);
|
|
1838
|
-
}
|
|
1839
|
-
du(p) {
|
|
1840
|
-
return du(this.accessor, p);
|
|
1841
|
-
}
|
|
1842
|
-
find(p, options = {}) {
|
|
1843
|
-
return find(this.accessor, p, options);
|
|
1844
|
-
}
|
|
1845
|
-
async fingerprint(p) {
|
|
1846
|
-
try {
|
|
1847
|
-
const remote = await stat(this.accessor, p);
|
|
1848
|
-
return remote.modified ?? null;
|
|
1849
|
-
} catch {
|
|
1850
|
-
return null;
|
|
1851
|
-
}
|
|
1852
|
-
}
|
|
1853
|
-
glob(paths, prefix = "") {
|
|
1854
|
-
const effective = prefix ? paths.map(
|
|
1855
|
-
(p) => p.prefix ? p : new PathSpec2({
|
|
1856
|
-
original: p.original,
|
|
1857
|
-
directory: p.directory,
|
|
1858
|
-
...p.pattern !== null ? { pattern: p.pattern } : {},
|
|
1859
|
-
resolved: p.resolved,
|
|
1860
|
-
prefix
|
|
1861
|
-
})
|
|
1862
|
-
) : paths;
|
|
1863
|
-
return resolveGlob(this.accessor, effective, this.index);
|
|
1864
|
-
}
|
|
1865
|
-
async getState() {
|
|
1866
|
-
await mkdir5(this.root, { recursive: true });
|
|
1867
|
-
const files = {};
|
|
1868
|
-
const fileList = [];
|
|
1869
|
-
await walkFiles(this.root, this.root, fileList);
|
|
1870
|
-
for (const full of fileList) {
|
|
1871
|
-
const rel = path8.relative(this.root, full).split(path8.sep).join("/");
|
|
1872
|
-
const data = await readFile3(full);
|
|
1873
|
-
files[rel] = new Uint8Array(data.buffer, data.byteOffset, data.byteLength);
|
|
1874
|
-
}
|
|
1875
|
-
return {
|
|
1876
|
-
type: this.kind,
|
|
1877
|
-
files
|
|
1878
|
-
};
|
|
1879
|
-
}
|
|
1880
|
-
async loadState(state) {
|
|
1881
|
-
await mkdir5(this.root, { recursive: true });
|
|
1882
|
-
for (const [rel, data] of Object.entries(state.files)) {
|
|
1883
|
-
const full = path8.join(this.root, rel);
|
|
1884
|
-
await mkdir5(path8.dirname(full), { recursive: true });
|
|
1885
|
-
await writeFile3(full, data);
|
|
1886
|
-
}
|
|
1887
|
-
}
|
|
1888
|
-
};
|
|
1889
|
-
|
|
1890
|
-
export {
|
|
1891
|
-
DISK_COMMANDS,
|
|
1892
|
-
DISK_OPS,
|
|
1893
|
-
DISK_PROMPT,
|
|
1894
|
-
DiskResource
|
|
1895
|
-
};
|
|
1896
|
-
//# sourceMappingURL=chunk-PBBG7VFT.js.map
|