@zhiwu215/code-template 1.0.0 → 1.0.1

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zhiwu215/code-template",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "专属脚手架与项目模板开发工具",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -1,6 +1,10 @@
1
- import fs from 'fs'
1
+ import fs from 'fs'
2
2
  import path from 'path'
3
3
 
4
+ const FILE_MAPPING = {
5
+ _gitignore: '.gitignore'
6
+ }
7
+
4
8
  /**
5
9
  * 递归模板渲染与覆盖引擎
6
10
  * @param {string} src 源目录
@@ -13,12 +17,13 @@ export function renderTemplate(src, dest) {
13
17
  if (['node_modules', 'pnpm-lock.yaml', 'package-lock.json', 'yarn.lock'].includes(path.basename(src))) return
14
18
  fs.mkdirSync(dest, { recursive: true })
15
19
  for (const file of fs.readdirSync(src)) {
16
- renderTemplate(path.resolve(src, file), path.resolve(dest, file))
20
+ const targetFileName = FILE_MAPPING[file] || file
21
+ renderTemplate(path.resolve(src, file), path.resolve(dest, targetFileName))
17
22
  }
18
23
  return
19
24
  }
20
25
 
21
- const filename = path.basename(src)
26
+ const filename = path.basename(dest)
22
27
 
23
28
  // 遇到 package.json 执行智能深度合并
24
29
  if (filename === 'package.json' && fs.existsSync(dest)) {
@@ -0,0 +1,6 @@
1
+ node_modules
2
+ dist
3
+ out
4
+ .DS_Store
5
+ .eslintcache
6
+ *.log*