@jay-framework/wix-deploy 0.23.1 → 0.24.1

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.
@@ -43,12 +43,36 @@ oauthStrategy:
43
43
 
44
44
  ### 5. Authenticate with Wix CLI
45
45
 
46
+ Run in your terminal:
47
+
46
48
  ```bash
47
- wix login
49
+ npx @wix/cli login
48
50
  ```
49
51
 
50
52
  Stores OAuth tokens in `~/.wix/auth/`. The deploy command refreshes expired tokens automatically.
51
53
 
54
+ ### 5b. Grant Velo deploy permissions to the headless application
55
+
56
+ Open the permissions dashboard for your headless application (`appId` from `wix.config.json`):
57
+
58
+ `https://manage.wix.com/apps/<appId>/dev-center-permissions`
59
+
60
+ Add:
61
+
62
+ | Permission | Required for |
63
+ |------------|--------------|
64
+ | `VELO.APP_PROJECT_READ` | Reading app project before deploy |
65
+ | `VELO.APP_DEPLOYMENT_CREATE` | Creating and releasing deployments |
66
+
67
+ Site co-owner access is not enough — the **headless application** must have these permissions. Without them, deploy fails with 403 at "Creating deployment...".
68
+
69
+ After adding permissions, refresh the CLI session in your terminal:
70
+
71
+ ```bash
72
+ npx @wix/cli logout
73
+ npx @wix/cli login
74
+ ```
75
+
52
76
  ### 6. Create the data collection
53
77
 
54
78
  Create a collection named `jay-backend-files` in the Wix dashboard (on the business site, where `.wix.yaml` points). Required fields:
@@ -120,7 +144,11 @@ jay-stack-cli run wix-deploy/deploy-baas # deploy to BaaS + CDN only
120
144
  node serve.mjs
121
145
  ```
122
146
 
123
- Starts a local server at `http://localhost:4000`. Uses the local build directory for backend files (no data collection access needed).
147
+ Starts a local server at `http://localhost:4000`. Generated by `wix-deploy/build-entry` alongside `dist/entry.mjs`.
148
+
149
+ By default, uses `WixDataArtifactStore` (same as production) — lazy artifacts (`page-parts.json`, cache files) are fetched from the Wix data collection for the deployed build version. Deploy first, or set `JAY_BACKEND_DIR=build/v*/backend` to test a fresh local build offline.
150
+
151
+ See **Troubleshooting → Local `serve.mjs` vs production** below.
124
152
 
125
153
  ## What Gets Deployed Where
126
154
 
@@ -166,3 +194,85 @@ Starts a local server at `http://localhost:4000`. Uses the local build directory
166
194
  When products or CMS content changes, the renderer server updates page files in the data collection. The BaaS instance picks up changes on the next request for that page (cache miss triggers a fresh fetch).
167
195
 
168
196
  To redeploy code changes: `npm run build:production && npm run deploy`.
197
+
198
+ ## Troubleshooting
199
+
200
+ ### Deploy fails with 403 (Velo permissions)
201
+
202
+ **Symptom:**
203
+
204
+ ```
205
+ [deploy] baas | Creating deployment...
206
+ 403 Forbidden — Permission 'VELO.APP_PROJECT_READ' denied for app with id '<appId>'
207
+ ```
208
+
209
+ **Cause:** The headless application (`appId` in `wix.config.json`) is missing Velo deploy permissions. Site co-owner access does not grant deploy rights to the application.
210
+
211
+ **Fix:**
212
+
213
+ 1. Open `https://manage.wix.com/apps/<appId>/dev-center-permissions` (replace `<appId>` with the value from `wix.config.json`)
214
+ 2. Add:
215
+ - `VELO.APP_PROJECT_READ`
216
+ - `VELO.APP_DEPLOYMENT_CREATE`
217
+ 3. In your terminal, refresh the Wix CLI session:
218
+
219
+ ```bash
220
+ npx @wix/cli logout
221
+ npx @wix/cli login
222
+ ```
223
+
224
+ 4. Retry: `npm run deploy`
225
+
226
+ **Verify:** `npx @wix/cli whoami`
227
+
228
+ ---
229
+
230
+ ### Live site returns 500 after successful deploy
231
+
232
+ #### 1. Regenerate `entry.mjs` after adding local modules
233
+
234
+ **Symptom:** `Module not found in registry: server/components/...`
235
+
236
+ **Cause:** Local server modules are not in `MODULE_REGISTRY` inside `entry.mjs`. `npm run deploy` runs `build-entry` internally, but if you test locally with an old `dist/entry.mjs`, modules may be missing.
237
+
238
+ **Fix:**
239
+
240
+ ```bash
241
+ npm run build:production
242
+ jay-stack-cli run wix-deploy/build-entry
243
+ node serve.mjs # local smoke test
244
+ npm run deploy
245
+ ```
246
+
247
+ For other runtime 500 causes (e.g. stale `page-parts.json`, fast-phase ViewState), see Jay design log #174 and agent-kit `devops/production-build.md`.
248
+
249
+ #### 2. Move validators to devDependencies
250
+
251
+ **Symptom:** Deploy succeeds; runtime errors mention `walkElements`, `resolveBinding`, or `parseTemplateParts` stubs.
252
+
253
+ **Cause:** `@jay-framework/wix-media`, `seo-validator`, or `a11y-validator` in `dependencies` get bundled into `entry.mjs`. They are build-time only.
254
+
255
+ **Fix:** Move to `devDependencies` in `package.json`, then rebuild and redeploy.
256
+
257
+ ---
258
+
259
+ ### Local `serve.mjs` vs production
260
+
261
+ | Mode | How | When to use |
262
+ |------|-----|-------------|
263
+ | Default | `node serve.mjs` | Production-like: `WixDataArtifactStore`, lazy files from data collection |
264
+ | Filesystem | `JAY_BACKEND_DIR=build/v*/backend node serve.mjs` | Test a fresh local build without redeploying |
265
+
266
+ **Note:** Filesystem mode dynamic-imports server modules from disk. Service resolution can differ from the bundled `entry.mjs` on BaaS. Prefer default mode to match production, or redeploy first so the data collection has current artifacts.
267
+
268
+ ---
269
+
270
+ ### Deploy checklist (quick)
271
+
272
+ ```bash
273
+ jay-stack-cli setup
274
+ npx @wix/cli login
275
+ npm run build:production
276
+ npm run deploy
277
+ curl -s -o /dev/null -w "%{http_code}\n" https://<your-release-url>/
278
+ ```
package/dist/index.js CHANGED
@@ -17,7 +17,15 @@ function getDeployVersion(metadata) {
17
17
  if (!hash) return version;
18
18
  return `${version}-${hash}`;
19
19
  }
20
- const DEFAULT_EXCLUDE_PLUGINS = ["aiditor", "wix-deploy"];
20
+ const DEFAULT_EXCLUDE_PLUGINS = [
21
+ "aiditor",
22
+ "ui-kit",
23
+ "wix-deploy",
24
+ // Build-time validators — use compiler APIs stubbed out of the BaaS bundle
25
+ "wix-media",
26
+ "seo-validator",
27
+ "a11y-validator"
28
+ ];
21
29
  function scanPagePartsFiles(dir, fs2, path2) {
22
30
  const results = [];
23
31
  for (const entry of fs2.readdirSync(dir, { withFileTypes: true })) {
@@ -30,6 +38,39 @@ function scanPagePartsFiles(dir, fs2, path2) {
30
38
  }
31
39
  return results;
32
40
  }
41
+ function copyPluginConfigsToDist(projectRoot, distConfigDir, fs2, path2, log) {
42
+ const configSrcDir = path2.join(projectRoot, "config");
43
+ if (!fs2.existsSync(configSrcDir)) {
44
+ return [];
45
+ }
46
+ fs2.mkdirSync(distConfigDir, { recursive: true });
47
+ const copied = [];
48
+ for (const entry of fs2.readdirSync(configSrcDir)) {
49
+ if (!entry.endsWith(".yaml") && !entry.endsWith(".yml")) {
50
+ continue;
51
+ }
52
+ const srcPath = path2.join(configSrcDir, entry);
53
+ if (!fs2.statSync(srcPath).isFile()) {
54
+ continue;
55
+ }
56
+ fs2.copyFileSync(srcPath, path2.join(distConfigDir, entry));
57
+ copied.push(entry);
58
+ if (entry.startsWith(".")) {
59
+ const plainName = entry.slice(1);
60
+ fs2.copyFileSync(srcPath, path2.join(distConfigDir, plainName));
61
+ copied.push(plainName);
62
+ } else if (!fs2.existsSync(path2.join(configSrcDir, `.${entry}`))) {
63
+ fs2.copyFileSync(srcPath, path2.join(distConfigDir, `.${entry}`));
64
+ copied.push(`.${entry}`);
65
+ }
66
+ }
67
+ if (copied.length > 0) {
68
+ log(`Copied plugin config files to dist/config/: ${[...new Set(copied)].join(", ")}`);
69
+ } else {
70
+ log("No config/*.yaml files found to copy");
71
+ }
72
+ return copied;
73
+ }
33
74
  function sortPluginsByDeps(plugins) {
34
75
  const priorityPackages = ["@jay-framework/wix-server-client"];
35
76
  const sorted = [];
@@ -142,14 +183,21 @@ async function initialize() {
142
183
  }
143
184
  console.log('[BaaS] CWD:', process.cwd());
144
185
 
145
- // BaaS skips dotfiles during upload — copy wix.yaml to .wix.yaml if needed
186
+ // BaaS may skip dotfiles during upload — restore dot-prefixed config from plain aliases
146
187
  const fs = await import('node:fs');
147
188
  const configDir = process.cwd() + '/config';
148
- const dotYaml = configDir + '/.wix.yaml';
149
- const plainYaml = configDir + '/wix.yaml';
150
- if (!fs.existsSync(dotYaml) && fs.existsSync(plainYaml)) {
151
- fs.copyFileSync(plainYaml, dotYaml);
152
- console.log('[BaaS] Copied config/wix.yaml to config/.wix.yaml');
189
+ if (fs.existsSync(configDir)) {
190
+ for (const name of fs.readdirSync(configDir)) {
191
+ if (name.startsWith('.') || (!name.endsWith('.yaml') && !name.endsWith('.yml'))) {
192
+ continue;
193
+ }
194
+ const plainPath = configDir + '/' + name;
195
+ const dotPath = configDir + '/.' + name;
196
+ if (!fs.existsSync(dotPath)) {
197
+ fs.copyFileSync(plainPath, dotPath);
198
+ console.log('[BaaS] Copied config/' + name + ' to config/.' + name);
199
+ }
200
+ }
153
201
  }
154
202
 
155
203
  // Initialize plugins first — wix-server-client reads config/.wix.yaml and creates WixClient
@@ -483,14 +531,16 @@ const buildEntry = makeCliCommand("build-entry").withServices(CONSOLE_CONTEXT).w
483
531
  }
484
532
  }
485
533
  ctx.log("Copied route-manifest.json + build-metadata.json to dist/");
534
+ const distConfigDir = path2.join(entryDir, "config");
535
+ copyPluginConfigsToDist(
536
+ ctx.projectRoot,
537
+ distConfigDir,
538
+ fs2,
539
+ path2,
540
+ (message) => ctx.log(message)
541
+ );
486
542
  const wixConfigSrc = path2.join(ctx.projectRoot, "config", ".wix.yaml");
487
- if (fs2.existsSync(wixConfigSrc)) {
488
- const configDir = path2.join(entryDir, "config");
489
- fs2.mkdirSync(configDir, { recursive: true });
490
- fs2.copyFileSync(wixConfigSrc, path2.join(configDir, ".wix.yaml"));
491
- fs2.copyFileSync(wixConfigSrc, path2.join(configDir, "wix.yaml"));
492
- ctx.log(`Copied config/.wix.yaml to dist/config/`);
493
- } else {
543
+ if (!fs2.existsSync(wixConfigSrc)) {
494
544
  ctx.warn(
495
545
  `config/.wix.yaml not found — wix-server-client init will fail on BaaS unless WIX_API_KEY env vars are set`
496
546
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jay-framework/wix-deploy",
3
- "version": "0.23.1",
3
+ "version": "0.24.1",
4
4
  "type": "module",
5
5
  "description": "Wix BaaS deployment adapter for Jay Framework — WixDataArtifactStore and entry builder",
6
6
  "license": "Apache-2.0",
@@ -27,19 +27,19 @@
27
27
  "test": ":"
28
28
  },
29
29
  "dependencies": {
30
- "@jay-framework/compiler-jay-html": "^0.23.1",
31
- "@jay-framework/compiler-shared": "^0.23.1",
32
- "@jay-framework/fullstack-component": "^0.23.1",
33
- "@jay-framework/production-server": "^0.23.1",
34
- "@jay-framework/stack-server-runtime": "^0.23.1",
35
- "@jay-framework/wix-server-client": "^0.23.1",
30
+ "@jay-framework/compiler-jay-html": "^0.24.1",
31
+ "@jay-framework/compiler-shared": "^0.24.1",
32
+ "@jay-framework/fullstack-component": "^0.24.1",
33
+ "@jay-framework/production-server": "^0.24.1",
34
+ "@jay-framework/stack-server-runtime": "^0.24.1",
35
+ "@jay-framework/wix-server-client": "^0.24.1",
36
36
  "@wix/data": "^1.0.433",
37
37
  "@wix/sdk": "^1.21.5",
38
38
  "esbuild": "^0.21.0",
39
39
  "js-yaml": "^4.1.0"
40
40
  },
41
41
  "devDependencies": {
42
- "@jay-framework/jay-stack-cli": "^0.23.1",
42
+ "@jay-framework/jay-stack-cli": "^0.24.1",
43
43
  "tsup": "^8.0.0",
44
44
  "typescript": "^5.3.3",
45
45
  "vite": "^5.0.0"