@mojaloop/ml-testing-toolkit-shared-lib 12.2.0 → 13.0.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/.ncurc.yaml ADDED
@@ -0,0 +1,6 @@
1
+ ## Add a TODO comment indicating the reason for each rejected dependency upgrade added to this list, and what should be done to resolve it (i.e. handle it through a story, etc).
2
+ reject: [
3
+ # Downgraded to 5.5.3 - Reason: removal of functional code in faker.js - https://github.com/advisories/GHSA-5w9c-rv96-fr7g
4
+ "faker"
5
+
6
+ ]
package/.nvmrc ADDED
@@ -0,0 +1 @@
1
+ 16.15.0
package/CHANGELOG.md ADDED
@@ -0,0 +1,16 @@
1
+ # Changelog
2
+
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
+
5
+ ## [13.0.0](https://github.com/mojaloop/ml-testing-toolkit-shared-lib/compare/v12.2.0...v13.0.0) (2022-07-21)
6
+
7
+
8
+ ### ⚠ BREAKING CHANGES
9
+
10
+ * Major version bump for node v16 LTS support, re-structuring of project directories to align to core Mojaloop repositories.
11
+
12
+ Major version bump since this is a big upgrade.
13
+
14
+ ### Features
15
+
16
+ * node upgrade ([#10](https://github.com/mojaloop/ml-testing-toolkit-shared-lib/issues/10)) ([e287fb5](https://github.com/mojaloop/ml-testing-toolkit-shared-lib/commit/e287fb517671689036d63f56cb27f0af1da64451))
package/CODEOWNERS ADDED
@@ -0,0 +1,30 @@
1
+ # Each line is a file pattern followed by one or more owners.
2
+ ## These owners will be the default owners for everything in
3
+ ## the repo. Unless a later match takes precedence,
4
+ ## @global-owner1 and @global-owner2 will be requested for
5
+ ## review when someone opens a pull request.
6
+ #* @global-owner1 @global-owner2
7
+ * @vijayg10 @mdebarros @elnyry-sam-k
8
+ ## Order is important; the last matching pattern takes the most
9
+ ## precedence. When someone opens a pull request that only
10
+ ## modifies JS files, only @js-owner and not the global
11
+ ## owner(s) will be requested for a review.
12
+ # *.js @js-owner
13
+ ## You can also use email addresses if you prefer. They'll be
14
+ ## used to look up users just like we do for commit author
15
+ ## emails.
16
+ #*.go docs@example.com
17
+ # In this example, @doctocat owns any files in the build/logs
18
+ # directory at the root of the repository and any of its
19
+ # subdirectories.
20
+ # /build/logs/ @doctocat
21
+ ## The `docs/*` pattern will match files like
22
+ ## `docs/getting-started.md` but not further nested files like
23
+ ## `docs/build-app/troubleshooting.md`.
24
+ # docs/* docs@example.com
25
+ ## In this example, @octocat owns any file in an apps directory
26
+ ## anywhere in your repository.
27
+ #apps/ @octocat
28
+ ## In this example, @doctocat owns any file in the `/docs`
29
+ ## directory in the root of your repository.
30
+ #/docs/ @doctocat
package/README.md CHANGED
@@ -1 +1,42 @@
1
1
  # ml-testing-toolkit-shared-lib
2
+ Library for shared code between Mojaloop testing-toolkit backend and frontend
3
+
4
+ ## Auditing Dependencies
5
+
6
+ We use `npm-audit-resolver` along with `npm audit` to check dependencies for node vulnerabilities, and keep track of resolved dependencies with an `audit-resolve.json` file.
7
+
8
+ To start a new resolution process, run:
9
+
10
+ ```bash
11
+ npm run audit:resolve
12
+ ```
13
+
14
+ You can then check to see if the CI will pass based on the current dependencies with:
15
+
16
+ ```bash
17
+ npm run audit:check
18
+ ```
19
+
20
+ And commit the changed `audit-resolve.json` to ensure that CircleCI will build correctly.
21
+
22
+ ## Container Scans
23
+
24
+ As part of our CI/CD process, we use anchore-cli to scan our built docker container for vulnerabilities upon release.
25
+
26
+ If you find your release builds are failing, refer to the [container scanning](https://github.com/mojaloop/ci-config#container-scanning) in our shared Mojaloop CI config repo. There is a good chance you simply need to update the `mojaloop-policy-generator.js` file and re-run the circleci workflow.
27
+
28
+ For more information on anchore and anchore-cli, refer to:
29
+ - [Anchore CLI](https://github.com/anchore/anchore-cli)
30
+ - [Circle Orb Registry](https://circleci.com/orbs/registry/orb/anchore/anchore-engine)
31
+
32
+ ## Automated Releases
33
+
34
+ As part of our CI/CD process, we use a combination of CircleCI, standard-version
35
+ npm package and github-release CircleCI orb to automatically trigger our releases
36
+ and image builds. This process essentially mimics a manual tag and release.
37
+
38
+ On a merge to master, CircleCI is configured to use the mojaloopci github account
39
+ to push the latest generated CHANGELOG and package version number.
40
+
41
+ Once those changes are pushed, CircleCI will pull the updated master, tag and
42
+ push a release triggering another subsequent build that also publishes a docker image.
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": [
7
+ // Unable to downgrade due to breaking change: glob-parent before 6.0.1 vulnerable to Regular Expression Denial of Service (ReDoS) - https://github.com/advisories/GHSA-cj88-88mr-972w
8
+ "GHSA-cj88-88mr-972w"
9
+ ]
10
+ }
package/package.json CHANGED
@@ -1,12 +1,28 @@
1
1
  {
2
2
  "name": "@mojaloop/ml-testing-toolkit-shared-lib",
3
- "version": "12.2.0",
3
+ "version": "13.0.0",
4
4
  "description": "Shared library for ml-testing-toolkit re-usable functions",
5
5
  "main": "src/index.js",
6
+ "contributors": [
7
+ "Vijaya Kumar <vijaya.guthi@modusbox.com>",
8
+ "Miguel de Barros <miguel.debarros@modusbox.com>"
9
+ ],
10
+ "engines": {
11
+ "node": "=16.x"
12
+ },
13
+ "license": "Apache-2.0",
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "git+https://github.com/mojaloop/ml-testing-toolkit-shared-lib.git"
17
+ },
18
+ "author": "Vijaya Kumar Guthi, ModusBox Inc.",
19
+ "bugs": {
20
+ "url": "https://github.com/mojaloop/ml-testing-toolkit-shared-lib/issues"
21
+ },
22
+ "homepage": "https://github.com/mojaloop/ml-testing-toolkit-shared-lib#readme",
6
23
  "pre-commit": [
7
24
  "lint",
8
- "dep:check",
9
- "test:unit"
25
+ "dep:check"
10
26
  ],
11
27
  "scripts": {
12
28
  "start": "node src/index.js",
@@ -22,40 +38,35 @@
22
38
  "test:junit": "jest --reporters=default --reporters=jest-junit --testMatch '**/test/unit/**/*.test.js'",
23
39
  "test:integration": "./test/integration-runner.sh ",
24
40
  "cover": "npx nyc --all report --reporter=lcov npm run test",
25
- "audit:resolve": "SHELL=sh resolve-audit",
26
- "audit:check": "SHELL=sh check-audit",
41
+ "audit:check": "npx audit-ci --config ./audit-ci.jsonc",
27
42
  "dep:check": "npx ncu -e 2",
28
- "dep:update": "npx ncu -u"
43
+ "dep:update": "npx ncu -u",
44
+ "release": "npx standard-version --no-verify --releaseCommitMessageFormat 'chore(release): {{currentTag}} [skip ci]'",
45
+ "snapshot": "npx standard-version --no-verify --skip.changelog --prerelease snapshot --releaseCommitMessageFormat 'chore(snapshot): {{currentTag}}'"
29
46
  },
30
- "repository": {
31
- "type": "git",
32
- "url": "git+https://github.com/mojaloop/ml-testing-toolkit-shared-lib.git"
33
- },
34
- "author": "Vijaya Kumar Guthi, ModusBox Inc.",
35
- "contributors": [
36
- "Vijaya Kumar <vijaya.guthi@modusbox.com>",
37
- "Miguel de Barros <miguel.debarros@modusbox.com>"
38
- ],
39
- "license": "Apache-2.0",
40
- "bugs": {
41
- "url": "https://github.com/mojaloop/ml-testing-toolkit-shared-lib/issues"
42
- },
43
- "homepage": "https://github.com/mojaloop/ml-testing-toolkit-shared-lib#readme",
44
47
  "dependencies": {
45
- "ajv": "8.5.0",
48
+ "ajv": "8.11.0",
46
49
  "faker": "5.5.3",
47
- "json-schema-faker": "0.5.0-rcv.34",
48
- "json-schema-ref-parser": "9.0.7",
50
+ "json-schema-faker": "0.5.0-rcv.44",
51
+ "json-schema-ref-parser": "9.0.9",
49
52
  "lodash": "4.17.21",
50
53
  "node-dir": "0.1.17"
51
54
  },
52
55
  "devDependencies": {
53
- "@types/jest": "26.0.23",
54
- "jest": "27.0.4",
55
- "jest-junit": "12.1.0",
56
- "npm-audit-resolver": "2.3.1",
57
- "npm-check-updates": "11.6.0",
58
- "standard": "^16.0.3"
56
+ "@types/jest": "28.1.6",
57
+ "audit-ci": "^6.3.0",
58
+ "jest": "28.1.3",
59
+ "jest-junit": "14.0.0",
60
+ "npm-check-updates": "15.3.4",
61
+ "pre-commit": "^1.2.2",
62
+ "replace": "^1.2.1",
63
+ "standard": "^17.0.0",
64
+ "standard-version": "^9.5.0"
65
+ },
66
+ "standard-version": {
67
+ "scripts": {
68
+ "postchangelog": "replace '\\[mojaloop/#(\\d+)\\]\\(https://github.com/mojaloop/(.*)/issues/(\\d+)\\)' '[mojaloop/#$1](https://github.com/mojaloop/project/issues/$1)' CHANGELOG.md"
69
+ }
59
70
  },
60
71
  "publishConfig": {
61
72
  "registry": "https://registry.npmjs.org/"
@@ -61,7 +61,7 @@ const convertToFolderNestedArray = (folderRawData) => {
61
61
  const children = []
62
62
  processFileOrFolder(inputItem[fileOrFolderItem], children, (prefix ? (prefix + '/') : '') + fileOrFolderItem)
63
63
  extraInfo = extraInfo || { type: 'folder' }
64
- inputArray.push({ key: (prefix ? (prefix + '/') : '') + fileOrFolderItem, title: fileOrFolderItem, extraInfo, children: children })
64
+ inputArray.push({ key: (prefix ? (prefix + '/') : '') + fileOrFolderItem, title: fileOrFolderItem, extraInfo, children })
65
65
  }
66
66
  }
67
67
  }
@@ -78,7 +78,7 @@ const convertToFolderNestedArray = (folderRawData) => {
78
78
  if (orderItem.type === 'file' || orderItem.type === 'folder') {
79
79
  const extraInfo = {
80
80
  type: orderItem.type
81
- }
81
+ }
82
82
  if (orderItem.labels) {
83
83
  extraInfo.labels = orderItem.labels
84
84
  }
@@ -163,13 +163,14 @@ const getAbsolutePathOfRelativeFileRef = (refNode) => {
163
163
  }
164
164
 
165
165
  const getLabels = (currentLabels, newLabels = []) => {
166
+ // eslint-disable-next-line no-unneeded-ternary
166
167
  currentLabels = currentLabels ? currentLabels : []
167
168
  const labels = (currentLabels && currentLabels.length > 0) ? [...currentLabels] : []
168
169
  newLabels.forEach(label => {
169
170
  if (!currentLabels.includes(label)) {
170
171
  labels.push(label)
171
172
  }
172
- });
173
+ })
173
174
  return labels
174
175
  }
175
176
 
@@ -213,7 +214,7 @@ const addChildrenToTestCases = (folderData, nodeChildren, testCases, selectedFil
213
214
  let isSelected = false
214
215
  if (testCase.fileInfo.labels && testCase.fileInfo.labels.length > 0) {
215
216
  for (let j = 0; j < testCase.fileInfo.labels.length; j++) {
216
- const l = testCase.fileInfo.labels[j];
217
+ const l = testCase.fileInfo.labels[j]
217
218
  if (selectedLabels.includes(l)) {
218
219
  isSelected = true
219
220
  break
@@ -1,301 +0,0 @@
1
- # CircleCI v2 Config
2
- version: 2
3
-
4
- defaults_working_directory: &defaults_working_directory
5
- working_directory: /home/circleci/project
6
-
7
- defaults_docker_node: &defaults_docker_node
8
- docker:
9
- - image: mhart/alpine-node:12.16.0
10
-
11
- defaults_Dependencies: &defaults_Dependencies |
12
- apk --no-cache add git
13
- apk --no-cache add ca-certificates
14
- apk --no-cache add curl
15
- apk --no-cache add openssh-client
16
- apk --no-cache add bash
17
- apk add --no-cache -t build-dependencies make gcc g++ python libtool autoconf automake
18
- npm config set unsafe-perm true
19
- npm install -g node-gyp
20
-
21
- defaults_awsCliDependencies: &defaults_awsCliDependencies |
22
- apk --no-cache add \
23
- python \
24
- py-pip \
25
- groff \
26
- less \
27
- mailcap
28
- pip install --upgrade awscli==1.14.5 s3cmd==2.0.1 python-magic
29
- apk -v --purge del py-pip
30
-
31
- defaults_license_scanner: &defaults_license_scanner
32
- name: Install and set up license-scanner
33
- command: |
34
- git clone https://github.com/mojaloop/license-scanner /tmp/license-scanner
35
- cd /tmp/license-scanner && make build default-files set-up
36
-
37
- defaults_npm_auth: &defaults_npm_auth
38
- name: Update NPM registry auth token
39
- command: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > .npmrc
40
-
41
- defaults_npm_publish_version: &defaults_npm_publish
42
- name: Update version to prerelease
43
- command: |
44
- source $BASH_ENV
45
- echo "Publishing tag $CIRCLE_TAG"
46
- npm publish --tag $CIRCLE_TAG --access public
47
-
48
- defaults_npm_publish_release: &defaults_npm_publish_release
49
- name: Publish NPM $RELEASE_TAG artifact
50
- command: |
51
- source $BASH_ENV
52
- echo "Publishing tag $RELEASE_TAG"
53
- npm publish --tag $RELEASE_TAG --access public
54
-
55
- defaults_slack_announcement: &defaults_slack_announcement
56
- name: Slack announcement for tag releases
57
- command: |
58
- curl -X POST \
59
- $SLACK_WEBHOOK_ANNOUNCEMENT \
60
- -H 'Content-type: application/json' \
61
- -H 'cache-control: no-cache' \
62
- -d "{
63
- \"text\": \"*${CIRCLE_PROJECT_REPONAME}* - Release \`${CIRCLE_TAG}\`: https://github.com/mojaloop/${CIRCLE_PROJECT_REPONAME}/releases/tag/${CIRCLE_TAG}\"
64
- }"
65
-
66
- jobs:
67
- setup:
68
- <<: *defaults_working_directory
69
- <<: *defaults_docker_node
70
- steps:
71
- - run:
72
- name: Install general dependencies
73
- command: *defaults_Dependencies
74
- - checkout
75
- - run:
76
- name: Update NPM install
77
- command: npm install
78
- - save_cache:
79
- key: dependency-cache-{{ checksum "package.json" }}
80
- paths:
81
- - node_modules
82
-
83
- test-unit:
84
- <<: *defaults_working_directory
85
- <<: *defaults_docker_node
86
- steps:
87
- - run:
88
- name: Install general dependencies
89
- command: *defaults_Dependencies
90
- - checkout
91
- - restore_cache:
92
- key: dependency-cache-{{ checksum "package.json" }}
93
- - run:
94
- name: Create dir for test results
95
- command: mkdir -p ./test/results
96
- - run:
97
- name: Execute unit tests
98
- command: npm -s run test:junit
99
- - store_artifacts:
100
- path: ./test/results
101
- prefix: test
102
- - store_test_results:
103
- path: ./test/results
104
-
105
- test-coverage:
106
- <<: *defaults_working_directory
107
- <<: *defaults_docker_node
108
- steps:
109
- - run:
110
- name: Install general dependencies
111
- command: *defaults_Dependencies
112
- - run:
113
- name: Install AWS CLI dependencies
114
- command: *defaults_awsCliDependencies
115
- - checkout
116
- - restore_cache:
117
- key: dependency-cache-{{ checksum "package.json" }}
118
- - run:
119
- name: Execute code coverage check
120
- command: npm -s run test:coverage-check
121
- - store_artifacts:
122
- path: coverage
123
- prefix: test
124
- - store_test_results:
125
- path: coverage
126
- - run:
127
- name: Copy code coverage to SonarQube
128
- command: |
129
- if [ "${CIRCLE_BRANCH}" == "master" ];
130
- then
131
- echo "Sending lcov.info to SonarQube..."
132
- aws s3 cp coverage/lcov.info $AWS_S3_DIR_SONARQUBE/ml-testing-toolkit-shared-lib/lcov.info
133
- else
134
- echo "Not a release (env CIRCLE_BRANCH != 'master'), skipping sending lcov.info to SonarQube."
135
- fi
136
-
137
- vulnerability-check:
138
- <<: *defaults_working_directory
139
- <<: *defaults_docker_node
140
- steps:
141
- - run:
142
- name: Install general dependencies
143
- command: *defaults_Dependencies
144
- - checkout
145
- - restore_cache:
146
- key: dependency-cache-{{ checksum "package.json" }}
147
- - run:
148
- name: Create dir for test results
149
- command: mkdir -p ./audit/results
150
- - run:
151
- name: Check for new npm vulnerabilities
152
- command: npm run audit:check --silent -- --json > ./audit/results/auditResults.json
153
- - store_artifacts:
154
- path: ./audit/results
155
- prefix: audit
156
-
157
- audit-licenses:
158
- <<: *defaults_working_directory
159
- <<: *defaults_docker_node
160
- steps:
161
- - run:
162
- name: Install general dependencies
163
- command: *defaults_Dependencies
164
- - run:
165
- <<: *defaults_license_scanner
166
- - checkout
167
- - restore_cache:
168
- key: dependency-cache-{{ checksum "package.json" }}
169
- - run:
170
- name: Prune non-production packages before running license-scanner
171
- command: npm prune --production
172
- - run:
173
- name: Run the license-scanner
174
- command: cd /tmp/license-scanner && pathToRepo=$CIRCLE_WORKING_DIRECTORY make run
175
- - store_artifacts:
176
- path: /tmp/license-scanner/results
177
- prefix: licenses
178
-
179
- build-snapshot:
180
- <<: *defaults_working_directory
181
- <<: *defaults_docker_node
182
- steps:
183
- - run:
184
- name: Install general dependencies
185
- command: *defaults_Dependencies
186
- - checkout
187
- - run:
188
- name: setup environment vars for SNAPSHOT release
189
- command: |
190
- echo 'export RELEASE_TAG=$RELEASE_TAG_SNAPSHOT' >> $BASH_ENV
191
- - run:
192
- <<: *defaults_npm_auth
193
- - run:
194
- <<: *defaults_npm_publish_release
195
- - run:
196
- <<: *defaults_slack_announcement
197
-
198
- build:
199
- <<: *defaults_working_directory
200
- <<: *defaults_docker_node
201
- steps:
202
- - run:
203
- name: Install general dependencies
204
- command: *defaults_Dependencies
205
- - checkout
206
- - run:
207
- name: setup environment vars for LATEST release
208
- command: |
209
- echo 'export RELEASE_TAG=$RELEASE_TAG_PROD' >> $BASH_ENV
210
- - run:
211
- <<: *defaults_npm_auth
212
- - run:
213
- <<: *defaults_npm_publish_release
214
- - run:
215
- <<: *defaults_slack_announcement
216
-
217
- workflows:
218
- version: 2
219
- build_and_test:
220
- jobs:
221
- - setup:
222
- context: org-global
223
- filters:
224
- tags:
225
- only: /.*/
226
- branches:
227
- ignore:
228
- - /feature*/
229
- - /bugfix*/
230
- - test-unit:
231
- context: org-global
232
- requires:
233
- - setup
234
- filters:
235
- tags:
236
- only: /.*/
237
- branches:
238
- ignore:
239
- - /feature*/
240
- - /bugfix*/
241
- - test-coverage:
242
- context: org-global
243
- requires:
244
- - setup
245
- filters:
246
- tags:
247
- only: /.*/
248
- branches:
249
- ignore:
250
- - /feature*/
251
- - /bugfix*/
252
- - vulnerability-check:
253
- context: org-global
254
- requires:
255
- - setup
256
- filters:
257
- tags:
258
- only: /.*/
259
- branches:
260
- ignore:
261
- - /feature*/
262
- - /bugfix*/
263
- - audit-licenses:
264
- context: org-global
265
- requires:
266
- - setup
267
- filters:
268
- tags:
269
- only: /.*/
270
- branches:
271
- ignore:
272
- - /feature*/
273
- - /bugfix*/
274
- - build-snapshot:
275
- context: org-global
276
- requires:
277
- - setup
278
- - test-unit
279
- - test-coverage
280
- - vulnerability-check
281
- - audit-licenses
282
- filters:
283
- tags:
284
- only: /v[0-9]+(\.[0-9]+)*\-snapshot+((\.[0-9]+)?)/
285
- branches:
286
- ignore:
287
- - /.*/
288
- - build:
289
- context: org-global
290
- requires:
291
- - setup
292
- - test-unit
293
- - test-coverage
294
- - vulnerability-check
295
- - audit-licenses
296
- filters:
297
- tags:
298
- only: /v[0-9]+(\.[0-9]+)*/
299
- branches:
300
- ignore:
301
- - /.*/