@scandipwa/magento-scripts 2.0.0-alpha.0 → 2.0.0-alpha.11
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/exec.js +71 -0
- package/index.js +1 -1
- package/lib/commands/cli.js +7 -2
- package/lib/commands/execute.js +3 -58
- package/lib/commands/import-db.js +1 -1
- package/lib/commands/logs.js +1 -1
- package/lib/commands/start.js +18 -8
- package/lib/commands/status.js +9 -1
- package/lib/config/config.js +20 -2
- package/lib/config/docker.js +79 -85
- package/lib/config/index.js +2 -2
- package/lib/config/php/versions/php-7.2.js +1 -0
- package/lib/config/php/versions/php-7.3.js +1 -0
- package/lib/config/php/versions/php-7.4.js +1 -0
- package/lib/config/php/versions/php-8.1.js +1 -0
- package/lib/config/php-config.js +4 -3
- package/lib/config/port-config.js +1 -1
- package/lib/config/services/composer/versions/composer-1.js +8 -0
- package/lib/config/services/composer/versions/composer-2.js +8 -0
- package/lib/config/services/composer/versions/index.js +4 -0
- package/lib/config/services/elasticsearch/base-repo.js +3 -0
- package/lib/config/services/elasticsearch/default-es-env.js +6 -0
- package/lib/config/services/elasticsearch/versions/elasticsearch-6.8.js +19 -0
- package/lib/config/services/elasticsearch/versions/index.js +5 -0
- package/lib/config/services/nginx/versions/index.js +3 -0
- package/lib/config/services/nginx/versions/nginx-1.18.js +11 -0
- package/lib/config/{ssl-terminator → services/ssl-terminator}/index.js +3 -0
- package/lib/config/templates/magentorc.template +6 -5
- package/lib/config/templates/mariadb.template.cnf +191 -0
- package/lib/config/templates/php-debug.template.ini +31 -0
- package/lib/config/templates/php-fpm.template.conf +1 -2
- package/lib/config/templates/php.template.ini +6 -202
- package/lib/config/templates/ssl-terminator.template.conf +10 -3
- package/lib/config/templates/varnish.template.vcl +20 -13
- package/lib/config/varnish/varnish-6-0.js +4 -0
- package/lib/config/varnish/varnish-6-6.js +4 -0
- package/lib/config/varnish/varnish-7-0.js +4 -0
- package/lib/config/versions/magento-2.3.0.js +7 -12
- package/lib/config/versions/magento-2.3.1.js +7 -12
- package/lib/config/versions/magento-2.3.2-p1.js +7 -12
- package/lib/config/versions/magento-2.3.2-p2.js +7 -12
- package/lib/config/versions/magento-2.3.2.js +7 -12
- package/lib/config/versions/magento-2.3.3-p1.js +7 -12
- package/lib/config/versions/magento-2.3.3.js +7 -12
- package/lib/config/versions/magento-2.3.4-p1.js +7 -12
- package/lib/config/versions/magento-2.3.4-p2.js +7 -12
- package/lib/config/versions/magento-2.3.4.js +7 -12
- package/lib/config/versions/magento-2.3.5-p1.js +5 -9
- package/lib/config/versions/magento-2.3.5-p2.js +5 -9
- package/lib/config/versions/magento-2.3.5.js +5 -9
- package/lib/config/versions/magento-2.3.6-p1.js +5 -9
- package/lib/config/versions/magento-2.3.6.js +5 -9
- package/lib/config/versions/magento-2.3.7-p1.js +5 -9
- package/lib/config/versions/magento-2.3.7-p2.js +5 -9
- package/lib/config/versions/magento-2.3.7-p3.js +5 -9
- package/lib/config/versions/magento-2.3.7-p4.js +40 -0
- package/lib/config/versions/magento-2.3.7.js +5 -9
- package/lib/config/versions/magento-2.4.0-p1.js +5 -9
- package/lib/config/versions/magento-2.4.0.js +5 -9
- package/lib/config/versions/magento-2.4.1-p1.js +5 -9
- package/lib/config/versions/magento-2.4.1.js +5 -9
- package/lib/config/versions/magento-2.4.2-p1.js +5 -9
- package/lib/config/versions/magento-2.4.2-p2.js +5 -9
- package/lib/config/versions/magento-2.4.2.js +5 -9
- package/lib/config/versions/magento-2.4.3-p1.js +5 -9
- package/lib/config/versions/magento-2.4.3-p2.js +5 -9
- package/lib/config/versions/magento-2.4.3-p3.js +42 -0
- package/lib/config/versions/magento-2.4.3.js +5 -9
- package/lib/config/versions/magento-2.4.4-p1.js +42 -0
- package/lib/config/versions/magento-2.4.4.js +5 -9
- package/lib/config/versions/magento-2.4.5.js +42 -0
- package/lib/tasks/cleanup.js +1 -1
- package/lib/tasks/composer/local-auth-json.js +1 -1
- package/lib/tasks/database/connect-to-database.js +120 -0
- package/lib/tasks/database/create-magento-database.js +21 -0
- package/lib/tasks/database/create-magento-user.js +50 -0
- package/lib/tasks/database/default-magento-database.js +3 -0
- package/lib/tasks/database/default-magento-user.js +7 -0
- package/lib/tasks/{mysql → database}/dump-theme-config.js +3 -3
- package/lib/tasks/{mysql → database}/fix-db.js +2 -2
- package/lib/tasks/{mysql/import-dump-to-mysql.js → database/import-dump-to-database.js} +21 -20
- package/lib/tasks/{mysql → database}/import-remote-db/index.js +0 -0
- package/lib/tasks/{mysql/import-remote-db/ssh/mysqldump-command.js → database/import-remote-db/ssh/database-dump-command.js} +2 -2
- package/lib/tasks/{mysql → database}/import-remote-db/ssh/index.js +0 -0
- package/lib/tasks/{mysql → database}/import-remote-db/ssh/readymage.js +4 -4
- package/lib/tasks/{mysql → database}/import-remote-db/ssh/regular-server.js +2 -2
- package/lib/tasks/{mysql → database}/index.js +2 -2
- package/lib/tasks/{mysql → database}/magento-tables.js +0 -0
- package/lib/tasks/{mysql → database}/restore-theme-config.js +4 -4
- package/lib/tasks/docker/api.d.ts +25 -1
- package/lib/tasks/docker/api.js +31 -1
- package/lib/tasks/docker/containers/container-api.d.ts +18 -0
- package/lib/tasks/docker/containers/container-api.js +76 -17
- package/lib/tasks/docker/containers/tasks.js +32 -1
- package/lib/tasks/docker/convert-legacy-volumes.js +8 -7
- package/lib/tasks/docker/convert-mysql-to-mariadb.js +284 -0
- package/lib/tasks/docker/index.js +6 -1
- package/lib/tasks/docker/network/network-api.d.ts +1 -1
- package/lib/tasks/docker/project-image-builder.js +7 -9
- package/lib/tasks/docker/volume/index.js +9 -0
- package/lib/tasks/docker/volume/tasks.js +94 -0
- package/lib/tasks/docker/volume/volume-api.d.ts +49 -0
- package/lib/tasks/docker/volume/volume-api.js +90 -0
- package/lib/tasks/execute.js +100 -0
- package/lib/tasks/file-system/create-mariadb-config.js +23 -0
- package/lib/tasks/file-system/create-nginx-config.js +3 -5
- package/lib/tasks/file-system/create-php-config.js +2 -23
- package/lib/tasks/file-system/create-php-debug-config.js +45 -0
- package/lib/tasks/file-system/create-php-fpm-config.js +2 -4
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/php-workspace-project-configuration-config.js +1 -1
- package/lib/tasks/file-system/create-ssl-terminator-config.js +4 -7
- package/lib/tasks/file-system/create-varnish-config.js +4 -7
- package/lib/tasks/file-system/index.js +5 -1
- package/lib/tasks/import-dump.js +6 -6
- package/lib/tasks/link.js +4 -2
- package/lib/tasks/magento/enable-magento-composer-plugins.js +85 -30
- package/lib/tasks/magento/install-magento-project.js +3 -2
- package/lib/tasks/magento/setup-magento/configure-elasticsearch.js +3 -5
- package/lib/tasks/magento/setup-magento/create-admin.js +1 -1
- package/lib/tasks/magento/setup-magento/delete-admin-users.js +2 -2
- package/lib/tasks/magento/setup-magento/delete-customers.js +4 -4
- package/lib/tasks/magento/setup-magento/delete-orders.js +4 -4
- package/lib/tasks/magento/setup-magento/flush-redis-config.js +3 -6
- package/lib/tasks/magento/setup-magento/increase-admin-session-lifetime.js +2 -2
- package/lib/tasks/magento/setup-magento/index.js +2 -0
- package/lib/tasks/magento/setup-magento/install-magento.js +15 -17
- package/lib/tasks/magento/setup-magento/migrate-database.js +5 -11
- package/lib/tasks/magento/setup-magento/set-base-url.js +3 -3
- package/lib/tasks/magento/setup-magento/set-url-rewrite.js +2 -2
- package/lib/tasks/magento/setup-magento/varnish-config.js +8 -13
- package/lib/tasks/magento/setup-magento/waiting-for-varnish.js +17 -16
- package/lib/tasks/php/php-container.js +7 -3
- package/lib/tasks/php/update-env-php.js +7 -6
- package/lib/tasks/php/update-env.php +12 -12
- package/lib/tasks/requirements/composer-credentials.js +7 -3
- package/lib/tasks/requirements/docker/context.js +88 -0
- package/lib/tasks/requirements/docker/index.js +110 -19
- package/lib/tasks/requirements/docker/install.js +21 -7
- package/lib/tasks/requirements/docker/permissions.js +2 -11
- package/lib/tasks/requirements/docker/running-status.js +94 -24
- package/lib/tasks/requirements/docker/version.js +1 -0
- package/lib/tasks/requirements/index.js +0 -2
- package/lib/tasks/requirements/php-version.js +4 -2
- package/lib/tasks/start.js +32 -31
- package/lib/tasks/status/index.js +17 -13
- package/lib/tasks/stop.js +2 -0
- package/lib/tasks/theme/link-theme.js +2 -2
- package/lib/util/config-file-validator.js +29 -13
- package/lib/util/database.js +7 -7
- package/lib/util/execute-in-container.js +63 -0
- package/lib/util/prefix.js +1 -1
- package/lib/util/systemctl.js +62 -13
- package/package.json +4 -3
- package/typings/context.d.ts +12 -5
- package/typings/index.d.ts +69 -31
- package/lib/tasks/docker/volumes.js +0 -63
- package/lib/tasks/execute/index.js +0 -23
- package/lib/tasks/mysql/connect-to-mysql.js +0 -127
- package/lib/tasks/mysql/create-magento-database.js +0 -18
- package/lib/tasks/requirements/dependency/arch.js +0 -50
- package/lib/tasks/requirements/dependency/centos.js +0 -36
- package/lib/tasks/requirements/dependency/fedora.js +0 -36
- package/lib/tasks/requirements/dependency/index.js +0 -33
- package/lib/tasks/requirements/dependency/mac.js +0 -124
- package/lib/tasks/requirements/dependency/ubuntu.js +0 -83
package/typings/index.d.ts
CHANGED
|
@@ -1,14 +1,21 @@
|
|
|
1
1
|
import { ListrContext } from './context';
|
|
2
2
|
|
|
3
3
|
/* eslint-disable no-use-before-define */
|
|
4
|
-
export interface
|
|
4
|
+
export interface ServiceWithImage {
|
|
5
5
|
/**
|
|
6
6
|
* Service version
|
|
7
|
+
*
|
|
8
|
+
* @deprecated
|
|
7
9
|
*/
|
|
8
10
|
version: string
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Service Docker image
|
|
14
|
+
*/
|
|
15
|
+
image: string
|
|
9
16
|
}
|
|
10
17
|
|
|
11
|
-
export interface SSLTerminatorConfiguration extends
|
|
18
|
+
export interface SSLTerminatorConfiguration extends ServiceWithImage {
|
|
12
19
|
/**
|
|
13
20
|
* Configuration file location
|
|
14
21
|
*
|
|
@@ -17,7 +24,7 @@ export interface SSLTerminatorConfiguration extends ServiceWithVersion {
|
|
|
17
24
|
configTemplate: string
|
|
18
25
|
}
|
|
19
26
|
|
|
20
|
-
export interface NginxConfiguration extends
|
|
27
|
+
export interface NginxConfiguration extends ServiceWithImage {
|
|
21
28
|
/**
|
|
22
29
|
* Configuration file location
|
|
23
30
|
*
|
|
@@ -26,7 +33,14 @@ export interface NginxConfiguration extends ServiceWithVersion {
|
|
|
26
33
|
configTemplate: string
|
|
27
34
|
}
|
|
28
35
|
|
|
29
|
-
export interface
|
|
36
|
+
export interface ElasticSearchConfiguration extends ServiceWithImage {
|
|
37
|
+
/**
|
|
38
|
+
* Environmental variables used for Elasticsearch container
|
|
39
|
+
*/
|
|
40
|
+
env: Record<string, unknown>
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export interface VarnishConfiguration extends ServiceWithImage {
|
|
30
44
|
/**
|
|
31
45
|
* Enable or disable Varnish in the project
|
|
32
46
|
*/
|
|
@@ -38,6 +52,42 @@ export interface VarnishConfiguration extends ServiceWithVersion {
|
|
|
38
52
|
* @example ./my-varnish-config.vcl
|
|
39
53
|
*/
|
|
40
54
|
configTemplate: string
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Enable or disable healthcheck in the project
|
|
58
|
+
*/
|
|
59
|
+
healthCheck: boolean
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export interface ComposerConfiguration {
|
|
63
|
+
/**
|
|
64
|
+
* Composer version
|
|
65
|
+
*
|
|
66
|
+
* This will become part of the url (`https://getcomposer.org/download/<version>/composer.phar`) so you can use the following variants as well:
|
|
67
|
+
* ```
|
|
68
|
+
* 'latest-stable'
|
|
69
|
+
* 'latest-preview'
|
|
70
|
+
* 'latest-1.x'
|
|
71
|
+
* 'latest-2.x'
|
|
72
|
+
* 'latest-2.2.x'
|
|
73
|
+
*
|
|
74
|
+
* '2.4.1'
|
|
75
|
+
* '2.3.10'
|
|
76
|
+
* '2.2.18'
|
|
77
|
+
* '2.1.14'
|
|
78
|
+
* ```
|
|
79
|
+
*
|
|
80
|
+
* @url https://getcomposer.org/download/
|
|
81
|
+
*/
|
|
82
|
+
version: string
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Composer global plugins that will be added to Docker image
|
|
86
|
+
*/
|
|
87
|
+
plugins: Record<string, {
|
|
88
|
+
version?: string
|
|
89
|
+
options?: string
|
|
90
|
+
}>
|
|
41
91
|
}
|
|
42
92
|
|
|
43
93
|
export interface PHPExtensionInstallationInstruction {
|
|
@@ -59,7 +109,9 @@ export interface PHPExtensionInstallationInstruction {
|
|
|
59
109
|
* pecl install xdebug && docker-php-ext-enable xdebug
|
|
60
110
|
* ```
|
|
61
111
|
*/
|
|
62
|
-
command:
|
|
112
|
+
command: string |
|
|
113
|
+
((arg0: (Omit<PHPExtensionInstallationInstruction, 'command'> & { ctx: ListrContext})) => string) |
|
|
114
|
+
((arg0: (Omit<PHPExtensionInstallationInstruction, 'command'> & { ctx: ListrContext})) => Promise<string>)
|
|
63
115
|
|
|
64
116
|
/**
|
|
65
117
|
* System dependencies required by the extension
|
|
@@ -97,6 +149,12 @@ export interface PHPConfiguration {
|
|
|
97
149
|
* @example ./my-php-template.ini
|
|
98
150
|
*/
|
|
99
151
|
configTemplate: string
|
|
152
|
+
/**
|
|
153
|
+
* PHP XDebug file template location
|
|
154
|
+
*
|
|
155
|
+
* @example ./my-php-debug-template.ini
|
|
156
|
+
*/
|
|
157
|
+
debugTemplate: string
|
|
100
158
|
|
|
101
159
|
/**
|
|
102
160
|
* PHP-FPM configuration file template location
|
|
@@ -109,11 +167,6 @@ export interface PHPConfiguration {
|
|
|
109
167
|
* Extensions for PHP
|
|
110
168
|
*/
|
|
111
169
|
extensions: PHPExtensions
|
|
112
|
-
|
|
113
|
-
/**
|
|
114
|
-
* Disabled extension list
|
|
115
|
-
*/
|
|
116
|
-
disabledExtensions?: string[]
|
|
117
170
|
}
|
|
118
171
|
export interface SSLConfiguration {
|
|
119
172
|
/**
|
|
@@ -153,30 +206,25 @@ export interface CMAConfiguration {
|
|
|
153
206
|
*/
|
|
154
207
|
nginx: NginxConfiguration
|
|
155
208
|
|
|
156
|
-
/**
|
|
157
|
-
* MySQL configuration
|
|
158
|
-
*/
|
|
159
|
-
mysql: ServiceWithVersion
|
|
160
|
-
|
|
161
209
|
/**
|
|
162
210
|
* MariaDB configuration
|
|
163
211
|
*/
|
|
164
|
-
mariadb:
|
|
212
|
+
mariadb: ServiceWithImage
|
|
165
213
|
|
|
166
214
|
/**
|
|
167
215
|
* ElasticSearch configuration
|
|
168
216
|
*/
|
|
169
|
-
elasticsearch:
|
|
217
|
+
elasticsearch: ElasticSearchConfiguration
|
|
170
218
|
|
|
171
219
|
/**
|
|
172
220
|
* Redis configuration
|
|
173
221
|
*/
|
|
174
|
-
redis:
|
|
222
|
+
redis: ServiceWithImage
|
|
175
223
|
|
|
176
224
|
/**
|
|
177
225
|
* Composer configuration
|
|
178
226
|
*/
|
|
179
|
-
composer:
|
|
227
|
+
composer: ComposerConfiguration
|
|
180
228
|
|
|
181
229
|
/**
|
|
182
230
|
* Varnish configuration
|
|
@@ -222,8 +270,8 @@ export interface CMAConfiguration {
|
|
|
222
270
|
}
|
|
223
271
|
/**
|
|
224
272
|
* Custom host for website base url
|
|
225
|
-
*
|
|
226
|
-
|
|
273
|
+
* @default 'localhost'
|
|
274
|
+
*/
|
|
227
275
|
host: string
|
|
228
276
|
|
|
229
277
|
/**
|
|
@@ -242,14 +290,4 @@ export interface CMAConfiguration {
|
|
|
242
290
|
* If prefix is set to `false` docker container and volume names will only include folder name **which is not safe and not recommended**.
|
|
243
291
|
*/
|
|
244
292
|
prefix: boolean
|
|
245
|
-
|
|
246
|
-
/**
|
|
247
|
-
* Non-overlapping ports config
|
|
248
|
-
* @default false
|
|
249
|
-
*
|
|
250
|
-
* @deprecated Use global configuration file.
|
|
251
|
-
* @description If set to `true` CMA will try retrieving others CMA projects port configuration
|
|
252
|
-
* and will not use their ports for itself.
|
|
253
|
-
*/
|
|
254
|
-
useNonOverlappingPorts: boolean
|
|
255
293
|
}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
const { execAsyncSpawn } = require('../../util/exec-async-command');
|
|
2
|
-
|
|
3
|
-
const create = ({
|
|
4
|
-
driver,
|
|
5
|
-
opts = {},
|
|
6
|
-
name
|
|
7
|
-
}) => {
|
|
8
|
-
let command = `docker volume create ${ Object.entries(opts).map(([name, value]) => `--opt ${name}='${value}'`).join(' ') } `;
|
|
9
|
-
|
|
10
|
-
if (driver) {
|
|
11
|
-
command += `--driver ${ driver }`;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
return execAsyncSpawn(`${ command } ${ name }`);
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* @type {() => import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
|
|
19
|
-
*/
|
|
20
|
-
const createVolumes = () => ({
|
|
21
|
-
title: 'Creating volumes',
|
|
22
|
-
task: async ({ config: { docker } }, task) => {
|
|
23
|
-
const volumeList = (await execAsyncSpawn('docker volume ls --format "{{.Name}}"')).split('\n');
|
|
24
|
-
|
|
25
|
-
const missingVolumes = Object.values(docker.volumes).filter(
|
|
26
|
-
({ name }) => !volumeList.includes(name)
|
|
27
|
-
);
|
|
28
|
-
|
|
29
|
-
if (missingVolumes.length === 0) {
|
|
30
|
-
task.skip();
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
await Promise.all(missingVolumes.map((volume) => create(volume)));
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* @type {() => import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
|
|
40
|
-
*/
|
|
41
|
-
const removeVolumes = () => ({
|
|
42
|
-
title: 'Removing volumes',
|
|
43
|
-
task: async ({ config: { docker } }, task) => {
|
|
44
|
-
const volumeList = (await execAsyncSpawn('docker volume ls --format "{{.Name}}"')).split('\n');
|
|
45
|
-
|
|
46
|
-
const deployedVolumes = Object.values(docker.volumes).filter(
|
|
47
|
-
({ name }) => volumeList.includes(name)
|
|
48
|
-
);
|
|
49
|
-
|
|
50
|
-
if (deployedVolumes.length === 0) {
|
|
51
|
-
task.skip();
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
await execAsyncSpawn(`docker volume rm ${deployedVolumes.map(({ name }) => name).join(' ')}`);
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
module.exports = {
|
|
60
|
-
createVolumes,
|
|
61
|
-
removeVolumes,
|
|
62
|
-
createVolume: create
|
|
63
|
-
};
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
// const path = require('path');
|
|
2
|
-
const { spawn } = require('child_process');
|
|
3
|
-
|
|
4
|
-
const executeInContainer = ({ containerName, commands }) => {
|
|
5
|
-
if (!process.stdin.isTTY) {
|
|
6
|
-
process.stderr.write('This app works only in TTY mode');
|
|
7
|
-
process.exit(1);
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
spawn('docker', [
|
|
11
|
-
'exec',
|
|
12
|
-
'-it',
|
|
13
|
-
containerName
|
|
14
|
-
].concat(...commands.map((command) => command.split(' '))), {
|
|
15
|
-
stdio: [0, 1, 2]
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
return new Promise((_resolve) => {
|
|
19
|
-
// never resolve
|
|
20
|
-
});
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
module.exports = executeInContainer;
|
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
const mysql2 = require('mysql2/promise');
|
|
2
|
-
const UnknownError = require('../../errors/unknown-error');
|
|
3
|
-
const { execAsyncSpawn } = require('../../util/exec-async-command');
|
|
4
|
-
const sleep = require('../../util/sleep');
|
|
5
|
-
const { createMagentoDatabase } = require('./create-magento-database');
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* @returns {import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
|
|
9
|
-
*/
|
|
10
|
-
const waitForMySQLInitialization = () => ({
|
|
11
|
-
title: 'Waiting for MySQL to initialize',
|
|
12
|
-
task: async (ctx, task) => {
|
|
13
|
-
const { mysql } = ctx.config.docker.getContainers();
|
|
14
|
-
|
|
15
|
-
task.title = `Waiting for ${mysql._} to initialize`;
|
|
16
|
-
|
|
17
|
-
let mysqlReadyForConnections = false;
|
|
18
|
-
|
|
19
|
-
while (!mysqlReadyForConnections) {
|
|
20
|
-
const mysqlOutput = await execAsyncSpawn(`docker logs ${mysql.name}`);
|
|
21
|
-
if (mysqlOutput.includes('ready for connections')) {
|
|
22
|
-
mysqlReadyForConnections = true;
|
|
23
|
-
break;
|
|
24
|
-
} else if (mysqlOutput.includes('Initializing database files')) {
|
|
25
|
-
task.output = `MySQL is initializing database files!
|
|
26
|
-
Please wait, this will take some time and do not restart the MySQL container until initialization is finished!`;
|
|
27
|
-
|
|
28
|
-
let mysqlFinishedInitialization = false;
|
|
29
|
-
while (!mysqlFinishedInitialization) {
|
|
30
|
-
const mysqlOutput = await execAsyncSpawn(`docker logs ${mysql.name}`);
|
|
31
|
-
if (mysqlOutput.includes('init process done.') && !mysqlFinishedInitialization) {
|
|
32
|
-
mysqlFinishedInitialization = true;
|
|
33
|
-
break;
|
|
34
|
-
}
|
|
35
|
-
await sleep(2000);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
await sleep(2000);
|
|
40
|
-
}
|
|
41
|
-
},
|
|
42
|
-
options: {
|
|
43
|
-
bottomBar: 10
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* @returns {import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
|
|
49
|
-
*/
|
|
50
|
-
const gettingMySQLConnection = () => ({
|
|
51
|
-
title: 'Getting MySQL connection',
|
|
52
|
-
task: async (ctx, task) => {
|
|
53
|
-
const { config: { docker }, ports } = ctx;
|
|
54
|
-
const { mysql } = docker.getContainers(ctx.ports);
|
|
55
|
-
let tries = 0;
|
|
56
|
-
const maxTries = 20;
|
|
57
|
-
const errors = [];
|
|
58
|
-
|
|
59
|
-
task.title = `Getting ${mysql._} connection`;
|
|
60
|
-
|
|
61
|
-
while (tries < maxTries) {
|
|
62
|
-
tries++;
|
|
63
|
-
try {
|
|
64
|
-
const connection = await mysql2.createConnection({
|
|
65
|
-
host: '127.0.0.1',
|
|
66
|
-
port: ports.mysql,
|
|
67
|
-
user: mysql.env.MYSQL_USER,
|
|
68
|
-
password: mysql.env.MYSQL_PASSWORD,
|
|
69
|
-
database: mysql.env.MYSQL_DATABASE
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
ctx.mysqlConnection = connection;
|
|
73
|
-
break;
|
|
74
|
-
} catch (e) {
|
|
75
|
-
errors.push(e);
|
|
76
|
-
}
|
|
77
|
-
await sleep(1000);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
if (tries === maxTries) {
|
|
81
|
-
throw new UnknownError(`Unable to connect to MySQL server. Check your server configuration!\n\n${ errors.join(' ') }`);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
task.title = 'MySQL server connected!';
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* @returns {import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
|
|
90
|
-
*/
|
|
91
|
-
const terminatingExistingConnection = () => ({
|
|
92
|
-
title: 'Terminating existing Database connection',
|
|
93
|
-
skip: (ctx) => !ctx.mysqlConnection,
|
|
94
|
-
task: (ctx) => {
|
|
95
|
-
ctx.mysqlConnection.destroy();
|
|
96
|
-
}
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* @returns {import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
|
|
101
|
-
*/
|
|
102
|
-
const connectToMySQL = () => ({
|
|
103
|
-
title: 'Connecting to MySQL server',
|
|
104
|
-
skip: (ctx) => ctx.skipSetup,
|
|
105
|
-
task: (ctx, task) => {
|
|
106
|
-
const { mysql } = ctx.config.docker.getContainers();
|
|
107
|
-
|
|
108
|
-
task.title = `Connecting to ${mysql._} server`;
|
|
109
|
-
|
|
110
|
-
return task.newListr([
|
|
111
|
-
waitForMySQLInitialization(),
|
|
112
|
-
createMagentoDatabase(),
|
|
113
|
-
terminatingExistingConnection(),
|
|
114
|
-
gettingMySQLConnection()
|
|
115
|
-
], {
|
|
116
|
-
concurrent: false,
|
|
117
|
-
rendererOptions: {
|
|
118
|
-
collapse: true
|
|
119
|
-
}
|
|
120
|
-
});
|
|
121
|
-
},
|
|
122
|
-
options: {
|
|
123
|
-
bottomBar: 10
|
|
124
|
-
}
|
|
125
|
-
});
|
|
126
|
-
|
|
127
|
-
module.exports = connectToMySQL;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
const { execAsyncSpawn } = require('../../util/exec-async-command');
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Will create database 'magento' in MySQL if it does not exist for some reason
|
|
5
|
-
* @returns {import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
|
|
6
|
-
*/
|
|
7
|
-
const createMagentoDatabase = () => ({
|
|
8
|
-
title: 'Creating Magento database in MySQL',
|
|
9
|
-
task: async (ctx) => {
|
|
10
|
-
const { mysql } = ctx.config.docker.getContainers();
|
|
11
|
-
|
|
12
|
-
await execAsyncSpawn(`docker exec ${mysql.name} mysql -umagento -pmagento -h 127.0.0.1 -e "CREATE DATABASE IF NOT EXISTS magento;"`);
|
|
13
|
-
}
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
module.exports = {
|
|
17
|
-
createMagentoDatabase
|
|
18
|
-
};
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
const dependenciesForPlatforms = require('../../../config/dependencies-for-platforms');
|
|
2
|
-
const UnknownError = require('../../../errors/unknown-error');
|
|
3
|
-
const { execAsyncSpawn } = require('../../../util/exec-async-command');
|
|
4
|
-
const installDependenciesTask = require('../../../util/install-dependencies-task');
|
|
5
|
-
|
|
6
|
-
const pkgRegex = /(\S+)\s(\S+)/i;
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* @type {() => import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
|
|
10
|
-
*/
|
|
11
|
-
const archDependenciesCheck = () => ({
|
|
12
|
-
title: 'Checking Arch Linux dependencies',
|
|
13
|
-
task: async (ctx, task) => {
|
|
14
|
-
const installedDependencies = (await execAsyncSpawn('pacman -Q')).split('\n')
|
|
15
|
-
.map((pkg) => {
|
|
16
|
-
const result = pkg.match(pkgRegex);
|
|
17
|
-
|
|
18
|
-
if (!result) {
|
|
19
|
-
throw new UnknownError(`Package without a version!\n\n${pkg}\n\nHOW?`);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
return result[1];
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
const dependenciesToInstall = dependenciesForPlatforms['Arch Linux']
|
|
26
|
-
.dependencies
|
|
27
|
-
.filter((dep) => {
|
|
28
|
-
if (Array.isArray(dep)) {
|
|
29
|
-
return !dep.some((dp) => installedDependencies.includes(dp));
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
return !installedDependencies.includes(dep);
|
|
33
|
-
})
|
|
34
|
-
.map((dep) => (Array.isArray(dep) ? dep[0] : dep));
|
|
35
|
-
|
|
36
|
-
if (dependenciesToInstall.length > 0) {
|
|
37
|
-
return task.newListr(
|
|
38
|
-
installDependenciesTask({
|
|
39
|
-
platform: 'Arch Linux',
|
|
40
|
-
dependenciesToInstall
|
|
41
|
-
})
|
|
42
|
-
);
|
|
43
|
-
}
|
|
44
|
-
},
|
|
45
|
-
options: {
|
|
46
|
-
bottomBar: 10
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
module.exports = archDependenciesCheck;
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
const dependenciesForPlatforms = require('../../../config/dependencies-for-platforms');
|
|
2
|
-
const { execAsyncSpawn } = require('../../../util/exec-async-command');
|
|
3
|
-
const installDependenciesTask = require('../../../util/install-dependencies-task');
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* @type {() => import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
|
|
7
|
-
*/
|
|
8
|
-
const centosDependenciesCheck = () => ({
|
|
9
|
-
title: 'Checking CentOS dependencies',
|
|
10
|
-
task: async (ctx, task) => {
|
|
11
|
-
const installedDependencies = (await execAsyncSpawn('yum list installed')).split('\n')
|
|
12
|
-
.filter((pkg) => !pkg.toLowerCase().includes('installed packages'))
|
|
13
|
-
.map((pkg) => pkg.match(/^(\S+)/i))
|
|
14
|
-
.filter(Boolean)
|
|
15
|
-
.map((pkg) => pkg[1])
|
|
16
|
-
.map((pkg) => pkg.match(/^(\S+)\.\S+/i))
|
|
17
|
-
.filter(Boolean)
|
|
18
|
-
.map((pkg) => pkg[1]);
|
|
19
|
-
|
|
20
|
-
const dependenciesToInstall = dependenciesForPlatforms
|
|
21
|
-
.CentOS
|
|
22
|
-
.dependencies
|
|
23
|
-
.filter((dep) => !installedDependencies.includes(dep));
|
|
24
|
-
|
|
25
|
-
if (dependenciesToInstall.length > 0) {
|
|
26
|
-
return task.newListr(
|
|
27
|
-
installDependenciesTask({
|
|
28
|
-
platform: 'CentOS',
|
|
29
|
-
dependenciesToInstall
|
|
30
|
-
})
|
|
31
|
-
);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
module.exports = centosDependenciesCheck;
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
const dependenciesForPlatforms = require('../../../config/dependencies-for-platforms');
|
|
2
|
-
const { execAsyncSpawn } = require('../../../util/exec-async-command');
|
|
3
|
-
const installDependenciesTask = require('../../../util/install-dependencies-task');
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* @type {() => import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
|
|
7
|
-
*/
|
|
8
|
-
const fedoraDependenciesCheck = () => ({
|
|
9
|
-
title: 'Checking Fedora Linux dependencies',
|
|
10
|
-
task: async (ctx, task) => {
|
|
11
|
-
const installedDependencies = (await execAsyncSpawn('yum list installed')).split('\n')
|
|
12
|
-
.filter((pkg) => !pkg.toLowerCase().includes('installed packages'))
|
|
13
|
-
.map((pkg) => pkg.match(/^(\S+)/i))
|
|
14
|
-
.filter(Boolean)
|
|
15
|
-
.map((pkg) => pkg[1])
|
|
16
|
-
.map((pkg) => pkg.match(/^(\S+)\.\S+/i))
|
|
17
|
-
.filter(Boolean)
|
|
18
|
-
.map((pkg) => pkg[1]);
|
|
19
|
-
|
|
20
|
-
const dependenciesToInstall = dependenciesForPlatforms
|
|
21
|
-
.Fedora
|
|
22
|
-
.dependencies
|
|
23
|
-
.filter((dep) => !installedDependencies.includes(dep));
|
|
24
|
-
|
|
25
|
-
if (dependenciesToInstall.length > 0) {
|
|
26
|
-
return task.newListr(
|
|
27
|
-
installDependenciesTask({
|
|
28
|
-
platform: 'Fedora',
|
|
29
|
-
dependenciesToInstall
|
|
30
|
-
})
|
|
31
|
-
);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
module.exports = fedoraDependenciesCheck;
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
const archDependenciesCheck = require('./arch');
|
|
2
|
-
const fedoraDependenciesCheck = require('./fedora');
|
|
3
|
-
const centosDependenciesCheck = require('./centos');
|
|
4
|
-
const ubuntuDependenciesCheck = require('./ubuntu');
|
|
5
|
-
const macDependenciesCheck = require('./mac');
|
|
6
|
-
const osPlatform = require('../../../util/os-platform');
|
|
7
|
-
|
|
8
|
-
const dependencyCheck = async () => {
|
|
9
|
-
if (process.platform === 'darwin') {
|
|
10
|
-
return macDependenciesCheck();
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
const distro = await osPlatform();
|
|
14
|
-
switch (distro) {
|
|
15
|
-
case 'Arch Linux': {
|
|
16
|
-
return archDependenciesCheck();
|
|
17
|
-
}
|
|
18
|
-
case 'Fedora': {
|
|
19
|
-
return fedoraDependenciesCheck();
|
|
20
|
-
}
|
|
21
|
-
case 'CentOS': {
|
|
22
|
-
return centosDependenciesCheck();
|
|
23
|
-
}
|
|
24
|
-
case 'Ubuntu': {
|
|
25
|
-
return ubuntuDependenciesCheck();
|
|
26
|
-
}
|
|
27
|
-
default: {
|
|
28
|
-
// skip check
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
module.exports = dependencyCheck;
|