@enspirit/emb 0.0.9 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +50 -28
- package/dist/src/cli/abstract/BaseCommand.d.ts +6 -0
- package/dist/src/cli/abstract/BaseCommand.js +33 -0
- package/dist/src/cli/abstract/FlavouredCommand.d.ts +2 -1
- package/dist/src/cli/abstract/FlavouredCommand.js +4 -3
- package/dist/src/cli/abstract/index.d.ts +1 -0
- package/dist/src/cli/abstract/index.js +1 -0
- package/dist/src/cli/commands/clean.d.ts +2 -2
- package/dist/src/cli/commands/clean.js +7 -6
- package/dist/src/cli/commands/components/index.d.ts +5 -4
- package/dist/src/cli/commands/components/index.js +13 -15
- package/dist/src/cli/commands/config/print.d.ts +2 -2
- package/dist/src/cli/commands/containers/index.d.ts +2 -2
- package/dist/src/cli/commands/containers/index.js +3 -3
- package/dist/src/cli/commands/containers/prune.d.ts +2 -2
- package/dist/src/cli/commands/containers/prune.js +2 -2
- package/dist/src/cli/commands/images/delete.d.ts +2 -2
- package/dist/src/cli/commands/images/delete.js +3 -2
- package/dist/src/cli/commands/images/index.d.ts +2 -2
- package/dist/src/cli/commands/images/index.js +3 -3
- package/dist/src/cli/commands/images/prune.d.ts +2 -2
- package/dist/src/cli/commands/images/prune.js +3 -2
- package/dist/src/cli/commands/{components → resources}/build.d.ts +3 -3
- package/dist/src/cli/commands/{components → resources}/build.js +11 -10
- package/dist/src/cli/commands/resources/index.d.ts +9 -0
- package/dist/src/cli/commands/resources/index.js +28 -0
- package/dist/src/cli/commands/tasks/index.d.ts +2 -2
- package/dist/src/cli/commands/tasks/index.js +4 -4
- package/dist/src/cli/commands/tasks/run.d.ts +2 -2
- package/dist/src/cli/commands/tasks/run.js +12 -5
- package/dist/src/cli/commands/up.js +5 -4
- package/dist/src/cli/hooks/init.js +1 -26
- package/dist/src/cli/utils.d.ts +1 -0
- package/dist/src/cli/utils.js +26 -0
- package/dist/src/config/convert.d.ts +2 -4
- package/dist/src/config/convert.js +12 -35
- package/dist/src/config/index.d.ts +3 -4
- package/dist/src/config/index.js +2 -3
- package/dist/src/config/schema.d.ts +69 -48
- package/dist/src/config/schema.json +185 -99
- package/dist/src/config/types.d.ts +13 -46
- package/dist/src/config/types.js +1 -1
- package/dist/src/config/validation.d.ts +3 -3
- package/dist/src/config/validation.js +9 -9
- package/dist/src/context.d.ts +1 -1
- package/dist/src/context.js +1 -0
- package/dist/src/docker/images/index.d.ts +0 -1
- package/dist/src/docker/images/index.js +0 -1
- package/dist/src/docker/index.d.ts +1 -1
- package/dist/src/docker/index.js +1 -1
- package/dist/src/docker/operations/containers/ExecContainerOperation.js +2 -1
- package/dist/src/docker/operations/images/BuildImageOperation.d.ts +7 -8
- package/dist/src/docker/operations/images/BuildImageOperation.js +16 -10
- package/dist/src/docker/resources/DockerImageResource.js +56 -0
- package/dist/src/docker/resources/index.d.ts +1 -0
- package/dist/src/docker/resources/index.js +1 -0
- package/dist/src/docker/utils.d.ts +1 -7
- package/dist/src/docker/utils.js +3 -7
- package/dist/src/errors.d.ts +9 -6
- package/dist/src/errors.js +15 -9
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.js +2 -0
- package/dist/src/monorepo/component.d.ts +14 -19
- package/dist/src/monorepo/component.js +42 -58
- package/dist/src/monorepo/config.d.ts +13 -15
- package/dist/src/monorepo/config.js +15 -46
- package/dist/src/monorepo/index.d.ts +1 -0
- package/dist/src/monorepo/index.js +1 -0
- package/dist/src/monorepo/monorepo.d.ts +13 -10
- package/dist/src/monorepo/monorepo.js +78 -19
- package/dist/src/monorepo/operations/components/index.d.ts +0 -1
- package/dist/src/monorepo/operations/components/index.js +0 -1
- package/dist/src/monorepo/operations/fs/CreateFileOperation.d.ts +11 -0
- package/dist/src/monorepo/operations/fs/CreateFileOperation.js +31 -0
- package/dist/src/monorepo/operations/fs/index.d.ts +1 -0
- package/dist/src/monorepo/operations/fs/index.js +1 -0
- package/dist/src/monorepo/operations/index.d.ts +1 -0
- package/dist/src/monorepo/operations/index.js +1 -0
- package/dist/src/monorepo/operations/resources/BuildResourcesOperation.d.ts +27 -0
- package/dist/src/monorepo/operations/resources/BuildResourcesOperation.js +146 -0
- package/dist/src/monorepo/operations/tasks/RunTasksOperation.js +1 -1
- package/dist/src/monorepo/plugins/{ComponentDiscoverPlugin.d.ts → AutoDockerPlugin.d.ts} +4 -4
- package/dist/src/monorepo/plugins/AutoDockerPlugin.js +46 -0
- package/dist/src/monorepo/plugins/EmbfileLoaderPlugin.js +9 -2
- package/dist/src/monorepo/plugins/index.d.ts +1 -1
- package/dist/src/monorepo/plugins/index.js +3 -3
- package/dist/src/monorepo/resources/FileResource.d.ts +1 -0
- package/dist/src/monorepo/resources/FileResource.js +13 -0
- package/dist/src/monorepo/resources/ResourceFactory.d.ts +23 -0
- package/dist/src/monorepo/resources/ResourceFactory.js +16 -0
- package/dist/src/monorepo/resources/index.d.ts +1 -0
- package/dist/src/monorepo/resources/index.js +1 -0
- package/dist/src/monorepo/store/index.d.ts +1 -1
- package/dist/src/monorepo/store/index.js +10 -2
- package/dist/src/monorepo/taskManagerFactory.d.ts +2 -2
- package/dist/src/monorepo/taskManagerFactory.js +1 -2
- package/dist/src/monorepo/types.d.ts +18 -5
- package/dist/src/monorepo/utils/{findRunOrder.d.ts → EMBCollection.d.ts} +3 -9
- package/dist/src/monorepo/utils/EMBCollection.js +101 -0
- package/dist/src/monorepo/utils/graph.d.ts +15 -0
- package/dist/src/monorepo/utils/graph.js +84 -0
- package/dist/src/monorepo/utils/index.d.ts +7 -1
- package/dist/src/monorepo/utils/index.js +14 -1
- package/dist/src/monorepo/utils/types.d.ts +2 -0
- package/dist/src/monorepo/utils/types.js +1 -0
- package/dist/src/operations/abstract/AbstractOperation.d.ts +3 -1
- package/dist/src/operations/abstract/AbstractOperation.js +3 -0
- package/dist/src/operations/types.d.ts +1 -1
- package/dist/src/prerequisites/GitPrerequisitePlugin.js +2 -2
- package/dist/src/utils/TemplateExpander.d.ts +2 -1
- package/dist/src/utils/TemplateExpander.js +3 -1
- package/oclif.manifest.json +105 -68
- package/package.json +7 -2
- package/dist/src/docker/images/buildImage.d.ts +0 -19
- package/dist/src/docker/images/buildImage.js +0 -64
- package/dist/src/docker/types.d.ts +0 -14
- package/dist/src/monorepo/operations/components/BuildComponentsOperation.d.ts +0 -23
- package/dist/src/monorepo/operations/components/BuildComponentsOperation.js +0 -157
- package/dist/src/monorepo/plugins/ComponentDiscoverPlugin.js +0 -44
- package/dist/src/monorepo/project.d.ts +0 -6
- package/dist/src/monorepo/project.js +0 -8
- package/dist/src/monorepo/utils/findRunOrder.js +0 -165
- /package/dist/src/docker/{types.js → resources/DockerImageResource.d.ts} +0 -0
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Flags } from '@oclif/core';
|
|
2
2
|
import { FlavoredCommand, getContext } from '../index.js';
|
|
3
3
|
import { ComposeUpOperation } from '../../docker/index.js';
|
|
4
|
-
import { BuildComponentsOperation } from '../../monorepo/index.js';
|
|
5
4
|
export default class UpCommand extends FlavoredCommand {
|
|
6
5
|
static description = 'Start the whole project.';
|
|
7
6
|
static enableJsonFlag = true;
|
|
@@ -17,9 +16,11 @@ export default class UpCommand extends FlavoredCommand {
|
|
|
17
16
|
async run() {
|
|
18
17
|
const { flags } = await this.parse(UpCommand);
|
|
19
18
|
const { monorepo } = getContext();
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
const buildFlags = [];
|
|
20
|
+
if (flags.force) {
|
|
21
|
+
buildFlags.push('--force');
|
|
22
|
+
}
|
|
23
|
+
await this.config.runCommand('resources:build', buildFlags);
|
|
23
24
|
await monorepo.run(new ComposeUpOperation(), {
|
|
24
25
|
forceRecreate: flags.force,
|
|
25
26
|
});
|
|
@@ -1,27 +1,2 @@
|
|
|
1
|
-
|
|
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
|
-
};
|
|
1
|
+
const hook = async function (_options) { };
|
|
27
2
|
export default hook;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getTimeAgo: (timestamp?: number) => string | undefined;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
const DATE_UNITS = {
|
|
2
|
+
day: 86_400,
|
|
3
|
+
hour: 3600,
|
|
4
|
+
minute: 60,
|
|
5
|
+
second: 1,
|
|
6
|
+
};
|
|
7
|
+
const getSecondsDiff = (timestamp) => (Date.now() - timestamp) / 1000;
|
|
8
|
+
const getUnitAndValueDate = (secondsElapsed) => {
|
|
9
|
+
for (const [unit, secondsInUnit] of Object.entries(DATE_UNITS)) {
|
|
10
|
+
if (secondsElapsed >= secondsInUnit || unit === 'second') {
|
|
11
|
+
const value = Math.floor(secondsElapsed / secondsInUnit) * -1;
|
|
12
|
+
return { value, unit: unit };
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
const value = Math.floor(secondsElapsed / DATE_UNITS.day) * -1;
|
|
16
|
+
return { value, unit: 'day' };
|
|
17
|
+
};
|
|
18
|
+
export const getTimeAgo = (timestamp) => {
|
|
19
|
+
if (!timestamp) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
const rtf = new Intl.RelativeTimeFormat();
|
|
23
|
+
const secondsElapsed = getSecondsDiff(timestamp * 1000);
|
|
24
|
+
const { value, unit } = getUnitAndValueDate(secondsElapsed);
|
|
25
|
+
return rtf.format(value, unit);
|
|
26
|
+
};
|
|
@@ -1,4 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
export declare const toFlavor: (flavor: Flavor) => FlavorConfig;
|
|
4
|
-
export declare const toProjectConfig: (config: UserConfig, rootDir?: string) => IMonorepoConfig;
|
|
1
|
+
import { EMBConfig, UserConfig } from './types.js';
|
|
2
|
+
export declare const toUserConfig: (config: EMBConfig, rootDir?: string) => UserConfig;
|
|
@@ -1,41 +1,18 @@
|
|
|
1
1
|
import { resolve } from 'node:path';
|
|
2
2
|
import { cwd } from 'node:process';
|
|
3
|
-
export const
|
|
4
|
-
|
|
5
|
-
...
|
|
6
|
-
|
|
3
|
+
export const toUserConfig = (config, rootDir) => {
|
|
4
|
+
const project = {
|
|
5
|
+
...config.project,
|
|
6
|
+
rootDir: config.project.rootDir
|
|
7
|
+
? rootDir
|
|
8
|
+
? resolve(rootDir, config.project.rootDir)
|
|
9
|
+
: config.project.rootDir
|
|
10
|
+
: rootDir || cwd(),
|
|
7
11
|
};
|
|
8
|
-
};
|
|
9
|
-
export const toProjectConfig = (config, rootDir) => {
|
|
10
|
-
const project = typeof config.project === 'string'
|
|
11
|
-
? { name: config.project }
|
|
12
|
-
: config.project;
|
|
13
|
-
if (project.rootDir) {
|
|
14
|
-
project.rootDir = rootDir
|
|
15
|
-
? resolve(rootDir, project.rootDir)
|
|
16
|
-
: project.rootDir;
|
|
17
|
-
}
|
|
18
|
-
else {
|
|
19
|
-
project.rootDir = rootDir || cwd();
|
|
20
|
-
}
|
|
21
|
-
const components = config.components || [];
|
|
22
|
-
const { defaults, flavors, ...rest } = config;
|
|
23
12
|
return {
|
|
24
|
-
...
|
|
25
|
-
components,
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
docker: {
|
|
29
|
-
...defaults?.docker,
|
|
30
|
-
labels: {
|
|
31
|
-
...defaults?.docker?.labels,
|
|
32
|
-
'emb/project': project.name,
|
|
33
|
-
},
|
|
34
|
-
},
|
|
35
|
-
},
|
|
36
|
-
flavors: flavors?.map(toFlavor),
|
|
37
|
-
project: {
|
|
38
|
-
...project,
|
|
39
|
-
},
|
|
13
|
+
...config,
|
|
14
|
+
components: config.components || {},
|
|
15
|
+
flavors: config.flavors || {},
|
|
16
|
+
project,
|
|
40
17
|
};
|
|
41
18
|
};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { UserConfig } from './types.js';
|
|
2
2
|
export * from './convert.js';
|
|
3
|
-
export * from './schema.js';
|
|
4
3
|
export * from './types.js';
|
|
5
4
|
export * from './validation.js';
|
|
6
|
-
export declare const loadConfig: (force?: boolean) => Promise<
|
|
7
|
-
export declare const getConfig: () =>
|
|
5
|
+
export declare const loadConfig: (force?: boolean) => Promise<UserConfig>;
|
|
6
|
+
export declare const getConfig: () => UserConfig;
|
package/dist/src/config/index.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { findUp } from 'find-up';
|
|
2
2
|
import { dirname } from 'node:path';
|
|
3
|
-
import {
|
|
3
|
+
import { toUserConfig } from './convert.js';
|
|
4
4
|
import { validateUserConfig } from './validation.js';
|
|
5
5
|
export * from './convert.js';
|
|
6
|
-
export * from './schema.js';
|
|
7
6
|
export * from './types.js';
|
|
8
7
|
export * from './validation.js';
|
|
9
8
|
let config;
|
|
@@ -15,7 +14,7 @@ export const loadConfig = async (force = false) => {
|
|
|
15
14
|
if (!path) {
|
|
16
15
|
throw new Error('Could not find EMB config anywhere');
|
|
17
16
|
}
|
|
18
|
-
config =
|
|
17
|
+
config = toUserConfig(await validateUserConfig(path), dirname(path));
|
|
19
18
|
return config;
|
|
20
19
|
};
|
|
21
20
|
export const getConfig = () => {
|
|
@@ -3,21 +3,30 @@
|
|
|
3
3
|
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
|
|
4
4
|
* and run json-schema-to-typescript to regenerate this file.
|
|
5
5
|
*/
|
|
6
|
-
export type
|
|
7
|
-
|
|
6
|
+
export type Identifier = string;
|
|
7
|
+
export type TaskConfig = TaskConfig1 & {
|
|
8
8
|
description?: string;
|
|
9
9
|
script?: string;
|
|
10
|
-
executor?:
|
|
10
|
+
executor?: Identifier;
|
|
11
11
|
options?: {
|
|
12
12
|
[k: string]: unknown;
|
|
13
13
|
};
|
|
14
|
-
pre?:
|
|
14
|
+
pre?: Identifier[];
|
|
15
15
|
};
|
|
16
|
-
export type
|
|
16
|
+
export type TaskConfig1 = {
|
|
17
17
|
[k: string]: unknown;
|
|
18
18
|
};
|
|
19
|
-
export
|
|
20
|
-
|
|
19
|
+
export type ResourceConfig = {
|
|
20
|
+
[k: string]: unknown;
|
|
21
|
+
} & {
|
|
22
|
+
type: string;
|
|
23
|
+
params?: unknown;
|
|
24
|
+
dependencies?: QualifiedIdentifier[];
|
|
25
|
+
};
|
|
26
|
+
export type QualifiedIdentifier = string;
|
|
27
|
+
export type JsonPatchOperation = JsonPatchAddOperation | JsonPatchRemoveOperation | JsonPatchReplaceOperation | JsonPatchMoveOperation | JsonPatchCopyOperation;
|
|
28
|
+
export interface EMBConfig {
|
|
29
|
+
project: {
|
|
21
30
|
/**
|
|
22
31
|
* The name of the project.
|
|
23
32
|
*/
|
|
@@ -28,7 +37,7 @@ export interface EMBConfigSchema {
|
|
|
28
37
|
rootDir?: string;
|
|
29
38
|
};
|
|
30
39
|
plugins?: {
|
|
31
|
-
name:
|
|
40
|
+
name: Identifier;
|
|
32
41
|
config?: unknown;
|
|
33
42
|
}[];
|
|
34
43
|
/**
|
|
@@ -43,21 +52,27 @@ export interface EMBConfigSchema {
|
|
|
43
52
|
vars?: {
|
|
44
53
|
[k: string]: unknown;
|
|
45
54
|
};
|
|
46
|
-
defaults?:
|
|
47
|
-
components?:
|
|
48
|
-
|
|
49
|
-
|
|
55
|
+
defaults?: DefaultsConfig;
|
|
56
|
+
components?: {
|
|
57
|
+
[k: string]: ComponentConfig;
|
|
58
|
+
};
|
|
59
|
+
flavors?: {
|
|
60
|
+
[k: string]: ProjectFlavorConfig;
|
|
61
|
+
};
|
|
62
|
+
tasks?: {
|
|
63
|
+
[k: string]: TaskConfig;
|
|
64
|
+
};
|
|
50
65
|
}
|
|
51
66
|
/**
|
|
52
67
|
* Default settings for build aspects
|
|
53
68
|
*/
|
|
54
|
-
export interface
|
|
69
|
+
export interface DefaultsConfig {
|
|
55
70
|
/**
|
|
56
71
|
* Default docker build settings
|
|
57
72
|
*/
|
|
58
73
|
docker?: {
|
|
59
74
|
tag?: string;
|
|
60
|
-
target?:
|
|
75
|
+
target?: Identifier;
|
|
61
76
|
buildArgs?: {
|
|
62
77
|
[k: string]: string;
|
|
63
78
|
};
|
|
@@ -67,43 +82,49 @@ export interface Defaults {
|
|
|
67
82
|
[k: string]: unknown;
|
|
68
83
|
};
|
|
69
84
|
}
|
|
70
|
-
export interface
|
|
71
|
-
/**
|
|
72
|
-
* The name of the component.
|
|
73
|
-
*/
|
|
74
|
-
name: string;
|
|
75
|
-
docker?: {
|
|
76
|
-
/**
|
|
77
|
-
* The directory of the component.
|
|
78
|
-
*/
|
|
79
|
-
context?: string;
|
|
80
|
-
buildArgs?: {
|
|
81
|
-
[k: string]: string;
|
|
82
|
-
};
|
|
83
|
-
dependencies?: string[];
|
|
84
|
-
/**
|
|
85
|
-
* The stage to target for the build
|
|
86
|
-
*/
|
|
87
|
-
target?: string;
|
|
88
|
-
/**
|
|
89
|
-
* The Dockerfile to use
|
|
90
|
-
*/
|
|
91
|
-
dockerfile?: string;
|
|
92
|
-
};
|
|
85
|
+
export interface ComponentConfig {
|
|
93
86
|
/**
|
|
94
87
|
* A description of the component.
|
|
95
88
|
*/
|
|
96
89
|
description?: string;
|
|
97
|
-
tasks?:
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
* Variables to install on the environment
|
|
103
|
-
*/
|
|
104
|
-
env?: {
|
|
105
|
-
[k: string]: string;
|
|
90
|
+
tasks?: {
|
|
91
|
+
[k: string]: TaskConfig;
|
|
92
|
+
};
|
|
93
|
+
resources?: {
|
|
94
|
+
[k: string]: ResourceConfig;
|
|
106
95
|
};
|
|
107
|
-
|
|
108
|
-
|
|
96
|
+
flavors?: {
|
|
97
|
+
[k: string]: ComponentFlavorConfig;
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
export interface ComponentFlavorConfig {
|
|
101
|
+
patches?: JsonPatchOperation[];
|
|
102
|
+
}
|
|
103
|
+
export interface JsonPatchAddOperation {
|
|
104
|
+
op: "add";
|
|
105
|
+
path: string;
|
|
106
|
+
value: unknown;
|
|
107
|
+
}
|
|
108
|
+
export interface JsonPatchRemoveOperation {
|
|
109
|
+
op: "remove";
|
|
110
|
+
path: string;
|
|
111
|
+
}
|
|
112
|
+
export interface JsonPatchReplaceOperation {
|
|
113
|
+
op: "replace";
|
|
114
|
+
path: string;
|
|
115
|
+
value: unknown;
|
|
116
|
+
}
|
|
117
|
+
export interface JsonPatchMoveOperation {
|
|
118
|
+
op: "move";
|
|
119
|
+
path: string;
|
|
120
|
+
from: string;
|
|
121
|
+
}
|
|
122
|
+
export interface JsonPatchCopyOperation {
|
|
123
|
+
op: "copy";
|
|
124
|
+
path: string;
|
|
125
|
+
from: string;
|
|
126
|
+
}
|
|
127
|
+
export interface ProjectFlavorConfig {
|
|
128
|
+
defaults?: DefaultsConfig;
|
|
129
|
+
patches?: JsonPatchOperation[];
|
|
109
130
|
}
|