@wocker/core 1.0.11 → 1.0.12

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/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 & {
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import fs, { createReadStream, MakeDirectoryOptions, RmOptions } from "fs";
3
2
  import { FileSystem } from "./FileSystem";
4
3
  export declare class FSManager {
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import * as fs from "fs";
3
2
  type ReaddirOptions = fs.ObjectEncodingOptions & {
4
3
  recursive?: boolean | undefined;
@@ -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";
@@ -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<void>;
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
  }
@@ -1,5 +1,3 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
1
  import { WriteFileOptions, MakeDirectoryOptions, RmOptions } from "fs";
4
2
  export declare class PluginConfigService {
5
3
  protected readonly pluginDir: string;
@@ -0,0 +1,3 @@
1
+ export declare abstract class ProxyService {
2
+ abstract start(): Promise<void>;
3
+ }
@@ -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);
@@ -5,3 +5,4 @@ export * from "./LogService";
5
5
  export * from "./PluginConfigService";
6
6
  export * from "./PresetService";
7
7
  export * from "./ProjectService";
8
+ export * from "./ProxyService";
@@ -21,3 +21,4 @@ __exportStar(require("./LogService"), exports);
21
21
  __exportStar(require("./PluginConfigService"), exports);
22
22
  __exportStar(require("./PresetService"), exports);
23
23
  __exportStar(require("./ProjectService"), exports);
24
+ __exportStar(require("./ProxyService"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wocker/core",
3
- "version": "1.0.11",
3
+ "version": "1.0.12",
4
4
  "author": "Kris Papercut <krispcut@gmail.com>",
5
5
  "description": "Core of wocker",
6
6
  "license": "MIT",
@@ -28,15 +28,15 @@
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.1"
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.1.2",
38
+ "ts-jest": "^29.2.4",
39
39
  "ts-node": "^10.9.2",
40
- "typescript": "^5.4.5"
40
+ "typescript": "^5.5.4"
41
41
  }
42
42
  }