@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.
Files changed (78) hide show
  1. package/bin/aws-credentials-client.d.ts +2 -2
  2. package/bin/caddy-client.d.ts +3 -3
  3. package/bin/ci-rest-api.d.ts +2 -2
  4. package/bin/deployment-queue-client.d.ts +4 -4
  5. package/bin/docker-client.d.ts +4 -4
  6. package/bin/index.d.ts +3 -1
  7. package/bin/index.js +4 -4
  8. package/bin/index.js.map +1 -1
  9. package/bin/{dist/index.cli.d.ts → platform-cli.d.ts} +0 -0
  10. package/bin/platform-client.d.ts +13 -0
  11. package/bin/platform-config.d.ts +4 -0
  12. package/bin/platform-template.d.ts +5 -0
  13. package/bin/types/index.d.ts +2 -2
  14. package/{dist/dist/types/index.d.ts → bin/types.d.ts} +2 -2
  15. package/dist/aws-credentials-client.d.ts +2 -2
  16. package/dist/caddy-client.d.ts +3 -3
  17. package/dist/ci-rest-api.d.ts +2 -2
  18. package/dist/deployment-queue-client.d.ts +4 -4
  19. package/dist/docker-client.d.ts +4 -4
  20. package/dist/index.d.ts +3 -1
  21. package/dist/index.js +4 -4
  22. package/dist/index.js.map +1 -1
  23. package/dist/{dist/index.cli.d.ts → platform-cli.d.ts} +0 -0
  24. package/dist/platform-client.d.ts +13 -0
  25. package/dist/platform-config.d.ts +4 -0
  26. package/dist/platform-template.d.ts +5 -0
  27. package/dist/types/index.d.ts +2 -2
  28. package/{bin/dist/types/index.d.ts → dist/types.d.ts} +2 -2
  29. package/package.json +2 -2
  30. package/src/aws-credentials-client.ts +2 -2
  31. package/src/caddy-client.ts +10 -10
  32. package/src/ci-rest-api.ts +4 -4
  33. package/src/cli-commands/deploy-handler.ts +10 -10
  34. package/src/cli-commands/index.ts +1 -1
  35. package/src/cli-commands/start-handler.ts +4 -4
  36. package/src/cli-commands/status-handler.ts +2 -2
  37. package/src/cli-commands/stop-handler.ts +1 -1
  38. package/src/deployment-queue-client.ts +15 -15
  39. package/src/docker-client.ts +7 -7
  40. package/src/index.d.ts +2 -0
  41. package/src/index.ts +3 -1
  42. package/src/{index.cli.ts → platform-cli.ts} +0 -0
  43. package/src/platform-client.ts +102 -0
  44. package/src/platform-config.ts +36 -0
  45. package/src/platform-template.ts +31 -0
  46. package/src/{types/index.ts → types.ts} +2 -2
  47. package/tsconfig.json +1 -2
  48. package/bin/deployment-platform-client.d.ts +0 -11
  49. package/bin/dist/aws-credentials-client.d.ts +0 -4
  50. package/bin/dist/caddy-client.d.ts +0 -13
  51. package/bin/dist/ci-rest-api.d.ts +0 -4
  52. package/bin/dist/cli-commands/deploy-handler.d.ts +0 -1
  53. package/bin/dist/cli-commands/index.d.ts +0 -4
  54. package/bin/dist/cli-commands/start-handler.d.ts +0 -1
  55. package/bin/dist/cli-commands/status-handler.d.ts +0 -1
  56. package/bin/dist/cli-commands/stop-handler.d.ts +0 -1
  57. package/bin/dist/deployment-platform-client.d.ts +0 -11
  58. package/bin/dist/deployment-queue-client.d.ts +0 -7
  59. package/bin/dist/docker-client.d.ts +0 -8
  60. package/bin/dist/index.d.ts +0 -2
  61. package/bin/dist/log/index.d.ts +0 -3
  62. package/bin/index.cli.d.ts +0 -1
  63. package/dist/deployment-platform-client.d.ts +0 -11
  64. package/dist/dist/aws-credentials-client.d.ts +0 -4
  65. package/dist/dist/caddy-client.d.ts +0 -13
  66. package/dist/dist/ci-rest-api.d.ts +0 -4
  67. package/dist/dist/cli-commands/deploy-handler.d.ts +0 -1
  68. package/dist/dist/cli-commands/index.d.ts +0 -4
  69. package/dist/dist/cli-commands/start-handler.d.ts +0 -1
  70. package/dist/dist/cli-commands/status-handler.d.ts +0 -1
  71. package/dist/dist/cli-commands/stop-handler.d.ts +0 -1
  72. package/dist/dist/deployment-platform-client.d.ts +0 -11
  73. package/dist/dist/deployment-queue-client.d.ts +0 -7
  74. package/dist/dist/docker-client.d.ts +0 -8
  75. package/dist/dist/index.d.ts +0 -2
  76. package/dist/dist/log/index.d.ts +0 -3
  77. package/dist/index.cli.d.ts +0 -2
  78. package/src/deployment-platform-client.ts +0 -141
@@ -1,4 +0,0 @@
1
- import { DeploymentPlatform } from 'types';
2
- export declare class CiRestApi {
3
- static start(deploymentPlatform: DeploymentPlatform): void;
4
- }
@@ -1 +0,0 @@
1
- export declare const deployHandler: (cliArgs: any) => void;
@@ -1,4 +0,0 @@
1
- export declare const runCliCommand: ({ name, args }: {
2
- name: any;
3
- args: any;
4
- }) => 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
- }
@@ -1,2 +0,0 @@
1
- export { DeploymentPlatformClient } from 'deployment-platform-client';
2
- export * from 'types';
@@ -1,3 +0,0 @@
1
- export declare const logInfo: (logInput: any) => void;
2
- export declare const logError: (logInput: any) => void;
3
- export declare const logDebug: (logInput: any) => void;
@@ -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,4 +0,0 @@
1
- import { DeploymentPlatform } from 'types';
2
- export declare class AwsCredentialsClient {
3
- static resolveAwsCredentials({ awsAccountId, awsRegion, awsRoleToAssume }: DeploymentPlatform): Promise<any>;
4
- }
@@ -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,4 +0,0 @@
1
- import { DeploymentPlatform } from 'types';
2
- export declare class CiRestApi {
3
- static start(deploymentPlatform: DeploymentPlatform): void;
4
- }
@@ -1 +0,0 @@
1
- export declare const deployHandler: (cliArgs: any) => void;
@@ -1,4 +0,0 @@
1
- export declare const runCliCommand: ({ name, args }: {
2
- name: any;
3
- args: any;
4
- }) => 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
- }
@@ -1,2 +0,0 @@
1
- export { DeploymentPlatformClient } from 'deployment-platform-client';
2
- export * from 'types';
@@ -1,3 +0,0 @@
1
- export declare const logInfo: (logInput: any) => void;
2
- export declare const logError: (logInput: any) => void;
3
- export declare const logDebug: (logInput: any) => void;
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- export {};
@@ -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
- }