@skillswaveca/nova-shared-libraries 3.5.17 → 3.6.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.
- package/.github/labeler.yml +25 -0
- package/.github/workflows/labels.yml +33 -0
- package/.github/workflows/pull-request.yml +5 -3
- package/.github/workflows/release.yml +5 -3
- package/README.md +3 -3
- package/docs-base/package-info.js +4 -4
- package/package.json +1 -1
- package/packages/drivers/package.json +1 -1
- package/packages/drivers/src/http.js +2 -2
- package/packages/nova-middleware/package.json +1 -1
- package/packages/nova-model/package.json +1 -1
- package/packages/nova-utils/package.json +1 -1
- package/packages/nova-utils/src/config.js +26 -7
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
area/github-actions:
|
|
2
|
+
- changed-files:
|
|
3
|
+
- any-glob-to-any-file:
|
|
4
|
+
- '.github/workflows/**'
|
|
5
|
+
area/docs:
|
|
6
|
+
- changed-files:
|
|
7
|
+
- any-glob-to-any-file:
|
|
8
|
+
- 'docs/**'
|
|
9
|
+
area/docs-base:
|
|
10
|
+
- changed-files:
|
|
11
|
+
- any-glob-to-any-file:
|
|
12
|
+
- 'docs-base/**'
|
|
13
|
+
area/packages:
|
|
14
|
+
- changed-files:
|
|
15
|
+
- any-glob-to-any-file:
|
|
16
|
+
- 'packages/**'
|
|
17
|
+
area/scripts:
|
|
18
|
+
- changed-files:
|
|
19
|
+
- any-glob-to-any-file:
|
|
20
|
+
- 'scripts/**'
|
|
21
|
+
area/package-list:
|
|
22
|
+
- changed-files:
|
|
23
|
+
- any-glob-to-any-file:
|
|
24
|
+
- '**/package-lock.json'
|
|
25
|
+
- '**/package.json'
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
name: "Apply labels to PRs"
|
|
2
|
+
on:
|
|
3
|
+
- pull_request
|
|
4
|
+
permissions:
|
|
5
|
+
pull-requests: write
|
|
6
|
+
actions: write
|
|
7
|
+
checks: write
|
|
8
|
+
contents: write
|
|
9
|
+
deployments: write
|
|
10
|
+
discussions: write
|
|
11
|
+
issues: write
|
|
12
|
+
packages: write
|
|
13
|
+
pages: write
|
|
14
|
+
repository-projects: write
|
|
15
|
+
security-events: write
|
|
16
|
+
statuses: write
|
|
17
|
+
|
|
18
|
+
jobs:
|
|
19
|
+
label:
|
|
20
|
+
runs-on: ubuntu-latest
|
|
21
|
+
timeout-minutes: 2
|
|
22
|
+
steps:
|
|
23
|
+
- uses: Brightspace/third-party-actions@actions/labeler
|
|
24
|
+
with:
|
|
25
|
+
repo-token: "${{ secrets.GITHUB_TOKEN }}"
|
|
26
|
+
- uses: Brightspace/third-party-actions@codelytv/pr-size-labeler
|
|
27
|
+
with:
|
|
28
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
29
|
+
xs_max_size: '15'
|
|
30
|
+
s_max_size: '75'
|
|
31
|
+
m_max_size: '250'
|
|
32
|
+
l_max_size: '750'
|
|
33
|
+
fail_if_xl: 'false'
|
|
@@ -6,8 +6,10 @@ jobs:
|
|
|
6
6
|
run-tests:
|
|
7
7
|
runs-on: ubuntu-latest
|
|
8
8
|
steps:
|
|
9
|
-
-
|
|
10
|
-
|
|
9
|
+
- uses: pnpm/action-setup@v4
|
|
10
|
+
name: Install pnpm
|
|
11
|
+
with:
|
|
12
|
+
version: 9
|
|
11
13
|
- uses: actions/checkout@v4
|
|
12
14
|
- name: Overwrite git protocol to https
|
|
13
15
|
run: git config --global url."https://github.com".insteadOf git://github.com
|
|
@@ -17,7 +19,7 @@ jobs:
|
|
|
17
19
|
cache: 'pnpm'
|
|
18
20
|
|
|
19
21
|
- name: Install deps
|
|
20
|
-
run: pnpm install
|
|
22
|
+
run: pnpm install --frozen-lockfile
|
|
21
23
|
|
|
22
24
|
- name: Run unit tests and linting
|
|
23
25
|
run: pnpm recursive run test
|
|
@@ -10,8 +10,10 @@ jobs:
|
|
|
10
10
|
runs-on: ubuntu-latest
|
|
11
11
|
|
|
12
12
|
steps:
|
|
13
|
-
-
|
|
14
|
-
|
|
13
|
+
- uses: pnpm/action-setup@v4
|
|
14
|
+
name: Install pnpm
|
|
15
|
+
with:
|
|
16
|
+
version: 9
|
|
15
17
|
|
|
16
18
|
- name: Checkout repository
|
|
17
19
|
uses: actions/checkout@v4
|
|
@@ -26,7 +28,7 @@ jobs:
|
|
|
26
28
|
registry-url: 'https://registry.npmjs.org/'
|
|
27
29
|
|
|
28
30
|
- name: Install dependencies
|
|
29
|
-
run: pnpm install
|
|
31
|
+
run: pnpm install --frozen-lockfile
|
|
30
32
|
|
|
31
33
|
- name: Initialize mandatory git config
|
|
32
34
|
run: |
|
package/README.md
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
<p align="center">
|
|
2
|
-
<img src="https://github.com/SkillsWave/nova-shared-libraries/assets/1350855/
|
|
2
|
+
<img src="https://github.com/SkillsWave/nova-shared-libraries/assets/1350855/3e7683f6-227c-4948-aaed-b9ee4d2400d7" width="400"/>
|
|
3
3
|
</p>
|
|
4
4
|
|
|
5
5
|
# Nova shared libraries
|
|
6
6
|
This repository contains a collection of shared libraries used across the Nova ecosystem. These libraries are designed to be used across multiple projects and are intended to simplify the development process.
|
|
7
7
|
|
|
8
8
|
## Usage
|
|
9
|
-
This package is published to
|
|
9
|
+
This package is published to npm. You can include it in your project by adding
|
|
10
10
|
```json
|
|
11
|
-
"@skillswaveca/nova-shared-libraries": "^
|
|
11
|
+
"@skillswaveca/nova-shared-libraries": "^3.6.1",
|
|
12
12
|
```
|
|
13
13
|
to your projects `package.json` or by running `npm install @skillswaveca/nova-shared-libraries`
|
|
14
14
|
|
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
export const packageInfo = [
|
|
2
2
|
{
|
|
3
3
|
"name": "@skillswaveca/nova-utils",
|
|
4
|
-
"version": "3.
|
|
4
|
+
"version": "3.6.0",
|
|
5
5
|
"description": "A collection of random utils used in nova repos",
|
|
6
6
|
"docsPath": "./nova-utils/index.html"
|
|
7
7
|
},
|
|
8
8
|
{
|
|
9
9
|
"name": "@skillswaveca/nova-model",
|
|
10
|
-
"version": "3.
|
|
10
|
+
"version": "3.6.0",
|
|
11
11
|
"description": "Nova model stuff",
|
|
12
12
|
"docsPath": "./nova-model/index.html"
|
|
13
13
|
},
|
|
14
14
|
{
|
|
15
15
|
"name": "@skillswaveca/nova-middleware",
|
|
16
|
-
"version": "3.
|
|
16
|
+
"version": "3.6.0",
|
|
17
17
|
"description": "A collection of middleware used by nova projects",
|
|
18
18
|
"docsPath": "./nova-middleware/index.html"
|
|
19
19
|
},
|
|
20
20
|
{
|
|
21
21
|
"name": "@skillswaveca/nova-drivers",
|
|
22
|
-
"version": "3.
|
|
22
|
+
"version": "3.6.0",
|
|
23
23
|
"description": "Some helper drivers for AWS services",
|
|
24
24
|
"docsPath": "./drivers/index.html"
|
|
25
25
|
}
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"name": "@skillswaveca/nova-shared-libraries",
|
|
4
4
|
"description": "A monorepo of shared libraries for Nova projects.",
|
|
5
5
|
"repository": "https://github.com/SkillsWave/nova-shared-libraries",
|
|
6
|
-
"version": "3.
|
|
6
|
+
"version": "3.6.1",
|
|
7
7
|
"main": "index.js",
|
|
8
8
|
"license": "MIT",
|
|
9
9
|
"keywords": [],
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"name": "@skillswaveca/nova-drivers",
|
|
4
4
|
"description": "Some helper drivers for AWS services",
|
|
5
5
|
"repository": "https://github.com/SkillsWave/nova-shared-libraries",
|
|
6
|
-
"version": "3.
|
|
6
|
+
"version": "3.6.1",
|
|
7
7
|
"main": "index.js",
|
|
8
8
|
"scripts": {
|
|
9
9
|
"pre-release": "pnpm run create-index",
|
|
@@ -112,7 +112,7 @@ export class HttpDriver extends NovaDriver {
|
|
|
112
112
|
error = await response.text();
|
|
113
113
|
}
|
|
114
114
|
|
|
115
|
-
return { success, body, error };
|
|
115
|
+
return { success, body, error, statusCode: response.status };
|
|
116
116
|
}
|
|
117
117
|
|
|
118
118
|
/**
|
|
@@ -152,7 +152,7 @@ export class HttpDriver extends NovaDriver {
|
|
|
152
152
|
return await this._handleResponse(url, options, response);
|
|
153
153
|
} catch (error) {
|
|
154
154
|
this.log.error({ url: url, method: method, error, message: error.message }, 'HTTP request failed');
|
|
155
|
-
return { success: false, error: error.message };
|
|
155
|
+
return { success: false, error: error.message, statusCode: error.status };
|
|
156
156
|
}
|
|
157
157
|
}
|
|
158
158
|
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"name": "@skillswaveca/nova-middleware",
|
|
4
4
|
"description": "A collection of middleware used by nova projects",
|
|
5
5
|
"repository": "https://github.com/SkillsWave/nova-shared-libraries",
|
|
6
|
-
"version": "3.
|
|
6
|
+
"version": "3.6.1",
|
|
7
7
|
"main": "index.js",
|
|
8
8
|
"scripts": {
|
|
9
9
|
"pre-release": "pnpm run create-index",
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"name": "@skillswaveca/nova-model",
|
|
4
4
|
"description": "Nova model stuff",
|
|
5
5
|
"repository": "https://github.com/SkillsWave/nova-shared-libraries",
|
|
6
|
-
"version": "3.
|
|
6
|
+
"version": "3.6.1",
|
|
7
7
|
"main": "index.js",
|
|
8
8
|
"scripts": {
|
|
9
9
|
"pre-release": "pnpm run create-index",
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"name": "@skillswaveca/nova-utils",
|
|
4
4
|
"description": "A collection of random utils used in nova repos",
|
|
5
5
|
"repository": "https://github.com/SkillsWave/nova-shared-libraries",
|
|
6
|
-
"version": "3.
|
|
6
|
+
"version": "3.6.1",
|
|
7
7
|
"main": "index.js",
|
|
8
8
|
"scripts": {
|
|
9
9
|
"pre-release": "pnpm run create-index",
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import * as fs from 'fs';
|
|
2
2
|
import * as path from 'path';
|
|
3
|
-
|
|
4
3
|
import yn from 'yn';
|
|
5
4
|
import { log } from './logger.js';
|
|
6
5
|
|
|
@@ -12,14 +11,16 @@ import { log } from './logger.js';
|
|
|
12
11
|
* @returns {Object} - The resulting merged object.
|
|
13
12
|
*/
|
|
14
13
|
export const deepMerge = (obj1, obj2) => {
|
|
15
|
-
const output =
|
|
14
|
+
const output = { ...obj1 }; // Use spread syntax for shallow copy
|
|
16
15
|
for (const key in obj2) {
|
|
17
|
-
if (obj2[key]) {
|
|
16
|
+
if (obj2[key] !== undefined && obj2[key] !== null) {
|
|
18
17
|
if (typeof obj2[key] === 'object' && obj2[key] !== null && obj1[key]) {
|
|
19
18
|
output[key] = deepMerge(obj1[key], obj2[key]);
|
|
20
19
|
} else {
|
|
21
20
|
output[key] = obj2[key];
|
|
22
21
|
}
|
|
22
|
+
} else if (obj2[key] === null) {
|
|
23
|
+
output[key] = obj2[key];
|
|
23
24
|
}
|
|
24
25
|
}
|
|
25
26
|
return output;
|
|
@@ -184,7 +185,11 @@ const readJsonFiles = dir => {
|
|
|
184
185
|
return fs.readdirSync(dir)
|
|
185
186
|
.filter(file => path.extname(file) === '.json')
|
|
186
187
|
.reduce((acc, file) => {
|
|
187
|
-
|
|
188
|
+
try {
|
|
189
|
+
acc[path.basename(file, '.json')] = JSON.parse(fs.readFileSync(path.join(dir, file), 'utf8'));
|
|
190
|
+
} catch (err) {
|
|
191
|
+
log.error({ message: err.message }, `Error reading JSON file: ${file}`);
|
|
192
|
+
}
|
|
188
193
|
return acc;
|
|
189
194
|
}, {});
|
|
190
195
|
};
|
|
@@ -199,10 +204,16 @@ export class NovaStageConfig {
|
|
|
199
204
|
*
|
|
200
205
|
* @param {Object} baseConfig - The default configuration object that will be used as the base.
|
|
201
206
|
* @param stageConfig - The stage configuration object or the path to the directory containing stage-specific JSON files.
|
|
207
|
+
* @param accountConfig - The account configuration object or the path to the directory containing account-specific JSON files.
|
|
202
208
|
*/
|
|
203
|
-
constructor(baseConfig, stageConfig) {
|
|
209
|
+
constructor(baseConfig, stageConfig, accountConfig) {
|
|
204
210
|
this.baseConfig = baseConfig;
|
|
205
211
|
this.stages = typeof stageConfig === 'string' ? readJsonFiles(stageConfig) : stageConfig;
|
|
212
|
+
if (accountConfig && typeof accountConfig === 'string') {
|
|
213
|
+
this.accounts = readJsonFiles(accountConfig);
|
|
214
|
+
} else {
|
|
215
|
+
log.info('No account configuration provided.');
|
|
216
|
+
}
|
|
206
217
|
if (!this.baseConfig) {
|
|
207
218
|
throw new Error('NovaConfig requires a base configuration object to be provided.');
|
|
208
219
|
}
|
|
@@ -218,11 +229,19 @@ export class NovaStageConfig {
|
|
|
218
229
|
*
|
|
219
230
|
* @param {string} stage - The stage for which the configuration is needed, typically corresponds
|
|
220
231
|
* to different deployment environments (e.g., 'prod', 'dev').
|
|
232
|
+
* @param region - The region for which the configuration is needed.
|
|
221
233
|
* @returns {Object} - The merged configuration object that combines the default settings with
|
|
222
234
|
* any stage-specific overrides.
|
|
223
235
|
*/
|
|
224
|
-
createConfigForStage(stage) {
|
|
236
|
+
createConfigForStage(stage, region) {
|
|
237
|
+
const baseConfig = this.baseConfig(stage);
|
|
225
238
|
const stageConfig = this.stages[stage] || this.stages.dev;
|
|
226
|
-
|
|
239
|
+
const awsAccount = stageConfig?.awsAccount || baseConfig?.awsAccount;
|
|
240
|
+
const accountConfig = this.accounts ? this.accounts[awsAccount] : {};
|
|
241
|
+
const regionConfig = region ? this.stages[`${stage}.${region}`] : {};
|
|
242
|
+
let ret = deepMerge(baseConfig, accountConfig);
|
|
243
|
+
ret = deepMerge(ret, stageConfig);
|
|
244
|
+
ret = deepMerge(ret, regionConfig);
|
|
245
|
+
return ret;
|
|
227
246
|
}
|
|
228
247
|
}
|