@tanqory/partner-cli 0.1.0-alpha.2 → 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 +25 -1
- package/lib/ops.mjs +6 -1
- package/lib/theme.mjs +16 -2
- package/lib/vendor/partner-checks.cjs +608 -257
- package/package.json +1 -1
package/lib/check.mjs
CHANGED
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
// development store (`theme install`). `--conformance` also runs the ABI conformance suites here, when
|
|
10
10
|
// @tanqory/theme-conformance is installed in the theme (they need workerd and Chromium).
|
|
11
11
|
import { createRequire } from 'node:module'
|
|
12
|
-
import { existsSync } from 'node:fs'
|
|
12
|
+
import { cpSync, existsSync, mkdtempSync, rmSync } from 'node:fs'
|
|
13
|
+
import { tmpdir } from 'node:os'
|
|
13
14
|
import { join } from 'node:path'
|
|
14
15
|
import { spawnSync } from 'node:child_process'
|
|
15
16
|
import { buildTheme, packSource, ThemeError } from './theme.mjs'
|
|
@@ -33,6 +34,29 @@ function vendor() {
|
|
|
33
34
|
return require(p)
|
|
34
35
|
}
|
|
35
36
|
|
|
37
|
+
/**
|
|
38
|
+
* What this machine can run of the sandbox lines, with the sandbox lane's own code (build-service local-sandbox.ts):
|
|
39
|
+
* sandbox_build (two builds of the same source are the same tree), entry_scan, budgets (static sizes) and
|
|
40
|
+
* network_allowlist. Each line has `local: true`: the sandbox run on a development install is the verdict.
|
|
41
|
+
*/
|
|
42
|
+
export function localResults(dir, { quiet = true } = {}) {
|
|
43
|
+
const { out } = buildTheme(dir, { quiet })
|
|
44
|
+
const first = mkdtempSync(join(tmpdir(), 'tanqory-first-build-'))
|
|
45
|
+
try {
|
|
46
|
+
cpSync(out, first, { recursive: true })
|
|
47
|
+
buildTheme(dir, { quiet })
|
|
48
|
+
return vendor().localSandboxLines(out, first).map((l) => ({ ...l, local: true }))
|
|
49
|
+
} finally {
|
|
50
|
+
rmSync(first, { recursive: true, force: true })
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** The source rules (@tanqory/theme-standard/source, as the bundled gate reads them). */
|
|
55
|
+
export const sourceRules = () => {
|
|
56
|
+
const v = vendor()
|
|
57
|
+
return { denyFix: v.denyFix, denyReason: v.denyReason, isStarterIgnoredPath: v.isStarterIgnoredPath, isStarterTree: v.isStarterTree, SOURCE_LIMITS: v.SOURCE_LIMITS, starterPackageProblems: v.starterPackageProblems, withoutPackFolder: v.withoutPackFolder }
|
|
58
|
+
}
|
|
59
|
+
|
|
36
60
|
/** Build, pack and check `dir`. Returns `{ ok, lines, tgzBytes, layout, out }`; never throws for a failed check. */
|
|
37
61
|
export async function checkTheme(dir, { build = true, quiet = false } = {}) {
|
|
38
62
|
const out = build ? buildTheme(dir, { quiet }).out : join(dir, 'dist', 'abi')
|
package/lib/ops.mjs
CHANGED
|
@@ -4,7 +4,7 @@ import { basename, dirname, join, resolve } from 'node:path'
|
|
|
4
4
|
import { fileURLToPath } from 'node:url'
|
|
5
5
|
import * as api from './api.mjs'
|
|
6
6
|
import { apiBase, defaultOrg, rememberOrg } from './auth.mjs'
|
|
7
|
-
import { checkTheme } from './check.mjs'
|
|
7
|
+
import { checkTheme, localResults as localResultsOf } from './check.mjs'
|
|
8
8
|
import { packSource, packageTheme, readPackage, ThemeError } from './theme.mjs'
|
|
9
9
|
|
|
10
10
|
const STARTER = join(dirname(fileURLToPath(import.meta.url)), '..', 'starter')
|
|
@@ -51,6 +51,11 @@ export async function check(dir, opts) {
|
|
|
51
51
|
return checkTheme(resolve(dir ?? '.'), opts)
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
+
/** What this machine can run of the sandbox lines (two builds compared, entry imports, static budgets, network origins). */
|
|
55
|
+
export function localResults(dir, opts) {
|
|
56
|
+
return localResultsOf(resolve(dir ?? '.'), opts)
|
|
57
|
+
}
|
|
58
|
+
|
|
54
59
|
export async function pkg(dir, opts) {
|
|
55
60
|
return packageTheme(resolve(dir ?? '.'), opts)
|
|
56
61
|
}
|
package/lib/theme.mjs
CHANGED
|
@@ -8,10 +8,14 @@
|
|
|
8
8
|
// - never node_modules, dist or .git;
|
|
9
9
|
// - no lockfile (package-lock.json, pnpm-lock.yaml, yarn.lock, bun.lockb): the builder never installs from one (it
|
|
10
10
|
// uses its own toolchain). (An uploaded lockfile is read for the SBOM only; since DECISIONS row 185 the licences
|
|
11
|
-
// check counts only what it ships, so its developer tools no longer fail it.)
|
|
11
|
+
// check counts only what it ships, so its developer tools no longer fail it.);
|
|
12
|
+
// - none of what the lane leaves out anyway (editor and AI assistant folders, tests, CI, macOS files:
|
|
13
|
+
// @tanqory/theme-standard/source `isStarterIgnoredPath`, bundled in lib/vendor), and no root manifest.json (the
|
|
14
|
+
// manifest goes beside the archive; a stale copy inside it would differ from it).
|
|
12
15
|
import { execFileSync, spawnSync } from 'node:child_process'
|
|
13
16
|
import { existsSync, mkdirSync, readFileSync, readdirSync, statSync, writeFileSync, copyFileSync } from 'node:fs'
|
|
14
17
|
import { dirname, join, resolve } from 'node:path'
|
|
18
|
+
import { createRequire } from 'node:module'
|
|
15
19
|
import * as tar from 'tar'
|
|
16
20
|
|
|
17
21
|
export const LOCKFILES = new Set(['package-lock.json', 'pnpm-lock.yaml', 'yarn.lock', 'bun.lockb', 'npm-shrinkwrap.json'])
|
|
@@ -19,6 +23,16 @@ const NEVER = new Set(['node_modules', 'dist', '.git'])
|
|
|
19
23
|
|
|
20
24
|
export class ThemeError extends Error {}
|
|
21
25
|
|
|
26
|
+
const requireHere = createRequire(import.meta.url)
|
|
27
|
+
/** The lane's own rule (bundled); a copy without lib/vendor packs as before. */
|
|
28
|
+
function leftOutByLane(path) {
|
|
29
|
+
try {
|
|
30
|
+
return requireHere('./vendor/partner-checks.cjs').isStarterIgnoredPath(path)
|
|
31
|
+
} catch {
|
|
32
|
+
return false
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
22
36
|
export function readPackage(dir) {
|
|
23
37
|
const p = join(dir, 'package.json')
|
|
24
38
|
if (!existsSync(p)) throw new ThemeError(`${dir} has no package.json. Run this in a theme folder, or make one with: tanqory-partner theme init <name>`)
|
|
@@ -66,7 +80,7 @@ export function themeFiles(dir) {
|
|
|
66
80
|
walk('')
|
|
67
81
|
}
|
|
68
82
|
return paths
|
|
69
|
-
.filter((p) => !p.split('/').some((seg) => NEVER.has(seg)) && !LOCKFILES.has(p))
|
|
83
|
+
.filter((p) => !p.split('/').some((seg) => NEVER.has(seg)) && !LOCKFILES.has(p) && p !== 'manifest.json' && !leftOutByLane(p))
|
|
70
84
|
.filter((p) => existsSync(join(dir, p)) && statSync(join(dir, p)).isFile())
|
|
71
85
|
.sort()
|
|
72
86
|
}
|
|
@@ -52,13 +52,13 @@ var require_editability = __commonJS({
|
|
|
52
52
|
var SVG_TEXT = /* @__PURE__ */ new Set(["text", "tspan", "title", "desc", "textPath"]);
|
|
53
53
|
var isWords = (s) => LETTER.test(s) && !/^\s*(&[a-z#0-9]+;\s*)+$/i.test(s);
|
|
54
54
|
function lineCol(src, i) {
|
|
55
|
-
let
|
|
55
|
+
let line3 = 1;
|
|
56
56
|
let last = -1;
|
|
57
57
|
for (let k = 0; k < i && k < src.length; k++) if (src.charCodeAt(k) === 10) {
|
|
58
|
-
|
|
58
|
+
line3++;
|
|
59
59
|
last = k;
|
|
60
60
|
}
|
|
61
|
-
return { line:
|
|
61
|
+
return { line: line3, column: i - last };
|
|
62
62
|
}
|
|
63
63
|
function scan(src) {
|
|
64
64
|
const n = src.length;
|
|
@@ -379,10 +379,10 @@ var require_editability = __commonJS({
|
|
|
379
379
|
const errors = [];
|
|
380
380
|
const warnings = [];
|
|
381
381
|
const add = (sev, code, file, src, at, message, fix) => {
|
|
382
|
-
const { line:
|
|
382
|
+
const { line: line3, column } = lineCol(src, at);
|
|
383
383
|
const list = sev === "error" ? errors : warnings;
|
|
384
|
-
if (list.some((x) => x.code === code && x.file === file && x.line ===
|
|
385
|
-
list.push({ severity: sev, code, file, line:
|
|
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
386
|
};
|
|
387
387
|
let en = opts.locales || null;
|
|
388
388
|
if (!en && typeof files["locales/en.json"] === "string") {
|
|
@@ -720,15 +720,15 @@ var require_editability = __commonJS({
|
|
|
720
720
|
const list = [...found.entries()];
|
|
721
721
|
for (let i = 0; i < list.length; i += concurrency) {
|
|
722
722
|
await Promise.all(list.slice(i, i + concurrency).map(async ([url, where]) => {
|
|
723
|
-
const { line:
|
|
723
|
+
const { line: line3, column } = lineCol(where.src, where.at);
|
|
724
724
|
const r = await ask(url);
|
|
725
725
|
let host = "";
|
|
726
726
|
try {
|
|
727
727
|
host = new URL(url).hostname;
|
|
728
728
|
} catch {
|
|
729
729
|
}
|
|
730
|
-
if (!r.ok) errors.push({ severity: "error", code: "image_not_found", file: where.file, line:
|
|
731
|
-
else if (!STORE_HOST.test(host)) warnings.push({ severity: "warning", code: "image_external", file: where.file, line:
|
|
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
732
|
}));
|
|
733
733
|
}
|
|
734
734
|
const sort = (a, b) => (a.file + a.line).localeCompare(b.file + b.line);
|
|
@@ -743,17 +743,330 @@ var require_editability = __commonJS({
|
|
|
743
743
|
}
|
|
744
744
|
});
|
|
745
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
|
+
|
|
746
1046
|
// ../../apps/build-service/src/review/partner-source.ts
|
|
747
1047
|
var partner_source_exports = {};
|
|
748
1048
|
__export(partner_source_exports, {
|
|
1049
|
+
SOURCE_LIMITS: () => import_source3.SOURCE_LIMITS,
|
|
1050
|
+
budgetsLine: () => budgetsLine,
|
|
749
1051
|
checkPartnerSource: () => checkPartnerSource,
|
|
750
|
-
|
|
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
|
|
751
1064
|
});
|
|
752
1065
|
module.exports = __toCommonJS(partner_source_exports);
|
|
753
1066
|
var import_node_fs4 = require("node:fs");
|
|
754
1067
|
var import_node_path4 = require("node:path");
|
|
755
1068
|
var import_node_stream = require("node:stream");
|
|
756
|
-
var
|
|
1069
|
+
var import_theme_abi3 = require("@tanqory/theme-abi");
|
|
757
1070
|
var import_editability = __toESM(require_editability());
|
|
758
1071
|
|
|
759
1072
|
// ../../apps/build-service/src/artifact/digest.ts
|
|
@@ -1111,6 +1424,7 @@ function allowlistProblem(allowlist, name, version, integrity) {
|
|
|
1111
1424
|
// ../../apps/build-service/src/config/third-party.ts
|
|
1112
1425
|
var import_node_fs2 = require("node:fs");
|
|
1113
1426
|
var import_node_path2 = require("node:path");
|
|
1427
|
+
var import_source = __toESM(require_source());
|
|
1114
1428
|
|
|
1115
1429
|
// ../../apps/build-service/src/config/first-party-themes.ts
|
|
1116
1430
|
var FIRST_PARTY_THEMES = Object.freeze([
|
|
@@ -1141,14 +1455,6 @@ var FIRST_PARTY_THEMES = Object.freeze([
|
|
|
1141
1455
|
]);
|
|
1142
1456
|
|
|
1143
1457
|
// ../../apps/build-service/src/config/third-party.ts
|
|
1144
|
-
var THIRD_PARTY_PLATFORM_PACKAGES = /* @__PURE__ */ new Map([
|
|
1145
|
-
["@tanqory/theme-kit", "runtime"],
|
|
1146
|
-
["@tanqory/theme-abi", "runtime"],
|
|
1147
|
-
["@tanqory/theme-conformance", "runtime"],
|
|
1148
|
-
["@tanqory/cli", "dev"],
|
|
1149
|
-
["@tanqory/dev-mcp", "dev"]
|
|
1150
|
-
]);
|
|
1151
|
-
var EXACT_VERSION_RE = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?$/;
|
|
1152
1458
|
var THIRD_PARTY_TOOLCHAINS_PATH = (0, import_node_path2.join)(
|
|
1153
1459
|
__dirname,
|
|
1154
1460
|
"..",
|
|
@@ -1162,7 +1468,7 @@ function loadThirdPartyKits(path = THIRD_PARTY_TOOLCHAINS_PATH) {
|
|
|
1162
1468
|
throw new Error(`${path}: kits must be a non-empty list`);
|
|
1163
1469
|
const seen = /* @__PURE__ */ new Set();
|
|
1164
1470
|
return doc.kits.map((k) => {
|
|
1165
|
-
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."))
|
|
1166
1472
|
throw new Error(`${path}: ${JSON.stringify(k.version)} is not an exact 2.x version`);
|
|
1167
1473
|
if (seen.has(k.version)) throw new Error(`${path}: ${k.version} is listed twice`);
|
|
1168
1474
|
seen.add(k.version);
|
|
@@ -1181,36 +1487,6 @@ function loadThirdPartyKits(path = THIRD_PARTY_TOOLCHAINS_PATH) {
|
|
|
1181
1487
|
});
|
|
1182
1488
|
}
|
|
1183
1489
|
var STARTER_ABI_VERSION = "2.0";
|
|
1184
|
-
var STARTER_DEFAULT_BUILDS = ["scripts/abi/build.mjs", "scripts/build.mjs"];
|
|
1185
|
-
var STARTER_DEFAULT_OUT = "dist/abi";
|
|
1186
|
-
var STARTER_PATH_RE = /^(?!\/)(?!.*(?:^|\/)\.\.?(?:\/|$))[A-Za-z0-9._-]+(?:\/[A-Za-z0-9._-]+)*$/;
|
|
1187
|
-
var STARTER_PROVIDED_PACKAGES = /* @__PURE__ */ new Set([
|
|
1188
|
-
"react",
|
|
1189
|
-
"react-dom",
|
|
1190
|
-
"vite",
|
|
1191
|
-
"@vitejs/plugin-react"
|
|
1192
|
-
]);
|
|
1193
|
-
function isStarterDevTool(name) {
|
|
1194
|
-
return /^(typescript|vitest|jsdom|axe-core|playwright|playwright-core)$/.test(name) || /^@types\/[a-z0-9._-]+$/.test(name) || /^@testing-library\/[a-z0-9._-]+$/.test(name);
|
|
1195
|
-
}
|
|
1196
|
-
function isStarterIgnoredPath(path) {
|
|
1197
|
-
const first = path.split("/")[0];
|
|
1198
|
-
return [
|
|
1199
|
-
"tests",
|
|
1200
|
-
".github",
|
|
1201
|
-
".vscode",
|
|
1202
|
-
".claude",
|
|
1203
|
-
".codex",
|
|
1204
|
-
".gemini",
|
|
1205
|
-
".cursor",
|
|
1206
|
-
".git",
|
|
1207
|
-
"node_modules",
|
|
1208
|
-
"dist",
|
|
1209
|
-
"reports",
|
|
1210
|
-
"coverage"
|
|
1211
|
-
].includes(first) || // .tanqory/ holds theme inputs (e.g. the Nova fork's frozen contracts); only the dev server's state is dropped
|
|
1212
|
-
path.startsWith(".tanqory/dev/") || [".mcp.json", "AGENTS.md", "CLAUDE.md", ".gitignore", "_gitignore", ".DS_Store"].includes(path);
|
|
1213
|
-
}
|
|
1214
1490
|
|
|
1215
1491
|
// ../../apps/build-service/src/ingest/archive-guard.ts
|
|
1216
1492
|
var import_node_crypto3 = require("node:crypto");
|
|
@@ -1304,28 +1580,16 @@ function leavesOf(files) {
|
|
|
1304
1580
|
}
|
|
1305
1581
|
|
|
1306
1582
|
// ../../apps/build-service/src/ingest/ingest-gate.ts
|
|
1583
|
+
var import_source2 = __toESM(require_source());
|
|
1307
1584
|
var INGEST_LIMITS = Object.freeze({
|
|
1308
|
-
maxEntries:
|
|
1309
|
-
maxUnpackedBytes:
|
|
1310
|
-
maxFileBytes:
|
|
1311
|
-
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,
|
|
1312
1589
|
/** unpacked / compressed, checked once ≥ ratioCheckAfterBytes of archive have been read */
|
|
1313
|
-
maxCompressionRatio:
|
|
1314
|
-
ratioCheckAfterBytes:
|
|
1590
|
+
maxCompressionRatio: import_source2.SOURCE_LIMITS.maxCompressionRatio,
|
|
1591
|
+
ratioCheckAfterBytes: import_source2.SOURCE_LIMITS.ratioCheckAfterBytes
|
|
1315
1592
|
});
|
|
1316
|
-
var DENY_BASENAMES = /* @__PURE__ */ new Set([".npmrc", ".pnpmfile.cjs", "pnpm-workspace.yaml"]);
|
|
1317
|
-
var DENY_SEGMENTS = /* @__PURE__ */ new Set(["node_modules", ".git", ".github", ".husky"]);
|
|
1318
|
-
var ALLOW_FILES = /* @__PURE__ */ new Set(["package.json", "pnpm-lock.yaml", "manifest.json"]);
|
|
1319
|
-
var ALLOW_PREFIXES = [
|
|
1320
|
-
"src/",
|
|
1321
|
-
"sections/",
|
|
1322
|
-
"templates/",
|
|
1323
|
-
"layouts/",
|
|
1324
|
-
"assets/",
|
|
1325
|
-
"locales/",
|
|
1326
|
-
"config/"
|
|
1327
|
-
];
|
|
1328
|
-
var ALLOW_PATTERNS = [/^README[^/]*$/, /^LICENSE[^/]*$/];
|
|
1329
1593
|
var FLATTENED_PREFIXES = ["locales/", "config/templates/", "config/regions/"];
|
|
1330
1594
|
var TOOLCHAIN_EXACT = /* @__PURE__ */ new Set([
|
|
1331
1595
|
"vite",
|
|
@@ -1343,48 +1607,10 @@ var VITE_IMPORT_ALLOW = [/^vite$/, /^@tanqory\/vite-plugin-[a-z0-9-]+$/, /^node:
|
|
|
1343
1607
|
function isToolchainPackage(name) {
|
|
1344
1608
|
return TOOLCHAIN_EXACT.has(name) || TOOLCHAIN_PREFIXES.some((p) => name.startsWith(p));
|
|
1345
1609
|
}
|
|
1346
|
-
var PLATFORM_PACKAGE_SECTIONS = {
|
|
1347
|
-
runtime: ["dependencies", "devDependencies"],
|
|
1348
|
-
dev: ["devDependencies"]
|
|
1349
|
-
};
|
|
1350
1610
|
function basename(path) {
|
|
1351
1611
|
return path.slice(path.lastIndexOf("/") + 1);
|
|
1352
1612
|
}
|
|
1353
|
-
function denyReason(path) {
|
|
1354
|
-
const base = basename(path);
|
|
1355
|
-
const segments = path.split("/");
|
|
1356
|
-
for (const seg of segments) {
|
|
1357
|
-
if (DENY_SEGMENTS.has(seg)) return `${seg}/ is not accepted`;
|
|
1358
|
-
}
|
|
1359
|
-
if (DENY_BASENAMES.has(base))
|
|
1360
|
-
return `${base} is rejected (pnpm/npm configuration is platform-owned)`;
|
|
1361
|
-
if (base.startsWith(".yarnrc"))
|
|
1362
|
-
return `${base} is rejected (yarn configuration is platform-owned)`;
|
|
1363
|
-
if (base.startsWith("Dockerfile")) return "Dockerfiles are rejected";
|
|
1364
|
-
if (base.startsWith(".env")) return "environment files are rejected";
|
|
1365
|
-
if (base.endsWith(".sh")) return "shell scripts are rejected";
|
|
1366
|
-
if (base.endsWith(".node")) return "native addons are rejected";
|
|
1367
|
-
if (base.endsWith(".wasm") && !path.startsWith("assets/"))
|
|
1368
|
-
return "wasm outside assets/ is rejected";
|
|
1369
|
-
return null;
|
|
1370
|
-
}
|
|
1371
|
-
function isAllowed(path) {
|
|
1372
|
-
if (ALLOW_FILES.has(path)) return true;
|
|
1373
|
-
if (ALLOW_PREFIXES.some((p) => path.startsWith(p))) return true;
|
|
1374
|
-
return ALLOW_PATTERNS.some((re) => re.test(path));
|
|
1375
|
-
}
|
|
1376
1613
|
var IMPORT_SPECIFIER_RE = /(?:\bimport\s*(?:[\w*{}\s,$]*\bfrom\s*)?|\bexport\s+[\w*{}\s,$]*\bfrom\s*|\brequire\s*\(\s*|\bimport\s*\(\s*)['"]([^'"]+)['"]/g;
|
|
1377
|
-
function isPlainRegistryRange(spec) {
|
|
1378
|
-
if (typeof spec !== "string" || spec.length === 0 || spec.length > 128) return false;
|
|
1379
|
-
const comparator = /^(?:[<>]=?|=|~|\^)?v?(?:0|[1-9]\d*|[xX*])(?:\.(?:0|[1-9]\d*|[xX*])){0,2}(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/;
|
|
1380
|
-
return spec.split("||").every((set) => {
|
|
1381
|
-
const parts = set.trim().split(/\s+/);
|
|
1382
|
-
if (parts.length === 1 && parts[0] === "") return false;
|
|
1383
|
-
if (parts.length === 3 && parts[1] === "-")
|
|
1384
|
-
return comparator.test(parts[0]) && comparator.test(parts[2]);
|
|
1385
|
-
return parts.every((p) => comparator.test(p));
|
|
1386
|
-
});
|
|
1387
|
-
}
|
|
1388
1614
|
function registryVersionOf(version) {
|
|
1389
1615
|
const m = /^(\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?)(\(.+\))*$/.exec(version);
|
|
1390
1616
|
return m ? m[1] : void 0;
|
|
@@ -1409,9 +1635,9 @@ var IngestGate = class {
|
|
|
1409
1635
|
constructor(opts) {
|
|
1410
1636
|
this.opts = opts;
|
|
1411
1637
|
}
|
|
1412
|
-
inspect(
|
|
1413
|
-
|
|
1414
|
-
|
|
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);
|
|
1415
1641
|
const files = sortLeaves(input);
|
|
1416
1642
|
if (files.length > INGEST_LIMITS.maxEntries) {
|
|
1417
1643
|
throw new IngestRejectedError(
|
|
@@ -1448,7 +1674,7 @@ var IngestGate = class {
|
|
|
1448
1674
|
if (seen.has(f.path))
|
|
1449
1675
|
throw new IngestRejectedError("params", `duplicate path ${f.path}`, f.path);
|
|
1450
1676
|
seen.add(f.path);
|
|
1451
|
-
const deny = denyReason(f.path);
|
|
1677
|
+
const deny = (0, import_source2.denyReason)(f.path);
|
|
1452
1678
|
if (deny) throw new IngestRejectedError("params", `${f.path}: ${deny}`, f.path);
|
|
1453
1679
|
const base = basename(f.path);
|
|
1454
1680
|
if (/^vite(st)?\.config\./.test(base)) {
|
|
@@ -1461,10 +1687,10 @@ var IngestGate = class {
|
|
|
1461
1687
|
);
|
|
1462
1688
|
}
|
|
1463
1689
|
}
|
|
1464
|
-
if (!
|
|
1690
|
+
if (!(0, import_source2.isThemeSourcePath)(f.path)) {
|
|
1465
1691
|
throw new IngestRejectedError(
|
|
1466
1692
|
"params",
|
|
1467
|
-
`${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`,
|
|
1468
1694
|
f.path
|
|
1469
1695
|
);
|
|
1470
1696
|
}
|
|
@@ -1517,7 +1743,9 @@ var IngestGate = class {
|
|
|
1517
1743
|
* - no manifest.json: the build writes it, and the platform checks the build's output.
|
|
1518
1744
|
*/
|
|
1519
1745
|
inspectStarter(input) {
|
|
1520
|
-
const files = sortLeaves(
|
|
1746
|
+
const files = sortLeaves(
|
|
1747
|
+
input.filter((f) => f.path !== "manifest.json" && !(0, import_source2.isStarterIgnoredPath)(f.path))
|
|
1748
|
+
);
|
|
1521
1749
|
if (files.length > INGEST_LIMITS.maxEntries)
|
|
1522
1750
|
throw new IngestRejectedError(
|
|
1523
1751
|
"size",
|
|
@@ -1543,7 +1771,7 @@ var IngestGate = class {
|
|
|
1543
1771
|
if (seen.has(f.path))
|
|
1544
1772
|
throw new IngestRejectedError("params", `duplicate path ${f.path}`, f.path);
|
|
1545
1773
|
seen.add(f.path);
|
|
1546
|
-
const deny = denyReason(f.path);
|
|
1774
|
+
const deny = (0, import_source2.denyReason)(f.path);
|
|
1547
1775
|
if (deny) throw new IngestRejectedError("params", `${f.path}: ${deny}`, f.path);
|
|
1548
1776
|
}
|
|
1549
1777
|
if (total > INGEST_LIMITS.maxUnpackedBytes)
|
|
@@ -1589,99 +1817,17 @@ var IngestGate = class {
|
|
|
1589
1817
|
};
|
|
1590
1818
|
}
|
|
1591
1819
|
checkStarterPackageJson(file, paths) {
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
} catch {
|
|
1596
|
-
throw new IngestRejectedError("params", "package.json is not valid JSON", file.path);
|
|
1597
|
-
}
|
|
1598
|
-
if (typeof pkg["name"] !== "string" || typeof pkg["version"] !== "string")
|
|
1599
|
-
throw new IngestRejectedError(
|
|
1600
|
-
"params",
|
|
1601
|
-
'package.json needs string "name" and "version"',
|
|
1602
|
-
file.path
|
|
1603
|
-
);
|
|
1604
|
-
for (const key of ["resolutions", "workspaces", "overrides"])
|
|
1605
|
-
if (key in pkg)
|
|
1606
|
-
throw new IngestRejectedError("params", `package.json "${key}" is rejected`, file.path);
|
|
1607
|
-
const pnpm = pkg["pnpm"] ?? {};
|
|
1608
|
-
for (const key of ["overrides", "patchedDependencies", "onlyBuiltDependencies"])
|
|
1609
|
-
if (key in pnpm)
|
|
1610
|
-
throw new IngestRejectedError("params", `package.json "pnpm.${key}" is rejected`, file.path);
|
|
1611
|
-
const tq = pkg["tanqory"] ?? {};
|
|
1612
|
-
if (typeof tq !== "object" || Array.isArray(tq))
|
|
1613
|
-
throw new IngestRejectedError("params", 'package.json "tanqory" must be an object', file.path);
|
|
1614
|
-
const build = tq["build"] ?? STARTER_DEFAULT_BUILDS.find((b) => paths.has(b)) ?? STARTER_DEFAULT_BUILDS[1];
|
|
1615
|
-
const out = tq["out"] ?? STARTER_DEFAULT_OUT;
|
|
1616
|
-
if (typeof build !== "string" || !STARTER_PATH_RE.test(build) || !build.endsWith(".mjs"))
|
|
1617
|
-
throw new IngestRejectedError(
|
|
1618
|
-
"params",
|
|
1619
|
-
`package.json tanqory.build ${JSON.stringify(build)} must be a relative path to a .mjs file in the theme`,
|
|
1620
|
-
file.path
|
|
1621
|
-
);
|
|
1622
|
-
if (!paths.has(build))
|
|
1623
|
-
throw new IngestRejectedError(
|
|
1624
|
-
"params",
|
|
1625
|
-
`the build file ${build} is not in the upload (package.json tanqory.build, or ${STARTER_DEFAULT_BUILDS.join(" / ")})`,
|
|
1626
|
-
build
|
|
1627
|
-
);
|
|
1628
|
-
if (typeof out !== "string" || !STARTER_PATH_RE.test(out))
|
|
1629
|
-
throw new IngestRejectedError(
|
|
1630
|
-
"params",
|
|
1631
|
-
`package.json tanqory.out ${JSON.stringify(out)} must be a relative directory in the theme`,
|
|
1632
|
-
file.path
|
|
1633
|
-
);
|
|
1634
|
-
const sections = ["dependencies", "devDependencies", "optionalDependencies", "peerDependencies"];
|
|
1635
|
-
let kit = false;
|
|
1636
|
-
for (const section of sections) {
|
|
1637
|
-
const deps = pkg[section] ?? {};
|
|
1638
|
-
for (const [name, spec] of Object.entries(deps)) {
|
|
1639
|
-
if (typeof spec !== "string" || !isPlainRegistryRange(spec))
|
|
1640
|
-
throw new IngestRejectedError(
|
|
1641
|
-
"deps",
|
|
1642
|
-
`package.json ${section}.${name}: ${JSON.stringify(spec)} is not a plain registry version range`,
|
|
1643
|
-
file.path,
|
|
1644
|
-
{ entry: name }
|
|
1645
|
-
);
|
|
1646
|
-
const platform = THIRD_PARTY_PLATFORM_PACKAGES.get(name);
|
|
1647
|
-
if (platform) {
|
|
1648
|
-
const allowed = PLATFORM_PACKAGE_SECTIONS[platform];
|
|
1649
|
-
if (!allowed.includes(section))
|
|
1650
|
-
throw new IngestRejectedError(
|
|
1651
|
-
"deps",
|
|
1652
|
-
`package.json ${section}.${name}: ${name} may be named only in ${allowed.join(" or ")}`,
|
|
1653
|
-
file.path,
|
|
1654
|
-
{ entry: name }
|
|
1655
|
-
);
|
|
1656
|
-
if (!EXACT_VERSION_RE.test(spec))
|
|
1657
|
-
throw new IngestRejectedError(
|
|
1658
|
-
"deps",
|
|
1659
|
-
`package.json ${section}.${name}: ${JSON.stringify(spec)} must be an exact version (e.g. "2.0.0-alpha.3"), not a range`,
|
|
1660
|
-
file.path,
|
|
1661
|
-
{ entry: name }
|
|
1662
|
-
);
|
|
1663
|
-
if (name === "@tanqory/theme-kit") kit = true;
|
|
1664
|
-
continue;
|
|
1665
|
-
}
|
|
1666
|
-
if (STARTER_PROVIDED_PACKAGES.has(name) && (section === "dependencies" || section === "devDependencies"))
|
|
1667
|
-
continue;
|
|
1668
|
-
if (isStarterDevTool(name) && section === "devDependencies") continue;
|
|
1669
|
-
throw new IngestRejectedError(
|
|
1670
|
-
"deps",
|
|
1671
|
-
`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)`,
|
|
1672
|
-
file.path,
|
|
1673
|
-
{ entry: name }
|
|
1674
|
-
);
|
|
1675
|
-
}
|
|
1676
|
-
}
|
|
1677
|
-
if (!kit)
|
|
1820
|
+
const { problems } = (0, import_source2.starterPackageProblems)(file.bytes.toString("utf8"), paths);
|
|
1821
|
+
const first = problems[0];
|
|
1822
|
+
if (first)
|
|
1678
1823
|
throw new IngestRejectedError(
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
{ entry:
|
|
1824
|
+
first.kind,
|
|
1825
|
+
first.message,
|
|
1826
|
+
first.path,
|
|
1827
|
+
first.entry ? { entry: first.entry } : void 0
|
|
1683
1828
|
);
|
|
1684
|
-
|
|
1829
|
+
const pkg = JSON.parse(file.bytes.toString("utf8"));
|
|
1830
|
+
return { name: pkg.name, version: pkg.version };
|
|
1685
1831
|
}
|
|
1686
1832
|
checkCollisions(files) {
|
|
1687
1833
|
const folded = /* @__PURE__ */ new Map();
|
|
@@ -1751,7 +1897,7 @@ var IngestGate = class {
|
|
|
1751
1897
|
]) {
|
|
1752
1898
|
const deps = pkg[section] ?? {};
|
|
1753
1899
|
for (const [name, spec] of Object.entries(deps)) {
|
|
1754
|
-
if (typeof spec !== "string" || !isPlainRegistryRange(spec)) {
|
|
1900
|
+
if (typeof spec !== "string" || !(0, import_source2.isPlainRegistryRange)(spec)) {
|
|
1755
1901
|
throw new IngestRejectedError(
|
|
1756
1902
|
"deps",
|
|
1757
1903
|
`package.json ${section}.${name}: ${JSON.stringify(spec)} is not a plain registry version range`,
|
|
@@ -1759,9 +1905,9 @@ var IngestGate = class {
|
|
|
1759
1905
|
{ entry: name }
|
|
1760
1906
|
);
|
|
1761
1907
|
}
|
|
1762
|
-
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;
|
|
1763
1909
|
if (platform) {
|
|
1764
|
-
const sections = PLATFORM_PACKAGE_SECTIONS[platform];
|
|
1910
|
+
const sections = import_source2.PLATFORM_PACKAGE_SECTIONS[platform];
|
|
1765
1911
|
if (!sections.includes(section))
|
|
1766
1912
|
throw new IngestRejectedError(
|
|
1767
1913
|
"deps",
|
|
@@ -1769,7 +1915,7 @@ var IngestGate = class {
|
|
|
1769
1915
|
file.path,
|
|
1770
1916
|
{ entry: name }
|
|
1771
1917
|
);
|
|
1772
|
-
if (!EXACT_VERSION_RE.test(spec))
|
|
1918
|
+
if (!import_source2.EXACT_VERSION_RE.test(spec))
|
|
1773
1919
|
throw new IngestRejectedError(
|
|
1774
1920
|
"deps",
|
|
1775
1921
|
`package.json ${section}.${name}: ${JSON.stringify(spec)} must be an exact version (e.g. "2.0.0-alpha.3"), not a range`,
|
|
@@ -1791,7 +1937,7 @@ var IngestGate = class {
|
|
|
1791
1937
|
for (const section of ["dependencies", "devDependencies", "optionalDependencies"]) {
|
|
1792
1938
|
const deps = pkg[section] ?? {};
|
|
1793
1939
|
for (const name of Object.keys(deps)) {
|
|
1794
|
-
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;
|
|
1795
1941
|
if (!this.opts.allowlist.packages.has(name)) {
|
|
1796
1942
|
throw new IngestRejectedError(
|
|
1797
1943
|
"deps",
|
|
@@ -1875,7 +2021,7 @@ var IngestGate = class {
|
|
|
1875
2021
|
if (d.importer !== ".") refuse(`${at}: only the root importer "." is accepted`, d.name);
|
|
1876
2022
|
if (d.section === "peerDependencies")
|
|
1877
2023
|
refuse(`${at}: an importer peer dependency is not accepted`, d.name);
|
|
1878
|
-
if (!isPlainRegistryRange(d.specifier))
|
|
2024
|
+
if (!(0, import_source2.isPlainRegistryRange)(d.specifier))
|
|
1879
2025
|
refuse(
|
|
1880
2026
|
`${at}: specifier ${JSON.stringify(d.specifier)} is not a plain registry range`,
|
|
1881
2027
|
d.name
|
|
@@ -1885,7 +2031,7 @@ var IngestGate = class {
|
|
|
1885
2031
|
refuse(`${at}: version ${JSON.stringify(d.version)} is not a registry version`, d.name);
|
|
1886
2032
|
if (!checked.has(`${d.name}@${version}`))
|
|
1887
2033
|
refuse(`${at}: ${d.name}@${version} has no entry in packages:`, d.name);
|
|
1888
|
-
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)
|
|
1889
2035
|
refuse(
|
|
1890
2036
|
`${at}: specifier ${d.specifier} must be the exact version it resolves to (${version})`,
|
|
1891
2037
|
d.name
|
|
@@ -1972,7 +2118,7 @@ function platformOnlyClosure(lock) {
|
|
|
1972
2118
|
if (d.importer !== ".") continue;
|
|
1973
2119
|
const v = registryVersionOf(d.version);
|
|
1974
2120
|
if (!v) continue;
|
|
1975
|
-
(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}`);
|
|
1976
2122
|
}
|
|
1977
2123
|
const other = reach(otherRoots);
|
|
1978
2124
|
return new Set([...reach(platformRoots)].filter((k) => !other.has(k)));
|
|
@@ -2152,11 +2298,210 @@ async function extractTarballGuarded(input, limits = INGEST_LIMITS) {
|
|
|
2152
2298
|
};
|
|
2153
2299
|
}
|
|
2154
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
|
+
|
|
2155
2500
|
// ../../apps/build-service/src/review/static-checks.ts
|
|
2156
2501
|
var import_node_fs3 = require("node:fs");
|
|
2157
2502
|
var import_node_path3 = require("node:path");
|
|
2158
|
-
var
|
|
2159
|
-
var
|
|
2503
|
+
var import_acorn2 = require("acorn");
|
|
2504
|
+
var import_acorn_walk2 = require("acorn-walk");
|
|
2160
2505
|
var import_zod = require("zod");
|
|
2161
2506
|
var FINDINGS_MAX = 50;
|
|
2162
2507
|
var isClientScript = (p) => /^client\/assets\/[A-Za-z0-9._-]+\.m?js$/.test(p);
|
|
@@ -2170,17 +2515,17 @@ var calleeName = (callee) => {
|
|
|
2170
2515
|
function evalFindings(path, source) {
|
|
2171
2516
|
let ast;
|
|
2172
2517
|
try {
|
|
2173
|
-
ast = (0,
|
|
2518
|
+
ast = (0, import_acorn2.parse)(source, { ecmaVersion: "latest", sourceType: "module", locations: true });
|
|
2174
2519
|
} catch {
|
|
2175
2520
|
try {
|
|
2176
|
-
ast = (0,
|
|
2521
|
+
ast = (0, import_acorn2.parse)(source, { ecmaVersion: "latest", sourceType: "script", locations: true });
|
|
2177
2522
|
} catch (e) {
|
|
2178
2523
|
return [{ path, code: "parse_error", message: `${path} does not parse as JavaScript: ${e.message}` }];
|
|
2179
2524
|
}
|
|
2180
2525
|
}
|
|
2181
2526
|
const out = [];
|
|
2182
2527
|
const at = (n) => `${path}:${n.loc?.start.line ?? 0}:${(n.loc?.start.column ?? 0) + 1}`;
|
|
2183
|
-
(0,
|
|
2528
|
+
(0, import_acorn_walk2.full)(ast, (node) => {
|
|
2184
2529
|
if (node.type !== "CallExpression" && node.type !== "NewExpression") return;
|
|
2185
2530
|
const n = node;
|
|
2186
2531
|
const name = calleeName(n.callee);
|
|
@@ -2296,12 +2641,7 @@ function licencesLine(files, table) {
|
|
|
2296
2641
|
}
|
|
2297
2642
|
|
|
2298
2643
|
// ../../apps/build-service/src/review/partner-source.ts
|
|
2299
|
-
var
|
|
2300
|
-
var EMOJI = /([\p{Extended_Pictographic}\u{1F1E6}-\u{1F1FF}])(\u{FE0F})?/gu;
|
|
2301
|
-
var TEXT_FORM_ALLOWED = /* @__PURE__ */ new Set(["\xA9", "\xAE", "\u2122"]);
|
|
2302
|
-
var hasEmoji = (s) => [...s.matchAll(EMOJI)].some(([, ch, vs]) => vs || !TEXT_FORM_ALLOWED.has(ch));
|
|
2303
|
-
var LABEL_KEYS = /* @__PURE__ */ new Set(["name", "title", "label", "info", "placeholder", "description"]);
|
|
2304
|
-
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: [] };
|
|
2305
2645
|
function treeOf(dir) {
|
|
2306
2646
|
const out = [];
|
|
2307
2647
|
const walk = (abs) => {
|
|
@@ -2332,22 +2672,22 @@ async function editabilityLine(files, imageFetch) {
|
|
|
2332
2672
|
const img = await (0, import_editability.checkImageLinks)(text, { fetch: imageFetch });
|
|
2333
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}` : ""}` });
|
|
2334
2674
|
}
|
|
2335
|
-
return
|
|
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)` : ""}`);
|
|
2336
2676
|
}
|
|
2337
2677
|
async function checkPartnerSource(tgz, built, opts = {}) {
|
|
2338
2678
|
const lines = [];
|
|
2339
2679
|
let files = [];
|
|
2340
2680
|
try {
|
|
2341
|
-
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);
|
|
2342
2682
|
} catch (e) {
|
|
2343
|
-
lines.push(
|
|
2683
|
+
lines.push(line2("archive", [failure(e)], ""));
|
|
2344
2684
|
}
|
|
2345
2685
|
let ingest = null;
|
|
2346
2686
|
try {
|
|
2347
2687
|
ingest = new IngestGate({ mirrorHosts: [], allowlist: loadMirrorAllowlist(), thirdParty: true }).inspect(files);
|
|
2348
|
-
lines.push(
|
|
2688
|
+
lines.push(line2("ingest_gate", [], `${ingest.layout} layout, ${ingest.files.length} build input(s)`));
|
|
2349
2689
|
} catch (e) {
|
|
2350
|
-
lines.push(
|
|
2690
|
+
lines.push(line2("ingest_gate", [failure(e)], ""));
|
|
2351
2691
|
}
|
|
2352
2692
|
const pkg = JSON.parse(files.find((f) => f.path === "package.json")?.bytes.toString("utf8") ?? "{}");
|
|
2353
2693
|
const pinOf = (name) => pkg["dependencies"]?.[name] ?? pkg["devDependencies"]?.[name];
|
|
@@ -2361,20 +2701,9 @@ async function checkPartnerSource(tgz, built, opts = {}) {
|
|
|
2361
2701
|
const abi = pinOf("@tanqory/theme-abi");
|
|
2362
2702
|
if (abi !== void 0 && ingest?.layout !== "theme-source" && abi !== starterAbi)
|
|
2363
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.` });
|
|
2364
|
-
lines.push(
|
|
2365
|
-
const text = [];
|
|
2366
|
-
|
|
2367
|
-
if (BRAND_RE.test(f.path)) text.push({ path: f.path, code: "brand_term", message: `The file name ${f.path} names another commerce platform. Rename it.` });
|
|
2368
|
-
else if (!f.bytes.subarray(0, 8192).includes(0)) {
|
|
2369
|
-
const s = f.bytes.toString("utf8");
|
|
2370
|
-
const i = s.search(BRAND_RE);
|
|
2371
|
-
if (i >= 0) {
|
|
2372
|
-
const at = s.slice(0, i).split("\n").length;
|
|
2373
|
-
text.push({ path: `${f.path}:${at}`, code: "brand_term", message: `${f.path} line ${at} names another commerce platform. Use your theme's own words.` });
|
|
2374
|
-
}
|
|
2375
|
-
}
|
|
2376
|
-
}
|
|
2377
|
-
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`));
|
|
2378
2707
|
lines.push(await editabilityLine(files, opts.imageFetch));
|
|
2379
2708
|
if (built) {
|
|
2380
2709
|
const out = treeOf(built);
|
|
@@ -2384,20 +2713,13 @@ async function checkPartnerSource(tgz, built, opts = {}) {
|
|
|
2384
2713
|
if (!manifestFile) mErrors.push({ path: "manifest.json", code: "manifest_missing", message: `The build wrote no manifest.json in ${built}.` });
|
|
2385
2714
|
else {
|
|
2386
2715
|
manifest = JSON.parse(manifestFile.bytes.toString("utf8"));
|
|
2387
|
-
const r = (0,
|
|
2716
|
+
const r = (0, import_theme_abi3.validateManifest)(manifest, { artifactFiles: out.map((f) => f.path) });
|
|
2388
2717
|
if (!r.ok) for (const e of r.errors) mErrors.push({ path: e.path, code: e.code, message: e.message });
|
|
2389
2718
|
}
|
|
2390
|
-
lines.push(
|
|
2391
|
-
const labels =
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
if (key !== null && LABEL_KEYS.has(key)) labels.push([path || "/", v]);
|
|
2395
|
-
} else if (Array.isArray(v)) v.forEach((x, i) => walk(x, `${path}/${i}`, key));
|
|
2396
|
-
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);
|
|
2397
|
-
};
|
|
2398
|
-
walk(manifest, "", null);
|
|
2399
|
-
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`));
|
|
2400
|
-
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`));
|
|
2401
2723
|
const noEval = noEvalLine(out);
|
|
2402
2724
|
lines.push({ key: "no_eval", ...noEval });
|
|
2403
2725
|
if (ingest) {
|
|
@@ -2413,8 +2735,37 @@ async function checkPartnerSource(tgz, built, opts = {}) {
|
|
|
2413
2735
|
}
|
|
2414
2736
|
return { tgzBytes: tgz.length, layout: ingest?.layout ?? null, lines };
|
|
2415
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
|
+
}
|
|
2416
2754
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2417
2755
|
0 && (module.exports = {
|
|
2756
|
+
SOURCE_LIMITS,
|
|
2757
|
+
budgetsLine,
|
|
2418
2758
|
checkPartnerSource,
|
|
2419
|
-
|
|
2759
|
+
denyFix,
|
|
2760
|
+
denyReason,
|
|
2761
|
+
editabilityLine,
|
|
2762
|
+
entryScanLine,
|
|
2763
|
+
isStarterIgnoredPath,
|
|
2764
|
+
isStarterTree,
|
|
2765
|
+
localSandboxLines,
|
|
2766
|
+
networkLine,
|
|
2767
|
+
reproducibleLine,
|
|
2768
|
+
starterPackageProblems,
|
|
2769
|
+
treeDigest,
|
|
2770
|
+
withoutPackFolder
|
|
2420
2771
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanqory/partner-cli",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.3",
|
|
4
4
|
"description": "Build, check and upload Tanqory partner themes: a starter that passes every partner check, the platform's own partner source checks run locally, packaging, upload through the Partner API with your partner sign-in, and an MCP server with the same operations.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Tanqory",
|