lone-format 0.9.1 → 0.9.6
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/dist/JSON_KEY_SORT.md +168 -0
- package/dist/PIPELINE.md +156 -0
- package/dist/PUBLISH_WORKFLOW.md +128 -0
- package/dist/SETUP_CHECKLIST.md +64 -0
- package/dist/filter-simple-test.html +56 -0
- package/dist/performance-test.html +230 -0
- package/dist/test-app-update.js +44 -0
- package/dist/test-columns-split.js +40 -0
- package/dist/test-copy-consistency.js +25 -0
- package/dist/test-create-table.js +52 -0
- package/dist/test-filter.html +0 -0
- package/dist/test-final-format-logic.js +57 -0
- package/dist/test-format.ts +45 -0
- package/dist/test-highlight.js +62 -0
- package/dist/test-indent-direct.js +15 -0
- package/dist/test-indent.html +66 -0
- package/dist/test-insert-direct.js +29 -0
- package/dist/test-insert-format.js +61 -0
- package/dist/test-insert-regex.js +19 -0
- package/dist/test-join-format.js +40 -0
- package/dist/test-join-parse.js +40 -0
- package/dist/test-join.ts +35 -0
- package/dist/test-parse-clauses.js +55 -0
- package/dist/test-preserve-order.js +34 -0
- package/dist/test-regex-match.js +43 -0
- package/dist/test-rendering-flow.js +77 -0
- package/dist/test-select-indent.js +29 -0
- package/dist/test-sql-format.js +51 -0
- package/dist/test-tokenize-indent.js +49 -0
- package/dist/test-update-example.js +22 -0
- package/dist/test-update-format.js +45 -0
- package/dist/test-update-indent.js +56 -0
- package/package.json +1 -1
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
# JSON Key Sorting Feature
|
|
2
|
+
|
|
3
|
+
## 功能说明
|
|
4
|
+
|
|
5
|
+
为 `JsonFormat` 组件添加了 JSON 对象 key 排序功能。该功能可以按字母顺序对所有对象的键进行排序,便于查看和比较 JSON 数据。
|
|
6
|
+
|
|
7
|
+
## 特性
|
|
8
|
+
|
|
9
|
+
✅ **递归排序**:深度遍历所有嵌套对象,对每个对象的 key 进行排序
|
|
10
|
+
✅ **保护原数据**:排序只影响显示,不修改原始 JSON 数据
|
|
11
|
+
✅ **支持过滤**:可以与过滤功能配合使用,对过滤后的数据进行排序
|
|
12
|
+
✅ **可逆操作**:可以随时清除排序,恢复原始 key 顺序
|
|
13
|
+
|
|
14
|
+
## API 使用
|
|
15
|
+
|
|
16
|
+
### 1. 启用 Key 排序
|
|
17
|
+
|
|
18
|
+
```typescript
|
|
19
|
+
jsonFormatRef.value?.sortKeys()
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
调用后,组件会递归地对所有对象的 key 按字母顺序排序并重新渲染。
|
|
23
|
+
|
|
24
|
+
### 2. 清除 Key 排序
|
|
25
|
+
|
|
26
|
+
```typescript
|
|
27
|
+
jsonFormatRef.value?.clearSortKeys()
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
恢复到原始 key 顺序。
|
|
31
|
+
|
|
32
|
+
### 3. 检查排序状态
|
|
33
|
+
|
|
34
|
+
```typescript
|
|
35
|
+
const sorted = jsonFormatRef.value?.isSorted()
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
返回 `true` 表示当前启用了排序,`false` 表示未排序。
|
|
39
|
+
|
|
40
|
+
## 完整示例
|
|
41
|
+
|
|
42
|
+
```vue
|
|
43
|
+
<template>
|
|
44
|
+
<div>
|
|
45
|
+
<div class="controls">
|
|
46
|
+
<button @click="toggleSort">
|
|
47
|
+
{{ isSortEnabled ? '清除排序' : '排序 Keys' }}
|
|
48
|
+
</button>
|
|
49
|
+
</div>
|
|
50
|
+
|
|
51
|
+
<JsonFormat ref="jsonRef" v-model="jsonData" />
|
|
52
|
+
</div>
|
|
53
|
+
</template>
|
|
54
|
+
|
|
55
|
+
<script setup lang="ts">
|
|
56
|
+
import { ref } from 'vue'
|
|
57
|
+
import JsonFormat from 'lone-format/json-format'
|
|
58
|
+
import type { JsonFormatExposed } from 'lone-format/json-format'
|
|
59
|
+
|
|
60
|
+
const jsonRef = ref<JsonFormatExposed>()
|
|
61
|
+
const isSortEnabled = ref(false)
|
|
62
|
+
|
|
63
|
+
const jsonData = ref(JSON.stringify({
|
|
64
|
+
zebra: 'last',
|
|
65
|
+
apple: 'first',
|
|
66
|
+
mango: 'middle',
|
|
67
|
+
banana: 'second'
|
|
68
|
+
}, null, 2))
|
|
69
|
+
|
|
70
|
+
const toggleSort = () => {
|
|
71
|
+
if (isSortEnabled.value) {
|
|
72
|
+
jsonRef.value?.clearSortKeys()
|
|
73
|
+
isSortEnabled.value = false
|
|
74
|
+
} else {
|
|
75
|
+
jsonRef.value?.sortKeys()
|
|
76
|
+
isSortEnabled.value = true
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
</script>
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## 排序示例
|
|
83
|
+
|
|
84
|
+
### 排序前
|
|
85
|
+
```json
|
|
86
|
+
{
|
|
87
|
+
"zebra": "last animal",
|
|
88
|
+
"apple": "first fruit",
|
|
89
|
+
"mango": "tropical fruit",
|
|
90
|
+
"banana": "yellow fruit",
|
|
91
|
+
"user": {
|
|
92
|
+
"zipCode": "12345",
|
|
93
|
+
"age": 25,
|
|
94
|
+
"name": "Alice",
|
|
95
|
+
"email": "alice@example.com"
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### 排序后
|
|
101
|
+
```json
|
|
102
|
+
{
|
|
103
|
+
"apple": "first fruit",
|
|
104
|
+
"banana": "yellow fruit",
|
|
105
|
+
"mango": "tropical fruit",
|
|
106
|
+
"user": {
|
|
107
|
+
"age": 25,
|
|
108
|
+
"email": "alice@example.com",
|
|
109
|
+
"name": "Alice",
|
|
110
|
+
"zipCode": "12345"
|
|
111
|
+
},
|
|
112
|
+
"zebra": "last animal"
|
|
113
|
+
}
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## 实现原理
|
|
117
|
+
|
|
118
|
+
1. **深度复制**:排序时创建数据的深度副本,保护原始数据
|
|
119
|
+
2. **递归处理**:
|
|
120
|
+
- 对象:提取所有 key,按字母排序后重新构建对象
|
|
121
|
+
- 数组:递归处理每个元素
|
|
122
|
+
- 原始类型:直接返回
|
|
123
|
+
3. **计算属性**:使用 Vue 的 `computed` 属性实现响应式排序
|
|
124
|
+
4. **状态管理**:通过 `isSorted` 状态控制是否应用排序
|
|
125
|
+
|
|
126
|
+
## 类型定义
|
|
127
|
+
|
|
128
|
+
```typescript
|
|
129
|
+
export interface JsonFormatExposed {
|
|
130
|
+
// ... 其他方法
|
|
131
|
+
|
|
132
|
+
// Key 排序相关方法
|
|
133
|
+
sortKeys: () => void
|
|
134
|
+
clearSortKeys: () => void
|
|
135
|
+
isSorted: () => boolean
|
|
136
|
+
}
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
## 使用场景
|
|
140
|
+
|
|
141
|
+
- 📊 **数据对比**:对比两个 JSON 对象时,排序可以让 key 顺序一致
|
|
142
|
+
- 🔍 **快速查找**:在大型 JSON 中按字母顺序查找特定字段
|
|
143
|
+
- 📝 **文档生成**:生成 API 文档时保持字段顺序的一致性
|
|
144
|
+
- ✅ **测试验证**:在单元测试中验证 JSON 结构时更容易比较
|
|
145
|
+
|
|
146
|
+
## 注意事项
|
|
147
|
+
|
|
148
|
+
1. **原数据保护**:排序功能不会修改 `v-model` 绑定的原始数据
|
|
149
|
+
2. **性能考虑**:对于超大型 JSON(数千个对象),排序可能需要一些时间
|
|
150
|
+
3. **数组顺序**:数组元素的顺序保持不变,只有对象的 key 会被排序
|
|
151
|
+
4. **与过滤配合**:先应用过滤,再排序,或者反过来都可以
|
|
152
|
+
|
|
153
|
+
## 测试
|
|
154
|
+
|
|
155
|
+
项目中提供了测试页面 `test-key-sort.html`,可以直接在浏览器中打开测试排序功能。
|
|
156
|
+
|
|
157
|
+
```bash
|
|
158
|
+
# 打开测试页面
|
|
159
|
+
open test-key-sort.html
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
## 更新日志
|
|
163
|
+
|
|
164
|
+
- **v0.7.1+**: 新增 Key 排序功能
|
|
165
|
+
- 添加 `sortKeys()` API
|
|
166
|
+
- 添加 `clearSortKeys()` API
|
|
167
|
+
- 添加 `isSorted()` API
|
|
168
|
+
- 在 App.vue 的 Filter Test 标签页中集成排序按钮
|
package/dist/PIPELINE.md
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
# Automated CI/CD Pipeline Setup
|
|
2
|
+
|
|
3
|
+
This document explains how to set up and use the automated publishing pipeline for the lone-format project.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
The pipeline automatically handles:
|
|
8
|
+
1. **Version Bumping**: Automatically increments version in `package.json`
|
|
9
|
+
2. **Building**: Compiles and builds the library
|
|
10
|
+
3. **Publishing**: Publishes to npmjs.com
|
|
11
|
+
4. **Merging**: Merges publish branch to main after successful publish
|
|
12
|
+
|
|
13
|
+
## Setup Instructions
|
|
14
|
+
|
|
15
|
+
### 1. Required Secrets
|
|
16
|
+
|
|
17
|
+
Add the following secrets to your GitHub repository settings:
|
|
18
|
+
|
|
19
|
+
#### NPM_TOKEN
|
|
20
|
+
1. Go to [npmjs.com](https://npmjs.com) and login
|
|
21
|
+
2. Click your avatar → "Access Tokens"
|
|
22
|
+
3. Click "Generate New Token" → "Automation" (for CI/CD)
|
|
23
|
+
4. Copy the token
|
|
24
|
+
5. In GitHub: Settings → Secrets and variables → Actions → New repository secret
|
|
25
|
+
6. Name: `NPM_TOKEN`, Value: [your token]
|
|
26
|
+
|
|
27
|
+
### 2. Branch Protection (Optional but Recommended)
|
|
28
|
+
|
|
29
|
+
Configure branch protection for `main`:
|
|
30
|
+
1. Go to Settings → Branches
|
|
31
|
+
2. Add rule for `main` branch
|
|
32
|
+
3. Check "Require status checks to pass before merging"
|
|
33
|
+
4. Check "Require branches to be up to date before merging"
|
|
34
|
+
|
|
35
|
+
## Usage
|
|
36
|
+
|
|
37
|
+
### Automatic Trigger
|
|
38
|
+
|
|
39
|
+
Push to the `publish` branch to trigger the pipeline:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
git checkout publish
|
|
43
|
+
git add .
|
|
44
|
+
git commit -m "feat: add new feature"
|
|
45
|
+
git push origin publish
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### Version Bump Rules
|
|
49
|
+
|
|
50
|
+
The pipeline automatically determines version bump type from commit messages:
|
|
51
|
+
|
|
52
|
+
- **Patch** (0.1.6 → 0.1.7): Default for any commit
|
|
53
|
+
- **Minor** (0.1.6 → 0.2.0): Commits with `feat:` or `minor:` prefix
|
|
54
|
+
- **Major** (0.1.6 → 1.0.0): Commits with `BREAKING CHANGE` or `major:` prefix
|
|
55
|
+
|
|
56
|
+
### Examples
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
# Patch version bump
|
|
60
|
+
git commit -m "fix: resolve issue with JSON parsing"
|
|
61
|
+
|
|
62
|
+
# Minor version bump
|
|
63
|
+
git commit -m "feat: add new theme support"
|
|
64
|
+
|
|
65
|
+
# Major version bump
|
|
66
|
+
git commit -m "major: complete API redesign
|
|
67
|
+
|
|
68
|
+
BREAKING CHANGE: API has been completely redesigned"
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Manual Trigger
|
|
72
|
+
|
|
73
|
+
You can also trigger the pipeline manually:
|
|
74
|
+
1. Go to Actions → "Auto Publish and Merge" workflow
|
|
75
|
+
2. Click "Run workflow"
|
|
76
|
+
3. Select branch `publish` and version type
|
|
77
|
+
4. Click "Run workflow"
|
|
78
|
+
|
|
79
|
+
## Pipeline Steps
|
|
80
|
+
|
|
81
|
+
### 1. Build and Publish Job
|
|
82
|
+
- Checks out `publish` branch
|
|
83
|
+
- Sets up Node.js environment
|
|
84
|
+
- Installs dependencies
|
|
85
|
+
- Bumps version based on commit message
|
|
86
|
+
- Builds the library
|
|
87
|
+
- Publishes to npm
|
|
88
|
+
- Commits version changes back to `publish`
|
|
89
|
+
|
|
90
|
+
### 2. Merge to Main Job
|
|
91
|
+
- Merges `publish` branch to `main`
|
|
92
|
+
- Creates a git tag for the release
|
|
93
|
+
- Creates a GitHub release with changelog
|
|
94
|
+
|
|
95
|
+
## Workflow Files
|
|
96
|
+
|
|
97
|
+
The project includes two workflow options:
|
|
98
|
+
|
|
99
|
+
### `publish.yml` - Full Featured
|
|
100
|
+
- Includes PR creation and auto-merge
|
|
101
|
+
- More complex error handling
|
|
102
|
+
- Better for teams with review processes
|
|
103
|
+
|
|
104
|
+
### `simple-publish.yml` - Streamlined
|
|
105
|
+
- Direct merge to main (no PRs)
|
|
106
|
+
- Simpler and faster
|
|
107
|
+
- Better for solo developers or trusted teams
|
|
108
|
+
|
|
109
|
+
## Troubleshooting
|
|
110
|
+
|
|
111
|
+
### Build Failures
|
|
112
|
+
If the build fails, the pipeline will still attempt to publish with minimal assets. Check the Actions logs for details.
|
|
113
|
+
|
|
114
|
+
### NPM Publishing Errors
|
|
115
|
+
- Verify `NPM_TOKEN` is set correctly
|
|
116
|
+
- Ensure you have publish permissions for the package
|
|
117
|
+
- Check if the version already exists on npm
|
|
118
|
+
|
|
119
|
+
### Merge Conflicts
|
|
120
|
+
If merge conflicts occur:
|
|
121
|
+
1. Manually resolve conflicts in `publish` branch
|
|
122
|
+
2. Push the resolved conflicts
|
|
123
|
+
3. The pipeline will retry automatically
|
|
124
|
+
|
|
125
|
+
## Package Configuration
|
|
126
|
+
|
|
127
|
+
The `package.json` includes these helpful scripts:
|
|
128
|
+
|
|
129
|
+
```json
|
|
130
|
+
{
|
|
131
|
+
"scripts": {
|
|
132
|
+
"build:lib": "vite build --mode lib",
|
|
133
|
+
"build:lib:full": "vue-tsc -b && vite build --mode lib",
|
|
134
|
+
"publish:lib": "npm publish --access public",
|
|
135
|
+
"publish:dry": "npm publish --dry-run",
|
|
136
|
+
"version:patch": "npm version patch --no-git-tag-version",
|
|
137
|
+
"version:minor": "npm version minor --no-git-tag-version",
|
|
138
|
+
"version:major": "npm version major --no-git-tag-version"
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
## Security Notes
|
|
144
|
+
|
|
145
|
+
- Never commit `NPM_TOKEN` to the repository
|
|
146
|
+
- Use automation tokens, not personal access tokens
|
|
147
|
+
- Regularly rotate your npm tokens
|
|
148
|
+
- Monitor npm package downloads and versions
|
|
149
|
+
|
|
150
|
+
## Support
|
|
151
|
+
|
|
152
|
+
If you encounter issues with the pipeline:
|
|
153
|
+
1. Check the Actions tab for detailed logs
|
|
154
|
+
2. Verify all secrets are properly configured
|
|
155
|
+
3. Ensure branch permissions are correctly set
|
|
156
|
+
4. Review commit message format for version bumping
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
# 发布工作流程说明
|
|
2
|
+
|
|
3
|
+
## 📋 概述
|
|
4
|
+
|
|
5
|
+
当代码推送到 `main` 分支时,GitHub Actions 会自动执行以下流程:
|
|
6
|
+
|
|
7
|
+
## 🔄 工作流程
|
|
8
|
+
|
|
9
|
+
### 1. 触发条件
|
|
10
|
+
- **自动触发**: Push 到 `main` 分支
|
|
11
|
+
- **手动触发**: 通过 GitHub Actions UI 手动执行(可选择版本类型)
|
|
12
|
+
|
|
13
|
+
### 2. 执行步骤
|
|
14
|
+
|
|
15
|
+
#### Step 1: 在 main 分支升级版本
|
|
16
|
+
1. Checkout `main` 分支
|
|
17
|
+
2. 安装依赖
|
|
18
|
+
3. 根据提交信息自动判断版本升级类型:
|
|
19
|
+
- `BREAKING CHANGE` 或 `major:` → major 版本
|
|
20
|
+
- `feat:` 或 `minor:` → minor 版本
|
|
21
|
+
- 其他 → patch 版本
|
|
22
|
+
4. 执行 `npm version` 升级版本号
|
|
23
|
+
5. 提交版本变更到 `main` 分支(带 `[skip ci]` 避免循环触发)
|
|
24
|
+
|
|
25
|
+
#### Step 2: 合并到 publish 分支
|
|
26
|
+
1. Fetch `publish` 分支(如不存在则创建)
|
|
27
|
+
2. 切换到 `publish` 分支
|
|
28
|
+
3. 将 `main` 分支合并到 `publish`
|
|
29
|
+
4. 推送 `publish` 分支
|
|
30
|
+
|
|
31
|
+
#### Step 3: 构建和发布
|
|
32
|
+
1. 在 `publish` 分支执行 `npm run build:lib`
|
|
33
|
+
2. 发布到 npm(使用 NPM_TOKEN secret)
|
|
34
|
+
3. 创建 Git Tag(格式:`vX.Y.Z`)
|
|
35
|
+
4. 推送 Tag 到远程仓库
|
|
36
|
+
|
|
37
|
+
### 3. 通知结果
|
|
38
|
+
- ✅ 成功:显示发布的版本号
|
|
39
|
+
- ❌ 失败:显示错误信息
|
|
40
|
+
|
|
41
|
+
## 🎯 分支策略
|
|
42
|
+
|
|
43
|
+
- **main**: 开发主分支,所有功能开发完成后合并到此分支
|
|
44
|
+
- **publish**: 发布分支,从 main 合并,用于构建和发布到 npm
|
|
45
|
+
- **dev**: 开发分支(可选),用于日常开发
|
|
46
|
+
|
|
47
|
+
## 📝 提交信息规范
|
|
48
|
+
|
|
49
|
+
为了自动判断版本升级类型,建议遵循以下提交信息规范:
|
|
50
|
+
|
|
51
|
+
- `feat: 新功能` → 触发 minor 版本升级
|
|
52
|
+
- `fix: 修复bug` → 触发 patch 版本升级
|
|
53
|
+
- `BREAKING CHANGE: 重大变更` → 触发 major 版本升级
|
|
54
|
+
- `chore: 日常维护` → 触发 patch 版本升级
|
|
55
|
+
|
|
56
|
+
## ⚙️ 配置要求
|
|
57
|
+
|
|
58
|
+
### GitHub Secrets
|
|
59
|
+
需要在 GitHub 仓库设置中添加以下 Secret:
|
|
60
|
+
|
|
61
|
+
- `NPM_TOKEN`: npm 发布令牌
|
|
62
|
+
- 获取方式:npm 官网 → Access Tokens → Generate New Token → Automation
|
|
63
|
+
|
|
64
|
+
### 权限设置
|
|
65
|
+
工作流需要以下权限:
|
|
66
|
+
- `contents: write` - 写入仓库内容
|
|
67
|
+
- `pull-requests: write` - 创建 PR
|
|
68
|
+
- `packages: write` - 发布包
|
|
69
|
+
|
|
70
|
+
## 🚀 使用示例
|
|
71
|
+
|
|
72
|
+
### 自动发布(推荐)
|
|
73
|
+
```bash
|
|
74
|
+
# 1. 在 dev 分支开发
|
|
75
|
+
git checkout dev
|
|
76
|
+
# ... 进行开发 ...
|
|
77
|
+
|
|
78
|
+
# 2. 提交代码
|
|
79
|
+
git add .
|
|
80
|
+
git commit -m "feat: 添加新功能"
|
|
81
|
+
git push origin dev
|
|
82
|
+
|
|
83
|
+
# 3. 合并到 main 分支
|
|
84
|
+
git checkout main
|
|
85
|
+
git merge dev
|
|
86
|
+
git push origin main # 这会自动触发发布流程
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### 手动发布
|
|
90
|
+
1. 访问 GitHub 仓库
|
|
91
|
+
2. 点击 "Actions" 标签
|
|
92
|
+
3. 选择 "Auto Publish and Merge" 工作流
|
|
93
|
+
4. 点击 "Run workflow"
|
|
94
|
+
5. 选择版本类型(patch/minor/major)
|
|
95
|
+
6. 点击 "Run workflow" 按钮
|
|
96
|
+
|
|
97
|
+
## 🔍 监控和调试
|
|
98
|
+
|
|
99
|
+
### 查看发布状态
|
|
100
|
+
1. 访问仓库的 Actions 页面
|
|
101
|
+
2. 查看最新的工作流运行记录
|
|
102
|
+
3. 点击查看详细日志
|
|
103
|
+
|
|
104
|
+
### 常见问题
|
|
105
|
+
|
|
106
|
+
**Q: 发布失败怎么办?**
|
|
107
|
+
A: 检查以下几点:
|
|
108
|
+
- NPM_TOKEN 是否正确配置
|
|
109
|
+
- package.json 中的 name 和 version 是否正确
|
|
110
|
+
- 是否有足够的权限发布到 npm
|
|
111
|
+
|
|
112
|
+
**Q: 如何跳过自动发布?**
|
|
113
|
+
A: 在提交信息中添加 `[skip ci]`
|
|
114
|
+
|
|
115
|
+
**Q: 如何回滚版本?**
|
|
116
|
+
A: 需要手动执行:
|
|
117
|
+
```bash
|
|
118
|
+
npm unpublish <package-name>@<version>
|
|
119
|
+
git tag -d v<version>
|
|
120
|
+
git push origin :refs/tags/v<version>
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
## 📌 注意事项
|
|
124
|
+
|
|
125
|
+
1. **避免循环触发**: 版本提交使用 `[skip ci]` 标记
|
|
126
|
+
2. **分支保护**: 建议为 `main` 和 `publish` 分支启用保护规则
|
|
127
|
+
3. **发布前测试**: 确保在 `dev` 分支充分测试后再合并到 `main`
|
|
128
|
+
4. **版本管理**: 遵循语义化版本规范(Semantic Versioning)
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# CI/CD Pipeline Setup Checklist
|
|
2
|
+
|
|
3
|
+
## ✅ Completed Tasks
|
|
4
|
+
|
|
5
|
+
- [x] Created GitHub Actions workflows for automated publishing
|
|
6
|
+
- [x] Configured automatic version bumping based on commit messages
|
|
7
|
+
- [x] Set up npm publishing automation
|
|
8
|
+
- [x] Implemented automatic merge from publish to main branch
|
|
9
|
+
- [x] Added comprehensive documentation
|
|
10
|
+
- [x] Created local testing script
|
|
11
|
+
- [x] Updated build configuration for better reliability
|
|
12
|
+
- [x] Enhanced README with pipeline information
|
|
13
|
+
|
|
14
|
+
## 📋 Setup Requirements
|
|
15
|
+
|
|
16
|
+
### Required GitHub Secrets
|
|
17
|
+
- [ ] `NPM_TOKEN` - Automation token from npmjs.com
|
|
18
|
+
|
|
19
|
+
### Branch Setup
|
|
20
|
+
- [ ] Create `publish` branch for triggering deployments
|
|
21
|
+
- [ ] Configure branch protection on `main` (optional but recommended)
|
|
22
|
+
|
|
23
|
+
## 🚀 Usage Instructions
|
|
24
|
+
|
|
25
|
+
### Automated Publishing Flow
|
|
26
|
+
1. Make changes on any branch
|
|
27
|
+
2. Merge/push to `publish` branch
|
|
28
|
+
3. Pipeline automatically:
|
|
29
|
+
- Bumps version based on commit message
|
|
30
|
+
- Builds the library
|
|
31
|
+
- Publishes to npm
|
|
32
|
+
- Merges to main branch
|
|
33
|
+
- Creates GitHub release
|
|
34
|
+
|
|
35
|
+
### Commit Message Conventions
|
|
36
|
+
- `fix:` or default → patch version (0.1.6 → 0.1.7)
|
|
37
|
+
- `feat:` or `minor:` → minor version (0.1.6 → 0.2.0)
|
|
38
|
+
- `BREAKING CHANGE` or `major:` → major version (0.1.6 → 1.0.0)
|
|
39
|
+
|
|
40
|
+
## 📄 Files Created
|
|
41
|
+
|
|
42
|
+
1. `.github/workflows/publish.yml` - Full-featured workflow with PR creation
|
|
43
|
+
2. `.github/workflows/simple-publish.yml` - Streamlined direct-merge workflow
|
|
44
|
+
3. `PIPELINE.md` - Detailed setup and usage documentation
|
|
45
|
+
4. `scripts/test-pipeline.sh` - Local testing script
|
|
46
|
+
5. Updated `README.md` with pipeline information
|
|
47
|
+
6. Updated `package.json` with additional scripts
|
|
48
|
+
7. Enhanced `vite.config.ts` for better builds
|
|
49
|
+
|
|
50
|
+
## ⚠️ Important Notes
|
|
51
|
+
|
|
52
|
+
- The `simple-publish.yml` workflow is recommended for most use cases
|
|
53
|
+
- Disable `publish.yml` if using `simple-publish.yml` to avoid conflicts
|
|
54
|
+
- Ensure NPM_TOKEN has publish permissions for the package
|
|
55
|
+
- Test locally with `./scripts/test-pipeline.sh` before first use
|
|
56
|
+
|
|
57
|
+
## 🔧 Next Steps
|
|
58
|
+
|
|
59
|
+
1. Add `NPM_TOKEN` to GitHub repository secrets
|
|
60
|
+
2. Create and test `publish` branch
|
|
61
|
+
3. Make a test commit to verify the pipeline works
|
|
62
|
+
4. Monitor first automated publish for any issues
|
|
63
|
+
|
|
64
|
+
Pipeline is ready for production use! 🎉
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
|
|
4
|
+
<head>
|
|
5
|
+
<meta charset="UTF-8">
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
7
|
+
<title>Filter Test</title>
|
|
8
|
+
<script src="./dist/lone-format.umd.cjs"></script>
|
|
9
|
+
<link rel="stylesheet" href="./dist/lone-format.css">
|
|
10
|
+
<style>
|
|
11
|
+
body {
|
|
12
|
+
font-family: Arial, sans-serif;
|
|
13
|
+
margin: 20px;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.test-section {
|
|
17
|
+
margin: 20px 0;
|
|
18
|
+
padding: 20px;
|
|
19
|
+
border: 1px solid #ccc;
|
|
20
|
+
}
|
|
21
|
+
</style>
|
|
22
|
+
</head>
|
|
23
|
+
|
|
24
|
+
<body>
|
|
25
|
+
<h1>Filter Feature Test</h1>
|
|
26
|
+
|
|
27
|
+
<div class="test-section">
|
|
28
|
+
<h3>Test 1: Basic Filter</h3>
|
|
29
|
+
<div id="test1"></div>
|
|
30
|
+
</div>
|
|
31
|
+
|
|
32
|
+
<script>
|
|
33
|
+
// Test basic filter functionality
|
|
34
|
+
console.log('LoneFormat:', typeof window.LoneFormat);
|
|
35
|
+
console.log('JsonFormat:', window.LoneFormat?.JsonFormat);
|
|
36
|
+
|
|
37
|
+
// Test data
|
|
38
|
+
const testData = {
|
|
39
|
+
"users": [
|
|
40
|
+
{ "id": 1, "name": "Alice", "age": 25 },
|
|
41
|
+
{ "id": 2, "name": "Bob", "age": 30 }
|
|
42
|
+
],
|
|
43
|
+
"company": "Test Corp"
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const jsonString = JSON.stringify(testData, null, 2);
|
|
47
|
+
|
|
48
|
+
// Create a simple test
|
|
49
|
+
document.getElementById('test1').innerHTML = `
|
|
50
|
+
<textarea rows="10" cols="50">${jsonString}</textarea>
|
|
51
|
+
<p>Filter functionality is available in the main app.</p>
|
|
52
|
+
`;
|
|
53
|
+
</script>
|
|
54
|
+
</body>
|
|
55
|
+
|
|
56
|
+
</html>
|