@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.
@@ -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 (target, key, descriptor) => {
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 (target, propertyKey, descriptor) => {
7
- Reflect.defineMetadata("completion", [
8
- ...Reflect.getMetadata("completion", descriptor.value) || [],
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 & {
@@ -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,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: any);
39
+ protected constructor(data: PresetProperties);
37
40
  abstract save(): Promise<void>;
38
41
  }
39
42
  export {};
@@ -5,6 +5,7 @@ class Preset {
5
5
  constructor(data) {
6
6
  this.id = data.id;
7
7
  this.name = data.name;
8
+ this.path = data.path;
8
9
  this.version = data.version;
9
10
  this.dockerfile = data.dockerfile;
10
11
  this.buildArgsOptions = data.buildArgsOptions;
@@ -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);
@@ -0,0 +1,5 @@
1
+ export type Volume = {
2
+ source: string;
3
+ destination: string;
4
+ options?: string;
5
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,3 +1,4 @@
1
1
  export * from "./AppConfig";
2
2
  export * from "./EnvConfig";
3
3
  export * from "./PickProperties";
4
+ export * from "./Volume";
@@ -17,3 +17,4 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./AppConfig"), exports);
18
18
  __exportStar(require("./EnvConfig"), exports);
19
19
  __exportStar(require("./PickProperties"), exports);
20
+ __exportStar(require("./Volume"), exports);
@@ -1,6 +1,2 @@
1
- export type Volume = {
2
- source: string;
3
- destination: string;
4
- options?: string;
5
- };
1
+ import { Volume } from "../types";
6
2
  export declare const volumeFormat: (volume: Volume) => string;
@@ -1,2 +1,2 @@
1
- import { Volume } from "./volumeFormat";
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.11",
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
- "watch:test": "jest --colors --watchAll --coverage",
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.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
  }