create-sonicjs 2.3.2 → 2.3.4
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 +1 -1
- package/src/cli.js +10 -11
- package/templates/starter/README.md +1 -3
package/package.json
CHANGED
package/src/cli.js
CHANGED
|
@@ -418,7 +418,7 @@ async function copyTemplate(templateName, targetDir, options) {
|
|
|
418
418
|
|
|
419
419
|
// Add @sonicjs-cms/core dependency
|
|
420
420
|
packageJson.dependencies = {
|
|
421
|
-
'@sonicjs-cms/core': '^2.3.
|
|
421
|
+
'@sonicjs-cms/core': '^2.3.4',
|
|
422
422
|
...packageJson.dependencies
|
|
423
423
|
}
|
|
424
424
|
|
|
@@ -452,6 +452,7 @@ async function createAdminSeedScript(targetDir, { email, password }) {
|
|
|
452
452
|
const seedScriptContent = `import { createDb, users } from '@sonicjs-cms/core'
|
|
453
453
|
import { eq } from 'drizzle-orm'
|
|
454
454
|
import bcrypt from 'bcryptjs'
|
|
455
|
+
import { getPlatformProxy } from 'wrangler'
|
|
455
456
|
|
|
456
457
|
/**
|
|
457
458
|
* Seed script to create initial admin user
|
|
@@ -465,17 +466,11 @@ import bcrypt from 'bcryptjs'
|
|
|
465
466
|
* Password: [as entered during setup]
|
|
466
467
|
*/
|
|
467
468
|
|
|
468
|
-
interface Env {
|
|
469
|
-
DB: D1Database
|
|
470
|
-
}
|
|
471
|
-
|
|
472
469
|
async function seed() {
|
|
473
|
-
// Get D1 database from Cloudflare environment
|
|
474
|
-
|
|
475
|
-
const { env } = await import('@cloudflare/workers-types/experimental')
|
|
476
|
-
const platform = (env as any).getPlatformProxy?.() || { env: {} }
|
|
470
|
+
// Get D1 database from Cloudflare environment using wrangler's getPlatformProxy
|
|
471
|
+
const { env, dispose } = await getPlatformProxy()
|
|
477
472
|
|
|
478
|
-
if (!
|
|
473
|
+
if (!env?.DB) {
|
|
479
474
|
console.error('❌ Error: DB binding not found')
|
|
480
475
|
console.error('')
|
|
481
476
|
console.error('Make sure you have:')
|
|
@@ -486,7 +481,7 @@ async function seed() {
|
|
|
486
481
|
process.exit(1)
|
|
487
482
|
}
|
|
488
483
|
|
|
489
|
-
const db = createDb(
|
|
484
|
+
const db = createDb(env.DB)
|
|
490
485
|
|
|
491
486
|
try {
|
|
492
487
|
// Check if admin user already exists
|
|
@@ -527,8 +522,12 @@ async function seed() {
|
|
|
527
522
|
console.log('You can now login at: http://localhost:8787/auth/login')
|
|
528
523
|
} catch (error) {
|
|
529
524
|
console.error('❌ Error creating admin user:', error)
|
|
525
|
+
await dispose()
|
|
530
526
|
process.exit(1)
|
|
531
527
|
}
|
|
528
|
+
|
|
529
|
+
// Clean up the platform proxy
|
|
530
|
+
await dispose()
|
|
532
531
|
}
|
|
533
532
|
|
|
534
533
|
// Run seed
|
|
@@ -42,9 +42,7 @@ A modern headless CMS built with [SonicJS](https://sonicjs.com) on Cloudflare's
|
|
|
42
42
|
6. **Open your browser:**
|
|
43
43
|
Navigate to `http://localhost:8787/admin` to access the admin interface.
|
|
44
44
|
|
|
45
|
-
|
|
46
|
-
- Email: `admin@sonicjs.com`
|
|
47
|
-
- Password: `admin`
|
|
45
|
+
Use the admin credentials you provided during project setup.
|
|
48
46
|
|
|
49
47
|
## Project Structure
|
|
50
48
|
|