create-astroid 0.3.0 → 0.3.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.
Files changed (2) hide show
  1. package/index.mjs +35 -13
  2. package/package.json +3 -3
package/index.mjs CHANGED
@@ -173,8 +173,23 @@ function astroidConfigSource(config) {
173
173
  ...(config.modules?.length ? [` modules: ${JSON.stringify(config.modules)},`] : []),
174
174
  // Must be emitted: `astroid generate` rebuilds the middleware from THIS
175
175
  // file, so a config that omitted the portal would regenerate a middleware
176
- // with no guard while src/portal-auth.ts sat there unused.
177
- ...(config.portal?.enabled ? [" portal: { enabled: true },"] : []),
176
+ // with no guard while src/portal-auth.ts sat there unused. And the FULL shape
177
+ // (tablePrefix, signUp) — not a bare `{ enabled: true }` — so a regenerate
178
+ // reproduces the SAME unprefixed `user`/`session` seam the 0002_portal_auth
179
+ // migration created, rather than defaulting the prefix back to `portal_`.
180
+ ...(config.portal?.enabled
181
+ ? [
182
+ " portal: {",
183
+ " enabled: true,",
184
+ ...(config.portal.tablePrefix !== undefined
185
+ ? [` tablePrefix: ${JSON.stringify(config.portal.tablePrefix)},`]
186
+ : []),
187
+ ...(config.portal.signUp !== undefined
188
+ ? [` signUp: ${JSON.stringify(config.portal.signUp)},`]
189
+ : []),
190
+ " },",
191
+ ]
192
+ : []),
178
193
  ' deploy: { platform: "cloudflare" },',
179
194
  "});",
180
195
  "",
@@ -243,9 +258,11 @@ async function main() {
243
258
  const archetype = ARCHETYPES.includes(archetypeRaw) ? archetypeRaw : "marketing";
244
259
  const color = flags.color || (await prompt("Brand color (hex)", "#5b4bff"));
245
260
  const host = flags.host && flags.host !== true ? flags.host : undefined;
246
- // Portal + commerce are opt-in and unprompted: each pulls in real
247
- // infrastructure a plain marketing site should not carry.
248
- const portal = flags.portal === true || flags.portal === "true";
261
+ // The customer PORTAL is opt-in via --portal, but a storefront IMPLIES one — a
262
+ // shop has customers who sign in, reorder, and track orders — so enable it there
263
+ // by default. (Commerce below stays opt-in: infra a marketing site shouldn't carry.)
264
+ const portal =
265
+ flags.portal === true || flags.portal === "true" || archetype === "storefront";
249
266
  // The map module is opt-in and pulls real weight (maplibre-gl is ~1 MB), so
250
267
  // it is never on by default.
251
268
  const map = flags.map === true || flags.map === "true";
@@ -284,7 +301,10 @@ async function main() {
284
301
  theme: { name, colors: { brand: color } },
285
302
  sections: ARCHETYPE_SECTIONS[archetype],
286
303
  ...(commerce ? { commerce: { provider: commerce } } : {}),
287
- ...(portal ? { portal: { enabled: true } } : {}),
304
+ // Unprefixed `user`/`session` (customers — email + password), so the studio's
305
+ // `louise_`-prefixed tables and the portal's never collide (mirrors the
306
+ // reference storefront). `signUp: true` because a shop lets customers register.
307
+ ...(portal ? { portal: { enabled: true, tablePrefix: "", signUp: true } } : {}),
288
308
  // ONE array, built from every enabled flag. Two separate `...(x ? {modules}
289
309
  // : {})` spreads would let the later one overwrite the earlier, silently
290
310
  // dropping a module whenever both were passed.
@@ -394,15 +414,17 @@ async function main() {
394
414
  // instance. Must match the `tablePrefix` in src/auth.ts and the `louise_user`
395
415
  // table the generated `editorsRoute` reads.
396
416
  write(dir, "migrations/0001_auth.sql", generateAuthSchemaSql({ tablePrefix: "louise_" }));
397
- // The portal's own auth tables. A SECOND set, prefixed — the two instances
398
- // share one D1 but never a row, so a portal account can't sign into the
399
- // studio and an editor doesn't appear in the portal. Without this migration
400
- // the portal builds fine and fails on the first sign-in.
417
+ // The portal's own auth tables — a SECOND Better Auth instance sharing one D1
418
+ // but never a row, so a portal account can't sign into the studio and an
419
+ // editor doesn't appear in the portal. `customers: true` (email + password)
420
+ // and the config's tablePrefix, so this schema matches the scaffolded
421
+ // portal-auth.ts exactly. Without this migration the portal builds fine and
422
+ // fails on the first sign-in with a missing table.
401
423
  if (config.portal?.enabled) {
402
424
  write(
403
425
  dir,
404
426
  "migrations/0002_portal_auth.sql",
405
- generateAuthSchemaSql({ tablePrefix: "portal_" }),
427
+ generateAuthSchemaSql({ customers: true, tablePrefix: config.portal.tablePrefix ?? "" }),
406
428
  );
407
429
  }
408
430
  authMigrationOk = true;
@@ -419,8 +441,8 @@ async function main() {
419
441
  write(
420
442
  dir,
421
443
  "migrations/0002_portal_auth.sql",
422
- "-- Portal Better Auth tables (prefixed) — generate after install:\n" +
423
- "-- pnpm exec louise gen-auth-schema --table-prefix portal_ --out migrations/0002_portal_auth.sql\n",
444
+ "-- Portal Better Auth tables (customers, unprefixed) — generate after install:\n" +
445
+ "-- pnpm exec louise gen-auth-schema --out migrations/0002_portal_auth.sql\n",
424
446
  );
425
447
  }
426
448
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-astroid",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "Scaffold a new Astroid site — an editable, multi-editor Astro app on Cloudflare Workers — in one command.",
5
5
  "keywords": [
6
6
  "astro",
@@ -32,8 +32,8 @@
32
32
  "dependencies": {
33
33
  "@better-auth/passkey": "^1.6.23",
34
34
  "better-auth": "^1.6.23",
35
- "louise-toolkit": "0.17.0",
36
- "astroidjs": "0.3.0"
35
+ "astroidjs": "0.3.1",
36
+ "louise-toolkit": "0.17.1"
37
37
  },
38
38
  "engines": {
39
39
  "node": ">=24.0.0"