@wocker/ws 1.0.1 → 1.0.3
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/README.md +11 -137
- package/bin/ws.js +7 -3
- package/lib/App.d.ts +10 -7
- package/lib/App.js +99 -44
- package/lib/controllers/ImageController.d.ts +4 -2
- package/lib/controllers/ImageController.js +27 -25
- package/lib/controllers/PluginController.d.ts +14 -0
- package/lib/controllers/PluginController.js +84 -0
- package/lib/controllers/PresetController.d.ts +21 -0
- package/lib/controllers/PresetController.js +169 -0
- package/lib/controllers/ProjectController.d.ts +11 -3
- package/lib/controllers/ProjectController.js +653 -536
- package/lib/{plugins/ProxyPlugin.d.ts → controllers/ProxyController.d.ts} +12 -11
- package/lib/controllers/ProxyController.js +273 -0
- package/lib/controllers/index.d.ts +3 -0
- package/lib/controllers/index.js +19 -25
- package/lib/env.js +33 -22
- package/lib/index.d.ts +2 -0
- package/lib/index.js +29 -28
- package/lib/makes/Controller.js +4 -8
- package/lib/makes/DI.d.ts +7 -0
- package/lib/makes/DI.js +27 -0
- package/lib/makes/Docker.js +299 -397
- package/lib/makes/FS.d.ts +1 -1
- package/lib/makes/FS.js +328 -301
- package/lib/makes/LineConvertStream.js +37 -40
- package/lib/makes/Logger.d.ts +5 -3
- package/lib/makes/Logger.js +18 -34
- package/lib/makes/Model.js +8 -12
- package/lib/makes/MySQL.js +6 -27
- package/lib/makes/Plugin.d.ts +1 -1
- package/lib/makes/Plugin.js +55 -37
- package/lib/makes/Preset.d.ts +46 -0
- package/lib/makes/Preset.js +33 -0
- package/lib/{models → makes}/Project.d.ts +23 -16
- package/lib/makes/Project.js +127 -0
- package/lib/makes/Repository.js +18 -21
- package/lib/makes/index.d.ts +3 -0
- package/lib/makes/index.js +23 -69
- package/lib/plugins/ElasticSearchPlugin.d.ts +18 -0
- package/lib/plugins/ElasticSearchPlugin.js +72 -0
- package/lib/plugins/LocaltunnelPlugin.d.ts +4 -4
- package/lib/plugins/LocaltunnelPlugin.js +256 -255
- package/lib/plugins/MaildevPlugin.d.ts +4 -2
- package/lib/plugins/MaildevPlugin.js +45 -41
- package/lib/plugins/MongodbPlugin.d.ts +6 -4
- package/lib/plugins/MongodbPlugin.js +303 -254
- package/lib/plugins/NgrokPlugin.d.ts +3 -4
- package/lib/plugins/NgrokPlugin.js +221 -230
- package/lib/plugins/PageKitePlugin.d.ts +3 -4
- package/lib/plugins/PageKitePlugin.js +150 -147
- package/lib/plugins/PostgresPlugin.d.ts +1 -1
- package/lib/plugins/PostgresPlugin.js +115 -88
- package/lib/plugins/ProxmoxPlugin.d.ts +1 -1
- package/lib/plugins/ProxmoxPlugin.js +50 -38
- package/lib/plugins/RedisPlugin.d.ts +10 -2
- package/lib/plugins/RedisPlugin.js +77 -39
- package/lib/plugins/index.d.ts +2 -6
- package/lib/plugins/index.js +25 -158
- package/lib/services/AppConfigService.d.ts +13 -3
- package/lib/services/AppConfigService.js +161 -71
- package/lib/services/AppEventsService.d.ts +5 -8
- package/lib/services/AppEventsService.js +26 -25
- package/lib/services/DockerService.d.ts +51 -0
- package/lib/services/DockerService.js +200 -0
- package/lib/services/LogService.d.ts +12 -0
- package/lib/services/LogService.js +38 -0
- package/lib/services/PluginService.d.ts +11 -0
- package/lib/services/PluginService.js +15 -0
- package/lib/services/PresetService.d.ts +14 -0
- package/lib/services/PresetService.js +64 -0
- package/lib/services/ProjectService.d.ts +12 -4
- package/lib/services/ProjectService.js +141 -78
- package/lib/services/index.d.ts +4 -0
- package/lib/services/index.js +21 -36
- package/lib/types/Config.d.ts +4 -3
- package/lib/types/Config.js +1 -4
- package/lib/types/EnvConfig.js +1 -4
- package/lib/types/index.js +16 -25
- package/lib/utils/buildOptions.js +5 -8
- package/lib/utils/demuxOutput.js +16 -22
- package/lib/utils/escapeRegExp.js +4 -7
- package/lib/utils/exec.d.ts +1 -1
- package/lib/utils/exec.js +38 -40
- package/lib/utils/fetch.js +45 -30
- package/lib/utils/followProgress.js +66 -77
- package/lib/utils/format-size-units.js +16 -16
- package/lib/utils/get-config.d.ts +1 -1
- package/lib/utils/get-config.js +13 -16
- package/lib/utils/get-cursor-position.js +22 -29
- package/lib/utils/image-build.js +35 -23
- package/lib/utils/index.d.ts +0 -4
- package/lib/utils/index.js +32 -235
- package/lib/utils/injectVariables.js +10 -13
- package/lib/utils/parse-table.js +20 -23
- package/lib/utils/set-config.d.ts +1 -1
- package/lib/utils/set-config.js +12 -15
- package/lib/utils/spawn.js +17 -20
- package/lib/utils/tty.js +2 -6
- package/lib/utils/volumeFormat.js +5 -12
- package/lib/utils/volumeParse.js +10 -13
- package/package.json +21 -47
- package/presets/bun/Dockerfile +11 -0
- package/presets/bun/config.json +3 -0
- package/presets/node/Dockerfile +4 -2
- package/presets/node/config.json +9 -7
- package/presets/php-apache/Dockerfile +40 -38
- 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.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/ProxyPlugin.js +0 -257
- 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/mariadb/admin/conf/config.user.inc.php +0 -9
- package/plugins/serveo/Dockerfile +0 -17
package/README.md
CHANGED
|
@@ -1,155 +1,29 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @wocker/ws
|
|
2
2
|
|
|
3
3
|
###### Docker workspace for web projects
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Installation
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
- [docker](https://www.docker.com)
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
## Usage
|
|
12
|
-
|
|
13
|
-
### Installation
|
|
7
|
+
**Note:** It is recommended to install Wocker globally to ensure accessibility from any directory in your terminal.
|
|
14
8
|
|
|
15
9
|
```shell
|
|
16
10
|
npm i -g @wocker/ws
|
|
17
11
|
```
|
|
18
12
|
|
|
19
|
-
### Project initialization
|
|
20
|
-
|
|
21
|
-
```text
|
|
22
|
-
127.0.0.1 <domain>
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
```shell
|
|
26
|
-
cd /project-dir
|
|
27
|
-
ws init
|
|
28
|
-
ws domain:add <domain>
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
### Starting project container
|
|
32
|
-
|
|
33
|
-
```shell
|
|
34
|
-
ws start -d
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
Options:
|
|
38
|
-
- --detach, -d -
|
|
39
|
-
|
|
40
|
-
[//]: # (TODO)
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
### Proxy
|
|
44
|
-
|
|
45
|
-
```shell
|
|
46
|
-
ws proxy:start
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
#### Logs
|
|
50
|
-
|
|
51
|
-
```shell
|
|
52
|
-
ws proxy:logs
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
### Mariadb
|
|
57
|
-
|
|
58
|
-
#### Installation
|
|
59
|
-
|
|
60
|
-
To access the following services within the workspace, please add the following entries to your hosts file:
|
|
61
|
-
|
|
62
|
-
```text
|
|
63
|
-
127.0.0.1 maildev.workspace
|
|
64
|
-
127.0.0.1 dbadmin-mariadb.workspace
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
#### Start Mariadb
|
|
69
|
-
|
|
70
|
-
```shell
|
|
71
|
-
ws maridb:start
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
### Backup db
|
|
75
|
-
|
|
76
|
-
The `mariadb:backup` command is used to create a backup of a MariaDB database.
|
|
77
|
-
|
|
78
|
-
```shell
|
|
79
|
-
ws mariadb:backup [database]
|
|
80
|
-
```
|
|
81
|
-
|
|
82
|
-
#### Backup Location
|
|
83
|
-
|
|
84
|
-
The backup file will be saved in the following directory:
|
|
85
|
-
|
|
86
|
-
> $WS_DIR/plugins/mariadb/dump/**\[dbname]**/yyyy-MM-dd HH-mm.sql
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
### Delete backup
|
|
90
|
-
|
|
91
|
-
The `mariadb:delete-backup` command will remove file from `$WS_DIR` directory.
|
|
92
|
-
|
|
93
|
-
```shell
|
|
94
|
-
ws mariadb:delete-backup [database] [filename]
|
|
95
|
-
```
|
|
96
|
-
|
|
97
|
-
### Dump
|
|
98
|
-
|
|
99
|
-
The `mariadb:dump` command is used to dump a MariaDB database to a file.
|
|
100
|
-
|
|
101
|
-
```shell
|
|
102
|
-
ws mairadb:dump [database] > dump.sql
|
|
103
|
-
```
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
## Technologies
|
|
107
|
-
|
|
108
|
-
- [typescript](https://www.typescriptlang.org)
|
|
109
|
-
- [dockerode](https://npmjs.org/package/dockerode)
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
## Environments
|
|
113
|
-
|
|
114
|
-
You can add `WS_DIR` into `.bashrc` for changing ws data path.
|
|
115
|
-
|
|
116
|
-
```shell
|
|
117
|
-
export WS_DIR="$HOME/.workspace"
|
|
118
|
-
```
|
|
119
|
-
|
|
120
13
|
|
|
121
14
|
### Completion
|
|
122
15
|
|
|
16
|
+
Wocker comes with shell completion support to enhance your development workflow. To enable shell completion, run the following command:
|
|
17
|
+
|
|
123
18
|
```bash
|
|
124
19
|
source <(ws completion script)
|
|
125
20
|
```
|
|
126
21
|
|
|
22
|
+
This will enable tab completion for `ws` commands, providing a more convenient and efficient way to interact with the tool.
|
|
127
23
|
|
|
128
|
-
## Folders structure
|
|
129
24
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
│ ├── mariadb/
|
|
136
|
-
│ └── ngrok/
|
|
137
|
-
├── presets/
|
|
138
|
-
│ ├── apache/
|
|
139
|
-
│ ├── go/
|
|
140
|
-
│ ├── node/
|
|
141
|
-
│ └── shopify/
|
|
142
|
-
├── plugins/
|
|
143
|
-
└── src/
|
|
144
|
-
├── makes/
|
|
145
|
-
│ └── index.ts
|
|
146
|
-
├── models/
|
|
147
|
-
│ └── index.ts
|
|
148
|
-
├── types/
|
|
149
|
-
│ └── index.ts
|
|
150
|
-
├── utils/
|
|
151
|
-
│ └── index.ts
|
|
152
|
-
├── App.ts
|
|
153
|
-
├── env.ts
|
|
154
|
-
└── index.ts
|
|
155
|
-
```
|
|
25
|
+
## Documentation
|
|
26
|
+
|
|
27
|
+
Wocker is a powerful tool for managing your web project's Docker workspace. It provides a convenient and efficient way to set up and manage your Docker containers.
|
|
28
|
+
|
|
29
|
+
For more information and detailed usage, please refer to the [documentation](https://kearisp.github.io/wocker).
|
package/bin/ws.js
CHANGED
|
@@ -4,10 +4,14 @@ const chalk = require("chalk");
|
|
|
4
4
|
const {app} = require("../lib/index.js");
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
app.run().then((res) => {
|
|
8
|
-
if(res) {
|
|
9
|
-
|
|
7
|
+
app.run(process.argv).then((res) => {
|
|
8
|
+
if(!res) {
|
|
9
|
+
return;
|
|
10
10
|
}
|
|
11
|
+
|
|
12
|
+
process.stdout.write(res);
|
|
11
13
|
}).catch((err) => {
|
|
12
14
|
console.error(chalk.red(err.message));
|
|
15
|
+
|
|
16
|
+
// throw err;
|
|
13
17
|
});
|
package/lib/App.d.ts
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
|
+
import { Controller } from "@wocker/core";
|
|
1
2
|
import { Cli } from "@kearisp/cli";
|
|
2
|
-
import {
|
|
3
|
-
import { AppConfigService } from "
|
|
3
|
+
import { DI } from "./makes";
|
|
4
|
+
import { AppConfigService } from "./services";
|
|
4
5
|
export declare class App {
|
|
5
|
-
protected
|
|
6
|
+
protected di: DI;
|
|
6
7
|
protected cli: Cli;
|
|
7
|
-
|
|
8
|
+
protected appConfigService: AppConfigService;
|
|
9
|
+
constructor();
|
|
8
10
|
install(): void;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
use(Constructor: {
|
|
12
|
+
new (...params: any[]): Controller;
|
|
13
|
+
}): void;
|
|
14
|
+
setDebug(status: string): Promise<string>;
|
|
12
15
|
run(): Promise<string>;
|
|
13
16
|
}
|
package/lib/App.js
CHANGED
|
@@ -1,52 +1,107 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
5
17
|
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
26
|
exports.App = void 0;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
27
|
+
const cli_1 = require("@kearisp/cli");
|
|
28
|
+
const Path = __importStar(require("path"));
|
|
29
|
+
const env_1 = require("./env");
|
|
30
|
+
const utils_1 = require("./utils");
|
|
31
|
+
const makes_1 = require("./makes");
|
|
32
|
+
const services_1 = require("./services");
|
|
33
|
+
const controllers_1 = require("./controllers");
|
|
14
34
|
class App {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
35
|
+
constructor() {
|
|
36
|
+
this.di = new makes_1.DI();
|
|
37
|
+
this.appConfigService = new services_1.AppConfigService();
|
|
38
|
+
this.di.registerService(services_1.AppConfigService, this.appConfigService);
|
|
39
|
+
this.di.registerService(services_1.AppEventsService, new services_1.AppEventsService());
|
|
40
|
+
this.di.registerService(services_1.DockerService, new services_1.DockerService(this.di));
|
|
41
|
+
this.di.registerService(services_1.PresetService, new services_1.PresetService(this.di));
|
|
42
|
+
this.di.registerService(services_1.PluginService, new services_1.PluginService(this.di));
|
|
43
|
+
this.di.registerService(services_1.ProjectService, new services_1.ProjectService(this.di));
|
|
44
|
+
this.di.registerService(services_1.LogService, new services_1.LogService(this.di));
|
|
45
|
+
this.di.registerService(cli_1.Cli, this.cli);
|
|
46
|
+
this.cli = new cli_1.Cli(makes_1.Logger);
|
|
47
|
+
makes_1.Preset.install(this.di);
|
|
48
|
+
makes_1.Project.install(this.di);
|
|
49
|
+
makes_1.Logger.install(this.di);
|
|
50
|
+
this.install();
|
|
51
|
+
this.use(controllers_1.ImageController);
|
|
52
|
+
this.use(controllers_1.PluginController);
|
|
53
|
+
this.use(controllers_1.PresetController);
|
|
54
|
+
this.use(controllers_1.ProjectController);
|
|
55
|
+
this.use(controllers_1.ProxyController);
|
|
56
|
+
}
|
|
57
|
+
install() {
|
|
58
|
+
this.cli.command("completion script")
|
|
59
|
+
.help(false)
|
|
60
|
+
.action(() => this.cli.completionScript());
|
|
61
|
+
this.cli.command("log [...items]")
|
|
62
|
+
.action((options, items) => {
|
|
63
|
+
makes_1.Logger.log(...items);
|
|
64
|
+
return "";
|
|
65
|
+
});
|
|
66
|
+
this.cli.command("debug <status>")
|
|
67
|
+
.completion("status", () => ["on", "off"])
|
|
68
|
+
.action(async (options, status) => this.setDebug(status));
|
|
69
|
+
}
|
|
70
|
+
use(Constructor) {
|
|
71
|
+
const controller = new Constructor(this.di);
|
|
72
|
+
controller.install(this.cli);
|
|
40
73
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
74
|
+
async setDebug(status) {
|
|
75
|
+
makes_1.Logger.info(`Set debug ${status}`);
|
|
76
|
+
await (0, utils_1.setConfig)({
|
|
77
|
+
debug: status === "on"
|
|
78
|
+
});
|
|
79
|
+
return "";
|
|
45
80
|
}
|
|
46
|
-
|
|
47
|
-
|
|
81
|
+
async run() {
|
|
82
|
+
const mapDir = Path.dirname(env_1.MAP_PATH);
|
|
83
|
+
if (!makes_1.FS.existsSync(mapDir)) {
|
|
84
|
+
await makes_1.FS.mkdir(mapDir);
|
|
85
|
+
}
|
|
86
|
+
if (!makes_1.FS.existsSync(env_1.MAP_PATH)) {
|
|
87
|
+
await makes_1.FS.writeJSON(env_1.MAP_PATH, {
|
|
88
|
+
projects: []
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
if (!makes_1.FS.existsSync(`${env_1.DATA_DIR}/projects`)) {
|
|
92
|
+
await makes_1.FS.mkdir(`${env_1.DATA_DIR}/projects`);
|
|
93
|
+
}
|
|
94
|
+
const { plugins = [] } = await this.appConfigService.getAppConfig();
|
|
95
|
+
for (const plugin of plugins) {
|
|
96
|
+
try {
|
|
97
|
+
const { default: Plugin } = await Promise.resolve(`${plugin}`).then(s => __importStar(require(s)));
|
|
98
|
+
this.use(Plugin);
|
|
99
|
+
}
|
|
100
|
+
catch (err) {
|
|
101
|
+
makes_1.Logger.error(err.message);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return this.cli.run(process.argv);
|
|
48
105
|
}
|
|
49
|
-
return this.cli.run(process.argv);
|
|
50
|
-
}
|
|
51
106
|
}
|
|
52
|
-
exports.App = App;
|
|
107
|
+
exports.App = App;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { Cli } from "@kearisp/cli";
|
|
2
|
-
import { Controller } from "
|
|
2
|
+
import { DI, Controller } from "../makes";
|
|
3
|
+
import { AppConfigService } from "../services";
|
|
3
4
|
declare class ImageController extends Controller {
|
|
4
|
-
|
|
5
|
+
protected appConfigService: AppConfigService;
|
|
6
|
+
constructor(di: DI);
|
|
5
7
|
install(cli: Cli): void;
|
|
6
8
|
list(): Promise<string>;
|
|
7
9
|
}
|
|
@@ -1,29 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
});
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.ImageController = void 0;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
class ImageController extends
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
7
|
+
const cli_table3_1 = __importDefault(require("cli-table3"));
|
|
8
|
+
const makes_1 = require("../makes");
|
|
9
|
+
const services_1 = require("../services");
|
|
10
|
+
class ImageController extends makes_1.Controller {
|
|
11
|
+
constructor(di) {
|
|
12
|
+
super();
|
|
13
|
+
this.appConfigService = di.resolveService(services_1.AppConfigService);
|
|
14
|
+
}
|
|
15
|
+
install(cli) {
|
|
16
|
+
super.install(cli);
|
|
17
|
+
cli.command("images")
|
|
18
|
+
.action(() => this.list());
|
|
19
|
+
}
|
|
20
|
+
async list() {
|
|
21
|
+
const images = await makes_1.Docker.imageLs({});
|
|
22
|
+
const table = new cli_table3_1.default({
|
|
23
|
+
head: ["Name"]
|
|
24
|
+
});
|
|
25
|
+
for (const image of images) {
|
|
26
|
+
table.push([image.Id]);
|
|
27
|
+
}
|
|
28
|
+
return table.toString() + "\n";
|
|
25
29
|
}
|
|
26
|
-
return table.toString() + "\n";
|
|
27
|
-
}
|
|
28
30
|
}
|
|
29
|
-
exports.ImageController = ImageController;
|
|
31
|
+
exports.ImageController = ImageController;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Cli } from "@kearisp/cli";
|
|
2
|
+
import { DI, Controller } from "../makes";
|
|
3
|
+
import { AppConfigService, PluginService } from "../services";
|
|
4
|
+
type AddOptions = {};
|
|
5
|
+
type RemoveOptions = {};
|
|
6
|
+
declare class PluginController extends Controller {
|
|
7
|
+
protected appConfigService: AppConfigService;
|
|
8
|
+
protected pluginService: PluginService;
|
|
9
|
+
constructor(di: DI);
|
|
10
|
+
install(cli: Cli): void;
|
|
11
|
+
add(options: AddOptions, addName: string): Promise<void>;
|
|
12
|
+
remove(options: RemoveOptions, removeName: string): Promise<void>;
|
|
13
|
+
}
|
|
14
|
+
export { PluginController };
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.PluginController = void 0;
|
|
30
|
+
const axios_1 = __importDefault(require("axios"));
|
|
31
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
32
|
+
const makes_1 = require("../makes");
|
|
33
|
+
const services_1 = require("../services");
|
|
34
|
+
const utils_1 = require("../utils");
|
|
35
|
+
class PluginController extends makes_1.Controller {
|
|
36
|
+
constructor(di) {
|
|
37
|
+
super();
|
|
38
|
+
this.appConfigService = di.resolveService(services_1.AppConfigService);
|
|
39
|
+
this.pluginService = di.resolveService(services_1.PluginService);
|
|
40
|
+
}
|
|
41
|
+
install(cli) {
|
|
42
|
+
super.install(cli);
|
|
43
|
+
cli.command("plugin:add <name>")
|
|
44
|
+
.action((options, name) => this.add(options, name));
|
|
45
|
+
cli.command("plugin:remove <name>")
|
|
46
|
+
.action((options, name) => this.remove(options, name));
|
|
47
|
+
}
|
|
48
|
+
async add(options, addName) {
|
|
49
|
+
const [, prefix = "@wocker/", name, suffix = "-plugin"] = /^(@wocker\/)?(\w+)(-plugin)?$/.exec(addName) || [];
|
|
50
|
+
const fullName = `${prefix}${name}${suffix}`;
|
|
51
|
+
try {
|
|
52
|
+
const { default: Plugin } = await Promise.resolve(`${fullName}`).then(s => __importStar(require(s)));
|
|
53
|
+
this.pluginService.use(Plugin);
|
|
54
|
+
await this.appConfigService.activatePlugin(fullName);
|
|
55
|
+
console.info(`Plugin ${fullName} activated`);
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
catch (err) {
|
|
59
|
+
makes_1.Logger.error(err.message);
|
|
60
|
+
}
|
|
61
|
+
try {
|
|
62
|
+
const res = await axios_1.default.get(`https://registry.npmjs.org/${encodeURIComponent(fullName)}`, {
|
|
63
|
+
validateStatus: () => true
|
|
64
|
+
});
|
|
65
|
+
if (res.status !== 200) {
|
|
66
|
+
console.error(chalk_1.default.red(`Plugin ${fullName} not found`));
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
console.info(`Installing ${fullName}`);
|
|
70
|
+
await (0, utils_1.exec)(`npm install -g ${fullName}`);
|
|
71
|
+
await this.appConfigService.activatePlugin(fullName);
|
|
72
|
+
}
|
|
73
|
+
catch (err) {
|
|
74
|
+
makes_1.Logger.error(err.message);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
async remove(options, removeName) {
|
|
78
|
+
const [, prefix = "@wocker/", name, suffix = "-plugin"] = /^(@wocker\/)?(\w+)(-plugin)?$/.exec(removeName) || [];
|
|
79
|
+
const fullName = `${prefix}${name}${suffix}`;
|
|
80
|
+
await this.appConfigService.deactivatePlugin(fullName);
|
|
81
|
+
console.info(`Plugin ${fullName} deactivated`);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
exports.PluginController = PluginController;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Cli } from "@wocker/core";
|
|
2
|
+
import { DI, Controller, Project } from "../makes";
|
|
3
|
+
import { AppConfigService, AppEventsService, ProjectService, PresetService, DockerService } from "../services";
|
|
4
|
+
type BuildParams = {
|
|
5
|
+
rebuild?: boolean;
|
|
6
|
+
};
|
|
7
|
+
declare class PresetController extends Controller {
|
|
8
|
+
protected appConfigService: AppConfigService;
|
|
9
|
+
protected appEventsService: AppEventsService;
|
|
10
|
+
protected projectService: ProjectService;
|
|
11
|
+
protected presetService: PresetService;
|
|
12
|
+
protected dockerService: DockerService;
|
|
13
|
+
constructor(di: DI);
|
|
14
|
+
install(cli: Cli): void;
|
|
15
|
+
presets(): Promise<string[]>;
|
|
16
|
+
protected onInit(project: Project): Promise<void>;
|
|
17
|
+
protected onRebuild(project: Project): Promise<void>;
|
|
18
|
+
protected onBeforeStart(project: Project): Promise<void>;
|
|
19
|
+
build(options: BuildParams, presetName: string): Promise<void>;
|
|
20
|
+
}
|
|
21
|
+
export { PresetController };
|