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

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.
@@ -2,16 +2,16 @@ name: CI
2
2
 
3
3
  env:
4
4
  AWS_REGION: ap-southeast-2
5
- TEST_UPLOAD_PATH: s3://test-cdn-pmnts-origin/sdk/v1/
6
5
  SBOX_UPLOAD_PATH: s3://sandbox-pmnts-resources/sdk/v1/
7
6
  PROD_UPLOAD_PATH: s3://pmnts-resources/sdk/v1/
7
+ SBOX_CLOUDFRONT_ID: "E5G12OAJDKLBT"
8
+ PROD_CLOUDFRONT_ID: "E3348QX8Q2J4OV"
8
9
  on:
9
10
  push:
10
- branches: ['**'] # all branches
11
+ branches: ['main']
11
12
  tags:
12
13
  - 'v*.*.*' # prod tags e.g. v1.5.8
13
14
  - 'v*.*.*-beta.*' # beta tags e.g. v1.5.8-beta.0
14
- pull_request:
15
15
 
16
16
  jobs:
17
17
  checks:
@@ -31,34 +31,9 @@ jobs:
31
31
 
32
32
  # --- BUILD JOBS ----------------------------------------------------
33
33
 
34
- build-staging:
35
- needs: checks
36
- if: github.ref_type == 'branch' && github.ref_name != 'main'
37
- runs-on: ubuntu-latest
38
- env:
39
- NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
40
- steps:
41
- - uses: actions/checkout@v4
42
- - uses: fatzebra/gh-workflows/build_npm@main
43
- with:
44
- credentials_json: |
45
- {
46
- "GITHUB_TOKEN": "${{ secrets.GITHUB_TOKEN }}",
47
- "NPM_CLOUDSMITH_REPO_PWD": "${{ secrets.CLOUDSMITH_API_KEY }}"
48
- }
49
- - name: Build (staging)
50
- run: npm run build:staging
51
- - uses: actions/upload-artifact@v4
52
- with:
53
- name: sdk-dist-staging
54
- path: |
55
- dist/staging/*.js
56
- dist/staging/*.css
57
- if-no-files-found: error
58
-
59
34
  build-sandbox:
60
35
  needs: checks
61
- if: github.ref_type == 'tag' && contains(github.ref_name, '-beta.') && github.base_ref == 'main'
36
+ if: github.ref_type == 'tag' && contains(github.ref_name, '-beta.')
62
37
  runs-on: ubuntu-latest
63
38
  env:
64
39
  NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
@@ -83,7 +58,7 @@ jobs:
83
58
 
84
59
  build-production:
85
60
  needs: checks
86
- if: github.ref_type == 'tag' && !contains(github.ref_name, '-beta.') && github.base_ref == 'main'
61
+ if: github.ref_type == 'tag' && !contains(github.ref_name, '-beta.')
87
62
  runs-on: ubuntu-latest
88
63
  env:
89
64
  NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
@@ -107,27 +82,20 @@ jobs:
107
82
  if-no-files-found: error
108
83
 
109
84
  # --- DEPLOY JOBS ----------------------------------------------------
110
-
111
- deploy-staging:
112
- needs: build-staging
113
- if: github.ref_type == 'branch' && github.ref_name != 'main'
114
- runs-on: ubuntu-latest
115
- permissions: { id-token: write, contents: read }
116
- steps:
117
- - uses: fatzebra/gh-workflows/aws_login@main
118
- with:
119
- platform: fz
120
- environment: test
121
- role_name: AppDeploy
122
- - run: aws s3 sync --delete --content-type 'application/javascript' --exclude '*' --include '*.js' dist/staging/ "${TEST_UPLOAD_PATH}"
123
- - run: aws s3 sync --delete --content-type 'text/css' --exclude '*' --include '*.css' dist/staging/ "${TEST_UPLOAD_PATH}"
124
-
125
85
  deploy-sandbox:
126
- needs: build-sandbox
127
- if: github.ref_type == 'tag' && contains(github.ref_name, '-beta.') && github.base_ref == 'main'
86
+ if: github.ref_type == 'tag' && contains(github.ref_name, '-beta.')
87
+ needs:
88
+ - build-sandbox
128
89
  runs-on: ubuntu-latest
129
- permissions: { id-token: write, contents: read }
90
+ permissions:
91
+ id-token: write
92
+ contents: read
93
+
130
94
  steps:
95
+ - uses: actions/download-artifact@v4
96
+ with:
97
+ name: sdk-dist-sandbox
98
+ path: dist/sandbox/
131
99
  - uses: fatzebra/gh-workflows/aws_login@main
132
100
  with:
133
101
  platform: fz
@@ -135,15 +103,33 @@ jobs:
135
103
  role_name: AppDeploy
136
104
  - run: aws s3 sync --delete --content-type 'application/javascript' --exclude '*' --include '*.js' dist/sandbox/ "${SBOX_UPLOAD_PATH}"
137
105
  - run: aws s3 sync --delete --content-type 'text/css' --exclude '*' --include '*.css' dist/sandbox/ "${SBOX_UPLOAD_PATH}"
106
+ - name: Invalidate CloudFront cache
107
+ shell: bash
108
+ run: |
109
+ invalidation_id=$(aws cloudfront create-invalidation \
110
+ --distribution-id "${SBOX_CLOUDFRONT_ID}" \
111
+ --paths '/sdk/*' \
112
+ --output text \
113
+ --query 'Invalidation.Id')
114
+ echo "Invalidation started: ${invalidation_id}"
115
+ aws cloudfront wait invalidation-completed \
116
+ --distribution-id "${SBOX_CLOUDFRONT_ID}" \
117
+ --id "${invalidation_id}"
118
+ echo "Invalidation completed."
138
119
 
139
120
  deploy-production:
140
- needs: build-production
141
- if: github.ref_type == 'tag' && !contains(github.ref_name, '-beta.') && github.base_ref == 'main'
121
+ if: github.ref_type == 'tag' && !contains(github.ref_name, '-beta.')
122
+ needs:
123
+ - build-production
142
124
  runs-on: ubuntu-latest
143
- permissions: { id-token: write, contents: read }
125
+ permissions:
126
+ id-token: write
127
+ contents: read
144
128
  steps:
145
129
  - uses: actions/download-artifact@v4
146
- with: { name: sdk-dist-production, path: dist/production }
130
+ with:
131
+ name: sdk-dist-production
132
+ path: dist/production
147
133
  - uses: fatzebra/gh-workflows/aws_login@main
148
134
  with:
149
135
  platform: fz
@@ -151,6 +137,19 @@ jobs:
151
137
  role_name: AppDeploy
152
138
  - run: aws s3 sync --delete --content-type 'application/javascript' --exclude '*' --include '*.js' dist/production/ "${PROD_UPLOAD_PATH}"
153
139
  - run: aws s3 sync --delete --content-type 'text/css' --exclude '*' --include '*.css' dist/production/ "${PROD_UPLOAD_PATH}"
140
+ - name: Invalidate CloudFront cache
141
+ shell: bash
142
+ run: |
143
+ invalidation_id=$(aws cloudfront create-invalidation \
144
+ --distribution-id "${PROD_CLOUDFRONT_ID}" \
145
+ --paths '/sdk/*' \
146
+ --output text \
147
+ --query 'Invalidation.Id')
148
+ echo "Invalidation started: ${invalidation_id}"
149
+ aws cloudfront wait invalidation-completed \
150
+ --distribution-id "${PROD_CLOUDFRONT_ID}" \
151
+ --id "${invalidation_id}"
152
+ echo "Invalidation completed."
154
153
 
155
154
  # Publish to npm for beta tags and production tags
156
155
  publish-npm-beta:
@@ -175,9 +174,8 @@ jobs:
175
174
  # make package.json version match the git tag (strip leading "v" if present)
176
175
  - name: Sync package.json version to git tag
177
176
  run: |
178
- VERSION="${TAG_NAME#v}" # v1.5.10-beta.0 -> 1.5.10-beta.0
177
+ VERSION="${TAG_NAME#v}"
179
178
  npm version --no-git-tag-version "$VERSION"
180
- echo "package.json version: $(node -p "require('./package.json').version")"
181
179
 
182
180
  - name: Install deps
183
181
  run: npm ci
@@ -191,12 +189,11 @@ jobs:
191
189
 
192
190
  # --- NPM publish for production tags (vX.Y.Z) ---
193
191
  publish-npm-latest:
192
+ if: startsWith(github.ref, 'refs/tags/') && !contains(github.ref_name, '-beta.')
194
193
  runs-on: ubuntu-latest
195
194
  env:
196
- TAG_NAME: ${{ github.ref_name }}
195
+ TAG_NAME: ${{ github.ref_name }}
197
196
  NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
198
- if: startsWith(github.ref, 'refs/tags/') &&
199
- !contains(github.ref_name, '-beta.')
200
197
  steps:
201
198
  - uses: actions/checkout@v4
202
199
  with:
@@ -212,9 +209,8 @@ jobs:
212
209
 
213
210
  - name: Sync package.json version to git tag
214
211
  run: |
215
- VERSION="${TAG_NAME#v}" # v1.5.10 -> 1.5.10
212
+ VERSION="${TAG_NAME#v}"
216
213
  npm version --no-git-tag-version "$VERSION"
217
- echo "package.json version: $(node -p "require('./package.json').version")"
218
214
 
219
215
  - name: Install deps
220
216
  run: npm ci
@@ -0,0 +1,128 @@
1
+ name: Non Prod CI
2
+
3
+ env:
4
+ AWS_REGION: ap-southeast-2
5
+ TEST_UPLOAD_PATH: s3://test-cdn-pmnts-origin/sdk/v1/
6
+ TEST_CLOUDFRONT_ID: "E1MCI9BNDVLHEU"
7
+ on:
8
+ push:
9
+ branches-ignore:
10
+ - main
11
+ tags:
12
+ - 'v*.*.*-beta.*'
13
+
14
+ jobs:
15
+ checks:
16
+ name: Security & Type checks
17
+ runs-on: ubuntu-latest
18
+ env:
19
+ NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
20
+ steps:
21
+ - uses: actions/checkout@v4
22
+ - uses: actions/setup-node@v4
23
+ with: { node-version: '20.x', cache: 'npm' }
24
+ - run: npm ci
25
+ - run: npx --yes audit-ci --high
26
+ - run: npx tsc --noEmit
27
+ - run: npx tsc -p tsconfig.package.json --noEmit
28
+ - run: yarn test
29
+
30
+ # --- BUILD JOBS ----------------------------------------------------
31
+
32
+ build-staging:
33
+ needs: checks
34
+ if: github.ref_type == 'branch' && github.ref_name != 'main'
35
+ runs-on: ubuntu-latest
36
+ env:
37
+ NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
38
+ steps:
39
+ - uses: actions/checkout@v4
40
+ - uses: fatzebra/gh-workflows/build_npm@main
41
+ with:
42
+ credentials_json: |
43
+ {
44
+ "GITHUB_TOKEN": "${{ secrets.GITHUB_TOKEN }}",
45
+ "NPM_CLOUDSMITH_REPO_PWD": "${{ secrets.CLOUDSMITH_API_KEY }}"
46
+ }
47
+ - name: Build (staging)
48
+ run: npm run build:staging
49
+ - uses: actions/upload-artifact@v4
50
+ with:
51
+ name: sdk-dist-staging
52
+ path: |
53
+ dist/staging/*.js
54
+ dist/staging/*.css
55
+ if-no-files-found: error
56
+
57
+ # --- DEPLOY JOBS ----------------------------------------------------
58
+
59
+ deploy-staging:
60
+ if: github.ref_type == 'branch' && github.ref_name != 'main'
61
+ needs:
62
+ - build-staging
63
+ runs-on: ubuntu-latest
64
+ permissions:
65
+ id-token: write
66
+ contents: read
67
+ steps:
68
+ - uses: actions/download-artifact@v4
69
+ with:
70
+ name: sdk-dist-staging
71
+ path: dist/staging/
72
+ - uses: fatzebra/gh-workflows/aws_login@main
73
+ with:
74
+ platform: fz
75
+ environment: test
76
+ role_name: AppDeploy
77
+
78
+ - run: aws s3 sync --delete --content-type 'application/javascript' --exclude '*' --include '*.js' dist/staging/ "${TEST_UPLOAD_PATH}"
79
+ - run: aws s3 sync --delete --content-type 'text/css' --exclude '*' --include '*.css' dist/staging/ "${TEST_UPLOAD_PATH}"
80
+
81
+ - name: Invalidate CloudFront cache
82
+ shell: bash
83
+ run: |
84
+ invalidation_id=$(aws cloudfront create-invalidation \
85
+ --distribution-id "${TEST_CLOUDFRONT_ID}" \
86
+ --paths '/sdk/*' \
87
+ --output text \
88
+ --query 'Invalidation.Id')
89
+ echo "Invalidation started: ${invalidation_id}"
90
+ aws cloudfront wait invalidation-completed \
91
+ --distribution-id "${TEST_CLOUDFRONT_ID}" \
92
+ --id "${invalidation_id}"
93
+ echo "Invalidation completed."
94
+
95
+ # Publish to npm for beta tags and production tags
96
+ publish-npm-beta:
97
+ runs-on: ubuntu-latest
98
+ if: startsWith(github.ref, 'refs/tags/') && contains(github.ref_name, '-beta.')
99
+ env:
100
+ TAG_NAME: ${{ github.ref_name }} # e.g. v1.5.10-beta.0
101
+ NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
102
+ steps:
103
+ - uses: actions/checkout@v4
104
+ with:
105
+ fetch-depth: 0
106
+
107
+ - uses: actions/setup-node@v4
108
+ with:
109
+ node-version: 20
110
+ registry-url: 'https://registry.npmjs.org' # writes .npmrc using NPM_TOKEN
111
+
112
+ - name: Show tag name
113
+ run: echo "Publishing for tag $TAG_NAME"
114
+
115
+ # make package.json version match the git tag (strip leading "v" if present)
116
+ - name: Sync package.json version to git tag
117
+ run: |
118
+ VERSION="${TAG_NAME#v}"
119
+ npm version --no-git-tag-version "$VERSION"
120
+
121
+ - name: Install deps
122
+ run: npm ci
123
+
124
+ - name: Run package build
125
+ run: npm run build:package
126
+
127
+ - name: Publish (beta dist-tag)
128
+ run: npm publish --access public --tag beta
@@ -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.2",
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