@lntvow/dev 0.1.9 → 0.2.3

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.1.9",
3
+ "version": "0.2.3",
4
4
  "description": "开发环境依赖包",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -36,6 +36,7 @@
36
36
  "commit": "git add . && git-cz && git push",
37
37
  "rimraf": "rimraf ./node_modules/",
38
38
  "release": "git add . && bumpp package.json --all --commit --no-tag --push",
39
- "preinstall": "node ./script/postinstall.js"
39
+ "preinstall": "node ./script/preinstall.js",
40
+ "postinstall": "node ./script/postinstall.js"
40
41
  }
41
42
  }
@@ -1,7 +1,7 @@
1
+ import { exec } from 'node:child_process'
1
2
  import fs from 'node:fs'
2
3
  import path from 'node:path'
3
4
  import { fileURLToPath } from 'node:url'
4
- import { execSync } from 'node:child_process'
5
5
 
6
6
  const __filename = fileURLToPath(import.meta.url)
7
7
  const __dirname = path.dirname(__filename)
@@ -39,33 +39,4 @@ function copyDirectorySync(source, target) {
39
39
  copyDirectorySync(path.resolve(__dirname, './tmp'), cwd)
40
40
 
41
41
  // 初始化 husky
42
- execSync('npx husky install', { cwd })
43
-
44
- // 写入 lint-staged 配置
45
- const packageJson = fs.readFileSync(path.resolve(cwd, './package.json'), 'utf8')
46
- const packageJsonObj = JSON.parse(packageJson)
47
-
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
- }
53
- }
54
-
55
- if (!packageJsonObj.scripts) {
56
- packageJsonObj.scripts = {}
57
- }
58
-
59
- packageJsonObj.scripts = {
60
- dev: 'vite --host',
61
- 'build:test': 'vite build --mode development',
62
- 'build:uat': 'vite build --mode uat',
63
- 'build:prod': 'vite build',
64
- commit: 'git add . && git-cz && git push',
65
- rimraf: 'rimraf ./node_modules/',
66
- release: 'git add . && bumpp package.json --all --commit --no-tag --push',
67
- ...packageJsonObj.scripts,
68
- }
69
-
70
- fs.writeFileSync(path.resolve(cwd, './package.json'), `${JSON.stringify(packageJsonObj, null, 2)}\n`)
71
- console.log('lint-staged 配置写入成功')
42
+ exec('npx husky install', { cwd })
@@ -0,0 +1,26 @@
1
+ import fs from 'node:fs'
2
+ import path from 'node:path'
3
+
4
+ const cwd = process.cwd().split('node_modules')[0]
5
+
6
+ // 写入配置
7
+ const packageJson = fs.readFileSync(path.resolve(cwd, './package.json'), 'utf8')
8
+ const packageJsonObj = JSON.parse(packageJson)
9
+
10
+ if (!packageJsonObj.scripts) {
11
+ packageJsonObj.scripts = {}
12
+ }
13
+
14
+ packageJsonObj.scripts = {
15
+ dev: 'vite --host',
16
+ 'build:test': 'vite build --mode development',
17
+ 'build:uat': 'vite build --mode uat',
18
+ 'build:prod': 'vite build',
19
+ commit: 'git add . && git-cz && git push',
20
+ rimraf: 'rimraf ./node_modules/',
21
+ release: 'git add . && bumpp package.json --all --commit --no-tag --push',
22
+ ...packageJsonObj.scripts,
23
+ }
24
+
25
+ fs.writeFileSync(path.resolve(cwd, './package.json'), `${JSON.stringify(packageJsonObj, null, 2)}\n`)
26
+ console.log('lint-staged 配置写入成功')
@@ -0,0 +1,4 @@
1
+ {
2
+ "*.{js,jsx,ts,tsx,vue}": ["eslint --fix"],
3
+ "*.{json,css,scss,md}": ["prettier --write"]
4
+ }