@kaynooo/cli-check 0.18.0 → 0.18.2
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 +3 -2
- package/dist/cli.js +135 -80
- package/dist/errs-cli.js +112 -62
- package/dist/fix-cli.js +122 -69
- package/dist/j-cli.js +159 -107
- package/package.json +2 -2
package/dist/fix-cli.js
CHANGED
|
@@ -2,13 +2,14 @@
|
|
|
2
2
|
// @bun
|
|
3
3
|
|
|
4
4
|
// src/fix-cli.ts
|
|
5
|
-
import
|
|
5
|
+
import process20 from "process";
|
|
6
6
|
// ../kit/src/args.ts
|
|
7
7
|
import process10 from "process";
|
|
8
8
|
import { parseArgs } from "util";
|
|
9
9
|
|
|
10
10
|
// ../kit/src/format.ts
|
|
11
11
|
import process7 from "process";
|
|
12
|
+
|
|
12
13
|
// ../../node_modules/.bun/@kaynooo+utils@3.0.0+4c7ddab9986847c5/node_modules/@kaynooo/utils/dist/chunk-rxztfxgv.js
|
|
13
14
|
var N = new Map;
|
|
14
15
|
var Nt = /\s+\S*$/;
|
|
@@ -26,6 +27,7 @@ function ko(t, e, r = "...") {
|
|
|
26
27
|
}
|
|
27
28
|
var be = new Map(["\u20AC", "", "\u201A", "\u0192", "\u201E", "\u2026", "\u2020", "\u2021", "\u02C6", "\u2030", "\u0160", "\u2039", "\u0152", "", "\u017D", "", "", "\u2018", "\u2019", "\u201C", "\u201D", "\u2022", "\u2013", "\u2014", "\u02DC", "\u2122", "\u0161", "\u203A", "\u0153", "", "\u017E", "\u0178"].map((t, e) => [t, 128 + e]).filter(([t]) => t));
|
|
28
29
|
var z = new Map;
|
|
30
|
+
|
|
29
31
|
// ../kit/src/mode.ts
|
|
30
32
|
import process2 from "process";
|
|
31
33
|
var MODES = new Set(["terminal", "ci", "agent", "pipe"]);
|
|
@@ -74,7 +76,7 @@ function C(r, e = globalThis.process?.env ?? {}) {
|
|
|
74
76
|
return false;
|
|
75
77
|
return r?.isTTY === true;
|
|
76
78
|
}
|
|
77
|
-
function
|
|
79
|
+
function f(r, e = []) {
|
|
78
80
|
let l = "", n = "";
|
|
79
81
|
for (let t = 0, i = e.length;t < i; t++)
|
|
80
82
|
l += `\x1B[${e[t][0]}m`, n = `\x1B[${e[t][1]}m${n}`;
|
|
@@ -84,7 +86,7 @@ function f2(r, e = []) {
|
|
|
84
86
|
if (Array.isArray(a)) {
|
|
85
87
|
let s = g.get(i);
|
|
86
88
|
if (s === undefined)
|
|
87
|
-
s =
|
|
89
|
+
s = f(r, [...e, a]), g.set(i, s);
|
|
88
90
|
return s;
|
|
89
91
|
}
|
|
90
92
|
if (typeof a === "function")
|
|
@@ -93,20 +95,20 @@ function f2(r, e = []) {
|
|
|
93
95
|
if (u === undefined) {
|
|
94
96
|
if (g.size >= 64)
|
|
95
97
|
g.clear();
|
|
96
|
-
u =
|
|
98
|
+
u = f(r, [...e, a(...s)]), g.set(y, u);
|
|
97
99
|
}
|
|
98
100
|
return u;
|
|
99
101
|
};
|
|
100
102
|
throw Error(`Unknown style: ${String(i)}`);
|
|
101
103
|
} });
|
|
102
104
|
}
|
|
103
|
-
function
|
|
104
|
-
return
|
|
105
|
+
function Fe(r = {}) {
|
|
106
|
+
return f(r);
|
|
105
107
|
}
|
|
106
|
-
var
|
|
108
|
+
var o = Fe();
|
|
107
109
|
|
|
108
110
|
// ../kit/src/theme.ts
|
|
109
|
-
import { existsSync as
|
|
111
|
+
import { existsSync as existsSync3, readFileSync as readFileSync2, statSync } from "fs";
|
|
110
112
|
import { homedir as homedir2 } from "os";
|
|
111
113
|
import { join as join3, resolve as resolve2 } from "path";
|
|
112
114
|
import process5 from "process";
|
|
@@ -127,6 +129,7 @@ function findUp(names, from = process3.cwd(), stop = () => false) {
|
|
|
127
129
|
}
|
|
128
130
|
|
|
129
131
|
// ../kit/src/user-config.ts
|
|
132
|
+
import { existsSync as existsSync2, readFileSync } from "fs";
|
|
130
133
|
import { homedir } from "os";
|
|
131
134
|
import { join as join2 } from "path";
|
|
132
135
|
import process4 from "process";
|
|
@@ -137,6 +140,24 @@ function configBase(where = {}) {
|
|
|
137
140
|
function userConfigPath(bin, where = {}) {
|
|
138
141
|
return join2(configBase(where), "kaynooo-cli", `${bin}.json`);
|
|
139
142
|
}
|
|
143
|
+
function userConfigReadPath(bin, legacy = [], where = {}) {
|
|
144
|
+
const current = userConfigPath(bin, where);
|
|
145
|
+
if (existsSync2(current))
|
|
146
|
+
return current;
|
|
147
|
+
const base = configBase(where);
|
|
148
|
+
return legacy.map((parts) => join2(base, ...parts)).find((path) => existsSync2(path)) ?? current;
|
|
149
|
+
}
|
|
150
|
+
function readUserConfig(bin, where = {}, legacy = []) {
|
|
151
|
+
const path = userConfigReadPath(bin, legacy, where);
|
|
152
|
+
if (!existsSync2(path))
|
|
153
|
+
return {};
|
|
154
|
+
try {
|
|
155
|
+
const parsed = Bun.JSONC.parse(readFileSync(path, "utf8"));
|
|
156
|
+
return typeof parsed === "object" && parsed !== null && !Array.isArray(parsed) ? parsed : {};
|
|
157
|
+
} catch {
|
|
158
|
+
return {};
|
|
159
|
+
}
|
|
160
|
+
}
|
|
140
161
|
|
|
141
162
|
// ../kit/src/theme.ts
|
|
142
163
|
var ENDS = new Map;
|
|
@@ -203,7 +224,7 @@ function readThemeFile(path, warn) {
|
|
|
203
224
|
warn(`${path} is not a regular file under ${MAX_FILE_BYTES / 1024} KiB, theme ignored`);
|
|
204
225
|
return;
|
|
205
226
|
}
|
|
206
|
-
const parsed = JSON.parse(
|
|
227
|
+
const parsed = JSON.parse(readFileSync2(path, "utf8"));
|
|
207
228
|
if (isRecord(parsed))
|
|
208
229
|
return parsed;
|
|
209
230
|
warn(`${path} is not a JSON object, theme ignored`);
|
|
@@ -269,7 +290,7 @@ function applyFile(theme, file, where, warn) {
|
|
|
269
290
|
}
|
|
270
291
|
}
|
|
271
292
|
function endsWalk(home) {
|
|
272
|
-
return (dir) => dir === resolve2(home) ||
|
|
293
|
+
return (dir) => dir === resolve2(home) || existsSync3(join3(dir, ".git"));
|
|
273
294
|
}
|
|
274
295
|
var warned = new Set;
|
|
275
296
|
function warnOnce(message) {
|
|
@@ -325,7 +346,7 @@ function takesControlCodes(stream, env = process6.env) {
|
|
|
325
346
|
return stream.isTTY === true && env.NO_COLOR === undefined && env.NODE_DISABLE_COLORS === undefined && env.TERM !== "dumb" && outputMode(stream, env) === "terminal";
|
|
326
347
|
}
|
|
327
348
|
function paint(stream, env = process6.env) {
|
|
328
|
-
return
|
|
349
|
+
return Fe({ stream: { isTTY: takesControlCodes(stream, env) }, env });
|
|
329
350
|
}
|
|
330
351
|
function marked(mark, text, stream, detail, env = process6.env) {
|
|
331
352
|
const colors = paint(stream, env);
|
|
@@ -759,9 +780,33 @@ function nearestOption(message, options, allowNegative) {
|
|
|
759
780
|
const meant = closest(word, known.map((flag) => flag.replace(DASHES, "")));
|
|
760
781
|
return meant === undefined ? undefined : `did you mean ${known.find((flag) => flag.replace(DASHES, "") === meant)}?`;
|
|
761
782
|
}
|
|
783
|
+
// ../kit/src/argv.ts
|
|
784
|
+
import { readFileSync as readFileSync3, realpathSync } from "fs";
|
|
785
|
+
import { resolve as resolve3 } from "path";
|
|
786
|
+
import process11 from "process";
|
|
787
|
+
function commandLine() {
|
|
788
|
+
try {
|
|
789
|
+
return readFileSync3("/proc/self/cmdline", "utf8").split("\x00").slice(0, -1);
|
|
790
|
+
} catch {
|
|
791
|
+
return;
|
|
792
|
+
}
|
|
793
|
+
}
|
|
794
|
+
function realPath(word) {
|
|
795
|
+
try {
|
|
796
|
+
return realpathSync(resolve3(word));
|
|
797
|
+
} catch {
|
|
798
|
+
return;
|
|
799
|
+
}
|
|
800
|
+
}
|
|
801
|
+
function scriptArgs(argv = process11.argv.slice(2), cmdline = commandLine(), script = process11.argv[1]) {
|
|
802
|
+
const target = script === undefined ? undefined : realPath(script) ?? script;
|
|
803
|
+
const at = cmdline === undefined || target === undefined ? -1 : cmdline.findIndex((word, index) => index > 0 && (resolve3(word) === script || realPath(word) === target));
|
|
804
|
+
const after = at === -1 ? [] : cmdline.slice(at + 1);
|
|
805
|
+
return after[0] === "--" && after.length === argv.length + 1 && argv.every((word, index) => word === after[index + 1]) ? after : argv;
|
|
806
|
+
}
|
|
762
807
|
// ../kit/src/process.ts
|
|
763
808
|
import { constants } from "os";
|
|
764
|
-
import
|
|
809
|
+
import process12 from "process";
|
|
765
810
|
var KILL_GRACE_MS = 2000;
|
|
766
811
|
var SIGNALS = ["SIGINT", "SIGTERM", "SIGHUP"];
|
|
767
812
|
function exitCodeOf(code, signal) {
|
|
@@ -783,7 +828,7 @@ function holdSignals(cleanup) {
|
|
|
783
828
|
},
|
|
784
829
|
release: () => {
|
|
785
830
|
for (const signal of SIGNALS)
|
|
786
|
-
|
|
831
|
+
process12.off(signal, onSignal);
|
|
787
832
|
}
|
|
788
833
|
};
|
|
789
834
|
function onSignal(signal) {
|
|
@@ -796,10 +841,10 @@ function holdSignals(cleanup) {
|
|
|
796
841
|
return;
|
|
797
842
|
held.release();
|
|
798
843
|
cleanup(signal);
|
|
799
|
-
|
|
844
|
+
process12.kill(process12.pid, signal);
|
|
800
845
|
}
|
|
801
846
|
for (const signal of SIGNALS)
|
|
802
|
-
|
|
847
|
+
process12.on(signal, onSignal);
|
|
803
848
|
return held;
|
|
804
849
|
}
|
|
805
850
|
async function runCommand(argv, { cwd, env, stdin = "ignore", timeoutMs, signal, maxBytes = Infinity, onChunk, onStart } = {}) {
|
|
@@ -813,7 +858,7 @@ async function runCommand(argv, { cwd, env, stdin = "ignore", timeoutMs, signal,
|
|
|
813
858
|
return;
|
|
814
859
|
try {
|
|
815
860
|
if (grouped)
|
|
816
|
-
|
|
861
|
+
process12.kill(-proc.pid, killing);
|
|
817
862
|
else
|
|
818
863
|
proc.kill(killing);
|
|
819
864
|
} catch {}
|
|
@@ -887,33 +932,33 @@ var ESCAPE_CODE = new RegExp(`${ESC}(?:\\[[\\x30-\\x3F]*[\\x20-\\x2F]*[\\x40-\\x
|
|
|
887
932
|
var RESET_STYLE = `${ESC}[0m`;
|
|
888
933
|
var CLOSE_LINK = `${ESC}]8;;${ESC}\\`;
|
|
889
934
|
// ../kit/src/cli.ts
|
|
890
|
-
import { readFileSync as
|
|
935
|
+
import { readFileSync as readFileSync4, realpathSync as realpathSync2 } from "fs";
|
|
891
936
|
import { dirname as dirname3, join as join6 } from "path";
|
|
892
|
-
import
|
|
937
|
+
import process15 from "process";
|
|
893
938
|
|
|
894
939
|
// ../kit/src/usage.ts
|
|
895
940
|
import { appendFileSync, mkdirSync } from "fs";
|
|
896
941
|
import { homedir as homedir4 } from "os";
|
|
897
942
|
import { dirname as dirname2, isAbsolute, join as join5 } from "path";
|
|
898
|
-
import
|
|
943
|
+
import process14 from "process";
|
|
899
944
|
|
|
900
945
|
// ../kit/src/logs.ts
|
|
901
946
|
import { lstatSync, openSync } from "fs";
|
|
902
947
|
import { mkdir, mkdtemp, readdir, rm, stat } from "fs/promises";
|
|
903
948
|
import { homedir as homedir3, tmpdir } from "os";
|
|
904
949
|
import { join as join4 } from "path";
|
|
905
|
-
import
|
|
950
|
+
import process13 from "process";
|
|
906
951
|
var DAY_MS = 24 * 60 * 60 * 1000;
|
|
907
952
|
var CLI_FOLDER = "kaynooo-cli";
|
|
908
953
|
function isPrivateDirectory(path) {
|
|
909
954
|
try {
|
|
910
955
|
const info = lstatSync(path, { throwIfNoEntry: false });
|
|
911
|
-
return info !== undefined && info.isDirectory() && info.uid === (
|
|
956
|
+
return info !== undefined && info.isDirectory() && info.uid === (process13.getuid?.() ?? info.uid) && (info.mode & 63) === 0;
|
|
912
957
|
} catch {
|
|
913
958
|
return false;
|
|
914
959
|
}
|
|
915
960
|
}
|
|
916
|
-
async function privateLogDirectory(name, env =
|
|
961
|
+
async function privateLogDirectory(name, env = process13.env) {
|
|
917
962
|
const runtime = env.XDG_RUNTIME_DIR;
|
|
918
963
|
const base = runtime === undefined || runtime === "" ? join4(homedir3(), ".cache", CLI_FOLDER) : join4(runtime, CLI_FOLDER);
|
|
919
964
|
const path = join4(base, name);
|
|
@@ -953,14 +998,14 @@ var usageError;
|
|
|
953
998
|
function noteUsageError(message) {
|
|
954
999
|
usageError = message;
|
|
955
1000
|
}
|
|
956
|
-
function stateHome(env =
|
|
1001
|
+
function stateHome(env = process14.env) {
|
|
957
1002
|
const dir = env.XDG_STATE_HOME;
|
|
958
1003
|
return dir !== undefined && isAbsolute(dir) ? dir : join5(homedir4(), ".local", "state");
|
|
959
1004
|
}
|
|
960
|
-
function usagePath(env =
|
|
1005
|
+
function usagePath(env = process14.env) {
|
|
961
1006
|
return join5(stateHome(env), CLI_FOLDER, "usage.jsonl");
|
|
962
1007
|
}
|
|
963
|
-
function usageRecorded(env =
|
|
1008
|
+
function usageRecorded(env = process14.env) {
|
|
964
1009
|
const off = env.KAYNOOO_CLI_NO_USAGE;
|
|
965
1010
|
return env.NODE_ENV !== "test" && (off === undefined || off === "" || off === "0");
|
|
966
1011
|
}
|
|
@@ -974,7 +1019,7 @@ function usageEntry(bin, command, argv, code, now = new Date) {
|
|
|
974
1019
|
usageError = undefined;
|
|
975
1020
|
return { at: now.toISOString(), bin, ...command === undefined ? {} : { command }, flags: flagNames(argv), code, ...unknown === undefined ? {} : { unknown } };
|
|
976
1021
|
}
|
|
977
|
-
function recordUsage(entry, env =
|
|
1022
|
+
function recordUsage(entry, env = process14.env) {
|
|
978
1023
|
if (!usageRecorded(env))
|
|
979
1024
|
return;
|
|
980
1025
|
try {
|
|
@@ -992,8 +1037,8 @@ var LEVEL_OPTIONS = {
|
|
|
992
1037
|
};
|
|
993
1038
|
var TOP_OPTIONS = { ...LEVEL_OPTIONS, version: { type: "boolean", short: "v", description: "print the version" } };
|
|
994
1039
|
function printError(prefix, message, hint, cause) {
|
|
995
|
-
const colors = paint(
|
|
996
|
-
const styled = takesControlCodes(
|
|
1040
|
+
const colors = paint(process15.stderr);
|
|
1041
|
+
const styled = takesControlCodes(process15.stderr);
|
|
997
1042
|
const head = styled ? `${colors.red.bold("error")} ${colors.dim(`${prefix}:`)}` : `error: ${prefix}:`;
|
|
998
1043
|
const under = (label, text, tint) => text === undefined ? "" : `
|
|
999
1044
|
${styled ? tint(label) : `${label}:`} ${text}`;
|
|
@@ -1037,24 +1082,24 @@ function candidateLine(candidate) {
|
|
|
1037
1082
|
}
|
|
1038
1083
|
function positionalBeingTyped(before, { options, positionals }) {
|
|
1039
1084
|
const takesValue = (word) => !word.includes("=") && Object.entries(options).some(([name, { short, type }]) => type === "string" && (word === `--${name}` || word === `-${short}`));
|
|
1040
|
-
|
|
1085
|
+
const typed = [];
|
|
1041
1086
|
let at = 0;
|
|
1042
1087
|
while (at < before.length) {
|
|
1043
1088
|
const word = before[at];
|
|
1044
1089
|
if (word === "--") {
|
|
1045
|
-
|
|
1090
|
+
typed.push(...before.slice(at + 1));
|
|
1046
1091
|
break;
|
|
1047
1092
|
}
|
|
1048
1093
|
if (!word.startsWith("-"))
|
|
1049
|
-
|
|
1094
|
+
typed.push(word);
|
|
1050
1095
|
else if (takesValue(word))
|
|
1051
1096
|
at++;
|
|
1052
1097
|
at++;
|
|
1053
1098
|
}
|
|
1054
1099
|
const last = positionals.at(-1);
|
|
1055
|
-
if (
|
|
1056
|
-
return positionals[
|
|
1057
|
-
return last?.replace("]", "").endsWith("...") === true ? last : undefined;
|
|
1100
|
+
if (typed.length < positionals.length)
|
|
1101
|
+
return { name: positionals[typed.length], typed };
|
|
1102
|
+
return { name: last?.replace("]", "").endsWith("...") === true ? last : undefined, typed };
|
|
1058
1103
|
}
|
|
1059
1104
|
async function leafCandidates(run, words) {
|
|
1060
1105
|
const completing = await completingOf(run);
|
|
@@ -1062,12 +1107,12 @@ async function leafCandidates(run, words) {
|
|
|
1062
1107
|
return Object.entries(completing.options).map(([name, option]) => option.description === undefined ? `--${name}` : `--${name} ${option.description}`);
|
|
1063
1108
|
const flag = words.at(-2);
|
|
1064
1109
|
const option = flag?.startsWith("-") === true ? Object.entries(completing.options).find(([name, { short }]) => flag === `--${name}` || flag === `-${short}`)?.[1] : undefined;
|
|
1110
|
+
const { name, typed } = positionalBeingTyped(words.slice(0, -1), completing);
|
|
1065
1111
|
if (option?.type === "string") {
|
|
1066
|
-
const values = option.choices === undefined ? await option.candidates?.() : option.choices;
|
|
1112
|
+
const values = option.choices === undefined ? await option.candidates?.(typed) : option.choices;
|
|
1067
1113
|
return values === undefined ? [FILES] : values.map(candidateLine);
|
|
1068
1114
|
}
|
|
1069
|
-
const
|
|
1070
|
-
const values = name === undefined ? undefined : await completing.candidates[name]?.();
|
|
1115
|
+
const values = name === undefined ? undefined : await completing.candidates[name]?.(typed);
|
|
1071
1116
|
return values === undefined ? [FILES] : values.map(candidateLine);
|
|
1072
1117
|
}
|
|
1073
1118
|
async function printCandidates(found) {
|
|
@@ -1076,9 +1121,9 @@ async function printCandidates(found) {
|
|
|
1076
1121
|
return 0;
|
|
1077
1122
|
}
|
|
1078
1123
|
function packageVersion(entry = Bun.main) {
|
|
1079
|
-
for (let dir = dirname3(
|
|
1124
|
+
for (let dir = dirname3(realpathSync2(entry));; dir = dirname3(dir)) {
|
|
1080
1125
|
try {
|
|
1081
|
-
const { version } = JSON.parse(
|
|
1126
|
+
const { version } = JSON.parse(readFileSync4(join6(dir, "package.json"), "utf8"));
|
|
1082
1127
|
if (typeof version === "string")
|
|
1083
1128
|
return version;
|
|
1084
1129
|
} catch {}
|
|
@@ -1086,7 +1131,7 @@ function packageVersion(entry = Bun.main) {
|
|
|
1086
1131
|
return "0.0.0";
|
|
1087
1132
|
}
|
|
1088
1133
|
}
|
|
1089
|
-
async function runMain({ name, version, run, redact, usage }, argv =
|
|
1134
|
+
async function runMain({ name, version, run, redact, usage }, argv = scriptArgs()) {
|
|
1090
1135
|
if (argv[0] === COMPLETE)
|
|
1091
1136
|
return printCandidates(leafCandidates(run, argv.slice(1)));
|
|
1092
1137
|
if (argv.length === 1 && (argv[0] === "--version" || argv[0] === "-v")) {
|
|
@@ -1108,6 +1153,11 @@ async function runMain({ name, version, run, redact, usage }, argv = process14.a
|
|
|
1108
1153
|
}
|
|
1109
1154
|
// ../kit/src/folders.ts
|
|
1110
1155
|
var SKIPPED_FOLDERS = new Set(["node_modules", "vendor", "dist", "build", "target", "coverage", "venv", "__pycache__"]);
|
|
1156
|
+
function ignoredFolders(extra = [], where = {}) {
|
|
1157
|
+
const configured = readUserConfig("config", where).ignore;
|
|
1158
|
+
const names = Array.isArray(configured) ? configured.filter((name) => typeof name === "string" && name !== "") : [];
|
|
1159
|
+
return new Set([...SKIPPED_FOLDERS, ...extra, ...names]);
|
|
1160
|
+
}
|
|
1111
1161
|
// ../kit/src/secrets.ts
|
|
1112
1162
|
var SECRET_WORDS = new Set(["key", "pass", "pwd", "auth", "salt", "cookie", "session", "jwt", "ssn", "iban", "card", "cvv", "otp"]);
|
|
1113
1163
|
// ../kit/src/sessions.ts
|
|
@@ -1115,13 +1165,13 @@ var {Glob } = globalThis.Bun;
|
|
|
1115
1165
|
var SESSION_FILES = new Glob("*.json");
|
|
1116
1166
|
var ACCOUNT_DIRS = new Glob("*/sessions");
|
|
1117
1167
|
// package.json
|
|
1118
|
-
var version = "0.18.
|
|
1168
|
+
var version = "0.18.2";
|
|
1119
1169
|
|
|
1120
1170
|
// src/fix.ts
|
|
1121
|
-
import { existsSync as
|
|
1171
|
+
import { existsSync as existsSync5, statSync as statSync2 } from "fs";
|
|
1122
1172
|
import { rename, writeFile as writeFile2 } from "fs/promises";
|
|
1123
1173
|
import { join as join11 } from "path";
|
|
1124
|
-
import
|
|
1174
|
+
import process19 from "process";
|
|
1125
1175
|
|
|
1126
1176
|
// src/changes.ts
|
|
1127
1177
|
import { stat as stat2 } from "fs/promises";
|
|
@@ -1147,10 +1197,10 @@ function changedFiles(before, after) {
|
|
|
1147
1197
|
}
|
|
1148
1198
|
|
|
1149
1199
|
// src/compose.ts
|
|
1150
|
-
import { existsSync as
|
|
1200
|
+
import { existsSync as existsSync4 } from "fs";
|
|
1151
1201
|
import { homedir as homedir5 } from "os";
|
|
1152
|
-
import { basename, dirname as dirname4, join as join8, relative, resolve as
|
|
1153
|
-
import
|
|
1202
|
+
import { basename, dirname as dirname4, join as join8, relative, resolve as resolve4 } from "path";
|
|
1203
|
+
import process17 from "process";
|
|
1154
1204
|
|
|
1155
1205
|
// ../kit/src/shell.ts
|
|
1156
1206
|
var SEPARATORS = new Set([`
|
|
@@ -1243,7 +1293,7 @@ async function variables(composeDir) {
|
|
|
1243
1293
|
if (match !== null && !line.trimStart().startsWith("#"))
|
|
1244
1294
|
env[match[1] ?? ""] = (match[2] ?? "").trim().replace(QUOTED, "$2");
|
|
1245
1295
|
}
|
|
1246
|
-
for (const [key, value] of Object.entries(
|
|
1296
|
+
for (const [key, value] of Object.entries(process17.env)) {
|
|
1247
1297
|
if (value !== undefined)
|
|
1248
1298
|
env[key] = value;
|
|
1249
1299
|
}
|
|
@@ -1265,8 +1315,8 @@ function bindSource(source, composeDir, env) {
|
|
|
1265
1315
|
if (path.startsWith("~"))
|
|
1266
1316
|
return join8(homedir5(), path.slice(1));
|
|
1267
1317
|
if (path.startsWith("/"))
|
|
1268
|
-
return
|
|
1269
|
-
return path.startsWith(".") ?
|
|
1318
|
+
return resolve4(path);
|
|
1319
|
+
return path.startsWith(".") ? resolve4(composeDir, path) : undefined;
|
|
1270
1320
|
}
|
|
1271
1321
|
function mountsOf(volumes, composeDir, env) {
|
|
1272
1322
|
if (!Array.isArray(volumes))
|
|
@@ -1308,7 +1358,7 @@ async function composeFiles(composeDir, env) {
|
|
|
1308
1358
|
const files = [];
|
|
1309
1359
|
const separator = env.COMPOSE_PATH_SEPARATOR;
|
|
1310
1360
|
for (const name of listed.split(separator === undefined || separator === "" ? ":" : separator).filter((entry) => entry !== "")) {
|
|
1311
|
-
const file = Bun.file(
|
|
1361
|
+
const file = Bun.file(resolve4(composeDir, name));
|
|
1312
1362
|
if (!await file.exists())
|
|
1313
1363
|
fail(`COMPOSE_FILE names ${join8(composeDir, name)}, which does not exist`, 1, "fix COMPOSE_FILE, or run on the host with --host");
|
|
1314
1364
|
files.push({ name, text: await file.text() });
|
|
@@ -1344,11 +1394,11 @@ async function readServices(composeDir) {
|
|
|
1344
1394
|
function climb(dir) {
|
|
1345
1395
|
const folders = [dir];
|
|
1346
1396
|
let current = dir;
|
|
1347
|
-
while (!
|
|
1397
|
+
while (!existsSync4(join8(current, ".git")) && dirname4(current) !== current) {
|
|
1348
1398
|
current = dirname4(current);
|
|
1349
1399
|
folders.push(current);
|
|
1350
1400
|
}
|
|
1351
|
-
return
|
|
1401
|
+
return existsSync4(join8(current, ".git")) ? folders : [dir];
|
|
1352
1402
|
}
|
|
1353
1403
|
function containerPath(service, dir) {
|
|
1354
1404
|
const holding = service.mounts.filter((mount) => {
|
|
@@ -1379,7 +1429,7 @@ async function place(dir, program, { service, host } = {}) {
|
|
|
1379
1429
|
fail(`--in ${service}: no compose project mounts ${dir}`);
|
|
1380
1430
|
return;
|
|
1381
1431
|
}
|
|
1382
|
-
if (Bun.which("docker", { PATH:
|
|
1432
|
+
if (Bun.which("docker", { PATH: process17.env.PATH ?? "" }) === null) {
|
|
1383
1433
|
if (service !== undefined)
|
|
1384
1434
|
fail(`--in ${service}: docker not found`);
|
|
1385
1435
|
if (!noticed.has(found.composeDir)) {
|
|
@@ -1431,7 +1481,7 @@ class Stack {
|
|
|
1431
1481
|
}
|
|
1432
1482
|
static async running(composeDir) {
|
|
1433
1483
|
try {
|
|
1434
|
-
const ran = await runCommand(["docker", "compose", "ps", "--services", "--status", "running"], { cwd: composeDir, env:
|
|
1484
|
+
const ran = await runCommand(["docker", "compose", "ps", "--services", "--status", "running"], { cwd: composeDir, env: process17.env, timeoutMs: PS_TIMEOUT_MS });
|
|
1435
1485
|
if (ran.code !== 0)
|
|
1436
1486
|
return `docker compose ps failed in ${composeDir}: ${ran.text.trim().split(`
|
|
1437
1487
|
`).at(-1) ?? `exit ${ran.code}`}`;
|
|
@@ -1499,12 +1549,12 @@ import { join as join9 } from "path";
|
|
|
1499
1549
|
var STEP_NAMES = ["check", "typecheck", "lint", "test"];
|
|
1500
1550
|
var TARGET2 = /^@?([\w-]+)(?:[ \t][^:=\n]*)?:(?!=)/gm;
|
|
1501
1551
|
var JUSTFILES = ["justfile", "Justfile", ".justfile"];
|
|
1552
|
+
var TASK_RUNNERS = new Set(["Justfile", "Makefile"]);
|
|
1502
1553
|
var MAKEFILES = ["GNUmakefile", "makefile", "Makefile"];
|
|
1503
1554
|
var CS_FIXER_CONFIGS = [".php-cs-fixer.php", ".php-cs-fixer.dist.php"];
|
|
1504
1555
|
var JUST_TIMEOUT_MS = 1e4;
|
|
1505
1556
|
var PHPSTAN_CONFIGS = ["phpstan.neon", "phpstan.neon.dist", "phpstan.dist.neon"];
|
|
1506
1557
|
var PHPUNIT_CONFIGS = ["phpunit.xml", "phpunit.xml.dist", "phpunit.dist.xml"];
|
|
1507
|
-
var SKIPPED = new Set([...SKIPPED_FOLDERS, "var", "tmp"]);
|
|
1508
1558
|
async function readFirst(dir, files) {
|
|
1509
1559
|
for (const file of files) {
|
|
1510
1560
|
const handle = Bun.file(join9(dir, file));
|
|
@@ -1599,8 +1649,9 @@ async function discoverProjects(dir) {
|
|
|
1599
1649
|
return [{ dir, steps: own }];
|
|
1600
1650
|
const projects = [];
|
|
1601
1651
|
const entries = await readdir2(dir, { withFileTypes: true });
|
|
1652
|
+
const ignored = ignoredFolders(["var", "tmp"]);
|
|
1602
1653
|
for (const entry of entries.toSorted((a, b) => a.name.localeCompare(b.name))) {
|
|
1603
|
-
if (!entry.isDirectory() || entry.name.startsWith(".") ||
|
|
1654
|
+
if (!entry.isDirectory() || entry.name.startsWith(".") || ignored.has(entry.name))
|
|
1604
1655
|
continue;
|
|
1605
1656
|
const steps = await discover(join9(dir, entry.name));
|
|
1606
1657
|
if (steps.length > 0)
|
|
@@ -1610,8 +1661,9 @@ async function discoverProjects(dir) {
|
|
|
1610
1661
|
}
|
|
1611
1662
|
async function discover(dir) {
|
|
1612
1663
|
const found = await candidates(dir, "check");
|
|
1664
|
+
const runnerCheck = found.find((candidate) => candidate.name === "check" && TASK_RUNNERS.has(candidate.source));
|
|
1613
1665
|
return STEP_NAMES.flatMap((name) => {
|
|
1614
|
-
const step = found.find((candidate) => candidate.name === name);
|
|
1666
|
+
const step = name === "check" && runnerCheck !== undefined ? runnerCheck : found.find((candidate) => candidate.name === name);
|
|
1615
1667
|
return step === undefined ? [] : [step];
|
|
1616
1668
|
});
|
|
1617
1669
|
}
|
|
@@ -1627,6 +1679,7 @@ var fixOptions = {
|
|
|
1627
1679
|
var options = {
|
|
1628
1680
|
...fixOptions,
|
|
1629
1681
|
fix: { type: "boolean", short: "f", description: "run the folder's fixers and formatters instead of the steps, as the fix bin does" },
|
|
1682
|
+
quiet: { type: "boolean", short: "q", description: "print nothing for a passing step, and nothing at all when every step passes" },
|
|
1630
1683
|
failed: { type: "boolean", description: "run only the steps that failed in the last run of this folder, read from the run folder" },
|
|
1631
1684
|
changed: { type: "boolean", short: "c", description: "narrow lint and test to the files changed against HEAD (a bare linter script, a bare bun test script), every other step runs in full and says so" },
|
|
1632
1685
|
slot: { type: "boolean", description: "run each step through slot, queued behind the machine-wide slots of the other sessions (needs the slot bin)" }
|
|
@@ -1647,7 +1700,7 @@ function pick(steps, only, noun = "step") {
|
|
|
1647
1700
|
// src/run.ts
|
|
1648
1701
|
import { mkdir as mkdir2, readdir as readdir3, stat as stat3, writeFile } from "fs/promises";
|
|
1649
1702
|
import { basename as basename2, join as join10 } from "path";
|
|
1650
|
-
import
|
|
1703
|
+
import process18 from "process";
|
|
1651
1704
|
|
|
1652
1705
|
// src/e2e.ts
|
|
1653
1706
|
var E2E_NOISE = [
|
|
@@ -2282,7 +2335,7 @@ var runPrefix = (cwd) => `${basename2(cwd)}-${Bun.hash(cwd).toString(36)}-`;
|
|
|
2282
2335
|
async function logDirectory(cwd) {
|
|
2283
2336
|
const root = await privateLogDirectory("check");
|
|
2284
2337
|
await sweepLogs(root, LOG_MAX_AGE_MS);
|
|
2285
|
-
const path = join10(root, `${runPrefix(cwd)}${Date.now().toString(36)}-${
|
|
2338
|
+
const path = join10(root, `${runPrefix(cwd)}${Date.now().toString(36)}-${process18.pid}`);
|
|
2286
2339
|
await mkdir2(path, { mode: 448 });
|
|
2287
2340
|
return path;
|
|
2288
2341
|
}
|
|
@@ -2308,7 +2361,7 @@ async function lastFailed(cwd) {
|
|
|
2308
2361
|
async function saveLog(output) {
|
|
2309
2362
|
const root = await privateLogDirectory("errs");
|
|
2310
2363
|
await sweepLogs(root);
|
|
2311
|
-
const path = join10(root, `${new Date().toISOString().replaceAll(/[:.]/g, "-")}-${
|
|
2364
|
+
const path = join10(root, `${new Date().toISOString().replaceAll(/[:.]/g, "-")}-${process18.pid}-${crypto.randomUUID().slice(0, 8)}.log`);
|
|
2312
2365
|
await writeFile(path, output, { mode: 384, flag: "wx" });
|
|
2313
2366
|
return path;
|
|
2314
2367
|
}
|
|
@@ -2316,7 +2369,7 @@ async function runStep(command, cwd, logFile, { env = {}, timeoutMs, held } = {}
|
|
|
2316
2369
|
const started = Date.now();
|
|
2317
2370
|
const { code, text, timedOut } = await runCommand(["sh", "-c", `${command} 2>&1`], {
|
|
2318
2371
|
cwd,
|
|
2319
|
-
env: { ...
|
|
2372
|
+
env: { ...process18.env, NO_COLOR: "1", FORCE_COLOR: "0", ...env },
|
|
2320
2373
|
...timeoutMs === undefined ? {} : { timeoutMs },
|
|
2321
2374
|
...held === undefined ? {} : { onStart: (child) => held.forward(child) }
|
|
2322
2375
|
});
|
|
@@ -2332,8 +2385,8 @@ function outcomeJson(name, command, logFile, outcome, service) {
|
|
|
2332
2385
|
return { name, command, ...service === undefined ? {} : { in: service }, ok: outcome.ok, ms: outcome.ms, log: logFile, ...outcome.timedOut === true ? { timedOut: true } : {}, ...outcome.ok ? {} : { failed: failureExcerpt(outcome.output) } };
|
|
2333
2386
|
}
|
|
2334
2387
|
function printOutcome(name, width, command, logFile, outcome) {
|
|
2335
|
-
const colors = paint(
|
|
2336
|
-
const path = role("path",
|
|
2388
|
+
const colors = paint(process18.stdout);
|
|
2389
|
+
const path = role("path", process18.stdout);
|
|
2337
2390
|
const took = colors.dim(formatDuration(outcome.ms));
|
|
2338
2391
|
if (outcome.ok) {
|
|
2339
2392
|
console.log(`${colors.bold(colors.green("ok "))} ${name.padEnd(width)} ${took} ${path(logFile)}`);
|
|
@@ -2364,7 +2417,7 @@ var RUFF_CONFIGS = ["ruff.toml", ".ruff.toml"];
|
|
|
2364
2417
|
var RUFF_SECTION = /^\[tool\.ruff/m;
|
|
2365
2418
|
var MAX_CHANGED = 30;
|
|
2366
2419
|
async function replaceFile(path, content) {
|
|
2367
|
-
const temporary = `${path}.${
|
|
2420
|
+
const temporary = `${path}.${process19.pid}.tmp`;
|
|
2368
2421
|
await writeFile2(temporary, content, { mode: statSync2(path).mode & 511 });
|
|
2369
2422
|
await rename(temporary, path);
|
|
2370
2423
|
}
|
|
@@ -2385,7 +2438,7 @@ async function toolFixers(dir) {
|
|
|
2385
2438
|
fixers.push({ name: "makefile", command: "declare every target .PHONY", source: makefile, write: async (cwd) => {
|
|
2386
2439
|
const path = join11(cwd, makefile);
|
|
2387
2440
|
const current = await Bun.file(path).text();
|
|
2388
|
-
const { content, targets } = declarePhony(current, (name) =>
|
|
2441
|
+
const { content, targets } = declarePhony(current, (name) => existsSync5(join11(cwd, name)));
|
|
2389
2442
|
if (content !== current)
|
|
2390
2443
|
await replaceFile(path, content);
|
|
2391
2444
|
return `.PHONY: ${targets.join(" ")}`;
|
|
@@ -2436,14 +2489,14 @@ function printChanged(changed) {
|
|
|
2436
2489
|
if (changed.length > MAX_CHANGED)
|
|
2437
2490
|
console.log(` and ${changed.length - MAX_CHANGED} more`);
|
|
2438
2491
|
}
|
|
2439
|
-
async function fix(args, cwd =
|
|
2492
|
+
async function fix(args, cwd = process19.cwd()) {
|
|
2440
2493
|
const parsed = parse(args, fixUsage, fixOptions, { replaces: "running each fixer and formatter by hand, or docker compose exec <service> bun run lint:fix", examples: ["fix", ["fix --list", "the fixers it would run"]] });
|
|
2441
2494
|
return runFixers(parsed.values, cwd);
|
|
2442
2495
|
}
|
|
2443
2496
|
async function runFixers(values, cwd) {
|
|
2444
2497
|
const parsed = { values };
|
|
2445
2498
|
const settings = placeSettings(values);
|
|
2446
|
-
if (
|
|
2499
|
+
if (process19.env[RUNNING] !== undefined)
|
|
2447
2500
|
fail("a fixer called fix again, which would recurse: give its script another command");
|
|
2448
2501
|
const found = await fixers(cwd);
|
|
2449
2502
|
if (found.length === 0)
|
|
@@ -2477,7 +2530,7 @@ async function runFixers(values, cwd) {
|
|
|
2477
2530
|
break;
|
|
2478
2531
|
if (missing(fixer)) {
|
|
2479
2532
|
if (!json)
|
|
2480
|
-
console.log(`${paint(
|
|
2533
|
+
console.log(`${paint(process19.stdout).yellow("skip ")} ${fixer.name.padEnd(width)} ${fixer.requires} is not installed`);
|
|
2481
2534
|
ran.push({ name: fixer.name, command: fixer.command, skipped: `${fixer.requires} is not installed` });
|
|
2482
2535
|
continue;
|
|
2483
2536
|
}
|
|
@@ -2510,4 +2563,4 @@ async function runFixers(values, cwd) {
|
|
|
2510
2563
|
}
|
|
2511
2564
|
|
|
2512
2565
|
// src/fix-cli.ts
|
|
2513
|
-
|
|
2566
|
+
process20.exitCode = await runMain({ name: "fix", version, run: async (args) => fix(args) });
|