@mbc-cqrs-serverless/cli 0.1.25-beta.0 → 0.1.27-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/package.json +2 -2
- package/templates/gitignore +3 -1
- package/templates/infra/.cdkgraphrc.js +3 -0
- package/templates/infra/bin/infra.ts +37 -42
- package/templates/infra/gitignore +5 -1
- package/templates/infra/jest.config.js +4 -0
- package/templates/infra/libs/build-app.ts +7 -4
- package/templates/infra/libs/pipeline-stack.ts +3 -3
- package/templates/infra/package.json +2 -0
- package/templates/infra/test/__snapshots__/infra.test.ts.snap +2392 -0
- package/templates/infra/test/infra.test.ts +81 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mbc-cqrs-serverless/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.27-beta.0",
|
|
4
4
|
"description": "a CLI to get started with MBC CQRS serverless framework",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"mbc",
|
|
@@ -49,5 +49,5 @@
|
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"@faker-js/faker": "^8.3.1"
|
|
51
51
|
},
|
|
52
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "34a52ba6d89eddb8724de7f0689a1c2d32b8d6a7"
|
|
53
53
|
}
|
package/templates/gitignore
CHANGED
|
@@ -1,47 +1,42 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import 'source-map-support/register'
|
|
3
2
|
import * as cdk from 'aws-cdk-lib'
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
// import * as dotenv from 'dotenv'
|
|
7
|
-
// import { Env } from '../config/type'
|
|
8
|
-
// import { getConfig } from '../config'
|
|
9
|
-
import { PipelineStack } from '../libs/pipeline-stack'
|
|
3
|
+
import 'source-map-support/register'
|
|
10
4
|
import { Env, PIPELINE_NAME } from '../config'
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
envName: env,
|
|
5
|
+
import { PipelineStack } from '../libs/pipeline-stack'
|
|
6
|
+
import { CdkGraph, FilterPreset } from '@aws/pdk/cdk-graph'
|
|
7
|
+
import { CdkGraphDiagramPlugin } from '@aws/pdk/cdk-graph-plugin-diagram'
|
|
8
|
+
;(async () => {
|
|
9
|
+
const app = new cdk.App()
|
|
10
|
+
|
|
11
|
+
const cdkEnv: cdk.Environment = {
|
|
12
|
+
account: '',
|
|
13
|
+
region: '',
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const envs: Env[] = ['dev']
|
|
17
|
+
|
|
18
|
+
for (const env of envs) {
|
|
19
|
+
new PipelineStack(app, env + '-' + PIPELINE_NAME + '-pipeline-stack', {
|
|
20
|
+
env: cdkEnv,
|
|
21
|
+
envName: env,
|
|
22
|
+
})
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const graph = new CdkGraph(app, {
|
|
26
|
+
plugins: [
|
|
27
|
+
new CdkGraphDiagramPlugin({
|
|
28
|
+
diagrams: [
|
|
29
|
+
{
|
|
30
|
+
name: 'diagram',
|
|
31
|
+
title: 'Infrastructure diagram',
|
|
32
|
+
theme: 'light',
|
|
33
|
+
},
|
|
34
|
+
],
|
|
35
|
+
}),
|
|
36
|
+
],
|
|
44
37
|
})
|
|
45
|
-
}
|
|
46
38
|
|
|
47
|
-
app.synth()
|
|
39
|
+
app.synth()
|
|
40
|
+
|
|
41
|
+
await graph.report()
|
|
42
|
+
})()
|
|
@@ -22,9 +22,9 @@ export function buildApp(env: Env, isLocal = false) {
|
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
const runCommand = function (cmd: string) {
|
|
25
|
+
const runCommand = function (cmd: string, cwdExec: string = cwd) {
|
|
26
26
|
console.log(cmd)
|
|
27
|
-
const ret = execSync(cmd, { cwd })
|
|
27
|
+
const ret = execSync(cmd, { cwd: cwdExec })
|
|
28
28
|
console.log(ret.toString())
|
|
29
29
|
}
|
|
30
30
|
|
|
@@ -48,11 +48,9 @@ export function buildApp(env: Env, isLocal = false) {
|
|
|
48
48
|
const prunePath = `${layerPath}/prune`
|
|
49
49
|
runCommand(`mkdir -p ${prunePath}`)
|
|
50
50
|
runCommand(`npm --prefix ./${prunePath} i node-prune modclean`)
|
|
51
|
-
runCommand(`npm --prefix ./${prunePath} exec node-prune`)
|
|
52
51
|
runCommand(
|
|
53
52
|
`npm --prefix ./${prunePath} exec modclean -- -n default:safe,default:caution -r`,
|
|
54
53
|
)
|
|
55
|
-
runCommand(`rm -rf ${prunePath}`)
|
|
56
54
|
runCommand(
|
|
57
55
|
'mv node_modules/.prisma/client/libquery_engine-linux-arm64-* prisma',
|
|
58
56
|
)
|
|
@@ -69,6 +67,11 @@ export function buildApp(env: Env, isLocal = false) {
|
|
|
69
67
|
runCommand(`mkdir -p ${nodejsLayerPath}`)
|
|
70
68
|
runCommand(`mv node_modules ${nodejsLayerPath}`)
|
|
71
69
|
|
|
70
|
+
// min size layer
|
|
71
|
+
console.log('============= min size layer =============')
|
|
72
|
+
runCommand(`npm --prefix ../prune exec node-prune`, `${layerFullPath}/nodejs`)
|
|
73
|
+
runCommand(`rm -rf ${prunePath}`)
|
|
74
|
+
|
|
72
75
|
console.log('============= build app finished =============')
|
|
73
76
|
|
|
74
77
|
if (isLocal) {
|
|
@@ -47,13 +47,13 @@ export class PipelineStack extends Stack {
|
|
|
47
47
|
|
|
48
48
|
const testStep = new CodeBuildStep(`${prefix}Test`, {
|
|
49
49
|
projectName: `${prefix}Test`,
|
|
50
|
-
installCommands: ['npm ci'],
|
|
51
|
-
commands: ['npm run test'],
|
|
50
|
+
installCommands: ['npm ci', 'npm --prefix ./infra ci'],
|
|
51
|
+
commands: ['npm run test', 'npm --prefix ./infra run test'],
|
|
52
52
|
primaryOutputDirectory: 'report',
|
|
53
53
|
partialBuildSpec: BuildSpec.fromObject({
|
|
54
54
|
reports: {
|
|
55
55
|
[unitTestReports.reportGroupArn]: {
|
|
56
|
-
files: ['
|
|
56
|
+
files: ['*.xml'],
|
|
57
57
|
'base-directory': 'report',
|
|
58
58
|
'discard-paths': true,
|
|
59
59
|
},
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
"@types/node": "^20.9.4",
|
|
16
16
|
"aws-cdk": "^2.147.0",
|
|
17
17
|
"jest": "^29.7.0",
|
|
18
|
+
"jest-junit": "^16.0.0",
|
|
18
19
|
"prettier": "^3.1.0",
|
|
19
20
|
"ts-jest": "^29.1.1",
|
|
20
21
|
"ts-node": "^10.9.1",
|
|
@@ -24,6 +25,7 @@
|
|
|
24
25
|
"@aws-cdk/aws-apigatewayv2-alpha": "^2.114.1-alpha.0",
|
|
25
26
|
"@aws-cdk/aws-apigatewayv2-authorizers-alpha": "^2.114.1-alpha.0",
|
|
26
27
|
"@aws-cdk/aws-apigatewayv2-integrations-alpha": "^2.114.1-alpha.0",
|
|
28
|
+
"@aws/pdk": "^0.25.7",
|
|
27
29
|
"aws-cdk-lib": "^2.147.0",
|
|
28
30
|
"cdk-ecr-deployment": "^3.0.71",
|
|
29
31
|
"constructs": "^10.3.0",
|