@wocker/ws 1.0.14 → 1.0.16

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.
Files changed (39) hide show
  1. package/lib/AppModule.js +3 -3
  2. package/lib/controllers/DebugController.d.ts +3 -0
  3. package/lib/controllers/DebugController.js +43 -1
  4. package/lib/controllers/PresetController.d.ts +3 -1
  5. package/lib/controllers/PresetController.js +42 -7
  6. package/lib/controllers/ProjectController.d.ts +2 -1
  7. package/lib/controllers/ProjectController.js +17 -13
  8. package/lib/controllers/ProxyController.d.ts +1 -1
  9. package/lib/controllers/ProxyController.js +4 -4
  10. package/lib/env.d.ts +0 -1
  11. package/lib/env.js +1 -2
  12. package/lib/plugins/index.d.ts +0 -1
  13. package/lib/plugins/index.js +0 -1
  14. package/lib/services/AppConfigService.d.ts +6 -6
  15. package/lib/services/AppConfigService.js +42 -27
  16. package/lib/services/LogService.d.ts +3 -1
  17. package/lib/services/LogService.js +9 -1
  18. package/lib/services/PluginService.js +1 -1
  19. package/lib/services/PresetService.d.ts +12 -3
  20. package/lib/services/PresetService.js +256 -20
  21. package/lib/services/ProjectService.d.ts +2 -3
  22. package/lib/services/ProjectService.js +32 -26
  23. package/lib/services/ProxyService.js +10 -20
  24. package/package.json +5 -3
  25. package/presets/bun/config.json +1 -0
  26. package/presets/go/config.json +1 -0
  27. package/presets/php-fpm/config.json +1 -0
  28. package/presets/shopify/config.json +2 -0
  29. package/lib/plugins/PageKitePlugin.d.ts +0 -30
  30. package/lib/plugins/PageKitePlugin.js +0 -145
  31. package/plugins/pagekite/Dockerfile +0 -3
  32. package/presets/node/Dockerfile +0 -39
  33. package/presets/node/config.json +0 -39
  34. package/presets/php-apache/Dockerfile +0 -227
  35. package/presets/php-apache/bin/compare-version +0 -3
  36. package/presets/php-apache/config.json +0 -64
  37. package/presets/php-apache/etc/apache2/apache2.conf +0 -230
  38. package/presets/php-apache/etc/apache2/mods-available/mpm_prefork.conf +0 -16
  39. package/presets/php-apache/etc/apache2/sites-available/000-default.conf +0 -21
@@ -1,145 +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.PageKitePlugin = void 0;
13
- const core_1 = require("@wocker/core");
14
- const utils_1 = require("@wocker/utils");
15
- const services_1 = require("../services");
16
- let PageKitePlugin = class PageKitePlugin {
17
- constructor(appConfigService, appEventsService, projectService, dockerService) {
18
- this.appConfigService = appConfigService;
19
- this.appEventsService = appEventsService;
20
- this.projectService = projectService;
21
- this.dockerService = dockerService;
22
- }
23
- pluginPath(...parts) {
24
- return this.appConfigService.pluginsPath("pagekite", ...parts);
25
- }
26
- async onProjectStart(project) {
27
- if (!project || project.getEnv("PAGEKITE_ENABLE", "false") !== "true") {
28
- return;
29
- }
30
- console.info("Pagekite starting...");
31
- await this.build();
32
- let container = await this.dockerService.getContainer(`pagekite-${project.name}`);
33
- if (container) {
34
- const { State: { Running } } = await container.inspect();
35
- if (Running) {
36
- console.info("Pagekite is already running");
37
- return;
38
- }
39
- else {
40
- await this.dockerService.removeContainer(`pagekite-${project.name}`);
41
- }
42
- }
43
- const subdomain = project.getEnv("PAGEKITE_SUBDOMAIN");
44
- container = await this.dockerService.createContainer({
45
- name: `pagekite-${project.name}`,
46
- image: "ws-pagekite",
47
- tty: true,
48
- restart: "always",
49
- cmd: [
50
- "python",
51
- "pagekite.py",
52
- `${project.name}.workspace:80`,
53
- `${subdomain}.pagekite.me`
54
- ]
55
- });
56
- await container.start();
57
- await container.resize({
58
- w: process.stdout.columns,
59
- h: process.stdout.rows
60
- });
61
- const stream = await container.attach({
62
- stream: true,
63
- stdin: true,
64
- stdout: true,
65
- stderr: true,
66
- hijack: true,
67
- logs: true
68
- });
69
- stream.on("data", (data) => {
70
- if (/Kites are flying and all is well\./.test(data.toString())) {
71
- stream.end();
72
- }
73
- });
74
- await this.dockerService.attachStream(stream);
75
- }
76
- async onProjectStop(project) {
77
- if (!project || project.getEnv("PAGEKITE_ENABLE", "false") !== "true") {
78
- return;
79
- }
80
- console.info("Pagekite stopping...");
81
- await this.dockerService.removeContainer(`pagekite-${project.name}`);
82
- }
83
- async init(options) {
84
- const project = await this.projectService.get();
85
- const enabled = await (0, utils_1.promptConfirm)({
86
- message: "Enable pagekite",
87
- default: project.getEnv("PAGEKITE_ENABLE", "true") === "true"
88
- });
89
- if (enabled) {
90
- project.setEnv("PAGEKITE_ENABLE", "true");
91
- const subdomain = await (0, utils_1.promptText)({
92
- message: "Subdomain",
93
- prefix: "https://",
94
- suffix: ".pagekite.me",
95
- default: project.getEnv("PAGEKITE_SUBDOMAIN", project.name)
96
- });
97
- project.setEnv("PAGEKITE_SUBDOMAIN", subdomain);
98
- }
99
- else {
100
- project.setEnv("PAGEKITE_ENABLE", "false");
101
- }
102
- await project.save();
103
- }
104
- async start(options) {
105
- const { name, restart } = options;
106
- if (name) {
107
- await this.projectService.cdProject(name);
108
- }
109
- const project = await this.projectService.get();
110
- if (restart) {
111
- await this.dockerService.removeContainer(`pagekite-${project.name}`);
112
- }
113
- await this.onProjectStart(project);
114
- }
115
- async stop(options) {
116
- const { name } = options;
117
- if (name) {
118
- await this.projectService.cdProject(name);
119
- }
120
- const project = await this.projectService.get();
121
- await this.onProjectStop(project);
122
- }
123
- async build(options = {}) {
124
- const { rebuild } = options;
125
- const exists = await this.dockerService.imageExists("ws-pagekite");
126
- if (rebuild) {
127
- await this.dockerService.removeContainer("ws-pagekite");
128
- }
129
- if (!exists || rebuild) {
130
- await this.dockerService.buildImage({
131
- tag: "ws-pagekite",
132
- context: this.pluginPath(),
133
- src: "./Dockerfile"
134
- });
135
- }
136
- }
137
- };
138
- exports.PageKitePlugin = PageKitePlugin;
139
- exports.PageKitePlugin = PageKitePlugin = __decorate([
140
- (0, core_1.Controller)(),
141
- __metadata("design:paramtypes", [services_1.AppConfigService,
142
- services_1.AppEventsService,
143
- services_1.ProjectService,
144
- services_1.DockerService])
145
- ], PageKitePlugin);
@@ -1,3 +0,0 @@
1
- FROM python:3
2
-
3
- RUN curl -O https://pagekite.net/pk/pagekite.py
@@ -1,39 +0,0 @@
1
- ARG NODE_VERSION
2
- ARG PACKAGE_MANAGER
3
-
4
- FROM node:${NODE_VERSION}
5
-
6
- ARG UID=1000
7
- ARG USER=user
8
-
9
- ENV TZ=America/Los_Angeles
10
- ENV APP_PORT 80
11
- ENV PORT=$APP_PORT
12
- ENV NPM_RUN 'npm start'
13
- ENV PACKAGE_MANAGER "npm"
14
-
15
- RUN ip r l
16
-
17
- RUN apk add tcpdump iproute2 iptables
18
-
19
- #RUN echo "1 test" >> /etc/iproute2/rt_tables
20
- #RUN ip rule add from 10.8.0.2 table test
21
-
22
- RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
23
- RUN apk --update --no-cache add busybox-extras
24
- RUN apk add --no-cache bash
25
-
26
- VOLUME ["/usr/app"]
27
-
28
- WORKDIR /usr/app
29
-
30
- EXPOSE 80
31
-
32
- USER $UID
33
-
34
- CMD if [ "$PACKAGE_MANAGER" = "npm" ]; then \
35
- npm install --quiet --no-progress; \
36
- else \
37
- yarn install --silent; \
38
- fi && \
39
- ${NPM_RUN}
@@ -1,39 +0,0 @@
1
- {
2
- "dockerfile": "./Dockerfile",
3
- "DocumentRoot": "/usr/app",
4
- "buildArgsOptions": {
5
- "NODE_VERSION": {
6
- "type": "select",
7
- "options": [
8
- "14-alpine3.14",
9
- "16-alpine3.14",
10
- "17-alpine3.14",
11
- "18-alpine3.14",
12
- "20-alpine3.18"
13
- ]
14
- }
15
- },
16
- "envOptions": {
17
- "APP_PORT": {
18
- "message": "Port",
19
- "type": "integer",
20
- "default": 80
21
- },
22
- "NPM_RUN": {
23
- "message": "Run command",
24
- "type": "string",
25
- "default": "npm start"
26
- },
27
- "PACKAGE_MANAGER": {
28
- "message": "Package manager",
29
- "type": "select",
30
- "options": [
31
- "npm",
32
- "yarn"
33
- ]
34
- }
35
- },
36
- "volumeOptions": [
37
- "./:/usr/app"
38
- ]
39
- }
@@ -1,227 +0,0 @@
1
- ARG PHP_VERSION
2
-
3
- FROM php:${PHP_VERSION}-apache
4
-
5
- ARG UID=1000
6
- ARG USER=www-data
7
-
8
- RUN usermod -u $UID -s /bin/bash $USER && \
9
- mkdir -p /home/$USER && \
10
- touch /home/$USER/.bashrc && \
11
- chown -R $USER:$USER /home/$USER
12
-
13
- # WS Tools
14
- ADD ./bin/compare-version /usr/local/bin/compare-version
15
- RUN chmod +x /usr/local/bin/compare-version
16
-
17
- RUN apt-get update --fix-missing -y
18
- RUN apt-get install -y curl git
19
-
20
- #RUN apt-get install -y \
21
- # build-essential \
22
- # libssl-dev \
23
- # zlib1g-dev
24
-
25
- # Http
26
- ARG HTTP_ENABLE=false
27
- RUN if [ "$HTTP_ENABLE" = "true" ]; then \
28
- apt-get update && apt-get install -y \
29
- libpcre3-dev \
30
- libssl-dev \
31
- libcurl4-openssl-dev \
32
- libicu-dev \
33
- g++ \
34
- zlib1g-dev && \
35
- docker-php-ext-install pcntl && \
36
- pecl install raphf && docker-php-ext-enable raphf && \
37
- pecl install pecl_http && docker-php-ext-enable http; \
38
- fi
39
-
40
- # Mysqli
41
- ARG MYSQLI_ENABLE=false
42
- RUN if [ "$MYSQLI_ENABLE" = "true" ]; then \
43
- docker-php-ext-install -j "$(nproc)" mysqli && \
44
- docker-php-ext-enable mysqli; \
45
- fi
46
-
47
- # pdo
48
- ARG PDO_MYSQL_ENABLE=false
49
- RUN if [ "$PDO_MYSQL_ENABLE" = "true" ]; then \
50
- docker-php-ext-install pdo pdo_mysql && \
51
- docker-php-ext-enable pdo_mysql; \
52
- fi
53
-
54
- # pgsql
55
- ARG PGSQL_ENABLE=false
56
- RUN if [ "$PGSQL_ENABLE" = "true" ]; then \
57
- apt-get install -y libpq-dev && \
58
- docker-php-ext-install -j "$(nproc)" pgsql pdo_pgsql && \
59
- docker-php-ext-enable pgsql pdo_pgsql; \
60
- fi
61
-
62
- #gd
63
- ARG GD_ENABLE=false
64
- RUN if [ "$GD_ENABLE" = "true" ]; then \
65
- apt-get update && apt-get install -y \
66
- libfreetype6-dev \
67
- libjpeg62-turbo-dev \
68
- libpng-dev && \
69
- compare-version $PHP_VERSION "7.3" && \
70
- docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include || \
71
- docker-php-ext-configure gd --with-freetype --with-jpeg && \
72
- docker-php-ext-install -j$(nproc) gd && \
73
- docker-php-ext-install exif; \
74
- fi
75
-
76
- # Zip
77
- ARG ZIP_ENABLE=false
78
- RUN if [ "$ZIP_ENABLE" = "true" ]; then \
79
- apt-get install -y libzip-dev zip unzip && \
80
- docker-php-ext-configure zip && \
81
- docker-php-ext-install -j "$(nproc)" zip; \
82
- fi
83
-
84
- # memcache
85
- ARG MEMCACHE_ENABLE=false
86
- RUN if [ "$MEMCACHE_ENABLE" = "true" ]; then \
87
- apt-get update && apt-get install -y \
88
- zlib1g-dev \
89
- libmemcached-dev && \
90
- pecl install memcache && docker-php-ext-enable memcache; \
91
- fi
92
-
93
- # memcached
94
- ARG MEMCACHED_ENABLE=false
95
- RUN if [ "$MEMCACHED_ENABLE" = "true" ]; then \
96
- apt-get update && apt-get install -y \
97
- libcurl4-openssl-dev \
98
- libssl-dev \
99
- libmemcached-dev \
100
- zlib1g-dev && \
101
- pecl install memcached && docker-php-ext-enable memcached; \
102
- fi
103
-
104
- # Intl
105
- ARG INTL_ENABLE=false
106
- RUN if [ "$INTL_ENABLE" = "true" ]; then \
107
- apt-get update && apt-get install -y \
108
- libicu-dev && \
109
- docker-php-ext-configure intl && \
110
- docker-php-ext-install intl; \
111
- fi
112
-
113
- # Pcntl
114
- ARG PCNTL_ENABLE=false
115
- RUN if [ "$PCNTL_ENABLE" = "true" ]; then \
116
- docker-php-ext-install pcntl && \
117
- docker-php-ext-enable pcntl; \
118
- fi
119
-
120
- # Soap
121
- ARG SOAP_ENABLE=false
122
- RUN if [ "$SOAP_ENABLE" = "true" ]; then \
123
- apt-get update && apt-get install -y \
124
- libxml2-dev && \
125
- docker-php-ext-install soap && \
126
- docker-php-ext-enable soap; \
127
- fi
128
-
129
- # XDebug
130
- ARG XDEBUG_ENABLE=false
131
- RUN if [ "$XDEBUG_ENABLE" = "true" ]; then \
132
- pecl install xdebug && \
133
- docker-php-ext-enable xdebug; \
134
- fi
135
-
136
- # Gettext
137
- ARG GETTEXT_ENABLE=false
138
- RUN if [ "$GETTEXT_ENABLE" = "true" ]; then \
139
- apt-get update && apt-get install -y gettext && \
140
- docker-php-ext-install -j "$(nproc)" gettext && \
141
- docker-php-ext-enable gettext; \
142
- fi
143
-
144
- # Bcmath
145
- ARG BCMATH_ENABLE=false
146
- RUN if [ "$BCMATH_ENABLE" = "true" ]; then \
147
- docker-php-ext-install -j "$(nproc)" bcmath && \
148
- docker-php-ext-enable bcmath; \
149
- fi
150
-
151
- # Sockets
152
- ARG SOCKETS_ENABLE=false
153
- RUN if [ "$SOCKETS_ENABLE" = "true" ]; then \
154
- docker-php-ext-install sockets && \
155
- docker-php-ext-enable sockets; \
156
- fi
157
-
158
- #RUN compare-version $PHP_VERSION "7.3" && \
159
- # docker-php-ext-configure zip || \
160
- # docker-php-ext-configure zip --with-libzip
161
-
162
- # Composer
163
- ARG COMPOSER_ENABLE=false
164
-
165
- SHELL ["/bin/bash", "-c"]
166
- RUN if [ "$COMPOSER_ENABLE" = "true" ]; then \
167
- apt-get update && \
168
- apt-get install -y bash-completion; \
169
- echo "source /etc/bash_completion" >> /home/$USER/.bashrc; \
170
- mkdir -p /home/$USER/.composer; \
171
- curl -sL https://getcomposer.org/installer | php && \
172
- mv composer.phar /usr/local/bin/composer && \
173
- chmod +x /usr/local/bin/composer; \
174
- echo ". <(composer completion bash)" >> /home/$USER/.bashrc; \
175
- fi
176
- SHELL ["/bin/sh", "-c"]
177
-
178
- # NodeJS
179
- #USER $USER
180
- ARG NODE_VERSION=''
181
- ENV NVM_DIR=/root/.nvm
182
-
183
- RUN if [ "$NODE_VERSION" != "" ] && [ "$NODE_VERSION" != "none" ]; then \
184
- mkdir -p $NVM_DIR; \
185
- curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash; \
186
- . "$NVM_DIR/nvm.sh" && \
187
- nvm install $NODE_VERSION && \
188
- nvm alias default $NODE_VERSION && \
189
- nvm use default; \
190
- echo "[ -n \"\$(command -v npm)\" ] && . <(npm completion)" >> /.bashrc; \
191
- fi
192
-
193
- #USER root
194
-
195
- RUN a2enmod rewrite
196
- RUN a2enmod headers
197
-
198
- ADD ./etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/000-default.conf
199
- ADD ./etc/apache2/apache2.conf /etc/apache2/apache2.conf
200
- COPY ./etc/apache2/mods-available/mpm_prefork.conf /etc/apache2/mods-available/
201
-
202
- #RUN touch /usr/local/etc/php/conf.d/mail.ini && \
203
- # echo "SMTP = maildev.workspace" >> /usr/local/etc/php/conf.d/mail.ini && \
204
- # echo "smtp_port = 25" >> /usr/local/etc/php/conf.d/mail.ini
205
-
206
- #RUN touch /usr/local/etc/php/conf.d/uploads.ini && \
207
- # echo "upload_max_filesize = 100M;" >> /usr/local/etc/php/conf.d/uploads.ini && \
208
- # echo "post_max_size = 100M;" >> /usr/local/etc/php/conf.d/uploads.ini
209
-
210
- #RUN touch /usr/local/etc/php/conf.d/memory.ini && \
211
- # echo "memory_limit = 256M;" >> /usr/local/etc/php/conf.d/memory.ini
212
-
213
- RUN touch /usr/local/bin/docker-entrypoint && \
214
- echo "#!/bin/bash" >> /usr/local/bin/docker-entrypoint && \
215
- echo "source /root/.bashrc" >> /usr/local/bin/docker-entrypoint && \
216
- echo "exec docker-php-entrypoint \"\$@\"" >> /usr/local/bin/docker-entrypoint && \
217
- chmod 775 /usr/local/bin/docker-entrypoint && \
218
- chmod +x /usr/local/bin/docker-entrypoint
219
-
220
- ENV APACHE_DOCUMENT_ROOT /var/www
221
- WORKDIR $APACHE_DOCUMENT_ROOT
222
-
223
- EXPOSE 80
224
- EXPOSE 443
225
-
226
- ENTRYPOINT ["docker-entrypoint"]
227
- CMD ["apache2-foreground"]
@@ -1,3 +0,0 @@
1
- #!/bin/bash
2
-
3
- printf '%s\n%s\n' "$2" "$1" | sort --check=quiet --version-sort
@@ -1,64 +0,0 @@
1
- {
2
- "dockerfile": "./Dockerfile",
3
- "buildArgsOptions": {
4
- "PHP_VERSION": {
5
- "message": "PHP version",
6
- "type": "select",
7
- "hash": false,
8
- "options": [
9
- "5.6",
10
- "7.3",
11
- "7.4",
12
- "8.0",
13
- "8.2"
14
- ]
15
- },
16
- "EXTENSIONS": {
17
- "type": "select",
18
- "multiple": true,
19
- "message": "Extensions",
20
- "options": {
21
- "MYSQLI_ENABLE": "Mysqli",
22
- "PDO_MYSQL_ENABLE": "PDO",
23
- "PGSQL_ENABLE": "Pgsql",
24
- "GD_ENABLE": "GD",
25
- "ZIP_ENABLE": "Zip",
26
- "MEMCACHE_ENABLE": "Memcache",
27
- "MEMCACHED_ENABLE": "Memcached",
28
- "HTTP_ENABLE": "Raphf+Http",
29
- "INTL_ENABLE": "Intl",
30
- "PCNTL_ENABLE": "Pcntl",
31
- "SOAP_ENABLE": "Soap",
32
- "XDEBUG_ENABLE": "XDebug",
33
- "GETTEXT_ENABLE": "GetText",
34
- "BCMATH_ENABLE": "Bcmath",
35
- "SOCKETS_ENABLE": "Sockets"
36
- }
37
- },
38
- "COMPOSER_ENABLE": {
39
- "message": "Install composer?",
40
- "type": "boolean",
41
- "default": false
42
- },
43
- "NODE_VERSION": {
44
- "type": "select",
45
- "message": "Node version",
46
- "options": [
47
- "none",
48
- "v17.9.1",
49
- "v18.16.0",
50
- "v20.11.0"
51
- ]
52
- }
53
- },
54
- "envOptions": {
55
- "APACHE_DOCUMENT_ROOT": {
56
- "type": "string",
57
- "message": "Apache document root",
58
- "default": "/var/www"
59
- }
60
- },
61
- "volumeOptions": [
62
- "./:/var/www"
63
- ]
64
- }