@enspirit/emb 0.0.6 → 0.0.8
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 +61 -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 +17 -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 +2 -1
- package/dist/src/cli/commands/tasks/run.js +30 -45
- 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/errors.d.ts +57 -0
- package/dist/src/errors.js +66 -0
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.js +1 -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 +5 -2
- package/dist/src/monorepo/monorepo.js +45 -17
- package/dist/src/monorepo/operations/components/BuildComponentsOperation.d.ts +12 -2
- package/dist/src/monorepo/operations/components/BuildComponentsOperation.js +50 -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 +20 -0
- package/dist/src/monorepo/operations/tasks/RunTasksOperation.js +82 -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 +94 -64
- package/package.json +9 -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
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
export declare class EMBError extends Error {
|
|
2
|
+
code: string;
|
|
3
|
+
message: string;
|
|
4
|
+
constructor(code: string, message: string);
|
|
5
|
+
toCliError(suggestions: string[], ref?: string): CliError;
|
|
6
|
+
}
|
|
7
|
+
export declare class CliError extends EMBError {
|
|
8
|
+
/**
|
|
9
|
+
* a unique error code for this error class
|
|
10
|
+
*/
|
|
11
|
+
code: string;
|
|
12
|
+
/**
|
|
13
|
+
* message to display related to the error
|
|
14
|
+
*/
|
|
15
|
+
message: string;
|
|
16
|
+
/**
|
|
17
|
+
* a suggestion that may be useful or provide additional context
|
|
18
|
+
*/
|
|
19
|
+
suggestions?: string[] | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* a url to find out more information related to this error
|
|
22
|
+
* or fixing the error
|
|
23
|
+
*/
|
|
24
|
+
ref?: string | undefined;
|
|
25
|
+
constructor(
|
|
26
|
+
/**
|
|
27
|
+
* a unique error code for this error class
|
|
28
|
+
*/
|
|
29
|
+
code: string,
|
|
30
|
+
/**
|
|
31
|
+
* message to display related to the error
|
|
32
|
+
*/
|
|
33
|
+
message: string,
|
|
34
|
+
/**
|
|
35
|
+
* a suggestion that may be useful or provide additional context
|
|
36
|
+
*/
|
|
37
|
+
suggestions?: string[] | undefined,
|
|
38
|
+
/**
|
|
39
|
+
* a url to find out more information related to this error
|
|
40
|
+
* or fixing the error
|
|
41
|
+
*/
|
|
42
|
+
ref?: string | undefined);
|
|
43
|
+
}
|
|
44
|
+
export declare class AmbiguousTaskError extends EMBError {
|
|
45
|
+
options: string[];
|
|
46
|
+
constructor(msg: string, options: string[]);
|
|
47
|
+
}
|
|
48
|
+
export declare class UnkownReferenceError extends EMBError {
|
|
49
|
+
constructor(msg: string);
|
|
50
|
+
}
|
|
51
|
+
export declare class TaskNameCollisionError extends EMBError {
|
|
52
|
+
collisions: Array<string>;
|
|
53
|
+
constructor(msg: string, collisions: Array<string>);
|
|
54
|
+
}
|
|
55
|
+
export declare class CircularDependencyError extends EMBError {
|
|
56
|
+
constructor(msg: string);
|
|
57
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
export class EMBError extends Error {
|
|
2
|
+
code;
|
|
3
|
+
message;
|
|
4
|
+
constructor(code, message) {
|
|
5
|
+
super(message);
|
|
6
|
+
this.code = code;
|
|
7
|
+
this.message = message;
|
|
8
|
+
}
|
|
9
|
+
toCliError(suggestions, ref) {
|
|
10
|
+
return new CliError(this.code, this.message, suggestions, ref);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
export class CliError extends EMBError {
|
|
14
|
+
code;
|
|
15
|
+
message;
|
|
16
|
+
suggestions;
|
|
17
|
+
ref;
|
|
18
|
+
constructor(
|
|
19
|
+
/**
|
|
20
|
+
* a unique error code for this error class
|
|
21
|
+
*/
|
|
22
|
+
code,
|
|
23
|
+
/**
|
|
24
|
+
* message to display related to the error
|
|
25
|
+
*/
|
|
26
|
+
message,
|
|
27
|
+
/**
|
|
28
|
+
* a suggestion that may be useful or provide additional context
|
|
29
|
+
*/
|
|
30
|
+
suggestions,
|
|
31
|
+
/**
|
|
32
|
+
* a url to find out more information related to this error
|
|
33
|
+
* or fixing the error
|
|
34
|
+
*/
|
|
35
|
+
ref) {
|
|
36
|
+
super(code, message);
|
|
37
|
+
this.code = code;
|
|
38
|
+
this.message = message;
|
|
39
|
+
this.suggestions = suggestions;
|
|
40
|
+
this.ref = ref;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
export class AmbiguousTaskError extends EMBError {
|
|
44
|
+
options;
|
|
45
|
+
constructor(msg, options) {
|
|
46
|
+
super('AMBIG_TASK', msg);
|
|
47
|
+
this.options = options;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
export class UnkownReferenceError extends EMBError {
|
|
51
|
+
constructor(msg) {
|
|
52
|
+
super('UNKNOWN_REF', msg);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
export class TaskNameCollisionError extends EMBError {
|
|
56
|
+
collisions;
|
|
57
|
+
constructor(msg, collisions) {
|
|
58
|
+
super('UNKNOWN_REF', msg);
|
|
59
|
+
this.collisions = collisions;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
export class CircularDependencyError extends EMBError {
|
|
63
|
+
constructor(msg) {
|
|
64
|
+
super('CIRCULAR_DEPS', msg);
|
|
65
|
+
}
|
|
66
|
+
}
|
package/dist/src/index.d.ts
CHANGED
package/dist/src/index.js
CHANGED
|
@@ -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,16 @@ 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;
|
|
27
|
+
private installEnv;
|
|
25
28
|
init(): Promise<Monorepo>;
|
|
26
29
|
join(...paths: string[]): string;
|
|
27
30
|
run<I, O>(operation: IOperation<I, O>, args: I): Promise<O>;
|