Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 28 additions & 17 deletions packages/create-app/src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const TEMPLATES = {

// Banner
console.log()
console.log(kleur.bold().cyan(' Create SonicJS App'))
console.log(kleur.bold().cyan('✨ Create SonicJS App'))
console.log(kleur.dim(` v${VERSION}`))
console.log()

Expand Down Expand Up @@ -103,7 +103,7 @@ async function main() {
await shutdown()

console.log()
console.log(kleur.yellow(' Cancelled'))
console.log(kleur.yellow('⚠ Cancelled'))
process.exit(0)
}

Expand All @@ -116,7 +116,7 @@ async function main() {
await shutdown()

console.error()
console.error(kleur.red(' Error:'), error.message)
console.error(kleur.red('✖ Error:'), error.message)
console.error()
process.exit(1)
}
Expand Down Expand Up @@ -376,7 +376,7 @@ async function createProject(answers, flags) {
answers.adminSeeded = false
}

spinner.succeed(kleur.bold().green(' Project created successfully!'))
spinner.succeed(kleur.bold().green('✓ Project created successfully!'))

} catch (error) {
spinner.fail('Failed to create project')
Expand Down Expand Up @@ -434,6 +434,17 @@ async function copyTemplate(templateName, targetDir, options) {
if (fs.existsSync(examplePath)) {
await fs.remove(examplePath)
}

// Also remove the blog post import and registration from index.ts
const indexPath = path.join(targetDir, 'src/index.ts')
if (fs.existsSync(indexPath)) {
let indexContent = await fs.readFile(indexPath, 'utf-8')
// Remove the import line
indexContent = indexContent.replace(/^import blogPostsCollection from ['"]\.\/collections\/blog-posts\.collection['"];?\n/m, '')
// Remove the registration entry from registerCollections array
indexContent = indexContent.replace(/\s*blogPostsCollection,?\n/, '\n')
await fs.writeFile(indexPath, indexContent, 'utf-8')
}
}

// Create admin seed script with provided credentials (only if creating admin user)
Expand Down Expand Up @@ -468,7 +479,7 @@ async function seed() {
const { env, dispose } = await getPlatformProxy()

if (!env?.DB) {
console.error(' Error: DB binding not found')
console.error('❌ Error: DB binding not found')
console.error('')
console.error('Make sure you have:')
console.error('1. Created your D1 database: wrangler d1 create <database-name>')
Expand All @@ -489,7 +500,7 @@ async function seed() {
.get()

if (existingUser) {
console.log(' Admin user already exists')
console.log('✓ Admin user already exists')
console.log(\` Email: ${email}\`)
console.log(\` Role: \${existingUser.role}\`)
return
Expand Down Expand Up @@ -518,13 +529,13 @@ async function seed() {
})
.run()

console.log(' Admin user created successfully')
console.log('✓ Admin user created successfully')
console.log(\` Email: ${email}\`)
console.log(\` Role: admin\`)
console.log('')
console.log('You can now login at: http://localhost:8787/auth/login')
} catch (error) {
console.error(' Error creating admin user:', error)
console.error('❌ Error creating admin user:', error)
await dispose()
process.exit(1)
}
Expand All @@ -537,11 +548,11 @@ async function seed() {
seed()
.then(() => {
console.log('')
console.log(' Seeding complete')
console.log('✓ Seeding complete')
process.exit(0)
})
.catch((error) => {
console.error(' Seeding failed:', error)
console.error('❌ Seeding failed:', error)
process.exit(1)
})
`
Expand Down Expand Up @@ -620,12 +631,12 @@ async function createCloudflareResources(databaseName, bucketName, targetDir) {
dbCreated = true
} else {
console.log('')
console.log(kleur.yellow(' Warning: Could not parse database_id from wrangler output'))
console.log(kleur.yellow('⚠ Warning: Could not parse database_id from wrangler output'))
console.log(kleur.dim(' You may need to manually update wrangler.toml'))
}
} catch (error) {
console.log('')
console.log(kleur.yellow(' D1 database creation failed:'))
console.log(kleur.yellow('⚠ D1 database creation failed:'))
console.log(kleur.dim(` ${error.message}`))
if (error.stderr) {
console.log(kleur.dim(` ${error.stderr}`))
Expand All @@ -643,7 +654,7 @@ async function createCloudflareResources(databaseName, bucketName, targetDir) {
bucketCreated = true
} catch (error) {
console.log('')
console.log(kleur.yellow(' R2 bucket creation failed:'))
console.log(kleur.yellow('⚠ R2 bucket creation failed:'))
console.log(kleur.dim(` ${error.message}`))
if (error.stderr) {
console.log(kleur.dim(` ${error.stderr}`))
Expand Down Expand Up @@ -761,7 +772,7 @@ function printSuccessMessage(answers) {
const { projectName, createResources, skipInstall, resourcesCreated, databaseIdSet, migrationsRan, adminSeeded, seedAdmin } = answers

console.log()
console.log(kleur.bold().green('🎉 Success!'))
console.log(kleur.bold().green('🎉 Success!'))
console.log()
console.log(kleur.bold('Next steps:'))
console.log()
Expand All @@ -770,7 +781,7 @@ function printSuccessMessage(answers) {
if (skipInstall) {
console.log(kleur.cyan(' npm install'))
console.log()
console.log(kleur.yellow(' Important: After npm install, copy migrations:'))
console.log(kleur.yellow('⚠ Important: After npm install, copy migrations:'))
console.log(kleur.dim(' cp -r node_modules/@sonicjs-cms/core/migrations ./'))
}

Expand Down Expand Up @@ -802,7 +813,7 @@ function printSuccessMessage(answers) {

console.log()
if (migrationsRan && (!seedAdmin || adminSeeded)) {
console.log(kleur.bold().green(' Database is ready! Start development:'))
console.log(kleur.bold().green('✓ Database is ready! Start development:'))
} else {
console.log(kleur.bold('Start development:'))
}
Expand All @@ -817,7 +828,7 @@ function printSuccessMessage(answers) {

if (migrationsRan && (!seedAdmin || adminSeeded)) {
console.log()
console.log(kleur.green(' Everything is set up! Just run npm run dev and login.'))
console.log(kleur.green('✓ Everything is set up! Just run npm run dev and login.'))
}

console.log()
Expand Down
Loading