@fat-zebra/sdk 1.5.10-beta.0 → 1.5.10-beta.1

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.
@@ -5,13 +5,15 @@ env:
5
5
  TEST_UPLOAD_PATH: s3://test-cdn-pmnts-origin/sdk/v1/
6
6
  SBOX_UPLOAD_PATH: s3://sandbox-pmnts-resources/sdk/v1/
7
7
  PROD_UPLOAD_PATH: s3://pmnts-resources/sdk/v1/
8
+ TEST_CLOUDFRONT_ID: "E1MCI9BNDVLHEU"
9
+ SBOX_CLOUDFRONT_ID: "E5G12OAJDKLBT"
10
+ PROD_CLOUDFRONT_ID: "E3348QX8Q2J4OV"
8
11
  on:
9
12
  push:
10
- branches: ['**'] # all branches
13
+ branches: ['**'] # all branches
11
14
  tags:
12
15
  - 'v*.*.*' # prod tags e.g. v1.5.8
13
16
  - 'v*.*.*-beta.*' # beta tags e.g. v1.5.8-beta.0
14
- pull_request:
15
17
 
16
18
  jobs:
17
19
  checks:
@@ -109,25 +111,55 @@ jobs:
109
111
  # --- DEPLOY JOBS ----------------------------------------------------
110
112
 
111
113
  deploy-staging:
112
- needs: build-staging
113
114
  if: github.ref_type == 'branch' && github.ref_name != 'main'
115
+ needs:
116
+ - build-staging
114
117
  runs-on: ubuntu-latest
115
- permissions: { id-token: write, contents: read }
118
+ permissions:
119
+ id-token: write
120
+ contents: read
116
121
  steps:
122
+ - uses: actions/download-artifact@v4
123
+ with:
124
+ name: sdk-dist-staging
125
+ path: dist/staging/
117
126
  - uses: fatzebra/gh-workflows/aws_login@main
118
127
  with:
119
128
  platform: fz
120
129
  environment: test
121
130
  role_name: AppDeploy
131
+
122
132
  - run: aws s3 sync --delete --content-type 'application/javascript' --exclude '*' --include '*.js' dist/staging/ "${TEST_UPLOAD_PATH}"
123
133
  - run: aws s3 sync --delete --content-type 'text/css' --exclude '*' --include '*.css' dist/staging/ "${TEST_UPLOAD_PATH}"
124
134
 
135
+ - name: Invalidate CloudFront cache
136
+ shell: bash
137
+ run: |
138
+ invalidation_id=$(aws cloudfront create-invalidation \
139
+ --distribution-id "${TEST_CLOUDFRONT_ID}" \
140
+ --paths '/sdk/*' \
141
+ --output text \
142
+ --query 'Invalidation.Id')
143
+ echo "Invalidation started: ${invalidation_id}"
144
+ aws cloudfront wait invalidation-completed \
145
+ --distribution-id "${TEST_CLOUDFRONT_ID}" \
146
+ --id "${invalidation_id}"
147
+ echo "Invalidation completed."
148
+
125
149
  deploy-sandbox:
126
- needs: build-sandbox
127
150
  if: github.ref_type == 'tag' && contains(github.ref_name, '-beta.') && github.base_ref == 'main'
151
+ needs:
152
+ - build-sandbox
128
153
  runs-on: ubuntu-latest
129
- permissions: { id-token: write, contents: read }
154
+ permissions:
155
+ id-token: write
156
+ contents: read
157
+
130
158
  steps:
159
+ - uses: actions/download-artifact@v4
160
+ with:
161
+ name: sdk-dist-sandbox
162
+ path: dist/sandbox/
131
163
  - uses: fatzebra/gh-workflows/aws_login@main
132
164
  with:
133
165
  platform: fz
@@ -135,15 +167,33 @@ jobs:
135
167
  role_name: AppDeploy
136
168
  - run: aws s3 sync --delete --content-type 'application/javascript' --exclude '*' --include '*.js' dist/sandbox/ "${SBOX_UPLOAD_PATH}"
137
169
  - run: aws s3 sync --delete --content-type 'text/css' --exclude '*' --include '*.css' dist/sandbox/ "${SBOX_UPLOAD_PATH}"
170
+ - name: Invalidate CloudFront cache
171
+ shell: bash
172
+ run: |
173
+ invalidation_id=$(aws cloudfront create-invalidation \
174
+ --distribution-id "${SBOX_CLOUDFRONT_ID}" \
175
+ --paths '/sdk/*' \
176
+ --output text \
177
+ --query 'Invalidation.Id')
178
+ echo "Invalidation started: ${invalidation_id}"
179
+ aws cloudfront wait invalidation-completed \
180
+ --distribution-id "${SBOX_CLOUDFRONT_ID}" \
181
+ --id "${invalidation_id}"
182
+ echo "Invalidation completed."
138
183
 
139
184
  deploy-production:
140
- needs: build-production
141
185
  if: github.ref_type == 'tag' && !contains(github.ref_name, '-beta.') && github.base_ref == 'main'
186
+ needs:
187
+ - build-production
142
188
  runs-on: ubuntu-latest
143
- permissions: { id-token: write, contents: read }
189
+ permissions:
190
+ id-token: write
191
+ contents: read
144
192
  steps:
145
193
  - uses: actions/download-artifact@v4
146
- with: { name: sdk-dist-production, path: dist/production }
194
+ with:
195
+ name: sdk-dist-production
196
+ path: dist/production
147
197
  - uses: fatzebra/gh-workflows/aws_login@main
148
198
  with:
149
199
  platform: fz
@@ -151,6 +201,19 @@ jobs:
151
201
  role_name: AppDeploy
152
202
  - run: aws s3 sync --delete --content-type 'application/javascript' --exclude '*' --include '*.js' dist/production/ "${PROD_UPLOAD_PATH}"
153
203
  - run: aws s3 sync --delete --content-type 'text/css' --exclude '*' --include '*.css' dist/production/ "${PROD_UPLOAD_PATH}"
204
+ - name: Invalidate CloudFront cache
205
+ shell: bash
206
+ run: |
207
+ invalidation_id=$(aws cloudfront create-invalidation \
208
+ --distribution-id "${PROD_CLOUDFRONT_ID}" \
209
+ --paths '/sdk/*' \
210
+ --output text \
211
+ --query 'Invalidation.Id')
212
+ echo "Invalidation started: ${invalidation_id}"
213
+ aws cloudfront wait invalidation-completed \
214
+ --distribution-id "${PROD_CLOUDFRONT_ID}" \
215
+ --id "${invalidation_id}"
216
+ echo "Invalidation completed."
154
217
 
155
218
  # Publish to npm for beta tags and production tags
156
219
  publish-npm-beta:
@@ -175,9 +238,8 @@ jobs:
175
238
  # make package.json version match the git tag (strip leading "v" if present)
176
239
  - name: Sync package.json version to git tag
177
240
  run: |
178
- VERSION="${TAG_NAME#v}" # v1.5.10-beta.0 -> 1.5.10-beta.0
241
+ VERSION="${TAG_NAME#v}"
179
242
  npm version --no-git-tag-version "$VERSION"
180
- echo "package.json version: $(node -p "require('./package.json').version")"
181
243
 
182
244
  - name: Install deps
183
245
  run: npm ci
@@ -191,12 +253,11 @@ jobs:
191
253
 
192
254
  # --- NPM publish for production tags (vX.Y.Z) ---
193
255
  publish-npm-latest:
256
+ if: startsWith(github.ref, 'refs/tags/') && !contains(github.ref_name, '-beta.')
194
257
  runs-on: ubuntu-latest
195
258
  env:
196
- TAG_NAME: ${{ github.ref_name }}
259
+ TAG_NAME: ${{ github.ref_name }}
197
260
  NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
198
- if: startsWith(github.ref, 'refs/tags/') &&
199
- !contains(github.ref_name, '-beta.')
200
261
  steps:
201
262
  - uses: actions/checkout@v4
202
263
  with:
@@ -212,9 +273,8 @@ jobs:
212
273
 
213
274
  - name: Sync package.json version to git tag
214
275
  run: |
215
- VERSION="${TAG_NAME#v}" # v1.5.10 -> 1.5.10
276
+ VERSION="${TAG_NAME#v}"
216
277
  npm version --no-git-tag-version "$VERSION"
217
- echo "package.json version: $(node -p "require('./package.json').version")"
218
278
 
219
279
  - name: Install deps
220
280
  run: npm ci
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env sh
2
+ . "$(dirname -- "$0")/_/husky.sh"
3
+
4
+ npx --no -- commitlint --edit "$1"
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env sh
2
+ . "$(dirname -- "$0")/_/husky.sh"
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env sh
2
+ . "$(dirname -- "$0")/_/husky.sh"
3
+
4
+ exec < /dev/tty && npx cz --hook || true
package/.tool-versions CHANGED
@@ -1 +1 @@
1
- nodejs 22.0.0
1
+ nodejs 23.7.0
package/README.dev.md CHANGED
@@ -165,45 +165,63 @@ from here enter your 2FA code and voila! You have published a new version of the
165
165
 
166
166
  ## Release Management
167
167
 
168
- ### Automated release:
168
+ ### NPM
169
169
 
170
- To deploy to npm run this command:
170
+ Releases are based on tags. There are two types of releases:
171
+ - Production
172
+ - Beta
171
173
 
174
+ To perform a production release:
175
+
176
+ ```shell
177
+ git tag -a v1.5.10 -m "Production Release: 1.5.10"
178
+ git push origin v1.5.10
172
179
  ```
173
- npm run npm:publish
180
+
181
+ To perform a beta release
182
+
183
+ ```shell
184
+ git tag -a v1.5.10-beta.0 -m "Beta: 1.5.10-beta.0"
185
+ git push origin v1.5.10-beta.0
174
186
  ```
175
187
 
176
- ![deployment options](deploy-menu.png)
188
+ ### CDN
177
189
 
178
- The semantic version will be bumped according to the selected release type.
190
+ ## Staging
179
191
 
180
- | Release type | version |
181
- |--------------|--------------|
182
- | Major | x-0-0 |
183
- | Minor | 0-x-0 |
184
- | Patch | 0-0-x |
185
- | Beta | 0-0-0-beta-x |
192
+ Staging is released automatically for each branch (on push)
186
193
 
187
- The publish script will also tag the release and push to the current branch.
188
- This process is an automated version of the process below, excluding changelog
194
+ ## Sandbox
189
195
 
190
- The release of the sdk follows a weekly schedule. In the beginning of a new release cycle, do the following
196
+ Sandbox deployment will trigger on the main branch and when pushing through a tag with beta in it.
197
+
198
+ Running this on main will trigger sandbox deployment (as well as npm beta release):
199
+
200
+ ```shell
201
+ git tag -a v1.5.10-beta.0 -m "Beta: 1.5.10-beta.0"
202
+ git push origin v1.5.10-beta.0
203
+ ```
191
204
 
192
- 1. Create a release branch, release/vX.X.X
193
- 2. Work out the PRs that need to be released. Make sure the merge destination points to the new release branch.
194
- 3. On the release cut-off day (2 days before the release day), merge all PRs into the release branch.
195
- 4. Do last round of testing.
196
- 5. While on the release branch locally, bump version number in package.json. Make sure the version number is the same as that of the release git branch.
197
- 6. Update CHANGELOG. List down all JIRAs included in the new release.
198
- 7. Push the changes (version update, CHANGELOG) to the release branch.
199
- 8. Create a PR for the release candidate.
200
- 9. Merge the release candidate PR back to develop. The git merge message should include the release number vX.X.X.
201
- 10. Prepare a new git tag for the new release version `git tag -a vX.X.X`.
202
- 11. Push git tag. `git push origin vX.X.X`.
205
+ ## Production
203
206
 
204
- Upon successful CI , a new entry with title 'Merged in release/vX.X,X' will be visible in the master branch page. This provides us with a clear view of what gets released in the past. Moreoever, we can quickly find out the list of features/bug fixes in a release by referring to the PR of the release candidate.
207
+ Sandbox deployment will trigger on the main branch and when pushing through a tag WITHOUT beta in it.
208
+ Running this on main will trigger production deployment:
205
209
 
210
+ ```shell
211
+ git tag -a v1.5.10 -m "Beta: 1.5.10"
212
+ git push origin v1.5.10
213
+ ```
206
214
 
207
215
  ## Rollback management
208
216
 
209
- The CDN is now versioned across staging, sandbox and production environments. The pipeline will upload a version to override the existing deployment, but also a version of the build to a folder in s3. The folder will be a shortened version of the commit hash. This will allow us to advise merchants to rollback to a specific working commit hash, or for us to test different versions in gazelle to facilitate a rollback if necessary.
217
+ The pipeline will upload a version to override the existing deployment, but also a version of the build to a folder in s3.
218
+
219
+ ## Commitizen
220
+
221
+ We use Husky and Commitizen to keep our commit history consistent, readable, and meaningful. Husky runs Git hooks automatically. This will in turn run commitizen. Commitizen enforces a standard commit message format based on Conventional Commits
222
+ . This ensures every commit clearly communicates its purpose, making it easier to track changes, generate changelogs, and automate releases.
223
+
224
+ Follow the commitizen wizard to correctly format the commit message.
225
+
226
+ ![commitizen wizard](readme.png)
227
+
package/commitizen.png ADDED
Binary file
@@ -0,0 +1,3 @@
1
+ module.exports = {
2
+ extends: ['@commitlint/config-conventional'],
3
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fat-zebra/sdk",
3
- "version": "1.5.10-beta.0",
3
+ "version": "1.5.10-beta.1",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -17,12 +17,15 @@
17
17
  "start:staging:es5": "export MERCHANT_MODE=es5 && npm run build:staging --watch && webpack serve --config webpack.config.dev.js --open 'Google Chrome'",
18
18
  "start:docker": "npm run build:dev --watch && webpack serve --config webpack.config.dev.js --host 0.0.0.0",
19
19
  "generate:jwt": "node scripts/generate-access-token.js",
20
- "npm:publish": "ts-node scripts/release-package.ts"
20
+ "npm:publish": "ts-node scripts/release-package.ts",
21
+ "prepare": "husky install"
21
22
  },
22
23
  "keywords": [],
23
24
  "author": "",
24
25
  "license": "ISC",
25
26
  "devDependencies": {
27
+ "@commitlint/cli": "^19.8.1",
28
+ "@commitlint/config-conventional": "^19.8.1",
26
29
  "@inquirer/prompts": "^5.3.8",
27
30
  "@testing-library/dom": "^10.4.0",
28
31
  "@testing-library/react": "^16.0.0",
@@ -38,10 +41,13 @@
38
41
  "@types/react": "^18.2.15",
39
42
  "@types/react-dom": "^18.2.7",
40
43
  "audit-ci": "^6.6.1",
44
+ "commitizen": "^4.3.1",
45
+ "cz-conventional-changelog": "^3.3.0",
41
46
  "dotenv": "^16.0.1",
42
47
  "dotenv-webpack": "^8.0.0",
43
48
  "ejs": "^3.0.1",
44
49
  "html-webpack-plugin": "^5.3.1",
50
+ "husky": "^8.0.0",
45
51
  "jest": "^29.6.1",
46
52
  "jest-environment-jsdom": "^29.6.1",
47
53
  "jest-localstorage-mock": "^2.4.22",
@@ -72,5 +78,10 @@
72
78
  "peerDependencies": {
73
79
  "react": ">= 16",
74
80
  "react-dom": ">= 16"
81
+ },
82
+ "config": {
83
+ "commitizen": {
84
+ "path": "./node_modules/cz-conventional-changelog"
85
+ }
75
86
  }
76
87
  }
package/deploy-menu.png DELETED
Binary file