@tanqory/partner-cli 0.1.0-alpha.0 → 0.1.0-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/check.mjs +31 -4
- package/lib/mcp.mjs +1 -1
- package/lib/ops.mjs +6 -1
- package/lib/theme.mjs +17 -3
- package/lib/vendor/partner-checks.cjs +1414 -260
- package/package.json +1 -1
- package/starter/README.md +7 -1
- package/starter/config/settings.json +3 -1
- package/starter/locales/en.schema.json +69 -0
- package/starter/locales/th.schema.json +69 -0
- package/starter/scripts/build.mjs +17 -1
- package/starter/src/sections/chrome.tsx +11 -11
- package/starter/src/sections/commerce.tsx +13 -13
- package/starter/src/sections/content.tsx +13 -9
- package/starter/src/sections/editorial.tsx +154 -29
- package/starter/src/settings.ts +8 -11
- package/starter/src/styles/theme.css +23 -6
- package/starter/src/theme.tsx +14 -4
- package/starter/templates/index.json +86 -6
- package/starter/templates/page.contact.json +5 -1
|
@@ -6,6 +6,13 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
6
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
7
|
var __getProtoOf = Object.getPrototypeOf;
|
|
8
8
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
10
|
+
try {
|
|
11
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
12
|
+
} catch (e) {
|
|
13
|
+
throw mod = 0, e;
|
|
14
|
+
}
|
|
15
|
+
};
|
|
9
16
|
var __export = (target, all) => {
|
|
10
17
|
for (var name in all)
|
|
11
18
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -28,16 +35,1039 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
28
35
|
));
|
|
29
36
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
37
|
|
|
38
|
+
// ../theme-standard/lib/editability.js
|
|
39
|
+
var require_editability = __commonJS({
|
|
40
|
+
"../theme-standard/lib/editability.js"(exports2, module2) {
|
|
41
|
+
"use strict";
|
|
42
|
+
var STRUCTURAL_LINK = /^(#[\w-]*|\/|\/cart|\/search|\/account(\/[\w/-]*)?|\/collections|\/collections\/all(\?[\w=&-]*)?)$/;
|
|
43
|
+
var TEXT_ATTRS = /* @__PURE__ */ new Set(["alt", "title", "placeholder", "aria-label", "aria-description", "aria-placeholder"]);
|
|
44
|
+
var FORMAT_EXAMPLE = /^\s*([\w.+-]+@[\w-]+(\.[\w-]+)+|https?:\/\/\S+|[\w-]+(\.[\w-]+)+)\s*$/;
|
|
45
|
+
var LINK_ATTRS = /* @__PURE__ */ new Set(["href"]);
|
|
46
|
+
var MEDIA_ATTRS = /* @__PURE__ */ new Set(["src", "srcSet", "srcset", "poster", "image", "video"]);
|
|
47
|
+
var TEMPLATE_SECTIONS = /* @__PURE__ */ new Set(["product", "collection", "cart", "search", "account", "page", "blog", "article", "not-found", "password", "gift-card", "policy", "list-collections", "customers", "main"]);
|
|
48
|
+
var CONTENT_KEY = /^(heading|title|quote)$/i;
|
|
49
|
+
var KIT_SETTINGS = /* @__PURE__ */ new Set(["showLocale", "showAccount"]);
|
|
50
|
+
var CHROME_KEY = /(^|\.)(cart|account|search|product|price|form|forms|newsletter|contact|menu|nav|notFound|errors?|general|accessibility|a11y|pagination|sort|filter|filters|localization|consent|customer|checkout|journal|blog|article|footer\.rights|shelf\.empty|viewAll|readMore|skip)(\.|$)/i;
|
|
51
|
+
var LETTER = new RegExp("\\p{L}", "u");
|
|
52
|
+
var SVG_TEXT = /* @__PURE__ */ new Set(["text", "tspan", "title", "desc", "textPath"]);
|
|
53
|
+
var isWords = (s) => LETTER.test(s) && !/^\s*(&[a-z#0-9]+;\s*)+$/i.test(s);
|
|
54
|
+
function lineCol(src, i) {
|
|
55
|
+
let line3 = 1;
|
|
56
|
+
let last = -1;
|
|
57
|
+
for (let k = 0; k < i && k < src.length; k++) if (src.charCodeAt(k) === 10) {
|
|
58
|
+
line3++;
|
|
59
|
+
last = k;
|
|
60
|
+
}
|
|
61
|
+
return { line: line3, column: i - last };
|
|
62
|
+
}
|
|
63
|
+
function scan(src) {
|
|
64
|
+
const n = src.length;
|
|
65
|
+
const texts = [];
|
|
66
|
+
const attrs = [];
|
|
67
|
+
const strings = [];
|
|
68
|
+
const exprs = [];
|
|
69
|
+
const mask = src.split("");
|
|
70
|
+
let hiddenDepth = 0;
|
|
71
|
+
const blank = (a, b, ch = " ") => {
|
|
72
|
+
for (let k = a; k < b && k < n; k++) if (mask[k] !== "\n") mask[k] = ch;
|
|
73
|
+
};
|
|
74
|
+
const prevSignificant = (i) => {
|
|
75
|
+
let k = i - 1;
|
|
76
|
+
while (k >= 0 && /\s/.test(src[k])) k--;
|
|
77
|
+
if (k < 0) return { ch: "", word: "" };
|
|
78
|
+
let w = k;
|
|
79
|
+
while (w >= 0 && /[\w$]/.test(src[w])) w--;
|
|
80
|
+
return { ch: src[k], word: src.slice(w + 1, k + 1) };
|
|
81
|
+
};
|
|
82
|
+
const jsxCanStart = (i) => {
|
|
83
|
+
const nx = src[i + 1];
|
|
84
|
+
if (!(nx === ">" || /[A-Za-z]/.test(nx || ""))) return false;
|
|
85
|
+
const p = prevSignificant(i);
|
|
86
|
+
if (p.word === "return" || p.word === "default" || p.word === "") return p.ch === "" || /[\s(,=?:{[!&|;>]/.test(p.ch) || p.word === "return" || p.word === "default";
|
|
87
|
+
return /[(,=?:{[!&|;>]/.test(p.ch) && !/[\w$)\]]/.test(p.ch);
|
|
88
|
+
};
|
|
89
|
+
function skipString(i) {
|
|
90
|
+
const q = src[i];
|
|
91
|
+
let k = i + 1;
|
|
92
|
+
while (k < n && src[k] !== q && src[k] !== "\n") {
|
|
93
|
+
if (src[k] === "\\") k++;
|
|
94
|
+
k++;
|
|
95
|
+
}
|
|
96
|
+
strings.push({ start: i, end: k + 1, value: src.slice(i + 1, k) });
|
|
97
|
+
blank(i + 1, k, "_");
|
|
98
|
+
return k + 1;
|
|
99
|
+
}
|
|
100
|
+
function skipTemplate(i) {
|
|
101
|
+
let k = i + 1;
|
|
102
|
+
let static_ = "";
|
|
103
|
+
let dynamic = false;
|
|
104
|
+
while (k < n && src[k] !== "`") {
|
|
105
|
+
if (src[k] === "\\") {
|
|
106
|
+
k += 2;
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
if (src[k] === "$" && src[k + 1] === "{") {
|
|
110
|
+
dynamic = true;
|
|
111
|
+
k = parseJS(k + 2, "}") + 1;
|
|
112
|
+
continue;
|
|
113
|
+
}
|
|
114
|
+
static_ += src[k];
|
|
115
|
+
mask[k] = src[k] === "\n" ? "\n" : "_";
|
|
116
|
+
k++;
|
|
117
|
+
}
|
|
118
|
+
strings.push({ start: i, end: k + 1, value: static_, template: true, dynamic });
|
|
119
|
+
return k + 1;
|
|
120
|
+
}
|
|
121
|
+
function parseJS(i, stop) {
|
|
122
|
+
let depth = 0;
|
|
123
|
+
while (i < n) {
|
|
124
|
+
const c = src[i];
|
|
125
|
+
if (c === "/" && src[i + 1] === "/") {
|
|
126
|
+
const e = src.indexOf("\n", i);
|
|
127
|
+
const end = e < 0 ? n : e;
|
|
128
|
+
blank(i, end);
|
|
129
|
+
i = end;
|
|
130
|
+
continue;
|
|
131
|
+
}
|
|
132
|
+
if (c === "/" && src[i + 1] === "*") {
|
|
133
|
+
const e = src.indexOf("*/", i + 2);
|
|
134
|
+
const end = e < 0 ? n : e + 2;
|
|
135
|
+
blank(i, end);
|
|
136
|
+
i = end;
|
|
137
|
+
continue;
|
|
138
|
+
}
|
|
139
|
+
if (c === '"' || c === "'") {
|
|
140
|
+
i = skipString(i);
|
|
141
|
+
continue;
|
|
142
|
+
}
|
|
143
|
+
if (c === "`") {
|
|
144
|
+
i = skipTemplate(i);
|
|
145
|
+
continue;
|
|
146
|
+
}
|
|
147
|
+
if (c === "{" || c === "(" || c === "[") {
|
|
148
|
+
depth++;
|
|
149
|
+
i++;
|
|
150
|
+
continue;
|
|
151
|
+
}
|
|
152
|
+
if (c === "}" || c === ")" || c === "]") {
|
|
153
|
+
if (depth === 0 && stop && c === stop) return i;
|
|
154
|
+
depth--;
|
|
155
|
+
i++;
|
|
156
|
+
continue;
|
|
157
|
+
}
|
|
158
|
+
if (c === "<" && jsxCanStart(i)) {
|
|
159
|
+
const j = parseElement(i);
|
|
160
|
+
if (j > 0) {
|
|
161
|
+
i = j;
|
|
162
|
+
continue;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
i++;
|
|
166
|
+
}
|
|
167
|
+
return n;
|
|
168
|
+
}
|
|
169
|
+
function parseElement(i) {
|
|
170
|
+
const start = i;
|
|
171
|
+
i++;
|
|
172
|
+
if (src[i] === ">") return parseChildren(i + 1, "", start);
|
|
173
|
+
const m = /^[A-Za-z][\w.:-]*/.exec(src.slice(i, i + 80));
|
|
174
|
+
if (!m) return -1;
|
|
175
|
+
const tag = m[0];
|
|
176
|
+
i += tag.length;
|
|
177
|
+
const mine = [];
|
|
178
|
+
for (; ; ) {
|
|
179
|
+
while (i < n && /\s/.test(src[i])) i++;
|
|
180
|
+
if (src[i] === "/" && src[i + 1] === "/") {
|
|
181
|
+
const e = src.indexOf("\n", i);
|
|
182
|
+
const end = e < 0 ? n : e;
|
|
183
|
+
blank(i, end);
|
|
184
|
+
i = end;
|
|
185
|
+
continue;
|
|
186
|
+
}
|
|
187
|
+
if (src[i] === "/" && src[i + 1] === "*") {
|
|
188
|
+
const e = src.indexOf("*/", i + 2);
|
|
189
|
+
const end = e < 0 ? n : e + 2;
|
|
190
|
+
blank(i, end);
|
|
191
|
+
i = end;
|
|
192
|
+
continue;
|
|
193
|
+
}
|
|
194
|
+
if (i >= n) return -1;
|
|
195
|
+
if (src[i] === "/" && src[i + 1] === ">") {
|
|
196
|
+
attrs.push(...mine);
|
|
197
|
+
return i + 2;
|
|
198
|
+
}
|
|
199
|
+
if (src[i] === ">") {
|
|
200
|
+
attrs.push(...mine);
|
|
201
|
+
const hid = mine.some((a2) => a2.name === "aria-hidden" && a2.kind === "literal" && a2.value === "true" || a2.name === "hidden" && a2.kind === "flag");
|
|
202
|
+
if (hid) hiddenDepth++;
|
|
203
|
+
try {
|
|
204
|
+
return parseChildren(i + 1, tag, start);
|
|
205
|
+
} finally {
|
|
206
|
+
if (hid) hiddenDepth--;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
if (src[i] === "{") {
|
|
210
|
+
const j = parseJS(i + 1, "}");
|
|
211
|
+
if (j >= n) return -1;
|
|
212
|
+
i = j + 1;
|
|
213
|
+
continue;
|
|
214
|
+
}
|
|
215
|
+
const a = /^[A-Za-z_][\w:.-]*/.exec(src.slice(i, i + 60));
|
|
216
|
+
if (!a) return -1;
|
|
217
|
+
const name = a[0];
|
|
218
|
+
const at = i;
|
|
219
|
+
i += name.length;
|
|
220
|
+
while (i < n && /\s/.test(src[i])) i++;
|
|
221
|
+
if (src[i] !== "=") {
|
|
222
|
+
mine.push({ tag, name, at, kind: "flag" });
|
|
223
|
+
continue;
|
|
224
|
+
}
|
|
225
|
+
i++;
|
|
226
|
+
while (i < n && /\s/.test(src[i])) i++;
|
|
227
|
+
if (src[i] === '"' || src[i] === "'") {
|
|
228
|
+
const q = src[i];
|
|
229
|
+
const e = src.indexOf(q, i + 1);
|
|
230
|
+
if (e < 0) return -1;
|
|
231
|
+
mine.push({ tag, name, at, kind: "literal", value: src.slice(i + 1, e), vstart: i });
|
|
232
|
+
blank(i + 1, e, "_");
|
|
233
|
+
i = e + 1;
|
|
234
|
+
continue;
|
|
235
|
+
}
|
|
236
|
+
if (src[i] === "{") {
|
|
237
|
+
const j = parseJS(i + 1, "}");
|
|
238
|
+
if (j >= n) return -1;
|
|
239
|
+
mine.push({ tag, name, at, kind: "expr", start: i + 1, end: j, value: src.slice(i + 1, j) });
|
|
240
|
+
i = j + 1;
|
|
241
|
+
continue;
|
|
242
|
+
}
|
|
243
|
+
return -1;
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
function parseChildren(i, tag, openAt) {
|
|
247
|
+
let textStart = i;
|
|
248
|
+
const flush = (end) => {
|
|
249
|
+
const raw = src.slice(textStart, end);
|
|
250
|
+
if (raw.trim()) {
|
|
251
|
+
const lead = raw.length - raw.trimStart().length;
|
|
252
|
+
texts.push({ start: textStart + lead, value: raw.trim().replace(/\s+/g, " "), tag, hidden: hiddenDepth > 0 });
|
|
253
|
+
}
|
|
254
|
+
};
|
|
255
|
+
while (i < n) {
|
|
256
|
+
const c = src[i];
|
|
257
|
+
if (c === "{") {
|
|
258
|
+
flush(i);
|
|
259
|
+
const j = parseJS(i + 1, "}");
|
|
260
|
+
exprs.push({ start: i + 1, end: j, value: src.slice(i + 1, j), tag });
|
|
261
|
+
i = j + 1;
|
|
262
|
+
textStart = i;
|
|
263
|
+
continue;
|
|
264
|
+
}
|
|
265
|
+
if (c === "<") {
|
|
266
|
+
if (src[i + 1] === "/") {
|
|
267
|
+
flush(i);
|
|
268
|
+
const e = src.indexOf(">", i);
|
|
269
|
+
return e < 0 ? n : e + 1;
|
|
270
|
+
}
|
|
271
|
+
flush(i);
|
|
272
|
+
const j = parseElement(i);
|
|
273
|
+
if (j < 0) {
|
|
274
|
+
i++;
|
|
275
|
+
continue;
|
|
276
|
+
}
|
|
277
|
+
i = j;
|
|
278
|
+
textStart = i;
|
|
279
|
+
continue;
|
|
280
|
+
}
|
|
281
|
+
i++;
|
|
282
|
+
}
|
|
283
|
+
void openAt;
|
|
284
|
+
return n;
|
|
285
|
+
}
|
|
286
|
+
parseJS(0, null);
|
|
287
|
+
return { texts, attrs, strings, exprs, mask: mask.join("") };
|
|
288
|
+
}
|
|
289
|
+
function matchBracket(mask, open) {
|
|
290
|
+
const pairs = { "{": "}", "(": ")", "[": "]" };
|
|
291
|
+
const stack = [];
|
|
292
|
+
for (let k = open; k < mask.length; k++) {
|
|
293
|
+
const c = mask[k];
|
|
294
|
+
if (pairs[c]) stack.push(pairs[c]);
|
|
295
|
+
else if (c === "}" || c === ")" || c === "]") {
|
|
296
|
+
if (stack.pop() !== c) return -1;
|
|
297
|
+
if (!stack.length) return k;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
return -1;
|
|
301
|
+
}
|
|
302
|
+
function literalAt(src, i) {
|
|
303
|
+
const m = /^\s*(['"`])((?:\\.|(?!\1)[^\\\n])*)\1/.exec(src.slice(i, i + 4e3));
|
|
304
|
+
if (!m || m[1] === "`" && m[2].includes("${")) return null;
|
|
305
|
+
return m[2];
|
|
306
|
+
}
|
|
307
|
+
function definitions(src, mask) {
|
|
308
|
+
const out = [];
|
|
309
|
+
const re = /\bdefine(Section|Block)\s*\(\s*\{/g;
|
|
310
|
+
let m;
|
|
311
|
+
while (m = re.exec(mask)) {
|
|
312
|
+
const open = m.index + m[0].length - 1;
|
|
313
|
+
const close = matchBracket(mask, open);
|
|
314
|
+
if (close < 0) continue;
|
|
315
|
+
const body = mask.slice(open, close + 1);
|
|
316
|
+
const prop = (name) => {
|
|
317
|
+
const r = new RegExp(`[{,\\s]${name}\\s*:`, "g");
|
|
318
|
+
let p;
|
|
319
|
+
while (p = r.exec(body)) {
|
|
320
|
+
const at = open + p.index + p[0].length;
|
|
321
|
+
let depth = 0;
|
|
322
|
+
for (let k = open + 1; k < open + p.index + 1; k++) {
|
|
323
|
+
const c = mask[k];
|
|
324
|
+
if ("{([".includes(c)) depth++;
|
|
325
|
+
else if ("})]".includes(c)) depth--;
|
|
326
|
+
}
|
|
327
|
+
if (depth === 0) return at;
|
|
328
|
+
}
|
|
329
|
+
return -1;
|
|
330
|
+
};
|
|
331
|
+
const typeAt = prop("type");
|
|
332
|
+
const type = typeAt >= 0 ? literalAt(src, typeAt) : null;
|
|
333
|
+
const def = { kind: m[1] === "Section" ? "section" : "block", type, start: m.index, open, close, settings: [], has: {} };
|
|
334
|
+
for (const k of ["zone", "requires", "presets", "blocks", "component", "title"]) def.has[k] = prop(k) >= 0;
|
|
335
|
+
def.componentAt = def.has.component ? prop("component") : close;
|
|
336
|
+
const presetsAt = prop("presets");
|
|
337
|
+
if (presetsAt >= 0) {
|
|
338
|
+
const o = mask.indexOf("[", presetsAt);
|
|
339
|
+
const c = o >= 0 ? matchBracket(mask, o) : -1;
|
|
340
|
+
def.presets = c > 0 ? src.slice(o, c + 1) : "";
|
|
341
|
+
}
|
|
342
|
+
const blocksAt = prop("blocks");
|
|
343
|
+
if (blocksAt >= 0) {
|
|
344
|
+
const o = mask.indexOf("[", blocksAt);
|
|
345
|
+
const c = o >= 0 && o - blocksAt < 4 ? matchBracket(mask, o) : -1;
|
|
346
|
+
def.blocksList = c > 0 ? src.slice(o, c + 1) : "";
|
|
347
|
+
}
|
|
348
|
+
const settingsAt = prop("settings");
|
|
349
|
+
if (settingsAt >= 0) {
|
|
350
|
+
const o = mask.indexOf("{", settingsAt);
|
|
351
|
+
const c = o >= 0 && o - settingsAt < 4 ? matchBracket(mask, o) : -1;
|
|
352
|
+
if (c > 0) {
|
|
353
|
+
def.settingsRange = [o, c];
|
|
354
|
+
const fr = /([A-Za-z_$][\w$]*)\s*:\s*field\s*\.\s*(\w+)\s*\(/g;
|
|
355
|
+
const seg = mask.slice(o, c);
|
|
356
|
+
let f;
|
|
357
|
+
while (f = fr.exec(seg)) {
|
|
358
|
+
const callOpen = o + f.index + f[0].length - 1;
|
|
359
|
+
const callClose = matchBracket(mask, callOpen);
|
|
360
|
+
const args = callClose > 0 ? src.slice(callOpen + 1, callClose) : "";
|
|
361
|
+
const kind = f[2];
|
|
362
|
+
const dflt = kind === "resource" ? null : ["text", "textarea", "richtext", "url", "color"].includes(kind) ? literalAt(args, 0) : null;
|
|
363
|
+
def.settings.push({ key: f[1], kind, default: dflt, hasLabel: /\blabel\s*:/.test(args), at: o + f.index, resourceKind: kind === "resource" ? literalAt(args, 0) : null });
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
out.push(def);
|
|
368
|
+
}
|
|
369
|
+
return out;
|
|
370
|
+
}
|
|
371
|
+
function stemOf(key) {
|
|
372
|
+
let m = /^(first|second|third|fourth|fifth|sixth|seventh|eighth)([A-Z_]\w*)?$/.exec(key);
|
|
373
|
+
if (m) return `#${(m[2] || "").toLowerCase()}`;
|
|
374
|
+
m = /^([A-Za-z_]+?)_?(\d{1,2})([A-Z]\w*)?$/.exec(key);
|
|
375
|
+
if (m) return `${m[1].toLowerCase()}#${(m[3] || "").toLowerCase()}`;
|
|
376
|
+
return null;
|
|
377
|
+
}
|
|
378
|
+
function checkEditability2(files, opts = {}) {
|
|
379
|
+
const errors = [];
|
|
380
|
+
const warnings = [];
|
|
381
|
+
const add = (sev, code, file, src, at, message, fix) => {
|
|
382
|
+
const { line: line3, column } = lineCol(src, at);
|
|
383
|
+
const list = sev === "error" ? errors : warnings;
|
|
384
|
+
if (list.some((x) => x.code === code && x.file === file && x.line === line3 && x.column === column)) return;
|
|
385
|
+
list.push({ severity: sev, code, file, line: line3, column, message, ...fix ? { fix } : {} });
|
|
386
|
+
};
|
|
387
|
+
let en = opts.locales || null;
|
|
388
|
+
if (!en && typeof files["locales/en.json"] === "string") {
|
|
389
|
+
try {
|
|
390
|
+
en = JSON.parse(files["locales/en.json"]);
|
|
391
|
+
} catch {
|
|
392
|
+
en = null;
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
const flat = {};
|
|
396
|
+
const flatten = (o, p) => {
|
|
397
|
+
if (o && typeof o === "object") for (const [k, v] of Object.entries(o)) flatten(v, p ? `${p}.${k}` : k);
|
|
398
|
+
else if (typeof o === "string") flat[p] = o;
|
|
399
|
+
};
|
|
400
|
+
flatten(en, "");
|
|
401
|
+
const schemaLocale = (lang) => {
|
|
402
|
+
const t = files[`locales/${lang}.schema.json`];
|
|
403
|
+
if (typeof t !== "string") return null;
|
|
404
|
+
try {
|
|
405
|
+
const out = {};
|
|
406
|
+
const walk = (o, p) => {
|
|
407
|
+
if (o && typeof o === "object" && !Array.isArray(o)) for (const [k, v] of Object.entries(o)) walk(v, p ? `${p}.${k}` : k);
|
|
408
|
+
else if (typeof o === "string") out[p] = o;
|
|
409
|
+
};
|
|
410
|
+
walk(JSON.parse(t), "");
|
|
411
|
+
return out;
|
|
412
|
+
} catch {
|
|
413
|
+
return null;
|
|
414
|
+
}
|
|
415
|
+
};
|
|
416
|
+
const schemaEn = schemaLocale("en");
|
|
417
|
+
const labelScan = (file, src, ranges) => {
|
|
418
|
+
const found = [];
|
|
419
|
+
const re = /\b(label|title|description|info|placeholder|group)\s*:\s*(['"])((?:\\.|(?!\2)[^\\\n])*)\2/g;
|
|
420
|
+
let m;
|
|
421
|
+
while (m = re.exec(src)) if (ranges.some(([a, b]) => m.index > a && m.index < b)) found.push({ at: m.index + m[0].length - m[3].length - 1, value: m[3] });
|
|
422
|
+
const pre = /(presets\s*:\s*\[\s*\{|\}\s*,\s*\{)\s*name\s*:\s*(['"])((?:\\.|(?!\2)[^\\\n])*)\2/g;
|
|
423
|
+
while (m = pre.exec(src)) if (ranges.some(([a, b]) => m.index > a && m.index < b) && /presets\s*:/.test(src.slice(Math.max(0, m.index - 2e3), m.index + 12))) found.push({ at: m.index + m[0].length - m[3].length - 1, value: m[3] });
|
|
424
|
+
const ol = /optionLabels\s*:\s*\{([^}]*)\}/g;
|
|
425
|
+
while (m = ol.exec(src)) {
|
|
426
|
+
const inner = /:\s*(['"])((?:\\.|(?!\1)[^\\\n])*)\1/g;
|
|
427
|
+
let v;
|
|
428
|
+
while (v = inner.exec(m[1])) found.push({ at: m.index + m[0].indexOf(m[1]) + v.index + v[0].length - v[2].length - 1, value: v[2] });
|
|
429
|
+
}
|
|
430
|
+
let plain = null;
|
|
431
|
+
for (const f of found) {
|
|
432
|
+
if (f.value.startsWith("t:")) {
|
|
433
|
+
const key = f.value.slice(2);
|
|
434
|
+
if (!schemaEn) add("error", "missing_label_translation", file, src, f.at, `"${f.value}" needs locales/en.schema.json, which the theme does not have (or is not valid JSON).`, `Add locales/en.schema.json with the key ${key} (nested JSON, as the reference's schema locale files).`);
|
|
435
|
+
else if (typeof schemaEn[key] !== "string" || !schemaEn[key].trim()) add("error", "missing_label_translation", file, src, f.at, `"${f.value}" has no English words in locales/en.schema.json.`, `Add "${key}" to locales/en.schema.json.`);
|
|
436
|
+
} else if (f.value.trim() && !plain) plain = f;
|
|
437
|
+
}
|
|
438
|
+
if (plain) add("warning", "label_not_translated", file, src, plain.at, `Labels such as "${plain.value.slice(0, 40)}" are plain English, so a merchant using the editor in another language reads them in English.`, `Write labels as t:<key> (label: 't:labels.heading') with the words in locales/en.schema.json; other languages go in locales/<lang>.schema.json (optional).`);
|
|
439
|
+
};
|
|
440
|
+
if (typeof files["src/settings.ts"] === "string") labelScan("src/settings.ts", files["src/settings.ts"], [[0, files["src/settings.ts"].length]]);
|
|
441
|
+
const sections = [];
|
|
442
|
+
const paths = Object.keys(files || {}).filter((p) => /^src\/.+\.(tsx|jsx|ts)$/.test(p) && typeof files[p] === "string").sort();
|
|
443
|
+
for (const file of paths) {
|
|
444
|
+
const src = files[file];
|
|
445
|
+
const isSectionFile = /^src\/(sections|blocks)\//.test(file) || /\bdefine(Section|Block)\s*\(/.test(src);
|
|
446
|
+
const isMarkupFile = isSectionFile || /^src\/components\//.test(file);
|
|
447
|
+
if (!isMarkupFile || !/\.(tsx|jsx)$/.test(file) && !isSectionFile) continue;
|
|
448
|
+
const s = scan(src);
|
|
449
|
+
const defs = isSectionFile ? definitions(src, s.mask) : [];
|
|
450
|
+
const inConfig = (at) => defs.some((d) => d.settingsRange && at > d.settingsRange[0] && at < d.settingsRange[1]) || defs.some((d) => d.presets && at > d.open && at < d.close && src.slice(d.open, at).lastIndexOf("presets") > src.slice(d.open, at).lastIndexOf("component"));
|
|
451
|
+
const perSection = new Map(defs.filter((d) => d.kind === "section").map((d) => [d, { fixed: 0 }]));
|
|
452
|
+
const owner = (at) => {
|
|
453
|
+
let best = null;
|
|
454
|
+
for (const d of perSection.keys()) if (at >= d.start && at <= d.close) best = d;
|
|
455
|
+
if (!best && perSection.size === 1) best = [...perSection.keys()][0];
|
|
456
|
+
return best;
|
|
457
|
+
};
|
|
458
|
+
const bump = (at) => {
|
|
459
|
+
const d = owner(at);
|
|
460
|
+
if (d) perSection.get(d).fixed++;
|
|
461
|
+
};
|
|
462
|
+
for (const t of s.texts) {
|
|
463
|
+
if (!isWords(t.value)) continue;
|
|
464
|
+
if (SVG_TEXT.has(t.tag) || t.hidden) continue;
|
|
465
|
+
add("error", "literal_text", file, src, t.start, `"${t.value.slice(0, 60)}" is written in the section's code, so the merchant cannot change it in the theme editor.`, `Move it to a setting: heading: field.text(${JSON.stringify(t.value.slice(0, 60))}, { label: 'Heading' }), and render {settings.heading}. Interface words (a cart button, "Search") go through t('key') with the words in locales/en.json and locales/th.json.`);
|
|
466
|
+
bump(t.start);
|
|
467
|
+
}
|
|
468
|
+
for (const e of s.exprs) {
|
|
469
|
+
const v = e.value.trim();
|
|
470
|
+
const lit = /^(['"])(.*)\1$/s.exec(v) || /^`([^`$]*)`$/s.exec(v);
|
|
471
|
+
if (lit && isWords(lit[2] ?? lit[1])) {
|
|
472
|
+
add("error", "literal_text", file, src, e.start, `"${(lit[2] ?? lit[1]).slice(0, 60)}" is written in the section's code.`, "Move it to a text setting and render {settings.<key>}.");
|
|
473
|
+
bump(e.start);
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
for (const a of s.attrs) {
|
|
477
|
+
const lit = a.kind === "literal" ? a.value : a.kind === "expr" ? (() => {
|
|
478
|
+
const v = a.value.trim();
|
|
479
|
+
const m = /^(['"])(.*)\1$/s.exec(v) || /^`([^`$]*)`$/s.exec(v);
|
|
480
|
+
return m ? m[2] ?? m[1] : null;
|
|
481
|
+
})() : null;
|
|
482
|
+
const at = a.kind === "literal" ? a.vstart : a.kind === "expr" ? a.start : a.at;
|
|
483
|
+
if (TEXT_ATTRS.has(a.name) && lit !== null && isWords(lit) && !FORMAT_EXAMPLE.test(lit)) {
|
|
484
|
+
add("error", "literal_text", file, src, at, `${a.name}="${lit.slice(0, 50)}" is written in the code.`, a.name === "alt" ? "Read it from the image's alt, or an imageAlt: field.text(...) setting beside the image." : "Interface words go through t('key') (locales/en.json and locales/th.json); shop copy goes in a text setting.");
|
|
485
|
+
bump(at);
|
|
486
|
+
}
|
|
487
|
+
if (LINK_ATTRS.has(a.name)) {
|
|
488
|
+
if (lit !== null && lit !== "" && !STRUCTURAL_LINK.test(lit)) {
|
|
489
|
+
add("error", "hardcoded_link", file, src, at, `href="${lit.slice(0, 60)}" is fixed in the code, so the merchant cannot point it somewhere else.`, `Add link: field.url(${JSON.stringify(lit)}, { label: 'Link' }) and use href={settings.link}. Links to a product, collection or page come from a resource setting (field.resource('product')) or a menu.`);
|
|
490
|
+
bump(at);
|
|
491
|
+
} else if (a.kind === "expr" && /(\|\||\?\?)\s*['"`][^'"`]*['"`]/.test(a.value) && /settings/.test(a.value)) {
|
|
492
|
+
const fb = /(\|\||\?\?)\s*(['"`])([^'"`]*)\2/.exec(a.value);
|
|
493
|
+
if (fb && fb[3] && !STRUCTURAL_LINK.test(fb[3])) {
|
|
494
|
+
add("error", "hidden_default", file, src, a.start, `This link falls back to "${fb[3]}" when its setting is empty, so the editor shows an empty field for a link that works.`, `Make "${fb[3]}" the setting's default (field.url(${JSON.stringify(fb[3])}, ...)) and use href={settings.<key>} alone.`);
|
|
495
|
+
bump(a.start);
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
if (MEDIA_ATTRS.has(a.name) && lit !== null && lit.trim() !== "") {
|
|
500
|
+
add("error", "hardcoded_image", file, src, at, `${a.name}="${lit.slice(0, 60)}" is an image or video fixed in the code.`, "Add image: field.resource('image', '', { label: 'Image' }) and render <Image image={settings.image} alt={settings.imageAlt} />; upload the picture with theme_upload_asset and put its URL in the template's settings.");
|
|
501
|
+
bump(at);
|
|
502
|
+
}
|
|
503
|
+
if (a.name === "alt" && a.kind === "literal" && a.value === "" && a.tag === "Image") {
|
|
504
|
+
const near = src.slice(Math.max(0, a.at - 200), a.at + 200);
|
|
505
|
+
if (/image=\{\s*(settings|block|b)\b/.test(near)) add("warning", "image_alt", file, src, a.at, `A merchant's image is shown with alt="" and no way to describe it.`, "Add imageAlt: field.text('<what the picture shows>', { label: 'Image description' }) and pass alt={settings.imageAlt}.");
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
const lines = s.mask.split("\n");
|
|
509
|
+
const srcLines = src.split("\n");
|
|
510
|
+
let offset = 0;
|
|
511
|
+
for (let ln = 0; ln < lines.length; ln++) {
|
|
512
|
+
const codeLine = lines[ln];
|
|
513
|
+
const raw = srcLines[ln];
|
|
514
|
+
const patterns = [
|
|
515
|
+
/settings\??\.\s*\??\.?([A-Za-z_$][\w$]*)\b[^;\n]{0,60}?(\|\||\?\?)\s*(t\s*\(|['"`])/g,
|
|
516
|
+
/\b[A-Za-z_$][\w$]*\s*\(\s*(?:String\s*\(\s*)?(?:[\w$]+\.)?settings\??\.\s*([A-Za-z_$][\w$]*)[^,;\n()]*\)?\s*,\s*(t\s*\(|['"`])/g
|
|
517
|
+
];
|
|
518
|
+
for (const re of patterns) {
|
|
519
|
+
re.lastIndex = 0;
|
|
520
|
+
let m;
|
|
521
|
+
while (m = re.exec(codeLine)) {
|
|
522
|
+
const tail = raw.slice(m.index + m[0].length - m[m.length - 1].length);
|
|
523
|
+
const lit = /^(['"`])([^'"`]*)\1/.exec(tail);
|
|
524
|
+
const isT = /^t\s*\(/.test(tail);
|
|
525
|
+
if (!isT && !(lit && isWords(lit[2]))) continue;
|
|
526
|
+
if (!isT && /^[a-z0-9_-]+$/.test(lit[2])) continue;
|
|
527
|
+
if (!isT && /^(\/|#|https?:|mailto:|tel:)/.test(lit[2])) continue;
|
|
528
|
+
if (re === patterns[0] && /^(String|Number)\s*\(/.test(codeLine.slice(m.index - 7, m.index))) {
|
|
529
|
+
}
|
|
530
|
+
const words = isT ? flat[(/t\s*\(\s*['"]([^'"]+)/.exec(tail) || [])[1]] || "a locale string" : lit[2];
|
|
531
|
+
add("error", "hidden_default", file, src, offset + m.index, `When the merchant leaves "${m[1]}" empty the section shows "${String(words).slice(0, 50)}" instead, so the editor's field is empty while the page shows words the merchant cannot find.`, `Make it the setting's default: ${m[1]}: field.text(${JSON.stringify(String(words).slice(0, 60))}, { label: '\u2026' }), render {settings.${m[1]}} alone, and put the same words in the template's settings.`);
|
|
532
|
+
bump(offset + m.index);
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
offset += raw.length + 1;
|
|
536
|
+
}
|
|
537
|
+
const arrays = [];
|
|
538
|
+
for (let k = 0; k < s.mask.length; k++) if (s.mask[k] === "[") {
|
|
539
|
+
const c = matchBracket(s.mask, k);
|
|
540
|
+
if (c > k) arrays.push([k, c]);
|
|
541
|
+
}
|
|
542
|
+
for (const [o, c] of arrays) {
|
|
543
|
+
if (inConfig(o)) continue;
|
|
544
|
+
if (arrays.some(([o2, c2]) => o2 < o && c2 > c)) continue;
|
|
545
|
+
const after = s.mask.slice(c + 1, c + 200);
|
|
546
|
+
let mapped = /^\s*(\.\s*\w+\s*\([^()]*\))*\s*\.\s*map\s*\(/.test(after);
|
|
547
|
+
if (!mapped) {
|
|
548
|
+
const before = s.mask.slice(Math.max(0, o - 60), o);
|
|
549
|
+
const nm = /(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s*(?::[^=]+)?=\s*$/.exec(before);
|
|
550
|
+
if (nm) mapped = new RegExp(`\\b${nm[1]}\\s*(\\.\\s*\\w+\\s*\\([^()]*\\))*\\s*\\.\\s*map\\s*\\(`).test(s.mask.slice(c));
|
|
551
|
+
}
|
|
552
|
+
if (!mapped) continue;
|
|
553
|
+
const inner = s.strings.filter((x) => x.start > o && x.end <= c + 1 && isWords(x.value) && (/[\s-]/.test(x.value) || /^[A-Z]/.test(x.value)));
|
|
554
|
+
const tCalls = (src.slice(o, c + 1).match(/\bt\s*\(\s*['"]/g) || []).length;
|
|
555
|
+
if (inner.length + tCalls >= 2) {
|
|
556
|
+
add("error", "hardcoded_list", file, src, o, `A list of ${inner.length + tCalls} items is written in the code and printed with .map(): the merchant cannot add, remove, reorder or change them.`, "Make each item a block: defineBlock({ type: 'item', title: 'Item', settings: { ... } }), add it to the section's blocks, render the section's blocks in order, and put the items in the preset and the template as blocks.");
|
|
557
|
+
bump(o);
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
{
|
|
561
|
+
const re = /settings\??\.\s*([A-Za-z_$][\w$]*)[^;\n]{0,40}?\.split\s*\(\s*(['"`]\s*[,;|]|\/\s*\[?[,;|])/g;
|
|
562
|
+
let m;
|
|
563
|
+
while (m = re.exec(s.mask.replace(/_/g, ","))) {
|
|
564
|
+
if (/^(collections|products|pages|blogs|articles|menus|handles|tags)$/i.test(m[1])) continue;
|
|
565
|
+
add("error", "packed_list", file, src, m.index, `"${m[1]}" is a list typed into one field and split on commas: the merchant cannot add, remove or reorder its items, or give one its own link or image.`, `Make each item a block (defineBlock({ type: 'item', settings: { text: field.text(\u2026) } })) and render the section's blocks.`);
|
|
566
|
+
bump(m.index);
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
for (const d of defs) {
|
|
570
|
+
const at = d.start;
|
|
571
|
+
if (d.kind === "section" && !d.has.presets && !d.has.zone && !d.has.requires && !TEMPLATE_SECTIONS.has(d.type || "")) {
|
|
572
|
+
add("error", "no_preset", file, src, at, `Section "${d.type}" has no preset, so the merchant cannot add it from "Add section".`, `presets: [{ name: '${d.type}', settings: { ...the sample content }${d.has.blocks ? ", blocks: [{ type: '\u2026', settings: {\u2026} }, \u2026]" : ""} }]`);
|
|
573
|
+
}
|
|
574
|
+
if (d.kind === "section" && d.has.blocks && d.blocksList && /\w/.test(d.blocksList) && d.has.presets && !/\bblocks\s*:/.test(d.presets || "")) {
|
|
575
|
+
add("error", "preset_without_blocks", file, src, at, `Section "${d.type}" takes blocks, but its preset adds none: a merchant who adds it gets an empty section.`, "Add the sample items to the preset: presets: [{ name: \u2026, blocks: [{ type: \u2026, settings: {\u2026} }, { \u2026 }, { \u2026 }] }]");
|
|
576
|
+
}
|
|
577
|
+
const stems = /* @__PURE__ */ new Map();
|
|
578
|
+
for (const st of d.settings) {
|
|
579
|
+
if (!st.hasLabel) add("error", "no_label", file, src, st.at, `Setting "${st.key}" has no label.`, `${st.key}: field.${st.kind}(\u2026, { label: '\u2026' })`);
|
|
580
|
+
const presetSets = d.presets && new RegExp(`\\b${st.key}\\s*:\\s*['"\`][^'"\`]`).test(d.presets);
|
|
581
|
+
if (["text", "textarea", "richtext"].includes(st.kind) && st.default === "" && CONTENT_KEY.test(st.key) && !presetSets) {
|
|
582
|
+
add(d.kind === "section" ? "error" : "warning", "empty_default", file, src, st.at, `Setting "${st.key}" is empty by default, so a newly added "${d.type}" shows nothing (or words from somewhere else).`, `Give it real sample words: ${st.key}: field.${st.kind}('\u2026', { label: '\u2026' }).`);
|
|
583
|
+
}
|
|
584
|
+
const stem = stemOf(st.key);
|
|
585
|
+
if (stem) stems.set(stem, [...stems.get(stem) || [], st]);
|
|
586
|
+
const outside = src.slice(0, d.settingsRange ? d.settingsRange[0] : 0) + src.slice(d.settingsRange ? d.settingsRange[1] : 0);
|
|
587
|
+
if (!KIT_SETTINGS.has(st.key) && !new RegExp(`(\\.|\\[\\s*['"])${st.key}\\b|\\b${st.key}\\s*[,}:]`).test(outside.replace(/presets\s*:[\s\S]*?\]\s*,/g, ""))) {
|
|
588
|
+
add("warning", "unused_setting", file, src, st.at, `Setting "${st.key}" of "${d.type}" is never read, so changing it in the editor changes nothing.`, `Render it, or remove it.`);
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
for (const [, group] of stems) {
|
|
592
|
+
if (group.length >= 2) {
|
|
593
|
+
add("error", "repeated_settings", file, src, group[0].at, `Settings ${group.map((g) => `"${g.key}"`).join(", ")} are numbered copies of one item: the merchant cannot add a third, remove one or reorder them.`, "Make the item a block type with one set of these settings, list it in the section's blocks, and render the blocks in order.");
|
|
594
|
+
bump(group[0].at);
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
if (defs.length) labelScan(file, src, defs.map((d) => [d.open, d.componentAt]));
|
|
599
|
+
if (isSectionFile) {
|
|
600
|
+
const tre = /\bt\s*\(\s*['"]([^'"]+)['"]/g;
|
|
601
|
+
let m;
|
|
602
|
+
while (m = tre.exec(src)) {
|
|
603
|
+
const v = flat[m[1]];
|
|
604
|
+
if (typeof v === "string" && v.split(/\s+/).length >= 8 && !CHROME_KEY.test(m[1])) {
|
|
605
|
+
add("warning", "locale_prose", file, src, m.index, `"${v.slice(0, 50)}\u2026" (${m[1]}) is shop copy kept in the locale files; the merchant edits it only through translations, not in the theme editor.`, "Make it a setting with these words as the default.");
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
for (const [d, v] of perSection) {
|
|
610
|
+
const visible = d.settings.filter((x) => ["text", "textarea", "richtext", "url", "color", "resource"].includes(x.kind)).length;
|
|
611
|
+
sections.push({ file, type: d.type, line: lineCol(src, d.start).line, settings: d.settings.length, editable: visible, fixed: v.fixed, blocks: d.has.blocks, presets: d.has.presets });
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
for (const file of Object.keys(files || {}).filter((p) => /^(templates|regions|groups)\/[^/]+\.json$/.test(p) && typeof files[p] === "string").sort()) {
|
|
615
|
+
let doc;
|
|
616
|
+
try {
|
|
617
|
+
doc = JSON.parse(files[file]);
|
|
618
|
+
} catch {
|
|
619
|
+
continue;
|
|
620
|
+
}
|
|
621
|
+
const seen = /* @__PURE__ */ new Set();
|
|
622
|
+
const visit = (node) => {
|
|
623
|
+
if (!node || typeof node !== "object") return;
|
|
624
|
+
if (Array.isArray(node)) {
|
|
625
|
+
node.forEach(visit);
|
|
626
|
+
return;
|
|
627
|
+
}
|
|
628
|
+
const st = node.settings;
|
|
629
|
+
if (st && typeof st === "object" && !Array.isArray(st) && node.type) {
|
|
630
|
+
const vals = Object.values(st).filter((v) => typeof v === "string");
|
|
631
|
+
const link = vals.find((v) => /^\/products\/[\w-]+\/?$/.test(v));
|
|
632
|
+
const words = vals.some((v) => !/^(\/|https?:|#)/.test(v) && isWords(v));
|
|
633
|
+
if (link && words && !seen.has(node.type)) {
|
|
634
|
+
seen.add(node.type);
|
|
635
|
+
const at = files[file].indexOf(JSON.stringify(link).slice(0, -1));
|
|
636
|
+
add("error", "product_by_hand", file, files[file], Math.max(0, at), `"${node.type}" names a product by hand (${link}) with its own title and picture: the price, stock and picture are not the store's and change nowhere when the product does.`, `Give "${node.type}" a product setting (product: field.resource('product', '', { label: 'Product' })) and show the product's own title, price and image with useProduct(settings.product); for a row of products use a collection setting.`);
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
for (const v of Object.values(node)) if (v && typeof v === "object") visit(v);
|
|
640
|
+
};
|
|
641
|
+
visit(doc);
|
|
642
|
+
}
|
|
643
|
+
if (typeof files["src/settings.ts"] === "string" && !/type\s*:\s*['"]color['"]|field\s*\.\s*color\s*\(/.test(files["src/settings.ts"])) {
|
|
644
|
+
add("error", "no_colour_settings", "src/settings.ts", files["src/settings.ts"], 0, "The theme declares no colour setting, so the merchant cannot change its colours in the editor's Theme panel.", "Add colour settings (colorBackground: { type: 'color', label: 'Background', default: '#ffffff' }, text, accent) and turn them into CSS variables on the page's root with sx() (see the starter's theme.tsx themeVars); read every colour in theme.css from those variables.");
|
|
645
|
+
}
|
|
646
|
+
const editable = sections.reduce((a, x) => a + x.editable, 0);
|
|
647
|
+
const fixed = sections.reduce((a, x) => a + x.fixed, 0);
|
|
648
|
+
const ok = errors.length === 0;
|
|
649
|
+
return {
|
|
650
|
+
ok,
|
|
651
|
+
errors,
|
|
652
|
+
warnings,
|
|
653
|
+
sections,
|
|
654
|
+
score: { editable, fixed, percent: editable + fixed ? Math.round(100 * editable / (editable + fixed)) : 100 },
|
|
655
|
+
summary: ok ? `Editable: every section's words, images and links come from settings or blocks (${editable} settings${warnings.length ? `, ${warnings.length} warning${warnings.length === 1 ? "" : "s"}` : ""}).` : `${errors.length} place${errors.length === 1 ? "" : "s"} where the merchant cannot edit what the shopper sees (${fixed} fixed values against ${editable} settings).`
|
|
656
|
+
};
|
|
657
|
+
}
|
|
658
|
+
var IMAGE_KEY = /image|img|photo|picture|background|logo|poster|banner|cover|thumbnail|avatar|icon|src/i;
|
|
659
|
+
var IMAGE_EXT = /\.(png|jpe?g|webp|gif|avif|svg)(\?[^#]*)?$/i;
|
|
660
|
+
var STORE_HOST = /(^|\.)(tanqory\.(com|dev)|mytanqory\.(com|dev))$/i;
|
|
661
|
+
async function checkImageLinks2(files, opts = {}) {
|
|
662
|
+
const fetchImpl = opts.fetch || globalThis.fetch;
|
|
663
|
+
const timeoutMs = opts.timeoutMs || 8e3;
|
|
664
|
+
const max = opts.max || 60;
|
|
665
|
+
const concurrency = opts.concurrency || 6;
|
|
666
|
+
const errors = [];
|
|
667
|
+
const warnings = [];
|
|
668
|
+
const found = /* @__PURE__ */ new Map();
|
|
669
|
+
const note = (url, file, src) => {
|
|
670
|
+
if (!found.has(url) && found.size < max) found.set(url, { file, src, at: Math.max(0, src.indexOf(url)) });
|
|
671
|
+
};
|
|
672
|
+
for (const [file, text] of Object.entries(files || {}).sort()) {
|
|
673
|
+
if (typeof text !== "string") continue;
|
|
674
|
+
if (/^(templates|regions|groups)\/[^/]+\.json$|^config\/settings\.json$/.test(file)) {
|
|
675
|
+
let doc;
|
|
676
|
+
try {
|
|
677
|
+
doc = JSON.parse(text);
|
|
678
|
+
} catch {
|
|
679
|
+
continue;
|
|
680
|
+
}
|
|
681
|
+
const walk = (v, key) => {
|
|
682
|
+
if (typeof v === "string") {
|
|
683
|
+
if (/^https?:\/\//i.test(v) && (IMAGE_KEY.test(key || "") || IMAGE_EXT.test(v))) note(v, file, text);
|
|
684
|
+
return;
|
|
685
|
+
}
|
|
686
|
+
if (Array.isArray(v)) {
|
|
687
|
+
v.forEach((x) => walk(x, key));
|
|
688
|
+
return;
|
|
689
|
+
}
|
|
690
|
+
if (v && typeof v === "object") for (const [k, x] of Object.entries(v)) walk(x, k);
|
|
691
|
+
};
|
|
692
|
+
walk(doc, "");
|
|
693
|
+
} else if (/^src\/.+\.(tsx|ts|jsx|js)$/.test(file)) {
|
|
694
|
+
const re = /(['"`])(https?:\/\/[^'"`\s]+?\.(?:png|jpe?g|webp|gif|avif|svg)(?:\?[^'"`\s]*)?)\1/gi;
|
|
695
|
+
let m;
|
|
696
|
+
while (m = re.exec(text)) note(m[2], file, text);
|
|
697
|
+
}
|
|
698
|
+
}
|
|
699
|
+
const ask = async (url) => {
|
|
700
|
+
const go = async (method) => {
|
|
701
|
+
const ctl = new AbortController();
|
|
702
|
+
const timer = setTimeout(() => ctl.abort(), timeoutMs);
|
|
703
|
+
try {
|
|
704
|
+
return await fetchImpl(url, { method, redirect: "follow", signal: ctl.signal, headers: method === "GET" ? { range: "bytes=0-0" } : {} });
|
|
705
|
+
} finally {
|
|
706
|
+
clearTimeout(timer);
|
|
707
|
+
}
|
|
708
|
+
};
|
|
709
|
+
try {
|
|
710
|
+
let r = await go("HEAD");
|
|
711
|
+
if (!r.ok) r = await go("GET");
|
|
712
|
+
const type = r.headers && typeof r.headers.get === "function" && r.headers.get("content-type") || "";
|
|
713
|
+
if (!r.ok) return { ok: false, why: `answers ${r.status}` };
|
|
714
|
+
if (type && !/^(image|video)\//i.test(type) && !/octet-stream/i.test(type)) return { ok: false, why: `is ${type.split(";")[0]}, not an image` };
|
|
715
|
+
return { ok: true };
|
|
716
|
+
} catch (e) {
|
|
717
|
+
return { ok: false, why: e && e.name === "AbortError" ? `did not answer within ${timeoutMs / 1e3} s` : "could not be reached" };
|
|
718
|
+
}
|
|
719
|
+
};
|
|
720
|
+
const list = [...found.entries()];
|
|
721
|
+
for (let i = 0; i < list.length; i += concurrency) {
|
|
722
|
+
await Promise.all(list.slice(i, i + concurrency).map(async ([url, where]) => {
|
|
723
|
+
const { line: line3, column } = lineCol(where.src, where.at);
|
|
724
|
+
const r = await ask(url);
|
|
725
|
+
let host = "";
|
|
726
|
+
try {
|
|
727
|
+
host = new URL(url).hostname;
|
|
728
|
+
} catch {
|
|
729
|
+
}
|
|
730
|
+
if (!r.ok) errors.push({ severity: "error", code: "image_not_found", file: where.file, line: line3, column, message: `The image ${url.slice(0, 100)} ${r.why}: the page would show an empty frame.`, fix: "Never guess an image address. Upload the picture with theme_upload_asset (or choose one of the store's files) and use the URL it returns." });
|
|
731
|
+
else if (!STORE_HOST.test(host)) warnings.push({ severity: "warning", code: "image_external", file: where.file, line: line3, column, message: `The image ${url.slice(0, 100)} is on another site (${host}): it can change or disappear.`, fix: "Upload it with theme_upload_asset and use the store file URL it returns." });
|
|
732
|
+
}));
|
|
733
|
+
}
|
|
734
|
+
const sort = (a, b) => (a.file + a.line).localeCompare(b.file + b.line);
|
|
735
|
+
errors.sort(sort);
|
|
736
|
+
warnings.sort(sort);
|
|
737
|
+
return { ok: errors.length === 0, errors, warnings, checked: list.length };
|
|
738
|
+
}
|
|
739
|
+
function formatEditability(result) {
|
|
740
|
+
return [...result.errors, ...result.warnings].map((f) => `${f.file}:${f.line}:${f.column} ${f.severity} ${f.code} ${f.message}${f.fix ? ` Fix: ${f.fix}` : ""}`).join("\n");
|
|
741
|
+
}
|
|
742
|
+
module2.exports = { checkEditability: checkEditability2, checkImageLinks: checkImageLinks2, formatEditability, scanTsx: scan, STRUCTURAL_LINK };
|
|
743
|
+
}
|
|
744
|
+
});
|
|
745
|
+
|
|
746
|
+
// ../theme-standard/lib/source.js
|
|
747
|
+
var require_source = __commonJS({
|
|
748
|
+
"../theme-standard/lib/source.js"(exports2, module2) {
|
|
749
|
+
"use strict";
|
|
750
|
+
var MiB = 1024 * 1024;
|
|
751
|
+
var SOURCE_LIMITS3 = Object.freeze({
|
|
752
|
+
/** partnerThemeVersionCreate's multipart file (api-central). */
|
|
753
|
+
uploadBytes: 20 * MiB,
|
|
754
|
+
maxEntries: 1e4,
|
|
755
|
+
maxUnpackedBytes: 64 * MiB,
|
|
756
|
+
maxFileBytes: 8 * MiB,
|
|
757
|
+
maxArchiveBytes: 100 * MiB,
|
|
758
|
+
/** unpacked / compressed, checked once `ratioCheckAfterBytes` of archive have been read */
|
|
759
|
+
maxCompressionRatio: 100,
|
|
760
|
+
ratioCheckAfterBytes: 4 * MiB
|
|
761
|
+
});
|
|
762
|
+
var DENY_BASENAMES = Object.freeze([".npmrc", ".pnpmfile.cjs", "pnpm-workspace.yaml"]);
|
|
763
|
+
var DENY_SEGMENTS = Object.freeze(["node_modules", ".git", ".github", ".husky"]);
|
|
764
|
+
var basename2 = (path) => path.slice(path.lastIndexOf("/") + 1);
|
|
765
|
+
function denyReason3(path) {
|
|
766
|
+
const base = basename2(path);
|
|
767
|
+
for (const seg of path.split("/")) if (DENY_SEGMENTS.includes(seg)) return `${seg}/ is not accepted`;
|
|
768
|
+
if (DENY_BASENAMES.includes(base)) return `${base} is rejected (pnpm/npm configuration is platform-owned)`;
|
|
769
|
+
if (base.startsWith(".yarnrc")) return `${base} is rejected (yarn configuration is platform-owned)`;
|
|
770
|
+
if (base.startsWith("Dockerfile")) return "Dockerfiles are rejected";
|
|
771
|
+
if (base.startsWith(".env")) return "environment files are rejected";
|
|
772
|
+
if (base.endsWith(".sh")) return "shell scripts are rejected";
|
|
773
|
+
if (base.endsWith(".node")) return "native addons are rejected";
|
|
774
|
+
if (base.endsWith(".wasm") && !path.startsWith("assets/")) return "wasm outside assets/ is rejected";
|
|
775
|
+
return null;
|
|
776
|
+
}
|
|
777
|
+
var DENIED_NAMES = Object.freeze([".npmrc", ".pnpmfile.cjs", "pnpm-workspace.yaml", ".yarnrc*", ".env*", "Dockerfile*", "*.sh", "*.node", "*.wasm outside assets/"]);
|
|
778
|
+
function denyFix2(path) {
|
|
779
|
+
const base = basename2(path);
|
|
780
|
+
if (DENY_BASENAMES.includes(base) || base.startsWith(".yarnrc"))
|
|
781
|
+
return `Delete ${path}: the builder uses its own package manager settings. Nothing in your theme needs it at build time.`;
|
|
782
|
+
if (base.startsWith(".env")) return `Delete ${path} from the upload and keep secrets out of the theme: a storefront theme has no secrets.`;
|
|
783
|
+
if (base.startsWith("Dockerfile")) return `Delete ${path}: the platform builds the theme with its own image.`;
|
|
784
|
+
if (base.endsWith(".sh")) return `Delete ${path}, or rewrite what it does in your build file (a .mjs run with node).`;
|
|
785
|
+
if (base.endsWith(".node")) return `Delete ${path}: native addons cannot run in the sandbox or on the storefront.`;
|
|
786
|
+
if (base.endsWith(".wasm")) return `Move ${path} under assets/, the only place a .wasm file may be.`;
|
|
787
|
+
return `Delete ${path} from the upload.`;
|
|
788
|
+
}
|
|
789
|
+
var THEME_SOURCE_FILES = Object.freeze(["package.json", "pnpm-lock.yaml", "manifest.json"]);
|
|
790
|
+
var THEME_SOURCE_PREFIXES = Object.freeze(["src/", "sections/", "templates/", "layouts/", "assets/", "locales/", "config/"]);
|
|
791
|
+
var THEME_SOURCE_PATTERNS = Object.freeze([/^README[^/]*$/, /^LICENSE[^/]*$/]);
|
|
792
|
+
function isThemeSourcePath2(path) {
|
|
793
|
+
if (THEME_SOURCE_FILES.includes(path)) return true;
|
|
794
|
+
if (THEME_SOURCE_PREFIXES.some((p) => path.startsWith(p))) return true;
|
|
795
|
+
return THEME_SOURCE_PATTERNS.some((re) => re.test(path));
|
|
796
|
+
}
|
|
797
|
+
var THEME_SOURCE_LAYOUT2 = `${THEME_SOURCE_FILES.join(", ")}, README*, LICENSE* and the folders ${THEME_SOURCE_PREFIXES.join(" ")}`;
|
|
798
|
+
var STARTER_DEFAULT_BUILDS = Object.freeze(["scripts/abi/build.mjs", "scripts/build.mjs"]);
|
|
799
|
+
var STARTER_DEFAULT_OUT = "dist/abi";
|
|
800
|
+
var STARTER_PATH_RE = /^(?!\/)(?!.*(?:^|\/)\.\.?(?:\/|$))[A-Za-z0-9._-]+(?:\/[A-Za-z0-9._-]+)*$/;
|
|
801
|
+
var STARTER_IGNORED_FOLDERS = Object.freeze([
|
|
802
|
+
"tests",
|
|
803
|
+
".github",
|
|
804
|
+
".vscode",
|
|
805
|
+
".claude",
|
|
806
|
+
".codex",
|
|
807
|
+
".gemini",
|
|
808
|
+
".cursor",
|
|
809
|
+
".agents",
|
|
810
|
+
".idea",
|
|
811
|
+
"__MACOSX",
|
|
812
|
+
".git",
|
|
813
|
+
"node_modules",
|
|
814
|
+
"dist",
|
|
815
|
+
"reports",
|
|
816
|
+
"coverage"
|
|
817
|
+
]);
|
|
818
|
+
var STARTER_IGNORED_FILES = Object.freeze([".mcp.json", "AGENTS.md", "CLAUDE.md", ".gitignore", "_gitignore", ".DS_Store"]);
|
|
819
|
+
function isStarterIgnoredPath3(path) {
|
|
820
|
+
const first = path.split("/")[0];
|
|
821
|
+
const base = basename2(path);
|
|
822
|
+
return STARTER_IGNORED_FOLDERS.includes(first) || base === ".DS_Store" || base.startsWith("._") || // .tanqory/ holds theme inputs (e.g. the Nova fork's frozen contracts); only the dev server's state is dropped
|
|
823
|
+
path.startsWith(".tanqory/dev/") || STARTER_IGNORED_FILES.includes(path);
|
|
824
|
+
}
|
|
825
|
+
function withoutPackFolder3(files) {
|
|
826
|
+
if (files.length === 0 || !files.every((f) => f.path.startsWith("package/") && f.path.length > 8)) return files;
|
|
827
|
+
return files.map((f) => ({ ...f, path: f.path.slice("package/".length) }));
|
|
828
|
+
}
|
|
829
|
+
var textOf = (f) => f.text !== void 0 ? String(f.text) : Buffer.from(f.bytes).toString("utf8");
|
|
830
|
+
function isStarterTree3(files) {
|
|
831
|
+
if (!files.some((f) => f.path === "manifest.json")) return true;
|
|
832
|
+
const paths = new Set(files.map((f) => f.path));
|
|
833
|
+
if (STARTER_DEFAULT_BUILDS.some((b) => paths.has(b))) return true;
|
|
834
|
+
const pkg = files.find((f) => f.path === "package.json");
|
|
835
|
+
if (!pkg) return false;
|
|
836
|
+
try {
|
|
837
|
+
const tq = JSON.parse(textOf(pkg)).tanqory;
|
|
838
|
+
return typeof (tq && tq.build) === "string";
|
|
839
|
+
} catch {
|
|
840
|
+
return false;
|
|
841
|
+
}
|
|
842
|
+
}
|
|
843
|
+
var THIRD_PARTY_PLATFORM_PACKAGES2 = /* @__PURE__ */ new Map([
|
|
844
|
+
["@tanqory/theme-kit", "runtime"],
|
|
845
|
+
["@tanqory/theme-abi", "runtime"],
|
|
846
|
+
["@tanqory/theme-conformance", "runtime"],
|
|
847
|
+
["@tanqory/cli", "dev"],
|
|
848
|
+
["@tanqory/dev-mcp", "dev"]
|
|
849
|
+
]);
|
|
850
|
+
var PLATFORM_PACKAGE_SECTIONS2 = Object.freeze({ runtime: ["dependencies", "devDependencies"], dev: ["devDependencies"] });
|
|
851
|
+
var EXACT_VERSION_RE3 = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?$/;
|
|
852
|
+
var STARTER_PROVIDED_PACKAGES = /* @__PURE__ */ new Set(["react", "react-dom", "vite", "@vitejs/plugin-react"]);
|
|
853
|
+
var STARTER_DEV_TOOLS = Object.freeze(["typescript", "vitest", "jsdom", "axe-core", "playwright", "playwright-core", "@types/*", "@testing-library/*"]);
|
|
854
|
+
function isStarterDevTool(name) {
|
|
855
|
+
return /^(typescript|vitest|jsdom|axe-core|playwright|playwright-core)$/.test(name) || /^@types\/[a-z0-9._-]+$/.test(name) || /^@testing-library\/[a-z0-9._-]+$/.test(name);
|
|
856
|
+
}
|
|
857
|
+
function isPlainRegistryRange2(spec) {
|
|
858
|
+
if (typeof spec !== "string" || spec.length === 0 || spec.length > 128) return false;
|
|
859
|
+
const comparator = /^(?:[<>]=?|=|~|\^)?v?(?:0|[1-9]\d*|[xX*])(?:\.(?:0|[1-9]\d*|[xX*])){0,2}(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/;
|
|
860
|
+
return spec.split("||").every((set) => {
|
|
861
|
+
const parts = set.trim().split(/\s+/);
|
|
862
|
+
if (parts.length === 1 && parts[0] === "") return false;
|
|
863
|
+
if (parts.length === 3 && parts[1] === "-") return comparator.test(parts[0]) && comparator.test(parts[2]);
|
|
864
|
+
return parts.every((p) => comparator.test(p));
|
|
865
|
+
});
|
|
866
|
+
}
|
|
867
|
+
var DEP_SECTIONS = Object.freeze(["dependencies", "devDependencies", "optionalDependencies", "peerDependencies"]);
|
|
868
|
+
function starterPackageProblems3(pkgOrText, paths) {
|
|
869
|
+
const out = [];
|
|
870
|
+
const add = (kind, message, fix, entry) => out.push({ kind, path: "package.json", message, fix, ...entry ? { entry } : {} });
|
|
871
|
+
let pkg = pkgOrText;
|
|
872
|
+
if (typeof pkg === "string") {
|
|
873
|
+
try {
|
|
874
|
+
pkg = JSON.parse(pkg);
|
|
875
|
+
} catch {
|
|
876
|
+
add("params", "package.json is not valid JSON", "Fix the JSON syntax of package.json.");
|
|
877
|
+
return { problems: out };
|
|
878
|
+
}
|
|
879
|
+
}
|
|
880
|
+
if (!pkg || typeof pkg !== "object" || Array.isArray(pkg)) {
|
|
881
|
+
add("params", "package.json is not valid JSON", "package.json must be one JSON object.");
|
|
882
|
+
return { problems: out };
|
|
883
|
+
}
|
|
884
|
+
if (typeof pkg.name !== "string" || typeof pkg.version !== "string")
|
|
885
|
+
add("params", 'package.json needs string "name" and "version"', 'Set "name" and "version" in package.json.');
|
|
886
|
+
for (const key of ["resolutions", "workspaces", "overrides"])
|
|
887
|
+
if (key in pkg) add("params", `package.json "${key}" is rejected`, `Remove "${key}" from package.json: the builder resolves packages from its own toolchain.`);
|
|
888
|
+
const pnpm = pkg.pnpm && typeof pkg.pnpm === "object" ? pkg.pnpm : {};
|
|
889
|
+
for (const key of ["overrides", "patchedDependencies", "onlyBuiltDependencies"])
|
|
890
|
+
if (key in pnpm) add("params", `package.json "pnpm.${key}" is rejected`, `Remove "pnpm.${key}" from package.json.`);
|
|
891
|
+
const tq = pkg.tanqory === void 0 ? {} : pkg.tanqory;
|
|
892
|
+
if (typeof tq !== "object" || tq === null || Array.isArray(tq)) {
|
|
893
|
+
add("params", 'package.json "tanqory" must be an object', 'Make "tanqory" an object: { "build": "scripts/build.mjs", "out": "dist/abi" }.');
|
|
894
|
+
return { problems: out };
|
|
895
|
+
}
|
|
896
|
+
const build = tq.build !== void 0 ? tq.build : STARTER_DEFAULT_BUILDS.find((b) => paths.has(b)) || STARTER_DEFAULT_BUILDS[1];
|
|
897
|
+
const outDir = tq.out !== void 0 ? tq.out : STARTER_DEFAULT_OUT;
|
|
898
|
+
if (typeof build !== "string" || !STARTER_PATH_RE.test(build) || !build.endsWith(".mjs"))
|
|
899
|
+
add("params", `package.json tanqory.build ${JSON.stringify(build)} must be a relative path to a .mjs file in the theme`, 'Point "tanqory.build" at your build file, e.g. "scripts/build.mjs".');
|
|
900
|
+
else if (!paths.has(build))
|
|
901
|
+
out.push({ kind: "params", path: build, message: `the build file ${build} is not in the upload (package.json tanqory.build, or ${STARTER_DEFAULT_BUILDS.join(" / ")})`, fix: `Add ${build} to the theme, or point package.json "tanqory.build" at the build file you have.` });
|
|
902
|
+
if (typeof outDir !== "string" || !STARTER_PATH_RE.test(outDir))
|
|
903
|
+
add("params", `package.json tanqory.out ${JSON.stringify(outDir)} must be a relative directory in the theme`, 'Set "tanqory.out" to the folder your build writes, e.g. "dist/abi".');
|
|
904
|
+
let kit = false;
|
|
905
|
+
for (const section of DEP_SECTIONS) {
|
|
906
|
+
const deps = pkg[section] && typeof pkg[section] === "object" ? pkg[section] : {};
|
|
907
|
+
for (const [name, spec] of Object.entries(deps)) {
|
|
908
|
+
if (typeof spec !== "string" || !isPlainRegistryRange2(spec)) {
|
|
909
|
+
add("deps", `package.json ${section}.${name}: ${JSON.stringify(spec)} is not a plain registry version range`, `Give ${name} a registry version such as "1.2.3" or "^1.2.3" (no git, file:, link:, workspace: or URL).`, name);
|
|
910
|
+
continue;
|
|
911
|
+
}
|
|
912
|
+
const platform = THIRD_PARTY_PLATFORM_PACKAGES2.get(name);
|
|
913
|
+
if (platform) {
|
|
914
|
+
const allowed = PLATFORM_PACKAGE_SECTIONS2[platform];
|
|
915
|
+
if (!allowed.includes(section)) add("deps", `package.json ${section}.${name}: ${name} may be named only in ${allowed.join(" or ")}`, `Move ${name} to ${allowed[allowed.length - 1]}.`, name);
|
|
916
|
+
else if (!EXACT_VERSION_RE3.test(spec)) add("deps", `package.json ${section}.${name}: ${JSON.stringify(spec)} must be an exact version (e.g. "2.0.0-alpha.3"), not a range`, `Pin ${name} to one exact version, without ^ or ~.`, name);
|
|
917
|
+
if (name === "@tanqory/theme-kit") kit = true;
|
|
918
|
+
continue;
|
|
919
|
+
}
|
|
920
|
+
if (STARTER_PROVIDED_PACKAGES.has(name) && (section === "dependencies" || section === "devDependencies")) continue;
|
|
921
|
+
if (isStarterDevTool(name) && section === "devDependencies") continue;
|
|
922
|
+
add(
|
|
923
|
+
"deps",
|
|
924
|
+
`package.json ${section}.${name}: the builder does not provide ${name} (a starter build uses the kit, react, react-dom, vite and @vitejs/plugin-react from the builder image)`,
|
|
925
|
+
isStarterDevTool(name) ? `Move ${name} to devDependencies.` : `Remove ${name}: copy the code you need into src/ (the builder installs nothing).`,
|
|
926
|
+
name
|
|
927
|
+
);
|
|
928
|
+
}
|
|
929
|
+
}
|
|
930
|
+
if (!kit) add("deps", "package.json must pin @tanqory/theme-kit exactly: it selects the toolchain the build runs with", 'Add "@tanqory/theme-kit" with one exact version to dependencies.', "@tanqory/theme-kit");
|
|
931
|
+
return { problems: out, build, out: outDir };
|
|
932
|
+
}
|
|
933
|
+
var CHECK_FIXES = Object.freeze({
|
|
934
|
+
ingest_gate: "Change the file the finding names: see what an upload may hold (docs.<root>/themes/source/), then upload a new version.",
|
|
935
|
+
sandbox_build: "Pin @tanqory/theme-kit and @tanqory/theme-abi exactly to versions the builder carries, and make the build write the same files every time (no dates, random names or absolute paths), then upload a new version.",
|
|
936
|
+
source_text: "Use your theme's own words in every file name and text file: no other commerce platform's name.",
|
|
937
|
+
editability: "Make every word, image, link and list a shopper sees a setting or a block, with labels in English (the finding's Fix says how).",
|
|
938
|
+
manifest: "Fix the declaration in src/ the manifest is built from, build again and upload the new manifest.json with a new version.",
|
|
939
|
+
manifest_brand_term: "Use your theme's own words in that label.",
|
|
940
|
+
manifest_emoji: "Use words instead of the emoji in that label.",
|
|
941
|
+
no_eval: "Remove eval, new Function and string timers from the client code: pass functions.",
|
|
942
|
+
licences: "Ship a LICENSE file (copied into the build output), and use only packages whose licence is on the allowed list.",
|
|
943
|
+
entry_scan: "Bundle everything server/entry.mjs and preview/entry.mjs import into them: one file each, zero imports.",
|
|
944
|
+
abi_conformance: "Run the ABI conformance suites locally (tanqory-partner theme check --conformance) and fix each failing case.",
|
|
945
|
+
network_allowlist: "Declare every outside origin the theme calls as a network:<https origin> capability, and call no other.",
|
|
946
|
+
budgets: "Make the theme smaller and faster: split the client code, drop unused code and assets, fewer data calls per render.",
|
|
947
|
+
accessibility: "Fix each serious or critical axe-core finding (labels, contrast, landmarks) on home, product and collection pages.",
|
|
948
|
+
preview_renders: "Make every route and section preview render on the three sample stores (small, large, right to left) without an error."
|
|
949
|
+
});
|
|
950
|
+
module2.exports = {
|
|
951
|
+
SOURCE_LIMITS: SOURCE_LIMITS3,
|
|
952
|
+
DENY_BASENAMES,
|
|
953
|
+
DENY_SEGMENTS,
|
|
954
|
+
DENIED_NAMES,
|
|
955
|
+
denyReason: denyReason3,
|
|
956
|
+
denyFix: denyFix2,
|
|
957
|
+
THEME_SOURCE_FILES,
|
|
958
|
+
THEME_SOURCE_PREFIXES,
|
|
959
|
+
THEME_SOURCE_PATTERNS,
|
|
960
|
+
THEME_SOURCE_LAYOUT: THEME_SOURCE_LAYOUT2,
|
|
961
|
+
isThemeSourcePath: isThemeSourcePath2,
|
|
962
|
+
STARTER_DEFAULT_BUILDS,
|
|
963
|
+
STARTER_DEFAULT_OUT,
|
|
964
|
+
STARTER_PATH_RE,
|
|
965
|
+
STARTER_IGNORED_FOLDERS,
|
|
966
|
+
STARTER_IGNORED_FILES,
|
|
967
|
+
isStarterIgnoredPath: isStarterIgnoredPath3,
|
|
968
|
+
withoutPackFolder: withoutPackFolder3,
|
|
969
|
+
isStarterTree: isStarterTree3,
|
|
970
|
+
THIRD_PARTY_PLATFORM_PACKAGES: THIRD_PARTY_PLATFORM_PACKAGES2,
|
|
971
|
+
PLATFORM_PACKAGE_SECTIONS: PLATFORM_PACKAGE_SECTIONS2,
|
|
972
|
+
EXACT_VERSION_RE: EXACT_VERSION_RE3,
|
|
973
|
+
STARTER_PROVIDED_PACKAGES,
|
|
974
|
+
STARTER_DEV_TOOLS,
|
|
975
|
+
isStarterDevTool,
|
|
976
|
+
isPlainRegistryRange: isPlainRegistryRange2,
|
|
977
|
+
starterPackageProblems: starterPackageProblems3,
|
|
978
|
+
CHECK_FIXES
|
|
979
|
+
};
|
|
980
|
+
}
|
|
981
|
+
});
|
|
982
|
+
|
|
983
|
+
// ../theme-standard/lib/text-rules.js
|
|
984
|
+
var require_text_rules = __commonJS({
|
|
985
|
+
"../theme-standard/lib/text-rules.js"(exports2, module2) {
|
|
986
|
+
"use strict";
|
|
987
|
+
var BRAND_RE = new RegExp(Buffer.from("c2hvcGlmeQ==", "base64").toString(), "i");
|
|
988
|
+
var EMOJI = /([\p{Extended_Pictographic}\u{1F1E6}-\u{1F1FF}])(\u{FE0F})?/gu;
|
|
989
|
+
var TEXT_FORM_ALLOWED = /* @__PURE__ */ new Set(["\xA9", "\xAE", "\u2122"]);
|
|
990
|
+
var LABEL_KEYS = /* @__PURE__ */ new Set(["name", "title", "label", "info", "placeholder", "description"]);
|
|
991
|
+
var namesBrandTerm2 = (text) => BRAND_RE.test(text);
|
|
992
|
+
var brandTermIndex = (text) => text.search(BRAND_RE);
|
|
993
|
+
function firstEmoji(text) {
|
|
994
|
+
for (const m of text.matchAll(EMOJI)) {
|
|
995
|
+
const [, ch, vs] = m;
|
|
996
|
+
if (!vs && TEXT_FORM_ALLOWED.has(ch)) continue;
|
|
997
|
+
return `U+${ch.codePointAt(0).toString(16).toUpperCase().padStart(4, "0")}`;
|
|
998
|
+
}
|
|
999
|
+
return null;
|
|
1000
|
+
}
|
|
1001
|
+
var hasEmoji2 = (text) => firstEmoji(text) !== null;
|
|
1002
|
+
function textFindings(entries) {
|
|
1003
|
+
const out = [];
|
|
1004
|
+
for (const [path, text] of entries) {
|
|
1005
|
+
if (namesBrandTerm2(text)) out.push({ rule: "brand_term", path, message: "Names another commerce platform. Use your theme's own words." });
|
|
1006
|
+
const e = firstEmoji(text);
|
|
1007
|
+
if (e) out.push({ rule: "emoji", path, message: `Contains an emoji (${e}). Use words; Tanqory's editor and Theme Store show no emoji.` });
|
|
1008
|
+
}
|
|
1009
|
+
return out;
|
|
1010
|
+
}
|
|
1011
|
+
function manifestLabels2(manifest) {
|
|
1012
|
+
const out = [];
|
|
1013
|
+
const walk = (v, path, key) => {
|
|
1014
|
+
if (out.length >= 1e4) return;
|
|
1015
|
+
if (typeof v === "string") {
|
|
1016
|
+
if (key !== null && LABEL_KEYS.has(key)) out.push([path || "/", v]);
|
|
1017
|
+
} else if (Array.isArray(v)) v.forEach((x, i) => walk(x, `${path}/${i}`, key));
|
|
1018
|
+
else if (v && typeof v === "object") for (const [k, x] of Object.entries(v)) walk(x, `${path}/${k.replace(/~/g, "~0").replace(/\//g, "~1")}`, k);
|
|
1019
|
+
};
|
|
1020
|
+
walk(manifest, "", null);
|
|
1021
|
+
return out;
|
|
1022
|
+
}
|
|
1023
|
+
function sourceTextFindings2(files, max = 50) {
|
|
1024
|
+
const out = [];
|
|
1025
|
+
for (const [path, bytes] of files) {
|
|
1026
|
+
if (out.length >= max) break;
|
|
1027
|
+
const buf = Buffer.from(bytes);
|
|
1028
|
+
if (namesBrandTerm2(path)) {
|
|
1029
|
+
out.push({ path, code: "brand_term", message: `The file name ${path} names another commerce platform. Rename it.` });
|
|
1030
|
+
continue;
|
|
1031
|
+
}
|
|
1032
|
+
if (buf.subarray(0, 8192).includes(0)) continue;
|
|
1033
|
+
const text = buf.toString("utf8");
|
|
1034
|
+
const i = brandTermIndex(text);
|
|
1035
|
+
if (i >= 0) {
|
|
1036
|
+
const line3 = text.slice(0, i).split("\n").length;
|
|
1037
|
+
out.push({ path: `${path}:${line3}`, code: "brand_term", message: `${path} line ${line3} names another commerce platform. Use your theme's own words.` });
|
|
1038
|
+
}
|
|
1039
|
+
}
|
|
1040
|
+
return out;
|
|
1041
|
+
}
|
|
1042
|
+
module2.exports = { LABEL_KEYS, namesBrandTerm: namesBrandTerm2, brandTermIndex, firstEmoji, hasEmoji: hasEmoji2, textFindings, manifestLabels: manifestLabels2, sourceTextFindings: sourceTextFindings2 };
|
|
1043
|
+
}
|
|
1044
|
+
});
|
|
1045
|
+
|
|
31
1046
|
// ../../apps/build-service/src/review/partner-source.ts
|
|
32
1047
|
var partner_source_exports = {};
|
|
33
1048
|
__export(partner_source_exports, {
|
|
34
|
-
|
|
1049
|
+
SOURCE_LIMITS: () => import_source3.SOURCE_LIMITS,
|
|
1050
|
+
budgetsLine: () => budgetsLine,
|
|
1051
|
+
checkPartnerSource: () => checkPartnerSource,
|
|
1052
|
+
denyFix: () => import_source3.denyFix,
|
|
1053
|
+
denyReason: () => import_source3.denyReason,
|
|
1054
|
+
editabilityLine: () => editabilityLine,
|
|
1055
|
+
entryScanLine: () => entryScanLine,
|
|
1056
|
+
isStarterIgnoredPath: () => import_source3.isStarterIgnoredPath,
|
|
1057
|
+
isStarterTree: () => import_source3.isStarterTree,
|
|
1058
|
+
localSandboxLines: () => localSandboxLines,
|
|
1059
|
+
networkLine: () => networkLine,
|
|
1060
|
+
reproducibleLine: () => reproducibleLine,
|
|
1061
|
+
starterPackageProblems: () => import_source3.starterPackageProblems,
|
|
1062
|
+
treeDigest: () => treeDigest,
|
|
1063
|
+
withoutPackFolder: () => import_source3.withoutPackFolder
|
|
35
1064
|
});
|
|
36
1065
|
module.exports = __toCommonJS(partner_source_exports);
|
|
37
1066
|
var import_node_fs4 = require("node:fs");
|
|
38
1067
|
var import_node_path4 = require("node:path");
|
|
39
1068
|
var import_node_stream = require("node:stream");
|
|
40
|
-
var
|
|
1069
|
+
var import_theme_abi3 = require("@tanqory/theme-abi");
|
|
1070
|
+
var import_editability = __toESM(require_editability());
|
|
41
1071
|
|
|
42
1072
|
// ../../apps/build-service/src/artifact/digest.ts
|
|
43
1073
|
var import_node_crypto = require("node:crypto");
|
|
@@ -76,6 +1106,42 @@ function splitPackageKey(key) {
|
|
|
76
1106
|
if (at <= 0) throw new LockfileParseError(`unparseable package key: ${key}`);
|
|
77
1107
|
return { name: key.slice(0, at), version: key.slice(at + 1) };
|
|
78
1108
|
}
|
|
1109
|
+
var DEPENDENCY_PATH_RE = /^(?:@[a-z0-9~-][a-z0-9._~-]*\/)?[a-z0-9~-][a-z0-9._~-]*@/i;
|
|
1110
|
+
var packageIdOf = (path) => {
|
|
1111
|
+
const paren = path.indexOf("(");
|
|
1112
|
+
return paren >= 0 ? path.slice(0, paren) : path;
|
|
1113
|
+
};
|
|
1114
|
+
function pnpmShippedIds(lockfileVersion, importer, rawSnapshots, rawPackages) {
|
|
1115
|
+
const major = Number.parseInt(lockfileVersion, 10);
|
|
1116
|
+
if (!Number.isFinite(major) || major < 9) return null;
|
|
1117
|
+
const ids = Object.keys(rawPackages);
|
|
1118
|
+
if (ids.length === 0) return /* @__PURE__ */ new Set();
|
|
1119
|
+
if (!rawSnapshots || typeof rawSnapshots !== "object") return null;
|
|
1120
|
+
const snapshots = rawSnapshots;
|
|
1121
|
+
const pathOf = (name, version) => DEPENDENCY_PATH_RE.test(version) ? version : `${name}@${version}`;
|
|
1122
|
+
const stack = [];
|
|
1123
|
+
for (const section of ["dependencies", "optionalDependencies"]) {
|
|
1124
|
+
const deps = importer[section] ?? {};
|
|
1125
|
+
for (const [name, spec] of Object.entries(deps))
|
|
1126
|
+
stack.push(pathOf(name, typeof spec === "string" ? spec : String(spec?.version ?? "")));
|
|
1127
|
+
}
|
|
1128
|
+
const known = new Set(ids);
|
|
1129
|
+
const seen = /* @__PURE__ */ new Set();
|
|
1130
|
+
while (stack.length > 0) {
|
|
1131
|
+
const path = stack.pop();
|
|
1132
|
+
if (seen.has(path)) continue;
|
|
1133
|
+
seen.add(path);
|
|
1134
|
+
if (!Object.prototype.hasOwnProperty.call(snapshots, path)) {
|
|
1135
|
+
if (known.has(packageIdOf(path))) return null;
|
|
1136
|
+
continue;
|
|
1137
|
+
}
|
|
1138
|
+
const entry = snapshots[path] ?? {};
|
|
1139
|
+
for (const section of ["dependencies", "optionalDependencies"])
|
|
1140
|
+
for (const [name, version] of Object.entries(entry[section] ?? {}))
|
|
1141
|
+
stack.push(pathOf(name, String(version)));
|
|
1142
|
+
}
|
|
1143
|
+
return new Set([...seen].map(packageIdOf));
|
|
1144
|
+
}
|
|
79
1145
|
function parsePnpmLockfile(bytes) {
|
|
80
1146
|
let doc;
|
|
81
1147
|
try {
|
|
@@ -88,8 +1154,11 @@ function parsePnpmLockfile(bytes) {
|
|
|
88
1154
|
const root = doc;
|
|
89
1155
|
const lockfileVersion = String(root["lockfileVersion"] ?? "");
|
|
90
1156
|
if (!lockfileVersion) throw new LockfileParseError("pnpm-lock.yaml has no lockfileVersion");
|
|
91
|
-
const packages = [];
|
|
92
1157
|
const rawPackages = root["packages"] ?? {};
|
|
1158
|
+
const importers = root["importers"] ?? {};
|
|
1159
|
+
const importer = importers["."] ?? {};
|
|
1160
|
+
const shipped = pnpmShippedIds(lockfileVersion, importer, root["snapshots"], rawPackages);
|
|
1161
|
+
const packages = [];
|
|
93
1162
|
for (const [key, entry] of Object.entries(rawPackages)) {
|
|
94
1163
|
const { name, version } = splitPackageKey(key);
|
|
95
1164
|
const resolution = entry?.["resolution"] ?? {};
|
|
@@ -97,12 +1166,11 @@ function parsePnpmLockfile(bytes) {
|
|
|
97
1166
|
name,
|
|
98
1167
|
version,
|
|
99
1168
|
...typeof resolution["integrity"] === "string" ? { integrity: resolution["integrity"] } : {},
|
|
100
|
-
...typeof resolution["tarball"] === "string" ? { tarball: resolution["tarball"] } : {}
|
|
1169
|
+
...typeof resolution["tarball"] === "string" ? { tarball: resolution["tarball"] } : {},
|
|
1170
|
+
...shipped && !shipped.has(key) ? { dev: true } : {}
|
|
101
1171
|
});
|
|
102
1172
|
}
|
|
103
1173
|
const rootDependencies = {};
|
|
104
|
-
const importers = root["importers"] ?? {};
|
|
105
|
-
const importer = importers["."] ?? {};
|
|
106
1174
|
for (const section of ["dependencies", "optionalDependencies", "devDependencies"]) {
|
|
107
1175
|
const deps = importer[section] ?? {};
|
|
108
1176
|
for (const [name, spec] of Object.entries(deps)) {
|
|
@@ -171,7 +1239,12 @@ function buildCycloneDxSbom(input) {
|
|
|
171
1239
|
version: p.version,
|
|
172
1240
|
purl: purlOf(p.name, p.version),
|
|
173
1241
|
"bom-ref": purlOf(p.name, p.version),
|
|
174
|
-
...hash ? { hashes: [hash] } : {}
|
|
1242
|
+
...hash ? { hashes: [hash] } : {},
|
|
1243
|
+
// CycloneDX 1.6 `component.scope` (bom-1.6.schema.json): "excluded" documents "component usage for test and
|
|
1244
|
+
// other non-runtime purposes. Excluded components are not reachable within a call graph at runtime"; absent
|
|
1245
|
+
// means "required". Only a dev-only package carries it, so an SBOM of a lockfile with none is byte-identical
|
|
1246
|
+
// to before (DECISIONS row 185).
|
|
1247
|
+
...p.dev ? { scope: "excluded" } : {}
|
|
175
1248
|
};
|
|
176
1249
|
}).sort((a, b) => a.purl < b.purl ? -1 : a.purl > b.purl ? 1 : 0);
|
|
177
1250
|
const direct = Object.entries(input.lockfile.rootDependencies).map(([name, version]) => purlOf(name, version)).sort();
|
|
@@ -203,14 +1276,21 @@ function serializeSbom(input) {
|
|
|
203
1276
|
var ApiException = class extends Error {
|
|
204
1277
|
constructor(errorCode, options = {}) {
|
|
205
1278
|
super(options.message || String(errorCode));
|
|
206
|
-
|
|
207
|
-
|
|
1279
|
+
const code = String(errorCode).toLowerCase().replace(/\s+/g, "_");
|
|
1280
|
+
const status = options.httpStatus ?? 500;
|
|
1281
|
+
this.errorCode = code;
|
|
1282
|
+
this.httpStatus = status;
|
|
208
1283
|
this.param = options.param;
|
|
209
1284
|
this.details = options.details;
|
|
1285
|
+
this.errorType = status >= 500 ? "api_error" : "invalid_request_error";
|
|
1286
|
+
this.response = { error: { type: this.errorType, code, message: this.message, status, param: options.param, details: options.details } };
|
|
210
1287
|
}
|
|
211
1288
|
getStatus() {
|
|
212
1289
|
return this.httpStatus;
|
|
213
1290
|
}
|
|
1291
|
+
getResponse() {
|
|
1292
|
+
return this.response;
|
|
1293
|
+
}
|
|
214
1294
|
};
|
|
215
1295
|
|
|
216
1296
|
// ../../apps/build-service/src/common/errors/build-service-errors.ts
|
|
@@ -344,6 +1424,7 @@ function allowlistProblem(allowlist, name, version, integrity) {
|
|
|
344
1424
|
// ../../apps/build-service/src/config/third-party.ts
|
|
345
1425
|
var import_node_fs2 = require("node:fs");
|
|
346
1426
|
var import_node_path2 = require("node:path");
|
|
1427
|
+
var import_source = __toESM(require_source());
|
|
347
1428
|
|
|
348
1429
|
// ../../apps/build-service/src/config/first-party-themes.ts
|
|
349
1430
|
var FIRST_PARTY_THEMES = Object.freeze([
|
|
@@ -374,14 +1455,6 @@ var FIRST_PARTY_THEMES = Object.freeze([
|
|
|
374
1455
|
]);
|
|
375
1456
|
|
|
376
1457
|
// ../../apps/build-service/src/config/third-party.ts
|
|
377
|
-
var THIRD_PARTY_PLATFORM_PACKAGES = /* @__PURE__ */ new Map([
|
|
378
|
-
["@tanqory/theme-kit", "runtime"],
|
|
379
|
-
["@tanqory/theme-abi", "runtime"],
|
|
380
|
-
["@tanqory/theme-conformance", "runtime"],
|
|
381
|
-
["@tanqory/cli", "dev"],
|
|
382
|
-
["@tanqory/dev-mcp", "dev"]
|
|
383
|
-
]);
|
|
384
|
-
var EXACT_VERSION_RE = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?$/;
|
|
385
1458
|
var THIRD_PARTY_TOOLCHAINS_PATH = (0, import_node_path2.join)(
|
|
386
1459
|
__dirname,
|
|
387
1460
|
"..",
|
|
@@ -395,7 +1468,7 @@ function loadThirdPartyKits(path = THIRD_PARTY_TOOLCHAINS_PATH) {
|
|
|
395
1468
|
throw new Error(`${path}: kits must be a non-empty list`);
|
|
396
1469
|
const seen = /* @__PURE__ */ new Set();
|
|
397
1470
|
return doc.kits.map((k) => {
|
|
398
|
-
if (typeof k.version !== "string" || !EXACT_VERSION_RE.test(k.version) || !k.version.startsWith("2."))
|
|
1471
|
+
if (typeof k.version !== "string" || !import_source.EXACT_VERSION_RE.test(k.version) || !k.version.startsWith("2."))
|
|
399
1472
|
throw new Error(`${path}: ${JSON.stringify(k.version)} is not an exact 2.x version`);
|
|
400
1473
|
if (seen.has(k.version)) throw new Error(`${path}: ${k.version} is listed twice`);
|
|
401
1474
|
seen.add(k.version);
|
|
@@ -414,36 +1487,6 @@ function loadThirdPartyKits(path = THIRD_PARTY_TOOLCHAINS_PATH) {
|
|
|
414
1487
|
});
|
|
415
1488
|
}
|
|
416
1489
|
var STARTER_ABI_VERSION = "2.0";
|
|
417
|
-
var STARTER_DEFAULT_BUILDS = ["scripts/abi/build.mjs", "scripts/build.mjs"];
|
|
418
|
-
var STARTER_DEFAULT_OUT = "dist/abi";
|
|
419
|
-
var STARTER_PATH_RE = /^(?!\/)(?!.*(?:^|\/)\.\.?(?:\/|$))[A-Za-z0-9._-]+(?:\/[A-Za-z0-9._-]+)*$/;
|
|
420
|
-
var STARTER_PROVIDED_PACKAGES = /* @__PURE__ */ new Set([
|
|
421
|
-
"react",
|
|
422
|
-
"react-dom",
|
|
423
|
-
"vite",
|
|
424
|
-
"@vitejs/plugin-react"
|
|
425
|
-
]);
|
|
426
|
-
function isStarterDevTool(name) {
|
|
427
|
-
return /^(typescript|vitest|jsdom|axe-core|playwright|playwright-core)$/.test(name) || /^@types\/[a-z0-9._-]+$/.test(name) || /^@testing-library\/[a-z0-9._-]+$/.test(name);
|
|
428
|
-
}
|
|
429
|
-
function isStarterIgnoredPath(path) {
|
|
430
|
-
const first = path.split("/")[0];
|
|
431
|
-
return [
|
|
432
|
-
"tests",
|
|
433
|
-
".github",
|
|
434
|
-
".vscode",
|
|
435
|
-
".claude",
|
|
436
|
-
".codex",
|
|
437
|
-
".gemini",
|
|
438
|
-
".cursor",
|
|
439
|
-
".git",
|
|
440
|
-
"node_modules",
|
|
441
|
-
"dist",
|
|
442
|
-
"reports",
|
|
443
|
-
"coverage"
|
|
444
|
-
].includes(first) || // .tanqory/ holds theme inputs (e.g. the Nova fork's frozen contracts); only the dev server's state is dropped
|
|
445
|
-
path.startsWith(".tanqory/dev/") || [".mcp.json", "AGENTS.md", "CLAUDE.md", ".gitignore", "_gitignore", ".DS_Store"].includes(path);
|
|
446
|
-
}
|
|
447
1490
|
|
|
448
1491
|
// ../../apps/build-service/src/ingest/archive-guard.ts
|
|
449
1492
|
var import_node_crypto3 = require("node:crypto");
|
|
@@ -537,28 +1580,16 @@ function leavesOf(files) {
|
|
|
537
1580
|
}
|
|
538
1581
|
|
|
539
1582
|
// ../../apps/build-service/src/ingest/ingest-gate.ts
|
|
1583
|
+
var import_source2 = __toESM(require_source());
|
|
540
1584
|
var INGEST_LIMITS = Object.freeze({
|
|
541
|
-
maxEntries:
|
|
542
|
-
maxUnpackedBytes:
|
|
543
|
-
maxFileBytes:
|
|
544
|
-
maxArchiveBytes:
|
|
1585
|
+
maxEntries: import_source2.SOURCE_LIMITS.maxEntries,
|
|
1586
|
+
maxUnpackedBytes: import_source2.SOURCE_LIMITS.maxUnpackedBytes,
|
|
1587
|
+
maxFileBytes: import_source2.SOURCE_LIMITS.maxFileBytes,
|
|
1588
|
+
maxArchiveBytes: import_source2.SOURCE_LIMITS.maxArchiveBytes,
|
|
545
1589
|
/** unpacked / compressed, checked once ≥ ratioCheckAfterBytes of archive have been read */
|
|
546
|
-
maxCompressionRatio:
|
|
547
|
-
ratioCheckAfterBytes:
|
|
1590
|
+
maxCompressionRatio: import_source2.SOURCE_LIMITS.maxCompressionRatio,
|
|
1591
|
+
ratioCheckAfterBytes: import_source2.SOURCE_LIMITS.ratioCheckAfterBytes
|
|
548
1592
|
});
|
|
549
|
-
var DENY_BASENAMES = /* @__PURE__ */ new Set([".npmrc", ".pnpmfile.cjs", "pnpm-workspace.yaml"]);
|
|
550
|
-
var DENY_SEGMENTS = /* @__PURE__ */ new Set(["node_modules", ".git", ".github", ".husky"]);
|
|
551
|
-
var ALLOW_FILES = /* @__PURE__ */ new Set(["package.json", "pnpm-lock.yaml", "manifest.json"]);
|
|
552
|
-
var ALLOW_PREFIXES = [
|
|
553
|
-
"src/",
|
|
554
|
-
"sections/",
|
|
555
|
-
"templates/",
|
|
556
|
-
"layouts/",
|
|
557
|
-
"assets/",
|
|
558
|
-
"locales/",
|
|
559
|
-
"config/"
|
|
560
|
-
];
|
|
561
|
-
var ALLOW_PATTERNS = [/^README[^/]*$/, /^LICENSE[^/]*$/];
|
|
562
1593
|
var FLATTENED_PREFIXES = ["locales/", "config/templates/", "config/regions/"];
|
|
563
1594
|
var TOOLCHAIN_EXACT = /* @__PURE__ */ new Set([
|
|
564
1595
|
"vite",
|
|
@@ -576,48 +1607,10 @@ var VITE_IMPORT_ALLOW = [/^vite$/, /^@tanqory\/vite-plugin-[a-z0-9-]+$/, /^node:
|
|
|
576
1607
|
function isToolchainPackage(name) {
|
|
577
1608
|
return TOOLCHAIN_EXACT.has(name) || TOOLCHAIN_PREFIXES.some((p) => name.startsWith(p));
|
|
578
1609
|
}
|
|
579
|
-
var PLATFORM_PACKAGE_SECTIONS = {
|
|
580
|
-
runtime: ["dependencies", "devDependencies"],
|
|
581
|
-
dev: ["devDependencies"]
|
|
582
|
-
};
|
|
583
1610
|
function basename(path) {
|
|
584
1611
|
return path.slice(path.lastIndexOf("/") + 1);
|
|
585
1612
|
}
|
|
586
|
-
function denyReason(path) {
|
|
587
|
-
const base = basename(path);
|
|
588
|
-
const segments = path.split("/");
|
|
589
|
-
for (const seg of segments) {
|
|
590
|
-
if (DENY_SEGMENTS.has(seg)) return `${seg}/ is not accepted`;
|
|
591
|
-
}
|
|
592
|
-
if (DENY_BASENAMES.has(base))
|
|
593
|
-
return `${base} is rejected (pnpm/npm configuration is platform-owned)`;
|
|
594
|
-
if (base.startsWith(".yarnrc"))
|
|
595
|
-
return `${base} is rejected (yarn configuration is platform-owned)`;
|
|
596
|
-
if (base.startsWith("Dockerfile")) return "Dockerfiles are rejected";
|
|
597
|
-
if (base.startsWith(".env")) return "environment files are rejected";
|
|
598
|
-
if (base.endsWith(".sh")) return "shell scripts are rejected";
|
|
599
|
-
if (base.endsWith(".node")) return "native addons are rejected";
|
|
600
|
-
if (base.endsWith(".wasm") && !path.startsWith("assets/"))
|
|
601
|
-
return "wasm outside assets/ is rejected";
|
|
602
|
-
return null;
|
|
603
|
-
}
|
|
604
|
-
function isAllowed(path) {
|
|
605
|
-
if (ALLOW_FILES.has(path)) return true;
|
|
606
|
-
if (ALLOW_PREFIXES.some((p) => path.startsWith(p))) return true;
|
|
607
|
-
return ALLOW_PATTERNS.some((re) => re.test(path));
|
|
608
|
-
}
|
|
609
1613
|
var IMPORT_SPECIFIER_RE = /(?:\bimport\s*(?:[\w*{}\s,$]*\bfrom\s*)?|\bexport\s+[\w*{}\s,$]*\bfrom\s*|\brequire\s*\(\s*|\bimport\s*\(\s*)['"]([^'"]+)['"]/g;
|
|
610
|
-
function isPlainRegistryRange(spec) {
|
|
611
|
-
if (typeof spec !== "string" || spec.length === 0 || spec.length > 128) return false;
|
|
612
|
-
const comparator = /^(?:[<>]=?|=|~|\^)?v?(?:0|[1-9]\d*|[xX*])(?:\.(?:0|[1-9]\d*|[xX*])){0,2}(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/;
|
|
613
|
-
return spec.split("||").every((set) => {
|
|
614
|
-
const parts = set.trim().split(/\s+/);
|
|
615
|
-
if (parts.length === 1 && parts[0] === "") return false;
|
|
616
|
-
if (parts.length === 3 && parts[1] === "-")
|
|
617
|
-
return comparator.test(parts[0]) && comparator.test(parts[2]);
|
|
618
|
-
return parts.every((p) => comparator.test(p));
|
|
619
|
-
});
|
|
620
|
-
}
|
|
621
1614
|
function registryVersionOf(version) {
|
|
622
1615
|
const m = /^(\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?)(\(.+\))*$/.exec(version);
|
|
623
1616
|
return m ? m[1] : void 0;
|
|
@@ -642,9 +1635,9 @@ var IngestGate = class {
|
|
|
642
1635
|
constructor(opts) {
|
|
643
1636
|
this.opts = opts;
|
|
644
1637
|
}
|
|
645
|
-
inspect(
|
|
646
|
-
|
|
647
|
-
|
|
1638
|
+
inspect(raw) {
|
|
1639
|
+
const input = this.opts.thirdParty ? (0, import_source2.withoutPackFolder)(raw) : raw;
|
|
1640
|
+
if (this.opts.thirdParty && (0, import_source2.isStarterTree)(input)) return this.inspectStarter(input);
|
|
648
1641
|
const files = sortLeaves(input);
|
|
649
1642
|
if (files.length > INGEST_LIMITS.maxEntries) {
|
|
650
1643
|
throw new IngestRejectedError(
|
|
@@ -681,7 +1674,7 @@ var IngestGate = class {
|
|
|
681
1674
|
if (seen.has(f.path))
|
|
682
1675
|
throw new IngestRejectedError("params", `duplicate path ${f.path}`, f.path);
|
|
683
1676
|
seen.add(f.path);
|
|
684
|
-
const deny = denyReason(f.path);
|
|
1677
|
+
const deny = (0, import_source2.denyReason)(f.path);
|
|
685
1678
|
if (deny) throw new IngestRejectedError("params", `${f.path}: ${deny}`, f.path);
|
|
686
1679
|
const base = basename(f.path);
|
|
687
1680
|
if (/^vite(st)?\.config\./.test(base)) {
|
|
@@ -694,10 +1687,10 @@ var IngestGate = class {
|
|
|
694
1687
|
);
|
|
695
1688
|
}
|
|
696
1689
|
}
|
|
697
|
-
if (!
|
|
1690
|
+
if (!(0, import_source2.isThemeSourcePath)(f.path)) {
|
|
698
1691
|
throw new IngestRejectedError(
|
|
699
1692
|
"params",
|
|
700
|
-
`${f.path} is outside the accepted source layout`,
|
|
1693
|
+
this.opts.thirdParty ? `${f.path} is outside the accepted source layout. A theme with manifest.json at its root and no build file of its own takes only ${import_source2.THEME_SOURCE_LAYOUT}. A theme with its own build file (package.json "tanqory.build", e.g. scripts/build.mjs, as create-tanqory-theme and tanqory-partner theme init make it) is built by that file and takes its whole folder.` : `${f.path} is outside the accepted source layout`,
|
|
701
1694
|
f.path
|
|
702
1695
|
);
|
|
703
1696
|
}
|
|
@@ -750,7 +1743,9 @@ var IngestGate = class {
|
|
|
750
1743
|
* - no manifest.json: the build writes it, and the platform checks the build's output.
|
|
751
1744
|
*/
|
|
752
1745
|
inspectStarter(input) {
|
|
753
|
-
const files = sortLeaves(
|
|
1746
|
+
const files = sortLeaves(
|
|
1747
|
+
input.filter((f) => f.path !== "manifest.json" && !(0, import_source2.isStarterIgnoredPath)(f.path))
|
|
1748
|
+
);
|
|
754
1749
|
if (files.length > INGEST_LIMITS.maxEntries)
|
|
755
1750
|
throw new IngestRejectedError(
|
|
756
1751
|
"size",
|
|
@@ -776,7 +1771,7 @@ var IngestGate = class {
|
|
|
776
1771
|
if (seen.has(f.path))
|
|
777
1772
|
throw new IngestRejectedError("params", `duplicate path ${f.path}`, f.path);
|
|
778
1773
|
seen.add(f.path);
|
|
779
|
-
const deny = denyReason(f.path);
|
|
1774
|
+
const deny = (0, import_source2.denyReason)(f.path);
|
|
780
1775
|
if (deny) throw new IngestRejectedError("params", `${f.path}: ${deny}`, f.path);
|
|
781
1776
|
}
|
|
782
1777
|
if (total > INGEST_LIMITS.maxUnpackedBytes)
|
|
@@ -822,99 +1817,17 @@ var IngestGate = class {
|
|
|
822
1817
|
};
|
|
823
1818
|
}
|
|
824
1819
|
checkStarterPackageJson(file, paths) {
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
} catch {
|
|
829
|
-
throw new IngestRejectedError("params", "package.json is not valid JSON", file.path);
|
|
830
|
-
}
|
|
831
|
-
if (typeof pkg["name"] !== "string" || typeof pkg["version"] !== "string")
|
|
1820
|
+
const { problems } = (0, import_source2.starterPackageProblems)(file.bytes.toString("utf8"), paths);
|
|
1821
|
+
const first = problems[0];
|
|
1822
|
+
if (first)
|
|
832
1823
|
throw new IngestRejectedError(
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
for (const key of ["resolutions", "workspaces", "overrides"])
|
|
838
|
-
if (key in pkg)
|
|
839
|
-
throw new IngestRejectedError("params", `package.json "${key}" is rejected`, file.path);
|
|
840
|
-
const pnpm = pkg["pnpm"] ?? {};
|
|
841
|
-
for (const key of ["overrides", "patchedDependencies", "onlyBuiltDependencies"])
|
|
842
|
-
if (key in pnpm)
|
|
843
|
-
throw new IngestRejectedError("params", `package.json "pnpm.${key}" is rejected`, file.path);
|
|
844
|
-
const tq = pkg["tanqory"] ?? {};
|
|
845
|
-
if (typeof tq !== "object" || Array.isArray(tq))
|
|
846
|
-
throw new IngestRejectedError("params", 'package.json "tanqory" must be an object', file.path);
|
|
847
|
-
const build = tq["build"] ?? STARTER_DEFAULT_BUILDS.find((b) => paths.has(b)) ?? STARTER_DEFAULT_BUILDS[1];
|
|
848
|
-
const out = tq["out"] ?? STARTER_DEFAULT_OUT;
|
|
849
|
-
if (typeof build !== "string" || !STARTER_PATH_RE.test(build) || !build.endsWith(".mjs"))
|
|
850
|
-
throw new IngestRejectedError(
|
|
851
|
-
"params",
|
|
852
|
-
`package.json tanqory.build ${JSON.stringify(build)} must be a relative path to a .mjs file in the theme`,
|
|
853
|
-
file.path
|
|
854
|
-
);
|
|
855
|
-
if (!paths.has(build))
|
|
856
|
-
throw new IngestRejectedError(
|
|
857
|
-
"params",
|
|
858
|
-
`the build file ${build} is not in the upload (package.json tanqory.build, or ${STARTER_DEFAULT_BUILDS.join(" / ")})`,
|
|
859
|
-
build
|
|
860
|
-
);
|
|
861
|
-
if (typeof out !== "string" || !STARTER_PATH_RE.test(out))
|
|
862
|
-
throw new IngestRejectedError(
|
|
863
|
-
"params",
|
|
864
|
-
`package.json tanqory.out ${JSON.stringify(out)} must be a relative directory in the theme`,
|
|
865
|
-
file.path
|
|
866
|
-
);
|
|
867
|
-
const sections = ["dependencies", "devDependencies", "optionalDependencies", "peerDependencies"];
|
|
868
|
-
let kit = false;
|
|
869
|
-
for (const section of sections) {
|
|
870
|
-
const deps = pkg[section] ?? {};
|
|
871
|
-
for (const [name, spec] of Object.entries(deps)) {
|
|
872
|
-
if (typeof spec !== "string" || !isPlainRegistryRange(spec))
|
|
873
|
-
throw new IngestRejectedError(
|
|
874
|
-
"deps",
|
|
875
|
-
`package.json ${section}.${name}: ${JSON.stringify(spec)} is not a plain registry version range`,
|
|
876
|
-
file.path,
|
|
877
|
-
{ entry: name }
|
|
878
|
-
);
|
|
879
|
-
const platform = THIRD_PARTY_PLATFORM_PACKAGES.get(name);
|
|
880
|
-
if (platform) {
|
|
881
|
-
const allowed = PLATFORM_PACKAGE_SECTIONS[platform];
|
|
882
|
-
if (!allowed.includes(section))
|
|
883
|
-
throw new IngestRejectedError(
|
|
884
|
-
"deps",
|
|
885
|
-
`package.json ${section}.${name}: ${name} may be named only in ${allowed.join(" or ")}`,
|
|
886
|
-
file.path,
|
|
887
|
-
{ entry: name }
|
|
888
|
-
);
|
|
889
|
-
if (!EXACT_VERSION_RE.test(spec))
|
|
890
|
-
throw new IngestRejectedError(
|
|
891
|
-
"deps",
|
|
892
|
-
`package.json ${section}.${name}: ${JSON.stringify(spec)} must be an exact version (e.g. "2.0.0-alpha.3"), not a range`,
|
|
893
|
-
file.path,
|
|
894
|
-
{ entry: name }
|
|
895
|
-
);
|
|
896
|
-
if (name === "@tanqory/theme-kit") kit = true;
|
|
897
|
-
continue;
|
|
898
|
-
}
|
|
899
|
-
if (STARTER_PROVIDED_PACKAGES.has(name) && (section === "dependencies" || section === "devDependencies"))
|
|
900
|
-
continue;
|
|
901
|
-
if (isStarterDevTool(name) && section === "devDependencies") continue;
|
|
902
|
-
throw new IngestRejectedError(
|
|
903
|
-
"deps",
|
|
904
|
-
`package.json ${section}.${name}: the builder does not provide ${name} (a starter build uses the kit, react, react-dom, vite and @vitejs/plugin-react from the builder image)`,
|
|
905
|
-
file.path,
|
|
906
|
-
{ entry: name }
|
|
907
|
-
);
|
|
908
|
-
}
|
|
909
|
-
}
|
|
910
|
-
if (!kit)
|
|
911
|
-
throw new IngestRejectedError(
|
|
912
|
-
"deps",
|
|
913
|
-
"package.json must pin @tanqory/theme-kit exactly: it selects the toolchain the build runs with",
|
|
914
|
-
file.path,
|
|
915
|
-
{ entry: "@tanqory/theme-kit" }
|
|
1824
|
+
first.kind,
|
|
1825
|
+
first.message,
|
|
1826
|
+
first.path,
|
|
1827
|
+
first.entry ? { entry: first.entry } : void 0
|
|
916
1828
|
);
|
|
917
|
-
|
|
1829
|
+
const pkg = JSON.parse(file.bytes.toString("utf8"));
|
|
1830
|
+
return { name: pkg.name, version: pkg.version };
|
|
918
1831
|
}
|
|
919
1832
|
checkCollisions(files) {
|
|
920
1833
|
const folded = /* @__PURE__ */ new Map();
|
|
@@ -984,7 +1897,7 @@ var IngestGate = class {
|
|
|
984
1897
|
]) {
|
|
985
1898
|
const deps = pkg[section] ?? {};
|
|
986
1899
|
for (const [name, spec] of Object.entries(deps)) {
|
|
987
|
-
if (typeof spec !== "string" || !isPlainRegistryRange(spec)) {
|
|
1900
|
+
if (typeof spec !== "string" || !(0, import_source2.isPlainRegistryRange)(spec)) {
|
|
988
1901
|
throw new IngestRejectedError(
|
|
989
1902
|
"deps",
|
|
990
1903
|
`package.json ${section}.${name}: ${JSON.stringify(spec)} is not a plain registry version range`,
|
|
@@ -992,9 +1905,9 @@ var IngestGate = class {
|
|
|
992
1905
|
{ entry: name }
|
|
993
1906
|
);
|
|
994
1907
|
}
|
|
995
|
-
const platform = this.opts.thirdParty ? THIRD_PARTY_PLATFORM_PACKAGES.get(name) : void 0;
|
|
1908
|
+
const platform = this.opts.thirdParty ? import_source2.THIRD_PARTY_PLATFORM_PACKAGES.get(name) : void 0;
|
|
996
1909
|
if (platform) {
|
|
997
|
-
const sections = PLATFORM_PACKAGE_SECTIONS[platform];
|
|
1910
|
+
const sections = import_source2.PLATFORM_PACKAGE_SECTIONS[platform];
|
|
998
1911
|
if (!sections.includes(section))
|
|
999
1912
|
throw new IngestRejectedError(
|
|
1000
1913
|
"deps",
|
|
@@ -1002,7 +1915,7 @@ var IngestGate = class {
|
|
|
1002
1915
|
file.path,
|
|
1003
1916
|
{ entry: name }
|
|
1004
1917
|
);
|
|
1005
|
-
if (!EXACT_VERSION_RE.test(spec))
|
|
1918
|
+
if (!import_source2.EXACT_VERSION_RE.test(spec))
|
|
1006
1919
|
throw new IngestRejectedError(
|
|
1007
1920
|
"deps",
|
|
1008
1921
|
`package.json ${section}.${name}: ${JSON.stringify(spec)} must be an exact version (e.g. "2.0.0-alpha.3"), not a range`,
|
|
@@ -1024,7 +1937,7 @@ var IngestGate = class {
|
|
|
1024
1937
|
for (const section of ["dependencies", "devDependencies", "optionalDependencies"]) {
|
|
1025
1938
|
const deps = pkg[section] ?? {};
|
|
1026
1939
|
for (const name of Object.keys(deps)) {
|
|
1027
|
-
if (this.opts.thirdParty && THIRD_PARTY_PLATFORM_PACKAGES.has(name)) continue;
|
|
1940
|
+
if (this.opts.thirdParty && import_source2.THIRD_PARTY_PLATFORM_PACKAGES.has(name)) continue;
|
|
1028
1941
|
if (!this.opts.allowlist.packages.has(name)) {
|
|
1029
1942
|
throw new IngestRejectedError(
|
|
1030
1943
|
"deps",
|
|
@@ -1108,7 +2021,7 @@ var IngestGate = class {
|
|
|
1108
2021
|
if (d.importer !== ".") refuse(`${at}: only the root importer "." is accepted`, d.name);
|
|
1109
2022
|
if (d.section === "peerDependencies")
|
|
1110
2023
|
refuse(`${at}: an importer peer dependency is not accepted`, d.name);
|
|
1111
|
-
if (!isPlainRegistryRange(d.specifier))
|
|
2024
|
+
if (!(0, import_source2.isPlainRegistryRange)(d.specifier))
|
|
1112
2025
|
refuse(
|
|
1113
2026
|
`${at}: specifier ${JSON.stringify(d.specifier)} is not a plain registry range`,
|
|
1114
2027
|
d.name
|
|
@@ -1118,7 +2031,7 @@ var IngestGate = class {
|
|
|
1118
2031
|
refuse(`${at}: version ${JSON.stringify(d.version)} is not a registry version`, d.name);
|
|
1119
2032
|
if (!checked.has(`${d.name}@${version}`))
|
|
1120
2033
|
refuse(`${at}: ${d.name}@${version} has no entry in packages:`, d.name);
|
|
1121
|
-
if (this.opts.thirdParty && THIRD_PARTY_PLATFORM_PACKAGES.has(d.name) && d.specifier !== version)
|
|
2034
|
+
if (this.opts.thirdParty && import_source2.THIRD_PARTY_PLATFORM_PACKAGES.has(d.name) && d.specifier !== version)
|
|
1122
2035
|
refuse(
|
|
1123
2036
|
`${at}: specifier ${d.specifier} must be the exact version it resolves to (${version})`,
|
|
1124
2037
|
d.name
|
|
@@ -1205,7 +2118,7 @@ function platformOnlyClosure(lock) {
|
|
|
1205
2118
|
if (d.importer !== ".") continue;
|
|
1206
2119
|
const v = registryVersionOf(d.version);
|
|
1207
2120
|
if (!v) continue;
|
|
1208
|
-
(THIRD_PARTY_PLATFORM_PACKAGES.has(d.name) ? platformRoots : otherRoots).push(`${d.name}@${v}`);
|
|
2121
|
+
(import_source2.THIRD_PARTY_PLATFORM_PACKAGES.has(d.name) ? platformRoots : otherRoots).push(`${d.name}@${v}`);
|
|
1209
2122
|
}
|
|
1210
2123
|
const other = reach(otherRoots);
|
|
1211
2124
|
return new Set([...reach(platformRoots)].filter((k) => !other.has(k)));
|
|
@@ -1227,17 +2140,30 @@ function parseNpmLockfile(bytes) {
|
|
|
1227
2140
|
if (typeof doc.lockfileVersion !== "number" || doc.lockfileVersion < 2 || !doc.packages)
|
|
1228
2141
|
throw new Error('package-lock.json lockfileVersion must be 2 or 3 with a "packages" map');
|
|
1229
2142
|
const packages = [];
|
|
1230
|
-
const seen = /* @__PURE__ */ new
|
|
2143
|
+
const seen = /* @__PURE__ */ new Map();
|
|
1231
2144
|
for (const [key, entry] of Object.entries(doc.packages)) {
|
|
1232
2145
|
if (!key.startsWith("node_modules/") || entry["link"]) continue;
|
|
1233
2146
|
const name = key.slice(key.lastIndexOf("node_modules/") + "node_modules/".length);
|
|
1234
2147
|
const version = entry["version"];
|
|
1235
|
-
if (typeof version !== "string"
|
|
1236
|
-
|
|
2148
|
+
if (typeof version !== "string") continue;
|
|
2149
|
+
const dev = entry["dev"] === true;
|
|
2150
|
+
const at = seen.get(`${name}@${version}`);
|
|
2151
|
+
if (at !== void 0) {
|
|
2152
|
+
const prev = packages[at];
|
|
2153
|
+
if (!dev && prev.dev)
|
|
2154
|
+
packages[at] = {
|
|
2155
|
+
name: prev.name,
|
|
2156
|
+
version: prev.version,
|
|
2157
|
+
...prev.integrity !== void 0 ? { integrity: prev.integrity } : {}
|
|
2158
|
+
};
|
|
2159
|
+
continue;
|
|
2160
|
+
}
|
|
2161
|
+
seen.set(`${name}@${version}`, packages.length);
|
|
1237
2162
|
packages.push({
|
|
1238
2163
|
name,
|
|
1239
2164
|
version,
|
|
1240
|
-
...typeof entry["integrity"] === "string" ? { integrity: entry["integrity"] } : {}
|
|
2165
|
+
...typeof entry["integrity"] === "string" ? { integrity: entry["integrity"] } : {},
|
|
2166
|
+
...dev ? { dev: true } : {}
|
|
1241
2167
|
});
|
|
1242
2168
|
}
|
|
1243
2169
|
const root = doc.packages[""] ?? {};
|
|
@@ -1372,11 +2298,210 @@ async function extractTarballGuarded(input, limits = INGEST_LIMITS) {
|
|
|
1372
2298
|
};
|
|
1373
2299
|
}
|
|
1374
2300
|
|
|
2301
|
+
// ../../apps/build-service/src/review/partner-source.ts
|
|
2302
|
+
var import_text_rules = __toESM(require_text_rules());
|
|
2303
|
+
|
|
2304
|
+
// ../../apps/build-service/src/review/local-sandbox.ts
|
|
2305
|
+
var import_node_crypto4 = require("node:crypto");
|
|
2306
|
+
var import_node_zlib = require("node:zlib");
|
|
2307
|
+
var import_theme_abi2 = require("@tanqory/theme-abi");
|
|
2308
|
+
|
|
2309
|
+
// ../../apps/build-service/src/artifact/entry-scan.ts
|
|
2310
|
+
var import_acorn = require("acorn");
|
|
2311
|
+
var import_acorn_walk = require("acorn-walk");
|
|
2312
|
+
function scanEntryModule(source) {
|
|
2313
|
+
let ast;
|
|
2314
|
+
try {
|
|
2315
|
+
ast = (0, import_acorn.parse)(source, {
|
|
2316
|
+
ecmaVersion: "latest",
|
|
2317
|
+
sourceType: "module",
|
|
2318
|
+
locations: true,
|
|
2319
|
+
allowHashBang: false
|
|
2320
|
+
});
|
|
2321
|
+
} catch (e) {
|
|
2322
|
+
return [{ kind: "parse_error", message: e.message }];
|
|
2323
|
+
}
|
|
2324
|
+
const findings = [];
|
|
2325
|
+
const line3 = (n) => n.loc?.start.line ?? 0;
|
|
2326
|
+
(0, import_acorn_walk.full)(ast, (node) => {
|
|
2327
|
+
switch (node.type) {
|
|
2328
|
+
case "ImportDeclaration":
|
|
2329
|
+
findings.push({ kind: "static_import", line: line3(node) });
|
|
2330
|
+
break;
|
|
2331
|
+
case "ImportExpression":
|
|
2332
|
+
findings.push({ kind: "dynamic_import", line: line3(node) });
|
|
2333
|
+
break;
|
|
2334
|
+
case "ExportAllDeclaration":
|
|
2335
|
+
findings.push({ kind: "export_from", line: line3(node) });
|
|
2336
|
+
break;
|
|
2337
|
+
case "ExportNamedDeclaration":
|
|
2338
|
+
if (node.source)
|
|
2339
|
+
findings.push({ kind: "export_from", line: line3(node) });
|
|
2340
|
+
break;
|
|
2341
|
+
case "CallExpression": {
|
|
2342
|
+
const callee = node.callee;
|
|
2343
|
+
if (callee.type === "Identifier" && callee.name === "require")
|
|
2344
|
+
findings.push({ kind: "require_call", line: line3(node) });
|
|
2345
|
+
if (callee.type === "Identifier" && callee.name === "importScripts")
|
|
2346
|
+
findings.push({ kind: "import_scripts_call", line: line3(node) });
|
|
2347
|
+
break;
|
|
2348
|
+
}
|
|
2349
|
+
}
|
|
2350
|
+
});
|
|
2351
|
+
return findings;
|
|
2352
|
+
}
|
|
2353
|
+
function describeFinding(f) {
|
|
2354
|
+
return f.kind === "parse_error" ? `does not parse as an ES module: ${f.message}` : `${f.kind.replace(/_/g, " ")} at line ${f.line}`;
|
|
2355
|
+
}
|
|
2356
|
+
function moduleReferences(source) {
|
|
2357
|
+
let ast;
|
|
2358
|
+
try {
|
|
2359
|
+
ast = (0, import_acorn.parse)(source, { ecmaVersion: "latest", sourceType: "module", locations: true });
|
|
2360
|
+
} catch {
|
|
2361
|
+
return void 0;
|
|
2362
|
+
}
|
|
2363
|
+
const out = [];
|
|
2364
|
+
const line3 = (n) => n.loc?.start.line ?? 0;
|
|
2365
|
+
const literal = (n) => {
|
|
2366
|
+
const v = n;
|
|
2367
|
+
return v?.type === "Literal" && typeof v.value === "string" ? v.value : null;
|
|
2368
|
+
};
|
|
2369
|
+
(0, import_acorn_walk.full)(ast, (node) => {
|
|
2370
|
+
const n = node;
|
|
2371
|
+
switch (node.type) {
|
|
2372
|
+
case "ImportDeclaration":
|
|
2373
|
+
out.push({ kind: "static_import", specifier: literal(n.source), line: line3(node) });
|
|
2374
|
+
break;
|
|
2375
|
+
case "ImportExpression":
|
|
2376
|
+
out.push({ kind: "dynamic_import", specifier: literal(n.source), line: line3(node) });
|
|
2377
|
+
break;
|
|
2378
|
+
case "ExportAllDeclaration":
|
|
2379
|
+
out.push({ kind: "export_from", specifier: literal(n.source), line: line3(node) });
|
|
2380
|
+
break;
|
|
2381
|
+
case "ExportNamedDeclaration":
|
|
2382
|
+
if (n.source)
|
|
2383
|
+
out.push({ kind: "export_from", specifier: literal(n.source), line: line3(node) });
|
|
2384
|
+
break;
|
|
2385
|
+
case "CallExpression":
|
|
2386
|
+
if (n.callee?.type === "Identifier" && n.callee.name === "require")
|
|
2387
|
+
out.push({ kind: "require_call", specifier: literal(n.arguments?.[0]), line: line3(node) });
|
|
2388
|
+
if (n.callee?.type === "Identifier" && n.callee.name === "importScripts")
|
|
2389
|
+
out.push({ kind: "import_scripts_call", specifier: null, line: line3(node) });
|
|
2390
|
+
break;
|
|
2391
|
+
}
|
|
2392
|
+
});
|
|
2393
|
+
return out;
|
|
2394
|
+
}
|
|
2395
|
+
function clientChunkProblem(path, source, shipped) {
|
|
2396
|
+
const refs = moduleReferences(source);
|
|
2397
|
+
if (!refs) return `${path} does not parse as an ES module`;
|
|
2398
|
+
for (const r of refs) {
|
|
2399
|
+
if (r.kind === "require_call" || r.kind === "import_scripts_call")
|
|
2400
|
+
return `${path}: ${r.kind.replace(/_/g, " ")} at line ${r.line}`;
|
|
2401
|
+
const m = r.specifier === null ? null : /^\.\/([A-Za-z0-9._-]+)$/.exec(r.specifier);
|
|
2402
|
+
if (!m || !shipped.has(m[1]))
|
|
2403
|
+
return `${path}: ${r.kind.replace(/_/g, " ")} of ${r.specifier === null ? "a computed specifier" : JSON.stringify(r.specifier)} at line ${r.line} \u2014 a client chunk may import only another shipped file (./<file>)`;
|
|
2404
|
+
}
|
|
2405
|
+
return void 0;
|
|
2406
|
+
}
|
|
2407
|
+
|
|
2408
|
+
// ../../apps/build-service/src/review/local-sandbox.ts
|
|
2409
|
+
var line = (key, errors, passed) => errors.length ? { key, status: "failed", message: errors[0].message, errors: errors.slice(0, 50) } : { key, status: "passed", message: passed, errors: [] };
|
|
2410
|
+
function treeDigest(files) {
|
|
2411
|
+
const h = (0, import_node_crypto4.createHash)("sha256");
|
|
2412
|
+
for (const f of [...files].sort((a, b) => a.path < b.path ? -1 : a.path > b.path ? 1 : 0))
|
|
2413
|
+
h.update(`${f.path}\0${(0, import_node_crypto4.createHash)("sha256").update(f.bytes).digest("hex")}
|
|
2414
|
+
`);
|
|
2415
|
+
return `sha256:${h.digest("hex")}`;
|
|
2416
|
+
}
|
|
2417
|
+
function reproducibleLine(first, second) {
|
|
2418
|
+
const a = new Map(first.map((f) => [f.path, (0, import_node_crypto4.createHash)("sha256").update(f.bytes).digest("hex")]));
|
|
2419
|
+
const b = new Map(second.map((f) => [f.path, (0, import_node_crypto4.createHash)("sha256").update(f.bytes).digest("hex")]));
|
|
2420
|
+
const errors = [];
|
|
2421
|
+
for (const p of [.../* @__PURE__ */ new Set([...a.keys(), ...b.keys()])].sort()) {
|
|
2422
|
+
if (a.get(p) === b.get(p)) continue;
|
|
2423
|
+
errors.push({
|
|
2424
|
+
path: p,
|
|
2425
|
+
code: "not_reproducible",
|
|
2426
|
+
message: !a.has(p) || !b.has(p) ? `${p} is written by only one of two builds of the same source. The sandbox builds twice and refuses any difference: write the same files every time.` : `${p} differs between two builds of the same source. The sandbox builds twice and refuses any difference: remove dates, random names and absolute paths from the build output.`
|
|
2427
|
+
});
|
|
2428
|
+
}
|
|
2429
|
+
return line("sandbox_build", errors, `Two builds wrote the same ${first.length} file(s) (${treeDigest(first)}).`);
|
|
2430
|
+
}
|
|
2431
|
+
function entryScanLine(out) {
|
|
2432
|
+
const errors = [];
|
|
2433
|
+
for (const entry of ["server/entry.mjs", "preview/entry.mjs"]) {
|
|
2434
|
+
const f = out.find((x) => x.path === entry);
|
|
2435
|
+
if (!f) continue;
|
|
2436
|
+
const findings = scanEntryModule(f.bytes.toString("utf8"));
|
|
2437
|
+
if (findings.length)
|
|
2438
|
+
errors.push({ path: entry, code: "entry_imports", message: `${entry} must be a single ESM file with zero imports: ${findings.map(describeFinding).join("; ")}. Bundle everything it imports into it.` });
|
|
2439
|
+
}
|
|
2440
|
+
const assets = out.filter((x) => x.path.startsWith("client/assets/"));
|
|
2441
|
+
const shipped = new Set(assets.map((x) => x.path.slice("client/assets/".length)));
|
|
2442
|
+
for (const f of assets.filter((x) => /\.m?js$/.test(x.path))) {
|
|
2443
|
+
const problem = clientChunkProblem(f.path, f.bytes.toString("utf8"), shipped);
|
|
2444
|
+
if (problem) errors.push({ path: f.path, code: "client_chunk_import", message: `${problem}. Bundle the module into the theme's own chunks.` });
|
|
2445
|
+
}
|
|
2446
|
+
return line("entry_scan", errors, `server/entry.mjs${out.some((x) => x.path === "preview/entry.mjs") ? " and preview/entry.mjs" : ""} import nothing; ${assets.length} client file(s) import only each other.`);
|
|
2447
|
+
}
|
|
2448
|
+
var gz = (b) => (0, import_node_zlib.gzipSync)(b, { level: 9 }).length;
|
|
2449
|
+
function budgetsLine(out) {
|
|
2450
|
+
const at = (p) => out.find((x) => x.path === p)?.bytes;
|
|
2451
|
+
const entry = at("server/entry.mjs") ?? Buffer.alloc(0);
|
|
2452
|
+
const assets = out.filter((x) => x.path.startsWith("client/assets/"));
|
|
2453
|
+
let initial = 0;
|
|
2454
|
+
try {
|
|
2455
|
+
const cm = JSON.parse((at("client/client-manifest.json") ?? Buffer.from("{}")).toString("utf8"));
|
|
2456
|
+
const main = Object.values(cm).find((e) => e.isEntry);
|
|
2457
|
+
const files = main ? [main.file, ...main.imports ?? [], ...main.css ?? []] : [];
|
|
2458
|
+
for (const f of new Set(files)) {
|
|
2459
|
+
const b = typeof f === "string" ? at(`client/assets/${f}`) ?? at(`client/${f}`) : void 0;
|
|
2460
|
+
if (b) initial += gz(b);
|
|
2461
|
+
}
|
|
2462
|
+
} catch {
|
|
2463
|
+
}
|
|
2464
|
+
const rows = [
|
|
2465
|
+
["ssrEntryRawBytes", entry.length],
|
|
2466
|
+
["ssrEntryGzipBytes", gz(entry)],
|
|
2467
|
+
["manifestBytes", at("manifest.json")?.length ?? 0],
|
|
2468
|
+
["clientInitialGzipBytes", initial],
|
|
2469
|
+
["clientTotalRawBytes", assets.reduce((n, x) => n + x.bytes.length, 0)]
|
|
2470
|
+
];
|
|
2471
|
+
const errors = [];
|
|
2472
|
+
const over = [];
|
|
2473
|
+
for (const [k, v] of rows) {
|
|
2474
|
+
const { budget, hard } = import_theme_abi2.LIMITS[k];
|
|
2475
|
+
if (v > hard) errors.push({ path: k, code: "over_hard_limit", message: `${k} is ${v}, over the hard limit ${hard} (ABI \xA78). Make the theme smaller: split the client code, drop unused code and assets.` });
|
|
2476
|
+
else if (budget !== null && v > budget) over.push(`${k} ${v} > budget ${budget}`);
|
|
2477
|
+
}
|
|
2478
|
+
return line("budgets", errors, `No static hard limit exceeded${over.length ? `; over budget (a warning): ${over.join(", ")}` : ""}. The sandbox also measures render budgets and Lighthouse.`);
|
|
2479
|
+
}
|
|
2480
|
+
function networkLine(manifest) {
|
|
2481
|
+
const caps = manifest?.capabilities?.server;
|
|
2482
|
+
const origins = Array.isArray(caps) ? caps.filter((c) => typeof c === "string" && c.startsWith("network:")).map((c) => c.slice(8)) : [];
|
|
2483
|
+
const errors = [];
|
|
2484
|
+
for (const o of origins) {
|
|
2485
|
+
let ok = false;
|
|
2486
|
+
try {
|
|
2487
|
+
const u = new URL(o);
|
|
2488
|
+
ok = u.protocol === "https:" && u.origin === o;
|
|
2489
|
+
} catch {
|
|
2490
|
+
ok = false;
|
|
2491
|
+
}
|
|
2492
|
+
if (!ok) errors.push({ path: `manifest.json capabilities.server network:${o}`, code: "network_origin", message: `network:${o} is not an https origin (https://host[:port], nothing after it). Declare the origin only.` });
|
|
2493
|
+
}
|
|
2494
|
+
return line("network_allowlist", errors, origins.length ? `${origins.length} network origin(s) declared (${origins.join(", ")}): reviewers ask why each is needed.` : "No network origin declared: the theme reads only the store's own data.");
|
|
2495
|
+
}
|
|
2496
|
+
|
|
2497
|
+
// ../../apps/build-service/src/review/partner-source.ts
|
|
2498
|
+
var import_source3 = __toESM(require_source());
|
|
2499
|
+
|
|
1375
2500
|
// ../../apps/build-service/src/review/static-checks.ts
|
|
1376
2501
|
var import_node_fs3 = require("node:fs");
|
|
1377
2502
|
var import_node_path3 = require("node:path");
|
|
1378
|
-
var
|
|
1379
|
-
var
|
|
2503
|
+
var import_acorn2 = require("acorn");
|
|
2504
|
+
var import_acorn_walk2 = require("acorn-walk");
|
|
1380
2505
|
var import_zod = require("zod");
|
|
1381
2506
|
var FINDINGS_MAX = 50;
|
|
1382
2507
|
var isClientScript = (p) => /^client\/assets\/[A-Za-z0-9._-]+\.m?js$/.test(p);
|
|
@@ -1390,17 +2515,17 @@ var calleeName = (callee) => {
|
|
|
1390
2515
|
function evalFindings(path, source) {
|
|
1391
2516
|
let ast;
|
|
1392
2517
|
try {
|
|
1393
|
-
ast = (0,
|
|
2518
|
+
ast = (0, import_acorn2.parse)(source, { ecmaVersion: "latest", sourceType: "module", locations: true });
|
|
1394
2519
|
} catch {
|
|
1395
2520
|
try {
|
|
1396
|
-
ast = (0,
|
|
2521
|
+
ast = (0, import_acorn2.parse)(source, { ecmaVersion: "latest", sourceType: "script", locations: true });
|
|
1397
2522
|
} catch (e) {
|
|
1398
2523
|
return [{ path, code: "parse_error", message: `${path} does not parse as JavaScript: ${e.message}` }];
|
|
1399
2524
|
}
|
|
1400
2525
|
}
|
|
1401
2526
|
const out = [];
|
|
1402
2527
|
const at = (n) => `${path}:${n.loc?.start.line ?? 0}:${(n.loc?.start.column ?? 0) + 1}`;
|
|
1403
|
-
(0,
|
|
2528
|
+
(0, import_acorn_walk2.full)(ast, (node) => {
|
|
1404
2529
|
if (node.type !== "CallExpression" && node.type !== "NewExpression") return;
|
|
1405
2530
|
const n = node;
|
|
1406
2531
|
const name = calleeName(n.callee);
|
|
@@ -1496,6 +2621,8 @@ function licencesLine(files, table) {
|
|
|
1496
2621
|
}
|
|
1497
2622
|
}
|
|
1498
2623
|
const allow = new Set(table.allowlist);
|
|
2624
|
+
const devOnly = components.filter((c) => c.scope === "excluded").length;
|
|
2625
|
+
components = components.filter((c) => c.scope !== "excluded");
|
|
1499
2626
|
for (const c of components) {
|
|
1500
2627
|
const name = typeof c.name === "string" ? c.name : "?";
|
|
1501
2628
|
const version = typeof c.version === "string" ? c.version : "?";
|
|
@@ -1506,16 +2633,15 @@ function licencesLine(files, table) {
|
|
|
1506
2633
|
errors.push({ path: `${name}@${version}`, code: "licence_not_allowed", message: `${name}@${version} is licensed ${licence}, which is not on the allowed list (${table.allowlist.join(", ")}).` });
|
|
1507
2634
|
if (errors.length >= FINDINGS_MAX) break;
|
|
1508
2635
|
}
|
|
1509
|
-
return errors.length ? { status: "failed", message: errors[0].message, errors: errors.slice(0, FINDINGS_MAX) } : {
|
|
2636
|
+
return errors.length ? { status: "failed", message: errors[0].message, errors: errors.slice(0, FINDINGS_MAX) } : {
|
|
2637
|
+
status: "passed",
|
|
2638
|
+
message: `A LICENSE file, and ${components.length} SBOM component(s) all on the allowed licence list.${devOnly ? ` ${devOnly} development-only component(s) are not shipped and not counted.` : ""}`,
|
|
2639
|
+
errors: []
|
|
2640
|
+
};
|
|
1510
2641
|
}
|
|
1511
2642
|
|
|
1512
2643
|
// ../../apps/build-service/src/review/partner-source.ts
|
|
1513
|
-
var
|
|
1514
|
-
var EMOJI = /([\p{Extended_Pictographic}\u{1F1E6}-\u{1F1FF}])(\u{FE0F})?/gu;
|
|
1515
|
-
var TEXT_FORM_ALLOWED = /* @__PURE__ */ new Set(["\xA9", "\xAE", "\u2122"]);
|
|
1516
|
-
var hasEmoji = (s) => [...s.matchAll(EMOJI)].some(([, ch, vs]) => vs || !TEXT_FORM_ALLOWED.has(ch));
|
|
1517
|
-
var LABEL_KEYS = /* @__PURE__ */ new Set(["name", "title", "label", "info", "placeholder", "description"]);
|
|
1518
|
-
var line = (key, errors, passed) => errors.length ? { key, status: "failed", message: errors[0].message, errors: errors.slice(0, 50) } : { key, status: "passed", message: passed, errors: [] };
|
|
2644
|
+
var line2 = (key, errors, passed) => errors.length ? { key, status: "failed", message: errors[0].message, errors: errors.slice(0, 50) } : { key, status: "passed", message: passed, errors: [] };
|
|
1519
2645
|
function treeOf(dir) {
|
|
1520
2646
|
const out = [];
|
|
1521
2647
|
const walk = (abs) => {
|
|
@@ -1533,20 +2659,35 @@ var failure = (e) => ({
|
|
|
1533
2659
|
code: e instanceof BuildServiceError ? String(e.kind ?? e.name) : "error",
|
|
1534
2660
|
message: e.message
|
|
1535
2661
|
});
|
|
1536
|
-
async function
|
|
2662
|
+
async function editabilityLine(files, imageFetch) {
|
|
2663
|
+
const text = {};
|
|
2664
|
+
for (const f of files) {
|
|
2665
|
+
if (!/^(src\/.+\.(tsx|ts|jsx|js)|locales\/[^/]+\.json|templates\/[^/]+\.json|regions\/[^/]+\.json|config\/settings\.json)$/.test(f.path)) continue;
|
|
2666
|
+
if (f.bytes.subarray(0, 8192).includes(0)) continue;
|
|
2667
|
+
text[f.path] = f.bytes.toString("utf8");
|
|
2668
|
+
}
|
|
2669
|
+
const r = (0, import_editability.checkEditability)(text);
|
|
2670
|
+
const errs = r.errors.map((e) => ({ path: `${e.file}:${e.line}:${e.column}`, code: e.code, message: `${e.message}${e.fix ? ` Fix: ${e.fix}` : ""}` }));
|
|
2671
|
+
if (imageFetch) {
|
|
2672
|
+
const img = await (0, import_editability.checkImageLinks)(text, { fetch: imageFetch });
|
|
2673
|
+
for (const e of img.errors) errs.push({ path: `${e.file}:${e.line}:${e.column}`, code: e.code, message: `${e.message}${e.fix ? ` Fix: ${e.fix}` : ""}` });
|
|
2674
|
+
}
|
|
2675
|
+
return line2("editability", errs, `${r.score.editable} settings; every section's words, images and links are editable (${r.score.percent} %)${r.warnings.length ? `; ${r.warnings.length} warning(s)` : ""}`);
|
|
2676
|
+
}
|
|
2677
|
+
async function checkPartnerSource(tgz, built, opts = {}) {
|
|
1537
2678
|
const lines = [];
|
|
1538
2679
|
let files = [];
|
|
1539
2680
|
try {
|
|
1540
|
-
files = (await extractTarballGuarded(import_node_stream.Readable.from([tgz]))).files;
|
|
2681
|
+
files = (0, import_source2.withoutPackFolder)((await extractTarballGuarded(import_node_stream.Readable.from([tgz]))).files);
|
|
1541
2682
|
} catch (e) {
|
|
1542
|
-
lines.push(
|
|
2683
|
+
lines.push(line2("archive", [failure(e)], ""));
|
|
1543
2684
|
}
|
|
1544
2685
|
let ingest = null;
|
|
1545
2686
|
try {
|
|
1546
2687
|
ingest = new IngestGate({ mirrorHosts: [], allowlist: loadMirrorAllowlist(), thirdParty: true }).inspect(files);
|
|
1547
|
-
lines.push(
|
|
2688
|
+
lines.push(line2("ingest_gate", [], `${ingest.layout} layout, ${ingest.files.length} build input(s)`));
|
|
1548
2689
|
} catch (e) {
|
|
1549
|
-
lines.push(
|
|
2690
|
+
lines.push(line2("ingest_gate", [failure(e)], ""));
|
|
1550
2691
|
}
|
|
1551
2692
|
const pkg = JSON.parse(files.find((f) => f.path === "package.json")?.bytes.toString("utf8") ?? "{}");
|
|
1552
2693
|
const pinOf = (name) => pkg["dependencies"]?.[name] ?? pkg["devDependencies"]?.[name];
|
|
@@ -1560,20 +2701,10 @@ async function checkPartnerSource(tgz, built) {
|
|
|
1560
2701
|
const abi = pinOf("@tanqory/theme-abi");
|
|
1561
2702
|
if (abi !== void 0 && ingest?.layout !== "theme-source" && abi !== starterAbi)
|
|
1562
2703
|
build.push({ path: "package.json", code: "abi_not_carried", message: `package.json pins @tanqory/theme-abi ${JSON.stringify(abi)}; the builder's starter toolchain carries ${starterAbi}. Pin that exactly.` });
|
|
1563
|
-
lines.push(
|
|
1564
|
-
const text = [];
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
else if (!f.bytes.subarray(0, 8192).includes(0)) {
|
|
1568
|
-
const s = f.bytes.toString("utf8");
|
|
1569
|
-
const i = s.search(BRAND_RE);
|
|
1570
|
-
if (i >= 0) {
|
|
1571
|
-
const at = s.slice(0, i).split("\n").length;
|
|
1572
|
-
text.push({ path: `${f.path}:${at}`, code: "brand_term", message: `${f.path} line ${at} names another commerce platform. Use your theme's own words.` });
|
|
1573
|
-
}
|
|
1574
|
-
}
|
|
1575
|
-
}
|
|
1576
|
-
lines.push(line("source_text", text, `${files.length} source file(s) checked`));
|
|
2704
|
+
lines.push(line2("sandbox_build", build, `@tanqory/theme-kit ${kit} and @tanqory/theme-abi ${abi ?? "(not pinned)"} are carried by the builder`));
|
|
2705
|
+
const text = (0, import_text_rules.sourceTextFindings)(files.map((f) => [f.path, f.bytes]));
|
|
2706
|
+
lines.push(line2("source_text", text, `${files.length} source file(s) checked`));
|
|
2707
|
+
lines.push(await editabilityLine(files, opts.imageFetch));
|
|
1577
2708
|
if (built) {
|
|
1578
2709
|
const out = treeOf(built);
|
|
1579
2710
|
const manifestFile = out.find((f) => f.path === "manifest.json");
|
|
@@ -1582,20 +2713,13 @@ async function checkPartnerSource(tgz, built) {
|
|
|
1582
2713
|
if (!manifestFile) mErrors.push({ path: "manifest.json", code: "manifest_missing", message: `The build wrote no manifest.json in ${built}.` });
|
|
1583
2714
|
else {
|
|
1584
2715
|
manifest = JSON.parse(manifestFile.bytes.toString("utf8"));
|
|
1585
|
-
const r = (0,
|
|
2716
|
+
const r = (0, import_theme_abi3.validateManifest)(manifest, { artifactFiles: out.map((f) => f.path) });
|
|
1586
2717
|
if (!r.ok) for (const e of r.errors) mErrors.push({ path: e.path, code: e.code, message: e.message });
|
|
1587
2718
|
}
|
|
1588
|
-
lines.push(
|
|
1589
|
-
const labels =
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
if (key !== null && LABEL_KEYS.has(key)) labels.push([path || "/", v]);
|
|
1593
|
-
} else if (Array.isArray(v)) v.forEach((x, i) => walk(x, `${path}/${i}`, key));
|
|
1594
|
-
else if (v && typeof v === "object") for (const [k, x] of Object.entries(v)) walk(x, `${path}/${k.replace(/~/g, "~0").replace(/\//g, "~1")}`, k);
|
|
1595
|
-
};
|
|
1596
|
-
walk(manifest, "", null);
|
|
1597
|
-
lines.push(line("manifest_brand_term", labels.filter(([, s]) => BRAND_RE.test(s)).map(([path]) => ({ path, code: "brand_term", message: `${path} names another commerce platform.` })), `${labels.length} label(s) checked`));
|
|
1598
|
-
lines.push(line("manifest_emoji", labels.filter(([, s]) => hasEmoji(s)).map(([path]) => ({ path, code: "emoji", message: `${path} contains an emoji.` })), `${labels.length} label(s) checked`));
|
|
2719
|
+
lines.push(line2("manifest", mErrors, "theme-manifest v2: schema and semantic checks passed"));
|
|
2720
|
+
const labels = (0, import_text_rules.manifestLabels)(manifest);
|
|
2721
|
+
lines.push(line2("manifest_brand_term", labels.filter(([, s]) => (0, import_text_rules.namesBrandTerm)(s)).map(([path]) => ({ path, code: "brand_term", message: `${path} names another commerce platform.` })), `${labels.length} label(s) checked`));
|
|
2722
|
+
lines.push(line2("manifest_emoji", labels.filter(([, s]) => (0, import_text_rules.hasEmoji)(s)).map(([path]) => ({ path, code: "emoji", message: `${path} contains an emoji.` })), `${labels.length} label(s) checked`));
|
|
1599
2723
|
const noEval = noEvalLine(out);
|
|
1600
2724
|
lines.push({ key: "no_eval", ...noEval });
|
|
1601
2725
|
if (ingest) {
|
|
@@ -1611,7 +2735,37 @@ async function checkPartnerSource(tgz, built) {
|
|
|
1611
2735
|
}
|
|
1612
2736
|
return { tgzBytes: tgz.length, layout: ingest?.layout ?? null, lines };
|
|
1613
2737
|
}
|
|
2738
|
+
function localSandboxLines(built, second) {
|
|
2739
|
+
const out = treeOf(built);
|
|
2740
|
+
const manifest = (() => {
|
|
2741
|
+
try {
|
|
2742
|
+
return JSON.parse(out.find((f) => f.path === "manifest.json")?.bytes.toString("utf8") ?? "null");
|
|
2743
|
+
} catch {
|
|
2744
|
+
return null;
|
|
2745
|
+
}
|
|
2746
|
+
})();
|
|
2747
|
+
return [
|
|
2748
|
+
...second ? [reproducibleLine(out, treeOf(second))] : [],
|
|
2749
|
+
entryScanLine(out),
|
|
2750
|
+
budgetsLine(out),
|
|
2751
|
+
networkLine(manifest)
|
|
2752
|
+
];
|
|
2753
|
+
}
|
|
1614
2754
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1615
2755
|
0 && (module.exports = {
|
|
1616
|
-
|
|
2756
|
+
SOURCE_LIMITS,
|
|
2757
|
+
budgetsLine,
|
|
2758
|
+
checkPartnerSource,
|
|
2759
|
+
denyFix,
|
|
2760
|
+
denyReason,
|
|
2761
|
+
editabilityLine,
|
|
2762
|
+
entryScanLine,
|
|
2763
|
+
isStarterIgnoredPath,
|
|
2764
|
+
isStarterTree,
|
|
2765
|
+
localSandboxLines,
|
|
2766
|
+
networkLine,
|
|
2767
|
+
reproducibleLine,
|
|
2768
|
+
starterPackageProblems,
|
|
2769
|
+
treeDigest,
|
|
2770
|
+
withoutPackFolder
|
|
1617
2771
|
});
|