@byaga/cdk-patterns 0.11.0 → 0.11.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/lib/create-stack.d.ts +3 -0
- package/lib/create-stack.js +2 -0
- package/lib/index.d.ts +2 -1
- package/lib/load-configuration.d.ts +12 -0
- package/lib/load-configuration.js +42 -0
- package/package.json +4 -3
package/lib/create-stack.d.ts
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
import { IConstruct } from "constructs";
|
2
2
|
import { Stack } from "aws-cdk-lib";
|
3
3
|
import { StackProps } from "aws-cdk-lib/core";
|
4
|
+
import { StackConfiguration } from "./load-configuration";
|
4
5
|
/**
|
5
6
|
* Interface for the arguments when creating a stack.
|
6
7
|
*/
|
@@ -10,6 +11,7 @@ export interface StackArguments extends StackProps {
|
|
10
11
|
project: string;
|
11
12
|
owner: string;
|
12
13
|
region: string;
|
14
|
+
config: StackConfiguration;
|
13
15
|
}
|
14
16
|
/**
|
15
17
|
* Interface for the deploy stack.
|
@@ -19,6 +21,7 @@ export interface DeployStack {
|
|
19
21
|
name: string;
|
20
22
|
stage: string;
|
21
23
|
project: string;
|
24
|
+
config: StackConfiguration;
|
22
25
|
}
|
23
26
|
/**
|
24
27
|
* Creates a new stack.
|
package/lib/create-stack.js
CHANGED
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.setCurrentStack = exports.getCurrentStack = exports.createStack = void 0;
|
4
4
|
const aws_cdk_lib_1 = require("aws-cdk-lib");
|
5
5
|
const generate_identifier_1 = require("./generate-identifier");
|
6
|
+
const load_configuration_1 = require("./load-configuration");
|
6
7
|
/**
|
7
8
|
* Creates a new stack.
|
8
9
|
* @param {IConstruct} scope - The scope in which to define this construct.
|
@@ -24,6 +25,7 @@ function createStack(scope, props) {
|
|
24
25
|
name: props.stackName,
|
25
26
|
stage,
|
26
27
|
project: props.project,
|
28
|
+
config: (0, load_configuration_1.loadConfiguration)(stage)
|
27
29
|
});
|
28
30
|
}
|
29
31
|
exports.createStack = createStack;
|
package/lib/index.d.ts
CHANGED
@@ -2,6 +2,7 @@ export { buildNodeSource } from './build/nodejs/build-node-source';
|
|
2
2
|
export { buildEcmaScript } from './build/nodejs/build-ecmascript';
|
3
3
|
export { buildTypeScript } from './build/nodejs/build-typescript';
|
4
4
|
export { createNodeJsLambda } from './lambda/create-nodejs-lambda';
|
5
|
-
export { createStack } from './create-stack';
|
5
|
+
export { createStack, StackArguments } from './create-stack';
|
6
|
+
export { StackConfiguration } from './load-configuration';
|
6
7
|
export { genName, genId, genStackResourceName, genStackResourceId } from './generate-identifier';
|
7
8
|
export * as ssm from "./ssm";
|
@@ -0,0 +1,12 @@
|
|
1
|
+
/**
|
2
|
+
* Interface for the stack configuration.
|
3
|
+
*/
|
4
|
+
export interface StackConfiguration {
|
5
|
+
}
|
6
|
+
/**
|
7
|
+
* Loads the configuration for a given stage.
|
8
|
+
* If the configuration file does not exist, an empty object is returned.
|
9
|
+
* @param {string} stage - The stage for which to load the configuration. Defaults to the value of the STAGE environment variable, or "develop" if STAGE is not set.
|
10
|
+
* @returns {StackConfiguration} The loaded configuration.
|
11
|
+
*/
|
12
|
+
export declare function loadConfiguration(stage?: string): StackConfiguration;
|
@@ -0,0 +1,42 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
+
if (k2 === undefined) k2 = k;
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
7
|
+
}
|
8
|
+
Object.defineProperty(o, k2, desc);
|
9
|
+
}) : (function(o, m, k, k2) {
|
10
|
+
if (k2 === undefined) k2 = k;
|
11
|
+
o[k2] = m[k];
|
12
|
+
}));
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
15
|
+
}) : function(o, v) {
|
16
|
+
o["default"] = v;
|
17
|
+
});
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
19
|
+
if (mod && mod.__esModule) return mod;
|
20
|
+
var result = {};
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
22
|
+
__setModuleDefault(result, mod);
|
23
|
+
return result;
|
24
|
+
};
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
26
|
+
exports.loadConfiguration = void 0;
|
27
|
+
const yaml = __importStar(require("js-yaml"));
|
28
|
+
const fs = __importStar(require("fs-extra"));
|
29
|
+
/**
|
30
|
+
* Loads the configuration for a given stage.
|
31
|
+
* If the configuration file does not exist, an empty object is returned.
|
32
|
+
* @param {string} stage - The stage for which to load the configuration. Defaults to the value of the STAGE environment variable, or "develop" if STAGE is not set.
|
33
|
+
* @returns {StackConfiguration} The loaded configuration.
|
34
|
+
*/
|
35
|
+
function loadConfiguration(stage = process.env.STAGE || "develop") {
|
36
|
+
const path = `config/${stage}.yml`;
|
37
|
+
if (fs.existsSync(path)) {
|
38
|
+
return yaml.load(fs.readFileSync(`config/${stage}.yml`).toString());
|
39
|
+
}
|
40
|
+
return {};
|
41
|
+
}
|
42
|
+
exports.loadConfiguration = loadConfiguration;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@byaga/cdk-patterns",
|
3
|
-
"version": "0.11.
|
3
|
+
"version": "0.11.1",
|
4
4
|
"description": "Collection of common patterns used when making AWS CloudFormation templates using CDK",
|
5
5
|
"main": "./lib/index.js",
|
6
6
|
"types": "./lib/index.d.ts",
|
@@ -24,12 +24,14 @@
|
|
24
24
|
"constructs": "^10.3.0",
|
25
25
|
"fs-extra": "^11.2.0",
|
26
26
|
"glob": "^10.3.10",
|
27
|
-
"ignore": "^5.3.0"
|
27
|
+
"ignore": "^5.3.0",
|
28
|
+
"js-yaml": "^4.1.0"
|
28
29
|
},
|
29
30
|
"devDependencies": {
|
30
31
|
"@types/fs-extra": "^11.0.4",
|
31
32
|
"@types/glob": "^8.1.0",
|
32
33
|
"@types/jest": "^29.5.11",
|
34
|
+
"@types/js-yaml": "^4.0.9",
|
33
35
|
"@types/node": "^20.11.5",
|
34
36
|
"@typescript-eslint/eslint-plugin": "^6.19.0",
|
35
37
|
"@typescript-eslint/parser": "^6.19.0",
|
@@ -38,7 +40,6 @@
|
|
38
40
|
"jest-html-reporters": "^3.1.7",
|
39
41
|
"jest-junit": "^16.0.0",
|
40
42
|
"ts-jest": "^29.1.1",
|
41
|
-
"ts-mockito": "^2.6.1",
|
42
43
|
"typescript": "^5.3.3"
|
43
44
|
},
|
44
45
|
"repository": {
|