@ossy/deployment-tools 0.0.26 → 0.0.28
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/dist/index.js +12 -3
- package/package.json +1 -1
- package/src/caddy-client.ts +2 -2
- package/src/deployment-platform-client.ts +10 -4
- package/src/deployment-queue-client.ts +7 -3
- package/src/log/index.ts +8 -1
package/dist/index.js
CHANGED
|
@@ -58353,9 +58353,10 @@ var __webpack_exports__ = {};
|
|
|
58353
58353
|
(() => {
|
|
58354
58354
|
|
|
58355
58355
|
;// CONCATENATED MODULE: ./src/log/index.ts
|
|
58356
|
-
const log = ({ type, message } = { type: 'info', message: '' }) => {
|
|
58356
|
+
const log = ({ type, message, error } = { type: 'info', message: '' }) => {
|
|
58357
58357
|
const messagePrefix = `[${type.toUpperCase()}]${message.startsWith('[') ? '' : ': '}`;
|
|
58358
58358
|
console.log(`${messagePrefix}${message}`);
|
|
58359
|
+
error && console.log('\t[Reason]:', error);
|
|
58359
58360
|
};
|
|
58360
58361
|
|
|
58361
58362
|
// EXTERNAL MODULE: ./node_modules/arg/index.js
|
|
@@ -60773,7 +60774,11 @@ class DeploymentQueueClient {
|
|
|
60773
60774
|
});
|
|
60774
60775
|
return sqsClient.send(command)
|
|
60775
60776
|
.then(() => log({ type: 'info', message: '[DeploymentQueueClient] Deployment request sent' }))
|
|
60776
|
-
.catch(
|
|
60777
|
+
.catch(error => log({
|
|
60778
|
+
type: 'error',
|
|
60779
|
+
message: '[DeploymentQueueClient] Could not send deployment request',
|
|
60780
|
+
error
|
|
60781
|
+
}));
|
|
60777
60782
|
});
|
|
60778
60783
|
}
|
|
60779
60784
|
static pollForDeploymentRequests(deploymentPlatform, handleDeploymentRequest) {
|
|
@@ -60865,7 +60870,11 @@ class DeploymentPlatformClient {
|
|
|
60865
60870
|
])
|
|
60866
60871
|
.then(([platforms, deploymentTemplates]) => {
|
|
60867
60872
|
deploymentTemplates.map(deploymentTemplate => {
|
|
60868
|
-
|
|
60873
|
+
log({
|
|
60874
|
+
type: 'info',
|
|
60875
|
+
message: `[DeploymentPlatformClient]: Found deployment platforms [${platforms.join(', ')}]`
|
|
60876
|
+
});
|
|
60877
|
+
const deploymentPlatform = platforms.find(platform => platform.platformName === deploymentTemplate.targetDeploymentPlatform);
|
|
60869
60878
|
if (!deploymentPlatform) {
|
|
60870
60879
|
log({ type: 'error', message: `[DeploymentPlatformClient] Could not find a deployment platform with the name ${deploymentTemplate.targetDeploymentPlatform}` });
|
|
60871
60880
|
return Promise.reject();
|
package/package.json
CHANGED
package/src/caddy-client.ts
CHANGED
|
@@ -39,7 +39,7 @@ export class CaddyClient {
|
|
|
39
39
|
}
|
|
40
40
|
]))
|
|
41
41
|
})
|
|
42
|
-
.catch(
|
|
42
|
+
.catch(error => log({ type: 'error', message: `[CaddyClient] Could not update caddy config to include ${url}`, error }))
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
static applyDefaultServerConfig(deploymentPlatform: DeploymentPlatform) {
|
|
@@ -105,7 +105,7 @@ export class CaddyClient {
|
|
|
105
105
|
}
|
|
106
106
|
})
|
|
107
107
|
})
|
|
108
|
-
.catch(
|
|
108
|
+
.catch(error => log({ type: 'error', message: '[CaddyClient] Could not apply default caddy config', error }))
|
|
109
109
|
}
|
|
110
110
|
|
|
111
111
|
}
|
|
@@ -37,7 +37,7 @@ export class DeploymentPlatformClient {
|
|
|
37
37
|
)
|
|
38
38
|
|
|
39
39
|
})
|
|
40
|
-
.catch(
|
|
40
|
+
.catch(error => log({ type: 'error', message: '[DeploymentPlatformClient] Could not start the deployment platform', error }))
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
//eslint-disable-next-line max-params
|
|
@@ -54,7 +54,13 @@ export class DeploymentPlatformClient {
|
|
|
54
54
|
])
|
|
55
55
|
.then(([platforms, deploymentTemplates]) => {
|
|
56
56
|
deploymentTemplates.map(deploymentTemplate => {
|
|
57
|
-
|
|
57
|
+
|
|
58
|
+
log({
|
|
59
|
+
type: 'info',
|
|
60
|
+
message: `[DeploymentPlatformClient]: Found deployment platforms [${platforms.join(', ')}]`
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
const deploymentPlatform = platforms.find(platform => platform.platformName === deploymentTemplate.targetDeploymentPlatform)
|
|
58
64
|
|
|
59
65
|
if (!deploymentPlatform) {
|
|
60
66
|
log({ type: 'error', message: `[DeploymentPlatformClient] Could not find a deployment platform with the name ${deploymentTemplate.targetDeploymentPlatform}` })
|
|
@@ -79,7 +85,7 @@ export class DeploymentPlatformClient {
|
|
|
79
85
|
|
|
80
86
|
})
|
|
81
87
|
})
|
|
82
|
-
.catch(error =>
|
|
88
|
+
.catch(error => log({ type: 'error', message: '[DeploymentPlatformClient] Could not send deployment request', error }))
|
|
83
89
|
}
|
|
84
90
|
|
|
85
91
|
static getDeploymentTemplates(pathToOssyFile: string): Promise<DeploymentTemplate[]> {
|
|
@@ -87,7 +93,7 @@ export class DeploymentPlatformClient {
|
|
|
87
93
|
return Promise.resolve(ossyfile.deployments || [])
|
|
88
94
|
}
|
|
89
95
|
|
|
90
|
-
static getDeploymentPlatforms(pathToDeploymentPlatforms: string) {
|
|
96
|
+
static getDeploymentPlatforms(pathToDeploymentPlatforms: string): Promise<DeploymentPlatform[]> {
|
|
91
97
|
let deploymentPlatforms = JSON.parse(readFileSync(resolve(pathToDeploymentPlatforms), 'utf8'))
|
|
92
98
|
|
|
93
99
|
if (!Array.isArray(deploymentPlatforms)) {
|
|
@@ -22,7 +22,11 @@ export class DeploymentQueueClient {
|
|
|
22
22
|
|
|
23
23
|
return sqsClient.send(command)
|
|
24
24
|
.then(() => log({ type: 'info', message: '[DeploymentQueueClient] Deployment request sent' }))
|
|
25
|
-
.catch(
|
|
25
|
+
.catch(error => log({
|
|
26
|
+
type: 'error',
|
|
27
|
+
message: '[DeploymentQueueClient] Could not send deployment request',
|
|
28
|
+
error
|
|
29
|
+
}))
|
|
26
30
|
|
|
27
31
|
})
|
|
28
32
|
|
|
@@ -52,11 +56,11 @@ export class DeploymentQueueClient {
|
|
|
52
56
|
|
|
53
57
|
sqsClient.send(deleteMessageCommand)
|
|
54
58
|
.then(() => log({ type: 'info', message: '[DeploymentQueueClient] Removing deployment request from queue' }))
|
|
55
|
-
.catch(
|
|
59
|
+
.catch(error => log({ type: 'error', message: '[DeploymentQueueClient] Could not delete message from queue', error }))
|
|
56
60
|
})
|
|
57
61
|
|
|
58
62
|
}))
|
|
59
|
-
.catch(
|
|
63
|
+
.catch(error => log({ type: 'error', message: '[ContainerManagerServer] Could not handle incoming deployment request', error }))
|
|
60
64
|
}, FIVE_MINUTES)
|
|
61
65
|
|
|
62
66
|
})
|
package/src/log/index.ts
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
interface LogInput {
|
|
2
|
+
type: 'info' | 'error';
|
|
3
|
+
message: string;
|
|
4
|
+
error?: any;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export const log = ({ type, message, error }: LogInput = { type: 'info', message: '' }) => {
|
|
2
8
|
const messagePrefix = `[${type.toUpperCase()}]${message.startsWith('[') ? '' : ': '}`
|
|
3
9
|
console.log(`${messagePrefix}${message}`)
|
|
10
|
+
error && console.log('\t[Reason]:', error)
|
|
4
11
|
}
|