@momo-kits/native-kits 0.156.1-test.9-debug → 0.156.1-tracking.2-debug

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.
Files changed (26) hide show
  1. package/PUBLISH_GUIDE.md +410 -184
  2. package/compose/build.gradle.kts +1 -1
  3. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +1 -0
  4. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +2 -3
  5. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +46 -7
  6. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +57 -1
  7. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/tracking/ScreenTracker.kt +218 -0
  8. package/example/ios/Example.xcodeproj/xcuserdata/sonnguyen.xcuserdatad/xcschemes/Example.xcscheme +32 -0
  9. package/example/ios/Example.xcodeproj/xcuserdata/sonnguyen.xcuserdatad/xcschemes/xcschememanagement.plist +14 -0
  10. package/example/ios/Example.xcworkspace/xcuserdata/sonnguyen.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  11. package/example/ios/Example.xcworkspace/xcuserdata/sonnguyen.xcuserdatad/WorkspaceSettings.xcsettings +16 -0
  12. package/example/ios/Example.xcworkspace/xcuserdata/sonnguyen.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +6 -0
  13. package/example/ios/Example.xcworkspace/xcuserdata/sonnguyen.xcuserdatad/xcschemes/xcschememanagement.plist +5 -0
  14. package/example/ios/Pods/Pods.xcodeproj/xcuserdata/sonnguyen.xcuserdatad/xcschemes/MoMoUIKits.xcscheme +58 -0
  15. package/example/ios/Pods/Pods.xcodeproj/xcuserdata/sonnguyen.xcuserdatad/xcschemes/Pods-Example.xcscheme +58 -0
  16. package/example/ios/Pods/Pods.xcodeproj/xcuserdata/sonnguyen.xcuserdatad/xcschemes/SDWebImage.xcscheme +58 -0
  17. package/example/ios/Pods/Pods.xcodeproj/xcuserdata/sonnguyen.xcuserdatad/xcschemes/SDWebImageSwiftUI.xcscheme +58 -0
  18. package/example/ios/Pods/Pods.xcodeproj/xcuserdata/sonnguyen.xcuserdatad/xcschemes/SkeletonUI.xcscheme +58 -0
  19. package/example/ios/Pods/Pods.xcodeproj/xcuserdata/sonnguyen.xcuserdatad/xcschemes/lottie-ios-LottiePrivacyInfo.xcscheme +58 -0
  20. package/example/ios/Pods/Pods.xcodeproj/xcuserdata/sonnguyen.xcuserdatad/xcschemes/lottie-ios.xcscheme +58 -0
  21. package/example/ios/Pods/Pods.xcodeproj/xcuserdata/sonnguyen.xcuserdatad/xcschemes/xcschememanagement.plist +60 -0
  22. package/gradle.properties +1 -1
  23. package/local.properties +2 -2
  24. package/package.json +1 -1
  25. package/{publish_release.sh → publish.sh} +195 -128
  26. package/publish_beta.sh +0 -275
package/PUBLISH_GUIDE.md CHANGED
@@ -1,90 +1,186 @@
1
1
  # Hướng Dẫn Publish NPM Package
2
2
 
3
- Tài liệu này hướng dẫn cách sử dụng các script publish beta và release cho `@momo-kits/native-kits`.
3
+ Tài liệu này hướng dẫn cách sử dụng script publish cho `@momo-kits/native-kits`.
4
4
 
5
5
  ---
6
6
 
7
7
  ## 📋 Tổng Quan
8
8
 
9
- Dự án 2 script publish chính:
9
+ Dự án sử dụng **`publish.sh`** - một script thống nhất hỗ trợ 2 modes:
10
10
 
11
- - **`publish_beta.sh`**: Publish phiên bản beta cho testing
12
- - **`publish_release.sh`**: Publish phiên bản release chính thức
11
+ - **`beta`**: Publish phiên bản beta cho testing
12
+ - **`release`**: Publish phiên bản release chính thức
13
+
14
+ Script có 3 phases riêng biệt:
15
+ 1. **Check Version**: Kiểm tra và chuẩn bị version
16
+ 2. **Publish NPM**: Publish lên NPM registry
17
+ 3. **Publish Maven**: Publish lên GitLab Maven repository
13
18
 
14
19
  ---
15
20
 
16
- ## 🔵 Publish Beta
21
+ ## 🚀 Publish Từ Local
22
+
23
+ ### Yêu Cầu Trước Khi Publish
24
+
25
+ 1. **Login NPM:**
26
+ ```bash
27
+ npm login
28
+ ```
29
+
30
+ 2. **Kiểm tra version hiện tại:**
31
+ ```bash
32
+ cat package.json | grep version
33
+ ```
17
34
 
18
- ### Khi Nào Sử Dụng?
35
+ ### 🔵 Publish Beta Từ Local
19
36
 
20
- - Khi cần test tính năng mới
21
- - Khi phát triển feature chưa hoàn thiện
22
- - Khi cần chia sẻ build cho team testing
37
+ #### **Cách 1: Publish tất cả phases (Khuyến nghị)**
23
38
 
24
- ### Cách Sử Dụng
39
+ ```bash
40
+ sh publish.sh beta
41
+ ```
25
42
 
26
- #### **Phương pháp 1: Manual**
43
+ #### **Cách 2: Chạy từng phase riêng**
27
44
 
28
45
  ```bash
29
- sh publish_beta.sh
46
+ # Phase 1: Check version
47
+ sh publish.sh beta check
48
+
49
+ # Phase 2: Publish NPM
50
+ sh publish.sh beta npm
51
+
52
+ # Phase 3: Publish Maven
53
+ sh publish.sh beta maven
30
54
  ```
31
55
 
32
- #### **Phương pháp 2: GitLab CI (Tự động)**
56
+ #### **Quy Trình Beta Publishing**
57
+
58
+ 1. **Update version trong `package.json`:**
59
+ ```json
60
+ {
61
+ "version": "0.156.2"
62
+ }
63
+ ```
64
+
65
+ 2. **Chạy check version trước (optional nhưng khuyến nghị):**
66
+ ```bash
67
+ sh publish.sh beta check
68
+ ```
69
+
70
+ 3. **Nếu check thành công, publish:**
71
+ ```bash
72
+ sh publish.sh beta
73
+ ```
74
+
75
+ #### **Ví Dụ Beta Publishing**
33
76
 
34
- Commit code với message chứa `[ci build]`:
77
+ ```bash
78
+ # 1. Kiểm tra version
79
+ $ cat package.json | grep version
80
+ "version": "0.156.2"
81
+
82
+ # 2. Test check version
83
+ $ sh publish.sh beta check
84
+ 📦 Version from package.json: 0.156.2
85
+ 🔎 Checking if version 0.156.2 already exists on npm...
86
+ ✅ Version 0.156.2 does not exist on npm. Safe to publish.
87
+ ✅ PHASE 1 COMPLETED
88
+
89
+ # 3. Publish
90
+ $ sh publish.sh beta
91
+ 🚀 PUBLISH SCRIPT - MODE: BETA
92
+ Running ALL PHASES
93
+ [... Phase 1: Check version ...]
94
+ [... Phase 2: Publish NPM ...]
95
+ 🐛 Debug version: 0.156.2-debug (with compose) - Published first
96
+ 📦 Normal version: 0.156.2 (without compose) - Published second
97
+ 🏷️ NPM Tag: beta
98
+ [... Phase 3: Publish Maven ...]
99
+ 🎉 ALL PHASES COMPLETED SUCCESSFULLY!
100
+ ```
101
+
102
+ #### **⚠️ Nếu Version Đã Tồn Tại**
35
103
 
36
104
  ```bash
37
- git commit -m "feat: add new feature [ci build]"
38
- git push
105
+ $ sh publish.sh beta check
106
+ ERROR: Version 0.156.1 already exists on npm!
107
+
108
+ Please update the version in package.json before publishing.
39
109
  ```
40
110
 
41
- ### Cách Hoạt Động
111
+ **Giải pháp:** Tăng version trong `package.json`:
112
+ ```bash
113
+ # Mở và edit file
114
+ vim package.json
115
+ # hoặc
116
+ code package.json
42
117
 
43
- 1. **Đọc version từ `package.json`**
44
- 2. **Publish 2 phiên bản:**
45
- - **Normal version**: Không bao gồm `compose/` (cho React Native)
46
- - **Debug version**: Bao gồm `compose/` với suffix `-debug`
118
+ # Thay đổi: "version": "0.156.1" → "0.156.2"
119
+ ```
47
120
 
48
- ### Dụ
121
+ ### 🟢 Publish Release Từ Local
49
122
 
50
- **Trước publish:** `package.json` `"version": "0.156.1"`
123
+ #### **Cách 1: Publish tất cả phases (Khuyến nghị)**
51
124
 
52
- **Output:**
125
+ ```bash
126
+ sh publish.sh release
53
127
  ```
54
- 📦 Version from package.json: 0.156.1
55
- 📤 Publishing normal version (without compose)...
56
- ✅ Normal version published successfully!
57
128
 
58
- 📦 Debug version: 0.156.1-debug
59
- 📤 Publishing debug version (with compose)...
60
- ✅ Publishing completed successfully!
129
+ #### **Cách 2: Chạy từng phase riêng**
130
+
131
+ ```bash
132
+ # Phase 1: Check version
133
+ sh publish.sh release check
134
+
135
+ # Phase 2: Publish NPM
136
+ sh publish.sh release npm
137
+
138
+ # Phase 3: Publish Maven
139
+ sh publish.sh release maven
61
140
  ```
62
141
 
63
- **Kết quả trên NPM:**
64
- - `@momo-kits/native-kits@0.156.1` (tag: beta)
65
- - `@momo-kits/native-kits@0.156.1-debug` (tag: beta)
142
+ #### **Quy Trình Release Publishing**
66
143
 
67
- ---
144
+ 1. **Version trong `package.json` có thể là bất kỳ format nào:**
145
+ ```json
146
+ {
147
+ "version": "0.156.1-test.5"
148
+ }
149
+ ```
150
+
151
+ 2. **Chạy publish:**
152
+ ```bash
153
+ sh publish.sh release
154
+ ```
68
155
 
69
- ## 🟢 Publish Release
156
+ 3. **Script sẽ tự động:**
157
+ - Convert sang format beta: `0.156.1-test.5` → `0.156.1-beta.1`
158
+ - Check version trên npm
159
+ - Auto-increment nếu đã tồn tại: `0.156.1-beta.1` → `0.156.1-beta.2`
160
+ - Publish với tag `latest`
70
161
 
71
- ### Khi Nào Sử Dụng?
162
+ ---
72
163
 
73
- - Khi merge code vào nhánh `main`
74
- - Khi release phiên bản production
75
- - Khi có version ổn định cần publish cho user
164
+ ## 🤖 Publish Tự Động Trên GitLab CI
76
165
 
77
- ### Cách Sử Dụng
166
+ ### 🔵 Beta Publishing (GitLab CI)
78
167
 
79
- #### **Phương pháp 1: Manual**
168
+ **Trigger:** Commit message chứa `[ci build]`
80
169
 
81
170
  ```bash
82
- sh publish_release.sh
171
+ git add .
172
+ git commit -m "feat: add new feature [ci build]"
173
+ git push
83
174
  ```
84
175
 
85
- #### **Phương pháp 2: GitLab CI (Tự động)**
176
+ **Pipeline sẽ chạy 3 stages:**
177
+ 1. `beta_check_version`
178
+ 2. `beta_publish_npm`
179
+ 3. `beta_publish_maven`
180
+
181
+ ### 🟢 Release Publishing (GitLab CI)
86
182
 
87
- Merge code vào nhánh `main`:
183
+ **Trigger:** Push vào nhánh `main`
88
184
 
89
185
  ```bash
90
186
  git checkout main
@@ -92,193 +188,224 @@ git merge develop
92
188
  git push origin main
93
189
  ```
94
190
 
95
- ### Cách Hoạt Động
191
+ **Pipeline sẽ chạy 3 stages:**
192
+ 1. `release_check_version`
193
+ 2. `release_publish_npm`
194
+ 3. `release_publish_maven`
96
195
 
97
- 1. **Đọc version từ `package.json`**
98
- 2. **Chuẩn hóa version về format beta:**
99
- - Nếu có suffix không phải `-beta.*` (ví dụ: `-test.5`, `-alpha.2`) → convert sang `-beta.1`
100
- - Nếu đã là `-beta.*` → giữ nguyên
101
- 3. **Kiểm tra version trên NPM:**
102
- - Nếu version đã tồn tại → tự động tăng beta number
103
- - Lặp lại cho đến khi tìm được version chưa tồn tại
104
- 4. **Publish với tag `latest`**
196
+ ---
105
197
 
106
- ### Dụ Chi Tiết
198
+ ## 📊 So Sánh Beta vs Release
107
199
 
108
- #### **Ví dụ 1: Version test được convert sang beta**
200
+ | Tiêu chí | Beta Mode | Release Mode |
201
+ |----------|-----------|--------------|
202
+ | **Script** | `sh publish.sh beta` | `sh publish.sh release` |
203
+ | **Trigger CI** | Commit có `[ci build]` | Push vào `main` |
204
+ | **Version Check** | **Fail** nếu tồn tại | **Auto-increment** |
205
+ | **Format Version** | Giữ nguyên | Convert → `-beta.*` |
206
+ | **NPM Tag** | `beta` | `latest` |
207
+ | **Publish Order** | Debug first → Normal | Debug first → Normal |
109
208
 
110
- **Trước publish:** `package.json` có `"version": "0.156.1-test.5"`
209
+ ---
111
210
 
112
- **Output:**
113
- ```
114
- 📦 Version from package.json: 0.156.1-test.5
115
- 🔄 Converting to beta format: 0.156.1-test.5 → 0.156.1-beta.1
116
- ✅ Version updated to beta format: 0.156.1-beta.1
117
- 🔎 Checking if version 0.156.1-beta.1 already exists on npm...
118
- ⚠️ Version 0.156.1-beta.1 already exists on npm. Auto-incrementing version...
119
- Version incremented: 0.156.1-beta.1 → 0.156.1-beta.2
120
- 🔄 Checking version 0.156.1-beta.2 on npm...
121
- ✅ Version 0.156.1-beta.2 does not exist on npm. Using this version.
122
- 📤 Publishing...
123
- ```
211
+ ## 🔍 Chi Tiết Các Phases
124
212
 
125
- **Kết quả:**
126
- - Publish `@momo-kits/native-kits@0.156.1-beta.2` (tag: latest)
213
+ ### **Phase 1: Check Version**
127
214
 
128
- ---
215
+ **Beta Mode:**
216
+ - Đọc version từ `package.json`
217
+ - Check version trên npm
218
+ - ❌ **FAIL** nếu version đã tồn tại
219
+ - Update `gradle.properties`
129
220
 
130
- #### ** dụ 2: Beta version tồn tại, tự động increment nhiều lần**
221
+ **Release Mode:**
222
+ - Đọc version từ `package.json`
223
+ - Convert sang format `-beta.*` nếu cần
224
+ - Check version trên npm
225
+ - ✅ **Auto-increment** nếu đã tồn tại
226
+ - Update `gradle.properties`
131
227
 
132
- **Trước publish:** `package.json` có `"version": "0.156.1-beta.5"`
228
+ ### **Phase 2: Publish NPM**
133
229
 
134
- **Giả sử trên NPM đã có:**
135
- - `0.156.1-beta.5` ✓
136
- - `0.156.1-beta.6` ✓
137
- - `0.156.1-beta.7` ✓
230
+ **Thứ tự publish (cả Beta và Release):**
138
231
 
139
- **Output:**
140
- ```
141
- 📦 Version from package.json: 0.156.1-beta.5
142
- 🔎 Checking if version 0.156.1-beta.5 already exists on npm...
143
- ⚠️ Version 0.156.1-beta.5 already exists on npm. Auto-incrementing version...
144
- Version incremented: 0.156.1-beta.5 → 0.156.1-beta.6
145
- 🔄 Checking version 0.156.1-beta.6 on npm...
146
- ⚠️ Version 0.156.1-beta.6 already exists on npm. Auto-incrementing version...
147
- Version incremented: 0.156.1-beta.6 → 0.156.1-beta.7
148
- 🔄 Checking version 0.156.1-beta.7 on npm...
149
- ⚠️ Version 0.156.1-beta.7 already exists on npm. Auto-incrementing version...
150
- Version incremented: 0.156.1-beta.7 → 0.156.1-beta.8
151
- 🔄 Checking version 0.156.1-beta.8 on npm...
152
- ✅ Version 0.156.1-beta.8 does not exist on npm. Using this version.
153
- ```
232
+ 1. **Debug version** (với compose) - Published FIRST
233
+ - Version: `X.Y.Z-debug`
234
+ - Bao gồm thư mục `compose/`
235
+ - Dành cho development/testing
154
236
 
155
- **Kết quả:**
156
- - Publish `@momo-kits/native-kits@0.156.1-beta.8` (tag: latest)
237
+ 2. **Normal version** (không compose) - Published SECOND
238
+ - Version: `X.Y.Z`
239
+ - Không bao gồm `compose/`
240
+ - Dành cho React Native apps
241
+
242
+ ### **Phase 3: Publish Maven**
243
+
244
+ - Publish Kotlin Multiplatform artifacts
245
+ - Lên GitLab Packages Repository
246
+ - Dành cho `compose` module
157
247
 
158
248
  ---
159
249
 
160
- #### **dụ 3: Version mới, không cần increment**
250
+ ## 📝 Dụ Chi Tiết
161
251
 
162
- **Trước publish:** `package.json` `"version": "0.157.0-beta.1"`
252
+ ### ** dụ 1: Beta - Version chưa tồn tại**
163
253
 
164
- **Output:**
165
- ```
166
- 📦 Version from package.json: 0.157.0-beta.1
167
- 🔎 Checking if version 0.157.0-beta.1 already exists on npm...
168
- Version 0.157.0-beta.1 does not exist on npm. Using this version.
254
+ ```bash
255
+ $ sh publish.sh beta
256
+
257
+ 📦 Version from package.json: 0.156.2
258
+ 🔎 Checking if version 0.156.2 already exists on npm...
259
+ ✅ Version 0.156.2 does not exist on npm. Safe to publish.
260
+
261
+ # Phase 2
262
+ 🐛 Debug version: 0.156.2-debug (with compose) - Published first
263
+ 📦 Normal version: 0.156.2 (without compose) - Published second
264
+ 🏷️ NPM Tag: beta
169
265
  ```
170
266
 
171
- **Kết quả:**
172
- - Publish `@momo-kits/native-kits@0.157.0-beta.1` (tag: latest)
267
+ **Kết quả trên NPM:**
268
+ - `@momo-kits/native-kits@0.156.2-debug` (tag: beta)
269
+ - `@momo-kits/native-kits@0.156.2` (tag: beta)
173
270
 
174
- ---
271
+ ### **Ví dụ 2: Beta - Version đã tồn tại (FAIL)**
272
+
273
+ ```bash
274
+ $ sh publish.sh beta check
175
275
 
176
- #### **Ví dụ 4: Version không có suffix**
276
+ 📦 Version from package.json: 0.156.1
277
+ 🔎 Checking if version 0.156.1 already exists on npm...
177
278
 
178
- **Trước publish:** `package.json` `"version": "1.0.0"`
279
+ ERROR: Version 0.156.1 already exists on npm!
179
280
 
180
- **Output:**
281
+ Please update the version in package.json before publishing.
282
+ # Exit code: 1
181
283
  ```
182
- 📦 Version from package.json: 1.0.0
183
- 🔎 Checking if version 1.0.0 already exists on npm...
184
- ⚠️ Version 1.0.0 already exists on npm. Auto-incrementing version...
185
- Version incremented: 1.0.0 → 1.0.1
186
- 🔄 Checking version 1.0.1 on npm...
187
- ✅ Version 1.0.1 does not exist on npm. Using this version.
284
+
285
+ ### **Ví dụ 3: Release - Auto-convert increment**
286
+
287
+ ```bash
288
+ $ sh publish.sh release
289
+
290
+ 📦 Version from package.json: 0.156.1-test.5
291
+ 🔄 Converting to beta format: 0.156.1-test.5 → 0.156.1-beta.1
292
+ ✅ Version updated to beta format: 0.156.1-beta.1
293
+ 🔎 Checking if version 0.156.1-beta.1 already exists on npm...
294
+ ⚠️ Version 0.156.1-beta.1 already exists on npm. Auto-incrementing...
295
+ Version incremented: 0.156.1-beta.1 → 0.156.1-beta.2
296
+ 🔄 Checking version 0.156.1-beta.2 on npm...
297
+ ✅ Version 0.156.1-beta.2 does not exist on npm. Using this version.
188
298
  ```
189
299
 
190
- **Kết quả:**
191
- - Publish `@momo-kits/native-kits@1.0.1` (tag: latest)
300
+ **Kết quả trên NPM:**
301
+ - `@momo-kits/native-kits@0.156.1-beta.2-debug` (tag: latest)
302
+ - `@momo-kits/native-kits@0.156.1-beta.2` (tag: latest)
192
303
 
193
- ---
304
+ ### **Ví dụ 4: Release - Multiple increments**
305
+
306
+ ```bash
307
+ $ sh publish.sh release
194
308
 
195
- ## 📊 So Sánh Publish Beta vs Release
309
+ 📦 Version from package.json: 0.156.1-beta.5
196
310
 
197
- | Tiêu chí | Publish Beta | Publish Release |
198
- |----------|--------------|-----------------|
199
- | **Script** | `publish_beta.sh` | `publish_release.sh` |
200
- | **Trigger CI** | Commit message có `[ci build]` | Merge vào `main` |
201
- | **NPM Tag** | `beta` | `latest` |
202
- | **Version Check** | Không | Có (tự động increment) |
203
- | **Format Version** | Giữ nguyên | Chuẩn hóa sang `-beta.*` |
204
- | **Số phiên bản publish** | 2 (normal + debug) | 1 (chỉ normal) |
311
+ # Giả sử NPM đã có: beta.5, beta.6, beta.7
312
+ ⚠️ Version 0.156.1-beta.5 already exists on npm...
313
+ Version incremented: 0.156.1-beta.5 0.156.1-beta.6
314
+ ⚠️ Version 0.156.1-beta.6 already exists on npm...
315
+ Version incremented: 0.156.1-beta.6 0.156.1-beta.7
316
+ ⚠️ Version 0.156.1-beta.7 already exists on npm...
317
+ Version incremented: 0.156.1-beta.7 0.156.1-beta.8
318
+ Version 0.156.1-beta.8 does not exist on npm. Using this version.
319
+ ```
205
320
 
206
321
  ---
207
322
 
208
- ## 🔧 Workflow Khuyến Nghị
323
+ ## 🎯 Workflow Khuyến Nghị
209
324
 
210
325
  ### Development Flow
211
326
 
212
- ```mermaid
213
- graph LR
214
- A[Develop Feature] --> B[Update version in package.json]
215
- B --> C{Ready for testing?}
216
- C -->|Yes| D[Commit với message ci build]
217
- D --> E[publish_beta.sh chạy tự động]
218
- E --> F[Team test version beta]
219
- F --> G{Approved?}
220
- G -->|No| A
221
- G -->|Yes| H[Merge to main]
222
- H --> I[publish_release.sh chạy tự động]
223
- I --> J[Version release published]
327
+ ```
328
+ ┌──────────────────────────────────────────────────┐
329
+ │ 1. Develop Feature
330
+ - Code changes │
331
+ - Update version in package.json │
332
+ └─────────────────┬────────────────────────────────┘
333
+
334
+ ┌──────────────────────────────────────────────────┐
335
+ 2. Beta Testing │
336
+ Local: sh publish.sh beta │
337
+ CI: git commit -m "feat: xxx [ci build]" │
338
+ └─────────────────┬────────────────────────────────┘
339
+
340
+ ┌──────────────────────────────────────────────────┐
341
+ │ 3. Team Testing │
342
+ │ npm install @momo-kits/native-kits@beta │
343
+ └─────────────────┬────────────────────────────────┘
344
+
345
+ ┌──────┴──────┐
346
+ │ Approved? │
347
+ └──────┬───────┘
348
+ │ Yes
349
+
350
+ ┌──────────────────────────────────────────────────┐
351
+ │ 4. Release Production │
352
+ │ Local: sh publish.sh release │
353
+ │ CI: merge to main │
354
+ └─────────────────┬────────────────────────────────┘
355
+
356
+ ┌──────────────────────────────────────────────────┐
357
+ │ 5. Production │
358
+ │ npm install @momo-kits/native-kits@latest │
359
+ └──────────────────────────────────────────────────┘
224
360
  ```
225
361
 
226
- ### Bước Thực Hiện
362
+ ---
227
363
 
228
- 1. **Development:**
229
- ```bash
230
- # Update version trong package.json
231
- # Ví dụ: "version": "0.156.2-test.1"
232
- ```
364
+ ## ⚠️ Lưu Ý Quan Trọng
233
365
 
234
- 2. **Beta Testing:**
235
- ```bash
236
- git add .
237
- git commit -m "feat: add new component [ci build]"
238
- git push
239
- # → Tự động publish beta
240
- ```
366
+ ### 1. Publishing Order
241
367
 
242
- 3. **Release Production:**
243
- ```bash
244
- git checkout main
245
- git merge develop
246
- git push origin main
247
- # → Tự động publish release với version được chuẩn hóa
248
- ```
368
+ **NPM publish theo thứ tự:**
369
+ 1. ✅ Debug version (`X.Y.Z-debug`) - FIRST
370
+ 2. Normal version (`X.Y.Z`) - SECOND
249
371
 
250
- ---
372
+ **Lý do:** Đảm bảo debug version luôn available trước
251
373
 
252
- ## ⚠️ Lưu Ý Quan Trọng
374
+ ### 2. Version Format
253
375
 
254
- ### 1. Format Version
376
+ **Beta Mode:**
377
+ - Giữ nguyên format trong `package.json`
378
+ - Fail nếu đã tồn tại trên npm
379
+ - ⚠️ Developer phải tự quản lý version
255
380
 
256
- - **Beta script**: Chấp nhận mọi format version
257
- - **Release script**: Tự động chuẩn hóa sang format `-beta.*`
381
+ **Release Mode:**
382
+ - Auto-convert sang `-beta.*` format:
258
383
  - `0.156.1-test.5` → `0.156.1-beta.1`
259
384
  - `0.156.1-alpha.2` → `0.156.1-beta.1`
260
385
  - `0.156.1-rc.3` → `0.156.1-beta.1`
261
-
262
- ### 2. Auto-Increment
263
-
264
- Script release có logic tự động tăng version:
265
- - **Beta versions**: Tăng beta number (`-beta.5` → `-beta.6`)
266
- - **Regular versions**: Tăng patch number (`1.0.0` → `1.0.1`)
386
+ - Auto-increment nếu tồn tại:
387
+ - Beta: `-beta.5` → `-beta.6`
388
+ - Regular: `1.0.0` → `1.0.1`
267
389
 
268
390
  ### 3. File Modifications
269
391
 
270
- Cả 2 script đều tạm thời modify các file sau (restore lại sau khi publish):
392
+ Script tạm thời modify các file (restore sau publish):
271
393
  - `package.json` (version)
272
394
  - `gradle.properties` (version)
273
395
  - `.npmignore` (cho debug version)
274
396
  - `compose/build.gradle.kts` (cho debug version)
275
397
 
276
- ### 4. Requirements
398
+ ### 4. NPM Permissions
277
399
 
278
- Cần có quyền publish package trên NPM:
279
400
  ```bash
280
- # Login NPM trước khi chạy manual
401
+ # Check account hiện tại
402
+ npm whoami
403
+
404
+ # Login nếu cần
281
405
  npm login
406
+
407
+ # Verify permissions
408
+ npm access ls-packages @momo-kits
282
409
  ```
283
410
 
284
411
  ---
@@ -287,32 +414,131 @@ npm login
287
414
 
288
415
  ### Lỗi: "Could not read version from package.json"
289
416
 
290
- **Nguyên nhân:** File `package.json` không hợp lệ hoặc không có field `version`
417
+ **Nguyên nhân:** File `package.json` không hợp lệ
291
418
 
292
419
  **Giải pháp:**
293
420
  ```bash
294
- # Kiểm tra package.json
421
+ # Kiểm tra syntax
422
+ cat package.json | jq .
423
+
424
+ # Kiểm tra version field
295
425
  cat package.json | grep version
296
426
  ```
297
427
 
298
- ### Lỗi: "Version already exists on npm"
428
+ ### Lỗi: "Version already exists on npm" (Beta)
299
429
 
300
- **Nguyên nhân:** Chỉ với beta script - version đã được publish
430
+ **Nguyên nhân:** Version đã được publish
301
431
 
302
- **Giải pháp:**
303
- - Tăng version trong `package.json` manually
304
- - Hoặc sử dụng release script (sẽ tự động increment)
432
+ **Giải pháp:**
433
+ ```bash
434
+ # Option 1: Tăng version thủ công
435
+ vim package.json
436
+ # "version": "0.156.1" → "0.156.2"
305
437
 
306
- ### Script không chạy trên GitLab CI
438
+ # Option 2: Sử dụng release mode (auto-increment)
439
+ sh publish.sh release
440
+ ```
307
441
 
308
- **Nguyên nhân:** Không đủ điều kiện trigger
442
+ ### Lỗi: "Permission denied"
443
+
444
+ **Nguyên nhân:** Không có quyền publish package
309
445
 
310
446
  **Giải pháp:**
311
- - Beta: Đảm bảo commit message có `[ci build]`
312
- - Release: Đảm bảo đang push vào nhánh `main`
447
+ ```bash
448
+ # 1. Kiểm tra account
449
+ npm whoami
450
+
451
+ # 2. Login với account có quyền
452
+ npm login
453
+
454
+ # 3. Liên hệ admin để cấp quyền
455
+ ```
456
+
457
+ ### Script không chạy trên GitLab CI
458
+
459
+ **Beta không trigger:**
460
+ - ✅ Check commit message có `[ci build]`
461
+ - ✅ Check branch không match `engine/w*`
462
+
463
+ **Release không trigger:**
464
+ - ✅ Check đang push vào `main` branch
465
+ - ✅ Check GitLab CI settings
466
+
467
+ ---
468
+
469
+ ## 📦 Sử Dụng Packages
470
+
471
+ ### Cài Đặt Beta Version
472
+
473
+ ```bash
474
+ # Latest beta
475
+ npm install @momo-kits/native-kits@beta
476
+
477
+ # Specific beta version
478
+ npm install @momo-kits/native-kits@0.156.2
479
+
480
+ # Debug version (with compose)
481
+ npm install @momo-kits/native-kits@0.156.2-debug
482
+ ```
483
+
484
+ ### Cài Đặt Release Version
485
+
486
+ ```bash
487
+ # Latest release
488
+ npm install @momo-kits/native-kits@latest
489
+ # hoặc
490
+ npm install @momo-kits/native-kits
491
+
492
+ # Specific release version
493
+ npm install @momo-kits/native-kits@0.156.1-beta.2
494
+ ```
495
+
496
+ ---
497
+
498
+ ## 🎓 Best Practices
499
+
500
+ 1. **Development:**
501
+ - Luôn test với beta trước khi release
502
+ - Dùng version có ý nghĩa (semantic versioning)
503
+
504
+ 2. **Beta Testing:**
505
+ - Update version mỗi lần publish beta
506
+ - Kiểm tra version trước khi commit
507
+
508
+ 3. **Release:**
509
+ - Chỉ release từ nhánh `main`
510
+ - Đảm bảo tất cả tests pass
511
+
512
+ 4. **Version Management:**
513
+ - Beta: Tự quản lý version, tăng thủ công
514
+ - Release: Để script auto-increment
313
515
 
314
516
  ---
315
517
 
316
518
  ## 📞 Support
317
519
 
318
520
  Nếu có vấn đề, liên hệ team hoặc tạo issue trên GitLab.
521
+
522
+ ---
523
+
524
+ ## 🔗 Quick Reference
525
+
526
+ ```bash
527
+ # Beta - Local
528
+ sh publish.sh beta # All phases
529
+ sh publish.sh beta check # Check only
530
+ sh publish.sh beta npm # NPM only
531
+ sh publish.sh beta maven # Maven only
532
+
533
+ # Release - Local
534
+ sh publish.sh release # All phases
535
+ sh publish.sh release check # Check only
536
+ sh publish.sh release npm # NPM only
537
+ sh publish.sh release maven # Maven only
538
+
539
+ # Beta - CI
540
+ git commit -m "feat: xxx [ci build]" # Trigger beta
541
+
542
+ # Release - CI
543
+ git push origin main # Trigger release
544
+ ```