@enspirit/emb 0.0.5 → 0.0.7
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 +61 -31
- package/dist/src/cli/commands/clean.d.ts +3 -1
- package/dist/src/cli/commands/clean.js +13 -2
- package/dist/src/cli/commands/components/build.d.ts +6 -2
- package/dist/src/cli/commands/components/build.js +16 -7
- package/dist/src/cli/commands/config/print.js +2 -3
- package/dist/src/cli/commands/down.d.ts +2 -2
- package/dist/src/cli/commands/down.js +5 -25
- package/dist/src/cli/commands/tasks/index.js +11 -5
- package/dist/src/cli/commands/tasks/run.d.ts +1 -3
- package/dist/src/cli/commands/tasks/run.js +11 -93
- package/dist/src/cli/commands/up.d.ts +1 -1
- package/dist/src/cli/commands/up.js +12 -34
- package/dist/src/config/convert.d.ts +2 -3
- package/dist/src/config/convert.js +4 -11
- package/dist/src/config/index.d.ts +1 -0
- package/dist/src/config/index.js +1 -0
- package/dist/src/config/schema.d.ts +36 -29
- package/dist/src/config/schema.json +42 -25
- package/dist/src/config/types.d.ts +11 -7
- package/dist/src/config/validation.d.ts +2 -0
- package/dist/src/config/validation.js +26 -1
- package/dist/src/docker/compose/index.d.ts +1 -7
- package/dist/src/docker/compose/index.js +1 -13
- package/dist/src/docker/compose/operations/ComposeDownOperation.d.ts +12 -0
- package/dist/src/docker/compose/operations/ComposeDownOperation.js +21 -0
- package/dist/src/docker/compose/operations/ComposeUpOperation.d.ts +13 -0
- package/dist/src/docker/compose/operations/ComposeUpOperation.js +39 -0
- package/dist/src/docker/compose/operations/index.d.ts +2 -0
- package/dist/src/docker/compose/operations/index.js +2 -0
- package/dist/src/docker/operations/containers/ExecContainerOperation.d.ts +22 -0
- package/dist/src/docker/operations/containers/ExecContainerOperation.js +78 -0
- package/dist/src/docker/operations/containers/index.d.ts +1 -0
- package/dist/src/docker/operations/containers/index.js +1 -0
- package/dist/src/monorepo/component.d.ts +2 -2
- package/dist/src/monorepo/component.js +6 -6
- package/dist/src/monorepo/config.d.ts +6 -3
- package/dist/src/monorepo/config.js +22 -4
- package/dist/src/monorepo/index.d.ts +2 -0
- package/dist/src/monorepo/index.js +2 -0
- package/dist/src/monorepo/monorepo.d.ts +4 -2
- package/dist/src/monorepo/monorepo.js +30 -6
- package/dist/src/monorepo/operations/components/BuildComponentsOperation.d.ts +11 -2
- package/dist/src/monorepo/operations/components/BuildComponentsOperation.js +45 -59
- package/dist/src/monorepo/operations/components/GetComponentContainerOperation.d.ts +6 -0
- package/dist/src/monorepo/operations/components/GetComponentContainerOperation.js +21 -0
- package/dist/src/monorepo/operations/components/index.d.ts +1 -0
- package/dist/src/monorepo/operations/components/index.js +1 -0
- package/dist/src/monorepo/operations/index.d.ts +2 -0
- package/dist/src/monorepo/operations/index.js +2 -0
- package/dist/src/monorepo/operations/shell/ExecuteLocalCommandOperation.d.ts +16 -0
- package/dist/src/monorepo/operations/shell/ExecuteLocalCommandOperation.js +30 -0
- package/dist/src/monorepo/operations/shell/index.d.ts +1 -0
- package/dist/src/monorepo/operations/shell/index.js +1 -0
- package/dist/src/monorepo/operations/tasks/RunTasksOperation.d.ts +21 -0
- package/dist/src/monorepo/operations/tasks/RunTasksOperation.js +84 -0
- package/dist/src/monorepo/operations/tasks/index.d.ts +1 -0
- package/dist/src/monorepo/operations/tasks/index.js +1 -0
- package/dist/src/monorepo/plugins/ComponentDiscoverPlugin.d.ts +15 -0
- package/dist/src/monorepo/plugins/{ComponentsDiscover.js → ComponentDiscoverPlugin.js} +16 -2
- package/dist/src/monorepo/plugins/EmbfileLoaderPlugin.d.ts +14 -0
- package/dist/src/monorepo/plugins/EmbfileLoaderPlugin.js +37 -0
- package/dist/src/monorepo/plugins/index.d.ts +3 -2
- package/dist/src/monorepo/plugins/index.js +5 -2
- package/dist/src/monorepo/store/index.js +5 -3
- package/dist/src/monorepo/taskManagerFactory.d.ts +3 -0
- package/dist/src/monorepo/taskManagerFactory.js +20 -0
- package/dist/src/monorepo/types.d.ts +2 -1
- package/dist/src/monorepo/utils/findRunOrder.d.ts +34 -0
- package/dist/src/monorepo/utils/findRunOrder.js +165 -0
- package/dist/src/monorepo/utils/index.d.ts +1 -1
- package/dist/src/monorepo/utils/index.js +1 -1
- package/dist/src/operations/abstract/AbstractOperation.d.ts +1 -1
- package/dist/src/utils/deepMergeArray.d.ts +3 -0
- package/dist/src/utils/deepMergeArray.js +1 -0
- package/oclif.manifest.json +63 -74
- package/package.json +4 -2
- package/dist/src/cli/commands/run/index.d.ts +0 -10
- package/dist/src/cli/commands/run/index.js +0 -49
- package/dist/src/executors/docker.d.ts +0 -6
- package/dist/src/executors/docker.js +0 -14
- package/dist/src/executors/index.d.ts +0 -6
- package/dist/src/executors/index.js +0 -7
- package/dist/src/executors/shell.d.ts +0 -2
- package/dist/src/executors/shell.js +0 -14
- package/dist/src/executors/types.d.ts +0 -8
- package/dist/src/executors/types.js +0 -1
- package/dist/src/monorepo/plugins/ComponentsDiscover.d.ts +0 -6
- package/dist/src/monorepo/utils/findBuildOrder.d.ts +0 -2
- package/dist/src/monorepo/utils/findBuildOrder.js +0 -41
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
emb (Enspirit's Monorepo Builder)
|
|
2
2
|
=================
|
|
3
3
|
|
|
4
|
-
A CLI to help on Enspirit monorepos. This aims at replacing our aging [Makefile for monorepos](https://github.com/enspirit/makefile-for-monorepos
|
|
4
|
+
A CLI to help on Enspirit monorepos. This aims at replacing our aging [Makefile for monorepos](https://github.com/enspirit/makefile-for-monorepos)
|
|
5
5
|
|
|
6
6
|
<!-- toc -->
|
|
7
7
|
* [Usage](#usage)
|
|
@@ -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.0.
|
|
17
|
+
@enspirit/emb/0.0.7 darwin-x64 node-v22.12.0
|
|
18
18
|
$ emb --help [COMMAND]
|
|
19
19
|
USAGE
|
|
20
20
|
$ emb COMMAND
|
|
@@ -36,10 +36,10 @@ USAGE
|
|
|
36
36
|
* [`emb images delete`](#emb-images-delete)
|
|
37
37
|
* [`emb images prune`](#emb-images-prune)
|
|
38
38
|
* [`emb ps`](#emb-ps)
|
|
39
|
-
* [`emb run COMPONENT SCRIPT`](#emb-run-component-script)
|
|
40
39
|
* [`emb tasks`](#emb-tasks)
|
|
41
|
-
* [`emb tasks run
|
|
40
|
+
* [`emb tasks run TASK`](#emb-tasks-run-task)
|
|
42
41
|
* [`emb up`](#emb-up)
|
|
42
|
+
* [`emb update [CHANNEL]`](#emb-update-channel)
|
|
43
43
|
|
|
44
44
|
## `emb autocomplete [SHELL]`
|
|
45
45
|
|
|
@@ -78,7 +78,10 @@ Clean the project.
|
|
|
78
78
|
|
|
79
79
|
```
|
|
80
80
|
USAGE
|
|
81
|
-
$ emb clean [--json]
|
|
81
|
+
$ emb clean [--json] [-f]
|
|
82
|
+
|
|
83
|
+
FLAGS
|
|
84
|
+
-f, --force Force the deletion of containers & images
|
|
82
85
|
|
|
83
86
|
GLOBAL FLAGS
|
|
84
87
|
--json Format output as json.
|
|
@@ -117,12 +120,13 @@ Build the components of the monorepo
|
|
|
117
120
|
|
|
118
121
|
```
|
|
119
122
|
USAGE
|
|
120
|
-
$ emb components build [COMPONENT...] [--json] [--flavor <value>]
|
|
123
|
+
$ emb components build [COMPONENT...] [--json] [--flavor <value>] [--dry-run]
|
|
121
124
|
|
|
122
125
|
ARGUMENTS
|
|
123
|
-
COMPONENT... List of components to build
|
|
126
|
+
COMPONENT... List of components to build (defaults to all)
|
|
124
127
|
|
|
125
128
|
FLAGS
|
|
129
|
+
--dry-run Do not build the components but only produce build meta information
|
|
126
130
|
--flavor=<value> Specify the flavor to use.
|
|
127
131
|
|
|
128
132
|
GLOBAL FLAGS
|
|
@@ -204,7 +208,10 @@ Stop the whole project.
|
|
|
204
208
|
|
|
205
209
|
```
|
|
206
210
|
USAGE
|
|
207
|
-
$ emb down [--json]
|
|
211
|
+
$ emb down [--json] [--flavor <value>]
|
|
212
|
+
|
|
213
|
+
FLAGS
|
|
214
|
+
--flavor=<value> Specify the flavor to use.
|
|
208
215
|
|
|
209
216
|
GLOBAL FLAGS
|
|
210
217
|
--json Format output as json.
|
|
@@ -323,22 +330,6 @@ EXAMPLES
|
|
|
323
330
|
$ emb ps
|
|
324
331
|
```
|
|
325
332
|
|
|
326
|
-
## `emb run COMPONENT SCRIPT`
|
|
327
|
-
|
|
328
|
-
Run an npm script from a component's package.json
|
|
329
|
-
|
|
330
|
-
```
|
|
331
|
-
USAGE
|
|
332
|
-
$ emb run COMPONENT SCRIPT
|
|
333
|
-
|
|
334
|
-
ARGUMENTS
|
|
335
|
-
COMPONENT Component name
|
|
336
|
-
SCRIPT NPM script to run
|
|
337
|
-
|
|
338
|
-
DESCRIPTION
|
|
339
|
-
Run an npm script from a component's package.json
|
|
340
|
-
```
|
|
341
|
-
|
|
342
333
|
## `emb tasks`
|
|
343
334
|
|
|
344
335
|
List tasks.
|
|
@@ -357,25 +348,26 @@ EXAMPLES
|
|
|
357
348
|
$ emb tasks
|
|
358
349
|
```
|
|
359
350
|
|
|
360
|
-
## `emb tasks run
|
|
351
|
+
## `emb tasks run TASK`
|
|
361
352
|
|
|
362
|
-
Run
|
|
353
|
+
Run tasks.
|
|
363
354
|
|
|
364
355
|
```
|
|
365
356
|
USAGE
|
|
366
|
-
$ emb tasks run
|
|
357
|
+
$ emb tasks run TASK... [--json] [-x container|local]
|
|
367
358
|
|
|
368
359
|
ARGUMENTS
|
|
369
|
-
TASK... List of tasks
|
|
360
|
+
TASK... List of tasks to run. You can provide either ids or names (eg: component:task or task)
|
|
370
361
|
|
|
371
362
|
FLAGS
|
|
372
|
-
-x, --executor=<option>
|
|
363
|
+
-x, --executor=<option> Where to run the task. (experimental!)
|
|
364
|
+
<options: container|local>
|
|
373
365
|
|
|
374
366
|
GLOBAL FLAGS
|
|
375
367
|
--json Format output as json.
|
|
376
368
|
|
|
377
369
|
DESCRIPTION
|
|
378
|
-
Run
|
|
370
|
+
Run tasks.
|
|
379
371
|
|
|
380
372
|
EXAMPLES
|
|
381
373
|
$ emb tasks run
|
|
@@ -390,7 +382,7 @@ USAGE
|
|
|
390
382
|
$ emb up [--json] [--flavor <value>] [-f]
|
|
391
383
|
|
|
392
384
|
FLAGS
|
|
393
|
-
-f, --force
|
|
385
|
+
-f, --force Bypass caches, force the recreation of containers, etc
|
|
394
386
|
--flavor=<value> Specify the flavor to use.
|
|
395
387
|
|
|
396
388
|
GLOBAL FLAGS
|
|
@@ -402,4 +394,42 @@ DESCRIPTION
|
|
|
402
394
|
EXAMPLES
|
|
403
395
|
$ emb up
|
|
404
396
|
```
|
|
397
|
+
|
|
398
|
+
## `emb update [CHANNEL]`
|
|
399
|
+
|
|
400
|
+
update the emb CLI
|
|
401
|
+
|
|
402
|
+
```
|
|
403
|
+
USAGE
|
|
404
|
+
$ emb update [CHANNEL] [--force | | [-a | -v <value> | -i]] [-b ]
|
|
405
|
+
|
|
406
|
+
FLAGS
|
|
407
|
+
-a, --available See available versions.
|
|
408
|
+
-b, --verbose Show more details about the available versions.
|
|
409
|
+
-i, --interactive Interactively select version to install. This is ignored if a channel is provided.
|
|
410
|
+
-v, --version=<value> Install a specific version.
|
|
411
|
+
--force Force a re-download of the requested version.
|
|
412
|
+
|
|
413
|
+
DESCRIPTION
|
|
414
|
+
update the emb CLI
|
|
415
|
+
|
|
416
|
+
EXAMPLES
|
|
417
|
+
Update to the stable channel:
|
|
418
|
+
|
|
419
|
+
$ emb update stable
|
|
420
|
+
|
|
421
|
+
Update to a specific version:
|
|
422
|
+
|
|
423
|
+
$ emb update --version 1.0.0
|
|
424
|
+
|
|
425
|
+
Interactively select version:
|
|
426
|
+
|
|
427
|
+
$ emb update --interactive
|
|
428
|
+
|
|
429
|
+
See available versions:
|
|
430
|
+
|
|
431
|
+
$ emb update --available
|
|
432
|
+
```
|
|
433
|
+
|
|
434
|
+
_See code: [@oclif/plugin-update](https://github.com/oclif/plugin-update/blob/v4.7.3/src/commands/update.ts)_
|
|
405
435
|
<!-- commandsstop -->
|
|
@@ -10,6 +10,8 @@ export default class CleanCommand extends Command {
|
|
|
10
10
|
static description: string;
|
|
11
11
|
static enableJsonFlag: boolean;
|
|
12
12
|
static examples: string[];
|
|
13
|
-
static flags: {
|
|
13
|
+
static flags: {
|
|
14
|
+
force: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
15
|
+
};
|
|
14
16
|
run(): Promise<void>;
|
|
15
17
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getContext } from '../../index.js';
|
|
2
|
-
import { Command } from '@oclif/core';
|
|
2
|
+
import { Command, Flags } from '@oclif/core';
|
|
3
3
|
import { Listr } from 'listr2';
|
|
4
4
|
/**
|
|
5
5
|
* For now, only cleans the stores (logs/sentinels)
|
|
@@ -12,9 +12,16 @@ export default class CleanCommand extends Command {
|
|
|
12
12
|
static description = 'Clean the project.';
|
|
13
13
|
static enableJsonFlag = true;
|
|
14
14
|
static examples = ['<%= config.bin %> <%= command.id %>'];
|
|
15
|
-
static flags = {
|
|
15
|
+
static flags = {
|
|
16
|
+
force: Flags.boolean({
|
|
17
|
+
name: 'force',
|
|
18
|
+
char: 'f',
|
|
19
|
+
description: 'Force the deletion of containers & images',
|
|
20
|
+
}),
|
|
21
|
+
};
|
|
16
22
|
async run() {
|
|
17
23
|
const { monorepo } = getContext();
|
|
24
|
+
const { flags } = await this.parse(CleanCommand);
|
|
18
25
|
const runner = new Listr([
|
|
19
26
|
{
|
|
20
27
|
rendererOptions: { persistentOutput: true },
|
|
@@ -25,5 +32,9 @@ export default class CleanCommand extends Command {
|
|
|
25
32
|
},
|
|
26
33
|
]);
|
|
27
34
|
await runner.run();
|
|
35
|
+
await this.config.runCommand('down');
|
|
36
|
+
await this.config.runCommand('containers:prune');
|
|
37
|
+
await this.config.runCommand('images:delete', flags.force ? ['--force'] : undefined);
|
|
38
|
+
await this.config.runCommand('images:prune', flags.force ? ['-a'] : undefined);
|
|
28
39
|
}
|
|
29
40
|
}
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import { FlavoredCommand } from '../../index.js';
|
|
2
|
+
import { BuildComponentMeta } from '../../../monorepo/index.js';
|
|
2
3
|
export default class BuildCommand extends FlavoredCommand<typeof BuildCommand> {
|
|
3
4
|
static args: {
|
|
4
5
|
component: import("@oclif/core/interfaces").Arg<string | undefined, Record<string, unknown>>;
|
|
5
6
|
};
|
|
6
7
|
static description: string;
|
|
7
8
|
static examples: string[];
|
|
8
|
-
static flags: {
|
|
9
|
+
static flags: {
|
|
10
|
+
'dry-run': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
11
|
+
};
|
|
12
|
+
static enableJsonFlag: boolean;
|
|
9
13
|
static strict: boolean;
|
|
10
|
-
run(): Promise<
|
|
14
|
+
run(): Promise<Record<string, BuildComponentMeta>>;
|
|
11
15
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { Args } from '@oclif/core';
|
|
1
|
+
import { Args, Flags } from '@oclif/core';
|
|
2
2
|
import { FlavoredCommand, getContext } from '../../index.js';
|
|
3
|
-
import { BuildComponentsOperation } from '../../../monorepo/
|
|
3
|
+
import { BuildComponentsOperation } from '../../../monorepo/index.js';
|
|
4
4
|
export default class BuildCommand extends FlavoredCommand {
|
|
5
5
|
static args = {
|
|
6
6
|
component: Args.string({
|
|
7
|
-
description: 'List of components to build',
|
|
7
|
+
description: 'List of components to build (defaults to all)',
|
|
8
8
|
required: false,
|
|
9
9
|
}),
|
|
10
10
|
};
|
|
@@ -12,13 +12,22 @@ export default class BuildCommand extends FlavoredCommand {
|
|
|
12
12
|
static examples = [
|
|
13
13
|
`<%= config.bin %> <%= command.id %> build --flavor development`,
|
|
14
14
|
];
|
|
15
|
-
static flags = {
|
|
15
|
+
static flags = {
|
|
16
|
+
'dry-run': Flags.boolean({
|
|
17
|
+
required: false,
|
|
18
|
+
description: 'Do not build the components but only produce build meta information',
|
|
19
|
+
}),
|
|
20
|
+
};
|
|
21
|
+
static enableJsonFlag = true;
|
|
16
22
|
static strict = false;
|
|
17
23
|
async run() {
|
|
18
|
-
const { argv } = await this.parse(BuildCommand);
|
|
24
|
+
const { argv, flags } = await this.parse(BuildCommand);
|
|
19
25
|
const { monorepo } = getContext();
|
|
20
|
-
|
|
21
|
-
|
|
26
|
+
return monorepo.run(new BuildComponentsOperation(), {
|
|
27
|
+
dryRun: flags['dry-run'],
|
|
28
|
+
components: argv.length > 0
|
|
29
|
+
? argv
|
|
30
|
+
: monorepo.components.map((c) => c.name),
|
|
22
31
|
});
|
|
23
32
|
}
|
|
24
33
|
}
|
|
@@ -7,10 +7,9 @@ export default class ConfigPrint extends FlavoredCommand {
|
|
|
7
7
|
async run() {
|
|
8
8
|
const { flags } = await this.parse(ConfigPrint);
|
|
9
9
|
const context = await getContext();
|
|
10
|
-
const { monorepo } = context;
|
|
11
10
|
if (!flags.json) {
|
|
12
|
-
|
|
11
|
+
this.log(YAML.stringify(context.monorepo.config));
|
|
13
12
|
}
|
|
14
|
-
return monorepo.config;
|
|
13
|
+
return context.monorepo.config;
|
|
15
14
|
}
|
|
16
15
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export default class DownCommand extends
|
|
1
|
+
import { FlavoredCommand } from '../index.js';
|
|
2
|
+
export default class DownCommand extends FlavoredCommand<typeof DownCommand> {
|
|
3
3
|
static description: string;
|
|
4
4
|
static enableJsonFlag: boolean;
|
|
5
5
|
static examples: string[];
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { getContext } from '../../index.js';
|
|
2
|
-
import { Command } from '@oclif/core';
|
|
3
1
|
import { Listr } from 'listr2';
|
|
4
|
-
import {
|
|
5
|
-
|
|
2
|
+
import { FlavoredCommand, getContext } from '../index.js';
|
|
3
|
+
import { ComposeDownOperation } from '../../docker/index.js';
|
|
4
|
+
export default class DownCommand extends FlavoredCommand {
|
|
6
5
|
static description = 'Stop the whole project.';
|
|
7
6
|
static enableJsonFlag = true;
|
|
8
7
|
static examples = ['<%= config.bin %> <%= command.id %>'];
|
|
@@ -12,27 +11,8 @@ export default class DownCommand extends Command {
|
|
|
12
11
|
const runner = new Listr([
|
|
13
12
|
{
|
|
14
13
|
rendererOptions: { persistentOutput: true },
|
|
15
|
-
async task(
|
|
16
|
-
|
|
17
|
-
const handleOutput = (chunk) => {
|
|
18
|
-
const line = chunk.toString();
|
|
19
|
-
task.output = line.trimEnd(); // This updates the live output in Listr
|
|
20
|
-
};
|
|
21
|
-
process.stdout?.on('data', handleOutput);
|
|
22
|
-
process.stderr?.on('data', handleOutput);
|
|
23
|
-
return new Promise((resolve, reject) => {
|
|
24
|
-
process.on('exit', (code) => {
|
|
25
|
-
if (code === 0) {
|
|
26
|
-
resolve(null);
|
|
27
|
-
}
|
|
28
|
-
else {
|
|
29
|
-
reject(new Error(`Command failed with code ${code}`));
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
process.on('error', (err) => {
|
|
33
|
-
reject(err);
|
|
34
|
-
});
|
|
35
|
-
});
|
|
14
|
+
async task() {
|
|
15
|
+
return monorepo.run(new ComposeDownOperation(), {});
|
|
36
16
|
},
|
|
37
17
|
title: 'Stopping project',
|
|
38
18
|
},
|
|
@@ -9,14 +9,20 @@ export default class TasksIndex extends Command {
|
|
|
9
9
|
static flags = {};
|
|
10
10
|
async run() {
|
|
11
11
|
const { flags } = await this.parse(TasksIndex);
|
|
12
|
-
const
|
|
13
|
-
const { monorepo } = context;
|
|
14
|
-
const { tasks } = monorepo;
|
|
12
|
+
const { monorepo: { tasks }, } = await getContext();
|
|
15
13
|
if (!flags.json)
|
|
16
14
|
printTable({
|
|
17
15
|
...TABLE_DEFAULTS,
|
|
18
|
-
columns: ['
|
|
19
|
-
data: tasks,
|
|
16
|
+
columns: ['name', 'component', 'description', 'id'],
|
|
17
|
+
data: tasks.toSorted((a, b) => {
|
|
18
|
+
if (a.component === b.component) {
|
|
19
|
+
return a.name < b.name ? -1 : 1;
|
|
20
|
+
}
|
|
21
|
+
if (!a.component && b.component) {
|
|
22
|
+
return -1;
|
|
23
|
+
}
|
|
24
|
+
return 0;
|
|
25
|
+
}),
|
|
20
26
|
});
|
|
21
27
|
return tasks;
|
|
22
28
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Command } from '@oclif/core';
|
|
2
2
|
export default class RunTask extends Command {
|
|
3
3
|
static args: {
|
|
4
|
-
task: import("@oclif/core/interfaces").Arg<string
|
|
4
|
+
task: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
5
5
|
};
|
|
6
6
|
static description: string;
|
|
7
7
|
static enableJsonFlag: boolean;
|
|
@@ -11,6 +11,4 @@ export default class RunTask extends Command {
|
|
|
11
11
|
};
|
|
12
12
|
static strict: boolean;
|
|
13
13
|
run(): Promise<void>;
|
|
14
|
-
private dockerExec;
|
|
15
|
-
private shellExec;
|
|
16
14
|
}
|
|
@@ -1,113 +1,31 @@
|
|
|
1
1
|
import { getContext } from '../../../index.js';
|
|
2
2
|
import { Args, Command, Flags } from '@oclif/core';
|
|
3
|
-
import {
|
|
4
|
-
import { PassThrough } from 'node:stream';
|
|
5
|
-
import { getContainer, ListContainersOperation } from '../../../docker/index.js';
|
|
6
|
-
import { dockerExecutor } from '../../../executors/docker.js';
|
|
7
|
-
import { ExecutorType } from '../../../executors/index.js';
|
|
8
|
-
import { shellExecutor } from '../../../executors/shell.js';
|
|
3
|
+
import { ExecutorType, RunTasksOperation } from '../../../monorepo/index.js';
|
|
9
4
|
export default class RunTask extends Command {
|
|
10
5
|
static args = {
|
|
11
6
|
task: Args.string({
|
|
12
|
-
description: 'List of tasks
|
|
13
|
-
required:
|
|
7
|
+
description: 'List of tasks to run. You can provide either ids or names (eg: component:task or task)',
|
|
8
|
+
required: true,
|
|
14
9
|
}),
|
|
15
10
|
};
|
|
16
|
-
static description = 'Run
|
|
11
|
+
static description = 'Run tasks.';
|
|
17
12
|
static enableJsonFlag = true;
|
|
18
13
|
static examples = ['<%= config.bin %> <%= command.id %>'];
|
|
19
14
|
static flags = {
|
|
20
15
|
executor: Flags.string({
|
|
21
|
-
char: 'x',
|
|
22
16
|
name: 'executor',
|
|
23
|
-
|
|
17
|
+
char: 'x',
|
|
18
|
+
description: 'Where to run the task. (experimental!)',
|
|
19
|
+
options: Object.values(ExecutorType),
|
|
24
20
|
}),
|
|
25
21
|
};
|
|
26
22
|
static strict = false;
|
|
27
23
|
async run() {
|
|
28
24
|
const { argv, flags } = await this.parse(RunTask);
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
const found = monorepo.tasks.filter((task) => task.id === t);
|
|
34
|
-
if (found.length === 0) {
|
|
35
|
-
throw new Error(`Task ${t} not found`);
|
|
36
|
-
}
|
|
37
|
-
return [...tasks, ...found];
|
|
38
|
-
}, [])
|
|
39
|
-
: monorepo.tasks;
|
|
40
|
-
const runTasks = toRun.map((task) => {
|
|
41
|
-
return {
|
|
42
|
-
rendererOptions: { persistentOutput: true },
|
|
43
|
-
task: async (_ctx, listrTask) => {
|
|
44
|
-
const type = flags.executor
|
|
45
|
-
? flags.executor
|
|
46
|
-
: ExecutorType.container;
|
|
47
|
-
const logStream = await monorepo.store.createWriteStream(`logs/tasks/run/${task.id}.log`);
|
|
48
|
-
// Gonna log on both the logStream and stdout
|
|
49
|
-
const tee = new PassThrough();
|
|
50
|
-
tee.pipe(listrTask.stdout());
|
|
51
|
-
tee.pipe(logStream);
|
|
52
|
-
switch (type) {
|
|
53
|
-
case ExecutorType.container: {
|
|
54
|
-
return this.dockerExec(task, tee);
|
|
55
|
-
}
|
|
56
|
-
case ExecutorType.local: {
|
|
57
|
-
return this.shellExec(task, tee);
|
|
58
|
-
}
|
|
59
|
-
default: {
|
|
60
|
-
throw new Error(`Unsupported executor: ${type}`);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
},
|
|
64
|
-
title: `Running ${task.id}`,
|
|
65
|
-
};
|
|
66
|
-
});
|
|
67
|
-
const runner = new Listr([
|
|
68
|
-
{
|
|
69
|
-
rendererOptions: { persistentOutput: true },
|
|
70
|
-
async task(ctx, task) {
|
|
71
|
-
return task.newListr(runTasks, {
|
|
72
|
-
exitOnError: true,
|
|
73
|
-
rendererOptions: { collapseSubtasks: false },
|
|
74
|
-
});
|
|
75
|
-
},
|
|
76
|
-
title: 'Running tasks',
|
|
77
|
-
},
|
|
78
|
-
]);
|
|
79
|
-
await runner.run();
|
|
80
|
-
}
|
|
81
|
-
async dockerExec(task, out) {
|
|
82
|
-
const { monorepo } = getContext();
|
|
83
|
-
const matching = await monorepo.run(new ListContainersOperation(), {
|
|
84
|
-
filters: {
|
|
85
|
-
label: [
|
|
86
|
-
`emb/project=${monorepo.name}`,
|
|
87
|
-
`emb/component=${task.component}`,
|
|
88
|
-
],
|
|
89
|
-
},
|
|
90
|
-
});
|
|
91
|
-
if (matching.length === 0) {
|
|
92
|
-
throw new Error(`Could not find a running container for '${task.component}'`);
|
|
93
|
-
}
|
|
94
|
-
if (matching.length > 1) {
|
|
95
|
-
throw new Error(`More than one running container found for '${task.component}'`);
|
|
96
|
-
}
|
|
97
|
-
const container = await getContainer(matching[0].Id);
|
|
98
|
-
return dockerExecutor.run(task.script, {
|
|
99
|
-
container,
|
|
100
|
-
out,
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
async shellExec(task, out) {
|
|
104
|
-
const { monorepo } = getContext();
|
|
105
|
-
const cwd = task.component
|
|
106
|
-
? monorepo.component(task.component).rootdir
|
|
107
|
-
: monorepo.rootDir;
|
|
108
|
-
return shellExecutor.run(task.script, {
|
|
109
|
-
cwd,
|
|
110
|
-
out,
|
|
25
|
+
const { monorepo } = await getContext();
|
|
26
|
+
await monorepo.run(new RunTasksOperation(), {
|
|
27
|
+
tasks: argv,
|
|
28
|
+
executor: flags.executor,
|
|
111
29
|
});
|
|
112
30
|
}
|
|
113
31
|
}
|
|
@@ -4,7 +4,7 @@ export default class UpCommand extends FlavoredCommand<typeof UpCommand> {
|
|
|
4
4
|
static enableJsonFlag: boolean;
|
|
5
5
|
static examples: string[];
|
|
6
6
|
static flags: {
|
|
7
|
-
|
|
7
|
+
force: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
8
8
|
};
|
|
9
9
|
run(): Promise<void>;
|
|
10
10
|
}
|
|
@@ -1,49 +1,27 @@
|
|
|
1
1
|
import { Flags } from '@oclif/core';
|
|
2
|
-
import { Listr } from 'listr2';
|
|
3
2
|
import { FlavoredCommand, getContext } from '../index.js';
|
|
4
|
-
import {
|
|
3
|
+
import { ComposeUpOperation } from '../../docker/index.js';
|
|
4
|
+
import { BuildComponentsOperation } from '../../monorepo/index.js';
|
|
5
5
|
export default class UpCommand extends FlavoredCommand {
|
|
6
6
|
static description = 'Start the whole project.';
|
|
7
7
|
static enableJsonFlag = true;
|
|
8
8
|
static examples = ['<%= config.bin %> <%= command.id %>'];
|
|
9
9
|
static flags = {
|
|
10
|
-
|
|
10
|
+
force: Flags.boolean({
|
|
11
11
|
char: 'f',
|
|
12
12
|
default: false,
|
|
13
|
-
description:
|
|
14
|
-
name: 'force
|
|
13
|
+
description: 'Bypass caches, force the recreation of containers, etc',
|
|
14
|
+
name: 'force',
|
|
15
15
|
}),
|
|
16
16
|
};
|
|
17
17
|
async run() {
|
|
18
|
+
const { flags } = await this.parse(UpCommand);
|
|
18
19
|
const { monorepo } = getContext();
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
const line = chunk.toString();
|
|
26
|
-
task.output = line.trimEnd(); // This updates the live output in Listr
|
|
27
|
-
};
|
|
28
|
-
process.stdout?.on('data', handleOutput);
|
|
29
|
-
process.stderr?.on('data', handleOutput);
|
|
30
|
-
return new Promise((resolve, reject) => {
|
|
31
|
-
process.on('exit', (code) => {
|
|
32
|
-
if (code === 0) {
|
|
33
|
-
resolve(null);
|
|
34
|
-
}
|
|
35
|
-
else {
|
|
36
|
-
reject(new Error(`Command failed with code ${code}`));
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
process.on('error', (err) => {
|
|
40
|
-
reject(err);
|
|
41
|
-
});
|
|
42
|
-
});
|
|
43
|
-
},
|
|
44
|
-
title: 'Starting project',
|
|
45
|
-
},
|
|
46
|
-
]);
|
|
47
|
-
await runner.run();
|
|
20
|
+
await monorepo.run(new BuildComponentsOperation(), {
|
|
21
|
+
components: monorepo.components.map((c) => c.name),
|
|
22
|
+
});
|
|
23
|
+
await monorepo.run(new ComposeUpOperation(), {
|
|
24
|
+
forceRecreate: flags.force,
|
|
25
|
+
});
|
|
48
26
|
}
|
|
49
27
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { Flavor } from './schema.js';
|
|
2
|
+
import { FlavorConfig, IMonorepoConfig, UserConfig } from './types.js';
|
|
3
3
|
export declare const toFlavor: (flavor: Flavor) => FlavorConfig;
|
|
4
|
-
export declare const toComponent: (cmp: Component) => ComponentConfig;
|
|
5
4
|
export declare const toProjectConfig: (config: UserConfig, rootDir?: string) => IMonorepoConfig;
|
|
@@ -3,14 +3,9 @@ import { cwd } from 'node:process';
|
|
|
3
3
|
export const toFlavor = (flavor) => {
|
|
4
4
|
return {
|
|
5
5
|
...flavor,
|
|
6
|
-
components: flavor.components
|
|
6
|
+
components: flavor.components,
|
|
7
7
|
};
|
|
8
8
|
};
|
|
9
|
-
export const toComponent = (cmp) => {
|
|
10
|
-
return typeof cmp === 'string'
|
|
11
|
-
? { context: cmp, name: cmp }
|
|
12
|
-
: cmp;
|
|
13
|
-
};
|
|
14
9
|
export const toProjectConfig = (config, rootDir) => {
|
|
15
10
|
const project = typeof config.project === 'string'
|
|
16
11
|
? { name: config.project }
|
|
@@ -23,9 +18,10 @@ export const toProjectConfig = (config, rootDir) => {
|
|
|
23
18
|
else {
|
|
24
19
|
project.rootDir = rootDir || cwd();
|
|
25
20
|
}
|
|
26
|
-
const components =
|
|
27
|
-
const { defaults,
|
|
21
|
+
const components = config.components || [];
|
|
22
|
+
const { defaults, flavors, ...rest } = config;
|
|
28
23
|
return {
|
|
24
|
+
...rest,
|
|
29
25
|
components,
|
|
30
26
|
defaults: {
|
|
31
27
|
...defaults,
|
|
@@ -37,12 +33,9 @@ export const toProjectConfig = (config, rootDir) => {
|
|
|
37
33
|
},
|
|
38
34
|
},
|
|
39
35
|
},
|
|
40
|
-
env,
|
|
41
36
|
flavors: flavors?.map(toFlavor),
|
|
42
|
-
plugins,
|
|
43
37
|
project: {
|
|
44
38
|
...project,
|
|
45
39
|
},
|
|
46
|
-
vars,
|
|
47
40
|
};
|
|
48
41
|
};
|
package/dist/src/config/index.js
CHANGED
|
@@ -3,6 +3,7 @@ import { dirname } from 'node:path';
|
|
|
3
3
|
import { toProjectConfig } from './convert.js';
|
|
4
4
|
import { validateUserConfig } from './validation.js';
|
|
5
5
|
export * from './convert.js';
|
|
6
|
+
export * from './schema.js';
|
|
6
7
|
export * from './types.js';
|
|
7
8
|
export * from './validation.js';
|
|
8
9
|
let config;
|