@ossy/deployment-tools 0.0.43 → 0.0.45

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,25 +1,24 @@
1
1
  {
2
2
  "name": "@ossy/deployment-tools",
3
- "version": "0.0.43",
3
+ "version": "0.0.45",
4
4
  "description": "Collection of scripts and tools to aid deployment of containers and static files to Amazon Web Services through GitHub Actions",
5
- "type": "module",
6
- "main": "src/index.js",
5
+ "main": "./src/index.js",
7
6
  "scripts": {
8
7
  "test": "echo \"Error: no test specified\" && exit 1",
9
8
  "build": "",
10
- "build:docs": "jsdoc src/index.js"
9
+ "build:docs": "jsdoc ./src/index.js ./package.json"
11
10
  },
12
11
  "author": "Ossy",
13
12
  "license": "ISC",
14
- "bin": "src/platform-cli.js",
13
+ "bin": "./src/platform-cli.js",
15
14
  "dependencies": {
16
15
  "@actions/core": "^1.10.0",
17
16
  "@aws-sdk/client-sqs": "^3.186.0",
18
17
  "@aws-sdk/client-sts": "^3.188.0",
19
18
  "arg": "^5.0.2",
20
19
  "express": "^4.18.1",
21
- "nanoid": "^4.0.0",
22
- "node-fetch": "^3.2.6"
20
+ "nanoid": "^3.3.4",
21
+ "node-fetch": "^2.6.7"
23
22
  },
24
23
  "devDependencies": {
25
24
  "jsdoc": "^3.6.11"
@@ -1,8 +1,8 @@
1
- import * as core from '@actions/core'
2
- import { STSClient, AssumeRoleWithWebIdentityCommand } from '@aws-sdk/client-sts'
3
- import { logInfo, logError } from './log.js'
1
+ const core = require('@actions/core')
2
+ const { STSClient, AssumeRoleWithWebIdentityCommand } = require('@aws-sdk/client-sts')
3
+ const { logInfo, logError } = require('./log')
4
4
 
5
- export class AwsCredentialsClient {
5
+ class AwsCredentialsClient {
6
6
 
7
7
  static resolveAwsCredentials(platformConfig) {
8
8
  // If awsRoleToAssume is present, then we assume we run in a github workflow
@@ -41,3 +41,7 @@ export class AwsCredentialsClient {
41
41
  }
42
42
 
43
43
  }
44
+
45
+ module.exports = {
46
+ AwsCredentialsClient
47
+ }
@@ -1,7 +1,7 @@
1
- import fetch from 'node-fetch'
2
- import { logInfo, logError } from './log.js'
1
+ const fetch = require('node-fetch')
2
+ const { logInfo, logError } = require('./log')
3
3
 
4
- export const Matchers = {
4
+ const Matchers = {
5
5
  host: host => ({ host: [host] }),
6
6
  path: path => ({ path: [path] })
7
7
  }
@@ -17,7 +17,7 @@ const Handlers = {
17
17
  })
18
18
  }
19
19
 
20
- export class CaddyClient {
20
+ class CaddyClient {
21
21
 
22
22
  static deploy(platformConfig, deploymentRequest) {
23
23
 
@@ -105,3 +105,7 @@ export class CaddyClient {
105
105
  }
106
106
 
107
107
  }
108
+
109
+ module.exports = {
110
+ CaddyClient
111
+ }
@@ -1,7 +1,7 @@
1
- import express from 'express'
2
- import { logInfo } from './log.js'
1
+ const express = require('express')
2
+ const { logInfo } = require('./log')
3
3
 
4
- export class CiRestApi {
4
+ class CiRestApi {
5
5
 
6
6
  static start(platformConfig) {
7
7
  const server = express()
@@ -22,3 +22,7 @@ export class CiRestApi {
22
22
  }
23
23
 
24
24
  }
25
+
26
+ module.exports = {
27
+ CiRestApi
28
+ }
@@ -1,8 +1,8 @@
1
- import arg from 'arg'
2
- import { logInfo } from '../log.js'
3
- import { PlatformClient } from '../platform-client.js'
1
+ const arg = require('arg')
2
+ const { logInfo } = require('../log')
3
+ const { PlatformClient } = require('../platform-client')
4
4
 
5
- export const deployHandler = cliArgs => {
5
+ const deployHandler = cliArgs => {
6
6
  logInfo({ message: 'Running deploy command' })
7
7
 
8
8
  const parsedArgs = arg({
@@ -30,3 +30,7 @@ export const deployHandler = cliArgs => {
30
30
  pathToOssyFile: parsedArgs['--ossyfile']
31
31
  })
32
32
  }
33
+
34
+ module.exports = {
35
+ deployHandler
36
+ }
@@ -1,10 +1,10 @@
1
- import { logError } from '../log.js'
2
- import { startHandler } from './start-handler.js'
3
- import { stopHandler } from './stop-handler.js'
4
- import { statusHandler } from './status-handler.js'
5
- import { deployHandler } from './deploy-handler.js'
1
+ const { logError } = require('../log')
2
+ const { startHandler } = require('./start-handler')
3
+ const { stopHandler } = require('./stop-handler')
4
+ const { statusHandler } = require('./status-handler')
5
+ const { deployHandler } = require('./deploy-handler')
6
6
 
7
- export const runCliCommand = ({ name, args }) => {
7
+ const runCliCommand = ({ name, args }) => {
8
8
 
9
9
  if (!name) return logError({ message: 'No command provided' })
10
10
 
@@ -21,3 +21,7 @@ export const runCliCommand = ({ name, args }) => {
21
21
 
22
22
  commandHandler(args)
23
23
  }
24
+
25
+ module.exports = {
26
+ runCliCommand
27
+ }
@@ -1,9 +1,9 @@
1
- import arg from 'arg'
2
- import { platform } from 'os'
3
- import { logInfo, logError } from '../log.js'
4
- import { PlatformClient } from '../platform-client.js'
1
+ const arg = require('arg')
2
+ const { platform } = require('os')
3
+ const { logInfo, logError } = require('../log')
4
+ const { PlatformClient } = require('../platform-client')
5
5
 
6
- export const startHandler = cliArgs => {
6
+ const startHandler = cliArgs => {
7
7
  logInfo({ message: 'Running start command' })
8
8
 
9
9
  const Platforms = {
@@ -22,3 +22,7 @@ export const startHandler = cliArgs => {
22
22
 
23
23
  PlatformClient.start(parsedArgs['--platforms'])
24
24
  }
25
+
26
+ module.exports = {
27
+ startHandler
28
+ }
@@ -1,7 +1,11 @@
1
- import { exec } from 'child_process'
2
- import { logInfo } from '../log.js'
1
+ const { exec } = require('child_process')
2
+ const { logInfo } = require('../log')
3
3
 
4
- export const statusHandler = () => {
4
+ const statusHandler = () => {
5
5
  logInfo({ message: 'Running status command' })
6
6
  exec('systemctl status deployment-tools.service')
7
7
  }
8
+
9
+ module.exports = {
10
+ statusHandler
11
+ }
@@ -1,7 +1,11 @@
1
- import { exec } from 'child_process'
2
- import { logInfo } from '../log.js'
1
+ const { exec } = require('child_process')
2
+ const { logInfo } = require('../log')
3
3
 
4
- export const stopHandler = () => {
4
+ const stopHandler = () => {
5
5
  logInfo({ message: 'Running stop command' })
6
6
  exec('systemctl stop deployment-tools.service')
7
7
  }
8
+
9
+ module.exports = {
10
+ stopHandler
11
+ }
@@ -1,13 +1,13 @@
1
- import {
1
+ const {
2
2
  SQSClient,
3
3
  SendMessageCommand,
4
4
  DeleteMessageCommand,
5
5
  ReceiveMessageCommand
6
- } from '@aws-sdk/client-sqs'
7
- import { AwsCredentialsClient } from './aws-credentials-client.js'
8
- import { logInfo, logError, logDebug } from './log.js'
6
+ } = require('@aws-sdk/client-sqs')
7
+ const { AwsCredentialsClient } = require('./aws-credentials-client.js')
8
+ const { logInfo, logError, logDebug } = require('./log')
9
9
 
10
- export class DeploymentQueueClient {
10
+ class DeploymentQueueClient {
11
11
 
12
12
  static sendDeploymentRequest(platformConfig, deploymentRequest) {
13
13
  logInfo({ message: '[DeploymentQueueClient] Starting deployment sequence' })
@@ -72,3 +72,7 @@ export class DeploymentQueueClient {
72
72
  }
73
73
 
74
74
  }
75
+
76
+ module.exports = {
77
+ DeploymentQueueClient
78
+ }
@@ -1,14 +1,9 @@
1
- import { exec } from 'child_process'
2
- import fs from 'fs'
3
- import { nanoid } from 'nanoid'
4
- import path from 'path'
5
- import { fileURLToPath } from 'url'
6
- import { logInfo, logError } from './log.js'
1
+ const { exec } = require('child_process')
2
+ const fs = require('fs')
3
+ const { nanoid } = require('nanoid')
4
+ const { logInfo, logError } = require('./log')
7
5
 
8
- const __filename = fileURLToPath(import.meta.url)
9
- const __dirname = path.dirname(__filename)
10
-
11
- export class DockerClient {
6
+ class DockerClient {
12
7
 
13
8
  static createDockerNetworkForContainerManagerServer(platformConfig) {
14
9
  logInfo({ message: '[DockerClient] Creating docker network for comunication between containers' })
@@ -77,3 +72,7 @@ ${DockerClient.startContainer(platformConfig, deploymentRequest)}`
77
72
  }
78
73
 
79
74
  }
75
+
76
+ module.exports = {
77
+ DockerClient
78
+ }
package/src/index.js CHANGED
@@ -1,3 +1,9 @@
1
- export { PlatformClient } from './platform-client.js'
2
- export { PlatformTemplateService } from './platform-template.js'
3
- export { PlatformConfigService } from './platform-config.js'
1
+ const { PlatformClient } = require('./platform-client')
2
+ const { PlatformTemplateService } = require('./platform-template')
3
+ const { PlatformConfigService } = require('./platform-config')
4
+
5
+ module.exports = {
6
+ PlatformClient,
7
+ PlatformTemplateService,
8
+ PlatformConfigService
9
+ }
package/src/log.js CHANGED
@@ -14,21 +14,27 @@ const TypeOfMessage = {
14
14
  const log = (...params) => { console.log(...params) }
15
15
  const prefixTo = (prefix, message) => `[${prefix}]${message.startsWith('[') ? '' : ': '}`
16
16
 
17
- export const logInfo = logInput => {
17
+ const logInfo = logInput => {
18
18
  const messagePrefix = prefixTo(TypeOfMessage.Info, logInput.message)
19
19
  log(`${messagePrefix}${logInput.message}`)
20
20
  }
21
21
 
22
- export const logError = logInput => {
22
+ const logError = logInput => {
23
23
  const messagePrefix = prefixTo(TypeOfMessage.Error, logInput.message)
24
24
  log(`${messagePrefix}${logInput.message}`)
25
25
  logInput.error && log('\n[Reason]:', logInput.error, '\n')
26
26
  }
27
27
 
28
- export const logDebug = logInput => {
28
+ const logDebug = logInput => {
29
29
  const isDebugOn = process.env.DEBUG || false
30
30
  if (!isDebugOn) return
31
31
  const messagePrefix = prefixTo(TypeOfMessage.Debug, logInput.message)
32
32
  log(`${messagePrefix}${logInput.message}`)
33
33
  logInput.data && log('\n[Debug data]:', logInput.data, '\n')
34
34
  }
35
+
36
+ module.exports = {
37
+ logInfo,
38
+ logError,
39
+ logDebug
40
+ }
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { runCliCommand } from './cli-commands/index.js'
2
+ const { runCliCommand } = require('./cli-commands/index')
3
3
 
4
4
  //eslint-disable-next-line no-unused-vars
5
5
  const [_, __, command, ...restArgs] = process.argv
@@ -1,16 +1,16 @@
1
- import { resolve } from 'path'
2
- import { readFileSync } from 'fs'
3
- import { SupportedDeploymentTypes } from './types.js'
4
- import { PlatformTemplateService } from './platform-template.js'
5
- import { PlatformConfigService } from './platform-config.js'
6
- import { CaddyClient } from './caddy-client.js'
7
- import { DockerClient } from './docker-client.js'
8
- import { DeploymentQueueClient } from './deployment-queue-client.js'
9
- import { CiRestApi } from './ci-rest-api.js'
10
- import { logError } from './log.js'
1
+ const { resolve } = require('path')
2
+ const { readFileSync } = require('fs')
3
+ const { SupportedDeploymentTypes } = require('./types')
4
+ const { PlatformTemplateService } = require('./platform-template')
5
+ const { PlatformConfigService } = require('./platform-config')
6
+ const { CaddyClient } = require('./caddy-client')
7
+ const { DockerClient } = require('./docker-client')
8
+ const { DeploymentQueueClient } = require('./deployment-queue-client')
9
+ const { CiRestApi } = require('./ci-rest-api')
10
+ const { logError } = require('./log')
11
11
 
12
12
  // journalctl -u service-name.service
13
- export class PlatformClient {
13
+ class PlatformClient {
14
14
 
15
15
  static start(platformTemplatesFilePath) {
16
16
  PlatformTemplateService.readFromFile(platformTemplatesFilePath).then(([firstPlatformTemplateFound]) => {
@@ -93,3 +93,7 @@ export class PlatformClient {
93
93
  }
94
94
 
95
95
  }
96
+
97
+ module.exports = {
98
+ PlatformClient
99
+ }
@@ -1,9 +1,6 @@
1
- import {
2
- SupportedEnvironments,
3
- SupportedRegions
4
- } from './types.js'
1
+ const { SupportedEnvironments, SupportedRegions } = require('./types')
5
2
 
6
- export class PlatformConfigService {
3
+ class PlatformConfigService {
7
4
 
8
5
  static from(template) {
9
6
 
@@ -32,3 +29,7 @@ export class PlatformConfigService {
32
29
  }
33
30
 
34
31
  }
32
+
33
+ module.exports = {
34
+ PlatformConfigService
35
+ }
@@ -1,10 +1,10 @@
1
- import { resolve } from 'path'
2
- import { readFileSync } from 'fs'
3
- import { logError, logInfo } from './log.js'
4
- // @param {number} [foo=1]
1
+ const { resolve } = require('path')
2
+ const { readFileSync } = require('fs')
3
+ const { logError, logInfo } = require('./log')
5
4
 
6
5
  /**
7
6
  * Platform template definition
7
+ * @namespace PlatformTemplate
8
8
  * @typedef {Object} PlatformTemplate
9
9
  * @property {string} platformName - Name of platform
10
10
  * @property {string} domain - example.com
@@ -20,7 +20,7 @@ import { logError, logInfo } from './log.js'
20
20
  * @property {string} ciServerName - ?
21
21
  * @property {string} ciDockerNetworkName - ?
22
22
  */
23
- export class PlatformTemplateService {
23
+ class PlatformTemplateService {
24
24
 
25
25
  /**
26
26
  * Reads the json file that holds the platform templates
@@ -61,3 +61,7 @@ export class PlatformTemplateService {
61
61
  return obj
62
62
  }
63
63
  }
64
+
65
+ module.exports = {
66
+ PlatformTemplateService
67
+ }
package/src/types.js CHANGED
@@ -20,11 +20,11 @@
20
20
  // awsKeyPairName?: string;
21
21
  // }
22
22
 
23
- export const SupportedRegions = {
23
+ const SupportedRegions = {
24
24
  North: 'eu-north-1'
25
25
  }
26
26
 
27
- export const SupportedEnvironments = {
27
+ const SupportedEnvironments = {
28
28
  LOCAL: 'local',
29
29
  QA: 'qa',
30
30
  TEST: 'test',
@@ -32,7 +32,7 @@ export const SupportedEnvironments = {
32
32
  PROD: 'prod'
33
33
  }
34
34
 
35
- export const SupportedDeploymentTypes = {
35
+ const SupportedDeploymentTypes = {
36
36
  Container: 'CONTAINER'
37
37
  // Static = 'STATIC'
38
38
  }
@@ -63,3 +63,9 @@ export const SupportedDeploymentTypes = {
63
63
  // authentication?: string;
64
64
  // username?: string;
65
65
  // }
66
+
67
+ module.exports = {
68
+ SupportedRegions,
69
+ SupportedEnvironments,
70
+ SupportedDeploymentTypes
71
+ }