commit-pack 1.0.5 → 1.0.8

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,8 +1,15 @@
1
1
  {
2
2
  "name": "commit-pack",
3
- "version": "1.0.5",
3
+ "version": "1.0.8",
4
4
  "description": "A setup package to automatly check project's style and commit configuration",
5
- "main": "index.js",
5
+ "main": "lib/index.js",
6
+ "bin": {
7
+ "commit-pack": "./index.js"
8
+ },
9
+ "files": [
10
+ "index.js",
11
+ "setup-script/"
12
+ ],
6
13
  "publishConfig": {
7
14
  "registry": "https://registry.npmjs.org/"
8
15
  },
@@ -48,11 +55,16 @@
48
55
  "shelljs": "^0.8.5",
49
56
  "standard-version": "^9.5.0"
50
57
  },
58
+ "vscode_custom_css.imports": [
59
+ "file:///Users/jett/code/Res/custom/custom.css",
60
+ "file:///Users/jett/code/Res/custom/custom.js"
61
+ ],
51
62
  "scripts": {
63
+ "postinstall": "node bin/index.mjs",
52
64
  "lint": "eslint ./ --ext .ts,.tsx,.json --max-warnings=0",
53
65
  "format": "prettier --config .prettierrc '.' --write",
54
66
  "commit": "cz",
55
- "build": "babel bin/index.js --out-file lib/index.js",
67
+ "build": "babel bin/index.mjs --out-file lib/index.mjs",
56
68
  "release": "standard-version"
57
69
  }
58
70
  }
package/.babelrc DELETED
@@ -1,14 +0,0 @@
1
- {
2
- "presets": [
3
- [
4
- "@babel/preset-env",
5
- {
6
- "targets": {
7
- "node": "current"
8
- },
9
- "modules": "commonjs",
10
- "exclude": ["transform-regenerator"]
11
- }
12
- ]
13
- ]
14
- }
@@ -1,30 +0,0 @@
1
- {
2
- "extends": ["@commitlint/config-conventional"],
3
- "parserPreset": {
4
- "parserOpts": {
5
- "headerPattern": "^(.+?)\\((.+?)\\): (.+)$",
6
- "headerCorrespondence": ["type", "scope", "subject"]
7
- }
8
- },
9
- "rules": {
10
- "scope-empty": [2, "never"],
11
- "type-enum": [
12
- 2,
13
- "always",
14
- [
15
- "✨ feat",
16
- "🐛 fix",
17
- "🎉 init",
18
- "✏️ docs",
19
- "💄 style",
20
- "♻️ refactor",
21
- "⚡️ perf",
22
- "✅ test",
23
- "⏪️ revert",
24
- "📦 build",
25
- "🚀 chore",
26
- "👷 ci"
27
- ]
28
- ]
29
- }
30
- }
package/.cz-config.js DELETED
@@ -1,41 +0,0 @@
1
- module.exports = {
2
- types: [
3
- { value: '✨ feat', name: ' ✨ feat: 新功能' },
4
- { value: '🐛 fix', name: ' 🐛 fix: 修复bug' },
5
- { value: '🎉 init', name: ' 🎉 init: 初始化' },
6
- { value: '✏️ docs', name: ' ✏️ docs: 文档变更' },
7
- { value: '💄 style', name: ' 💄 style: 更改样式' },
8
- { value: '♻️ refactor', name: ' ♻️ refactor: 重构' },
9
- { value: '⚡️ perf', name: ' ⚡️ perf: 性能优化' },
10
- { value: '✅ test', name: ' ✅ test: 测试' },
11
- { value: '⏪️ revert', name: ' ⏪️ revert: 回退' },
12
- { value: '📦 build', name: ' 📦 build: 打包' },
13
- { value: '🚀 chore', name: ' 🚀 chore: 构建/工程依赖/工具' },
14
- { value: '👷 ci', name: ' 👷 ci: CI related changes' }
15
- ],
16
-
17
- scopes: [
18
- { name: 'components' },
19
- { name: 'page' },
20
- { name: 'css' },
21
- { name: 'api' },
22
- { name: 'README.md' },
23
- { name: 'custom' }
24
- ],
25
-
26
- messages: {
27
- type: '请选择提交类型(必填)',
28
- scope: '请选择文件修改范围(必填):',
29
- customScope: '请输自定义文件修改范围(必填)',
30
- subject: '请简要描述提交(必填)',
31
- body: '请输入详细描述(可选)',
32
- breaking: '列出任何breaking changes(可选)',
33
- footer: '请输入要关闭的issue(可选)',
34
- confirmCommit: '确定提交吗'
35
- },
36
-
37
- allowCustomScopes: true,
38
- allowBreakingChanges: ['✨ feat', '🐛 fix'],
39
- subjectLimit: 49
40
-
41
- }
package/.czrc DELETED
@@ -1,3 +0,0 @@
1
- {
2
- "path": "cz-customizable"
3
- }
package/.eslintignore DELETED
@@ -1,3 +0,0 @@
1
- node_modules/
2
-
3
- README.md
package/.eslintrc DELETED
@@ -1,15 +0,0 @@
1
- {
2
- "root": true,
3
- "parser": "@typescript-eslint/parser",
4
- "extends": [
5
- "eslint:recommended",
6
- "plugin:@typescript-eslint/recommended",
7
- "prettier"
8
- ],
9
- "plugins": ["@typescript-eslint", "prettier"],
10
- "rules": {
11
- "prettier/prettier": "error",
12
- "arrow-body-style": "off",
13
- "prefer-arrow-callback": "off"
14
- }
15
- }
@@ -1,73 +0,0 @@
1
- name: Publish to npm
2
-
3
- on:
4
- push:
5
- branches:
6
- - main
7
- paths-ignore:
8
- - 'pnpm-lock.yaml'
9
-
10
- permissions:
11
- contents: write
12
- jobs:
13
- release:
14
- runs-on: ubuntu-latest
15
-
16
- steps:
17
- # 1. 检出代码
18
- - name: Checkout code
19
- uses: actions/checkout@v4
20
- with:
21
- fetch-depth: 0
22
-
23
- # 2. 设置 Node.js 环境
24
- - name: Sync node version and setup cache
25
- uses: actions/setup-node@v4
26
- with:
27
- node-version: 20
28
-
29
- # 3. 安装 pnpm
30
- - name: Install PNPM
31
- run: npm i -g pnpm
32
-
33
- # 4. 验证 pnpm 安装
34
- - name: Verify pnpm installation
35
- run: pnpm --version
36
-
37
- # 5. 安装依赖
38
- - name: Install dependencies
39
- run: pnpm install
40
-
41
- # 6. 配置 Git 信息
42
- - name: Configure Git
43
- run: |
44
- git config user.name "github-actions[bot]"
45
- git config user.email "github-actions[bot]@users.noreply.github.com"
46
-
47
- # 7. 更新版本号并创建标签
48
- - name: Bump version and create tag
49
- run: pnpm run release
50
- env:
51
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
52
-
53
- # 8. 配置 Git 身份验证
54
- - name: 配置 Git 身份验证
55
- run: |
56
- git remote set-url origin https://${GITHUB_ACTOR}:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}
57
-
58
- # 9. 推送更改
59
- - name: Push changes
60
- run: |
61
- git push origin main --follow-tags
62
- env:
63
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
64
-
65
- # 10. 运行构建脚本
66
- - name: Run build
67
- run: pnpm run build
68
-
69
- # 11. 发布到 npm
70
- - name: Publish to npm
71
- run: pnpm publish --access public
72
- env:
73
- NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
package/.husky/commit-msg DELETED
@@ -1 +0,0 @@
1
- npx --no -- commitlint --edit "$1"
package/.husky/pre-commit DELETED
@@ -1 +0,0 @@
1
- npx lint-staged
package/.lintstagedrc DELETED
@@ -1,3 +0,0 @@
1
- {
2
- "*.{js,jsx,ts,tsx}": ["eslint --fix", "prettier --write"]
3
- }
package/.prettierignore DELETED
@@ -1,5 +0,0 @@
1
- node_modules/
2
-
3
- README.md
4
-
5
- .cz-config.js
package/.prettierrc DELETED
@@ -1,10 +0,0 @@
1
- {
2
- "singleQuote": true,
3
- "printWidth": 88,
4
- "jsxSingleQuote": true,
5
- "bracketSameLine": true,
6
- "semi": false,
7
- "tabWidth": 2,
8
- "bracketSpacing": true,
9
- "trailingComma": "none"
10
- }
package/CHANGELOG.md DELETED
@@ -1,21 +0,0 @@
1
- # Changelog
2
-
3
- All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
-
5
- ## [1.0.5](https://github.com/Jett191/commit-pack/compare/v1.0.4...v1.0.5) (2024-11-05)
6
-
7
-
8
-
9
- ## [1.0.4](https://github.com/Jett191/commit-pack/compare/v1.0.3...v1.0.4) (2024-11-05)
10
-
11
-
12
-
13
- ## [1.0.3](https://github.com/Jett191/commit-pack/compare/v1.0.2...v1.0.3) (2024-11-05)
14
-
15
-
16
-
17
- ## [1.0.2](https://github.com/Jett191/commit-pack/compare/v1.0.1...v1.0.2) (2024-11-05)
18
-
19
-
20
-
21
- ## 1.0.1 (2024-11-05)
package/bin/index.js DELETED
@@ -1,181 +0,0 @@
1
- /* eslint-env node */
2
-
3
- import fs from 'fs'
4
- import chalk from 'chalk'
5
- import { execSync } from 'child_process'
6
-
7
- // 检测包管理器
8
- function detectPackageManager() {
9
- if (fs.existsSync('pnpm-lock.yaml')) {
10
- return 'pnpm'
11
- } else if (fs.existsSync('yarn.lock')) {
12
- return 'yarn'
13
- } else if (fs.existsSync('bun.lockb')) {
14
- return 'bun'
15
- } else {
16
- return 'npm'
17
- }
18
- }
19
-
20
- const packageManager = detectPackageManager()
21
- console.log(chalk.green(`检测到使用的包管理器:${packageManager}`))
22
-
23
- const packageJsonPath = './package.json'
24
- const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'))
25
-
26
- // 确保 devDependencies 存在
27
- if (!packageJson.devDependencies) {
28
- packageJson.devDependencies = {}
29
- }
30
-
31
- const devDependenciesWithVersion = {
32
- commitizen: '4.2.4',
33
- eslint: '8.57.1'
34
- }
35
-
36
- const devDependencies = [
37
- '@typescript-eslint/parser',
38
- '@typescript-eslint/eslint-plugin',
39
- 'prettier',
40
- 'eslint-config-prettier',
41
- 'eslint-plugin-prettier',
42
- 'husky',
43
- 'lint-staged',
44
- '@commitlint/cli',
45
- '@commitlint/config-conventional',
46
- 'commitlint-config-cz',
47
- 'cz-customizable',
48
- 'cz-custom'
49
- ]
50
-
51
- let dependenciesToInstall = []
52
-
53
- // 检查并收集需要安装的依赖
54
- for (const dep of devDependencies) {
55
- if (!packageJson.devDependencies[dep]) {
56
- dependenciesToInstall.push(dep)
57
- }
58
- }
59
-
60
- for (const [dep, version] of Object.entries(devDependenciesWithVersion)) {
61
- if (!packageJson.devDependencies[dep]) {
62
- dependenciesToInstall.push(`${dep}@${version}`)
63
- }
64
- }
65
-
66
- // 安装缺失的依赖
67
- if (dependenciesToInstall.length > 0) {
68
- let installCommand = ''
69
-
70
- switch (packageManager) {
71
- case 'pnpm':
72
- installCommand = `pnpm add -D ${dependenciesToInstall.join(' ')}`
73
- break
74
- case 'yarn':
75
- installCommand = `yarn add ${dependenciesToInstall.join(' ')} --dev`
76
- break
77
- case 'bun':
78
- installCommand = `bun add -d ${dependenciesToInstall.join(' ')}`
79
- break
80
- default:
81
- installCommand = `npm install ${dependenciesToInstall.join(' ')} --save-dev`
82
- break
83
- }
84
-
85
- console.log(chalk.green(`正在安装开发依赖:${dependenciesToInstall.join(', ')}`))
86
- console.log(chalk.green(`执行命令:${installCommand}`))
87
- execSync(installCommand, { stdio: 'inherit' })
88
- } else {
89
- console.log(chalk.yellow('所有开发依赖已安装,无需安装'))
90
- }
91
-
92
- // 初始化 Git 仓库
93
- console.log(chalk.green('初始化 Git 仓库'))
94
- try {
95
- // 检查是否已经是 Git 仓库
96
- execSync('git rev-parse --is-inside-work-tree', { stdio: 'ignore' })
97
- console.log(chalk.yellow('当前已是一个 Git 仓库'))
98
- } catch (error) {
99
- console.error(chalk.red('未检测到 Git 仓库,正在初始化...'), error)
100
- // 初始化 Git 仓库
101
- execSync('git init', { stdio: 'inherit' })
102
- }
103
-
104
- // 根据包管理器,执行对应的 Husky 初始化命令
105
- let huskyInitCommand = ''
106
- switch (packageManager) {
107
- case 'pnpm':
108
- huskyInitCommand = 'pnpm exec husky init'
109
- break
110
- case 'yarn':
111
- huskyInitCommand = 'yarn dlx husky-init'
112
- break
113
- case 'bun':
114
- huskyInitCommand = 'bunx husky init'
115
- break
116
- default:
117
- huskyInitCommand = 'npx husky init'
118
- break
119
- }
120
-
121
- console.log(chalk.green(`执行 Husky 初始化命令:${huskyInitCommand}`))
122
- execSync(huskyInitCommand, { stdio: 'inherit' })
123
-
124
- // 执行 setup-script 中的所有文件
125
- console.log(chalk.green('执行 setup-script 中的所有文件'))
126
- try {
127
- execSync('sh ./prettier.sh', { stdio: 'inherit' })
128
- execSync('sh ./lintstagedrc.sh', { stdio: 'inherit' })
129
- execSync('sh ./eslint.sh', { stdio: 'inherit' })
130
- execSync('sh ./czrc.sh', { stdio: 'inherit' })
131
- execSync('sh ./husky.sh', { stdio: 'inherit' })
132
- execSync('sh ./commitlintrc.sh', { stdio: 'inherit' })
133
- console.log(chalk.green('所有 setup-script 已执行完毕'))
134
- } catch (error) {
135
- console.error(chalk.red('执行 setup-script 时出错'), error)
136
- }
137
-
138
- // 创建或更新脚本
139
- if (!packageJson.scripts) {
140
- packageJson.scripts = {}
141
- }
142
-
143
- let modified = false
144
-
145
- if (!packageJson.scripts.lint) {
146
- packageJson.scripts.lint = 'eslint ./ --ext .ts,.tsx,.json --max-warnings=0'
147
- console.log(chalk.green('已添加 "lint" 脚本到 package.json'))
148
- modified = true
149
- } else {
150
- console.log(chalk.yellow('package.json 中已存在 "lint" 脚本,未作修改'))
151
- }
152
-
153
- if (!packageJson.scripts.format) {
154
- packageJson.scripts.format = "prettier --config .prettierrc '.' --write"
155
- console.log(chalk.green('已添加 "format" 脚本到 package.json'))
156
- modified = true
157
- } else {
158
- console.log(chalk.yellow('package.json 中已存在 "format" 脚本,未作修改'))
159
- }
160
-
161
- // 添加或更新 "commit" 脚本
162
- packageJson.scripts.commit = 'cz'
163
- console.log(chalk.green('已添加或更新 "commit" 脚本到 package.json'))
164
- modified = true
165
-
166
- // 添加或更新 "config.commitizen" 配置
167
- if (!packageJson.config) {
168
- packageJson.config = {}
169
- }
170
-
171
- packageJson.config.commitizen = {
172
- path: 'node_modules/cz-customizable'
173
- }
174
- console.log(chalk.green('已添加或更新 "config.commitizen" 到 package.json'))
175
- modified = true
176
-
177
- // 写入修改后的 package.json
178
- if (modified) {
179
- fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2), 'utf8')
180
- console.log(chalk.green('已更新 package.json'))
181
- }