@goldstack/infra 0.3.38 → 0.4.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.
@@ -1,13 +1,13 @@
1
- import { DeploymentsState, DeploymentState } from './types/deploymentStatesTypes';
2
- export declare const validateDeploymentsState: (deploymentsState: any) => DeploymentsState;
3
- export declare const hasDeploymentsState: (packageDir: string) => boolean;
4
- export interface ReadDeploymentsStateOptions {
5
- createIfNotExist: boolean;
6
- }
7
- export declare const readDeploymentsState: (packageDir: string, options?: ReadDeploymentsStateOptions) => DeploymentsState;
8
- export declare const getDeploymentState: (deploymentsState: DeploymentsState, deploymentName: string, options?: ReadDeploymentsStateOptions) => DeploymentState;
9
- export declare const readDeploymentState: (packageDir: string, deploymentName: string, options?: ReadDeploymentsStateOptions) => DeploymentState;
10
- export declare const writeDeploymentsState: (packageDir: string, deploymentsState: DeploymentsState) => void;
11
- export declare const writeDeploymentState: (packageDir: string, deploymentState: DeploymentState) => void;
12
- export declare const readTerraformStateVariable: (deploymentState: DeploymentState, variableName: string) => any;
1
+ import { DeploymentsState, DeploymentState } from './types/deploymentStatesTypes';
2
+ export declare const validateDeploymentsState: (deploymentsState: any) => DeploymentsState;
3
+ export declare const hasDeploymentsState: (packageDir: string) => boolean;
4
+ export interface ReadDeploymentsStateOptions {
5
+ createIfNotExist: boolean;
6
+ }
7
+ export declare const readDeploymentsState: (packageDir: string, options?: ReadDeploymentsStateOptions) => DeploymentsState;
8
+ export declare const getDeploymentState: (deploymentsState: DeploymentsState, deploymentName: string, options?: ReadDeploymentsStateOptions) => DeploymentState;
9
+ export declare const readDeploymentState: (packageDir: string, deploymentName: string, options?: ReadDeploymentsStateOptions) => DeploymentState;
10
+ export declare const writeDeploymentsState: (packageDir: string, deploymentsState: DeploymentsState) => void;
11
+ export declare const writeDeploymentState: (packageDir: string, deploymentState: DeploymentState) => void;
12
+ export declare const readTerraformStateVariable: (deploymentState: DeploymentState, variableName: string) => any;
13
13
  //# sourceMappingURL=deploymentState.d.ts.map
@@ -1,89 +1,89 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.readTerraformStateVariable = exports.writeDeploymentState = exports.writeDeploymentsState = exports.readDeploymentState = exports.getDeploymentState = exports.readDeploymentsState = exports.hasDeploymentsState = exports.validateDeploymentsState = void 0;
7
- const utils_sh_1 = require("@goldstack/utils-sh");
8
- const utils_config_1 = require("@goldstack/utils-config");
9
- const fs_1 = __importDefault(require("fs"));
10
- const deploymentsStateSchema_json_1 = __importDefault(require("./schemas/deploymentsStateSchema.json"));
11
- const path_1 = __importDefault(require("path"));
12
- const deploymentsStatePath = 'src/state/deployments.json';
13
- const validateDeploymentsState = (
14
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
15
- deploymentsState) => {
16
- return (0, utils_config_1.validateConfig)(deploymentsState, deploymentsStateSchema_json_1.default, {
17
- errorMessage: 'Cannot validate deployments state.',
18
- });
19
- };
20
- exports.validateDeploymentsState = validateDeploymentsState;
21
- const hasDeploymentsState = (packageDir) => {
22
- return fs_1.default.existsSync(packageDir + deploymentsStatePath);
23
- };
24
- exports.hasDeploymentsState = hasDeploymentsState;
25
- const readDeploymentsState = (packageDir, options) => {
26
- if (!(0, exports.hasDeploymentsState)(packageDir)) {
27
- if (options && options.createIfNotExist) {
28
- return [];
29
- }
30
- throw new Error(`Deployments state does not exist in ${path_1.default.resolve(packageDir + deploymentsStatePath)}. Have you deployed this package yet?`);
31
- }
32
- const data = JSON.parse((0, utils_sh_1.read)(packageDir + deploymentsStatePath));
33
- return (0, exports.validateDeploymentsState)(data);
34
- };
35
- exports.readDeploymentsState = readDeploymentsState;
36
- const getDeploymentState = (deploymentsState, deploymentName, options) => {
37
- const deploymentState = deploymentsState.find((deploymentState) => deploymentState.name === deploymentName);
38
- if (!deploymentState) {
39
- if (options && options.createIfNotExist) {
40
- return {
41
- name: deploymentName,
42
- };
43
- }
44
- throw new Error(`Deployment state not defined for deployment '${deploymentName}'. Did you already deploy this deployment?`);
45
- }
46
- return deploymentState;
47
- };
48
- exports.getDeploymentState = getDeploymentState;
49
- const readDeploymentState = (packageDir, deploymentName, options) => {
50
- const deploymentsState = (0, exports.readDeploymentsState)(packageDir, options);
51
- return (0, exports.getDeploymentState)(deploymentsState, deploymentName, options);
52
- };
53
- exports.readDeploymentState = readDeploymentState;
54
- const writeDeploymentsState = (packageDir, deploymentsState) => {
55
- (0, utils_sh_1.write)(JSON.stringify(deploymentsState, null, 2), packageDir + deploymentsStatePath);
56
- };
57
- exports.writeDeploymentsState = writeDeploymentsState;
58
- const writeDeploymentState = (packageDir, deploymentState) => {
59
- let deploymentsState;
60
- if ((0, exports.hasDeploymentsState)(packageDir)) {
61
- deploymentsState = (0, exports.readDeploymentsState)(packageDir);
62
- }
63
- else {
64
- deploymentsState = [];
65
- }
66
- const idx = deploymentsState.findIndex((deployment) => deployment.name === deploymentState.name);
67
- if (idx === -1) {
68
- deploymentsState.push(deploymentState);
69
- }
70
- else {
71
- deploymentsState[idx] = deploymentState;
72
- }
73
- (0, exports.writeDeploymentsState)(packageDir, deploymentsState);
74
- };
75
- exports.writeDeploymentState = writeDeploymentState;
76
- const readTerraformStateVariable = (deploymentState, variableName
77
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
78
- ) => {
79
- if (!deploymentState.terraform) {
80
- throw new Error(`Terraform configuration not defined in deployment state for ${deploymentState.name}. Make sure to stand up the infrastructure for this module using 'yarn infra up'.`);
81
- }
82
- const tfVar = deploymentState.terraform[variableName];
83
- if (!tfVar) {
84
- throw new Error(`Terraform variable '${variableName}' not defined in deployment state.`);
85
- }
86
- return tfVar.value;
87
- };
88
- exports.readTerraformStateVariable = readTerraformStateVariable;
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.readTerraformStateVariable = exports.writeDeploymentState = exports.writeDeploymentsState = exports.readDeploymentState = exports.getDeploymentState = exports.readDeploymentsState = exports.hasDeploymentsState = exports.validateDeploymentsState = void 0;
7
+ const utils_sh_1 = require("@goldstack/utils-sh");
8
+ const utils_config_1 = require("@goldstack/utils-config");
9
+ const fs_1 = __importDefault(require("fs"));
10
+ const deploymentsStateSchema_json_1 = __importDefault(require("./schemas/deploymentsStateSchema.json"));
11
+ const path_1 = __importDefault(require("path"));
12
+ const deploymentsStatePath = 'src/state/deployments.json';
13
+ const validateDeploymentsState = (
14
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
15
+ deploymentsState) => {
16
+ return (0, utils_config_1.validateConfig)(deploymentsState, deploymentsStateSchema_json_1.default, {
17
+ errorMessage: 'Cannot validate deployments state.',
18
+ });
19
+ };
20
+ exports.validateDeploymentsState = validateDeploymentsState;
21
+ const hasDeploymentsState = (packageDir) => {
22
+ return fs_1.default.existsSync(packageDir + deploymentsStatePath);
23
+ };
24
+ exports.hasDeploymentsState = hasDeploymentsState;
25
+ const readDeploymentsState = (packageDir, options) => {
26
+ if (!(0, exports.hasDeploymentsState)(packageDir)) {
27
+ if (options && options.createIfNotExist) {
28
+ return [];
29
+ }
30
+ throw new Error(`Deployments state does not exist in ${path_1.default.resolve(packageDir + deploymentsStatePath)}. Have you deployed this package yet?`);
31
+ }
32
+ const data = JSON.parse((0, utils_sh_1.read)(packageDir + deploymentsStatePath));
33
+ return (0, exports.validateDeploymentsState)(data);
34
+ };
35
+ exports.readDeploymentsState = readDeploymentsState;
36
+ const getDeploymentState = (deploymentsState, deploymentName, options) => {
37
+ const deploymentState = deploymentsState.find((deploymentState) => deploymentState.name === deploymentName);
38
+ if (!deploymentState) {
39
+ if (options && options.createIfNotExist) {
40
+ return {
41
+ name: deploymentName,
42
+ };
43
+ }
44
+ throw new Error(`Deployment state not defined for deployment '${deploymentName}'. Did you already deploy this deployment?`);
45
+ }
46
+ return deploymentState;
47
+ };
48
+ exports.getDeploymentState = getDeploymentState;
49
+ const readDeploymentState = (packageDir, deploymentName, options) => {
50
+ const deploymentsState = (0, exports.readDeploymentsState)(packageDir, options);
51
+ return (0, exports.getDeploymentState)(deploymentsState, deploymentName, options);
52
+ };
53
+ exports.readDeploymentState = readDeploymentState;
54
+ const writeDeploymentsState = (packageDir, deploymentsState) => {
55
+ (0, utils_sh_1.write)(JSON.stringify(deploymentsState, null, 2), packageDir + deploymentsStatePath);
56
+ };
57
+ exports.writeDeploymentsState = writeDeploymentsState;
58
+ const writeDeploymentState = (packageDir, deploymentState) => {
59
+ let deploymentsState;
60
+ if ((0, exports.hasDeploymentsState)(packageDir)) {
61
+ deploymentsState = (0, exports.readDeploymentsState)(packageDir);
62
+ }
63
+ else {
64
+ deploymentsState = [];
65
+ }
66
+ const idx = deploymentsState.findIndex((deployment) => deployment.name === deploymentState.name);
67
+ if (idx === -1) {
68
+ deploymentsState.push(deploymentState);
69
+ }
70
+ else {
71
+ deploymentsState[idx] = deploymentState;
72
+ }
73
+ (0, exports.writeDeploymentsState)(packageDir, deploymentsState);
74
+ };
75
+ exports.writeDeploymentState = writeDeploymentState;
76
+ const readTerraformStateVariable = (deploymentState, variableName
77
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
78
+ ) => {
79
+ if (!deploymentState.terraform) {
80
+ throw new Error(`Terraform configuration not defined in deployment state for ${deploymentState.name}. Make sure to stand up the infrastructure for this module using 'yarn infra up'.`);
81
+ }
82
+ const tfVar = deploymentState.terraform[variableName];
83
+ if (!tfVar) {
84
+ throw new Error(`Terraform variable '${variableName}' not defined in deployment state.`);
85
+ }
86
+ return tfVar.value;
87
+ };
88
+ exports.readTerraformStateVariable = readTerraformStateVariable;
89
89
  //# sourceMappingURL=deploymentState.js.map
@@ -1,4 +1,4 @@
1
- export type { Deployment, DeploymentName, DeploymentConfiguration, } from './types/InfrastructureConfiguration';
2
- export type { DeploymentState, DeploymentsState, } from './types/deploymentStatesTypes';
3
- export * from './deploymentState';
1
+ export type { Deployment, DeploymentName, DeploymentConfiguration, } from './types/InfrastructureConfiguration';
2
+ export type { DeploymentState, DeploymentsState, } from './types/deploymentStatesTypes';
3
+ export * from './deploymentState';
4
4
  //# sourceMappingURL=infra.d.ts.map
package/dist/src/infra.js CHANGED
@@ -1,18 +1,18 @@
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./deploymentState"), exports);
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./deploymentState"), exports);
18
18
  //# sourceMappingURL=infra.js.map
@@ -1,29 +1,29 @@
1
- {
2
- "$ref": "#/definitions/DeploymentsState",
3
- "$schema": "http://json-schema.org/draft-07/schema#",
4
- "definitions": {
5
- "DeploymentState": {
6
- "properties": {
7
- "name": {
8
- "type": "string"
9
- },
10
- "terraform": {
11
- "$ref": "#/definitions/TerraformState"
12
- }
13
- },
14
- "required": [
15
- "name"
16
- ],
17
- "type": "object"
18
- },
19
- "DeploymentsState": {
20
- "items": {
21
- "$ref": "#/definitions/DeploymentState"
22
- },
23
- "type": "array"
24
- },
25
- "TerraformState": {
26
- "type": "object"
27
- }
28
- }
29
- }
1
+ {
2
+ "$ref": "#/definitions/DeploymentsState",
3
+ "$schema": "http://json-schema.org/draft-07/schema#",
4
+ "definitions": {
5
+ "DeploymentState": {
6
+ "properties": {
7
+ "name": {
8
+ "type": "string"
9
+ },
10
+ "terraform": {
11
+ "$ref": "#/definitions/TerraformState"
12
+ }
13
+ },
14
+ "required": [
15
+ "name"
16
+ ],
17
+ "type": "object"
18
+ },
19
+ "DeploymentsState": {
20
+ "items": {
21
+ "$ref": "#/definitions/DeploymentState"
22
+ },
23
+ "type": "array"
24
+ },
25
+ "TerraformState": {
26
+ "type": "object"
27
+ }
28
+ }
29
+ }
@@ -1,34 +1,34 @@
1
- {
2
- "$ref": "#/definitions/Deployment",
3
- "$schema": "http://json-schema.org/draft-07/schema#",
4
- "definitions": {
5
- "Deployment": {
6
- "description": "Configures a deployment.",
7
- "properties": {
8
- "configuration": {
9
- "$ref": "#/definitions/DeploymentConfiguration"
10
- },
11
- "name": {
12
- "$ref": "#/definitions/DeploymentName"
13
- }
14
- },
15
- "required": [
16
- "name",
17
- "configuration"
18
- ],
19
- "title": "Deployment",
20
- "type": "object"
21
- },
22
- "DeploymentConfiguration": {
23
- "description": "Specifies configuration for a specific deployment.",
24
- "title": "Deployment Configuration",
25
- "type": "object"
26
- },
27
- "DeploymentName": {
28
- "description": "Identifier for this deployment. No spaces allowed in name.",
29
- "pattern": "^[^\\s]*$",
30
- "title": "Deployment Name",
31
- "type": "string"
32
- }
33
- }
34
- }
1
+ {
2
+ "$ref": "#/definitions/Deployment",
3
+ "$schema": "http://json-schema.org/draft-07/schema#",
4
+ "definitions": {
5
+ "Deployment": {
6
+ "description": "Configures a deployment.",
7
+ "properties": {
8
+ "configuration": {
9
+ "$ref": "#/definitions/DeploymentConfiguration"
10
+ },
11
+ "name": {
12
+ "$ref": "#/definitions/DeploymentName"
13
+ }
14
+ },
15
+ "required": [
16
+ "name",
17
+ "configuration"
18
+ ],
19
+ "title": "Deployment",
20
+ "type": "object"
21
+ },
22
+ "DeploymentConfiguration": {
23
+ "description": "Specifies configuration for a specific deployment.",
24
+ "title": "Deployment Configuration",
25
+ "type": "object"
26
+ },
27
+ "DeploymentName": {
28
+ "description": "Identifier for this deployment. No spaces allowed in name.",
29
+ "pattern": "^[^\\s]*$",
30
+ "title": "Deployment Name",
31
+ "type": "string"
32
+ }
33
+ }
34
+ }
@@ -1,26 +1,26 @@
1
- /**
2
- * Identifier for this deployment. No spaces allowed in name.
3
- *
4
- * @title Deployment Name
5
- * @pattern ^[^\s]*$
6
- */
7
- export declare type DeploymentName = string;
8
- /**
9
- * Specifies configuration for a specific deployment.
10
- *
11
- * @title Deployment Configuration
12
- */
13
- export interface DeploymentConfiguration {
14
- [propName: string]: any;
15
- }
16
- /**
17
- * Configures a deployment.
18
- *
19
- * @title Deployment
20
- */
21
- export interface Deployment {
22
- name: DeploymentName;
23
- configuration: DeploymentConfiguration;
24
- [propName: string]: any;
25
- }
1
+ /**
2
+ * Identifier for this deployment. No spaces allowed in name.
3
+ *
4
+ * @title Deployment Name
5
+ * @pattern ^[^\s]*$
6
+ */
7
+ export declare type DeploymentName = string;
8
+ /**
9
+ * Specifies configuration for a specific deployment.
10
+ *
11
+ * @title Deployment Configuration
12
+ */
13
+ export interface DeploymentConfiguration {
14
+ [propName: string]: any;
15
+ }
16
+ /**
17
+ * Configures a deployment.
18
+ *
19
+ * @title Deployment
20
+ */
21
+ export interface Deployment {
22
+ name: DeploymentName;
23
+ configuration: DeploymentConfiguration;
24
+ [propName: string]: any;
25
+ }
26
26
  //# sourceMappingURL=InfrastructureConfiguration.d.ts.map
@@ -1,3 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  //# sourceMappingURL=InfrastructureConfiguration.js.map
@@ -1,10 +1,10 @@
1
- export interface TerraformState {
2
- [propName: string]: any;
3
- }
4
- export interface DeploymentState {
5
- name: string;
6
- terraform?: TerraformState;
7
- [propName: string]: any;
8
- }
9
- export declare type DeploymentsState = DeploymentState[];
1
+ export interface TerraformState {
2
+ [propName: string]: any;
3
+ }
4
+ export interface DeploymentState {
5
+ name: string;
6
+ terraform?: TerraformState;
7
+ [propName: string]: any;
8
+ }
9
+ export declare type DeploymentsState = DeploymentState[];
10
10
  //# sourceMappingURL=deploymentStatesTypes.d.ts.map
@@ -1,3 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  //# sourceMappingURL=deploymentStatesTypes.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@goldstack/infra",
3
- "version": "0.3.38",
3
+ "version": "0.4.0",
4
4
  "description": "Utilities for defining infrastructure for npm packages.",
5
5
  "keywords": [
6
6
  "goldstack",
@@ -37,14 +37,14 @@
37
37
  "version:apply:force": "yarn version $@ && yarn version apply"
38
38
  },
39
39
  "dependencies": {
40
- "@goldstack/utils-config": "0.3.35",
41
- "@goldstack/utils-log": "0.2.16",
42
- "@goldstack/utils-sh": "0.4.33"
40
+ "@goldstack/utils-config": "0.4.0",
41
+ "@goldstack/utils-log": "0.3.0",
42
+ "@goldstack/utils-sh": "0.5.0"
43
43
  },
44
44
  "devDependencies": {
45
- "@goldstack/utils-git": "0.1.36",
46
- "@types/jest": "^27.5.1",
47
- "@types/node": "^17.0.33",
45
+ "@goldstack/utils-git": "0.2.0",
46
+ "@types/jest": "^28.1.8",
47
+ "@types/node": "^18.7.13",
48
48
  "jest": "^28.1.0",
49
49
  "renamer": "^0.7.0",
50
50
  "rimraf": "^3.0.2",