@enspirit/emb 0.4.1 → 0.5.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/README.md +15 -16
- package/dist/src/cli/commands/components/logs.d.ts +2 -2
- package/dist/src/cli/commands/components/logs.js +2 -2
- package/dist/src/cli/commands/components/shell.d.ts +2 -2
- package/dist/src/cli/commands/components/shell.js +2 -2
- package/dist/src/cli/commands/up.d.ts +4 -0
- package/dist/src/cli/commands/up.js +31 -5
- package/dist/src/config/schema.json +48 -27
- package/dist/src/config/validation.js +1 -1
- package/dist/src/docker/compose/operations/ComposeUpOperation.d.ts +1 -0
- package/dist/src/docker/compose/operations/ComposeUpOperation.js +7 -0
- package/dist/src/docker/operations/images/BuildImageOperation.d.ts +5 -0
- package/dist/src/docker/operations/images/BuildImageOperation.js +73 -23
- package/dist/src/errors.d.ts +5 -0
- package/dist/src/errors.js +9 -0
- package/dist/src/monorepo/monorepo.js +1 -7
- package/dist/src/monorepo/operations/resources/BuildResourcesOperation.js +1 -0
- package/dist/src/monorepo/operations/shell/ExecuteLocalCommandOperation.d.ts +2 -2
- package/dist/src/monorepo/operations/shell/ExecuteLocalCommandOperation.js +3 -1
- package/dist/src/monorepo/operations/tasks/RunTasksOperation.js +0 -1
- package/oclif.manifest.json +10 -18
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -14,7 +14,7 @@ $ npm install -g @enspirit/emb
|
|
|
14
14
|
$ emb COMMAND
|
|
15
15
|
running command...
|
|
16
16
|
$ emb (--version)
|
|
17
|
-
@enspirit/emb/0.
|
|
17
|
+
@enspirit/emb/0.5.0 darwin-x64 node-v22.18.0
|
|
18
18
|
$ emb --help [COMMAND]
|
|
19
19
|
USAGE
|
|
20
20
|
$ emb COMMAND
|
|
@@ -43,7 +43,7 @@ USAGE
|
|
|
43
43
|
* [`emb shell COMPONENT`](#emb-shell-component)
|
|
44
44
|
* [`emb tasks`](#emb-tasks)
|
|
45
45
|
* [`emb tasks run TASK`](#emb-tasks-run-task)
|
|
46
|
-
* [`emb up`](#emb-up)
|
|
46
|
+
* [`emb up [COMPONENT]`](#emb-up-component)
|
|
47
47
|
* [`emb update [CHANNEL]`](#emb-update-channel)
|
|
48
48
|
|
|
49
49
|
## `emb autocomplete [SHELL]`
|
|
@@ -125,14 +125,13 @@ Get components logs.
|
|
|
125
125
|
|
|
126
126
|
```
|
|
127
127
|
USAGE
|
|
128
|
-
$ emb components logs COMPONENT [
|
|
128
|
+
$ emb components logs COMPONENT [-f]
|
|
129
129
|
|
|
130
130
|
ARGUMENTS
|
|
131
131
|
COMPONENT The component you want to see the logs of
|
|
132
132
|
|
|
133
133
|
FLAGS
|
|
134
|
-
-f, --follow
|
|
135
|
-
--flavor=<value> Specify the flavor to use.
|
|
134
|
+
-f, --follow Follow log output
|
|
136
135
|
|
|
137
136
|
DESCRIPTION
|
|
138
137
|
Get components logs.
|
|
@@ -150,14 +149,13 @@ Get a shell on a running component.
|
|
|
150
149
|
|
|
151
150
|
```
|
|
152
151
|
USAGE
|
|
153
|
-
$ emb components shell COMPONENT [
|
|
152
|
+
$ emb components shell COMPONENT [-s <value>]
|
|
154
153
|
|
|
155
154
|
ARGUMENTS
|
|
156
155
|
COMPONENT The component you want to get a shell on
|
|
157
156
|
|
|
158
157
|
FLAGS
|
|
159
|
-
-s, --shell=<value>
|
|
160
|
-
--flavor=<value> Specify the flavor to use.
|
|
158
|
+
-s, --shell=<value> [default: bash] The shell to run
|
|
161
159
|
|
|
162
160
|
DESCRIPTION
|
|
163
161
|
Get a shell on a running component.
|
|
@@ -343,14 +341,13 @@ Get components logs.
|
|
|
343
341
|
|
|
344
342
|
```
|
|
345
343
|
USAGE
|
|
346
|
-
$ emb logs COMPONENT [
|
|
344
|
+
$ emb logs COMPONENT [-f]
|
|
347
345
|
|
|
348
346
|
ARGUMENTS
|
|
349
347
|
COMPONENT The component you want to see the logs of
|
|
350
348
|
|
|
351
349
|
FLAGS
|
|
352
|
-
-f, --follow
|
|
353
|
-
--flavor=<value> Specify the flavor to use.
|
|
350
|
+
-f, --follow Follow log output
|
|
354
351
|
|
|
355
352
|
DESCRIPTION
|
|
356
353
|
Get components logs.
|
|
@@ -439,14 +436,13 @@ Get a shell on a running component.
|
|
|
439
436
|
|
|
440
437
|
```
|
|
441
438
|
USAGE
|
|
442
|
-
$ emb shell COMPONENT [
|
|
439
|
+
$ emb shell COMPONENT [-s <value>]
|
|
443
440
|
|
|
444
441
|
ARGUMENTS
|
|
445
442
|
COMPONENT The component you want to get a shell on
|
|
446
443
|
|
|
447
444
|
FLAGS
|
|
448
|
-
-s, --shell=<value>
|
|
449
|
-
--flavor=<value> Specify the flavor to use.
|
|
445
|
+
-s, --shell=<value> [default: bash] The shell to run
|
|
450
446
|
|
|
451
447
|
DESCRIPTION
|
|
452
448
|
Get a shell on a running component.
|
|
@@ -502,13 +498,16 @@ EXAMPLES
|
|
|
502
498
|
$ emb tasks run
|
|
503
499
|
```
|
|
504
500
|
|
|
505
|
-
## `emb up`
|
|
501
|
+
## `emb up [COMPONENT]`
|
|
506
502
|
|
|
507
503
|
Start the whole project.
|
|
508
504
|
|
|
509
505
|
```
|
|
510
506
|
USAGE
|
|
511
|
-
$ emb up [--json] [--flavor <value>] [-f]
|
|
507
|
+
$ emb up [COMPONENT...] [--json] [--flavor <value>] [-f]
|
|
508
|
+
|
|
509
|
+
ARGUMENTS
|
|
510
|
+
COMPONENT... The component(s) to build and start
|
|
512
511
|
|
|
513
512
|
FLAGS
|
|
514
513
|
-f, --force Bypass caches, force the recreation of containers, etc
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export default class ComponentsLogs extends
|
|
1
|
+
import { BaseCommand } from '../../index.js';
|
|
2
|
+
export default class ComponentsLogs extends BaseCommand {
|
|
3
3
|
static aliases: string[];
|
|
4
4
|
static description: string;
|
|
5
5
|
static enableJsonFlag: boolean;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Args, Flags } from '@oclif/core';
|
|
2
|
-
import {
|
|
2
|
+
import { BaseCommand, getContext } from '../../index.js';
|
|
3
3
|
import { ListContainersOperation } from '../../../docker/index.js';
|
|
4
|
-
export default class ComponentsLogs extends
|
|
4
|
+
export default class ComponentsLogs extends BaseCommand {
|
|
5
5
|
static aliases = ['logs'];
|
|
6
6
|
static description = 'Get components logs.';
|
|
7
7
|
static enableJsonFlag = false;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export default class ComponentsLogs extends
|
|
1
|
+
import { BaseCommand } from '../../index.js';
|
|
2
|
+
export default class ComponentsLogs extends BaseCommand {
|
|
3
3
|
static aliases: string[];
|
|
4
4
|
static description: string;
|
|
5
5
|
static enableJsonFlag: boolean;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Args, Flags } from '@oclif/core';
|
|
2
|
-
import {
|
|
2
|
+
import { BaseCommand, getContext } from '../../index.js';
|
|
3
3
|
import { ComposeExecShellOperation } from '../../../docker/index.js';
|
|
4
4
|
import { ShellExitError } from '../../../errors.js';
|
|
5
|
-
export default class ComponentsLogs extends
|
|
5
|
+
export default class ComponentsLogs extends BaseCommand {
|
|
6
6
|
static aliases = ['shell'];
|
|
7
7
|
static description = 'Get a shell on a running component.';
|
|
8
8
|
static enableJsonFlag = false;
|
|
@@ -6,5 +6,9 @@ export default class UpCommand extends FlavoredCommand<typeof UpCommand> {
|
|
|
6
6
|
static flags: {
|
|
7
7
|
force: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
8
8
|
};
|
|
9
|
+
static args: {
|
|
10
|
+
component: import("@oclif/core/interfaces").Arg<string | undefined, Record<string, unknown>>;
|
|
11
|
+
};
|
|
12
|
+
static strict: boolean;
|
|
9
13
|
run(): Promise<void>;
|
|
10
14
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { Flags } from '@oclif/core';
|
|
1
|
+
import { Args, Flags } from '@oclif/core';
|
|
2
2
|
import { FlavoredCommand, getContext } from '../index.js';
|
|
3
3
|
import { ComposeUpOperation } from '../../docker/index.js';
|
|
4
|
+
import { BuildResourcesOperation } from '../../monorepo/operations/resources/BuildResourcesOperation.js';
|
|
4
5
|
export default class UpCommand extends FlavoredCommand {
|
|
5
6
|
static description = 'Start the whole project.';
|
|
6
7
|
static enableJsonFlag = true;
|
|
@@ -13,19 +14,44 @@ export default class UpCommand extends FlavoredCommand {
|
|
|
13
14
|
name: 'force',
|
|
14
15
|
}),
|
|
15
16
|
};
|
|
17
|
+
static args = {
|
|
18
|
+
component: Args.string({
|
|
19
|
+
name: 'component',
|
|
20
|
+
description: 'The component(s) to build and start',
|
|
21
|
+
}),
|
|
22
|
+
};
|
|
23
|
+
static strict = false;
|
|
16
24
|
async run() {
|
|
17
|
-
const { flags } = await this.parse(UpCommand);
|
|
25
|
+
const { flags, argv } = await this.parse(UpCommand);
|
|
18
26
|
const { monorepo } = getContext();
|
|
19
27
|
const buildFlags = [];
|
|
20
28
|
if (flags.force) {
|
|
21
29
|
buildFlags.push('--force');
|
|
22
30
|
}
|
|
23
|
-
|
|
24
|
-
|
|
31
|
+
let components;
|
|
32
|
+
let resources;
|
|
33
|
+
if (argv.length > 0) {
|
|
34
|
+
components =
|
|
35
|
+
argv.length > 0
|
|
36
|
+
? argv.map((name) => monorepo.component(name))
|
|
37
|
+
: monorepo.components;
|
|
38
|
+
resources = components.reduce((resources, component) => {
|
|
39
|
+
return [
|
|
40
|
+
...resources,
|
|
41
|
+
...Object.values(component.resources).map((r) => r.id),
|
|
42
|
+
];
|
|
43
|
+
}, []);
|
|
25
44
|
}
|
|
26
|
-
|
|
45
|
+
else {
|
|
46
|
+
resources = monorepo.resources.map((r) => r.id);
|
|
47
|
+
}
|
|
48
|
+
await monorepo.run(new BuildResourcesOperation(), {
|
|
49
|
+
force: flags.force,
|
|
50
|
+
resources,
|
|
51
|
+
});
|
|
27
52
|
await monorepo.run(new ComposeUpOperation(), {
|
|
28
53
|
forceRecreate: flags.force,
|
|
54
|
+
components: components?.map((c) => c.name),
|
|
29
55
|
});
|
|
30
56
|
}
|
|
31
57
|
}
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"required": ["name"],
|
|
11
11
|
"properties": {
|
|
12
12
|
"name": {
|
|
13
|
-
"$ref": "
|
|
13
|
+
"$ref": "#/definitions/Identifier",
|
|
14
14
|
"description": "The name of the project."
|
|
15
15
|
},
|
|
16
16
|
"rootDir": {
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"required": ["name"],
|
|
29
29
|
"properties": {
|
|
30
30
|
"name": {
|
|
31
|
-
"$ref": "
|
|
31
|
+
"$ref": "#/definitions/Identifier"
|
|
32
32
|
},
|
|
33
33
|
"config": {}
|
|
34
34
|
},
|
|
@@ -48,29 +48,29 @@
|
|
|
48
48
|
"additionalProperties": true
|
|
49
49
|
},
|
|
50
50
|
"defaults": {
|
|
51
|
-
"$ref": "
|
|
51
|
+
"$ref": "#/definitions/DefaultsConfig"
|
|
52
52
|
},
|
|
53
53
|
"components": {
|
|
54
54
|
"type": "object",
|
|
55
55
|
"additionalProperties": {
|
|
56
|
-
"$ref": "
|
|
56
|
+
"$ref": "#/definitions/ComponentConfig"
|
|
57
57
|
}
|
|
58
58
|
},
|
|
59
59
|
"flavors": {
|
|
60
60
|
"type": "object",
|
|
61
61
|
"additionalProperties": {
|
|
62
|
-
"$ref": "
|
|
62
|
+
"$ref": "#/definitions/ProjectFlavorConfig"
|
|
63
63
|
}
|
|
64
64
|
},
|
|
65
65
|
"tasks": {
|
|
66
66
|
"type": "object",
|
|
67
67
|
"additionalProperties": {
|
|
68
|
-
"$ref": "
|
|
68
|
+
"$ref": "#/definitions/TaskConfig"
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
71
|
},
|
|
72
72
|
"required": ["project"],
|
|
73
|
-
"
|
|
73
|
+
"definitions": {
|
|
74
74
|
"Identifier": {
|
|
75
75
|
"type": "string",
|
|
76
76
|
"pattern": "^[a-zA-Z]+[\\w._-]+$"
|
|
@@ -92,7 +92,7 @@
|
|
|
92
92
|
"type": "string"
|
|
93
93
|
},
|
|
94
94
|
"target": {
|
|
95
|
-
"$ref": "
|
|
95
|
+
"$ref": "#/definitions/Identifier"
|
|
96
96
|
},
|
|
97
97
|
"buildArgs": {
|
|
98
98
|
"type": "object",
|
|
@@ -125,7 +125,7 @@
|
|
|
125
125
|
"type": "string"
|
|
126
126
|
},
|
|
127
127
|
"executor": {
|
|
128
|
-
"$ref": "
|
|
128
|
+
"$ref": "#/definitions/Identifier"
|
|
129
129
|
},
|
|
130
130
|
"options": {
|
|
131
131
|
"type": "object",
|
|
@@ -134,7 +134,7 @@
|
|
|
134
134
|
"pre": {
|
|
135
135
|
"type": "array",
|
|
136
136
|
"items": {
|
|
137
|
-
"$ref": "
|
|
137
|
+
"$ref": "#/definitions/Identifier"
|
|
138
138
|
}
|
|
139
139
|
}
|
|
140
140
|
},
|
|
@@ -156,19 +156,19 @@
|
|
|
156
156
|
"tasks": {
|
|
157
157
|
"type": "object",
|
|
158
158
|
"additionalProperties": {
|
|
159
|
-
"$ref": "
|
|
159
|
+
"$ref": "#/definitions/TaskConfig"
|
|
160
160
|
}
|
|
161
161
|
},
|
|
162
162
|
"resources": {
|
|
163
163
|
"type": "object",
|
|
164
164
|
"additionalProperties": {
|
|
165
|
-
"$ref": "
|
|
165
|
+
"$ref": "#/definitions/ResourceConfig"
|
|
166
166
|
}
|
|
167
167
|
},
|
|
168
168
|
"flavors": {
|
|
169
169
|
"type": "object",
|
|
170
170
|
"additionalProperties": {
|
|
171
|
-
"$ref": "
|
|
171
|
+
"$ref": "#/definitions/ComponentFlavorConfig"
|
|
172
172
|
}
|
|
173
173
|
}
|
|
174
174
|
},
|
|
@@ -203,7 +203,7 @@
|
|
|
203
203
|
"patches": {
|
|
204
204
|
"type": "array",
|
|
205
205
|
"items": {
|
|
206
|
-
"$ref": "
|
|
206
|
+
"$ref": "#/definitions/JsonPatchOperation"
|
|
207
207
|
}
|
|
208
208
|
}
|
|
209
209
|
}
|
|
@@ -216,9 +216,7 @@
|
|
|
216
216
|
"params": {},
|
|
217
217
|
"dependencies": {
|
|
218
218
|
"type": "array",
|
|
219
|
-
"items": {
|
|
220
|
-
"$ref": "#/$defs/QualifiedIdentifier"
|
|
221
|
-
},
|
|
219
|
+
"items": { "$ref": "#/definitions/QualifiedIdentifier" },
|
|
222
220
|
"uniqueItems": true
|
|
223
221
|
}
|
|
224
222
|
},
|
|
@@ -226,14 +224,37 @@
|
|
|
226
224
|
"allOf": [
|
|
227
225
|
{
|
|
228
226
|
"if": {
|
|
229
|
-
"properties": {
|
|
227
|
+
"properties": {
|
|
228
|
+
"type": { "const": "docker/image" }
|
|
229
|
+
},
|
|
230
230
|
"required": ["type"]
|
|
231
231
|
},
|
|
232
232
|
"then": {
|
|
233
|
-
"properties": {
|
|
233
|
+
"properties": {
|
|
234
|
+
"params": { "$ref": "#/definitions/DockerImageConfig" }
|
|
235
|
+
},
|
|
236
|
+
"required": ["params"]
|
|
237
|
+
}
|
|
238
|
+
},
|
|
239
|
+
{
|
|
240
|
+
"if": {
|
|
241
|
+
"properties": {
|
|
242
|
+
"type": { "const": "file" }
|
|
243
|
+
},
|
|
244
|
+
"required": ["type"]
|
|
234
245
|
},
|
|
235
|
-
"
|
|
236
|
-
"properties": {
|
|
246
|
+
"then": {
|
|
247
|
+
"properties": {
|
|
248
|
+
"params": {
|
|
249
|
+
"type": "object",
|
|
250
|
+
"additionalProperties": false,
|
|
251
|
+
"properties": {
|
|
252
|
+
"path": {
|
|
253
|
+
"type": "string"
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
}
|
|
237
258
|
}
|
|
238
259
|
}
|
|
239
260
|
]
|
|
@@ -246,7 +267,7 @@
|
|
|
246
267
|
"patches": {
|
|
247
268
|
"type": "array",
|
|
248
269
|
"items": {
|
|
249
|
-
"$ref": "
|
|
270
|
+
"$ref": "#/definitions/JsonPatchOperation"
|
|
250
271
|
}
|
|
251
272
|
}
|
|
252
273
|
}
|
|
@@ -302,11 +323,11 @@
|
|
|
302
323
|
},
|
|
303
324
|
"JsonPatchOperation": {
|
|
304
325
|
"oneOf": [
|
|
305
|
-
{ "$ref": "
|
|
306
|
-
{ "$ref": "
|
|
307
|
-
{ "$ref": "
|
|
308
|
-
{ "$ref": "
|
|
309
|
-
{ "$ref": "
|
|
326
|
+
{ "$ref": "#/definitions/JsonPatchAddOperation" },
|
|
327
|
+
{ "$ref": "#/definitions/JsonPatchRemoveOperation" },
|
|
328
|
+
{ "$ref": "#/definitions/JsonPatchReplaceOperation" },
|
|
329
|
+
{ "$ref": "#/definitions/JsonPatchMoveOperation" },
|
|
330
|
+
{ "$ref": "#/definitions/JsonPatchCopyOperation" }
|
|
310
331
|
]
|
|
311
332
|
}
|
|
312
333
|
}
|
|
@@ -38,7 +38,7 @@ export const validateEmbfile = async (pathOrObject) => {
|
|
|
38
38
|
else {
|
|
39
39
|
component = pathOrObject;
|
|
40
40
|
}
|
|
41
|
-
const validate = ajv.getSchema('/schemas/config
|
|
41
|
+
const validate = ajv.getSchema('/schemas/config#/definitions/ComponentConfig');
|
|
42
42
|
if (!validate) {
|
|
43
43
|
throw new Error('Could not find the JSON schema validator for Embfile');
|
|
44
44
|
}
|
|
@@ -4,6 +4,7 @@ import { AbstractOperation } from '../../../operations/index.js';
|
|
|
4
4
|
* https://docs.docker.com/reference/cli/docker/compose/up/
|
|
5
5
|
*/
|
|
6
6
|
declare const schema: z.ZodOptional<z.ZodObject<{
|
|
7
|
+
components: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
7
8
|
forceRecreate: z.ZodOptional<z.ZodBoolean>;
|
|
8
9
|
}, z.core.$strip>>;
|
|
9
10
|
export declare class ComposeUpOperation extends AbstractOperation<typeof schema, void> {
|
|
@@ -7,6 +7,10 @@ import { AbstractOperation } from '../../../operations/index.js';
|
|
|
7
7
|
*/
|
|
8
8
|
const schema = z
|
|
9
9
|
.object({
|
|
10
|
+
components: z
|
|
11
|
+
.array(z.string())
|
|
12
|
+
.optional()
|
|
13
|
+
.describe('The list of service to up'),
|
|
10
14
|
forceRecreate: z
|
|
11
15
|
.boolean()
|
|
12
16
|
.optional()
|
|
@@ -21,6 +25,9 @@ export class ComposeUpOperation extends AbstractOperation {
|
|
|
21
25
|
const { monorepo } = getContext();
|
|
22
26
|
const manager = taskManagerFactory();
|
|
23
27
|
const command = ['docker', 'compose', 'up', '-d'];
|
|
28
|
+
if (input?.components) {
|
|
29
|
+
command.push(...input.components);
|
|
30
|
+
}
|
|
24
31
|
if (input?.forceRecreate) {
|
|
25
32
|
command.push('--force-recreate');
|
|
26
33
|
}
|
|
@@ -17,4 +17,9 @@ export declare class BuildImageOperation extends AbstractOperation<typeof BuildI
|
|
|
17
17
|
private out?;
|
|
18
18
|
constructor(out?: Writable | undefined);
|
|
19
19
|
protected _run(input: z.input<typeof BuildImageOperationInputSchema>): Promise<void>;
|
|
20
|
+
protected _buildWithDockerCLI(input: z.input<typeof BuildImageOperationInputSchema>): Promise<void>;
|
|
21
|
+
/**
|
|
22
|
+
* Experimental with dockerode and the docker API directly
|
|
23
|
+
*/
|
|
24
|
+
protected _buildWithDockerode(input: z.input<typeof BuildImageOperationInputSchema>): Promise<void>;
|
|
20
25
|
}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CommandExecError } from '../../../index.js';
|
|
2
|
+
import { spawn } from 'node:child_process';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
import { PassThrough } from 'node:stream';
|
|
2
5
|
import * as z from 'zod';
|
|
3
6
|
import { decodeBuildkitStatusResponse } from '../../index.js';
|
|
4
7
|
import { AbstractOperation } from '../../../operations/index.js';
|
|
@@ -37,28 +40,56 @@ export class BuildImageOperation extends AbstractOperation {
|
|
|
37
40
|
this.out = out;
|
|
38
41
|
}
|
|
39
42
|
async _run(input) {
|
|
43
|
+
return this._buildWithDockerCLI(input);
|
|
44
|
+
}
|
|
45
|
+
async _buildWithDockerCLI(input) {
|
|
46
|
+
const args = [
|
|
47
|
+
'build',
|
|
48
|
+
input.context,
|
|
49
|
+
'-f',
|
|
50
|
+
join(input.context, input.dockerfile || 'Dockerfile'),
|
|
51
|
+
];
|
|
52
|
+
if (input.tag) {
|
|
53
|
+
args.push('--tag', input.tag);
|
|
54
|
+
}
|
|
55
|
+
if (input.target) {
|
|
56
|
+
args.push('--target', input.target);
|
|
57
|
+
}
|
|
58
|
+
Object.entries(input.buildArgs || []).forEach(([key, value]) => {
|
|
59
|
+
args.push('--build-arg', `${key.trim()}=${value.trim()}`);
|
|
60
|
+
});
|
|
61
|
+
Object.entries(input.labels || {}).forEach(([key, value]) => {
|
|
62
|
+
args.push('--label', `${key.trim()}=${value.trim()}`);
|
|
63
|
+
});
|
|
40
64
|
const logFile = await this.context.monorepo.store.createWriteStream(`logs/docker/build/${input.tag}.log`);
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
catch (error) {
|
|
58
|
-
console.error('__OOPS', error);
|
|
65
|
+
const tee = new PassThrough();
|
|
66
|
+
tee.pipe(logFile);
|
|
67
|
+
if (this.out) {
|
|
68
|
+
tee.pipe(this.out);
|
|
69
|
+
}
|
|
70
|
+
tee.write('Building image with opts: ' + JSON.stringify(args));
|
|
71
|
+
const child = await spawn('docker', args);
|
|
72
|
+
child.stderr.pipe(tee);
|
|
73
|
+
child.stdout.pipe(tee);
|
|
74
|
+
return new Promise((resolve, reject) => {
|
|
75
|
+
child.on('close', () => {
|
|
76
|
+
resolve();
|
|
77
|
+
});
|
|
78
|
+
child.on('exit', (code, signal) => {
|
|
79
|
+
if (code !== 0) {
|
|
80
|
+
reject(new CommandExecError('Docker build failed', code || -1, signal));
|
|
59
81
|
}
|
|
60
|
-
}
|
|
82
|
+
});
|
|
83
|
+
child.on('error', (err) => {
|
|
84
|
+
reject(err);
|
|
85
|
+
});
|
|
61
86
|
});
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Experimental with dockerode and the docker API directly
|
|
90
|
+
*/
|
|
91
|
+
async _buildWithDockerode(input) {
|
|
92
|
+
const logFile = await this.context.monorepo.store.createWriteStream(`logs/docker/build/${input.tag}.log`);
|
|
62
93
|
const stream = await this.context.docker.buildImage({
|
|
63
94
|
context: input.context,
|
|
64
95
|
src: [...input.src],
|
|
@@ -71,9 +102,28 @@ export class BuildImageOperation extends AbstractOperation {
|
|
|
71
102
|
version: '2',
|
|
72
103
|
});
|
|
73
104
|
return new Promise((resolve, reject) => {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
105
|
+
this.context.docker.modem.followProgress(stream, (err, _traces) => {
|
|
106
|
+
return err ? reject(err) : resolve();
|
|
107
|
+
}, async (trace) => {
|
|
108
|
+
if (trace.error) {
|
|
109
|
+
logFile.write(trace.error + '\n');
|
|
110
|
+
this.out?.write(trace.error + '\n');
|
|
111
|
+
reject(trace.error);
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
try {
|
|
115
|
+
const { vertexes } = await decodeBuildkitStatusResponse(trace.aux);
|
|
116
|
+
vertexes.forEach((v) => {
|
|
117
|
+
// logStream.write(JSON.stringify(v) + '\n');
|
|
118
|
+
logFile.write(v.name + '\n');
|
|
119
|
+
this.out?.write(v.name + '\n');
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
catch (error) {
|
|
123
|
+
console.error(error);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
});
|
|
77
127
|
});
|
|
78
128
|
}
|
|
79
129
|
}
|
package/dist/src/errors.d.ts
CHANGED
|
@@ -72,6 +72,11 @@ export declare class MultipleContainersFoundError extends EMBError {
|
|
|
72
72
|
component: string;
|
|
73
73
|
constructor(msg: string, component: string);
|
|
74
74
|
}
|
|
75
|
+
export declare class CommandExecError extends EMBError {
|
|
76
|
+
exitCode: number;
|
|
77
|
+
signal?: (NodeJS.Signals | null) | undefined;
|
|
78
|
+
constructor(msg: string, exitCode: number, signal?: (NodeJS.Signals | null) | undefined);
|
|
79
|
+
}
|
|
75
80
|
export declare class ComposeExecError extends EMBError {
|
|
76
81
|
exitCode: number;
|
|
77
82
|
signal?: (NodeJS.Signals | null) | undefined;
|
package/dist/src/errors.js
CHANGED
|
@@ -95,6 +95,15 @@ export class MultipleContainersFoundError extends EMBError {
|
|
|
95
95
|
this.component = component;
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
|
+
export class CommandExecError extends EMBError {
|
|
99
|
+
exitCode;
|
|
100
|
+
signal;
|
|
101
|
+
constructor(msg, exitCode, signal) {
|
|
102
|
+
super('COMMAND_EXEC_ERR', msg);
|
|
103
|
+
this.exitCode = exitCode;
|
|
104
|
+
this.signal = signal;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
98
107
|
export class ComposeExecError extends EMBError {
|
|
99
108
|
exitCode;
|
|
100
109
|
signal;
|
|
@@ -46,13 +46,7 @@ export class Monorepo {
|
|
|
46
46
|
return new Component(name, this._config.component(name), this);
|
|
47
47
|
}
|
|
48
48
|
get tasks() {
|
|
49
|
-
const globalTasks = Object.
|
|
50
|
-
return {
|
|
51
|
-
...task,
|
|
52
|
-
name,
|
|
53
|
-
id: `global:${name}`,
|
|
54
|
-
};
|
|
55
|
-
});
|
|
49
|
+
const globalTasks = Object.values(this._config.tasks);
|
|
56
50
|
return this.components.reduce((tasks, cmp) => {
|
|
57
51
|
const cmpTasks = Object.entries(cmp.tasks || {}).map(([name, task]) => {
|
|
58
52
|
return {
|
|
@@ -10,8 +10,8 @@ declare const schema: z.ZodObject<{
|
|
|
10
10
|
workingDir: z.ZodOptional<z.ZodString>;
|
|
11
11
|
}, z.core.$strip>;
|
|
12
12
|
export declare class ExecuteLocalCommandOperation extends AbstractOperation<typeof schema, Readable> {
|
|
13
|
-
protected out
|
|
14
|
-
constructor(out
|
|
13
|
+
protected out?: Writable | undefined;
|
|
14
|
+
constructor(out?: Writable | undefined);
|
|
15
15
|
protected _run(input: z.input<typeof schema>): Promise<Readable>;
|
|
16
16
|
}
|
|
17
17
|
export {};
|
|
@@ -29,7 +29,6 @@ export class RunTasksOperation {
|
|
|
29
29
|
if (!task.script) {
|
|
30
30
|
return;
|
|
31
31
|
}
|
|
32
|
-
console.log('YES WE DO', task.component);
|
|
33
32
|
const executor = params.executor ??
|
|
34
33
|
(task.component ? ExecutorType.container : ExecutorType.local);
|
|
35
34
|
if (executor === ExecutorType.container && !task.component) {
|
package/oclif.manifest.json
CHANGED
|
@@ -82,7 +82,12 @@
|
|
|
82
82
|
},
|
|
83
83
|
"up": {
|
|
84
84
|
"aliases": [],
|
|
85
|
-
"args": {
|
|
85
|
+
"args": {
|
|
86
|
+
"component": {
|
|
87
|
+
"description": "The component(s) to build and start",
|
|
88
|
+
"name": "component"
|
|
89
|
+
}
|
|
90
|
+
},
|
|
86
91
|
"description": "Start the whole project.",
|
|
87
92
|
"examples": [
|
|
88
93
|
"<%= config.bin %> <%= command.id %>"
|
|
@@ -117,6 +122,7 @@
|
|
|
117
122
|
"pluginAlias": "@enspirit/emb",
|
|
118
123
|
"pluginName": "@enspirit/emb",
|
|
119
124
|
"pluginType": "core",
|
|
125
|
+
"strict": false,
|
|
120
126
|
"enableJsonFlag": true,
|
|
121
127
|
"isESM": true,
|
|
122
128
|
"relativePath": [
|
|
@@ -184,14 +190,6 @@
|
|
|
184
190
|
"<%= config.bin %> <%= command.id %>"
|
|
185
191
|
],
|
|
186
192
|
"flags": {
|
|
187
|
-
"flavor": {
|
|
188
|
-
"description": "Specify the flavor to use.",
|
|
189
|
-
"name": "flavor",
|
|
190
|
-
"required": false,
|
|
191
|
-
"hasDynamicHelp": false,
|
|
192
|
-
"multiple": false,
|
|
193
|
-
"type": "option"
|
|
194
|
-
},
|
|
195
193
|
"follow": {
|
|
196
194
|
"char": "f",
|
|
197
195
|
"description": "Follow log output",
|
|
@@ -206,6 +204,7 @@
|
|
|
206
204
|
"pluginAlias": "@enspirit/emb",
|
|
207
205
|
"pluginName": "@enspirit/emb",
|
|
208
206
|
"pluginType": "core",
|
|
207
|
+
"strict": true,
|
|
209
208
|
"enableJsonFlag": false,
|
|
210
209
|
"isESM": true,
|
|
211
210
|
"relativePath": [
|
|
@@ -233,14 +232,6 @@
|
|
|
233
232
|
"<%= config.bin %> <%= command.id %>"
|
|
234
233
|
],
|
|
235
234
|
"flags": {
|
|
236
|
-
"flavor": {
|
|
237
|
-
"description": "Specify the flavor to use.",
|
|
238
|
-
"name": "flavor",
|
|
239
|
-
"required": false,
|
|
240
|
-
"hasDynamicHelp": false,
|
|
241
|
-
"multiple": false,
|
|
242
|
-
"type": "option"
|
|
243
|
-
},
|
|
244
235
|
"shell": {
|
|
245
236
|
"char": "s",
|
|
246
237
|
"description": "The shell to run",
|
|
@@ -257,6 +248,7 @@
|
|
|
257
248
|
"pluginAlias": "@enspirit/emb",
|
|
258
249
|
"pluginName": "@enspirit/emb",
|
|
259
250
|
"pluginType": "core",
|
|
251
|
+
"strict": true,
|
|
260
252
|
"enableJsonFlag": false,
|
|
261
253
|
"isESM": true,
|
|
262
254
|
"relativePath": [
|
|
@@ -718,5 +710,5 @@
|
|
|
718
710
|
]
|
|
719
711
|
}
|
|
720
712
|
},
|
|
721
|
-
"version": "0.
|
|
713
|
+
"version": "0.5.0"
|
|
722
714
|
}
|