@wayai/cli 0.3.336 → 0.3.337
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +156 -138
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -5000,6 +5000,15 @@ function isUnder(parent, child) {
|
|
|
5000
5000
|
const rel = path.relative(parent, child);
|
|
5001
5001
|
return rel === "" || rel !== ".." && !rel.startsWith(`..${path.sep}`) && !path.isAbsolute(rel);
|
|
5002
5002
|
}
|
|
5003
|
+
function ownedByAnotherUser(st) {
|
|
5004
|
+
return typeof process.getuid === "function" && st.uid !== process.getuid();
|
|
5005
|
+
}
|
|
5006
|
+
function ownProblem(st) {
|
|
5007
|
+
if (typeof process.getuid !== "function") return null;
|
|
5008
|
+
if (ownedByAnotherUser(st)) return "it belongs to another user";
|
|
5009
|
+
if ((st.mode & 2) !== 0 && !st.isSymbolicLink()) return "any user can write to it";
|
|
5010
|
+
return null;
|
|
5011
|
+
}
|
|
5003
5012
|
function isSymlink(p) {
|
|
5004
5013
|
try {
|
|
5005
5014
|
return fs.lstatSync(p).isSymbolicLink();
|
|
@@ -18907,7 +18916,14 @@ function findGitRoot() {
|
|
|
18907
18916
|
function findRepoRootSync() {
|
|
18908
18917
|
let current = process.cwd();
|
|
18909
18918
|
while (true) {
|
|
18910
|
-
|
|
18919
|
+
const git = path4.join(current, ".git");
|
|
18920
|
+
if (fs3.existsSync(git)) {
|
|
18921
|
+
try {
|
|
18922
|
+
return ownedByAnotherUser(fs3.lstatSync(git)) || ownedByAnotherUser(fs3.lstatSync(current)) ? null : current;
|
|
18923
|
+
} catch {
|
|
18924
|
+
return null;
|
|
18925
|
+
}
|
|
18926
|
+
}
|
|
18911
18927
|
const parent = path4.dirname(current);
|
|
18912
18928
|
if (parent === current) return null;
|
|
18913
18929
|
current = parent;
|
|
@@ -22111,10 +22127,10 @@ function manualCleanupCommand(account, service = KEYRING_SERVICE) {
|
|
|
22111
22127
|
}
|
|
22112
22128
|
return `(remove the entry with service="${service}" account="${account}" from your OS credential store)`;
|
|
22113
22129
|
}
|
|
22114
|
-
async function clearSlot(keyring, account) {
|
|
22130
|
+
async function clearSlot(keyring, account, confirm2 = keyring) {
|
|
22115
22131
|
await keyring.deletePassword(KEYRING_SERVICE, account);
|
|
22116
22132
|
try {
|
|
22117
|
-
return await
|
|
22133
|
+
return await confirm2.getPassword(KEYRING_SERVICE, account) === null;
|
|
22118
22134
|
} catch {
|
|
22119
22135
|
return false;
|
|
22120
22136
|
}
|
|
@@ -22322,13 +22338,16 @@ async function setOAuthTokens(access_token, refresh_token, expires_at) {
|
|
|
22322
22338
|
writeFileFallback({ access_token, refresh_token, token_expires_at: expires_at });
|
|
22323
22339
|
}
|
|
22324
22340
|
async function clearTokens() {
|
|
22341
|
+
const stuck = [];
|
|
22325
22342
|
const keyring = await getKeyring();
|
|
22326
22343
|
if (keyring) {
|
|
22344
|
+
const confirm2 = await getStrictKeyring() ?? keyring;
|
|
22327
22345
|
const slots = [KEY_WAY_TOKEN, KEY_OAUTH_ACCESS, KEY_OAUTH_REFRESH];
|
|
22328
|
-
const cleared = await Promise.all(slots.map((account) => clearSlot(keyring, account)));
|
|
22346
|
+
const cleared = await Promise.all(slots.map((account) => clearSlot(keyring, account, confirm2)));
|
|
22329
22347
|
for (const [i, ok] of cleared.entries()) {
|
|
22330
22348
|
if (!ok) {
|
|
22331
22349
|
const account = slots[i];
|
|
22350
|
+
stuck.push(account);
|
|
22332
22351
|
console.warn(
|
|
22333
22352
|
`wayai: could not clear keyring slot "${account}". Subsequent commands may still pick the stale token. Manually:
|
|
22334
22353
|
${manualCleanupCommand(account)}`
|
|
@@ -22339,6 +22358,7 @@ async function clearTokens() {
|
|
|
22339
22358
|
if (fs8.existsSync(configPath2())) {
|
|
22340
22359
|
fs8.unlinkSync(configPath2());
|
|
22341
22360
|
}
|
|
22361
|
+
return stuck;
|
|
22342
22362
|
}
|
|
22343
22363
|
function readMetadataExpiresAt() {
|
|
22344
22364
|
const legacy = readLegacyConfigFile();
|
|
@@ -22619,7 +22639,7 @@ __export(skill_symlink_exports, {
|
|
|
22619
22639
|
healClaudeSkillLink: () => healClaudeSkillLink,
|
|
22620
22640
|
healSkillLinkForCommand: () => healSkillLinkForCommand
|
|
22621
22641
|
});
|
|
22622
|
-
import { existsSync as existsSync8, lstatSync as
|
|
22642
|
+
import { existsSync as existsSync8, lstatSync as lstatSync5, mkdirSync as mkdirSync5, rmSync as rmSync3, symlinkSync } from "fs";
|
|
22623
22643
|
import { join as join12 } from "path";
|
|
22624
22644
|
function healClaudeSkillLink(root) {
|
|
22625
22645
|
try {
|
|
@@ -22629,7 +22649,7 @@ function healClaudeSkillLink(root) {
|
|
|
22629
22649
|
if (existsSync8(join12(link, SKILL_FILENAME))) return false;
|
|
22630
22650
|
let entry = null;
|
|
22631
22651
|
try {
|
|
22632
|
-
entry =
|
|
22652
|
+
entry = lstatSync5(link);
|
|
22633
22653
|
} catch {
|
|
22634
22654
|
entry = null;
|
|
22635
22655
|
}
|
|
@@ -22923,9 +22943,14 @@ async function logoutCommand() {
|
|
|
22923
22943
|
return;
|
|
22924
22944
|
}
|
|
22925
22945
|
const envOverrideActive = !!envTokenOverride();
|
|
22926
|
-
|
|
22927
|
-
|
|
22928
|
-
|
|
22946
|
+
const envNote = "Note: WAYAI_TOKEN env var is still set in this shell \u2014 unset it to fully log out.";
|
|
22947
|
+
const stuck = await clearTokens();
|
|
22948
|
+
if (stuck.length > 0) {
|
|
22949
|
+
console.log(
|
|
22950
|
+
`Logout incomplete: could not confirm the OS keyring holds no token (${stuck.join(", ")}). If it holds one, clear it with the commands above.` + (envOverrideActive ? ` ${envNote}` : "")
|
|
22951
|
+
);
|
|
22952
|
+
} else if (envOverrideActive) {
|
|
22953
|
+
console.log(`Tokens cleared from keyring and file. ${envNote}`);
|
|
22929
22954
|
} else {
|
|
22930
22955
|
console.log("Logged out. Tokens cleared.");
|
|
22931
22956
|
}
|
|
@@ -38802,120 +38827,9 @@ var init_case_review = __esm({
|
|
|
38802
38827
|
}
|
|
38803
38828
|
});
|
|
38804
38829
|
|
|
38805
|
-
// src/cases/case-
|
|
38830
|
+
// src/cases/case-clone-record.ts
|
|
38806
38831
|
import * as fs30 from "fs";
|
|
38807
38832
|
import * as path42 from "path";
|
|
38808
|
-
function ownProblem(st) {
|
|
38809
|
-
if (typeof process.getuid !== "function") return null;
|
|
38810
|
-
if (st.uid !== process.getuid()) return "it belongs to another user";
|
|
38811
|
-
if ((st.mode & 2) !== 0 && !st.isSymbolicLink()) return "any user can write to it";
|
|
38812
|
-
return null;
|
|
38813
|
-
}
|
|
38814
|
-
function requireOwn(abs) {
|
|
38815
|
-
let st;
|
|
38816
|
-
try {
|
|
38817
|
-
st = fs30.lstatSync(abs);
|
|
38818
|
-
} catch {
|
|
38819
|
-
return;
|
|
38820
|
-
}
|
|
38821
|
-
const problem = ownProblem(st);
|
|
38822
|
-
if (problem) {
|
|
38823
|
-
throw expected(
|
|
38824
|
-
`Refused ${sanitizeTerminalText(abs)}: ${problem}. A case is read and written only in folders and files you own, never in one every user can write to.`
|
|
38825
|
-
);
|
|
38826
|
-
}
|
|
38827
|
-
}
|
|
38828
|
-
function caseLocalPathProblem(rel) {
|
|
38829
|
-
if (rel === "") return "it is empty";
|
|
38830
|
-
if (rel.includes("\0")) return "it holds a NUL";
|
|
38831
|
-
if (rel.includes("\\")) return "it holds a backslash";
|
|
38832
|
-
if (rel.startsWith("/") || /^[A-Za-z]:/.test(rel)) return "it is absolute";
|
|
38833
|
-
for (const segment2 of rel.split("/")) {
|
|
38834
|
-
if (segment2 === "") return "it has an empty segment";
|
|
38835
|
-
if (segment2 === "." || segment2 === "..") return `it has a "${segment2}" segment`;
|
|
38836
|
-
}
|
|
38837
|
-
return null;
|
|
38838
|
-
}
|
|
38839
|
-
function caseLocalRoot(dir) {
|
|
38840
|
-
let root;
|
|
38841
|
-
try {
|
|
38842
|
-
root = fs30.realpathSync(path42.resolve(dir));
|
|
38843
|
-
} catch {
|
|
38844
|
-
throw expected(`${sanitizeTerminalText(dir)} does not exist.`);
|
|
38845
|
-
}
|
|
38846
|
-
if (!fs30.statSync(root).isDirectory()) throw expected(`${sanitizeTerminalText(dir)} is not a folder.`);
|
|
38847
|
-
requireOwn(root);
|
|
38848
|
-
return root;
|
|
38849
|
-
}
|
|
38850
|
-
function writeCaseLocalFile(root, rel, data) {
|
|
38851
|
-
const problem = caseLocalPathProblem(rel);
|
|
38852
|
-
const shown3 = sanitizeTerminalText(rel);
|
|
38853
|
-
if (problem) throw expected(`Refused to write ${JSON.stringify(shown3)}: ${problem}.`);
|
|
38854
|
-
const target = path42.join(root, ...rel.split("/"));
|
|
38855
|
-
requireOwn(root);
|
|
38856
|
-
let folder = root;
|
|
38857
|
-
for (const segment2 of rel.split("/").slice(0, -1)) {
|
|
38858
|
-
folder = path42.join(folder, segment2);
|
|
38859
|
-
let st;
|
|
38860
|
-
try {
|
|
38861
|
-
st = fs30.lstatSync(folder);
|
|
38862
|
-
} catch {
|
|
38863
|
-
st = void 0;
|
|
38864
|
-
}
|
|
38865
|
-
if (!st) {
|
|
38866
|
-
try {
|
|
38867
|
-
fs30.mkdirSync(folder, { mode: CASE_FOLDER_MODE });
|
|
38868
|
-
} catch (err) {
|
|
38869
|
-
if (err.code !== "EEXIST") throw err;
|
|
38870
|
-
}
|
|
38871
|
-
st = fs30.lstatSync(folder);
|
|
38872
|
-
}
|
|
38873
|
-
if (!st.isDirectory()) {
|
|
38874
|
-
throw expected(`Refused to write ${shown3}: a folder on its way is a symlink or a file. The CLI never writes through a symlink.`);
|
|
38875
|
-
}
|
|
38876
|
-
requireOwn(folder);
|
|
38877
|
-
}
|
|
38878
|
-
if (!ensureRealSubdirNoSymlink(root, path42.dirname(target), true)) {
|
|
38879
|
-
throw expected(`Refused to write ${shown3}: a folder on its way is a symlink or a file. The CLI never writes through a symlink.`);
|
|
38880
|
-
}
|
|
38881
|
-
let existing;
|
|
38882
|
-
try {
|
|
38883
|
-
existing = fs30.lstatSync(target);
|
|
38884
|
-
} catch {
|
|
38885
|
-
existing = void 0;
|
|
38886
|
-
}
|
|
38887
|
-
if (existing && !existing.isFile()) throw expected(`Refused to write ${shown3}: it is a symlink or not a file. The CLI never writes through a symlink.`);
|
|
38888
|
-
if (existing) requireOwn(target);
|
|
38889
|
-
if (existing && fileHasBytes(target, data)) return "unchanged";
|
|
38890
|
-
const flags = fs30.constants.O_WRONLY | fs30.constants.O_CREAT | fs30.constants.O_TRUNC | (fs30.constants.O_NOFOLLOW ?? 0);
|
|
38891
|
-
let fd;
|
|
38892
|
-
try {
|
|
38893
|
-
fd = fs30.openSync(target, flags, 420);
|
|
38894
|
-
} catch (err) {
|
|
38895
|
-
if (err.code === "ELOOP") throw expected(`Refused to write ${shown3}: it is a symlink. The CLI never writes through a symlink.`);
|
|
38896
|
-
throw err;
|
|
38897
|
-
}
|
|
38898
|
-
try {
|
|
38899
|
-
fs30.writeFileSync(fd, data);
|
|
38900
|
-
} finally {
|
|
38901
|
-
fs30.closeSync(fd);
|
|
38902
|
-
}
|
|
38903
|
-
return "written";
|
|
38904
|
-
}
|
|
38905
|
-
var CASE_FOLDER_MODE;
|
|
38906
|
-
var init_case_local_files = __esm({
|
|
38907
|
-
"src/cases/case-local-files.ts"() {
|
|
38908
|
-
"use strict";
|
|
38909
|
-
init_fs_safety();
|
|
38910
|
-
init_expected();
|
|
38911
|
-
init_terminal_output();
|
|
38912
|
-
CASE_FOLDER_MODE = 493;
|
|
38913
|
-
}
|
|
38914
|
-
});
|
|
38915
|
-
|
|
38916
|
-
// src/cases/case-clone-record.ts
|
|
38917
|
-
import * as fs31 from "fs";
|
|
38918
|
-
import * as path43 from "path";
|
|
38919
38833
|
function isCloneRecord(value) {
|
|
38920
38834
|
if (typeof value !== "object" || value === null) return false;
|
|
38921
38835
|
const v = value;
|
|
@@ -38927,15 +38841,15 @@ function isCloneRecord(value) {
|
|
|
38927
38841
|
});
|
|
38928
38842
|
}
|
|
38929
38843
|
function readCloneRecord(root) {
|
|
38930
|
-
const file =
|
|
38844
|
+
const file = path42.join(root, CASE_CLONE_RECORD_FILE);
|
|
38931
38845
|
let marker;
|
|
38932
38846
|
try {
|
|
38933
|
-
marker =
|
|
38847
|
+
marker = fs30.lstatSync(file);
|
|
38934
38848
|
} catch {
|
|
38935
38849
|
return null;
|
|
38936
38850
|
}
|
|
38937
38851
|
const markerProblem = ownProblem(marker);
|
|
38938
|
-
const folderProblem = markerProblem ? null : ownProblem(
|
|
38852
|
+
const folderProblem = markerProblem ? null : ownProblem(fs30.lstatSync(root));
|
|
38939
38853
|
if (markerProblem || folderProblem) {
|
|
38940
38854
|
throw expected(sanitizeTerminalText(
|
|
38941
38855
|
`Refused the case clone marker ${file}: ${markerProblem ?? `its folder: ${folderProblem}`}. A clone counts only in a folder you own that not every user can write to: remove it, or work in a clone of your own.`
|
|
@@ -38959,19 +38873,19 @@ function writeCloneRecord(root, record) {
|
|
|
38959
38873
|
for (const rel of Object.keys(record.files).sort()) files[rel] = { sha: record.files[rel].sha, confidential: record.files[rel].confidential };
|
|
38960
38874
|
const body = `${JSON.stringify({ org_id: record.org_id, space_id: record.space_id, code: record.code, files }, null, 2)}
|
|
38961
38875
|
`;
|
|
38962
|
-
const tmp =
|
|
38876
|
+
const tmp = path42.join(root, `${CASE_CLONE_RECORD_FILE}.tmp`);
|
|
38963
38877
|
if (!writeFileNoFollow(root, tmp, Buffer.from(body, "utf-8"))) throw symlinkRefusal(tmp, "file");
|
|
38964
|
-
|
|
38965
|
-
|
|
38878
|
+
fs30.chmodSync(tmp, 420);
|
|
38879
|
+
fs30.renameSync(tmp, path42.join(root, CASE_CLONE_RECORD_FILE));
|
|
38966
38880
|
}
|
|
38967
38881
|
function findCaseClone(from) {
|
|
38968
|
-
let dir =
|
|
38882
|
+
let dir = path42.resolve(from);
|
|
38969
38883
|
for (; ; ) {
|
|
38970
38884
|
try {
|
|
38971
|
-
dir =
|
|
38885
|
+
dir = fs30.realpathSync(dir);
|
|
38972
38886
|
break;
|
|
38973
38887
|
} catch {
|
|
38974
|
-
const parent =
|
|
38888
|
+
const parent = path42.dirname(dir);
|
|
38975
38889
|
if (parent === dir) return null;
|
|
38976
38890
|
dir = parent;
|
|
38977
38891
|
}
|
|
@@ -38979,7 +38893,7 @@ function findCaseClone(from) {
|
|
|
38979
38893
|
for (; ; ) {
|
|
38980
38894
|
const record = readCloneRecord(dir);
|
|
38981
38895
|
if (record) return { root: dir, record };
|
|
38982
|
-
const parent =
|
|
38896
|
+
const parent = path42.dirname(dir);
|
|
38983
38897
|
if (parent === dir) return null;
|
|
38984
38898
|
dir = parent;
|
|
38985
38899
|
}
|
|
@@ -38990,7 +38904,6 @@ var init_case_clone_record = __esm({
|
|
|
38990
38904
|
"use strict";
|
|
38991
38905
|
init_expected();
|
|
38992
38906
|
init_fs_safety();
|
|
38993
|
-
init_case_local_files();
|
|
38994
38907
|
init_terminal_output();
|
|
38995
38908
|
init_case_files();
|
|
38996
38909
|
CASE_CLONE_RECORD_FILE = ".wayai-case.json";
|
|
@@ -38999,12 +38912,12 @@ var init_case_clone_record = __esm({
|
|
|
38999
38912
|
});
|
|
39000
38913
|
|
|
39001
38914
|
// src/cases/case-tokens.ts
|
|
39002
|
-
import * as
|
|
39003
|
-
import * as
|
|
38915
|
+
import * as fs31 from "fs";
|
|
38916
|
+
import * as path43 from "path";
|
|
39004
38917
|
import * as os3 from "os";
|
|
39005
38918
|
import { randomBytes as randomBytes2 } from "crypto";
|
|
39006
38919
|
function listPath() {
|
|
39007
|
-
return
|
|
38920
|
+
return path43.join(os3.homedir(), ".wayai", "case-connections.json");
|
|
39008
38921
|
}
|
|
39009
38922
|
function caseTokenAccount(ref) {
|
|
39010
38923
|
return `${ref.org_id}/${ref.space_id}/${ref.code}`;
|
|
@@ -39042,7 +38955,7 @@ function isConnection(value) {
|
|
|
39042
38955
|
function listCaseConnections() {
|
|
39043
38956
|
let parsed;
|
|
39044
38957
|
try {
|
|
39045
|
-
parsed = JSON.parse(
|
|
38958
|
+
parsed = JSON.parse(fs31.readFileSync(listPath(), "utf-8"));
|
|
39046
38959
|
} catch {
|
|
39047
38960
|
return [];
|
|
39048
38961
|
}
|
|
@@ -39050,8 +38963,8 @@ function listCaseConnections() {
|
|
|
39050
38963
|
return Array.isArray(connections) ? connections.filter(isConnection) : [];
|
|
39051
38964
|
}
|
|
39052
38965
|
function writeList(connections) {
|
|
39053
|
-
|
|
39054
|
-
|
|
38966
|
+
fs31.mkdirSync(path43.dirname(listPath()), { recursive: true });
|
|
38967
|
+
fs31.writeFileSync(listPath(), JSON.stringify({ connections }, null, 2) + "\n", { mode: 384 });
|
|
39055
38968
|
}
|
|
39056
38969
|
function findCaseConnection(ref) {
|
|
39057
38970
|
return listCaseConnections().find((c) => sameCase(c, ref));
|
|
@@ -39167,6 +39080,111 @@ var init_case_session = __esm({
|
|
|
39167
39080
|
}
|
|
39168
39081
|
});
|
|
39169
39082
|
|
|
39083
|
+
// src/cases/case-local-files.ts
|
|
39084
|
+
import * as fs32 from "fs";
|
|
39085
|
+
import * as path44 from "path";
|
|
39086
|
+
function requireOwn(abs) {
|
|
39087
|
+
let st;
|
|
39088
|
+
try {
|
|
39089
|
+
st = fs32.lstatSync(abs);
|
|
39090
|
+
} catch {
|
|
39091
|
+
return;
|
|
39092
|
+
}
|
|
39093
|
+
const problem = ownProblem(st);
|
|
39094
|
+
if (problem) {
|
|
39095
|
+
throw expected(
|
|
39096
|
+
`Refused ${sanitizeTerminalText(abs)}: ${problem}. A case is read and written only in folders and files you own, never in one every user can write to.`
|
|
39097
|
+
);
|
|
39098
|
+
}
|
|
39099
|
+
}
|
|
39100
|
+
function caseLocalPathProblem(rel) {
|
|
39101
|
+
if (rel === "") return "it is empty";
|
|
39102
|
+
if (rel.includes("\0")) return "it holds a NUL";
|
|
39103
|
+
if (rel.includes("\\")) return "it holds a backslash";
|
|
39104
|
+
if (rel.startsWith("/") || /^[A-Za-z]:/.test(rel)) return "it is absolute";
|
|
39105
|
+
for (const segment2 of rel.split("/")) {
|
|
39106
|
+
if (segment2 === "") return "it has an empty segment";
|
|
39107
|
+
if (segment2 === "." || segment2 === "..") return `it has a "${segment2}" segment`;
|
|
39108
|
+
}
|
|
39109
|
+
return null;
|
|
39110
|
+
}
|
|
39111
|
+
function caseLocalRoot(dir) {
|
|
39112
|
+
let root;
|
|
39113
|
+
try {
|
|
39114
|
+
root = fs32.realpathSync(path44.resolve(dir));
|
|
39115
|
+
} catch {
|
|
39116
|
+
throw expected(`${sanitizeTerminalText(dir)} does not exist.`);
|
|
39117
|
+
}
|
|
39118
|
+
if (!fs32.statSync(root).isDirectory()) throw expected(`${sanitizeTerminalText(dir)} is not a folder.`);
|
|
39119
|
+
requireOwn(root);
|
|
39120
|
+
return root;
|
|
39121
|
+
}
|
|
39122
|
+
function writeCaseLocalFile(root, rel, data) {
|
|
39123
|
+
const problem = caseLocalPathProblem(rel);
|
|
39124
|
+
const shown3 = sanitizeTerminalText(rel);
|
|
39125
|
+
if (problem) throw expected(`Refused to write ${JSON.stringify(shown3)}: ${problem}.`);
|
|
39126
|
+
const target = path44.join(root, ...rel.split("/"));
|
|
39127
|
+
requireOwn(root);
|
|
39128
|
+
let folder = root;
|
|
39129
|
+
for (const segment2 of rel.split("/").slice(0, -1)) {
|
|
39130
|
+
folder = path44.join(folder, segment2);
|
|
39131
|
+
let st;
|
|
39132
|
+
try {
|
|
39133
|
+
st = fs32.lstatSync(folder);
|
|
39134
|
+
} catch {
|
|
39135
|
+
st = void 0;
|
|
39136
|
+
}
|
|
39137
|
+
if (!st) {
|
|
39138
|
+
try {
|
|
39139
|
+
fs32.mkdirSync(folder, { mode: CASE_FOLDER_MODE });
|
|
39140
|
+
} catch (err) {
|
|
39141
|
+
if (err.code !== "EEXIST") throw err;
|
|
39142
|
+
}
|
|
39143
|
+
st = fs32.lstatSync(folder);
|
|
39144
|
+
}
|
|
39145
|
+
if (!st.isDirectory()) {
|
|
39146
|
+
throw expected(`Refused to write ${shown3}: a folder on its way is a symlink or a file. The CLI never writes through a symlink.`);
|
|
39147
|
+
}
|
|
39148
|
+
requireOwn(folder);
|
|
39149
|
+
}
|
|
39150
|
+
if (!ensureRealSubdirNoSymlink(root, path44.dirname(target), true)) {
|
|
39151
|
+
throw expected(`Refused to write ${shown3}: a folder on its way is a symlink or a file. The CLI never writes through a symlink.`);
|
|
39152
|
+
}
|
|
39153
|
+
let existing;
|
|
39154
|
+
try {
|
|
39155
|
+
existing = fs32.lstatSync(target);
|
|
39156
|
+
} catch {
|
|
39157
|
+
existing = void 0;
|
|
39158
|
+
}
|
|
39159
|
+
if (existing && !existing.isFile()) throw expected(`Refused to write ${shown3}: it is a symlink or not a file. The CLI never writes through a symlink.`);
|
|
39160
|
+
if (existing) requireOwn(target);
|
|
39161
|
+
if (existing && fileHasBytes(target, data)) return "unchanged";
|
|
39162
|
+
const flags = fs32.constants.O_WRONLY | fs32.constants.O_CREAT | fs32.constants.O_TRUNC | (fs32.constants.O_NOFOLLOW ?? 0);
|
|
39163
|
+
let fd;
|
|
39164
|
+
try {
|
|
39165
|
+
fd = fs32.openSync(target, flags, 420);
|
|
39166
|
+
} catch (err) {
|
|
39167
|
+
if (err.code === "ELOOP") throw expected(`Refused to write ${shown3}: it is a symlink. The CLI never writes through a symlink.`);
|
|
39168
|
+
throw err;
|
|
39169
|
+
}
|
|
39170
|
+
try {
|
|
39171
|
+
fs32.writeFileSync(fd, data);
|
|
39172
|
+
} finally {
|
|
39173
|
+
fs32.closeSync(fd);
|
|
39174
|
+
}
|
|
39175
|
+
return "written";
|
|
39176
|
+
}
|
|
39177
|
+
var CASE_FOLDER_MODE;
|
|
39178
|
+
var init_case_local_files = __esm({
|
|
39179
|
+
"src/cases/case-local-files.ts"() {
|
|
39180
|
+
"use strict";
|
|
39181
|
+
init_fs_safety();
|
|
39182
|
+
init_expected();
|
|
39183
|
+
init_terminal_output();
|
|
39184
|
+
CASE_FOLDER_MODE = 493;
|
|
39185
|
+
}
|
|
39186
|
+
});
|
|
39187
|
+
|
|
39170
39188
|
// ../../packages/core/dist/contracts/case-notes.js
|
|
39171
39189
|
var init_case_notes = __esm({
|
|
39172
39190
|
"../../packages/core/dist/contracts/case-notes.js"() {
|