@ossy/deployment-tools 0.0.24 → 0.0.25

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/package.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "@ossy/deployment-tools",
3
- "version": "0.0.24",
3
+ "version": "0.0.25",
4
4
  "description": "Collection of scripts and tools to aid deployment of containers and static files",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
7
7
  "scripts": {
8
8
  "test": "echo \"Error: no test specified\" && exit 1",
9
- "build": "npx --yes @vercel/ncc build src/index.js --out dist --license licenses.txt"
9
+ "build": "npx --yes @vercel/ncc build src/index.js --out dist --license licenses.txt",
10
+ "build:esbuild": "npx --yes esbuild src/index.js --platform=node --bundle --outfile=dist/index.js"
10
11
  },
11
12
  "author": "Ossy",
12
13
  "license": "ISC",
@@ -1,5 +1,7 @@
1
1
  import fetch from 'node-fetch'
2
- import * as config from './config.js'
2
+ import { resolveConfiguration } from './config.js'
3
+
4
+ const config = resolveConfiguration()
3
5
 
4
6
  export const Matchers = {
5
7
  host: host => ({ host: [host] }),
package/src/config.js CHANGED
@@ -1,9 +1,22 @@
1
- export const platformName = process.env.DEPLOYMENT_TOOLS_PLATFORM_NAME
2
- export const domain = process.env.DEPLOYMENT_TOOLS_DOMAIN || 'localhost'
3
- export const environmentName = process.env.DEPLOYMENT_TOOLS_ENVIRONMENT_NAME || 'dev'
4
- export const ciSubDomain = process.env.DEPLOYMENT_TOOLS_CI_SUB_DOMAIN || 'ci'
5
- export const port = process.env.DEPLOYMENT_TOOLS_PORT || 3000
6
- export const awsAccountId = process.env.AWS_ACCOUNT_ID
7
- export const awsRegion = process.env.AWS_REGION
1
+ export const resolveConfiguration = (deploymentPlatform = {}) => {
2
+ const platformName = deploymentPlatform.name || process.env.DEPLOYMENT_TOOLS_PLATFORM_NAME
3
+ const domain = deploymentPlatform.domain || process.env.DEPLOYMENT_TOOLS_DOMAIN || 'localhost'
4
+ const environmentName = process.env.DEPLOYMENT_TOOLS_ENVIRONMENT_NAME || 'dev'
5
+ const ciSubDomain = deploymentPlatform.ciSubDomain || process.env.DEPLOYMENT_TOOLS_CI_SUB_DOMAIN || 'ci'
6
+ const port = process.env.DEPLOYMENT_TOOLS_PORT || 3000
7
+ const awsAccountId = deploymentPlatform.awsAccountId || process.env.AWS_ACCOUNT_ID
8
+ const awsRegion = deploymentPlatform.awsRegion || process.env.AWS_REGION
8
9
 
9
- export const deploymentQueueUrl = `https://sqs.${awsRegion}.amazonaws.com/${awsAccountId}/${platformName}-${environmentName}`
10
+ const deploymentQueueUrl = `https://sqs.${awsRegion}.amazonaws.com/${awsAccountId}/${platformName}-${environmentName}`
11
+
12
+ return {
13
+ platformName,
14
+ domain,
15
+ environmentName,
16
+ ciSubDomain,
17
+ port,
18
+ awsAccountId,
19
+ awsRegion,
20
+ deploymentQueueUrl
21
+ }
22
+ }
@@ -72,9 +72,6 @@ export class ContainerManagerClient {
72
72
  pathToDeploymentPlatforms,
73
73
  pathToOssyFile
74
74
  ) {
75
- console.log('pathToDeploymentPlatforms', pathToDeploymentPlatforms)
76
- console.log('pathToOssyFile', pathToOssyFile)
77
- console.log('pathToOssyFile resolved', resolve(pathToOssyFile))
78
75
  return Promise.all([
79
76
  this.getDeploymentPlatforms(pathToDeploymentPlatforms),
80
77
  this.getDeployments(pathToOssyFile)
@@ -104,7 +101,7 @@ export class ContainerManagerClient {
104
101
 
105
102
  return AwsCredentialsClient.getTemporaryCredentials(platform.awsAccountId, platform.awsRegion)
106
103
  .then(credentials => {
107
- const deploymentQueueClient = DeploymentQueueClient.new({ credentials })
104
+ const deploymentQueueClient = DeploymentQueueClient.new({ deploymentPlatform: platform, credentials })
108
105
  return deploymentQueueClient.sendMessage(body)
109
106
  .then(() => console.log('[ContainerManagerCommands] Deployment request has been sent'))
110
107
  .catch(error => console.log('[ContainerManagerCommands] Could not send deployment request', error))
@@ -2,7 +2,9 @@ import express from 'express'
2
2
  import { CaddyClient } from './caddy-client.js'
3
3
  import { DockerClient } from './docker-client.js'
4
4
  import { DeploymentQueueClient } from './deployment-queue-client.js'
5
- import * as config from './config.js'
5
+ import { resolveConfiguration } from './config.js'
6
+
7
+ const config = resolveConfiguration()
6
8
 
7
9
  export class ContainerManagerServer {
8
10
 
@@ -4,22 +4,16 @@ import {
4
4
  DeleteMessageCommand,
5
5
  ReceiveMessageCommand
6
6
  } from '@aws-sdk/client-sqs'
7
- import * as config from './config.js'
7
+ import { resolveConfiguration } from './config.js'
8
8
 
9
9
  export class DeploymentQueueClient {
10
10
 
11
- static new({ queueUrl, region, credentials } = {}) {
12
-
13
- const deploymentQueueClientDefaultConfig = {
14
- queueUrl: queueUrl || config.deploymentQueueUrl,
15
- region: region || config.awsRegion,
16
- credentials
17
- }
18
-
19
- return new DeploymentQueueClient(deploymentQueueClientDefaultConfig)
11
+ static new(config) {
12
+ return new DeploymentQueueClient(config)
20
13
  }
21
14
 
22
- constructor({ queueUrl, region, credentials }) {
15
+ constructor({ deploymentPlatform, credentials } = {}) {
16
+ const { region, deploymentQueueUrl: queueUrl } = resolveConfiguration(deploymentPlatform)
23
17
  this.queueUrl = queueUrl
24
18
  this.sqs = new SQSClient({ region, credentials })
25
19
  }