@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
|
@@ -1,8 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
description?: string;
|
|
1
|
+
import { ComponentFlavorConfig, IResourceConfig, ProjectFlavorConfig, TaskConfig } from '../config/types.js';
|
|
2
|
+
export type ComponentIdentifiable<T> = T & {
|
|
4
3
|
id: string;
|
|
5
4
|
name: string;
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
component: string;
|
|
6
|
+
};
|
|
7
|
+
export type ResourceInfo = ComponentIdentifiable<IResourceConfig>;
|
|
8
|
+
export type Resources = {
|
|
9
|
+
[k: string]: ResourceInfo;
|
|
10
|
+
};
|
|
11
|
+
export type ProjectFlavors = {
|
|
12
|
+
[k: string]: ProjectFlavorConfig;
|
|
13
|
+
};
|
|
14
|
+
export type ComponentFlavorInfo = ComponentIdentifiable<ComponentFlavorConfig>;
|
|
15
|
+
export type ComponentFlavors = {
|
|
16
|
+
[k: string]: ComponentFlavorInfo;
|
|
17
|
+
};
|
|
18
|
+
export type TaskInfo = ComponentIdentifiable<TaskConfig>;
|
|
19
|
+
export type Tasks = {
|
|
20
|
+
[k: string]: TaskInfo;
|
|
8
21
|
};
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
type CollectionConfig<IDK extends PropertyKey, DPK extends PropertyKey> = {
|
|
1
|
+
import { DepList } from './types.js';
|
|
2
|
+
export type CollectionConfig<IDK extends PropertyKey, DPK extends PropertyKey> = {
|
|
3
3
|
idField: IDK;
|
|
4
4
|
depField: DPK;
|
|
5
5
|
/** If true, throw when an item's id equals some other item's name (or vice versa). */
|
|
6
6
|
forbidIdNameCollision?: boolean;
|
|
7
7
|
};
|
|
8
|
-
type AmbiguityPolicy = 'error' | 'runAll';
|
|
9
8
|
export declare class EMBCollection<T extends Partial<Record<DPK, DepList>> & Record<IDK, string> & {
|
|
10
9
|
name: string;
|
|
11
10
|
}, IDK extends keyof T, DPK extends keyof T> {
|
|
12
11
|
private items;
|
|
13
12
|
readonly idField: IDK;
|
|
14
13
|
readonly depField: DPK;
|
|
14
|
+
readonly forbidIdNameCollision: boolean;
|
|
15
15
|
private byId;
|
|
16
16
|
private byName;
|
|
17
17
|
constructor(items: Iterable<T>, cfg: CollectionConfig<IDK, DPK>);
|
|
@@ -26,9 +26,3 @@ export declare class EMBCollection<T extends Partial<Record<DPK, DepList>> & Rec
|
|
|
26
26
|
multiple: true;
|
|
27
27
|
}): T[];
|
|
28
28
|
}
|
|
29
|
-
export declare function findRunOrder<T extends Partial<Record<DPK, DepList>> & Record<IDK, string> & {
|
|
30
|
-
name: string;
|
|
31
|
-
}, IDK extends keyof T, DPK extends keyof T>(selection: readonly string[], collection: EMBCollection<T, IDK, DPK>, { onAmbiguous }?: {
|
|
32
|
-
onAmbiguous?: AmbiguityPolicy | undefined;
|
|
33
|
-
}): T[];
|
|
34
|
-
export {};
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { AmbiguousReferenceError, ItemCollisionsError, UnkownReferenceError, } from '../../errors.js';
|
|
2
|
+
export class EMBCollection {
|
|
3
|
+
items;
|
|
4
|
+
idField;
|
|
5
|
+
depField;
|
|
6
|
+
forbidIdNameCollision;
|
|
7
|
+
//
|
|
8
|
+
byId;
|
|
9
|
+
byName;
|
|
10
|
+
constructor(items, cfg) {
|
|
11
|
+
this.items = [];
|
|
12
|
+
this.idField = cfg.idField;
|
|
13
|
+
this.depField = cfg.depField;
|
|
14
|
+
this.forbidIdNameCollision = cfg.forbidIdNameCollision ?? true;
|
|
15
|
+
this.byId = new Map();
|
|
16
|
+
this.byName = new Map();
|
|
17
|
+
// single-pass validation state
|
|
18
|
+
const seenIds = new Set();
|
|
19
|
+
const seenNames = new Set();
|
|
20
|
+
const dupIdReports = [];
|
|
21
|
+
const collisions = [];
|
|
22
|
+
for (const t of items) {
|
|
23
|
+
const id = t[this.idField];
|
|
24
|
+
const { name } = t;
|
|
25
|
+
// duplicate id?
|
|
26
|
+
if (seenIds.has(id)) {
|
|
27
|
+
const firstOwner = this.byId.get(id); // first occurrence already stored
|
|
28
|
+
dupIdReports.push(`id \`${id}\` used by \`${firstOwner.name}\` and \`${name}\``);
|
|
29
|
+
// keep the first owner in byId; do not overwrite
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
this.byId.set(id, t);
|
|
33
|
+
seenIds.add(id);
|
|
34
|
+
}
|
|
35
|
+
// --- Optional validation: forbid id <-> name collisions ---
|
|
36
|
+
if (this.forbidIdNameCollision) {
|
|
37
|
+
if (seenNames.has(id)) {
|
|
38
|
+
const nameOwners = this.byName.get(id) ?? [];
|
|
39
|
+
const ownerIds = nameOwners.map((o) => o[this.idField]).join(', ');
|
|
40
|
+
collisions.push(`value \`${id}\` is an id of \`${name}\` and also a name of item(s) with id(s): [${ownerIds}]`);
|
|
41
|
+
}
|
|
42
|
+
if (seenIds.has(name)) {
|
|
43
|
+
const idOwner = this.byId.get(name);
|
|
44
|
+
collisions.push(`value \`${name}\` is a name of \`${t.name}\` and also an id of \`${idOwner.name}\``);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
// byName index
|
|
48
|
+
const list = this.byName.get(name);
|
|
49
|
+
if (list) {
|
|
50
|
+
list.push(t);
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
this.byName.set(name, [t]);
|
|
54
|
+
}
|
|
55
|
+
// keep item list (stable order)
|
|
56
|
+
this.items.push(t);
|
|
57
|
+
// record name after checks so current name won’t collide with itself
|
|
58
|
+
seenNames.add(name);
|
|
59
|
+
}
|
|
60
|
+
if (dupIdReports.length > 0 || collisions.length > 0) {
|
|
61
|
+
const parts = [];
|
|
62
|
+
if (dupIdReports.length > 0) {
|
|
63
|
+
parts.push(`Duplicate ${String(this.idField)} values (${dupIdReports.length}):\n` +
|
|
64
|
+
dupIdReports.join('\n'));
|
|
65
|
+
}
|
|
66
|
+
if (collisions.length > 0) {
|
|
67
|
+
parts.push(`id↔name collisions (${collisions.length}):\n` +
|
|
68
|
+
collisions.join('\n'));
|
|
69
|
+
}
|
|
70
|
+
throw new ItemCollisionsError('Collision between items', parts);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
/** All items (stable array iteration) */
|
|
74
|
+
get all() {
|
|
75
|
+
return this.items;
|
|
76
|
+
}
|
|
77
|
+
idOf(t) {
|
|
78
|
+
return t[this.idField];
|
|
79
|
+
}
|
|
80
|
+
depsOf(t) {
|
|
81
|
+
return (t[this.depField] ?? []);
|
|
82
|
+
}
|
|
83
|
+
matches(ref, opts) {
|
|
84
|
+
const idHit = this.byId.get(ref);
|
|
85
|
+
if (idHit) {
|
|
86
|
+
return opts?.multiple ? [idHit] : idHit;
|
|
87
|
+
}
|
|
88
|
+
const nameHits = this.byName.get(ref) ?? [];
|
|
89
|
+
if (nameHits.length === 0) {
|
|
90
|
+
throw new UnkownReferenceError(`Unknown reference \`${ref}\``, ref);
|
|
91
|
+
}
|
|
92
|
+
if (opts?.multiple) {
|
|
93
|
+
return nameHits;
|
|
94
|
+
}
|
|
95
|
+
if (nameHits.length > 1) {
|
|
96
|
+
const names = nameHits.map((t) => this.idOf(t));
|
|
97
|
+
throw new AmbiguousReferenceError(`Ambiguous reference \`${ref}\` matches multiple names`, ref, names);
|
|
98
|
+
}
|
|
99
|
+
return nameHits[0];
|
|
100
|
+
}
|
|
101
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import graphlib from 'graphlib';
|
|
2
|
+
import { EMBCollection } from './EMBCollection.js';
|
|
3
|
+
import { AmbiguityPolicy, DepList } from './types.js';
|
|
4
|
+
export declare function resolveRefSet<T extends Partial<Record<DPK, DepList>> & Record<IDK, string> & {
|
|
5
|
+
name: string;
|
|
6
|
+
}, IDK extends keyof T, DPK extends keyof T>(col: EMBCollection<T, IDK, DPK>, ref: string, policy: AmbiguityPolicy): string[];
|
|
7
|
+
export declare function collectPredecessorClosure(g: graphlib.Graph, seeds: Iterable<string>): Set<string>;
|
|
8
|
+
export declare function buildGraph<T extends Partial<Record<DPK, DepList>> & Record<IDK, string> & {
|
|
9
|
+
name: string;
|
|
10
|
+
}, IDK extends keyof T, DPK extends keyof T>(col: EMBCollection<T, IDK, DPK>, policy: AmbiguityPolicy): graphlib.Graph;
|
|
11
|
+
export declare function findRunOrder<T extends Partial<Record<DPK, DepList>> & Record<IDK, string> & {
|
|
12
|
+
name: string;
|
|
13
|
+
}, IDK extends keyof T, DPK extends keyof T>(selection: readonly string[], collection: EMBCollection<T, IDK, DPK>, { onAmbiguous }?: {
|
|
14
|
+
onAmbiguous?: AmbiguityPolicy | undefined;
|
|
15
|
+
}): T[];
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import graphlib from 'graphlib';
|
|
2
|
+
import { CircularDependencyError } from '../../errors.js';
|
|
3
|
+
/* ----------------- run-order helpers unchanged (for completeness) ---------------- */
|
|
4
|
+
export function resolveRefSet(col, ref, policy) {
|
|
5
|
+
if (policy === 'runAll') {
|
|
6
|
+
return col.matches(ref, { multiple: true }).map((t) => col.idOf(t));
|
|
7
|
+
}
|
|
8
|
+
return [col.idOf(col.matches(ref))];
|
|
9
|
+
}
|
|
10
|
+
export function collectPredecessorClosure(g, seeds) {
|
|
11
|
+
const seen = new Set();
|
|
12
|
+
const q = [];
|
|
13
|
+
for (const s of seeds) {
|
|
14
|
+
if (!seen.has(s)) {
|
|
15
|
+
seen.add(s);
|
|
16
|
+
q.push(s);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
while (q.length > 0) {
|
|
20
|
+
const cur = q.shift();
|
|
21
|
+
for (const p of g.predecessors(cur) ?? []) {
|
|
22
|
+
if (!seen.has(p)) {
|
|
23
|
+
seen.add(p);
|
|
24
|
+
q.push(p);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return seen;
|
|
29
|
+
}
|
|
30
|
+
export function buildGraph(col, policy) {
|
|
31
|
+
const g = new graphlib.Graph({ directed: true });
|
|
32
|
+
for (const t of col.all) {
|
|
33
|
+
g.setNode(col.idOf(t));
|
|
34
|
+
}
|
|
35
|
+
for (const t of col.all) {
|
|
36
|
+
const toId = col.idOf(t);
|
|
37
|
+
for (const ref of col.depsOf(t)) {
|
|
38
|
+
for (const fromId of resolveRefSet(col, ref, policy)) {
|
|
39
|
+
g.setEdge(fromId, toId);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return g;
|
|
44
|
+
}
|
|
45
|
+
export function findRunOrder(selection, collection, { onAmbiguous = 'error' } = {}) {
|
|
46
|
+
const g = buildGraph(collection, onAmbiguous);
|
|
47
|
+
const cycles = graphlib.alg.findCycles(g);
|
|
48
|
+
if (cycles.length > 0) {
|
|
49
|
+
throw new CircularDependencyError(`Circular dependencies detected: ${JSON.stringify(cycles)}`, cycles);
|
|
50
|
+
}
|
|
51
|
+
const selectedIds = new Set();
|
|
52
|
+
for (const ref of selection) {
|
|
53
|
+
for (const id of resolveRefSet(collection, ref, onAmbiguous)) {
|
|
54
|
+
selectedIds.add(id);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
if (selectedIds.size === 0) {
|
|
58
|
+
throw new Error('Selection resolved to no items.');
|
|
59
|
+
}
|
|
60
|
+
const include = collectPredecessorClosure(g, selectedIds.values());
|
|
61
|
+
const sub = new graphlib.Graph({ directed: true });
|
|
62
|
+
for (const id of include) {
|
|
63
|
+
sub.setNode(id);
|
|
64
|
+
}
|
|
65
|
+
for (const id of include) {
|
|
66
|
+
for (const p of g.predecessors(id) ?? []) {
|
|
67
|
+
if (include.has(p)) {
|
|
68
|
+
sub.setEdge(p, id);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
const ids = graphlib.alg.topsort(sub);
|
|
73
|
+
const byId = new Map();
|
|
74
|
+
for (const t of collection.all) {
|
|
75
|
+
byId.set(collection.idOf(t), t);
|
|
76
|
+
}
|
|
77
|
+
return ids.map((id) => {
|
|
78
|
+
const t = byId.get(id);
|
|
79
|
+
if (!t) {
|
|
80
|
+
throw new Error(`Internal error: missing item for id "${id}"`);
|
|
81
|
+
}
|
|
82
|
+
return t;
|
|
83
|
+
});
|
|
84
|
+
}
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import { ComponentIdentifiable } from '../../index.js';
|
|
2
|
+
export * from './EMBCollection.js';
|
|
3
|
+
export * from './graph.js';
|
|
4
|
+
export * from './types.js';
|
|
5
|
+
export declare const toIdentifedHash: <V, T extends {
|
|
6
|
+
[k: string]: V;
|
|
7
|
+
}>(hash: T, parentName: string) => Record<string, ComponentIdentifiable<V>>;
|
|
@@ -1 +1,14 @@
|
|
|
1
|
-
export * from './
|
|
1
|
+
export * from './EMBCollection.js';
|
|
2
|
+
export * from './graph.js';
|
|
3
|
+
export * from './types.js';
|
|
4
|
+
export const toIdentifedHash = (hash, parentName) => {
|
|
5
|
+
return Object.entries(hash).reduce((hash, [key, value]) => {
|
|
6
|
+
hash[key] = {
|
|
7
|
+
...value,
|
|
8
|
+
id: `${parentName}:${key}`,
|
|
9
|
+
name: key,
|
|
10
|
+
component: parentName,
|
|
11
|
+
};
|
|
12
|
+
return hash;
|
|
13
|
+
}, {});
|
|
14
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { EmbContext } from '../../index.js';
|
|
2
2
|
import * as z from 'zod';
|
|
3
3
|
import { IOperation } from '../index.js';
|
|
4
|
+
export type OpInput<A extends AbstractOperation<z.Schema, unknown>> = A extends AbstractOperation<infer I, unknown> ? z.infer<I> : never;
|
|
5
|
+
export type OpOutput<A extends AbstractOperation<z.Schema, unknown>> = A extends AbstractOperation<z.Schema, infer O> ? O : never;
|
|
4
6
|
export declare abstract class AbstractOperation<S extends z.Schema, O = unknown> implements IOperation<z.infer<S>, O> {
|
|
5
7
|
protected inputSchema: S;
|
|
6
8
|
protected context: EmbContext;
|
|
7
9
|
constructor(inputSchema: S);
|
|
8
10
|
protected abstract _run(input: z.infer<S>): Promise<O>;
|
|
9
|
-
run(input: z.infer<S>): Promise<O>;
|
|
11
|
+
run(input: unknown | z.infer<S>): Promise<O>;
|
|
10
12
|
}
|
|
@@ -4,6 +4,9 @@ export class AbstractOperation {
|
|
|
4
4
|
context;
|
|
5
5
|
constructor(inputSchema) {
|
|
6
6
|
this.inputSchema = inputSchema;
|
|
7
|
+
if (!inputSchema) {
|
|
8
|
+
throw new Error(`${this.constructor.name} does not call super() with validation schema`);
|
|
9
|
+
}
|
|
7
10
|
this.context = getContext();
|
|
8
11
|
}
|
|
9
12
|
async run(input) {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { Component } from '../monorepo/index.js';
|
|
2
1
|
import { FilePrerequisite, PrerequisitePlugin, PrerequisiteType } from './types.js';
|
|
3
2
|
export declare class GitPrerequisitePlugin implements PrerequisitePlugin<PrerequisiteType.file, FilePrerequisite> {
|
|
4
|
-
collect(
|
|
3
|
+
collect(path: string): Promise<Array<FilePrerequisite>>;
|
|
5
4
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { simpleGit } from 'simple-git';
|
|
2
2
|
import { PrerequisiteType, } from './types.js';
|
|
3
3
|
export class GitPrerequisitePlugin {
|
|
4
|
-
async collect(
|
|
5
|
-
const repo = simpleGit(
|
|
6
|
-
return (await repo.raw('ls-files',
|
|
4
|
+
async collect(path) {
|
|
5
|
+
const repo = simpleGit(path);
|
|
6
|
+
return (await repo.raw('ls-files', path))
|
|
7
7
|
.split('\n')
|
|
8
8
|
.map((s) => s.trim())
|
|
9
9
|
.filter(Boolean)
|
|
@@ -18,9 +18,9 @@ export interface FilePrerequisite extends Prerequisite<PrerequisiteType.file> {
|
|
|
18
18
|
}
|
|
19
19
|
export interface PrerequisitePlugin<T extends PrerequisiteType, P extends Prerequisite<T>, Output = unknown, Changes = unknown> {
|
|
20
20
|
/**
|
|
21
|
-
* Collect/discover prerequisistes for a
|
|
21
|
+
* Collect/discover prerequisistes for a path (relative to the monorepo root)
|
|
22
22
|
*/
|
|
23
|
-
collect?(
|
|
23
|
+
collect?(path: string): Promise<Array<P>>;
|
|
24
24
|
/**
|
|
25
25
|
* Returns the list of changes between the last collection and the new
|
|
26
26
|
* collection.
|
|
@@ -15,7 +15,8 @@ export declare class TemplateExpander {
|
|
|
15
15
|
private expansions;
|
|
16
16
|
get expansionCount(): number;
|
|
17
17
|
expand(str: string, options?: ExpandOptions): Promise<string>;
|
|
18
|
-
expandRecord<R extends Record<string, unknown>>(record: R, options
|
|
18
|
+
expandRecord<R extends Record<string, unknown>>(record: R, options: ExpandOptions): Promise<R>;
|
|
19
|
+
expandRecord<R extends Array<unknown>>(record: R, options: ExpandOptions): Promise<R>;
|
|
19
20
|
private track;
|
|
20
21
|
}
|
|
21
22
|
export {};
|
|
@@ -37,9 +37,11 @@ export class TemplateExpander {
|
|
|
37
37
|
.replaceAll('\\${', '${'));
|
|
38
38
|
}
|
|
39
39
|
async expandRecord(record, options = {}) {
|
|
40
|
+
if (Array.isArray(record)) {
|
|
41
|
+
return Promise.all(record.map((v) => this.expand(v, options)));
|
|
42
|
+
}
|
|
40
43
|
return Object.entries(record).reduce(async (vars, [name, str]) => {
|
|
41
44
|
const previous = await vars;
|
|
42
|
-
// @ts-expect-error dunno
|
|
43
45
|
previous[name] = await (typeof str === 'object'
|
|
44
46
|
? this.expandRecord(str, options)
|
|
45
47
|
: this.expand(str, options));
|