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

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 (79) 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 +41 -46
  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/default-es-env.js +6 -0
  11. package/lib/config/services/elasticsearch/versions/elasticsearch-6.8.js +19 -0
  12. package/lib/config/services/elasticsearch/versions/index.js +5 -0
  13. package/lib/config/templates/magentorc.template +2 -2
  14. package/lib/config/templates/mariadb.template.cnf +191 -0
  15. package/lib/config/versions/magento-2.3.0.js +2 -3
  16. package/lib/config/versions/magento-2.3.1.js +2 -3
  17. package/lib/config/versions/magento-2.3.2-p1.js +2 -3
  18. package/lib/config/versions/magento-2.3.2-p2.js +2 -3
  19. package/lib/config/versions/magento-2.3.2.js +2 -3
  20. package/lib/config/versions/magento-2.3.3-p1.js +2 -3
  21. package/lib/config/versions/magento-2.3.3.js +2 -3
  22. package/lib/config/versions/magento-2.3.4-p1.js +2 -3
  23. package/lib/config/versions/magento-2.3.4-p2.js +2 -3
  24. package/lib/config/versions/magento-2.3.4.js +2 -3
  25. package/lib/tasks/cleanup.js +1 -1
  26. package/lib/tasks/database/connect-to-database.js +117 -0
  27. package/lib/tasks/database/create-magento-database.js +18 -0
  28. package/lib/tasks/{mysql → database}/dump-theme-config.js +3 -3
  29. package/lib/tasks/{mysql → database}/fix-db.js +2 -2
  30. package/lib/tasks/{mysql/import-dump-to-mysql.js → database/import-dump-to-database.js} +20 -20
  31. package/lib/tasks/{mysql → database}/import-remote-db/index.js +0 -0
  32. package/lib/tasks/{mysql/import-remote-db/ssh/mysqldump-command.js → database/import-remote-db/ssh/database-dump-command.js} +2 -2
  33. package/lib/tasks/{mysql → database}/import-remote-db/ssh/index.js +0 -0
  34. package/lib/tasks/{mysql → database}/import-remote-db/ssh/readymage.js +4 -4
  35. package/lib/tasks/{mysql → database}/import-remote-db/ssh/regular-server.js +2 -2
  36. package/lib/tasks/{mysql → database}/index.js +2 -2
  37. package/lib/tasks/{mysql → database}/magento-tables.js +0 -0
  38. package/lib/tasks/{mysql → database}/restore-theme-config.js +4 -4
  39. package/lib/tasks/docker/convert-legacy-volumes.js +8 -7
  40. package/lib/tasks/docker/convert-mysql-to-mariadb.js +284 -0
  41. package/lib/tasks/docker/network/network-api.d.ts +1 -1
  42. package/lib/tasks/docker/project-image-builder.js +1 -1
  43. package/lib/tasks/docker/volume/index.js +8 -0
  44. package/lib/tasks/docker/{volumes.js → volume/tasks.js} +5 -19
  45. package/lib/tasks/docker/volume/volume-api.d.ts +39 -0
  46. package/lib/tasks/docker/volume/volume-api.js +66 -0
  47. package/lib/tasks/execute/index.js +5 -2
  48. package/lib/tasks/file-system/create-mariadb-config.js +23 -0
  49. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/php-workspace-project-configuration-config.js +1 -1
  50. package/lib/tasks/file-system/index.js +3 -1
  51. package/lib/tasks/import-dump.js +6 -6
  52. package/lib/tasks/link.js +4 -2
  53. package/lib/tasks/magento/install-magento-project.js +1 -1
  54. package/lib/tasks/magento/setup-magento/configure-elasticsearch.js +2 -2
  55. package/lib/tasks/magento/setup-magento/create-admin.js +1 -1
  56. package/lib/tasks/magento/setup-magento/delete-admin-users.js +2 -2
  57. package/lib/tasks/magento/setup-magento/delete-customers.js +4 -4
  58. package/lib/tasks/magento/setup-magento/delete-orders.js +4 -4
  59. package/lib/tasks/magento/setup-magento/increase-admin-session-lifetime.js +2 -2
  60. package/lib/tasks/magento/setup-magento/index.js +2 -0
  61. package/lib/tasks/magento/setup-magento/install-magento.js +12 -12
  62. package/lib/tasks/magento/setup-magento/migrate-database.js +5 -11
  63. package/lib/tasks/magento/setup-magento/set-base-url.js +2 -2
  64. package/lib/tasks/magento/setup-magento/set-url-rewrite.js +2 -2
  65. package/lib/tasks/magento/setup-magento/varnish-config.js +4 -4
  66. package/lib/tasks/php/update-env-php.js +5 -3
  67. package/lib/tasks/php/update-env.php +12 -12
  68. package/lib/tasks/start.js +5 -25
  69. package/lib/tasks/status/index.js +4 -2
  70. package/lib/tasks/theme/link-theme.js +2 -2
  71. package/lib/util/config-file-validator.js +27 -13
  72. package/lib/util/database.js +7 -7
  73. package/lib/util/prefix.js +1 -1
  74. package/package.json +2 -2
  75. package/typings/context.d.ts +5 -5
  76. package/typings/index.d.ts +31 -30
  77. package/yarn-error.log +9660 -0
  78. package/lib/tasks/mysql/connect-to-mysql.js +0 -127
  79. package/lib/tasks/mysql/create-magento-database.js +0 -18
@@ -1,4 +1,4 @@
1
- const { customerTables } = require('../../mysql/magento-tables');
1
+ const { customerTables } = require('../../database/magento-tables');
2
2
 
3
3
  /**
4
4
  * @returns {import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
@@ -6,19 +6,19 @@ const { customerTables } = require('../../mysql/magento-tables');
6
6
  const deleteCustomers = () => ({
7
7
  title: 'Deleting customers',
8
8
  task: async (ctx, task) => {
9
- const { mysqlConnection, withCustomersData } = ctx;
9
+ const { databaseConnection, withCustomersData } = ctx;
10
10
 
11
11
  if (withCustomersData) {
12
12
  task.skip();
13
13
  return;
14
14
  }
15
15
 
16
- const [rows] = await mysqlConnection.query('select TABLE_NAME from information_schema.TABLES;');
16
+ const [rows] = await databaseConnection.query('select TABLE_NAME from information_schema.TABLES;');
17
17
 
18
18
  await Promise.all(
19
19
  customerTables
20
20
  .filter((tableName) => rows.some((row) => row.TABLE_NAME === tableName))
21
- .map((tableName) => mysqlConnection.query(`TRUNCATE TABLE \`${ tableName }\`;`))
21
+ .map((tableName) => databaseConnection.query(`TRUNCATE TABLE \`${ tableName }\`;`))
22
22
  );
23
23
  }
24
24
  });
@@ -1,4 +1,4 @@
1
- const { orderTables } = require('../../mysql/magento-tables');
1
+ const { orderTables } = require('../../database/magento-tables');
2
2
 
3
3
  /**
4
4
  * @returns {import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
@@ -6,19 +6,19 @@ const { orderTables } = require('../../mysql/magento-tables');
6
6
  const deleteOrders = () => ({
7
7
  title: 'Deleting orders',
8
8
  task: async (ctx, task) => {
9
- const { mysqlConnection, withCustomersData } = ctx;
9
+ const { databaseConnection, withCustomersData } = ctx;
10
10
 
11
11
  if (withCustomersData) {
12
12
  task.skip();
13
13
  return;
14
14
  }
15
15
 
16
- const [rows] = await mysqlConnection.query('select TABLE_NAME from information_schema.TABLES;');
16
+ const [rows] = await databaseConnection.query('select TABLE_NAME from information_schema.TABLES;');
17
17
 
18
18
  await Promise.all(
19
19
  orderTables
20
20
  .filter((tableName) => rows.some((row) => row.TABLE_NAME === tableName))
21
- .map((tableName) => mysqlConnection.query(`TRUNCATE TABLE \`${ tableName }\`;`))
21
+ .map((tableName) => databaseConnection.query(`TRUNCATE TABLE \`${ tableName }\`;`))
22
22
  );
23
23
  }
24
24
  });
@@ -5,7 +5,7 @@ const { updateTableValues } = require('../../../util/database');
5
5
  */
6
6
  const increaseAdminSessionLifetime = () => ({
7
7
  title: 'Increase admin session lifetime to 1 month',
8
- task: async ({ mysqlConnection }, task) => updateTableValues('core_config_data', [
8
+ task: async ({ databaseConnection }, task) => updateTableValues('core_config_data', [
9
9
  {
10
10
  path: 'admin/security/session_lifetime',
11
11
  value: '2800000'
@@ -15,7 +15,7 @@ const increaseAdminSessionLifetime = () => ({
15
15
  value: null
16
16
  }
17
17
  ], {
18
- mysqlConnection,
18
+ databaseConnection,
19
19
  task
20
20
  })
21
21
 
@@ -11,6 +11,7 @@ const increaseAdminSessionLifetime = require('./increase-admin-session-lifetime'
11
11
  const magentoTask = require('../../../util/magento-task');
12
12
  const urnHighlighter = require('./urn-highlighter');
13
13
  const adjustFullPageCache = require('./adjust-full-page-cache');
14
+ const updateEnvPHP = require('../../php/update-env-php');
14
15
 
15
16
  /**
16
17
  * @param {Object} [options]
@@ -32,6 +33,7 @@ const setupMagento = (options = {}) => ({
32
33
  return task.newListr([
33
34
  flushRedisConfig(),
34
35
  waitingForRedis(),
36
+ updateEnvPHP(),
35
37
  migrateDatabase(),
36
38
  {
37
39
  title: 'Configuring Magento settings',
@@ -24,19 +24,19 @@ const installMagento = ({ isDbEmpty = false } = {}) => ({
24
24
  magentoConfiguration
25
25
  },
26
26
  ports,
27
- mysqlConnection
27
+ databaseConnection
28
28
  } = ctx;
29
29
 
30
30
  const isLinux = ctx.platform === 'linux';
31
31
  const isNativeLinux = isLinux && !ctx.isWsl;
32
32
  const hostMachine = isNativeLinux ? '127.0.0.1' : 'host.docker.internal';
33
33
 
34
- const [tableResponse] = await mysqlConnection.query(
34
+ const [tableResponse] = await databaseConnection.query(
35
35
  'SELECT * FROM information_schema.tables WHERE table_schema = \'magento\' AND table_name = \'admin_user\' LIMIT 1;'
36
36
  );
37
37
 
38
38
  if (tableResponse.length > 0) {
39
- const response = await mysqlConnection.query(
39
+ const response = await databaseConnection.query(
40
40
  'select * from admin_user where username=\'admin\';'
41
41
  );
42
42
 
@@ -58,23 +58,23 @@ const installMagento = ({ isDbEmpty = false } = {}) => ({
58
58
  ]
59
59
  });
60
60
 
61
- await mysqlConnection.query('SET FOREIGN_KEY_CHECKS = 0;');
61
+ await databaseConnection.query('SET FOREIGN_KEY_CHECKS = 0;');
62
62
 
63
63
  if (confirmDeleteAdminUsers === 'delete-all') {
64
- await mysqlConnection.query(`
64
+ await databaseConnection.query(`
65
65
  TRUNCATE TABLE admin_user;
66
66
  `);
67
67
  } else {
68
- await mysqlConnection.query(`
68
+ await databaseConnection.query(`
69
69
  DELETE FROM admin_user WHERE username='admin';
70
70
  `);
71
71
  }
72
72
 
73
- await mysqlConnection.query('SET FOREIGN_KEY_CHECKS = 1;');
73
+ await databaseConnection.query('SET FOREIGN_KEY_CHECKS = 1;');
74
74
  }
75
75
  }
76
76
 
77
- const { mysql: { env } } = docker.getContainers(ports);
77
+ const { mariadb: { env } } = docker.getContainers(ports);
78
78
  const envPhpData = await envPhpToJson(ctx);
79
79
 
80
80
  const envPhpHaveEncryptionKey = envPhpData && envPhpData.crypt && envPhpData.crypt.key && envPhpData.crypt.key;
@@ -126,10 +126,10 @@ const installMagento = ({ isDbEmpty = false } = {}) => ({
126
126
  --cache-backend-redis-server='${ hostMachine }' \
127
127
  --cache-backend-redis-port='${ ports.redis }' \
128
128
  --cache-backend-redis-db='0't \
129
- --db-host='${ hostMachine }:${ ports.mysql }' \
130
- --db-name='${ env.MYSQL_DATABASE }' \
131
- --db-user='${ env.MYSQL_USER }' \
132
- --db-password='${ env.MYSQL_PASSWORD }' \
129
+ --db-host='${ hostMachine }:${ ports.mariadb }' \
130
+ --db-name='${ env.MARIADB_DATABASE }' \
131
+ --db-user='${ env.MARIADB_USER }' \
132
+ --db-password='${ env.MARIADB_PASSWORD }' \
133
133
  --backend-frontname='${ magentoConfiguration.adminuri }' \
134
134
  --no-interaction`;
135
135
 
@@ -8,6 +8,7 @@ const upgradeMagento = require('./upgrade-magento');
8
8
  const varnishConfigSetup = require('./varnish-config');
9
9
  const pathExists = require('../../../util/path-exists');
10
10
  const updateEnvPHP = require('../../php/update-env-php');
11
+ const UnknownError = require('../../../errors/unknown-error');
11
12
 
12
13
  /**
13
14
  * @param {Object} [options]
@@ -17,9 +18,9 @@ const updateEnvPHP = require('../../php/update-env-php');
17
18
  const migrateDatabase = (options = {}) => ({
18
19
  title: 'Migrating database',
19
20
  task: async (ctx, task) => {
20
- const { mysqlConnection } = ctx;
21
+ const { databaseConnection } = ctx;
21
22
 
22
- const [[{ tableCount }]] = await mysqlConnection.query(`
23
+ const [[{ tableCount }]] = await databaseConnection.query(`
23
24
  SELECT count(*) AS tableCount
24
25
  FROM INFORMATION_SCHEMA.TABLES
25
26
  WHERE TABLE_SCHEMA = 'magento';
@@ -33,13 +34,11 @@ const migrateDatabase = (options = {}) => ({
33
34
  if (options.onlyInstallMagento) {
34
35
  ctx.isSetupUpgradeNeeded = false;
35
36
  return task.newListr([
36
- updateEnvPHP(),
37
37
  installMagento({ isDbEmpty: true })
38
38
  ]);
39
39
  }
40
40
 
41
41
  return task.newListr([
42
- updateEnvPHP(),
43
42
  installMagento({ isDbEmpty: true }),
44
43
  updateEnvPHP(),
45
44
  varnishConfigSetup(),
@@ -56,7 +55,7 @@ const migrateDatabase = (options = {}) => ({
56
55
  });
57
56
  }
58
57
 
59
- const { code } = await runMagentoCommand(ctx, 'setup:db:status', {
58
+ const { code, result } = await runMagentoCommand(ctx, 'setup:db:status', {
60
59
  throwNonZeroCode: false
61
60
  });
62
61
 
@@ -65,7 +64,6 @@ const migrateDatabase = (options = {}) => ({
65
64
  ctx.isSetupUpgradeNeeded = false;
66
65
  // no setup is needed, but still to be sure configure ES
67
66
  return task.newListr([
68
- updateEnvPHP(),
69
67
  varnishConfigSetup(),
70
68
  configureElasticsearch()
71
69
  ], {
@@ -88,7 +86,6 @@ const migrateDatabase = (options = {}) => ({
88
86
 
89
87
  return task.newListr([
90
88
  installMagentoProject(),
91
- updateEnvPHP(),
92
89
  installMagento(),
93
90
  updateEnvPHP(),
94
91
  varnishConfigSetup(),
@@ -106,7 +103,6 @@ const migrateDatabase = (options = {}) => ({
106
103
  }
107
104
  case 2: {
108
105
  return task.newListr([
109
- updateEnvPHP(),
110
106
  varnishConfigSetup(),
111
107
  configureElasticsearch(),
112
108
  upgradeMagento()
@@ -120,9 +116,7 @@ const migrateDatabase = (options = {}) => ({
120
116
  });
121
117
  }
122
118
  default: {
123
- // TODO: handle these statuses ?
124
- task.title = 'Migrating database failed: manual action is required!';
125
- break;
119
+ throw new UnknownError(`Migrating database failed: manual action is required!\n\n${result}`);
126
120
  }
127
121
  }
128
122
  },
@@ -14,7 +14,7 @@ module.exports = () => ({
14
14
  ssl
15
15
  }
16
16
  },
17
- mysqlConnection
17
+ databaseConnection
18
18
  } = ctx;
19
19
  const isNgrok = host.endsWith('ngrok.io');
20
20
  const enableSecureFrontend = ssl.enabled ? '1' : '0';
@@ -29,6 +29,6 @@ module.exports = () => ({
29
29
  { path: 'web/secure/use_in_frontend', value: enableSecureFrontend },
30
30
  { path: 'web/secure/use_in_adminhtml', value: enableSecureFrontend },
31
31
  { path: 'web/cookie/cookie_domain', value: null }
32
- ], { mysqlConnection, task });
32
+ ], { databaseConnection, task });
33
33
  }
34
34
  });
@@ -5,13 +5,13 @@ const { updateTableValues } = require('../../../util/database');
5
5
  */
6
6
  const setUrlRewrite = () => ({
7
7
  title: 'Setting up url-rewrites',
8
- task: async ({ mysqlConnection }, task) => {
8
+ task: async ({ databaseConnection }, task) => {
9
9
  await updateTableValues('core_config_data', [
10
10
  {
11
11
  path: 'web/seo/use_rewrites',
12
12
  value: '1'
13
13
  }
14
- ], { mysqlConnection, task });
14
+ ], { databaseConnection, task });
15
15
  }
16
16
  });
17
17
 
@@ -18,7 +18,7 @@ const varnishConfigSetup = () => ({
18
18
  }
19
19
  }
20
20
  },
21
- mysqlConnection,
21
+ databaseConnection,
22
22
  ports,
23
23
  debug
24
24
  } = ctx;
@@ -45,10 +45,10 @@ const varnishConfigSetup = () => ({
45
45
  path: 'system/full_page_cache/caching_application',
46
46
  value: '2'
47
47
  }
48
- ], { mysqlConnection, task });
48
+ ], { databaseConnection, task });
49
49
  } else {
50
50
  // delete varnish configuration if exists
51
- await mysqlConnection.query(`
51
+ await databaseConnection.query(`
52
52
  DELETE FROM core_config_data WHERE path LIKE '%varnish%';
53
53
  `);
54
54
 
@@ -59,7 +59,7 @@ const varnishConfigSetup = () => ({
59
59
  path: 'system/full_page_cache/caching_application',
60
60
  value: '0'
61
61
  }
62
- ], { mysqlConnection, task });
62
+ ], { databaseConnection, task });
63
63
  }
64
64
  },
65
65
  options: {
@@ -1,4 +1,5 @@
1
1
  const path = require('path');
2
+ const os = require('os');
2
3
  const envPhpToJson = require('../../util/env-php-json');
3
4
  const getJsonfileData = require('../../util/get-jsonfile-data');
4
5
  const pathExists = require('../../util/path-exists');
@@ -48,8 +49,8 @@ const updateEnvPHP = () => ({
48
49
  if (
49
50
  persistedQueryConfig
50
51
  && persistedQueryConfig.redis
51
- && persistedQueryConfig.redis.port === `${ ctx.ports.redis }`
52
- && persistedQueryConfig.redis.host === 'localhost'
52
+ && (persistedQueryConfig.redis.port !== `${ ctx.ports.redis }`
53
+ || persistedQueryConfig.redis.host === hostMachine)
53
54
  ) {
54
55
  SETUP_PQ = '';
55
56
  return;
@@ -76,7 +77,8 @@ const updateEnvPHP = () => ({
76
77
  ],
77
78
  image: php.image,
78
79
  detach: false,
79
- rm: true
80
+ rm: true,
81
+ user: isLinux ? `${os.userInfo().uid}:${os.userInfo().gid}` : ''
80
82
  });
81
83
 
82
84
  task.output = result;
@@ -85,18 +85,12 @@ class EnvUpdater
85
85
  $hostMachine = '127.0.0.1';
86
86
  }
87
87
 
88
- // update mysql config
88
+ // update mariadb config
89
89
  if (isset($this->config["db"]["connection"]["default"])) {
90
90
  $conn = &$this->config["db"]["connection"]["default"];
91
- $mysqlHost = $hostMachine . ":" . $this->portConfig["mysql"];
92
- if (
93
- isset($conn["engine"]) &&
94
- isset($conn["host"]) &&
95
- $conn["engine"] === "innodb" &&
96
- $conn["host"] !== $mysqlHost
97
- ) {
98
- $conn["host"] = $mysqlHost;
99
- }
91
+ $mysqlHost = $hostMachine . ":" . $this->portConfig["mariadb"];
92
+
93
+ $conn["host"] = $mysqlHost;
100
94
  }
101
95
 
102
96
  // update redis session config
@@ -132,8 +126,14 @@ class EnvUpdater
132
126
  $cacheConfig = &$this->config["cache"];
133
127
  $redisPort = getenv("REDIS_PORT");
134
128
 
135
- if (isset($cacheConfig) && isset($cacheConfig["persisted-query"]) && isset($cacheConfig["persisted-query"]["redis"]) && $cacheConfig["persisted-query"]["redis"]["port"] != $redisPort) {
136
- $cacheConfig["persisted-query"]["redis"]["port"] = $redisPort;
129
+ if (isset($cacheConfig) && isset($cacheConfig["persisted-query"]) && isset($cacheConfig["persisted-query"]["redis"])) {
130
+ if ($cacheConfig["persisted-query"]["redis"]["port"] !== $redisPort) {
131
+ $cacheConfig["persisted-query"]["redis"]["port"] = $redisPort;
132
+ }
133
+
134
+ if ($cacheConfig["persisted-query"]["redis"]["host"] !== $hostMachine) {
135
+ $cacheConfig["persisted-query"]["redis"]["host"] = $hostMachine;
136
+ }
137
137
  } else {
138
138
  if (!isset($cacheConfig)) {
139
139
  $this->config["cache"] = [];
@@ -12,13 +12,7 @@ const { installMagentoProject, setupMagento } = require('./magento');
12
12
  const { pullImages, stopContainers } = require('./docker/containers');
13
13
  const dockerNetwork = require('./docker/network');
14
14
  const { setPrefix } = require('./prefix');
15
- const {
16
- connectToMySQL
17
- // importDumpToMySQL,
18
- // fixDB,
19
- // restoreThemeConfig,
20
- // dumpThemeConfig
21
- } = require('./mysql');
15
+ const { connectToDatabase } = require('./database');
22
16
  const { buildProjectImage, buildDebugProjectImage } = require('./docker/project-image-builder');
23
17
  const getProjectConfiguration = require('../config/get-project-configuration');
24
18
  const { getSystemConfigTask } = require('../config/system-config');
@@ -32,7 +26,8 @@ const checkForXDGOpen = require('../util/xdg-open-exists');
32
26
  const { getInstanceMetadata, constants: { WEB_LOCATION_TITLE } } = require('../util/instance-metadata');
33
27
  const waitingForVarnish = require('./magento/setup-magento/waiting-for-varnish');
34
28
  const checkPHPVersion = require('./requirements/php-version');
35
- const volumes = require('./docker/volumes');
29
+ const volumes = require('./docker/volume/tasks');
30
+ const convertMySQLDatabaseToMariaDB = require('./docker/convert-mysql-to-mariadb');
36
31
 
37
32
  /**
38
33
  * @type {() => import('listr2').ListrTask<import('../../typings/context').ListrContext>}
@@ -44,6 +39,7 @@ const retrieveProjectConfiguration = () => ({
44
39
  checkConfigurationFile(),
45
40
  getProjectConfiguration(),
46
41
  convertLegacyVolumes(),
42
+ convertMySQLDatabaseToMariaDB(),
47
43
  createCacheFolder(),
48
44
  getSystemConfigTask(),
49
45
  getCachedPorts()
@@ -114,7 +110,7 @@ const configureProject = () => ({
114
110
  installMagentoProject(),
115
111
  enableMagentoComposerPlugins(),
116
112
  startServices(),
117
- connectToMySQL()
113
+ connectToDatabase()
118
114
  ])
119
115
  });
120
116
 
@@ -125,22 +121,6 @@ const finishProjectConfiguration = () => ({
125
121
  title: 'Finishing project configuration',
126
122
  skip: ({ skipSetup }) => skipSetup,
127
123
  task: (ctx, task) => task.newListr([
128
- // {
129
- // skip: (ctx) => !ctx.importDb,
130
- // task: (ctx, task) => {
131
- // task.title = 'Importing database dump';
132
- // return task.newListr([
133
- // dumpThemeConfig(),
134
- // importDumpToMySQL(),
135
- // fixDB(),
136
- // restoreThemeConfig(),
137
- // setupMagento()
138
- // ], {
139
- // concurrent: false,
140
- // exitOnError: true
141
- // });
142
- // }
143
- // },
144
124
  setupThemes(),
145
125
  waitingForVarnish()
146
126
  ], {
@@ -73,8 +73,10 @@ const prettyStatus = async (ctx) => {
73
73
 
74
74
  if (container.status && container.status.Health) {
75
75
  containerStatus = `✓ ${ logger.style.file(container.status.Health.Status) } and ${ logger.style.file('running') }`;
76
- } else {
76
+ } else if (container.status) {
77
77
  containerStatus = logger.style.file(container.status.Status);
78
+ } else {
79
+ containerStatus = '✖ Not running';
78
80
  }
79
81
 
80
82
  block
@@ -83,7 +85,7 @@ const prettyStatus = async (ctx) => {
83
85
  .addLine(`Image: ${logger.style.file(container.image)}`)
84
86
  .addLine(`Network: ${logger.style.link(container.network)}`);
85
87
 
86
- if (container.forwardedPorts && container.forwardedPorts.length > 0) {
88
+ if (!containerStatus.includes('Not running') && container.forwardedPorts && container.forwardedPorts.length > 0) {
87
89
  block.addLine('Port forwarding:');
88
90
  container.forwardedPorts.forEach((port) => {
89
91
  const { host, hostPort, containerPort } = parsePort(port);
@@ -18,7 +18,7 @@ const linkTheme = () => ({
18
18
  absoluteThemePath,
19
19
  themePath,
20
20
  composerData,
21
- mysqlConnection
21
+ databaseConnection
22
22
  } = ctx;
23
23
  const {
24
24
  magento: { edition: magentoEdition },
@@ -27,7 +27,7 @@ const linkTheme = () => ({
27
27
 
28
28
  const isEnterprise = magentoEdition === 'enterprise';
29
29
  const isPageBuilderInstalled = isEnterprise && semver.satisfies(semver.coerce(magentoVersion), '^2.4');
30
- const [queryResult] = await mysqlConnection.query(`
30
+ const [queryResult] = await databaseConnection.query(`
31
31
  SELECT value AS isPagebuilderEnabled
32
32
  FROM core_config_data
33
33
  WHERE path = 'cms/pagebuilder/enabled'
@@ -46,10 +46,16 @@ const sslSchema = Joi.object({
46
46
  ssl_certificate_key: Joi.string().required()
47
47
  });
48
48
 
49
+ /**
50
+ * @type {Joi.ObjectSchema<import('../../typings/index').PHPExtensions>}
51
+ */
49
52
  const phpExtensionConfiguration = Joi.object()
50
53
  .pattern(
51
54
  Joi.string(),
52
55
  Joi.object({
56
+ alternativeName: Joi.array().items(Joi.string()).optional(),
57
+ command: Joi.func().optional(),
58
+ dependencies: Joi.array().items(Joi.string()).optional(),
53
59
  version: Joi.string().optional()
54
60
  })
55
61
  .unknown()
@@ -59,38 +65,47 @@ const phpExtensionConfiguration = Joi.object()
59
65
  * @type {Joi.ObjectSchema<import('../../typings').PHPConfiguration>}
60
66
  */
61
67
  const phpConfigurationSchema = Joi.object({
62
- version: Joi.string().optional().custom(versionValidator),
68
+ baseImage: Joi.string().optional(),
69
+ debugImage: Joi.string().optional(),
70
+ fpmConfigTemplate: Joi.string().optional(),
63
71
  configTemplate: Joi.string().optional().custom(fileExistsValidator),
64
- extensions: phpExtensionConfiguration.optional(),
65
- disabledExtensions: Joi.array().items(Joi.string())
72
+ extensions: phpExtensionConfiguration.optional()
66
73
  });
67
74
 
68
75
  /**
69
76
  * @type {Joi.ObjectSchema<import('../../typings').NginxConfiguration>}
70
77
  */
71
78
  const nginxConfigurationSchema = Joi.object({
72
- version: Joi.string().optional(),
79
+ image: Joi.string().optional(),
73
80
  configTemplate: Joi.string().optional().custom(fileExistsValidator)
74
81
  });
75
82
 
76
83
  /**
77
- * @type {Joi.ObjectSchema<import('../../typings').NginxConfiguration>}
84
+ * @type {Joi.ObjectSchema<import('../../typings').VarnishConfiguration>}
78
85
  */
79
86
  const varnishConfigurationSchema = Joi.object({
80
87
  enabled: Joi.boolean().optional(),
81
- version: Joi.string().optional(),
88
+ image: Joi.string().optional(),
82
89
  configTemplate: Joi.string().optional().custom(fileExistsValidator)
83
90
  });
84
91
 
85
92
  /**
86
- * @type {Joi.ObjectSchema<import('../../typings').ServiceWithVersion>}
93
+ * @type {Joi.ObjectSchema<import('../../typings').ServiceWithImage>}
87
94
  */
88
95
  const serviceConfigurationSchema = Joi.object({
89
- version: Joi.string().optional()
96
+ image: Joi.string().optional()
97
+ });
98
+
99
+ /**
100
+ * @type {Joi.ObjectSchema<import('../../typings').ElasticSearchConfiguration>}
101
+ */
102
+ const elasticsearchConfigurationSchema = Joi.object({
103
+ image: Joi.string().optional(),
104
+ env: Joi.object().optional()
90
105
  });
91
106
 
92
107
  /**
93
- * @type {Joi.ObjectSchema<import('../../typings').CMAConfiguration['configuration']['composer']>}
108
+ * @type {Joi.ObjectSchema<import('../../typings').ComposerConfiguration>}
94
109
  */
95
110
  const composerConfigurationSchema = Joi.object({
96
111
  version: Joi.string().optional().custom((value) => {
@@ -108,8 +123,8 @@ const composerConfigurationSchema = Joi.object({
108
123
  const configurationSchema = Joi.object({
109
124
  php: phpConfigurationSchema.optional(),
110
125
  nginx: nginxConfigurationSchema.optional(),
111
- mysql: serviceConfigurationSchema.optional(),
112
- elasticsearch: serviceConfigurationSchema.optional(),
126
+ mariadb: serviceConfigurationSchema.optional(),
127
+ elasticsearch: elasticsearchConfigurationSchema.optional(),
113
128
  redis: serviceConfigurationSchema.optional(),
114
129
  composer: composerConfigurationSchema.optional(),
115
130
  varnish: varnishConfigurationSchema.optional(),
@@ -124,8 +139,7 @@ const configFileSchema = Joi.object({
124
139
  host: Joi.string().optional(),
125
140
  ssl: sslSchema.optional(),
126
141
  prefix: Joi.bool().optional(),
127
- configuration: configurationSchema.required(),
128
- useNonOverlappingPorts: Joi.bool().forbidden()
142
+ configuration: configurationSchema.required()
129
143
  });
130
144
 
131
145
  /**
@@ -4,8 +4,8 @@
4
4
  * @param {{path: string, value: string}[]} values
5
5
  * @param {import('../../typings/context').ListrContext} param1
6
6
  */
7
- const updateTableValues = async (table, values, { mysqlConnection, task }) => {
8
- const [rows] = await mysqlConnection.query(`
7
+ const updateTableValues = async (table, values, { databaseConnection, task }) => {
8
+ const [rows] = await databaseConnection.query(`
9
9
  SELECT * FROM ${table}
10
10
  WHERE ${values.map((p) => `path = '${p.path}'`).join(' OR ')};
11
11
  `);
@@ -13,7 +13,7 @@ const updateTableValues = async (table, values, { mysqlConnection, task }) => {
13
13
  if (rows.filter(Boolean).length !== values.length) {
14
14
  const lostConfigs = values.filter((p) => !rows.some((row) => row.path === p.path));
15
15
  for (const config of lostConfigs) {
16
- await mysqlConnection.query(`
16
+ await databaseConnection.query(`
17
17
  INSERT INTO ${table}
18
18
  (scope, path, value)
19
19
  VALUES ('default', ?, ?);
@@ -22,7 +22,7 @@ const updateTableValues = async (table, values, { mysqlConnection, task }) => {
22
22
 
23
23
  const configsToUpdate = values.filter((p) => rows.some((row) => row.path === p.path));
24
24
  for (const config of configsToUpdate) {
25
- await mysqlConnection.query(`
25
+ await databaseConnection.query(`
26
26
  UPDATE ${table}
27
27
  SET value = ?
28
28
  WHERE path = ?;
@@ -50,7 +50,7 @@ const updateTableValues = async (table, values, { mysqlConnection, task }) => {
50
50
  });
51
51
 
52
52
  for (const config of configsToUpdate) {
53
- await mysqlConnection.query(`
53
+ await databaseConnection.query(`
54
54
  UPDATE ${table}
55
55
  SET value = ?
56
56
  WHERE path = ?;
@@ -63,11 +63,11 @@ const updateTableValues = async (table, values, { mysqlConnection, task }) => {
63
63
  * @param {String} tableName
64
64
  * @param {import('../../typings/context').ListrContext} param2
65
65
  */
66
- const isTableExists = async (database, tableName, { mysqlConnection }) => {
66
+ const isTableExists = async (database, tableName, { databaseConnection }) => {
67
67
  /**
68
68
  * @type {{ tableCount: number }[][]}
69
69
  */
70
- const [[{ tableCount }]] = await mysqlConnection.query(`
70
+ const [[{ tableCount }]] = await databaseConnection.query(`
71
71
  SELECT count(*) as tableCount
72
72
  FROM information_schema.TABLES
73
73
  WHERE (TABLE_SCHEMA = ?) AND (TABLE_NAME = ?);
@@ -22,7 +22,7 @@ const getPrefix = (fName = folderName) => {
22
22
  }
23
23
 
24
24
  if (projectInGlobalConfig && projectInGlobalConfig.prefix) {
25
- return `${fName}.${projectInGlobalConfig.prefix}`;
25
+ return `${fName}-${projectInGlobalConfig.prefix}`;
26
26
  }
27
27
 
28
28
  return fName;
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "Scripts and configuration used by CMA.",
4
4
  "homepage": "https://docs.create-magento-app.com/",
5
5
  "repository": "github:scandipwa/create-magento-app",
6
- "version": "2.0.0-alpha.0",
6
+ "version": "2.0.0-alpha.3",
7
7
  "main": "./index.js",
8
8
  "types": "./typings/index.d.ts",
9
9
  "license": "OSL-3.0",
@@ -53,5 +53,5 @@
53
53
  "mysql",
54
54
  "scandipwa"
55
55
  ],
56
- "gitHead": "a63454a3015891e4ebe5a7e84a0c88989a1d0edc"
56
+ "gitHead": "b98906089cdc84e062599bdb06cfd121a8004541"
57
57
  }