@wocker/core 1.0.30-beta.0 → 1.0.30-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.
@@ -12,6 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.ApplicationContext = void 0;
13
13
  const cli_1 = require("@kearisp/cli");
14
14
  const AsyncStorage_1 = require("./AsyncStorage");
15
+ const env_1 = require("../env");
15
16
  class ApplicationContext {
16
17
  constructor(module, container) {
17
18
  this.module = module;
@@ -33,7 +34,15 @@ class ApplicationContext {
33
34
  return new Promise((resolve) => {
34
35
  AsyncStorage_1.AsyncStorage.run(this.container, () => {
35
36
  const cli = this.get(cli_1.Cli);
36
- cli.command("").action(() => {
37
+ cli.command("")
38
+ .option("version", {
39
+ type: "boolean",
40
+ alias: "v"
41
+ })
42
+ .action((input) => {
43
+ if (input.option("version")) {
44
+ return env_1.WOCKER_VERSION;
45
+ }
37
46
  for (const [, module] of this.container.modules) {
38
47
  for (const [, container] of module.controllers) {
39
48
  if (!container.description) {
@@ -1,2 +1,3 @@
1
+ export * from "./services/ContainerService";
1
2
  export * from "./services/DockerService";
2
3
  export * from "./services/ModemService";
@@ -14,5 +14,6 @@ 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("./services/ContainerService"), exports);
17
18
  __exportStar(require("./services/DockerService"), exports);
18
19
  __exportStar(require("./services/ModemService"), exports);
@@ -0,0 +1,56 @@
1
+ import type Docker from "dockerode";
2
+ import type { Container, ContainerInfo } from "dockerode";
3
+ export declare abstract class ContainerService {
4
+ abstract get docker(): Docker;
5
+ abstract create(params: ContainerService.CreateParams): Promise<Container>;
6
+ abstract get(name: string | string[]): Promise<Container | null>;
7
+ abstract list(params: ContainerService.ListParams): Promise<ContainerInfo[]>;
8
+ abstract logs(containerOrName: ContainerService.ContainerOrName, params?: ContainerService.LogsParams): Promise<NodeJS.ReadableStream | null>;
9
+ }
10
+ export declare namespace ContainerService {
11
+ type ContainerOrName = string | Container;
12
+ type CreateParams = {
13
+ name: string;
14
+ labels?: {
15
+ [key: string]: string;
16
+ };
17
+ image: string;
18
+ user?: string;
19
+ restart?: "always";
20
+ entrypoint?: string | string[];
21
+ /** @deprecated */
22
+ projectId?: string;
23
+ tty?: boolean;
24
+ memory?: number;
25
+ memorySwap?: number;
26
+ ulimits?: {
27
+ [key: string]: {
28
+ hard?: number;
29
+ soft?: number;
30
+ };
31
+ };
32
+ links?: string[];
33
+ env?: {
34
+ [key: string]: string;
35
+ };
36
+ networkMode?: string;
37
+ extraHosts?: any;
38
+ volumes?: string[];
39
+ ports?: string[];
40
+ cmd?: string[];
41
+ network?: string;
42
+ aliases?: string[];
43
+ };
44
+ type ListParams = {
45
+ all?: boolean;
46
+ name?: string | string[];
47
+ } | undefined;
48
+ type ExecParams = string[] | {
49
+ cmd: string[];
50
+ tty?: boolean;
51
+ user?: string;
52
+ };
53
+ type LogsParams = {
54
+ signal?: AbortSignal;
55
+ };
56
+ }
@@ -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.ContainerService = void 0;
10
+ const decorators_1 = require("../../../decorators");
11
+ let ContainerService = class ContainerService {
12
+ };
13
+ exports.ContainerService = ContainerService;
14
+ exports.ContainerService = ContainerService = __decorate([
15
+ (0, decorators_1.Injectable)("DOCKER_CONTAINER_SERVICE")
16
+ ], ContainerService);
@@ -1,47 +1,30 @@
1
1
  import type Docker from "dockerode";
2
- import type { Container, ImageInfo, VolumeCreateResponse } from "dockerode";
2
+ import type { Container, ContainerInfo, ImageInfo, VolumeCreateResponse } from "dockerode";
3
3
  import { Duplex } from "node:stream";
4
- export declare namespace DockerService {
5
- type ImageLSOptions = {
6
- tag?: string;
7
- reference?: string[];
8
- labels?: {
9
- [key: string]: string;
10
- };
11
- };
4
+ import { ContainerService } from "./ContainerService";
5
+ export declare abstract class DockerService {
6
+ abstract get docker(): Docker;
7
+ abstract createContainer(params: DockerService.CreateContainerParams): Promise<Container>;
8
+ abstract getContainer(name: string | string[]): Promise<Container | null>;
9
+ abstract listContainer(params: DockerService.ListContainerParams): Promise<ContainerInfo[]>;
10
+ abstract removeContainer(name: string): Promise<void>;
11
+ abstract createVolume(name: string): Promise<VolumeCreateResponse>;
12
+ abstract hasVolume(name: string): Promise<boolean>;
13
+ abstract rmVolume(name: string): Promise<void>;
14
+ abstract buildImage(params: DockerService.BuildImageParams): Promise<any>;
15
+ abstract imageLs(options?: DockerService.ImageLSOptions): Promise<ImageInfo[]>;
16
+ abstract imageExists(tag: string): Promise<boolean>;
17
+ abstract imageRm(tag: string, force?: boolean): Promise<void>;
18
+ abstract pullImage(tag: string): Promise<void>;
19
+ abstract attach(name: string | Container): Promise<NodeJS.ReadWriteStream | null | undefined>;
20
+ abstract attachStream(stream: NodeJS.ReadWriteStream): Promise<NodeJS.ReadWriteStream>;
21
+ abstract exec(name: string, command?: DockerService.ExecParams, tty?: boolean): Promise<Duplex | null>;
22
+ abstract logs(containerOrName: DockerService.ContainerOrName, params?: DockerService.LogsParams): Promise<NodeJS.ReadableStream | null | undefined>;
12
23
  }
13
- export declare namespace DockerServiceParams {
14
- type CreateContainer = {
15
- name: string;
16
- image: string;
17
- user?: string;
18
- restart?: "always";
19
- entrypoint?: string | string[];
20
- projectId?: string;
21
- tty?: boolean;
22
- memory?: number;
23
- memorySwap?: number;
24
- ulimits?: {
25
- [key: string]: {
26
- hard?: number;
27
- soft?: number;
28
- };
29
- };
30
- links?: string[];
31
- env?: {
32
- [key: string]: string;
33
- };
34
- networkMode?: string;
35
- extraHosts?: any;
36
- volumes?: string[];
37
- ports?: string[];
38
- cmd?: string[];
39
- network?: string;
40
- aliases?: string[];
41
- };
42
- /** @deprecated */
43
- type ImageList = DockerService.ImageLSOptions;
44
- type BuildImage = {
24
+ export declare namespace DockerService {
25
+ type CreateContainerParams = ContainerService.CreateParams;
26
+ type ListContainerParams = ContainerService.ListParams;
27
+ type BuildImageParams = {
45
28
  version?: "1" | "2";
46
29
  tag: string;
47
30
  buildArgs?: {
@@ -57,27 +40,23 @@ export declare namespace DockerServiceParams {
57
40
  } | {
58
41
  dockerfile: string;
59
42
  });
60
- type Exec = {
61
- cmd: string[];
62
- tty?: boolean;
63
- user?: string;
43
+ type ExecParams = ContainerService.ExecParams;
44
+ type ImageLSOptions = {
45
+ tag?: string;
46
+ reference?: string[];
47
+ labels?: {
48
+ [key: string]: string;
49
+ };
64
50
  };
51
+ type ContainerOrName = ContainerService.ContainerOrName;
52
+ type LogsParams = ContainerService.LogsParams;
65
53
  }
66
- export declare abstract class DockerService {
67
- abstract get docker(): Docker;
68
- abstract createContainer(params: DockerServiceParams.CreateContainer): Promise<Container>;
69
- abstract getContainer(name: string): Promise<Container | null>;
70
- abstract removeContainer(name: string): Promise<void>;
71
- abstract createVolume(name: string): Promise<VolumeCreateResponse>;
72
- abstract hasVolume(name: string): Promise<boolean>;
73
- abstract rmVolume(name: string): Promise<void>;
74
- abstract buildImage(params: DockerServiceParams.BuildImage): Promise<any>;
75
- abstract imageLs(options?: DockerService.ImageLSOptions): Promise<ImageInfo[]>;
76
- abstract imageExists(tag: string): Promise<boolean>;
77
- abstract imageRm(tag: string, force?: boolean): Promise<void>;
78
- abstract pullImage(tag: string): Promise<void>;
79
- abstract attach(name: string | Container): Promise<NodeJS.ReadWriteStream | null | undefined>;
80
- abstract attachStream(stream: NodeJS.ReadWriteStream): Promise<NodeJS.ReadWriteStream>;
81
- abstract exec(name: string, command?: DockerServiceParams.Exec | string[], tty?: boolean): Promise<Duplex | null>;
82
- abstract logs(containerOrName: string | Container): Promise<NodeJS.ReadableStream | null | undefined>;
54
+ export declare namespace DockerServiceParams {
55
+ /** @deprecated */
56
+ type CreateContainer = DockerService.CreateContainerParams;
57
+ /** @deprecated */
58
+ type ImageList = DockerService.ImageLSOptions;
59
+ type BuildImage = DockerService.BuildImageParams;
60
+ /** @deprecated */
61
+ type Exec = DockerService.ExecParams;
83
62
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@wocker/core",
3
3
  "type": "commonjs",
4
- "version": "1.0.30-beta.0",
4
+ "version": "1.0.30-beta.1",
5
5
  "author": "Kris Papercut <krispcut@gmail.com>",
6
6
  "description": "Core of the Wocker",
7
7
  "license": "MIT",
@@ -27,7 +27,7 @@
27
27
  "make-coverage-badge": "make-coverage-badge"
28
28
  },
29
29
  "dependencies": {
30
- "@kearisp/cli": "^2.0.8",
30
+ "@kearisp/cli": "^2.0.9",
31
31
  "date-fns": "^4.1.0",
32
32
  "readline": "^1.3.0",
33
33
  "reflect-metadata": "^0.2.2",