Skip to content

Commit

Permalink
CLI: Generate .gitignore file by default
Browse files Browse the repository at this point in the history
  • Loading branch information
fuma-nama committed Aug 15, 2023
1 parent f5c4761 commit 3b0f469
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 74 deletions.
5 changes: 5 additions & 0 deletions .changeset/cold-phones-applaud.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'create-next-docs-app': patch
---

Generate .gitignore file by default
37 changes: 0 additions & 37 deletions examples/advanced/.gitignore

This file was deleted.

37 changes: 0 additions & 37 deletions examples/simple/.gitignore

This file was deleted.

31 changes: 31 additions & 0 deletions packages/create-next-docs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ async function main() {
info.message('Updating README.md')
generateReadme(path.join(dest, 'README.md'), name)

info.message('Adding .gitignore')
generateGitIgnore(path.join(dest, '.gitignore'))

info.stop('Project Generated')

outro(color.bgGreen(color.bold('Done')))
Expand Down Expand Up @@ -134,6 +137,34 @@ function generateReadme(path: string, projectName: string) {
fs.writeFileSync(path, content)
}

function generateGitIgnore(path: string) {
const ignores = [
// deps
'/node_modules',
'/.pnp',
'.pnp.js',
// outputs
'.contentlayer',
'/coverage',
'/.next/',
'/out/',
'/build',
'.DS_Store',
'*.pem',
// debug logs
'npm-debug.log*',
'yarn-debug.log*',
'yarn-error.log*',

'.env*.local',
'.vercel',
'*.tsbuildinfo',
'next-env.d.ts'
]

fs.writeFileSync(path, ignores.join('\n'))
}

function copy(
from: string,
to: string,
Expand Down

0 comments on commit 3b0f469

Please sign in to comment.