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 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-v1.0.123456 (latest with build number)
71
- ├── BE-v2.1.0 (semantic version)
72
- ├── payments-v1.0.789012
73
- └── auth-v3.0.0
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., `v2.1.0`) or build numbers (e.g., `v1.0.123456`)
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
- # Build with auto-generated build number
90
+ # Automatically uses package.json version
83
91
  npx haven-cypress build --product=BE --push
84
- → ECR tag: BE-v1.0.123456
92
+ → ECR tag: BE-2.1.0
93
+ ```
85
94
 
86
- # Build with semantic version
87
- npx haven-cypress build --product=BE --tag=v2.1.0 --push
88
- ECR tag: BE-v2.1.0
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
- # Build with custom build number (CI/CD)
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-v1.0.456
109
+ → ECR tag: BE-1.0.456
93
110
  ```
94
111
 
95
112
  ## What's Included
@@ -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-v1.0.{BUILD_NUMBER}
32
- --tag=v2.1.0 → ECR tag: BE-v2.1.0
33
- BUILD_NUMBER env Custom build number (default: timestamp)
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 'latest'
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
- // For 'latest', use build number format: product-v1.0.BUILD_NUMBER
162
- const buildNumber = process.env.BUILD_NUMBER || Date.now().toString().slice(-6);
163
- ecrTag = `${product}-v1.0.${buildNumber}`;
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 exactly
166
- // Ensure version starts with 'v' prefix for consistency
167
- const versionTag = localVersion.startsWith('v') ? localVersion : `v${localVersion}`;
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}`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "haven-cypress-integration",
3
- "version": "1.2.1",
3
+ "version": "1.3.0",
4
4
  "description": "Seamless Cypress integration with HAVEN test case management",
5
5
  "main": "index.js",
6
6
  "bin": {