@wocker/core 1.0.11 → 1.0.13
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/decorators/Command.js +1 -1
- package/lib/decorators/Completion.js +4 -3
- package/lib/makes/FS.d.ts +0 -4
- package/lib/makes/FSManager.d.ts +0 -1
- package/lib/makes/FileSystem.d.ts +0 -1
- package/lib/makes/Preset.d.ts +4 -1
- package/lib/makes/Preset.js +1 -0
- package/lib/makes/Project.d.ts +9 -1
- package/lib/makes/Project.js +55 -1
- package/lib/services/DockerService.d.ts +1 -3
- package/lib/services/PluginConfigService.d.ts +0 -2
- package/lib/services/ProxyService.d.ts +3 -0
- package/lib/services/ProxyService.js +16 -0
- package/lib/services/index.d.ts +1 -0
- package/lib/services/index.js +1 -0
- package/lib/types/Volume.d.ts +5 -0
- package/lib/types/Volume.js +2 -0
- package/lib/types/index.d.ts +1 -0
- package/lib/types/index.js +1 -0
- package/lib/utils/volumeFormat.d.ts +1 -5
- package/lib/utils/volumeParse.d.ts +1 -1
- package/package.json +6 -6
|
@@ -4,7 +4,7 @@ exports.Command = void 0;
|
|
|
4
4
|
require("reflect-metadata");
|
|
5
5
|
const env_1 = require("../env");
|
|
6
6
|
const Command = (command) => {
|
|
7
|
-
return (
|
|
7
|
+
return (_target, _key, descriptor) => {
|
|
8
8
|
Reflect.defineMetadata(env_1.COMMAND_METADATA, command, descriptor.value);
|
|
9
9
|
};
|
|
10
10
|
};
|
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Completion = void 0;
|
|
4
4
|
require("reflect-metadata");
|
|
5
|
+
const env_1 = require("../env");
|
|
5
6
|
const Completion = (name, command) => {
|
|
6
|
-
return (
|
|
7
|
-
Reflect.defineMetadata(
|
|
8
|
-
...Reflect.getMetadata(
|
|
7
|
+
return (_target, _propertyKey, descriptor) => {
|
|
8
|
+
Reflect.defineMetadata(env_1.COMPLETION_METADATA, [
|
|
9
|
+
...Reflect.getMetadata(env_1.COMPLETION_METADATA, descriptor.value) || [],
|
|
9
10
|
{
|
|
10
11
|
name,
|
|
11
12
|
command
|
package/lib/makes/FS.d.ts
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/// <reference types="node" />
|
|
3
|
-
/// <reference types="node" />
|
|
4
|
-
/// <reference types="node" />
|
|
5
1
|
import { Abortable } from "node:events";
|
|
6
2
|
import { PathLike, PathOrFileDescriptor, WriteFileOptions, RmOptions, MakeDirectoryOptions } from "fs";
|
|
7
3
|
type ReadFileOptions = Abortable & {
|
package/lib/makes/FSManager.d.ts
CHANGED
package/lib/makes/Preset.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { PickProperties } from "../types";
|
|
1
2
|
type TextOption = {
|
|
2
3
|
type: "string" | "number" | "int";
|
|
3
4
|
message?: string;
|
|
@@ -20,6 +21,7 @@ type SelectOption = {
|
|
|
20
21
|
default?: string;
|
|
21
22
|
};
|
|
22
23
|
type AnyOption = TextOption | ConfirmOption | SelectOption;
|
|
24
|
+
export type PresetProperties = PickProperties<Preset>;
|
|
23
25
|
export declare abstract class Preset {
|
|
24
26
|
id: string;
|
|
25
27
|
name: string;
|
|
@@ -31,9 +33,10 @@ export declare abstract class Preset {
|
|
|
31
33
|
envOptions?: {
|
|
32
34
|
[name: string]: AnyOption;
|
|
33
35
|
};
|
|
36
|
+
path: string;
|
|
34
37
|
volumes?: string[];
|
|
35
38
|
volumeOptions?: string[];
|
|
36
|
-
protected constructor(data:
|
|
39
|
+
protected constructor(data: PresetProperties);
|
|
37
40
|
abstract save(): Promise<void>;
|
|
38
41
|
}
|
|
39
42
|
export {};
|
package/lib/makes/Preset.js
CHANGED
package/lib/makes/Project.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PickProperties, EnvConfig } from "../types";
|
|
2
|
-
export type ProjectProperties = Omit<PickProperties<Project>, "containerName">;
|
|
2
|
+
export type ProjectProperties = Omit<PickProperties<Project>, "containerName" | "domains">;
|
|
3
3
|
export declare abstract class Project {
|
|
4
4
|
id: string;
|
|
5
5
|
name: string;
|
|
@@ -16,6 +16,13 @@ export declare abstract class Project {
|
|
|
16
16
|
metadata?: EnvConfig;
|
|
17
17
|
protected constructor(data: ProjectProperties);
|
|
18
18
|
get containerName(): string;
|
|
19
|
+
get domains(): string[];
|
|
20
|
+
hasDomain(domain: string): boolean;
|
|
21
|
+
addDomain(addDomain: string): void;
|
|
22
|
+
removeDomain(removeDomain: string): void;
|
|
23
|
+
clearDomains(): void;
|
|
24
|
+
linkPort(hostPort: number, containerPort: number): void;
|
|
25
|
+
unlinkPort(hostPort: number, containerPort: number): void;
|
|
19
26
|
hasEnv(name: string): boolean;
|
|
20
27
|
getEnv(name: string, defaultValue?: string): string | undefined;
|
|
21
28
|
setEnv(name: string, value: string | boolean): void;
|
|
@@ -33,3 +40,4 @@ export declare abstract class Project {
|
|
|
33
40
|
}
|
|
34
41
|
export declare const PROJECT_TYPE_DOCKERFILE = "dockerfile";
|
|
35
42
|
export declare const PROJECT_TYPE_IMAGE = "image";
|
|
43
|
+
export declare const PROJECT_TYPE_PRESET = "preset";
|
package/lib/makes/Project.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PROJECT_TYPE_IMAGE = exports.PROJECT_TYPE_DOCKERFILE = exports.Project = void 0;
|
|
3
|
+
exports.PROJECT_TYPE_PRESET = exports.PROJECT_TYPE_IMAGE = exports.PROJECT_TYPE_DOCKERFILE = exports.Project = void 0;
|
|
4
4
|
const volumeParse_1 = require("../utils/volumeParse");
|
|
5
5
|
class Project {
|
|
6
6
|
constructor(data) {
|
|
@@ -22,6 +22,59 @@ class Project {
|
|
|
22
22
|
get containerName() {
|
|
23
23
|
return `${this.name}.workspace`;
|
|
24
24
|
}
|
|
25
|
+
get domains() {
|
|
26
|
+
const host = this.getEnv("VIRTUAL_HOST");
|
|
27
|
+
if (!host) {
|
|
28
|
+
return [];
|
|
29
|
+
}
|
|
30
|
+
return host.split(",");
|
|
31
|
+
}
|
|
32
|
+
hasDomain(domain) {
|
|
33
|
+
return this.domains.includes(domain);
|
|
34
|
+
}
|
|
35
|
+
addDomain(addDomain) {
|
|
36
|
+
let domains = [
|
|
37
|
+
...this.domains.filter((domain) => {
|
|
38
|
+
return domain !== addDomain;
|
|
39
|
+
}),
|
|
40
|
+
addDomain
|
|
41
|
+
];
|
|
42
|
+
this.setEnv("VIRTUAL_HOST", domains.join(","));
|
|
43
|
+
}
|
|
44
|
+
removeDomain(removeDomain) {
|
|
45
|
+
if (!this.hasDomain(removeDomain)) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
let domains = this.domains.filter((domain) => {
|
|
49
|
+
return domain !== removeDomain;
|
|
50
|
+
});
|
|
51
|
+
this.setEnv("VIRTUAL_HOST", domains.join(","));
|
|
52
|
+
}
|
|
53
|
+
clearDomains() {
|
|
54
|
+
this.unsetEnv("VIRTUAL_HOST");
|
|
55
|
+
}
|
|
56
|
+
linkPort(hostPort, containerPort) {
|
|
57
|
+
if (!this.ports) {
|
|
58
|
+
this.ports = [];
|
|
59
|
+
}
|
|
60
|
+
this.ports = [
|
|
61
|
+
...this.ports.filter((link) => {
|
|
62
|
+
return link !== `${hostPort}:${containerPort}`;
|
|
63
|
+
}),
|
|
64
|
+
`${hostPort}:${containerPort}`
|
|
65
|
+
];
|
|
66
|
+
}
|
|
67
|
+
unlinkPort(hostPort, containerPort) {
|
|
68
|
+
if (!this.ports) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
this.ports = this.ports.filter((link) => {
|
|
72
|
+
return link !== `${hostPort}:${containerPort}`;
|
|
73
|
+
});
|
|
74
|
+
if (this.ports.length === 0) {
|
|
75
|
+
delete this.ports;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
25
78
|
hasEnv(name) {
|
|
26
79
|
if (!this.env) {
|
|
27
80
|
return false;
|
|
@@ -127,3 +180,4 @@ class Project {
|
|
|
127
180
|
exports.Project = Project;
|
|
128
181
|
exports.PROJECT_TYPE_DOCKERFILE = "dockerfile";
|
|
129
182
|
exports.PROJECT_TYPE_IMAGE = "image";
|
|
183
|
+
exports.PROJECT_TYPE_PRESET = "preset";
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/// <reference types="node" />
|
|
3
1
|
import { Container, ImageInfo } from "dockerode";
|
|
4
2
|
import { Duplex } from "node:stream";
|
|
5
3
|
declare namespace DockerServiceParams {
|
|
@@ -55,7 +53,7 @@ declare abstract class DockerService {
|
|
|
55
53
|
abstract imageLs(options?: DockerServiceParams.ImageList): Promise<ImageInfo[]>;
|
|
56
54
|
abstract imageRm(tag: string): Promise<void>;
|
|
57
55
|
abstract pullImage(tag: string): Promise<void>;
|
|
58
|
-
abstract attach(name: string): Promise<
|
|
56
|
+
abstract attach(name: string | Container): Promise<NodeJS.ReadWriteStream>;
|
|
59
57
|
abstract attachStream(stream: NodeJS.ReadWriteStream): Promise<void>;
|
|
60
58
|
abstract exec(name: string, command?: string[], tty?: boolean): Promise<Duplex>;
|
|
61
59
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.ProxyService = void 0;
|
|
10
|
+
const decorators_1 = require("../decorators");
|
|
11
|
+
let ProxyService = class ProxyService {
|
|
12
|
+
};
|
|
13
|
+
exports.ProxyService = ProxyService;
|
|
14
|
+
exports.ProxyService = ProxyService = __decorate([
|
|
15
|
+
(0, decorators_1.Injectable)("PROXY_SERVICE")
|
|
16
|
+
], ProxyService);
|
package/lib/services/index.d.ts
CHANGED
package/lib/services/index.js
CHANGED
package/lib/types/index.d.ts
CHANGED
package/lib/types/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Volume } from "
|
|
1
|
+
import { Volume } from "../types";
|
|
2
2
|
export declare const volumeParse: (volume: string) => Volume;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wocker/core",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.13",
|
|
4
4
|
"author": "Kris Papercut <krispcut@gmail.com>",
|
|
5
5
|
"description": "Core of wocker",
|
|
6
6
|
"license": "MIT",
|
|
@@ -21,22 +21,22 @@
|
|
|
21
21
|
"prepare": "npm run build",
|
|
22
22
|
"build": "tsc --project tsconfig.build.json",
|
|
23
23
|
"watch": "tsc -w --project tsconfig.build.json",
|
|
24
|
-
"
|
|
25
|
-
"test": "jest --colors"
|
|
24
|
+
"test": "jest --colors",
|
|
25
|
+
"test-watch": "jest --colors --watchAll --coverage"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@kearisp/cli": "^2.0.4",
|
|
29
29
|
"fs": "^0.0.1-security",
|
|
30
30
|
"path": "^0.12.7",
|
|
31
|
-
"reflect-metadata": "^0.2.
|
|
31
|
+
"reflect-metadata": "^0.2.2"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@types/dockerode": "^3.3.23",
|
|
35
35
|
"@types/jest": "^29.5.12",
|
|
36
36
|
"@types/node": "^20.11.7",
|
|
37
37
|
"jest": "^29.7.0",
|
|
38
|
-
"ts-jest": "^29.
|
|
38
|
+
"ts-jest": "^29.2.4",
|
|
39
39
|
"ts-node": "^10.9.2",
|
|
40
|
-
"typescript": "^5.4
|
|
40
|
+
"typescript": "^5.5.4"
|
|
41
41
|
}
|
|
42
42
|
}
|