@mojaloop/ml-number 11.2.0 → 11.2.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.
@@ -5,50 +5,29 @@ version: 2.1
5
5
  # orbs
6
6
  #
7
7
  # Orbs used in this pipeline
8
- ###
8
+ ##
9
9
  orbs:
10
- anchore: anchore/anchore-engine@1.6.0
11
- slack: circleci/slack@3.4.2
12
- pr-tools: mojaloop/pr-tools@0.1.8
13
- github-release: h-matsuo/github-release@0.1.3
10
+ slack: circleci/slack@4.12.5 # Ref: https://github.com/mojaloop/ci-config/tree/master/slack-templates
11
+ pr-tools: mojaloop/pr-tools@0.1.10 # Ref: https://github.com/mojaloop/ci-config/
12
+ gh: circleci/github-cli@2.2.0
14
13
 
15
14
  ##
16
- # Executors
15
+ # defaults
17
16
  #
18
- # CircleCI Executors
17
+ # YAML defaults templates
19
18
  ##
20
- executors:
21
- default-docker:
22
- working_directory: /home/circleci/project
23
- docker:
24
- - image: node:12.16.1-alpine
25
-
26
- default-machine:
27
- machine:
28
- image: ubuntu-1604:201903-01
29
-
30
- defaults_working_directory: &defaults_working_directory
31
- working_directory: /home/circleci/project
32
19
 
33
- defaults_Dependencies: &defaults_Dependencies |
20
+ ## Default 'default-docker' executor dependencies
21
+ defaults_docker_Dependencies: &defaults_docker_Dependencies |
34
22
  apk --no-cache add git
35
23
  apk --no-cache add ca-certificates
36
24
  apk --no-cache add curl
37
25
  apk --no-cache add openssh-client
38
- apk --no-cache add bash
39
- apk add --no-cache -t build-dependencies make gcc g++ python libtool autoconf automake
40
- npm config set unsafe-perm true
26
+ apk add --no-cache -t build-dependencies make gcc g++ python3 libtool autoconf automake jq bash
41
27
  npm install -g node-gyp
42
28
 
43
29
  defaults_awsCliDependencies: &defaults_awsCliDependencies |
44
- apk --no-cache add \
45
- python \
46
- py-pip \
47
- groff \
48
- less \
49
- mailcap
50
- pip install --upgrade awscli==1.14.5 s3cmd==2.0.1 python-magic
51
- apk -v --purge del py-pip
30
+ apk --no-cache add aws-cli
52
31
 
53
32
  defaults_license_scanner: &defaults_license_scanner
54
33
  name: Install and set up license-scanner
@@ -56,17 +35,23 @@ defaults_license_scanner: &defaults_license_scanner
56
35
  git clone https://github.com/mojaloop/license-scanner /tmp/license-scanner
57
36
  cd /tmp/license-scanner && make build default-files set-up
58
37
 
38
+ defaults_export_version_from_package: &defaults_export_version_from_package
39
+ name: Format the changelog into the github release body and get release tag
40
+ command: |
41
+ git diff --no-indent-heuristic master~1 HEAD CHANGELOG.md | sed -n '/^+[^+]/ s/^+//p' > /tmp/changes
42
+ echo 'export RELEASE_CHANGES=`cat /tmp/changes`' >> $BASH_ENV
43
+ echo 'export RELEASE_TAG=`cat package-lock.json | jq -r .version`' >> $BASH_ENV
44
+
45
+ defaults_configure_git: &defaults_configure_git
46
+ name: Configure git
47
+ command: |
48
+ git config user.email ${GIT_CI_EMAIL}
49
+ git config user.name ${GIT_CI_USER}
50
+
59
51
  defaults_npm_auth: &defaults_npm_auth
60
52
  name: Update NPM registry auth token
61
53
  command: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > .npmrc
62
54
 
63
- defaults_npm_publish_version: &defaults_npm_publish
64
- name: Update version to prerelease
65
- command: |
66
- source $BASH_ENV
67
- echo "Publishing tag $CIRCLE_TAG"
68
- npm publish --tag $CIRCLE_TAG --access public
69
-
70
55
  defaults_npm_publish_release: &defaults_npm_publish_release
71
56
  name: Publish NPM $RELEASE_TAG artifact
72
57
  command: |
@@ -74,45 +59,153 @@ defaults_npm_publish_release: &defaults_npm_publish_release
74
59
  echo "Publishing tag $RELEASE_TAG"
75
60
  npm publish --tag $RELEASE_TAG --access public
76
61
 
77
- defaults_slack_announcement: &defaults_slack_announcement
78
- name: Slack announcement for tag releases
62
+ defaults_configure_nvm: &defaults_configure_nvm
63
+ name: Configure NVM
64
+ command: |
65
+ cd $HOME
66
+
67
+ export ENV_DOT_PROFILE=$HOME/.profile
68
+ touch $ENV_DOT_PROFILE
69
+
70
+ echo "1. Export env variable"
71
+ export NVM_DIR="$HOME/.nvm"
72
+ if [ -z "$NVMRC_VERSION" ]; then
73
+ echo "==> Configuring NVMRC_VERSION!"
74
+ export NVMRC_VERSION=$(cat $CIRCLE_WORKING_DIRECTORY/.nvmrc)
75
+ echo "export NVMRC_VERSION=$NVMRC_VERSION" >> $ENV_DOT_PROFILE
76
+ fi
77
+
78
+ if [ -f "$NVM_DIR" ]; then
79
+ echo "==> $NVM_DIR exists. Skipping steps 2-4!"
80
+ else
81
+ echo "==> $NVM_DIR does not exists. Executing steps 2-4!"
82
+
83
+ echo "2. Installing NVM"
84
+ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash
85
+
86
+ echo "3. Executing $NVM_DIR/nvm.sh"
87
+ [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
88
+ fi
89
+
90
+ ## Ref: https://github.com/nvm-sh/nvm/issues/1102#issuecomment-550572252
91
+ if [ ! -z "$NVM_ARCH_UNOFFICIAL_OVERRIDE" ]; then
92
+ echo "==> Handle NVM_ARCH_UNOFFICIAL_OVERRIDE=$NVM_ARCH_UNOFFICIAL_OVERRIDE!"
93
+ echo "nvm_get_arch() { nvm_echo \"${NVM_ARCH_UNOFFICIAL_OVERRIDE}\"; }" >> $ENV_DOT_PROFILE
94
+ echo "export NVM_NODEJS_ORG_MIRROR=https://unofficial-builds.nodejs.org/download/release" >> $ENV_DOT_PROFILE
95
+ source $ENV_DOT_PROFILE
96
+ fi
97
+
98
+ echo "4. Installing Node version: $NVMRC_VERSION"
99
+ nvm install $NVMRC_VERSION
100
+ nvm alias default $NVMRC_VERSION
101
+ nvm use $NVMRC_VERSION
102
+
103
+ cd $CIRCLE_WORKING_DIRECTORY
104
+
105
+ defaults_display_versions: &defaults_display_versions
106
+ name: Display Versions
79
107
  command: |
80
- curl -X POST \
81
- $SLACK_WEBHOOK_ANNOUNCEMENT \
82
- -H 'Content-type: application/json' \
83
- -H 'cache-control: no-cache' \
84
- -d "{
85
- \"text\": \"*${CIRCLE_PROJECT_REPONAME}* - Release \`${CIRCLE_TAG}\`: https://github.com/mojaloop/${CIRCLE_PROJECT_REPONAME}/releases/tag/${CIRCLE_TAG}\"
86
- }"
108
+ echo "What is the active version of Nodejs?"
109
+ echo "node: $(node --version)"
110
+ echo "yarn: $(yarn --version)"
111
+ echo "npm: $(npm --version)"
112
+ echo "nvm: $(nvm --version)"
113
+
114
+ ##
115
+ # Executors
116
+ #
117
+ # CircleCI Executors
118
+ ##
119
+ executors:
120
+ default-docker:
121
+ working_directory: &WORKING_DIR /home/circleci/project
122
+ shell: "/bin/sh -leo pipefail" ## Ref: https://circleci.com/docs/env-vars/#alpine-linux
123
+ environment:
124
+ BASH_ENV: /etc/profile ## Ref: https://circleci.com/docs/env-vars/#alpine-linux
125
+ NVM_ARCH_UNOFFICIAL_OVERRIDE: x64-musl ## Ref: https://github.com/nvm-sh/nvm/issues/1102#issuecomment-550572252
126
+ docker:
127
+ - image: node:lts-alpine
87
128
 
129
+ default-machine:
130
+ working_directory: *WORKING_DIR
131
+ shell: "/bin/bash -leo pipefail"
132
+ machine:
133
+ image: ubuntu-2204:2023.04.2 # Ref: https://circleci.com/developer/machine/image/ubuntu-2204
134
+
135
+ ##
136
+ # Jobs
137
+ #
138
+ # A map of CircleCI jobs
139
+ ##
88
140
  jobs:
89
141
  setup:
90
- <<: *defaults_working_directory
91
142
  executor: default-docker
92
143
  steps:
93
144
  - run:
94
145
  name: Install general dependencies
95
- command: *defaults_Dependencies
146
+ command: *defaults_docker_Dependencies
96
147
  - checkout
97
148
  - run:
98
- name: Update NPM install
99
- command: npm install
149
+ <<: *defaults_configure_nvm
150
+ - run:
151
+ <<: *defaults_display_versions
152
+ - run:
153
+ name: Install NPM dependencies
154
+ command: npm ci
100
155
  - save_cache:
101
156
  key: dependency-cache-{{ .Environment.CIRCLE_SHA1 }}
102
157
  paths:
103
158
  - node_modules
104
159
 
160
+ test-dependencies:
161
+ executor: default-docker
162
+ steps:
163
+ - run:
164
+ name: Install general dependencies
165
+ command: *defaults_docker_Dependencies
166
+ - checkout
167
+ - run:
168
+ <<: *defaults_configure_nvm
169
+ - run:
170
+ <<: *defaults_display_versions
171
+ - restore_cache:
172
+ key: dependency-cache-{{ .Environment.CIRCLE_SHA1 }}
173
+ - run:
174
+ name: Execute dependency tests
175
+ command: npm run dep:check
176
+
177
+ test-lint:
178
+ executor: default-docker
179
+ steps:
180
+ - run:
181
+ name: Install general dependencies
182
+ command: *defaults_docker_Dependencies
183
+ - checkout
184
+ - run:
185
+ <<: *defaults_configure_nvm
186
+ - run:
187
+ <<: *defaults_display_versions
188
+ - restore_cache:
189
+ key: dependency-cache-{{ .Environment.CIRCLE_SHA1 }}
190
+ - run:
191
+ name: Execute lint tests
192
+ command: npm run lint
193
+
105
194
  test-unit:
106
- <<: *defaults_working_directory
107
195
  executor: default-docker
108
196
  steps:
109
197
  - run:
110
198
  name: Install general dependencies
111
- command: *defaults_Dependencies
199
+ command: *defaults_docker_Dependencies
112
200
  - checkout
201
+ - run:
202
+ <<: *defaults_configure_nvm
203
+ - run:
204
+ <<: *defaults_display_versions
113
205
  - restore_cache:
114
206
  key: dependency-cache-{{ .Environment.CIRCLE_SHA1 }}
115
207
  - run:
208
+ # This is needed for legacy core tests. Remove this once 'tape' is fully deprecated.
116
209
  name: Install tape, tapes and tap-xunit
117
210
  command: npm install tape tapes tap-xunit
118
211
  - run:
@@ -120,24 +213,27 @@ jobs:
120
213
  command: mkdir -p ./test/results
121
214
  - run:
122
215
  name: Execute unit tests
123
- command: npm -s run test:xunit > ./test/results/tape.xml
216
+ command: npm -s run test:xunit
124
217
  - store_artifacts:
125
218
  path: ./test/results
126
- prefix: test
219
+ destination: test
127
220
  - store_test_results:
128
221
  path: ./test/results
129
222
 
130
223
  test-coverage:
131
- <<: *defaults_working_directory
132
224
  executor: default-docker
133
225
  steps:
134
226
  - run:
135
227
  name: Install general dependencies
136
- command: *defaults_Dependencies
228
+ command: *defaults_docker_Dependencies
137
229
  - run:
138
230
  name: Install AWS CLI dependencies
139
231
  command: *defaults_awsCliDependencies
140
232
  - checkout
233
+ - run:
234
+ <<: *defaults_configure_nvm
235
+ - run:
236
+ <<: *defaults_display_versions
141
237
  - restore_cache:
142
238
  key: dependency-cache-{{ .Environment.CIRCLE_SHA1 }}
143
239
  - run:
@@ -145,28 +241,21 @@ jobs:
145
241
  command: npm -s run test:coverage-check
146
242
  - store_artifacts:
147
243
  path: coverage
148
- prefix: test
244
+ destination: test
149
245
  - store_test_results:
150
- path: coverage/lcov.info
151
- - run:
152
- name: Copy code coverage to SonarQube
153
- command: |
154
- if [ "${CIRCLE_BRANCH}" == "master" ];
155
- then
156
- echo "Sending lcov.info to SonarQube..."
157
- aws s3 cp coverage/lcov.info $AWS_S3_DIR_SONARQUBE/$CIRCLE_PROJECT_REPONAME/lcov.info
158
- else
159
- echo "Not a release (env CIRCLE_BRANCH != 'master'), skipping sending lcov.info to SonarQube."
160
- fi
246
+ path: coverage
161
247
 
162
248
  vulnerability-check:
163
- <<: *defaults_working_directory
164
249
  executor: default-docker
165
250
  steps:
166
251
  - run:
167
252
  name: Install general dependencies
168
- command: *defaults_Dependencies
253
+ command: *defaults_docker_Dependencies
169
254
  - checkout
255
+ - run:
256
+ <<: *defaults_configure_nvm
257
+ - run:
258
+ <<: *defaults_display_versions
170
259
  - restore_cache:
171
260
  key: dependency-cache-{{ .Environment.CIRCLE_SHA1 }}
172
261
  - run:
@@ -174,18 +263,17 @@ jobs:
174
263
  command: mkdir -p ./audit/results
175
264
  - run:
176
265
  name: Check for new npm vulnerabilities
177
- command: npm run audit:check --silent -- --json > ./audit/results/auditResults.json
266
+ command: npm run audit:check -- -o json > ./audit/results/auditResults.json
178
267
  - store_artifacts:
179
268
  path: ./audit/results
180
- prefix: audit
269
+ destination: audit
181
270
 
182
271
  audit-licenses:
183
- <<: *defaults_working_directory
184
272
  executor: default-docker
185
273
  steps:
186
274
  - run:
187
275
  name: Install general dependencies
188
- command: *defaults_Dependencies
276
+ command: *defaults_docker_Dependencies
189
277
  - run:
190
278
  <<: *defaults_license_scanner
191
279
  - checkout
@@ -196,113 +284,161 @@ jobs:
196
284
  command: cd /tmp/license-scanner && pathToRepo=$CIRCLE_WORKING_DIRECTORY make run
197
285
  - store_artifacts:
198
286
  path: /tmp/license-scanner/results
199
- prefix: licenses
287
+ destination: licenses
200
288
 
201
- publish-snapshot:
202
- <<: *defaults_working_directory
289
+ release:
203
290
  executor: default-docker
204
291
  steps:
205
292
  - run:
206
293
  name: Install general dependencies
207
- command: *defaults_Dependencies
294
+ command: *defaults_docker_Dependencies
208
295
  - checkout
296
+ - restore_cache:
297
+ keys:
298
+ - dependency-cache-{{ .Environment.CIRCLE_SHA1 }}
209
299
  - run:
210
- name: setup environment vars for SNAPSHOT release
211
- command: |
212
- echo 'export RELEASE_TAG=$RELEASE_TAG_SNAPSHOT' >> $BASH_ENV
300
+ <<: *defaults_configure_git
213
301
  - run:
214
- <<: *defaults_npm_auth
302
+ name: Setup Slack config
303
+ command: |
304
+ echo "export SLACK_PROJECT_NAME=${CIRCLE_PROJECT_REPONAME}" >> $BASH_ENV
305
+ echo "export SLACK_RELEASE_TYPE='GitHub Release'" >> $BASH_ENV
306
+ echo "export SLACK_RELEASE_TAG='${RELEASE_TAG} on ${CIRCLE_BRANCH} branch'" >> $BASH_ENV
307
+ echo "export SLACK_BUILD_ID=${CIRCLE_BUILD_NUM}" >> $BASH_ENV
308
+ echo "export SLACK_CI_URL=${CIRCLE_BUILD_URL}" >> $BASH_ENV
215
309
  - run:
216
- <<: *defaults_npm_publish_release
310
+ name: Generate changelog and bump package version
311
+ command: npm run release -- --no-verify
217
312
  - run:
218
- <<: *defaults_slack_announcement
313
+ name: Push the release
314
+ command: git push --follow-tags origin ${CIRCLE_BRANCH}
315
+ - slack/notify:
316
+ event: fail
317
+ template: SLACK_TEMP_RELEASE_FAILURE
219
318
 
220
- publish:
221
- <<: *defaults_working_directory
222
- executor: default-docker
319
+ github-release:
320
+ executor: default-machine
321
+ shell: "/bin/bash -eo pipefail"
223
322
  steps:
224
323
  - run:
225
- name: Install general dependencies
226
- command: *defaults_Dependencies
324
+ name: Install git
325
+ command: |
326
+ sudo apt-get update && sudo apt-get install -y git
327
+ - gh/install
227
328
  - checkout
228
329
  - run:
229
- name: setup environment vars for LATEST release
330
+ <<: *defaults_configure_git
331
+ - run:
332
+ name: Fetch updated release branch
230
333
  command: |
231
- echo 'export RELEASE_TAG=$RELEASE_TAG_PROD' >> $BASH_ENV
334
+ git fetch origin
335
+ git checkout origin/${CIRCLE_BRANCH}
232
336
  - run:
233
- <<: *defaults_npm_auth
337
+ <<: *defaults_export_version_from_package
234
338
  - run:
235
- <<: *defaults_npm_publish_release
339
+ name: Check the release changes
340
+ command: |
341
+ echo "Changes are: ${RELEASE_CHANGES}"
236
342
  - run:
237
- <<: *defaults_slack_announcement
343
+ name: Setup Slack config
344
+ command: |
345
+ echo "export SLACK_PROJECT_NAME=${CIRCLE_PROJECT_REPONAME}" >> $BASH_ENV
346
+ echo "export SLACK_RELEASE_TYPE='Github Release'" >> $BASH_ENV
347
+ echo "export SLACK_RELEASE_TAG=v${RELEASE_TAG}" >> $BASH_ENV
348
+ echo "export SLACK_RELEASE_URL=https://github.com/mojaloop/${CIRCLE_PROJECT_REPONAME}/releases/tag/v${RELEASE_TAG}" >> $BASH_ENV
349
+ echo "export SLACK_BUILD_ID=${CIRCLE_BUILD_NUM}" >> $BASH_ENV
350
+ echo "export SLACK_CI_URL=${CIRCLE_BUILD_URL}" >> $BASH_ENV
351
+ - run:
352
+ name: Create Release
353
+ command: |
354
+ gh release create "v${RELEASE_TAG}" --title "v${RELEASE_TAG} Release" --draft=false --notes "${RELEASE_CHANGES}" ./CHANGELOG.md
355
+ - slack/notify:
356
+ event: pass
357
+ template: SLACK_TEMP_RELEASE_SUCCESS
358
+ - slack/notify:
359
+ event: fail
360
+ template: SLACK_TEMP_RELEASE_FAILURE
238
361
 
239
- release:
362
+ publish:
240
363
  executor: default-docker
241
364
  steps:
242
365
  - run:
243
366
  name: Install general dependencies
244
- command: *defaults_Dependencies
367
+ command: *defaults_docker_Dependencies
245
368
  - checkout
246
369
  - restore_cache:
247
- keys:
248
- - dependency-cache-{{ .Environment.CIRCLE_SHA1 }}
370
+ key: dependency-cache-{{ .Environment.CIRCLE_SHA1 }}
249
371
  - run:
250
- name: Configure git
372
+ name: Setup for LATEST release
251
373
  command: |
252
- git config user.email ${GIT_CI_EMAIL}
253
- git config user.name ${GIT_CI_USER}
254
- git checkout ${CIRCLE_BRANCH}
374
+ echo "export RELEASE_TAG=$RELEASE_TAG_PROD" >> $BASH_ENV
375
+ echo "RELEASE_TAG=$RELEASE_TAG_PROD"
376
+
377
+ PACKAGE_VERSION=$(cat package-lock.json | jq -r .version)
378
+ echo "export PACKAGE_VERSION=${PACKAGE_VERSION}" >> $BASH_ENV
379
+ echo "PACKAGE_VERSION=${PACKAGE_VERSION}"
255
380
  - run:
256
- name: Configure ssh
381
+ name: Setup Slack config
257
382
  command: |
258
- mkdir -p ~/.ssh
259
- ssh-keyscan -p 443 ssh.github.com >> ~/.ssh/known_hosts
260
- ssh-keyscan github.com >> ~/.ssh/known_hosts
383
+ echo "export SLACK_PROJECT_NAME=${CIRCLE_PROJECT_REPONAME}" >> $BASH_ENV
384
+ echo "export SLACK_RELEASE_TYPE='NPM Release'" >> $BASH_ENV
385
+ echo "export SLACK_RELEASE_TAG=v${CIRCLE_TAG:1}" >> $BASH_ENV
386
+ echo "export SLACK_RELEASE_URL=https://www.npmjs.com/package/@mojaloop/${CIRCLE_PROJECT_REPONAME}/v/${CIRCLE_TAG:1}" >> $BASH_ENV
387
+ echo "export SLACK_BUILD_ID=${CIRCLE_BUILD_NUM}" >> $BASH_ENV
388
+ echo "export SLACK_CI_URL=${CIRCLE_BUILD_URL}" >> $BASH_ENV
261
389
  - run:
262
- name: Generate changelog and bump package version
263
- command: npm run release
390
+ <<: *defaults_npm_auth
264
391
  - run:
265
- name: Push the release
266
- command: git push --follow-tags origin ${CIRCLE_BRANCH}
392
+ <<: *defaults_npm_publish_release
393
+ - slack/notify:
394
+ event: pass
395
+ template: SLACK_TEMP_RELEASE_SUCCESS
396
+ - slack/notify:
397
+ event: fail
398
+ template: SLACK_TEMP_RELEASE_FAILURE
267
399
 
268
- github-release:
269
- executor: default-machine
400
+ publish-snapshot:
401
+ executor: default-docker
270
402
  steps:
271
403
  - run:
272
- name: Install git
273
- command: |
274
- sudo apt-get update && sudo apt-get install -y git
404
+ name: Install general dependencies
405
+ command: *defaults_docker_Dependencies
275
406
  - checkout
407
+ - restore_cache:
408
+ key: dependency-cache-{{ .Environment.CIRCLE_SHA1 }}
276
409
  - run:
277
- name: Fetch updated release branch
410
+ name: Setup for SNAPSHOT release
278
411
  command: |
279
- git config user.email ${GIT_CI_EMAIL}
280
- git config user.name ${GIT_CI_USER}
281
- git fetch origin
282
- git checkout origin/${CIRCLE_BRANCH}
412
+ echo "export RELEASE_TAG=${RELEASE_TAG_SNAPSHOT}" >> $BASH_ENV
413
+ echo "RELEASE_TAG=${RELEASE_TAG_SNAPSHOT}"
414
+
415
+ echo "Override package version: ${CIRCLE_TAG:1}"
416
+ npx standard-version --skip.tag --skip.commit --skip.changelog --release-as ${CIRCLE_TAG:1}
417
+
418
+ PACKAGE_VERSION=$(cat package-lock.json | jq -r .version)
419
+ echo "export PACKAGE_VERSION=${PACKAGE_VERSION}" >> $BASH_ENV
420
+ echo "PACKAGE_VERSION=${PACKAGE_VERSION}"
283
421
  - run:
284
- # Note: this is rather imperfect, but will do for now
285
- name: Format the changelog into the github release body and get release tag
422
+ name: Setup Slack config
286
423
  command: |
287
- git diff --no-indent-heuristic master~1 HEAD CHANGELOG.md | sed -n '/^+[^+]/ s/^+//p' > /tmp/changes
288
- echo 'export RELEASE_CHANGES=`cat /tmp/changes`' >> $BASH_ENV
289
- echo 'export RELEASE_TAG=`cat package-lock.json | jq -r .version`' >> $BASH_ENV
424
+ echo "export SLACK_PROJECT_NAME=${CIRCLE_PROJECT_REPONAME}" >> $BASH_ENV
425
+ echo "export SLACK_RELEASE_TYPE='NPM Snapshot'" >> $BASH_ENV
426
+ echo "export SLACK_RELEASE_TAG=v${CIRCLE_TAG:1}" >> $BASH_ENV
427
+ echo "export SLACK_RELEASE_URL=https://www.npmjs.com/package/@mojaloop/${CIRCLE_PROJECT_REPONAME}/v/${CIRCLE_TAG:1}" >> $BASH_ENV
428
+ echo "export SLACK_BUILD_ID=${CIRCLE_BUILD_NUM}" >> $BASH_ENV
429
+ echo "export SLACK_CI_URL=${CIRCLE_BUILD_URL}" >> $BASH_ENV
290
430
  - run:
291
- name: check the release changes
292
- command: |
293
- echo "Changes are: ${RELEASE_CHANGES}"
294
- - github-release/create:
295
- github-token-variable: ${GITHUB_TOKEN}
296
- tag: v${RELEASE_TAG}
297
- title: v${RELEASE_TAG} Release
298
- description: ${RELEASE_CHANGES}
299
- file-path: CHANGELOG.md
300
- - slack/status:
301
- webhook: "$SLACK_WEBHOOK_ANNOUNCEMENT"
302
- success_message: '*"${CIRCLE_PROJECT_REPONAME}"* - Release \`"v${RELEASE_TAG}"\` \nhttps://github.com/mojaloop/"${CIRCLE_PROJECT_REPONAME}"/releases/tag/"v${RELEASE_TAG}"'
431
+ <<: *defaults_npm_auth
432
+ - run:
433
+ <<: *defaults_npm_publish_release
434
+ - slack/notify:
435
+ event: pass
436
+ template: SLACK_TEMP_RELEASE_SUCCESS
437
+ - slack/notify:
438
+ event: fail
439
+ template: SLACK_TEMP_RELEASE_FAILURE
303
440
 
304
441
  workflows:
305
- version: 2
306
442
  build_and_test:
307
443
  jobs:
308
444
  - pr-tools/pr-title-check:
@@ -316,6 +452,28 @@ workflows:
316
452
  ignore:
317
453
  - /feature*/
318
454
  - /bugfix*/
455
+ - test-dependencies:
456
+ context: org-global
457
+ requires:
458
+ - setup
459
+ filters:
460
+ tags:
461
+ only: /.*/
462
+ branches:
463
+ ignore:
464
+ - /feature*/
465
+ - /bugfix*/
466
+ - test-lint:
467
+ context: org-global
468
+ requires:
469
+ - setup
470
+ filters:
471
+ tags:
472
+ only: /.*/
473
+ branches:
474
+ ignore:
475
+ - /feature*/
476
+ - /bugfix*/
319
477
  - test-unit:
320
478
  context: org-global
321
479
  requires:
@@ -365,7 +523,8 @@ workflows:
365
523
  context: org-global
366
524
  requires:
367
525
  - pr-tools/pr-title-check
368
- - setup
526
+ - test-dependencies
527
+ - test-lint
369
528
  - test-unit
370
529
  - test-coverage
371
530
  - vulnerability-check
@@ -388,7 +547,7 @@ workflows:
388
547
  context: org-global
389
548
  requires:
390
549
  - pr-tools/pr-title-check
391
- - setup
550
+ - test-lint
392
551
  - test-unit
393
552
  - test-coverage
394
553
  - vulnerability-check
@@ -403,7 +562,7 @@ workflows:
403
562
  context: org-global
404
563
  requires:
405
564
  - pr-tools/pr-title-check
406
- - setup
565
+ - test-lint
407
566
  - test-unit
408
567
  - test-coverage
409
568
  - vulnerability-check
package/.nvmrc ADDED
@@ -0,0 +1 @@
1
+ 18.17.1
package/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [11.2.2](https://github.com/mojaloop/ml-number/compare/v11.2.1...v11.2.2) (2023-08-24)
6
+
7
+ ### [11.2.1](https://github.com/mojaloop/ml-number/compare/v11.2.0...v11.2.1) (2021-09-22)
8
+
5
9
  ## [11.2.0](https://github.com/mojaloop/ml-number/compare/v11.1.0...v11.2.0) (2021-09-22)
6
10
 
7
11
 
package/CODEOWNERS ADDED
@@ -0,0 +1,38 @@
1
+ # This is a comment.
2
+ # Each line is a file pattern followed by one or more owners.
3
+
4
+ ## These owners will be the default owners for everything in
5
+ ## the repo. Unless a later match takes precedence,
6
+ ## @global-owner1 and @global-owner2 will be requested for
7
+ ## review when someone opens a pull request.
8
+ #* @global-owner1 @global-owner2
9
+ * @vijayg10 @mdebarros @elnyry-sam-k @lewisdaly
10
+
11
+ ## Order is important; the last matching pattern takes the most
12
+ ## precedence. When someone opens a pull request that only
13
+ ## modifies JS files, only @js-owner and not the global
14
+ ## owner(s) will be requested for a review.
15
+ # *.js @js-owner
16
+
17
+ ## You can also use email addresses if you prefer. They'll be
18
+ ## used to look up users just like we do for commit author
19
+ ## emails.
20
+ #*.go docs@example.com
21
+
22
+ # In this example, @doctocat owns any files in the build/logs
23
+ # directory at the root of the repository and any of its
24
+ # subdirectories.
25
+ # /build/logs/ @doctocat
26
+
27
+ ## The `docs/*` pattern will match files like
28
+ ## `docs/getting-started.md` but not further nested files like
29
+ ## `docs/build-app/troubleshooting.md`.
30
+ # docs/* docs@example.com
31
+
32
+ ## In this example, @octocat owns any file in an apps directory
33
+ ## anywhere in your repository.
34
+ #apps/ @octocat
35
+
36
+ ## In this example, @doctocat owns any file in the `/docs`
37
+ ## directory in the root of your repository.
38
+ #/docs/ @doctocat
package/README.md CHANGED
@@ -55,6 +55,8 @@ const toNumberResult = multiplyResult.toNumber() // = 72
55
55
  const toFixedResult = divisionResult.toFixed() // = "3.0000"
56
56
 
57
57
  const toFixedWithDecimalPlaceResult = subtractionResult.toFixed(7) // = "4.0000000"
58
+
59
+ const shifted = new MLNumber('0123').shiftedBy(-4) // = "{"MLNumber": "0.0123"}"
58
60
  ```
59
61
 
60
62
  ## Running the tests
package/audit-ci.jsonc ADDED
@@ -0,0 +1,10 @@
1
+ {
2
+ "$schema": "https://github.com/IBM/audit-ci/raw/main/docs/schema.json",
3
+ // audit-ci supports reading JSON, JSONC, and JSON5 config files.
4
+ // Only use one of ["low": true, "moderate": true, "high": true, "critical": true]
5
+ "moderate": true,
6
+ "allowlist": [ // NOTE: Please add as much information as possible to any items added to the allowList
7
+ // Currently no fixes available for the following
8
+ ]
9
+ }
10
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mojaloop/ml-number",
3
- "version": "11.2.0",
3
+ "version": "11.2.2",
4
4
  "description": "Mojaloop Number Library implementation that handles decimal processing of amounts/numbers",
5
5
  "author": "ModusBox",
6
6
  "contributors": [
@@ -33,8 +33,8 @@
33
33
  "test:xunit": "npm run test:unit | tap-xunit",
34
34
  "test:coverage": "nyc --reporter=lcov --reporter=text-summary tapes -- 'test/unit/**/**.test.js'",
35
35
  "test:coverage-check": "npm run test:coverage && nyc check-coverage",
36
- "audit:resolve": "SHELL=sh resolve-audit --production",
37
- "audit:check": "SHELL=sh check-audit --production",
36
+ "audit:fix": "npm audit fix",
37
+ "audit:check": "npx audit-ci --config ./audit-ci.jsonc",
38
38
  "dep:check": "npx ncu -e 2",
39
39
  "dep:update": "npx ncu -u",
40
40
  "release": "standard-version --releaseCommitMessageFormat 'chore(release): {{currentTag}} [skip ci]'"
@@ -46,19 +46,19 @@
46
46
  "registry": "https://registry.npmjs.org/"
47
47
  },
48
48
  "dependencies": {
49
- "bignumber.js": "9.0.1"
49
+ "bignumber.js": "9.1.1"
50
50
  },
51
51
  "devDependencies": {
52
- "eslint": "7.32.0",
53
- "faucet": "0.0.1",
54
- "npm-audit-resolver": "2.3.1",
55
- "npm-check-updates": "11.8.5",
52
+ "audit-ci": "^6.6.1",
53
+ "eslint": "8.47.0",
54
+ "faucet": "0.0.4",
55
+ "npm-check-updates": "16.13.1",
56
56
  "nyc": "15.1.0",
57
57
  "pre-commit": "1.2.2",
58
- "standard": "16.0.3",
59
- "standard-version": "^9.3.1",
58
+ "standard": "17.1.0",
59
+ "standard-version": "^9.5.0",
60
60
  "tap-xunit": "2.4.1",
61
- "tape": "5.3.1",
61
+ "tape": "5.6.6",
62
62
  "tapes": "4.1.0"
63
63
  }
64
64
  }
@@ -132,6 +132,12 @@ Test('MLNumber', mlNumberTest => {
132
132
  test.end()
133
133
  })
134
134
 
135
+ mlNumberTest.test('shiftedBy should return a number with shifted decimal values to the left with 0-prefix string', test => {
136
+ const shifted = new MLNumber('0123').shiftedBy(-4)
137
+ test.equal(shifted.toString(), '0.0123')
138
+ test.end()
139
+ })
140
+
135
141
  mlNumberTest.test('shiftedBy should return a number with shifted decimal values to the right', test => {
136
142
  const shifted = new MLNumber('1').shiftedBy(+2)
137
143
  test.equal(shifted.toString(), '100')
@@ -1,11 +0,0 @@
1
- {
2
- "decisions": {
3
- "1179|faucet>minimist": {
4
- "decision": "ignore",
5
- "madeAt": 1604389956257,
6
- "expiresAt": 1606981946065
7
- }
8
- },
9
- "rules": {},
10
- "version": 1
11
- }