@goldstack/utils-package 0.4.0 → 0.4.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.
|
@@ -1,92 +1,92 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$ref": "#/definitions/Package",
|
|
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
|
-
"Name": {
|
|
34
|
-
"description": "Name of this package.",
|
|
35
|
-
"title": "Package Name",
|
|
36
|
-
"type": "string"
|
|
37
|
-
},
|
|
38
|
-
"Package": {
|
|
39
|
-
"additionalProperties": false,
|
|
40
|
-
"description": "Definition for a Goldstack Package.",
|
|
41
|
-
"properties": {
|
|
42
|
-
"$schema": {
|
|
43
|
-
"type": "string"
|
|
44
|
-
},
|
|
45
|
-
"configuration": {
|
|
46
|
-
"$ref": "#/definitions/PackageConfiguration"
|
|
47
|
-
},
|
|
48
|
-
"deployments": {
|
|
49
|
-
"items": {
|
|
50
|
-
"$ref": "#/definitions/Deployment"
|
|
51
|
-
},
|
|
52
|
-
"type": "array"
|
|
53
|
-
},
|
|
54
|
-
"name": {
|
|
55
|
-
"$ref": "#/definitions/Name"
|
|
56
|
-
},
|
|
57
|
-
"template": {
|
|
58
|
-
"$ref": "#/definitions/Template"
|
|
59
|
-
},
|
|
60
|
-
"templateVersion": {
|
|
61
|
-
"$ref": "#/definitions/TemplateVersion"
|
|
62
|
-
}
|
|
63
|
-
},
|
|
64
|
-
"required": [
|
|
65
|
-
"template",
|
|
66
|
-
"templateVersion",
|
|
67
|
-
"name",
|
|
68
|
-
"configuration",
|
|
69
|
-
"deployments",
|
|
70
|
-
"$schema"
|
|
71
|
-
],
|
|
72
|
-
"title": "Package",
|
|
73
|
-
"type": "object"
|
|
74
|
-
},
|
|
75
|
-
"PackageConfiguration": {
|
|
76
|
-
"description": "Configuration of this package",
|
|
77
|
-
"title": "Configuration",
|
|
78
|
-
"type": "object"
|
|
79
|
-
},
|
|
80
|
-
"Template": {
|
|
81
|
-
"description": "Name of the template used for creating this package.",
|
|
82
|
-
"pattern": "^[^\\s]*$",
|
|
83
|
-
"title": "Template",
|
|
84
|
-
"type": "string"
|
|
85
|
-
},
|
|
86
|
-
"TemplateVersion": {
|
|
87
|
-
"description": "Latest template version that was applied to this package.",
|
|
88
|
-
"title": "Template Version",
|
|
89
|
-
"type": "string"
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"$ref": "#/definitions/Package",
|
|
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
|
+
"Name": {
|
|
34
|
+
"description": "Name of this package.",
|
|
35
|
+
"title": "Package Name",
|
|
36
|
+
"type": "string"
|
|
37
|
+
},
|
|
38
|
+
"Package": {
|
|
39
|
+
"additionalProperties": false,
|
|
40
|
+
"description": "Definition for a Goldstack Package.",
|
|
41
|
+
"properties": {
|
|
42
|
+
"$schema": {
|
|
43
|
+
"type": "string"
|
|
44
|
+
},
|
|
45
|
+
"configuration": {
|
|
46
|
+
"$ref": "#/definitions/PackageConfiguration"
|
|
47
|
+
},
|
|
48
|
+
"deployments": {
|
|
49
|
+
"items": {
|
|
50
|
+
"$ref": "#/definitions/Deployment"
|
|
51
|
+
},
|
|
52
|
+
"type": "array"
|
|
53
|
+
},
|
|
54
|
+
"name": {
|
|
55
|
+
"$ref": "#/definitions/Name"
|
|
56
|
+
},
|
|
57
|
+
"template": {
|
|
58
|
+
"$ref": "#/definitions/Template"
|
|
59
|
+
},
|
|
60
|
+
"templateVersion": {
|
|
61
|
+
"$ref": "#/definitions/TemplateVersion"
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
"required": [
|
|
65
|
+
"template",
|
|
66
|
+
"templateVersion",
|
|
67
|
+
"name",
|
|
68
|
+
"configuration",
|
|
69
|
+
"deployments",
|
|
70
|
+
"$schema"
|
|
71
|
+
],
|
|
72
|
+
"title": "Package",
|
|
73
|
+
"type": "object"
|
|
74
|
+
},
|
|
75
|
+
"PackageConfiguration": {
|
|
76
|
+
"description": "Configuration of this package",
|
|
77
|
+
"title": "Configuration",
|
|
78
|
+
"type": "object"
|
|
79
|
+
},
|
|
80
|
+
"Template": {
|
|
81
|
+
"description": "Name of the template used for creating this package.",
|
|
82
|
+
"pattern": "^[^\\s]*$",
|
|
83
|
+
"title": "Template",
|
|
84
|
+
"type": "string"
|
|
85
|
+
},
|
|
86
|
+
"TemplateVersion": {
|
|
87
|
+
"description": "Latest template version that was applied to this package.",
|
|
88
|
+
"title": "Template Version",
|
|
89
|
+
"type": "string"
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
import { Deployment } from '@goldstack/infra';
|
|
2
|
-
/**
|
|
3
|
-
* Name of the template used for creating this package.
|
|
4
|
-
*
|
|
5
|
-
* @title Template
|
|
6
|
-
* @pattern ^[^\s]*$
|
|
7
|
-
*/
|
|
8
|
-
export declare type Template = string;
|
|
9
|
-
/**
|
|
10
|
-
* Latest template version that was applied to this package.
|
|
11
|
-
*
|
|
12
|
-
* @title Template Version
|
|
13
|
-
*/
|
|
14
|
-
export declare type TemplateVersion = string;
|
|
15
|
-
/**
|
|
16
|
-
* Name of this package.
|
|
17
|
-
*
|
|
18
|
-
* @title Package Name
|
|
19
|
-
*/
|
|
20
|
-
export declare type Name = string;
|
|
21
|
-
/**
|
|
22
|
-
* Configuration of this package
|
|
23
|
-
*
|
|
24
|
-
* @title Configuration
|
|
25
|
-
*/
|
|
26
|
-
export interface PackageConfiguration {
|
|
27
|
-
[propName: string]: any;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Definition for a Goldstack Package.
|
|
31
|
-
*
|
|
32
|
-
* @title Package
|
|
33
|
-
*/
|
|
34
|
-
export interface Package {
|
|
35
|
-
template: Template;
|
|
36
|
-
templateVersion: TemplateVersion;
|
|
37
|
-
name: Name;
|
|
38
|
-
configuration: PackageConfiguration;
|
|
39
|
-
deployments: Deployment[];
|
|
40
|
-
$schema: string;
|
|
41
|
-
}
|
|
1
|
+
import { Deployment } from '@goldstack/infra';
|
|
2
|
+
/**
|
|
3
|
+
* Name of the template used for creating this package.
|
|
4
|
+
*
|
|
5
|
+
* @title Template
|
|
6
|
+
* @pattern ^[^\s]*$
|
|
7
|
+
*/
|
|
8
|
+
export declare type Template = string;
|
|
9
|
+
/**
|
|
10
|
+
* Latest template version that was applied to this package.
|
|
11
|
+
*
|
|
12
|
+
* @title Template Version
|
|
13
|
+
*/
|
|
14
|
+
export declare type TemplateVersion = string;
|
|
15
|
+
/**
|
|
16
|
+
* Name of this package.
|
|
17
|
+
*
|
|
18
|
+
* @title Package Name
|
|
19
|
+
*/
|
|
20
|
+
export declare type Name = string;
|
|
21
|
+
/**
|
|
22
|
+
* Configuration of this package
|
|
23
|
+
*
|
|
24
|
+
* @title Configuration
|
|
25
|
+
*/
|
|
26
|
+
export interface PackageConfiguration {
|
|
27
|
+
[propName: string]: any;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Definition for a Goldstack Package.
|
|
31
|
+
*
|
|
32
|
+
* @title Package
|
|
33
|
+
*/
|
|
34
|
+
export interface Package {
|
|
35
|
+
template: Template;
|
|
36
|
+
templateVersion: TemplateVersion;
|
|
37
|
+
name: Name;
|
|
38
|
+
configuration: PackageConfiguration;
|
|
39
|
+
deployments: Deployment[];
|
|
40
|
+
$schema: string;
|
|
41
|
+
}
|
|
42
42
|
//# sourceMappingURL=packageTypes.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=packageTypes.js.map
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { Package } from './types/packageTypes';
|
|
2
|
-
import { Argv } from 'yargs';
|
|
3
|
-
export type { Package, PackageConfiguration as Configuration, Name, } from './types/packageTypes';
|
|
4
|
-
export declare const getPackageConfigSchema: () => object;
|
|
5
|
-
export declare const writePackageConfig: (packageConfig: Package, packagePath?: string) => void;
|
|
6
|
-
export declare const readPackageConfig: (packagePath?: string) => Package;
|
|
7
|
-
export declare const readPackageConfigFromDir: (dir: string) => Package;
|
|
8
|
-
interface BuildCliParams {
|
|
9
|
-
yargs: Argv<any>;
|
|
10
|
-
infraCommands: (yargs: Argv<any>) => void;
|
|
11
|
-
deployCommands: (yargs: Argv<any>) => void;
|
|
12
|
-
}
|
|
13
|
-
export declare const buildCli: (params: BuildCliParams) => Argv<any>;
|
|
14
|
-
export declare const buildDeployCommands: () => (yargs: Argv<any>) => Argv<any>;
|
|
1
|
+
import { Package } from './types/packageTypes';
|
|
2
|
+
import { Argv } from 'yargs';
|
|
3
|
+
export type { Package, PackageConfiguration as Configuration, Name, } from './types/packageTypes';
|
|
4
|
+
export declare const getPackageConfigSchema: () => object;
|
|
5
|
+
export declare const writePackageConfig: (packageConfig: Package, packagePath?: string) => void;
|
|
6
|
+
export declare const readPackageConfig: (packagePath?: string) => Package;
|
|
7
|
+
export declare const readPackageConfigFromDir: (dir: string) => Package;
|
|
8
|
+
interface BuildCliParams {
|
|
9
|
+
yargs: Argv<any>;
|
|
10
|
+
infraCommands: (yargs: Argv<any>) => void;
|
|
11
|
+
deployCommands: (yargs: Argv<any>) => void;
|
|
12
|
+
}
|
|
13
|
+
export declare const buildCli: (params: BuildCliParams) => Argv<any>;
|
|
14
|
+
export declare const buildDeployCommands: () => (yargs: Argv<any>) => Argv<any>;
|
|
15
15
|
//# sourceMappingURL=utilsPackage.d.ts.map
|
package/dist/src/utilsPackage.js
CHANGED
|
@@ -1,56 +1,56 @@
|
|
|
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.buildDeployCommands = exports.buildCli = exports.readPackageConfigFromDir = exports.readPackageConfig = exports.writePackageConfig = exports.getPackageConfigSchema = void 0;
|
|
7
|
-
const utils_config_1 = require("@goldstack/utils-config");
|
|
8
|
-
const configSchema_json_1 = __importDefault(require("./schemas/configSchema.json"));
|
|
9
|
-
const utils_sh_1 = require("@goldstack/utils-sh");
|
|
10
|
-
const path_1 = __importDefault(require("path"));
|
|
11
|
-
const console_1 = require("console");
|
|
12
|
-
const getPackageConfigSchema = () => {
|
|
13
|
-
return configSchema_json_1.default;
|
|
14
|
-
};
|
|
15
|
-
exports.getPackageConfigSchema = getPackageConfigSchema;
|
|
16
|
-
const writePackageConfig = (packageConfig, packagePath = './') => {
|
|
17
|
-
const schemaPath = packagePath + 'schemas/package.schema.json';
|
|
18
|
-
(0, utils_config_1.validateConfig)(packageConfig, JSON.parse((0, utils_sh_1.read)(schemaPath)), {
|
|
19
|
-
errorMessage: 'Cannot write package config since it is not valid.',
|
|
20
|
-
});
|
|
21
|
-
(0, utils_sh_1.write)(JSON.stringify(packageConfig, null, 2), packagePath + 'goldstack.json');
|
|
22
|
-
};
|
|
23
|
-
exports.writePackageConfig = writePackageConfig;
|
|
24
|
-
const readPackageConfig = (packagePath = './') => {
|
|
25
|
-
const schemaPath = packagePath + 'schemas/package.schema.json';
|
|
26
|
-
const config = (0, utils_config_1.parseConfig)((0, utils_sh_1.read)(packagePath + 'goldstack.json'), JSON.parse((0, utils_sh_1.read)(schemaPath)), {
|
|
27
|
-
errorMessage: 'Cannot load package configuration from ' +
|
|
28
|
-
path_1.default.resolve(packagePath),
|
|
29
|
-
});
|
|
30
|
-
return config;
|
|
31
|
-
};
|
|
32
|
-
exports.readPackageConfig = readPackageConfig;
|
|
33
|
-
const readPackageConfigFromDir = (dir) => {
|
|
34
|
-
(0, console_1.assert)(dir.endsWith('/'));
|
|
35
|
-
return (0, exports.readPackageConfig)(dir);
|
|
36
|
-
};
|
|
37
|
-
exports.readPackageConfigFromDir = readPackageConfigFromDir;
|
|
38
|
-
const buildCli = (params) => {
|
|
39
|
-
return params.yargs
|
|
40
|
-
.scriptName('template')
|
|
41
|
-
.usage('$0 <infra|deploy>')
|
|
42
|
-
.command('infra <up|down|init|plan|apply|destroy|upgrade|terraform> <deployment>', 'Manage infrastructure for deployment', params.infraCommands)
|
|
43
|
-
.command('deploy <deployment>', 'Deploy to specified deployment', params.deployCommands);
|
|
44
|
-
};
|
|
45
|
-
exports.buildCli = buildCli;
|
|
46
|
-
const buildDeployCommands = () => {
|
|
47
|
-
return (yargs) => {
|
|
48
|
-
return yargs.positional('deployment', {
|
|
49
|
-
description: 'Name of the deployment where the package should be deployed to.',
|
|
50
|
-
type: 'string',
|
|
51
|
-
demandOption: true,
|
|
52
|
-
});
|
|
53
|
-
};
|
|
54
|
-
};
|
|
55
|
-
exports.buildDeployCommands = buildDeployCommands;
|
|
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.buildDeployCommands = exports.buildCli = exports.readPackageConfigFromDir = exports.readPackageConfig = exports.writePackageConfig = exports.getPackageConfigSchema = void 0;
|
|
7
|
+
const utils_config_1 = require("@goldstack/utils-config");
|
|
8
|
+
const configSchema_json_1 = __importDefault(require("./schemas/configSchema.json"));
|
|
9
|
+
const utils_sh_1 = require("@goldstack/utils-sh");
|
|
10
|
+
const path_1 = __importDefault(require("path"));
|
|
11
|
+
const console_1 = require("console");
|
|
12
|
+
const getPackageConfigSchema = () => {
|
|
13
|
+
return configSchema_json_1.default;
|
|
14
|
+
};
|
|
15
|
+
exports.getPackageConfigSchema = getPackageConfigSchema;
|
|
16
|
+
const writePackageConfig = (packageConfig, packagePath = './') => {
|
|
17
|
+
const schemaPath = packagePath + 'schemas/package.schema.json';
|
|
18
|
+
(0, utils_config_1.validateConfig)(packageConfig, JSON.parse((0, utils_sh_1.read)(schemaPath)), {
|
|
19
|
+
errorMessage: 'Cannot write package config since it is not valid.',
|
|
20
|
+
});
|
|
21
|
+
(0, utils_sh_1.write)(JSON.stringify(packageConfig, null, 2), packagePath + 'goldstack.json');
|
|
22
|
+
};
|
|
23
|
+
exports.writePackageConfig = writePackageConfig;
|
|
24
|
+
const readPackageConfig = (packagePath = './') => {
|
|
25
|
+
const schemaPath = packagePath + 'schemas/package.schema.json';
|
|
26
|
+
const config = (0, utils_config_1.parseConfig)((0, utils_sh_1.read)(packagePath + 'goldstack.json'), JSON.parse((0, utils_sh_1.read)(schemaPath)), {
|
|
27
|
+
errorMessage: 'Cannot load package configuration from ' +
|
|
28
|
+
path_1.default.resolve(packagePath),
|
|
29
|
+
});
|
|
30
|
+
return config;
|
|
31
|
+
};
|
|
32
|
+
exports.readPackageConfig = readPackageConfig;
|
|
33
|
+
const readPackageConfigFromDir = (dir) => {
|
|
34
|
+
(0, console_1.assert)(dir.endsWith('/'));
|
|
35
|
+
return (0, exports.readPackageConfig)(dir);
|
|
36
|
+
};
|
|
37
|
+
exports.readPackageConfigFromDir = readPackageConfigFromDir;
|
|
38
|
+
const buildCli = (params) => {
|
|
39
|
+
return params.yargs
|
|
40
|
+
.scriptName('template')
|
|
41
|
+
.usage('$0 <infra|deploy>')
|
|
42
|
+
.command('infra <up|down|init|plan|apply|destroy|upgrade|terraform> <deployment>', 'Manage infrastructure for deployment', params.infraCommands)
|
|
43
|
+
.command('deploy <deployment>', 'Deploy to specified deployment', params.deployCommands);
|
|
44
|
+
};
|
|
45
|
+
exports.buildCli = buildCli;
|
|
46
|
+
const buildDeployCommands = () => {
|
|
47
|
+
return (yargs) => {
|
|
48
|
+
return yargs.positional('deployment', {
|
|
49
|
+
description: 'Name of the deployment where the package should be deployed to.',
|
|
50
|
+
type: 'string',
|
|
51
|
+
demandOption: true,
|
|
52
|
+
});
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
exports.buildDeployCommands = buildDeployCommands;
|
|
56
56
|
//# sourceMappingURL=utilsPackage.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@goldstack/utils-package",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "Utilities to work with Goldstack package configurations.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"goldstack",
|
|
@@ -37,13 +37,13 @@
|
|
|
37
37
|
"version:apply:force": "yarn version $@ && yarn version apply"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@goldstack/infra": "0.4.
|
|
41
|
-
"@goldstack/utils-config": "0.4.
|
|
42
|
-
"@goldstack/utils-sh": "0.5.
|
|
40
|
+
"@goldstack/infra": "0.4.1",
|
|
41
|
+
"@goldstack/utils-config": "0.4.1",
|
|
42
|
+
"@goldstack/utils-sh": "0.5.1",
|
|
43
43
|
"yargs": "^17.5.1"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@goldstack/utils-git": "0.2.
|
|
46
|
+
"@goldstack/utils-git": "0.2.1",
|
|
47
47
|
"@types/jest": "^28.1.8",
|
|
48
48
|
"@types/node": "^18.7.13",
|
|
49
49
|
"@types/yargs": "^17.0.10",
|