@enspirit/emb 0.0.8 → 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 (125) hide show
  1. package/README.md +50 -27
  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 +4 -3
  24. package/dist/src/cli/commands/resources/build.js +42 -0
  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/compose/operations/ComposeUpOperation.js +13 -12
  48. package/dist/src/docker/images/index.d.ts +0 -1
  49. package/dist/src/docker/images/index.js +0 -1
  50. package/dist/src/docker/index.d.ts +1 -1
  51. package/dist/src/docker/index.js +1 -1
  52. package/dist/src/docker/operations/containers/ExecContainerOperation.js +2 -1
  53. package/dist/src/docker/operations/images/BuildImageOperation.d.ts +7 -8
  54. package/dist/src/docker/operations/images/BuildImageOperation.js +17 -11
  55. package/dist/src/docker/resources/DockerImageResource.js +56 -0
  56. package/dist/src/docker/resources/index.d.ts +1 -0
  57. package/dist/src/docker/resources/index.js +1 -0
  58. package/dist/src/docker/utils.d.ts +1 -7
  59. package/dist/src/docker/utils.js +3 -7
  60. package/dist/src/errors.d.ts +9 -6
  61. package/dist/src/errors.js +15 -9
  62. package/dist/src/index.d.ts +2 -0
  63. package/dist/src/index.js +2 -0
  64. package/dist/src/monorepo/component.d.ts +14 -19
  65. package/dist/src/monorepo/component.js +42 -58
  66. package/dist/src/monorepo/config.d.ts +13 -15
  67. package/dist/src/monorepo/config.js +15 -46
  68. package/dist/src/monorepo/index.d.ts +1 -0
  69. package/dist/src/monorepo/index.js +1 -0
  70. package/dist/src/monorepo/monorepo.d.ts +13 -10
  71. package/dist/src/monorepo/monorepo.js +78 -19
  72. package/dist/src/monorepo/operations/components/index.d.ts +0 -1
  73. package/dist/src/monorepo/operations/components/index.js +0 -1
  74. package/dist/src/monorepo/operations/fs/CreateFileOperation.d.ts +11 -0
  75. package/dist/src/monorepo/operations/fs/CreateFileOperation.js +31 -0
  76. package/dist/src/monorepo/operations/fs/index.d.ts +1 -0
  77. package/dist/src/monorepo/operations/fs/index.js +1 -0
  78. package/dist/src/monorepo/operations/index.d.ts +1 -0
  79. package/dist/src/monorepo/operations/index.js +1 -0
  80. package/dist/src/monorepo/operations/resources/BuildResourcesOperation.d.ts +27 -0
  81. package/dist/src/monorepo/operations/resources/BuildResourcesOperation.js +146 -0
  82. package/dist/src/monorepo/operations/tasks/RunTasksOperation.js +5 -13
  83. package/dist/src/monorepo/plugins/{ComponentDiscoverPlugin.d.ts → AutoDockerPlugin.d.ts} +4 -4
  84. package/dist/src/monorepo/plugins/AutoDockerPlugin.js +46 -0
  85. package/dist/src/monorepo/plugins/EmbfileLoaderPlugin.js +9 -2
  86. package/dist/src/monorepo/plugins/index.d.ts +1 -1
  87. package/dist/src/monorepo/plugins/index.js +3 -3
  88. package/dist/src/monorepo/resources/FileResource.d.ts +1 -0
  89. package/dist/src/monorepo/resources/FileResource.js +13 -0
  90. package/dist/src/monorepo/resources/ResourceFactory.d.ts +23 -0
  91. package/dist/src/monorepo/resources/ResourceFactory.js +16 -0
  92. package/dist/src/monorepo/resources/index.d.ts +1 -0
  93. package/dist/src/monorepo/resources/index.js +1 -0
  94. package/dist/src/monorepo/store/index.d.ts +1 -1
  95. package/dist/src/monorepo/store/index.js +10 -2
  96. package/dist/src/monorepo/taskManagerFactory.d.ts +2 -2
  97. package/dist/src/monorepo/taskManagerFactory.js +2 -2
  98. package/dist/src/monorepo/types.d.ts +18 -5
  99. package/dist/src/monorepo/utils/{findRunOrder.d.ts → EMBCollection.d.ts} +3 -9
  100. package/dist/src/monorepo/utils/EMBCollection.js +101 -0
  101. package/dist/src/monorepo/utils/graph.d.ts +15 -0
  102. package/dist/src/monorepo/utils/graph.js +84 -0
  103. package/dist/src/monorepo/utils/index.d.ts +7 -1
  104. package/dist/src/monorepo/utils/index.js +14 -1
  105. package/dist/src/monorepo/utils/types.d.ts +2 -0
  106. package/dist/src/monorepo/utils/types.js +1 -0
  107. package/dist/src/operations/abstract/AbstractOperation.d.ts +3 -1
  108. package/dist/src/operations/abstract/AbstractOperation.js +3 -0
  109. package/dist/src/operations/types.d.ts +1 -1
  110. package/dist/src/prerequisites/GitPrerequisitePlugin.js +2 -2
  111. package/dist/src/utils/TemplateExpander.d.ts +2 -1
  112. package/dist/src/utils/TemplateExpander.js +3 -1
  113. package/oclif.manifest.json +157 -112
  114. package/package.json +7 -2
  115. package/dist/src/cli/commands/components/build.js +0 -34
  116. package/dist/src/docker/images/buildImage.d.ts +0 -19
  117. package/dist/src/docker/images/buildImage.js +0 -64
  118. package/dist/src/docker/types.d.ts +0 -14
  119. package/dist/src/monorepo/operations/components/BuildComponentsOperation.d.ts +0 -21
  120. package/dist/src/monorepo/operations/components/BuildComponentsOperation.js +0 -135
  121. package/dist/src/monorepo/plugins/ComponentDiscoverPlugin.js +0 -44
  122. package/dist/src/monorepo/project.d.ts +0 -6
  123. package/dist/src/monorepo/project.js +0 -8
  124. package/dist/src/monorepo/utils/findRunOrder.js +0 -165
  125. /package/dist/src/docker/{types.js → resources/DockerImageResource.d.ts} +0 -0
@@ -1,34 +1,25 @@
1
1
  {
2
2
  "$id": "/schemas/config",
3
3
  "$schema": "http://json-schema.org/draft-07/schema#",
4
- "title": "EMB Config Schema",
4
+ "title": "EMBConfig",
5
5
  "type": "object",
6
+ "additionalProperties": false,
6
7
  "properties": {
7
8
  "project": {
8
- "oneOf": [
9
- {
10
- "type": "string",
11
- "minLength": 3,
12
- "description": "Shortcut for specifying the project name."
9
+ "type": "object",
10
+ "required": ["name"],
11
+ "properties": {
12
+ "name": {
13
+ "$ref": "#/$defs/Identifier",
14
+ "description": "The name of the project."
13
15
  },
14
- {
15
- "type": "object",
16
- "required": ["name"],
17
- "properties": {
18
- "name": {
19
- "type": "string",
20
- "minLength": 3,
21
- "description": "The name of the project."
22
- },
23
- "rootDir": {
24
- "type": "string",
25
- "minLength": 1,
26
- "description": "The root directory of the project."
27
- }
28
- },
29
- "additionalProperties": false
16
+ "rootDir": {
17
+ "type": "string",
18
+ "minLength": 1,
19
+ "description": "The root directory of the project."
30
20
  }
31
- ]
21
+ },
22
+ "additionalProperties": false
32
23
  },
33
24
  "plugins": {
34
25
  "type": "array",
@@ -37,7 +28,7 @@
37
28
  "required": ["name"],
38
29
  "properties": {
39
30
  "name": {
40
- "type": "string"
31
+ "$ref": "#/$defs/Identifier"
41
32
  },
42
33
  "config": {}
43
34
  },
@@ -57,31 +48,38 @@
57
48
  "additionalProperties": true
58
49
  },
59
50
  "defaults": {
60
- "$ref": "#/$defs/defaults"
51
+ "$ref": "#/$defs/DefaultsConfig"
61
52
  },
62
53
  "components": {
63
- "type": "array",
64
- "items": {
65
- "$ref": "#/$defs/component"
54
+ "type": "object",
55
+ "additionalProperties": {
56
+ "$ref": "#/$defs/ComponentConfig"
66
57
  }
67
58
  },
68
59
  "flavors": {
69
- "type": "array",
70
- "items": {
71
- "$ref": "#/$defs/flavor"
60
+ "type": "object",
61
+ "additionalProperties": {
62
+ "$ref": "#/$defs/ProjectFlavorConfig"
72
63
  }
73
64
  },
74
65
  "tasks": {
75
- "type": "array",
76
- "items": {
77
- "$ref": "#/$defs/task"
66
+ "type": "object",
67
+ "additionalProperties": {
68
+ "$ref": "#/$defs/TaskConfig"
78
69
  }
79
70
  }
80
71
  },
81
72
  "required": ["project"],
82
- "additionalProperties": false,
83
73
  "$defs": {
84
- "defaults": {
74
+ "Identifier": {
75
+ "type": "string",
76
+ "pattern": "^[a-zA-Z]+[\\w._-]+$"
77
+ },
78
+ "QualifiedIdentifier": {
79
+ "type": "string",
80
+ "pattern": "^([a-zA-Z]+[\\w._-]+:)?[a-zA-Z]+[\\w._-]+$"
81
+ },
82
+ "DefaultsConfig": {
85
83
  "type": "object",
86
84
  "description": "Default settings for build aspects",
87
85
  "additionalProperties": false,
@@ -90,8 +88,12 @@
90
88
  "type": "object",
91
89
  "description": "Default docker build settings",
92
90
  "properties": {
93
- "tag": { "type": "string" },
94
- "target": { "type": "string" },
91
+ "tag": {
92
+ "type": "string"
93
+ },
94
+ "target": {
95
+ "$ref": "#/$defs/Identifier"
96
+ },
95
97
  "buildArgs": {
96
98
  "type": "object",
97
99
  "additionalProperties": {
@@ -108,17 +110,14 @@
108
110
  }
109
111
  }
110
112
  },
111
- "task": {
113
+ "TaskConfig": {
112
114
  "type": "object",
113
- "required": ["name"],
115
+ "required": [],
114
116
  "anyOf": [
115
117
  { "required": ["script"] },
116
118
  { "required": ["pre"] }
117
119
  ],
118
120
  "properties": {
119
- "name": {
120
- "type": "string"
121
- },
122
121
  "description": {
123
122
  "type": "string"
124
123
  },
@@ -126,7 +125,7 @@
126
125
  "type": "string"
127
126
  },
128
127
  "executor": {
129
- "type": "string"
128
+ "$ref": "#/$defs/Identifier"
130
129
  },
131
130
  "options": {
132
131
  "type": "object",
@@ -135,92 +134,179 @@
135
134
  "pre": {
136
135
  "type": "array",
137
136
  "items": {
138
- "type": "string"
137
+ "$ref": "#/$defs/Identifier"
139
138
  }
140
139
  }
141
140
  },
142
141
  "additionalProperties": false
143
142
  },
144
- "component": {
143
+ "ComponentConfig": {
145
144
  "type": "object",
146
- "required": ["name"],
145
+ "required": [],
147
146
  "properties": {
148
- "name": {
149
- "type": "string",
150
- "minLength": 3,
151
- "description": "The name of the component."
152
- },
153
- "docker": {
154
- "type": "object",
155
- "properties": {
156
- "context": {
157
- "type": "string",
158
- "minLength": 1,
159
- "description": "The directory of the component."
160
- },
161
- "buildArgs": {
162
- "type": "object",
163
- "properties": {},
164
- "additionalProperties": {
165
- "type": "string"
166
- }
167
- },
168
- "dependencies": {
169
- "type": "array",
170
- "items": {
171
- "type": "string"
172
- }
173
- },
174
- "target": {
175
- "type": "string",
176
- "description": "The stage to target for the build"
177
- },
178
- "dockerfile": {
179
- "type": "string",
180
- "description": "The Dockerfile to use"
181
- }
182
- },
183
- "additionalProperties": false
184
- },
185
147
  "description": {
186
148
  "type": "string",
187
149
  "minLength": 1,
188
150
  "description": "A description of the component."
189
151
  },
190
152
  "tasks": {
191
- "type": "array",
192
- "items": {
193
- "$ref": "#/$defs/task"
153
+ "type": "object",
154
+ "additionalProperties": {
155
+ "$ref": "#/$defs/TaskConfig"
156
+ }
157
+ },
158
+ "resources": {
159
+ "type": "object",
160
+ "additionalProperties": {
161
+ "$ref": "#/$defs/ResourceConfig"
162
+ }
163
+ },
164
+ "flavors": {
165
+ "type": "object",
166
+ "additionalProperties": {
167
+ "$ref": "#/$defs/ComponentFlavorConfig"
194
168
  }
195
169
  }
196
170
  },
197
171
  "additionalProperties": false
198
172
  },
199
- "flavor": {
173
+ "DockerImageConfig": {
200
174
  "type": "object",
201
- "required": ["name"],
202
175
  "properties": {
203
- "name": {
204
- "type": "string"
205
- },
206
- "env": {
176
+ "buildArgs": {
207
177
  "type": "object",
208
- "description": "Variables to install on the environment",
178
+ "properties": {},
209
179
  "additionalProperties": {
210
180
  "type": "string"
211
181
  }
212
182
  },
213
- "components": {
183
+ "target": {
184
+ "type": "string",
185
+ "description": "The stage to target for the build"
186
+ },
187
+ "dockerfile": {
188
+ "type": "string",
189
+ "description": "The Dockerfile to use"
190
+ }
191
+ },
192
+ "additionalProperties": false
193
+ },
194
+ "ProjectFlavorConfig": {
195
+ "type": "object",
196
+ "additionalProperties": false,
197
+ "required": [],
198
+ "properties": {
199
+ "defaults": {
200
+ "$ref": "#/$defs/DefaultsConfig"
201
+ },
202
+ "patches": {
214
203
  "type": "array",
215
204
  "items": {
216
- "$ref": "#/$defs/component"
205
+ "$ref": "#/$defs/JsonPatchOperation"
206
+ }
207
+ }
208
+ }
209
+ },
210
+ "ResourceConfig": {
211
+ "type": "object",
212
+ "required": ["type"],
213
+ "properties": {
214
+ "type": { "type": "string" },
215
+ "params": {},
216
+ "dependencies": {
217
+ "type": "array",
218
+ "items": {
219
+ "$ref": "#/$defs/QualifiedIdentifier"
220
+ },
221
+ "uniqueItems": true
222
+ }
223
+ },
224
+ "additionalProperties": false,
225
+ "allOf": [
226
+ {
227
+ "if": {
228
+ "properties": { "type": { "const": "docker/DockerImageConfig" } },
229
+ "required": ["type"]
230
+ },
231
+ "then": {
232
+ "properties": { "params": { "$ref": "#/$defs/DockerImageConfig" } }
233
+ },
234
+ "else": {
235
+ "properties": { "params": { "type": "object" } }
236
+ }
237
+ }
238
+ ]
239
+ },
240
+ "ComponentFlavorConfig": {
241
+ "type": "object",
242
+ "additionalProperties": false,
243
+ "required": [],
244
+ "properties": {
245
+ "patches": {
246
+ "type": "array",
247
+ "items": {
248
+ "$ref": "#/$defs/JsonPatchOperation"
217
249
  }
218
- },
219
- "defaults": {
220
- "$ref": "#/$defs/defaults"
221
250
  }
251
+ }
252
+ },
253
+ "JsonPatchAddOperation": {
254
+ "type": "object",
255
+ "properties": {
256
+ "op": { "const": "add" },
257
+ "path": { "type": "string", "minLength": 1 },
258
+ "value": {}
259
+ },
260
+ "required": ["op", "path", "value"],
261
+ "additionalProperties": false
262
+ },
263
+ "JsonPatchRemoveOperation": {
264
+ "type": "object",
265
+ "properties": {
266
+ "op": { "const": "remove" },
267
+ "path": { "type": "string", "minLength": 1 }
222
268
  },
269
+ "required": ["op", "path"],
223
270
  "additionalProperties": false
271
+ },
272
+ "JsonPatchReplaceOperation": {
273
+ "type": "object",
274
+ "properties": {
275
+ "op": { "const": "replace" },
276
+ "path": { "type": "string", "minLength": 1 },
277
+ "value": {}
278
+ },
279
+ "required": ["op", "path", "value"],
280
+ "additionalProperties": false
281
+ },
282
+ "JsonPatchMoveOperation": {
283
+ "type": "object",
284
+ "properties": {
285
+ "op": { "const": "move" },
286
+ "path": { "type": "string", "minLength": 1 },
287
+ "from": { "type": "string", "minLength": 1 }
288
+ },
289
+ "required": ["op", "path", "from"],
290
+ "additionalProperties": false
291
+ },
292
+ "JsonPatchCopyOperation": {
293
+ "type": "object",
294
+ "properties": {
295
+ "op": { "const": "copy" },
296
+ "path": { "type": "string", "minLength": 1 },
297
+ "from": { "type": "string", "minLength": 1 }
298
+ },
299
+ "required": ["op", "path", "from"],
300
+ "additionalProperties": false
301
+ },
302
+ "JsonPatchOperation": {
303
+ "oneOf": [
304
+ { "$ref": "#/$defs/JsonPatchAddOperation" },
305
+ { "$ref": "#/$defs/JsonPatchRemoveOperation" },
306
+ { "$ref": "#/$defs/JsonPatchReplaceOperation" },
307
+ { "$ref": "#/$defs/JsonPatchMoveOperation" },
308
+ { "$ref": "#/$defs/JsonPatchCopyOperation" }
309
+ ]
224
310
  }
225
311
  }
226
312
  }
@@ -1,47 +1,14 @@
1
- import { EMBConfigSchema, Task } from './schema.js';
2
- export type UserConfig = EMBConfigSchema;
3
- export type IProjectConfig = {
4
- name: string;
5
- rootDir: string;
6
- };
7
- export type ComponentConfig = {
8
- name: string;
9
- docker?: {
10
- buildArgs?: Record<string, string>;
11
- context?: string;
12
- dependencies?: Array<string>;
13
- dockerfile?: string;
14
- labels?: Record<string, string>;
15
- target?: string;
16
- };
17
- tasks?: Array<Task>;
18
- };
19
- export type DefaultSettings = {
20
- docker?: {
21
- buildArgs?: Record<string, string>;
22
- labels?: Record<string, string>;
23
- tag?: string;
24
- target?: string;
25
- };
26
- };
27
- export type FlavorConfig = {
28
- components?: Array<ComponentConfig>;
29
- defaults?: DefaultSettings;
30
- env?: Record<string, string>;
31
- name: string;
32
- };
33
- export type PluginConfig = {
34
- config?: unknown;
35
- name: string;
36
- };
37
- export type IMonorepoConfig = {
38
- currentFlavor?: string;
39
- components: Array<ComponentConfig>;
40
- defaults?: DefaultSettings;
41
- env?: Record<string, string>;
42
- flavors?: Array<FlavorConfig>;
43
- plugins?: Array<PluginConfig>;
44
- project: IProjectConfig;
45
- tasks?: Array<Task>;
46
- vars?: Record<string, unknown>;
1
+ import { EMBConfig, ResourceConfig } from './schema.js';
2
+ export * from './schema.js';
3
+ type RemoveIndexSignature<T> = {
4
+ [K in keyof T as K extends string ? (string extends K ? never : K) : K]: T[K];
5
+ };
6
+ export type ProjectConfig = Required<EMBConfig['project']>;
7
+ export type UserConfig = EMBConfig & {
8
+ project: ProjectConfig;
9
+ };
10
+ export type PluginConfig = Required<EMBConfig>['plugins'][number];
11
+ export type IResourceConfig = RemoveIndexSignature<ResourceConfig>;
12
+ export type QualifiedResourceConfig = IResourceConfig & {
13
+ id: string;
47
14
  };
@@ -1 +1 @@
1
- export {};
1
+ export * from './schema.js';
@@ -1,3 +1,3 @@
1
- import { Component } from './schema.js';
2
- export declare const validateUserConfig: (pathOrObject: string | unknown) => Promise<import("./types.js").IMonorepoConfig>;
3
- export declare const validateEmbfile: (pathOrObject: string | unknown) => Promise<Component>;
1
+ import { ComponentConfig, UserConfig } from './types.js';
2
+ export declare const validateUserConfig: (pathOrObject: string | unknown) => Promise<UserConfig>;
3
+ export declare const validateEmbfile: (pathOrObject: string | unknown) => Promise<ComponentConfig>;
@@ -1,29 +1,29 @@
1
1
  import { Ajv } from 'ajv';
2
2
  import { readFile, stat } from 'node:fs/promises';
3
3
  import yaml from 'yaml';
4
- import { toProjectConfig } from './convert.js';
4
+ import { toUserConfig } from './convert.js';
5
5
  import configSchema from './schema.json' with { type: 'json' };
6
6
  const ajv = new Ajv();
7
7
  ajv.addSchema(configSchema);
8
8
  export const validateUserConfig = async (pathOrObject) => {
9
- let userConfig;
9
+ let embConfig;
10
10
  if (typeof pathOrObject === 'string') {
11
11
  if (await stat(pathOrObject)) {
12
12
  const cfgYaml = (await readFile(pathOrObject)).toString();
13
- userConfig = yaml.parse(cfgYaml.toString());
13
+ embConfig = yaml.parse(cfgYaml.toString());
14
14
  }
15
15
  else {
16
16
  throw new Error(`Could not find file: ${pathOrObject}`);
17
17
  }
18
18
  }
19
19
  else {
20
- userConfig = pathOrObject;
20
+ embConfig = pathOrObject;
21
21
  }
22
- if (!ajv.validate(configSchema, userConfig)) {
23
- ajv.errors.forEach((err) => console.error(err));
22
+ if (!ajv.validate(configSchema, embConfig)) {
23
+ ajv.errors?.forEach((err) => console.error(err));
24
24
  throw new Error(`Your .emb.yml is incorrect`);
25
25
  }
26
- return toProjectConfig(userConfig);
26
+ return toUserConfig(embConfig);
27
27
  };
28
28
  export const validateEmbfile = async (pathOrObject) => {
29
29
  let component;
@@ -39,12 +39,12 @@ export const validateEmbfile = async (pathOrObject) => {
39
39
  else {
40
40
  component = pathOrObject;
41
41
  }
42
- const validate = ajv.getSchema('/schemas/config#/$defs/component');
42
+ const validate = ajv.getSchema('/schemas/config#/$defs/ComponentConfig');
43
43
  if (!validate) {
44
44
  throw new Error('Could not find the JSON schema validator for Embfile');
45
45
  }
46
46
  if (!validate(component)) {
47
- ajv.errors.forEach((err) => console.error(err));
47
+ ajv.errors?.forEach((err) => console.error(err));
48
48
  throw new Error(`Your .emb.yml is incorrect`);
49
49
  }
50
50
  return component;
@@ -1,3 +1,3 @@
1
1
  import { EmbContext } from './types.js';
2
2
  export declare const getContext: () => EmbContext;
3
- export declare const setContext: (ctx: EmbContext) => void;
3
+ export declare const setContext: (ctx: EmbContext) => EmbContext;
@@ -4,4 +4,5 @@ export const getContext = () => {
4
4
  };
5
5
  export const setContext = (ctx) => {
6
6
  context = ctx;
7
+ return ctx;
7
8
  };
@@ -1,7 +1,6 @@
1
1
  import { getContext } from '../../../index.js';
2
- import { Listr } from 'listr2';
3
2
  import * as z from 'zod';
4
- import { ExecuteLocalCommandOperation } from '../../../monorepo/index.js';
3
+ import { ExecuteLocalCommandOperation, taskManagerFactory } from '../../../monorepo/index.js';
5
4
  import { AbstractOperation } from '../../../operations/index.js';
6
5
  /**
7
6
  * https://docs.docker.com/reference/cli/docker/compose/up/
@@ -20,20 +19,22 @@ export class ComposeUpOperation extends AbstractOperation {
20
19
  }
21
20
  async _run(input) {
22
21
  const { monorepo } = getContext();
22
+ const manager = taskManagerFactory();
23
23
  const command = ['docker', 'compose', 'up', '-d'];
24
24
  if (input?.forceRecreate) {
25
25
  command.push('--force-recreate');
26
26
  }
27
- const task = new Listr({
28
- rendererOptions: { persistentOutput: true },
29
- async task() {
30
- return monorepo.run(new ExecuteLocalCommandOperation(), {
31
- script: command.join(' '),
32
- workingDir: monorepo.rootDir,
33
- });
27
+ manager.add([
28
+ {
29
+ async task() {
30
+ return monorepo.run(new ExecuteLocalCommandOperation(), {
31
+ script: command.join(' '),
32
+ workingDir: monorepo.rootDir,
33
+ });
34
+ },
35
+ title: 'Starting project',
34
36
  },
35
- title: 'Starting project',
36
- });
37
- await task.run();
37
+ ]);
38
+ await manager.runAll();
38
39
  }
39
40
  }
@@ -1,4 +1,3 @@
1
- export * from './buildImage.js';
2
1
  export * from './deleteImage.js';
3
2
  export * from './listImages.js';
4
3
  export * from './pruneImages.js';
@@ -1,4 +1,3 @@
1
- export * from './buildImage.js';
2
1
  export * from './deleteImage.js';
3
2
  export * from './listImages.js';
4
3
  export * from './pruneImages.js';
@@ -1,7 +1,7 @@
1
+ import './resources/index.js';
1
2
  export * from './compose/index.js';
2
3
  export * from './containers/index.js';
3
4
  export * from './images/index.js';
4
5
  export * from './operations/index.js';
5
6
  export * from './protobuf/index.js';
6
- export * from './types.js';
7
7
  export * from './utils.js';
@@ -1,7 +1,7 @@
1
+ import './resources/index.js';
1
2
  export * from './compose/index.js';
2
3
  export * from './containers/index.js';
3
4
  export * from './images/index.js';
4
5
  export * from './operations/index.js';
5
6
  export * from './protobuf/index.js';
6
- export * from './types.js';
7
7
  export * from './utils.js';
@@ -58,8 +58,9 @@ export class ContainerExecOperation extends AbstractOperation {
58
58
  const onError = (err) => reject(err);
59
59
  const onEnd = async () => {
60
60
  exec.inspect((error, res) => {
61
- if (error)
61
+ if (error) {
62
62
  return reject(error);
63
+ }
63
64
  const code = res?.ExitCode ?? 0;
64
65
  if (code !== 0) {
65
66
  const msg = res?.ProcessConfig?.entrypoint
@@ -3,18 +3,17 @@ import { AbstractOperation } from '../../../operations/index.js';
3
3
  /**
4
4
  * https://docs.docker.com/reference/api/engine/version/v1.37/#tag/Image/operation/ImageBuild
5
5
  */
6
- declare const schema: z.ZodObject<{
7
- buildArgs: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
6
+ export declare const BuildImageOperationInputSchema: z.ZodObject<{
8
7
  context: z.ZodString;
9
- dockerfile: z.ZodString;
10
- labels: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
8
+ dockerfile: z.ZodDefault<z.ZodOptional<z.ZodString>>;
11
9
  src: z.ZodArray<z.ZodString>;
12
- tag: z.ZodString;
10
+ tag: z.ZodOptional<z.ZodString>;
11
+ buildArgs: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
12
+ labels: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
13
13
  target: z.ZodOptional<z.ZodString>;
14
14
  }, z.core.$strip>;
15
- export declare class BuildImageOperation extends AbstractOperation<typeof schema, Array<unknown>> {
15
+ export declare class BuildImageOperation extends AbstractOperation<typeof BuildImageOperationInputSchema, Array<unknown>> {
16
16
  private observer?;
17
17
  constructor(observer?: ((progress: string) => void) | undefined);
18
- protected _run(input: z.input<typeof schema>): Promise<Array<unknown>>;
18
+ protected _run(input: z.input<typeof BuildImageOperationInputSchema>): Promise<Array<unknown>>;
19
19
  }
20
- export {};