@scandipwa/magento-scripts 1.16.1 → 2.0.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (226) hide show
  1. package/lib/commands/cli.js +4 -6
  2. package/lib/commands/execute.js +29 -4
  3. package/lib/commands/import-db.js +1 -1
  4. package/lib/commands/logs.js +1 -1
  5. package/lib/commands/start.js +38 -20
  6. package/lib/commands/status.js +2 -0
  7. package/lib/config/docker.js +102 -84
  8. package/lib/config/get-project-configuration.js +3 -1
  9. package/lib/config/index.js +10 -7
  10. package/lib/config/magento/required-php-extensions/index.js +29 -0
  11. package/lib/config/magento/required-php-extensions/magento-2.3.js +19 -0
  12. package/lib/config/magento/required-php-extensions/magento-2.4.js +29 -0
  13. package/lib/config/php/base-repo.js +3 -0
  14. package/lib/config/php/extensions/apcu.js +12 -0
  15. package/lib/config/php/extensions/bcmath.js +7 -0
  16. package/lib/config/php/extensions/curl.js +11 -0
  17. package/lib/config/php/extensions/gd.js +14 -0
  18. package/lib/config/php/extensions/index.js +18 -2
  19. package/lib/config/php/extensions/intl.js +10 -0
  20. package/lib/config/php/extensions/opcache.js +10 -0
  21. package/lib/config/php/extensions/pdo_mysql.js +7 -0
  22. package/lib/config/php/extensions/soap.js +10 -0
  23. package/lib/config/php/extensions/sodium.js +10 -0
  24. package/lib/config/php/extensions/xdebug.js +8 -5
  25. package/lib/config/php/extensions/xsl.js +10 -0
  26. package/lib/config/php/extensions/zip.js +10 -0
  27. package/lib/config/php/{releases → versions}/index.js +0 -0
  28. package/lib/config/php/versions/php-7.2.js +23 -0
  29. package/lib/config/php/versions/php-7.3.js +23 -0
  30. package/lib/config/php/versions/php-7.4.js +23 -0
  31. package/lib/config/php/versions/php-8.1.js +23 -0
  32. package/lib/config/php-config.js +8 -12
  33. package/lib/config/port-config.js +2 -6
  34. package/lib/config/services/elasticsearch/base-repo.js +3 -0
  35. package/lib/config/services/elasticsearch/default-es-env.js +6 -0
  36. package/lib/config/services/elasticsearch/versions/elasticsearch-6.8.js +19 -0
  37. package/lib/config/services/elasticsearch/versions/index.js +5 -0
  38. package/lib/config/templates/magentorc.template +5 -5
  39. package/lib/config/templates/mariadb.template.cnf +191 -0
  40. package/lib/config/templates/php-fpm.template.conf +3 -3
  41. package/lib/config/templates/php.template.ini +12 -6
  42. package/lib/config/templates/ssl-terminator.template.conf +1 -1
  43. package/lib/config/templates/vscode-launch.template.json +3 -1
  44. package/lib/config/versions/magento-2.3.0.js +10 -5
  45. package/lib/config/versions/magento-2.3.1.js +10 -5
  46. package/lib/config/versions/magento-2.3.2-p1.js +43 -0
  47. package/lib/config/versions/magento-2.3.2-p2.js +10 -5
  48. package/lib/config/versions/magento-2.3.2.js +10 -5
  49. package/lib/config/versions/magento-2.3.3-p1.js +10 -5
  50. package/lib/config/versions/magento-2.3.3.js +10 -5
  51. package/lib/config/versions/magento-2.3.4-p1.js +43 -0
  52. package/lib/config/versions/magento-2.3.4-p2.js +10 -5
  53. package/lib/config/versions/magento-2.3.4.js +10 -5
  54. package/lib/config/versions/magento-2.3.5-p1.js +8 -2
  55. package/lib/config/versions/magento-2.3.5-p2.js +8 -2
  56. package/lib/config/versions/magento-2.3.5.js +8 -2
  57. package/lib/config/versions/magento-2.3.6-p1.js +8 -2
  58. package/lib/config/versions/magento-2.3.6.js +8 -2
  59. package/lib/config/versions/magento-2.3.7-p1.js +8 -2
  60. package/lib/config/versions/magento-2.3.7-p2.js +8 -2
  61. package/lib/config/versions/magento-2.3.7-p3.js +8 -2
  62. package/lib/config/versions/magento-2.3.7.js +8 -2
  63. package/lib/config/versions/magento-2.4.0-p1.js +9 -3
  64. package/lib/config/versions/magento-2.4.0.js +9 -3
  65. package/lib/config/versions/magento-2.4.1-p1.js +6 -5
  66. package/lib/config/versions/magento-2.4.1.js +9 -2
  67. package/lib/config/versions/magento-2.4.2-p1.js +6 -5
  68. package/lib/config/versions/magento-2.4.2-p2.js +6 -6
  69. package/lib/config/versions/magento-2.4.2.js +6 -6
  70. package/lib/config/versions/magento-2.4.3-p1.js +7 -7
  71. package/lib/config/versions/magento-2.4.3-p2.js +7 -7
  72. package/lib/config/versions/magento-2.4.3.js +7 -7
  73. package/lib/config/versions/magento-2.4.4.js +9 -2
  74. package/lib/tasks/cleanup.js +3 -3
  75. package/lib/tasks/composer/index.js +14 -104
  76. package/lib/tasks/database/connect-to-database.js +117 -0
  77. package/lib/tasks/database/create-magento-database.js +18 -0
  78. package/lib/tasks/{mysql → database}/dump-theme-config.js +3 -3
  79. package/lib/tasks/{mysql → database}/fix-db.js +2 -2
  80. package/lib/tasks/{mysql/import-dump-to-mysql.js → database/import-dump-to-database.js} +65 -22
  81. package/lib/tasks/{mysql → database}/import-remote-db/index.js +0 -0
  82. package/lib/tasks/{mysql/import-remote-db/ssh/mysqldump-command.js → database/import-remote-db/ssh/database-dump-command.js} +2 -2
  83. package/lib/tasks/{mysql → database}/import-remote-db/ssh/index.js +0 -0
  84. package/lib/tasks/{mysql → database}/import-remote-db/ssh/readymage.js +4 -4
  85. package/lib/tasks/{mysql → database}/import-remote-db/ssh/regular-server.js +2 -2
  86. package/lib/tasks/{mysql → database}/index.js +2 -2
  87. package/lib/tasks/{mysql → database}/magento-tables.js +0 -0
  88. package/lib/tasks/{mysql → database}/restore-theme-config.js +4 -4
  89. package/lib/tasks/docker/api.d.ts +71 -0
  90. package/lib/tasks/docker/api.js +30 -0
  91. package/lib/tasks/docker/containers/container-api.d.ts +128 -0
  92. package/lib/tasks/docker/containers/container-api.js +153 -0
  93. package/lib/tasks/docker/containers/index.js +19 -0
  94. package/lib/tasks/docker/containers/tasks.js +215 -0
  95. package/lib/tasks/docker/convert-legacy-volumes.js +15 -10
  96. package/lib/tasks/docker/convert-mysql-to-mariadb.js +284 -0
  97. package/lib/tasks/docker/image/image-api.d.ts +34 -0
  98. package/lib/tasks/docker/image/image-api.js +49 -0
  99. package/lib/tasks/docker/image/index.js +5 -0
  100. package/lib/tasks/docker/index.js +1 -13
  101. package/lib/tasks/docker/network/index.js +7 -0
  102. package/lib/tasks/docker/network/network-api.d.ts +103 -0
  103. package/lib/tasks/docker/network/network-api.js +99 -0
  104. package/lib/tasks/docker/{network.js → network/tasks.js} +17 -10
  105. package/lib/tasks/docker/project-image-builder.js +167 -0
  106. package/lib/tasks/docker/volume/index.js +8 -0
  107. package/lib/tasks/docker/{volumes.js → volume/tasks.js} +5 -19
  108. package/lib/tasks/docker/volume/volume-api.d.ts +39 -0
  109. package/lib/tasks/docker/volume/volume-api.js +66 -0
  110. package/lib/tasks/execute/index.js +5 -2
  111. package/lib/tasks/file-system/create-mariadb-config.js +23 -0
  112. package/lib/tasks/file-system/create-nginx-config.js +2 -3
  113. package/lib/tasks/file-system/create-php-config.js +20 -5
  114. package/lib/tasks/file-system/create-php-fpm-config.js +8 -4
  115. package/lib/tasks/file-system/create-phpstorm-config/exclude-folder-config.js +41 -29
  116. package/lib/tasks/file-system/create-phpstorm-config/index.js +2 -0
  117. package/lib/tasks/file-system/create-phpstorm-config/keys.js +15 -1
  118. package/lib/tasks/file-system/create-phpstorm-config/php-config/index.js +4 -1
  119. package/lib/tasks/file-system/create-phpstorm-config/php-config/php-config.js +3 -3
  120. package/lib/tasks/file-system/create-phpstorm-config/php-config/php-interpreters-config.js +81 -0
  121. package/lib/tasks/file-system/create-phpstorm-config/php-docker-settings-config/index.js +42 -0
  122. package/lib/tasks/file-system/create-phpstorm-config/php-docker-settings-config/php-docker-settings-config.js +9 -0
  123. package/lib/tasks/file-system/create-phpstorm-config/php-docker-settings-config/setup-php-docker-container-settings-config.js +66 -0
  124. package/lib/tasks/file-system/create-phpstorm-config/setup-xml-structure.js +11 -9
  125. package/lib/tasks/file-system/create-phpstorm-config/stylelint-config.js +2 -1
  126. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/composer-settings-config.js +15 -30
  127. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/index.js +24 -5
  128. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/mess-detector-project-configuration-config.js +50 -0
  129. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/php-code-sniffer-project-configuration-config.js +50 -0
  130. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/php-cs-fixer-project-configuration-config.js +50 -0
  131. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/php-debug-general-config.js +15 -15
  132. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/php-server-config.js +29 -3
  133. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/php-stan-project-configuration-config.js.js +50 -0
  134. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/php-workspace-project-configuration-config.js +42 -0
  135. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/psalm-project-configuration-config.js.js +50 -0
  136. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/workspace-config.js +0 -2
  137. package/lib/tasks/file-system/create-ssl-terminator-config.js +4 -2
  138. package/lib/tasks/file-system/create-vscode-config.js +57 -42
  139. package/lib/tasks/file-system/index.js +5 -2
  140. package/lib/tasks/import-dump.js +6 -6
  141. package/lib/tasks/link.js +5 -4
  142. package/lib/tasks/magento/install-magento-project.js +31 -63
  143. package/lib/tasks/magento/setup-magento/adjust-full-page-cache.js +4 -4
  144. package/lib/tasks/magento/setup-magento/configure-elasticsearch.js +7 -3
  145. package/lib/tasks/magento/setup-magento/create-admin.js +5 -6
  146. package/lib/tasks/magento/setup-magento/delete-admin-users.js +2 -2
  147. package/lib/tasks/magento/setup-magento/delete-customers.js +4 -4
  148. package/lib/tasks/magento/setup-magento/delete-orders.js +4 -4
  149. package/lib/tasks/magento/setup-magento/disable-2fa.js +3 -5
  150. package/lib/tasks/magento/setup-magento/disable-maintenance-mode.js +3 -4
  151. package/lib/tasks/magento/setup-magento/increase-admin-session-lifetime.js +2 -2
  152. package/lib/tasks/magento/setup-magento/index.js +2 -0
  153. package/lib/tasks/magento/setup-magento/install-magento.js +21 -20
  154. package/lib/tasks/magento/setup-magento/migrate-database.js +7 -14
  155. package/lib/tasks/magento/setup-magento/set-base-url.js +2 -2
  156. package/lib/tasks/magento/setup-magento/set-deployment-mode.js +4 -4
  157. package/lib/tasks/magento/setup-magento/set-url-rewrite.js +2 -2
  158. package/lib/tasks/magento/setup-magento/varnish-config.js +10 -8
  159. package/lib/tasks/magento/setup-magento/waiting-for-varnish.js +128 -3
  160. package/lib/tasks/php/php-container.js +108 -0
  161. package/lib/tasks/php/update-env-php.js +39 -21
  162. package/lib/tasks/php/update-env.php +66 -61
  163. package/lib/tasks/php/working_health_check.php +85 -0
  164. package/lib/tasks/requirements/{composer.js → composer-credentials.js} +3 -1
  165. package/lib/tasks/requirements/docker/index.js +15 -12
  166. package/lib/tasks/requirements/docker/performance.js +54 -0
  167. package/lib/tasks/requirements/docker/version.js +8 -8
  168. package/lib/tasks/requirements/index.js +5 -8
  169. package/lib/tasks/requirements/php-version.js +8 -116
  170. package/lib/tasks/requirements/platform.js +12 -25
  171. package/lib/tasks/start.js +21 -50
  172. package/lib/tasks/status/index.js +8 -12
  173. package/lib/tasks/stop.js +0 -2
  174. package/lib/tasks/theme/install-theme.js +1 -1
  175. package/lib/tasks/theme/link-theme.js +2 -2
  176. package/lib/tasks/theme/symlink-theme.js +2 -3
  177. package/lib/util/config-file-validator.js +27 -13
  178. package/lib/util/config-php-json.js +13 -4
  179. package/lib/util/database.js +7 -7
  180. package/lib/util/dockerfile-builder/build-instructions.js +197 -0
  181. package/lib/util/dockerfile-builder/index.js +276 -0
  182. package/lib/util/dockerfile-builder/types.d.ts +123 -0
  183. package/lib/util/env-php-json.js +10 -6
  184. package/lib/util/exec-async-command.js +3 -9
  185. package/lib/util/macos-version.js +20 -0
  186. package/lib/util/magento-task.js +3 -4
  187. package/lib/util/nginx-logs-parser.js +122 -0
  188. package/lib/util/php-task.js +3 -6
  189. package/lib/util/run-composer.js +6 -14
  190. package/lib/util/run-container-image.js +17 -0
  191. package/lib/util/run-magento.js +6 -14
  192. package/lib/util/run-php.js +6 -17
  193. package/package.json +9 -9
  194. package/typings/context.d.ts +7 -13
  195. package/typings/index.d.ts +67 -85
  196. package/yarn-error.log +9660 -0
  197. package/lib/config/composer.js +0 -11
  198. package/lib/config/php/extensions/libsodium.js +0 -36
  199. package/lib/config/php/releases/php-7.2.js +0 -25
  200. package/lib/config/php/releases/php-7.3.js +0 -25
  201. package/lib/config/php/releases/php-7.4.js +0 -23
  202. package/lib/config/php/releases/php-8.1.js +0 -25
  203. package/lib/config/phpbrew.js +0 -12
  204. package/lib/tasks/composer/install-prestissimo.js +0 -103
  205. package/lib/tasks/docker/containers.js +0 -231
  206. package/lib/tasks/mysql/connect-to-mysql.js +0 -114
  207. package/lib/tasks/mysql/create-magento-database.js +0 -18
  208. package/lib/tasks/php/bundled-extensions.js +0 -27
  209. package/lib/tasks/php/compile-options.js +0 -56
  210. package/lib/tasks/php/compile.js +0 -55
  211. package/lib/tasks/php/configure.js +0 -89
  212. package/lib/tasks/php/extensions/disable.js +0 -49
  213. package/lib/tasks/php/extensions/enable.js +0 -52
  214. package/lib/tasks/php/extensions/index.js +0 -80
  215. package/lib/tasks/php/extensions/install.js +0 -54
  216. package/lib/tasks/php/index.js +0 -79
  217. package/lib/tasks/php/install-sodium.js +0 -93
  218. package/lib/tasks/php/update-phpbrew.js +0 -45
  219. package/lib/tasks/php/validate-php.js +0 -67
  220. package/lib/tasks/php-fpm/get-process-id.js +0 -14
  221. package/lib/tasks/php-fpm/index.js +0 -4
  222. package/lib/tasks/php-fpm/start-php-fpm.js +0 -49
  223. package/lib/tasks/php-fpm/stop-php-fpm.js +0 -48
  224. package/lib/tasks/requirements/phpbrew/index.js +0 -61
  225. package/lib/tasks/requirements/phpbrew/install.js +0 -159
  226. package/lib/tasks/requirements/phpbrew/version.js +0 -28
@@ -8,14 +8,14 @@ const varnishConfigSetup = require('../magento/setup-magento/varnish-config');
8
8
  * @type {() => import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
9
9
  */
10
10
  const enableForeignKeyCheck = () => ({
11
- task: ({ mysqlConnection }) => mysqlConnection.query('SET FOREIGN_KEY_CHECKS = 0;')
11
+ task: ({ databaseConnection }) => databaseConnection.query('SET FOREIGN_KEY_CHECKS = 0;')
12
12
  });
13
13
 
14
14
  /**
15
15
  * @type {() => import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
16
16
  */
17
17
  const disableForeignKeyCheck = () => ({
18
- task: ({ mysqlConnection }) => mysqlConnection.query('SET FOREIGN_KEY_CHECKS = 1;')
18
+ task: ({ databaseConnection }) => databaseConnection.query('SET FOREIGN_KEY_CHECKS = 1;')
19
19
  });
20
20
 
21
21
  /**
@@ -4,7 +4,7 @@ const KnownError = require('../../errors/known-error');
4
4
  const UnknownError = require('../../errors/unknown-error');
5
5
  const { execAsyncSpawn, execCommandTask } = require('../../util/exec-async-command');
6
6
  const pathExists = require('../../util/path-exists');
7
- const connectToMySQL = require('./connect-to-mysql');
7
+ const connectToDatabase = require('./connect-to-database');
8
8
 
9
9
  /**
10
10
  * @type {() => import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
@@ -13,10 +13,10 @@ const copyDatabaseDumpIntoContainer = () => ({
13
13
  title: 'Copying database dump into container',
14
14
  task: async (ctx, task) => {
15
15
  const { config: { docker }, ports } = ctx;
16
- const { mysql } = docker.getContainers(ports);
16
+ const { mariadb } = docker.getContainers(ports);
17
17
 
18
18
  return task.newListr(
19
- execCommandTask(`docker cp ${ctx.importDb} ${mysql.name}:/dump.sql`, {
19
+ execCommandTask(`docker cp ${ctx.importDb} ${mariadb.name}:/dump.sql`, {
20
20
  logOutput: true
21
21
  })
22
22
  );
@@ -29,10 +29,10 @@ const copyDatabaseDumpIntoContainer = () => ({
29
29
  const runSetGlobalLogBinTrustFunctionCreatorsCommand = () => ({
30
30
  task: async (ctx, task) => {
31
31
  const { config: { docker }, ports } = ctx;
32
- const { mysql } = docker.getContainers(ports);
32
+ const { mariadb } = docker.getContainers(ports);
33
33
 
34
34
  return task.newListr(
35
- execCommandTask(`docker exec ${mysql.name} bash -c 'mysql -uroot -p${mysql.env.MYSQL_ROOT_PASSWORD} -e "SET GLOBAL log_bin_trust_function_creators = 1;"'`)
35
+ execCommandTask(`docker exec ${mariadb.name} bash -c 'mysql -uroot -p${mariadb.env.MARIADB_ROOT_PASSWORD} -e "SET GLOBAL log_bin_trust_function_creators = 1;"'`)
36
36
  );
37
37
  }
38
38
  });
@@ -63,8 +63,8 @@ Note that you will lose your existing database!`,
63
63
  });
64
64
 
65
65
  if (deleteDatabaseMagentoChoice === 'delete') {
66
- await ctx.mysqlConnection.query('DROP DATABASE IF EXISTS magento;');
67
- await ctx.mysqlConnection.query('CREATE DATABASE magento;');
66
+ await ctx.databaseConnection.query('DROP DATABASE IF EXISTS magento;');
67
+ await ctx.databaseConnection.query('CREATE DATABASE magento;');
68
68
  return;
69
69
  }
70
70
  task.skip();
@@ -77,28 +77,28 @@ Note that you will lose your existing database!`,
77
77
  const executeImportDumpSQL = () => ({
78
78
  task: async (ctx, task) => {
79
79
  const { config: { docker }, ports } = ctx;
80
- const { mysql } = docker.getContainers(ports);
80
+ const { mariadb } = docker.getContainers(ports);
81
81
 
82
- const userCredentialsForMySQLCLI = await task.prompt({
82
+ const userCredentialsForMariaDBCLI = await task.prompt({
83
83
  type: 'Select',
84
- message: 'Which user do you want to use to import db in MySQL client?',
84
+ message: `Which user do you want to use to import db in ${ mariadb._ } client?`,
85
85
  choices: [
86
86
  {
87
- name: `--user=root --password=${mysql.env.MYSQL_ROOT_PASSWORD}`,
87
+ name: `--user=root --password=${mariadb.env.MARIADB_ROOT_PASSWORD}`,
88
88
  message: `root (${logger.style.command('Probably safest option')})`
89
89
  },
90
90
  {
91
- name: `--user=${mysql.env.MYSQL_USER} --password=${mysql.env.MYSQL_PASSWORD}`,
92
- message: `${mysql.env.MYSQL_USER}`
91
+ name: `--user=${mariadb.env.MARIADB_USER} --password=${mariadb.env.MARIADB_PASSWORD}`,
92
+ message: `${mariadb.env.MARIADB_USER}`
93
93
  }
94
94
  ]
95
95
  });
96
96
 
97
- const importCommand = `docker exec ${mysql.name} bash -c "mysql ${userCredentialsForMySQLCLI} magento < ./dump.sql"`;
97
+ const importCommand = `docker exec ${mariadb.name} bash -c "mysql ${userCredentialsForMariaDBCLI} magento < ./dump.sql"`;
98
98
 
99
99
  const startImportTime = Date.now();
100
100
  const tickInterval = setInterval(() => {
101
- task.title = `Importing Database Dump To MySQL, ${Math.floor((Date.now() - startImportTime) / 1000)}s in progress...`;
101
+ task.title = `Importing Database Dump To ${ mariadb._ }, ${Math.floor((Date.now() - startImportTime) / 1000)}s in progress...`;
102
102
  }, 1000);
103
103
 
104
104
  try {
@@ -111,12 +111,55 @@ const executeImportDumpSQL = () => ({
111
111
  }
112
112
  );
113
113
  } catch (e) {
114
- if (e.includes('Unknown collation: \'utf8mb4_0900_ai_ci\'')) {
115
- throw new KnownError(`Error happened during database dump import!
114
+ if (e.message.includes('Unknown collation: \'utf8mb4_0900_ai_ci\'')) {
115
+ const confirmFixingCollation = await task.prompt({
116
+ type: 'Select',
117
+ message: `We got the following error while trying to import ${logger.style.file('dump.sql')}!
118
+
119
+ ${e.message}
120
+
121
+ To fix this error we suggest running the following commands:
122
+ ${logger.style.command('sed -i \'s/utf8mb4_0900_ai_ci/utf8mb4_general_ci/g\' dump.sql')}
123
+ `,
124
+ choices: [
125
+ {
126
+ name: 'yes',
127
+ message: 'Yes, run the following commands, I reaaaalllyy want dump to work! (this will not edit original dump.sql)'
128
+ },
129
+ {
130
+ name: 'no',
131
+ message: 'Okay, I got it. Will try to fix myself'
132
+ }
133
+ ]
134
+ });
135
+
136
+ if (confirmFixingCollation === 'yes') {
137
+ task.output = 'Running fix command...';
138
+ await execAsyncSpawn(`docker exec ${mariadb.name} bash -c "sed -i 's/utf8mb4_0900_ai_ci/utf8mb4_general_ci/g' dump.sql"`);
139
+
140
+ task.output = 'Trying to import dump again...';
141
+ try {
142
+ await execAsyncSpawn(
143
+ importCommand,
144
+ {
145
+ callback: (t) => {
146
+ task.output = t;
147
+ }
148
+ }
149
+ );
150
+
151
+ return;
152
+ } catch (e) {
153
+ throw new KnownError(`Fixing ${logger.style.file('dump.sql')} collations did not helped, we got the following error:
154
+ ${e.message}`);
155
+ }
156
+ } else {
157
+ throw new KnownError(`Database dump import unsuccessful!
116
158
 
117
- ${e}
159
+ ${e.message}
118
160
 
119
161
  You can try replacing all occurrences of ${logger.style.misc('utf8mb4_0900_ai_ci')} with ${logger.style.misc('utf8mb4_general_ci')} in your ${logger.style.file(ctx.importDb)} file!`);
162
+ }
120
163
  }
121
164
 
122
165
  throw new UnknownError(`Unexpected error during dump import.\n\n${e}`);
@@ -132,8 +175,8 @@ You can try replacing all occurrences of ${logger.style.misc('utf8mb4_0900_ai_ci
132
175
  /**
133
176
  * @type {() => import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
134
177
  */
135
- const importDumpToMySQL = () => ({
136
- title: 'Importing Database Dump To MySQL',
178
+ const importDumpToDatabase = () => ({
179
+ title: 'Importing Database Dump',
137
180
  task: async (ctx, task) => {
138
181
  if (!await pathExists(ctx.importDb)) {
139
182
  throw new KnownError(`Dump file at ${ctx.importDb} does not exist. Please provide correct relative path to the file`);
@@ -144,7 +187,7 @@ const importDumpToMySQL = () => ({
144
187
  deleteDatabaseBeforeImportingDumpPrompt(),
145
188
  runSetGlobalLogBinTrustFunctionCreatorsCommand(),
146
189
  executeImportDumpSQL(),
147
- connectToMySQL(),
190
+ connectToDatabase(),
148
191
  {
149
192
  task: () => {
150
193
  task.title = 'Database imported!';
@@ -158,4 +201,4 @@ const importDumpToMySQL = () => ({
158
201
  }
159
202
  });
160
203
 
161
- module.exports = importDumpToMySQL;
204
+ module.exports = importDumpToDatabase;
@@ -1,4 +1,4 @@
1
- const mysqlDumpCommandWithOptions = [
1
+ const databaseDumpCommandWithOptions = [
2
2
  'mysqldump',
3
3
  'magento',
4
4
  '--skip-lock-tables',
@@ -9,4 +9,4 @@ const mysqlDumpCommandWithOptions = [
9
9
  '--no-tablespaces'
10
10
  ];
11
11
 
12
- module.exports = mysqlDumpCommandWithOptions;
12
+ module.exports = databaseDumpCommandWithOptions;
@@ -1,7 +1,7 @@
1
1
  const mergeFiles = require('merge-files');
2
2
  const { orderTables, customerTables } = require('../../magento-tables');
3
3
  const { execAsyncSpawn } = require('../../../../util/exec-async-command');
4
- const mysqlDumpCommandWithOptions = require('./mysqldump-command');
4
+ const databaseDumpCommandWithOptions = require('./database-dump-command');
5
5
 
6
6
  /**
7
7
  * @type {() => import('listr2').ListrTask<import('../../../../../typings/context').ListrContext & { ssh: import('node-ssh').NodeSSH }>}
@@ -25,7 +25,7 @@ const readymageSSH = () => ({
25
25
  */
26
26
  await ssh.execCommand(
27
27
  [
28
- ...mysqlDumpCommandWithOptions,
28
+ ...databaseDumpCommandWithOptions,
29
29
  ...[...orderTables, ...customerTables].map((table) => `--ignore-table=magento.${table}`),
30
30
  '--result-file=dump-0.sql'
31
31
  ].join(' ')
@@ -33,7 +33,7 @@ const readymageSSH = () => ({
33
33
 
34
34
  await ssh.execCommand(
35
35
  [
36
- ...mysqlDumpCommandWithOptions,
36
+ ...databaseDumpCommandWithOptions,
37
37
  '--no-data',
38
38
  '--result-file=dump-1.sql',
39
39
  ...[...orderTables, ...customerTables]
@@ -41,7 +41,7 @@ const readymageSSH = () => ({
41
41
  );
42
42
  } else {
43
43
  task.output = 'Making remote database dump file with customers data...';
44
- await ssh.execCommand([...mysqlDumpCommandWithOptions, '--result-file=dump.sql'].join(' '));
44
+ await ssh.execCommand([...databaseDumpCommandWithOptions, '--result-file=dump.sql'].join(' '));
45
45
  }
46
46
 
47
47
  if (!noCompress) {
@@ -1,7 +1,7 @@
1
1
  const mergeFiles = require('merge-files');
2
2
  const { orderTables, customerTables } = require('../../magento-tables');
3
3
  const { execAsyncSpawn } = require('../../../../util/exec-async-command');
4
- const mysqlDumpCommandWithOptions = require('./mysqldump-command');
4
+ const databaseDumpCommandWithOptions = require('./database-dump-command');
5
5
  const KnownError = require('../../../../errors/known-error');
6
6
  /**
7
7
  * @type {() => import('listr2').ListrTask<import('../../../../../typings/context').ListrContext & { ssh: import('node-ssh').NodeSSH }>}
@@ -27,7 +27,7 @@ Do not enter "--result-file" option, we need to control that part.
27
27
 
28
28
  (documentation reference available here: https://dev.mysql.com/doc/refman/8.0/en/mysqldump.html)
29
29
  `,
30
- initial: mysqlDumpCommandWithOptions.join(' ')
30
+ initial: databaseDumpCommandWithOptions.join(' ')
31
31
  });
32
32
 
33
33
  if (dumpCommand.includes('--result-file')) {
@@ -1,6 +1,6 @@
1
1
  module.exports = {
2
- connectToMySQL: require('./connect-to-mysql'),
3
- importDumpToMySQL: require('./import-dump-to-mysql'),
2
+ connectToDatabase: require('./connect-to-database'),
3
+ importDumpToDatabase: require('./import-dump-to-database'),
4
4
  fixDB: require('./fix-db'),
5
5
  dumpThemeConfig: require('./dump-theme-config'),
6
6
  restoreThemeConfig: require('./restore-theme-config')
File without changes
@@ -6,7 +6,7 @@ const { updateTableValues } = require('../../util/database');
6
6
  const restoreThemeConfig = () => ({
7
7
  title: 'Restoring themes and theme configuration',
8
8
  task: async (ctx, task) => {
9
- const { themeDump, mysqlConnection } = ctx;
9
+ const { themeDump, databaseConnection } = ctx;
10
10
 
11
11
  const { themeIdConfig, themes } = themeDump;
12
12
 
@@ -22,7 +22,7 @@ const restoreThemeConfig = () => ({
22
22
  path: themeIdConfig.path,
23
23
  value: themeIdConfig.value
24
24
  }
25
- ], { mysqlConnection, task });
25
+ ], { databaseConnection, task });
26
26
  }
27
27
 
28
28
  if (themes.length === 0) {
@@ -31,10 +31,10 @@ const restoreThemeConfig = () => ({
31
31
 
32
32
  // restore themes
33
33
  const themeKeys = Object.keys(themes[0]);
34
- await mysqlConnection.query('delete from theme;');
34
+ await databaseConnection.query('delete from theme;');
35
35
 
36
36
  for (const theme of themes) {
37
- await mysqlConnection.query(`
37
+ await databaseConnection.query(`
38
38
  insert into theme (${themeKeys.join(', ')})
39
39
  values (${themeKeys.map(() => '?').join(', ')})
40
40
  `, Object.values(theme));
@@ -0,0 +1,71 @@
1
+ import { ExecAsyncSpawnOptions } from '../../util/exec-async-command';
2
+
3
+ export interface DockerVersionOptions<T extends boolean = false> {
4
+ format?: string
5
+ format?: string
6
+ formatToJSON?: T
7
+ }
8
+
9
+ export interface DockerClientDetails {
10
+ Platform: {
11
+ Name: string
12
+ }
13
+ CloudIntegration: string
14
+ Version: string
15
+ ApiVersion: string
16
+ DefaultAPIVersion: string
17
+ GitCommit: string
18
+ GoVersion: string
19
+ Os: string
20
+ Arch: string
21
+ BuildTime: string
22
+ Context: string
23
+ Experimental: boolean
24
+ }
25
+
26
+ export interface DockerServerComponent {
27
+ Name: string
28
+ Version: string
29
+ Details: {
30
+ ApiVersion?: string
31
+ Arch?: string
32
+ BuildTime?: string
33
+ Experimental?: string
34
+ GitCommit: string
35
+ GoVersion?: string
36
+ KernelVersion?: string
37
+ MinApiVersion?: string
38
+ Os?: string
39
+ }
40
+ }
41
+
42
+ export interface DockerServerDetails {
43
+ Platform: {
44
+ Name: string
45
+ }
46
+ Components: DockerServerComponent[]
47
+ Version: string
48
+ ApiVersion: string
49
+ MinAPIVersion: string
50
+ GitCommit: string
51
+ GoVersion: string
52
+ Os: string
53
+ Arch: string
54
+ KernelVersion: string
55
+ BuildTime: string
56
+ }
57
+
58
+ export interface DockerVersionResult {
59
+ Client: DockerClientDetails
60
+ Server: DockerServerDetails
61
+ }
62
+
63
+ export function version(
64
+ options: DockerVersionOptions,
65
+ execOptions?: ExecAsyncSpawnOptions<false>
66
+ ): Promise<string>
67
+
68
+ export function version(
69
+ options: DockerVersionOptions<true>,
70
+ execOptions?: ExecAsyncSpawnOptions<false>
71
+ ): Promise<DockerVersionResult>
@@ -0,0 +1,30 @@
1
+ const { execAsyncSpawn } = require('../../util/exec-async-command');
2
+
3
+ /**
4
+ * @param {import('./api').DockerVersionOptions} options
5
+ * @param {import('../../util/exec-async-command').ExecAsyncSpawnOptions} execOptions
6
+ */
7
+ const version = async (options, execOptions = {}) => {
8
+ const {
9
+ format,
10
+ formatToJSON
11
+ } = options;
12
+
13
+ const formatArg = !formatToJSON && format
14
+ ? `--format=${format}`
15
+ : formatToJSON && '--format=\'{{json .}}\'';
16
+ const args = [
17
+ formatArg
18
+ ].filter(Boolean).join(' ');
19
+
20
+ if (formatToJSON) {
21
+ const result = await execAsyncSpawn(`docker version ${args}`, execOptions);
22
+ return JSON.parse(result);
23
+ }
24
+
25
+ return execAsyncSpawn(`docker version ${args}`, execOptions);
26
+ };
27
+
28
+ module.exports = {
29
+ version
30
+ };
@@ -0,0 +1,128 @@
1
+ /* eslint-disable max-len */
2
+ import { ExecAsyncSpawnOptions } from '../../../util/exec-async-command';
3
+
4
+ export interface ContainerLsOptions<T extends boolean = false> {
5
+ all?: boolean
6
+ filter?: string | string[]
7
+ format?: string
8
+ quiet?: boolean
9
+ noTrunc?: boolean
10
+ formatToJSON?: T
11
+ latest?: boolean
12
+ }
13
+
14
+ export interface ContainerLsResult {
15
+ Command: string
16
+ CreatedAt: string
17
+ ID: string
18
+ Image: string
19
+ Labels: string
20
+ LocalVolumes: string
21
+ Mounts: string
22
+ Names: string
23
+ Networks: string
24
+ Ports: string
25
+ RunningFor: string
26
+ Size: string
27
+ State: string
28
+ Status: string
29
+ }
30
+
31
+ export function ls(options?: ContainerLsOptions, execOptions?: ExecAsyncSpawnOptions<false>): Promise<string>
32
+ export function ls(options?: ContainerLsOptions<true>, execOptions?: ExecAsyncSpawnOptions<false>): Promise<ContainerLsResult[]>
33
+
34
+ export interface ContainerExecOptions {
35
+ /**
36
+ * Set environment variables [docs](https://docs.docker.com/engine/reference/commandline/run/#set-environment-variables--e---env---env-file)
37
+ */
38
+ env?: Record<string, string>
39
+
40
+ /**
41
+ * Working directory inside the container
42
+ */
43
+ workdir?: string
44
+
45
+ /**
46
+ * Username or UID (format: <name|uid>[:<group|gid>])
47
+ */
48
+ user?: string
49
+
50
+ /**
51
+ * Allocate a pseudo-TTY
52
+ */
53
+ tty?: boolean
54
+ }
55
+
56
+ export function exec(command: string, container: string, options?: ContainerExecOptions, execOptions?: ExecAsyncSpawnOptions<false>): Promise<string>
57
+
58
+ export interface ContainerRunOptions {
59
+ /**
60
+ * Add a custom host-to-IP mapping (host:ip)
61
+ */
62
+ addHost?: string
63
+ /**
64
+ * Automatically remove the container when it exits
65
+ */
66
+ rm?: boolean
67
+
68
+ /**
69
+ * Run container in background and print container ID
70
+ */
71
+ detach?: boolean
72
+ /**
73
+ * Publish or expose port [docs](https://docs.docker.com/engine/reference/commandline/run/#publish-or-expose-port--p---expose)
74
+ */
75
+ ports?: number[]
76
+
77
+ /**
78
+ * Add bind mounts or volumes using the --mount flag [docs](https://docs.docker.com/engine/reference/commandline/run/#add-bind-mounts-or-volumes-using-the---mount-flag)
79
+ */
80
+ mounts?: string[]
81
+
82
+ /**
83
+ * Mount volume [docs](https://docs.docker.com/engine/reference/commandline/run/#mount-volume--v---read-only)
84
+ */
85
+ mountVolumes?: string[]
86
+
87
+ /**
88
+ * Set environment variables [docs](https://docs.docker.com/engine/reference/commandline/run/#set-environment-variables--e---env---env-file)
89
+ */
90
+ env?: Record<string, string>
91
+ image?: string
92
+ /**
93
+ * Restart policies [docs](https://docs.docker.com/engine/reference/commandline/run/#restart-policies---restart)
94
+ */
95
+ restart?: string
96
+
97
+ /**
98
+ * Container name
99
+ */
100
+ name?: string
101
+
102
+ /**
103
+ * Container entrypoint
104
+ */
105
+ entrypoint?: string
106
+
107
+ /**
108
+ * Container command
109
+ */
110
+ command?: string
111
+
112
+ /**
113
+ * Container heathcheck properties
114
+ */
115
+ healthCheck?: Record<'cmd' | 'interval' | 'retries' | 'start-period' | 'timeout', string>
116
+
117
+ /**
118
+ * Security options [docs](https://docs.docker.com/engine/reference/commandline/run/#optional-security-options---security-opt)
119
+ */
120
+ securityOptions?: string[]
121
+ tmpfs?: string[]
122
+ /**
123
+ * Username or UID (format: <name|uid>[:<group|gid>])
124
+ */
125
+ user?: string
126
+ }
127
+
128
+ export function run(containerOptions: ContainerRunOptions, execOptions?: ExecAsyncSpawnOptions<false>): Promise<false>