@jerryan/just-bash 3.8.0 → 3.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/README.md +5 -15
- package/dist/AGENTS.md +2 -2
- package/dist/Bash.d.ts +2 -4
- package/dist/bin/chunks/{chunk-7WBCA2BB.js → chunk-3DWQCLNP.js} +1 -1
- package/dist/bin/{shell/chunks/chunk-MPFNZYEA.js → chunks/chunk-6JEDM6CZ.js} +1 -1
- package/dist/bin/chunks/{chunk-QFTZKD5O.js → chunk-6TUILMPB.js} +1 -1
- package/dist/bin/chunks/chunk-E54Z6VIE.js +12 -0
- package/dist/bin/chunks/chunk-GBKR5KTT.js +44 -0
- package/dist/bin/{shell/chunks/chunk-MF3GVFLC.js → chunks/chunk-L345YZ6R.js} +1 -1
- package/dist/bin/chunks/chunk-QKJAAJ7J.js +3 -0
- package/dist/bin/chunks/{diff-JSJ56EOK.js → diff-DM47S5PT.js} +1 -1
- package/dist/bin/{shell/chunks/flag-coverage-2H5CPEM6.js → chunks/flag-coverage-LLAQBVIG.js} +1 -1
- package/dist/bin/chunks/js-exec-ZAAIZQWI.js +99 -0
- package/dist/bin/chunks/js-exec-worker.js +4995 -0
- package/dist/bin/chunks/python3-TJ6DCPIA.js +14 -0
- package/dist/bin/chunks/{sleep-DVFE2GSF.js → sleep-MOJQBZMY.js} +1 -1
- package/dist/bin/{shell/chunks/sqlite3-KNN6V2W6.js → chunks/sqlite3-CXQTZRPZ.js} +1 -1
- package/dist/bin/chunks/{timeout-YGFHQJKX.js → timeout-RQOWSWYG.js} +1 -1
- package/dist/bin/just-bash.js +1 -1
- package/dist/bin/shell/chunks/{chunk-7WBCA2BB.js → chunk-3DWQCLNP.js} +1 -1
- package/dist/bin/{chunks/chunk-MPFNZYEA.js → shell/chunks/chunk-6JEDM6CZ.js} +1 -1
- package/dist/bin/shell/chunks/{chunk-QFTZKD5O.js → chunk-6TUILMPB.js} +1 -1
- package/dist/bin/shell/chunks/chunk-E54Z6VIE.js +12 -0
- package/dist/bin/shell/chunks/chunk-GBKR5KTT.js +44 -0
- package/dist/bin/{chunks/chunk-MF3GVFLC.js → shell/chunks/chunk-L345YZ6R.js} +1 -1
- package/dist/bin/shell/chunks/chunk-QKJAAJ7J.js +3 -0
- package/dist/bin/shell/chunks/{diff-JSJ56EOK.js → diff-DM47S5PT.js} +1 -1
- package/dist/bin/{chunks/flag-coverage-2H5CPEM6.js → shell/chunks/flag-coverage-LLAQBVIG.js} +1 -1
- package/dist/bin/shell/chunks/js-exec-ZAAIZQWI.js +99 -0
- package/dist/bin/shell/chunks/python3-TJ6DCPIA.js +14 -0
- package/dist/bin/shell/chunks/{sleep-DVFE2GSF.js → sleep-MOJQBZMY.js} +1 -1
- package/dist/bin/{chunks/sqlite3-KNN6V2W6.js → shell/chunks/sqlite3-CXQTZRPZ.js} +1 -1
- package/dist/bin/shell/chunks/{timeout-YGFHQJKX.js → timeout-RQOWSWYG.js} +1 -1
- package/dist/bin/shell/shell.js +1 -1
- package/dist/bundle/browser.js +596 -579
- package/dist/bundle/chunks/{chunk-N3A4JVFJ.js → chunk-6IA4DXG2.js} +1 -1
- package/dist/bundle/chunks/chunk-BS6EJR2R.js +11 -0
- package/dist/bundle/chunks/chunk-E2F4A3CM.js +43 -0
- package/dist/bundle/chunks/{chunk-GNPLDVBD.js → chunk-H3A45X3W.js} +1 -1
- package/dist/bundle/chunks/chunk-PS2RJNZZ.js +2 -0
- package/dist/bundle/chunks/{chunk-DMWNBCXJ.js → chunk-TLPMB3FO.js} +1 -1
- package/dist/bundle/chunks/{chunk-XV2V56NQ.js → chunk-YFFU74KY.js} +1 -1
- package/dist/bundle/chunks/{diff-VDB6RXHO.js → diff-R7TXVVLN.js} +1 -1
- package/dist/bundle/chunks/{flag-coverage-UMQ3BWDP.js → flag-coverage-YQGACUSN.js} +1 -1
- package/dist/bundle/chunks/js-exec-MUZRDUJ3.js +98 -0
- package/dist/bundle/chunks/js-exec-worker.js +4995 -0
- package/dist/bundle/chunks/python3-W4UMQJAQ.js +13 -0
- package/dist/bundle/chunks/{sleep-PPRBTSVR.js → sleep-25QUPVDK.js} +1 -1
- package/dist/bundle/chunks/{sqlite3-KB3MXTTM.js → sqlite3-DQNCWDG5.js} +1 -1
- package/dist/bundle/chunks/{timeout-C6WDYPLV.js → timeout-37GM7IIL.js} +1 -1
- package/dist/bundle/index.cjs +1128 -2663
- package/dist/bundle/index.js +2 -2
- package/dist/commands/js-exec/js-exec-worker.d.ts +35 -0
- package/dist/commands/js-exec/js-exec.d.ts +14 -1
- package/dist/fs/vfs-template.d.ts +6 -0
- package/dist/interpreter/interpreter.d.ts +1 -1
- package/dist/interpreter/types.d.ts +1 -1
- package/dist/limits.d.ts +2 -2
- package/dist/timers.d.ts +9 -0
- package/dist/types.d.ts +3 -4
- package/package.json +8 -8
- package/dist/bin/chunks/chunk-2NJJXU4K.js +0 -27
- package/dist/bin/chunks/chunk-PPVF2N6C.js +0 -3
- package/dist/bin/chunks/js-exec-T3SAB2B6.js +0 -1651
- package/dist/bin/chunks/python3-3ERN3L6S.js +0 -23
- package/dist/bin/shell/chunks/chunk-2NJJXU4K.js +0 -27
- package/dist/bin/shell/chunks/chunk-PPVF2N6C.js +0 -3
- package/dist/bin/shell/chunks/js-exec-T3SAB2B6.js +0 -1651
- package/dist/bin/shell/chunks/python3-3ERN3L6S.js +0 -23
- package/dist/bundle/chunks/chunk-B6OSJB22.js +0 -26
- package/dist/bundle/chunks/chunk-WXPNKIIH.js +0 -2
- package/dist/bundle/chunks/js-exec-ZQMIYQTH.js +0 -1650
- package/dist/bundle/chunks/python3-QB7OE256.js +0 -22
- package/dist/commands/js-exec/run-runtime.d.ts +0 -10
package/dist/timers.d.ts
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
export declare const _setTimeout: typeof globalThis.setTimeout;
|
|
2
2
|
export declare const _clearTimeout: typeof globalThis.clearTimeout;
|
|
3
|
+
/**
|
|
4
|
+
* Native setTimeout WITHOUT execution-context binding. `_setTimeout`
|
|
5
|
+
* binds callbacks to the scheduling execution's defense context, which
|
|
6
|
+
* DefenseInDepthBox suppresses once that execution deactivates — correct
|
|
7
|
+
* for intra-execution timers (sleep, fetch deadlines), fatal for host
|
|
8
|
+
* infrastructure callbacks that must fire AFTER the execution ends
|
|
9
|
+
* (e.g. idle teardown of a shared worker). Use this for the latter.
|
|
10
|
+
*/
|
|
11
|
+
export declare const _setTimeoutUnbound: typeof globalThis.setTimeout;
|
|
3
12
|
export interface FiniteTimeoutHandle {
|
|
4
13
|
cleared: boolean;
|
|
5
14
|
remainingMs: number;
|
package/dist/types.d.ts
CHANGED
|
@@ -283,11 +283,10 @@ export interface RuntimeCommandContext {
|
|
|
283
283
|
jsBootstrapCode?: string;
|
|
284
284
|
/**
|
|
285
285
|
* Tool invoker hook. When present, js-exec sets up a `tools` proxy that
|
|
286
|
-
* routes calls through this callback. Receives `(path, argsJson
|
|
287
|
-
*
|
|
288
|
-
* forward the signal to cancelable work.
|
|
286
|
+
* routes calls through this callback. Receives `(path, argsJson)` and
|
|
287
|
+
* returns a JSON result string.
|
|
289
288
|
*/
|
|
290
|
-
invokeTool?: (path: string, argsJson: string
|
|
289
|
+
invokeTool?: (path: string, argsJson: string) => Promise<string>;
|
|
291
290
|
}
|
|
292
291
|
/** Legacy standalone context shape used by direct command invocations. */
|
|
293
292
|
export type CommandContext = Omit<RuntimeCommandContext, "limits" | "executionScope"> & {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jerryan/just-bash",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.9.0",
|
|
4
4
|
"description": "A simulated bash environment with virtual filesystem",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -77,6 +77,7 @@
|
|
|
77
77
|
"fast-check": "^3.23.2",
|
|
78
78
|
"knip": "^5.88.1",
|
|
79
79
|
"tsx": "^4.23.12",
|
|
80
|
+
"typescript": "^5.9.3",
|
|
80
81
|
"vitest": "^4.1.10"
|
|
81
82
|
},
|
|
82
83
|
"dependencies": {
|
|
@@ -87,14 +88,13 @@
|
|
|
87
88
|
"ini": "^6.0.0",
|
|
88
89
|
"modern-tar": "^0.7.7",
|
|
89
90
|
"papaparse": "^5.6.0",
|
|
91
|
+
"quickjs-emscripten": "^0.32.0",
|
|
90
92
|
"re2js": "^1.3.3",
|
|
91
|
-
"run": "2.1.3",
|
|
92
93
|
"seek-bzip": "^2.0.0",
|
|
93
94
|
"smol-toml": "^1.8.0",
|
|
94
95
|
"sprintf-js": "^1.1.3",
|
|
95
96
|
"sql.js": "^1.14.1",
|
|
96
97
|
"turndown": "^7.2.4",
|
|
97
|
-
"typescript": "^5.9.3",
|
|
98
98
|
"undici": "^7.29.0",
|
|
99
99
|
"yaml": "^2.9.0"
|
|
100
100
|
},
|
|
@@ -105,12 +105,12 @@
|
|
|
105
105
|
"scripts": {
|
|
106
106
|
"build": "rm -rf dist && tsc && pnpm build:lib && pnpm build:lib:cjs && pnpm build:browser && pnpm build:cli && pnpm build:shell && pnpm build:worker && pnpm build:clean && cp dist/index.d.ts dist/index.d.cts && sed '1,/^-->/d' AGENTS.npm.md > dist/AGENTS.md",
|
|
107
107
|
"build:clean": "find dist -name '*.test.js' -delete && find dist -name '*.test.d.ts' -delete",
|
|
108
|
-
"build:worker": "esbuild src/commands/python3/worker.ts --bundle --platform=node --format=esm --outfile=src/commands/python3/worker.js --external:../../../vendor/cpython-emscripten/* && cp src/commands/python3/worker.js dist/commands/python3/worker.js && mkdir -p dist/bin/chunks && cp src/commands/python3/worker.js dist/bin/chunks/worker.js && mkdir -p dist/bundle/chunks && cp src/commands/python3/worker.js dist/bundle/chunks/worker.js && esbuild src/commands/sqlite3/worker.ts --bundle --platform=node --format=esm --outfile=src/commands/sqlite3/worker.js --external:sql.js && mkdir -p dist/commands/sqlite3 && cp src/commands/sqlite3/worker.js dist/commands/sqlite3/worker.js && cp src/commands/sqlite3/worker.js dist/bin/chunks/sqlite3-worker.js && cp src/commands/sqlite3/worker.js dist/bundle/chunks/sqlite3-worker.js",
|
|
109
|
-
"build:lib": "esbuild dist/index.js --bundle --splitting --platform=node --format=esm --minify --outdir=dist/bundle --chunk-names=chunks/[name]-[hash] --banner:js='import{createRequire} from\"node:module\";const require=createRequire(import.meta.url);' --external:diff --external:sprintf-js --external:turndown --external:sql.js --external:
|
|
110
|
-
"build:lib:cjs": "esbuild dist/index.js --bundle --platform=node --format=cjs --minify --outfile=dist/bundle/index.cjs --external:diff --external:sprintf-js --external:turndown --external:sql.js --external:
|
|
108
|
+
"build:worker": "esbuild src/commands/python3/worker.ts --bundle --platform=node --format=esm --outfile=src/commands/python3/worker.js --external:../../../vendor/cpython-emscripten/* && cp src/commands/python3/worker.js dist/commands/python3/worker.js && mkdir -p dist/bin/chunks && cp src/commands/python3/worker.js dist/bin/chunks/worker.js && mkdir -p dist/bundle/chunks && cp src/commands/python3/worker.js dist/bundle/chunks/worker.js && esbuild src/commands/js-exec/js-exec-worker.ts --bundle --platform=node --format=esm --outfile=src/commands/js-exec/js-exec-worker.js --external:quickjs-emscripten && cp src/commands/js-exec/js-exec-worker.js dist/commands/js-exec/js-exec-worker.js && cp src/commands/js-exec/js-exec-worker.js dist/bin/chunks/js-exec-worker.js && cp src/commands/js-exec/js-exec-worker.js dist/bundle/chunks/js-exec-worker.js && esbuild src/commands/sqlite3/worker.ts --bundle --platform=node --format=esm --outfile=src/commands/sqlite3/worker.js --external:sql.js && mkdir -p dist/commands/sqlite3 && cp src/commands/sqlite3/worker.js dist/commands/sqlite3/worker.js && cp src/commands/sqlite3/worker.js dist/bin/chunks/sqlite3-worker.js && cp src/commands/sqlite3/worker.js dist/bundle/chunks/sqlite3-worker.js",
|
|
109
|
+
"build:lib": "esbuild dist/index.js --bundle --splitting --platform=node --format=esm --minify --outdir=dist/bundle --chunk-names=chunks/[name]-[hash] --banner:js='import{createRequire} from\"node:module\";const require=createRequire(import.meta.url);' --external:diff --external:sprintf-js --external:turndown --external:sql.js --external:quickjs-emscripten --external:@mongodb-js/zstd --external:node-liblzma --external:seek-bzip --external:guarded-fetch",
|
|
110
|
+
"build:lib:cjs": "esbuild dist/index.js --bundle --platform=node --format=cjs --minify --outfile=dist/bundle/index.cjs --external:diff --external:sprintf-js --external:turndown --external:sql.js --external:quickjs-emscripten --external:@mongodb-js/zstd --external:node-liblzma --external:seek-bzip --external:guarded-fetch",
|
|
111
111
|
"build:browser": "esbuild dist/browser.js --bundle --platform=browser --format=esm --minify --outfile=dist/bundle/browser.js --external:diff --external:sprintf-js --external:turndown --external:undici --external:guarded-fetch --external:node:zlib --external:@mongodb-js/zstd --external:node-liblzma --external:seek-bzip --define:__BROWSER__=true --alias:node:async_hooks=./src/shims/browser-unsupported.js --alias:node:dns=./src/shims/browser-unsupported.js --alias:node:module=./src/shims/browser-unsupported.js",
|
|
112
|
-
"build:cli": "esbuild dist/cli/just-bash.js --bundle --splitting --platform=node --format=esm --minify --outdir=dist/bin --entry-names=[name] --chunk-names=chunks/[name]-[hash] --banner:js='#!/usr/bin/env node\nimport{createRequire} from\"node:module\";const require=createRequire(import.meta.url);' --external:sql.js --external:
|
|
113
|
-
"build:shell": "esbuild dist/cli/shell.js --bundle --splitting --platform=node --format=esm --minify --outdir=dist/bin/shell --entry-names=[name] --chunk-names=chunks/[name]-[hash] --banner:js='#!/usr/bin/env node\nimport{createRequire} from\"node:module\";const require=createRequire(import.meta.url);' --external:sql.js --external:
|
|
112
|
+
"build:cli": "esbuild dist/cli/just-bash.js --bundle --splitting --platform=node --format=esm --minify --outdir=dist/bin --entry-names=[name] --chunk-names=chunks/[name]-[hash] --banner:js='#!/usr/bin/env node\nimport{createRequire} from\"node:module\";const require=createRequire(import.meta.url);' --external:sql.js --external:quickjs-emscripten --external:@mongodb-js/zstd --external:node-liblzma --external:seek-bzip",
|
|
113
|
+
"build:shell": "esbuild dist/cli/shell.js --bundle --splitting --platform=node --format=esm --minify --outdir=dist/bin/shell --entry-names=[name] --chunk-names=chunks/[name]-[hash] --banner:js='#!/usr/bin/env node\nimport{createRequire} from\"node:module\";const require=createRequire(import.meta.url);' --external:sql.js --external:quickjs-emscripten --external:@mongodb-js/zstd --external:node-liblzma --external:seek-bzip",
|
|
114
114
|
"validate": "pnpm lint && pnpm knip && pnpm typecheck && pnpm build && pnpm check:worker-sync && pnpm test:run && pnpm test:wasm && pnpm test:dist",
|
|
115
115
|
"typecheck": "tsc --noEmit",
|
|
116
116
|
"lint": "pnpm lint:banned",
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import{createRequire} from"node:module";const require=createRequire(import.meta.url);
|
|
3
|
-
import{b as E}from"./chunk-CPKBPQ2C.js";import{a as M}from"./chunk-NE4R2FVV.js";import{a as A,b as j}from"./chunk-MUFNRCMY.js";var S=class{diff(t,o,e={}){let i;typeof e=="function"?(i=e,e={}):"callback"in e&&(i=e.callback);let s=this.castInput(t,e),f=this.castInput(o,e),a=this.removeEmpty(this.tokenize(s,e)),n=this.removeEmpty(this.tokenize(f,e));return this.diffWithOptionsObj(a,n,e,i)}diffWithOptionsObj(t,o,e,i){var s;let f=d=>{if(d=this.postProcess(d,e),i){setTimeout(function(){i(d)},0);return}else return d},a=o.length,n=t.length,u=1,l=a+n;e.maxEditLength!=null&&(l=Math.min(l,e.maxEditLength));let c=(s=e.timeout)!==null&&s!==void 0?s:1/0,m=Date.now()+c,h=[{oldPos:-1,lastComponent:void 0}],p=this.extractCommon(h[0],o,t,0,e);if(h[0].oldPos+1>=n&&p+1>=a)return f(this.buildValues(h[0].lastComponent,o,t));let C=-1/0,w=1/0,P=()=>{for(let d=Math.max(C,-u);d<=Math.min(w,u);d+=2){let x,y=h[d-1],v=h[d+1];y&&(h[d-1]=void 0);let $=!1;if(v){let I=v.oldPos-d;$=v&&0<=I&&I<a}let N=y&&y.oldPos+1<n;if(!$&&!N){h[d]=void 0;continue}if(!N||$&&y.oldPos<v.oldPos?x=this.addToPath(v,!0,!1,0,e):x=this.addToPath(y,!1,!0,1,e),p=this.extractCommon(x,o,t,d,e),x.oldPos+1>=n&&p+1>=a)return f(this.buildValues(x.lastComponent,o,t))||!0;h[d]=x,x.oldPos+1>=n&&(w=Math.min(w,d-1)),p+1>=a&&(C=Math.max(C,d+1))}u++};if(i)(function d(){setTimeout(function(){if(u>l||Date.now()>m)return i(void 0);P()||d()},0)})();else for(;u<=l&&Date.now()<=m;){let d=P();if(d)return d}}addToPath(t,o,e,i,s){let f=t.lastComponent;return f&&!s.oneChangePerToken&&f.added===o&&f.removed===e?{oldPos:t.oldPos+i,lastComponent:{count:f.count+1,added:o,removed:e,previousComponent:f.previousComponent}}:{oldPos:t.oldPos+i,lastComponent:{count:1,added:o,removed:e,previousComponent:f}}}extractCommon(t,o,e,i,s){let f=o.length,a=e.length,n=t.oldPos,u=n-i,l=0;for(;u+1<f&&n+1<a&&this.equals(e[n+1],o[u+1],s);)u++,n++,l++,s.oneChangePerToken&&(t.lastComponent={count:1,previousComponent:t.lastComponent,added:!1,removed:!1});return l&&!s.oneChangePerToken&&(t.lastComponent={count:l,previousComponent:t.lastComponent,added:!1,removed:!1}),t.oldPos=n,u}equals(t,o,e){return e.comparator?e.comparator(t,o):t===o||!!e.ignoreCase&&t.toLowerCase()===o.toLowerCase()}removeEmpty(t){let o=[];for(let e=0;e<t.length;e++)t[e]&&o.push(t[e]);return o}castInput(t,o){return t}tokenize(t,o){return Array.from(t)}join(t){return t.join("")}postProcess(t,o){return t}get useLongestToken(){return!1}buildValues(t,o,e){let i=[],s;for(;t;)i.push(t),s=t.previousComponent,delete t.previousComponent,t=s;i.reverse();let f=i.length,a=0,n=0,u=0;for(;a<f;a++){let l=i[a];if(l.removed)l.value=this.join(e.slice(u,u+l.count)),u+=l.count;else{if(!l.added&&this.useLongestToken){let c=o.slice(n,n+l.count);c=c.map(function(m,h){let p=e[u+h];return p.length>m.length?p:m}),l.value=this.join(c)}else l.value=this.join(o.slice(n,n+l.count));n+=l.count,l.added||(u+=l.count)}}return i}};var b=class extends S{tokenize(t){return t.slice()}join(t){return t}removeEmpty(t){return t}},z=new b;function T(r,t,o){return z.diff(r,t,o)}var Y=`\
|
|
4
|
-
`,D=3;function F(r){if(r==="")return{lines:[],noEol:!1};let t=!r.endsWith(`
|
|
5
|
-
`),o=r.split(`
|
|
6
|
-
`);return t||o.pop(),{lines:o,noEol:t}}function O(r,t){let o=r.lines.length-1;return r.lines.map((e,i)=>{let s=i===o&&r.noEol?e:`${e}
|
|
7
|
-
`;return t?s.toLowerCase():s})}function q(r,t,o){let e=T(O(r,o),O(t,o)),i=[],s=0,f=0,a=0;for(;a<e.length;){let n=e[a];if(!n.added&&!n.removed){s+=n.count??n.value.length,f+=n.count??n.value.length,a++;continue}let u={oldStart:s,oldCount:0,newStart:f,newCount:0};for(;a<e.length&&(e[a].added||e[a].removed);){let l=e[a].count??e[a].value.length;e[a].removed?(u.oldCount+=l,s+=l):(u.newCount+=l,f+=l),a++}i.push(u)}return i}function L(r){if(!/[\s"\u0000-\u001f\u007f]/.test(r))return r;let t='"';for(let o of r)o==='"'||o==="\\"?t+=`\\${o}`:o===" "?t+="\\t":o===`
|
|
8
|
-
`?t+="\\n":o==="\r"?t+="\\r":o<" "||o==="\x7F"?t+=`\\${o.charCodeAt(0).toString(8).padStart(3,"0")}`:t+=o;return`${t}"`}function g(r,t,o,e){r.push(`${e}${t.lines[o]}
|
|
9
|
-
`),t.noEol&&o===t.lines.length-1&&r.push(Y)}function W(r,t){return t===0?String(r):t===1?String(r+1):`${r+1},${r+t}`}function U(r,t,o){let e=[];for(let i of o){let s=i.oldCount===0?"a":i.newCount===0?"d":"c";e.push(`${W(i.oldStart,i.oldCount)}${s}${W(i.newStart,i.newCount)}
|
|
10
|
-
`);for(let f=0;f<i.oldCount;f++)g(e,r,i.oldStart+f,"< ");s==="c"&&e.push(`---
|
|
11
|
-
`);for(let f=0;f<i.newCount;f++)g(e,t,i.newStart+f,"> ")}return e.join("")}function k(r,t){let o=[],e=[];for(let i of r){let s=e[e.length-1];s&&i.oldStart-(s.oldStart+s.oldCount)>2*t&&(o.push(e),e=[]),e.push(i)}return e.length>0&&o.push(e),o}function V(r,t,o,e){let i=r[0],s=r[r.length-1];return{oldFrom:Math.max(0,i.oldStart-e),oldTo:Math.min(t.lines.length,s.oldStart+s.oldCount+e),newFrom:Math.max(0,i.newStart-e),newTo:Math.min(o.lines.length,s.newStart+s.newCount+e)}}function _(r,t){let o=t-r;return o===0?`${r},0`:o===1?String(r+1):`${r+1},${o}`}function X(r,t,o,e,i,s){let f=[`--- ${L(r)}
|
|
12
|
-
`,`+++ ${L(t)}
|
|
13
|
-
`];for(let a of k(i,s)){let n=V(a,o,e,s);f.push(`@@ -${_(n.oldFrom,n.oldTo)} +${_(n.newFrom,n.newTo)} @@
|
|
14
|
-
`);let u=n.oldFrom;for(let l of a){for(;u<l.oldStart;u++)g(f,o,u," ");for(let c=0;c<l.oldCount;c++)g(f,o,l.oldStart+c,"-");for(let c=0;c<l.newCount;c++)g(f,e,l.newStart+c,"+");u=l.oldStart+l.oldCount}for(;u<n.oldTo;u++)g(f,o,u," ")}return f.join("")}function H(r,t){let o=t-r;return o===0?String(r):o===1?String(r+1):`${r+1},${t}`}function R(r,t,o,e,i,s){if(!o.some(n=>(s?n.oldCount:n.newCount)>0))return;let a=e;for(let n of o){let u=s?n.oldStart:n.newStart,l=s?n.oldCount:n.newCount;for(;a<u;a++)g(r,t,a," ");let c=n.oldCount>0&&n.newCount>0?"! ":s?"- ":"+ ";for(let m=0;m<l;m++)g(r,t,u+m,c);a=u+l}for(;a<i;a++)g(r,t,a," ")}function B(r,t,o,e,i,s){let f=[`*** ${L(r)}
|
|
15
|
-
`,`--- ${L(t)}
|
|
16
|
-
`];for(let a of k(i,s)){let n=V(a,o,e,s);f.push(`***************
|
|
17
|
-
`),f.push(`*** ${H(n.oldFrom,n.oldTo)} ****
|
|
18
|
-
`),R(f,o,a,n.oldFrom,n.oldTo,!0),f.push(`--- ${H(n.newFrom,n.newTo)} ----
|
|
19
|
-
`),R(f,e,a,n.newFrom,n.newTo,!1)}return f.join("")}var G={name:"diff",summary:"compare files line by line",usage:"diff [OPTION]... FILE1 FILE2",options:[" --normal output a normal diff (default)","-u, --unified output a unified diff","-c, --context output a context diff","-q, --brief report only whether files differ","-s, --report-identical-files report when files are the same","-i, --ignore-case ignore case differences"," --version output version information and exit"," --help display this help and exit"]},K={normal:{long:"normal",type:"boolean"},unified:{short:"u",long:"unified",type:"boolean"},context:{short:"c",long:"context",type:"boolean"},brief:{short:"q",long:"brief",type:"boolean"},reportSame:{short:"s",long:"report-identical-files",type:"boolean"},ignoreCase:{short:"i",long:"ignore-case",type:"boolean"},version:{long:"version",type:"boolean"}},ft={name:"diff",async execute(r,t){if(j(r))return A(G);let o=M("diff",r,K);if(!o.ok)return o.error;let e=o.result.flags;if(e.version)return{stdout:`diff (just-bash)
|
|
20
|
-
`,stderr:"",exitCode:0};if(Number(e.normal)+Number(e.unified)+Number(e.context)>1)return{stdout:"",stderr:`diff: conflicting output style options
|
|
21
|
-
diff: Try 'diff --help' for more information.
|
|
22
|
-
`,exitCode:2};let s=e.brief,f=e.reportSame,a=e.ignoreCase,n=o.result.positional;if(n.length<2)return{stdout:"",stderr:`diff: missing operand
|
|
23
|
-
`,exitCode:2};let u,l,[c,m]=n;try{u=c==="-"?E(t.stdin):await t.fs.readFile(t.fs.resolvePath(t.cwd,c))}catch{return{stdout:"",stderr:`diff: ${c}: No such file or directory
|
|
24
|
-
`,exitCode:2}}try{l=m==="-"?E(t.stdin):await t.fs.readFile(t.fs.resolvePath(t.cwd,m))}catch{return{stdout:"",stderr:`diff: ${m}: No such file or directory
|
|
25
|
-
`,exitCode:2}}let h=u,p=l;if(a&&(h=h.toLowerCase(),p=p.toLowerCase()),h===p)return f?{stdout:`Files ${c} and ${m} are identical
|
|
26
|
-
`,stderr:"",exitCode:0}:{stdout:"",stderr:"",exitCode:0};if(s)return{stdout:`Files ${c} and ${m} differ
|
|
27
|
-
`,stderr:"",exitCode:1};let C=F(u),w=F(l),P=q(C,w,a),d;return e.unified?d=X(c,m,C,w,P,D):e.context?d=B(c,m,C,w,P,D):d=U(C,w,P),{stdout:d,stderr:"",exitCode:1}}},at={name:"diff",flags:[{flag:"--normal",type:"boolean"},{flag:"-u",type:"boolean"},{flag:"-c",type:"boolean"},{flag:"-q",type:"boolean"},{flag:"-s",type:"boolean"},{flag:"-i",type:"boolean"}],needsArgs:!0,minArgs:2};export{ft as a,at as b};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import{createRequire} from"node:module";const require=createRequire(import.meta.url);
|
|
3
|
-
import{b as a}from"./chunk-HWI42GQO.js";var s=globalThis.setTimeout.bind(globalThis),l=globalThis.clearTimeout.bind(globalThis),T=globalThis.setInterval.bind(globalThis),f=globalThis.clearInterval.bind(globalThis);function u(e){return typeof e!="function"?e:a.bindCurrentContext(e)}var b=((e,n,...i)=>s(u(e),n,...i)),d=l,c=2147483647;function I(e,n){if(n===Number.POSITIVE_INFINITY)return;let i=u(e),t={cleared:!1,remainingMs:Math.max(0,n),timer:void 0},r=()=>{if(t.cleared)return;let o=Math.min(t.remainingMs,c);t.timer=s(()=>{t.cleared||(t.remainingMs-=o,t.remainingMs>0?r():i())},o)};return r(),t}function _(e){e&&(e.cleared=!0,e.timer!==void 0&&l(e.timer))}export{b as a,d as b,I as c,_ as d};
|