Building and Packaging

The theme CLI is one of the theme tools, available to customers from My Account on onlinepokerscript.com. It is not published to npm and is not part of the Docker image.

The theme CLI turns a source tree into an archive, validates it, and runs a development proxy against a local product. It uses the product’s own validator and contract from the Poker Engine source, uses development dependencies only, and pins them to the product’s versions.

Commands

npm run theme -- build <dir> [--sourcemap]               # compile the theme into dist/
npm run theme -- pack <dir> [--out <dir>] [--skip-validation]
                                                        # validate, then write dist/<slug>-<version>.tgz
npm run theme -- validate <dir | archive.tgz> [--json]  # run the validator; the same rules as upload
npm run theme -- dev <dir> [--port 5180] [--vite-port 5173]
                                                        # proxy a local product with the theme rebuilding live
npm run theme -- fonts <dir> --family <id>              # copy font families into fonts/ with their licence text
npm run theme -- lint-rtl <dir>                         # right-to-left lint over the theme's TSX and CSS

Every command takes the theme’s source directory (the one holding theme.json and src/). The directory can be anywhere; it needs no package.json or node_modules. Run the commands from the root of the Poker Engine source, with its dependencies installed (npm ci). npm run theme -- --help prints the CLI’s usage.

build

  • Library mode, ES module output, one entry (the manifest’s entry, dist/<name>.js) and lazy chunks (dist/chunks/). A registration written as () => import('./file') becomes a chunk the host loads on demand.
  • One stylesheet (the manifest’s styles, dist/<name>.css); no CSS code splitting. A theme whose entry imports a stylesheet must declare styles; a tokens-only theme declares none.
  • Readable JavaScript. The output is not minified, because the scanner rejects minified files as obfuscation (see Validation and Scanner Rules). Dead code and unused host exports are dropped.
  • Assets are never inlined, because the content security policy blocks inline fonts. Refer to the theme’s own files with root-relative URLs (url(/fonts/inter/inter-latin-400-normal.woff2), url(/assets/felt.svg)); the build checks they exist and emits them relative to the stylesheet.
  • No module preload, so the host controls loading order.
  • react, react/jsx-runtime, react-dom and @pe/sdk are rewritten to the copies the host exposes, read once per bundle in the prologue the scanner allows. The theme never ships React.
  • The build finds those host reads by parsing each output file, not by searching its text. A string, template literal or comment that happens to contain window.__pokerEngine is your theme’s data and is kept exactly as written.
  • Tailwind, when used, is imported as tailwindcss/theme.css and tailwindcss/utilities.css (never tailwindcss, which carries preflight) with prefix(<prefix>), where the prefix is the letters of the slug. The compiled sheet opens with the layer order and sits entirely inside @layer pe-theme; Tailwind’s own layers are flattened into it, because the validator allows no other layer.
  • The build fails on a manifest that does not pass the contract schema, a Tailwind import without the prefix or with preflight, a package URL that points at a missing file, or a relative @import that carries options.

pack

Runs the validator over the files it is about to archive and, when no error remains, writes dist/<slug>-<version>.tgz rooted at <slug>/ with only the files on the extension allow-list (js css json woff2 svg png webp jpg mp3 ogg md txt and a root LICENSE). Sources, node_modules/, dot-files, source maps and earlier archives are left out and listed. An error finding stops the pack and is printed as rule file:line message; --skip-validation writes the archive regardless. The archive is reproducible: the same build packs to the same bytes wherever it is built (SOURCE_DATE_EPOCH sets the entry timestamp). It is what you upload in Site & Content › Themes.

validate

Runs every rule in Validation and Scanner Rules on a theme directory or a .tgz and prints the report the server would print, one finding per line as rule severity file:line:column message, errors first, then a summary. --json prints the report object. The exit code is 0 when no error remains, 1 on errors, 2 on usage errors. On a source directory the validator sees exactly the files pack would archive.

dev

A proxy on port 5180 in front of the client’s development server (5173, which proxies the API on 3000). It rebuilds the theme on every change under the folder, answers GET /api/v1/config/theme with the local build as if it were the active theme, serves /themes/<slug>/<version>/… from dist/, proxies everything else, and injects a reload client so the page reloads after each rebuild:

theme dev: http://localhost:5180  (theme sample-parts@0.1.0 from …/sample-parts; client via http://localhost:5173)
rebuilt sample-parts@0.1.0; reloading 1 client(s)

Nothing is installed on the server. The proxy serves no settings (each value is missing, so code must fall back to its defaults), no parent chain beyond default, and ignores the Show the active theme to players switch. --link, building straight into a local server’s installed-themes folder, is not yet supported: install with pack and Site & Content › Themes instead.

fonts

Copies installed @fontsource/<id> families into fonts/<id>/ with their licence text, latin and latin-ext subsets only, writes src/styles/fonts.css and records each family in theme.json as { family, files: [{ path, weight, style, subset }], license }.

lint-rtl

Lints the theme’s TSX and CSS for physical-direction utilities and properties. A table layout that cannot be mirrored declares rtlLocked in theme.json and its files under src/layouts/<id>/ are exempt; a skin of the built-in standard layout is exempt too, because that layout is locked left-to-right.

The contract snapshot

A theme is built against a versioned export of the contract: types, the SDK declarations, the manifest schema, the validator, the token list, the DOM contract, the tag dictionary and the scanner’s test corpus. The product writes it with:

npm run themes:export-contract -- --out <dir> [--fixtures]

which prints Theme contract 0.2.0 exported to <dir> and writes VERSION, types.d.ts, sdk.d.ts, manifest.schema.json, ids.json, sections.json, tokens.json, tags.json, dom-contract.json, rules.json, validator.mjs and corpus/. A theme pins the version in engines.contract. The CLI reads the contract directly from the Poker Engine source; building a theme from the snapshot alone, without the source, is not yet supported.

Continuous integration

A theme’s own CI pipeline built on the contract snapshot alone, without the Poker Engine source, is not yet supported. A pipeline that has the source and the theme tools can run validate, lint-rtl and pack and fail on their exit codes.

Try the live demo Pricing

Have questions about Poker Engine? We reply fast.