create-sonicjs 3.0.0-beta.16 → 3.0.0-beta.18

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-sonicjs",
3
- "version": "3.0.0-beta.16",
3
+ "version": "3.0.0-beta.18",
4
4
  "description": "Create a new SonicJS application with zero configuration",
5
5
  "type": "module",
6
6
  "bin": {
package/src/cli.js CHANGED
@@ -409,7 +409,7 @@ async function copyTemplate(templateName, targetDir, options) {
409
409
 
410
410
  // Add @sonicjs-cms/core dependency
411
411
  packageJson.dependencies = {
412
- '@sonicjs-cms/core': '^3.0.0-beta.16',
412
+ '@sonicjs-cms/core': '^3.0.0-beta.18',
413
413
  ...packageJson.dependencies
414
414
  }
415
415
 
@@ -326,6 +326,17 @@ export const examplePlugin = definePlugin({
326
326
  // We guard with a COUNT query to stay idempotent — subsequent warm-ups skip
327
327
  // seeding if any mood documents already exist.
328
328
  try {
329
+ // Ensure the document type row exists before seeding. plugin onBoot can
330
+ // race bootstrapMiddleware on the very first request (e.g. a static-asset
331
+ // or favicon hits wirePlugins before bootstrap has run
332
+ // autoRegisterCollectionDocumentTypes). D1 local enforces the FK on
333
+ // documents.type_id, so the seed insert would fail silently. INSERT OR
334
+ // IGNORE here is idempotent and harmless when the row already exists.
335
+ await db!.prepare(
336
+ `INSERT OR IGNORE INTO document_types (id, name, display_name, source, settings, created_at, updated_at)
337
+ VALUES (?, ?, ?, 'system', '{"baseGrants":{"public":["read"],"admin":["read","create","update","delete","publish","manage"]}}', strftime('%s','now'), strftime('%s','now'))`
338
+ ).bind(MOODS_TYPE_ID, MOODS_TYPE_ID, 'Example').run()
339
+
329
340
  const countRow = await db!
330
341
  .prepare(`SELECT COUNT(*) as n FROM documents WHERE type_id = ? AND tenant_id = ? AND deleted_at IS NULL`)
331
342
  .bind(MOODS_TYPE_ID, 'default')