Skip to content

Commit 5a255d7

Browse files
supplier data auto fixes
1 parent 0b5e2e5 commit 5a255d7

File tree

3 files changed

+42
-47
lines changed

3 files changed

+42
-47
lines changed

scripts/utilities/supplier-data/jest.config.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import type { Config } from 'jest';
1+
import type { Config } from "jest";
22

33
export const baseJestConfig: Config = {
4-
preset: 'ts-jest',
4+
preset: "ts-jest",
55

66
// Automatically clear mock calls, instances, contexts and results before every test
77
clearMocks: true,
@@ -10,10 +10,10 @@ export const baseJestConfig: Config = {
1010
collectCoverage: true,
1111

1212
// The directory where Jest should output its coverage files
13-
coverageDirectory: './.reports/unit/coverage',
13+
coverageDirectory: "./.reports/unit/coverage",
1414

1515
// Indicates which provider should be used to instrument code for coverage
16-
coverageProvider: 'babel',
16+
coverageProvider: "babel",
1717

1818
coverageThreshold: {
1919
global: {
@@ -24,37 +24,37 @@ export const baseJestConfig: Config = {
2424
},
2525
},
2626

27-
coveragePathIgnorePatterns: ['/__tests__/'],
28-
transform: { '^.+\\.ts$': 'ts-jest' },
29-
testPathIgnorePatterns: ['.build'],
30-
testMatch: ['**/?(*.)+(spec|test).[jt]s?(x)'],
27+
coveragePathIgnorePatterns: ["/__tests__/"],
28+
transform: { "^.+\\.ts$": "ts-jest" },
29+
testPathIgnorePatterns: [".build"],
30+
testMatch: ["**/?(*.)+(spec|test).[jt]s?(x)"],
3131

3232
// Use this configuration option to add custom reporters to Jest
3333
reporters: [
34-
'default',
34+
"default",
3535
[
36-
'jest-html-reporter',
36+
"jest-html-reporter",
3737
{
38-
pageTitle: 'Test Report',
39-
outputPath: './.reports/unit/test-report.html',
38+
pageTitle: "Test Report",
39+
outputPath: "./.reports/unit/test-report.html",
4040
includeFailureMsg: true,
4141
},
4242
],
4343
],
4444

4545
// The test environment that will be used for testing
46-
testEnvironment: 'jsdom',
46+
testEnvironment: "jsdom",
4747
};
4848

4949
const utilsJestConfig = {
5050
...baseJestConfig,
5151

52-
testEnvironment: 'node',
52+
testEnvironment: "node",
5353

5454
coveragePathIgnorePatterns: [
5555
...(baseJestConfig.coveragePathIgnorePatterns ?? []),
56-
'cli/index.ts',
57-
'suppliers-repo-factory.ts',
56+
"cli/index.ts",
57+
"suppliers-repo-factory.ts",
5858
],
5959
};
6060

Lines changed: 19 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
import { hideBin } from "yargs/helpers";
2-
import yargs from 'yargs';
2+
import yargs from "yargs";
33
import { LetterStatusType } from "@internal/datastore/src/types";
4-
import { randomUUID } from "crypto";
4+
import { randomUUID } from "node:crypto";
55
import { createSupplierRepository } from "../infrastructure/suppliers-repo-factory";
66

7-
8-
97
async function main() {
108
await yargs(hideBin(process.argv))
119
.command(
@@ -16,35 +14,32 @@ async function main() {
1614
type: "string",
1715
demandOption: true,
1816
},
19-
"id": {
17+
id: {
2018
type: "string",
2119
demandOption: true,
2220
},
23-
"name": {
21+
name: {
2422
type: "string",
2523
demandOption: true,
2624
},
27-
"apimId": {
25+
apimId: {
2826
type: "string",
2927
demandOption: true,
3028
},
3129
status: {
3230
type: "string",
3331
demandOption: true,
34-
choices: [
35-
"ENABLED",
36-
"DISABLED"
37-
],
32+
choices: ["ENABLED", "DISABLED"],
3833
},
3934
},
4035
async (argv) => {
4136
// parse args
42-
const id = argv.id;
43-
const name = argv.name;
44-
const apimId = argv.apimId;
37+
const { id } = argv;
38+
const { name } = argv;
39+
const { apimId } = argv;
4540
const status = argv.status as "ENABLED" | "DISABLED";
4641

47-
const environment = argv.environment;
42+
const { environment } = argv;
4843

4944
const supplierRepository = createSupplierRepository(environment);
5045

@@ -56,13 +51,13 @@ async function main() {
5651
});
5752

5853
console.log(`PUT successful ${JSON.stringify(putResult)}`);
59-
}
54+
},
6055
)
6156
.command(
6257
"get-supplier-by-id",
6358
"Get a supplier by their Supplier ID",
6459
{
65-
"id": {
60+
id: {
6661
type: "string",
6762
demandOption: true,
6863
},
@@ -72,9 +67,8 @@ async function main() {
7267
},
7368
},
7469
async (argv) => {
75-
76-
const id = argv.id;
77-
const environment = argv.environment;
70+
const { id } = argv;
71+
const { environment } = argv;
7872

7973
const supplierRepository = createSupplierRepository(environment);
8074

@@ -87,7 +81,7 @@ async function main() {
8781
"get-supplier-by-apim-id",
8882
"Get a supplier by their APIM ID",
8983
{
90-
"apimId": {
84+
apimId: {
9185
type: "string",
9286
demandOption: true,
9387
},
@@ -97,9 +91,8 @@ async function main() {
9791
},
9892
},
9993
async (argv) => {
100-
101-
const apimId = argv.apimId;
102-
const environment = argv.environment;
94+
const { apimId } = argv;
95+
const { environment } = argv;
10396

10497
const supplierRepository = createSupplierRepository(environment);
10598

@@ -113,8 +106,8 @@ async function main() {
113106
}
114107

115108
if (require.main === module) {
116-
main().catch((err) => {
117-
console.error(err);
109+
main().catch((error) => {
110+
console.error(error);
118111
process.exitCode = 1;
119112
});
120113
}

scripts/utilities/supplier-data/src/infrastructure/suppliers-repo-factory.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
import { DynamoDBClient } from '@aws-sdk/client-dynamodb';
2-
import { DynamoDBDocumentClient } from '@aws-sdk/lib-dynamodb';
3-
import { pino } from 'pino';
4-
import { SupplierRepository } from '@internal/datastore';
1+
import { DynamoDBClient } from "@aws-sdk/client-dynamodb";
2+
import { DynamoDBDocumentClient } from "@aws-sdk/lib-dynamodb";
3+
import { pino } from "pino";
4+
import { SupplierRepository } from "@internal/datastore";
55

6-
export function createSupplierRepository(environment: string): SupplierRepository {
6+
export function createSupplierRepository(
7+
environment: string,
8+
): SupplierRepository {
79
const ddbClient = new DynamoDBClient({});
810
const docClient = DynamoDBDocumentClient.from(ddbClient);
911
const log = pino();

0 commit comments

Comments
 (0)