@scandipwa/magento-scripts 2.0.0-alpha.0 → 2.0.0-alpha.1

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 (77) hide show
  1. package/lib/commands/cli.js +2 -2
  2. package/lib/commands/execute.js +1 -1
  3. package/lib/commands/import-db.js +1 -1
  4. package/lib/commands/logs.js +1 -1
  5. package/lib/commands/start.js +1 -5
  6. package/lib/config/docker.js +37 -45
  7. package/lib/config/index.js +1 -1
  8. package/lib/config/port-config.js +1 -1
  9. package/lib/config/services/elasticsearch/base-repo.js +3 -0
  10. package/lib/config/services/elasticsearch/versions/elasticsearch-6.8.js +23 -0
  11. package/lib/config/services/elasticsearch/versions/index.js +5 -0
  12. package/lib/config/templates/magentorc.template +2 -2
  13. package/lib/config/templates/mariadb.template.cnf +191 -0
  14. package/lib/config/versions/magento-2.3.0.js +2 -3
  15. package/lib/config/versions/magento-2.3.1.js +2 -3
  16. package/lib/config/versions/magento-2.3.2-p1.js +2 -3
  17. package/lib/config/versions/magento-2.3.2-p2.js +2 -3
  18. package/lib/config/versions/magento-2.3.2.js +2 -3
  19. package/lib/config/versions/magento-2.3.3-p1.js +2 -3
  20. package/lib/config/versions/magento-2.3.3.js +2 -3
  21. package/lib/config/versions/magento-2.3.4-p1.js +2 -3
  22. package/lib/config/versions/magento-2.3.4-p2.js +2 -3
  23. package/lib/config/versions/magento-2.3.4.js +2 -3
  24. package/lib/tasks/cleanup.js +1 -1
  25. package/lib/tasks/database/connect-to-database.js +117 -0
  26. package/lib/tasks/database/create-magento-database.js +18 -0
  27. package/lib/tasks/{mysql → database}/dump-theme-config.js +3 -3
  28. package/lib/tasks/{mysql → database}/fix-db.js +2 -2
  29. package/lib/tasks/{mysql/import-dump-to-mysql.js → database/import-dump-to-database.js} +20 -20
  30. package/lib/tasks/{mysql → database}/import-remote-db/index.js +0 -0
  31. package/lib/tasks/{mysql/import-remote-db/ssh/mysqldump-command.js → database/import-remote-db/ssh/database-dump-command.js} +2 -2
  32. package/lib/tasks/{mysql → database}/import-remote-db/ssh/index.js +0 -0
  33. package/lib/tasks/{mysql → database}/import-remote-db/ssh/readymage.js +4 -4
  34. package/lib/tasks/{mysql → database}/import-remote-db/ssh/regular-server.js +2 -2
  35. package/lib/tasks/{mysql → database}/index.js +2 -2
  36. package/lib/tasks/{mysql → database}/magento-tables.js +0 -0
  37. package/lib/tasks/{mysql → database}/restore-theme-config.js +4 -4
  38. package/lib/tasks/docker/convert-legacy-volumes.js +8 -7
  39. package/lib/tasks/docker/convert-mysql-to-mariadb.js +284 -0
  40. package/lib/tasks/docker/network/network-api.d.ts +1 -1
  41. package/lib/tasks/docker/project-image-builder.js +1 -1
  42. package/lib/tasks/docker/volume/index.js +8 -0
  43. package/lib/tasks/docker/{volumes.js → volume/tasks.js} +5 -19
  44. package/lib/tasks/docker/volume/volume-api.d.ts +39 -0
  45. package/lib/tasks/docker/volume/volume-api.js +66 -0
  46. package/lib/tasks/execute/index.js +5 -2
  47. package/lib/tasks/file-system/create-mariadb-config.js +23 -0
  48. package/lib/tasks/file-system/index.js +3 -1
  49. package/lib/tasks/import-dump.js +6 -6
  50. package/lib/tasks/link.js +4 -2
  51. package/lib/tasks/magento/install-magento-project.js +1 -1
  52. package/lib/tasks/magento/setup-magento/configure-elasticsearch.js +2 -2
  53. package/lib/tasks/magento/setup-magento/create-admin.js +1 -1
  54. package/lib/tasks/magento/setup-magento/delete-admin-users.js +2 -2
  55. package/lib/tasks/magento/setup-magento/delete-customers.js +4 -4
  56. package/lib/tasks/magento/setup-magento/delete-orders.js +4 -4
  57. package/lib/tasks/magento/setup-magento/increase-admin-session-lifetime.js +2 -2
  58. package/lib/tasks/magento/setup-magento/index.js +2 -0
  59. package/lib/tasks/magento/setup-magento/install-magento.js +12 -12
  60. package/lib/tasks/magento/setup-magento/migrate-database.js +5 -11
  61. package/lib/tasks/magento/setup-magento/set-base-url.js +2 -2
  62. package/lib/tasks/magento/setup-magento/set-url-rewrite.js +2 -2
  63. package/lib/tasks/magento/setup-magento/varnish-config.js +4 -4
  64. package/lib/tasks/php/update-env-php.js +5 -3
  65. package/lib/tasks/php/update-env.php +12 -12
  66. package/lib/tasks/start.js +5 -25
  67. package/lib/tasks/status/index.js +4 -2
  68. package/lib/tasks/theme/link-theme.js +2 -2
  69. package/lib/util/config-file-validator.js +27 -13
  70. package/lib/util/database.js +7 -7
  71. package/lib/util/prefix.js +1 -1
  72. package/package.json +2 -2
  73. package/typings/context.d.ts +5 -5
  74. package/typings/index.d.ts +31 -30
  75. package/yarn-error.log +9660 -0
  76. package/lib/tasks/mysql/connect-to-mysql.js +0 -127
  77. package/lib/tasks/mysql/create-magento-database.js +0 -18
@@ -1,4 +1,5 @@
1
1
  const path = require('path');
2
+ const { elasticsearch68 } = require('../services/elasticsearch/versions');
2
3
  const { defaultMagentoConfig } = require('../magento-config');
3
4
  const { magento23PHPExtensionList } = require('../magento/required-php-extensions');
4
5
  const { repo } = require('../php/base-repo');
@@ -27,9 +28,7 @@ module.exports = ({ templateDir } = {}) => ({
27
28
  mariadb: {
28
29
  version: '10.2'
29
30
  },
30
- elasticsearch: {
31
- version: '6.8.16'
32
- },
31
+ elasticsearch: elasticsearch68(),
33
32
  composer: {
34
33
  version: '1'
35
34
  },
@@ -1,4 +1,5 @@
1
1
  const path = require('path');
2
+ const { elasticsearch68 } = require('../services/elasticsearch/versions');
2
3
  const { defaultMagentoConfig } = require('../magento-config');
3
4
  const { magento23PHPExtensionList } = require('../magento/required-php-extensions');
4
5
  const { repo } = require('../php/base-repo');
@@ -27,9 +28,7 @@ module.exports = ({ templateDir } = {}) => ({
27
28
  mariadb: {
28
29
  version: '10.2'
29
30
  },
30
- elasticsearch: {
31
- version: '6.8.16'
32
- },
31
+ elasticsearch: elasticsearch68(),
33
32
  composer: {
34
33
  version: '1'
35
34
  },
@@ -1,4 +1,5 @@
1
1
  const path = require('path');
2
+ const { elasticsearch68 } = require('../services/elasticsearch/versions');
2
3
  const { defaultMagentoConfig } = require('../magento-config');
3
4
  const { magento23PHPExtensionList } = require('../magento/required-php-extensions');
4
5
  const { repo } = require('../php/base-repo');
@@ -27,9 +28,7 @@ module.exports = ({ templateDir } = {}) => ({
27
28
  mariadb: {
28
29
  version: '10.2'
29
30
  },
30
- elasticsearch: {
31
- version: '6.8.16'
32
- },
31
+ elasticsearch: elasticsearch68(),
33
32
  composer: {
34
33
  version: '1'
35
34
  },
@@ -1,6 +1,6 @@
1
1
  const { removeCacheFolder } = require('./cache');
2
2
  const { stopServices } = require('./docker');
3
- const { removeVolumes } = require('./docker/volumes');
3
+ const { removeVolumes } = require('./docker/volume/tasks');
4
4
  const {
5
5
  uninstallMagento,
6
6
  removeMagento
@@ -0,0 +1,117 @@
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 waitForDatabaseInitialization = () => ({
11
+ title: 'Waiting for Database to initialize',
12
+ task: async (ctx, task) => {
13
+ const { mariadb } = ctx.config.docker.getContainers();
14
+
15
+ let databaseReadyForConnections = false;
16
+
17
+ while (!databaseReadyForConnections) {
18
+ const databaseOutput = await execAsyncSpawn(`docker logs ${mariadb.name}`);
19
+ if (databaseOutput.includes('ready for connections')) {
20
+ databaseReadyForConnections = true;
21
+ break;
22
+ } else if (databaseOutput.includes('Initializing database files')) {
23
+ task.output = `${mariadb._} is initializing database files!
24
+ Please wait, this will take some time and do not restart the ${mariadb._} container until initialization is finished!`;
25
+
26
+ let databaseFinishedInitialization = false;
27
+ while (!databaseFinishedInitialization) {
28
+ const databaseOutput2 = await execAsyncSpawn(`docker logs ${mariadb.name}`);
29
+ if (databaseOutput2.includes('init process done.') && !databaseFinishedInitialization) {
30
+ databaseFinishedInitialization = true;
31
+ break;
32
+ }
33
+ await sleep(2000);
34
+ }
35
+ }
36
+
37
+ await sleep(2000);
38
+ }
39
+ },
40
+ options: {
41
+ bottomBar: 10
42
+ }
43
+ });
44
+
45
+ /**
46
+ * @returns {import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
47
+ */
48
+ const gettingDatabaseConnection = () => ({
49
+ title: 'Getting Database connection',
50
+ task: async (ctx, task) => {
51
+ const { config: { docker }, ports } = ctx;
52
+ const { mariadb } = docker.getContainers(ctx.ports);
53
+ let tries = 0;
54
+ const maxTries = 20;
55
+ const errors = [];
56
+
57
+ while (tries < maxTries) {
58
+ tries++;
59
+ try {
60
+ const connection = await mysql2.createConnection({
61
+ host: '127.0.0.1',
62
+ port: ports.mariadb,
63
+ user: mariadb.env.MARIADB_USER,
64
+ password: mariadb.env.MARIADB_PASSWORD,
65
+ database: mariadb.env.MARIADB_DATABASE
66
+ });
67
+
68
+ ctx.databaseConnection = connection;
69
+ break;
70
+ } catch (e) {
71
+ errors.push(e);
72
+ }
73
+ await sleep(1000);
74
+ }
75
+
76
+ if (tries === maxTries) {
77
+ throw new UnknownError(`Unable to connect to ${ mariadb._ } server. Check your server configuration!\n\n${ errors.join(' ') }`);
78
+ }
79
+
80
+ task.title = `${ mariadb._ } server connected!`;
81
+ }
82
+ });
83
+
84
+ /**
85
+ * @returns {import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
86
+ */
87
+ const terminatingExistingConnection = () => ({
88
+ title: 'Terminating existing Database connection',
89
+ skip: (ctx) => !ctx.databaseConnection,
90
+ task: (ctx) => {
91
+ ctx.databaseConnection.destroy();
92
+ }
93
+ });
94
+
95
+ /**
96
+ * @returns {import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
97
+ */
98
+ const connectToDatabase = () => ({
99
+ title: 'Connecting to Database server',
100
+ skip: (ctx) => ctx.skipSetup,
101
+ task: (ctx, task) => task.newListr([
102
+ waitForDatabaseInitialization(),
103
+ createMagentoDatabase(),
104
+ terminatingExistingConnection(),
105
+ gettingDatabaseConnection()
106
+ ], {
107
+ concurrent: false,
108
+ rendererOptions: {
109
+ collapse: true
110
+ }
111
+ }),
112
+ options: {
113
+ bottomBar: 10
114
+ }
115
+ });
116
+
117
+ module.exports = connectToDatabase;
@@ -0,0 +1,18 @@
1
+ const { execAsyncSpawn } = require('../../util/exec-async-command');
2
+
3
+ /**
4
+ * Will create database 'magento' in MariaDB 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',
9
+ task: async (ctx, task) => {
10
+ const { mariadb } = ctx.config.docker.getContainers();
11
+ task.title = `Creating Magento database in ${ mariadb._ }`;
12
+ await execAsyncSpawn(`docker exec ${mariadb.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
+ };
@@ -6,9 +6,9 @@ const { isTableExists } = require('../../util/database');
6
6
  const dumpThemeConfig = () => ({
7
7
  title: 'Dumping themes and theme configuration',
8
8
  task: async (ctx, task) => {
9
- const { mysqlConnection } = ctx;
9
+ const { databaseConnection } = ctx;
10
10
  if (await isTableExists('magento', 'theme', ctx)) {
11
- const [themes] = await mysqlConnection.query('select * from theme;');
11
+ const [themes] = await databaseConnection.query('select * from theme;');
12
12
  if (themes.length === 0) {
13
13
  ctx.themeDump = {
14
14
  themes: [],
@@ -17,7 +17,7 @@ const dumpThemeConfig = () => ({
17
17
  }
18
18
 
19
19
  if (await isTableExists('magento', 'core_config_data', ctx)) {
20
- const [themeIdConfig] = await mysqlConnection.query('select * from core_config_data where path = \'design/theme/theme_id\';');
20
+ const [themeIdConfig] = await databaseConnection.query('select * from core_config_data where path = \'design/theme/theme_id\';');
21
21
  if (themeIdConfig.length !== 0) {
22
22
  ctx.themeDump = {
23
23
  themes,
@@ -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 {
@@ -135,7 +135,7 @@ ${logger.style.command('sed -i \'s/utf8mb4_0900_ai_ci/utf8mb4_general_ci/g\' dum
135
135
 
136
136
  if (confirmFixingCollation === 'yes') {
137
137
  task.output = 'Running fix command...';
138
- await execAsyncSpawn(`docker exec ${mysql.name} bash -c "sed -i 's/utf8mb4_0900_ai_ci/utf8mb4_general_ci/g' dump.sql"`);
138
+ await execAsyncSpawn(`docker exec ${mariadb.name} bash -c "sed -i 's/utf8mb4_0900_ai_ci/utf8mb4_general_ci/g' dump.sql"`);
139
139
 
140
140
  task.output = 'Trying to import dump again...';
141
141
  try {
@@ -175,8 +175,8 @@ You can try replacing all occurrences of ${logger.style.misc('utf8mb4_0900_ai_ci
175
175
  /**
176
176
  * @type {() => import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
177
177
  */
178
- const importDumpToMySQL = () => ({
179
- title: 'Importing Database Dump To MySQL',
178
+ const importDumpToDatabase = () => ({
179
+ title: 'Importing Database Dump',
180
180
  task: async (ctx, task) => {
181
181
  if (!await pathExists(ctx.importDb)) {
182
182
  throw new KnownError(`Dump file at ${ctx.importDb} does not exist. Please provide correct relative path to the file`);
@@ -187,7 +187,7 @@ const importDumpToMySQL = () => ({
187
187
  deleteDatabaseBeforeImportingDumpPrompt(),
188
188
  runSetGlobalLogBinTrustFunctionCreatorsCommand(),
189
189
  executeImportDumpSQL(),
190
- connectToMySQL(),
190
+ connectToDatabase(),
191
191
  {
192
192
  task: () => {
193
193
  task.title = 'Database imported!';
@@ -201,4 +201,4 @@ const importDumpToMySQL = () => ({
201
201
  }
202
202
  });
203
203
 
204
- 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));
@@ -1,10 +1,11 @@
1
+ /* eslint-disable no-param-reassign */
1
2
  /* eslint-disable max-len */
2
3
  const { stopServices } = require('./index');
3
4
  const { getBaseConfig, getConfigFromMagentoVersion } = require('../../config');
4
5
  const getDockerConfig = require('../../config/docker');
5
6
  const { execAsyncSpawn } = require('../../util/exec-async-command');
6
7
  const { folderName, legacyFolderName } = require('../../util/prefix');
7
- const { createVolume } = require('./volumes');
8
+ const { volumeApi } = require('./volume');
8
9
 
9
10
  /**
10
11
  * @type {() => import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
@@ -14,20 +15,20 @@ const convertLegacyVolumes = () => ({
14
15
  const { config: { overridenConfiguration } } = ctx;
15
16
  const newDockerConfig = await getDockerConfig(ctx, overridenConfiguration, getBaseConfig(process.cwd(), folderName));
16
17
 
17
- const newVolumeNames = Object.values(newDockerConfig.volumes).filter((v) => !v.opts).map(({ name }) => name);
18
+ const newVolumeNames = Object.values(newDockerConfig.volumes).filter((v) => !v.opt).map(({ name }) => name);
18
19
 
19
- const existingVolumes = (await execAsyncSpawn('docker volume ls -q')).split('\n');
20
+ const existingVolumes = await volumeApi.ls({ formatToJSON: true });
20
21
 
21
22
  if (newVolumeNames.every((v) => existingVolumes.includes(v))) {
22
23
  return;
23
24
  }
24
25
 
25
26
  const legacyDockerConfig = await getDockerConfig(ctx, overridenConfiguration, getBaseConfig(process.cwd(), legacyFolderName));
26
- const legacyVolumeNames = Object.values(legacyDockerConfig.volumes).filter((v) => !v.opts).map(({ name }) => name);
27
+ const legacyVolumeNames = Object.values(legacyDockerConfig.volumes).filter((v) => !v.opt).map(({ name }) => name);
27
28
 
28
29
  if (
29
- newVolumeNames.every((name) => !existingVolumes.includes(name))
30
- && legacyVolumeNames.every((name) => existingVolumes.includes(name))
30
+ newVolumeNames.every((name) => !existingVolumes.some((v) => v.Name === name))
31
+ && legacyVolumeNames.every((name) => existingVolumes.some((v) => v.Name === name))
31
32
  ) {
32
33
  ctx.config = await getConfigFromMagentoVersion(ctx, {
33
34
  magentoVersion: ctx.magentoVersion,
@@ -46,7 +47,7 @@ const convertLegacyVolumes = () => ({
46
47
  const legacyVolumeConfig = legacyDockerConfig.volumes[volumeName];
47
48
 
48
49
  subTask.output = `Creating volume ${volumeConfig.name}...`;
49
- await createVolume(volumeConfig);
50
+ await volumeApi.create(volumeConfig);
50
51
  subTask.output = `Copying data from ${legacyVolumeConfig.name} to ${volumeConfig.name}...`;
51
52
  await execAsyncSpawn(
52
53
  `docker run --rm -v ${legacyVolumeConfig.name}:/from:ro -v ${volumeConfig.name}:/to alpine ash -c "cd /from; cp -av . /to"`, {