@codedependant/semantic-release-docker 3.1.1 → 4.1.0
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/CHANGELOG.md +51 -0
- package/README.md +82 -35
- package/lib/build-config.js +5 -2
- package/lib/docker/image.js +18 -3
- package/lib/handlebars/helpers/endswith.js +10 -0
- package/lib/handlebars/helpers/eq.js +7 -0
- package/lib/handlebars/helpers/gt.js +7 -0
- package/lib/handlebars/helpers/gte.js +7 -0
- package/lib/handlebars/helpers/includes.js +9 -0
- package/lib/handlebars/helpers/index.js +17 -0
- package/lib/handlebars/helpers/lower.js +8 -0
- package/lib/handlebars/helpers/lt.js +7 -0
- package/lib/handlebars/helpers/lte.js +7 -0
- package/lib/handlebars/helpers/neq.js +9 -0
- package/lib/handlebars/helpers/pick.js +13 -0
- package/lib/handlebars/helpers/split.js +5 -0
- package/lib/handlebars/helpers/startswith.js +10 -0
- package/lib/handlebars/helpers/upper.js +9 -0
- package/lib/handlebars/index.js +10 -0
- package/lib/lang/string/template.js +9 -7
- package/lib/prepare.js +1 -0
- package/lib/publish.js +1 -0
- package/lib/verify.js +51 -36
- package/package.json +21 -34
- package/test/common/git/add.js +0 -9
- package/test/common/git/commit.js +0 -11
- package/test/common/git/head.js +0 -10
- package/test/common/git/index.js +0 -13
- package/test/common/git/init-origin.js +0 -13
- package/test/common/git/init-remote.js +0 -16
- package/test/common/git/init.js +0 -20
- package/test/common/git/push.js +0 -9
- package/test/common/git/tag.js +0 -13
- package/test/common/git/tags.js +0 -14
- package/test/fixture/docker/Dockerfile.prepare +0 -4
- package/test/fixture/docker/Dockerfile.publish +0 -4
- package/test/fixture/docker/Dockerfile.test +0 -4
- package/test/fixture/package.json +0 -4
- package/test/fixture/pkg/one/package.json +0 -5
- package/test/fixture/pkg/two/package.json +0 -0
- package/test/integration/prepare.js +0 -74
- package/test/integration/publish.js +0 -60
- package/test/integration/release.js +0 -92
- package/test/integration/verify.js +0 -205
- package/test/unit/build-config.js +0 -167
- package/test/unit/build-template-vars.js +0 -63
- package/test/unit/docker/image.js +0 -289
- package/test/unit/lang/array.js +0 -34
- package/test/unit/lang/object.js +0 -45
- package/test/unit/lang/string.js +0 -37
- package/test/unit/parse-pkg-name.js +0 -27
- package/test/unit/read-pkg.js +0 -36
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,56 @@
|
|
|
1
1
|
# Semantic Release Docker
|
|
2
2
|
|
|
3
|
+
# [4.1.0](https://github.com/esatterwhite/semantic-release-docker/compare/v4.0.0...v4.1.0) (2022-04-10)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Chores
|
|
7
|
+
|
|
8
|
+
* **deps**: semantic-release/error@3.0.0 [d55ff11](https://github.com/esatterwhite/semantic-release-docker/commit/d55ff1108a0130ce10932e409683fb741fb315d3) - Eric Satterwhite
|
|
9
|
+
* **deps**: tap@16.0.0 [94d3340](https://github.com/esatterwhite/semantic-release-docker/commit/94d3340dba42ed702b71325ea5afc2f627df1fcc) - Eric Satterwhite
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### Features
|
|
13
|
+
|
|
14
|
+
* **docker**: allow command to be run via docker in verify step [4646bd6](https://github.com/esatterwhite/semantic-release-docker/commit/4646bd681cb4d7ee4a48a9187fbe7dfe88686b78) - Eric Satterwhite, closes: [#20](https://github.com/esatterwhite/semantic-release-docker/issues/20)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Miscellaneous
|
|
18
|
+
|
|
19
|
+
* add prerelease example [90158fd](https://github.com/esatterwhite/semantic-release-docker/commit/90158fdaa65b35a861ce40ca2c3a660f28446f72) - Eric Satterwhite
|
|
20
|
+
* Update Readme [74f9910](https://github.com/esatterwhite/semantic-release-docker/commit/74f99107723223a67009c96a762b200f8d25621d) - GitHub
|
|
21
|
+
|
|
22
|
+
# [4.0.0](https://github.com/esatterwhite/semantic-release-docker/compare/v3.1.2...v4.0.0) (2021-12-31)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### Chores
|
|
26
|
+
|
|
27
|
+
* **deps**: @codedependant/release-config-npm@1.0.4 [fdb0985](https://github.com/esatterwhite/semantic-release-docker/commit/fdb0985d346b1f74d61cf4d0ef238743e5f1d6f4) - Eric Satterwhite
|
|
28
|
+
* **deps**: eslint-config-codedependant@3.0.0 [6807acc](https://github.com/esatterwhite/semantic-release-docker/commit/6807accd81002e7bc86d79f260c19141f40363f6) - Eric Satterwhite
|
|
29
|
+
* **deps**: eslint@8.5.0 [f7e0bbe](https://github.com/esatterwhite/semantic-release-docker/commit/f7e0bbeb67156dedb0b3a8a2d0bad0d8828c7dde) - Eric Satterwhite
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
### Features
|
|
33
|
+
|
|
34
|
+
* **template**: replace simple template engine with handlebars [b20c89c](https://github.com/esatterwhite/semantic-release-docker/commit/b20c89ca979de7969028541b6a29ac9b867a06c3) - Eric Satterwhite, closes: [#16](https://github.com/esatterwhite/semantic-release-docker/issues/16)
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
### Miscellaneous
|
|
38
|
+
|
|
39
|
+
* fix typo [3aa33ba](https://github.com/esatterwhite/semantic-release-docker/commit/3aa33ba2fc003a9f88e6b1d4263999152a577eda) - Eric Satterwhite
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
### **BREAKING CHANGES**
|
|
43
|
+
|
|
44
|
+
* **template:** Use handlebars as template engine. Place holders are
|
|
45
|
+
now double curlies `{{ }}`
|
|
46
|
+
|
|
47
|
+
## [3.1.2](https://github.com/esatterwhite/semantic-release-docker/compare/v3.1.1...v3.1.2) (2021-09-18)
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
### Bug Fixes
|
|
51
|
+
|
|
52
|
+
* **config**: ensure the docker context is passed image builds [366b8d1](https://github.com/esatterwhite/semantic-release-docker/commit/366b8d1d1f90855a76cfdb78009ec4510ead769e) - Eric Satterwhite, closes: [#13](https://github.com/esatterwhite/semantic-release-docker/issues/13)
|
|
53
|
+
|
|
3
54
|
## [3.1.1](https://github.com/esatterwhite/semantic-release-docker/compare/v3.1.0...v3.1.1) (2021-09-18)
|
|
4
55
|
|
|
5
56
|
|
package/README.md
CHANGED
|
@@ -20,7 +20,7 @@ builds a an image using the specified docker file and context. This image will b
|
|
|
20
20
|
### publish
|
|
21
21
|
|
|
22
22
|
pushes the tags Images with specified tags and pushes them to the registry.
|
|
23
|
-
Tags support simple templating. Values enclosed in braces `{}` will be
|
|
23
|
+
Tags support simple templating via [handlebars][]. Values enclosed in braces `{{}}` will be substituted with release context information
|
|
24
24
|
|
|
25
25
|
## Installation
|
|
26
26
|
|
|
@@ -31,7 +31,7 @@ Run `npm i --save-dev @codedependant/semantic-release-docker` to install this se
|
|
|
31
31
|
### Docker registry authentication
|
|
32
32
|
|
|
33
33
|
The `docker registry` authentication set via environment variables. It is not required, and if
|
|
34
|
-
omitted, it is assumed the docker daemon is already authenticated with the
|
|
34
|
+
omitted, it is assumed the docker daemon is already authenticated with the target registry.
|
|
35
35
|
|
|
36
36
|
### Environment variables
|
|
37
37
|
|
|
@@ -42,30 +42,31 @@ omitted, it is assumed the docker daemon is already authenticated with the targe
|
|
|
42
42
|
|
|
43
43
|
### Options
|
|
44
44
|
|
|
45
|
-
| Option
|
|
46
|
-
|
|
47
|
-
| `dockerTags`
|
|
48
|
-
| `dockerImage`
|
|
49
|
-
| `dockerRegistry`
|
|
50
|
-
| `dockerProject`
|
|
51
|
-
| `dockerFile`
|
|
52
|
-
| `dockerContext`
|
|
53
|
-
| `dockerLogin`
|
|
54
|
-
| `dockerArgs`
|
|
55
|
-
| `dockerPublish`
|
|
45
|
+
| Option | Description | Default |
|
|
46
|
+
|-------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------|
|
|
47
|
+
| `dockerTags` | _Optional_. An array of strings allowing to specify additional tags to apply to the image. Supports templating | [`latest`, `{{major}}-latest`, `{{version}}`] |
|
|
48
|
+
| `dockerImage` | _Optional_. The name of the image to release. | Parsed from package.json `name` property |
|
|
49
|
+
| `dockerRegistry` | _Optional_. The hostname and port used by the the registry in format `hostname[:port]`. Omit the port if the registry uses the default port | `null` (dockerhub) |
|
|
50
|
+
| `dockerProject` | _Optional_. The project or repository name to publish the image to | For scoped packages, the scope will be used, otherwise `null` |
|
|
51
|
+
| `dockerFile` | _Optional_. The path, relative to `$PWD` to a Docker file to build the target image with | `Dockerfile` |
|
|
52
|
+
| `dockerContext` | _Optional_. A path, relative to `$PWD` to use as the build context A | `.` |
|
|
53
|
+
| `dockerLogin` | _Optional_. Set to false it by pass docker login if the docker daemon is already authorized | `true` |
|
|
54
|
+
| `dockerArgs` | _Optional_. Include additional values for docker's `build-arg`. Supports templating | |
|
|
55
|
+
| `dockerPublish` | _Optional_. Automatically push image tags during the publish phase. | `true` |
|
|
56
|
+
| `dockerVerifyCmd` | _Optional_. If specified, during the verify stage, the specified command will execute in a container of the build image. If the command errors, the release will fail. | `false` |
|
|
56
57
|
|
|
57
58
|
### Build Arguments
|
|
58
59
|
|
|
59
60
|
By default several build arguments will be included when the docker images is being built.
|
|
60
61
|
Build arguments can be templated in the same fashion as docker tags. If the value for a
|
|
61
|
-
build argument is
|
|
62
|
-
a matching environment variable will be utilized instead. This can be
|
|
62
|
+
build argument is explicitly `true`, the value will be omitted and the value from
|
|
63
|
+
a matching environment variable will be utilized instead. This can be useful when trying to include
|
|
63
64
|
secrets and other sensitive information
|
|
64
65
|
|
|
65
66
|
| Argument Name | Description | Default |
|
|
66
67
|
|---------------------|--------------------------------------------------------------------------------------------|------------------------------|
|
|
67
68
|
| `SRC_DIRECTORY` | The of the directory the build was triggered from | The directory name of CWD |
|
|
68
|
-
| `TARGET_PATH` | Path relative to the execution root.
|
|
69
|
+
| `TARGET_PATH` | Path relative to the execution root. Useful for Sharing a Single Docker file in monorepos | |
|
|
69
70
|
| `NPM_PACKAGE_NAME` | The `name` property extracted from `package.json` - if present | |
|
|
70
71
|
| `NPM_PACKAGE_SCOPE` | The parsed scope from the `name` property from `package.json` - sans `@` | |
|
|
71
72
|
| `CONFIG_NAME` | The configured name of the docker image. | The parsed package name |
|
|
@@ -77,21 +78,44 @@ secrets and other sensitive information
|
|
|
77
78
|
|
|
78
79
|
String template will be passed these
|
|
79
80
|
|
|
80
|
-
| Variable name | Description | Type
|
|
81
|
-
|
|
82
|
-
| `git_sha` | The commit SHA of the current release | `String`
|
|
83
|
-
| `git_tag` | The git tag of the current release | `String`
|
|
84
|
-
| `release_type` | The severity type of the current build (`major`, `minor`, `patch`) | `String`
|
|
85
|
-
| `relase_notes` | The release notes blob associated with the release | `String`
|
|
86
|
-
| `next` | Semver object representing the next release | `Object`
|
|
87
|
-
| `previous` | Semver object representing the previous release | `Object`
|
|
88
|
-
| `major` | The major version of the next release | `Number`
|
|
89
|
-
| `minor` | The minor version of the next release | `Number`
|
|
90
|
-
| `patch` | The patch version of the next release | `Number`
|
|
91
|
-
| `
|
|
92
|
-
| `
|
|
93
|
-
| `
|
|
94
|
-
| `
|
|
81
|
+
| Variable name | Description | Type |
|
|
82
|
+
|----------------|--------------------------------------------------------------------|-----------------|
|
|
83
|
+
| `git_sha` | The commit SHA of the current release | `String` |
|
|
84
|
+
| `git_tag` | The git tag of the current release | `String` |
|
|
85
|
+
| `release_type` | The severity type of the current build (`major`, `minor`, `patch`) | `String` |
|
|
86
|
+
| `relase_notes` | The release notes blob associated with the release | `String` |
|
|
87
|
+
| `next` | Semver object representing the next release | `Object` |
|
|
88
|
+
| `previous` | Semver object representing the previous release | `Object` |
|
|
89
|
+
| `major` | The major version of the next release | `Number` |
|
|
90
|
+
| `minor` | The minor version of the next release | `Number` |
|
|
91
|
+
| `patch` | The patch version of the next release | `Number` |
|
|
92
|
+
| `prerelease` | The prerelease versions of the next release | `Array<Number>` |
|
|
93
|
+
| `env` | Environment variables that were set at build time | `Object` |
|
|
94
|
+
| `pkg` | Values parsed from `package.json` | `Object` |
|
|
95
|
+
| `build` | A Random build hash representing the current execution context | `String` |
|
|
96
|
+
| `now` | Current timestamp is ISO 8601 format | `String` |
|
|
97
|
+
|
|
98
|
+
### Template Helpers
|
|
99
|
+
|
|
100
|
+
The following handlebars template helpers are pre installed
|
|
101
|
+
|
|
102
|
+
| Helper name | Description | Return Type | Example |
|
|
103
|
+
|:------------:|------------------------------------------------------------------------|:-----------:|--------------------------------------------------------------------------------------------|
|
|
104
|
+
| `endswith` | returns true if a string ends with another | [Boolean][] | <pre lang="hbs">{{#if (endswith myvar 'ing')}}{{ othervar }}{{/if}}</pre> |
|
|
105
|
+
| `eq` | returns true if two values are strictly equal to each other | [Boolean][] | <pre lang="hbs">{{#if (eq var_one var_two)}}{{ var_three }}{{/if}}</pre> |
|
|
106
|
+
| `gt` | returns true if the first value is greater than the second | [Boolean][] | <pre lang="hbs">{{#if (gt var_one var_two)}}{{ var_three }}{{/if}}</pre> |
|
|
107
|
+
| `gte` | returns true if the first value is greater than or equal to the second | [Boolean][] | <pre lang="hbs">{{#if (gte var_one var_two)}}{{ var_three }}{{/if}}</pre> |
|
|
108
|
+
| `includes` | returns true if the input (string \| array) includes the second value | [Boolean][] | <pre lang="hbs">{{#if (includes some_array 'one')}}{{ var_one }}{{/if}}</pre> |
|
|
109
|
+
| `lower` | returns the lower cased varient of the input string | [String][] | <pre lang="hbs">{{ lower my_var }}</pre> |
|
|
110
|
+
| `lt` | returns true if the first value is less than the second | [Boolean][] | <pre lang="hbs">{{#if (lt var_one var_two)}}{{ var_three }}{{/if}}</pre> |
|
|
111
|
+
| `lte` | returns true if the first value is less than or equal to the second | [Boolean][] | <pre lang="hbs">{{#if (lte var_one var_two)}}{{ var_three }}{{/if}}</pre> |
|
|
112
|
+
| `neq` | returns true if two values are not equal to each other | [Boolean][] | <pre lang="hbs">{{#if (neq var_one var_two)}}{{ var_three }}{{/if}}</pre> |
|
|
113
|
+
| `pick` | returns the first non null-ish value. Will treat `false` as a value | `any` | <pre lang="hbs">{{#with (pick var_one, var_two) as \| value \|}}{{ value }}{{/with}}</pre> |
|
|
114
|
+
| `split` | splits csv values into a javascript array | [Array][] | <pre lang="hbs">{{#each (split csv_value)}}{{ this }}{{/each}} |
|
|
115
|
+
| `startswith` | returns true if a string starts with another | [Boolean][] | <pre lang="hbs">{{#if (starts myvar 'foo')}}{{ othervar }}{{/if}}</pre> |
|
|
116
|
+
| `upper` | returns the upper cased varient of the input string | [String][] | <pre lang="hbs">{{upper my_var}}</pre> |
|
|
117
|
+
|
|
118
|
+
|
|
95
119
|
|
|
96
120
|
## Usage
|
|
97
121
|
|
|
@@ -104,7 +128,7 @@ module.exports = {
|
|
|
104
128
|
branches: ['main']
|
|
105
129
|
plugins: [
|
|
106
130
|
['@codedependant/semantic-release-docker', {
|
|
107
|
-
dockerTags: ['latest', '{version}', '{major}-latest', '{major}.{minor}'],
|
|
131
|
+
dockerTags: ['latest', '{{version}}', '{{major}}-latest', '{{major}}.{{minor}}'],
|
|
108
132
|
dockerImage: 'my-image',
|
|
109
133
|
dockerFile: 'Dockerfile',
|
|
110
134
|
dockerRegistry: 'quay.io',
|
|
@@ -112,7 +136,7 @@ module.exports = {
|
|
|
112
136
|
dockerArgs: {
|
|
113
137
|
API_TOKEN: true
|
|
114
138
|
, RELEASE_DATE: new Date().toISOString()
|
|
115
|
-
, RELEASE_VERSION: '{next.version}'
|
|
139
|
+
, RELEASE_VERSION: '{{next.version}}'
|
|
116
140
|
}
|
|
117
141
|
}]
|
|
118
142
|
]
|
|
@@ -129,13 +153,13 @@ Alternatively, using global options w/ root configuration
|
|
|
129
153
|
"version": "1.0.0"
|
|
130
154
|
"release": {
|
|
131
155
|
"extends": "@internal/release-config-docker",
|
|
132
|
-
"dockerTags": ["latest", "{version}", "{major}-latest", "{major}.{minor}"],
|
|
156
|
+
"dockerTags": ["latest", "{{version}}", "{{major}}-latest", "{{major}}.{{minor}}"],
|
|
133
157
|
"dockerImage": "my-image",
|
|
134
158
|
"dockerFile": "Dockerfile",
|
|
135
159
|
"dockerRegistry": "quay.io",
|
|
136
160
|
"dockerArgs": {
|
|
137
161
|
"GITHUB_TOKEN": true
|
|
138
|
-
, "SOME_VALUE": '{git_sha}'
|
|
162
|
+
, "SOME_VALUE": '{{git_sha}}'
|
|
139
163
|
}
|
|
140
164
|
}
|
|
141
165
|
}
|
|
@@ -169,6 +193,24 @@ $ docker push quay.io/codedependant/my-image
|
|
|
169
193
|
|
|
170
194
|
the default docker image tags for the 1.0.0 release would be `1.0.0`, `1-latest`, `latest`
|
|
171
195
|
|
|
196
|
+
**example prerelease configuration**:
|
|
197
|
+
|
|
198
|
+
```json
|
|
199
|
+
{
|
|
200
|
+
"release": {
|
|
201
|
+
"dockerTags": [
|
|
202
|
+
"{{#if prerelease.[0]}}{{prerelease.[0]}}{{else}}latest{{/if}}",
|
|
203
|
+
"{{major}}-{{#if prerelease.[0]}}{{prerelease.[0]}}{{else}}latest{{/if}}",
|
|
204
|
+
"{{major}}.{{minor}}-{{#if prerelease.[0]}}{{prerelease.[0]}}{{else}}latest{{/if}}",
|
|
205
|
+
"{{version}}"
|
|
206
|
+
]
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
the docker tags for version `1.2.3` will be `1.2.3`, `1.2-latest`, `1-latest` and `latest`
|
|
212
|
+
the docker tags for version `2.3.4-beta.6` will be `2.3.4-beta.6`, `2.3-beta`, `2-beta` and `beta`
|
|
213
|
+
|
|
172
214
|
## Development
|
|
173
215
|
|
|
174
216
|
### Docker Registry
|
|
@@ -182,3 +224,8 @@ $ openssl req -new -newkey rsa:2048 -days 365 -nodes -x509 -keyout server.key -o
|
|
|
182
224
|
|
|
183
225
|
**NOTE**: When prompted for an FQDN it must be `registry:5000`
|
|
184
226
|
**NOTE**: The credentials for the local registry are **user:** `iamweasel`, **pass:** `secretsquirrel`
|
|
227
|
+
|
|
228
|
+
[handlebars]: https://handlebarsjs.com
|
|
229
|
+
[Boolean]: https://mdn.io/boolean
|
|
230
|
+
[String]: https://mdn.io/string
|
|
231
|
+
[Array]: https://mdn.io/array
|
package/lib/build-config.js
CHANGED
|
@@ -13,12 +13,14 @@ async function buildConfig(build_id, config, context) {
|
|
|
13
13
|
const {
|
|
14
14
|
dockerFile: dockerfile = 'Dockerfile'
|
|
15
15
|
, dockerNoCache: nocache = false
|
|
16
|
-
, dockerTags: tags = ['latest', '{major}-latest', '{version}']
|
|
16
|
+
, dockerTags: tags = ['latest', '{{major}}-latest', '{{version}}']
|
|
17
17
|
, dockerArgs: args = {}
|
|
18
18
|
, dockerRegistry: registry = null
|
|
19
19
|
, dockerLogin: login = true
|
|
20
20
|
, dockerImage: image
|
|
21
21
|
, dockerPublish: publish = true
|
|
22
|
+
, dockerContext = '.'
|
|
23
|
+
, dockerVerifyCmd: verifycmd = null
|
|
22
24
|
} = config
|
|
23
25
|
|
|
24
26
|
let name = null
|
|
@@ -43,6 +45,7 @@ async function buildConfig(build_id, config, context) {
|
|
|
43
45
|
, project
|
|
44
46
|
, publish
|
|
45
47
|
, tags: array.toArray(tags)
|
|
48
|
+
, verifycmd
|
|
46
49
|
, args: {
|
|
47
50
|
SRC_DIRECTORY: path.basename(context.cwd)
|
|
48
51
|
, TARGET_PATH: target
|
|
@@ -58,6 +61,6 @@ async function buildConfig(build_id, config, context) {
|
|
|
58
61
|
, build: build_id
|
|
59
62
|
, login: login
|
|
60
63
|
, env: context.env
|
|
61
|
-
, context:
|
|
64
|
+
, context: dockerContext
|
|
62
65
|
}
|
|
63
66
|
}
|
package/lib/docker/image.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
const path = require('path')
|
|
4
4
|
const crypto = require('crypto')
|
|
5
5
|
const execa = require('execa')
|
|
6
|
+
const array = require('../lang/array/index.js')
|
|
6
7
|
|
|
7
8
|
class Image {
|
|
8
9
|
constructor(opts) {
|
|
@@ -53,7 +54,7 @@ class Image {
|
|
|
53
54
|
}
|
|
54
55
|
|
|
55
56
|
get context() {
|
|
56
|
-
return this.opts.context
|
|
57
|
+
return path.resolve(this.opts.cwd, this.opts.context)
|
|
57
58
|
}
|
|
58
59
|
|
|
59
60
|
set context(ctx) {
|
|
@@ -79,7 +80,7 @@ class Image {
|
|
|
79
80
|
args.push('--build-arg', `${name}=${value}`)
|
|
80
81
|
}
|
|
81
82
|
}
|
|
82
|
-
|
|
83
|
+
return [
|
|
83
84
|
'build'
|
|
84
85
|
, '--quiet'
|
|
85
86
|
, '--tag'
|
|
@@ -89,7 +90,21 @@ class Image {
|
|
|
89
90
|
, this.dockerfile
|
|
90
91
|
, this.context
|
|
91
92
|
]
|
|
92
|
-
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
async run(cmd) {
|
|
96
|
+
const stream = execa('docker', [
|
|
97
|
+
'run'
|
|
98
|
+
, '--rm'
|
|
99
|
+
, this.name
|
|
100
|
+
, ...array.toArray(cmd)
|
|
101
|
+
], {all: true})
|
|
102
|
+
|
|
103
|
+
stream.stdout.pipe(process.stdout)
|
|
104
|
+
stream.stderr.pipe(process.stderr)
|
|
105
|
+
|
|
106
|
+
const {all} = await stream
|
|
107
|
+
return all
|
|
93
108
|
}
|
|
94
109
|
|
|
95
110
|
async build() {
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
endswith: require('./endswith')
|
|
5
|
+
, eq: require('./eq')
|
|
6
|
+
, gt: require('./gt')
|
|
7
|
+
, gte: require('./gte')
|
|
8
|
+
, includes: require('./includes')
|
|
9
|
+
, lower: require('./lower')
|
|
10
|
+
, lt: require('./lt')
|
|
11
|
+
, lte: require('./lte')
|
|
12
|
+
, neq: require('./neq')
|
|
13
|
+
, pick: require('./pick')
|
|
14
|
+
, startswith: require('./startswith')
|
|
15
|
+
, split: require('./split')
|
|
16
|
+
, upper: require('./upper')
|
|
17
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
module.exports = pick
|
|
4
|
+
|
|
5
|
+
function pick(...args) {
|
|
6
|
+
return args.find((value) => {
|
|
7
|
+
/* eslint-disable no-eq-null */
|
|
8
|
+
if (value == null) return false
|
|
9
|
+
/* eslint-enable no-eq-null */
|
|
10
|
+
if (value === '') return false
|
|
11
|
+
return true
|
|
12
|
+
})
|
|
13
|
+
}
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
'use strict'
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
const handlebars = require('../../handlebars')
|
|
3
4
|
|
|
4
5
|
module.exports = template
|
|
5
6
|
|
|
6
7
|
function template(str) {
|
|
7
|
-
return
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
if (typeof str !== 'string') return echo(str)
|
|
9
|
+
return handlebars.compile(str)
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function echo(input) {
|
|
13
|
+
return () => {
|
|
14
|
+
return input
|
|
13
15
|
}
|
|
14
16
|
}
|
package/lib/prepare.js
CHANGED