@enspirit/emb 0.0.2 → 0.0.4

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 (164) hide show
  1. package/README.md +190 -164
  2. package/bin/run.js +8 -2
  3. package/dist/src/cli/abstract/FlavouredCommand.d.ts +12 -0
  4. package/dist/src/cli/abstract/FlavouredCommand.js +40 -0
  5. package/dist/src/cli/abstract/index.d.ts +1 -0
  6. package/dist/src/cli/abstract/index.js +1 -0
  7. package/dist/src/cli/commands/clean.d.ts +15 -0
  8. package/dist/src/cli/commands/clean.js +29 -0
  9. package/dist/src/cli/commands/components/build.d.ts +11 -0
  10. package/dist/src/cli/commands/components/build.js +24 -0
  11. package/dist/src/cli/commands/components/index.d.ts +14 -0
  12. package/dist/src/cli/commands/components/index.js +44 -0
  13. package/dist/src/cli/commands/config/print.d.ts +13 -0
  14. package/dist/src/cli/commands/config/print.js +16 -0
  15. package/dist/src/cli/commands/containers/index.d.ts +12 -0
  16. package/dist/src/cli/commands/containers/index.js +66 -0
  17. package/dist/src/cli/commands/containers/prune.d.ts +8 -0
  18. package/dist/src/cli/commands/containers/prune.js +23 -0
  19. package/dist/src/cli/commands/down.d.ts +8 -0
  20. package/dist/src/cli/commands/down.js +42 -0
  21. package/dist/src/cli/commands/images/delete.d.ts +10 -0
  22. package/dist/src/cli/commands/images/delete.js +44 -0
  23. package/dist/src/cli/commands/images/index.d.ts +17 -0
  24. package/dist/src/cli/commands/images/index.js +59 -0
  25. package/dist/src/cli/commands/images/prune.d.ts +11 -0
  26. package/dist/src/cli/commands/images/prune.js +35 -0
  27. package/dist/src/cli/commands/run/index.d.ts +10 -0
  28. package/dist/src/cli/commands/run/index.js +49 -0
  29. package/dist/src/cli/commands/tasks/index.d.ts +9 -0
  30. package/dist/src/cli/commands/tasks/index.js +23 -0
  31. package/dist/src/cli/commands/tasks/run.d.ts +16 -0
  32. package/dist/src/cli/commands/tasks/run.js +113 -0
  33. package/dist/src/cli/commands/up.d.ts +10 -0
  34. package/dist/src/cli/commands/up.js +49 -0
  35. package/dist/src/cli/constants.d.ts +2 -0
  36. package/dist/src/cli/constants.js +6 -0
  37. package/dist/src/cli/hooks/init.d.ts +3 -0
  38. package/dist/src/cli/hooks/init.js +27 -0
  39. package/dist/src/cli/index.d.ts +3 -0
  40. package/dist/src/cli/index.js +3 -0
  41. package/dist/src/config/convert.d.ts +5 -0
  42. package/dist/src/config/convert.js +48 -0
  43. package/dist/src/config/index.d.ts +6 -0
  44. package/dist/src/config/index.js +25 -0
  45. package/dist/src/config/schema.d.ts +102 -0
  46. package/dist/src/config/schema.js +7 -0
  47. package/dist/src/config/schema.json +209 -0
  48. package/dist/src/config/types.d.ts +43 -0
  49. package/dist/src/config/types.js +1 -0
  50. package/dist/src/config/validation.d.ts +1 -0
  51. package/dist/src/config/validation.js +26 -0
  52. package/dist/src/context.d.ts +3 -0
  53. package/dist/src/context.js +7 -0
  54. package/dist/src/docker/compose/index.d.ts +7 -0
  55. package/dist/src/docker/compose/index.js +13 -0
  56. package/dist/src/docker/containers/getContainer.d.ts +2 -0
  57. package/dist/src/docker/containers/getContainer.js +5 -0
  58. package/dist/src/docker/containers/index.d.ts +1 -0
  59. package/dist/src/docker/containers/index.js +1 -0
  60. package/dist/src/docker/images/buildImage.d.ts +19 -0
  61. package/dist/src/docker/images/buildImage.js +64 -0
  62. package/dist/src/docker/images/deleteImage.d.ts +5 -0
  63. package/dist/src/docker/images/deleteImage.js +6 -0
  64. package/dist/src/docker/images/index.d.ts +4 -0
  65. package/dist/src/docker/images/index.js +4 -0
  66. package/dist/src/docker/images/listImages.d.ts +2 -0
  67. package/dist/src/docker/images/listImages.js +8 -0
  68. package/dist/src/docker/images/pruneImages.d.ts +6 -0
  69. package/dist/src/docker/images/pruneImages.js +8 -0
  70. package/dist/src/docker/index.d.ts +7 -0
  71. package/dist/src/docker/index.js +7 -0
  72. package/dist/src/docker/operations/containers/ListContainersOperation.d.ts +18 -0
  73. package/dist/src/docker/operations/containers/ListContainersOperation.js +44 -0
  74. package/dist/src/docker/operations/containers/PruneContainersOperation.d.ts +16 -0
  75. package/dist/src/docker/operations/containers/PruneContainersOperation.js +33 -0
  76. package/dist/src/docker/operations/containers/index.d.ts +2 -0
  77. package/dist/src/docker/operations/containers/index.js +2 -0
  78. package/dist/src/docker/operations/images/BuildImageOperation.d.ts +20 -0
  79. package/dist/src/docker/operations/images/BuildImageOperation.js +69 -0
  80. package/dist/src/docker/operations/images/ListImagesOperation.d.ts +17 -0
  81. package/dist/src/docker/operations/images/ListImagesOperation.js +38 -0
  82. package/dist/src/docker/operations/images/PruneImagesOperation.d.ts +16 -0
  83. package/dist/src/docker/operations/images/PruneImagesOperation.js +33 -0
  84. package/dist/src/docker/operations/images/index.d.ts +3 -0
  85. package/dist/src/docker/operations/images/index.js +3 -0
  86. package/dist/src/docker/operations/index.d.ts +2 -0
  87. package/dist/src/docker/operations/index.js +2 -0
  88. package/dist/src/docker/protobuf/control.proto +48 -0
  89. package/dist/src/docker/protobuf/index.d.ts +5 -0
  90. package/dist/src/docker/protobuf/index.js +29 -0
  91. package/dist/src/docker/types.d.ts +14 -0
  92. package/dist/src/docker/types.js +1 -0
  93. package/dist/src/docker/utils.d.ts +7 -0
  94. package/dist/src/docker/utils.js +10 -0
  95. package/dist/src/executors/docker.d.ts +6 -0
  96. package/dist/src/executors/docker.js +14 -0
  97. package/dist/src/executors/index.d.ts +6 -0
  98. package/dist/src/executors/index.js +7 -0
  99. package/dist/src/executors/shell.d.ts +2 -0
  100. package/dist/src/executors/shell.js +14 -0
  101. package/dist/src/executors/types.d.ts +8 -0
  102. package/dist/src/executors/types.js +1 -0
  103. package/dist/src/index.d.ts +3 -0
  104. package/dist/src/index.js +3 -0
  105. package/dist/src/monorepo/component.d.ts +24 -0
  106. package/dist/src/monorepo/component.js +77 -0
  107. package/dist/src/monorepo/config.d.ts +16 -0
  108. package/dist/src/monorepo/config.js +66 -0
  109. package/dist/src/monorepo/index.d.ts +7 -0
  110. package/dist/src/monorepo/index.js +7 -0
  111. package/dist/src/monorepo/monorepo.d.ts +29 -0
  112. package/dist/src/monorepo/monorepo.js +106 -0
  113. package/dist/src/monorepo/operations/components/BuildComponentsOperation.d.ts +11 -0
  114. package/dist/src/monorepo/operations/components/BuildComponentsOperation.js +144 -0
  115. package/dist/src/monorepo/operations/components/index.d.ts +1 -0
  116. package/dist/src/monorepo/operations/components/index.js +1 -0
  117. package/dist/src/monorepo/operations/index.d.ts +1 -0
  118. package/dist/src/monorepo/operations/index.js +1 -0
  119. package/dist/src/monorepo/plugins/ComponentsDiscover.d.ts +6 -0
  120. package/dist/src/monorepo/plugins/ComponentsDiscover.js +30 -0
  121. package/dist/src/monorepo/plugins/DotEnvPlugin.d.ts +5 -0
  122. package/dist/src/monorepo/plugins/DotEnvPlugin.js +11 -0
  123. package/dist/src/monorepo/plugins/index.d.ts +7 -0
  124. package/dist/src/monorepo/plugins/index.js +20 -0
  125. package/dist/src/monorepo/plugins/plugin.d.ts +15 -0
  126. package/dist/src/monorepo/plugins/plugin.js +12 -0
  127. package/dist/src/monorepo/project.d.ts +6 -0
  128. package/dist/src/monorepo/project.js +8 -0
  129. package/dist/src/monorepo/store/index.d.ts +20 -0
  130. package/dist/src/monorepo/store/index.js +65 -0
  131. package/dist/src/monorepo/types.d.ts +7 -0
  132. package/dist/src/monorepo/types.js +1 -0
  133. package/dist/src/monorepo/utils/findBuildOrder.d.ts +2 -0
  134. package/dist/src/monorepo/utils/findBuildOrder.js +41 -0
  135. package/dist/src/monorepo/utils/index.d.ts +1 -0
  136. package/dist/src/monorepo/utils/index.js +1 -0
  137. package/dist/src/operations/abstract/AbstractOperation.d.ts +10 -0
  138. package/dist/src/operations/abstract/AbstractOperation.js +13 -0
  139. package/dist/src/operations/abstract/index.d.ts +1 -0
  140. package/dist/src/operations/abstract/index.js +1 -0
  141. package/dist/src/operations/index.d.ts +2 -0
  142. package/dist/src/operations/index.js +2 -0
  143. package/dist/src/operations/types.d.ts +3 -0
  144. package/dist/src/operations/types.js +1 -0
  145. package/dist/src/prerequisites/FilePrerequisitePlugin.d.ts +7 -0
  146. package/dist/src/prerequisites/FilePrerequisitePlugin.js +41 -0
  147. package/dist/src/prerequisites/GitPrerequisitePlugin.d.ts +5 -0
  148. package/dist/src/prerequisites/GitPrerequisitePlugin.js +17 -0
  149. package/dist/src/prerequisites/index.d.ts +3 -0
  150. package/dist/src/prerequisites/index.js +3 -0
  151. package/dist/src/prerequisites/types.d.ts +46 -0
  152. package/dist/src/prerequisites/types.js +24 -0
  153. package/dist/src/types.d.ts +13 -0
  154. package/dist/src/types.js +1 -0
  155. package/dist/src/utils/TemplateExpander.d.ts +21 -0
  156. package/dist/src/utils/TemplateExpander.js +53 -0
  157. package/dist/src/utils/deepMergeArray.d.ts +1 -0
  158. package/dist/src/utils/deepMergeArray.js +19 -0
  159. package/dist/src/utils/index.d.ts +3 -0
  160. package/dist/src/utils/index.js +3 -0
  161. package/dist/src/utils/time.d.ts +2 -0
  162. package/dist/src/utils/time.js +19 -0
  163. package/oclif.manifest.json +572 -2
  164. package/package.json +7 -9
@@ -0,0 +1,113 @@
1
+ import { getContext } from '../../../index.js';
2
+ import { Args, Command, Flags } from '@oclif/core';
3
+ import { Listr } from 'listr2';
4
+ import { PassThrough } from 'node:stream';
5
+ import { getContainer, ListContainersOperation } from '../../../docker/index.js';
6
+ import { dockerExecutor } from '../../../executors/docker.js';
7
+ import { ExecutorType } from '../../../executors/index.js';
8
+ import { shellExecutor } from '../../../executors/shell.js';
9
+ export default class RunTask extends Command {
10
+ static args = {
11
+ task: Args.string({
12
+ description: 'List of tasks ids to run (eg: component:task)',
13
+ required: false,
14
+ }),
15
+ };
16
+ static description = 'Run a task.';
17
+ static enableJsonFlag = true;
18
+ static examples = ['<%= config.bin %> <%= command.id %>'];
19
+ static flags = {
20
+ executor: Flags.string({
21
+ char: 'x',
22
+ name: 'executor',
23
+ options: Object.keys(ExecutorType),
24
+ }),
25
+ };
26
+ static strict = false;
27
+ async run() {
28
+ const { argv, flags } = await this.parse(RunTask);
29
+ const context = await getContext();
30
+ const { monorepo } = context;
31
+ const toRun = argv.length > 0
32
+ ? argv.reduce((tasks, t) => {
33
+ const found = monorepo.tasks.filter((task) => task.id === t);
34
+ if (found.length === 0) {
35
+ throw new Error(`Task ${t} not found`);
36
+ }
37
+ return [...tasks, ...found];
38
+ }, [])
39
+ : monorepo.tasks;
40
+ const runTasks = toRun.map((task) => {
41
+ return {
42
+ rendererOptions: { persistentOutput: true },
43
+ task: async (_ctx, listrTask) => {
44
+ const type = flags.executor
45
+ ? flags.executor
46
+ : ExecutorType.container;
47
+ const logStream = await monorepo.store.createWriteStream(`logs/tasks/run/${task.id}.log`);
48
+ // Gonna log on both the logStream and stdout
49
+ const tee = new PassThrough();
50
+ tee.pipe(listrTask.stdout());
51
+ tee.pipe(logStream);
52
+ switch (type) {
53
+ case ExecutorType.container: {
54
+ return this.dockerExec(task, tee);
55
+ }
56
+ case ExecutorType.local: {
57
+ return this.shellExec(task, tee);
58
+ }
59
+ default: {
60
+ throw new Error(`Unsupported executor: ${type}`);
61
+ }
62
+ }
63
+ },
64
+ title: `Running ${task.id}`,
65
+ };
66
+ });
67
+ const runner = new Listr([
68
+ {
69
+ rendererOptions: { persistentOutput: true },
70
+ async task(ctx, task) {
71
+ return task.newListr(runTasks, {
72
+ exitOnError: true,
73
+ rendererOptions: { collapseSubtasks: false },
74
+ });
75
+ },
76
+ title: 'Running tasks',
77
+ },
78
+ ]);
79
+ await runner.run();
80
+ }
81
+ async dockerExec(task, out) {
82
+ const { monorepo } = getContext();
83
+ const matching = await monorepo.run(new ListContainersOperation(), {
84
+ filters: {
85
+ label: [
86
+ `emb/project=${monorepo.name}`,
87
+ `emb/component=${task.component}`,
88
+ ],
89
+ },
90
+ });
91
+ if (matching.length === 0) {
92
+ throw new Error(`Could not find a running container for '${task.component}'`);
93
+ }
94
+ if (matching.length > 1) {
95
+ throw new Error(`More than one running container found for '${task.component}'`);
96
+ }
97
+ const container = await getContainer(matching[0].Id);
98
+ return dockerExecutor.run(task.script, {
99
+ container,
100
+ out,
101
+ });
102
+ }
103
+ async shellExec(task, out) {
104
+ const { monorepo } = getContext();
105
+ const cwd = task.component
106
+ ? monorepo.component(task.component).rootdir
107
+ : monorepo.rootDir;
108
+ return shellExecutor.run(task.script, {
109
+ cwd,
110
+ out,
111
+ });
112
+ }
113
+ }
@@ -0,0 +1,10 @@
1
+ import { FlavoredCommand } from '../index.js';
2
+ export default class UpCommand extends FlavoredCommand<typeof UpCommand> {
3
+ static description: string;
4
+ static enableJsonFlag: boolean;
5
+ static examples: string[];
6
+ static flags: {
7
+ 'force-recreate': import("@oclif/core/interfaces").BooleanFlag<boolean>;
8
+ };
9
+ run(): Promise<void>;
10
+ }
@@ -0,0 +1,49 @@
1
+ import { Flags } from '@oclif/core';
2
+ import { Listr } from 'listr2';
3
+ import { FlavoredCommand, getContext } from '../index.js';
4
+ import { up } from '../../docker/index.js';
5
+ export default class UpCommand extends FlavoredCommand {
6
+ static description = 'Start the whole project.';
7
+ static enableJsonFlag = true;
8
+ static examples = ['<%= config.bin %> <%= command.id %>'];
9
+ static flags = {
10
+ 'force-recreate': Flags.boolean({
11
+ char: 'f',
12
+ default: false,
13
+ description: "Recreate containers even if their configuration and image haven't changed",
14
+ name: 'force-recreate',
15
+ }),
16
+ };
17
+ async run() {
18
+ const { monorepo } = getContext();
19
+ const runner = new Listr([
20
+ {
21
+ rendererOptions: { persistentOutput: true },
22
+ async task(ctx, task) {
23
+ const process = await up({ cwd: monorepo.rootDir });
24
+ const handleOutput = (chunk) => {
25
+ const line = chunk.toString();
26
+ task.output = line.trimEnd(); // This updates the live output in Listr
27
+ };
28
+ process.stdout?.on('data', handleOutput);
29
+ process.stderr?.on('data', handleOutput);
30
+ return new Promise((resolve, reject) => {
31
+ process.on('exit', (code) => {
32
+ if (code === 0) {
33
+ resolve(null);
34
+ }
35
+ else {
36
+ reject(new Error(`Command failed with code ${code}`));
37
+ }
38
+ });
39
+ process.on('error', (err) => {
40
+ reject(err);
41
+ });
42
+ });
43
+ },
44
+ title: 'Starting project',
45
+ },
46
+ ]);
47
+ await runner.run();
48
+ }
49
+ }
@@ -0,0 +1,2 @@
1
+ import { TableOptions } from '@oclif/table';
2
+ export declare const TABLE_DEFAULTS: Partial<TableOptions<Record<string, unknown>>>;
@@ -0,0 +1,6 @@
1
+ export const TABLE_DEFAULTS = {
2
+ borderStyle: 'none',
3
+ headerOptions: {
4
+ formatter: 'constantCase',
5
+ },
6
+ };
@@ -0,0 +1,3 @@
1
+ import { Hook } from '@oclif/core';
2
+ declare const hook: Hook.Init;
3
+ export default hook;
@@ -0,0 +1,27 @@
1
+ import { setContext } from '../../index.js';
2
+ import { Performance } from '@oclif/core';
3
+ import Dockerode from 'dockerode';
4
+ import { loadConfig } from '../../config/index.js';
5
+ import { Monorepo } from '../../monorepo/index.js';
6
+ const withMarker = async (owner, name, cb) => {
7
+ const marker = Performance.mark(owner, name);
8
+ const res = await cb();
9
+ marker?.stop();
10
+ return res;
11
+ };
12
+ const hook = async function (options) {
13
+ try {
14
+ const config = await withMarker('emb:config', 'load', () => loadConfig());
15
+ const monorepo = await withMarker('emb:monorepo', 'init', () => {
16
+ return new Monorepo(config).init();
17
+ });
18
+ setContext({
19
+ docker: new Dockerode(),
20
+ monorepo,
21
+ });
22
+ }
23
+ catch (error) {
24
+ options.context.error(error);
25
+ }
26
+ };
27
+ export default hook;
@@ -0,0 +1,3 @@
1
+ export * from '../context.js';
2
+ export * from './abstract/index.js';
3
+ export * from './constants.js';
@@ -0,0 +1,3 @@
1
+ export * from '../context.js';
2
+ export * from './abstract/index.js';
3
+ export * from './constants.js';
@@ -0,0 +1,5 @@
1
+ import { Component, Flavor } from './schema.js';
2
+ import { ComponentConfig, FlavorConfig, IMonorepoConfig, UserConfig } from './types.js';
3
+ export declare const toFlavor: (flavor: Flavor) => FlavorConfig;
4
+ export declare const toComponent: (cmp: Component) => ComponentConfig;
5
+ export declare const toProjectConfig: (config: UserConfig, rootDir?: string) => IMonorepoConfig;
@@ -0,0 +1,48 @@
1
+ import { resolve } from 'node:path';
2
+ import { cwd } from 'node:process';
3
+ export const toFlavor = (flavor) => {
4
+ return {
5
+ ...flavor,
6
+ components: flavor.components?.map(toComponent),
7
+ };
8
+ };
9
+ export const toComponent = (cmp) => {
10
+ return typeof cmp === 'string'
11
+ ? { context: cmp, name: cmp }
12
+ : cmp;
13
+ };
14
+ export const toProjectConfig = (config, rootDir) => {
15
+ const project = typeof config.project === 'string'
16
+ ? { name: config.project }
17
+ : config.project;
18
+ if (project.rootDir) {
19
+ project.rootDir = rootDir
20
+ ? resolve(rootDir, project.rootDir)
21
+ : project.rootDir;
22
+ }
23
+ else {
24
+ project.rootDir = rootDir || cwd();
25
+ }
26
+ const components = (config.components || []).map((cmp) => toComponent(cmp));
27
+ const { defaults, env, flavors, plugins, vars } = config;
28
+ return {
29
+ components,
30
+ defaults: {
31
+ ...defaults,
32
+ docker: {
33
+ ...defaults?.docker,
34
+ labels: {
35
+ ...defaults?.docker?.labels,
36
+ 'emb/project': project.name,
37
+ },
38
+ },
39
+ },
40
+ env,
41
+ flavors: flavors?.map(toFlavor),
42
+ plugins,
43
+ project: {
44
+ ...project,
45
+ },
46
+ vars,
47
+ };
48
+ };
@@ -0,0 +1,6 @@
1
+ import { IMonorepoConfig } from './types.js';
2
+ export * from './convert.js';
3
+ export * from './types.js';
4
+ export * from './validation.js';
5
+ export declare const loadConfig: (force?: boolean) => Promise<IMonorepoConfig>;
6
+ export declare const getConfig: () => IMonorepoConfig;
@@ -0,0 +1,25 @@
1
+ import { findUp } from 'find-up';
2
+ import { dirname } from 'node:path';
3
+ import { toProjectConfig } from './convert.js';
4
+ import { validateUserConfig } from './validation.js';
5
+ export * from './convert.js';
6
+ export * from './types.js';
7
+ export * from './validation.js';
8
+ let config;
9
+ export const loadConfig = async (force = false) => {
10
+ if (config && !force) {
11
+ return config;
12
+ }
13
+ const path = await findUp('.emb.yml');
14
+ if (!path) {
15
+ throw new Error('Could not find EMB config anywhere');
16
+ }
17
+ config = toProjectConfig(await validateUserConfig(path), dirname(path));
18
+ return config;
19
+ };
20
+ export const getConfig = () => {
21
+ if (!config) {
22
+ throw new Error(`Config not loaded, please use 'loadConfig' first`);
23
+ }
24
+ return config;
25
+ };
@@ -0,0 +1,102 @@
1
+ /**
2
+ * This file was automatically generated by json-schema-to-typescript.
3
+ * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
4
+ * and run json-schema-to-typescript to regenerate this file.
5
+ */
6
+ export type Component = string | {
7
+ /**
8
+ * The name of the component.
9
+ */
10
+ name: string;
11
+ /**
12
+ * The directory of the component.
13
+ */
14
+ context?: string;
15
+ /**
16
+ * A description of the component.
17
+ */
18
+ description?: string;
19
+ buildArgs?: {
20
+ [k: string]: unknown;
21
+ };
22
+ dependencies?: string[];
23
+ /**
24
+ * The stage to target for the build
25
+ */
26
+ target?: string;
27
+ /**
28
+ * The Dockerfile to use
29
+ */
30
+ dockerfile?: string;
31
+ tasks?: Task[];
32
+ };
33
+ export interface EMBConfigSchema {
34
+ project: string | {
35
+ /**
36
+ * The name of the project.
37
+ */
38
+ name: string;
39
+ /**
40
+ * The root directory of the project.
41
+ */
42
+ rootDir?: string;
43
+ };
44
+ plugins?: {
45
+ name: string;
46
+ config?: unknown;
47
+ }[];
48
+ /**
49
+ * Variables to install on the environment
50
+ */
51
+ env?: {
52
+ [k: string]: string;
53
+ };
54
+ /**
55
+ * Variables that will be accessible for string expansion
56
+ */
57
+ vars?: {
58
+ [k: string]: unknown;
59
+ };
60
+ defaults?: Defaults;
61
+ components?: Component[];
62
+ flavors?: Flavor[];
63
+ }
64
+ /**
65
+ * Default settings for build aspects
66
+ */
67
+ export interface Defaults {
68
+ /**
69
+ * Default docker build settings
70
+ */
71
+ docker?: {
72
+ tag?: string;
73
+ target?: string;
74
+ buildArgs?: {
75
+ [k: string]: unknown;
76
+ };
77
+ labels?: {
78
+ [k: string]: string;
79
+ };
80
+ [k: string]: unknown;
81
+ };
82
+ }
83
+ export interface Task {
84
+ name: string;
85
+ description?: string;
86
+ script: string;
87
+ executor?: string;
88
+ options?: {
89
+ [k: string]: unknown;
90
+ };
91
+ }
92
+ export interface Flavor {
93
+ name: string;
94
+ /**
95
+ * Variables to install on the environment
96
+ */
97
+ env?: {
98
+ [k: string]: string;
99
+ };
100
+ components?: Component[];
101
+ defaults?: Defaults;
102
+ }
@@ -0,0 +1,7 @@
1
+ /* eslint-disable */
2
+ /**
3
+ * This file was automatically generated by json-schema-to-typescript.
4
+ * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
5
+ * and run json-schema-to-typescript to regenerate this file.
6
+ */
7
+ export {};
@@ -0,0 +1,209 @@
1
+ {
2
+ "$id": "/schemas/config",
3
+ "$schema": "http://json-schema.org/draft-07/schema#",
4
+ "title": "EMB Config Schema",
5
+ "type": "object",
6
+ "properties": {
7
+ "project": {
8
+ "oneOf": [
9
+ {
10
+ "type": "string",
11
+ "minLength": 3,
12
+ "description": "Shortcut for specifying the project name."
13
+ },
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
30
+ }
31
+ ]
32
+ },
33
+ "plugins": {
34
+ "type": "array",
35
+ "items": {
36
+ "type": "object",
37
+ "required": ["name"],
38
+ "properties": {
39
+ "name": {
40
+ "type": "string"
41
+ },
42
+ "config": {}
43
+ },
44
+ "additionalProperties": false
45
+ }
46
+ },
47
+ "env": {
48
+ "type": "object",
49
+ "description": "Variables to install on the environment",
50
+ "additionalProperties": {
51
+ "type": "string"
52
+ }
53
+ },
54
+ "vars": {
55
+ "type": "object",
56
+ "description": "Variables that will be accessible for string expansion",
57
+ "additionalProperties": true
58
+ },
59
+ "defaults": {
60
+ "$ref": "#/$defs/defaults"
61
+ },
62
+ "components": {
63
+ "type": "array",
64
+ "items": {
65
+ "$ref": "#/$defs/component"
66
+ }
67
+ },
68
+ "flavors": {
69
+ "type": "array",
70
+ "items": {
71
+ "$ref": "#/$defs/flavor"
72
+ }
73
+ }
74
+ },
75
+ "required": ["project"],
76
+ "additionalProperties": false,
77
+ "$defs": {
78
+ "defaults": {
79
+ "type": "object",
80
+ "description": "Default settings for build aspects",
81
+ "additionalProperties": false,
82
+ "properties": {
83
+ "docker": {
84
+ "type": "object",
85
+ "description": "Default docker build settings",
86
+ "properties": {
87
+ "tag": { "type": "string" },
88
+ "target": { "type": "string" },
89
+ "buildArgs": {
90
+ "type": "object",
91
+ "additionalProperties": true
92
+ },
93
+ "labels": {
94
+ "type": "object",
95
+ "additionalProperties": {
96
+ "type": "string"
97
+ }
98
+ }
99
+ }
100
+ }
101
+ }
102
+ },
103
+ "task": {
104
+ "type": "object",
105
+ "required": ["name", "script"],
106
+ "properties": {
107
+ "name": {
108
+ "type": "string"
109
+ },
110
+ "description": {
111
+ "type": "string"
112
+ },
113
+ "script": {
114
+ "type": "string"
115
+ },
116
+ "executor": {
117
+ "type": "string"
118
+ },
119
+ "options": {
120
+ "type": "object",
121
+ "additionalProperties": true
122
+ }
123
+ },
124
+ "additionalProperties": false
125
+ },
126
+ "component": {
127
+ "oneOf": [
128
+ {
129
+ "type": "string",
130
+ "minLength": 3,
131
+ "description": "Shortcut for specifying the component name."
132
+ },
133
+ {
134
+ "type": "object",
135
+ "required": ["name"],
136
+ "properties": {
137
+ "name": {
138
+ "type": "string",
139
+ "minLength": 3,
140
+ "description": "The name of the component."
141
+ },
142
+ "context": {
143
+ "type": "string",
144
+ "minLength": 1,
145
+ "description": "The directory of the component."
146
+ },
147
+ "description": {
148
+ "type": "string",
149
+ "minLength": 1,
150
+ "description": "A description of the component."
151
+ },
152
+ "buildArgs": {
153
+ "type": "object",
154
+ "properties": {},
155
+ "additionalProperties": true
156
+ },
157
+ "dependencies": {
158
+ "type": "array",
159
+ "items": {
160
+ "type": "string"
161
+ }
162
+ },
163
+ "target": {
164
+ "type": "string",
165
+ "description": "The stage to target for the build"
166
+ },
167
+ "dockerfile": {
168
+ "type": "string",
169
+ "description": "The Dockerfile to use"
170
+ },
171
+ "tasks": {
172
+ "type": "array",
173
+ "items": {
174
+ "$ref": "#/$defs/task"
175
+ }
176
+ }
177
+ },
178
+ "additionalProperties": false
179
+ }
180
+ ]
181
+ },
182
+ "flavor": {
183
+ "type": "object",
184
+ "required": ["name"],
185
+ "properties": {
186
+ "name": {
187
+ "type": "string"
188
+ },
189
+ "env": {
190
+ "type": "object",
191
+ "description": "Variables to install on the environment",
192
+ "additionalProperties": {
193
+ "type": "string"
194
+ }
195
+ },
196
+ "components": {
197
+ "type": "array",
198
+ "items": {
199
+ "$ref": "#/$defs/component"
200
+ }
201
+ },
202
+ "defaults": {
203
+ "$ref": "#/$defs/defaults"
204
+ }
205
+ },
206
+ "additionalProperties": false
207
+ }
208
+ }
209
+ }
@@ -0,0 +1,43 @@
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
+ buildArgs?: Record<PropertyKey, string>;
9
+ context?: string;
10
+ dependencies?: Array<string>;
11
+ dockerfile?: string;
12
+ labels?: Record<string, string>;
13
+ name: string;
14
+ target?: string;
15
+ tasks?: Array<Task>;
16
+ };
17
+ export type DefaultSettings = {
18
+ docker?: {
19
+ buildArgs?: Record<string, unknown>;
20
+ labels?: Record<string, string>;
21
+ tag?: string;
22
+ target?: string;
23
+ };
24
+ };
25
+ export type FlavorConfig = {
26
+ components?: Array<ComponentConfig>;
27
+ defaults?: DefaultSettings;
28
+ env?: Record<string, string>;
29
+ name: string;
30
+ };
31
+ export type PluginConfig = {
32
+ config?: unknown;
33
+ name: string;
34
+ };
35
+ export type IMonorepoConfig = {
36
+ components: Array<ComponentConfig>;
37
+ defaults?: DefaultSettings;
38
+ env?: Record<string, string>;
39
+ flavors?: Array<FlavorConfig>;
40
+ plugins?: Array<PluginConfig>;
41
+ project: IProjectConfig;
42
+ vars?: Record<string, unknown>;
43
+ };
@@ -0,0 +1 @@
1
+ export {};