@wocker/core 1.0.25-beta.0 → 1.0.25-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/core/ApplicationContext.js +29 -24
- package/lib/core/AsyncStorage.d.ts +3 -0
- package/lib/core/AsyncStorage.js +5 -0
- package/lib/core/Container.d.ts +1 -0
- package/lib/core/Container.js +6 -0
- package/lib/core/index.d.ts +1 -0
- package/lib/core/index.js +1 -0
- package/lib/makes/Logger.d.ts +1 -2
- package/lib/makes/Logger.js +17 -19
- package/lib/makes/Preset.d.ts +1 -1
- package/lib/makes/Project.d.ts +2 -6
- package/lib/makes/Project.js +0 -21
- package/lib/services/AppConfigService.d.ts +3 -1
- package/lib/services/AppConfigService.js +13 -8
- package/lib/services/AppFileSystemService.d.ts +1 -1
- package/lib/services/AppFileSystemService.js +2 -2
- package/lib/services/DockerService.d.ts +6 -1
- package/lib/services/ModemService.js +1 -1
- package/lib/types/PresetRef.d.ts +1 -1
- package/package.json +2 -2
|
@@ -11,6 +11,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.ApplicationContext = void 0;
|
|
13
13
|
const cli_1 = require("@kearisp/cli");
|
|
14
|
+
const AsyncStorage_1 = require("./AsyncStorage");
|
|
14
15
|
class ApplicationContext {
|
|
15
16
|
constructor(module, container) {
|
|
16
17
|
this.module = module;
|
|
@@ -29,33 +30,37 @@ class ApplicationContext {
|
|
|
29
30
|
}
|
|
30
31
|
run(args) {
|
|
31
32
|
return __awaiter(this, void 0, void 0, function* () {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
33
|
+
return new Promise((resolve) => {
|
|
34
|
+
AsyncStorage_1.AsyncStorage.run(this.container, () => {
|
|
35
|
+
const cli = this.get(cli_1.Cli);
|
|
36
|
+
cli.command("").action(() => {
|
|
37
|
+
for (const [, module] of this.container.modules) {
|
|
38
|
+
for (const [, container] of module.controllers) {
|
|
39
|
+
if (!container.description) {
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
console.info(`${container.description}:`);
|
|
43
|
+
const spaceLength = container.commands.reduce((space, route) => {
|
|
44
|
+
return route.commandNames.reduce((space, command) => {
|
|
45
|
+
return Math.max(space, command.length + 2);
|
|
46
|
+
}, space);
|
|
47
|
+
}, 0);
|
|
48
|
+
for (const route of container.commands) {
|
|
49
|
+
if (!route.description) {
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
for (const commandName of route.commandNames) {
|
|
53
|
+
const space = " ".repeat(Math.max(0, spaceLength - commandName.length));
|
|
54
|
+
console.info(` ${commandName} ${space} ${route.description}`);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
console.info("");
|
|
52
58
|
}
|
|
53
59
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}
|
|
60
|
+
});
|
|
61
|
+
return resolve(cli.run(args));
|
|
62
|
+
});
|
|
57
63
|
});
|
|
58
|
-
return cli.run(args);
|
|
59
64
|
});
|
|
60
65
|
}
|
|
61
66
|
}
|
package/lib/core/Container.d.ts
CHANGED
|
@@ -10,5 +10,6 @@ export declare class Container {
|
|
|
10
10
|
hasModule<TInput = any>(type: Type<TInput>): boolean;
|
|
11
11
|
getModule<TInput = any>(type: Type<TInput>): ModuleWrapper<TInput>;
|
|
12
12
|
addProvider(type: InjectionToken, wrapper: InstanceWrapper): void;
|
|
13
|
+
getProvider(type: InjectionToken): InstanceWrapper | undefined;
|
|
13
14
|
replace(type: InjectionToken, provider: ProviderType): void;
|
|
14
15
|
}
|
package/lib/core/Container.js
CHANGED
|
@@ -31,6 +31,12 @@ class Container {
|
|
|
31
31
|
: type;
|
|
32
32
|
this.globalProviders.set(token, wrapper);
|
|
33
33
|
}
|
|
34
|
+
getProvider(type) {
|
|
35
|
+
const token = typeof type !== "string"
|
|
36
|
+
? Reflect.getMetadata(env_1.INJECT_TOKEN_METADATA, type) || type
|
|
37
|
+
: type;
|
|
38
|
+
return this.globalProviders.get(token);
|
|
39
|
+
}
|
|
34
40
|
replace(type, provider) {
|
|
35
41
|
const token = typeof type !== "string"
|
|
36
42
|
? Reflect.getMetadata(env_1.INJECT_TOKEN_METADATA, type) || type
|
package/lib/core/index.d.ts
CHANGED
package/lib/core/index.js
CHANGED
|
@@ -14,6 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./AsyncStorage"), exports);
|
|
17
18
|
__exportStar(require("./ApplicationContext"), exports);
|
|
18
19
|
__exportStar(require("./Container"), exports);
|
|
19
20
|
__exportStar(require("./Factory"), exports);
|
package/lib/makes/Logger.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { LogService } from "../services/LogService";
|
|
2
1
|
export declare class Logger {
|
|
3
|
-
static
|
|
2
|
+
protected static getLogService(): any | undefined;
|
|
4
3
|
static log(...data: any[]): void;
|
|
5
4
|
static info(...data: any[]): void;
|
|
6
5
|
static warn(...data: any[]): void;
|
package/lib/makes/Logger.js
CHANGED
|
@@ -1,34 +1,32 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Logger = void 0;
|
|
4
|
-
|
|
4
|
+
const core_1 = require("../core");
|
|
5
|
+
const services_1 = require("../services");
|
|
5
6
|
class Logger {
|
|
6
|
-
static
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
if (!loggerService) {
|
|
7
|
+
static getLogService() {
|
|
8
|
+
var _a;
|
|
9
|
+
const container = core_1.AsyncStorage.getStore();
|
|
10
|
+
if (!container) {
|
|
11
11
|
return;
|
|
12
12
|
}
|
|
13
|
-
|
|
13
|
+
return (_a = container.getProvider(services_1.LogService)) === null || _a === void 0 ? void 0 : _a.instance;
|
|
14
|
+
}
|
|
15
|
+
static log(...data) {
|
|
16
|
+
var _a;
|
|
17
|
+
(_a = Logger.getLogService()) === null || _a === void 0 ? void 0 : _a.log(...data);
|
|
14
18
|
}
|
|
15
19
|
static info(...data) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
loggerService.info(...data);
|
|
20
|
+
var _a;
|
|
21
|
+
(_a = Logger.getLogService()) === null || _a === void 0 ? void 0 : _a.info(...data);
|
|
20
22
|
}
|
|
21
23
|
static warn(...data) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
loggerService.warn(...data);
|
|
24
|
+
var _a;
|
|
25
|
+
(_a = Logger.getLogService()) === null || _a === void 0 ? void 0 : _a.warn(...data);
|
|
26
26
|
}
|
|
27
27
|
static error(...data) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
loggerService.error(...data);
|
|
28
|
+
var _a;
|
|
29
|
+
(_a = Logger.getLogService()) === null || _a === void 0 ? void 0 : _a.error(...data);
|
|
32
30
|
}
|
|
33
31
|
}
|
|
34
32
|
exports.Logger = Logger;
|
package/lib/makes/Preset.d.ts
CHANGED
package/lib/makes/Project.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export type ProjectProperties = Omit<PickProperties<Project>, "containerName" |
|
|
|
4
4
|
export declare abstract class Project {
|
|
5
5
|
id: string;
|
|
6
6
|
name: string;
|
|
7
|
-
type:
|
|
7
|
+
type: ProjectType;
|
|
8
8
|
path: string;
|
|
9
9
|
preset?: string;
|
|
10
10
|
presetMode?: "global" | "project";
|
|
@@ -18,7 +18,7 @@ export declare abstract class Project {
|
|
|
18
18
|
metadata?: EnvConfig;
|
|
19
19
|
ports?: string[];
|
|
20
20
|
volumes?: string[];
|
|
21
|
-
|
|
21
|
+
constructor(data: ProjectProperties);
|
|
22
22
|
get containerName(): string;
|
|
23
23
|
get domains(): string[];
|
|
24
24
|
hasDomain(domain: string): boolean;
|
|
@@ -45,10 +45,6 @@ export declare abstract class Project {
|
|
|
45
45
|
abstract getSecret(key: string, byDefault?: string): Promise<string | undefined>;
|
|
46
46
|
abstract setSecret(key: string, value: string): Promise<void>;
|
|
47
47
|
abstract save(): void;
|
|
48
|
-
/**
|
|
49
|
-
* @deprecated
|
|
50
|
-
*/
|
|
51
|
-
toJSON(): ProjectProperties;
|
|
52
48
|
toObject(): ProjectProperties;
|
|
53
49
|
}
|
|
54
50
|
export declare const PROJECT_TYPE_DOCKERFILE = "dockerfile";
|
package/lib/makes/Project.js
CHANGED
|
@@ -4,21 +4,6 @@ exports.PROJECT_TYPE_COMPOSE = exports.PROJECT_TYPE_PRESET = exports.PROJECT_TYP
|
|
|
4
4
|
const volumeParse_1 = require("../utils/volumeParse");
|
|
5
5
|
class Project {
|
|
6
6
|
constructor(data) {
|
|
7
|
-
this.id = data.id;
|
|
8
|
-
this.name = data.name;
|
|
9
|
-
this.type = data.type;
|
|
10
|
-
this.path = data.path;
|
|
11
|
-
this.preset = data.preset;
|
|
12
|
-
this.presetMode = data.presetMode;
|
|
13
|
-
this.imageName = data.imageName;
|
|
14
|
-
this.dockerfile = data.dockerfile;
|
|
15
|
-
this.scripts = data.scripts;
|
|
16
|
-
this.buildArgs = data.buildArgs;
|
|
17
|
-
this.env = data.env;
|
|
18
|
-
this.ports = data.ports;
|
|
19
|
-
this.volumes = data.volumes;
|
|
20
|
-
this.extraHosts = data.extraHosts;
|
|
21
|
-
this.metadata = data.metadata;
|
|
22
7
|
Object.assign(this, data);
|
|
23
8
|
}
|
|
24
9
|
get containerName() {
|
|
@@ -187,12 +172,6 @@ class Project {
|
|
|
187
172
|
delete this.extraHosts;
|
|
188
173
|
}
|
|
189
174
|
}
|
|
190
|
-
/**
|
|
191
|
-
* @deprecated
|
|
192
|
-
*/
|
|
193
|
-
toJSON() {
|
|
194
|
-
return this.toObject();
|
|
195
|
-
}
|
|
196
175
|
toObject() {
|
|
197
176
|
return {
|
|
198
177
|
id: this.id,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { AppConfig
|
|
1
|
+
import { AppConfig } from "../makes/AppConfig";
|
|
2
|
+
import { PresetSource } from "../makes/Preset";
|
|
2
3
|
import { ProjectRef } from "../types/ProjectRef";
|
|
3
4
|
import { PluginRef } from "../types/PluginRef";
|
|
4
5
|
import { AppFileSystemService } from "./AppFileSystemService";
|
|
@@ -50,6 +51,7 @@ export declare class AppConfigService {
|
|
|
50
51
|
getMeta(name: string, byDefault: string): string;
|
|
51
52
|
setMeta(name: string, value: string): void;
|
|
52
53
|
unsetMeta(name: string): void;
|
|
54
|
+
isExperimentalEnabled(key: string): boolean;
|
|
53
55
|
getProjectTypes(): TypeMap;
|
|
54
56
|
save(): void;
|
|
55
57
|
}
|
|
@@ -18,7 +18,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
18
18
|
exports.AppConfigService = void 0;
|
|
19
19
|
const path_1 = __importDefault(require("path"));
|
|
20
20
|
const decorators_1 = require("../decorators");
|
|
21
|
-
const
|
|
21
|
+
const AppConfig_1 = require("../makes/AppConfig");
|
|
22
|
+
const Project_1 = require("../makes/Project");
|
|
22
23
|
const AppFileSystemService_1 = require("./AppFileSystemService");
|
|
23
24
|
const ProcessService_1 = require("./ProcessService");
|
|
24
25
|
const env_1 = require("../env");
|
|
@@ -28,15 +29,16 @@ let AppConfigService = class AppConfigService {
|
|
|
28
29
|
this.processService = processService;
|
|
29
30
|
this.fs = fs;
|
|
30
31
|
this.mapTypes = {
|
|
31
|
-
[
|
|
32
|
-
[
|
|
33
|
-
[
|
|
32
|
+
[Project_1.PROJECT_TYPE_PRESET]: "Preset",
|
|
33
|
+
[Project_1.PROJECT_TYPE_IMAGE]: "Image",
|
|
34
|
+
[Project_1.PROJECT_TYPE_DOCKERFILE]: "Dockerfile"
|
|
34
35
|
};
|
|
35
36
|
this._pwd = (process.cwd() || process.env.PWD);
|
|
36
37
|
}
|
|
37
38
|
get experimentalFeatures() {
|
|
38
39
|
return [
|
|
39
|
-
"projectComposeType"
|
|
40
|
+
"projectComposeType",
|
|
41
|
+
"buildKit"
|
|
40
42
|
];
|
|
41
43
|
}
|
|
42
44
|
get debug() {
|
|
@@ -83,7 +85,7 @@ let AppConfigService = class AppConfigService {
|
|
|
83
85
|
recursive: true
|
|
84
86
|
});
|
|
85
87
|
}
|
|
86
|
-
this._config = new
|
|
88
|
+
this._config = new AppConfig_1.AppConfig(data);
|
|
87
89
|
}
|
|
88
90
|
return this._config;
|
|
89
91
|
}
|
|
@@ -163,9 +165,12 @@ let AppConfigService = class AppConfigService {
|
|
|
163
165
|
unsetMeta(name) {
|
|
164
166
|
this.config.unsetMeta(name);
|
|
165
167
|
}
|
|
168
|
+
isExperimentalEnabled(key) {
|
|
169
|
+
return this.config.getMeta(`experimental.${key}`) === "enabled";
|
|
170
|
+
}
|
|
166
171
|
getProjectTypes() {
|
|
167
|
-
if (this.
|
|
168
|
-
return Object.assign(Object.assign({}, this.mapTypes), { [
|
|
172
|
+
if (this.isExperimentalEnabled("projectComposeType")) {
|
|
173
|
+
return Object.assign(Object.assign({}, this.mapTypes), { [Project_1.PROJECT_TYPE_COMPOSE]: "Docker compose" });
|
|
169
174
|
}
|
|
170
175
|
return this.mapTypes;
|
|
171
176
|
}
|
|
@@ -14,9 +14,9 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.AppFileSystemService = void 0;
|
|
16
16
|
const decorators_1 = require("../decorators");
|
|
17
|
-
const
|
|
17
|
+
const FileSystem_1 = require("../makes/FileSystem");
|
|
18
18
|
const env_1 = require("../env");
|
|
19
|
-
let AppFileSystemService = class AppFileSystemService extends
|
|
19
|
+
let AppFileSystemService = class AppFileSystemService extends FileSystem_1.FileSystem {
|
|
20
20
|
constructor(dataDir) {
|
|
21
21
|
super(dataDir);
|
|
22
22
|
}
|
|
@@ -38,6 +38,7 @@ export declare namespace DockerServiceParams {
|
|
|
38
38
|
};
|
|
39
39
|
};
|
|
40
40
|
type BuildImage = {
|
|
41
|
+
version?: "1" | "2";
|
|
41
42
|
tag: string;
|
|
42
43
|
buildArgs?: {
|
|
43
44
|
[key: string]: string;
|
|
@@ -46,8 +47,12 @@ export declare namespace DockerServiceParams {
|
|
|
46
47
|
[key: string]: string;
|
|
47
48
|
};
|
|
48
49
|
context: string;
|
|
50
|
+
} & ({
|
|
51
|
+
/** @deprecated */
|
|
49
52
|
src: string;
|
|
50
|
-
}
|
|
53
|
+
} | {
|
|
54
|
+
dockerfile: string;
|
|
55
|
+
});
|
|
51
56
|
type Exec = {
|
|
52
57
|
cmd: string[];
|
|
53
58
|
tty?: boolean;
|
package/lib/types/PresetRef.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wocker/core",
|
|
3
|
-
"version": "1.0.25-beta.
|
|
3
|
+
"version": "1.0.25-beta.1",
|
|
4
4
|
"author": "Kris Papercut <krispcut@gmail.com>",
|
|
5
5
|
"description": "Core of the Wocker",
|
|
6
6
|
"license": "MIT",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"@types/docker-modem": "^3.0.6",
|
|
41
41
|
"@types/dockerode": "^3.3.23",
|
|
42
42
|
"@types/jest": "^29.5.14",
|
|
43
|
-
"@types/node": "^
|
|
43
|
+
"@types/node": "^24.0.13",
|
|
44
44
|
"jest": "^29.7.0",
|
|
45
45
|
"make-coverage-badge": "^1.2.0",
|
|
46
46
|
"memfs": "^4.17.1",
|