@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.
Files changed (165) hide show
  1. package/exec.js +71 -0
  2. package/index.js +1 -1
  3. package/lib/commands/cli.js +7 -2
  4. package/lib/commands/execute.js +3 -58
  5. package/lib/commands/import-db.js +1 -1
  6. package/lib/commands/logs.js +1 -1
  7. package/lib/commands/start.js +18 -8
  8. package/lib/commands/status.js +9 -1
  9. package/lib/config/config.js +20 -2
  10. package/lib/config/docker.js +79 -85
  11. package/lib/config/index.js +2 -2
  12. package/lib/config/php/versions/php-7.2.js +1 -0
  13. package/lib/config/php/versions/php-7.3.js +1 -0
  14. package/lib/config/php/versions/php-7.4.js +1 -0
  15. package/lib/config/php/versions/php-8.1.js +1 -0
  16. package/lib/config/php-config.js +4 -3
  17. package/lib/config/port-config.js +1 -1
  18. package/lib/config/services/composer/versions/composer-1.js +8 -0
  19. package/lib/config/services/composer/versions/composer-2.js +8 -0
  20. package/lib/config/services/composer/versions/index.js +4 -0
  21. package/lib/config/services/elasticsearch/base-repo.js +3 -0
  22. package/lib/config/services/elasticsearch/default-es-env.js +6 -0
  23. package/lib/config/services/elasticsearch/versions/elasticsearch-6.8.js +19 -0
  24. package/lib/config/services/elasticsearch/versions/index.js +5 -0
  25. package/lib/config/services/nginx/versions/index.js +3 -0
  26. package/lib/config/services/nginx/versions/nginx-1.18.js +11 -0
  27. package/lib/config/{ssl-terminator → services/ssl-terminator}/index.js +3 -0
  28. package/lib/config/templates/magentorc.template +6 -5
  29. package/lib/config/templates/mariadb.template.cnf +191 -0
  30. package/lib/config/templates/php-debug.template.ini +31 -0
  31. package/lib/config/templates/php-fpm.template.conf +1 -2
  32. package/lib/config/templates/php.template.ini +6 -202
  33. package/lib/config/templates/ssl-terminator.template.conf +10 -3
  34. package/lib/config/templates/varnish.template.vcl +20 -13
  35. package/lib/config/varnish/varnish-6-0.js +4 -0
  36. package/lib/config/varnish/varnish-6-6.js +4 -0
  37. package/lib/config/varnish/varnish-7-0.js +4 -0
  38. package/lib/config/versions/magento-2.3.0.js +7 -12
  39. package/lib/config/versions/magento-2.3.1.js +7 -12
  40. package/lib/config/versions/magento-2.3.2-p1.js +7 -12
  41. package/lib/config/versions/magento-2.3.2-p2.js +7 -12
  42. package/lib/config/versions/magento-2.3.2.js +7 -12
  43. package/lib/config/versions/magento-2.3.3-p1.js +7 -12
  44. package/lib/config/versions/magento-2.3.3.js +7 -12
  45. package/lib/config/versions/magento-2.3.4-p1.js +7 -12
  46. package/lib/config/versions/magento-2.3.4-p2.js +7 -12
  47. package/lib/config/versions/magento-2.3.4.js +7 -12
  48. package/lib/config/versions/magento-2.3.5-p1.js +5 -9
  49. package/lib/config/versions/magento-2.3.5-p2.js +5 -9
  50. package/lib/config/versions/magento-2.3.5.js +5 -9
  51. package/lib/config/versions/magento-2.3.6-p1.js +5 -9
  52. package/lib/config/versions/magento-2.3.6.js +5 -9
  53. package/lib/config/versions/magento-2.3.7-p1.js +5 -9
  54. package/lib/config/versions/magento-2.3.7-p2.js +5 -9
  55. package/lib/config/versions/magento-2.3.7-p3.js +5 -9
  56. package/lib/config/versions/magento-2.3.7-p4.js +40 -0
  57. package/lib/config/versions/magento-2.3.7.js +5 -9
  58. package/lib/config/versions/magento-2.4.0-p1.js +5 -9
  59. package/lib/config/versions/magento-2.4.0.js +5 -9
  60. package/lib/config/versions/magento-2.4.1-p1.js +5 -9
  61. package/lib/config/versions/magento-2.4.1.js +5 -9
  62. package/lib/config/versions/magento-2.4.2-p1.js +5 -9
  63. package/lib/config/versions/magento-2.4.2-p2.js +5 -9
  64. package/lib/config/versions/magento-2.4.2.js +5 -9
  65. package/lib/config/versions/magento-2.4.3-p1.js +5 -9
  66. package/lib/config/versions/magento-2.4.3-p2.js +5 -9
  67. package/lib/config/versions/magento-2.4.3-p3.js +42 -0
  68. package/lib/config/versions/magento-2.4.3.js +5 -9
  69. package/lib/config/versions/magento-2.4.4-p1.js +42 -0
  70. package/lib/config/versions/magento-2.4.4.js +5 -9
  71. package/lib/config/versions/magento-2.4.5.js +42 -0
  72. package/lib/tasks/cleanup.js +1 -1
  73. package/lib/tasks/composer/local-auth-json.js +1 -1
  74. package/lib/tasks/database/connect-to-database.js +120 -0
  75. package/lib/tasks/database/create-magento-database.js +21 -0
  76. package/lib/tasks/database/create-magento-user.js +50 -0
  77. package/lib/tasks/database/default-magento-database.js +3 -0
  78. package/lib/tasks/database/default-magento-user.js +7 -0
  79. package/lib/tasks/{mysql → database}/dump-theme-config.js +3 -3
  80. package/lib/tasks/{mysql → database}/fix-db.js +2 -2
  81. package/lib/tasks/{mysql/import-dump-to-mysql.js → database/import-dump-to-database.js} +21 -20
  82. package/lib/tasks/{mysql → database}/import-remote-db/index.js +0 -0
  83. package/lib/tasks/{mysql/import-remote-db/ssh/mysqldump-command.js → database/import-remote-db/ssh/database-dump-command.js} +2 -2
  84. package/lib/tasks/{mysql → database}/import-remote-db/ssh/index.js +0 -0
  85. package/lib/tasks/{mysql → database}/import-remote-db/ssh/readymage.js +4 -4
  86. package/lib/tasks/{mysql → database}/import-remote-db/ssh/regular-server.js +2 -2
  87. package/lib/tasks/{mysql → database}/index.js +2 -2
  88. package/lib/tasks/{mysql → database}/magento-tables.js +0 -0
  89. package/lib/tasks/{mysql → database}/restore-theme-config.js +4 -4
  90. package/lib/tasks/docker/api.d.ts +25 -1
  91. package/lib/tasks/docker/api.js +31 -1
  92. package/lib/tasks/docker/containers/container-api.d.ts +18 -0
  93. package/lib/tasks/docker/containers/container-api.js +76 -17
  94. package/lib/tasks/docker/containers/tasks.js +32 -1
  95. package/lib/tasks/docker/convert-legacy-volumes.js +8 -7
  96. package/lib/tasks/docker/convert-mysql-to-mariadb.js +284 -0
  97. package/lib/tasks/docker/index.js +6 -1
  98. package/lib/tasks/docker/network/network-api.d.ts +1 -1
  99. package/lib/tasks/docker/project-image-builder.js +7 -9
  100. package/lib/tasks/docker/volume/index.js +9 -0
  101. package/lib/tasks/docker/volume/tasks.js +94 -0
  102. package/lib/tasks/docker/volume/volume-api.d.ts +49 -0
  103. package/lib/tasks/docker/volume/volume-api.js +90 -0
  104. package/lib/tasks/execute.js +100 -0
  105. package/lib/tasks/file-system/create-mariadb-config.js +23 -0
  106. package/lib/tasks/file-system/create-nginx-config.js +3 -5
  107. package/lib/tasks/file-system/create-php-config.js +2 -23
  108. package/lib/tasks/file-system/create-php-debug-config.js +45 -0
  109. package/lib/tasks/file-system/create-php-fpm-config.js +2 -4
  110. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/php-workspace-project-configuration-config.js +1 -1
  111. package/lib/tasks/file-system/create-ssl-terminator-config.js +4 -7
  112. package/lib/tasks/file-system/create-varnish-config.js +4 -7
  113. package/lib/tasks/file-system/index.js +5 -1
  114. package/lib/tasks/import-dump.js +6 -6
  115. package/lib/tasks/link.js +4 -2
  116. package/lib/tasks/magento/enable-magento-composer-plugins.js +85 -30
  117. package/lib/tasks/magento/install-magento-project.js +3 -2
  118. package/lib/tasks/magento/setup-magento/configure-elasticsearch.js +3 -5
  119. package/lib/tasks/magento/setup-magento/create-admin.js +1 -1
  120. package/lib/tasks/magento/setup-magento/delete-admin-users.js +2 -2
  121. package/lib/tasks/magento/setup-magento/delete-customers.js +4 -4
  122. package/lib/tasks/magento/setup-magento/delete-orders.js +4 -4
  123. package/lib/tasks/magento/setup-magento/flush-redis-config.js +3 -6
  124. package/lib/tasks/magento/setup-magento/increase-admin-session-lifetime.js +2 -2
  125. package/lib/tasks/magento/setup-magento/index.js +2 -0
  126. package/lib/tasks/magento/setup-magento/install-magento.js +15 -17
  127. package/lib/tasks/magento/setup-magento/migrate-database.js +5 -11
  128. package/lib/tasks/magento/setup-magento/set-base-url.js +3 -3
  129. package/lib/tasks/magento/setup-magento/set-url-rewrite.js +2 -2
  130. package/lib/tasks/magento/setup-magento/varnish-config.js +8 -13
  131. package/lib/tasks/magento/setup-magento/waiting-for-varnish.js +17 -16
  132. package/lib/tasks/php/php-container.js +7 -3
  133. package/lib/tasks/php/update-env-php.js +7 -6
  134. package/lib/tasks/php/update-env.php +12 -12
  135. package/lib/tasks/requirements/composer-credentials.js +7 -3
  136. package/lib/tasks/requirements/docker/context.js +88 -0
  137. package/lib/tasks/requirements/docker/index.js +110 -19
  138. package/lib/tasks/requirements/docker/install.js +21 -7
  139. package/lib/tasks/requirements/docker/permissions.js +2 -11
  140. package/lib/tasks/requirements/docker/running-status.js +94 -24
  141. package/lib/tasks/requirements/docker/version.js +1 -0
  142. package/lib/tasks/requirements/index.js +0 -2
  143. package/lib/tasks/requirements/php-version.js +4 -2
  144. package/lib/tasks/start.js +32 -31
  145. package/lib/tasks/status/index.js +17 -13
  146. package/lib/tasks/stop.js +2 -0
  147. package/lib/tasks/theme/link-theme.js +2 -2
  148. package/lib/util/config-file-validator.js +29 -13
  149. package/lib/util/database.js +7 -7
  150. package/lib/util/execute-in-container.js +63 -0
  151. package/lib/util/prefix.js +1 -1
  152. package/lib/util/systemctl.js +62 -13
  153. package/package.json +4 -3
  154. package/typings/context.d.ts +12 -5
  155. package/typings/index.d.ts +69 -31
  156. package/lib/tasks/docker/volumes.js +0 -63
  157. package/lib/tasks/execute/index.js +0 -23
  158. package/lib/tasks/mysql/connect-to-mysql.js +0 -127
  159. package/lib/tasks/mysql/create-magento-database.js +0 -18
  160. package/lib/tasks/requirements/dependency/arch.js +0 -50
  161. package/lib/tasks/requirements/dependency/centos.js +0 -36
  162. package/lib/tasks/requirements/dependency/fedora.js +0 -36
  163. package/lib/tasks/requirements/dependency/index.js +0 -33
  164. package/lib/tasks/requirements/dependency/mac.js +0 -124
  165. package/lib/tasks/requirements/dependency/ubuntu.js +0 -83
@@ -1,14 +1,21 @@
1
1
  import { ListrContext } from './context';
2
2
 
3
3
  /* eslint-disable no-use-before-define */
4
- export interface ServiceWithVersion {
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 ServiceWithVersion {
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 ServiceWithVersion {
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 VarnishConfiguration extends ServiceWithVersion {
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: (arg0: (Omit<PHPExtensionInstallationInstruction, 'command'> & { ctx: ListrContext})) => string | string
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: ServiceWithVersion
212
+ mariadb: ServiceWithImage
165
213
 
166
214
  /**
167
215
  * ElasticSearch configuration
168
216
  */
169
- elasticsearch: ServiceWithVersion
217
+ elasticsearch: ElasticSearchConfiguration
170
218
 
171
219
  /**
172
220
  * Redis configuration
173
221
  */
174
- redis: ServiceWithVersion
222
+ redis: ServiceWithImage
175
223
 
176
224
  /**
177
225
  * Composer configuration
178
226
  */
179
- composer: ServiceWithVersion
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
- * @default 'localhost'
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;