@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.
Files changed (125) 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 +71 -46
  40. package/dist/src/config/schema.json +187 -97
  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 +12 -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 +62 -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 -21
  64. package/dist/src/monorepo/component.js +40 -63
  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 +77 -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 +12 -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.d.ts +1 -2
  110. package/dist/src/prerequisites/GitPrerequisitePlugin.js +3 -3
  111. package/dist/src/prerequisites/types.d.ts +2 -2
  112. package/dist/src/utils/TemplateExpander.d.ts +2 -1
  113. package/dist/src/utils/TemplateExpander.js +3 -1
  114. package/oclif.manifest.json +126 -89
  115. package/package.json +7 -2
  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 -23
  120. package/dist/src/monorepo/operations/components/BuildComponentsOperation.js +0 -157
  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,52 +134,19 @@
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": {
147
+ "rootDir": {
149
148
  "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
149
+ "description": "Path to the component's root folder (relative to root of monorepo)"
184
150
  },
185
151
  "description": {
186
152
  "type": "string",
@@ -188,39 +154,163 @@
188
154
  "description": "A description of the component."
189
155
  },
190
156
  "tasks": {
191
- "type": "array",
192
- "items": {
193
- "$ref": "#/$defs/task"
157
+ "type": "object",
158
+ "additionalProperties": {
159
+ "$ref": "#/$defs/TaskConfig"
160
+ }
161
+ },
162
+ "resources": {
163
+ "type": "object",
164
+ "additionalProperties": {
165
+ "$ref": "#/$defs/ResourceConfig"
166
+ }
167
+ },
168
+ "flavors": {
169
+ "type": "object",
170
+ "additionalProperties": {
171
+ "$ref": "#/$defs/ComponentFlavorConfig"
194
172
  }
195
173
  }
196
174
  },
197
175
  "additionalProperties": false
198
176
  },
199
- "flavor": {
177
+ "DockerImageConfig": {
200
178
  "type": "object",
201
- "required": ["name"],
202
179
  "properties": {
203
- "name": {
204
- "type": "string"
205
- },
206
- "env": {
180
+ "buildArgs": {
207
181
  "type": "object",
208
- "description": "Variables to install on the environment",
182
+ "properties": {},
209
183
  "additionalProperties": {
210
184
  "type": "string"
211
185
  }
212
186
  },
213
- "components": {
187
+ "target": {
188
+ "type": "string",
189
+ "description": "The stage to target for the build"
190
+ },
191
+ "dockerfile": {
192
+ "type": "string",
193
+ "description": "The Dockerfile to use"
194
+ }
195
+ },
196
+ "additionalProperties": false
197
+ },
198
+ "ProjectFlavorConfig": {
199
+ "type": "object",
200
+ "additionalProperties": false,
201
+ "required": [],
202
+ "properties": {
203
+ "defaults": {
204
+ "$ref": "#/$defs/DefaultsConfig"
205
+ },
206
+ "patches": {
214
207
  "type": "array",
215
208
  "items": {
216
- "$ref": "#/$defs/component"
209
+ "$ref": "#/$defs/JsonPatchOperation"
217
210
  }
218
- },
219
- "defaults": {
220
- "$ref": "#/$defs/defaults"
211
+ }
212
+ }
213
+ },
214
+ "ResourceConfig": {
215
+ "type": "object",
216
+ "required": ["type"],
217
+ "properties": {
218
+ "type": { "type": "string" },
219
+ "params": {},
220
+ "dependencies": {
221
+ "type": "array",
222
+ "items": {
223
+ "$ref": "#/$defs/QualifiedIdentifier"
224
+ },
225
+ "uniqueItems": true
221
226
  }
222
227
  },
228
+ "additionalProperties": false,
229
+ "allOf": [
230
+ {
231
+ "if": {
232
+ "properties": { "type": { "const": "docker/DockerImageConfig" } },
233
+ "required": ["type"]
234
+ },
235
+ "then": {
236
+ "properties": { "params": { "$ref": "#/$defs/DockerImageConfig" } }
237
+ },
238
+ "else": {
239
+ "properties": { "params": { "type": "object" } }
240
+ }
241
+ }
242
+ ]
243
+ },
244
+ "ComponentFlavorConfig": {
245
+ "type": "object",
246
+ "additionalProperties": false,
247
+ "required": [],
248
+ "properties": {
249
+ "patches": {
250
+ "type": "array",
251
+ "items": {
252
+ "$ref": "#/$defs/JsonPatchOperation"
253
+ }
254
+ }
255
+ }
256
+ },
257
+ "JsonPatchAddOperation": {
258
+ "type": "object",
259
+ "properties": {
260
+ "op": { "const": "add" },
261
+ "path": { "type": "string", "minLength": 1 },
262
+ "value": {}
263
+ },
264
+ "required": ["op", "path", "value"],
265
+ "additionalProperties": false
266
+ },
267
+ "JsonPatchRemoveOperation": {
268
+ "type": "object",
269
+ "properties": {
270
+ "op": { "const": "remove" },
271
+ "path": { "type": "string", "minLength": 1 }
272
+ },
273
+ "required": ["op", "path"],
223
274
  "additionalProperties": false
275
+ },
276
+ "JsonPatchReplaceOperation": {
277
+ "type": "object",
278
+ "properties": {
279
+ "op": { "const": "replace" },
280
+ "path": { "type": "string", "minLength": 1 },
281
+ "value": {}
282
+ },
283
+ "required": ["op", "path", "value"],
284
+ "additionalProperties": false
285
+ },
286
+ "JsonPatchMoveOperation": {
287
+ "type": "object",
288
+ "properties": {
289
+ "op": { "const": "move" },
290
+ "path": { "type": "string", "minLength": 1 },
291
+ "from": { "type": "string", "minLength": 1 }
292
+ },
293
+ "required": ["op", "path", "from"],
294
+ "additionalProperties": false
295
+ },
296
+ "JsonPatchCopyOperation": {
297
+ "type": "object",
298
+ "properties": {
299
+ "op": { "const": "copy" },
300
+ "path": { "type": "string", "minLength": 1 },
301
+ "from": { "type": "string", "minLength": 1 }
302
+ },
303
+ "required": ["op", "path", "from"],
304
+ "additionalProperties": false
305
+ },
306
+ "JsonPatchOperation": {
307
+ "oneOf": [
308
+ { "$ref": "#/$defs/JsonPatchAddOperation" },
309
+ { "$ref": "#/$defs/JsonPatchRemoveOperation" },
310
+ { "$ref": "#/$defs/JsonPatchReplaceOperation" },
311
+ { "$ref": "#/$defs/JsonPatchMoveOperation" },
312
+ { "$ref": "#/$defs/JsonPatchCopyOperation" }
313
+ ]
224
314
  }
225
315
  }
226
316
  }
@@ -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,15 @@ 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
+ if (!component) {
47
+ return {};
48
+ }
46
49
  if (!validate(component)) {
47
- ajv.errors.forEach((err) => console.error(err));
50
+ ajv.errors?.forEach((err) => console.error(err));
48
51
  throw new Error(`Your .emb.yml is incorrect`);
49
52
  }
50
53
  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,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 {};
@@ -4,29 +4,35 @@ import { AbstractOperation } from '../../../operations/index.js';
4
4
  /**
5
5
  * https://docs.docker.com/reference/api/engine/version/v1.37/#tag/Image/operation/ImageBuild
6
6
  */
7
- const schema = z.object({
8
- buildArgs: z
9
- .record(z.string(), z.string())
10
- .optional()
11
- .describe('Map of string pairs for build-time variables'),
7
+ export const BuildImageOperationInputSchema = z.object({
8
+ //
12
9
  context: z.string().describe('Path to the build context'),
13
10
  dockerfile: z
14
11
  .string()
15
- .describe('Path within the build context to the Dockerfile.'),
16
- labels: z
17
- .record(z.string(), z.string())
18
12
  .optional()
19
- .describe('Arbitrary key/value labels to set on the image, as a JSON map of string pairs.'),
13
+ .default('Dockerfile')
14
+ .describe('Path within the build context to the Dockerfile.'),
20
15
  src: z.array(z.string()),
21
16
  tag: z.z
22
17
  .string()
18
+ .optional()
19
+ .describe('latest')
23
20
  .describe('A name and optional tag to apply to the image in the name:tag'),
21
+ //
22
+ buildArgs: z
23
+ .record(z.string(), z.string())
24
+ .optional()
25
+ .describe('Map of string pairs for build-time variables'),
26
+ labels: z
27
+ .record(z.string(), z.string())
28
+ .optional()
29
+ .describe('Arbitrary key/value labels to set on the image, as a JSON map of string pairs.'),
24
30
  target: z.string().optional().describe('Target build stage'),
25
31
  });
26
32
  export class BuildImageOperation extends AbstractOperation {
27
33
  observer;
28
34
  constructor(observer) {
29
- super(schema);
35
+ super(BuildImageOperationInputSchema);
30
36
  this.observer = observer;
31
37
  }
32
38
  async _run(input) {