@jay-framework/wix-deploy 0.24.1 → 0.24.2

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.
Files changed (2) hide show
  1. package/dist/index.js +114 -4
  2. package/package.json +8 -8
package/dist/index.js CHANGED
@@ -19,7 +19,6 @@ function getDeployVersion(metadata) {
19
19
  }
20
20
  const DEFAULT_EXCLUDE_PLUGINS = [
21
21
  "aiditor",
22
- "ui-kit",
23
22
  "wix-deploy",
24
23
  // Build-time validators — use compiler APIs stubbed out of the BaaS bundle
25
24
  "wix-media",
@@ -248,6 +247,49 @@ function errorPage(title, err, path) {
248
247
  return new Response(html, { status: 500, headers: { 'Content-Type': 'text/html' } });
249
248
  }
250
249
 
250
+ // Build a concrete URL from a route pattern + instance params (mirrors framework generate-sitemap.ts)
251
+ function buildUrl(pattern, params) {
252
+ return (
253
+ pattern
254
+ .replace(/\\[\\[(\\w+)\\]\\]/g, (_, n) => params[n] || '')
255
+ .replace(/\\[\\.\\.\\.(\\w+)\\]/g, (_, n) => params[n] || '')
256
+ .replace(/\\[(\\w+)\\]/g, (_, n) => params[n] || '')
257
+ .replace(/\\/\\/+/g, '/')
258
+ .replace(/\\/$/, '') || '/'
259
+ );
260
+ }
261
+
262
+ // Serve the Wix page inventory (/_wix/pages.json) — Wix reads this to build /sitemap.xml.
263
+ // Streamed to handle large page counts. All pages are static (Jay resolves params itself).
264
+ function streamPagesJson(manifest) {
265
+ const enc = new TextEncoder();
266
+ const stream = new ReadableStream({
267
+ start(controller) {
268
+ controller.enqueue(enc.encode('['));
269
+ let first = true;
270
+ const emit = (path) => {
271
+ const entry = { path, srcFilePath: path, static: true };
272
+ controller.enqueue(enc.encode((first ? '' : ',') + JSON.stringify(entry)));
273
+ first = false;
274
+ };
275
+ for (const route of manifest.routes) {
276
+ if (route.devOnly || route.noIndex) continue;
277
+ if (!route.instances || route.instances.length === 0) {
278
+ const hasDynamic = route.segments.some((s) => s.type !== 'static');
279
+ if (!hasDynamic) emit(route.pattern === '/' ? '/' : route.pattern);
280
+ continue;
281
+ }
282
+ for (const instance of route.instances) {
283
+ emit(buildUrl(route.pattern, instance.params));
284
+ }
285
+ }
286
+ controller.enqueue(enc.encode(']'));
287
+ controller.close();
288
+ },
289
+ });
290
+ return new Response(stream, { headers: { 'Content-Type': 'application/json' } });
291
+ }
292
+
251
293
  async function handler(request) {
252
294
  const url = new URL(request.url);
253
295
 
@@ -286,6 +328,10 @@ async function handler(request) {
286
328
  if (isActionRequest(url.pathname)) return fetchActionRequest(request);
287
329
 
288
330
  const manifest = await artifacts.readManifest();
331
+
332
+ // Wix reads this page inventory to build /sitemap.xml
333
+ if (url.pathname === '/_wix/pages.json') return streamPagesJson(manifest);
334
+
289
335
  const match = matchRequest(manifest, url.pathname);
290
336
  if (!match) return new Response('Not Found', { status: 404 });
291
337
 
@@ -322,6 +368,7 @@ function generateServeSource(frontendDir, backendDir) {
322
368
  ' ".css": "text/css", ".html": "text/html", ".json": "application/json",',
323
369
  ' ".png": "image/png", ".jpg": "image/jpeg", ".svg": "image/svg+xml",',
324
370
  ' ".woff2": "font/woff2", ".woff": "font/woff",',
371
+ ' ".xml": "application/xml", ".txt": "text/plain",',
325
372
  "};",
326
373
  "",
327
374
  "function serveStatic(pathname, res) {",
@@ -505,7 +552,7 @@ const buildEntry = makeCliCommand("build-entry").withServices(CONSOLE_CONTEXT).w
505
552
  let patched = fs2.readFileSync(outFile, "utf8");
506
553
  let patchCount = 0;
507
554
  for (const mod of runtimeStubs) {
508
- const pattern = new RegExp(`(\\w+)\\("${mod}"\\)`, "g");
555
+ const pattern = new RegExp(`[\\w$]+\\("${mod}"\\)`, "g");
509
556
  const before = patched;
510
557
  patched = patched.replace(pattern, "({})");
511
558
  if (patched !== before) patchCount++;
@@ -950,6 +997,64 @@ const deployBaas = makeCliCommand("deploy-baas").withServices(CONSOLE_CONTEXT).w
950
997
  ctx.log(`Released → ${releaseUrl}`);
951
998
  return { success: true, deploymentId, baseUrl: releaseUrl };
952
999
  });
1000
+ const TXT_FILES = [
1001
+ {
1002
+ fileName: "robots.txt",
1003
+ url: "https://www.wixapis.com/promote-seo-txt-file-server/v2/robots",
1004
+ bodyKey: "robotsTxt"
1005
+ },
1006
+ {
1007
+ fileName: "ads.txt",
1008
+ url: "https://www.wixapis.com/promote-seo-txt-file-server/v2/ads",
1009
+ bodyKey: "adsTxt"
1010
+ },
1011
+ {
1012
+ fileName: "llms.txt",
1013
+ url: "https://www.wixapis.com/promote-seo-txt-file-server/v2/llms",
1014
+ bodyKey: "llmsTxt"
1015
+ }
1016
+ ];
1017
+ const syncTxtFiles = makeCliCommand("sync-txt-files").withServices(WIX_CLIENT_SERVICE, CONSOLE_CONTEXT).withHandler(
1018
+ async (input, wixClientService, ctx) => {
1019
+ const fs2 = await import("node:fs");
1020
+ const path2 = await import("node:path");
1021
+ const subdomain = input.subdomain || "www";
1022
+ const publicDir = path2.join(ctx.projectRoot, "public");
1023
+ const synced = [];
1024
+ const skipped = [];
1025
+ const errors = [];
1026
+ for (const file of TXT_FILES) {
1027
+ const filePath = path2.join(publicDir, file.fileName);
1028
+ if (!fs2.existsSync(filePath)) {
1029
+ skipped.push(file.fileName);
1030
+ continue;
1031
+ }
1032
+ const content = fs2.readFileSync(filePath, "utf8");
1033
+ const body = { [file.bodyKey]: { content, default: false, subdomain } };
1034
+ try {
1035
+ const response = await wixClientService.wixClient.fetchWithAuth(file.url, {
1036
+ method: "PUT",
1037
+ headers: { "Content-Type": "application/json" },
1038
+ body: JSON.stringify(body)
1039
+ });
1040
+ if (!response.ok) {
1041
+ const text = await response.text();
1042
+ errors.push(`${file.fileName}: HTTP ${response.status} ${text}`);
1043
+ continue;
1044
+ }
1045
+ synced.push(file.fileName);
1046
+ } catch (err) {
1047
+ errors.push(`${file.fileName}: ${err instanceof Error ? err.message : err}`);
1048
+ }
1049
+ }
1050
+ const parts = [];
1051
+ if (synced.length) parts.push(`Synced ${synced.join(", ")}`);
1052
+ if (skipped.length) parts.push(`skipped ${skipped.join(", ")} (not in public/)`);
1053
+ ctx.log(parts.join("; ") || "No txt files to sync");
1054
+ for (const error of errors) ctx.warn(error);
1055
+ return { success: errors.length === 0, synced, skipped, errors };
1056
+ }
1057
+ );
953
1058
  function silentCtx(ctx) {
954
1059
  return { ...ctx, log: () => {
955
1060
  }, warn: () => {
@@ -989,16 +1094,21 @@ const deploy = makeCliCommand("deploy").withServices(WIX_CLIENT_SERVICE, CONSOLE
989
1094
  ctx.log(`[deploy] Bundled entry.mjs (${buildResult.sizeMB} MB) in ${bundleTime}s`);
990
1095
  ctx.log("[deploy] Uploading...");
991
1096
  const t1 = Date.now();
992
- const [uploadResult, deployResult] = await Promise.all([
1097
+ const [uploadResult, deployResult, txtResult] = await Promise.all([
993
1098
  uploadBackend.handler(
994
1099
  { collectionId: input.collectionId, dryRun },
995
1100
  wixClient,
996
1101
  prefixCtx(ctx, "data |")
997
1102
  ),
998
- dryRun ? { success: true, baseUrl: "(dry run)" } : deployBaas.handler({ dryRun }, prefixCtx(ctx, "baas |"))
1103
+ dryRun ? { success: true, baseUrl: "(dry run)" } : deployBaas.handler({ dryRun }, prefixCtx(ctx, "baas |")),
1104
+ dryRun ? { success: true } : syncTxtFiles.handler({}, wixClient, prefixCtx(ctx, "txt |"))
999
1105
  ]);
1000
1106
  if (!uploadResult?.success) ctx.error("[deploy] Backend data upload failed");
1001
1107
  if (!deployResult?.success) ctx.error("[deploy] BaaS deployment failed");
1108
+ if (!txtResult?.success) {
1109
+ ctx.warn("[deploy] Some txt files failed to sync (non-fatal):");
1110
+ for (const error of txtResult?.errors ?? []) ctx.warn(`[deploy] txt | ${error}`);
1111
+ }
1002
1112
  const success = !!(uploadResult?.success && deployResult?.success);
1003
1113
  const elapsed = ((Date.now() - t0) / 1e3).toFixed(1);
1004
1114
  const deployTime = ((Date.now() - t1) / 1e3).toFixed(1);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jay-framework/wix-deploy",
3
- "version": "0.24.1",
3
+ "version": "0.24.2",
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.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",
30
+ "@jay-framework/compiler-jay-html": "^0.24.2",
31
+ "@jay-framework/compiler-shared": "^0.24.2",
32
+ "@jay-framework/fullstack-component": "^0.24.2",
33
+ "@jay-framework/production-server": "^0.24.2",
34
+ "@jay-framework/stack-server-runtime": "^0.24.2",
35
+ "@jay-framework/wix-server-client": "^0.24.2",
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.24.1",
42
+ "@jay-framework/jay-stack-cli": "^0.24.2",
43
43
  "tsup": "^8.0.0",
44
44
  "typescript": "^5.3.3",
45
45
  "vite": "^5.0.0"