@saastemly/voidcommerce 0.9.0 → 0.11.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/cli.js CHANGED
@@ -21,7 +21,7 @@ import {
21
21
  runVoid,
22
22
  version,
23
23
  voidAppsIn
24
- } from "./index-0w66yc8y.js";
24
+ } from "./index-964eqtx0.js";
25
25
  import {
26
26
  LOCAL_KEY_FILE,
27
27
  PRIVATE_KEY_VAR,
@@ -50,7 +50,7 @@ import {
50
50
  setVariable,
51
51
  variableNames,
52
52
  verifyCloudflareToken
53
- } from "./index-wykd4zmk.js";
53
+ } from "./index-62q6669q.js";
54
54
  import {
55
55
  LAYOUTS,
56
56
  oneOrigin,
@@ -3,6 +3,16 @@ import { type Manifest, has } from "../manifest";
3
3
  export declare function allEnvKeys(manifest: Manifest): EnvKey[];
4
4
  export declare function renderEnvTs(manifest: Manifest): string;
5
5
  export declare function renderEnvExample(manifest: Manifest): string;
6
+ /**
7
+ * Keys whose value is the MANIFEST'S to decide, not the operator's.
8
+ *
9
+ * These are the shop's identity. Preserving whatever was already on disk is
10
+ * right for a credential and wrong for these: a shop copied from another one
11
+ * kept `SHOP_DOMAIN=tshirt.test` and an EMAIL_FROM at the wrong domain, which
12
+ * is how a storefront ends up quietly addressing the wrong business. If you
13
+ * want a different domain, change the manifest — that is what it is for.
14
+ */
15
+ export declare const MANIFEST_OWNED_ENV: Set<string>;
6
16
  export declare function renderEnvLocal(manifest: Manifest): string;
7
17
  export declare function renderEnvProduction(manifest: Manifest): string;
8
18
  /** So the generator can say what it decided. */
@@ -23,7 +23,7 @@ export declare const FRONTEND_BRANCH = "frontend-static";
23
23
  export declare function renderFrontendApiTs(manifest: Manifest): string;
24
24
  export declare function renderFrontendEnvProduction(manifest: Manifest): string;
25
25
  /** The Vite config for a static Void site. Deliberately small: this is yours. */
26
- export declare function renderFrontendViteConfig(): string;
26
+ export declare function renderFrontendViteConfig(manifest: Manifest): string;
27
27
  /**
28
28
  * `target: node` because Void 0.10.13's Cloudflare prerender calls miniflare
29
29
  * with the single-worker shorthand that the miniflare its own dependencies
@@ -2,6 +2,7 @@ import {
2
2
  envKeysOf,
3
3
  hasFrontend,
4
4
  isApex,
5
+ oneOrigin,
5
6
  zone
6
7
  } from "./index-tjy6yygc.js";
7
8
  import {
@@ -232,6 +233,7 @@ function renderEnvExample(manifest) {
232
233
  ].join(`
233
234
  `);
234
235
  }
236
+ var MANIFEST_OWNED_ENV = new Set(["SHOP_DOMAIN", "SHOP_ZONE", "EMAIL_FROM", "GITHUB_PAGES_HOST"]);
235
237
  function renderEnvLocal(manifest) {
236
238
  const keys = allEnvKeys(manifest);
237
239
  const local = {
@@ -247,7 +249,7 @@ function renderEnvLocal(manifest) {
247
249
  "# Local development. Gitignored; .env.example documents every key.",
248
250
  "",
249
251
  ...keys.map((key) => `${key.key}=${local[key.key] ?? key.dev ?? "unset"}`),
250
- ...hasFrontend(manifest.layout) ? ["", "# The storefront, reaching the worker. Start the worker first.", "VITE_API_ORIGIN=http://localhost:5173"] : [],
252
+ ...hasFrontend(manifest.layout) && !oneOrigin(manifest.layout) ? ["", "# The storefront, reaching the worker. Start the worker first.", "VITE_API_ORIGIN=http://localhost:5173"] : [],
251
253
  ""
252
254
  ].join(`
253
255
  `);
@@ -384,7 +386,7 @@ async function decryptSecrets(project) {
384
386
  }
385
387
  const expected = committedPublicKey(root);
386
388
  if (expected) {
387
- const { publicKeyFor } = await import("./keys-68c6vmds.js");
389
+ const { publicKeyFor } = await import("./keys-1cqepd69.js");
388
390
  const derived = await publicKeyFor(privateKey);
389
391
  if (derived && derived.toLowerCase() !== expected.toLowerCase()) {
390
392
  return {
@@ -911,4 +913,4 @@ ${color2.green("✓")} re-keyed under ${made.publicKey.slice(0, 20)}… and ${PR
911
913
  return 0;
912
914
  }
913
915
 
914
- export { allEnvKeys, renderEnvTs, renderEnvExample, renderEnvLocal, renderEnvProduction, envSummary, ghAuth, repoSlug, setSecret, secretNames, setVariable, variableNames, verifyCloudflareToken, cloudflareAccounts, LOCAL_KEY_FILE, localPrivateKey, committedPublicKey, generateKeypair, publicKeyFor, keyState, provisionKey, ignoresKeyFile, keysCommand, SECRETS_FILE, PRIVATE_KEY_VAR, run2 as run, committedPublicKeyInto, declaredSecretNames, plaintextSecretNames, plaintextSecretEntries, decryptSecrets, secretsCommand, initSecrets, encryptInto };
916
+ export { allEnvKeys, renderEnvTs, renderEnvExample, MANIFEST_OWNED_ENV, renderEnvLocal, renderEnvProduction, envSummary, ghAuth, repoSlug, setSecret, secretNames, setVariable, variableNames, verifyCloudflareToken, cloudflareAccounts, LOCAL_KEY_FILE, localPrivateKey, committedPublicKey, generateKeypair, publicKeyFor, keyState, provisionKey, ignoresKeyFile, keysCommand, SECRETS_FILE, PRIVATE_KEY_VAR, run2 as run, committedPublicKeyInto, declaredSecretNames, plaintextSecretNames, plaintextSecretEntries, decryptSecrets, secretsCommand, initSecrets, encryptInto };
@@ -1,4 +1,5 @@
1
1
  import {
2
+ MANIFEST_OWNED_ENV,
2
3
  PRIVATE_KEY_VAR,
3
4
  SECRETS_FILE,
4
5
  allEnvKeys,
@@ -9,7 +10,7 @@ import {
9
10
  renderEnvLocal,
10
11
  renderEnvProduction,
11
12
  renderEnvTs
12
- } from "./index-wykd4zmk.js";
13
+ } from "./index-62q6669q.js";
13
14
  import {
14
15
  MANIFEST_FILE,
15
16
  has,
@@ -422,7 +423,33 @@ function renderFrontendEnvProduction(manifest) {
422
423
  VITE_API_ORIGIN=https://api.${manifest.shop.domain}
423
424
  `;
424
425
  }
425
- function renderFrontendViteConfig() {
426
+ function renderFrontendViteConfig(manifest) {
427
+ if (oneOrigin(manifest.layout)) {
428
+ return `import { defineConfig } from "vite";
429
+ import { voidPlugin } from "void";
430
+ import { voidReact } from "@void/react/plugin";
431
+
432
+ /**
433
+ * The storefront.
434
+ *
435
+ * In production one worker serves this page and the API it calls, so the
436
+ * client uses relative URLs and there is nothing to configure. In DEV they
437
+ * are two processes on two ports, and a relative /api call would hit this
438
+ * dev server instead of the worker — so it is proxied. Without this, local
439
+ * development is the only place the shop is broken.
440
+ *
441
+ * Start the worker first: it takes 5173, and this lands on the next port.
442
+ */
443
+ export default defineConfig({
444
+ plugins: [voidPlugin(), voidReact()],
445
+ server: {
446
+ proxy: {
447
+ "/api": { target: "http://127.0.0.1:5173", changeOrigin: false },
448
+ },
449
+ },
450
+ });
451
+ `;
452
+ }
426
453
  return `import { defineConfig } from "vite";
427
454
  import { voidPlugin } from "void";
428
455
  import { voidReact } from "@void/react/plugin";
@@ -1344,7 +1371,7 @@ import color from "picocolors";
1344
1371
  // package.json
1345
1372
  var package_default = {
1346
1373
  name: "@saastemly/voidcommerce",
1347
- version: "0.9.0",
1374
+ version: "0.11.0",
1348
1375
  description: "Void, with a shop in it. `vc init` walks you through Better Auth, betterCommerce and every plugin; everything else passes through to `void`.",
1349
1376
  type: "module",
1350
1377
  license: "MIT",
@@ -2318,6 +2345,8 @@ async function putEnv(root, file, rendered, result) {
2318
2345
  const match = /^\s*([A-Z][A-Z0-9_]*)\s*=\s*(.*)$/.exec(line2);
2319
2346
  if (!match)
2320
2347
  return line2;
2348
+ if (MANIFEST_OWNED_ENV.has(match[1]))
2349
+ return line2;
2321
2350
  const had = existing.get(match[1]);
2322
2351
  return had !== undefined && had !== "" && had !== "unset" ? `${match[1]}=${had}` : line2;
2323
2352
  }).join(`
@@ -2457,7 +2486,7 @@ async function generateFrontend(root, dir, manifest, result) {
2457
2486
  const at = (file) => join4(dir, file);
2458
2487
  await put(root, at("lib/api.ts"), renderFrontendApiTs(manifest), result, "own");
2459
2488
  await put(root, at(".env.production"), renderFrontendEnvProduction(manifest), result, "regenerate");
2460
- await put(root, at("vite.config.ts"), renderFrontendViteConfig(), result, "own");
2489
+ await put(root, at("vite.config.ts"), renderFrontendViteConfig(manifest), result, "own");
2461
2490
  await put(root, at("void.json"), renderFrontendVoidJson(), result, "own");
2462
2491
  await put(root, at("tsconfig.json"), renderFrontendTsconfig(), result, "own");
2463
2492
  await put(root, at("pages/index.tsx"), renderStorefrontPage(manifest), result, "own");
@@ -3405,4 +3434,4 @@ async function importHelp() {
3405
3434
  return 0;
3406
3435
  }
3407
3436
 
3408
- export { renderAuthTs, FRONTEND_BRANCH, renderFrontendApiTs, renderFrontendEnvProduction, renderStorefrontPage, renderFrontendWorkflow, runVoid, runInherit, captureVoid, isVoidApp, voidAppsIn, STRICT_APP, VOID_VERSION, strictDependencies, renderVoidPatch, renderViteConfig, renderStrictTsconfig, renderVoidJson, renderDbSchema, renderDbSeed, renderLayoutTsx, renderAppCss, renderIndexServer, INDEX_PAGE, renderDashboardPage, CLIENT_ONLY, renderSignInPage, renderAuthClient, renderContentTs, renderCron, renderQueue, renderLiveStream, renderLiveRoute, renderStrictAppPackageJson, DATA_README, BRANDING_README, MIGRATIONS_README, finishStrict, line, row, box, fullHelp, initHelp, version, findProject, ensureGenerated, DIST_DIR, DIST_BRANCH, distCommand, distHelp, renderDistWorkflow, renderDeployReadme, renderRequirementsTs, renderDomainTs, generate, parseJsonc, upsertJsonc, findWrangler, parseWhoAmI, productionEnv, routeProblem, preflight, printPreflight, deployCloudflare, importCommand, importHelp };
3437
+ export { renderAuthTs, FRONTEND_BRANCH, renderFrontendApiTs, renderFrontendEnvProduction, renderFrontendViteConfig, renderStorefrontPage, renderFrontendWorkflow, runVoid, runInherit, captureVoid, isVoidApp, voidAppsIn, STRICT_APP, VOID_VERSION, strictDependencies, renderVoidPatch, renderViteConfig, renderStrictTsconfig, renderVoidJson, renderDbSchema, renderDbSeed, renderLayoutTsx, renderAppCss, renderIndexServer, INDEX_PAGE, renderDashboardPage, CLIENT_ONLY, renderSignInPage, renderAuthClient, renderContentTs, renderCron, renderQueue, renderLiveStream, renderLiveRoute, renderStrictAppPackageJson, DATA_README, BRANDING_README, MIGRATIONS_README, finishStrict, line, row, box, fullHelp, initHelp, version, findProject, ensureGenerated, DIST_DIR, DIST_BRANCH, distCommand, distHelp, renderDistWorkflow, renderDeployReadme, renderRequirementsTs, renderDomainTs, generate, parseJsonc, upsertJsonc, findWrangler, parseWhoAmI, productionEnv, routeProblem, preflight, printPreflight, deployCloudflare, importCommand, importHelp };
package/dist/index.d.ts CHANGED
@@ -18,7 +18,7 @@ export { parseJsonc, upsertJsonc } from "./deploy/jsonc";
18
18
  export { parseWhoAmI, findWrangler } from "./deploy/wrangler";
19
19
  export { preflight, printPreflight, productionEnv, routeProblem } from "./deploy/preflight";
20
20
  export { deployCloudflare } from "./deploy/cloudflare";
21
- export { FRONTEND_BRANCH, renderFrontendApiTs, renderFrontendEnvProduction, renderFrontendWorkflow, renderStorefrontPage, } from "./generate/frontend";
21
+ export { FRONTEND_BRANCH, renderFrontendViteConfig, renderFrontendApiTs, renderFrontendEnvProduction, renderFrontendWorkflow, renderStorefrontPage, } from "./generate/frontend";
22
22
  export { distCommand, DIST_BRANCH, DIST_DIR } from "./dist";
23
23
  export { renderDistWorkflow, renderDeployReadme } from "./generate/ci";
24
24
  export { importCommand } from "./import";
package/dist/index.js CHANGED
@@ -34,6 +34,7 @@ import {
34
34
  renderDomainTs,
35
35
  renderFrontendApiTs,
36
36
  renderFrontendEnvProduction,
37
+ renderFrontendViteConfig,
37
38
  renderFrontendWorkflow,
38
39
  renderIndexServer,
39
40
  renderLayoutTsx,
@@ -51,7 +52,7 @@ import {
51
52
  routeProblem,
52
53
  strictDependencies,
53
54
  upsertJsonc
54
- } from "./index-0w66yc8y.js";
55
+ } from "./index-964eqtx0.js";
55
56
  import {
56
57
  allEnvKeys,
57
58
  envSummary,
@@ -59,7 +60,7 @@ import {
59
60
  renderEnvLocal,
60
61
  renderEnvProduction,
61
62
  renderEnvTs
62
- } from "./index-wykd4zmk.js";
63
+ } from "./index-62q6669q.js";
63
64
  import {
64
65
  LAYOUTS,
65
66
  MANIFEST_FILE,
@@ -124,6 +125,7 @@ export {
124
125
  renderLayoutTsx,
125
126
  renderIndexServer,
126
127
  renderFrontendWorkflow,
128
+ renderFrontendViteConfig,
127
129
  renderFrontendEnvProduction,
128
130
  renderFrontendApiTs,
129
131
  renderEnvTs,
@@ -8,7 +8,7 @@ import {
8
8
  localPrivateKey,
9
9
  provisionKey,
10
10
  publicKeyFor
11
- } from "./index-wykd4zmk.js";
11
+ } from "./index-62q6669q.js";
12
12
  import"./index-tjy6yygc.js";
13
13
  import"./index-mnb7fz2t.js";
14
14
  import"./index-0v6na3yp.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@saastemly/voidcommerce",
3
- "version": "0.9.0",
3
+ "version": "0.11.0",
4
4
  "description": "Void, with a shop in it. `vc init` walks you through Better Auth, betterCommerce and every plugin; everything else passes through to `void`.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -1,5 +1,5 @@
1
1
  import { type EnvKey } from "../catalog";
2
- import { type Manifest, envKeysOf, has, hasFrontend, isApex, zone } from "../manifest";
2
+ import { type Manifest, envKeysOf, has, hasFrontend, isApex, zone , oneOrigin} from "../manifest";
3
3
 
4
4
  /**
5
5
  * `env.ts`, `.env.example` and `.env.production` — from the manifest.
@@ -105,6 +105,17 @@ export function renderEnvExample(manifest: Manifest): string {
105
105
  ].join("\n");
106
106
  }
107
107
 
108
+ /**
109
+ * Keys whose value is the MANIFEST'S to decide, not the operator's.
110
+ *
111
+ * These are the shop's identity. Preserving whatever was already on disk is
112
+ * right for a credential and wrong for these: a shop copied from another one
113
+ * kept `SHOP_DOMAIN=tshirt.test` and an EMAIL_FROM at the wrong domain, which
114
+ * is how a storefront ends up quietly addressing the wrong business. If you
115
+ * want a different domain, change the manifest — that is what it is for.
116
+ */
117
+ export const MANIFEST_OWNED_ENV = new Set(["SHOP_DOMAIN", "SHOP_ZONE", "EMAIL_FROM", "GITHUB_PAGES_HOST"]);
118
+
108
119
  export function renderEnvLocal(manifest: Manifest): string {
109
120
  const keys = allEnvKeys(manifest);
110
121
  const local: Record<string, string> = {
@@ -123,7 +134,10 @@ export function renderEnvLocal(manifest: Manifest): string {
123
134
  // One file for both halves in a strict repo, where the storefront and
124
135
  // the worker share a root. The worker takes 5173 because it is started
125
136
  // first; the storefront lands on the next free port and calls back here.
126
- ...(hasFrontend(manifest.layout)
137
+ // Only a monorepo bakes the API's address in. Where one worker serves
138
+ // both, the client uses relative URLs and dev proxies /api instead —
139
+ // so a VITE_API_ORIGIN here would be read by nothing.
140
+ ...(hasFrontend(manifest.layout) && !oneOrigin(manifest.layout)
127
141
  ? ["", "# The storefront, reaching the worker. Start the worker first.", "VITE_API_ORIGIN=http://localhost:5173"]
128
142
  : []),
129
143
  "",
@@ -74,7 +74,33 @@ VITE_API_ORIGIN=https://api.${manifest.shop.domain}
74
74
  }
75
75
 
76
76
  /** The Vite config for a static Void site. Deliberately small: this is yours. */
77
- export function renderFrontendViteConfig(): string {
77
+ export function renderFrontendViteConfig(manifest: Manifest): string {
78
+ if (oneOrigin(manifest.layout)) {
79
+ return `import { defineConfig } from "vite";
80
+ import { voidPlugin } from "void";
81
+ import { voidReact } from "@void/react/plugin";
82
+
83
+ /**
84
+ * The storefront.
85
+ *
86
+ * In production one worker serves this page and the API it calls, so the
87
+ * client uses relative URLs and there is nothing to configure. In DEV they
88
+ * are two processes on two ports, and a relative /api call would hit this
89
+ * dev server instead of the worker — so it is proxied. Without this, local
90
+ * development is the only place the shop is broken.
91
+ *
92
+ * Start the worker first: it takes 5173, and this lands on the next port.
93
+ */
94
+ export default defineConfig({
95
+ plugins: [voidPlugin(), voidReact()],
96
+ server: {
97
+ proxy: {
98
+ "/api": { target: "http://127.0.0.1:5173", changeOrigin: false },
99
+ },
100
+ },
101
+ });
102
+ `;
103
+ }
78
104
  return `import { defineConfig } from "vite";
79
105
  import { voidPlugin } from "void";
80
106
  import { voidReact } from "@void/react/plugin";
@@ -8,6 +8,7 @@ import {
8
8
  envSummary,
9
9
  renderEnvExample,
10
10
  renderEnvLocal,
11
+ MANIFEST_OWNED_ENV,
11
12
  renderEnvProduction,
12
13
  renderEnvTs,
13
14
  } from "./env";
@@ -128,6 +129,9 @@ async function putEnv(root: string, file: string, rendered: string, result: Gene
128
129
  .map((line) => {
129
130
  const match = /^\s*([A-Z][A-Z0-9_]*)\s*=\s*(.*)$/.exec(line);
130
131
  if (!match) return line;
132
+ // The shop's identity is the manifest's to decide; a value carried
133
+ // over from a shop this one was copied from is not a preference.
134
+ if (MANIFEST_OWNED_ENV.has(match[1]!)) return line;
131
135
  const had = existing.get(match[1]!);
132
136
  // A real value the operator set beats the template's placeholder.
133
137
  // `unset` and empty are placeholders, not answers.
@@ -314,7 +318,7 @@ async function generateFrontend(root: string, dir: string, manifest: Manifest, r
314
318
 
315
319
  await put(root, at("lib/api.ts"), renderFrontendApiTs(manifest), result, "own");
316
320
  await put(root, at(".env.production"), renderFrontendEnvProduction(manifest), result, "regenerate");
317
- await put(root, at("vite.config.ts"), renderFrontendViteConfig(), result, "own");
321
+ await put(root, at("vite.config.ts"), renderFrontendViteConfig(manifest), result, "own");
318
322
  await put(root, at("void.json"), renderFrontendVoidJson(), result, "own");
319
323
  await put(root, at("tsconfig.json"), renderFrontendTsconfig(), result, "own");
320
324
  await put(root, at("pages/index.tsx"), renderStorefrontPage(manifest), result, "own");
package/src/index.ts CHANGED
@@ -27,6 +27,7 @@ export { preflight, printPreflight, productionEnv, routeProblem } from "./deploy
27
27
  export { deployCloudflare } from "./deploy/cloudflare";
28
28
  export {
29
29
  FRONTEND_BRANCH,
30
+ renderFrontendViteConfig,
30
31
  renderFrontendApiTs,
31
32
  renderFrontendEnvProduction,
32
33
  renderFrontendWorkflow,