CLI: Generate .gitignore file by default

This commit is contained in:
SonMooSans
2023-08-15 22:59:06 +08:00
parent f5c4761a5d
commit 3b0f469910
4 changed files with 36 additions and 74 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'create-next-docs-app': patch
---
Generate .gitignore file by default
-37
View File
@@ -1,37 +0,0 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
# dependencies
/node_modules
/.pnp
.pnp.js
.contentlayer
# testing
/coverage
# next.js
/.next/
/out/
# production
/build
# misc
.DS_Store
*.pem
# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# local env files
.env*.local
# vercel
.vercel
# typescript
*.tsbuildinfo
next-env.d.ts
-37
View File
@@ -1,37 +0,0 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
# dependencies
/node_modules
/.pnp
.pnp.js
.contentlayer
# testing
/coverage
# next.js
/.next/
/out/
# production
/build
# misc
.DS_Store
*.pem
# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# local env files
.env*.local
# vercel
.vercel
# typescript
*.tsbuildinfo
next-env.d.ts
+31
View File
@@ -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')))
@@ -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,