@enspirit/emb 0.0.6 → 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 +60 -13
- 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 -1
- package/dist/src/cli/commands/tasks/run.js +10 -43
- package/dist/src/cli/commands/up.d.ts +1 -1
- package/dist/src/cli/commands/up.js +12 -34
- package/dist/src/config/convert.js +2 -4
- package/dist/src/config/index.d.ts +1 -0
- package/dist/src/config/index.js +1 -0
- package/dist/src/config/schema.d.ts +32 -25
- package/dist/src/config/schema.json +48 -26
- package/dist/src/config/types.d.ts +10 -6
- 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/monorepo/component.d.ts +2 -2
- package/dist/src/monorepo/component.js +6 -6
- package/dist/src/monorepo/config.d.ts +4 -2
- package/dist/src/monorepo/config.js +14 -2
- 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 +1 -1
- package/dist/src/monorepo/operations/components/GetComponentContainerOperation.js +1 -1
- package/dist/src/monorepo/operations/shell/ExecuteLocalCommandOperation.d.ts +4 -6
- package/dist/src/monorepo/operations/shell/ExecuteLocalCommandOperation.js +2 -7
- 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 -1
- package/dist/src/monorepo/operations/tasks/index.js +1 -1
- package/dist/src/monorepo/plugins/ComponentDiscoverPlugin.js +3 -1
- package/dist/src/monorepo/plugins/EmbfileLoaderPlugin.d.ts +3 -3
- package/dist/src/monorepo/plugins/EmbfileLoaderPlugin.js +9 -5
- 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/oclif.manifest.json +63 -40
- package/package.json +4 -2
- package/dist/src/monorepo/operations/tasks/RunTaskOperation.d.ts +0 -18
- package/dist/src/monorepo/operations/tasks/RunTaskOperation.js +0 -50
- package/dist/src/monorepo/utils/findBuildOrder.d.ts +0 -2
- package/dist/src/monorepo/utils/findBuildOrder.js +0 -41
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './
|
|
1
|
+
export * from './findRunOrder.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './
|
|
1
|
+
export * from './findRunOrder.js';
|
package/oclif.manifest.json
CHANGED
|
@@ -14,6 +14,13 @@
|
|
|
14
14
|
"name": "json",
|
|
15
15
|
"allowNo": false,
|
|
16
16
|
"type": "boolean"
|
|
17
|
+
},
|
|
18
|
+
"force": {
|
|
19
|
+
"char": "f",
|
|
20
|
+
"description": "Force the deletion of containers & images",
|
|
21
|
+
"name": "force",
|
|
22
|
+
"allowNo": false,
|
|
23
|
+
"type": "boolean"
|
|
17
24
|
}
|
|
18
25
|
},
|
|
19
26
|
"hasDynamicHelp": false,
|
|
@@ -47,6 +54,14 @@
|
|
|
47
54
|
"name": "json",
|
|
48
55
|
"allowNo": false,
|
|
49
56
|
"type": "boolean"
|
|
57
|
+
},
|
|
58
|
+
"flavor": {
|
|
59
|
+
"description": "Specify the flavor to use.",
|
|
60
|
+
"name": "flavor",
|
|
61
|
+
"required": false,
|
|
62
|
+
"hasDynamicHelp": false,
|
|
63
|
+
"multiple": false,
|
|
64
|
+
"type": "option"
|
|
50
65
|
}
|
|
51
66
|
},
|
|
52
67
|
"hasDynamicHelp": false,
|
|
@@ -89,10 +104,10 @@
|
|
|
89
104
|
"multiple": false,
|
|
90
105
|
"type": "option"
|
|
91
106
|
},
|
|
92
|
-
"force
|
|
107
|
+
"force": {
|
|
93
108
|
"char": "f",
|
|
94
|
-
"description": "
|
|
95
|
-
"name": "force
|
|
109
|
+
"description": "Bypass caches, force the recreation of containers, etc",
|
|
110
|
+
"name": "force",
|
|
96
111
|
"allowNo": false,
|
|
97
112
|
"type": "boolean"
|
|
98
113
|
}
|
|
@@ -118,7 +133,7 @@
|
|
|
118
133
|
"aliases": [],
|
|
119
134
|
"args": {
|
|
120
135
|
"component": {
|
|
121
|
-
"description": "List of components to build",
|
|
136
|
+
"description": "List of components to build (defaults to all)",
|
|
122
137
|
"name": "component",
|
|
123
138
|
"required": false
|
|
124
139
|
}
|
|
@@ -142,6 +157,13 @@
|
|
|
142
157
|
"hasDynamicHelp": false,
|
|
143
158
|
"multiple": false,
|
|
144
159
|
"type": "option"
|
|
160
|
+
},
|
|
161
|
+
"dry-run": {
|
|
162
|
+
"description": "Do not build the components but only produce build meta information",
|
|
163
|
+
"name": "dry-run",
|
|
164
|
+
"required": false,
|
|
165
|
+
"allowNo": false,
|
|
166
|
+
"type": "boolean"
|
|
145
167
|
}
|
|
146
168
|
},
|
|
147
169
|
"hasDynamicHelp": false,
|
|
@@ -204,10 +226,12 @@
|
|
|
204
226
|
"index.js"
|
|
205
227
|
]
|
|
206
228
|
},
|
|
207
|
-
"
|
|
208
|
-
"aliases": [
|
|
229
|
+
"containers": {
|
|
230
|
+
"aliases": [
|
|
231
|
+
"ps"
|
|
232
|
+
],
|
|
209
233
|
"args": {},
|
|
210
|
-
"description": "
|
|
234
|
+
"description": "List docker containers.",
|
|
211
235
|
"examples": [
|
|
212
236
|
"<%= config.bin %> <%= command.id %>"
|
|
213
237
|
],
|
|
@@ -219,18 +243,18 @@
|
|
|
219
243
|
"allowNo": false,
|
|
220
244
|
"type": "boolean"
|
|
221
245
|
},
|
|
222
|
-
"
|
|
223
|
-
"
|
|
224
|
-
"
|
|
246
|
+
"all": {
|
|
247
|
+
"char": "a",
|
|
248
|
+
"description": "Retun all containers. By default, only running containers are shown",
|
|
249
|
+
"name": "all",
|
|
225
250
|
"required": false,
|
|
226
|
-
"
|
|
227
|
-
"
|
|
228
|
-
"type": "option"
|
|
251
|
+
"allowNo": false,
|
|
252
|
+
"type": "boolean"
|
|
229
253
|
}
|
|
230
254
|
},
|
|
231
255
|
"hasDynamicHelp": false,
|
|
232
256
|
"hiddenAliases": [],
|
|
233
|
-
"id": "
|
|
257
|
+
"id": "containers",
|
|
234
258
|
"pluginAlias": "@enspirit/emb",
|
|
235
259
|
"pluginName": "@enspirit/emb",
|
|
236
260
|
"pluginType": "core",
|
|
@@ -242,16 +266,14 @@
|
|
|
242
266
|
"src",
|
|
243
267
|
"cli",
|
|
244
268
|
"commands",
|
|
245
|
-
"
|
|
246
|
-
"
|
|
269
|
+
"containers",
|
|
270
|
+
"index.js"
|
|
247
271
|
]
|
|
248
272
|
},
|
|
249
|
-
"containers": {
|
|
250
|
-
"aliases": [
|
|
251
|
-
"ps"
|
|
252
|
-
],
|
|
273
|
+
"containers:prune": {
|
|
274
|
+
"aliases": [],
|
|
253
275
|
"args": {},
|
|
254
|
-
"description": "
|
|
276
|
+
"description": "Prune containers.",
|
|
255
277
|
"examples": [
|
|
256
278
|
"<%= config.bin %> <%= command.id %>"
|
|
257
279
|
],
|
|
@@ -262,19 +284,11 @@
|
|
|
262
284
|
"name": "json",
|
|
263
285
|
"allowNo": false,
|
|
264
286
|
"type": "boolean"
|
|
265
|
-
},
|
|
266
|
-
"all": {
|
|
267
|
-
"char": "a",
|
|
268
|
-
"description": "Retun all containers. By default, only running containers are shown",
|
|
269
|
-
"name": "all",
|
|
270
|
-
"required": false,
|
|
271
|
-
"allowNo": false,
|
|
272
|
-
"type": "boolean"
|
|
273
287
|
}
|
|
274
288
|
},
|
|
275
289
|
"hasDynamicHelp": false,
|
|
276
290
|
"hiddenAliases": [],
|
|
277
|
-
"id": "containers",
|
|
291
|
+
"id": "containers:prune",
|
|
278
292
|
"pluginAlias": "@enspirit/emb",
|
|
279
293
|
"pluginName": "@enspirit/emb",
|
|
280
294
|
"pluginType": "core",
|
|
@@ -287,13 +301,13 @@
|
|
|
287
301
|
"cli",
|
|
288
302
|
"commands",
|
|
289
303
|
"containers",
|
|
290
|
-
"
|
|
304
|
+
"prune.js"
|
|
291
305
|
]
|
|
292
306
|
},
|
|
293
|
-
"
|
|
307
|
+
"config:print": {
|
|
294
308
|
"aliases": [],
|
|
295
309
|
"args": {},
|
|
296
|
-
"description": "
|
|
310
|
+
"description": "Print the current config.",
|
|
297
311
|
"examples": [
|
|
298
312
|
"<%= config.bin %> <%= command.id %>"
|
|
299
313
|
],
|
|
@@ -304,11 +318,19 @@
|
|
|
304
318
|
"name": "json",
|
|
305
319
|
"allowNo": false,
|
|
306
320
|
"type": "boolean"
|
|
321
|
+
},
|
|
322
|
+
"flavor": {
|
|
323
|
+
"description": "Specify the flavor to use.",
|
|
324
|
+
"name": "flavor",
|
|
325
|
+
"required": false,
|
|
326
|
+
"hasDynamicHelp": false,
|
|
327
|
+
"multiple": false,
|
|
328
|
+
"type": "option"
|
|
307
329
|
}
|
|
308
330
|
},
|
|
309
331
|
"hasDynamicHelp": false,
|
|
310
332
|
"hiddenAliases": [],
|
|
311
|
-
"id": "
|
|
333
|
+
"id": "config:print",
|
|
312
334
|
"pluginAlias": "@enspirit/emb",
|
|
313
335
|
"pluginName": "@enspirit/emb",
|
|
314
336
|
"pluginType": "core",
|
|
@@ -320,8 +342,8 @@
|
|
|
320
342
|
"src",
|
|
321
343
|
"cli",
|
|
322
344
|
"commands",
|
|
323
|
-
"
|
|
324
|
-
"
|
|
345
|
+
"config",
|
|
346
|
+
"print.js"
|
|
325
347
|
]
|
|
326
348
|
},
|
|
327
349
|
"images:delete": {
|
|
@@ -488,12 +510,12 @@
|
|
|
488
510
|
"aliases": [],
|
|
489
511
|
"args": {
|
|
490
512
|
"task": {
|
|
491
|
-
"description": "List of tasks
|
|
513
|
+
"description": "List of tasks to run. You can provide either ids or names (eg: component:task or task)",
|
|
492
514
|
"name": "task",
|
|
493
|
-
"required":
|
|
515
|
+
"required": true
|
|
494
516
|
}
|
|
495
517
|
},
|
|
496
|
-
"description": "Run
|
|
518
|
+
"description": "Run tasks.",
|
|
497
519
|
"examples": [
|
|
498
520
|
"<%= config.bin %> <%= command.id %>"
|
|
499
521
|
],
|
|
@@ -507,6 +529,7 @@
|
|
|
507
529
|
},
|
|
508
530
|
"executor": {
|
|
509
531
|
"char": "x",
|
|
532
|
+
"description": "Where to run the task. (experimental!)",
|
|
510
533
|
"name": "executor",
|
|
511
534
|
"hasDynamicHelp": false,
|
|
512
535
|
"multiple": false,
|
|
@@ -536,5 +559,5 @@
|
|
|
536
559
|
]
|
|
537
560
|
}
|
|
538
561
|
},
|
|
539
|
-
"version": "0.0.
|
|
562
|
+
"version": "0.0.7"
|
|
540
563
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@enspirit/emb",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.7",
|
|
5
5
|
"keywords": ["monorepo", "docker", "taskrunner", "ci", "docker compose", "sentinel", "makefile"],
|
|
6
6
|
"author": "Louis Lambeau <louis.lambeau@enspirit.be>",
|
|
7
7
|
"license": "ISC",
|
|
@@ -35,6 +35,7 @@
|
|
|
35
35
|
"@oclif/plugin-autocomplete": "^3.2.34",
|
|
36
36
|
"@oclif/plugin-help": "^6.2.32",
|
|
37
37
|
"@oclif/plugin-not-found": "^3.2.63",
|
|
38
|
+
"@oclif/plugin-update": "^4.7.3",
|
|
38
39
|
"@oclif/table": "^0.4.12",
|
|
39
40
|
"ajv": "^8.17.1",
|
|
40
41
|
"colorette": "^2.0.20",
|
|
@@ -103,7 +104,8 @@
|
|
|
103
104
|
"plugins": [
|
|
104
105
|
"@oclif/plugin-help",
|
|
105
106
|
"@oclif/plugin-autocomplete",
|
|
106
|
-
"@oclif/plugin-not-found"
|
|
107
|
+
"@oclif/plugin-not-found",
|
|
108
|
+
"@oclif/plugin-update"
|
|
107
109
|
],
|
|
108
110
|
"topicSeparator": " ",
|
|
109
111
|
"topics": {
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { Writable } from 'node:stream';
|
|
2
|
-
import { TaskInfo } from '../../types.js';
|
|
3
|
-
import { IOperation } from '../../../operations/types.js';
|
|
4
|
-
export declare enum ExecutorType {
|
|
5
|
-
container = "container",
|
|
6
|
-
local = "local"
|
|
7
|
-
}
|
|
8
|
-
export type RunTaskOperationParams = {
|
|
9
|
-
executor: ExecutorType;
|
|
10
|
-
task: TaskInfo;
|
|
11
|
-
};
|
|
12
|
-
export declare class RunTaskOperation implements IOperation<RunTaskOperationParams, void> {
|
|
13
|
-
protected out?: Writable | undefined;
|
|
14
|
-
constructor(out?: Writable | undefined);
|
|
15
|
-
run(params: RunTaskOperationParams): Promise<void>;
|
|
16
|
-
private runDocker;
|
|
17
|
-
private runLocal;
|
|
18
|
-
}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { getContext } from '../../../index.js';
|
|
2
|
-
import { ContainerExecOperation } from '../../../docker/index.js';
|
|
3
|
-
import { ExecuteLocalCommandOperation, GetComponentContainerOperation, } from '../index.js';
|
|
4
|
-
export var ExecutorType;
|
|
5
|
-
(function (ExecutorType) {
|
|
6
|
-
ExecutorType["container"] = "container";
|
|
7
|
-
ExecutorType["local"] = "local";
|
|
8
|
-
})(ExecutorType || (ExecutorType = {}));
|
|
9
|
-
export class RunTaskOperation {
|
|
10
|
-
out;
|
|
11
|
-
constructor(out) {
|
|
12
|
-
this.out = out;
|
|
13
|
-
}
|
|
14
|
-
async run(params) {
|
|
15
|
-
switch (params.executor) {
|
|
16
|
-
case ExecutorType.container: {
|
|
17
|
-
return this.runDocker(params);
|
|
18
|
-
}
|
|
19
|
-
case ExecutorType.local: {
|
|
20
|
-
return this.runLocal(params);
|
|
21
|
-
}
|
|
22
|
-
default: {
|
|
23
|
-
throw new Error(`Unsupported executor type: ${params.executor}`);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
async runDocker(params) {
|
|
28
|
-
const { monorepo } = getContext();
|
|
29
|
-
if (!params.task.component) {
|
|
30
|
-
throw new Error(`Support for non-component tasks not implemented`);
|
|
31
|
-
}
|
|
32
|
-
const containerInfo = await monorepo.run(new GetComponentContainerOperation(), params.task.component);
|
|
33
|
-
await monorepo.run(new ContainerExecOperation(this.out), {
|
|
34
|
-
attachStderr: true,
|
|
35
|
-
attachStdout: true,
|
|
36
|
-
container: containerInfo.Id,
|
|
37
|
-
script: params.task.script,
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
async runLocal(params) {
|
|
41
|
-
const { monorepo } = getContext();
|
|
42
|
-
const cwd = params.task.component
|
|
43
|
-
? monorepo.component(params.task.component).rootdir
|
|
44
|
-
: monorepo.rootDir;
|
|
45
|
-
await monorepo.run(new ExecuteLocalCommandOperation(this.out), {
|
|
46
|
-
script: params.task.script,
|
|
47
|
-
workingDir: cwd,
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import graphlib from 'graphlib';
|
|
2
|
-
const toGraph = (components) => {
|
|
3
|
-
const graph = new graphlib.Graph();
|
|
4
|
-
// Add all components as nodes
|
|
5
|
-
for (const comp of components) {
|
|
6
|
-
graph.setNode(comp.name);
|
|
7
|
-
}
|
|
8
|
-
// Add edges
|
|
9
|
-
for (const comp of components) {
|
|
10
|
-
for (const dep of comp.dependencies ?? []) {
|
|
11
|
-
graph.setEdge(dep.name, comp.name);
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
return graph;
|
|
15
|
-
};
|
|
16
|
-
export const findBuildOrder = (components, selection) => {
|
|
17
|
-
const hash = components.reduce((cmps, cmp) => {
|
|
18
|
-
cmps[cmp.name] = cmp;
|
|
19
|
-
return cmps;
|
|
20
|
-
}, {});
|
|
21
|
-
const graph = toGraph(components);
|
|
22
|
-
// Detect cycles
|
|
23
|
-
const cycles = graphlib.alg.findCycles(graph);
|
|
24
|
-
if (cycles.length > 0) {
|
|
25
|
-
throw new Error('Circular dependencies detected: ' + JSON.stringify(cycles));
|
|
26
|
-
}
|
|
27
|
-
// Pick nodes that we want to build and rebuild a graph only with these
|
|
28
|
-
const toBuild = selection || components.map((c) => c.name);
|
|
29
|
-
const includingDeps = toBuild
|
|
30
|
-
.reduce((set, name) => {
|
|
31
|
-
graph.predecessors(name)?.forEach((name) => {
|
|
32
|
-
set.add(name);
|
|
33
|
-
});
|
|
34
|
-
return set;
|
|
35
|
-
}, new Set(toBuild))
|
|
36
|
-
.values();
|
|
37
|
-
const newGraph = toGraph([...includingDeps].map((name) => hash[name]));
|
|
38
|
-
// Get build order
|
|
39
|
-
const order = graphlib.alg.topsort(newGraph);
|
|
40
|
-
return order.map((name) => hash[name]);
|
|
41
|
-
};
|