@lntvow/dev 0.2.1 → 0.2.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lntvow/dev",
3
- "version": "0.2.1",
3
+ "version": "0.2.4",
4
4
  "description": "开发环境依赖包",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -20,14 +20,6 @@
20
20
  "lint-staged": "^15.2.2",
21
21
  "rimraf": "^5.0.5"
22
22
  },
23
- "lint-staged": {
24
- "*.{js,jsx,ts,tsx,vue}": [
25
- "eslint --fix"
26
- ],
27
- "*.{json,css,scss,md}": [
28
- "prettier --write"
29
- ]
30
- },
31
23
  "scripts": {
32
24
  "dev": "vite --host",
33
25
  "build:test": "vite build --mode development",
@@ -36,7 +28,6 @@
36
28
  "commit": "git add . && git-cz && git push",
37
29
  "rimraf": "rimraf ./node_modules/",
38
30
  "release": "git add . && bumpp package.json --all --commit --no-tag --push",
39
- "preinstall": "node ./script/preinstall.js",
40
31
  "postinstall": "node ./script/postinstall.js"
41
32
  }
42
33
  }
@@ -1,4 +1,42 @@
1
1
  import { exec } from 'node:child_process'
2
+ import fs from 'node:fs'
3
+ import path from 'node:path'
4
+ import { fileURLToPath } from 'node:url'
5
+
6
+ const __filename = fileURLToPath(import.meta.url)
7
+ const __dirname = path.dirname(__filename)
8
+
9
+ const cwd = process.cwd().split('node_modules')[0]
10
+
11
+ function copyDirectorySync(source, target) {
12
+ // 创建目标目录(如果不存在)
13
+ if (!fs.existsSync(target)) {
14
+ fs.mkdirSync(target)
15
+ }
16
+
17
+ // 获取源目录下的所有文件和子目录
18
+ const files = fs.readdirSync(source, { withFileTypes: true })
19
+
20
+ // 遍历并复制文件和子目录
21
+ files.forEach(file => {
22
+ const sourcePath = path.resolve(source, file.name)
23
+ const filePath = path.resolve(target, file.name)
24
+
25
+ if (file.isDirectory()) {
26
+ // 如果是子目录,递归复制
27
+ copyDirectorySync(sourcePath, filePath)
28
+ } else {
29
+ if (fs.existsSync(filePath)) return
30
+
31
+ // 如果是文件,使用流复制
32
+ fs.createReadStream(sourcePath).pipe(fs.createWriteStream(filePath))
33
+ console.log(`文件复制成功: ${sourcePath}`)
34
+ }
35
+ })
36
+ }
37
+
38
+ // 复制模板文件
39
+ copyDirectorySync(path.resolve(__dirname, './tmp'), cwd)
2
40
 
3
41
  // 初始化 husky
4
- exec('npx husky install', { cwd: process.cwd().split('node_modules')[0] })
42
+ exec('npx husky install', { cwd })
@@ -1,53 +1,12 @@
1
1
  import fs from 'node:fs'
2
2
  import path from 'node:path'
3
- import { fileURLToPath } from 'node:url'
4
-
5
- const __filename = fileURLToPath(import.meta.url)
6
- const __dirname = path.dirname(__filename)
7
3
 
8
4
  const cwd = process.cwd().split('node_modules')[0]
9
5
 
10
- function copyDirectorySync(source, target) {
11
- // 创建目标目录(如果不存在)
12
- if (!fs.existsSync(target)) {
13
- fs.mkdirSync(target)
14
- }
15
-
16
- // 获取源目录下的所有文件和子目录
17
- const files = fs.readdirSync(source, { withFileTypes: true })
18
-
19
- // 遍历并复制文件和子目录
20
- files.forEach(file => {
21
- const sourcePath = path.resolve(source, file.name)
22
- const filePath = path.resolve(target, file.name)
23
-
24
- if (file.isDirectory()) {
25
- // 如果是子目录,递归复制
26
- copyDirectorySync(sourcePath, filePath)
27
- } else {
28
- if (fs.existsSync(filePath)) return
29
-
30
- // 如果是文件,使用流复制
31
- fs.createReadStream(sourcePath).pipe(fs.createWriteStream(filePath))
32
- console.log(`文件复制成功: ${sourcePath}`)
33
- }
34
- })
35
- }
36
-
37
- // 复制模板文件
38
- copyDirectorySync(path.resolve(__dirname, './tmp'), cwd)
39
-
40
- // 写入 lint-staged 配置
6
+ // 写入配置
41
7
  const packageJson = fs.readFileSync(path.resolve(cwd, './package.json'), 'utf8')
42
8
  const packageJsonObj = JSON.parse(packageJson)
43
9
 
44
- if (!packageJsonObj['lint-staged']) {
45
- packageJsonObj['lint-staged'] = {
46
- '*.{js,jsx,ts,tsx,vue}': ['eslint --fix'],
47
- '*.{json,css,scss,md}': ['prettier --write'],
48
- }
49
- }
50
-
51
10
  if (!packageJsonObj.scripts) {
52
11
  packageJsonObj.scripts = {}
53
12
  }
@@ -0,0 +1,4 @@
1
+ {
2
+ "*.{js,jsx,ts,tsx,vue}": ["eslint --fix"],
3
+ "*.{json,css,scss,md}": ["prettier --write"]
4
+ }