haven-cypress-integration 1.2.1 → 1.3.0
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/README.md +29 -12
- package/bin/haven-cypress.js +8 -3
- package/index.js +25 -8
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -67,29 +67,46 @@ npx haven-cypress run --automationIds=TC-AUTO-123,TC-AUTO-124
|
|
|
67
67
|
Images are organized in the `haven-test-images` ECR repository with product-based versioning:
|
|
68
68
|
```
|
|
69
69
|
Repository: haven-test-images
|
|
70
|
-
├── BE-
|
|
71
|
-
├── BE-
|
|
72
|
-
├── payments-
|
|
73
|
-
└── auth-
|
|
70
|
+
├── BE-1.0.123456 (latest with build number)
|
|
71
|
+
├── BE-2.1.0 (semantic version)
|
|
72
|
+
├── payments-1.0.789012
|
|
73
|
+
└── auth-3.0.0
|
|
74
74
|
```
|
|
75
75
|
|
|
76
76
|
**Tag Format**: `{PRODUCT}-{VERSION}`
|
|
77
77
|
- **Product**: Organizes images by product/team
|
|
78
|
-
- **Version**: Semantic versioning (e.g., `
|
|
78
|
+
- **Version**: Semantic versioning (e.g., `2.1.0`) or build numbers (e.g., `1.0.123456`)
|
|
79
79
|
|
|
80
80
|
### Versioning Examples
|
|
81
|
+
|
|
82
|
+
**Using package.json version (Recommended):**
|
|
83
|
+
```json
|
|
84
|
+
// package.json
|
|
85
|
+
{
|
|
86
|
+
"version": "2.1.0"
|
|
87
|
+
}
|
|
88
|
+
```
|
|
81
89
|
```bash
|
|
82
|
-
#
|
|
90
|
+
# Automatically uses package.json version
|
|
83
91
|
npx haven-cypress build --product=BE --push
|
|
84
|
-
→ ECR tag: BE-
|
|
92
|
+
→ ECR tag: BE-2.1.0
|
|
93
|
+
```
|
|
85
94
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
95
|
+
**Manual version override:**
|
|
96
|
+
```bash
|
|
97
|
+
# Override with custom semantic version
|
|
98
|
+
npx haven-cypress build --product=BE --tag=v3.0.0 --push
|
|
99
|
+
→ ECR tag: BE-3.0.0
|
|
89
100
|
|
|
90
|
-
|
|
101
|
+
npx haven-cypress build --product=BE --tag=3.0.0 --push
|
|
102
|
+
→ ECR tag: BE-3.0.0
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
**Fallback for missing package.json:**
|
|
106
|
+
```bash
|
|
107
|
+
# Falls back to build number if no package.json version found
|
|
91
108
|
BUILD_NUMBER=456 npx haven-cypress build --product=BE --push
|
|
92
|
-
→ ECR tag: BE-
|
|
109
|
+
→ ECR tag: BE-1.0.456
|
|
93
110
|
```
|
|
94
111
|
|
|
95
112
|
## What's Included
|
package/bin/haven-cypress.js
CHANGED
|
@@ -28,9 +28,14 @@ Examples:
|
|
|
28
28
|
npx haven-cypress run --automationIds=TC-AUTO-123,TC-AUTO-124
|
|
29
29
|
|
|
30
30
|
Versioning:
|
|
31
|
-
--tag=latest → ECR tag: BE-
|
|
32
|
-
--tag=v2.1.0 → ECR tag: BE-
|
|
33
|
-
|
|
31
|
+
--tag=latest → ECR tag: BE-{package.json.version} or BE-1.0.{BUILD_NUMBER}
|
|
32
|
+
--tag=v2.1.0 → ECR tag: BE-2.1.0
|
|
33
|
+
--tag=2.1.0 → ECR tag: BE-2.1.0
|
|
34
|
+
|
|
35
|
+
Version Priority:
|
|
36
|
+
1. Custom --tag (if provided)
|
|
37
|
+
2. package.json version (for --tag=latest)
|
|
38
|
+
3. BUILD_NUMBER fallback (if package.json not found)
|
|
34
39
|
`);
|
|
35
40
|
process.exit(1);
|
|
36
41
|
}
|
package/index.js
CHANGED
|
@@ -152,20 +152,37 @@ class HavenCypressIntegration {
|
|
|
152
152
|
const ecrRepo = 'haven-test-images';
|
|
153
153
|
const ecrUri = `${accountId}.dkr.ecr.${region}.amazonaws.com/${ecrRepo}`;
|
|
154
154
|
|
|
155
|
-
// Extract version from local tag or use
|
|
155
|
+
// Extract version from local tag or use package.json version
|
|
156
156
|
const localVersion = localTag.split(':')[1] || 'latest';
|
|
157
157
|
|
|
158
158
|
// Generate ECR tag with product and version
|
|
159
159
|
let ecrTag;
|
|
160
160
|
if (localVersion === 'latest') {
|
|
161
|
-
//
|
|
162
|
-
|
|
163
|
-
|
|
161
|
+
// Try to read version from package.json first
|
|
162
|
+
let packageVersion = null;
|
|
163
|
+
try {
|
|
164
|
+
const packageJsonPath = path.join(process.cwd(), 'package.json');
|
|
165
|
+
if (fs.existsSync(packageJsonPath)) {
|
|
166
|
+
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
|
|
167
|
+
packageVersion = packageJson.version;
|
|
168
|
+
}
|
|
169
|
+
} catch (error) {
|
|
170
|
+
console.warn('⚠️ Could not read package.json version:', error.message);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
if (packageVersion) {
|
|
174
|
+
// Use package.json version
|
|
175
|
+
const cleanVersion = packageVersion.startsWith('v') ? packageVersion.slice(1) : packageVersion;
|
|
176
|
+
ecrTag = `${product}-${cleanVersion}`;
|
|
177
|
+
} else {
|
|
178
|
+
// Fallback to build number format
|
|
179
|
+
const buildNumber = process.env.BUILD_NUMBER || Date.now().toString().slice(-6);
|
|
180
|
+
ecrTag = `${product}-1.0.${buildNumber}`;
|
|
181
|
+
}
|
|
164
182
|
} else {
|
|
165
|
-
// For custom versions, preserve semantic versioning
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
ecrTag = `${product}-${versionTag}`;
|
|
183
|
+
// For custom versions, preserve semantic versioning without 'v' prefix
|
|
184
|
+
const cleanVersion = localVersion.startsWith('v') ? localVersion.slice(1) : localVersion;
|
|
185
|
+
ecrTag = `${product}-${cleanVersion}`;
|
|
169
186
|
}
|
|
170
187
|
|
|
171
188
|
const fullEcrUri = `${ecrUri}:${ecrTag}`;
|