@enspirit/emb 0.0.9 → 0.1.0

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.
Files changed (123) hide show
  1. package/README.md +50 -28
  2. package/dist/src/cli/abstract/BaseCommand.d.ts +6 -0
  3. package/dist/src/cli/abstract/BaseCommand.js +33 -0
  4. package/dist/src/cli/abstract/FlavouredCommand.d.ts +2 -1
  5. package/dist/src/cli/abstract/FlavouredCommand.js +4 -3
  6. package/dist/src/cli/abstract/index.d.ts +1 -0
  7. package/dist/src/cli/abstract/index.js +1 -0
  8. package/dist/src/cli/commands/clean.d.ts +2 -2
  9. package/dist/src/cli/commands/clean.js +7 -6
  10. package/dist/src/cli/commands/components/index.d.ts +5 -4
  11. package/dist/src/cli/commands/components/index.js +13 -15
  12. package/dist/src/cli/commands/config/print.d.ts +2 -2
  13. package/dist/src/cli/commands/containers/index.d.ts +2 -2
  14. package/dist/src/cli/commands/containers/index.js +3 -3
  15. package/dist/src/cli/commands/containers/prune.d.ts +2 -2
  16. package/dist/src/cli/commands/containers/prune.js +2 -2
  17. package/dist/src/cli/commands/images/delete.d.ts +2 -2
  18. package/dist/src/cli/commands/images/delete.js +3 -2
  19. package/dist/src/cli/commands/images/index.d.ts +2 -2
  20. package/dist/src/cli/commands/images/index.js +3 -3
  21. package/dist/src/cli/commands/images/prune.d.ts +2 -2
  22. package/dist/src/cli/commands/images/prune.js +3 -2
  23. package/dist/src/cli/commands/{components → resources}/build.d.ts +3 -3
  24. package/dist/src/cli/commands/{components → resources}/build.js +11 -10
  25. package/dist/src/cli/commands/resources/index.d.ts +9 -0
  26. package/dist/src/cli/commands/resources/index.js +28 -0
  27. package/dist/src/cli/commands/tasks/index.d.ts +2 -2
  28. package/dist/src/cli/commands/tasks/index.js +4 -4
  29. package/dist/src/cli/commands/tasks/run.d.ts +2 -2
  30. package/dist/src/cli/commands/tasks/run.js +12 -5
  31. package/dist/src/cli/commands/up.js +5 -4
  32. package/dist/src/cli/hooks/init.js +1 -26
  33. package/dist/src/cli/utils.d.ts +1 -0
  34. package/dist/src/cli/utils.js +26 -0
  35. package/dist/src/config/convert.d.ts +2 -4
  36. package/dist/src/config/convert.js +12 -35
  37. package/dist/src/config/index.d.ts +3 -4
  38. package/dist/src/config/index.js +2 -3
  39. package/dist/src/config/schema.d.ts +69 -48
  40. package/dist/src/config/schema.json +185 -99
  41. package/dist/src/config/types.d.ts +13 -46
  42. package/dist/src/config/types.js +1 -1
  43. package/dist/src/config/validation.d.ts +3 -3
  44. package/dist/src/config/validation.js +9 -9
  45. package/dist/src/context.d.ts +1 -1
  46. package/dist/src/context.js +1 -0
  47. package/dist/src/docker/images/index.d.ts +0 -1
  48. package/dist/src/docker/images/index.js +0 -1
  49. package/dist/src/docker/index.d.ts +1 -1
  50. package/dist/src/docker/index.js +1 -1
  51. package/dist/src/docker/operations/containers/ExecContainerOperation.js +2 -1
  52. package/dist/src/docker/operations/images/BuildImageOperation.d.ts +7 -8
  53. package/dist/src/docker/operations/images/BuildImageOperation.js +16 -10
  54. package/dist/src/docker/resources/DockerImageResource.js +56 -0
  55. package/dist/src/docker/resources/index.d.ts +1 -0
  56. package/dist/src/docker/resources/index.js +1 -0
  57. package/dist/src/docker/utils.d.ts +1 -7
  58. package/dist/src/docker/utils.js +3 -7
  59. package/dist/src/errors.d.ts +9 -6
  60. package/dist/src/errors.js +15 -9
  61. package/dist/src/index.d.ts +2 -0
  62. package/dist/src/index.js +2 -0
  63. package/dist/src/monorepo/component.d.ts +14 -19
  64. package/dist/src/monorepo/component.js +42 -58
  65. package/dist/src/monorepo/config.d.ts +13 -15
  66. package/dist/src/monorepo/config.js +15 -46
  67. package/dist/src/monorepo/index.d.ts +1 -0
  68. package/dist/src/monorepo/index.js +1 -0
  69. package/dist/src/monorepo/monorepo.d.ts +13 -10
  70. package/dist/src/monorepo/monorepo.js +78 -19
  71. package/dist/src/monorepo/operations/components/index.d.ts +0 -1
  72. package/dist/src/monorepo/operations/components/index.js +0 -1
  73. package/dist/src/monorepo/operations/fs/CreateFileOperation.d.ts +11 -0
  74. package/dist/src/monorepo/operations/fs/CreateFileOperation.js +31 -0
  75. package/dist/src/monorepo/operations/fs/index.d.ts +1 -0
  76. package/dist/src/monorepo/operations/fs/index.js +1 -0
  77. package/dist/src/monorepo/operations/index.d.ts +1 -0
  78. package/dist/src/monorepo/operations/index.js +1 -0
  79. package/dist/src/monorepo/operations/resources/BuildResourcesOperation.d.ts +27 -0
  80. package/dist/src/monorepo/operations/resources/BuildResourcesOperation.js +146 -0
  81. package/dist/src/monorepo/operations/tasks/RunTasksOperation.js +1 -1
  82. package/dist/src/monorepo/plugins/{ComponentDiscoverPlugin.d.ts → AutoDockerPlugin.d.ts} +4 -4
  83. package/dist/src/monorepo/plugins/AutoDockerPlugin.js +46 -0
  84. package/dist/src/monorepo/plugins/EmbfileLoaderPlugin.js +9 -2
  85. package/dist/src/monorepo/plugins/index.d.ts +1 -1
  86. package/dist/src/monorepo/plugins/index.js +3 -3
  87. package/dist/src/monorepo/resources/FileResource.d.ts +1 -0
  88. package/dist/src/monorepo/resources/FileResource.js +13 -0
  89. package/dist/src/monorepo/resources/ResourceFactory.d.ts +23 -0
  90. package/dist/src/monorepo/resources/ResourceFactory.js +16 -0
  91. package/dist/src/monorepo/resources/index.d.ts +1 -0
  92. package/dist/src/monorepo/resources/index.js +1 -0
  93. package/dist/src/monorepo/store/index.d.ts +1 -1
  94. package/dist/src/monorepo/store/index.js +10 -2
  95. package/dist/src/monorepo/taskManagerFactory.d.ts +2 -2
  96. package/dist/src/monorepo/taskManagerFactory.js +1 -2
  97. package/dist/src/monorepo/types.d.ts +18 -5
  98. package/dist/src/monorepo/utils/{findRunOrder.d.ts → EMBCollection.d.ts} +3 -9
  99. package/dist/src/monorepo/utils/EMBCollection.js +101 -0
  100. package/dist/src/monorepo/utils/graph.d.ts +15 -0
  101. package/dist/src/monorepo/utils/graph.js +84 -0
  102. package/dist/src/monorepo/utils/index.d.ts +7 -1
  103. package/dist/src/monorepo/utils/index.js +14 -1
  104. package/dist/src/monorepo/utils/types.d.ts +2 -0
  105. package/dist/src/monorepo/utils/types.js +1 -0
  106. package/dist/src/operations/abstract/AbstractOperation.d.ts +3 -1
  107. package/dist/src/operations/abstract/AbstractOperation.js +3 -0
  108. package/dist/src/operations/types.d.ts +1 -1
  109. package/dist/src/prerequisites/GitPrerequisitePlugin.js +2 -2
  110. package/dist/src/utils/TemplateExpander.d.ts +2 -1
  111. package/dist/src/utils/TemplateExpander.js +3 -1
  112. package/oclif.manifest.json +105 -68
  113. package/package.json +7 -2
  114. package/dist/src/docker/images/buildImage.d.ts +0 -19
  115. package/dist/src/docker/images/buildImage.js +0 -64
  116. package/dist/src/docker/types.d.ts +0 -14
  117. package/dist/src/monorepo/operations/components/BuildComponentsOperation.d.ts +0 -23
  118. package/dist/src/monorepo/operations/components/BuildComponentsOperation.js +0 -157
  119. package/dist/src/monorepo/plugins/ComponentDiscoverPlugin.js +0 -44
  120. package/dist/src/monorepo/project.d.ts +0 -6
  121. package/dist/src/monorepo/project.js +0 -8
  122. package/dist/src/monorepo/utils/findRunOrder.js +0 -165
  123. /package/dist/src/docker/{types.js → resources/DockerImageResource.d.ts} +0 -0
@@ -1,8 +1,21 @@
1
- export type TaskInfo = {
2
- component?: string;
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
- script?: string;
7
- pre?: Array<string>;
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
- type DepList = readonly string[] | string[] | undefined;
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
- export * from './findRunOrder.js';
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 './findRunOrder.js';
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,2 @@
1
+ export type DepList = readonly string[] | string[] | undefined;
2
+ export type AmbiguityPolicy = 'error' | 'runAll';
@@ -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,3 +1,3 @@
1
- export interface IOperation<I = unknown, O = unknown> {
1
+ export interface IOperation<I, O> {
2
2
  run(input: I): Promise<O>;
3
3
  }
@@ -2,8 +2,8 @@ import { simpleGit } from 'simple-git';
2
2
  import { PrerequisiteType, } from './types.js';
3
3
  export class GitPrerequisitePlugin {
4
4
  async collect(component) {
5
- const repo = simpleGit(component.rootdir);
6
- return (await repo.raw('ls-files', component.rootdir))
5
+ const repo = simpleGit(component.rootDir);
6
+ return (await repo.raw('ls-files', component.rootDir))
7
7
  .split('\n')
8
8
  .map((s) => s.trim())
9
9
  .filter(Boolean)
@@ -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?: ExpandOptions): Promise<R>;
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));
@@ -70,7 +70,6 @@
70
70
  "pluginAlias": "@enspirit/emb",
71
71
  "pluginName": "@enspirit/emb",
72
72
  "pluginType": "core",
73
- "strict": true,
74
73
  "enableJsonFlag": true,
75
74
  "isESM": true,
76
75
  "relativePath": [
@@ -118,7 +117,6 @@
118
117
  "pluginAlias": "@enspirit/emb",
119
118
  "pluginName": "@enspirit/emb",
120
119
  "pluginType": "core",
121
- "strict": true,
122
120
  "enableJsonFlag": true,
123
121
  "isESM": true,
124
122
  "relativePath": [
@@ -129,69 +127,6 @@
129
127
  "up.js"
130
128
  ]
131
129
  },
132
- "components:build": {
133
- "aliases": [],
134
- "args": {
135
- "component": {
136
- "description": "List of components to build (defaults to all)",
137
- "name": "component",
138
- "required": false
139
- }
140
- },
141
- "description": "Build the components of the monorepo",
142
- "examples": [
143
- "<%= config.bin %> <%= command.id %> build --flavor development"
144
- ],
145
- "flags": {
146
- "json": {
147
- "description": "Format output as json.",
148
- "helpGroup": "GLOBAL",
149
- "name": "json",
150
- "allowNo": false,
151
- "type": "boolean"
152
- },
153
- "flavor": {
154
- "description": "Specify the flavor to use.",
155
- "name": "flavor",
156
- "required": false,
157
- "hasDynamicHelp": false,
158
- "multiple": false,
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"
167
- },
168
- "force": {
169
- "char": "f",
170
- "description": "Bypass the cache and force the build",
171
- "name": "force",
172
- "required": false,
173
- "allowNo": false,
174
- "type": "boolean"
175
- }
176
- },
177
- "hasDynamicHelp": false,
178
- "hiddenAliases": [],
179
- "id": "components:build",
180
- "pluginAlias": "@enspirit/emb",
181
- "pluginName": "@enspirit/emb",
182
- "pluginType": "core",
183
- "strict": false,
184
- "enableJsonFlag": true,
185
- "isESM": true,
186
- "relativePath": [
187
- "dist",
188
- "src",
189
- "cli",
190
- "commands",
191
- "components",
192
- "build.js"
193
- ]
194
- },
195
130
  "components": {
196
131
  "aliases": [],
197
132
  "args": {},
@@ -222,7 +157,6 @@
222
157
  "pluginAlias": "@enspirit/emb",
223
158
  "pluginName": "@enspirit/emb",
224
159
  "pluginType": "core",
225
- "strict": true,
226
160
  "enableJsonFlag": true,
227
161
  "isESM": true,
228
162
  "relativePath": [
@@ -264,7 +198,6 @@
264
198
  "pluginAlias": "@enspirit/emb",
265
199
  "pluginName": "@enspirit/emb",
266
200
  "pluginType": "core",
267
- "strict": true,
268
201
  "enableJsonFlag": true,
269
202
  "isESM": true,
270
203
  "relativePath": [
@@ -572,7 +505,111 @@
572
505
  "tasks",
573
506
  "run.js"
574
507
  ]
508
+ },
509
+ "resources:build": {
510
+ "aliases": [],
511
+ "args": {
512
+ "component": {
513
+ "description": "List of resources to build (defaults to all)",
514
+ "name": "component",
515
+ "required": false
516
+ }
517
+ },
518
+ "description": "Build the resources of the monorepo",
519
+ "examples": [
520
+ "<%= config.bin %> <%= command.id %> build --flavor development"
521
+ ],
522
+ "flags": {
523
+ "json": {
524
+ "description": "Format output as json.",
525
+ "helpGroup": "GLOBAL",
526
+ "name": "json",
527
+ "allowNo": false,
528
+ "type": "boolean"
529
+ },
530
+ "flavor": {
531
+ "description": "Specify the flavor to use.",
532
+ "name": "flavor",
533
+ "required": false,
534
+ "hasDynamicHelp": false,
535
+ "multiple": false,
536
+ "type": "option"
537
+ },
538
+ "dry-run": {
539
+ "description": "Do not build the resources but only produce build meta information",
540
+ "name": "dry-run",
541
+ "required": false,
542
+ "allowNo": false,
543
+ "type": "boolean"
544
+ },
545
+ "force": {
546
+ "char": "f",
547
+ "description": "Bypass the cache and force the build",
548
+ "name": "force",
549
+ "required": false,
550
+ "allowNo": false,
551
+ "type": "boolean"
552
+ }
553
+ },
554
+ "hasDynamicHelp": false,
555
+ "hiddenAliases": [],
556
+ "id": "resources:build",
557
+ "pluginAlias": "@enspirit/emb",
558
+ "pluginName": "@enspirit/emb",
559
+ "pluginType": "core",
560
+ "strict": false,
561
+ "enableJsonFlag": true,
562
+ "isESM": true,
563
+ "relativePath": [
564
+ "dist",
565
+ "src",
566
+ "cli",
567
+ "commands",
568
+ "resources",
569
+ "build.js"
570
+ ]
571
+ },
572
+ "resources": {
573
+ "aliases": [],
574
+ "args": {},
575
+ "description": "List resources.",
576
+ "examples": [
577
+ "<%= config.bin %> <%= command.id %>"
578
+ ],
579
+ "flags": {
580
+ "json": {
581
+ "description": "Format output as json.",
582
+ "helpGroup": "GLOBAL",
583
+ "name": "json",
584
+ "allowNo": false,
585
+ "type": "boolean"
586
+ },
587
+ "flavor": {
588
+ "description": "Specify the flavor to use.",
589
+ "name": "flavor",
590
+ "required": false,
591
+ "hasDynamicHelp": false,
592
+ "multiple": false,
593
+ "type": "option"
594
+ }
595
+ },
596
+ "hasDynamicHelp": false,
597
+ "hiddenAliases": [],
598
+ "id": "resources",
599
+ "pluginAlias": "@enspirit/emb",
600
+ "pluginName": "@enspirit/emb",
601
+ "pluginType": "core",
602
+ "enableJsonFlag": true,
603
+ "isESM": true,
604
+ "relativePath": [
605
+ "dist",
606
+ "src",
607
+ "cli",
608
+ "commands",
609
+ "resources",
610
+ "index.js"
611
+ ]
575
612
  }
576
613
  },
577
- "version": "0.0.9"
614
+ "version": "0.1.0"
578
615
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@enspirit/emb",
3
3
  "type": "module",
4
- "version": "0.0.9",
4
+ "version": "0.1.0",
5
5
  "keywords": ["monorepo", "docker", "taskrunner", "ci", "docker compose", "sentinel", "makefile"],
6
6
  "author": "Louis Lambeau <louis.lambeau@enspirit.be>",
7
7
  "license": "ISC",
@@ -13,6 +13,7 @@
13
13
  "build": "rimraf dist && npm run build:types && npm run build:ts && npm run copy:proto",
14
14
  "copy:proto": "cp -r src/docker/protobuf/*.proto dist/src/docker/protobuf/",
15
15
  "build:ts": "tsc -b && tsc-alias",
16
+ "build:ts:watch": "tsc --watch",
16
17
  "build:types": "json2ts src/config/schema.json > src/config/schema.ts",
17
18
  "lint": "eslint",
18
19
  "lint:fix": "eslint --fix",
@@ -22,9 +23,11 @@
22
23
  "postpack": "shx rm -f oclif.manifest.json",
23
24
  "posttest": "npm run lint",
24
25
  "prepack": "oclif manifest && oclif readme",
25
- "test": "npm run build:types && npm run test:unit",
26
+ "test": "npm run build:types && npm run test:unit && npm run test:integration",
26
27
  "test:unit": "vitest run tests/unit",
28
+ "test:unit:watch": "vitest tests/unit",
27
29
  "test:integration": "vitest run tests/integration",
30
+ "test:integration:watch": "vitest tests/integration",
28
31
  "test:watch": "vitest",
29
32
  "version": "oclif readme && git add README.md"
30
33
  },
@@ -43,6 +46,7 @@
43
46
  "dockerode": "^4.0.7",
44
47
  "dotenv": "^17.2.1",
45
48
  "execa": "^9.6.0",
49
+ "fast-json-patch": "^3.1.1",
46
50
  "find-up": "^7.0.0",
47
51
  "glob": "^11.0.3",
48
52
  "graphlib": "^2.1.8",
@@ -111,6 +115,7 @@
111
115
  "topics": {
112
116
  "images": {"description": "List, delete, prune docker containers" },
113
117
  "containers": {"description": "List, delete, prune docker images" },
118
+ "resources": {"description": "List, clean, build resources" },
114
119
  "components": {"description": "List & build components resources" },
115
120
  "config": {"description": "It's all about config" },
116
121
  "tasks": {"description": "List and run tasks" }
@@ -1,19 +0,0 @@
1
- import { Writable } from 'node:stream';
2
- import { DockerComponentBuild } from '../index.js';
3
- import { Component } from '../../monorepo/index.js';
4
- export type MobyTrace = {
5
- aux: unknown;
6
- error?: string;
7
- id: string;
8
- };
9
- export type Progress = {
10
- error?: string;
11
- name?: string;
12
- };
13
- export type DockerBuildExtraOptions = {
14
- output?: Writable;
15
- };
16
- export type BuildDockerImageOutput = DockerComponentBuild & {
17
- traces: Array<MobyTrace>;
18
- };
19
- export declare const buildDockerImage: (component: Component, opts?: DockerBuildExtraOptions, progress?: (progress: Progress) => void) => Promise<BuildDockerImageOutput | undefined>;