create-better-system 1.0.2 → 1.0.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.
Files changed (2) hide show
  1. package/index.js +28 -10
  2. package/package.json +3 -2
package/index.js CHANGED
@@ -5,6 +5,7 @@ import { execa } from 'execa'
5
5
  import fs from 'fs-extra'
6
6
  import path from 'path'
7
7
  import crypto from 'crypto'
8
+ import ora from 'ora'
8
9
 
9
10
  const THEME_PRESETS = {
10
11
  dark: {
@@ -108,14 +109,20 @@ const headingFontVarName = toVarName(answers.headingFont) + 'Font'
108
109
 
109
110
  // ─── Clone template ───────────────────────────────────────────────────────────
110
111
 
111
- console.log('\n📦 Cloning Better System template...')
112
- await execa('npx', ['degit', 'brunogilferro/better-system', projectName], {
113
- stdio: 'inherit',
114
- })
112
+ const spinnerClone = ora('Cloning Better System template...').start()
113
+ try {
114
+ await execa('npx', ['degit', 'brunogilferro/better-system', projectName], {
115
+ stdio: 'pipe',
116
+ })
117
+ spinnerClone.succeed('Template cloned')
118
+ } catch (err) {
119
+ spinnerClone.fail('Failed to clone template')
120
+ throw err
121
+ }
115
122
 
116
123
  // ─── Update layout.tsx with heading font ─────────────────────────────────────
117
124
 
118
- console.log('🔤 Configuring fonts...')
125
+ const spinnerSetup = ora('Configuring project...').start()
119
126
 
120
127
  const layoutPath = path.join(projectPath, 'apps', 'frontend', 'app', 'layout.tsx')
121
128
  let layout = await fs.readFile(layoutPath, 'utf-8')
@@ -137,10 +144,10 @@ layout = layout
137
144
  .replaceAll('__PROJECT_NAME__', projectName)
138
145
 
139
146
  await fs.writeFile(layoutPath, layout)
147
+ spinnerSetup.text = 'Configuring CSS variables...'
140
148
 
141
149
  // ─── Fill globals.css placeholders ───────────────────────────────────────────
142
150
 
143
- console.log('💅 Configuring CSS variables...')
144
151
 
145
152
  const cssPath = path.join(projectPath, 'apps', 'frontend', 'app', 'globals.css')
146
153
  let css = await fs.readFile(cssPath, 'utf-8')
@@ -186,10 +193,10 @@ if (isBoth) {
186
193
  }
187
194
 
188
195
  await fs.writeFile(cssPath, css)
196
+ spinnerSetup.text = 'Configuring design tokens...'
189
197
 
190
198
  // ─── Fill figma-design-rules.md placeholders ─────────────────────────────────
191
199
 
192
- console.log('🎨 Configuring design tokens...')
193
200
 
194
201
  const figmaRulesPath = path.join(projectPath, 'docs', 'figma-design-rules.md')
195
202
  let figmaRules = await fs.readFile(figmaRulesPath, 'utf-8')
@@ -226,10 +233,10 @@ for (const [placeholder, value] of Object.entries(figmaReplacements)) {
226
233
  }
227
234
 
228
235
  await fs.writeFile(figmaRulesPath, figmaRules)
236
+ spinnerSetup.text = 'Generating APP_KEY...'
229
237
 
230
238
  // ─── Setup backend .env ───────────────────────────────────────────────────────
231
239
 
232
- console.log('🔑 Generating APP_KEY...')
233
240
 
234
241
  const backendPath = path.join(projectPath, 'apps', 'backend')
235
242
  const envExamplePath = path.join(backendPath, '.env.example')
@@ -242,15 +249,24 @@ const generatedKey = crypto.randomBytes(32).toString('base64url')
242
249
  let envContent = await fs.readFile(envPath, 'utf-8')
243
250
  envContent = envContent.replace('APP_KEY=', `APP_KEY=${generatedKey}`)
244
251
  await fs.writeFile(envPath, envContent)
252
+ spinnerSetup.text = 'Updating package.json...'
245
253
 
246
254
  // ─── Update root package.json ─────────────────────────────────────────────────
247
255
 
248
- console.log('📝 Updating package.json...')
249
256
 
250
257
  const rootPkgPath = path.join(projectPath, 'package.json')
251
258
  const rootPkg = await fs.readJson(rootPkgPath)
252
259
  rootPkg.name = projectName
253
260
  await fs.writeJson(rootPkgPath, rootPkg, { spaces: 2 })
261
+ spinnerSetup.succeed('Project configured')
262
+
263
+ // ─── Git init ─────────────────────────────────────────────────────────────────
264
+
265
+ const spinnerGit = ora('Initializing git repository...').start()
266
+ await execa('git', ['init'], { cwd: projectPath })
267
+ await execa('git', ['add', '.'], { cwd: projectPath })
268
+ await execa('git', ['commit', '-m', 'init: better system'], { cwd: projectPath })
269
+ spinnerGit.succeed('Git repository initialized')
254
270
 
255
271
  // ─── Done ─────────────────────────────────────────────────────────────────────
256
272
 
@@ -264,4 +280,6 @@ if (isBoth) {
264
280
  console.log(`\nNext steps:`)
265
281
  console.log(` cd ${projectName}`)
266
282
  console.log(` pnpm install`)
267
- console.log(` pnpm dev\n`)
283
+ console.log(` pnpm dev`)
284
+ console.log(`\nTo push to GitHub:`)
285
+ console.log(` gh repo create ${projectName} --private --source=. --push\n`)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-better-system",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "bin": {
5
5
  "create-better-system": "index.js"
6
6
  },
@@ -8,6 +8,7 @@
8
8
  "dependencies": {
9
9
  "inquirer": "^9.0.0",
10
10
  "execa": "^8.0.0",
11
- "fs-extra": "^11.0.0"
11
+ "fs-extra": "^11.0.0",
12
+ "ora": "^8.0.0"
12
13
  }
13
14
  }