@ossy/deployment-tools 0.0.40 → 0.0.41
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/bin/aws-credentials-client.d.ts +2 -2
- package/bin/caddy-client.d.ts +3 -3
- package/bin/ci-rest-api.d.ts +2 -2
- package/bin/deployment-queue-client.d.ts +4 -4
- package/bin/docker-client.d.ts +4 -4
- package/bin/index.d.ts +3 -1
- package/bin/index.js +4 -4
- package/bin/index.js.map +1 -1
- package/bin/{dist/index.cli.d.ts → platform-cli.d.ts} +0 -0
- package/bin/platform-client.d.ts +13 -0
- package/bin/platform-config.d.ts +4 -0
- package/bin/platform-template.d.ts +5 -0
- package/bin/types/index.d.ts +2 -2
- package/{dist/dist/types/index.d.ts → bin/types.d.ts} +2 -2
- package/dist/aws-credentials-client.d.ts +2 -2
- package/dist/caddy-client.d.ts +3 -3
- package/dist/ci-rest-api.d.ts +2 -2
- package/dist/deployment-queue-client.d.ts +4 -4
- package/dist/docker-client.d.ts +4 -4
- package/dist/index.d.ts +3 -1
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/dist/{dist/index.cli.d.ts → platform-cli.d.ts} +0 -0
- package/dist/platform-client.d.ts +13 -0
- package/dist/platform-config.d.ts +4 -0
- package/dist/platform-template.d.ts +5 -0
- package/dist/types/index.d.ts +2 -2
- package/{bin/dist/types/index.d.ts → dist/types.d.ts} +2 -2
- package/package.json +2 -2
- package/src/aws-credentials-client.ts +2 -2
- package/src/caddy-client.ts +10 -10
- package/src/ci-rest-api.ts +4 -4
- package/src/cli-commands/deploy-handler.ts +10 -10
- package/src/cli-commands/index.ts +1 -1
- package/src/cli-commands/start-handler.ts +4 -4
- package/src/cli-commands/status-handler.ts +2 -2
- package/src/cli-commands/stop-handler.ts +1 -1
- package/src/deployment-queue-client.ts +15 -15
- package/src/docker-client.ts +7 -7
- package/src/index.d.ts +2 -0
- package/src/index.ts +3 -1
- package/src/{index.cli.ts → platform-cli.ts} +0 -0
- package/src/platform-client.ts +102 -0
- package/src/platform-config.ts +36 -0
- package/src/platform-template.ts +31 -0
- package/src/{types/index.ts → types.ts} +2 -2
- package/tsconfig.json +1 -2
- package/bin/deployment-platform-client.d.ts +0 -11
- package/bin/dist/aws-credentials-client.d.ts +0 -4
- package/bin/dist/caddy-client.d.ts +0 -13
- package/bin/dist/ci-rest-api.d.ts +0 -4
- package/bin/dist/cli-commands/deploy-handler.d.ts +0 -1
- package/bin/dist/cli-commands/index.d.ts +0 -4
- package/bin/dist/cli-commands/start-handler.d.ts +0 -1
- package/bin/dist/cli-commands/status-handler.d.ts +0 -1
- package/bin/dist/cli-commands/stop-handler.d.ts +0 -1
- package/bin/dist/deployment-platform-client.d.ts +0 -11
- package/bin/dist/deployment-queue-client.d.ts +0 -7
- package/bin/dist/docker-client.d.ts +0 -8
- package/bin/dist/index.d.ts +0 -2
- package/bin/dist/log/index.d.ts +0 -3
- package/bin/index.cli.d.ts +0 -1
- package/dist/deployment-platform-client.d.ts +0 -11
- package/dist/dist/aws-credentials-client.d.ts +0 -4
- package/dist/dist/caddy-client.d.ts +0 -13
- package/dist/dist/ci-rest-api.d.ts +0 -4
- package/dist/dist/cli-commands/deploy-handler.d.ts +0 -1
- package/dist/dist/cli-commands/index.d.ts +0 -4
- package/dist/dist/cli-commands/start-handler.d.ts +0 -1
- package/dist/dist/cli-commands/status-handler.d.ts +0 -1
- package/dist/dist/cli-commands/stop-handler.d.ts +0 -1
- package/dist/dist/deployment-platform-client.d.ts +0 -11
- package/dist/dist/deployment-queue-client.d.ts +0 -7
- package/dist/dist/docker-client.d.ts +0 -8
- package/dist/dist/index.d.ts +0 -2
- package/dist/dist/log/index.d.ts +0 -3
- package/dist/index.cli.d.ts +0 -2
- package/src/deployment-platform-client.ts +0 -141
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const deployHandler: (cliArgs: any) => void;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const startHandler: (cliArgs: any) => void;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const statusHandler: () => void;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const stopHandler: () => void;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { DeploymentPlatform, SupportedEnvironments, DeploymentTemplate } from 'types';
|
|
2
|
-
export declare class DeploymentPlatformClient {
|
|
3
|
-
static start(pathToDeploymentPlatforms: string): void;
|
|
4
|
-
static deploy(username: any, authentication: any, targetEnvironment: any, pathToDeploymentPlatforms: any, pathToOssyFile: any): Promise<void>;
|
|
5
|
-
static getDeploymentTemplates(pathToOssyFile: string): Promise<DeploymentTemplate[]>;
|
|
6
|
-
static getDeploymentPlatforms(pathToDeploymentPlatforms: string): Promise<DeploymentPlatform[]>;
|
|
7
|
-
static getEnvironmentVariables(targetEnvironment: SupportedEnvironments, deploymentRequest: DeploymentTemplate): any;
|
|
8
|
-
static resolveDeploymentPlatformValues(deploymentPlatform: DeploymentPlatform): DeploymentPlatform;
|
|
9
|
-
static setDefaultDeploymentPlatformValues(deploymentPlatform: DeploymentPlatform): DeploymentPlatform;
|
|
10
|
-
static setCalculatedDeploymentPlatformValues(deploymentPlatform: DeploymentPlatform): DeploymentPlatform;
|
|
11
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { SQSClient } from '@aws-sdk/client-sqs';
|
|
2
|
-
import { DeploymentPlatform, ContainerDeploymentRequest } from 'types';
|
|
3
|
-
export declare class DeploymentQueueClient {
|
|
4
|
-
static sendDeploymentRequest(deploymentPlatform: DeploymentPlatform, deploymentRequest: ContainerDeploymentRequest): Promise<void>;
|
|
5
|
-
static pollForDeploymentRequests(deploymentPlatform: DeploymentPlatform, handleDeploymentRequest: (deploymentRequest: ContainerDeploymentRequest) => Promise<void>): void;
|
|
6
|
-
static createAwsSqsClient(deploymentPlatform: DeploymentPlatform): Promise<SQSClient>;
|
|
7
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { DeploymentPlatform, ContainerDeploymentRequest } from 'types';
|
|
2
|
-
export declare class DockerClient {
|
|
3
|
-
static createDockerNetworkForContainerManagerServer(deploymentPlatform: DeploymentPlatform): void;
|
|
4
|
-
static stopContainer(deploymentRequest: ContainerDeploymentRequest): string;
|
|
5
|
-
static startContainer(deploymentPlatform: any, { image, containerPort, hostPort, registry, env }: ContainerDeploymentRequest): string;
|
|
6
|
-
static resolveCredentials({ registry, username, authentication }: ContainerDeploymentRequest): string;
|
|
7
|
-
static deploy(deploymentPlatform: DeploymentPlatform, deploymentRequest: ContainerDeploymentRequest): Promise<void>;
|
|
8
|
-
}
|
package/bin/dist/index.d.ts
DELETED
package/bin/dist/log/index.d.ts
DELETED
package/bin/index.cli.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { DeploymentPlatform, SupportedEnvironments, DeploymentTemplate } from 'types';
|
|
2
|
-
export declare class DeploymentPlatformClient {
|
|
3
|
-
static start(pathToDeploymentPlatforms: string): void;
|
|
4
|
-
static deploy(username: any, authentication: any, targetEnvironment: any, pathToDeploymentPlatforms: any, pathToOssyFile: any): Promise<void>;
|
|
5
|
-
static getDeploymentTemplates(pathToOssyFile: string): Promise<DeploymentTemplate[]>;
|
|
6
|
-
static getDeploymentPlatforms(pathToDeploymentPlatforms: string): Promise<DeploymentPlatform[]>;
|
|
7
|
-
static getEnvironmentVariables(targetEnvironment: SupportedEnvironments, deploymentRequest: DeploymentTemplate): any;
|
|
8
|
-
static resolveDeploymentPlatformValues(deploymentPlatform: DeploymentPlatform): DeploymentPlatform;
|
|
9
|
-
static setDefaultDeploymentPlatformValues(deploymentPlatform: DeploymentPlatform): DeploymentPlatform;
|
|
10
|
-
static setCalculatedDeploymentPlatformValues(deploymentPlatform: DeploymentPlatform): DeploymentPlatform;
|
|
11
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { DeploymentPlatform, ContainerDeploymentRequest } from 'types';
|
|
2
|
-
export declare const Matchers: {
|
|
3
|
-
host: (host: any) => {
|
|
4
|
-
host: any[];
|
|
5
|
-
};
|
|
6
|
-
path: (path: any) => {
|
|
7
|
-
path: any[];
|
|
8
|
-
};
|
|
9
|
-
};
|
|
10
|
-
export declare class CaddyClient {
|
|
11
|
-
static deploy(deploymentPlatform: DeploymentPlatform, deploymentRequest: ContainerDeploymentRequest): Promise<void | import("node-fetch").Response>;
|
|
12
|
-
static applyDefaultServerConfig(deploymentPlatform: DeploymentPlatform): Promise<void | import("node-fetch").Response>;
|
|
13
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const deployHandler: (cliArgs: any) => void;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const startHandler: (cliArgs: any) => void;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const statusHandler: () => void;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const stopHandler: () => void;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { DeploymentPlatform, SupportedEnvironments, DeploymentTemplate } from 'types';
|
|
2
|
-
export declare class DeploymentPlatformClient {
|
|
3
|
-
static start(pathToDeploymentPlatforms: string): void;
|
|
4
|
-
static deploy(username: any, authentication: any, targetEnvironment: any, pathToDeploymentPlatforms: any, pathToOssyFile: any): Promise<void>;
|
|
5
|
-
static getDeploymentTemplates(pathToOssyFile: string): Promise<DeploymentTemplate[]>;
|
|
6
|
-
static getDeploymentPlatforms(pathToDeploymentPlatforms: string): Promise<DeploymentPlatform[]>;
|
|
7
|
-
static getEnvironmentVariables(targetEnvironment: SupportedEnvironments, deploymentRequest: DeploymentTemplate): any;
|
|
8
|
-
static resolveDeploymentPlatformValues(deploymentPlatform: DeploymentPlatform): DeploymentPlatform;
|
|
9
|
-
static setDefaultDeploymentPlatformValues(deploymentPlatform: DeploymentPlatform): DeploymentPlatform;
|
|
10
|
-
static setCalculatedDeploymentPlatformValues(deploymentPlatform: DeploymentPlatform): DeploymentPlatform;
|
|
11
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { SQSClient } from '@aws-sdk/client-sqs';
|
|
2
|
-
import { DeploymentPlatform, ContainerDeploymentRequest } from 'types';
|
|
3
|
-
export declare class DeploymentQueueClient {
|
|
4
|
-
static sendDeploymentRequest(deploymentPlatform: DeploymentPlatform, deploymentRequest: ContainerDeploymentRequest): Promise<void>;
|
|
5
|
-
static pollForDeploymentRequests(deploymentPlatform: DeploymentPlatform, handleDeploymentRequest: (deploymentRequest: ContainerDeploymentRequest) => Promise<void>): void;
|
|
6
|
-
static createAwsSqsClient(deploymentPlatform: DeploymentPlatform): Promise<SQSClient>;
|
|
7
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { DeploymentPlatform, ContainerDeploymentRequest } from 'types';
|
|
2
|
-
export declare class DockerClient {
|
|
3
|
-
static createDockerNetworkForContainerManagerServer(deploymentPlatform: DeploymentPlatform): void;
|
|
4
|
-
static stopContainer(deploymentRequest: ContainerDeploymentRequest): string;
|
|
5
|
-
static startContainer(deploymentPlatform: any, { image, containerPort, hostPort, registry, env }: ContainerDeploymentRequest): string;
|
|
6
|
-
static resolveCredentials({ registry, username, authentication }: ContainerDeploymentRequest): string;
|
|
7
|
-
static deploy(deploymentPlatform: DeploymentPlatform, deploymentRequest: ContainerDeploymentRequest): Promise<void>;
|
|
8
|
-
}
|
package/dist/dist/index.d.ts
DELETED
package/dist/dist/log/index.d.ts
DELETED
package/dist/index.cli.d.ts
DELETED
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
import { resolve } from 'path'
|
|
2
|
-
import { readFileSync } from 'fs'
|
|
3
|
-
import {
|
|
4
|
-
DeploymentPlatform,
|
|
5
|
-
SupportedEnvironments,
|
|
6
|
-
ContainerDeploymentRequest,
|
|
7
|
-
DeploymentTemplate,
|
|
8
|
-
ContainerDeploymentTemplate,
|
|
9
|
-
SupportedDeploymentTypes,
|
|
10
|
-
SupportedRegions
|
|
11
|
-
} from 'types'
|
|
12
|
-
import { CaddyClient } from './caddy-client'
|
|
13
|
-
import { DockerClient } from './docker-client'
|
|
14
|
-
import { DeploymentQueueClient } from './deployment-queue-client'
|
|
15
|
-
import { CiRestApi } from './ci-rest-api'
|
|
16
|
-
import { logInfo, logError } from 'log'
|
|
17
|
-
|
|
18
|
-
export class DeploymentPlatformClient {
|
|
19
|
-
|
|
20
|
-
static start(pathToDeploymentPlatforms: string) {
|
|
21
|
-
DeploymentPlatformClient.getDeploymentPlatforms(pathToDeploymentPlatforms).then(([firstPlatformFound]) => {
|
|
22
|
-
|
|
23
|
-
if (!firstPlatformFound) {
|
|
24
|
-
logError({ message: '[DeploymentPlatformClient] Could not find a deployment platform' })
|
|
25
|
-
return Promise.reject()
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
CiRestApi.start(firstPlatformFound)
|
|
29
|
-
CaddyClient.applyDefaultServerConfig(firstPlatformFound)
|
|
30
|
-
|
|
31
|
-
DeploymentQueueClient.pollForDeploymentRequests(
|
|
32
|
-
firstPlatformFound,
|
|
33
|
-
(deploymentRequest: ContainerDeploymentRequest) => {
|
|
34
|
-
DockerClient.deploy(firstPlatformFound, deploymentRequest)
|
|
35
|
-
CaddyClient.deploy(firstPlatformFound, deploymentRequest)
|
|
36
|
-
return Promise.resolve()
|
|
37
|
-
}
|
|
38
|
-
)
|
|
39
|
-
|
|
40
|
-
})
|
|
41
|
-
.catch(error => logError({ message: '[DeploymentPlatformClient] Could not start the deployment platform', error }))
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
//eslint-disable-next-line max-params
|
|
45
|
-
static deploy(
|
|
46
|
-
username,
|
|
47
|
-
authentication,
|
|
48
|
-
targetEnvironment,
|
|
49
|
-
pathToDeploymentPlatforms,
|
|
50
|
-
pathToOssyFile
|
|
51
|
-
) {
|
|
52
|
-
return Promise.all([
|
|
53
|
-
DeploymentPlatformClient.getDeploymentPlatforms(pathToDeploymentPlatforms),
|
|
54
|
-
DeploymentPlatformClient.getDeploymentTemplates(pathToOssyFile)
|
|
55
|
-
])
|
|
56
|
-
.then(([platforms, deploymentTemplates]) => {
|
|
57
|
-
deploymentTemplates.map(deploymentTemplate => {
|
|
58
|
-
|
|
59
|
-
logInfo({ message: `[DeploymentPlatformClient]: Found deployment platforms [${platforms.map(x => x.platformName).join(', ')}]` })
|
|
60
|
-
|
|
61
|
-
const deploymentPlatform = platforms
|
|
62
|
-
.map(platform => DeploymentPlatformClient.setCalculatedDeploymentPlatformValues({ ...platform, activeEnvironment: targetEnvironment }))
|
|
63
|
-
.find(platform => platform.platformName === deploymentTemplate.targetDeploymentPlatform)
|
|
64
|
-
|
|
65
|
-
if (!deploymentPlatform) {
|
|
66
|
-
logError({ message: `[DeploymentPlatformClient] Could not find a deployment platform with the name ${deploymentTemplate.targetDeploymentPlatform}` })
|
|
67
|
-
return Promise.reject()
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0'
|
|
71
|
-
|
|
72
|
-
if (deploymentTemplate.type !== SupportedDeploymentTypes.Container) {
|
|
73
|
-
logError({ message: `[DeploymentPlatformClient] Unsupported deployment type of ${deploymentTemplate.type}` })
|
|
74
|
-
return Promise.reject()
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
const deploymentRequest: ContainerDeploymentRequest = {
|
|
78
|
-
...deploymentTemplate as ContainerDeploymentTemplate,
|
|
79
|
-
env: DeploymentPlatformClient.getEnvironmentVariables(targetEnvironment, deploymentTemplate),
|
|
80
|
-
username: username,
|
|
81
|
-
authentication: authentication
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
return DeploymentQueueClient.sendDeploymentRequest(deploymentPlatform, deploymentRequest)
|
|
85
|
-
|
|
86
|
-
})
|
|
87
|
-
})
|
|
88
|
-
.catch(error => logError({ message: '[DeploymentPlatformClient] Could not send deployment request', error }))
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
static getDeploymentTemplates(pathToOssyFile: string): Promise<DeploymentTemplate[]> {
|
|
92
|
-
const ossyfile = JSON.parse(readFileSync(resolve(pathToOssyFile), 'utf8'))
|
|
93
|
-
return Promise.resolve(ossyfile.deployments || [])
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
static getDeploymentPlatforms(pathToDeploymentPlatforms: string): Promise<DeploymentPlatform[]> {
|
|
97
|
-
let deploymentPlatforms = JSON.parse(readFileSync(resolve(pathToDeploymentPlatforms), 'utf8'))
|
|
98
|
-
|
|
99
|
-
if (!Array.isArray(deploymentPlatforms)) {
|
|
100
|
-
deploymentPlatforms = [deploymentPlatforms]
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
return Promise.resolve((deploymentPlatforms || []).map(DeploymentPlatformClient.resolveDeploymentPlatformValues))
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
static getEnvironmentVariables(targetEnvironment: SupportedEnvironments, deploymentRequest: DeploymentTemplate) {
|
|
107
|
-
const envs = deploymentRequest.env || {}
|
|
108
|
-
return {
|
|
109
|
-
...(envs.shared || {}),
|
|
110
|
-
...(envs[targetEnvironment] || {})
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
static resolveDeploymentPlatformValues(deploymentPlatform: DeploymentPlatform): DeploymentPlatform {
|
|
115
|
-
return DeploymentPlatformClient.setCalculatedDeploymentPlatformValues(DeploymentPlatformClient.setDefaultDeploymentPlatformValues(deploymentPlatform))
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
static setDefaultDeploymentPlatformValues(deploymentPlatform: DeploymentPlatform): DeploymentPlatform {
|
|
119
|
-
return {
|
|
120
|
-
platformName: SupportedEnvironments.LOCAL,
|
|
121
|
-
domain: 'localhost',
|
|
122
|
-
activeEnvironment: SupportedEnvironments.LOCAL,
|
|
123
|
-
supportedDeploymentTypes: ['CONTAINER'],
|
|
124
|
-
ciSubDomain: 'ci',
|
|
125
|
-
ciInternalServerPort: 3000,
|
|
126
|
-
ciServerName: 'ci-client',
|
|
127
|
-
ciDockerNetworkName: 'deployment-tools',
|
|
128
|
-
awsRegion: SupportedRegions.North,
|
|
129
|
-
// awsRoleToAssume: 'github-ci-role', //todo: find a way to have this a a default value and still keep the same logic when resolving aws credentials
|
|
130
|
-
...deploymentPlatform
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
static setCalculatedDeploymentPlatformValues(deploymentPlatform: DeploymentPlatform): DeploymentPlatform {
|
|
135
|
-
return {
|
|
136
|
-
...deploymentPlatform,
|
|
137
|
-
awsDeploymentSqsArn: `https://sqs.${deploymentPlatform.awsRegion}.amazonaws.com/${deploymentPlatform.awsAccountId}/${deploymentPlatform.platformName}-${deploymentPlatform.activeEnvironment}`,
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
}
|