presidium 0.25.2 → 0.26.1
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/Archive.test.js +48 -37
- package/Docker.js +1 -0
- package/DockerService.js +1 -0
- package/EcrLoginPassword.js +16 -2
- package/internal/pathWalk.js +29 -21
- package/internal/pathWalk.test.js +20 -11
- package/package.json +2 -1
package/Archive.test.js
CHANGED
|
@@ -6,42 +6,53 @@ const pathResolve = require('./internal/pathResolve')
|
|
|
6
6
|
const map = require('rubico/map')
|
|
7
7
|
const reduce = require('rubico/reduce')
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const extracted = await archive.untar(pack)
|
|
15
|
-
assert(extracted.size > 0)
|
|
16
|
-
for (const [path, stream] of extracted) {
|
|
17
|
-
assert('header' in stream)
|
|
18
|
-
assert(!path.startsWith('/'))
|
|
19
|
-
assert.equal(typeof path, 'string')
|
|
20
|
-
assert.equal(typeof stream[Symbol.asyncIterator], 'function')
|
|
21
|
-
}
|
|
22
|
-
})
|
|
23
|
-
.case({
|
|
24
|
-
Dockerfile: 'FROM node:15-alpine'
|
|
25
|
-
}, async archive => {
|
|
26
|
-
const pack = await archive.tar(pathResolve(__dirname, 'internal'))
|
|
27
|
-
const extracted = await archive.untar(pack)
|
|
28
|
-
const dir = await fs.readdir(pathResolve(__dirname, 'internal'))
|
|
29
|
-
assert.equal(extracted.size, dir.length + 1) // extra Dockerfile
|
|
30
|
-
assert(extracted.has('Dockerfile'))
|
|
31
|
-
assert.equal(
|
|
32
|
-
await reduce((a, b) => a + b, '')(extracted.get('Dockerfile')),
|
|
33
|
-
'FROM node:15-alpine')
|
|
9
|
+
const test = new Test('Archive', Archive)
|
|
10
|
+
|
|
11
|
+
.case(async archive => {
|
|
12
|
+
const pack = await archive.tar(pathResolve(__dirname), {
|
|
13
|
+
ignore: ['Dockerfile', 'node_modules', '.git', '.nyc_output'],
|
|
34
14
|
})
|
|
35
|
-
.
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
15
|
+
const extracted = await archive.untar(pack)
|
|
16
|
+
assert(extracted.size > 0)
|
|
17
|
+
for (const [path, stream] of extracted) {
|
|
18
|
+
assert('header' in stream)
|
|
19
|
+
assert(!path.startsWith('/'))
|
|
20
|
+
assert.equal(typeof path, 'string')
|
|
21
|
+
assert.equal(typeof stream[Symbol.asyncIterator], 'function')
|
|
22
|
+
}
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
.case({
|
|
26
|
+
Dockerfile: 'FROM node:15-alpine'
|
|
27
|
+
}, async archive => {
|
|
28
|
+
const pack = await archive.tar(pathResolve(__dirname, 'internal'))
|
|
29
|
+
const extracted = await archive.untar(pack)
|
|
30
|
+
const dir = await fs.readdir(pathResolve(__dirname, 'internal'))
|
|
31
|
+
assert.equal(extracted.size, dir.length + 1) // extra Dockerfile
|
|
32
|
+
assert(extracted.has('Dockerfile'))
|
|
33
|
+
assert.equal(
|
|
34
|
+
await reduce((a, b) => a + b, '')(extracted.get('Dockerfile')),
|
|
35
|
+
'FROM node:15-alpine')
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
.case({
|
|
39
|
+
Dockerfile: 'FROM busybox:1.32'
|
|
40
|
+
'.aws/credentials': '[claimyr]\naccessKeyId\nsecretAccessKey',
|
|
41
|
+
}, async archive => {
|
|
42
|
+
const pack = await archive.tar(`${pathResolve(__dirname, 'internal')}/`, {
|
|
43
|
+
ignore: ['hashJSON.js'],
|
|
47
44
|
})
|
|
45
|
+
const extracted = await archive.untar(pack)
|
|
46
|
+
assert(extracted.size > 0)
|
|
47
|
+
assert(extracted.has('Dockerfile'))
|
|
48
|
+
assert(extracted.has('.aws/credentials'))
|
|
49
|
+
assert.equal(
|
|
50
|
+
await reduce((a, b) => a + b, '')(extracted.get('Dockerfile')),
|
|
51
|
+
'FROM busybox:1.32')
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
if (process.argv[1] == __filename) {
|
|
55
|
+
test()
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
module.exports = test
|
package/Docker.js
CHANGED
|
@@ -332,6 +332,7 @@ Docker.prototype.removeImage = function dockerRemoveImage(image, options) {
|
|
|
332
332
|
* source: string, // name of volume
|
|
333
333
|
* target: string, // mounted path inside container
|
|
334
334
|
* readonly: boolean,
|
|
335
|
+
* type?: string, // default volume
|
|
335
336
|
* }>|Array<string>, // '<source>:<target>[:readonly]'
|
|
336
337
|
*
|
|
337
338
|
* // Dockerfile defaults
|
package/DockerService.js
CHANGED
|
@@ -237,6 +237,7 @@ DockerService.prototype.synchronize = function dockerServiceSynchronize() {
|
|
|
237
237
|
* source: string, // name of volume
|
|
238
238
|
* target: string, // mounted path inside container
|
|
239
239
|
* readonly: boolean,
|
|
240
|
+
* type?: string, // default volume
|
|
240
241
|
* }>|Array<string>, // '<source>:<target>[:readonly]'
|
|
241
242
|
*
|
|
242
243
|
* cmd: Array<string|number>, // CMD
|
package/EcrLoginPassword.js
CHANGED
|
@@ -9,13 +9,27 @@ const streamToString = require('./internal/streamToString')
|
|
|
9
9
|
* @synopsis
|
|
10
10
|
* ```coffeescript [specscript]
|
|
11
11
|
* EcrLoginPassword(options {
|
|
12
|
+
* awsAccessKeyId?: string,
|
|
13
|
+
* awsSecretAccessKey?: string,
|
|
14
|
+
* awsProfile?: string,
|
|
12
15
|
* awsRegion: string,
|
|
13
|
-
* awsProfile: string,
|
|
14
16
|
* }) -> Promise<password string>
|
|
15
17
|
* ```
|
|
16
18
|
*/
|
|
17
19
|
|
|
18
|
-
const EcrLoginPassword = async function ({
|
|
20
|
+
const EcrLoginPassword = async function ({
|
|
21
|
+
awsAccessKeyId,
|
|
22
|
+
awsSecretAccessKey,
|
|
23
|
+
awsRegion,
|
|
24
|
+
awsProfile,
|
|
25
|
+
}) {
|
|
26
|
+
if (awsAccessKeyId != null && awsSecretAccessKey != null) {
|
|
27
|
+
const childprocess = exec(`
|
|
28
|
+
AWS_ACCESS_KEY_ID=${awsAccessKeyId} AWS_SECRET_ACCESS_KEY=${awsSecretAccessKey} aws ecr --region ${awsRegion} get-login-password
|
|
29
|
+
`.trim())
|
|
30
|
+
return streamToString(childprocess.stdout).then(callProp('trim'))
|
|
31
|
+
}
|
|
32
|
+
|
|
19
33
|
const childprocess = exec(`
|
|
20
34
|
aws ecr --profile ${awsProfile} --region ${awsRegion} get-login-password
|
|
21
35
|
`.trim())
|
package/internal/pathWalk.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
require('rubico/global')
|
|
2
2
|
const fs = require('fs/promises')
|
|
3
|
+
const { minimatch } = require('minimatch')
|
|
3
4
|
const pathResolve = require('./pathResolve')
|
|
4
5
|
const isArray = require('./isArray')
|
|
5
6
|
|
|
@@ -20,29 +21,36 @@ const isArray = require('./isArray')
|
|
|
20
21
|
* }) // -> Promise<paths Array<string>>
|
|
21
22
|
* ```
|
|
22
23
|
*/
|
|
23
|
-
const pathWalk = function (path, options) {
|
|
24
|
-
const ignore =
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
curry.arity(2, fs.readdir, __, { withFileTypes: true }),
|
|
29
|
-
() => []),
|
|
24
|
+
const pathWalk = async function (path, options = {}) {
|
|
25
|
+
const { ignore = [] } = options
|
|
26
|
+
const absPath = pathResolve(path)
|
|
27
|
+
const dirents = await fs.readdir(absPath, { withFileTypes: true })
|
|
28
|
+
const result = []
|
|
30
29
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
30
|
+
for (const dirent of dirents) {
|
|
31
|
+
const dirName = dirent.name
|
|
32
|
+
const dirPath = pathResolve(path, dirName)
|
|
33
|
+
let shouldIgnore = false
|
|
34
|
+
for (const pattern of ignore) {
|
|
35
|
+
if (minimatch(dirPath, pattern) || minimatch(dirName, pattern)) {
|
|
36
|
+
shouldIgnore = true
|
|
37
|
+
break
|
|
39
38
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (shouldIgnore) {
|
|
42
|
+
continue
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (dirent.isDirectory()) {
|
|
46
|
+
const subPaths = await pathWalk(dirPath, options)
|
|
47
|
+
result.push(...subPaths)
|
|
48
|
+
} else {
|
|
49
|
+
result.push(dirPath)
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return result
|
|
46
54
|
}
|
|
47
55
|
|
|
48
56
|
module.exports = pathWalk
|
|
@@ -3,14 +3,23 @@ const Test = require('thunk-test')
|
|
|
3
3
|
const pathWalk = require('./pathWalk')
|
|
4
4
|
const pathResolve = require('./pathResolve')
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
.
|
|
15
|
-
|
|
16
|
-
|
|
6
|
+
const test = Test('pathWalk', pathWalk)
|
|
7
|
+
|
|
8
|
+
.case(__dirname, function (paths) {
|
|
9
|
+
assert(paths.length > 0)
|
|
10
|
+
this.allInternalPaths = paths
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
.case(__dirname, { ignore: ['pathWalk.js'] }, function (paths) {
|
|
14
|
+
assert.equal(paths.length, this.allInternalPaths.length - 1)
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
.case(__dirname, { ignore: [pathResolve(__dirname, 'pathWalk.js')] }, function (paths) {
|
|
18
|
+
assert.equal(paths.length, this.allInternalPaths.length - 1)
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
if (process.argv[1] == __filename) {
|
|
22
|
+
test()
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
module.exports = test
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "presidium",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.26.1",
|
|
4
4
|
"description": "A library for creating web services",
|
|
5
5
|
"author": "Richard Tong",
|
|
6
6
|
"license": "MIT",
|
|
@@ -33,6 +33,7 @@
|
|
|
33
33
|
"aws-sdk": "^2.1123.0",
|
|
34
34
|
"bcrypt": "^5.1.0",
|
|
35
35
|
"ioredis": "^4.19.0",
|
|
36
|
+
"minimatch": "^9.0.3",
|
|
36
37
|
"mongodb": "^3.6.3",
|
|
37
38
|
"node-fetch": "^2.6.1",
|
|
38
39
|
"rubico": "latest",
|