@enspirit/emb 0.1.1 → 0.1.2
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 +4 -3
- package/dist/src/cli/abstract/FlavouredCommand.d.ts +3 -0
- package/dist/src/cli/abstract/FlavouredCommand.js +14 -0
- package/dist/src/cli/commands/images/index.d.ts +2 -2
- package/dist/src/cli/commands/images/index.js +2 -2
- package/dist/src/cli/commands/up.js +3 -0
- package/dist/src/config/schema.d.ts +0 -1
- package/dist/src/config/schema.json +0 -3
- package/dist/src/docker/resources/DockerImageResource.js +3 -1
- package/dist/src/monorepo/component.js +1 -1
- package/dist/src/monorepo/monorepo.js +2 -2
- package/oclif.manifest.json +9 -2
- 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.1.
|
|
17
|
+
@enspirit/emb/0.1.2 darwin-x64 node-v22.12.0
|
|
18
18
|
$ emb --help [COMMAND]
|
|
19
19
|
USAGE
|
|
20
20
|
$ emb COMMAND
|
|
@@ -225,10 +225,11 @@ List docker images.
|
|
|
225
225
|
|
|
226
226
|
```
|
|
227
227
|
USAGE
|
|
228
|
-
$ emb images [--json] [-a]
|
|
228
|
+
$ emb images [--json] [--flavor <value>] [-a]
|
|
229
229
|
|
|
230
230
|
FLAGS
|
|
231
|
-
-a, --all
|
|
231
|
+
-a, --all Show all images. Only images from a final layer (no children) are shown by default.
|
|
232
|
+
--flavor=<value> Specify the flavor to use.
|
|
232
233
|
|
|
233
234
|
GLOBAL FLAGS
|
|
234
235
|
--json Format output as json.
|
|
@@ -9,5 +9,8 @@ export declare abstract class FlavoredCommand<T extends typeof Command> extends
|
|
|
9
9
|
static enableJsonFlag: boolean;
|
|
10
10
|
protected args: Args<T>;
|
|
11
11
|
protected flags: Flags<T>;
|
|
12
|
+
protected catch(err: Error & {
|
|
13
|
+
exitCode?: number;
|
|
14
|
+
}): Promise<void>;
|
|
12
15
|
init(): Promise<void>;
|
|
13
16
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { getContext, setContext } from '../../index.js';
|
|
2
2
|
import { Flags } from '@oclif/core';
|
|
3
|
+
import { JsonPatchError } from 'fast-json-patch';
|
|
3
4
|
import { BaseCommand } from './BaseCommand.js';
|
|
4
5
|
export class FlavoredCommand extends BaseCommand {
|
|
5
6
|
// define flags that can be inherited by any command that extends FlavoredCommand
|
|
@@ -14,6 +15,19 @@ export class FlavoredCommand extends BaseCommand {
|
|
|
14
15
|
static enableJsonFlag = true;
|
|
15
16
|
args;
|
|
16
17
|
flags;
|
|
18
|
+
async catch(err) {
|
|
19
|
+
if (err instanceof JsonPatchError) {
|
|
20
|
+
this.log('INVALID', err.operation);
|
|
21
|
+
this.error('Invalid patch detected while applying flavor', {
|
|
22
|
+
code: err.name,
|
|
23
|
+
message: `Path \`${err.operation?.path}\``,
|
|
24
|
+
});
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
// add any custom logic to handle errors from the command
|
|
28
|
+
// or simply return the parent class error handling
|
|
29
|
+
return super.catch(err);
|
|
30
|
+
}
|
|
17
31
|
async init() {
|
|
18
32
|
await super.init();
|
|
19
33
|
const { args, flags } = await this.parse({
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { FlavoredCommand } 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 FlavoredCommand<typeof ImagesIndex> {
|
|
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
2
|
import { Flags } from '@oclif/core';
|
|
3
3
|
import { printTable } from '@oclif/table';
|
|
4
|
-
import {
|
|
4
|
+
import { FlavoredCommand, 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 FlavoredCommand {
|
|
8
8
|
static description = 'List docker images.';
|
|
9
9
|
static enableJsonFlag = true;
|
|
10
10
|
static examples = ['<%= config.bin %> <%= command.id %>'];
|
|
@@ -20,6 +20,9 @@ export default class UpCommand extends FlavoredCommand {
|
|
|
20
20
|
if (flags.force) {
|
|
21
21
|
buildFlags.push('--force');
|
|
22
22
|
}
|
|
23
|
+
if (flags.flavor) {
|
|
24
|
+
buildFlags.push('--flavor', flags.flavor);
|
|
25
|
+
}
|
|
23
26
|
await this.config.runCommand('resources:build', buildFlags);
|
|
24
27
|
await monorepo.run(new ComposeUpOperation(), {
|
|
25
28
|
forceRecreate: flags.force,
|
|
@@ -15,12 +15,14 @@ const DockerImageOpFactory = async ({ config, component, monorepo }) => {
|
|
|
15
15
|
await statfs(context);
|
|
16
16
|
const plugin = new GitPrerequisitePlugin();
|
|
17
17
|
const sources = await plugin.collect(context);
|
|
18
|
+
const imageName = [monorepo.name, fromConfig.tag || component.name].join('/');
|
|
19
|
+
const tagName = fromConfig.tag || monorepo.defaults.docker?.tag || 'latest';
|
|
18
20
|
const buildParams = {
|
|
19
21
|
context,
|
|
20
22
|
dockerfile: fromConfig.dockerfile || 'Dockerfile',
|
|
21
23
|
src: sources.map((s) => s.path),
|
|
22
24
|
buildArgs: fromConfig.buildArgs || {},
|
|
23
|
-
tag:
|
|
25
|
+
tag: `${imageName}:${tagName}`,
|
|
24
26
|
labels: {
|
|
25
27
|
...fromConfig.labels,
|
|
26
28
|
'emb/project': monorepo.name,
|
|
@@ -41,7 +41,7 @@ export class Component {
|
|
|
41
41
|
const patches = this.flavor(name).patches || [];
|
|
42
42
|
const errors = jsonpatch.validate(patches, original);
|
|
43
43
|
if (errors) {
|
|
44
|
-
throw
|
|
44
|
+
throw errors;
|
|
45
45
|
}
|
|
46
46
|
const patched = patches.reduce((doc, patch, index) => {
|
|
47
47
|
return jsonpatch.applyReducer(doc, patch, index);
|
|
@@ -167,13 +167,13 @@ export class Monorepo {
|
|
|
167
167
|
const original = this._config.toJSON();
|
|
168
168
|
const errors = jsonpatch.validate(patches || [], original);
|
|
169
169
|
if (errors) {
|
|
170
|
-
throw
|
|
170
|
+
throw errors;
|
|
171
171
|
}
|
|
172
172
|
const withComponentPatches = this.components.reduce((config, cmp) => {
|
|
173
173
|
const componentPatches = cmp.flavor(flavorName, false)?.patches || [];
|
|
174
174
|
const errors = jsonpatch.validate(componentPatches || [], config.components[cmp.name]);
|
|
175
175
|
if (errors) {
|
|
176
|
-
throw
|
|
176
|
+
throw errors;
|
|
177
177
|
}
|
|
178
178
|
config.components[cmp.name] = componentPatches.reduce((doc, patch, index) => {
|
|
179
179
|
return jsonpatch.applyReducer(doc, patch, index);
|
package/oclif.manifest.json
CHANGED
|
@@ -344,6 +344,14 @@
|
|
|
344
344
|
"allowNo": false,
|
|
345
345
|
"type": "boolean"
|
|
346
346
|
},
|
|
347
|
+
"flavor": {
|
|
348
|
+
"description": "Specify the flavor to use.",
|
|
349
|
+
"name": "flavor",
|
|
350
|
+
"required": false,
|
|
351
|
+
"hasDynamicHelp": false,
|
|
352
|
+
"multiple": false,
|
|
353
|
+
"type": "option"
|
|
354
|
+
},
|
|
347
355
|
"all": {
|
|
348
356
|
"char": "a",
|
|
349
357
|
"description": "Show all images. Only images from a final layer (no children) are shown by default.",
|
|
@@ -359,7 +367,6 @@
|
|
|
359
367
|
"pluginAlias": "@enspirit/emb",
|
|
360
368
|
"pluginName": "@enspirit/emb",
|
|
361
369
|
"pluginType": "core",
|
|
362
|
-
"strict": true,
|
|
363
370
|
"enableJsonFlag": true,
|
|
364
371
|
"isESM": true,
|
|
365
372
|
"relativePath": [
|
|
@@ -611,5 +618,5 @@
|
|
|
611
618
|
]
|
|
612
619
|
}
|
|
613
620
|
},
|
|
614
|
-
"version": "0.1.
|
|
621
|
+
"version": "0.1.2"
|
|
615
622
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@enspirit/emb",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.2",
|
|
5
5
|
"keywords": ["monorepo", "docker", "taskrunner", "ci", "docker compose", "sentinel", "makefile"],
|
|
6
6
|
"author": "Louis Lambeau <louis.lambeau@enspirit.be>",
|
|
7
7
|
"license": "ISC",
|