Skip to content

Commit 01b1bdb

Browse files
Split deploymentUtils into its own package
1 parent a399ea2 commit 01b1bdb

23 files changed

Lines changed: 374 additions & 121 deletions

.github/workflows/release.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ jobs:
5959
dry_run: false
6060
asdfVersion: ${{ needs.get_asdf_version.outputs.asdf_version }}
6161
branch_name: main
62-
publish_package: true
62+
publish_package: false
63+
publish_subpackages: packages/cdkConstructs,packages/deploymentUtils
6364
tag_format: ${{ needs.get_asdf_version.outputs.tag_format }}
6465
secrets: inherit
6566

.pre-commit-config.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,5 +50,14 @@ repos:
5050
types_or: [ts, tsx, javascript, jsx, json]
5151
pass_filenames: false
5252

53+
- id: lint-deploymentUtils
54+
name: Lint deploymentUtils
55+
entry: npm
56+
args: ["run", "--prefix=packages/deploymentUtils", "lint"]
57+
language: system
58+
files: ^packages\/deploymentUtils
59+
types_or: [ts, tsx, javascript, jsx, json]
60+
pass_filenames: false
61+
5362
fail_fast: true
5463
default_stages: [pre-commit]

.vscode/eps-cdk-utils.code-workspace

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
{
88
"name": "packages/cdkConstructs",
99
"path": "../packages/cdkConstructs"
10+
},
11+
{
12+
"name": "packages/deploymentUtils",
13+
"path": "../packages/deploymentUtils"
1014
}
1115
],
1216
"settings": {

Makefile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ install-hooks: install-python
2020
lint-node:
2121
npm run lint
2222
npm run lint --workspace packages/cdkConstructs
23+
npm run lint --workspace packages/deploymentUtils
2324

2425
lint-githubactions:
2526
actionlint
@@ -32,6 +33,8 @@ lint: lint-node lint-githubactions lint-githubaction-scripts
3233
clean:
3334
rm -rf packages/cdkConstructs/lib
3435
rm -rf packages/cdkConstructs/coverage
36+
rm -rf packages/deploymentUtils/lib
37+
rm -rf packages/deploymentUtils/coverage
3538
rm -rf lib
3639

3740
deep-clean: clean
@@ -43,6 +46,7 @@ check-licenses: check-licenses-node check-licenses-python
4346
check-licenses-node:
4447
npm run check-licenses
4548
npm run check-licenses --workspace packages/cdkConstructs
49+
npm run check-licenses --workspace packages/deploymentUtils
4650

4751
check-licenses-python:
4852
scripts/check_python_licenses.sh
@@ -55,10 +59,13 @@ aws-login:
5559

5660
test: clean
5761
npm run test --workspace packages/cdkConstructs
62+
npm run test --workspace packages/deploymentUtils
5863

5964
package: build
6065
mkdir -p lib/
6166
npm pack --workspace packages/cdkConstructs --pack-destination lib/
67+
npm pack --workspace packages/deploymentUtils --pack-destination lib/
6268

6369
build:
6470
npm run build --workspace packages/cdkConstructs
71+
npm run build --workspace packages/deploymentUtils

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ This repository contains a docker image used to deploy CDK to our environments a
66

77
- `docker/` Contains Dockerfile used to build image used fo for CDK deployments
88
- `packages/cdkConstructs/` Contains common CDK constructs used in EPS projects
9+
- `packages/depoymentUtils/` Contains shared code for standardizing OAS files and performing proxygen deployments
910
- `scripts/` Utilities helpful to developers of this specification
1011
- `.github/` Contains GitHub workflows that are used for building and deploying from pull requests and releases
1112

package-lock.json

Lines changed: 32 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,14 @@
11
{
2-
"name": "@nhsdigital/eps-cdk-constructs",
3-
"version": "1.0.0",
4-
"description": "Common AWS CDK Constructs for NHS Digital EPS Projects",
52
"scripts": {
63
"test": "echo \"Error: no test specified\" && exit 1",
74
"check-licenses": "node_modules/.bin/license-checker --failOn GPL --failOn LGPL",
8-
"lint": "echo \"Error: no linting specified\"",
9-
"prepublishOnly": "cd packages/cdkConstructs && npm run prepublishOnly"
10-
},
11-
"repository": {
12-
"type": "git",
13-
"url": "https://github.com/NHSDigital/eps-cdk-utils"
5+
"lint": "echo \"Error: no linting specified\""
146
},
157
"workspaces": [
16-
"packages/cdkConstructs"
8+
"packages/cdkConstructs",
9+
"packages/deploymentUtils"
1710
],
1811
"keywords": [],
19-
"author": "NHS Digital",
2012
"license": "MIT",
2113
"devDependencies": {
2214
"@types/node": "^25.0.3",
@@ -39,15 +31,5 @@
3931
"cdk-nag": "^2.37.52",
4032
"constructs": "^10.4.4",
4133
"esbuild": "^0.27.2"
42-
},
43-
"publishConfig": {
44-
"registry": "https://npm.pkg.github.com",
45-
"access": "public"
46-
},
47-
"type": "module",
48-
"files": [
49-
"packages/cdkConstructs/lib/src"
50-
],
51-
"main": "packages/cdkConstructs/lib/src/index.js",
52-
"types": "packages/cdkConstructs/lib/src/index.d.ts"
34+
}
5335
}

packages/cdkConstructs/package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,11 @@
2121
"type": "module",
2222
"dependencies": {
2323
"@aws-sdk/client-cloudformation": "^3.958.0",
24-
"@aws-sdk/client-lambda": "^3.958.0",
2524
"@aws-sdk/client-s3": "^3.958.0",
2625
"aws-cdk": "^2.1100.3",
2726
"aws-cdk-lib": "^2.234.1",
2827
"cdk-nag": "^2.37.52",
29-
"constructs": "^10.4.4",
30-
"json-schema-to-ts": "^3.1.1"
28+
"constructs": "^10.4.4"
3129
},
3230
"bugs": {
3331
"url": "https://github.com/NHSDigital/eps-cdk-utils/issues"
Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {CloudFormationClient, ListExportsCommand, DescribeStacksCommand} from "@aws-sdk/client-cloudformation"
1+
import {CloudFormationClient, DescribeStacksCommand} from "@aws-sdk/client-cloudformation"
22
import {S3Client, HeadObjectCommand} from "@aws-sdk/client-s3"
33

44
export function getConfigFromEnvVar(varName: string, prefix: string = "CDK_CONFIG_"): string {
@@ -32,39 +32,6 @@ export async function getTrustStoreVersion(trustStoreFile: string, region: strin
3232
return headObjectResponse.VersionId!
3333
}
3434

35-
export async function getCloudFormationExports(region: string = "eu-west-2"): Promise<Record<string, string>> {
36-
const cfnClient = new CloudFormationClient({region})
37-
const listExportsCommand = new ListExportsCommand({})
38-
const exports: Record<string, string> = {}
39-
let nextToken: string | undefined = undefined
40-
41-
do {
42-
const response = await cfnClient.send(listExportsCommand)
43-
response.Exports?.forEach((exp) => {
44-
if (exp.Name && exp.Value) {
45-
exports[exp.Name] = exp.Value
46-
}
47-
})
48-
nextToken = response.NextToken
49-
listExportsCommand.input.NextToken = nextToken
50-
} while (nextToken)
51-
52-
return exports
53-
}
54-
55-
export function getCFConfigValue(exports: Record<string, string>, exportName: string): string {
56-
const value = exports[exportName]
57-
if (!value) {
58-
throw new Error(`CloudFormation export ${exportName} not found`)
59-
}
60-
return value
61-
}
62-
63-
export function getBooleanCFConfigValue(exports: Record<string, string>, exportName: string): boolean {
64-
const value = getCFConfigValue(exports, exportName)
65-
return value.toLowerCase() === "true"
66-
}
67-
6835
export function calculateVersionedStackName(baseStackName: string, version: string): string {
6936
return `${baseStackName}-${version.replaceAll(".", "-")}`
7037
}

0 commit comments

Comments
 (0)