Skip to content

Commit 30bf0df

Browse files
rsbhclaude
andcommitted
fix: set type module and add node_modules/.next to gitignore in init
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 5a2be79 commit 30bf0df

1 file changed

Lines changed: 15 additions & 7 deletions

File tree

  • packages/chronicle/src/cli/commands

packages/chronicle/src/cli/commands/init.ts

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ function createPackageJson(name: string): Record<string, unknown> {
2121
return {
2222
name,
2323
private: true,
24+
type: 'module',
2425
scripts: {
2526
dev: 'chronicle dev',
2627
build: 'chronicle build',
@@ -74,6 +75,12 @@ export const initCommand = new Command('init')
7475
const template = createPackageJson(dirName)
7576
let updated = false
7677

78+
// Set type to module
79+
if (existing.type !== 'module') {
80+
existing.type = 'module'
81+
updated = true
82+
}
83+
7784
// Merge missing scripts
7885
if (!existing.scripts) existing.scripts = {}
7986
for (const [key, value] of Object.entries(template.scripts as Record<string, string>)) {
@@ -126,18 +133,19 @@ export const initCommand = new Command('init')
126133
console.log(chalk.green('✓'), 'Created', indexPath)
127134
}
128135

129-
// Add .chronicle to .gitignore
136+
// Add entries to .gitignore
130137
const gitignorePath = path.join(projectDir, '.gitignore')
131-
const chronicleEntry = '.chronicle'
138+
const gitignoreEntries = ['.chronicle', 'node_modules', '.next']
132139
if (fs.existsSync(gitignorePath)) {
133140
const existing = fs.readFileSync(gitignorePath, 'utf-8')
134-
if (!existing.includes(chronicleEntry)) {
135-
fs.appendFileSync(gitignorePath, `\n${chronicleEntry}\n`)
136-
console.log(chalk.green('✓'), 'Added .chronicle to .gitignore')
141+
const missing = gitignoreEntries.filter(e => !existing.includes(e))
142+
if (missing.length > 0) {
143+
fs.appendFileSync(gitignorePath, `\n${missing.join('\n')}\n`)
144+
console.log(chalk.green('✓'), 'Added', missing.join(', '), 'to .gitignore')
137145
}
138146
} else {
139-
fs.writeFileSync(gitignorePath, `${chronicleEntry}\n`)
140-
console.log(chalk.green('✓'), 'Created .gitignore with .chronicle')
147+
fs.writeFileSync(gitignorePath, `${gitignoreEntries.join('\n')}\n`)
148+
console.log(chalk.green('✓'), 'Created .gitignore')
141149
}
142150

143151
// Install dependencies

0 commit comments

Comments
 (0)