@enspirit/emb 0.4.2 → 0.5.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/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.4.2 darwin-x64 node-v22.18.0
17
+ @enspirit/emb/0.5.1 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 [--flavor <value>] [-f]
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 Follow log output
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 [--flavor <value>] [-s <value>]
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> [default: bash] The shell to run
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 [--flavor <value>] [-f]
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 Follow log output
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 [--flavor <value>] [-s <value>]
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> [default: bash] The shell to run
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 { FlavoredCommand } from '../../index.js';
2
- export default class ComponentsLogs extends FlavoredCommand<typeof ComponentsLogs> {
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 { FlavoredCommand, getContext } from '../../index.js';
2
+ import { BaseCommand, getContext } from '../../index.js';
3
3
  import { ListContainersOperation } from '../../../docker/index.js';
4
- export default class ComponentsLogs extends FlavoredCommand {
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 { FlavoredCommand } from '../../index.js';
2
- export default class ComponentsLogs extends FlavoredCommand<typeof ComponentsLogs> {
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 { FlavoredCommand, getContext } from '../../index.js';
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 FlavoredCommand {
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,16 +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
- await this.config.runCommand('resources:build', buildFlags);
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
+ }, []);
44
+ }
45
+ else {
46
+ resources = monorepo.resources.map((r) => r.id);
47
+ }
48
+ await monorepo.run(new BuildResourcesOperation(), {
49
+ force: flags.force,
50
+ resources,
51
+ });
24
52
  await monorepo.run(new ComposeUpOperation(), {
25
53
  forceRecreate: flags.force,
54
+ components: components?.map((c) => c.name),
26
55
  });
27
56
  }
28
57
  }
@@ -10,7 +10,7 @@
10
10
  "required": ["name"],
11
11
  "properties": {
12
12
  "name": {
13
- "$ref": "#/$defs/Identifier",
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": "#/$defs/Identifier"
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": "#/$defs/DefaultsConfig"
51
+ "$ref": "#/definitions/DefaultsConfig"
52
52
  },
53
53
  "components": {
54
54
  "type": "object",
55
55
  "additionalProperties": {
56
- "$ref": "#/$defs/ComponentConfig"
56
+ "$ref": "#/definitions/ComponentConfig"
57
57
  }
58
58
  },
59
59
  "flavors": {
60
60
  "type": "object",
61
61
  "additionalProperties": {
62
- "$ref": "#/$defs/ProjectFlavorConfig"
62
+ "$ref": "#/definitions/ProjectFlavorConfig"
63
63
  }
64
64
  },
65
65
  "tasks": {
66
66
  "type": "object",
67
67
  "additionalProperties": {
68
- "$ref": "#/$defs/TaskConfig"
68
+ "$ref": "#/definitions/TaskConfig"
69
69
  }
70
70
  }
71
71
  },
72
72
  "required": ["project"],
73
- "$defs": {
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": "#/$defs/Identifier"
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": "#/$defs/Identifier"
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": "#/$defs/Identifier"
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": "#/$defs/TaskConfig"
159
+ "$ref": "#/definitions/TaskConfig"
160
160
  }
161
161
  },
162
162
  "resources": {
163
163
  "type": "object",
164
164
  "additionalProperties": {
165
- "$ref": "#/$defs/ResourceConfig"
165
+ "$ref": "#/definitions/ResourceConfig"
166
166
  }
167
167
  },
168
168
  "flavors": {
169
169
  "type": "object",
170
170
  "additionalProperties": {
171
- "$ref": "#/$defs/ComponentFlavorConfig"
171
+ "$ref": "#/definitions/ComponentFlavorConfig"
172
172
  }
173
173
  }
174
174
  },
@@ -188,6 +188,17 @@
188
188
  "type": "string",
189
189
  "description": "The stage to target for the build"
190
190
  },
191
+ "labels": {
192
+ "type": "object",
193
+ "additionalProperties": {
194
+ "type": "string"
195
+ },
196
+ "description": "Labels to apply to the resulting image"
197
+ },
198
+ "context": {
199
+ "type": "string",
200
+ "description": "The context folder for the docker build"
201
+ },
191
202
  "dockerfile": {
192
203
  "type": "string",
193
204
  "description": "The Dockerfile to use"
@@ -203,7 +214,7 @@
203
214
  "patches": {
204
215
  "type": "array",
205
216
  "items": {
206
- "$ref": "#/$defs/JsonPatchOperation"
217
+ "$ref": "#/definitions/JsonPatchOperation"
207
218
  }
208
219
  }
209
220
  }
@@ -216,9 +227,7 @@
216
227
  "params": {},
217
228
  "dependencies": {
218
229
  "type": "array",
219
- "items": {
220
- "$ref": "#/$defs/QualifiedIdentifier"
221
- },
230
+ "items": { "$ref": "#/definitions/QualifiedIdentifier" },
222
231
  "uniqueItems": true
223
232
  }
224
233
  },
@@ -226,14 +235,36 @@
226
235
  "allOf": [
227
236
  {
228
237
  "if": {
229
- "properties": { "type": { "const": "docker/DockerImageConfig" } },
238
+ "properties": {
239
+ "type": { "const": "docker/image" }
240
+ },
230
241
  "required": ["type"]
231
242
  },
232
243
  "then": {
233
- "properties": { "params": { "$ref": "#/$defs/DockerImageConfig" } }
244
+ "properties": {
245
+ "params": { "$ref": "#/definitions/DockerImageConfig" }
246
+ }
247
+ }
248
+ },
249
+ {
250
+ "if": {
251
+ "properties": {
252
+ "type": { "const": "file" }
253
+ },
254
+ "required": ["type"]
234
255
  },
235
- "else": {
236
- "properties": { "params": { "type": "object" } }
256
+ "then": {
257
+ "properties": {
258
+ "params": {
259
+ "type": "object",
260
+ "additionalProperties": false,
261
+ "properties": {
262
+ "path": {
263
+ "type": "string"
264
+ }
265
+ }
266
+ }
267
+ }
237
268
  }
238
269
  }
239
270
  ]
@@ -246,7 +277,7 @@
246
277
  "patches": {
247
278
  "type": "array",
248
279
  "items": {
249
- "$ref": "#/$defs/JsonPatchOperation"
280
+ "$ref": "#/definitions/JsonPatchOperation"
250
281
  }
251
282
  }
252
283
  }
@@ -302,11 +333,11 @@
302
333
  },
303
334
  "JsonPatchOperation": {
304
335
  "oneOf": [
305
- { "$ref": "#/$defs/JsonPatchAddOperation" },
306
- { "$ref": "#/$defs/JsonPatchRemoveOperation" },
307
- { "$ref": "#/$defs/JsonPatchReplaceOperation" },
308
- { "$ref": "#/$defs/JsonPatchMoveOperation" },
309
- { "$ref": "#/$defs/JsonPatchCopyOperation" }
336
+ { "$ref": "#/definitions/JsonPatchAddOperation" },
337
+ { "$ref": "#/definitions/JsonPatchRemoveOperation" },
338
+ { "$ref": "#/definitions/JsonPatchReplaceOperation" },
339
+ { "$ref": "#/definitions/JsonPatchMoveOperation" },
340
+ { "$ref": "#/definitions/JsonPatchCopyOperation" }
310
341
  ]
311
342
  }
312
343
  }
@@ -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#/$defs/ComponentConfig');
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
  }
@@ -43,19 +43,11 @@ export class BuildImageOperation extends AbstractOperation {
43
43
  return this._buildWithDockerCLI(input);
44
44
  }
45
45
  async _buildWithDockerCLI(input) {
46
- const labels = Object.entries(input.labels || {})
47
- .reduce((arr, [key, value]) => {
48
- arr.push(`${key.trim()}=${value.trim()}`);
49
- return arr;
50
- }, [])
51
- .join(',');
52
46
  const args = [
53
47
  'build',
54
48
  input.context,
55
49
  '-f',
56
50
  join(input.context, input.dockerfile || 'Dockerfile'),
57
- '--label',
58
- labels,
59
51
  ];
60
52
  if (input.tag) {
61
53
  args.push('--tag', input.tag);
@@ -66,6 +58,9 @@ export class BuildImageOperation extends AbstractOperation {
66
58
  Object.entries(input.buildArgs || []).forEach(([key, value]) => {
67
59
  args.push('--build-arg', `${key.trim()}=${value.trim()}`);
68
60
  });
61
+ Object.entries(input.labels || {}).forEach(([key, value]) => {
62
+ args.push('--label', `${key.trim()}=${value.trim()}`);
63
+ });
69
64
  const logFile = await this.context.monorepo.store.createWriteStream(`logs/docker/build/${input.tag}.log`);
70
65
  const tee = new PassThrough();
71
66
  tee.pipe(logFile);
@@ -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.entries(this._config.tasks || {}).map(([name, task]) => {
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 {
@@ -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.4.2"
713
+ "version": "0.5.1"
722
714
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@enspirit/emb",
3
3
  "type": "module",
4
- "version": "0.4.2",
4
+ "version": "0.5.1",
5
5
  "keywords": [
6
6
  "monorepo",
7
7
  "docker",