@enspirit/emb 0.0.6 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +60 -13
- package/dist/src/cli/commands/clean.d.ts +3 -1
- package/dist/src/cli/commands/clean.js +13 -2
- package/dist/src/cli/commands/components/build.d.ts +6 -2
- package/dist/src/cli/commands/components/build.js +16 -7
- package/dist/src/cli/commands/config/print.js +2 -3
- package/dist/src/cli/commands/down.d.ts +2 -2
- package/dist/src/cli/commands/down.js +5 -25
- package/dist/src/cli/commands/tasks/index.js +11 -5
- package/dist/src/cli/commands/tasks/run.d.ts +1 -1
- package/dist/src/cli/commands/tasks/run.js +10 -43
- package/dist/src/cli/commands/up.d.ts +1 -1
- package/dist/src/cli/commands/up.js +12 -34
- package/dist/src/config/convert.js +2 -4
- package/dist/src/config/index.d.ts +1 -0
- package/dist/src/config/index.js +1 -0
- package/dist/src/config/schema.d.ts +32 -25
- package/dist/src/config/schema.json +48 -26
- package/dist/src/config/types.d.ts +10 -6
- package/dist/src/docker/compose/index.d.ts +1 -7
- package/dist/src/docker/compose/index.js +1 -13
- package/dist/src/docker/compose/operations/ComposeDownOperation.d.ts +12 -0
- package/dist/src/docker/compose/operations/ComposeDownOperation.js +21 -0
- package/dist/src/docker/compose/operations/ComposeUpOperation.d.ts +13 -0
- package/dist/src/docker/compose/operations/ComposeUpOperation.js +39 -0
- package/dist/src/docker/compose/operations/index.d.ts +2 -0
- package/dist/src/docker/compose/operations/index.js +2 -0
- package/dist/src/monorepo/component.d.ts +2 -2
- package/dist/src/monorepo/component.js +6 -6
- package/dist/src/monorepo/config.d.ts +4 -2
- package/dist/src/monorepo/config.js +14 -2
- package/dist/src/monorepo/index.d.ts +2 -0
- package/dist/src/monorepo/index.js +2 -0
- package/dist/src/monorepo/monorepo.d.ts +4 -2
- package/dist/src/monorepo/monorepo.js +30 -6
- package/dist/src/monorepo/operations/components/BuildComponentsOperation.d.ts +11 -2
- package/dist/src/monorepo/operations/components/BuildComponentsOperation.js +45 -59
- package/dist/src/monorepo/operations/components/GetComponentContainerOperation.d.ts +1 -1
- package/dist/src/monorepo/operations/components/GetComponentContainerOperation.js +1 -1
- package/dist/src/monorepo/operations/shell/ExecuteLocalCommandOperation.d.ts +4 -6
- package/dist/src/monorepo/operations/shell/ExecuteLocalCommandOperation.js +2 -7
- package/dist/src/monorepo/operations/tasks/RunTasksOperation.d.ts +21 -0
- package/dist/src/monorepo/operations/tasks/RunTasksOperation.js +84 -0
- package/dist/src/monorepo/operations/tasks/index.d.ts +1 -1
- package/dist/src/monorepo/operations/tasks/index.js +1 -1
- package/dist/src/monorepo/plugins/ComponentDiscoverPlugin.js +3 -1
- package/dist/src/monorepo/plugins/EmbfileLoaderPlugin.d.ts +3 -3
- package/dist/src/monorepo/plugins/EmbfileLoaderPlugin.js +9 -5
- package/dist/src/monorepo/store/index.js +5 -3
- package/dist/src/monorepo/taskManagerFactory.d.ts +3 -0
- package/dist/src/monorepo/taskManagerFactory.js +20 -0
- package/dist/src/monorepo/types.d.ts +2 -1
- package/dist/src/monorepo/utils/findRunOrder.d.ts +34 -0
- package/dist/src/monorepo/utils/findRunOrder.js +165 -0
- package/dist/src/monorepo/utils/index.d.ts +1 -1
- package/dist/src/monorepo/utils/index.js +1 -1
- package/oclif.manifest.json +63 -40
- package/package.json +4 -2
- package/dist/src/monorepo/operations/tasks/RunTaskOperation.d.ts +0 -18
- package/dist/src/monorepo/operations/tasks/RunTaskOperation.js +0 -50
- package/dist/src/monorepo/utils/findBuildOrder.d.ts +0 -2
- package/dist/src/monorepo/utils/findBuildOrder.js +0 -41
|
@@ -70,6 +70,12 @@
|
|
|
70
70
|
"items": {
|
|
71
71
|
"$ref": "#/$defs/flavor"
|
|
72
72
|
}
|
|
73
|
+
},
|
|
74
|
+
"tasks": {
|
|
75
|
+
"type": "array",
|
|
76
|
+
"items": {
|
|
77
|
+
"$ref": "#/$defs/task"
|
|
78
|
+
}
|
|
73
79
|
}
|
|
74
80
|
},
|
|
75
81
|
"required": ["project"],
|
|
@@ -104,7 +110,11 @@
|
|
|
104
110
|
},
|
|
105
111
|
"task": {
|
|
106
112
|
"type": "object",
|
|
107
|
-
"required": ["name"
|
|
113
|
+
"required": ["name"],
|
|
114
|
+
"anyOf": [
|
|
115
|
+
{ "required": ["script"] },
|
|
116
|
+
{ "required": ["pre"] }
|
|
117
|
+
],
|
|
108
118
|
"properties": {
|
|
109
119
|
"name": {
|
|
110
120
|
"type": "string"
|
|
@@ -121,6 +131,12 @@
|
|
|
121
131
|
"options": {
|
|
122
132
|
"type": "object",
|
|
123
133
|
"additionalProperties": true
|
|
134
|
+
},
|
|
135
|
+
"pre": {
|
|
136
|
+
"type": "array",
|
|
137
|
+
"items": {
|
|
138
|
+
"type": "string"
|
|
139
|
+
}
|
|
124
140
|
}
|
|
125
141
|
},
|
|
126
142
|
"additionalProperties": false
|
|
@@ -134,37 +150,43 @@
|
|
|
134
150
|
"minLength": 3,
|
|
135
151
|
"description": "The name of the component."
|
|
136
152
|
},
|
|
137
|
-
"
|
|
138
|
-
"type": "
|
|
139
|
-
"
|
|
140
|
-
|
|
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
|
|
141
184
|
},
|
|
142
185
|
"description": {
|
|
143
186
|
"type": "string",
|
|
144
187
|
"minLength": 1,
|
|
145
188
|
"description": "A description of the component."
|
|
146
189
|
},
|
|
147
|
-
"buildArgs": {
|
|
148
|
-
"type": "object",
|
|
149
|
-
"properties": {},
|
|
150
|
-
"additionalProperties": {
|
|
151
|
-
"type": "string"
|
|
152
|
-
}
|
|
153
|
-
},
|
|
154
|
-
"dependencies": {
|
|
155
|
-
"type": "array",
|
|
156
|
-
"items": {
|
|
157
|
-
"type": "string"
|
|
158
|
-
}
|
|
159
|
-
},
|
|
160
|
-
"target": {
|
|
161
|
-
"type": "string",
|
|
162
|
-
"description": "The stage to target for the build"
|
|
163
|
-
},
|
|
164
|
-
"dockerfile": {
|
|
165
|
-
"type": "string",
|
|
166
|
-
"description": "The Dockerfile to use"
|
|
167
|
-
},
|
|
168
190
|
"tasks": {
|
|
169
191
|
"type": "array",
|
|
170
192
|
"items": {
|
|
@@ -5,13 +5,15 @@ export type IProjectConfig = {
|
|
|
5
5
|
rootDir: string;
|
|
6
6
|
};
|
|
7
7
|
export type ComponentConfig = {
|
|
8
|
-
buildArgs?: Record<string, string>;
|
|
9
|
-
context?: string;
|
|
10
|
-
dependencies?: Array<string>;
|
|
11
|
-
dockerfile?: string;
|
|
12
|
-
labels?: Record<string, string>;
|
|
13
8
|
name: string;
|
|
14
|
-
|
|
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
|
+
};
|
|
15
17
|
tasks?: Array<Task>;
|
|
16
18
|
};
|
|
17
19
|
export type DefaultSettings = {
|
|
@@ -33,11 +35,13 @@ export type PluginConfig = {
|
|
|
33
35
|
name: string;
|
|
34
36
|
};
|
|
35
37
|
export type IMonorepoConfig = {
|
|
38
|
+
currentFlavor?: string;
|
|
36
39
|
components: Array<ComponentConfig>;
|
|
37
40
|
defaults?: DefaultSettings;
|
|
38
41
|
env?: Record<string, string>;
|
|
39
42
|
flavors?: Array<FlavorConfig>;
|
|
40
43
|
plugins?: Array<PluginConfig>;
|
|
41
44
|
project: IProjectConfig;
|
|
45
|
+
tasks?: Array<Task>;
|
|
42
46
|
vars?: Record<string, unknown>;
|
|
43
47
|
};
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
cwd?: string;
|
|
3
|
-
};
|
|
4
|
-
export type UpOptions = DockerComposeOptions & {};
|
|
5
|
-
export declare const up: (opts?: UpOptions) => Promise<import("child_process").ChildProcessWithoutNullStreams>;
|
|
6
|
-
export type DownOptions = DockerComposeOptions & {};
|
|
7
|
-
export declare const down: (opts?: UpOptions) => Promise<import("child_process").ChildProcessWithoutNullStreams>;
|
|
1
|
+
export * from './operations/index.js';
|
|
@@ -1,13 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export const up = async (opts) => {
|
|
3
|
-
return spawn('docker', ['compose', 'up', '-d'], {
|
|
4
|
-
cwd: opts?.cwd,
|
|
5
|
-
env: process.env,
|
|
6
|
-
});
|
|
7
|
-
};
|
|
8
|
-
export const down = async (opts) => {
|
|
9
|
-
return spawn('docker', ['compose', 'down'], {
|
|
10
|
-
cwd: opts?.cwd,
|
|
11
|
-
env: process.env,
|
|
12
|
-
});
|
|
13
|
-
};
|
|
1
|
+
export * from './operations/index.js';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Readable } from 'node:stream';
|
|
2
|
+
import * as z from 'zod';
|
|
3
|
+
import { AbstractOperation } from '../../../operations/index.js';
|
|
4
|
+
/**
|
|
5
|
+
* https://docs.docker.com/reference/cli/docker/compose/down/
|
|
6
|
+
*/
|
|
7
|
+
declare const schema: z.ZodOptional<z.ZodObject<{}, z.core.$strip>>;
|
|
8
|
+
export declare class ComposeDownOperation extends AbstractOperation<typeof schema, Readable> {
|
|
9
|
+
constructor();
|
|
10
|
+
protected _run(_input: z.input<typeof schema>): Promise<Readable>;
|
|
11
|
+
}
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { getContext } from '../../../index.js';
|
|
2
|
+
import * as z from 'zod';
|
|
3
|
+
import { ExecuteLocalCommandOperation } from '../../../monorepo/index.js';
|
|
4
|
+
import { AbstractOperation } from '../../../operations/index.js';
|
|
5
|
+
/**
|
|
6
|
+
* https://docs.docker.com/reference/cli/docker/compose/down/
|
|
7
|
+
*/
|
|
8
|
+
const schema = z.object({}).optional();
|
|
9
|
+
export class ComposeDownOperation extends AbstractOperation {
|
|
10
|
+
constructor() {
|
|
11
|
+
super(schema);
|
|
12
|
+
}
|
|
13
|
+
async _run(_input) {
|
|
14
|
+
const { monorepo } = getContext();
|
|
15
|
+
const command = ['docker', 'compose', 'down'];
|
|
16
|
+
return monorepo.run(new ExecuteLocalCommandOperation(), {
|
|
17
|
+
script: command.join(' '),
|
|
18
|
+
workingDir: monorepo.rootDir,
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as z from 'zod';
|
|
2
|
+
import { AbstractOperation } from '../../../operations/index.js';
|
|
3
|
+
/**
|
|
4
|
+
* https://docs.docker.com/reference/cli/docker/compose/up/
|
|
5
|
+
*/
|
|
6
|
+
declare const schema: z.ZodOptional<z.ZodObject<{
|
|
7
|
+
forceRecreate: z.ZodOptional<z.ZodBoolean>;
|
|
8
|
+
}, z.core.$strip>>;
|
|
9
|
+
export declare class ComposeUpOperation extends AbstractOperation<typeof schema, void> {
|
|
10
|
+
constructor();
|
|
11
|
+
protected _run(input: z.input<typeof schema>): Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { getContext } from '../../../index.js';
|
|
2
|
+
import { Listr } from 'listr2';
|
|
3
|
+
import * as z from 'zod';
|
|
4
|
+
import { ExecuteLocalCommandOperation } from '../../../monorepo/index.js';
|
|
5
|
+
import { AbstractOperation } from '../../../operations/index.js';
|
|
6
|
+
/**
|
|
7
|
+
* https://docs.docker.com/reference/cli/docker/compose/up/
|
|
8
|
+
*/
|
|
9
|
+
const schema = z
|
|
10
|
+
.object({
|
|
11
|
+
forceRecreate: z
|
|
12
|
+
.boolean()
|
|
13
|
+
.optional()
|
|
14
|
+
.describe("Recreate containers even if their configuration and image haven't changed"),
|
|
15
|
+
})
|
|
16
|
+
.optional();
|
|
17
|
+
export class ComposeUpOperation extends AbstractOperation {
|
|
18
|
+
constructor() {
|
|
19
|
+
super(schema);
|
|
20
|
+
}
|
|
21
|
+
async _run(input) {
|
|
22
|
+
const { monorepo } = getContext();
|
|
23
|
+
const command = ['docker', 'compose', 'up', '-d'];
|
|
24
|
+
if (input?.forceRecreate) {
|
|
25
|
+
command.push('--force-recreate');
|
|
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
|
+
});
|
|
34
|
+
},
|
|
35
|
+
title: 'Starting project',
|
|
36
|
+
});
|
|
37
|
+
await task.run();
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -7,8 +7,8 @@ export declare class Component {
|
|
|
7
7
|
protected monorepo: Monorepo;
|
|
8
8
|
constructor(_config: ComponentConfig, monorepo: Monorepo);
|
|
9
9
|
get config(): ComponentConfig;
|
|
10
|
-
get context(): string
|
|
11
|
-
get dependencies():
|
|
10
|
+
get context(): string;
|
|
11
|
+
get dependencies(): string[];
|
|
12
12
|
get imageName(): string;
|
|
13
13
|
get imageTag(): string;
|
|
14
14
|
get labels(): {
|
|
@@ -12,10 +12,10 @@ export class Component {
|
|
|
12
12
|
return structuredClone(this._config);
|
|
13
13
|
}
|
|
14
14
|
get context() {
|
|
15
|
-
return this.config.context;
|
|
15
|
+
return this.config.docker?.context || this.name;
|
|
16
16
|
}
|
|
17
17
|
get dependencies() {
|
|
18
|
-
return this.
|
|
18
|
+
return this.config.docker?.dependencies || [];
|
|
19
19
|
}
|
|
20
20
|
get imageName() {
|
|
21
21
|
return join(this.monorepo.name, this.name);
|
|
@@ -26,7 +26,7 @@ export class Component {
|
|
|
26
26
|
get labels() {
|
|
27
27
|
return {
|
|
28
28
|
'emb/component': this.name,
|
|
29
|
-
...this._config.labels,
|
|
29
|
+
...this._config.docker?.labels,
|
|
30
30
|
};
|
|
31
31
|
}
|
|
32
32
|
get name() {
|
|
@@ -60,9 +60,9 @@ export class Component {
|
|
|
60
60
|
}
|
|
61
61
|
async toDockerBuild() {
|
|
62
62
|
return {
|
|
63
|
-
buildArgs: await this.monorepo.expand(deepmerge()(this.monorepo.defaults.docker?.buildArgs || {}, this.config.buildArgs || {})),
|
|
63
|
+
buildArgs: await this.monorepo.expand(deepmerge()(this.monorepo.defaults.docker?.buildArgs || {}, this.config.docker?.buildArgs || {})),
|
|
64
64
|
context: this.rootdir,
|
|
65
|
-
dockerfile: this.config.dockerfile || 'Dockerfile',
|
|
65
|
+
dockerfile: this.config.docker?.dockerfile || 'Dockerfile',
|
|
66
66
|
labels: deepmerge()({
|
|
67
67
|
...this.monorepo.defaults.docker?.labels,
|
|
68
68
|
}, this.labels),
|
|
@@ -71,7 +71,7 @@ export class Component {
|
|
|
71
71
|
tag: this.imageTag
|
|
72
72
|
? await this.monorepo.expand(this.imageTag)
|
|
73
73
|
: 'latest',
|
|
74
|
-
target: this.config.target || this.monorepo.defaults?.docker?.target,
|
|
74
|
+
target: this.config.docker?.target || this.monorepo.defaults?.docker?.target,
|
|
75
75
|
};
|
|
76
76
|
}
|
|
77
77
|
}
|
|
@@ -1,17 +1,19 @@
|
|
|
1
|
-
import { ComponentConfig, DefaultSettings, FlavorConfig, IMonorepoConfig, IProjectConfig, PluginConfig } from '../config/index.js';
|
|
1
|
+
import { ComponentConfig, DefaultSettings, FlavorConfig, IMonorepoConfig, IProjectConfig, PluginConfig, Task } from '../config/index.js';
|
|
2
2
|
export declare class MonorepoConfig implements IMonorepoConfig {
|
|
3
|
+
currentFlavor: string;
|
|
3
4
|
defaults: DefaultSettings;
|
|
4
5
|
env: Record<string, string>;
|
|
5
6
|
flavors: Array<FlavorConfig>;
|
|
6
7
|
plugins: Array<PluginConfig>;
|
|
7
8
|
project: IProjectConfig;
|
|
8
9
|
vars: Record<string, unknown>;
|
|
10
|
+
tasks: Array<Task>;
|
|
9
11
|
private _components;
|
|
10
12
|
constructor(config: IMonorepoConfig);
|
|
11
13
|
get components(): ComponentConfig[];
|
|
12
14
|
component(name: string): ComponentConfig;
|
|
13
15
|
flavor(name: string): FlavorConfig;
|
|
14
|
-
toJSON():
|
|
16
|
+
toJSON(): IMonorepoConfig;
|
|
15
17
|
with(overrides: Partial<IMonorepoConfig>): MonorepoConfig;
|
|
16
18
|
withFlavor(name: string): MonorepoConfig;
|
|
17
19
|
}
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import deepMerge from '@fastify/deepmerge';
|
|
2
2
|
import { deepMergeArray } from '../utils/index.js';
|
|
3
3
|
export class MonorepoConfig {
|
|
4
|
+
// the flavor we come from
|
|
5
|
+
currentFlavor;
|
|
6
|
+
//
|
|
4
7
|
defaults;
|
|
5
8
|
env;
|
|
6
9
|
flavors;
|
|
7
10
|
plugins;
|
|
8
11
|
project;
|
|
9
12
|
vars;
|
|
13
|
+
tasks;
|
|
10
14
|
_components;
|
|
11
15
|
constructor(config) {
|
|
12
16
|
this._components = config.components.reduce((map, cmp) => {
|
|
@@ -19,6 +23,8 @@ export class MonorepoConfig {
|
|
|
19
23
|
this.flavors = config.flavors || [];
|
|
20
24
|
this.env = config.env || {};
|
|
21
25
|
this.plugins = config.plugins || [];
|
|
26
|
+
this.tasks = config.tasks || [];
|
|
27
|
+
this.currentFlavor = config.currentFlavor || 'default';
|
|
22
28
|
}
|
|
23
29
|
get components() {
|
|
24
30
|
return [...this._components.values()];
|
|
@@ -39,6 +45,7 @@ export class MonorepoConfig {
|
|
|
39
45
|
}
|
|
40
46
|
toJSON() {
|
|
41
47
|
return {
|
|
48
|
+
currentFlavor: this.currentFlavor,
|
|
42
49
|
components: this.components,
|
|
43
50
|
defaults: this.defaults,
|
|
44
51
|
env: this.env,
|
|
@@ -46,11 +53,13 @@ export class MonorepoConfig {
|
|
|
46
53
|
plugins: this.plugins,
|
|
47
54
|
project: this.project,
|
|
48
55
|
vars: this.vars,
|
|
56
|
+
tasks: this.tasks,
|
|
49
57
|
};
|
|
50
58
|
}
|
|
51
59
|
with(overrides) {
|
|
52
60
|
const newConfig = {
|
|
53
61
|
...this.toJSON(),
|
|
62
|
+
...overrides,
|
|
54
63
|
components: deepMerge({
|
|
55
64
|
mergeArray() {
|
|
56
65
|
// Merge components by identifying them by name
|
|
@@ -59,7 +68,7 @@ export class MonorepoConfig {
|
|
|
59
68
|
});
|
|
60
69
|
},
|
|
61
70
|
})(this.components, overrides?.components || []),
|
|
62
|
-
defaults: deepMerge()(this.defaults, overrides.defaults),
|
|
71
|
+
defaults: deepMerge()(this.defaults || {}, overrides.defaults || {}),
|
|
63
72
|
env: deepMerge()(this.env, overrides?.env || {}),
|
|
64
73
|
project: deepMerge()(this.project, overrides?.project || {}),
|
|
65
74
|
vars: deepMerge()(this.vars, overrides?.vars || {}),
|
|
@@ -67,6 +76,9 @@ export class MonorepoConfig {
|
|
|
67
76
|
return new MonorepoConfig(newConfig);
|
|
68
77
|
}
|
|
69
78
|
withFlavor(name) {
|
|
70
|
-
return this.with(
|
|
79
|
+
return this.with({
|
|
80
|
+
...this.flavor(name),
|
|
81
|
+
currentFlavor: name,
|
|
82
|
+
});
|
|
71
83
|
}
|
|
72
84
|
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
export * from './component.js';
|
|
2
2
|
export * from './config.js';
|
|
3
3
|
export * from './monorepo.js';
|
|
4
|
+
export * from './operations/index.js';
|
|
4
5
|
export * from './plugins/index.js';
|
|
5
6
|
export * from './store/index.js';
|
|
7
|
+
export * from './taskManagerFactory.js';
|
|
6
8
|
export * from './types.js';
|
|
7
9
|
export * from './utils/index.js';
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
export * from './component.js';
|
|
2
2
|
export * from './config.js';
|
|
3
3
|
export * from './monorepo.js';
|
|
4
|
+
export * from './operations/index.js';
|
|
4
5
|
export * from './plugins/index.js';
|
|
5
6
|
export * from './store/index.js';
|
|
7
|
+
export * from './taskManagerFactory.js';
|
|
6
8
|
export * from './types.js';
|
|
7
9
|
export * from './utils/index.js';
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { IMonorepoConfig } from '../config/index.js';
|
|
2
|
-
import { IOperation } from '../operations/
|
|
2
|
+
import { IOperation } from '../operations/index.js';
|
|
3
3
|
import { TemplateExpander } from '../utils/index.js';
|
|
4
4
|
import { Component } from './component.js';
|
|
5
5
|
import { EMBStore } from './store/index.js';
|
|
6
6
|
import { TaskInfo } from './types.js';
|
|
7
7
|
export declare class Monorepo {
|
|
8
8
|
private _config;
|
|
9
|
-
private _env;
|
|
10
9
|
private _store;
|
|
11
10
|
private initialized;
|
|
12
11
|
constructor(config: IMonorepoConfig);
|
|
@@ -16,12 +15,15 @@ export declare class Monorepo {
|
|
|
16
15
|
get flavors(): string[];
|
|
17
16
|
get name(): string;
|
|
18
17
|
get rootDir(): string;
|
|
18
|
+
get currentFlavor(): string;
|
|
19
19
|
get store(): EMBStore;
|
|
20
20
|
get tasks(): TaskInfo[];
|
|
21
21
|
get vars(): Record<string, unknown>;
|
|
22
22
|
component(name: string): Component;
|
|
23
|
+
task(nameOrId: string): TaskInfo;
|
|
23
24
|
expand(str: string, expander?: TemplateExpander): Promise<string>;
|
|
24
25
|
expand<R extends Record<string, unknown>>(record: R, expander?: TemplateExpander): Promise<R>;
|
|
26
|
+
private installStore;
|
|
25
27
|
init(): Promise<Monorepo>;
|
|
26
28
|
join(...paths: string[]): string;
|
|
27
29
|
run<I, O>(operation: IOperation<I, O>, args: I): Promise<O>;
|
|
@@ -6,12 +6,10 @@ import { getPlugin } from './plugins/index.js';
|
|
|
6
6
|
import { EMBStore } from './store/index.js';
|
|
7
7
|
export class Monorepo {
|
|
8
8
|
_config;
|
|
9
|
-
_env;
|
|
10
9
|
_store;
|
|
11
10
|
initialized = false;
|
|
12
11
|
constructor(config) {
|
|
13
12
|
this._config = new MonorepoConfig(config);
|
|
14
|
-
this._env = config.env || {};
|
|
15
13
|
}
|
|
16
14
|
// TODO: cache/improve
|
|
17
15
|
get components() {
|
|
@@ -32,13 +30,22 @@ export class Monorepo {
|
|
|
32
30
|
get rootDir() {
|
|
33
31
|
return this._config.project.rootDir;
|
|
34
32
|
}
|
|
33
|
+
get currentFlavor() {
|
|
34
|
+
return this._config.currentFlavor;
|
|
35
|
+
}
|
|
35
36
|
get store() {
|
|
36
37
|
return this._store;
|
|
37
38
|
}
|
|
38
39
|
get tasks() {
|
|
40
|
+
const globalTasks = (this._config.tasks || [])?.map((t) => {
|
|
41
|
+
return {
|
|
42
|
+
...t,
|
|
43
|
+
id: `global:${t.name}`,
|
|
44
|
+
};
|
|
45
|
+
});
|
|
39
46
|
return this.components.reduce((tasks, cmp) => {
|
|
40
47
|
return [...tasks, ...cmp.tasks];
|
|
41
|
-
},
|
|
48
|
+
}, globalTasks);
|
|
42
49
|
}
|
|
43
50
|
get vars() {
|
|
44
51
|
return this._config.vars;
|
|
@@ -46,6 +53,20 @@ export class Monorepo {
|
|
|
46
53
|
component(name) {
|
|
47
54
|
return new Component(this._config.component(name), this);
|
|
48
55
|
}
|
|
56
|
+
task(nameOrId) {
|
|
57
|
+
const byId = this.tasks.find((t) => t.id === nameOrId);
|
|
58
|
+
if (byId) {
|
|
59
|
+
return byId;
|
|
60
|
+
}
|
|
61
|
+
const found = this.tasks.filter((t) => t.name === nameOrId);
|
|
62
|
+
if (found.length > 1) {
|
|
63
|
+
throw new Error(`Task name ambigous, found multiple matches: ${nameOrId}`);
|
|
64
|
+
}
|
|
65
|
+
if (found.length === 0) {
|
|
66
|
+
throw new Error(`Task not found: ${nameOrId}`);
|
|
67
|
+
}
|
|
68
|
+
return found[0];
|
|
69
|
+
}
|
|
49
70
|
async expand(strOrRecord, expander = new TemplateExpander()) {
|
|
50
71
|
const options = {
|
|
51
72
|
default: 'vars',
|
|
@@ -59,13 +80,16 @@ export class Monorepo {
|
|
|
59
80
|
}
|
|
60
81
|
return expander.expandRecord(strOrRecord, options);
|
|
61
82
|
}
|
|
83
|
+
async installStore(store) {
|
|
84
|
+
this._store = store || new EMBStore(this);
|
|
85
|
+
await this._store.init();
|
|
86
|
+
}
|
|
62
87
|
// Initialize
|
|
63
88
|
async init() {
|
|
64
89
|
if (this.initialized) {
|
|
65
90
|
throw new Error('Monorepo already initialized');
|
|
66
91
|
}
|
|
67
|
-
this.
|
|
68
|
-
await this._store.init();
|
|
92
|
+
await this.installStore();
|
|
69
93
|
const plugins = this._config.plugins.map((p) => {
|
|
70
94
|
const PluginClass = getPlugin(p.name);
|
|
71
95
|
return new PluginClass(p.config, this);
|
|
@@ -100,7 +124,7 @@ export class Monorepo {
|
|
|
100
124
|
}
|
|
101
125
|
async withFlavor(name) {
|
|
102
126
|
const repo = new Monorepo(this._config.withFlavor(name));
|
|
103
|
-
await repo.
|
|
127
|
+
await repo.installStore();
|
|
104
128
|
return repo;
|
|
105
129
|
}
|
|
106
130
|
}
|
|
@@ -1,11 +1,20 @@
|
|
|
1
1
|
import * as z from 'zod';
|
|
2
|
+
import { DockerComponentBuild } from '../../../docker/index.js';
|
|
2
3
|
import { AbstractOperation } from '../../../operations/index.js';
|
|
4
|
+
export type BuildComponentMeta = {
|
|
5
|
+
dryRun?: boolean;
|
|
6
|
+
cacheHit?: boolean;
|
|
7
|
+
build: DockerComponentBuild;
|
|
8
|
+
preBuildMeta?: string;
|
|
9
|
+
sentinelFile: string;
|
|
10
|
+
};
|
|
3
11
|
declare const schema: z.ZodObject<{
|
|
4
12
|
components: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
13
|
+
dryRun: z.ZodOptional<z.ZodBoolean>;
|
|
5
14
|
}, z.core.$strip>;
|
|
6
|
-
export declare class BuildComponentsOperation extends AbstractOperation<typeof schema,
|
|
15
|
+
export declare class BuildComponentsOperation extends AbstractOperation<typeof schema, Record<string, BuildComponentMeta>> {
|
|
7
16
|
constructor();
|
|
8
|
-
protected _run(input: z.input<typeof schema>): Promise<
|
|
17
|
+
protected _run(input: z.input<typeof schema>): Promise<Record<string, BuildComponentMeta>>;
|
|
9
18
|
private buildComponent;
|
|
10
19
|
}
|
|
11
20
|
export {};
|