@scandipwa/magento-scripts 1.15.6 → 1.15.7

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 (34) hide show
  1. package/lib/config/dependencies-for-platforms.js +19 -4
  2. package/lib/config/php-config.js +2 -2
  3. package/lib/config/templates/ssl-terminator.template.conf +6 -0
  4. package/lib/tasks/file-system/create-ssl-terminator-config.js +3 -3
  5. package/lib/tasks/import-dump.js +13 -5
  6. package/lib/tasks/magento/index.js +1 -1
  7. package/lib/tasks/magento/{install-magento.js → install-magento-project.js} +5 -4
  8. package/lib/tasks/magento/setup-magento/adjust-full-page-cache.js +1 -1
  9. package/lib/tasks/magento/setup-magento/configure-elasticsearch.js +1 -1
  10. package/lib/tasks/magento/setup-magento/create-admin.js +1 -1
  11. package/lib/tasks/magento/setup-magento/disable-2fa.js +1 -1
  12. package/lib/tasks/magento/setup-magento/disable-maintenance-mode.js +1 -1
  13. package/lib/tasks/magento/setup-magento/disable-page-builder.js +1 -1
  14. package/lib/tasks/magento/setup-magento/flush-redis-config.js +1 -1
  15. package/lib/tasks/magento/setup-magento/increase-admin-session-lifetime.js +1 -1
  16. package/lib/tasks/magento/setup-magento/index-products.js +1 -1
  17. package/lib/tasks/magento/setup-magento/index.js +3 -1
  18. package/lib/tasks/magento/setup-magento/install-magento.js +4 -2
  19. package/lib/tasks/magento/setup-magento/migrate-database.js +20 -10
  20. package/lib/tasks/magento/setup-magento/set-base-url.js +1 -1
  21. package/lib/tasks/magento/setup-magento/set-deployment-mode.js +1 -1
  22. package/lib/tasks/magento/setup-magento/set-url-rewrite.js +1 -3
  23. package/lib/tasks/magento/setup-magento/upgrade-magento.js +1 -1
  24. package/lib/tasks/magento/setup-magento/urn-highlighter.js +4 -4
  25. package/lib/tasks/magento/setup-magento/varnish-config.js +1 -2
  26. package/lib/tasks/magento/setup-magento/waiting-for-redis.js +1 -1
  27. package/lib/tasks/magento/setup-magento/waiting-for-varnish.js +1 -1
  28. package/lib/tasks/php/bundled-extensions.js +0 -1
  29. package/lib/tasks/php/update-env-php.js +1 -1
  30. package/lib/tasks/requirements/dependency/mac.js +102 -25
  31. package/lib/tasks/requirements/phpbrew/install.js +4 -74
  32. package/lib/tasks/start.js +2 -2
  33. package/lib/util/install-dependencies-task.js +4 -6
  34. package/package.json +2 -2
@@ -20,6 +20,16 @@ const dependenciesForPlatforms = {
20
20
  installCommand: (deps, { native } = { native: false }) => `${getBrewCommandSync({ native })} install ${deps}`,
21
21
  packageManager: 'brew'
22
22
  },
23
+ 'darwin-arm': {
24
+ dependencies: [
25
+ 'php',
26
+ 'autoconf',
27
+ 'pkg-config',
28
+ 'gd'
29
+ ],
30
+ installCommand: (deps, { native } = { native: false }) => `${getBrewCommandSync({ native })} install ${deps}`,
31
+ packageManager: 'brew'
32
+ },
23
33
  'Arch Linux': {
24
34
  dependencies: [
25
35
  'freetype2',
@@ -36,7 +46,9 @@ const dependenciesForPlatforms = {
36
46
  'sqlite',
37
47
  'readline',
38
48
  'perl',
39
- 'libsodium'
49
+ 'libsodium',
50
+ 'php',
51
+ 'pkgconf'
40
52
  ],
41
53
  installCommand: (deps) => `sudo pacman -S ${deps} --noconfirm`,
42
54
  packageManager: 'pacman'
@@ -58,7 +70,8 @@ const dependenciesForPlatforms = {
58
70
  'bzip2-devel',
59
71
  'curl-devel',
60
72
  'libxslt-devel',
61
- 'autoconf'
73
+ 'autoconf',
74
+ 'php'
62
75
  ],
63
76
  installCommand: (deps) => `sudo yum install ${deps} -y`,
64
77
  packageManager: 'yum'
@@ -80,7 +93,8 @@ const dependenciesForPlatforms = {
80
93
  'bzip2-devel',
81
94
  'curl-devel',
82
95
  'libxslt-devel',
83
- 'autoconf'
96
+ 'autoconf',
97
+ 'php'
84
98
  ],
85
99
  installCommand: (deps) => `sudo yum install --enablerepo=PowerTools ${deps} -y`,
86
100
  packageManager: 'yum'
@@ -109,7 +123,8 @@ const dependenciesForPlatforms = {
109
123
  'php-bz2',
110
124
  'pkg-config',
111
125
  'autoconf',
112
- 'cmake'
126
+ 'cmake',
127
+ 'php'
113
128
  ],
114
129
  installCommand: (deps) => `sudo apt install ${deps} -y`,
115
130
  packageManager: 'apt'
@@ -17,8 +17,8 @@ module.exports = (app, config) => {
17
17
  binPath: path.join(phpVersionDir, 'bin', 'php'),
18
18
  iniPath: path.join(cacheDir, 'php.ini'),
19
19
  iniTemplatePath: php.configTemplate,
20
- fpmBinPath: path.resolve(phpVersionDir, 'sbin', 'php-fpm'),
21
- fpmConfPath: path.resolve(cacheDir, 'php-fpm.conf'),
20
+ fpmBinPath: path.join(phpVersionDir, 'sbin', 'php-fpm'),
21
+ fpmConfPath: path.join(cacheDir, 'php-fpm.conf'),
22
22
  fpmPidFilePath: path.join(cacheDir, 'php-fpm.pid'),
23
23
  extensions: php.extensions,
24
24
  version: php.version
@@ -21,6 +21,12 @@ server {
21
21
  proxy_set_header X-Real-IP $remote_addr;
22
22
  proxy_set_header X-Forwarded-For $remote_addr;
23
23
  proxy_set_header Host $http_host;
24
+ proxy_http_version 1.1;
25
+ proxy_set_header Connection "";
26
+ proxy_connect_timeout 300;
27
+ proxy_send_timeout 300;
28
+ proxy_read_timeout 300;
29
+ send_timeout 300;
24
30
 
25
31
  proxy_pass http://<%= it.hostMachine %>:<% if (it.config.configuration.varnish.enabled) { %><%= it.ports.varnish %><% } else { %><%= it.ports.app %><% } %>;
26
32
  }
@@ -38,9 +38,9 @@ const createSSLTerminatorConfig = () => ({
38
38
  throw new KnownError('ssl.ssl_certificate_key file does not exist!');
39
39
  }
40
40
 
41
- const nginxCacheDir = path.join(baseConfig.cacheDir, 'nginx', 'conf.d');
42
- if (!await pathExists(nginxCacheDir)) {
43
- await fs.promises.mkdir(nginxCacheDir, { recursive: true });
41
+ const sslTerminatorCacheDir = path.join(baseConfig.cacheDir, 'ssl-terminator', 'conf.d');
42
+ if (!await pathExists(sslTerminatorCacheDir)) {
43
+ await fs.promises.mkdir(sslTerminatorCacheDir, { recursive: true });
44
44
  }
45
45
 
46
46
  await fs.promises.copyFile(
@@ -31,12 +31,20 @@ const importDump = () => ({
31
31
  configureProject(),
32
32
  {
33
33
  title: 'Installing Magento',
34
- // skip setup if env.php and config.php are present in app/etc folder
35
- skip: () => matchFilesystem(path.resolve('app/etc'), ['config.php', 'env.php']),
34
+ // skip setup if env.php and config.php are present in app/etc folder and db is not empty
35
+ skip: async (ctx) => {
36
+ const isFsMatching = await matchFilesystem(path.join(process.cwd(), 'app', 'etc'), ['config.php', 'env.php']);
37
+ const { mysqlConnection } = ctx;
38
+ const [[{ tableCount }]] = await mysqlConnection.query(`
39
+ SELECT count(*) AS tableCount
40
+ FROM INFORMATION_SCHEMA.TABLES
41
+ WHERE TABLE_SCHEMA = 'magento';
42
+ `);
43
+
44
+ return tableCount !== 0 || !isFsMatching;
45
+ },
36
46
  task: (subCtx, subTask) => subTask.newListr(
37
- setupMagento({
38
- onlyInstallMagento: true
39
- })
47
+ setupMagento({ onlyInstallMagento: true })
40
48
  )
41
49
  },
42
50
  dumpThemeConfig(),
@@ -1,5 +1,5 @@
1
1
  module.exports = {
2
- installMagento: require('./install-magento'),
2
+ installMagentoProject: require('./install-magento-project'),
3
3
  setupMagento: require('./setup-magento'),
4
4
  uninstallMagento: require('./uninstall-magento'),
5
5
  removeMagento: require('./remove-magento')
@@ -8,6 +8,7 @@ const getJsonFileData = require('../../util/get-jsonfile-data');
8
8
  const rmdirSafe = require('../../util/rmdir-safe');
9
9
  const KnownError = require('../../errors/known-error');
10
10
  const UnknownError = require('../../errors/unknown-error');
11
+ const logger = require('@scandipwa/scandipwa-dev-utils/logger');
11
12
 
12
13
  const magentoProductEnterpriseEdition = 'magento/product-enterprise-edition';
13
14
  const magentoProductCommunityEdition = 'magento/product-community-edition';
@@ -124,9 +125,9 @@ const createMagentoProject = async ({
124
125
  };
125
126
 
126
127
  /**
127
- * @type {() => import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
128
+ * @returns {import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
128
129
  */
129
- const installMagento = () => ({
130
+ const installMagentoProject = () => ({
130
131
  title: 'Installing Magento',
131
132
  task: async (ctx, task) => {
132
133
  const { magentoVersion, config: { baseConfig, overridenConfiguration }, verbose } = ctx;
@@ -190,7 +191,7 @@ const installMagento = () => ({
190
191
  } catch (e) {
191
192
  if (e.message.includes('man-in-the-middle attack')) {
192
193
  throw new KnownError(`Probably you haven't setup pubkeys in composer.
193
- Please run composer diagnose in cli to get mode.\n\n${e}`);
194
+ Please run ${logger.style.command('composer diagnose')} in cli to get mode.\n\n${e}`);
194
195
  }
195
196
 
196
197
  throw new UnknownError(`Unexpected error during composer install.\n\n${e}`);
@@ -202,4 +203,4 @@ Please run composer diagnose in cli to get mode.\n\n${e}`);
202
203
  }
203
204
  });
204
205
 
205
- module.exports = installMagento;
206
+ module.exports = installMagentoProject;
@@ -2,7 +2,7 @@ const envPhpToJson = require('../../../util/env-php-json');
2
2
  const magentoTask = require('../../../util/magento-task');
3
3
 
4
4
  /**
5
- * @type {() => import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
5
+ * @returns {import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
6
6
  */
7
7
  const disableFullPageCache = () => ({
8
8
  title: 'Adjusting full_page cache setting',
@@ -1,7 +1,7 @@
1
1
  const { updateTableValues, isTableExists } = require('../../../util/database');
2
2
 
3
3
  /**
4
- * @type {() => import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
4
+ * @returns {import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
5
5
  */
6
6
  module.exports = () => ({
7
7
  title: 'Configuring Elasticsearch',
@@ -1,7 +1,7 @@
1
1
  const runMagentoCommand = require('../../../util/run-magento');
2
2
 
3
3
  /**
4
- * @type {() => import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
4
+ * @returns {import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
5
5
  */
6
6
  module.exports = () => ({
7
7
  title: 'Creating admin user',
@@ -2,7 +2,7 @@ const configPhpToJson = require('../../../util/config-php-json');
2
2
  const runMagentoCommand = require('../../../util/run-magento');
3
3
 
4
4
  /**
5
- * @type {() => import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
5
+ * @returns {import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
6
6
  */
7
7
  module.exports = () => ({
8
8
  title: 'Disabling 2fa for admin',
@@ -1,7 +1,7 @@
1
1
  const runMagentoCommand = require('../../../util/run-magento');
2
2
 
3
3
  /**
4
- * @type {() => import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
4
+ * @returns {import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
5
5
  */
6
6
  const disableMaintenanceMode = () => ({
7
7
  title: 'Disabling maintenance mode',
@@ -1,7 +1,7 @@
1
1
  const magentoTask = require('../../../util/magento-task');
2
2
 
3
3
  /**
4
- * @type {() => import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
4
+ * @returns {import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
5
5
  */
6
6
  const disablePageBuilder = () => ({
7
7
  title: 'Disabling page builder in Magento',
@@ -5,7 +5,7 @@ const UnknownError = require('../../../errors/unknown-error');
5
5
  const isLinux = os.platform() === 'linux';
6
6
 
7
7
  /**
8
- * @type {() => import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
8
+ * @returns {import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
9
9
  */
10
10
  module.exports = () => ({
11
11
  title: 'Flushing Magento redis cache',
@@ -1,7 +1,7 @@
1
1
  const { updateTableValues } = require('../../../util/database');
2
2
 
3
3
  /**
4
- * @type {() => import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
4
+ * @returns {import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
5
5
  */
6
6
  const increaseAdminSessionLifetime = () => ({
7
7
  title: 'Increase admin session lifetime to 1 month',
@@ -1,7 +1,7 @@
1
1
  const magentoTask = require('../../../util/magento-task');
2
2
 
3
3
  /**
4
- * @type {() => import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
4
+ * @returns {import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
5
5
  */
6
6
  const indexProducts = () => ({
7
7
  task: (ctx, task) => task.newListr(
@@ -14,7 +14,9 @@ const urnHighlighter = require('./urn-highlighter');
14
14
  const waitingForVarnish = require('./waiting-for-varnish');
15
15
 
16
16
  /**
17
- * @type {({ onlyInstallMagento: boolean }) => import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
17
+ * @param {Object} [options]
18
+ * @param {Boolean} options.onlyInstallMagento
19
+ * @returns {import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
18
20
  */
19
21
  const setupMagento = (options = {}) => ({
20
22
  title: 'Setting up Magento',
@@ -7,7 +7,9 @@ const envPhpToJson = require('../../../util/env-php-json');
7
7
  const logger = require('@scandipwa/scandipwa-dev-utils/logger');
8
8
 
9
9
  /**
10
- * @type {({ isDbEmpty }: { isDbEmpty: boolean }) => import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
10
+ * @param {Object} [param0]
11
+ * @param {Boolean} param0.isDbEmpty
12
+ * @returns {import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
11
13
  */
12
14
  const installMagento = ({ isDbEmpty = false } = {}) => ({
13
15
  title: 'Installing magento',
@@ -82,7 +84,7 @@ const installMagento = ({ isDbEmpty = false } = {}) => ({
82
84
  --db-user='${ env.MYSQL_USER }' \
83
85
  --db-password='${ env.MYSQL_PASSWORD }' \
84
86
  --backend-frontname='${ magentoConfiguration.adminuri }' \
85
- --no-interaction ${ tries > 0 ? '--cleanup-database' : '' }`;
87
+ --no-interaction`;
86
88
 
87
89
  await runMagentoCommand(command, {
88
90
  magentoVersion,
@@ -1,12 +1,17 @@
1
+ const path = require('path');
2
+ const installMagentoProject = require('../install-magento-project');
1
3
  const magentoTask = require('../../../util/magento-task');
2
4
  const runMagentoCommand = require('../../../util/run-magento');
3
5
  const configureElasticsearch = require('./configure-elasticsearch');
4
6
  const installMagento = require('./install-magento');
5
7
  const upgradeMagento = require('./upgrade-magento');
6
8
  const varnishConfigSetup = require('./varnish-config');
9
+ const pathExists = require('../../../util/path-exists');
7
10
 
8
11
  /**
9
- * @type {({ onlyInstallMagento: boolean }) => import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
12
+ * @param {Object} [options]
13
+ * @param {Boolean} options.onlyInstallMagento
14
+ * @returns {import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
10
15
  */
11
16
  const migrateDatabase = (options = {}) => ({
12
17
  title: 'Migrating database',
@@ -22,7 +27,11 @@ const migrateDatabase = (options = {}) => ({
22
27
  WHERE TABLE_SCHEMA = 'magento';
23
28
  `);
24
29
 
25
- if (tableCount === 0) {
30
+ if (
31
+ tableCount === 0
32
+ || !(await pathExists(path.join(process.cwd(), 'app', 'etc', 'env.php'))
33
+ || (!await pathExists(path.join(process.cwd(), 'app', 'etc', 'config.php'))))
34
+ ) {
26
35
  if (options.onlyInstallMagento) {
27
36
  ctx.isSetupUpgradeNeeded = false;
28
37
  return task.newListr(
@@ -32,10 +41,10 @@ const migrateDatabase = (options = {}) => ({
32
41
 
33
42
  return task.newListr([
34
43
  installMagento({ isDbEmpty: true }),
35
- upgradeMagento(),
36
- magentoTask('cache:enable'),
37
44
  varnishConfigSetup(),
38
- configureElasticsearch()
45
+ configureElasticsearch(),
46
+ upgradeMagento(),
47
+ magentoTask('cache:enable')
39
48
  ], {
40
49
  concurrent: false,
41
50
  exitOnError: true,
@@ -45,6 +54,7 @@ const migrateDatabase = (options = {}) => ({
45
54
  }
46
55
  });
47
56
  }
57
+
48
58
  const { code } = await runMagentoCommand('setup:db:status', {
49
59
  magentoVersion,
50
60
  throwNonZeroCode: false
@@ -70,16 +80,16 @@ const migrateDatabase = (options = {}) => ({
70
80
  if (options.onlyInstallMagento) {
71
81
  ctx.isSetupUpgradeNeeded = false;
72
82
  return task.newListr(
73
- installMagento()
83
+ installMagentoProject()
74
84
  );
75
85
  }
76
86
 
77
87
  return task.newListr([
78
- installMagento(),
79
- upgradeMagento(),
80
- magentoTask('cache:enable'),
88
+ installMagentoProject(),
81
89
  varnishConfigSetup(),
82
- configureElasticsearch()
90
+ configureElasticsearch(),
91
+ upgradeMagento(),
92
+ magentoTask('cache:enable')
83
93
  ], {
84
94
  concurrent: false,
85
95
  exitOnError: true,
@@ -1,7 +1,7 @@
1
1
  const { updateTableValues } = require('../../../util/database');
2
2
 
3
3
  /**
4
- * @type {() => import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
4
+ * @returns {import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
5
5
  */
6
6
  module.exports = () => ({
7
7
  title: 'Setting baseurl and secure baseurl',
@@ -2,7 +2,7 @@ const magentoTask = require('../../../util/magento-task');
2
2
  const runMagentoCommand = require('../../../util/run-magento');
3
3
 
4
4
  /**
5
- * @type {() => import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
5
+ * @returns {import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
6
6
  */
7
7
  module.exports = () => ({
8
8
  title: 'Switching Magento mode',
@@ -1,9 +1,7 @@
1
- // const runMagentoCommand = require('../../../util/run-magento');
2
-
3
1
  const { updateTableValues } = require('../../../util/database');
4
2
 
5
3
  /**
6
- * @type {() => import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
4
+ * @returns {import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
7
5
  */
8
6
  const setUrlRewrite = () => ({
9
7
  title: 'Setting up url-rewrites',
@@ -3,7 +3,7 @@ const logger = require('@scandipwa/scandipwa-dev-utils/logger');
3
3
  const KnownError = require('../../../errors/known-error');
4
4
 
5
5
  /**
6
- * @type {() => import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
6
+ * @returns {import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
7
7
  */
8
8
  const upgradeMagento = () => ({
9
9
  skip: (ctx) => {
@@ -4,18 +4,18 @@ const magentoTask = require('../../../util/magento-task');
4
4
  const pathExists = require('../../../util/path-exists');
5
5
 
6
6
  /**
7
- * @type {() => import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
7
+ * @returns {import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
8
8
  *
9
9
  * @reference https://devdocs.magento.com/guides/v2.4/config-guide/cli/config-cli-subcommands-urn.html
10
10
  */
11
11
  const urnHighlighter = () => ({
12
12
  title: 'Generating URN highlighter',
13
13
  task: async (ctx, task) => {
14
- if (!await pathExists(path.resolve('./.idea'))) {
15
- await fs.promises.mkdir(path.resolve('./.idea'));
14
+ if (!await pathExists(path.join(process.cwd(), './.idea'))) {
15
+ await fs.promises.mkdir(path.join(process.cwd(), './.idea'));
16
16
  }
17
17
 
18
- if (await pathExists(path.resolve('./.idea/misc.xml'))) {
18
+ if (await pathExists(path.join(process.cwd(), './.idea/misc.xml'))) {
19
19
  task.skip();
20
20
  return;
21
21
  }
@@ -3,7 +3,7 @@ const { updateTableValues } = require('../../../util/database');
3
3
  const getIsWsl = require('../../../util/is-wsl');
4
4
 
5
5
  /**
6
- * @type {() => import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
6
+ * @returns {import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
7
7
  */
8
8
  const varnishConfigSetup = () => ({
9
9
  title: 'Varnish setup',
@@ -24,7 +24,6 @@ const varnishConfigSetup = () => ({
24
24
 
25
25
  const isLinux = os.platform() === 'linux';
26
26
  const isWsl = await getIsWsl();
27
- // const host = (isLinux && !isWsl) ? 'localhost' : 'host.docker.internal';
28
27
 
29
28
  if (varnishEnabled) {
30
29
  await updateTableValues('core_config_data', [
@@ -1,7 +1,7 @@
1
1
  const waitForIt = require('../../../util/wait-for-it');
2
2
 
3
3
  /**
4
- * @type {() => import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
4
+ * @returns {import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
5
5
  */
6
6
  module.exports = () => ({
7
7
  title: 'Waiting for Redis',
@@ -3,7 +3,7 @@ const KnownError = require('../../../errors/known-error');
3
3
  const sleep = require('../../../util/sleep');
4
4
 
5
5
  /**
6
- * @type {() => import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
6
+ * @returns {import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
7
7
  */
8
8
  const waitingForVarnish = () => ({
9
9
  title: 'Waiting for Varnish to return code 200',
@@ -16,7 +16,6 @@ const bundledExtensions = [
16
16
  'mysql',
17
17
  'pdo',
18
18
  'soap',
19
- 'xmlrpc',
20
19
  'xml',
21
20
  'zip',
22
21
  'fpm',
@@ -9,7 +9,7 @@ const updateEnvPHP = () => ({
9
9
  title: 'Updating env.php',
10
10
  task: async (ctx, task) => {
11
11
  // update env.php only if it's exist
12
- if (!await pathExists(path.resolve('app', 'etc', 'env.php'))) {
12
+ if (!await pathExists(path.join(process.cwd(), 'app', 'etc', 'env.php'))) {
13
13
  task.skip();
14
14
  return;
15
15
  }
@@ -1,43 +1,120 @@
1
- const logger = require('@scandipwa/scandipwa-dev-utils/logger');
2
1
  const dependenciesForPlatforms = require('../../../config/dependencies-for-platforms');
3
- const KnownError = require('../../../errors/known-error');
4
- const { execAsyncSpawn } = require('../../../util/exec-async-command');
2
+ const { execAsyncSpawn, execCommandTask } = require('../../../util/exec-async-command');
5
3
  const {
6
4
  BREW_BIN_PATH_ARM_NATIVE,
7
5
  BREW_BIN_PATH_ARM_ROSETTA,
6
+ BREW_BIN_PATH_INTEL,
8
7
  getBrewCommand
9
8
  } = require('../../../util/get-brew-bin-path');
10
9
  const installDependenciesTask = require('../../../util/install-dependencies-task');
11
10
  const pathExists = require('../../../util/path-exists');
11
+
12
+ const brewInstallCommand = '$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)';
13
+
14
+ /**
15
+ * @returns {import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
16
+ */
17
+ const installBrewRosettaTask = () => ({
18
+ title: 'Installing Brew using Rosetta 2',
19
+ task: async (ctx, task) => {
20
+ if (await pathExists(BREW_BIN_PATH_ARM_ROSETTA)) {
21
+ task.skip('Brew in Rosetta is already installed');
22
+ return;
23
+ }
24
+
25
+ return task.newListr(
26
+ execCommandTask(brewInstallCommand, {
27
+ useRosetta2: true
28
+ })
29
+ );
30
+ }
31
+ });
32
+
33
+ /**
34
+ * @returns {import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
35
+ */
36
+ const installBrewNativeTask = () => ({
37
+ title: 'Installing Brew',
38
+ task: async (ctx, task) => {
39
+ if (
40
+ (ctx.arch === 'arm64' && await pathExists(BREW_BIN_PATH_ARM_NATIVE))
41
+ || (ctx.arch === 'x64' && await pathExists(BREW_BIN_PATH_INTEL))
42
+ ) {
43
+ task.skip('Brew in native path is already installed');
44
+ return;
45
+ }
46
+
47
+ return task.newListr(
48
+ execCommandTask(brewInstallCommand, {
49
+ useRosetta2: false
50
+ })
51
+ );
52
+ }
53
+ });
54
+
12
55
  /**
13
- * @type {() => import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
56
+ * @returns {import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
14
57
  */
15
58
  const macDependenciesCheck = () => ({
16
59
  title: 'Checking MacOS dependencies',
17
60
  task: async (ctx, task) => {
61
+ const tasks = [installBrewNativeTask()];
62
+
18
63
  if (ctx.arch === 'arm64') {
19
- if (!await pathExists(BREW_BIN_PATH_ARM_ROSETTA) && await pathExists(BREW_BIN_PATH_ARM_NATIVE)) {
20
- throw new KnownError(`Missing rosetta brew!
21
- Please make sure that you have installed brew in rosetta2 terminal!
22
- Follow the instructions: ${logger.style.link('https://docs.create-magento-app.com/getting-started/prerequisites/installation-on-macos/installation-on-macos-apple-silicon')}`);
23
- }
24
- }
25
- const installedDependencies = (await execAsyncSpawn(`${await getBrewCommand()} list`)).split('\n');
26
-
27
- const dependenciesToInstall = dependenciesForPlatforms
28
- .darwin
29
- .dependencies
30
- .filter((dep) => !installedDependencies.includes(dep));
31
-
32
- if (dependenciesToInstall.length > 0) {
33
- return task.newListr(
34
- installDependenciesTask({
35
- platform: 'darwin',
36
- dependenciesToInstall,
37
- useMacNativeEnvironment: false
38
- })
39
- );
64
+ tasks.push(installBrewRosettaTask());
40
65
  }
66
+
67
+ return task.newListr(
68
+ tasks.concat([
69
+ {
70
+ task: async () => {
71
+ const installDependenciesTasks = [];
72
+ if (ctx.arch === 'arm64') {
73
+ const installedNativeDependencies = (
74
+ await execAsyncSpawn(`${await getBrewCommand({ native: true })} list`, { useRosetta2: false })
75
+ ).split('\n');
76
+ const dependenciesToInstallOnArm = dependenciesForPlatforms['darwin-arm']
77
+ .dependencies
78
+ .filter((dep) => !installedNativeDependencies.includes(dep));
79
+
80
+ if (dependenciesToInstallOnArm.length > 0) {
81
+ installDependenciesTasks.push(
82
+ installDependenciesTask({
83
+ platform: 'darwin-arm',
84
+ dependenciesToInstall: dependenciesToInstallOnArm,
85
+ useMacNativeEnvironment: true
86
+ })
87
+ );
88
+ }
89
+ }
90
+
91
+ const installedDependencies = (
92
+ await execAsyncSpawn(`${await getBrewCommand({ native: false })} list`, { useRosetta2: true })
93
+ ).split('\n');
94
+ const dependenciesToInstall = dependenciesForPlatforms
95
+ .darwin
96
+ .dependencies
97
+ .filter((dep) => !installedDependencies.includes(dep));
98
+
99
+ if (dependenciesToInstall.length > 0) {
100
+ installDependenciesTasks.push(
101
+ installDependenciesTask({
102
+ platform: 'darwin',
103
+ dependenciesToInstall,
104
+ useMacNativeEnvironment: false
105
+ })
106
+ );
107
+ }
108
+
109
+ if (installDependenciesTasks.length > 0) {
110
+ return task.newListr(installDependenciesTasks);
111
+ }
112
+
113
+ task.skip();
114
+ }
115
+ }
116
+ ])
117
+ );
41
118
  },
42
119
  options: {
43
120
  bottomBar: 10
@@ -3,78 +3,10 @@ const path = require('path');
3
3
  const fs = require('fs');
4
4
  const { execAsyncSpawn } = require('../../../util/exec-async-command');
5
5
  const logger = require('@scandipwa/scandipwa-dev-utils/logger');
6
- const installDependenciesTask = require('../../../util/install-dependencies-task');
7
- const osPlatform = require('../../../util/os-platform');
8
6
  const KnownError = require('../../../errors/known-error');
9
- const { getBrewCommand } = require('../../../util/get-brew-bin-path');
10
7
 
11
8
  /**
12
- * @type {() => import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
13
- */
14
- const installPHPBrewDependencies = () => ({
15
- title: 'Installing PHPBrew dependencies',
16
- task: async (ctx, task) => {
17
- if (process.platform === 'darwin') {
18
- const installedDependencies = (await execAsyncSpawn(`${await getBrewCommand({ native: true })} list`)).split('\n');
19
-
20
- const dependenciesToInstall = ['php', 'autoconf', 'pkg-config', 'gd'].filter((dep) => !installedDependencies.includes(dep));
21
-
22
- if (dependenciesToInstall.length === 0) {
23
- task.skip();
24
- return;
25
- }
26
-
27
- return task.newListr(
28
- installDependenciesTask({
29
- platform: 'darwin',
30
- dependenciesToInstall,
31
- useMacNativeEnvironment: true
32
- })
33
- );
34
- }
35
- const distro = await osPlatform();
36
- switch (distro) {
37
- case 'Arch Linux': {
38
- return task.newListr(
39
- installDependenciesTask({
40
- platform: 'Arch Linux',
41
- dependenciesToInstall: ['php', 'pkg-config']
42
- })
43
- );
44
- }
45
- case 'Fedora': {
46
- return task.newListr(
47
- installDependenciesTask({
48
- platform: 'Fedora',
49
- dependenciesToInstall: ['php']
50
- })
51
- );
52
- }
53
- case 'CentOS': {
54
- return task.newListr(
55
- installDependenciesTask({
56
- platform: 'CentOS',
57
- dependenciesToInstall: ['php']
58
- })
59
- );
60
- }
61
- case 'Ubuntu': {
62
- return task.newListr(
63
- installDependenciesTask({
64
- platform: 'Ubuntu',
65
- dependenciesToInstall: ['php']
66
- })
67
- );
68
- }
69
- default: {
70
- task.skip();
71
- }
72
- }
73
- }
74
- });
75
-
76
- /**
77
- * @type {() => import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
9
+ * @returns {import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
78
10
  */
79
11
  const installXcode = () => ({
80
12
  title: 'Installing XCode',
@@ -105,7 +37,7 @@ const installXcode = () => ({
105
37
  });
106
38
 
107
39
  /**
108
- * @type {() => import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
40
+ * @returns {import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
109
41
  */
110
42
  const installPHPBrewBinary = () => ({
111
43
  title: 'Installing PHPBrew binary',
@@ -138,7 +70,7 @@ const installPHPBrewBinary = () => ({
138
70
  });
139
71
 
140
72
  /**
141
- * @type {() => import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
73
+ * @returns {import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
142
74
  */
143
75
  const addPHPBrewInitiatorLineToConfigFile = () => ({
144
76
  task: async (ctx, task) => {
@@ -188,7 +120,7 @@ Then you can continue installation.`);
188
120
  });
189
121
 
190
122
  /**
191
- * @type {() => import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
123
+ * @returns {import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
192
124
  */
193
125
  const installPHPBrew = () => ({
194
126
  title: 'Installing PHPBrew',
@@ -196,14 +128,12 @@ const installPHPBrew = () => ({
196
128
  if (process.platform === 'darwin') {
197
129
  return task.newListr([
198
130
  installXcode(),
199
- installPHPBrewDependencies(),
200
131
  installPHPBrewBinary(),
201
132
  addPHPBrewInitiatorLineToConfigFile()
202
133
  ]);
203
134
  }
204
135
 
205
136
  return task.newListr([
206
- installPHPBrewDependencies(),
207
137
  installPHPBrewBinary(),
208
138
  addPHPBrewInitiatorLineToConfigFile()
209
139
  ]);
@@ -10,7 +10,7 @@ const { checkRequirements } = require('./requirements');
10
10
  const { createCacheFolder } = require('./cache');
11
11
  const { startPhpFpm, stopPhpFpm } = require('./php-fpm');
12
12
  const { prepareFileSystem } = require('./file-system');
13
- const { installMagento, setupMagento } = require('./magento');
13
+ const { installMagentoProject, setupMagento } = require('./magento');
14
14
  const { pullContainers, stopContainers } = require('./docker/containers');
15
15
  const { setPrefix } = require('./prefix');
16
16
  const {
@@ -118,7 +118,7 @@ const configureProject = () => ({
118
118
  configurePhp(),
119
119
  validatePHPInstallation(),
120
120
  installPrestissimo(),
121
- installMagento(),
121
+ installMagentoProject(),
122
122
  enableMagentoComposerPlugins(),
123
123
  startServices(),
124
124
  startPhpFpm(),
@@ -14,16 +14,14 @@ const KnownError = require('../errors/known-error');
14
14
  * @returns {import('listr2').ListrTask<import('../../typings/context').ListrContext>}
15
15
  */
16
16
  const installDependenciesTask = (options) => ({
17
- title: 'Installing missing dependencies',
18
17
  task: async (ctx, task) => {
19
18
  const { dependenciesToInstall, platform } = options;
19
+ task.title = `Installing ${platform} dependencies`;
20
20
  let cmd;
21
21
  if (os.platform() === 'darwin') {
22
- if (options.useMacNativeEnvironment) {
23
- cmd = dependenciesForPlatforms[platform].installCommand(dependenciesToInstall.join(' '), { native: true });
24
- } else {
25
- cmd = dependenciesForPlatforms[platform].installCommand(dependenciesToInstall.join(' '));
26
- }
22
+ cmd = dependenciesForPlatforms[platform].installCommand(dependenciesToInstall.join(' '), {
23
+ native: options.useMacNativeEnvironment
24
+ });
27
25
  } else {
28
26
  cmd = dependenciesForPlatforms[platform].installCommand(dependenciesToInstall.join(' '));
29
27
  }
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": "1.15.6",
6
+ "version": "1.15.7",
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": "78f8b8d57032441f7667da0ef98ef6370de2fc7c"
56
+ "gitHead": "f9e7474aca6c1a80ec37f6d51ab2a1a8a61582cc"
57
57
  }