@wocker/ws 1.0.1 → 1.0.2
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/.github/workflows/publish.yml +31 -0
- package/README.md +11 -137
- package/bin/ws.js +7 -3
- package/lib/App.d.ts +7 -5
- package/lib/App.js +45 -11
- package/lib/controllers/ImageController.d.ts +3 -1
- package/lib/controllers/ImageController.js +3 -1
- package/lib/controllers/PluginController.d.ts +14 -0
- package/lib/controllers/PluginController.js +62 -0
- package/lib/controllers/PresetController.d.ts +19 -0
- package/lib/controllers/PresetController.js +150 -0
- package/lib/controllers/ProjectController.d.ts +13 -5
- package/lib/controllers/ProjectController.js +92 -25
- package/lib/{plugins/ProxyPlugin.d.ts → controllers/ProxyController.d.ts} +9 -11
- package/lib/{plugins/ProxyPlugin.js → controllers/ProxyController.js} +120 -128
- package/lib/controllers/index.d.ts +3 -0
- package/lib/controllers/index.js +33 -0
- package/lib/env.js +9 -16
- package/lib/index.js +11 -24
- package/lib/makes/Docker.js +11 -25
- package/lib/makes/FS.d.ts +1 -1
- package/lib/makes/FS.js +13 -10
- package/lib/makes/Logger.d.ts +1 -7
- package/lib/makes/Logger.js +6 -33
- package/lib/makes/Plugin.js +2 -2
- package/lib/plugins/ElasticSearchPlugin.d.ts +16 -0
- package/lib/plugins/ElasticSearchPlugin.js +72 -0
- package/lib/plugins/LocaltunnelPlugin.d.ts +3 -3
- package/lib/plugins/LocaltunnelPlugin.js +17 -15
- package/lib/plugins/MaildevPlugin.d.ts +3 -1
- package/lib/plugins/MaildevPlugin.js +8 -5
- package/lib/plugins/MongodbPlugin.d.ts +5 -3
- package/lib/plugins/MongodbPlugin.js +10 -16
- package/lib/plugins/NgrokPlugin.d.ts +2 -3
- package/lib/plugins/NgrokPlugin.js +7 -6
- package/lib/plugins/PageKitePlugin.d.ts +2 -3
- package/lib/plugins/PageKitePlugin.js +8 -6
- package/lib/plugins/PostgresPlugin.js +5 -4
- package/lib/plugins/ProxmoxPlugin.js +2 -2
- package/lib/plugins/RedisPlugin.d.ts +8 -2
- package/lib/plugins/RedisPlugin.js +57 -20
- package/lib/plugins/index.d.ts +2 -6
- package/lib/plugins/index.js +11 -66
- package/lib/services/AppConfigService.d.ts +14 -4
- package/lib/services/AppConfigService.js +88 -3
- package/lib/services/AppEventsService.d.ts +5 -8
- package/lib/services/AppEventsService.js +2 -3
- package/lib/services/DockerService.d.ts +16 -0
- package/lib/services/DockerService.js +220 -0
- package/lib/services/LogService.d.ts +11 -0
- package/lib/services/LogService.js +39 -0
- package/lib/services/PluginService.d.ts +10 -0
- package/lib/services/PluginService.js +18 -0
- package/lib/services/PresetService.d.ts +9 -0
- package/lib/services/PresetService.js +63 -0
- package/lib/services/ProjectService.d.ts +8 -7
- package/lib/services/ProjectService.js +64 -12
- package/lib/services/index.d.ts +4 -0
- package/lib/services/index.js +44 -0
- package/lib/utils/demuxOutput.js +0 -2
- package/lib/utils/exec.d.ts +1 -1
- package/lib/utils/exec.js +4 -5
- package/lib/utils/fetch.js +3 -4
- package/lib/utils/image-build.js +2 -2
- package/lib/utils/index.d.ts +0 -4
- package/lib/utils/index.js +0 -44
- package/lib/utils/injectVariables.js +1 -1
- package/package.json +13 -13
- package/presets/node/config.json +9 -7
- package/presets/php-apache/Dockerfile +37 -36
- package/presets/php-apache/config.json +10 -15
- package/presets/php-fpm/Dockerfile +21 -0
- package/presets/php-fpm/config.json +25 -0
- package/lib/models/Preset.d.ts +0 -19
- package/lib/models/Preset.js +0 -60
- package/lib/models/Project.d.ts +0 -38
- package/lib/models/Project.js +0 -151
- package/lib/models/index.d.ts +0 -2
- package/lib/models/index.js +0 -27
- package/lib/plugins/MariadbPlugin.d.ts +0 -25
- package/lib/plugins/MariadbPlugin.js +0 -297
- package/lib/plugins/PresetPlugin.d.ts +0 -19
- package/lib/plugins/PresetPlugin.js +0 -164
- package/lib/plugins/ProjectPlugin.d.ts +0 -12
- package/lib/plugins/ProjectPlugin.js +0 -54
- package/lib/plugins/ServeoPlugin.d.ts +0 -36
- package/lib/plugins/ServeoPlugin.js +0 -260
- package/lib/plugins/TestPlugin.d.ts +0 -10
- package/lib/plugins/TestPlugin.js +0 -75
- package/lib/utils/promptConfirm.d.ts +0 -6
- package/lib/utils/promptConfirm.js +0 -21
- package/lib/utils/promptGroup.d.ts +0 -16
- package/lib/utils/promptGroup.js +0 -39
- package/lib/utils/promptSelect.d.ts +0 -12
- package/lib/utils/promptSelect.js +0 -47
- package/lib/utils/promptText.d.ts +0 -13
- package/lib/utils/promptText.js +0 -53
- package/plugins/serveo/Dockerfile +0 -17
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { Cli } from "@kearisp/cli";
|
|
2
|
-
import { Plugin } from "src/makes";
|
|
3
|
-
type ProjectListOptions = {
|
|
4
|
-
all?: boolean;
|
|
5
|
-
};
|
|
6
|
-
declare class ProjectPlugin extends Plugin {
|
|
7
|
-
constructor();
|
|
8
|
-
install(cli: Cli): void;
|
|
9
|
-
projectList(options: ProjectListOptions): Promise<string>;
|
|
10
|
-
init(): Promise<void>;
|
|
11
|
-
}
|
|
12
|
-
export { ProjectPlugin };
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.ProjectPlugin = void 0;
|
|
7
|
-
var _cliTable = _interopRequireDefault(require("cli-table3"));
|
|
8
|
-
var _makes = require("../makes");
|
|
9
|
-
var _models = require("../models");
|
|
10
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
-
class ProjectPlugin extends _makes.Plugin {
|
|
12
|
-
constructor() {
|
|
13
|
-
super("project");
|
|
14
|
-
}
|
|
15
|
-
install(cli) {
|
|
16
|
-
super.install(cli);
|
|
17
|
-
cli.command("ps").option("all", {
|
|
18
|
-
type: "boolean",
|
|
19
|
-
alias: "a",
|
|
20
|
-
description: "All projects"
|
|
21
|
-
}).action(options => this.projectList(options));
|
|
22
|
-
}
|
|
23
|
-
async projectList(options) {
|
|
24
|
-
const {
|
|
25
|
-
all
|
|
26
|
-
} = options;
|
|
27
|
-
const projects = await _models.Project.search();
|
|
28
|
-
const table = new _cliTable.default({
|
|
29
|
-
head: ["Name", "Type", "Status"],
|
|
30
|
-
colAligns: ["left", "center"]
|
|
31
|
-
});
|
|
32
|
-
for (const i in projects) {
|
|
33
|
-
const project = projects[i];
|
|
34
|
-
const container = await _makes.Docker.getContainer(`${project.name}.workspace`);
|
|
35
|
-
if (!container) {
|
|
36
|
-
if (all) {
|
|
37
|
-
table.push([project.name, project.type, "-"]);
|
|
38
|
-
}
|
|
39
|
-
continue;
|
|
40
|
-
}
|
|
41
|
-
const {
|
|
42
|
-
State: {
|
|
43
|
-
Status = "Stopped"
|
|
44
|
-
} = {}
|
|
45
|
-
} = await container.inspect();
|
|
46
|
-
table.push([project.name, project.type, Status]);
|
|
47
|
-
}
|
|
48
|
-
return table.toString();
|
|
49
|
-
}
|
|
50
|
-
async init() {
|
|
51
|
-
//
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
exports.ProjectPlugin = ProjectPlugin;
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { Cli } from "@kearisp/cli";
|
|
2
|
-
import { Plugin } from "src/makes";
|
|
3
|
-
import { Project } from "src/models";
|
|
4
|
-
import { AppConfigService, AppEventsService, ProjectService } from "src/services";
|
|
5
|
-
type InitOptions = {
|
|
6
|
-
name?: string;
|
|
7
|
-
};
|
|
8
|
-
type StartOptions = {
|
|
9
|
-
name?: string;
|
|
10
|
-
rebuild?: boolean;
|
|
11
|
-
detach?: boolean;
|
|
12
|
-
};
|
|
13
|
-
type StopOptions = {
|
|
14
|
-
name?: string;
|
|
15
|
-
};
|
|
16
|
-
type LogsOptions = {
|
|
17
|
-
name?: string;
|
|
18
|
-
detach?: boolean;
|
|
19
|
-
};
|
|
20
|
-
declare class ServeoPlugin extends Plugin {
|
|
21
|
-
protected appConfigService: AppConfigService;
|
|
22
|
-
protected appEventsService: AppEventsService;
|
|
23
|
-
protected projectService: ProjectService;
|
|
24
|
-
constructor(appConfigService: AppConfigService, appEventsService: AppEventsService, projectService: ProjectService);
|
|
25
|
-
install(cli: Cli): void;
|
|
26
|
-
onProjectStart(project: Project): Promise<void>;
|
|
27
|
-
onProjectStop(project: Project): 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
|
-
build(): Promise<void>;
|
|
33
|
-
rebuild(): Promise<void>;
|
|
34
|
-
logs(options: LogsOptions): Promise<void>;
|
|
35
|
-
}
|
|
36
|
-
export { ServeoPlugin };
|
|
@@ -1,260 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.ServeoPlugin = void 0;
|
|
7
|
-
var _makes = require("../makes");
|
|
8
|
-
var _models = require("../models");
|
|
9
|
-
var _utils = require("../utils");
|
|
10
|
-
class ServeoPlugin extends _makes.Plugin {
|
|
11
|
-
constructor(appConfigService, appEventsService, projectService) {
|
|
12
|
-
super("serveo");
|
|
13
|
-
this.appConfigService = appConfigService;
|
|
14
|
-
this.appEventsService = appEventsService;
|
|
15
|
-
this.projectService = projectService;
|
|
16
|
-
}
|
|
17
|
-
install(cli) {
|
|
18
|
-
super.install(cli);
|
|
19
|
-
this.appEventsService.on("project:start", project => this.onProjectStart(project));
|
|
20
|
-
this.appEventsService.on("project:stop", project => this.onProjectStop(project));
|
|
21
|
-
cli.command("serveo:init").option("name", {
|
|
22
|
-
alias: "n",
|
|
23
|
-
type: "string",
|
|
24
|
-
description: "Project name"
|
|
25
|
-
}).action(options => this.init(options));
|
|
26
|
-
cli.command("serveo:start").option("name", {
|
|
27
|
-
alias: "n",
|
|
28
|
-
type: "string",
|
|
29
|
-
description: "Project name"
|
|
30
|
-
}).option("detach", {
|
|
31
|
-
alias: "d",
|
|
32
|
-
type: "boolean",
|
|
33
|
-
description: "Detach"
|
|
34
|
-
}).option("rebuild", {
|
|
35
|
-
alias: "r",
|
|
36
|
-
type: "boolean",
|
|
37
|
-
description: "Rebuild"
|
|
38
|
-
}).action(options => this.start(options));
|
|
39
|
-
cli.command("serveo:restart").option("name", {
|
|
40
|
-
alias: "n",
|
|
41
|
-
type: "string",
|
|
42
|
-
description: "Project name"
|
|
43
|
-
}).option("detach", {
|
|
44
|
-
alias: "d",
|
|
45
|
-
type: "boolean",
|
|
46
|
-
description: "Detach"
|
|
47
|
-
}).option("rebuild", {
|
|
48
|
-
alias: "r",
|
|
49
|
-
type: "boolean",
|
|
50
|
-
description: "Rebuild"
|
|
51
|
-
}).action(options => this.restart(options));
|
|
52
|
-
cli.command("serveo:stop").option("name", {
|
|
53
|
-
alias: "n",
|
|
54
|
-
type: "string",
|
|
55
|
-
description: "Project name"
|
|
56
|
-
}).action(options => this.stop(options));
|
|
57
|
-
cli.command("serveo:build").action(() => this.build());
|
|
58
|
-
cli.command("serveo:rebuild").action(() => this.rebuild());
|
|
59
|
-
cli.command("serveo:logs").option("name", {
|
|
60
|
-
alias: "n",
|
|
61
|
-
type: "string",
|
|
62
|
-
description: "Project name"
|
|
63
|
-
}).option("detach", {
|
|
64
|
-
type: "boolean",
|
|
65
|
-
alias: "d",
|
|
66
|
-
description: "Detach"
|
|
67
|
-
}).action(options => this.logs(options));
|
|
68
|
-
}
|
|
69
|
-
async onProjectStart(project) {
|
|
70
|
-
if (!project || project.getEnv("SERVEO_ENABLE", "false") !== "true") {
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
console.info("Serveo starting...");
|
|
74
|
-
await this.build();
|
|
75
|
-
const subdomain = project.getEnv(`SERVEO_SUBDOMAIN`);
|
|
76
|
-
await _makes.FS.mkdir(this.dataPath(".ssh"), {
|
|
77
|
-
recursive: true
|
|
78
|
-
});
|
|
79
|
-
let container = await _makes.Docker.getContainer(`serveo-${project.name}`);
|
|
80
|
-
if (container) {
|
|
81
|
-
const {
|
|
82
|
-
State: {
|
|
83
|
-
Running
|
|
84
|
-
}
|
|
85
|
-
} = await container.inspect();
|
|
86
|
-
if (Running) {
|
|
87
|
-
console.info("Serveo is already running");
|
|
88
|
-
return;
|
|
89
|
-
} else {
|
|
90
|
-
await _makes.Docker.removeContainer(`serveo-${project.name}`);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
container = await _makes.Docker.createContainer({
|
|
94
|
-
name: `serveo-${project.name}`,
|
|
95
|
-
image: "ws-serveo",
|
|
96
|
-
tty: true,
|
|
97
|
-
restart: "always",
|
|
98
|
-
volumes: [`${this.dataPath(".ssh")}:/home/user/.ssh`]
|
|
99
|
-
});
|
|
100
|
-
await container.start();
|
|
101
|
-
const stream = await container.attach({
|
|
102
|
-
stream: true,
|
|
103
|
-
stdin: true,
|
|
104
|
-
stdout: true,
|
|
105
|
-
stderr: true,
|
|
106
|
-
hijack: true,
|
|
107
|
-
logs: true
|
|
108
|
-
});
|
|
109
|
-
await container.resize({
|
|
110
|
-
w: process.stdout.columns,
|
|
111
|
-
h: process.stdout.rows
|
|
112
|
-
});
|
|
113
|
-
const lsExec = await container.exec({
|
|
114
|
-
AttachStdin: true,
|
|
115
|
-
AttachStdout: true,
|
|
116
|
-
AttachStderr: true,
|
|
117
|
-
Cmd: ["ls", "/home/user/.ssh/"]
|
|
118
|
-
});
|
|
119
|
-
const lsStream = await lsExec.start({});
|
|
120
|
-
const ls = await new Promise((resolve, reject) => {
|
|
121
|
-
let ls = "";
|
|
122
|
-
lsStream.on("data", data => {
|
|
123
|
-
ls += (0, _utils.demuxOutput)(data);
|
|
124
|
-
});
|
|
125
|
-
lsStream.on("end", () => {
|
|
126
|
-
resolve(ls);
|
|
127
|
-
});
|
|
128
|
-
lsStream.on("error", reject);
|
|
129
|
-
});
|
|
130
|
-
if (ls === "") {
|
|
131
|
-
stream.write("ssh-keygen -q -t rsa -N '' -f ~/.ssh/id_rsa\n");
|
|
132
|
-
} else {
|
|
133
|
-
_makes.Logger.log(JSON.stringify(ls));
|
|
134
|
-
}
|
|
135
|
-
stream.write(`autossh -R ${subdomain ? `${subdomain}.serveo.net:` : ""}80:${project.name}.workspace:80 serveo.net\n`);
|
|
136
|
-
stream.on("data", data => {
|
|
137
|
-
_makes.Logger.log(data);
|
|
138
|
-
if (/Forwarding HTTP traffic/.test(data.toString())) {
|
|
139
|
-
stream.end();
|
|
140
|
-
}
|
|
141
|
-
});
|
|
142
|
-
await _makes.Docker.attachStream(stream);
|
|
143
|
-
}
|
|
144
|
-
async onProjectStop(project) {
|
|
145
|
-
if (!project || project.getEnv("SERVEO_ENABLE", "false") !== "true") {
|
|
146
|
-
return;
|
|
147
|
-
}
|
|
148
|
-
console.info("Serveo stopping...");
|
|
149
|
-
await _makes.Docker.removeContainer(`serveo-${project.name}`);
|
|
150
|
-
}
|
|
151
|
-
async init(options) {
|
|
152
|
-
const {
|
|
153
|
-
name
|
|
154
|
-
} = options;
|
|
155
|
-
const project = await _models.Project.searchOne(name ? {
|
|
156
|
-
name
|
|
157
|
-
} : {
|
|
158
|
-
src: this.appConfigService.getPWD()
|
|
159
|
-
});
|
|
160
|
-
if (!project) {
|
|
161
|
-
throw new Error(`Project not found`);
|
|
162
|
-
}
|
|
163
|
-
const enabled = await (0, _utils.promptConfirm)({
|
|
164
|
-
message: "Enable serveo?",
|
|
165
|
-
default: project.getEnv("SERVEO_ENABLE", "true") === "true"
|
|
166
|
-
});
|
|
167
|
-
if (enabled) {
|
|
168
|
-
project.setEnv("SERVEO_ENABLE", "true");
|
|
169
|
-
const subdomain = await (0, _utils.promptText)({
|
|
170
|
-
message: "Subdomain",
|
|
171
|
-
prefix: "https://",
|
|
172
|
-
suffix: ".serveo.net",
|
|
173
|
-
default: project.getEnv("SERVEO_SUBDOMAIN", project.name)
|
|
174
|
-
});
|
|
175
|
-
project.setEnv("SERVEO_SUBDOMAIN", subdomain);
|
|
176
|
-
} else {
|
|
177
|
-
project.setEnv("SERVEO_ENABLE", "false");
|
|
178
|
-
}
|
|
179
|
-
await project.save();
|
|
180
|
-
}
|
|
181
|
-
async start(options) {
|
|
182
|
-
const {
|
|
183
|
-
name,
|
|
184
|
-
detach,
|
|
185
|
-
rebuild
|
|
186
|
-
} = options;
|
|
187
|
-
if (name) {
|
|
188
|
-
await this.projectService.cdProject(name);
|
|
189
|
-
}
|
|
190
|
-
const project = await this.projectService.get();
|
|
191
|
-
if (rebuild) {
|
|
192
|
-
await this.rebuild();
|
|
193
|
-
}
|
|
194
|
-
await this.onProjectStart(project);
|
|
195
|
-
|
|
196
|
-
// const project = await Project.
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
async stop(options) {
|
|
200
|
-
const {
|
|
201
|
-
name
|
|
202
|
-
} = options;
|
|
203
|
-
if (name) {
|
|
204
|
-
await this.projectService.cdProject(name);
|
|
205
|
-
}
|
|
206
|
-
const project = await this.projectService.get();
|
|
207
|
-
await this.onProjectStop(project);
|
|
208
|
-
}
|
|
209
|
-
async restart(options) {
|
|
210
|
-
const {
|
|
211
|
-
name
|
|
212
|
-
} = options;
|
|
213
|
-
await this.stop({
|
|
214
|
-
name
|
|
215
|
-
});
|
|
216
|
-
await this.start(options);
|
|
217
|
-
}
|
|
218
|
-
async build() {
|
|
219
|
-
const exists = await _makes.Docker.imageExists("ws-serveo");
|
|
220
|
-
if (!exists) {
|
|
221
|
-
const stream = await _makes.Docker.imageBuild2({
|
|
222
|
-
tag: "ws-serveo",
|
|
223
|
-
context: this.pluginPath(),
|
|
224
|
-
src: "./Dockerfile"
|
|
225
|
-
});
|
|
226
|
-
await (0, _utils.followProgress)(stream);
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
async rebuild() {
|
|
230
|
-
const exists = await _makes.Docker.imageExists("ws-serveo");
|
|
231
|
-
if (exists) {
|
|
232
|
-
await _makes.Docker.imageRm("ws-serveo");
|
|
233
|
-
}
|
|
234
|
-
await this.build();
|
|
235
|
-
}
|
|
236
|
-
async logs(options) {
|
|
237
|
-
const {
|
|
238
|
-
name,
|
|
239
|
-
detach
|
|
240
|
-
} = options;
|
|
241
|
-
if (name) {
|
|
242
|
-
await this.projectService.cdProject(name);
|
|
243
|
-
}
|
|
244
|
-
const project = await this.projectService.get();
|
|
245
|
-
const container = await _makes.Docker.getContainer(`serveo-${project.name}`);
|
|
246
|
-
const stream = await container.logs({
|
|
247
|
-
follow: true,
|
|
248
|
-
stderr: true,
|
|
249
|
-
stdout: true,
|
|
250
|
-
tail: 5
|
|
251
|
-
});
|
|
252
|
-
stream.on("data", data => {
|
|
253
|
-
process.stdout.write(data);
|
|
254
|
-
});
|
|
255
|
-
stream.on("error", data => {
|
|
256
|
-
process.stderr.write(data);
|
|
257
|
-
});
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
exports.ServeoPlugin = ServeoPlugin;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { Cli } from "@kearisp/cli";
|
|
2
|
-
import { Plugin } from "src/makes";
|
|
3
|
-
declare class TestPlugin extends Plugin {
|
|
4
|
-
constructor();
|
|
5
|
-
install(cli: Cli): void;
|
|
6
|
-
test(): Promise<void>;
|
|
7
|
-
testData(): Promise<void>;
|
|
8
|
-
test2(): Promise<void>;
|
|
9
|
-
}
|
|
10
|
-
export { TestPlugin };
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.TestPlugin = void 0;
|
|
7
|
-
var os = _interopRequireWildcard(require("os"));
|
|
8
|
-
var _stream = require("stream");
|
|
9
|
-
var _makes = require("../makes");
|
|
10
|
-
var _utils = require("../utils");
|
|
11
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
12
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
13
|
-
class TestPlugin extends _makes.Plugin {
|
|
14
|
-
constructor() {
|
|
15
|
-
super("test");
|
|
16
|
-
}
|
|
17
|
-
install(cli) {
|
|
18
|
-
super.install(cli);
|
|
19
|
-
cli.command("test").action(() => this.test());
|
|
20
|
-
cli.command("test2").action(() => this.test2());
|
|
21
|
-
cli.command("test:data").action(() => this.testData());
|
|
22
|
-
cli.command("test:info").action(async () => {
|
|
23
|
-
_makes.Logger.info(Math.random());
|
|
24
|
-
});
|
|
25
|
-
cli.command("test:warning").action(async () => {
|
|
26
|
-
_makes.Logger.warning(Math.random());
|
|
27
|
-
});
|
|
28
|
-
cli.command("test:error").action(async () => {
|
|
29
|
-
_makes.Logger.error(Math.random());
|
|
30
|
-
});
|
|
31
|
-
cli.command("test:action").action(async () => {
|
|
32
|
-
const a = process.stdout.getWindowSize();
|
|
33
|
-
_makes.Logger.info(a);
|
|
34
|
-
|
|
35
|
-
// await Docker.attach("timer.workspace");
|
|
36
|
-
// await Docker.attach("ngrok-timer");
|
|
37
|
-
|
|
38
|
-
// let image = await Docker.getImage("node:lts");
|
|
39
|
-
|
|
40
|
-
// console.log(image);
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
async test() {
|
|
45
|
-
const readable = new _stream.Readable();
|
|
46
|
-
const pause = async (time = 0) => {
|
|
47
|
-
await new Promise(resolve => setTimeout(resolve, time * 1000));
|
|
48
|
-
};
|
|
49
|
-
readable._read = () => undefined;
|
|
50
|
-
(0, _utils.followProgress)(readable);
|
|
51
|
-
const chunks = ["{\"stream\":\"Step 1/13 : ARG PHP_VERSION\"}\n", "{\"stream\":\"\\n\"}\n", "{\"stream\":\"Step 2/13 : FROM php:${PHP_VERSION}-apache\"}\n", "{\"stream\":\"\\n\"}\n", "{\"status\":\"Pulling from library/php\",\"id\":\"5.6-apache\"}\n", "{\"status\":\"Pulling fs layer\",\"progressDetail\":{},\"id\":\"5e6ec7f28fb7\"}\n", "{\"status\":\"Pulling fs layer\",\"progressDetail\":{},\"id\":\"cf165947b5b7\"}\n", "{\"status\":\"Waiting\",\"progressDetail\":{},\"id\":\"5e6ec7f28fb7\"}\n", "{\"status\":\"Downloading\",\"progressDetail\":{\"current\":10,\"total\":229},\"id\":\"cf165947b5b7\"}\n", "{\"status\":\"Downloading\",\"progressDetail\":{\"current\":25,\"total\":229},\"id\":\"cf165947b5b7\"}\n", "{\"status\":\"Downloading\",\"progressDetail\":{\"current\":50,\"total\":229},\"id\":\"cf165947b5b7\"}\n", "{\"status\":\"Downloading\",\"progressDetail\":{\"current\":100,\"total\":229},\"id\":\"cf165947b5b7\"}\n", "{\"status\":\"Downloading\",\"progressDetail\":{\"current\":120,\"total\":229},\"id\":\"cf165947b5b7\"}\n", "{\"status\":\"Downloading\",\"progressDetail\":{\"current\":200,\"total\":229},\"id\":\"cf165947b5b7\"}\n", "{\"status\":\"Downloading\",\"progressDetail\":{\"current\":229,\"total\":229},\"id\":\"cf165947b5b7\"}\n", "{\"status\":\"Download complete\",\"progressDetail\":{},\"id\":\"cf165947b5b7\"}\n", "{\"status\":\"Digest: sha256:0a40fd273961b99d8afe69a61a68c73c04bc0caa9de384d3b2dd9e7986eec86d\"}\n", "{\"aux\":{\"ID\":\"sha256:87ebbade0d24f347f4067955aad05690956e610dfc0e20c5b278b415c1c36dfc\"}}\n", "{\"status\":\"Downloading\",\"progressDetail\":{\"current\":15,\"total\":100},\"id\":\"5e6ec7f28fb7\"}\n", "{\"status\":\"Downloading\",\"progressDetail\":{\"current\":30,\"total\":100},\"id\":\"5e6ec7f28fb7\"}\n", "{\"status\":\"Download complete\",\"progressDetail\":{},\"id\":\"5e6ec7f28fb7\"}\n", "{\"stream\":\"\\u001b[91m\\r# 1.0%\\u001b[0m\"}\n", "{\"stream\":\"\\u001b[91m\\r## 2.0%\\u001b[0m\"}\n", "{\"stream\":\"Long line ..................................................................................\\rReplace long line.............\\n\"}\n", "{\"stream\":\"\\u001b[91m\\r### 3.0%\\u001b[0m\"}\n", "{\"stream\":\"\\u001b[91m\\r##### 5.0%\\u001b[0m\"}\n", "{\"stream\":\"\\u001b[91m\\r###### 5.0%\\u001b[0m\"}\n", "{\"stream\":\"\\u001b[91m\\r####### 5.0%\\u001b[0m\"}\n", "{\"stream\":\"\\n\"}\n", "{\"stream\":\"\\n\"}\n", "{\"status\":\"Downloading\",\"progressDetail\":{\"current\":100,\"total\":100},\"id\":\"5e6ec7f28fb7\"}\n"];
|
|
52
|
-
for (const chunk of chunks) {
|
|
53
|
-
readable.push(chunk);
|
|
54
|
-
await pause(0.5);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
async testData() {
|
|
58
|
-
const homedir = os.homedir();
|
|
59
|
-
_makes.Logger.info(homedir);
|
|
60
|
-
}
|
|
61
|
-
async test2() {
|
|
62
|
-
process.stdout.write("1 Line\n");
|
|
63
|
-
process.stdout.write("2 Line\n\n");
|
|
64
|
-
process.stdout.write(`\x1b[1A`);
|
|
65
|
-
process.stdout.write("3 Line\n");
|
|
66
|
-
process.stdout.write("4 Line\n");
|
|
67
|
-
process.stdout.write(`\x1b[s`);
|
|
68
|
-
process.stdout.write("5 Line\n");
|
|
69
|
-
process.stdout.write(`\x1b[1A`);
|
|
70
|
-
process.stdout.write("Not 5 Line\n");
|
|
71
|
-
process.stdout.write(`\x1b[u`);
|
|
72
|
-
process.stdout.write("6 Line\n");
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
exports.TestPlugin = TestPlugin;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.promptConfirm = void 0;
|
|
7
|
-
var _inquirer = require("inquirer");
|
|
8
|
-
const promptConfirm = async options => {
|
|
9
|
-
const {
|
|
10
|
-
message,
|
|
11
|
-
default: defaultValue = true
|
|
12
|
-
} = options;
|
|
13
|
-
const res = await (0, _inquirer.prompt)({
|
|
14
|
-
type: "confirm",
|
|
15
|
-
name: "confirm",
|
|
16
|
-
message,
|
|
17
|
-
default: defaultValue
|
|
18
|
-
});
|
|
19
|
-
return res.confirm;
|
|
20
|
-
};
|
|
21
|
-
exports.promptConfirm = promptConfirm;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { PromptConfirmOptions } from "./promptConfirm";
|
|
2
|
-
import { PromptSelectOptions } from "./promptSelect";
|
|
3
|
-
import { PromptTextOptions } from "./promptText";
|
|
4
|
-
type Values = {
|
|
5
|
-
[key: string]: string;
|
|
6
|
-
};
|
|
7
|
-
type Option = ({
|
|
8
|
-
type: "boolean";
|
|
9
|
-
} & PromptConfirmOptions) | PromptTextOptions | ({
|
|
10
|
-
type: "select";
|
|
11
|
-
} & PromptSelectOptions);
|
|
12
|
-
type Options<T = unknown> = {
|
|
13
|
-
[key: string]: Option & T;
|
|
14
|
-
};
|
|
15
|
-
export declare const promptGroup: (values: Values, options: Options) => Promise<Values>;
|
|
16
|
-
export { Options as PromptGroupOptions };
|
package/lib/utils/promptGroup.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.promptGroup = void 0;
|
|
7
|
-
var _promptConfirm = require("./promptConfirm");
|
|
8
|
-
var _promptSelect = require("./promptSelect");
|
|
9
|
-
var _promptText = require("./promptText");
|
|
10
|
-
const promptGroup = async (values, options) => {
|
|
11
|
-
for (const key in options) {
|
|
12
|
-
const value = values[key];
|
|
13
|
-
const option = options[key];
|
|
14
|
-
switch (option.type) {
|
|
15
|
-
case "boolean":
|
|
16
|
-
values[key] = await (0, _promptConfirm.promptConfirm)({
|
|
17
|
-
...option,
|
|
18
|
-
default: typeof value !== "undefined" ? value === "true" : true
|
|
19
|
-
});
|
|
20
|
-
values[key] = values[key].toString();
|
|
21
|
-
break;
|
|
22
|
-
case "string":
|
|
23
|
-
case "integer":
|
|
24
|
-
values[key] = await (0, _promptText.promptText)({
|
|
25
|
-
...option,
|
|
26
|
-
default: typeof value !== "undefined" ? value : option.default || ""
|
|
27
|
-
});
|
|
28
|
-
break;
|
|
29
|
-
case "select":
|
|
30
|
-
values[key] = await (0, _promptSelect.promptSelect)({
|
|
31
|
-
...option,
|
|
32
|
-
default: typeof value !== "undefined" ? value : option.default || ""
|
|
33
|
-
});
|
|
34
|
-
break;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
return values;
|
|
38
|
-
};
|
|
39
|
-
exports.promptGroup = promptGroup;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
type Options = {
|
|
2
|
-
message?: string;
|
|
3
|
-
options: string[] | {
|
|
4
|
-
[value: string]: string;
|
|
5
|
-
} | {
|
|
6
|
-
label?: string;
|
|
7
|
-
value: string;
|
|
8
|
-
}[];
|
|
9
|
-
default?: string;
|
|
10
|
-
};
|
|
11
|
-
declare const promptSelect: (props: Options) => Promise<any>;
|
|
12
|
-
export { promptSelect, Options as PromptSelectOptions };
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.promptSelect = void 0;
|
|
7
|
-
var inquirer = _interopRequireWildcard(require("inquirer"));
|
|
8
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
9
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
10
|
-
const promptSelect = async props => {
|
|
11
|
-
const {
|
|
12
|
-
message = "Select: ",
|
|
13
|
-
options: rawOptions,
|
|
14
|
-
default: value
|
|
15
|
-
} = props;
|
|
16
|
-
const options = Array.isArray(rawOptions) ? rawOptions.map(option => {
|
|
17
|
-
return {
|
|
18
|
-
label: typeof option === "string" ? option : option.label || option.value,
|
|
19
|
-
value: typeof option === "string" ? option : option.value
|
|
20
|
-
};
|
|
21
|
-
}) : Object.keys(rawOptions).map(value => {
|
|
22
|
-
return {
|
|
23
|
-
label: rawOptions[value],
|
|
24
|
-
value
|
|
25
|
-
};
|
|
26
|
-
});
|
|
27
|
-
const defaultOption = options.find(option => {
|
|
28
|
-
return option.value === value;
|
|
29
|
-
});
|
|
30
|
-
const res = await inquirer.prompt({
|
|
31
|
-
type: "list",
|
|
32
|
-
name: "value",
|
|
33
|
-
message: `${message}: `,
|
|
34
|
-
choices: options.map(option => {
|
|
35
|
-
return option.label || option.value;
|
|
36
|
-
}),
|
|
37
|
-
default: defaultOption ? defaultOption.label || defaultOption.value : ""
|
|
38
|
-
});
|
|
39
|
-
const option = options.find(option => {
|
|
40
|
-
return (option.label || option.value) === res.value;
|
|
41
|
-
});
|
|
42
|
-
if (option) {
|
|
43
|
-
return option.value;
|
|
44
|
-
}
|
|
45
|
-
return "";
|
|
46
|
-
};
|
|
47
|
-
exports.promptSelect = promptSelect;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Transformer } from "inquirer";
|
|
2
|
-
type Options = {
|
|
3
|
-
required?: boolean;
|
|
4
|
-
message?: string;
|
|
5
|
-
label?: string;
|
|
6
|
-
prefix?: string;
|
|
7
|
-
suffix?: string;
|
|
8
|
-
type?: "string" | "integer";
|
|
9
|
-
default?: string;
|
|
10
|
-
transformer?: Transformer;
|
|
11
|
-
};
|
|
12
|
-
export declare const promptText: (props: Options) => Promise<any>;
|
|
13
|
-
export { Options as PromptTextOptions };
|
package/lib/utils/promptText.js
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.promptText = void 0;
|
|
7
|
-
var _inquirer = require("inquirer");
|
|
8
|
-
var _chalk = _interopRequireDefault(require("chalk"));
|
|
9
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
-
const promptText = async props => {
|
|
11
|
-
const {
|
|
12
|
-
required,
|
|
13
|
-
message = "Prompt",
|
|
14
|
-
label = message || "Prompt",
|
|
15
|
-
prefix = "",
|
|
16
|
-
suffix = "",
|
|
17
|
-
type = "string",
|
|
18
|
-
default: defaultValue,
|
|
19
|
-
transformer
|
|
20
|
-
} = props;
|
|
21
|
-
const res = await (0, _inquirer.prompt)({
|
|
22
|
-
message: `${label}: `,
|
|
23
|
-
name: "value",
|
|
24
|
-
type: "input",
|
|
25
|
-
default: defaultValue,
|
|
26
|
-
validate(value) {
|
|
27
|
-
if (required) {
|
|
28
|
-
if (typeof value === "undefined" || value === "") {
|
|
29
|
-
return "Mandatory value";
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
if (type === "integer") {
|
|
33
|
-
if (isNaN(parseInt(value)) || parseInt(value).toString() !== value) {
|
|
34
|
-
return "Should be integer";
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
return true;
|
|
38
|
-
},
|
|
39
|
-
transformer: transformer || (value => {
|
|
40
|
-
if (!prefix && !suffix) {
|
|
41
|
-
return value;
|
|
42
|
-
}
|
|
43
|
-
if (suffix) {
|
|
44
|
-
setTimeout(() => {
|
|
45
|
-
process.stdout.write(`\x1b[${suffix.length}D`);
|
|
46
|
-
}, 0);
|
|
47
|
-
}
|
|
48
|
-
return `${_chalk.default.gray(prefix)}${value}${_chalk.default.gray(suffix)}`;
|
|
49
|
-
})
|
|
50
|
-
});
|
|
51
|
-
return res.value;
|
|
52
|
-
};
|
|
53
|
-
exports.promptText = promptText;
|