@ossy/deployment-tools 0.0.84 → 0.0.85
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 +1 -1
- package/src/cms/cli.js +9 -8
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ossy/deployment-tools",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.85",
|
|
4
4
|
"description": "Collection of scripts and tools to aid deployment of containers and static files to Amazon Web Services through GitHub Actions",
|
|
5
5
|
"source": "./src/index.js",
|
|
6
6
|
"main": "./src/index.js",
|
package/src/cms/cli.js
CHANGED
|
@@ -5,6 +5,10 @@ const arg = require('arg')
|
|
|
5
5
|
const fetch = require('node-fetch')
|
|
6
6
|
const { logInfo, logError } = require('../log')
|
|
7
7
|
|
|
8
|
+
const config = {
|
|
9
|
+
apiUrl: 'https://api.ossy.se/api/v0'
|
|
10
|
+
}
|
|
11
|
+
|
|
8
12
|
const getTokenPayload = token =>
|
|
9
13
|
JSON.parse(Buffer.from(token.split('.')[1], 'base64').toString())
|
|
10
14
|
|
|
@@ -23,26 +27,23 @@ const importResourceTemplates = options => {
|
|
|
23
27
|
const tokenPayload = getTokenPayload(token)
|
|
24
28
|
const ossyfile = JSON.parse(readFileSync(resolve(parsedArgs['--ossy-file']), 'utf8'))
|
|
25
29
|
|
|
26
|
-
console.log('ossyfile', ossyfile)
|
|
27
|
-
|
|
28
30
|
if (!token) return logError({ message: '[CMS] No token provided with --authentication'})
|
|
29
31
|
if (!ossyfile?.workspaceId) return logError({ message: '[CMS] No workspaceId provided in ossy.json'})
|
|
30
32
|
if (!ossyfile?.resourceTemplates) return logError({ message: '[CMS] No resource templates provided in ossy.json'})
|
|
31
33
|
|
|
32
34
|
logInfo({ message: '[CMS] uploading resource templates' })
|
|
33
35
|
|
|
36
|
+
const endpoint = `${config.apiUrl}/workspaces/${ossyfile.workspaceId}/resource-templates`
|
|
37
|
+
|
|
34
38
|
const fetchOptions = {
|
|
35
39
|
method: 'POST',
|
|
36
40
|
headers: { 'Authorization': token, 'Content-Type': 'application/json' },
|
|
37
41
|
body: JSON.stringify(ossyfile.resourceTemplates)
|
|
38
42
|
}
|
|
39
43
|
|
|
40
|
-
fetch(
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
)
|
|
44
|
-
.then(() => logInfo({ message: '[CMS] done' }))
|
|
45
|
-
.catch(error => logError({ message: '[CMS] Error', error }))
|
|
44
|
+
fetch(endpoint, fetchOptions)
|
|
45
|
+
.then(() => logInfo({ message: '[CMS] Done' }))
|
|
46
|
+
.catch(error => logError({ message: '[CMS] Error', error }))
|
|
46
47
|
}
|
|
47
48
|
|
|
48
49
|
module.exports = {
|