@koda-sl/baker-cli 0.452.0-dev.63867ce0e → 0.454.0-dev.c94fef7ea
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 -3
- package/dist/{chunk-Q2ZO6I47.js → chunk-MYOTW5GV.js} +15 -5
- package/dist/chunk-MYOTW5GV.js.map +1 -0
- package/dist/cli.js +336 -298
- package/dist/cli.js.map +1 -1
- package/dist/engine/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-Q2ZO6I47.js.map +0 -1
package/dist/cli.js
CHANGED
|
@@ -201,7 +201,7 @@ import {
|
|
|
201
201
|
withoutCastName,
|
|
202
202
|
wordCount,
|
|
203
203
|
ytDlpBlockSignal
|
|
204
|
-
} from "./chunk-
|
|
204
|
+
} from "./chunk-MYOTW5GV.js";
|
|
205
205
|
import {
|
|
206
206
|
NAME_CONTAINS_ARG,
|
|
207
207
|
csvOrJson,
|
|
@@ -35514,16 +35514,16 @@ async function runChatgptRead(reference, read, hintsFor4) {
|
|
|
35514
35514
|
}
|
|
35515
35515
|
}
|
|
35516
35516
|
var TRUNCATED_HINT = "These rows are the first 2,000, not the whole account \u2014 narrow the read (--campaign-id, --ad-group-id) before counting them or concluding something is missing.";
|
|
35517
|
-
async function getChatgptList(
|
|
35518
|
-
const { data, headers } = await apiGetWithHeaders(
|
|
35517
|
+
async function getChatgptList(path69, params) {
|
|
35518
|
+
const { data, headers } = await apiGetWithHeaders(path69, params);
|
|
35519
35519
|
return { data, truncated: headers.get(CHATGPT_ADS_TRUNCATED_HEADER) === "true" };
|
|
35520
35520
|
}
|
|
35521
|
-
async function runChatgptListRead(reference,
|
|
35521
|
+
async function runChatgptListRead(reference, path69, params, hintsFor4) {
|
|
35522
35522
|
let truncated = false;
|
|
35523
35523
|
await runChatgptRead(
|
|
35524
35524
|
reference,
|
|
35525
35525
|
async () => {
|
|
35526
|
-
const read = await getChatgptList(
|
|
35526
|
+
const read = await getChatgptList(path69, params);
|
|
35527
35527
|
truncated = read.truncated;
|
|
35528
35528
|
return read.data;
|
|
35529
35529
|
},
|
|
@@ -36328,7 +36328,7 @@ var MEMBER_ARGS = {
|
|
|
36328
36328
|
},
|
|
36329
36329
|
country: { type: "string", description: "Country of phones written without a +code, e.g. ES" }
|
|
36330
36330
|
};
|
|
36331
|
-
function membersFromArgs(args8, readFile52 = (
|
|
36331
|
+
function membersFromArgs(args8, readFile52 = (path69) => readFileSync2(path69, "utf8")) {
|
|
36332
36332
|
const fromFile = typeof args8.file === "string" && args8.file ? membersFromFile(readFile52(args8.file)) : { emails: [], phones: [] };
|
|
36333
36333
|
const given = [...csvArg(args8.emails) ?? [], ...fromFile.emails];
|
|
36334
36334
|
const givenPhones = [...csvArg(args8.phones) ?? [], ...fromFile.phones];
|
|
@@ -39721,9 +39721,9 @@ var COPY_LIST_FLAG = {
|
|
|
39721
39721
|
descriptions: "--descriptions",
|
|
39722
39722
|
longHeadlines: "--long-headlines"
|
|
39723
39723
|
};
|
|
39724
|
-
function valueAt(root,
|
|
39724
|
+
function valueAt(root, path69) {
|
|
39725
39725
|
let node = root;
|
|
39726
|
-
for (const key of
|
|
39726
|
+
for (const key of path69) {
|
|
39727
39727
|
if (node === null || typeof node !== "object") return void 0;
|
|
39728
39728
|
node = node[key];
|
|
39729
39729
|
}
|
|
@@ -39956,11 +39956,11 @@ function parseKeywordEntry(raw, defaultMatch) {
|
|
|
39956
39956
|
function rawTextEntries(value2, rawArgs) {
|
|
39957
39957
|
return repeatedValues(rawArgs, "text", value2).flatMap((v) => v.split(",")).map((v) => v.trim()).filter(Boolean);
|
|
39958
39958
|
}
|
|
39959
|
-
function rawFileEntries(
|
|
39960
|
-
if (typeof
|
|
39959
|
+
function rawFileEntries(path69) {
|
|
39960
|
+
if (typeof path69 !== "string" || path69.length === 0) {
|
|
39961
39961
|
return [];
|
|
39962
39962
|
}
|
|
39963
|
-
return readFileSync4(
|
|
39963
|
+
return readFileSync4(path69, "utf8").split(/\r?\n/).map((line) => line.trim()).filter((line) => line.length > 0 && !line.startsWith("#"));
|
|
39964
39964
|
}
|
|
39965
39965
|
function keywordEntries(args8, rawArgs) {
|
|
39966
39966
|
const defaultMatch = typeof args8["match-type"] === "string" ? args8["match-type"].toUpperCase() : void 0;
|
|
@@ -39983,14 +39983,14 @@ function keywordEntries(args8, rawArgs) {
|
|
|
39983
39983
|
}
|
|
39984
39984
|
return entries;
|
|
39985
39985
|
}
|
|
39986
|
-
function loadJsonFileArg(
|
|
39987
|
-
if (typeof
|
|
39986
|
+
function loadJsonFileArg(path69) {
|
|
39987
|
+
if (typeof path69 !== "string" || path69.length === 0) {
|
|
39988
39988
|
return {};
|
|
39989
39989
|
}
|
|
39990
|
-
const inline =
|
|
39991
|
-
const source = inline ? "inline JSON" :
|
|
39990
|
+
const inline = path69.trimStart().startsWith("{");
|
|
39991
|
+
const source = inline ? "inline JSON" : path69;
|
|
39992
39992
|
try {
|
|
39993
|
-
const parsed = JSON.parse(inline ?
|
|
39993
|
+
const parsed = JSON.parse(inline ? path69 : readFileSync4(path69, "utf8"));
|
|
39994
39994
|
if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
39995
39995
|
failWriteValidation2(`${source} must contain a JSON object`);
|
|
39996
39996
|
}
|
|
@@ -40127,10 +40127,10 @@ async function stageUpdate(kind, customerId, target2, payload, hints2) {
|
|
|
40127
40127
|
async function stageTarget(kind, customerId, target2, hints2) {
|
|
40128
40128
|
await stageGoogleOp({ kind, customerId, target: target2 }, hints2);
|
|
40129
40129
|
}
|
|
40130
|
-
async function draftAction(
|
|
40130
|
+
async function draftAction(path69, body, chat) {
|
|
40131
40131
|
try {
|
|
40132
40132
|
const chatId = resolveChatId(chat);
|
|
40133
|
-
const response = await apiPost(
|
|
40133
|
+
const response = await apiPost(path69, { chatId, ...body });
|
|
40134
40134
|
writeJsonEnvelope(response);
|
|
40135
40135
|
} catch (err) {
|
|
40136
40136
|
handleGoogleError(err);
|
|
@@ -42550,14 +42550,14 @@ function mappingRowProblem(row2) {
|
|
|
42550
42550
|
|
|
42551
42551
|
// ../api/src/event-sources/template.ts
|
|
42552
42552
|
var MENTION = /\{\{\s*([^{}]+?)\s*\}\}/g;
|
|
42553
|
-
function mentionOf(
|
|
42554
|
-
return `{{${
|
|
42553
|
+
function mentionOf(path69) {
|
|
42554
|
+
return `{{${path69}}}`;
|
|
42555
42555
|
}
|
|
42556
42556
|
function templateMentions(template) {
|
|
42557
42557
|
const seen = [];
|
|
42558
42558
|
for (const match of template.matchAll(MENTION)) {
|
|
42559
|
-
const
|
|
42560
|
-
if (
|
|
42559
|
+
const path69 = (match[1] ?? "").trim();
|
|
42560
|
+
if (path69 !== "" && !seen.includes(path69)) seen.push(path69);
|
|
42561
42561
|
}
|
|
42562
42562
|
return seen;
|
|
42563
42563
|
}
|
|
@@ -45954,17 +45954,17 @@ function ignoredColumnHints(columns) {
|
|
|
45954
45954
|
`Ignored ${columns.length} column(s) that are not part of a conversion: ${columns.join(", ")}. A conversion carries an order id, a date, and something to match on: a click id (gclid / gbraid / wbraid), an email, a phone, or all four of givenName + familyName + country + postalCode. Optionally a value + currency, conversionCount, and eventSource (WEB / APP / IN_STORE / PHONE / OTHER). A column named just \`Name\` is ignored on purpose \u2014 Google needs the first and last name separately, so split it before re-running.`
|
|
45955
45955
|
];
|
|
45956
45956
|
}
|
|
45957
|
-
function readRowsFile(
|
|
45958
|
-
const inline =
|
|
45957
|
+
function readRowsFile(path69) {
|
|
45958
|
+
const inline = path69.trimStart().startsWith("[") || path69.trimStart().startsWith("{");
|
|
45959
45959
|
let text3;
|
|
45960
45960
|
try {
|
|
45961
|
-
text3 = inline ?
|
|
45961
|
+
text3 = inline ? path69 : readFileSync6(path69, "utf8");
|
|
45962
45962
|
} catch (err) {
|
|
45963
|
-
failWriteValidation2(`could not read ${
|
|
45963
|
+
failWriteValidation2(`could not read ${path69}: ${err instanceof Error ? err.message : String(err)}`);
|
|
45964
45964
|
}
|
|
45965
45965
|
const parsed = parseConversionRowsText(text3);
|
|
45966
45966
|
if (!parsed.ok) {
|
|
45967
|
-
failWriteValidation2(`${inline ? "the conversions passed inline" :
|
|
45967
|
+
failWriteValidation2(`${inline ? "the conversions passed inline" : path69}: ${parsed.error}`);
|
|
45968
45968
|
}
|
|
45969
45969
|
return { rows: parsed.rows, ignoredColumns: parsed.ignoredColumns };
|
|
45970
45970
|
}
|
|
@@ -47865,19 +47865,19 @@ function failWriteValidation3(message) {
|
|
|
47865
47865
|
writeJsonEnvelope({ ok: false, error: { code: "VALIDATION_ERROR", message } });
|
|
47866
47866
|
process.exit(1);
|
|
47867
47867
|
}
|
|
47868
|
-
function loadJsonFileArg2(
|
|
47869
|
-
if (typeof
|
|
47868
|
+
function loadJsonFileArg2(path69) {
|
|
47869
|
+
if (typeof path69 !== "string" || path69.length === 0) {
|
|
47870
47870
|
return {};
|
|
47871
47871
|
}
|
|
47872
47872
|
try {
|
|
47873
|
-
const parsed = JSON.parse(readFileSync7(
|
|
47873
|
+
const parsed = JSON.parse(readFileSync7(path69, "utf8"));
|
|
47874
47874
|
if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
47875
|
-
failWriteValidation3(`${
|
|
47875
|
+
failWriteValidation3(`${path69} must contain a JSON object`);
|
|
47876
47876
|
}
|
|
47877
47877
|
return parsed;
|
|
47878
47878
|
} catch (err) {
|
|
47879
47879
|
if (err instanceof SyntaxError) {
|
|
47880
|
-
failWriteValidation3(`${
|
|
47880
|
+
failWriteValidation3(`${path69} is not valid JSON: ${err.message}`);
|
|
47881
47881
|
}
|
|
47882
47882
|
throw err;
|
|
47883
47883
|
}
|
|
@@ -47962,15 +47962,15 @@ function parseLocaleFlag(value2) {
|
|
|
47962
47962
|
}
|
|
47963
47963
|
return { language: match[1], country: match[2].toUpperCase() };
|
|
47964
47964
|
}
|
|
47965
|
-
function loadTargetingFileArg(
|
|
47966
|
-
if (typeof
|
|
47965
|
+
function loadTargetingFileArg(path69) {
|
|
47966
|
+
if (typeof path69 !== "string" || path69.length === 0) {
|
|
47967
47967
|
return void 0;
|
|
47968
47968
|
}
|
|
47969
|
-
const parsed = loadJsonFileArg2(
|
|
47969
|
+
const parsed = loadJsonFileArg2(path69);
|
|
47970
47970
|
const criteria = parsed.targetingCriteria ?? parsed;
|
|
47971
47971
|
if (!criteria.include) {
|
|
47972
47972
|
failWriteValidation3(
|
|
47973
|
-
`${
|
|
47973
|
+
`${path69} must contain targeting criteria with an "include" block (see baker schema ads.linkedin.campaigns.create)`
|
|
47974
47974
|
);
|
|
47975
47975
|
}
|
|
47976
47976
|
return criteria;
|
|
@@ -48005,14 +48005,14 @@ function parseCsvLine(line) {
|
|
|
48005
48005
|
cells.push(current);
|
|
48006
48006
|
return cells.map((cell3) => cell3.trim());
|
|
48007
48007
|
}
|
|
48008
|
-
function parseListFileArg(
|
|
48009
|
-
if (typeof
|
|
48008
|
+
function parseListFileArg(path69, maxRows) {
|
|
48009
|
+
if (typeof path69 !== "string" || path69.length === 0) {
|
|
48010
48010
|
return void 0;
|
|
48011
48011
|
}
|
|
48012
|
-
const raw = readFileSync7(
|
|
48012
|
+
const raw = readFileSync7(path69, "utf8");
|
|
48013
48013
|
const lines = raw.split(/\r?\n/).filter((line) => line.trim().length > 0);
|
|
48014
48014
|
if (lines.length < 2) {
|
|
48015
|
-
failWriteValidation3(`${
|
|
48015
|
+
failWriteValidation3(`${path69} needs a header row and at least one data row`);
|
|
48016
48016
|
}
|
|
48017
48017
|
const columns = parseCsvLine(lines[0]).map((column) => column.trim());
|
|
48018
48018
|
const rows = [];
|
|
@@ -48031,7 +48031,7 @@ function parseListFileArg(path68, maxRows) {
|
|
|
48031
48031
|
}
|
|
48032
48032
|
}
|
|
48033
48033
|
if (rows.length > maxRows) {
|
|
48034
|
-
failWriteValidation3(`${
|
|
48034
|
+
failWriteValidation3(`${path69} has ${rows.length} rows \u2014 the inline limit is ${maxRows}. Split the list.`);
|
|
48035
48035
|
}
|
|
48036
48036
|
return { columns, rows };
|
|
48037
48037
|
}
|
|
@@ -48127,11 +48127,11 @@ function readPositionals(args8) {
|
|
|
48127
48127
|
function splitIdList(raw) {
|
|
48128
48128
|
return raw.split(",").map((id) => id.trim()).filter(Boolean);
|
|
48129
48129
|
}
|
|
48130
|
-
function idsFileEntries(
|
|
48131
|
-
if (typeof
|
|
48130
|
+
function idsFileEntries(path69) {
|
|
48131
|
+
if (typeof path69 !== "string" || path69.length === 0) {
|
|
48132
48132
|
return [];
|
|
48133
48133
|
}
|
|
48134
|
-
return readFileSync7(
|
|
48134
|
+
return readFileSync7(path69, "utf8").split(/\r?\n/).map((line) => line.trim()).filter((line) => line.length > 0 && !line.startsWith("#")).flatMap(splitIdList);
|
|
48135
48135
|
}
|
|
48136
48136
|
function requireTargets2(args8, entity) {
|
|
48137
48137
|
const positionals = readPositionals(args8);
|
|
@@ -52233,54 +52233,54 @@ function ruleFields(node) {
|
|
|
52233
52233
|
([key, value2]) => (key === "and" || key === "or") && Array.isArray(value2) ? value2.flatMap(ruleFields) : [key]
|
|
52234
52234
|
);
|
|
52235
52235
|
}
|
|
52236
|
-
function branchRefusal(key, value2,
|
|
52236
|
+
function branchRefusal(key, value2, path69) {
|
|
52237
52237
|
if (!Array.isArray(value2) || value2.length === 0) {
|
|
52238
|
-
return `${
|
|
52238
|
+
return `${path69}.${key} must be a non-empty array of conditions \u2014 an empty one counts every event the pixel sends`;
|
|
52239
52239
|
}
|
|
52240
52240
|
for (const [index, child] of value2.entries()) {
|
|
52241
|
-
const refusal = ruleNodeRefusal(child, `${
|
|
52241
|
+
const refusal = ruleNodeRefusal(child, `${path69}.${key}[${index}]`);
|
|
52242
52242
|
if (refusal) {
|
|
52243
52243
|
return refusal;
|
|
52244
52244
|
}
|
|
52245
52245
|
}
|
|
52246
52246
|
return void 0;
|
|
52247
52247
|
}
|
|
52248
|
-
function conditionRefusal(key, value2,
|
|
52249
|
-
return key === "and" || key === "or" ? branchRefusal(key, value2,
|
|
52248
|
+
function conditionRefusal(key, value2, path69) {
|
|
52249
|
+
return key === "and" || key === "or" ? branchRefusal(key, value2, path69) : leafRefusal(key, value2, path69);
|
|
52250
52250
|
}
|
|
52251
|
-
function ruleNodeRefusal(node,
|
|
52251
|
+
function ruleNodeRefusal(node, path69) {
|
|
52252
52252
|
if (!isRecord2(node)) {
|
|
52253
|
-
return `${
|
|
52253
|
+
return `${path69} must be an object like {"URL":{"i_contains":"/thank-you"}}`;
|
|
52254
52254
|
}
|
|
52255
52255
|
const entries = Object.entries(node);
|
|
52256
52256
|
if (entries.length === 0) {
|
|
52257
|
-
return `${
|
|
52257
|
+
return `${path69} is empty \u2014 a rule with no condition counts every event the pixel sends`;
|
|
52258
52258
|
}
|
|
52259
52259
|
if (entries.length > 1) {
|
|
52260
|
-
return `${
|
|
52260
|
+
return `${path69} names ${entries.length} conditions side by side (${entries.map(([key]) => key).join(", ")}) \u2014 Meta reads one branch or one field test per object, so combine them with {"and":[\u2026]}`;
|
|
52261
52261
|
}
|
|
52262
52262
|
for (const [key, value2] of entries) {
|
|
52263
|
-
const refusal = conditionRefusal(key, value2,
|
|
52263
|
+
const refusal = conditionRefusal(key, value2, path69);
|
|
52264
52264
|
if (refusal) {
|
|
52265
52265
|
return refusal;
|
|
52266
52266
|
}
|
|
52267
52267
|
}
|
|
52268
52268
|
return void 0;
|
|
52269
52269
|
}
|
|
52270
|
-
function leafRefusal(field, condition,
|
|
52270
|
+
function leafRefusal(field, condition, path69) {
|
|
52271
52271
|
if (!isRecord2(condition)) {
|
|
52272
|
-
return `${
|
|
52272
|
+
return `${path69}.${field} must be a test like {"i_contains":"/thank-you"}, not a bare value`;
|
|
52273
52273
|
}
|
|
52274
52274
|
const tests = Object.entries(condition);
|
|
52275
52275
|
if (tests.length === 0) {
|
|
52276
|
-
return `${
|
|
52276
|
+
return `${path69}.${field} names no test \u2014 use one of ${Object.keys(RULE_OPERATORS).join(", ")}`;
|
|
52277
52277
|
}
|
|
52278
52278
|
if (tests.length > 1) {
|
|
52279
|
-
return `${
|
|
52279
|
+
return `${path69}.${field} names ${tests.length} operators at once (${tests.map(([operator]) => operator).join(", ")}) \u2014 test a field once per condition and combine them with {"and":[\u2026]}`;
|
|
52280
52280
|
}
|
|
52281
52281
|
for (const [operator] of tests) {
|
|
52282
52282
|
if (!RULE_OPERATORS[operator]) {
|
|
52283
|
-
return `${
|
|
52283
|
+
return `${path69}.${field} uses "${operator}", which is not a Meta rule operator \u2014 use one of ${Object.keys(RULE_OPERATORS).join(", ")} (URL matching is i_contains, not contains or includes)`;
|
|
52284
52284
|
}
|
|
52285
52285
|
}
|
|
52286
52286
|
return void 0;
|
|
@@ -52996,11 +52996,11 @@ var updateStatusSchema2 = z52.enum(UPDATE_STATUSES);
|
|
|
52996
52996
|
function currencyMinimums2(currencyCode) {
|
|
52997
52997
|
return CURRENCY_MINIMUMS2[currencyCode] ?? DEFAULT_CURRENCY_MINIMUM2;
|
|
52998
52998
|
}
|
|
52999
|
-
function validateDailyBudgetFloor(money, ctx,
|
|
52999
|
+
function validateDailyBudgetFloor(money, ctx, path69) {
|
|
53000
53000
|
if (money?.currencyCode) {
|
|
53001
53001
|
const min = currencyMinimums2(money.currencyCode).dailyBudgetMin;
|
|
53002
53002
|
if (Number(money.amount) < min) {
|
|
53003
|
-
ctx.addIssue({ code: "custom", path:
|
|
53003
|
+
ctx.addIssue({ code: "custom", path: path69, message: `below the ${min} ${money.currencyCode} daily minimum` });
|
|
53004
53004
|
}
|
|
53005
53005
|
}
|
|
53006
53006
|
}
|
|
@@ -53918,19 +53918,19 @@ function refuseDeleteByUpdate(payload, group) {
|
|
|
53918
53918
|
);
|
|
53919
53919
|
}
|
|
53920
53920
|
}
|
|
53921
|
-
function loadJsonFileArg3(
|
|
53922
|
-
if (typeof
|
|
53921
|
+
function loadJsonFileArg3(path69) {
|
|
53922
|
+
if (typeof path69 !== "string" || path69.length === 0) {
|
|
53923
53923
|
return {};
|
|
53924
53924
|
}
|
|
53925
53925
|
try {
|
|
53926
|
-
const parsed = JSON.parse(readFileSync11(
|
|
53926
|
+
const parsed = JSON.parse(readFileSync11(path69, "utf8"));
|
|
53927
53927
|
if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
53928
|
-
failWriteValidation4(`${
|
|
53928
|
+
failWriteValidation4(`${path69} must contain a JSON object`);
|
|
53929
53929
|
}
|
|
53930
53930
|
return parsed;
|
|
53931
53931
|
} catch (err) {
|
|
53932
53932
|
if (err instanceof SyntaxError) {
|
|
53933
|
-
failWriteValidation4(`${
|
|
53933
|
+
failWriteValidation4(`${path69} is not valid JSON: ${err.message}`);
|
|
53934
53934
|
}
|
|
53935
53935
|
throw err;
|
|
53936
53936
|
}
|
|
@@ -54832,9 +54832,9 @@ var listArgs6 = {
|
|
|
54832
54832
|
},
|
|
54833
54833
|
...META_LIST_SHAPE_ARGS
|
|
54834
54834
|
};
|
|
54835
|
-
async function readOrEmpty(
|
|
54835
|
+
async function readOrEmpty(path69, params, label, hints2) {
|
|
54836
54836
|
try {
|
|
54837
|
-
return await apiGet(
|
|
54837
|
+
return await apiGet(path69, params);
|
|
54838
54838
|
} catch (err) {
|
|
54839
54839
|
const message = err instanceof Error ? err.message : "unknown error";
|
|
54840
54840
|
hints2.push(`Could not read the account's ${label} (${message}); the viewer was read without them.`);
|
|
@@ -59777,12 +59777,12 @@ function flowExists(slug) {
|
|
|
59777
59777
|
return existsSync3(join2(flowsDir(), slug, "_data.json"));
|
|
59778
59778
|
}
|
|
59779
59779
|
function readFlowTree(slug) {
|
|
59780
|
-
const
|
|
59781
|
-
if (!existsSync3(
|
|
59780
|
+
const path69 = join2(flowsDir(), slug, "_data.json");
|
|
59781
|
+
if (!existsSync3(path69)) {
|
|
59782
59782
|
failLocal(`No form "${slug}". Run "baker flows list" to see the forms in this workspace.`);
|
|
59783
59783
|
}
|
|
59784
59784
|
try {
|
|
59785
|
-
return JSON.parse(readFileSync13(
|
|
59785
|
+
return JSON.parse(readFileSync13(path69, "utf-8"));
|
|
59786
59786
|
} catch (error) {
|
|
59787
59787
|
failLocal(`Could not read form "${slug}": ${error instanceof Error ? error.message : String(error)}`);
|
|
59788
59788
|
}
|
|
@@ -60759,12 +60759,12 @@ function readPeopleFile(args8) {
|
|
|
60759
60759
|
}
|
|
60760
60760
|
function unreadablePeopleFile(args8) {
|
|
60761
60761
|
if (!args8["people-file"]) return void 0;
|
|
60762
|
-
const
|
|
60762
|
+
const path69 = String(args8["people-file"]);
|
|
60763
60763
|
try {
|
|
60764
|
-
readFileSync14(
|
|
60764
|
+
readFileSync14(path69, "utf8");
|
|
60765
60765
|
return void 0;
|
|
60766
60766
|
} catch {
|
|
60767
|
-
return `Couldn't read --people-file ${
|
|
60767
|
+
return `Couldn't read --people-file ${path69}. Check the path, or pass the people inline with --person.`;
|
|
60768
60768
|
}
|
|
60769
60769
|
}
|
|
60770
60770
|
function peopleLimitError(args8) {
|
|
@@ -61736,11 +61736,11 @@ function parseFieldArgs(argv) {
|
|
|
61736
61736
|
for (const pair of parseRepeated(argv, "--field")) {
|
|
61737
61737
|
const eq = pair.indexOf("=");
|
|
61738
61738
|
const field = eq === -1 ? pair : pair.slice(0, eq);
|
|
61739
|
-
const
|
|
61739
|
+
const path69 = eq === -1 ? "" : pair.slice(eq + 1).trim();
|
|
61740
61740
|
const problem = mappingRowProblem(field);
|
|
61741
61741
|
if (problem !== null) throw new ConversionArgsError(problem);
|
|
61742
|
-
if (
|
|
61743
|
-
mapping[field] =
|
|
61742
|
+
if (path69 === "") throw new ConversionArgsError(`--field ${field} needs a path: --field ${field}=<dotted.path>.`);
|
|
61743
|
+
mapping[field] = path69;
|
|
61744
61744
|
}
|
|
61745
61745
|
return mapping;
|
|
61746
61746
|
}
|
|
@@ -63413,11 +63413,11 @@ function unwrap(response) {
|
|
|
63413
63413
|
}
|
|
63414
63414
|
return response.data;
|
|
63415
63415
|
}
|
|
63416
|
-
async function readAvatars(
|
|
63417
|
-
return unwrap(await apiGet(
|
|
63416
|
+
async function readAvatars(path69, params) {
|
|
63417
|
+
return unwrap(await apiGet(path69, params));
|
|
63418
63418
|
}
|
|
63419
|
-
async function writeAvatars(
|
|
63420
|
-
return unwrap(await apiPost(
|
|
63419
|
+
async function writeAvatars(path69, body, opts) {
|
|
63420
|
+
return unwrap(await apiPost(path69, body, opts));
|
|
63421
63421
|
}
|
|
63422
63422
|
|
|
63423
63423
|
// src/commands/avatars/create.ts
|
|
@@ -64531,12 +64531,12 @@ function missingFontFiles(urls, available) {
|
|
|
64531
64531
|
function planFontAdoption(sources, families) {
|
|
64532
64532
|
const wanted = new Map(families.map((family) => [normalizeFamily(family), family]));
|
|
64533
64533
|
const byFamily = /* @__PURE__ */ new Map();
|
|
64534
|
-
for (const { path:
|
|
64535
|
-
const dir = posix.dirname(
|
|
64534
|
+
for (const { path: path69, source } of sources) {
|
|
64535
|
+
const dir = posix.dirname(path69);
|
|
64536
64536
|
for (const face of declaredFontFaces(source)) {
|
|
64537
64537
|
if (!wanted.has(face.family)) continue;
|
|
64538
64538
|
const perFile = byFamily.get(face.family) ?? /* @__PURE__ */ new Map();
|
|
64539
|
-
perFile.set(
|
|
64539
|
+
perFile.set(path69, [...perFile.get(path69) ?? [], rebaseFontFaceSrc(face.block, dir)]);
|
|
64540
64540
|
byFamily.set(face.family, perFile);
|
|
64541
64541
|
}
|
|
64542
64542
|
}
|
|
@@ -67205,8 +67205,8 @@ function logoComposited(opts) {
|
|
|
67205
67205
|
}
|
|
67206
67206
|
var MAX_TAKES = 3;
|
|
67207
67207
|
var UNCOMPILED = "compiled from prompt.json";
|
|
67208
|
-
function ingestNode(id,
|
|
67209
|
-
return { id, type: "ingest", params: { source: "path", path:
|
|
67208
|
+
function ingestNode(id, path69, expect) {
|
|
67209
|
+
return { id, type: "ingest", params: { source: "path", path: path69, expect } };
|
|
67210
67210
|
}
|
|
67211
67211
|
function aspectRatio(blueprint, opts) {
|
|
67212
67212
|
const requested = opts.aspectRatio ?? blueprint.meta?.estimated_aspect_ratio;
|
|
@@ -67496,19 +67496,32 @@ function variantStage(canvas) {
|
|
|
67496
67496
|
const template = [...variants, ...calls].find((n) => n.type === "image_generate");
|
|
67497
67497
|
const master = nodesWithRole(canvas, STATIC_MASTER_ROLE)[0];
|
|
67498
67498
|
if (!template || !master) throw new Error("not a static ad canvas: it renders no variants to correct");
|
|
67499
|
+
const masterInputs = JSON.stringify(master.inputs ?? {});
|
|
67500
|
+
const prefilter = nodesWithRole(canvas, VARIANT_PREFILTER_ROLE).find((n) => masterInputs.includes(`$ref:${n.id}.`));
|
|
67499
67501
|
const removed = new Set(
|
|
67500
67502
|
[
|
|
67501
67503
|
...variants,
|
|
67502
67504
|
...calls,
|
|
67503
|
-
...nodesWithRole(canvas, VARIANT_PREFILTER_ROLE),
|
|
67505
|
+
...nodesWithRole(canvas, VARIANT_PREFILTER_ROLE).filter((n) => n !== prefilter),
|
|
67504
67506
|
...nodesWithRole(canvas, STATIC_PICK_ROLE)
|
|
67505
67507
|
].map((n) => n.id)
|
|
67506
67508
|
);
|
|
67507
|
-
return {
|
|
67509
|
+
return {
|
|
67510
|
+
removed,
|
|
67511
|
+
template,
|
|
67512
|
+
masterId: master.id,
|
|
67513
|
+
...prefilter ? { prefilterId: prefilter.id } : {}
|
|
67514
|
+
};
|
|
67508
67515
|
}
|
|
67509
67516
|
function withMasterSource(canvas, stage, source, ref2, opts) {
|
|
67510
|
-
const kept = canvas.nodes.filter((n) => !stage.removed.has(n.id)).map((n) =>
|
|
67511
|
-
|
|
67517
|
+
const kept = canvas.nodes.filter((n) => !stage.removed.has(n.id)).map((n) => {
|
|
67518
|
+
if (n.id === stage.prefilterId) {
|
|
67519
|
+
const { judge_model: _judge, judge_prompt: _prompt, ...params } = n.params ?? {};
|
|
67520
|
+
return { ...n, inputs: { ...n.inputs, images: [ref2] }, params };
|
|
67521
|
+
}
|
|
67522
|
+
return n.id === stage.masterId && !stage.prefilterId ? { ...n, inputs: { ...n.inputs, image: ref2 } } : n;
|
|
67523
|
+
});
|
|
67524
|
+
const at = kept.findIndex((n) => n.id === (stage.prefilterId ?? stage.masterId));
|
|
67512
67525
|
const description = `${canvas.metadata?.description ?? ""} ${opts.note}`;
|
|
67513
67526
|
return {
|
|
67514
67527
|
...canvas,
|
|
@@ -72315,6 +72328,9 @@ async function readRenderState(canvasRoot, slug) {
|
|
|
72315
72328
|
return {};
|
|
72316
72329
|
}
|
|
72317
72330
|
}
|
|
72331
|
+
async function latestVersion(canvasRoot, slug) {
|
|
72332
|
+
return (await readRenderState(canvasRoot, slug)).rendered?.runId ?? null;
|
|
72333
|
+
}
|
|
72318
72334
|
async function updateRenderState(canvasRoot, slug, patch) {
|
|
72319
72335
|
try {
|
|
72320
72336
|
const next = { ...await readRenderState(canvasRoot, slug), ...patch };
|
|
@@ -75249,8 +75265,8 @@ var Answer = z67.object({
|
|
|
75249
75265
|
changed: z67.string().min(1),
|
|
75250
75266
|
set: z67.array(z67.object({ path: z67.string().min(1), value: z67.unknown() }))
|
|
75251
75267
|
});
|
|
75252
|
-
function withValueAt(root,
|
|
75253
|
-
const [key, ...rest] =
|
|
75268
|
+
function withValueAt(root, path69, value2) {
|
|
75269
|
+
const [key, ...rest] = path69;
|
|
75254
75270
|
if (key === void 0) return value2;
|
|
75255
75271
|
if (Array.isArray(root)) {
|
|
75256
75272
|
const at = Number(key);
|
|
@@ -75268,7 +75284,7 @@ function printedWords(spec) {
|
|
|
75268
75284
|
function acceptRepair(before, answer) {
|
|
75269
75285
|
const parsed = Answer.safeParse(answer);
|
|
75270
75286
|
if (!parsed.success || !isAdSpec(before)) return null;
|
|
75271
|
-
const spec = parsed.data.set.reduce((at, { path:
|
|
75287
|
+
const spec = parsed.data.set.reduce((at, { path: path69, value: value2 }) => withValueAt(at, path69.split("."), value2), before);
|
|
75272
75288
|
if (!isAdSpec(spec)) return null;
|
|
75273
75289
|
const was = AdSpecSchema.safeParse(before);
|
|
75274
75290
|
const now = AdSpecSchema.safeParse(spec);
|
|
@@ -75576,8 +75592,8 @@ ${describeRewrites(prepared.rewrites)}
|
|
|
75576
75592
|
});
|
|
75577
75593
|
const last = Object.fromEntries(
|
|
75578
75594
|
nodesWithRole(parsed, STATIC_ADAPT_FORMAT_ROLE).flatMap((n) => {
|
|
75579
|
-
const
|
|
75580
|
-
return
|
|
75595
|
+
const path69 = delivered.find((d) => d.format === formatOfAdaptId(n.id))?.path;
|
|
75596
|
+
return path69 ? [[n.id, path69]] : [];
|
|
75581
75597
|
})
|
|
75582
75598
|
);
|
|
75583
75599
|
parsed = withSizesFollowingFix(parsed, {
|
|
@@ -80777,8 +80793,8 @@ var FLAG_FOR_FIELD = {
|
|
|
80777
80793
|
first_seen_after: "--first-seen-after",
|
|
80778
80794
|
first_seen_before: "--first-seen-before"
|
|
80779
80795
|
};
|
|
80780
|
-
function flagFor(
|
|
80781
|
-
const field = String(
|
|
80796
|
+
function flagFor(path69) {
|
|
80797
|
+
const field = String(path69[0] === "hard_filters" ? path69[1] : path69[0]);
|
|
80782
80798
|
return FLAG_FOR_FIELD[field] ?? field;
|
|
80783
80799
|
}
|
|
80784
80800
|
function schemaRejection(body) {
|
|
@@ -81671,12 +81687,26 @@ import { defineCommand as defineCommand157 } from "citty";
|
|
|
81671
81687
|
|
|
81672
81688
|
// src/commands/creatives/feedback-record.ts
|
|
81673
81689
|
import { defineCommand as defineCommand156 } from "citty";
|
|
81690
|
+
|
|
81691
|
+
// src/commands/creatives/version-of.ts
|
|
81692
|
+
import path45 from "path";
|
|
81693
|
+
async function versionOf(slug, run3) {
|
|
81694
|
+
if (typeof run3 === "string" && run3.trim()) return run3.trim();
|
|
81695
|
+
const canvas = path45.join("src", "creatives", slug, `${slug}.canvas.json`);
|
|
81696
|
+
return await latestVersion(canvasOutputsRoot(canvas), slug) ?? void 0;
|
|
81697
|
+
}
|
|
81698
|
+
|
|
81699
|
+
// src/commands/creatives/feedback-record.ts
|
|
81674
81700
|
var DESCRIPTION7 = `Record what the user said about one version of a creative in this chat: Approve, or Not this one with reasons. Saved as their verdict (the person who wrote the latest message here), exactly like reviewing it in Baker, and read back by baker creatives feedback. One verdict per person per version or option: a later one replaces it.
|
|
81675
|
-
Start here: baker creatives feedback record --slug spring-offer --
|
|
81701
|
+
Start here: baker creatives feedback record --slug spring-offer --verdict rejected --reasons text_mistakes --note "<their words>"
|
|
81676
81702
|
Only record what the user said, never your own judgment. Picking one of several concepts is not a rejection of the others.`;
|
|
81677
81703
|
var ARGS10 = {
|
|
81678
81704
|
slug: { type: "string", description: "The creative: its folder name under src/creatives/.", required: true },
|
|
81679
|
-
run: {
|
|
81705
|
+
run: {
|
|
81706
|
+
type: "string",
|
|
81707
|
+
description: "The version: its canvas run id (r_\u2026) Left out, the version the creative shows now (its last render).",
|
|
81708
|
+
required: false
|
|
81709
|
+
},
|
|
81680
81710
|
option: {
|
|
81681
81711
|
type: "string",
|
|
81682
81712
|
description: 'One option of a version that made several: its label ("ugc"), its number ("2") or its slot. Left out, the whole version.',
|
|
@@ -81730,7 +81760,9 @@ var feedbackRecordCommand = defineCommand156({
|
|
|
81730
81760
|
}
|
|
81731
81761
|
const parsed = creativesFeedbackRecordRequestSchema.safeParse({
|
|
81732
81762
|
slug: args8.slug,
|
|
81733
|
-
runId: args8.run
|
|
81763
|
+
runId: await versionOf(String(args8.slug), args8.run).then(
|
|
81764
|
+
(run3) => run3 ?? fail5("VALIDATION_ERROR", "--run: this creative has no rendered version here; name one (r_\u2026).")
|
|
81765
|
+
),
|
|
81734
81766
|
...typeof args8.option === "string" && args8.option.trim() ? { option: args8.option.trim() } : {},
|
|
81735
81767
|
verdict: args8.verdict,
|
|
81736
81768
|
...reasons ? { reasons } : {},
|
|
@@ -81805,7 +81837,7 @@ var feedbackCommand = defineCommand157({
|
|
|
81805
81837
|
// src/commands/creatives/learn.ts
|
|
81806
81838
|
import { readFileSync as readFileSync18 } from "fs";
|
|
81807
81839
|
import { readFile as readFile37, writeFile as writeFile23 } from "fs/promises";
|
|
81808
|
-
import
|
|
81840
|
+
import path46 from "path";
|
|
81809
81841
|
import { defineCommand as defineCommand158 } from "citty";
|
|
81810
81842
|
|
|
81811
81843
|
// src/commands/creatives/learn-model.ts
|
|
@@ -82027,14 +82059,14 @@ function learnEnvelope(learnings, written, unreadable = []) {
|
|
|
82027
82059
|
}
|
|
82028
82060
|
async function writeBack(root, learnings) {
|
|
82029
82061
|
for (const learning of learnings) {
|
|
82030
|
-
const file =
|
|
82062
|
+
const file = path46.join(root, IDEAS_DIR, `${learning.idea}.md`);
|
|
82031
82063
|
const raw = await readFile37(file, "utf8");
|
|
82032
82064
|
await writeFile23(file, setDefinitionFields(raw, { status: learning.to, result: learning.result }), "utf8");
|
|
82033
82065
|
}
|
|
82034
82066
|
}
|
|
82035
82067
|
function readDefinition2(root, slug) {
|
|
82036
82068
|
try {
|
|
82037
|
-
return readFileSync18(
|
|
82069
|
+
return readFileSync18(path46.join(root, "src", "creatives", slug, "_definition.md"), "utf8");
|
|
82038
82070
|
} catch {
|
|
82039
82071
|
return null;
|
|
82040
82072
|
}
|
|
@@ -82074,7 +82106,7 @@ var learnCommand = defineCommand158({
|
|
|
82074
82106
|
import { execFile as execFile3 } from "child_process";
|
|
82075
82107
|
import { mkdtemp as mkdtemp2, readFile as readFile38, rm as rm7, stat as stat7, writeFile as writeFile24 } from "fs/promises";
|
|
82076
82108
|
import { tmpdir as tmpdir3 } from "os";
|
|
82077
|
-
import
|
|
82109
|
+
import path47 from "path";
|
|
82078
82110
|
import { promisify as promisify3 } from "util";
|
|
82079
82111
|
import { defineCommand as defineCommand159 } from "citty";
|
|
82080
82112
|
var run2 = promisify3(execFile3);
|
|
@@ -82297,7 +82329,7 @@ async function scaffoldIdea(root, idea, args8, slug, temperature) {
|
|
|
82297
82329
|
],
|
|
82298
82330
|
signal
|
|
82299
82331
|
);
|
|
82300
|
-
const dir =
|
|
82332
|
+
const dir = path47.join(root, "src", "creatives", slug);
|
|
82301
82333
|
const fresh = !await stat7(dir).catch(() => null);
|
|
82302
82334
|
const reference = args8.reference ? { adId: args8.reference, platform: asPlatform(args8.platform), why: "chosen by hand", tried: 0 } : args8.fromIdea ? { code: "FROM_IDEA", message: "Asked to start from the idea." } : await pickReference(
|
|
82303
82335
|
root,
|
|
@@ -82317,8 +82349,8 @@ async function scaffoldIdea(root, idea, args8, slug, temperature) {
|
|
|
82317
82349
|
return { scaffold, reference };
|
|
82318
82350
|
}
|
|
82319
82351
|
async function scaffoldFromIdea(idea, slug, viewerFlags) {
|
|
82320
|
-
const dir = await mkdtemp2(
|
|
82321
|
-
const specPath =
|
|
82352
|
+
const dir = await mkdtemp2(path47.join(tmpdir3(), "idea-spec-"));
|
|
82353
|
+
const specPath = path47.join(dir, "prompt.json");
|
|
82322
82354
|
await writeFile24(specPath, JSON.stringify(ideaSpec(idea, idea.who.replace(/[-_]/g, " ")), null, 2), "utf8");
|
|
82323
82355
|
try {
|
|
82324
82356
|
return await baker([
|
|
@@ -82337,18 +82369,18 @@ async function scaffoldFromIdea(idea, slug, viewerFlags) {
|
|
|
82337
82369
|
}
|
|
82338
82370
|
}
|
|
82339
82371
|
async function recordIdea(root, slug, idea, evidence) {
|
|
82340
|
-
const dir =
|
|
82341
|
-
const definitionPath =
|
|
82372
|
+
const dir = path47.join(root, "src", "creatives", slug);
|
|
82373
|
+
const definitionPath = path47.join(dir, "_definition.md");
|
|
82342
82374
|
const definition = await readFile38(definitionPath, "utf8").catch(() => null);
|
|
82343
82375
|
if (definition !== null) {
|
|
82344
82376
|
await writeFile24(definitionPath, setDefinitionFields(definition, { ...definitionFieldsOf(idea, evidence) }), "utf8");
|
|
82345
82377
|
}
|
|
82346
|
-
const promptPath =
|
|
82378
|
+
const promptPath = path47.join(dir, "prompt.json");
|
|
82347
82379
|
const prompt = isVideoIdea(idea) ? null : await readFile38(promptPath, "utf8").catch(() => null);
|
|
82348
82380
|
if (prompt !== null) await writeFile24(promptPath, setSpecMessage(prompt, idea.message), "utf8").catch(() => void 0);
|
|
82349
82381
|
const unsourcedCopy = prompt === null ? [] : await draftedClaims(root, prompt);
|
|
82350
82382
|
if (idea.status === "idea") {
|
|
82351
|
-
const ideaPath =
|
|
82383
|
+
const ideaPath = path47.join(root, IDEAS_DIR, `${idea.id}.md`);
|
|
82352
82384
|
await writeFile24(ideaPath, setDefinitionFields(await readFile38(ideaPath, "utf8"), { status: "built" }), "utf8");
|
|
82353
82385
|
}
|
|
82354
82386
|
await baker(["canvas", "sync-definition", dir]);
|
|
@@ -82425,7 +82457,7 @@ var makeCommand = defineCommand159({
|
|
|
82425
82457
|
const opts = makeArgsOf(args8);
|
|
82426
82458
|
const { idea, check } = await loadIdea(root, String(args8.idea));
|
|
82427
82459
|
const slug = opts.slug ?? idea.id;
|
|
82428
|
-
const written = await readFile38(
|
|
82460
|
+
const written = await readFile38(path47.join(root, "src", "creatives", slug, "prompt.json"), "utf8").then(
|
|
82429
82461
|
(text3) => {
|
|
82430
82462
|
try {
|
|
82431
82463
|
return JSON.parse(text3);
|
|
@@ -82449,7 +82481,7 @@ var makeCommand = defineCommand159({
|
|
|
82449
82481
|
reference,
|
|
82450
82482
|
...fromIdea ? { fromIdea } : {},
|
|
82451
82483
|
viewer: opts.adset ? { adset: opts.adset } : { temperature },
|
|
82452
|
-
canvasPath:
|
|
82484
|
+
canvasPath: path47.relative(root, String(scaffold.canvas_path ?? path47.join(dir, `${slug}.canvas.json`))),
|
|
82453
82485
|
scaffoldHints: Array.isArray(scaffold.hints) ? scaffold.hints : [],
|
|
82454
82486
|
unsourcedCopy
|
|
82455
82487
|
})
|
|
@@ -82905,11 +82937,15 @@ var publishCommand = defineCommand160({
|
|
|
82905
82937
|
// src/commands/creatives/select.ts
|
|
82906
82938
|
import { defineCommand as defineCommand161 } from "citty";
|
|
82907
82939
|
var DESCRIPTION12 = `Choose the version of a creative to keep, and optionally which of its options, only when the user says to keep this version in this chat. The creative shows that version as the chosen one, and the choice counts as the user's approval. A version you render after it replaces it when the chat is published (the user saw that one last). It does not save the image to their library (that is baker creatives publish) and puts nothing into an ad.
|
|
82908
|
-
Start here: baker creatives select --slug spring-offer
|
|
82940
|
+
Start here: baker creatives select --slug spring-offer
|
|
82909
82941
|
Only some options of a version that made several: --options "ugc,2" (labels or numbers). Naming options again replaces the earlier pick.`;
|
|
82910
82942
|
var ARGS14 = {
|
|
82911
82943
|
slug: { type: "string", description: "The creative: its folder name under src/creatives/.", required: true },
|
|
82912
|
-
run: {
|
|
82944
|
+
run: {
|
|
82945
|
+
type: "string",
|
|
82946
|
+
description: "The version to keep: its canvas run id (r_\u2026) Left out, the version the creative shows now (its last render).",
|
|
82947
|
+
required: false
|
|
82948
|
+
},
|
|
82913
82949
|
options: {
|
|
82914
82950
|
type: "string",
|
|
82915
82951
|
description: 'Keep only these options of the version, comma-separated: labels ("ugc"), numbers ("2") or slots. Left out, the whole version.',
|
|
@@ -82928,7 +82964,9 @@ var selectCommand = defineCommand161({
|
|
|
82928
82964
|
const options = typeof args8.options === "string" ? args8.options.split(",").map((option) => option.trim()).filter((option) => option.length > 0) : [];
|
|
82929
82965
|
const parsed = creativesSelectRequestSchema.safeParse({
|
|
82930
82966
|
slug: args8.slug,
|
|
82931
|
-
runId: args8.run
|
|
82967
|
+
runId: await versionOf(String(args8.slug), args8.run).then(
|
|
82968
|
+
(run3) => run3 ?? fail7("VALIDATION_ERROR", "--run: this creative has no rendered version here; name one (r_\u2026).")
|
|
82969
|
+
),
|
|
82932
82970
|
...options.length > 0 ? { options } : {}
|
|
82933
82971
|
});
|
|
82934
82972
|
if (!parsed.success) {
|
|
@@ -84197,11 +84235,11 @@ import { defineCommand as defineCommand164 } from "citty";
|
|
|
84197
84235
|
|
|
84198
84236
|
// src/commands/experiment/composition.ts
|
|
84199
84237
|
import { readdir as readdir19, readFile as readFile42 } from "fs/promises";
|
|
84200
|
-
import
|
|
84238
|
+
import path49 from "path";
|
|
84201
84239
|
|
|
84202
84240
|
// src/commands/landing/import-graph.ts
|
|
84203
84241
|
import { readdir as readdir18, readFile as readFile41, stat as stat8 } from "fs/promises";
|
|
84204
|
-
import
|
|
84242
|
+
import path48 from "path";
|
|
84205
84243
|
var SOURCE_EXT = /\.(astro|ts|tsx|js|jsx|mjs|cjs|vue|svelte)$/;
|
|
84206
84244
|
var RESOLVE_CANDIDATES = [
|
|
84207
84245
|
"",
|
|
@@ -84234,7 +84272,7 @@ async function walkFiles(dir) {
|
|
|
84234
84272
|
}
|
|
84235
84273
|
const out = [];
|
|
84236
84274
|
for (const entry of entries) {
|
|
84237
|
-
const full =
|
|
84275
|
+
const full = path48.join(dir, entry.name);
|
|
84238
84276
|
if (entry.isDirectory()) {
|
|
84239
84277
|
if (entry.name === "node_modules" || entry.name === "dist") continue;
|
|
84240
84278
|
out.push(...await walkFiles(full));
|
|
@@ -84248,8 +84286,8 @@ async function resolveSpecifier(specifier, fromFile, root) {
|
|
|
84248
84286
|
const bare = specifier.split("?")[0] ?? "";
|
|
84249
84287
|
if (bare.includes("*")) return null;
|
|
84250
84288
|
let base;
|
|
84251
|
-
if (bare.startsWith("/")) base =
|
|
84252
|
-
else if (bare.startsWith(".")) base =
|
|
84289
|
+
if (bare.startsWith("/")) base = path48.join(root, bare.slice(1));
|
|
84290
|
+
else if (bare.startsWith(".")) base = path48.resolve(path48.dirname(fromFile), bare);
|
|
84253
84291
|
else return null;
|
|
84254
84292
|
for (const suffix of RESOLVE_CANDIDATES) {
|
|
84255
84293
|
const candidate = base + suffix;
|
|
@@ -84271,7 +84309,7 @@ async function importedFiles(text3, file, root) {
|
|
|
84271
84309
|
}
|
|
84272
84310
|
async function landingGraphFiles(root, slug) {
|
|
84273
84311
|
const seen = /* @__PURE__ */ new Set();
|
|
84274
|
-
const queue = await walkFiles(
|
|
84312
|
+
const queue = await walkFiles(path48.join(root, "src/pages", slug));
|
|
84275
84313
|
while (queue.length > 0) {
|
|
84276
84314
|
const file = queue.pop();
|
|
84277
84315
|
if (file === void 0 || seen.has(file)) continue;
|
|
@@ -84286,7 +84324,7 @@ async function landingGraphFiles(root, slug) {
|
|
|
84286
84324
|
if (!seen.has(target2)) queue.push(target2);
|
|
84287
84325
|
}
|
|
84288
84326
|
}
|
|
84289
|
-
return new Set([...seen].map((abs) =>
|
|
84327
|
+
return new Set([...seen].map((abs) => path48.relative(root, abs).split(path48.sep).join("/")));
|
|
84290
84328
|
}
|
|
84291
84329
|
|
|
84292
84330
|
// src/commands/experiment/composition.ts
|
|
@@ -84331,7 +84369,7 @@ function formsOnlyIn(these, those) {
|
|
|
84331
84369
|
}
|
|
84332
84370
|
async function knownFlows(root) {
|
|
84333
84371
|
try {
|
|
84334
|
-
const entries = await readdir19(
|
|
84372
|
+
const entries = await readdir19(path49.join(root, "src/lib/flow-engine/flows"), { withFileTypes: true });
|
|
84335
84373
|
return new Set(entries.filter((entry) => entry.isDirectory()).map((entry) => entry.name));
|
|
84336
84374
|
} catch {
|
|
84337
84375
|
return /* @__PURE__ */ new Set();
|
|
@@ -84342,7 +84380,7 @@ async function readForms(root, slug) {
|
|
|
84342
84380
|
const [files, flows] = await Promise.all([landingGraphFiles(root, slug), knownFlows(root)]);
|
|
84343
84381
|
if (flows.size === 0) return [];
|
|
84344
84382
|
const texts = await Promise.all(
|
|
84345
|
-
[...files].filter((file) => /\.(astro|ts|tsx|js|mjs)$/.test(file)).map((file) => readFile42(
|
|
84383
|
+
[...files].filter((file) => /\.(astro|ts|tsx|js|mjs)$/.test(file)).map((file) => readFile42(path49.join(root, file), "utf8"))
|
|
84346
84384
|
);
|
|
84347
84385
|
return formsReferenced(texts, flows);
|
|
84348
84386
|
} catch {
|
|
@@ -84353,7 +84391,7 @@ async function readForms(root, slug) {
|
|
|
84353
84391
|
// src/commands/experiment/fold.ts
|
|
84354
84392
|
import { statSync } from "fs";
|
|
84355
84393
|
import { cp as cp3, mkdir as mkdir15, readdir as readdir20, readFile as readFile43, rm as rm8, stat as stat9, writeFile as writeFile25 } from "fs/promises";
|
|
84356
|
-
import
|
|
84394
|
+
import path51 from "path";
|
|
84357
84395
|
|
|
84358
84396
|
// ../api/src/experiments/variants.ts
|
|
84359
84397
|
var VARIANT_SEPARATOR = "--";
|
|
@@ -84378,21 +84416,21 @@ function nextVariantNumber(page, existingSlugs, archived) {
|
|
|
84378
84416
|
}
|
|
84379
84417
|
|
|
84380
84418
|
// src/commands/landing/repoint.ts
|
|
84381
|
-
import
|
|
84419
|
+
import path50 from "path";
|
|
84382
84420
|
var QUOTED_RELATIVE = /(['"])(\.\.?\/[^'"]*)\1/g;
|
|
84383
84421
|
function isInside3(abs, dir) {
|
|
84384
|
-
return abs === dir || abs.startsWith(dir +
|
|
84422
|
+
return abs === dir || abs.startsWith(dir + path50.sep);
|
|
84385
84423
|
}
|
|
84386
84424
|
function toSpecifier(from, to) {
|
|
84387
|
-
const rel =
|
|
84425
|
+
const rel = path50.relative(from, to).split(path50.sep).join("/");
|
|
84388
84426
|
return rel.startsWith(".") ? rel : `./${rel}`;
|
|
84389
84427
|
}
|
|
84390
84428
|
function repointSpecifier(spec, opts) {
|
|
84391
84429
|
if (!spec.startsWith(".")) return spec;
|
|
84392
|
-
const abs =
|
|
84430
|
+
const abs = path50.resolve(opts.fromDir, spec);
|
|
84393
84431
|
if (opts.forkedTargets?.has(abs)) {
|
|
84394
|
-
const withinControl =
|
|
84395
|
-
return toSpecifier(opts.toDir,
|
|
84432
|
+
const withinControl = path50.relative(opts.controlDir, abs);
|
|
84433
|
+
return toSpecifier(opts.toDir, path50.resolve(opts.variantDir, withinControl));
|
|
84396
84434
|
}
|
|
84397
84435
|
if (!isInside3(abs, opts.controlDir)) return spec;
|
|
84398
84436
|
return toSpecifier(opts.toDir, abs);
|
|
@@ -84404,9 +84442,9 @@ function repointFile(text3, opts) {
|
|
|
84404
84442
|
}
|
|
84405
84443
|
function repointMoved(text3, opts) {
|
|
84406
84444
|
return text3.replace(QUOTED_RELATIVE, (_match, quote, spec) => {
|
|
84407
|
-
const abs =
|
|
84408
|
-
const within =
|
|
84409
|
-
const target2 = within.startsWith("..") ||
|
|
84445
|
+
const abs = path50.resolve(opts.fromDir, spec);
|
|
84446
|
+
const within = path50.relative(opts.movedFrom, abs);
|
|
84447
|
+
const target2 = within.startsWith("..") || path50.isAbsolute(within) ? abs : path50.resolve(opts.movedTo, within);
|
|
84410
84448
|
return `${quote}${toSpecifier(opts.toDir, target2)}${quote}`;
|
|
84411
84449
|
});
|
|
84412
84450
|
}
|
|
@@ -84415,7 +84453,7 @@ function repointMoved(text3, opts) {
|
|
|
84415
84453
|
var ARCHIVE_ROOT = "src/_variants";
|
|
84416
84454
|
var QUOTED_RELATIVE2 = /(['"])(\.\.?\/[^'"]*)\1/g;
|
|
84417
84455
|
function posix2(p) {
|
|
84418
|
-
return p.split(
|
|
84456
|
+
return p.split(path51.sep).join("/");
|
|
84419
84457
|
}
|
|
84420
84458
|
async function isDir(p) {
|
|
84421
84459
|
try {
|
|
@@ -84434,39 +84472,39 @@ async function filesUnder(dir, prefix = "") {
|
|
|
84434
84472
|
const out = [];
|
|
84435
84473
|
for (const entry of entries) {
|
|
84436
84474
|
const rel = prefix ? `${prefix}/${entry.name}` : entry.name;
|
|
84437
|
-
if (entry.isDirectory()) out.push(...await filesUnder(
|
|
84475
|
+
if (entry.isDirectory()) out.push(...await filesUnder(path51.join(dir, entry.name), rel));
|
|
84438
84476
|
else out.push(rel);
|
|
84439
84477
|
}
|
|
84440
84478
|
return out.sort();
|
|
84441
84479
|
}
|
|
84442
84480
|
var TEXT_EXT = /\.(astro|ts|tsx|js|jsx|mjs|cjs|vue|svelte|md|json|css)$/;
|
|
84443
84481
|
function archiveRelPath(abs, base) {
|
|
84444
|
-
if (!abs.startsWith(base +
|
|
84445
|
-
return posix2(
|
|
84482
|
+
if (!abs.startsWith(base + path51.sep)) return null;
|
|
84483
|
+
return posix2(path51.relative(base, abs));
|
|
84446
84484
|
}
|
|
84447
84485
|
async function archiveArm(opts) {
|
|
84448
84486
|
const { root, armDir, pageDir, archiveDir, armSlug } = opts;
|
|
84449
84487
|
const targets = await archiveContents({ root, armDir, pageDir, armSlug });
|
|
84450
|
-
const archivedBySource = new Map([...targets].map(([rel, abs]) => [abs,
|
|
84488
|
+
const archivedBySource = new Map([...targets].map(([rel, abs]) => [abs, path51.join(archiveDir, rel)]));
|
|
84451
84489
|
const written = [];
|
|
84452
84490
|
for (const [rel, abs] of [...targets].sort()) {
|
|
84453
|
-
const dest =
|
|
84454
|
-
await mkdir15(
|
|
84491
|
+
const dest = path51.join(archiveDir, rel);
|
|
84492
|
+
await mkdir15(path51.dirname(dest), { recursive: true });
|
|
84455
84493
|
if (!TEXT_EXT.test(rel)) {
|
|
84456
84494
|
await cp3(abs, dest);
|
|
84457
84495
|
} else {
|
|
84458
84496
|
const text3 = await readFile43(abs, "utf8");
|
|
84459
84497
|
await writeFile25(dest, repointIntoArchive(text3, abs, dest, archivedBySource), "utf8");
|
|
84460
84498
|
}
|
|
84461
|
-
written.push(posix2(
|
|
84499
|
+
written.push(posix2(path51.relative(root, dest)));
|
|
84462
84500
|
}
|
|
84463
84501
|
return written;
|
|
84464
84502
|
}
|
|
84465
84503
|
async function archiveContents(opts) {
|
|
84466
84504
|
const { root, armDir, pageDir, armSlug } = opts;
|
|
84467
84505
|
const graph = await landingGraphFiles(root, armSlug);
|
|
84468
|
-
const reachable = new Set([...graph].map((rel) =>
|
|
84469
|
-
for (const rel of await filesUnder(armDir)) reachable.add(
|
|
84506
|
+
const reachable = new Set([...graph].map((rel) => path51.resolve(root, rel)));
|
|
84507
|
+
for (const rel of await filesUnder(armDir)) reachable.add(path51.join(armDir, rel));
|
|
84470
84508
|
const sorted = [...reachable].sort();
|
|
84471
84509
|
const targets = /* @__PURE__ */ new Map();
|
|
84472
84510
|
for (const base of [pageDir, armDir]) {
|
|
@@ -84479,14 +84517,14 @@ async function archiveContents(opts) {
|
|
|
84479
84517
|
return targets;
|
|
84480
84518
|
}
|
|
84481
84519
|
function repointIntoArchive(text3, sourceAbs, destAbs, archivedBySource) {
|
|
84482
|
-
const fromDir =
|
|
84483
|
-
const toDir =
|
|
84520
|
+
const fromDir = path51.dirname(sourceAbs);
|
|
84521
|
+
const toDir = path51.dirname(destAbs);
|
|
84484
84522
|
return text3.replace(QUOTED_RELATIVE2, (match, quote, spec, offset) => {
|
|
84485
84523
|
const [specPath, suffix] = splitSuffix(spec);
|
|
84486
|
-
const target2 =
|
|
84524
|
+
const target2 = path51.resolve(fromDir, specPath);
|
|
84487
84525
|
const resolved = resolveInArchive(target2, archivedBySource) ?? resolveOnDisk(target2, isImportPosition(text3, offset));
|
|
84488
84526
|
if (resolved === null) return match;
|
|
84489
|
-
const rel = posix2(
|
|
84527
|
+
const rel = posix2(path51.relative(toDir, resolved));
|
|
84490
84528
|
return `${quote}${rel.startsWith(".") ? rel : `./${rel}`}${suffix}${quote}`;
|
|
84491
84529
|
});
|
|
84492
84530
|
}
|
|
@@ -84520,9 +84558,9 @@ async function promoteVariantFiles(opts) {
|
|
|
84520
84558
|
const written = [];
|
|
84521
84559
|
for (const rel of await filesUnder(variantDir)) {
|
|
84522
84560
|
if (rel === "_definition.md") continue;
|
|
84523
|
-
const from =
|
|
84524
|
-
const to =
|
|
84525
|
-
await mkdir15(
|
|
84561
|
+
const from = path51.join(variantDir, rel);
|
|
84562
|
+
const to = path51.join(pageDir, rel);
|
|
84563
|
+
await mkdir15(path51.dirname(to), { recursive: true });
|
|
84526
84564
|
if (!TEXT_EXT.test(rel)) {
|
|
84527
84565
|
await cp3(from, to);
|
|
84528
84566
|
} else {
|
|
@@ -84530,15 +84568,15 @@ async function promoteVariantFiles(opts) {
|
|
|
84530
84568
|
await writeFile25(
|
|
84531
84569
|
to,
|
|
84532
84570
|
repointMoved(text3, {
|
|
84533
|
-
fromDir:
|
|
84534
|
-
toDir:
|
|
84571
|
+
fromDir: path51.dirname(from),
|
|
84572
|
+
toDir: path51.dirname(to),
|
|
84535
84573
|
movedFrom: variantDir,
|
|
84536
84574
|
movedTo: pageDir
|
|
84537
84575
|
}),
|
|
84538
84576
|
"utf8"
|
|
84539
84577
|
);
|
|
84540
84578
|
}
|
|
84541
|
-
written.push(posix2(
|
|
84579
|
+
written.push(posix2(path51.relative(root, to)));
|
|
84542
84580
|
}
|
|
84543
84581
|
return written;
|
|
84544
84582
|
}
|
|
@@ -84562,8 +84600,8 @@ function archiveRecord(target2, variantNumber) {
|
|
|
84562
84600
|
`;
|
|
84563
84601
|
}
|
|
84564
84602
|
async function foldExperiment(root, target2) {
|
|
84565
|
-
const pageDir =
|
|
84566
|
-
const variantDir =
|
|
84603
|
+
const pageDir = path51.resolve(root, "src/pages", target2.landingSlug);
|
|
84604
|
+
const variantDir = path51.resolve(root, "src/pages", target2.variantSlug);
|
|
84567
84605
|
const variantNumber = variantNumberOf(target2.variantSlug);
|
|
84568
84606
|
if (variantNumber === null) {
|
|
84569
84607
|
return {
|
|
@@ -84577,7 +84615,7 @@ async function foldExperiment(root, target2) {
|
|
|
84577
84615
|
return { error: `src/pages/${target2.variantSlug}/ is already gone \u2014 this test looks folded in already` };
|
|
84578
84616
|
}
|
|
84579
84617
|
const archiveKey = target2.landingInternalId ?? target2.landingSlug;
|
|
84580
|
-
const archiveDir =
|
|
84618
|
+
const archiveDir = path51.resolve(root, ARCHIVE_ROOT, archiveKey, String(variantNumber));
|
|
84581
84619
|
await rm8(archiveDir, { recursive: true, force: true });
|
|
84582
84620
|
await mkdir15(archiveDir, { recursive: true });
|
|
84583
84621
|
const written = await archiveArm({
|
|
@@ -84587,8 +84625,8 @@ async function foldExperiment(root, target2) {
|
|
|
84587
84625
|
archiveDir,
|
|
84588
84626
|
armSlug: target2.survivor === "variant" ? target2.landingSlug : target2.variantSlug
|
|
84589
84627
|
});
|
|
84590
|
-
await writeFile25(
|
|
84591
|
-
written.push(posix2(
|
|
84628
|
+
await writeFile25(path51.join(archiveDir, "_variant.json"), archiveRecord(target2, variantNumber), "utf8");
|
|
84629
|
+
written.push(posix2(path51.join(ARCHIVE_ROOT, archiveKey, String(variantNumber), "_variant.json")));
|
|
84592
84630
|
if (target2.survivor === "variant") {
|
|
84593
84631
|
written.push(...await promoteVariantFiles({ root, pageDir, variantDir }));
|
|
84594
84632
|
}
|
|
@@ -84596,7 +84634,7 @@ async function foldExperiment(root, target2) {
|
|
|
84596
84634
|
return {
|
|
84597
84635
|
experimentId: target2.experimentId,
|
|
84598
84636
|
page: target2.landingSlug,
|
|
84599
|
-
archivedTo: posix2(
|
|
84637
|
+
archivedTo: posix2(path51.join(ARCHIVE_ROOT, archiveKey, String(variantNumber))),
|
|
84600
84638
|
written,
|
|
84601
84639
|
removed: [`src/pages/${target2.variantSlug}`]
|
|
84602
84640
|
};
|
|
@@ -85369,10 +85407,10 @@ function parseEvidence(raw, rawArgs) {
|
|
|
85369
85407
|
|
|
85370
85408
|
// src/commands/experiment/identity.ts
|
|
85371
85409
|
import { readFile as readFile44 } from "fs/promises";
|
|
85372
|
-
import
|
|
85410
|
+
import path52 from "path";
|
|
85373
85411
|
async function readPageInternalId(root, slug) {
|
|
85374
85412
|
try {
|
|
85375
|
-
const text3 = await readFile44(
|
|
85413
|
+
const text3 = await readFile44(path52.resolve(root, "src", "pages", slug, "_definition.md"), "utf8");
|
|
85376
85414
|
return /^internalId:\s*"?([^"\s]+)"?\s*$/m.exec(text3)?.[1];
|
|
85377
85415
|
} catch {
|
|
85378
85416
|
return void 0;
|
|
@@ -85381,7 +85419,7 @@ async function readPageInternalId(root, slug) {
|
|
|
85381
85419
|
|
|
85382
85420
|
// src/commands/experiment/measurement.ts
|
|
85383
85421
|
import { readFile as readFile45 } from "fs/promises";
|
|
85384
|
-
import
|
|
85422
|
+
import path53 from "path";
|
|
85385
85423
|
function eventDeclarationsIn(source) {
|
|
85386
85424
|
const found = [];
|
|
85387
85425
|
const pattern = /\b(data-baker-(?:view|event))\s*=\s*["']([^"']+)["']/g;
|
|
@@ -85441,7 +85479,7 @@ function sectionsOf(files, slug) {
|
|
|
85441
85479
|
return files.filter((file) => file.startsWith(prefix) && !file.slice(prefix.length).startsWith("index."));
|
|
85442
85480
|
}
|
|
85443
85481
|
async function declarationsOf(root, files) {
|
|
85444
|
-
const sources = await Promise.all(files.map((file) => readFile45(
|
|
85482
|
+
const sources = await Promise.all(files.map((file) => readFile45(path53.join(root, file), "utf8").catch(() => "")));
|
|
85445
85483
|
return sources.flatMap(eventDeclarationsIn);
|
|
85446
85484
|
}
|
|
85447
85485
|
|
|
@@ -86863,10 +86901,10 @@ function parseValueExpression(raw) {
|
|
|
86863
86901
|
return parts.map(parsePart);
|
|
86864
86902
|
}
|
|
86865
86903
|
function trackingFieldIds() {
|
|
86866
|
-
const
|
|
86867
|
-
if (!existsSync9(
|
|
86904
|
+
const path69 = join4(flowsDir(), "..", "tracking.ts");
|
|
86905
|
+
if (!existsSync9(path69)) return null;
|
|
86868
86906
|
try {
|
|
86869
|
-
const source = readFileSync19(
|
|
86907
|
+
const source = readFileSync19(path69, "utf-8");
|
|
86870
86908
|
const block2 = source.match(/TRACKING_FIELD_IDS\s*=\s*\[([\s\S]*?)\]\s*as const/)?.[1];
|
|
86871
86909
|
if (!block2) return null;
|
|
86872
86910
|
const ids2 = [...block2.matchAll(/"(tracking\.[a-z0-9_]+)"/g)].map((match) => match[1]);
|
|
@@ -87448,13 +87486,13 @@ function specsFromFile(parsed) {
|
|
|
87448
87486
|
return `${destField}${type}=${entry?.value ?? ""}`;
|
|
87449
87487
|
});
|
|
87450
87488
|
}
|
|
87451
|
-
function readSpecFile(
|
|
87489
|
+
function readSpecFile(path69) {
|
|
87452
87490
|
let raw;
|
|
87453
87491
|
try {
|
|
87454
|
-
raw =
|
|
87492
|
+
raw = path69 === "-" ? readFileSync20(0, "utf-8") : readFileSync20(path69, "utf-8");
|
|
87455
87493
|
} catch (error) {
|
|
87456
87494
|
refuse3(
|
|
87457
|
-
`Could not read ${
|
|
87495
|
+
`Could not read ${path69 === "-" ? "the mapping from stdin" : `"${path69}"`}: ${error instanceof Error ? error.message : String(error)}`
|
|
87458
87496
|
);
|
|
87459
87497
|
}
|
|
87460
87498
|
let parsed;
|
|
@@ -87462,7 +87500,7 @@ function readSpecFile(path68) {
|
|
|
87462
87500
|
parsed = JSON.parse(raw);
|
|
87463
87501
|
} catch (error) {
|
|
87464
87502
|
refuse3(
|
|
87465
|
-
`${
|
|
87503
|
+
`${path69 === "-" ? "stdin" : `"${path69}"`} is not valid JSON: ${error instanceof Error ? error.message : String(error)}`,
|
|
87466
87504
|
'Expected { "map": { "<destField>": "<value>", \u2026 } }'
|
|
87467
87505
|
);
|
|
87468
87506
|
}
|
|
@@ -87761,21 +87799,21 @@ var ARRAY_FIELDS = [
|
|
|
87761
87799
|
"tagIds"
|
|
87762
87800
|
];
|
|
87763
87801
|
var ARRAY_OWNERS = ["", "body"];
|
|
87764
|
-
function dropUnsetOptionals(sideEffect,
|
|
87802
|
+
function dropUnsetOptionals(sideEffect, path69) {
|
|
87765
87803
|
return OPTIONAL_STRINGS.flatMap((key) => {
|
|
87766
87804
|
if (!(key in sideEffect) || sideEffect[key] !== null && sideEffect[key] !== "") return [];
|
|
87767
87805
|
delete sideEffect[key];
|
|
87768
|
-
return [{ path:
|
|
87806
|
+
return [{ path: path69, change: `dropped \`${key}\` (an optional string is absent, never null)` }];
|
|
87769
87807
|
});
|
|
87770
87808
|
}
|
|
87771
|
-
function fillNulledArrays(target2, prefix,
|
|
87809
|
+
function fillNulledArrays(target2, prefix, path69) {
|
|
87772
87810
|
return ARRAY_FIELDS.flatMap((key) => {
|
|
87773
87811
|
if (!(key in target2) || target2[key] !== null) return [];
|
|
87774
87812
|
target2[key] = [];
|
|
87775
|
-
return [{ path:
|
|
87813
|
+
return [{ path: path69, change: `\`${prefix}${key}: null\` \u2192 \`[]\`` }];
|
|
87776
87814
|
});
|
|
87777
87815
|
}
|
|
87778
|
-
function tidyEmailRecipients(sideEffect,
|
|
87816
|
+
function tidyEmailRecipients(sideEffect, path69) {
|
|
87779
87817
|
if (sideEffect.type !== "email") return [];
|
|
87780
87818
|
const config = sideEffect.encryptedConfig;
|
|
87781
87819
|
if (!config || typeof config !== "object" || Array.isArray(config)) return [];
|
|
@@ -87786,7 +87824,7 @@ function tidyEmailRecipients(sideEffect, path68) {
|
|
|
87786
87824
|
const tidied = to.join(", ");
|
|
87787
87825
|
if (tidied === raw) return [];
|
|
87788
87826
|
config.email = tidied;
|
|
87789
|
-
return [{ path:
|
|
87827
|
+
return [{ path: path69, change: "tidied the recipient list's spacing and separators" }];
|
|
87790
87828
|
}
|
|
87791
87829
|
function sideEffectsOf(node) {
|
|
87792
87830
|
if (!Array.isArray(node.sideEffects)) return [];
|
|
@@ -87795,13 +87833,13 @@ function sideEffectsOf(node) {
|
|
|
87795
87833
|
);
|
|
87796
87834
|
}
|
|
87797
87835
|
function normalizeSideEffect(sideEffect, where) {
|
|
87798
|
-
const
|
|
87836
|
+
const path69 = `${where} \u2192 ${String(sideEffect.id ?? "side effect")}`;
|
|
87799
87837
|
const arrays = ARRAY_OWNERS.flatMap((owner) => {
|
|
87800
87838
|
const target2 = owner ? sideEffect[owner] : sideEffect;
|
|
87801
87839
|
if (!target2 || typeof target2 !== "object") return [];
|
|
87802
|
-
return fillNulledArrays(target2, owner ? `${owner}.` : "",
|
|
87840
|
+
return fillNulledArrays(target2, owner ? `${owner}.` : "", path69);
|
|
87803
87841
|
});
|
|
87804
|
-
return [...dropUnsetOptionals(sideEffect,
|
|
87842
|
+
return [...dropUnsetOptionals(sideEffect, path69), ...arrays, ...tidyEmailRecipients(sideEffect, path69)];
|
|
87805
87843
|
}
|
|
87806
87844
|
function normalizeFlowTree(tree) {
|
|
87807
87845
|
const changes = [];
|
|
@@ -89307,10 +89345,10 @@ async function stageOps(ops) {
|
|
|
89307
89345
|
handleError5(err);
|
|
89308
89346
|
}
|
|
89309
89347
|
}
|
|
89310
|
-
async function draftAction2(
|
|
89348
|
+
async function draftAction2(path69, body, chat) {
|
|
89311
89349
|
const chatId = resolveChatId(chat);
|
|
89312
89350
|
try {
|
|
89313
|
-
const { data, hints: hints2 } = splitHints(await apiPost(
|
|
89351
|
+
const { data, hints: hints2 } = splitHints(await apiPost(path69, { chatId, ...body }));
|
|
89314
89352
|
writeJsonEnvelope({ ok: true, data, ...hints2.length > 0 ? { hints: hints2 } : {} });
|
|
89315
89353
|
return data;
|
|
89316
89354
|
} catch (err) {
|
|
@@ -91856,9 +91894,9 @@ async function readImageBuffer(pathOrUrl) {
|
|
|
91856
91894
|
}
|
|
91857
91895
|
return readFile46(pathOrUrl);
|
|
91858
91896
|
}
|
|
91859
|
-
async function isDirectory(
|
|
91897
|
+
async function isDirectory(path69) {
|
|
91860
91898
|
try {
|
|
91861
|
-
const s = await stat10(
|
|
91899
|
+
const s = await stat10(path69);
|
|
91862
91900
|
return s.isDirectory();
|
|
91863
91901
|
} catch {
|
|
91864
91902
|
return false;
|
|
@@ -92286,13 +92324,13 @@ function resolveDownloadPath({ baseName, extension, out, outIsDirectory: outIsDi
|
|
|
92286
92324
|
}
|
|
92287
92325
|
function disambiguate(paths) {
|
|
92288
92326
|
const taken = /* @__PURE__ */ new Set();
|
|
92289
|
-
return paths.map((
|
|
92290
|
-
if (!taken.has(
|
|
92291
|
-
taken.add(
|
|
92292
|
-
return
|
|
92327
|
+
return paths.map((path69) => {
|
|
92328
|
+
if (!taken.has(path69)) {
|
|
92329
|
+
taken.add(path69);
|
|
92330
|
+
return path69;
|
|
92293
92331
|
}
|
|
92294
|
-
const ext = extname4(
|
|
92295
|
-
const stem =
|
|
92332
|
+
const ext = extname4(path69);
|
|
92333
|
+
const stem = path69.slice(0, path69.length - ext.length);
|
|
92296
92334
|
let n = 2;
|
|
92297
92335
|
while (taken.has(`${stem}-${n}${ext}`)) n += 1;
|
|
92298
92336
|
const unique2 = `${stem}-${n}${ext}`;
|
|
@@ -92418,10 +92456,10 @@ async function runDownloads(plan) {
|
|
|
92418
92456
|
const paths = disambiguate(fetched.map((item) => item.path));
|
|
92419
92457
|
const downloaded = [];
|
|
92420
92458
|
for (const [index, item] of fetched.entries()) {
|
|
92421
|
-
const
|
|
92459
|
+
const path69 = paths[index] ?? item.path;
|
|
92422
92460
|
try {
|
|
92423
|
-
await atomicWrite(
|
|
92424
|
-
downloaded.push({ input: item.input, output:
|
|
92461
|
+
await atomicWrite(path69, item.buffer);
|
|
92462
|
+
downloaded.push({ input: item.input, output: path69, bytes: item.buffer.length, contentType: item.contentType });
|
|
92425
92463
|
} catch (err) {
|
|
92426
92464
|
failed.push({ input: item.input, error: failureMessage(err, "Write failed") });
|
|
92427
92465
|
}
|
|
@@ -95317,7 +95355,7 @@ import { defineCommand as defineCommand226 } from "citty";
|
|
|
95317
95355
|
|
|
95318
95356
|
// src/commands/landing/critique.ts
|
|
95319
95357
|
import { readdir as readdir22, readFile as readFile48, stat as stat12 } from "fs/promises";
|
|
95320
|
-
import
|
|
95358
|
+
import path56 from "path";
|
|
95321
95359
|
import { defineCommand as defineCommand213 } from "citty";
|
|
95322
95360
|
|
|
95323
95361
|
// src/engine/landing/lib/constants.ts
|
|
@@ -96509,13 +96547,13 @@ function describeCounts(findings) {
|
|
|
96509
96547
|
|
|
96510
96548
|
// src/commands/landing/snapshot.ts
|
|
96511
96549
|
import { mkdir as mkdir16, rename as rename3, writeFile as writeFile27 } from "fs/promises";
|
|
96512
|
-
import
|
|
96550
|
+
import path54 from "path";
|
|
96513
96551
|
var CRITIC_VERSION = "4";
|
|
96514
96552
|
function critiqueCacheDir(projectRoot) {
|
|
96515
|
-
return
|
|
96553
|
+
return path54.join(projectRoot, ".cache", "landing-critique");
|
|
96516
96554
|
}
|
|
96517
96555
|
function snapshotPath(projectRoot, slug) {
|
|
96518
|
-
return
|
|
96556
|
+
return path54.join(critiqueCacheDir(projectRoot), `${slug}.json`);
|
|
96519
96557
|
}
|
|
96520
96558
|
async function writeCritiqueSnapshot(projectRoot, snapshot) {
|
|
96521
96559
|
await mkdir16(critiqueCacheDir(projectRoot), { recursive: true });
|
|
@@ -96528,7 +96566,7 @@ async function writeCritiqueSnapshot(projectRoot, snapshot) {
|
|
|
96528
96566
|
|
|
96529
96567
|
// src/commands/landing/source-version.ts
|
|
96530
96568
|
import { readdir as readdir21, readFile as readFile47, stat as stat11 } from "fs/promises";
|
|
96531
|
-
import
|
|
96569
|
+
import path55 from "path";
|
|
96532
96570
|
var CRITIQUED_ROOTS = ["src/pages/", "src/components/"];
|
|
96533
96571
|
async function landingSourceRelPaths(root, slug) {
|
|
96534
96572
|
const files = await landingGraphFiles(root, slug);
|
|
@@ -96537,7 +96575,7 @@ async function landingSourceRelPaths(root, slug) {
|
|
|
96537
96575
|
async function readLandingSources(root, slug) {
|
|
96538
96576
|
const rel = await landingSourceRelPaths(root, slug);
|
|
96539
96577
|
const out = [];
|
|
96540
|
-
for (const r of rel) out.push({ path: r, text: await readFile47(
|
|
96578
|
+
for (const r of rel) out.push({ path: r, text: await readFile47(path55.join(root, r), "utf8") });
|
|
96541
96579
|
return out;
|
|
96542
96580
|
}
|
|
96543
96581
|
async function computeLandingSourceSha(root, slug) {
|
|
@@ -96546,7 +96584,7 @@ async function computeLandingSourceSha(root, slug) {
|
|
|
96546
96584
|
for (const r of rel) {
|
|
96547
96585
|
let bytes;
|
|
96548
96586
|
try {
|
|
96549
|
-
bytes = await readFile47(
|
|
96587
|
+
bytes = await readFile47(path55.join(root, r));
|
|
96550
96588
|
} catch {
|
|
96551
96589
|
bytes = Buffer.alloc(0);
|
|
96552
96590
|
}
|
|
@@ -96556,16 +96594,16 @@ async function computeLandingSourceSha(root, slug) {
|
|
|
96556
96594
|
}
|
|
96557
96595
|
async function computeLegacyLandingSourceSha(landingDir) {
|
|
96558
96596
|
const rel = [];
|
|
96559
|
-
if (await isFile2(
|
|
96560
|
-
for (const abs of await walkAstro(
|
|
96561
|
-
rel.push(
|
|
96597
|
+
if (await isFile2(path55.join(landingDir, "index.astro"))) rel.push("index.astro");
|
|
96598
|
+
for (const abs of await walkAstro(path55.join(landingDir, "_components"))) {
|
|
96599
|
+
rel.push(path55.relative(landingDir, abs).split(path55.sep).join("/"));
|
|
96562
96600
|
}
|
|
96563
96601
|
rel.sort((a, b) => a < b ? -1 : a > b ? 1 : 0);
|
|
96564
96602
|
const parts = [];
|
|
96565
96603
|
for (const r of rel) {
|
|
96566
96604
|
let bytes;
|
|
96567
96605
|
try {
|
|
96568
|
-
bytes = await readFile47(
|
|
96606
|
+
bytes = await readFile47(path55.join(landingDir, r));
|
|
96569
96607
|
} catch {
|
|
96570
96608
|
bytes = Buffer.alloc(0);
|
|
96571
96609
|
}
|
|
@@ -96589,7 +96627,7 @@ async function walkAstro(dir) {
|
|
|
96589
96627
|
}
|
|
96590
96628
|
const out = [];
|
|
96591
96629
|
for (const entry of entries) {
|
|
96592
|
-
const abs =
|
|
96630
|
+
const abs = path55.join(dir, entry.name);
|
|
96593
96631
|
if (entry.isDirectory()) out.push(...await walkAstro(abs));
|
|
96594
96632
|
else if (entry.isFile() && entry.name.endsWith(".astro")) out.push(abs);
|
|
96595
96633
|
}
|
|
@@ -96650,7 +96688,7 @@ var critiqueCommand2 = defineCommand213({
|
|
|
96650
96688
|
{ availableSlugs: await listLandingSlugs(projectRoot) }
|
|
96651
96689
|
);
|
|
96652
96690
|
}
|
|
96653
|
-
if (!await isDir2(
|
|
96691
|
+
if (!await isDir2(path56.resolve(projectRoot, "src", "pages", slug))) {
|
|
96654
96692
|
fail10("NOT_FOUND", `No landing at src/pages/${slug}/`, {
|
|
96655
96693
|
availableSlugs: await listLandingSlugs(projectRoot)
|
|
96656
96694
|
});
|
|
@@ -96693,7 +96731,7 @@ async function critiqueOne(projectRoot, slug, brand, competitors) {
|
|
|
96693
96731
|
const [sources, compositionSha, sourceSha] = await Promise.all([
|
|
96694
96732
|
readLandingSources(projectRoot, slug),
|
|
96695
96733
|
computeLandingSourceSha(projectRoot, slug),
|
|
96696
|
-
computeLegacyLandingSourceSha(
|
|
96734
|
+
computeLegacyLandingSourceSha(path56.resolve(projectRoot, "src", "pages", slug))
|
|
96697
96735
|
]);
|
|
96698
96736
|
const report = critiqueLanding({ slug, sources, brand, competitors });
|
|
96699
96737
|
let snapshotFailed = false;
|
|
@@ -96713,7 +96751,7 @@ async function critiqueOne(projectRoot, slug, brand, competitors) {
|
|
|
96713
96751
|
return { slug, report, snapshotFailed };
|
|
96714
96752
|
}
|
|
96715
96753
|
async function readCompetitorNames(projectRoot) {
|
|
96716
|
-
const dir =
|
|
96754
|
+
const dir = path56.join(projectRoot, "src", "content", "competitors");
|
|
96717
96755
|
let entries;
|
|
96718
96756
|
try {
|
|
96719
96757
|
entries = (await readdir22(dir)).filter((f) => f.endsWith(".md"));
|
|
@@ -96722,9 +96760,9 @@ async function readCompetitorNames(projectRoot) {
|
|
|
96722
96760
|
}
|
|
96723
96761
|
const names = [];
|
|
96724
96762
|
for (const entry of entries) {
|
|
96725
|
-
names.push(
|
|
96763
|
+
names.push(path56.basename(entry, ".md").replace(/[-_]+/g, " "));
|
|
96726
96764
|
try {
|
|
96727
|
-
const head = (await readFile48(
|
|
96765
|
+
const head = (await readFile48(path56.join(dir, entry), "utf8")).slice(0, 2e3);
|
|
96728
96766
|
const titled = /^\s*(?:title|name)\s*:\s*["']?([^"'\n]+)["']?\s*$/im.exec(head);
|
|
96729
96767
|
if (titled?.[1]) names.push(titled[1].trim());
|
|
96730
96768
|
} catch {
|
|
@@ -96734,7 +96772,7 @@ async function readCompetitorNames(projectRoot) {
|
|
|
96734
96772
|
}
|
|
96735
96773
|
async function listLandingSlugs(projectRoot) {
|
|
96736
96774
|
try {
|
|
96737
|
-
const entries = await readdir22(
|
|
96775
|
+
const entries = await readdir22(path56.join(projectRoot, "src", "pages"), { withFileTypes: true });
|
|
96738
96776
|
return entries.filter((e) => e.isDirectory() && !e.name.startsWith("_") && !e.name.startsWith(".")).map((e) => e.name).sort();
|
|
96739
96777
|
} catch {
|
|
96740
96778
|
return [];
|
|
@@ -96858,7 +96896,7 @@ function exportStatusHints(view) {
|
|
|
96858
96896
|
}
|
|
96859
96897
|
return ["Still being prepared. Carry on with other work and check again in a minute \u2014 never sleep-loop on it."];
|
|
96860
96898
|
}
|
|
96861
|
-
function parseProfileFlag(raw, readFile52 = (
|
|
96899
|
+
function parseProfileFlag(raw, readFile52 = (path69) => readFileSync25(path69, "utf8")) {
|
|
96862
96900
|
let parsed;
|
|
96863
96901
|
try {
|
|
96864
96902
|
parsed = JSON.parse(raw.startsWith("@") ? readFile52(raw.slice(1)) : raw);
|
|
@@ -97033,7 +97071,7 @@ var addCommand = defineCommand215({
|
|
|
97033
97071
|
|
|
97034
97072
|
// src/commands/landing/inspiration/code.ts
|
|
97035
97073
|
import { mkdir as mkdir17, writeFile as writeFile28 } from "fs/promises";
|
|
97036
|
-
import
|
|
97074
|
+
import path57 from "path";
|
|
97037
97075
|
import { defineCommand as defineCommand216 } from "citty";
|
|
97038
97076
|
registerSchema({
|
|
97039
97077
|
command: "landing.inspiration.code",
|
|
@@ -97056,9 +97094,9 @@ var codeCommand = defineCommand216({
|
|
|
97056
97094
|
try {
|
|
97057
97095
|
const id = args8.id;
|
|
97058
97096
|
const data = await apiGet("/api/landing-inspiration/section-code", { id });
|
|
97059
|
-
const dir =
|
|
97097
|
+
const dir = path57.join(process.cwd(), ".baker", "inspiration", id);
|
|
97060
97098
|
await mkdir17(dir, { recursive: true });
|
|
97061
|
-
const file =
|
|
97099
|
+
const file = path57.join(dir, "section.html");
|
|
97062
97100
|
await writeFile28(file, data.html);
|
|
97063
97101
|
const hints2 = [INSPIRATION_HINTS.structureNotCopy, INSPIRATION_HINTS.adapt];
|
|
97064
97102
|
const fidelity = fidelityHint(data.fidelity);
|
|
@@ -97068,7 +97106,7 @@ var codeCommand = defineCommand216({
|
|
|
97068
97106
|
ok: true,
|
|
97069
97107
|
data: {
|
|
97070
97108
|
id,
|
|
97071
|
-
file:
|
|
97109
|
+
file: path57.relative(process.cwd(), file),
|
|
97072
97110
|
bytes: data.html.length,
|
|
97073
97111
|
fidelity: data.fidelity,
|
|
97074
97112
|
reproduction_notes: data.reproductionNotes,
|
|
@@ -97528,7 +97566,7 @@ function classifyCaptureFailure(error) {
|
|
|
97528
97566
|
|
|
97529
97567
|
// src/engine/landing-library/run.ts
|
|
97530
97568
|
import { mkdir as mkdir18, writeFile as writeFile30 } from "fs/promises";
|
|
97531
|
-
import
|
|
97569
|
+
import path59 from "path";
|
|
97532
97570
|
|
|
97533
97571
|
// ../proxy/src/preflight.ts
|
|
97534
97572
|
import http from "http";
|
|
@@ -98946,9 +98984,9 @@ async function renderBundleToPng(browser, html, viewportWidth, options = {}) {
|
|
|
98946
98984
|
|
|
98947
98985
|
// src/engine/landing-library/report.ts
|
|
98948
98986
|
import { writeFile as writeFile29 } from "fs/promises";
|
|
98949
|
-
import
|
|
98987
|
+
import path58 from "path";
|
|
98950
98988
|
async function writeCaptureReport(manifest, outDir) {
|
|
98951
|
-
const file =
|
|
98989
|
+
const file = path58.join(outDir, "report.html");
|
|
98952
98990
|
await writeFile29(file, renderReport(manifest));
|
|
98953
98991
|
return file;
|
|
98954
98992
|
}
|
|
@@ -99092,32 +99130,32 @@ async function reproducePage(args8) {
|
|
|
99092
99130
|
const { browser, page, outDir, pageUrl, livePageShot } = args8;
|
|
99093
99131
|
const built = await buildSectionBundle(page, "body", pageUrl).catch(() => null);
|
|
99094
99132
|
if (!built) return { bundle: null, fidelity: null };
|
|
99095
|
-
await writeFile30(
|
|
99133
|
+
await writeFile30(path59.join(outDir, "page.html"), built.html);
|
|
99096
99134
|
const rendered = await renderBundleToPng(browser, built.html, DESKTOP_VIEWPORT.width, {
|
|
99097
99135
|
wholePage: true,
|
|
99098
99136
|
timeoutMs: 6e4
|
|
99099
99137
|
});
|
|
99100
99138
|
if (!rendered || !livePageShot) return { bundle: "page.html", fidelity: null };
|
|
99101
|
-
await writeFile30(
|
|
99139
|
+
await writeFile30(path59.join(outDir, "page-rendered.png"), rendered);
|
|
99102
99140
|
const { score, note } = await scoreFidelity(livePageShot, rendered);
|
|
99103
99141
|
return { bundle: "page.html", fidelity: score, ...note ? { fidelityNote: note } : {} };
|
|
99104
99142
|
}
|
|
99105
99143
|
async function captureOneSection(args8) {
|
|
99106
99144
|
const { browser, page, candidate, sectionsDir, outDir, pageUrl, withCode } = args8;
|
|
99107
|
-
const dir =
|
|
99145
|
+
const dir = path59.join(sectionsDir, String(candidate.index).padStart(2, "0"));
|
|
99108
99146
|
await mkdir18(dir, { recursive: true });
|
|
99109
99147
|
const desktop = await captureSection(page, candidate);
|
|
99110
|
-
if (desktop) await writeFile30(
|
|
99148
|
+
if (desktop) await writeFile30(path59.join(dir, "desktop.png"), desktop);
|
|
99111
99149
|
const visualHash = desktop ? await perceptualHash(desktop) : null;
|
|
99112
99150
|
const motion = await collectMotion(page, candidate.selector);
|
|
99113
99151
|
const built = withCode ? await buildSectionBundle(page, candidate.selector, pageUrl) : null;
|
|
99114
99152
|
let fidelity = null;
|
|
99115
99153
|
let fidelityNote;
|
|
99116
99154
|
if (built) {
|
|
99117
|
-
await writeFile30(
|
|
99155
|
+
await writeFile30(path59.join(dir, "section.html"), built.html);
|
|
99118
99156
|
const rendered = await renderBundleToPng(browser, built.html, DESKTOP_VIEWPORT.width);
|
|
99119
99157
|
if (rendered && desktop) {
|
|
99120
|
-
await writeFile30(
|
|
99158
|
+
await writeFile30(path59.join(dir, "section-rendered.png"), rendered);
|
|
99121
99159
|
const result = await scoreFidelity(desktop, rendered);
|
|
99122
99160
|
fidelity = result.score;
|
|
99123
99161
|
fidelityNote = result.note;
|
|
@@ -99125,9 +99163,9 @@ async function captureOneSection(args8) {
|
|
|
99125
99163
|
}
|
|
99126
99164
|
return {
|
|
99127
99165
|
...candidate,
|
|
99128
|
-
desktopShot: desktop ?
|
|
99166
|
+
desktopShot: desktop ? path59.relative(outDir, path59.join(dir, "desktop.png")) : null,
|
|
99129
99167
|
mobileShot: null,
|
|
99130
|
-
bundle: built ?
|
|
99168
|
+
bundle: built ? path59.relative(outDir, path59.join(dir, "section.html")) : null,
|
|
99131
99169
|
fidelity,
|
|
99132
99170
|
...fidelityNote ? { fidelityNote } : {},
|
|
99133
99171
|
...built ? { cssStats: built.stats } : {},
|
|
@@ -99146,9 +99184,9 @@ async function captureMobileShots(args8) {
|
|
|
99146
99184
|
for (const section2 of sections) {
|
|
99147
99185
|
const shot = await captureSectionOnMobile(mobile.page, section2);
|
|
99148
99186
|
if (!shot) continue;
|
|
99149
|
-
const file =
|
|
99187
|
+
const file = path59.join(sectionsDir, String(section2.index).padStart(2, "0"), "mobile.png");
|
|
99150
99188
|
await writeFile30(file, shot);
|
|
99151
|
-
section2.mobileShot =
|
|
99189
|
+
section2.mobileShot = path59.relative(outDir, file);
|
|
99152
99190
|
}
|
|
99153
99191
|
} finally {
|
|
99154
99192
|
await mobile.context.close();
|
|
@@ -99163,10 +99201,10 @@ async function captureMotionTakes(args8) {
|
|
|
99163
99201
|
const filmOne = async (section2) => {
|
|
99164
99202
|
const take = await captureMotionTake(browser, pageUrl, section2.selector).catch(() => null);
|
|
99165
99203
|
if (!take) return;
|
|
99166
|
-
const dir =
|
|
99167
|
-
const file =
|
|
99204
|
+
const dir = path59.join(sectionsDir, String(section2.index).padStart(2, "0"));
|
|
99205
|
+
const file = path59.join(dir, "motion-filmstrip.png");
|
|
99168
99206
|
await writeFile30(file, take.filmstrip);
|
|
99169
|
-
section2.motionFilmstrip =
|
|
99207
|
+
section2.motionFilmstrip = path59.relative(outDir, file);
|
|
99170
99208
|
log(` [${section2.index}] ${section2.motion.summary}`);
|
|
99171
99209
|
};
|
|
99172
99210
|
const queue = [...moving];
|
|
@@ -99223,7 +99261,7 @@ async function captureAlternateViews(args8) {
|
|
|
99223
99261
|
async function reproduceWholePage(args8) {
|
|
99224
99262
|
const { browser, page, outDir, pageUrl, withCode, log } = args8;
|
|
99225
99263
|
const fullPage = await page.screenshot({ type: "png", fullPage: true }).catch(() => null);
|
|
99226
|
-
if (fullPage) await writeFile30(
|
|
99264
|
+
if (fullPage) await writeFile30(path59.join(outDir, "full-page.png"), fullPage);
|
|
99227
99265
|
if (!withCode) return { bundle: null, fidelity: null };
|
|
99228
99266
|
const reproduction = await reproducePage({ browser, page, outDir, pageUrl, livePageShot: fullPage });
|
|
99229
99267
|
log(`page reproduction: ${reproduction.fidelity === null ? "unavailable" : reproduction.fidelity.toFixed(2)}`);
|
|
@@ -99294,7 +99332,7 @@ async function openViaLadder(args8) {
|
|
|
99294
99332
|
async function scrapeLanding(options) {
|
|
99295
99333
|
const timeoutMs = options.timeoutMs ?? 45e3;
|
|
99296
99334
|
const log = options.onProgress ?? (() => void 0);
|
|
99297
|
-
const sectionsDir =
|
|
99335
|
+
const sectionsDir = path59.join(options.outDir, "sections");
|
|
99298
99336
|
const nonPublic = refuseNonPublicUrl(options.url);
|
|
99299
99337
|
if (nonPublic) {
|
|
99300
99338
|
throw new BlockedPageError({
|
|
@@ -99356,7 +99394,7 @@ async function scrapeLanding(options) {
|
|
|
99356
99394
|
security: prepared.security,
|
|
99357
99395
|
captureTier: tier
|
|
99358
99396
|
};
|
|
99359
|
-
await writeFile30(
|
|
99397
|
+
await writeFile30(path59.join(options.outDir, "manifest.json"), `${JSON.stringify(manifest, null, 2)}
|
|
99360
99398
|
`);
|
|
99361
99399
|
if (options.report !== false) {
|
|
99362
99400
|
const reportPath = await writeCaptureReport(manifest, options.outDir);
|
|
@@ -99371,28 +99409,28 @@ async function scrapeLanding(options) {
|
|
|
99371
99409
|
|
|
99372
99410
|
// src/commands/landing/inspiration/captureOut.ts
|
|
99373
99411
|
import { existsSync as existsSync12 } from "fs";
|
|
99374
|
-
import
|
|
99412
|
+
import path60 from "path";
|
|
99375
99413
|
var SCRATCH_DIR = ".baker";
|
|
99376
99414
|
function isWithin(parent, target2) {
|
|
99377
|
-
const relative =
|
|
99378
|
-
return relative === "" || !relative.startsWith("..") && !
|
|
99415
|
+
const relative = path60.relative(parent, target2);
|
|
99416
|
+
return relative === "" || !relative.startsWith("..") && !path60.isAbsolute(relative);
|
|
99379
99417
|
}
|
|
99380
99418
|
function findRepoRoot(from) {
|
|
99381
|
-
let dir =
|
|
99419
|
+
let dir = path60.resolve(from);
|
|
99382
99420
|
for (; ; ) {
|
|
99383
|
-
if (existsSync12(
|
|
99384
|
-
const parent =
|
|
99421
|
+
if (existsSync12(path60.join(dir, ".git"))) return dir;
|
|
99422
|
+
const parent = path60.dirname(dir);
|
|
99385
99423
|
if (parent === dir) return null;
|
|
99386
99424
|
dir = parent;
|
|
99387
99425
|
}
|
|
99388
99426
|
}
|
|
99389
99427
|
function checkCaptureOut(out, options) {
|
|
99390
99428
|
const { cwd, repoRoot } = options;
|
|
99391
|
-
const resolved =
|
|
99429
|
+
const resolved = path60.resolve(cwd, out);
|
|
99392
99430
|
if (repoRoot === null || !isWithin(repoRoot, resolved)) return { ok: true };
|
|
99393
|
-
const scratch =
|
|
99431
|
+
const scratch = path60.join(repoRoot, SCRATCH_DIR);
|
|
99394
99432
|
if (isWithin(scratch, resolved)) return { ok: true };
|
|
99395
|
-
const suggestion =
|
|
99433
|
+
const suggestion = path60.posix.join(SCRATCH_DIR, "teardowns", path60.basename(resolved) || "capture");
|
|
99396
99434
|
return {
|
|
99397
99435
|
ok: false,
|
|
99398
99436
|
error: {
|
|
@@ -99566,12 +99604,12 @@ var scrapeCommand = defineCommand220({
|
|
|
99566
99604
|
});
|
|
99567
99605
|
|
|
99568
99606
|
// src/commands/landing/inspiration/search.ts
|
|
99569
|
-
import
|
|
99607
|
+
import path62 from "path";
|
|
99570
99608
|
import { defineCommand as defineCommand221 } from "citty";
|
|
99571
99609
|
|
|
99572
99610
|
// src/commands/landing/inspiration/shot.ts
|
|
99573
99611
|
import { mkdir as mkdir19, writeFile as writeFile31 } from "fs/promises";
|
|
99574
|
-
import
|
|
99612
|
+
import path61 from "path";
|
|
99575
99613
|
import sharp9 from "sharp";
|
|
99576
99614
|
var READABLE_SHOT = {
|
|
99577
99615
|
maxWidth: 1440,
|
|
@@ -99597,9 +99635,9 @@ async function downloadReadableShot(url, file) {
|
|
|
99597
99635
|
const response = await fetch(url);
|
|
99598
99636
|
if (!response.ok) return null;
|
|
99599
99637
|
const shot = await toReadableShot(Buffer.from(await response.arrayBuffer()));
|
|
99600
|
-
await mkdir19(
|
|
99638
|
+
await mkdir19(path61.dirname(file), { recursive: true });
|
|
99601
99639
|
await writeFile31(file, shot);
|
|
99602
|
-
return
|
|
99640
|
+
return path61.relative(process.cwd(), file);
|
|
99603
99641
|
} catch {
|
|
99604
99642
|
return null;
|
|
99605
99643
|
}
|
|
@@ -99691,13 +99729,13 @@ function buildSearchBody2(args8) {
|
|
|
99691
99729
|
return body;
|
|
99692
99730
|
}
|
|
99693
99731
|
async function downloadShots(results) {
|
|
99694
|
-
const dir =
|
|
99732
|
+
const dir = path62.join(process.cwd(), ".baker", "inspiration");
|
|
99695
99733
|
const saved = /* @__PURE__ */ new Map();
|
|
99696
99734
|
await Promise.all(
|
|
99697
99735
|
results.map(async (result) => {
|
|
99698
99736
|
const file = await downloadReadableShot(
|
|
99699
99737
|
result.desktopShotUrl,
|
|
99700
|
-
|
|
99738
|
+
path62.join(dir, `${result.id}.${READABLE_SHOT.extension}`)
|
|
99701
99739
|
);
|
|
99702
99740
|
if (file) saved.set(result.id, file);
|
|
99703
99741
|
})
|
|
@@ -99925,7 +99963,7 @@ var sequencesCommand = defineCommand222({
|
|
|
99925
99963
|
});
|
|
99926
99964
|
|
|
99927
99965
|
// src/commands/landing/inspiration/view.ts
|
|
99928
|
-
import
|
|
99966
|
+
import path63 from "path";
|
|
99929
99967
|
import { defineCommand as defineCommand223 } from "citty";
|
|
99930
99968
|
registerSchema({
|
|
99931
99969
|
command: "landing.inspiration.view",
|
|
@@ -99958,12 +99996,12 @@ var viewCommand2 = defineCommand223({
|
|
|
99958
99996
|
const id = args8.id;
|
|
99959
99997
|
const data = await apiGet("/api/landing-inspiration/section", { id });
|
|
99960
99998
|
const section2 = data.section;
|
|
99961
|
-
const dir =
|
|
99999
|
+
const dir = path63.join(process.cwd(), ".baker", "inspiration", id);
|
|
99962
100000
|
const ext = READABLE_SHOT.extension;
|
|
99963
100001
|
const [desktop, mobile, filmstrip] = await Promise.all([
|
|
99964
|
-
downloadReadableShot(section2.desktopShotUrl,
|
|
99965
|
-
downloadReadableShot(section2.mobileShotUrl,
|
|
99966
|
-
downloadReadableShot(section2.motionFilmstripUrl,
|
|
100002
|
+
downloadReadableShot(section2.desktopShotUrl, path63.join(dir, `desktop.${ext}`)),
|
|
100003
|
+
downloadReadableShot(section2.mobileShotUrl, path63.join(dir, `mobile.${ext}`)),
|
|
100004
|
+
downloadReadableShot(section2.motionFilmstripUrl, path63.join(dir, `motion-filmstrip.${ext}`))
|
|
99967
100005
|
]);
|
|
99968
100006
|
const full = args8.full;
|
|
99969
100007
|
const hints2 = [INSPIRATION_HINTS.structureNotCopy, INSPIRATION_HINTS.adapt];
|
|
@@ -100072,7 +100110,7 @@ Full guide: __tooling__/docs/tools/baker/landing.md`
|
|
|
100072
100110
|
// src/commands/landing/variant.ts
|
|
100073
100111
|
import { randomUUID as randomUUID4 } from "crypto";
|
|
100074
100112
|
import { mkdir as mkdir20, readdir as readdir23, readFile as readFile49, stat as stat13, writeFile as writeFile32 } from "fs/promises";
|
|
100075
|
-
import
|
|
100113
|
+
import path64 from "path";
|
|
100076
100114
|
import { defineCommand as defineCommand225 } from "citty";
|
|
100077
100115
|
registerSchema({
|
|
100078
100116
|
command: "landing.variant",
|
|
@@ -100108,7 +100146,7 @@ async function readInternalId(definitionPath) {
|
|
|
100108
100146
|
async function archivedVariantNumbers(root, internalId) {
|
|
100109
100147
|
if (!internalId) return [];
|
|
100110
100148
|
try {
|
|
100111
|
-
const entries = await readdir23(
|
|
100149
|
+
const entries = await readdir23(path64.resolve(root, "src/_variants", internalId), { withFileTypes: true });
|
|
100112
100150
|
return entries.filter((entry) => entry.isDirectory()).map((entry) => Number(entry.name)).filter((n) => Number.isInteger(n) && n > 0);
|
|
100113
100151
|
} catch {
|
|
100114
100152
|
return [];
|
|
@@ -100138,7 +100176,7 @@ async function exists2(p) {
|
|
|
100138
100176
|
}
|
|
100139
100177
|
async function listLandingSlugs2(root) {
|
|
100140
100178
|
try {
|
|
100141
|
-
const entries = await readdir23(
|
|
100179
|
+
const entries = await readdir23(path64.resolve(root, "src", "pages"), { withFileTypes: true });
|
|
100142
100180
|
return entries.filter((e) => e.isDirectory() && !e.name.startsWith("_") && !e.name.startsWith(".")).map((e) => e.name).sort();
|
|
100143
100181
|
} catch {
|
|
100144
100182
|
return [];
|
|
@@ -100154,7 +100192,7 @@ async function listComponents(componentsDir, prefix = "") {
|
|
|
100154
100192
|
const out = [];
|
|
100155
100193
|
for (const entry of entries) {
|
|
100156
100194
|
const rel = prefix ? `${prefix}/${entry.name}` : entry.name;
|
|
100157
|
-
if (entry.isDirectory()) out.push(...await listComponents(
|
|
100195
|
+
if (entry.isDirectory()) out.push(...await listComponents(path64.join(componentsDir, entry.name), rel));
|
|
100158
100196
|
else if (entry.name.endsWith(".astro")) out.push(rel);
|
|
100159
100197
|
}
|
|
100160
100198
|
return out.sort();
|
|
@@ -100221,16 +100259,16 @@ async function resolveTargets(projectRoot, opts) {
|
|
|
100221
100259
|
`"${controlSlug}" is already a variant of "${variantOfSlug(controlSlug)}". Make the next variant of the page itself: \`baker landing variant ${variantOfSlug(controlSlug)}\`.`
|
|
100222
100260
|
);
|
|
100223
100261
|
}
|
|
100224
|
-
const controlDir =
|
|
100262
|
+
const controlDir = path64.resolve(projectRoot, "src", "pages", controlSlug);
|
|
100225
100263
|
if (!await isDir3(controlDir)) {
|
|
100226
100264
|
fail11("NOT_FOUND", `No page at src/pages/${controlSlug}/`, {
|
|
100227
100265
|
availableSlugs: await listLandingSlugs2(projectRoot)
|
|
100228
100266
|
});
|
|
100229
100267
|
}
|
|
100230
|
-
if (!await exists2(
|
|
100268
|
+
if (!await exists2(path64.join(controlDir, "index.astro"))) {
|
|
100231
100269
|
fail11("NOT_FOUND", `src/pages/${controlSlug}/index.astro is missing, so there is no page to make a variant of.`);
|
|
100232
100270
|
}
|
|
100233
|
-
const internalId = await readInternalId(
|
|
100271
|
+
const internalId = await readInternalId(path64.join(controlDir, "_definition.md"));
|
|
100234
100272
|
const variantSlugValue = variantSlug(
|
|
100235
100273
|
controlSlug,
|
|
100236
100274
|
nextVariantNumber(
|
|
@@ -100239,8 +100277,8 @@ async function resolveTargets(projectRoot, opts) {
|
|
|
100239
100277
|
await archivedVariantNumbers(projectRoot, internalId)
|
|
100240
100278
|
)
|
|
100241
100279
|
);
|
|
100242
|
-
const variantDir =
|
|
100243
|
-
const available = await listComponents(
|
|
100280
|
+
const variantDir = path64.resolve(projectRoot, "src", "pages", variantSlugValue);
|
|
100281
|
+
const available = await listComponents(path64.join(controlDir, "_components"));
|
|
100244
100282
|
const forks = [];
|
|
100245
100283
|
for (const name of parseForks(opts.fork, opts.rawArgs)) {
|
|
100246
100284
|
const resolved = resolveForkName(name, available);
|
|
@@ -100256,26 +100294,26 @@ async function resolveTargets(projectRoot, opts) {
|
|
|
100256
100294
|
}
|
|
100257
100295
|
async function writeVariant(opts) {
|
|
100258
100296
|
const { controlDir, variantDir, controlSlug, variantSlug: variantSlug2, forks } = opts;
|
|
100259
|
-
const forkedTargets = new Set(forks.map((f) =>
|
|
100297
|
+
const forkedTargets = new Set(forks.map((f) => path64.join(controlDir, "_components", f)));
|
|
100260
100298
|
const written = [];
|
|
100261
|
-
const indexText = await readFile49(
|
|
100299
|
+
const indexText = await readFile49(path64.join(controlDir, "index.astro"), "utf8");
|
|
100262
100300
|
await mkdir20(variantDir, { recursive: true });
|
|
100263
100301
|
await writeFile32(
|
|
100264
|
-
|
|
100302
|
+
path64.join(variantDir, "index.astro"),
|
|
100265
100303
|
repointFile(indexText, { fromDir: controlDir, toDir: variantDir, controlDir, variantDir, forkedTargets }),
|
|
100266
100304
|
"utf8"
|
|
100267
100305
|
);
|
|
100268
100306
|
written.push(`src/pages/${variantSlug2}/index.astro`);
|
|
100269
100307
|
for (const fork of forks) {
|
|
100270
|
-
const fromFile =
|
|
100271
|
-
const toFile =
|
|
100308
|
+
const fromFile = path64.join(controlDir, "_components", fork);
|
|
100309
|
+
const toFile = path64.join(variantDir, "_components", fork);
|
|
100272
100310
|
const text3 = await readFile49(fromFile, "utf8");
|
|
100273
|
-
await mkdir20(
|
|
100311
|
+
await mkdir20(path64.dirname(toFile), { recursive: true });
|
|
100274
100312
|
await writeFile32(
|
|
100275
100313
|
toFile,
|
|
100276
100314
|
repointFile(text3, {
|
|
100277
|
-
fromDir:
|
|
100278
|
-
toDir:
|
|
100315
|
+
fromDir: path64.dirname(fromFile),
|
|
100316
|
+
toDir: path64.dirname(toFile),
|
|
100279
100317
|
controlDir,
|
|
100280
100318
|
variantDir,
|
|
100281
100319
|
forkedTargets
|
|
@@ -100284,7 +100322,7 @@ async function writeVariant(opts) {
|
|
|
100284
100322
|
);
|
|
100285
100323
|
written.push(`src/pages/${variantSlug2}/_components/${fork}`);
|
|
100286
100324
|
}
|
|
100287
|
-
const controlDefinitionPath =
|
|
100325
|
+
const controlDefinitionPath = path64.join(controlDir, "_definition.md");
|
|
100288
100326
|
if (await exists2(controlDefinitionPath)) {
|
|
100289
100327
|
const definition = buildVariantDefinition(await readFile49(controlDefinitionPath, "utf8"), {
|
|
100290
100328
|
internalId: randomUUID4().replace(/-/g, "").slice(0, 8),
|
|
@@ -100294,11 +100332,11 @@ async function writeVariant(opts) {
|
|
|
100294
100332
|
...opts.because ? { because: opts.because } : {},
|
|
100295
100333
|
...opts.change ? { change: opts.change } : {}
|
|
100296
100334
|
});
|
|
100297
|
-
await writeFile32(
|
|
100335
|
+
await writeFile32(path64.join(variantDir, "_definition.md"), definition, "utf8");
|
|
100298
100336
|
written.push(`src/pages/${variantSlug2}/_definition.md`);
|
|
100299
100337
|
}
|
|
100300
|
-
await mkdir20(
|
|
100301
|
-
await writeFile32(
|
|
100338
|
+
await mkdir20(path64.join(variantDir, "_images"), { recursive: true });
|
|
100339
|
+
await writeFile32(path64.join(variantDir, "_images", ".gitkeep"), "", "utf8");
|
|
100302
100340
|
return written;
|
|
100303
100341
|
}
|
|
100304
100342
|
var variantCommand = defineCommand225({
|
|
@@ -101646,7 +101684,7 @@ var countriesCommand = defineCommand237({
|
|
|
101646
101684
|
|
|
101647
101685
|
// src/commands/research/customers.ts
|
|
101648
101686
|
import { mkdir as mkdir21, readdir as readdir24, readFile as readFile50, writeFile as writeFile33 } from "fs/promises";
|
|
101649
|
-
import
|
|
101687
|
+
import path65 from "path";
|
|
101650
101688
|
import { defineCommand as defineCommand239 } from "citty";
|
|
101651
101689
|
import { parse as parseYaml5 } from "yaml";
|
|
101652
101690
|
import { z as z77 } from "zod";
|
|
@@ -102198,7 +102236,7 @@ function customersHints(input) {
|
|
|
102198
102236
|
const cite = `Cite these by id in an idea's \`evidence\` (src/creatives/_ideas/<idea>.md); write the ad from the quote as said.`;
|
|
102199
102237
|
return written < FEW_OBSERVED ? [`Only ${written} observed. ${widen}`, cite] : [cite];
|
|
102200
102238
|
}
|
|
102201
|
-
var INSIGHTS_DIR2 =
|
|
102239
|
+
var INSIGHTS_DIR2 = path65.join("src", "content", "insights");
|
|
102202
102240
|
var BATCH_CHARS = 24e3;
|
|
102203
102241
|
var MAX_BATCHES = 5;
|
|
102204
102242
|
var WEB_PAGES = 3;
|
|
@@ -102263,12 +102301,12 @@ async function readExistingInsights(dir) {
|
|
|
102263
102301
|
return await Promise.all(
|
|
102264
102302
|
files.map(async (file) => ({
|
|
102265
102303
|
id: file.slice(0, -3),
|
|
102266
|
-
quote: quoteOf(await readFile50(
|
|
102304
|
+
quote: quoteOf(await readFile50(path65.join(dir, file), "utf8").catch(() => ""))
|
|
102267
102305
|
}))
|
|
102268
102306
|
);
|
|
102269
102307
|
}
|
|
102270
102308
|
async function productSlugs(root) {
|
|
102271
|
-
const files = await readdir24(
|
|
102309
|
+
const files = await readdir24(path65.join(root, "src", "content", "products")).catch(() => []);
|
|
102272
102310
|
return files.filter((f) => f.endsWith(".md")).map((f) => f.slice(0, -3));
|
|
102273
102311
|
}
|
|
102274
102312
|
async function gatherTestimonials(focus) {
|
|
@@ -102368,7 +102406,7 @@ async function classifyAll(sources, focus, root) {
|
|
|
102368
102406
|
const batches = batchSources(sources, BATCH_CHARS).slice(0, MAX_BATCHES);
|
|
102369
102407
|
const spent = [];
|
|
102370
102408
|
const answers = await Promise.all(batches.map((batch) => classifyBatch(batch, focus, (u) => spent.push(u))));
|
|
102371
|
-
await holdUnbilledSpend(
|
|
102409
|
+
await holdUnbilledSpend(path65.join(root, "canvas", ".cache"), spent);
|
|
102372
102410
|
if (batches.length > 0 && answers.every((a) => a === null)) return null;
|
|
102373
102411
|
const result = { kept: [], dropped: 0, tooLong: 0 };
|
|
102374
102412
|
batches.forEach((batch, i) => {
|
|
@@ -102385,7 +102423,7 @@ async function writeInsights(dir, writes, opts) {
|
|
|
102385
102423
|
const written = [];
|
|
102386
102424
|
for (const entry of writes) {
|
|
102387
102425
|
const file = renderInsightFile(entry.insight, opts);
|
|
102388
|
-
const ok = await writeFile33(
|
|
102426
|
+
const ok = await writeFile33(path65.join(dir, `${entry.id}.md`), file, { encoding: "utf8", flag: "wx" }).then(
|
|
102389
102427
|
() => true,
|
|
102390
102428
|
() => false
|
|
102391
102429
|
);
|
|
@@ -102436,7 +102474,7 @@ var customersCommand = defineCommand239({
|
|
|
102436
102474
|
"Run it again. Do not write insights by hand: an insight is only a quote this command found in its source."
|
|
102437
102475
|
);
|
|
102438
102476
|
}
|
|
102439
|
-
const dir =
|
|
102477
|
+
const dir = path65.join(root, INSIGHTS_DIR2);
|
|
102440
102478
|
const plan = planInsightWrites(gated.kept, await readExistingInsights(dir), limit);
|
|
102441
102479
|
const today2 = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
|
|
102442
102480
|
const shown = dryRun ? plan.writes : await writeInsights(dir, plan.writes, { today: today2, ...product ? { product } : {} });
|
|
@@ -104039,7 +104077,7 @@ Full guide: __tooling__/docs/tools/baker/scheduled-agents.md`
|
|
|
104039
104077
|
|
|
104040
104078
|
// src/commands/scheduled-agents/templates.ts
|
|
104041
104079
|
import { readFile as readFile51 } from "fs/promises";
|
|
104042
|
-
import
|
|
104080
|
+
import path66 from "path";
|
|
104043
104081
|
import { defineCommand as defineCommand256 } from "citty";
|
|
104044
104082
|
registerSchema({
|
|
104045
104083
|
command: "scheduled-agents.templates",
|
|
@@ -104146,7 +104184,7 @@ Full guide: __tooling__/docs/tools/baker/scheduled-agents.md`
|
|
|
104146
104184
|
}
|
|
104147
104185
|
if (save.length > 0) {
|
|
104148
104186
|
const briefFile = flag2("brief-file");
|
|
104149
|
-
const brief2 = briefFile.length > 0 ? await readFile51(
|
|
104187
|
+
const brief2 = briefFile.length > 0 ? await readFile51(path66.resolve(briefFile), "utf8") : flag2("brief");
|
|
104150
104188
|
if (brief2.trim().length === 0) {
|
|
104151
104189
|
failValidation6("--brief-file (preferred) or --brief is required: the brief is the recipe.");
|
|
104152
104190
|
}
|
|
@@ -104928,7 +104966,7 @@ var setCommand = defineCommand264({
|
|
|
104928
104966
|
timezone: args8.timezone,
|
|
104929
104967
|
"export-profile": args8["export-profile"]
|
|
104930
104968
|
},
|
|
104931
|
-
(
|
|
104969
|
+
(path69) => readFileSync26(path69, "utf8")
|
|
104932
104970
|
);
|
|
104933
104971
|
const body = { chatId: requireChatId(), inputs };
|
|
104934
104972
|
writeJson(await apiPost("/api/site/stage", body));
|
|
@@ -105210,7 +105248,7 @@ function parseImageRefs(spec) {
|
|
|
105210
105248
|
}
|
|
105211
105249
|
var defaultDeps = {
|
|
105212
105250
|
ingest: (url) => apiPost("/api/images/ingest", { url, source: "uploaded" }),
|
|
105213
|
-
upload: (
|
|
105251
|
+
upload: (path69) => uploadLocalImage({ file: path69, contentType: detectImageContentType(path69), source: "uploaded" })
|
|
105214
105252
|
};
|
|
105215
105253
|
async function resolveLibraryImageIds(spec, limit, deps = defaultDeps) {
|
|
105216
105254
|
const refs = parseImageRefs(spec);
|
|
@@ -105230,10 +105268,10 @@ async function resolveLibraryImageIds(spec, limit, deps = defaultDeps) {
|
|
|
105230
105268
|
}
|
|
105231
105269
|
return { imageIds, added };
|
|
105232
105270
|
}
|
|
105233
|
-
function uploadFailure(
|
|
105271
|
+
function uploadFailure(path69) {
|
|
105234
105272
|
return (error) => {
|
|
105235
105273
|
if (error instanceof ApiError) throw error;
|
|
105236
|
-
throw new ApiError("VALIDATION_ERROR", `Could not read "${
|
|
105274
|
+
throw new ApiError("VALIDATION_ERROR", `Could not read "${path69}" as an image.`);
|
|
105237
105275
|
};
|
|
105238
105276
|
}
|
|
105239
105277
|
|
|
@@ -106333,10 +106371,10 @@ async function stageOp4(op) {
|
|
|
106333
106371
|
handleError8(err);
|
|
106334
106372
|
}
|
|
106335
106373
|
}
|
|
106336
|
-
async function draftAction3(
|
|
106374
|
+
async function draftAction3(path69, body, chat) {
|
|
106337
106375
|
const chatId = resolveChatId(chat);
|
|
106338
106376
|
try {
|
|
106339
|
-
const { data, hints: hints2 } = splitHints(await apiPost(
|
|
106377
|
+
const { data, hints: hints2 } = splitHints(await apiPost(path69, { chatId, ...body }));
|
|
106340
106378
|
writeJsonEnvelope({ ok: true, data, ...hints2.length > 0 ? { hints: hints2 } : {} });
|
|
106341
106379
|
return data;
|
|
106342
106380
|
} catch (err) {
|
|
@@ -107900,7 +107938,7 @@ Example: baker videos describe j571abc123 --description "Customer explaining how
|
|
|
107900
107938
|
import { constants } from "fs";
|
|
107901
107939
|
import { copyFile as copyFile2, mkdir as mkdir22, mkdtemp as mkdtemp3, rm as rm9 } from "fs/promises";
|
|
107902
107940
|
import { tmpdir as tmpdir4 } from "os";
|
|
107903
|
-
import
|
|
107941
|
+
import path67 from "path";
|
|
107904
107942
|
import { defineCommand as defineCommand293 } from "citty";
|
|
107905
107943
|
|
|
107906
107944
|
// src/commands/videos/videoPlatforms.ts
|
|
@@ -108068,8 +108106,8 @@ var fetchCommand2 = defineCommand293({
|
|
|
108068
108106
|
}
|
|
108069
108107
|
});
|
|
108070
108108
|
async function fetchVideo(args8) {
|
|
108071
|
-
const outDir =
|
|
108072
|
-
const workDir = await mkdtemp3(
|
|
108109
|
+
const outDir = path67.resolve(args8.out);
|
|
108110
|
+
const workDir = await mkdtemp3(path67.join(tmpdir4(), "videos-fetch-"));
|
|
108073
108111
|
try {
|
|
108074
108112
|
await mkdir22(outDir, { recursive: true });
|
|
108075
108113
|
const vimeoCookie = captureVimeoCookie();
|
|
@@ -108114,7 +108152,7 @@ function fileStem(info) {
|
|
|
108114
108152
|
}
|
|
108115
108153
|
async function placeInto(outDir, source, stem) {
|
|
108116
108154
|
for (let n = 1; ; n++) {
|
|
108117
|
-
const target2 =
|
|
108155
|
+
const target2 = path67.join(outDir, `${stem}${n === 1 ? "" : `-${n}`}${path67.extname(source)}`);
|
|
108118
108156
|
try {
|
|
108119
108157
|
await copyFile2(source, target2, constants.COPYFILE_EXCL);
|
|
108120
108158
|
return target2;
|
|
@@ -108201,7 +108239,7 @@ var groupCommand2 = defineCommand295({
|
|
|
108201
108239
|
// src/commands/videos/ingest.ts
|
|
108202
108240
|
import { mkdtemp as mkdtemp4, rm as rm10, stat as stat14 } from "fs/promises";
|
|
108203
108241
|
import { tmpdir as tmpdir5 } from "os";
|
|
108204
|
-
import
|
|
108242
|
+
import path68 from "path";
|
|
108205
108243
|
import { defineCommand as defineCommand296 } from "citty";
|
|
108206
108244
|
|
|
108207
108245
|
// src/lib/streamUpload.ts
|
|
@@ -108441,7 +108479,7 @@ function ingestUrl(args8) {
|
|
|
108441
108479
|
}
|
|
108442
108480
|
async function downloadThenIngest(args8, country) {
|
|
108443
108481
|
const vimeoCookie = captureVimeoCookie();
|
|
108444
|
-
const workDir = await mkdtemp4(
|
|
108482
|
+
const workDir = await mkdtemp4(path68.join(tmpdir5(), "videos-ingest-"));
|
|
108445
108483
|
try {
|
|
108446
108484
|
const probe = await probeYtDlp({ url: args8.url, country, vimeoCookie, cookieDir: workDir });
|
|
108447
108485
|
if (isAudioOnly(probe.info)) {
|