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.
- package/index.mjs +35 -13
- 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
|
-
|
|
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
|
-
//
|
|
247
|
-
//
|
|
248
|
-
|
|
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
|
-
|
|
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
|
|
398
|
-
//
|
|
399
|
-
//
|
|
400
|
-
// the
|
|
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: "
|
|
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 (
|
|
423
|
-
"-- pnpm exec louise gen-auth-schema --
|
|
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.
|
|
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
|
-
"
|
|
36
|
-
"
|
|
35
|
+
"astroidjs": "0.3.1",
|
|
36
|
+
"louise-toolkit": "0.17.1"
|
|
37
37
|
},
|
|
38
38
|
"engines": {
|
|
39
39
|
"node": ">=24.0.0"
|