@mbc-cqrs-serverless/cli 0.1.23-beta.0 → 0.1.25-beta.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/dist/actions/new.action.js +25 -1
- package/package.json +2 -2
- package/templates/.dockerignore +11 -0
- package/templates/Dockerfile +32 -0
- package/templates/infra/.prettierrc +8 -0
- package/templates/infra/README.md +25 -0
- package/templates/infra/asset/schema.graphql +32 -0
- package/templates/infra/bin/infra.ts +47 -0
- package/templates/infra/cdk.json +48 -0
- package/templates/infra/config/constant.ts +8 -0
- package/templates/infra/config/dev/index.ts +48 -0
- package/templates/infra/config/index.ts +17 -0
- package/templates/infra/config/prod/index.ts +48 -0
- package/templates/infra/config/stg/index.ts +48 -0
- package/templates/infra/config/type.ts +53 -0
- package/templates/infra/gitignore +8 -0
- package/templates/infra/jest.config.js +8 -0
- package/templates/infra/libs/build-app.ts +85 -0
- package/templates/infra/libs/infra-stack.ts +948 -0
- package/templates/infra/libs/pipeline-infra-stage.ts +34 -0
- package/templates/infra/libs/pipeline-stack.ts +115 -0
- package/templates/infra/package.json +33 -0
- package/templates/infra/test/.gitkeep +0 -0
- package/templates/infra/tsconfig.json +23 -0
- package/templates/jest.config.json +19 -0
- package/templates/package.json +20 -30
- package/templates/jest.config.js +0 -4
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { CfnOutput, Stage, StageProps } from 'aws-cdk-lib'
|
|
2
|
+
import { Construct } from 'constructs'
|
|
3
|
+
import { InfraStack } from './infra-stack'
|
|
4
|
+
import { getConfig } from '../config'
|
|
5
|
+
import { Env } from '../config/type'
|
|
6
|
+
|
|
7
|
+
export interface PipelineInfraStageProps extends StageProps {
|
|
8
|
+
appEnv: Env
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export class PipelineInfraStage extends Stage {
|
|
12
|
+
public readonly userPoolId: CfnOutput
|
|
13
|
+
public readonly userPoolClientId: CfnOutput
|
|
14
|
+
public readonly graphqlApiUrl: CfnOutput
|
|
15
|
+
public readonly graphqlApiKey: CfnOutput
|
|
16
|
+
public readonly httpApiUrl: CfnOutput
|
|
17
|
+
public readonly httpDistributionDomain: CfnOutput
|
|
18
|
+
|
|
19
|
+
constructor(scope: Construct, id: string, props: PipelineInfraStageProps) {
|
|
20
|
+
super(scope, id, props)
|
|
21
|
+
|
|
22
|
+
const config = getConfig(props.appEnv)
|
|
23
|
+
const infraStack = new InfraStack(this, props.appEnv + 'InfraStack', {
|
|
24
|
+
config,
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
this.userPoolId = infraStack.userPoolId
|
|
28
|
+
this.userPoolClientId = infraStack.userPoolClientId
|
|
29
|
+
this.graphqlApiUrl = infraStack.graphqlApiUrl
|
|
30
|
+
this.graphqlApiKey = infraStack.graphqlApiKey
|
|
31
|
+
this.httpApiUrl = infraStack.httpApiUrl
|
|
32
|
+
this.httpDistributionDomain = infraStack.httpDistributionDomain
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { RemovalPolicy, Stack, StackProps } from 'aws-cdk-lib'
|
|
2
|
+
import { BuildSpec, ReportGroup } from 'aws-cdk-lib/aws-codebuild'
|
|
3
|
+
import {
|
|
4
|
+
CodeBuildStep,
|
|
5
|
+
CodePipeline,
|
|
6
|
+
CodePipelineSource,
|
|
7
|
+
ShellStep,
|
|
8
|
+
} from 'aws-cdk-lib/pipelines'
|
|
9
|
+
import { Construct } from 'constructs'
|
|
10
|
+
import {
|
|
11
|
+
GIT_CONNECTION_ARN,
|
|
12
|
+
GIT_REPO,
|
|
13
|
+
PIPELINE_NAME,
|
|
14
|
+
getConfig,
|
|
15
|
+
} from '../config'
|
|
16
|
+
import { Env } from '../config/type'
|
|
17
|
+
import { PipelineInfraStage } from './pipeline-infra-stage'
|
|
18
|
+
|
|
19
|
+
export interface PipelineStackProps extends StackProps {
|
|
20
|
+
envName: Env
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const mappingBranchName = {
|
|
24
|
+
dev: 'develop',
|
|
25
|
+
stg: 'staging',
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export class PipelineStack extends Stack {
|
|
29
|
+
constructor(scope: Construct, id: string, props?: PipelineStackProps) {
|
|
30
|
+
super(scope, id, props)
|
|
31
|
+
|
|
32
|
+
const env = props?.envName || 'dev'
|
|
33
|
+
|
|
34
|
+
const idName = env.charAt(0).toUpperCase() + env.slice(1)
|
|
35
|
+
const branchName =
|
|
36
|
+
mappingBranchName[env as keyof typeof mappingBranchName] || 'main'
|
|
37
|
+
|
|
38
|
+
const config = getConfig(env)
|
|
39
|
+
const name = config.appName
|
|
40
|
+
|
|
41
|
+
const prefix = `${env}-${name}-`
|
|
42
|
+
|
|
43
|
+
const unitTestReports = new ReportGroup(this, `${prefix}UnitTestReports`, {
|
|
44
|
+
reportGroupName: `${prefix}UnitTestReports`,
|
|
45
|
+
removalPolicy: RemovalPolicy.DESTROY,
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
const testStep = new CodeBuildStep(`${prefix}Test`, {
|
|
49
|
+
projectName: `${prefix}Test`,
|
|
50
|
+
installCommands: ['npm ci'],
|
|
51
|
+
commands: ['npm run test'],
|
|
52
|
+
primaryOutputDirectory: 'report',
|
|
53
|
+
partialBuildSpec: BuildSpec.fromObject({
|
|
54
|
+
reports: {
|
|
55
|
+
[unitTestReports.reportGroupArn]: {
|
|
56
|
+
files: ['unit.xml'],
|
|
57
|
+
'base-directory': 'report',
|
|
58
|
+
'discard-paths': true,
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
}),
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
const pipeline = new CodePipeline(this, idName + 'PipelineV3', {
|
|
65
|
+
selfMutation: true,
|
|
66
|
+
synth: new ShellStep('Synth', {
|
|
67
|
+
input: CodePipelineSource.connection(GIT_REPO, branchName, {
|
|
68
|
+
connectionArn: GIT_CONNECTION_ARN,
|
|
69
|
+
}),
|
|
70
|
+
additionalInputs: {
|
|
71
|
+
testOut: testStep,
|
|
72
|
+
},
|
|
73
|
+
commands: [
|
|
74
|
+
'cd infra',
|
|
75
|
+
'npm ci',
|
|
76
|
+
'npm run build',
|
|
77
|
+
'npx cdk synth ' + id + ' -e',
|
|
78
|
+
],
|
|
79
|
+
primaryOutputDirectory: 'infra/cdk.out',
|
|
80
|
+
}),
|
|
81
|
+
})
|
|
82
|
+
|
|
83
|
+
const infraPipelineStage = new PipelineInfraStage(
|
|
84
|
+
this,
|
|
85
|
+
idName + PIPELINE_NAME + 'InfraStage',
|
|
86
|
+
{
|
|
87
|
+
appEnv: env,
|
|
88
|
+
env: { account: this.account, region: this.region },
|
|
89
|
+
},
|
|
90
|
+
)
|
|
91
|
+
|
|
92
|
+
const infraStage = pipeline.addStage(infraPipelineStage)
|
|
93
|
+
infraStage.addPost(
|
|
94
|
+
new ShellStep('validate', {
|
|
95
|
+
envFromCfnOutputs: {
|
|
96
|
+
OUTPUT_HTTP_API_URL: infraPipelineStage.httpApiUrl,
|
|
97
|
+
OUTPUT_GRAPHQL_API_URL: infraPipelineStage.graphqlApiUrl,
|
|
98
|
+
OUTPUT_GRAPHQL_API_KEY: infraPipelineStage.graphqlApiKey,
|
|
99
|
+
OUTPUT_USER_POOL_ID: infraPipelineStage.userPoolId,
|
|
100
|
+
OUTPUT_HTTP_DISTRIBUTION_DOMAIN:
|
|
101
|
+
infraPipelineStage.httpDistributionDomain,
|
|
102
|
+
},
|
|
103
|
+
commands: [
|
|
104
|
+
'echo $OUTPUT_HTTP_API_URL',
|
|
105
|
+
'echo $OUTPUT_GRAPHQL_API_URL',
|
|
106
|
+
'echo $OUTPUT_GRAPHQL_API_KEY',
|
|
107
|
+
'echo $OUTPUT_USER_POOL_ID',
|
|
108
|
+
'echo $OUTPUT_HTTP_DISTRIBUTION_DOMAIN',
|
|
109
|
+
],
|
|
110
|
+
}),
|
|
111
|
+
)
|
|
112
|
+
pipeline.buildPipeline()
|
|
113
|
+
unitTestReports.grantWrite(testStep.grantPrincipal)
|
|
114
|
+
}
|
|
115
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "infra",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"bin": {
|
|
5
|
+
"infra": "bin/infra.js"
|
|
6
|
+
},
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "tsc",
|
|
9
|
+
"watch": "tsc -w",
|
|
10
|
+
"test": "jest",
|
|
11
|
+
"cdk": "cdk"
|
|
12
|
+
},
|
|
13
|
+
"devDependencies": {
|
|
14
|
+
"@types/jest": "^29.5.10",
|
|
15
|
+
"@types/node": "^20.9.4",
|
|
16
|
+
"aws-cdk": "^2.147.0",
|
|
17
|
+
"jest": "^29.7.0",
|
|
18
|
+
"prettier": "^3.1.0",
|
|
19
|
+
"ts-jest": "^29.1.1",
|
|
20
|
+
"ts-node": "^10.9.1",
|
|
21
|
+
"typescript": "^5.3.2"
|
|
22
|
+
},
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"@aws-cdk/aws-apigatewayv2-alpha": "^2.114.1-alpha.0",
|
|
25
|
+
"@aws-cdk/aws-apigatewayv2-authorizers-alpha": "^2.114.1-alpha.0",
|
|
26
|
+
"@aws-cdk/aws-apigatewayv2-integrations-alpha": "^2.114.1-alpha.0",
|
|
27
|
+
"aws-cdk-lib": "^2.147.0",
|
|
28
|
+
"cdk-ecr-deployment": "^3.0.71",
|
|
29
|
+
"constructs": "^10.3.0",
|
|
30
|
+
"dotenv": "^16.3.1",
|
|
31
|
+
"source-map-support": "^0.5.21"
|
|
32
|
+
}
|
|
33
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2020",
|
|
4
|
+
"module": "commonjs",
|
|
5
|
+
"lib": ["es2020", "dom"],
|
|
6
|
+
"declaration": false,
|
|
7
|
+
"strict": true,
|
|
8
|
+
"noImplicitAny": true,
|
|
9
|
+
"strictNullChecks": true,
|
|
10
|
+
"noImplicitThis": true,
|
|
11
|
+
"alwaysStrict": true,
|
|
12
|
+
"noUnusedLocals": false,
|
|
13
|
+
"noUnusedParameters": false,
|
|
14
|
+
"noImplicitReturns": true,
|
|
15
|
+
"noFallthroughCasesInSwitch": false,
|
|
16
|
+
"inlineSourceMap": true,
|
|
17
|
+
"inlineSources": true,
|
|
18
|
+
"experimentalDecorators": true,
|
|
19
|
+
"strictPropertyInitialization": false,
|
|
20
|
+
"typeRoots": ["./node_modules/@types"]
|
|
21
|
+
},
|
|
22
|
+
"exclude": ["node_modules", "cdk.out"]
|
|
23
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"moduleFileExtensions": ["js", "json", "ts"],
|
|
3
|
+
"rootDir": ".",
|
|
4
|
+
"testEnvironment": "node",
|
|
5
|
+
"testRegex": "\\.spec\\.ts$",
|
|
6
|
+
"transform": {
|
|
7
|
+
"^.+\\.(t|j)s$": "ts-jest"
|
|
8
|
+
},
|
|
9
|
+
"moduleNameMapper": {
|
|
10
|
+
"^test/(.*)$": "<rootDir>/test/$1",
|
|
11
|
+
"^src/(.*)$": "<rootDir>/src/$1"
|
|
12
|
+
},
|
|
13
|
+
"modulePathIgnorePatterns": ["infra"],
|
|
14
|
+
"passWithNoTests": true,
|
|
15
|
+
"reporters": [
|
|
16
|
+
"default",
|
|
17
|
+
["jest-junit", { "outputDirectory": "report", "outputName": "unit.xml" }]
|
|
18
|
+
]
|
|
19
|
+
}
|
package/templates/package.json
CHANGED
|
@@ -11,7 +11,10 @@
|
|
|
11
11
|
"build": "nest build --watch",
|
|
12
12
|
"build:prod": "nest build",
|
|
13
13
|
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
|
|
14
|
+
"start": "nest start",
|
|
15
|
+
"start:dev": "nest start --watch",
|
|
14
16
|
"start:repl": "nest start --watch --entryFile repl",
|
|
17
|
+
"start:prod": "node dist/main",
|
|
15
18
|
"offline:docker:build": "run-script-os",
|
|
16
19
|
"offline:docker:build:default": "cd infra-local && docker compose up --build --remove-orphans",
|
|
17
20
|
"offline:docker:build:win32": "powershell -Command \"Set-Location infra-local; docker compose up --build --remove-orphans\"",
|
|
@@ -37,21 +40,10 @@
|
|
|
37
40
|
},
|
|
38
41
|
"dependencies": {
|
|
39
42
|
"@mbc-cqrs-serverless/core": "",
|
|
40
|
-
"@prisma/client": "^5.7.1"
|
|
43
|
+
"@prisma/client": "^5.7.1",
|
|
44
|
+
"prisma": "^5.7.1"
|
|
41
45
|
},
|
|
42
46
|
"devDependencies": {
|
|
43
|
-
"@aws-sdk/client-dynamodb": "^3.478.0",
|
|
44
|
-
"@aws-sdk/client-s3": "^3.478.0",
|
|
45
|
-
"@aws-sdk/client-sesv2": "^3.478.0",
|
|
46
|
-
"@aws-sdk/client-sfn": "^3.478.0",
|
|
47
|
-
"@aws-sdk/client-sns": "^3.478.0",
|
|
48
|
-
"@aws-sdk/client-sqs": "^3.478.0",
|
|
49
|
-
"@aws-sdk/credential-provider-node": "^3.451.0",
|
|
50
|
-
"@aws-sdk/lib-storage": "^3.478.0",
|
|
51
|
-
"@aws-sdk/s3-request-presigner": "^3.478.0",
|
|
52
|
-
"@aws-sdk/signature-v4": "^3.374.0",
|
|
53
|
-
"@aws-sdk/util-create-request": "^3.468.0",
|
|
54
|
-
"@aws-sdk/util-dynamodb": "^3.360.0",
|
|
55
47
|
"@mbc-cqrs-serverless/cli": "",
|
|
56
48
|
"@nestjs/cli": "^10.2.1",
|
|
57
49
|
"@nestjs/common": "^10.3.0",
|
|
@@ -76,9 +68,9 @@
|
|
|
76
68
|
"eslint-plugin-prettier": "^5.1.2",
|
|
77
69
|
"eslint-plugin-simple-import-sort": "^10.0.0",
|
|
78
70
|
"jest": "^29.7.0",
|
|
71
|
+
"jest-junit": "^16.0.0",
|
|
79
72
|
"nestjs-spelunker": "^1.3.0",
|
|
80
73
|
"prettier": "^3.1.1",
|
|
81
|
-
"prisma": "^5.7.1",
|
|
82
74
|
"run-script-os": "^1.1.6",
|
|
83
75
|
"serverless": "^3.38.0",
|
|
84
76
|
"serverless-dynamodb": "^0.2.47",
|
|
@@ -109,21 +101,19 @@
|
|
|
109
101
|
"ulid": "^2.3.0",
|
|
110
102
|
"webpack": "^5.88.2"
|
|
111
103
|
},
|
|
112
|
-
"
|
|
113
|
-
"
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
"
|
|
119
|
-
"
|
|
120
|
-
"
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
"
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
"coverageDirectory": "../coverage",
|
|
127
|
-
"testEnvironment": "node"
|
|
104
|
+
"optionalDependencies": {
|
|
105
|
+
"@aws-sdk/client-dynamodb": "^3.606.0",
|
|
106
|
+
"@aws-sdk/client-s3": "^3.608.0",
|
|
107
|
+
"@aws-sdk/client-sesv2": "^3.608.0",
|
|
108
|
+
"@aws-sdk/client-sfn": "^3.606.0",
|
|
109
|
+
"@aws-sdk/client-sns": "^3.606.0",
|
|
110
|
+
"@aws-sdk/client-sqs": "^3.606.0",
|
|
111
|
+
"@aws-sdk/client-ssm": "^3.606.0",
|
|
112
|
+
"@aws-sdk/credential-provider-node": "^3.600.0",
|
|
113
|
+
"@aws-sdk/lib-storage": "^3.608.0",
|
|
114
|
+
"@aws-sdk/s3-request-presigner": "^3.608.0",
|
|
115
|
+
"@aws-sdk/signature-v4": "^3.374.0",
|
|
116
|
+
"@aws-sdk/util-create-request": "^3.598.0",
|
|
117
|
+
"@aws-sdk/util-dynamodb": "^3.606.0"
|
|
128
118
|
}
|
|
129
119
|
}
|
package/templates/jest.config.js
DELETED