@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
package/lib/check.mjs
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
// `theme check`: the partner checks that need no sandbox, run here exactly as the platform runs them on an upload
|
|
2
2
|
// (build-service's own code, bundled into lib/vendor by scripts/prepare.mjs):
|
|
3
|
-
// ingest_gate, sandbox_build, source_text
|
|
3
|
+
// ingest_gate, sandbox_build, source_text, editability on the .tgz `theme package` makes (editability: every
|
|
4
|
+
// word, image, link and list a shopper sees is a setting or a block, labels in
|
|
5
|
+
// English and Thai, and every image address answers; theme-standard EDITABILITY.md)
|
|
4
6
|
// manifest, manifest_brand_term, manifest_emoji, no_eval, licences on the build output (dist/abi)
|
|
5
7
|
// The other six lines (the two sandbox builds and their digests, entry scan, ABI conformance, network allowlist,
|
|
6
8
|
// budgets, accessibility, preview renders) run the theme, in the platform's sandbox, when a version is installed on a
|
|
7
9
|
// development store (`theme install`). `--conformance` also runs the ABI conformance suites here, when
|
|
8
10
|
// @tanqory/theme-conformance is installed in the theme (they need workerd and Chromium).
|
|
9
11
|
import { createRequire } from 'node:module'
|
|
10
|
-
import { existsSync } from 'node:fs'
|
|
12
|
+
import { cpSync, existsSync, mkdtempSync, rmSync } from 'node:fs'
|
|
13
|
+
import { tmpdir } from 'node:os'
|
|
11
14
|
import { join } from 'node:path'
|
|
12
15
|
import { spawnSync } from 'node:child_process'
|
|
13
16
|
import { buildTheme, packSource, ThemeError } from './theme.mjs'
|
|
@@ -31,11 +34,34 @@ function vendor() {
|
|
|
31
34
|
return require(p)
|
|
32
35
|
}
|
|
33
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
|
+
|
|
34
60
|
/** Build, pack and check `dir`. Returns `{ ok, lines, tgzBytes, layout, out }`; never throws for a failed check. */
|
|
35
61
|
export async function checkTheme(dir, { build = true, quiet = false } = {}) {
|
|
36
62
|
const out = build ? buildTheme(dir, { quiet }).out : join(dir, 'dist', 'abi')
|
|
37
63
|
const { bytes } = await packSource(dir)
|
|
38
|
-
const report = await vendor().checkPartnerSource(bytes, out)
|
|
64
|
+
const report = await vendor().checkPartnerSource(bytes, out, { imageFetch: globalThis.fetch })
|
|
39
65
|
return { ok: report.lines.every((l) => l.status === 'passed'), lines: report.lines, tgzBytes: report.tgzBytes, layout: report.layout, out }
|
|
40
66
|
}
|
|
41
67
|
|
|
@@ -57,7 +83,8 @@ export function formatLines(lines) {
|
|
|
57
83
|
const rows = []
|
|
58
84
|
for (const l of lines) {
|
|
59
85
|
rows.push(`${l.status === 'passed' ? 'passed' : 'FAILED'} ${l.key}: ${l.message}`)
|
|
60
|
-
|
|
86
|
+
// every finding of a failed line as file, rule, message (the first is also the line's message)
|
|
87
|
+
if (l.status !== 'passed') for (const e of l.errors.slice(0, 20)) rows.push(` ${e.path || '(source)'} ${e.code || 'error'} ${e.message}`)
|
|
61
88
|
}
|
|
62
89
|
return rows.join('\n')
|
|
63
90
|
}
|
package/lib/mcp.mjs
CHANGED
|
@@ -47,7 +47,7 @@ export function toolList() {
|
|
|
47
47
|
confirmationToken: confirm,
|
|
48
48
|
}, ['dir'], ann(false)),
|
|
49
49
|
tool('partner_theme_install', 'Install a version on a development store', "Builds the version in Tanqory's sandbox, runs every check and installs it as the store's developer draft, never live. You approve it first.", { versionId: { type: 'string' }, storeId: { type: 'string', description: 'Leave out when the organization has one development store.' }, org, confirmationToken: confirm }, ['versionId'], ann(false)),
|
|
50
|
-
tool('partner_theme_status', 'Read a version and its checks', 'Shows a version, each of its
|
|
50
|
+
tool('partner_theme_status', 'Read a version and its checks', 'Shows a version, each of its 15 check lines and its development installs with the preview link. Each read moves the install and the checks on.', { versionId: { type: 'string' }, org }, ['versionId'], ann(true)),
|
|
51
51
|
tool('partner_theme_list', 'List partner themes', "Lists the organization's themes and each one's latest version.", { org }, null, ann(true)),
|
|
52
52
|
tool('partner_development_stores', 'List development stores', "Lists the organization's development stores, to install a version on.", { org }, null, ann(true)),
|
|
53
53
|
]
|
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
|
@@ -7,11 +7,15 @@
|
|
|
7
7
|
// walk that applies the folder's .gitignore;
|
|
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
|
-
// uses its own toolchain)
|
|
11
|
-
//
|
|
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.);
|
|
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
|
}
|