@ossy/deployment-tools 0.0.47 → 0.0.49

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/cdk.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "app": "node src/infrastructure/cli.js",
2
+ "app": "node ./src/infrastructure/cli.js",
3
3
  "watch": {
4
4
  "include": [
5
5
  "**"
@@ -0,0 +1,19 @@
1
+
2
+ module.exports = {
3
+ plugins: ['plugins/markdown'],
4
+ recurseDepth: 10,
5
+ source: {
6
+ // includePattern: '.+\\.js(doc|x)?$',
7
+ includePattern: '.+\\.js$',
8
+ excludePattern: '(^|\\/|\\\\)_'
9
+ },
10
+ sourceType: 'module',
11
+ tags: {
12
+ allowUnknownTags: true,
13
+ dictionaries: ['jsdoc', 'closure']
14
+ },
15
+ templates: {
16
+ cleverLinks: false,
17
+ monospaceLinks: false
18
+ }
19
+ }
package/package.json CHANGED
@@ -1,23 +1,18 @@
1
1
  {
2
2
  "name": "@ossy/deployment-tools",
3
- "version": "0.0.47",
3
+ "version": "0.0.49",
4
4
  "description": "Collection of scripts and tools to aid deployment of containers and static files to Amazon Web Services through GitHub Actions",
5
+ "source": "./src/index.js",
5
6
  "main": "./src/index.js",
6
7
  "scripts": {
7
8
  "test": "echo \"Error: no test specified\" && exit 1",
8
9
  "build": "echo \"The build step is not required when using JavaScript!\" && exit 0",
9
- "build:docs": "jsdoc ./src/index.js ./package.json",
10
+ "build:docs": "jsdoc -c ./jsdoc.config.js ./src/index.js ./package.json",
10
11
  "cdk": "cdk"
11
12
  },
12
13
  "author": "Ossy",
13
14
  "license": "ISC",
14
- "bin": {
15
- "aws": "./src/aws-credentials/cli.js",
16
- "deploy": "./src/deploy/cli.js",
17
- "template": "./src/template/cli.js",
18
- "server": "./src/server/cli.js",
19
- "infrastructure": "./src/infrastructure/cli.js"
20
- },
15
+ "bin": "./src/index.cli.js",
21
16
  "dependencies": {
22
17
  "@actions/core": "^1.10.0",
23
18
  "@aws-sdk/client-sqs": "^3.186.0",
@@ -1,4 +1,3 @@
1
- #!/usr/bin/env node
2
1
  const arg = require('arg')
3
2
  const { AwsCredentialsService } = require('./aws-credentials')
4
3
 
@@ -6,10 +5,7 @@ const { PlatformTemplateService } = require('../template')
6
5
  const { PlatformConfigService } = require('../config')
7
6
  const { logInfo, logError } = require('../log')
8
7
 
9
- //eslint-disable-next-line no-unused-vars
10
- const [_, __, command, ...options] = process.argv
11
-
12
- const resolveCredentials = () => {
8
+ const resolveCredentials = options => {
13
9
  logInfo({ message: 'resolve-credentials' })
14
10
 
15
11
  const parsedArgs = arg({
@@ -25,7 +21,7 @@ const resolveCredentials = () => {
25
21
  })
26
22
  }
27
23
 
28
- const assumeRole = () => {
24
+ const assumeRole = options => {
29
25
  logInfo({ message: 'assume-role' })
30
26
 
31
27
  const parsedArgs = arg({
@@ -51,6 +47,10 @@ const assumeRole = () => {
51
47
 
52
48
  }
53
49
 
54
- !!command
55
- ? { 'resolve-credentials': resolveCredentials, 'assume-role': assumeRole }[command]()
56
- : logError({ message: 'No command provided' })
50
+ module.exports = {
51
+ handler: ([command, ...options]) => {
52
+ !!command
53
+ ? { 'resolve-credentials': resolveCredentials, 'assume-role': assumeRole }[command](options)
54
+ : logError({ message: 'No command provided' })
55
+ }
56
+ }
package/src/deploy/cli.js CHANGED
@@ -1,12 +1,9 @@
1
1
  #!/usr/bin/env node
2
2
  const arg = require('arg')
3
3
  const { PlatformDeploymentService } = require('./platform-deployment')
4
- const { logInfo } = require('../log')
4
+ const { logInfo, logError } = require('../log')
5
5
 
6
- //eslint-disable-next-line no-unused-vars
7
- const [_, __, ...options] = process.argv
8
-
9
- const deploy = () => {
6
+ const deploy = options => {
10
7
  logInfo({ message: 'Running deploy command' })
11
8
 
12
9
  const parsedArgs = arg({
@@ -35,4 +32,10 @@ const deploy = () => {
35
32
  })
36
33
  }
37
34
 
38
- deploy()
35
+ module.exports = {
36
+ handler: ([command, ...options]) => {
37
+ !!command
38
+ ? { deploy }[command](options)
39
+ : logError({ message: 'No command provided' })
40
+ }
41
+ }
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/env node
2
+ /* eslint-disable global-require, no-unused-vars */
3
+
4
+ const [_, __, handlerName, ...restArgs] = process.argv
5
+
6
+ const loadHandler = {
7
+ aws: () => require('./aws-credentials/cli.js'),
8
+ deployment: () => require('./deploy/cli.js'),
9
+ template: () => require('./template/cli.js'),
10
+ server: () => require('./server/cli.js')
11
+ }[handlerName]
12
+
13
+ !!loadHandler && loadHandler().handler(restArgs)
@@ -9,7 +9,7 @@ User=caddy
9
9
  Group=caddy
10
10
  AmbientCapabilities=CAP_NET_BIND_SERVICE
11
11
  CapabilityBoundingSet=CAP_NET_BIND_SERVICE
12
- ExecStart=/usr/bin/npx --yes @ossy/deployment-tools start --platforms /home/ubuntu/deployment-platform.json
12
+ ExecStart=/usr/bin/npx --yes @ossy/deployment-tools start --platforms /home/ubuntu/platform-config.json
13
13
  Restart=on-failure
14
14
 
15
15
  [Install]
package/src/server/cli.js CHANGED
@@ -1,22 +1,18 @@
1
- #!/usr/bin/env node
2
1
  const arg = require('arg')
3
2
  const { exec } = require('child_process')
4
- const { PlatformClient } = require('./platform-server')
3
+ const { PlatformServerService } = require('./platform-server')
5
4
 
6
5
  const { logInfo, logError } = require('../log')
7
6
 
8
- //eslint-disable-next-line no-unused-vars
9
- const [_, __, command, ...restArgs] = process.argv
10
-
11
- const start = cliArgs => {
7
+ const start = options => {
12
8
  logInfo({ message: 'Running start command' })
13
9
 
14
10
  const parsedArgs = arg({
15
11
  '--platforms': String,
16
12
  '-p': '--platforms'
17
- }, { argv: cliArgs })
13
+ }, { argv: options })
18
14
 
19
- PlatformClient.start(parsedArgs['--platforms'])
15
+ PlatformServerService.start(parsedArgs['--platforms'])
20
16
  }
21
17
 
22
18
  const status = () => {
@@ -29,6 +25,10 @@ const stop = () => {
29
25
  exec('systemctl stop deployment-tools.service')
30
26
  }
31
27
 
32
- !!command
33
- ? { start, status, stop }[command]()
34
- : logError({ message: 'No command provided' })
28
+ module.exports = {
29
+ handler: ([command, ...options]) => {
30
+ !!command
31
+ ? { start, status, stop }[command](options)
32
+ : logError({ message: 'No command provided' })
33
+ }
34
+ }
@@ -1,13 +1,9 @@
1
- #!/usr/bin/env node
2
1
  const arg = require('arg')
3
2
  const { PlatformTemplateService } = require('./platform-template')
4
3
 
5
4
  const { logInfo, logError } = require('../log')
6
5
 
7
- //eslint-disable-next-line no-unused-vars
8
- const [_, __, command, ...options] = process.argv
9
-
10
- const validate = () => {
6
+ const validate = options => {
11
7
  logInfo({ message: 'Running validate command' })
12
8
 
13
9
  const parsedArgs = arg({
@@ -19,4 +15,10 @@ const validate = () => {
19
15
  .then(() => logInfo({ message: 'Template is valid' }))
20
16
  }
21
17
 
22
- command === 'validate' ? validate() : logError({ message: 'No command provided' })
18
+ module.exports = {
19
+ handler: ([command, ...options]) => {
20
+ !!command
21
+ ? { validate }[command](options)
22
+ : logError({ message: 'No command provided' })
23
+ }
24
+ }