@lntvow/dev 0.0.17 → 0.1.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": "@lntvow/dev",
3
- "version": "0.0.17",
3
+ "version": "0.1.1",
4
4
  "description": "开发环境依赖包",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -17,7 +17,8 @@
17
17
  "commitizen": "^4.3.0",
18
18
  "cz-conventional-changelog": "^3.3.0",
19
19
  "husky": "^9.0.11",
20
- "lint-staged": "^15.2.2"
20
+ "lint-staged": "^15.2.2",
21
+ "rimraf": "^5.0.5"
21
22
  },
22
23
  "lint-staged": {
23
24
  "*.{js,jsx,ts,tsx,vue}": [
@@ -28,6 +29,10 @@
28
29
  ]
29
30
  },
30
31
  "scripts": {
32
+ "dev": "vite --host",
33
+ "build:test": "vite build --mode development",
34
+ "build:uat": "vite build --mode uat",
35
+ "build:prod": "vite build",
31
36
  "commit": "git add . && git-cz && git push",
32
37
  "rimraf": "rimraf ./node_modules/",
33
38
  "release": "git add . && bumpp package.json --all --commit --no-tag --push",
@@ -1,7 +1,7 @@
1
1
  import fs from 'node:fs'
2
2
  import path from 'node:path'
3
3
  import { fileURLToPath } from 'node:url'
4
- import { exec } from 'node:child_process'
4
+ import { execSync } from 'node:child_process'
5
5
 
6
6
  const __filename = fileURLToPath(import.meta.url)
7
7
  const __dirname = path.dirname(__filename)
@@ -41,17 +41,36 @@ function copyDirectorySync(source, target) {
41
41
  // 复制模板文件
42
42
  copyDirectorySync(path.resolve(__dirname, './tmp'), cwd)
43
43
 
44
+ // 初始化 husky
45
+ execSync('npx husky install', { cwd })
46
+
44
47
  // 写入 lint-staged 配置
45
- const packageJson = fs.readFileSync(path.resolve(cwd, './package.json'), 'utf8')
46
- const packageJsonObj = JSON.parse(packageJson)
48
+ setTimeout(() => {
49
+ const packageJson = fs.readFileSync(path.resolve(cwd, './package.json'), 'utf8')
50
+ const packageJsonObj = JSON.parse(packageJson)
47
51
 
48
- if (!packageJsonObj['lint-staged']) {
49
- packageJsonObj['lint-staged'] = {
50
- '*.{js,jsx,ts,tsx,vue}': ['eslint --fix'],
51
- '*.{json,css,scss,md}': ['prettier --write'],
52
+ if (!packageJsonObj['lint-staged']) {
53
+ packageJsonObj['lint-staged'] = {
54
+ '*.{js,jsx,ts,tsx,vue}': ['eslint --fix'],
55
+ '*.{json,css,scss,md}': ['prettier --write'],
56
+ }
52
57
  }
53
- fs.writeFileSync(path.resolve(cwd, './package.json'), JSON.stringify(packageJsonObj, null, 2))
54
- }
55
58
 
56
- // 初始化 husky
57
- exec('npx husky install', { cwd })
59
+ if (!packageJsonObj.scripts) {
60
+ packageJsonObj.scripts = {}
61
+ }
62
+
63
+ packageJsonObj.scripts = {
64
+ dev: 'vite --host',
65
+ 'build:test': 'vite build --mode development',
66
+ 'build:uat': 'vite build --mode uat',
67
+ 'build:prod': 'vite build',
68
+ commit: 'git add . && git-cz && git push',
69
+ rimraf: 'rimraf ./node_modules/',
70
+ release: 'git add . && bumpp package.json --all --commit --no-tag --push',
71
+ ...packageJsonObj.scripts,
72
+ }
73
+
74
+ fs.writeFileSync(path.resolve(cwd, './package.json'), JSON.stringify(packageJsonObj, null, 2))
75
+ console.log('lint-staged 配置写入成功')
76
+ }, 1000)