@shop-on/theme-cli 0.3.0 → 0.5.0
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/dist/audit/server.mjs +21 -2
- package/package.json +4 -3
package/dist/audit/server.mjs
CHANGED
|
@@ -6,6 +6,8 @@ import path from "node:path";
|
|
|
6
6
|
import { spawn } from "node:child_process";
|
|
7
7
|
import net from "node:net";
|
|
8
8
|
import os from "node:os";
|
|
9
|
+
import { currentPresetHandle } from "@shop-on/theme-contract/preset-listing";
|
|
10
|
+
import { materializePreset } from "@shop-on/theme-contract/preset-materializer";
|
|
9
11
|
//#region src/audit/server.ts
|
|
10
12
|
const STOP_GRACE_MS = 5e3;
|
|
11
13
|
async function freePort() {
|
|
@@ -86,6 +88,23 @@ function tail({ logPath, secrets }) {
|
|
|
86
88
|
return lines.length ? `:\n${lines.join("\n")}` : "";
|
|
87
89
|
}
|
|
88
90
|
/**
|
|
91
|
+
* Copies a build's `config/` to `target` with its current preset applied, as
|
|
92
|
+
* the orchestrator does at install. The build keeps each preset's templates and
|
|
93
|
+
* section groups in `listings/<handle>/`, and the loader treats a built config
|
|
94
|
+
* as already applied: served as is, a theme whose base templates are empty
|
|
95
|
+
* (volt's) renders a blank page.
|
|
96
|
+
*/
|
|
97
|
+
async function stageConfig(source, target) {
|
|
98
|
+
cpSync(source, target, { recursive: true });
|
|
99
|
+
const settingsPath = path.join(target, "settings-data.json");
|
|
100
|
+
if (!existsSync(settingsPath)) return;
|
|
101
|
+
const presetHandle = currentPresetHandle(JSON.parse(readFileSync(settingsPath, "utf-8")));
|
|
102
|
+
if (presetHandle) await materializePreset({
|
|
103
|
+
configDir: target,
|
|
104
|
+
presetHandle
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
89
108
|
* The runtime the platform serves a theme on is workerd, loading the build's
|
|
90
109
|
* module map with `config/` beside the server modules and `CONFIG_DIR` pointing
|
|
91
110
|
* at it (`apps/storefront-orchestrator/src/routes/shard.ts`). Locally that is
|
|
@@ -111,7 +130,7 @@ async function startBuiltServer(themeDir, env) {
|
|
|
111
130
|
try {
|
|
112
131
|
const bundle = path.join(tmp, "bundle");
|
|
113
132
|
cpSync(path.join(output, "server"), bundle, { recursive: true });
|
|
114
|
-
|
|
133
|
+
await stageConfig(path.join(output, "config"), path.join(bundle, "config"));
|
|
115
134
|
const manifest = path.join(output, "public/.vite/manifest.json");
|
|
116
135
|
if (existsSync(manifest)) {
|
|
117
136
|
mkdirSync(path.join(bundle, "public/.vite"), { recursive: true });
|
|
@@ -187,4 +206,4 @@ async function startBuiltServer(themeDir, env) {
|
|
|
187
206
|
}
|
|
188
207
|
}
|
|
189
208
|
//#endregion
|
|
190
|
-
export { freePort, startBuiltServer, startServer };
|
|
209
|
+
export { freePort, stageConfig, startBuiltServer, startServer };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shop-on/theme-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "The Shop-On theme developer CLI: `shop-on login`, `shop-on theme init`, `shop-on theme dev`, `shop-on theme audit` and `shop-on theme pack`.",
|
|
5
5
|
"license": "SEE LICENSE IN dist/LICENSE.md",
|
|
6
6
|
"bin": {
|
|
@@ -15,8 +15,9 @@
|
|
|
15
15
|
"lighthouse": "^13.5.0",
|
|
16
16
|
"tar": "^7.5.22",
|
|
17
17
|
"wrangler": "4.151.0",
|
|
18
|
-
"@shop-on/theme-
|
|
19
|
-
"@shop-on/create-theme": "0.
|
|
18
|
+
"@shop-on/theme-contract": "0.5.0",
|
|
19
|
+
"@shop-on/create-theme": "0.5.0",
|
|
20
|
+
"@shop-on/theme-dev-host": "0.5.0"
|
|
20
21
|
},
|
|
21
22
|
"devDependencies": {
|
|
22
23
|
"@types/node": "26.6.5",
|