@wocker/ws 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/controllers/ProjectController.d.ts +1 -1
- package/lib/controllers/ProjectController.js +19 -11
- package/lib/controllers/ProxyController.js +6 -6
- package/lib/makes/FS.d.ts +0 -2
- package/lib/makes/LineConvertStream.d.ts +0 -2
- package/lib/makes/index.d.ts +0 -1
- package/lib/makes/index.js +0 -1
- package/lib/plugins/index.d.ts +0 -2
- package/lib/plugins/index.js +0 -2
- package/lib/services/DockerService.d.ts +0 -2
- package/lib/services/ProjectService.d.ts +3 -2
- package/lib/services/ProjectService.js +15 -4
- package/lib/utils/exec.d.ts +0 -1
- package/lib/utils/followProgress.d.ts +0 -5
- package/package.json +4 -5
- package/lib/makes/Preset.d.ts +0 -45
- package/lib/makes/Preset.js +0 -44
- package/lib/plugins/LocaltunnelPlugin.d.ts +0 -34
- package/lib/plugins/LocaltunnelPlugin.js +0 -231
- package/lib/plugins/MaildevPlugin.d.ts +0 -9
- package/lib/plugins/MaildevPlugin.js +0 -56
- package/plugins/localtunnel/Dockerfile +0 -37
- package/plugins/localtunnel/Ubuntu.dockerfile +0 -34
- package/plugins/localtunnel/config.json +0 -3
- package/plugins/maildev/Dockerfile +0 -5
- package/plugins/maildev/config.json +0 -3
|
@@ -10,7 +10,7 @@ export declare class ProjectController {
|
|
|
10
10
|
getScriptNames(): Promise<string[]>;
|
|
11
11
|
init(name: string, type: string, preset: string): Promise<void>;
|
|
12
12
|
projectList(all: boolean): Promise<string>;
|
|
13
|
-
start(name?: string, detach?: boolean, rebuild?: boolean, restart?: boolean): Promise<void>;
|
|
13
|
+
start(name?: string, detach?: boolean, attach?: boolean, rebuild?: boolean, restart?: boolean): Promise<void>;
|
|
14
14
|
stop(name: string): Promise<void>;
|
|
15
15
|
run(name: string, script: string): Promise<void>;
|
|
16
16
|
attach(name?: string): Promise<void>;
|
|
@@ -155,17 +155,19 @@ let ProjectController = class ProjectController {
|
|
|
155
155
|
}
|
|
156
156
|
return table.toString();
|
|
157
157
|
}
|
|
158
|
-
async start(name, detach, rebuild, restart) {
|
|
158
|
+
async start(name, detach, attach, rebuild, restart) {
|
|
159
159
|
if (name) {
|
|
160
160
|
await this.projectService.cdProject(name);
|
|
161
161
|
}
|
|
162
162
|
const project = await this.projectService.get();
|
|
163
163
|
if (rebuild) {
|
|
164
|
-
await this.projectService.
|
|
165
|
-
await this.appEventsService.emit("project:rebuild", project);
|
|
164
|
+
await this.projectService.rebuild(project);
|
|
166
165
|
}
|
|
167
|
-
await this.projectService.start(restart);
|
|
168
|
-
if (
|
|
166
|
+
await this.projectService.start(project, restart);
|
|
167
|
+
if (detach) {
|
|
168
|
+
console.info(chalk_1.default.yellow("Warning: Detach option is deprecated"));
|
|
169
|
+
}
|
|
170
|
+
if (attach) {
|
|
169
171
|
const project = await this.projectService.get();
|
|
170
172
|
const containerName = project.containerName;
|
|
171
173
|
const container = await this.dockerService.getContainer(containerName);
|
|
@@ -180,7 +182,8 @@ let ProjectController = class ProjectController {
|
|
|
180
182
|
if (name) {
|
|
181
183
|
await this.projectService.cdProject(name);
|
|
182
184
|
}
|
|
183
|
-
await this.projectService.
|
|
185
|
+
const project = await this.projectService.get();
|
|
186
|
+
await this.projectService.stop(project);
|
|
184
187
|
}
|
|
185
188
|
async run(name, script) {
|
|
186
189
|
if (name) {
|
|
@@ -275,7 +278,7 @@ let ProjectController = class ProjectController {
|
|
|
275
278
|
const project = await this.projectService.get();
|
|
276
279
|
const container = await this.dockerService.getContainer(project.containerName);
|
|
277
280
|
if (container) {
|
|
278
|
-
await this.projectService.start(true);
|
|
281
|
+
await this.projectService.start(project, true);
|
|
279
282
|
}
|
|
280
283
|
}
|
|
281
284
|
}
|
|
@@ -300,7 +303,7 @@ let ProjectController = class ProjectController {
|
|
|
300
303
|
const project = await this.projectService.get();
|
|
301
304
|
const container = await this.dockerService.getContainer(project.containerName);
|
|
302
305
|
if (container) {
|
|
303
|
-
await this.projectService.start(true);
|
|
306
|
+
await this.projectService.start(project, true);
|
|
304
307
|
}
|
|
305
308
|
}
|
|
306
309
|
}
|
|
@@ -550,18 +553,23 @@ __decorate([
|
|
|
550
553
|
description: "Detach",
|
|
551
554
|
alias: "d"
|
|
552
555
|
})),
|
|
553
|
-
__param(2, (0, core_1.Option)("
|
|
556
|
+
__param(2, (0, core_1.Option)("attach", {
|
|
557
|
+
type: "boolean",
|
|
558
|
+
description: "Attach",
|
|
559
|
+
alias: "a"
|
|
560
|
+
})),
|
|
561
|
+
__param(3, (0, core_1.Option)("build", {
|
|
554
562
|
type: "boolean",
|
|
555
563
|
description: "Build",
|
|
556
564
|
alias: "b"
|
|
557
565
|
})),
|
|
558
|
-
__param(
|
|
566
|
+
__param(4, (0, core_1.Option)("restart", {
|
|
559
567
|
type: "boolean",
|
|
560
568
|
alias: "r",
|
|
561
569
|
description: "Restart"
|
|
562
570
|
})),
|
|
563
571
|
__metadata("design:type", Function),
|
|
564
|
-
__metadata("design:paramtypes", [String, Boolean, Boolean, Boolean]),
|
|
572
|
+
__metadata("design:paramtypes", [String, Boolean, Boolean, Boolean, Boolean]),
|
|
565
573
|
__metadata("design:returntype", Promise)
|
|
566
574
|
], ProjectController.prototype, "start", null);
|
|
567
575
|
__decorate([
|
|
@@ -143,8 +143,8 @@ let ProxyController = class ProxyController {
|
|
|
143
143
|
await project.save();
|
|
144
144
|
const container = await this.dockerService.getContainer(`${project.name}.workspace`);
|
|
145
145
|
if (container) {
|
|
146
|
-
await this.projectService.stop();
|
|
147
|
-
await this.projectService.start();
|
|
146
|
+
await this.projectService.stop(project);
|
|
147
|
+
await this.projectService.start(project);
|
|
148
148
|
}
|
|
149
149
|
}
|
|
150
150
|
async addDomain(name, addDomains) {
|
|
@@ -167,8 +167,8 @@ let ProxyController = class ProxyController {
|
|
|
167
167
|
await project.save();
|
|
168
168
|
const container = await this.dockerService.getContainer(`${project.name}.workspace`);
|
|
169
169
|
if (container) {
|
|
170
|
-
await this.projectService.stop();
|
|
171
|
-
await this.projectService.start();
|
|
170
|
+
await this.projectService.stop(project);
|
|
171
|
+
await this.projectService.start(project);
|
|
172
172
|
}
|
|
173
173
|
}
|
|
174
174
|
async removeDomain(name, removeDomains) {
|
|
@@ -194,8 +194,8 @@ let ProxyController = class ProxyController {
|
|
|
194
194
|
await project.save();
|
|
195
195
|
const container = await this.dockerService.getContainer(`${project.name}.workspace`);
|
|
196
196
|
if (container) {
|
|
197
|
-
await this.projectService.stop();
|
|
198
|
-
await this.projectService.start();
|
|
197
|
+
await this.projectService.stop(project);
|
|
198
|
+
await this.projectService.start(project);
|
|
199
199
|
}
|
|
200
200
|
}
|
|
201
201
|
async logs() {
|
package/lib/makes/FS.d.ts
CHANGED
package/lib/makes/index.d.ts
CHANGED
package/lib/makes/index.js
CHANGED
package/lib/plugins/index.d.ts
CHANGED
package/lib/plugins/index.js
CHANGED
|
@@ -15,8 +15,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./ElasticSearchPlugin"), exports);
|
|
18
|
-
__exportStar(require("./LocaltunnelPlugin"), exports);
|
|
19
|
-
__exportStar(require("./MaildevPlugin"), exports);
|
|
20
18
|
__exportStar(require("./MongodbPlugin"), exports);
|
|
21
19
|
__exportStar(require("./PageKitePlugin"), exports);
|
|
22
20
|
__exportStar(require("./ProxmoxPlugin"), exports);
|
|
@@ -15,8 +15,9 @@ declare class ProjectService {
|
|
|
15
15
|
cdProject(name: string): Promise<void>;
|
|
16
16
|
get(): Promise<Project>;
|
|
17
17
|
getContainer(): Promise<import("dockerode").Container>;
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
rebuild(project: Project): Promise<void>;
|
|
19
|
+
start(project: Project, restart?: boolean): Promise<void>;
|
|
20
|
+
stop(project: Project): Promise<void>;
|
|
20
21
|
save(project: Project): Promise<void>;
|
|
21
22
|
search(params?: Partial<SearchParams>): Promise<Project[]>;
|
|
22
23
|
searchOne(params?: Partial<SearchParams>): Promise<Project | null>;
|
|
@@ -80,8 +80,20 @@ let ProjectService = class ProjectService {
|
|
|
80
80
|
const project = await this.get();
|
|
81
81
|
return this.dockerService.getContainer(project.containerName);
|
|
82
82
|
}
|
|
83
|
-
async
|
|
84
|
-
|
|
83
|
+
async rebuild(project) {
|
|
84
|
+
await this.stop(project);
|
|
85
|
+
if (project.type === "dockerfile") {
|
|
86
|
+
project.imageName = `project-${project.name}:develop`;
|
|
87
|
+
const images = await this.dockerService.imageLs({
|
|
88
|
+
tag: project.imageName
|
|
89
|
+
});
|
|
90
|
+
if (images.length > 0) {
|
|
91
|
+
await this.dockerService.imageRm(project.imageName);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
await this.appEventsService.emit("project:rebuild", project);
|
|
95
|
+
}
|
|
96
|
+
async start(project, restart) {
|
|
85
97
|
if (project.type === "dockerfile") {
|
|
86
98
|
project.imageName = `project-${project.name}:develop`;
|
|
87
99
|
const images = await this.dockerService.imageLs({
|
|
@@ -126,8 +138,7 @@ let ProjectService = class ProjectService {
|
|
|
126
138
|
}
|
|
127
139
|
await this.appEventsService.emit("project:start", project);
|
|
128
140
|
}
|
|
129
|
-
async stop() {
|
|
130
|
-
const project = await this.get();
|
|
141
|
+
async stop(project) {
|
|
131
142
|
const container = await this.dockerService.getContainer(project.containerName);
|
|
132
143
|
if (!container) {
|
|
133
144
|
return;
|
package/lib/utils/exec.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wocker/ws",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.13",
|
|
4
4
|
"author": "Kris Papercut <krispcut@gmail.com>",
|
|
5
5
|
"description": "Docker workspace for web projects",
|
|
6
6
|
"license": "MIT",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@wocker/core": "^1.0.11",
|
|
29
|
-
"@wocker/utils": "^1.0.
|
|
29
|
+
"@wocker/utils": "^1.0.5",
|
|
30
30
|
"async-mutex": "^0.4.0",
|
|
31
31
|
"axios": "^1.6.7",
|
|
32
32
|
"chalk": "^2.4.2",
|
|
@@ -38,8 +38,7 @@
|
|
|
38
38
|
"md5": "^2.3.0",
|
|
39
39
|
"os": "^0.1.2",
|
|
40
40
|
"path": "^0.12.7",
|
|
41
|
-
"readable-stream": "^4.1.0"
|
|
42
|
-
"reflect-metadata": "^0.2.1"
|
|
41
|
+
"readable-stream": "^4.1.0"
|
|
43
42
|
},
|
|
44
43
|
"devDependencies": {
|
|
45
44
|
"@types/dockerode": "3.3.23",
|
|
@@ -55,6 +54,6 @@
|
|
|
55
54
|
"eslint-plugin-import": "^2.28.1",
|
|
56
55
|
"eslint-plugin-node": "^11.1.0",
|
|
57
56
|
"eslint-webpack-plugin": "^3.1.0",
|
|
58
|
-
"typescript": "^5.
|
|
57
|
+
"typescript": "^5.5.4"
|
|
59
58
|
}
|
|
60
59
|
}
|
package/lib/makes/Preset.d.ts
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { EnvConfig } from "@wocker/core";
|
|
2
|
-
import { PresetService, PresetServiceSearchOptions as SearchOptions } from "../services/PresetService";
|
|
3
|
-
type TextOption = {
|
|
4
|
-
type: "string" | "number" | "int";
|
|
5
|
-
message?: string;
|
|
6
|
-
default?: string | number;
|
|
7
|
-
};
|
|
8
|
-
type ConfirmOption = {
|
|
9
|
-
type: "boolean";
|
|
10
|
-
message?: string;
|
|
11
|
-
default?: boolean;
|
|
12
|
-
};
|
|
13
|
-
type SelectOption = {
|
|
14
|
-
type: "select";
|
|
15
|
-
options: string[] | {
|
|
16
|
-
label?: string;
|
|
17
|
-
value: string;
|
|
18
|
-
}[] | {
|
|
19
|
-
[name: string]: string;
|
|
20
|
-
};
|
|
21
|
-
message?: string;
|
|
22
|
-
default?: string;
|
|
23
|
-
};
|
|
24
|
-
type AnyOption = TextOption | ConfirmOption | SelectOption;
|
|
25
|
-
declare class Preset {
|
|
26
|
-
id: string;
|
|
27
|
-
name: string;
|
|
28
|
-
version: string;
|
|
29
|
-
dockerfile?: string;
|
|
30
|
-
buildArgsOptions?: {
|
|
31
|
-
[name: string]: AnyOption;
|
|
32
|
-
};
|
|
33
|
-
envOptions?: {
|
|
34
|
-
[name: string]: AnyOption;
|
|
35
|
-
};
|
|
36
|
-
volumes?: string[];
|
|
37
|
-
volumeOptions?: string[];
|
|
38
|
-
constructor(data: any);
|
|
39
|
-
save(): Promise<void>;
|
|
40
|
-
getImageName(buildArgs?: EnvConfig): string;
|
|
41
|
-
static install(ps: PresetService): void;
|
|
42
|
-
static search(options: SearchOptions): Promise<import("@wocker/core").Preset[]>;
|
|
43
|
-
static searchOne(options: SearchOptions): Promise<import("@wocker/core").Preset>;
|
|
44
|
-
}
|
|
45
|
-
export { Preset };
|
package/lib/makes/Preset.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Preset = void 0;
|
|
4
|
-
let presetService;
|
|
5
|
-
class Preset {
|
|
6
|
-
constructor(data) {
|
|
7
|
-
this.id = data.id;
|
|
8
|
-
this.name = data.name;
|
|
9
|
-
this.version = data.version;
|
|
10
|
-
this.dockerfile = data.dockerfile;
|
|
11
|
-
this.buildArgsOptions = data.buildArgsOptions;
|
|
12
|
-
this.envOptions = data.envOptions;
|
|
13
|
-
this.volumes = data.volumes;
|
|
14
|
-
this.volumeOptions = data.volumeOptions;
|
|
15
|
-
}
|
|
16
|
-
async save() {
|
|
17
|
-
if (!presetService) {
|
|
18
|
-
throw new Error("Dependency is missing");
|
|
19
|
-
}
|
|
20
|
-
return presetService.save(this);
|
|
21
|
-
}
|
|
22
|
-
getImageName(buildArgs) {
|
|
23
|
-
if (!presetService) {
|
|
24
|
-
throw new Error("Dependency is missing");
|
|
25
|
-
}
|
|
26
|
-
return presetService.getImageName(this, buildArgs);
|
|
27
|
-
}
|
|
28
|
-
static install(ps) {
|
|
29
|
-
presetService = ps;
|
|
30
|
-
}
|
|
31
|
-
static search(options) {
|
|
32
|
-
if (!presetService) {
|
|
33
|
-
throw new Error("Dependency is missing");
|
|
34
|
-
}
|
|
35
|
-
return presetService.search(options);
|
|
36
|
-
}
|
|
37
|
-
static searchOne(options) {
|
|
38
|
-
if (!presetService) {
|
|
39
|
-
throw new Error("Dependency is missing");
|
|
40
|
-
}
|
|
41
|
-
return presetService.searchOne(options);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
exports.Preset = Preset;
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { Project } from "@wocker/core";
|
|
2
|
-
import { AppConfigService, AppEventsService, ProjectService, DockerService } from "../services";
|
|
3
|
-
type InitOptions = {
|
|
4
|
-
name?: string;
|
|
5
|
-
};
|
|
6
|
-
type StartOptions = {
|
|
7
|
-
name?: string;
|
|
8
|
-
detach?: boolean;
|
|
9
|
-
};
|
|
10
|
-
type StopOptions = {
|
|
11
|
-
name?: string;
|
|
12
|
-
};
|
|
13
|
-
type LogsOptions = {
|
|
14
|
-
name?: string;
|
|
15
|
-
detach?: boolean;
|
|
16
|
-
};
|
|
17
|
-
export declare class LocaltunnelPlugin {
|
|
18
|
-
protected readonly appConfigService: AppConfigService;
|
|
19
|
-
protected readonly appEventsService: AppEventsService;
|
|
20
|
-
protected readonly projectService: ProjectService;
|
|
21
|
-
protected readonly dockerService: DockerService;
|
|
22
|
-
constructor(appConfigService: AppConfigService, appEventsService: AppEventsService, projectService: ProjectService, dockerService: DockerService);
|
|
23
|
-
getIp(): Promise<string>;
|
|
24
|
-
onProjectStart(project: Project): Promise<void>;
|
|
25
|
-
onProjectStop(project: Project): Promise<void>;
|
|
26
|
-
build(): Promise<void>;
|
|
27
|
-
rebuild(): Promise<void>;
|
|
28
|
-
init(options: InitOptions): Promise<void>;
|
|
29
|
-
start(options: StartOptions): Promise<void>;
|
|
30
|
-
stop(options: StopOptions): Promise<void>;
|
|
31
|
-
restart(options: StartOptions): Promise<void>;
|
|
32
|
-
logs(options: LogsOptions): Promise<void>;
|
|
33
|
-
}
|
|
34
|
-
export {};
|
|
@@ -1,231 +0,0 @@
|
|
|
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
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.LocaltunnelPlugin = void 0;
|
|
16
|
-
const core_1 = require("@wocker/core");
|
|
17
|
-
const utils_1 = require("@wocker/utils");
|
|
18
|
-
const axios_1 = __importDefault(require("axios"));
|
|
19
|
-
const makes_1 = require("../makes");
|
|
20
|
-
const services_1 = require("../services");
|
|
21
|
-
let LocaltunnelPlugin = class LocaltunnelPlugin {
|
|
22
|
-
constructor(appConfigService, appEventsService, projectService, dockerService) {
|
|
23
|
-
this.appConfigService = appConfigService;
|
|
24
|
-
this.appEventsService = appEventsService;
|
|
25
|
-
this.projectService = projectService;
|
|
26
|
-
this.dockerService = dockerService;
|
|
27
|
-
}
|
|
28
|
-
async getIp() {
|
|
29
|
-
const res = await axios_1.default.get("https://ipv4.icanhazip.com");
|
|
30
|
-
return res.data.replace("\n", "");
|
|
31
|
-
}
|
|
32
|
-
async onProjectStart(project) {
|
|
33
|
-
if (!project || project.getEnv("LOCALTUNNEL_ENABLE", "false") !== "true") {
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
let container = await this.dockerService.getContainer(`localtunnel-${project.name}`);
|
|
37
|
-
if (container) {
|
|
38
|
-
const { State: { Running } } = await container.inspect();
|
|
39
|
-
if (Running) {
|
|
40
|
-
console.info("Localtunnel is already running");
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
else {
|
|
44
|
-
await this.dockerService.removeContainer(`localtunnel-${project.name}`);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
console.info("Localtunnel starting...");
|
|
48
|
-
makes_1.Logger.info(`Localtunnel start: ${project.name}`);
|
|
49
|
-
await this.build();
|
|
50
|
-
const subdomain = project.getEnv("LOCALTUNNEL_SUBDOMAIN", project.name);
|
|
51
|
-
container = await this.dockerService.createContainer({
|
|
52
|
-
name: `localtunnel-${project.name}`,
|
|
53
|
-
image: "ws-localtunnel",
|
|
54
|
-
restart: "always",
|
|
55
|
-
networkMode: "host",
|
|
56
|
-
cmd: [
|
|
57
|
-
"lt",
|
|
58
|
-
`--port=80`,
|
|
59
|
-
`--subdomain=${subdomain}`,
|
|
60
|
-
"--print-requests"
|
|
61
|
-
]
|
|
62
|
-
});
|
|
63
|
-
const stream = await container.attach({
|
|
64
|
-
logs: true,
|
|
65
|
-
stream: true,
|
|
66
|
-
hijack: true,
|
|
67
|
-
stdin: true,
|
|
68
|
-
stdout: true,
|
|
69
|
-
stderr: true
|
|
70
|
-
});
|
|
71
|
-
stream.setEncoding("utf8");
|
|
72
|
-
await container.start();
|
|
73
|
-
const link = await new Promise((resolve, reject) => {
|
|
74
|
-
let res = "";
|
|
75
|
-
stream.on("data", (data) => {
|
|
76
|
-
const regLink = /(https?):\/\/(\w[\w.-]+[a-z]|\d+\.\d+\.\d+\.\d+)(?::(\d+))?/;
|
|
77
|
-
if (regLink.test(data.toString())) {
|
|
78
|
-
const [link] = regLink.exec(data.toString());
|
|
79
|
-
if (link.includes(".loca.lt")) {
|
|
80
|
-
res = link;
|
|
81
|
-
stream.end();
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
});
|
|
85
|
-
stream.on("end", () => resolve(res));
|
|
86
|
-
stream.on("error", reject);
|
|
87
|
-
});
|
|
88
|
-
makes_1.Logger.info(`${project.name} localtunnel forwarding: ${link}`);
|
|
89
|
-
const ip = await this.getIp();
|
|
90
|
-
console.info(`IP: ${ip}`);
|
|
91
|
-
console.info(`Forwarding: ${link}`);
|
|
92
|
-
if (project.getEnv("LOCALTUNNEL_AUTO_CONFIRM", "false") === "true") {
|
|
93
|
-
console.info("Skipping IP confirmation...");
|
|
94
|
-
const res = await axios_1.default.get(link, {
|
|
95
|
-
headers: {
|
|
96
|
-
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36"
|
|
97
|
-
},
|
|
98
|
-
validateStatus: () => true
|
|
99
|
-
});
|
|
100
|
-
const [path] = /\/continue\/[\w.]+/.exec(res.data) || [];
|
|
101
|
-
if (path) {
|
|
102
|
-
const sendData = new URLSearchParams({
|
|
103
|
-
endpoint: ip
|
|
104
|
-
});
|
|
105
|
-
const res = await axios_1.default.post(`${link}${path}`, sendData.toString(), {
|
|
106
|
-
headers: {
|
|
107
|
-
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36",
|
|
108
|
-
"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"
|
|
109
|
-
}
|
|
110
|
-
});
|
|
111
|
-
if (res.status === 200) {
|
|
112
|
-
console.info("IP confirmed");
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
async onProjectStop(project) {
|
|
118
|
-
if (!project || project.getEnv("LOCALTUNNEL_ENABLE", "false") !== "true") {
|
|
119
|
-
return;
|
|
120
|
-
}
|
|
121
|
-
console.info("Localtunnel stopping...");
|
|
122
|
-
await this.dockerService.removeContainer(`localtunnel-${project.name}`);
|
|
123
|
-
}
|
|
124
|
-
async build() {
|
|
125
|
-
const exists = await this.dockerService.imageExists("ws-localtunnel");
|
|
126
|
-
if (!exists) {
|
|
127
|
-
await this.dockerService.buildImage({
|
|
128
|
-
tag: "ws-localtunnel",
|
|
129
|
-
context: this.appConfigService.pluginsPath("plugins/localtunnel"),
|
|
130
|
-
src: "./Dockerfile"
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
async rebuild() {
|
|
135
|
-
try {
|
|
136
|
-
await this.dockerService.imageRm("ws-localtunnel");
|
|
137
|
-
}
|
|
138
|
-
catch (err) {
|
|
139
|
-
console.info(err.message);
|
|
140
|
-
}
|
|
141
|
-
await this.build();
|
|
142
|
-
}
|
|
143
|
-
async init(options) {
|
|
144
|
-
const { name } = options;
|
|
145
|
-
if (name) {
|
|
146
|
-
await this.projectService.cdProject(name);
|
|
147
|
-
}
|
|
148
|
-
const project = await this.projectService.get();
|
|
149
|
-
const enabled = await (0, utils_1.promptConfirm)({
|
|
150
|
-
message: "Enable localtunnel?",
|
|
151
|
-
default: project.getEnv("LOCALTUNNEL_ENABLE", "false") === "true"
|
|
152
|
-
});
|
|
153
|
-
if (enabled) {
|
|
154
|
-
const subdomain = await (0, utils_1.promptText)({
|
|
155
|
-
message: "Subdomain",
|
|
156
|
-
prefix: "https://",
|
|
157
|
-
suffix: ".loca.lt",
|
|
158
|
-
default: project.getEnv("LOCALTUNNEL_SUBDOMAIN")
|
|
159
|
-
});
|
|
160
|
-
if (!subdomain) {
|
|
161
|
-
throw new Error("Subdomain can't be empty");
|
|
162
|
-
}
|
|
163
|
-
const autoConfirmIP = await (0, utils_1.promptConfirm)({
|
|
164
|
-
message: "Do you want to skip the IP confirmation form automatically?",
|
|
165
|
-
default: project.getEnv("LOCALTUNNEL_AUTO_CONFIRM", "true") === "true"
|
|
166
|
-
});
|
|
167
|
-
project.setEnv("LOCALTUNNEL_ENABLE", "true");
|
|
168
|
-
project.setEnv("LOCALTUNNEL_SUBDOMAIN", subdomain);
|
|
169
|
-
project.setEnv("LOCALTUNNEL_AUTO_CONFIRM", autoConfirmIP ? "true" : "false");
|
|
170
|
-
}
|
|
171
|
-
else {
|
|
172
|
-
project.setEnv("LOCALTUNNEL_ENABLE", "false");
|
|
173
|
-
}
|
|
174
|
-
await project.save();
|
|
175
|
-
}
|
|
176
|
-
async start(options) {
|
|
177
|
-
const { name, detach } = options;
|
|
178
|
-
if (name) {
|
|
179
|
-
await this.projectService.cdProject(name);
|
|
180
|
-
}
|
|
181
|
-
const project = await this.projectService.get();
|
|
182
|
-
if (project.getEnv("LOCALTUNNEL_ENABLE", "false") !== "true") {
|
|
183
|
-
throw new Error(`Localtunnel is not initialized. Run "ws localtunnel:init${name ? ` -n=${name}` : ""}" first.`);
|
|
184
|
-
}
|
|
185
|
-
await this.onProjectStart(project);
|
|
186
|
-
if (!detach) {
|
|
187
|
-
await this.logs({ name });
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
async stop(options) {
|
|
191
|
-
const { name } = options;
|
|
192
|
-
if (name) {
|
|
193
|
-
await this.projectService.cdProject(name);
|
|
194
|
-
}
|
|
195
|
-
const project = await this.projectService.get();
|
|
196
|
-
await this.onProjectStop(project);
|
|
197
|
-
}
|
|
198
|
-
async restart(options) {
|
|
199
|
-
const { name } = options;
|
|
200
|
-
await this.stop({ name });
|
|
201
|
-
await this.start(options);
|
|
202
|
-
}
|
|
203
|
-
async logs(options) {
|
|
204
|
-
const { name, } = options;
|
|
205
|
-
if (name) {
|
|
206
|
-
await this.projectService.cdProject(name);
|
|
207
|
-
}
|
|
208
|
-
const project = await this.projectService.get();
|
|
209
|
-
const container = await this.dockerService.getContainer(`localtunnel-${project.name}`);
|
|
210
|
-
const stream = await container.logs({
|
|
211
|
-
follow: true,
|
|
212
|
-
stderr: true,
|
|
213
|
-
stdout: true,
|
|
214
|
-
tail: 5
|
|
215
|
-
});
|
|
216
|
-
stream.on("data", (data) => {
|
|
217
|
-
process.stdout.write(data);
|
|
218
|
-
});
|
|
219
|
-
stream.on("error", (data) => {
|
|
220
|
-
process.stderr.write(data);
|
|
221
|
-
});
|
|
222
|
-
}
|
|
223
|
-
};
|
|
224
|
-
exports.LocaltunnelPlugin = LocaltunnelPlugin;
|
|
225
|
-
exports.LocaltunnelPlugin = LocaltunnelPlugin = __decorate([
|
|
226
|
-
(0, core_1.Controller)(),
|
|
227
|
-
__metadata("design:paramtypes", [services_1.AppConfigService,
|
|
228
|
-
services_1.AppEventsService,
|
|
229
|
-
services_1.ProjectService,
|
|
230
|
-
services_1.DockerService])
|
|
231
|
-
], LocaltunnelPlugin);
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { DockerService, AppConfigService } from "../services";
|
|
2
|
-
export declare class MaildevPlugin {
|
|
3
|
-
protected readonly appConfigService: AppConfigService;
|
|
4
|
-
protected readonly dockerService: DockerService;
|
|
5
|
-
protected containerName: string;
|
|
6
|
-
constructor(appConfigService: AppConfigService, dockerService: DockerService);
|
|
7
|
-
start(): Promise<void>;
|
|
8
|
-
stop(): Promise<void>;
|
|
9
|
-
}
|
|
@@ -1,56 +0,0 @@
|
|
|
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
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.MaildevPlugin = void 0;
|
|
13
|
-
const core_1 = require("@wocker/core");
|
|
14
|
-
const services_1 = require("../services");
|
|
15
|
-
let MaildevPlugin = class MaildevPlugin {
|
|
16
|
-
constructor(appConfigService, dockerService) {
|
|
17
|
-
this.appConfigService = appConfigService;
|
|
18
|
-
this.dockerService = dockerService;
|
|
19
|
-
this.containerName = "maildev.workspace";
|
|
20
|
-
}
|
|
21
|
-
async start() {
|
|
22
|
-
console.log("Maildev starting...");
|
|
23
|
-
const imageName = "ws-maildev";
|
|
24
|
-
if (!await this.dockerService.imageExists(imageName)) {
|
|
25
|
-
await this.dockerService.buildImage({
|
|
26
|
-
tag: "ws-maildev",
|
|
27
|
-
buildArgs: {},
|
|
28
|
-
labels: {},
|
|
29
|
-
context: this.appConfigService.pluginsPath("plugins/maildev"),
|
|
30
|
-
src: "./Dockerfile"
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
let container = await this.dockerService.createContainer({
|
|
34
|
-
name: this.containerName,
|
|
35
|
-
restart: "always",
|
|
36
|
-
env: {
|
|
37
|
-
VIRTUAL_HOST: "maildev.workspace"
|
|
38
|
-
},
|
|
39
|
-
ports: [
|
|
40
|
-
"25:25"
|
|
41
|
-
],
|
|
42
|
-
image: imageName
|
|
43
|
-
});
|
|
44
|
-
await container.start();
|
|
45
|
-
}
|
|
46
|
-
async stop() {
|
|
47
|
-
console.log("Maildev stopping...");
|
|
48
|
-
await this.dockerService.removeContainer(this.containerName);
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
exports.MaildevPlugin = MaildevPlugin;
|
|
52
|
-
exports.MaildevPlugin = MaildevPlugin = __decorate([
|
|
53
|
-
(0, core_1.Controller)(),
|
|
54
|
-
__metadata("design:paramtypes", [services_1.AppConfigService,
|
|
55
|
-
services_1.DockerService])
|
|
56
|
-
], MaildevPlugin);
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
FROM alpine:latest
|
|
2
|
-
|
|
3
|
-
RUN apk update && apk upgrade && apk add --no-cache curl bash nodejs npm
|
|
4
|
-
|
|
5
|
-
RUN npm install --quiet -g localtunnel
|
|
6
|
-
|
|
7
|
-
SHELL ["/bin/bash", "-c"]
|
|
8
|
-
|
|
9
|
-
ARG UID=1000
|
|
10
|
-
ARG USER=user
|
|
11
|
-
|
|
12
|
-
RUN adduser -D -u $UID $USER
|
|
13
|
-
|
|
14
|
-
USER $USER
|
|
15
|
-
|
|
16
|
-
RUN touch /home/$USER/.bashrc && chmod +x /home/$USER/.bashrc
|
|
17
|
-
|
|
18
|
-
#ENV NODE_VERSION 16.13.0
|
|
19
|
-
#ENV NVM_DIR /home/$USER/.nvm
|
|
20
|
-
|
|
21
|
-
#RUN mkdir -p $NVM_DIR && \
|
|
22
|
-
# curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
|
|
23
|
-
|
|
24
|
-
#RUN echo "[ -s \"$NVM_DIR/nvm.sh\" ] && \. \"$NVM_DIR/nvm.sh\"" >> ~/.bashrc
|
|
25
|
-
#RUN echo "[ -s \"$NVM_DIR/bash_completion\" ] && \. \"$NVM_DIR/bash_completion\"" >> ~/.bashrc
|
|
26
|
-
|
|
27
|
-
#ENV NODE_PATH $NVM_DIR/versions/node/v$NODE_VERSION/bin
|
|
28
|
-
#ENV PATH $NODE_PATH:$PATH
|
|
29
|
-
|
|
30
|
-
#RUN source /home/$USER/.bashrc && \
|
|
31
|
-
#RUN source $NVM_DIR/nvm.sh && \
|
|
32
|
-
# nvm install $NODE_VERSION && \
|
|
33
|
-
# nvm alias default $NODE_VERSION && \
|
|
34
|
-
# nvm use default #&& \
|
|
35
|
-
#npm install --quiet -g localtunnel
|
|
36
|
-
|
|
37
|
-
#ENTRYPOINT ["lt"]
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
FROM ubuntu:latest
|
|
2
|
-
|
|
3
|
-
RUN apt-get update && apt-get upgrade -y && apt-get install -y curl bash
|
|
4
|
-
|
|
5
|
-
SHELL ["/bin/bash", "-c"]
|
|
6
|
-
|
|
7
|
-
ARG UID=1000
|
|
8
|
-
ARG USER=user
|
|
9
|
-
|
|
10
|
-
RUN useradd -m -u $UID $USER
|
|
11
|
-
|
|
12
|
-
USER $USER
|
|
13
|
-
|
|
14
|
-
RUN touch /home/$USER/.bashrc && chmod +x /home/$USER/.bashrc
|
|
15
|
-
|
|
16
|
-
ENV NODE_VERSION 16.13.0
|
|
17
|
-
ENV NVM_DIR /home/$USER/.nvm
|
|
18
|
-
|
|
19
|
-
RUN mkdir -p $NVM_DIR && \
|
|
20
|
-
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
|
|
21
|
-
|
|
22
|
-
RUN echo "[ -s \"$NVM_DIR/nvm.sh\" ] && \. \"$NVM_DIR/nvm.sh\"" >> ~/.bashrc
|
|
23
|
-
RUN echo "[ -s \"$NVM_DIR/bash_completion\" ] && \. \"$NVM_DIR/bash_completion\"" >> ~/.bashrc
|
|
24
|
-
|
|
25
|
-
ENV NODE_PATH $NVM_DIR/versions/node/v$NODE_VERSION/bin
|
|
26
|
-
ENV PATH $NODE_PATH:$PATH
|
|
27
|
-
|
|
28
|
-
RUN source $NVM_DIR/nvm.sh && \
|
|
29
|
-
nvm install $NODE_VERSION && \
|
|
30
|
-
nvm alias default $NODE_VERSION && \
|
|
31
|
-
nvm use default && \
|
|
32
|
-
npm install --quiet -g localtunnel
|
|
33
|
-
|
|
34
|
-
ENTRYPOINT ["lt"]
|