@momo-kits/native-kits 0.156.1-test.7-debug → 0.156.1-test.8-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.
@@ -0,0 +1,318 @@
1
+ # Hướng Dẫn Publish NPM Package
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`.
4
+
5
+ ---
6
+
7
+ ## 📋 Tổng Quan
8
+
9
+ Dự án có 2 script publish chính:
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
13
+
14
+ ---
15
+
16
+ ## 🔵 Publish Beta
17
+
18
+ ### Khi Nào Sử Dụng?
19
+
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
23
+
24
+ ### Cách Sử Dụng
25
+
26
+ #### **Phương pháp 1: Manual**
27
+
28
+ ```bash
29
+ sh publish_beta.sh
30
+ ```
31
+
32
+ #### **Phương pháp 2: GitLab CI (Tự động)**
33
+
34
+ Commit code với message chứa `[ci build]`:
35
+
36
+ ```bash
37
+ git commit -m "feat: add new feature [ci build]"
38
+ git push
39
+ ```
40
+
41
+ ### Cách Hoạt Động
42
+
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`
47
+
48
+ ### Ví Dụ
49
+
50
+ **Trước publish:** `package.json` có `"version": "0.156.1"`
51
+
52
+ **Output:**
53
+ ```
54
+ 📦 Version from package.json: 0.156.1
55
+ 📤 Publishing normal version (without compose)...
56
+ ✅ Normal version published successfully!
57
+
58
+ 📦 Debug version: 0.156.1-debug
59
+ 📤 Publishing debug version (with compose)...
60
+ ✅ Publishing completed successfully!
61
+ ```
62
+
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)
66
+
67
+ ---
68
+
69
+ ## 🟢 Publish Release
70
+
71
+ ### Khi Nào Sử Dụng?
72
+
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
76
+
77
+ ### Cách Sử Dụng
78
+
79
+ #### **Phương pháp 1: Manual**
80
+
81
+ ```bash
82
+ sh publish_release.sh
83
+ ```
84
+
85
+ #### **Phương pháp 2: GitLab CI (Tự động)**
86
+
87
+ Merge code vào nhánh `main`:
88
+
89
+ ```bash
90
+ git checkout main
91
+ git merge develop
92
+ git push origin main
93
+ ```
94
+
95
+ ### Cách Hoạt Động
96
+
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`**
105
+
106
+ ### Ví Dụ Chi Tiết
107
+
108
+ #### **Ví dụ 1: Version test được convert sang beta**
109
+
110
+ **Trước publish:** `package.json` có `"version": "0.156.1-test.5"`
111
+
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
+ ```
124
+
125
+ **Kết quả:**
126
+ - Publish `@momo-kits/native-kits@0.156.1-beta.2` (tag: latest)
127
+
128
+ ---
129
+
130
+ #### **Ví dụ 2: Beta version tồn tại, tự động increment nhiều lần**
131
+
132
+ **Trước publish:** `package.json` có `"version": "0.156.1-beta.5"`
133
+
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` ✓
138
+
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
+ ```
154
+
155
+ **Kết quả:**
156
+ - Publish `@momo-kits/native-kits@0.156.1-beta.8` (tag: latest)
157
+
158
+ ---
159
+
160
+ #### **Ví dụ 3: Version mới, không cần increment**
161
+
162
+ **Trước publish:** `package.json` có `"version": "0.157.0-beta.1"`
163
+
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.
169
+ ```
170
+
171
+ **Kết quả:**
172
+ - Publish `@momo-kits/native-kits@0.157.0-beta.1` (tag: latest)
173
+
174
+ ---
175
+
176
+ #### **Ví dụ 4: Version không có suffix**
177
+
178
+ **Trước publish:** `package.json` có `"version": "1.0.0"`
179
+
180
+ **Output:**
181
+ ```
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.
188
+ ```
189
+
190
+ **Kết quả:**
191
+ - Publish `@momo-kits/native-kits@1.0.1` (tag: latest)
192
+
193
+ ---
194
+
195
+ ## 📊 So Sánh Publish Beta vs Release
196
+
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) |
205
+
206
+ ---
207
+
208
+ ## 🔧 Workflow Khuyến Nghị
209
+
210
+ ### Development Flow
211
+
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]
224
+ ```
225
+
226
+ ### Bước Thực Hiện
227
+
228
+ 1. **Development:**
229
+ ```bash
230
+ # Update version trong package.json
231
+ # Ví dụ: "version": "0.156.2-test.1"
232
+ ```
233
+
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
+ ```
241
+
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
+ ```
249
+
250
+ ---
251
+
252
+ ## ⚠️ Lưu Ý Quan Trọng
253
+
254
+ ### 1. Format Version
255
+
256
+ - **Beta script**: Chấp nhận mọi format version
257
+ - **Release script**: Tự động chuẩn hóa sang format `-beta.*`
258
+ - `0.156.1-test.5` → `0.156.1-beta.1`
259
+ - `0.156.1-alpha.2` → `0.156.1-beta.1`
260
+ - `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`)
267
+
268
+ ### 3. File Modifications
269
+
270
+ Cả 2 script đều tạm thời modify các file sau (và restore lại sau khi publish):
271
+ - `package.json` (version)
272
+ - `gradle.properties` (version)
273
+ - `.npmignore` (cho debug version)
274
+ - `compose/build.gradle.kts` (cho debug version)
275
+
276
+ ### 4. Requirements
277
+
278
+ Cần có quyền publish package trên NPM:
279
+ ```bash
280
+ # Login NPM trước khi chạy manual
281
+ npm login
282
+ ```
283
+
284
+ ---
285
+
286
+ ## 🐛 Troubleshooting
287
+
288
+ ### Lỗi: "Could not read version from package.json"
289
+
290
+ **Nguyên nhân:** File `package.json` không hợp lệ hoặc không có field `version`
291
+
292
+ **Giải pháp:**
293
+ ```bash
294
+ # Kiểm tra package.json
295
+ cat package.json | grep version
296
+ ```
297
+
298
+ ### Lỗi: "Version already exists on npm"
299
+
300
+ **Nguyên nhân:** Chỉ với beta script - version đã được publish
301
+
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)
305
+
306
+ ### Script không chạy trên GitLab CI
307
+
308
+ **Nguyên nhân:** Không đủ điều kiện trigger
309
+
310
+ **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`
313
+
314
+ ---
315
+
316
+ ## 📞 Support
317
+
318
+ Nếu có vấn đề, liên hệ team hoặc tạo issue trên GitLab.
@@ -40,7 +40,7 @@ kotlin {
40
40
  }
41
41
 
42
42
  cocoapods {
43
- version = "0.156.1-test.7-debug"
43
+ version = "0.156.1-test.8-debug"
44
44
  summary = "IOS Shared module"
45
45
  homepage = "https://momo.vn"
46
46
  ios.deploymentTarget = "15.0"
package/gradle.properties CHANGED
@@ -18,7 +18,7 @@ kotlin.apple.xcodeCompatibility.nowarn=true
18
18
  name="ComposeKits"
19
19
  group=vn.momo.kits
20
20
  artifact.id=kits
21
- version=0.156.1-test.7
21
+ version=0.156.1-test.8
22
22
 
23
23
  repo=GitLab
24
24
  url=https://gitlab.mservice.com.vn/api/v4/projects/5400/packages/maven
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/native-kits",
3
- "version": "0.156.1-test.7-debug",
3
+ "version": "0.156.1-test.8-debug",
4
4
  "private": false,
5
5
  "dependencies": {},
6
6
  "devDependencies": {},