@enspirit/emb 0.0.9 → 0.1.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 +50 -28
- package/dist/src/cli/abstract/BaseCommand.d.ts +6 -0
- package/dist/src/cli/abstract/BaseCommand.js +33 -0
- package/dist/src/cli/abstract/FlavouredCommand.d.ts +2 -1
- package/dist/src/cli/abstract/FlavouredCommand.js +4 -3
- package/dist/src/cli/abstract/index.d.ts +1 -0
- package/dist/src/cli/abstract/index.js +1 -0
- package/dist/src/cli/commands/clean.d.ts +2 -2
- package/dist/src/cli/commands/clean.js +7 -6
- package/dist/src/cli/commands/components/index.d.ts +5 -4
- package/dist/src/cli/commands/components/index.js +13 -15
- package/dist/src/cli/commands/config/print.d.ts +2 -2
- package/dist/src/cli/commands/containers/index.d.ts +2 -2
- package/dist/src/cli/commands/containers/index.js +3 -3
- package/dist/src/cli/commands/containers/prune.d.ts +2 -2
- package/dist/src/cli/commands/containers/prune.js +2 -2
- package/dist/src/cli/commands/images/delete.d.ts +2 -2
- package/dist/src/cli/commands/images/delete.js +3 -2
- package/dist/src/cli/commands/images/index.d.ts +2 -2
- package/dist/src/cli/commands/images/index.js +3 -3
- package/dist/src/cli/commands/images/prune.d.ts +2 -2
- package/dist/src/cli/commands/images/prune.js +3 -2
- package/dist/src/cli/commands/{components → resources}/build.d.ts +3 -3
- package/dist/src/cli/commands/{components → resources}/build.js +11 -10
- package/dist/src/cli/commands/resources/index.d.ts +9 -0
- package/dist/src/cli/commands/resources/index.js +28 -0
- package/dist/src/cli/commands/tasks/index.d.ts +2 -2
- package/dist/src/cli/commands/tasks/index.js +4 -4
- package/dist/src/cli/commands/tasks/run.d.ts +2 -2
- package/dist/src/cli/commands/tasks/run.js +12 -5
- package/dist/src/cli/commands/up.js +5 -4
- package/dist/src/cli/hooks/init.js +1 -26
- package/dist/src/cli/utils.d.ts +1 -0
- package/dist/src/cli/utils.js +26 -0
- package/dist/src/config/convert.d.ts +2 -4
- package/dist/src/config/convert.js +12 -35
- package/dist/src/config/index.d.ts +3 -4
- package/dist/src/config/index.js +2 -3
- package/dist/src/config/schema.d.ts +71 -46
- package/dist/src/config/schema.json +187 -97
- package/dist/src/config/types.d.ts +13 -46
- package/dist/src/config/types.js +1 -1
- package/dist/src/config/validation.d.ts +3 -3
- package/dist/src/config/validation.js +12 -9
- package/dist/src/context.d.ts +1 -1
- package/dist/src/context.js +1 -0
- package/dist/src/docker/images/index.d.ts +0 -1
- package/dist/src/docker/images/index.js +0 -1
- package/dist/src/docker/index.d.ts +1 -1
- package/dist/src/docker/index.js +1 -1
- package/dist/src/docker/operations/containers/ExecContainerOperation.js +2 -1
- package/dist/src/docker/operations/images/BuildImageOperation.d.ts +7 -8
- package/dist/src/docker/operations/images/BuildImageOperation.js +16 -10
- package/dist/src/docker/resources/DockerImageResource.js +62 -0
- package/dist/src/docker/resources/index.d.ts +1 -0
- package/dist/src/docker/resources/index.js +1 -0
- package/dist/src/docker/utils.d.ts +1 -7
- package/dist/src/docker/utils.js +3 -7
- package/dist/src/errors.d.ts +9 -6
- package/dist/src/errors.js +15 -9
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.js +2 -0
- package/dist/src/monorepo/component.d.ts +14 -21
- package/dist/src/monorepo/component.js +40 -63
- package/dist/src/monorepo/config.d.ts +13 -15
- package/dist/src/monorepo/config.js +15 -46
- package/dist/src/monorepo/index.d.ts +1 -0
- package/dist/src/monorepo/index.js +1 -0
- package/dist/src/monorepo/monorepo.d.ts +13 -10
- package/dist/src/monorepo/monorepo.js +77 -19
- package/dist/src/monorepo/operations/components/index.d.ts +0 -1
- package/dist/src/monorepo/operations/components/index.js +0 -1
- package/dist/src/monorepo/operations/fs/CreateFileOperation.d.ts +11 -0
- package/dist/src/monorepo/operations/fs/CreateFileOperation.js +31 -0
- package/dist/src/monorepo/operations/fs/index.d.ts +1 -0
- package/dist/src/monorepo/operations/fs/index.js +1 -0
- package/dist/src/monorepo/operations/index.d.ts +1 -0
- package/dist/src/monorepo/operations/index.js +1 -0
- package/dist/src/monorepo/operations/resources/BuildResourcesOperation.d.ts +27 -0
- package/dist/src/monorepo/operations/resources/BuildResourcesOperation.js +146 -0
- package/dist/src/monorepo/operations/tasks/RunTasksOperation.js +1 -1
- package/dist/src/monorepo/plugins/{ComponentDiscoverPlugin.d.ts → AutoDockerPlugin.d.ts} +4 -4
- package/dist/src/monorepo/plugins/AutoDockerPlugin.js +46 -0
- package/dist/src/monorepo/plugins/EmbfileLoaderPlugin.js +12 -2
- package/dist/src/monorepo/plugins/index.d.ts +1 -1
- package/dist/src/monorepo/plugins/index.js +3 -3
- package/dist/src/monorepo/resources/FileResource.d.ts +1 -0
- package/dist/src/monorepo/resources/FileResource.js +13 -0
- package/dist/src/monorepo/resources/ResourceFactory.d.ts +23 -0
- package/dist/src/monorepo/resources/ResourceFactory.js +16 -0
- package/dist/src/monorepo/resources/index.d.ts +1 -0
- package/dist/src/monorepo/resources/index.js +1 -0
- package/dist/src/monorepo/store/index.d.ts +1 -1
- package/dist/src/monorepo/store/index.js +10 -2
- package/dist/src/monorepo/taskManagerFactory.d.ts +2 -2
- package/dist/src/monorepo/taskManagerFactory.js +1 -2
- package/dist/src/monorepo/types.d.ts +18 -5
- package/dist/src/monorepo/utils/{findRunOrder.d.ts → EMBCollection.d.ts} +3 -9
- package/dist/src/monorepo/utils/EMBCollection.js +101 -0
- package/dist/src/monorepo/utils/graph.d.ts +15 -0
- package/dist/src/monorepo/utils/graph.js +84 -0
- package/dist/src/monorepo/utils/index.d.ts +7 -1
- package/dist/src/monorepo/utils/index.js +14 -1
- package/dist/src/monorepo/utils/types.d.ts +2 -0
- package/dist/src/monorepo/utils/types.js +1 -0
- package/dist/src/operations/abstract/AbstractOperation.d.ts +3 -1
- package/dist/src/operations/abstract/AbstractOperation.js +3 -0
- package/dist/src/operations/types.d.ts +1 -1
- package/dist/src/prerequisites/GitPrerequisitePlugin.d.ts +1 -2
- package/dist/src/prerequisites/GitPrerequisitePlugin.js +3 -3
- package/dist/src/prerequisites/types.d.ts +2 -2
- package/dist/src/utils/TemplateExpander.d.ts +2 -1
- package/dist/src/utils/TemplateExpander.js +3 -1
- package/oclif.manifest.json +126 -89
- package/package.json +7 -2
- package/dist/src/docker/images/buildImage.d.ts +0 -19
- package/dist/src/docker/images/buildImage.js +0 -64
- package/dist/src/docker/types.d.ts +0 -14
- package/dist/src/monorepo/operations/components/BuildComponentsOperation.d.ts +0 -23
- package/dist/src/monorepo/operations/components/BuildComponentsOperation.js +0 -157
- package/dist/src/monorepo/plugins/ComponentDiscoverPlugin.js +0 -44
- package/dist/src/monorepo/project.d.ts +0 -6
- package/dist/src/monorepo/project.js +0 -8
- package/dist/src/monorepo/utils/findRunOrder.js +0 -165
- /package/dist/src/docker/{types.js → resources/DockerImageResource.d.ts} +0 -0
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.1.1 darwin-x64 node-v22.12.0
|
|
18
18
|
$ emb --help [COMMAND]
|
|
19
19
|
USAGE
|
|
20
20
|
$ emb COMMAND
|
|
@@ -26,7 +26,6 @@ USAGE
|
|
|
26
26
|
* [`emb autocomplete [SHELL]`](#emb-autocomplete-shell)
|
|
27
27
|
* [`emb clean`](#emb-clean)
|
|
28
28
|
* [`emb components`](#emb-components)
|
|
29
|
-
* [`emb components build [COMPONENT]`](#emb-components-build-component)
|
|
30
29
|
* [`emb config print`](#emb-config-print)
|
|
31
30
|
* [`emb containers`](#emb-containers)
|
|
32
31
|
* [`emb containers prune`](#emb-containers-prune)
|
|
@@ -36,6 +35,8 @@ USAGE
|
|
|
36
35
|
* [`emb images delete`](#emb-images-delete)
|
|
37
36
|
* [`emb images prune`](#emb-images-prune)
|
|
38
37
|
* [`emb ps`](#emb-ps)
|
|
38
|
+
* [`emb resources`](#emb-resources)
|
|
39
|
+
* [`emb resources build [COMPONENT]`](#emb-resources-build-component)
|
|
39
40
|
* [`emb tasks`](#emb-tasks)
|
|
40
41
|
* [`emb tasks run TASK`](#emb-tasks-run-task)
|
|
41
42
|
* [`emb up`](#emb-up)
|
|
@@ -114,32 +115,6 @@ EXAMPLES
|
|
|
114
115
|
$ emb components
|
|
115
116
|
```
|
|
116
117
|
|
|
117
|
-
## `emb components build [COMPONENT]`
|
|
118
|
-
|
|
119
|
-
Build the components of the monorepo
|
|
120
|
-
|
|
121
|
-
```
|
|
122
|
-
USAGE
|
|
123
|
-
$ emb components build [COMPONENT...] [--json] [--flavor <value>] [--dry-run] [-f]
|
|
124
|
-
|
|
125
|
-
ARGUMENTS
|
|
126
|
-
COMPONENT... List of components to build (defaults to all)
|
|
127
|
-
|
|
128
|
-
FLAGS
|
|
129
|
-
-f, --force Bypass the cache and force the build
|
|
130
|
-
--dry-run Do not build the components but only produce build meta information
|
|
131
|
-
--flavor=<value> Specify the flavor to use.
|
|
132
|
-
|
|
133
|
-
GLOBAL FLAGS
|
|
134
|
-
--json Format output as json.
|
|
135
|
-
|
|
136
|
-
DESCRIPTION
|
|
137
|
-
Build the components of the monorepo
|
|
138
|
-
|
|
139
|
-
EXAMPLES
|
|
140
|
-
$ emb components build build --flavor development
|
|
141
|
-
```
|
|
142
|
-
|
|
143
118
|
## `emb config print`
|
|
144
119
|
|
|
145
120
|
Print the current config.
|
|
@@ -331,6 +306,53 @@ EXAMPLES
|
|
|
331
306
|
$ emb ps
|
|
332
307
|
```
|
|
333
308
|
|
|
309
|
+
## `emb resources`
|
|
310
|
+
|
|
311
|
+
List resources.
|
|
312
|
+
|
|
313
|
+
```
|
|
314
|
+
USAGE
|
|
315
|
+
$ emb resources [--json] [--flavor <value>]
|
|
316
|
+
|
|
317
|
+
FLAGS
|
|
318
|
+
--flavor=<value> Specify the flavor to use.
|
|
319
|
+
|
|
320
|
+
GLOBAL FLAGS
|
|
321
|
+
--json Format output as json.
|
|
322
|
+
|
|
323
|
+
DESCRIPTION
|
|
324
|
+
List resources.
|
|
325
|
+
|
|
326
|
+
EXAMPLES
|
|
327
|
+
$ emb resources
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
## `emb resources build [COMPONENT]`
|
|
331
|
+
|
|
332
|
+
Build the resources of the monorepo
|
|
333
|
+
|
|
334
|
+
```
|
|
335
|
+
USAGE
|
|
336
|
+
$ emb resources build [COMPONENT...] [--json] [--flavor <value>] [--dry-run] [-f]
|
|
337
|
+
|
|
338
|
+
ARGUMENTS
|
|
339
|
+
COMPONENT... List of resources to build (defaults to all)
|
|
340
|
+
|
|
341
|
+
FLAGS
|
|
342
|
+
-f, --force Bypass the cache and force the build
|
|
343
|
+
--dry-run Do not build the resources but only produce build meta information
|
|
344
|
+
--flavor=<value> Specify the flavor to use.
|
|
345
|
+
|
|
346
|
+
GLOBAL FLAGS
|
|
347
|
+
--json Format output as json.
|
|
348
|
+
|
|
349
|
+
DESCRIPTION
|
|
350
|
+
Build the resources of the monorepo
|
|
351
|
+
|
|
352
|
+
EXAMPLES
|
|
353
|
+
$ emb resources build build --flavor development
|
|
354
|
+
```
|
|
355
|
+
|
|
334
356
|
## `emb tasks`
|
|
335
357
|
|
|
336
358
|
List tasks.
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { getContext, setContext } from '../../index.js';
|
|
2
|
+
import { Command, Performance } from '@oclif/core';
|
|
3
|
+
import Dockerode from 'dockerode';
|
|
4
|
+
import { loadConfig } from '../../config/index.js';
|
|
5
|
+
import { Monorepo } from '../../monorepo/monorepo.js';
|
|
6
|
+
const withMarker = async (owner, name, cb) => {
|
|
7
|
+
const marker = Performance.mark(owner, name);
|
|
8
|
+
const res = await cb();
|
|
9
|
+
marker?.stop();
|
|
10
|
+
return res;
|
|
11
|
+
};
|
|
12
|
+
export class BaseCommand extends Command {
|
|
13
|
+
context;
|
|
14
|
+
async init() {
|
|
15
|
+
await super.init();
|
|
16
|
+
if (getContext()) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
try {
|
|
20
|
+
const config = await withMarker('emb:config', 'load', () => loadConfig());
|
|
21
|
+
const monorepo = await withMarker('emb:monorepo', 'init', () => {
|
|
22
|
+
return new Monorepo(config).init();
|
|
23
|
+
});
|
|
24
|
+
this.context = setContext({
|
|
25
|
+
docker: new Dockerode(),
|
|
26
|
+
monorepo,
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
this.error(error);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { Command, Interfaces } from '@oclif/core';
|
|
2
|
+
import { BaseCommand } from './BaseCommand.js';
|
|
2
3
|
export type Flags<T extends typeof Command> = Interfaces.InferredFlags<(typeof FlavoredCommand)['baseFlags'] & T['flags']>;
|
|
3
4
|
export type Args<T extends typeof Command> = Interfaces.InferredArgs<T['args']>;
|
|
4
|
-
export declare abstract class FlavoredCommand<T extends typeof Command> extends
|
|
5
|
+
export declare abstract class FlavoredCommand<T extends typeof Command> extends BaseCommand {
|
|
5
6
|
static baseFlags: {
|
|
6
7
|
flavor: Interfaces.OptionFlag<string | undefined, Interfaces.CustomOptions>;
|
|
7
8
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { getContext, setContext } from '../../index.js';
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import { Flags } from '@oclif/core';
|
|
3
|
+
import { BaseCommand } from './BaseCommand.js';
|
|
4
|
+
export class FlavoredCommand extends BaseCommand {
|
|
4
5
|
// define flags that can be inherited by any command that extends FlavoredCommand
|
|
5
6
|
static baseFlags = {
|
|
6
7
|
flavor: Flags.string({
|
|
@@ -31,7 +32,7 @@ export class FlavoredCommand extends Command {
|
|
|
31
32
|
// complain properly if incorrect
|
|
32
33
|
const { flavor } = this.flags;
|
|
33
34
|
if (flavor) {
|
|
34
|
-
setContext({
|
|
35
|
+
this.context = setContext({
|
|
35
36
|
...context,
|
|
36
37
|
monorepo: await context.monorepo.withFlavor(flavor),
|
|
37
38
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BaseCommand } from '../abstract/BaseCommand.js';
|
|
2
2
|
/**
|
|
3
3
|
* For now, only cleans the stores (logs/sentinels)
|
|
4
4
|
* But this should permit to clean everytning (via flags)
|
|
@@ -6,7 +6,7 @@ import { Command } from '@oclif/core';
|
|
|
6
6
|
* Eg: --containers --volumes --images --networks
|
|
7
7
|
* Or: --all
|
|
8
8
|
*/
|
|
9
|
-
export default class CleanCommand extends
|
|
9
|
+
export default class CleanCommand extends BaseCommand {
|
|
10
10
|
static description: string;
|
|
11
11
|
static enableJsonFlag: boolean;
|
|
12
12
|
static examples: string[];
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { getContext } from '../../index.js';
|
|
2
|
-
import {
|
|
2
|
+
import { Flags } from '@oclif/core';
|
|
3
3
|
import { Listr } from 'listr2';
|
|
4
|
+
import { BaseCommand } from '../abstract/BaseCommand.js';
|
|
4
5
|
/**
|
|
5
6
|
* For now, only cleans the stores (logs/sentinels)
|
|
6
7
|
* But this should permit to clean everytning (via flags)
|
|
@@ -8,7 +9,7 @@ import { Listr } from 'listr2';
|
|
|
8
9
|
* Eg: --containers --volumes --images --networks
|
|
9
10
|
* Or: --all
|
|
10
11
|
*/
|
|
11
|
-
export default class CleanCommand extends
|
|
12
|
+
export default class CleanCommand extends BaseCommand {
|
|
12
13
|
static description = 'Clean the project.';
|
|
13
14
|
static enableJsonFlag = true;
|
|
14
15
|
static examples = ['<%= config.bin %> <%= command.id %>'];
|
|
@@ -22,6 +23,10 @@ export default class CleanCommand extends Command {
|
|
|
22
23
|
async run() {
|
|
23
24
|
const { monorepo } = getContext();
|
|
24
25
|
const { flags } = await this.parse(CleanCommand);
|
|
26
|
+
await this.config.runCommand('down');
|
|
27
|
+
await this.config.runCommand('containers:prune');
|
|
28
|
+
await this.config.runCommand('images:delete', flags.force ? ['--force'] : undefined);
|
|
29
|
+
await this.config.runCommand('images:prune', flags.force ? ['-a'] : undefined);
|
|
25
30
|
const runner = new Listr([
|
|
26
31
|
{
|
|
27
32
|
rendererOptions: { persistentOutput: true },
|
|
@@ -32,9 +37,5 @@ export default class CleanCommand extends Command {
|
|
|
32
37
|
},
|
|
33
38
|
]);
|
|
34
39
|
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);
|
|
39
40
|
}
|
|
40
41
|
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { FlavoredCommand } from '../../index.js';
|
|
2
2
|
export type ComponentInfo = {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
component: string;
|
|
4
|
+
name?: string;
|
|
5
|
+
id?: string;
|
|
6
|
+
created?: string;
|
|
7
|
+
status?: string;
|
|
7
8
|
};
|
|
8
9
|
export default class ComponentsIndex extends FlavoredCommand<typeof ComponentsIndex> {
|
|
9
10
|
static description: string;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { printTable } from '@oclif/table';
|
|
2
2
|
import { FlavoredCommand, getContext, TABLE_DEFAULTS } from '../../index.js';
|
|
3
|
-
import {
|
|
3
|
+
import { getTimeAgo } from '../../utils.js';
|
|
4
|
+
import { ListContainersOperation } from '../../../docker/operations/index.js';
|
|
5
|
+
import { shortId } from '../../../docker/utils.js';
|
|
4
6
|
export default class ComponentsIndex extends FlavoredCommand {
|
|
5
7
|
static description = 'List components.';
|
|
6
8
|
static enableJsonFlag = true;
|
|
@@ -9,30 +11,26 @@ export default class ComponentsIndex extends FlavoredCommand {
|
|
|
9
11
|
async run() {
|
|
10
12
|
const { flags } = await this.parse(ComponentsIndex);
|
|
11
13
|
const { monorepo } = await getContext();
|
|
12
|
-
// Get all running containers for this project
|
|
13
|
-
// and then try to do a mapping. It's probably better than
|
|
14
|
-
// doing N queries to list with specific filters
|
|
15
14
|
const runningContainers = await monorepo.run(new ListContainersOperation(), {
|
|
16
15
|
filters: {
|
|
17
16
|
label: [`emb/project=${monorepo.name}`],
|
|
18
17
|
},
|
|
19
18
|
});
|
|
20
|
-
const components =
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
return cont.Image === `${buildInfos.name}:${buildInfos.tag}`;
|
|
24
|
-
});
|
|
19
|
+
const components = monorepo.components.map((cmp) => {
|
|
20
|
+
const container = runningContainers.find((c) => c.Labels['emb/component'] === cmp.name &&
|
|
21
|
+
c.Labels['emb/flavor'] === monorepo.currentFlavor);
|
|
25
22
|
return {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
name:
|
|
29
|
-
|
|
23
|
+
component: cmp.name,
|
|
24
|
+
id: shortId(container?.Id),
|
|
25
|
+
name: container?.Names?.join(', '),
|
|
26
|
+
created: getTimeAgo(container?.Created),
|
|
27
|
+
status: container?.Status,
|
|
30
28
|
};
|
|
31
|
-
})
|
|
29
|
+
});
|
|
32
30
|
if (!flags.json) {
|
|
33
31
|
printTable({
|
|
34
32
|
...TABLE_DEFAULTS,
|
|
35
|
-
columns: ['name', '
|
|
33
|
+
columns: ['component', 'name', 'id', 'created', 'status'],
|
|
36
34
|
data: components,
|
|
37
35
|
sort: {
|
|
38
36
|
name: 'asc',
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FlavoredCommand } from '../../index.js';
|
|
2
|
-
import {
|
|
2
|
+
import { EMBConfig } from '../../../config/schema.js';
|
|
3
3
|
export type TaskInfo = {
|
|
4
4
|
component?: string;
|
|
5
5
|
description?: string;
|
|
@@ -9,5 +9,5 @@ export default class ConfigPrint extends FlavoredCommand<typeof ConfigPrint> {
|
|
|
9
9
|
static description: string;
|
|
10
10
|
static enableJsonFlag: boolean;
|
|
11
11
|
static examples: string[];
|
|
12
|
-
run(): Promise<
|
|
12
|
+
run(): Promise<EMBConfig>;
|
|
13
13
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Command } from '@oclif/core';
|
|
2
1
|
import { ContainerInfo } from 'dockerode';
|
|
3
|
-
|
|
2
|
+
import { BaseCommand } from '../../index.js';
|
|
3
|
+
export default class ContainersIndex extends BaseCommand {
|
|
4
4
|
static aliases: string[];
|
|
5
5
|
static description: string;
|
|
6
6
|
static enableJsonFlag: boolean;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { getContext } from '../../../index.js';
|
|
2
|
-
import {
|
|
2
|
+
import { Flags } from '@oclif/core';
|
|
3
3
|
import { printTable } from '@oclif/table';
|
|
4
|
-
import { TABLE_DEFAULTS } from '../../index.js';
|
|
4
|
+
import { BaseCommand, TABLE_DEFAULTS } from '../../index.js';
|
|
5
5
|
import { ListContainersOperation, shortId } from '../../../docker/index.js';
|
|
6
6
|
import { timeAgo } from '../../../utils/index.js';
|
|
7
|
-
export default class ContainersIndex extends
|
|
7
|
+
export default class ContainersIndex extends BaseCommand {
|
|
8
8
|
static aliases = ['ps'];
|
|
9
9
|
static description = 'List docker containers.';
|
|
10
10
|
static enableJsonFlag = true;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Command } from '@oclif/core';
|
|
2
1
|
import { PruneContainersInfo } from 'dockerode';
|
|
3
|
-
|
|
2
|
+
import { BaseCommand } from '../../abstract/BaseCommand.js';
|
|
3
|
+
export default class ContainersPrune extends BaseCommand {
|
|
4
4
|
static description: string;
|
|
5
5
|
static enableJsonFlag: boolean;
|
|
6
6
|
static examples: string[];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getContext } from '../../../index.js';
|
|
2
|
-
import {
|
|
2
|
+
import { BaseCommand } from '../../abstract/BaseCommand.js';
|
|
3
3
|
import { PruneContainersOperation } from '../../../docker/index.js';
|
|
4
|
-
export default class ContainersPrune extends
|
|
4
|
+
export default class ContainersPrune extends BaseCommand {
|
|
5
5
|
static description = 'Prune containers.';
|
|
6
6
|
static enableJsonFlag = true;
|
|
7
7
|
static examples = ['<%= config.bin %> <%= command.id %>'];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export default class ImagesDelete extends
|
|
1
|
+
import { BaseCommand } from '../../index.js';
|
|
2
|
+
export default class ImagesDelete extends BaseCommand {
|
|
3
3
|
static description: string;
|
|
4
4
|
static enableJsonFlag: boolean;
|
|
5
5
|
static examples: string[];
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { getContext } from '../../../index.js';
|
|
2
|
-
import {
|
|
2
|
+
import { Flags } from '@oclif/core';
|
|
3
3
|
import { Listr } from 'listr2';
|
|
4
|
+
import { BaseCommand } from '../../index.js';
|
|
4
5
|
import { deleteImage, listImages } from '../../../docker/index.js';
|
|
5
|
-
export default class ImagesDelete extends
|
|
6
|
+
export default class ImagesDelete extends BaseCommand {
|
|
6
7
|
static description = 'Delete project images.';
|
|
7
8
|
static enableJsonFlag = true;
|
|
8
9
|
static examples = ['<%= config.bin %> <%= command.id %>'];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BaseCommand } from '../../index.js';
|
|
2
2
|
export type ImageInfo = {
|
|
3
3
|
created: Date;
|
|
4
4
|
imageId: string;
|
|
@@ -6,7 +6,7 @@ export type ImageInfo = {
|
|
|
6
6
|
size: number;
|
|
7
7
|
tag: string;
|
|
8
8
|
};
|
|
9
|
-
export default class ImagesIndex extends
|
|
9
|
+
export default class ImagesIndex extends BaseCommand {
|
|
10
10
|
static description: string;
|
|
11
11
|
static enableJsonFlag: boolean;
|
|
12
12
|
static examples: string[];
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { getContext } from '../../../index.js';
|
|
2
|
-
import {
|
|
2
|
+
import { Flags } from '@oclif/core';
|
|
3
3
|
import { printTable } from '@oclif/table';
|
|
4
|
-
import { TABLE_DEFAULTS } from '../../index.js';
|
|
4
|
+
import { BaseCommand, TABLE_DEFAULTS } from '../../index.js';
|
|
5
5
|
import { listImages, shortId } from '../../../docker/index.js';
|
|
6
6
|
import { timeAgo } from '../../../utils/index.js';
|
|
7
|
-
export default class ImagesIndex extends
|
|
7
|
+
export default class ImagesIndex extends BaseCommand {
|
|
8
8
|
static description = 'List docker images.';
|
|
9
9
|
static enableJsonFlag = true;
|
|
10
10
|
static examples = ['<%= config.bin %> <%= command.id %>'];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Command } from '@oclif/core';
|
|
2
1
|
import { PruneImagesInfo } from 'dockerode';
|
|
3
|
-
|
|
2
|
+
import { BaseCommand } from '../../index.js';
|
|
3
|
+
export default class ImagesPrune extends BaseCommand {
|
|
4
4
|
static description: string;
|
|
5
5
|
static enableJsonFlag: boolean;
|
|
6
6
|
static examples: string[];
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { getContext } from '../../../index.js';
|
|
2
|
-
import {
|
|
2
|
+
import { Flags } from '@oclif/core';
|
|
3
|
+
import { BaseCommand } from '../../index.js';
|
|
3
4
|
import { pruneImages } from '../../../docker/index.js';
|
|
4
|
-
export default class ImagesPrune extends
|
|
5
|
+
export default class ImagesPrune extends BaseCommand {
|
|
5
6
|
static description = 'Prune project images.';
|
|
6
7
|
static enableJsonFlag = true;
|
|
7
8
|
static examples = ['<%= config.bin %> <%= command.id %>'];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FlavoredCommand } from '../../index.js';
|
|
2
|
-
import {
|
|
3
|
-
export default class
|
|
2
|
+
import { BuildResourceMeta } from '../../../monorepo/operations/resources/BuildResourcesOperation.js';
|
|
3
|
+
export default class ResourcesBuildCommand extends FlavoredCommand<typeof ResourcesBuildCommand> {
|
|
4
4
|
static args: {
|
|
5
5
|
component: import("@oclif/core/interfaces").Arg<string | undefined, Record<string, unknown>>;
|
|
6
6
|
};
|
|
@@ -12,5 +12,5 @@ export default class BuildCommand extends FlavoredCommand<typeof BuildCommand> {
|
|
|
12
12
|
};
|
|
13
13
|
static enableJsonFlag: boolean;
|
|
14
14
|
static strict: boolean;
|
|
15
|
-
run(): Promise<Record<string,
|
|
15
|
+
run(): Promise<Record<string, BuildResourceMeta>>;
|
|
16
16
|
}
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import { Args, Flags } from '@oclif/core';
|
|
2
2
|
import { FlavoredCommand, getContext } from '../../index.js';
|
|
3
|
-
import {
|
|
4
|
-
export default class
|
|
3
|
+
import { BuildResourcesOperation, } from '../../../monorepo/operations/resources/BuildResourcesOperation.js';
|
|
4
|
+
export default class ResourcesBuildCommand extends FlavoredCommand {
|
|
5
5
|
static args = {
|
|
6
6
|
component: Args.string({
|
|
7
|
-
description: 'List of
|
|
7
|
+
description: 'List of resources to build (defaults to all)',
|
|
8
8
|
required: false,
|
|
9
9
|
}),
|
|
10
10
|
};
|
|
11
|
-
static description = 'Build the
|
|
11
|
+
static description = 'Build the resources of the monorepo';
|
|
12
12
|
static examples = [
|
|
13
13
|
`<%= config.bin %> <%= command.id %> build --flavor development`,
|
|
14
14
|
];
|
|
15
15
|
static flags = {
|
|
16
16
|
'dry-run': Flags.boolean({
|
|
17
17
|
required: false,
|
|
18
|
-
description: 'Do not build the
|
|
18
|
+
description: 'Do not build the resources but only produce build meta information',
|
|
19
19
|
}),
|
|
20
20
|
force: Flags.boolean({
|
|
21
21
|
name: 'force',
|
|
@@ -27,15 +27,16 @@ export default class BuildCommand extends FlavoredCommand {
|
|
|
27
27
|
static enableJsonFlag = true;
|
|
28
28
|
static strict = false;
|
|
29
29
|
async run() {
|
|
30
|
-
const { argv, flags } = await this.parse(
|
|
30
|
+
const { argv, flags } = await this.parse(ResourcesBuildCommand);
|
|
31
31
|
const { monorepo } = getContext();
|
|
32
|
-
|
|
32
|
+
const toBuild = argv.length > 0
|
|
33
|
+
? argv
|
|
34
|
+
: monorepo.resources.map((c) => c.id);
|
|
35
|
+
return monorepo.run(new BuildResourcesOperation(), {
|
|
33
36
|
dryRun: flags['dry-run'],
|
|
34
37
|
force: flags.force,
|
|
35
38
|
silent: flags.json,
|
|
36
|
-
|
|
37
|
-
? argv
|
|
38
|
-
: monorepo.components.map((c) => c.name),
|
|
39
|
+
resources: toBuild,
|
|
39
40
|
});
|
|
40
41
|
}
|
|
41
42
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { FlavoredCommand } from '../../index.js';
|
|
2
|
+
import { ResourceConfig } from '../../../config/schema.js';
|
|
3
|
+
export default class ResourcesIndex extends FlavoredCommand<typeof ResourcesIndex> {
|
|
4
|
+
static description: string;
|
|
5
|
+
static enableJsonFlag: boolean;
|
|
6
|
+
static examples: string[];
|
|
7
|
+
static flags: {};
|
|
8
|
+
run(): Promise<Array<ResourceConfig>>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { printTable } from '@oclif/table';
|
|
2
|
+
import { FlavoredCommand, getContext, TABLE_DEFAULTS } from '../../index.js';
|
|
3
|
+
export default class ResourcesIndex extends FlavoredCommand {
|
|
4
|
+
static description = 'List resources.';
|
|
5
|
+
static enableJsonFlag = true;
|
|
6
|
+
static examples = ['<%= config.bin %> <%= command.id %>'];
|
|
7
|
+
static flags = {};
|
|
8
|
+
async run() {
|
|
9
|
+
const { flags } = await this.parse(ResourcesIndex);
|
|
10
|
+
const { monorepo } = await getContext();
|
|
11
|
+
const resources = await Promise.all(monorepo.resources.map(async (config) => {
|
|
12
|
+
return {
|
|
13
|
+
...config,
|
|
14
|
+
};
|
|
15
|
+
}));
|
|
16
|
+
if (!flags.json) {
|
|
17
|
+
printTable({
|
|
18
|
+
...TABLE_DEFAULTS,
|
|
19
|
+
columns: ['name', 'type', 'id'],
|
|
20
|
+
data: resources,
|
|
21
|
+
sort: {
|
|
22
|
+
name: 'asc',
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
return resources;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BaseCommand } from '../../index.js';
|
|
2
2
|
import { TaskInfo } from '../../../monorepo/index.js';
|
|
3
|
-
export default class TasksIndex extends
|
|
3
|
+
export default class TasksIndex extends BaseCommand {
|
|
4
4
|
static description: string;
|
|
5
5
|
static enableJsonFlag: boolean;
|
|
6
6
|
static examples: string[];
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { getContext } from '../../../index.js';
|
|
2
|
-
import { Command } from '@oclif/core';
|
|
3
2
|
import { printTable } from '@oclif/table';
|
|
4
|
-
import { TABLE_DEFAULTS } from '../../index.js';
|
|
5
|
-
export default class TasksIndex extends
|
|
3
|
+
import { BaseCommand, TABLE_DEFAULTS } from '../../index.js';
|
|
4
|
+
export default class TasksIndex extends BaseCommand {
|
|
6
5
|
static description = 'List tasks.';
|
|
7
6
|
static enableJsonFlag = true;
|
|
8
7
|
static examples = ['<%= config.bin %> <%= command.id %>'];
|
|
@@ -10,7 +9,7 @@ export default class TasksIndex extends Command {
|
|
|
10
9
|
async run() {
|
|
11
10
|
const { flags } = await this.parse(TasksIndex);
|
|
12
11
|
const { monorepo: { tasks }, } = await getContext();
|
|
13
|
-
if (!flags.json)
|
|
12
|
+
if (!flags.json) {
|
|
14
13
|
printTable({
|
|
15
14
|
...TABLE_DEFAULTS,
|
|
16
15
|
columns: ['name', 'component', 'description', 'id'],
|
|
@@ -24,6 +23,7 @@ export default class TasksIndex extends Command {
|
|
|
24
23
|
return 0;
|
|
25
24
|
}),
|
|
26
25
|
});
|
|
26
|
+
}
|
|
27
27
|
return tasks;
|
|
28
28
|
}
|
|
29
29
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export default class RunTask extends
|
|
1
|
+
import { BaseCommand } from '../../index.js';
|
|
2
|
+
export default class RunTask extends BaseCommand {
|
|
3
3
|
static args: {
|
|
4
4
|
task: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
5
5
|
};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Args,
|
|
1
|
+
import { AmbiguousReferenceError, getContext, UnkownReferenceError } from '../../../index.js';
|
|
2
|
+
import { Args, Flags } from '@oclif/core';
|
|
3
|
+
import { BaseCommand } from '../../index.js';
|
|
3
4
|
import { ExecutorType, RunTasksOperation } from '../../../monorepo/index.js';
|
|
4
|
-
export default class RunTask extends
|
|
5
|
+
export default class RunTask extends BaseCommand {
|
|
5
6
|
static args = {
|
|
6
7
|
task: Args.string({
|
|
7
8
|
description: 'List of tasks to run. You can provide either ids or names (eg: component:task or task)',
|
|
@@ -37,13 +38,19 @@ export default class RunTask extends Command {
|
|
|
37
38
|
});
|
|
38
39
|
}
|
|
39
40
|
catch (error) {
|
|
40
|
-
if (error instanceof
|
|
41
|
+
if (error instanceof AmbiguousReferenceError) {
|
|
41
42
|
throw error.toCliError([
|
|
42
|
-
`Specify just one. Eg: \`emb tasks run ${error.
|
|
43
|
+
`Specify just one. Eg: \`emb tasks run ${error.matches[0]}\``,
|
|
43
44
|
'Run the same command with --all-matches / -a',
|
|
44
45
|
'Review the list of tasks by running `emb tasks`',
|
|
45
46
|
]);
|
|
46
47
|
}
|
|
48
|
+
if (error instanceof UnkownReferenceError) {
|
|
49
|
+
throw error.toCliError([
|
|
50
|
+
`Check the list of tasks available by running: \`emb tasks\``,
|
|
51
|
+
]);
|
|
52
|
+
}
|
|
53
|
+
throw error;
|
|
47
54
|
}
|
|
48
55
|
}
|
|
49
56
|
}
|