@scandipwa/magento-scripts 1.15.6 → 1.16.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 (84) hide show
  1. package/lib/commands/execute.js +4 -1
  2. package/lib/commands/logs.js +3 -0
  3. package/lib/config/dependencies-for-platforms.js +19 -4
  4. package/lib/config/docker.js +20 -1
  5. package/lib/config/php/extensions/index.js +2 -1
  6. package/lib/config/php/extensions/xdebug.js +9 -0
  7. package/lib/config/php/releases/index.js +6 -0
  8. package/lib/config/php/releases/php-7.2.js +25 -0
  9. package/lib/config/php/releases/php-7.3.js +25 -0
  10. package/lib/config/php/releases/php-7.4.js +23 -0
  11. package/lib/config/php/releases/php-8.1.js +25 -0
  12. package/lib/config/php-config.js +2 -2
  13. package/lib/config/templates/ssl-terminator.template.conf +6 -0
  14. package/lib/config/versions/magento-2.3.0.js +2 -21
  15. package/lib/config/versions/magento-2.3.1.js +2 -21
  16. package/lib/config/versions/magento-2.3.2-p2.js +2 -21
  17. package/lib/config/versions/magento-2.3.2.js +2 -21
  18. package/lib/config/versions/magento-2.3.3-p1.js +2 -21
  19. package/lib/config/versions/magento-2.3.3.js +2 -21
  20. package/lib/config/versions/magento-2.3.4-p2.js +2 -21
  21. package/lib/config/versions/magento-2.3.4.js +2 -21
  22. package/lib/config/versions/magento-2.3.5-p1.js +2 -21
  23. package/lib/config/versions/magento-2.3.5-p2.js +2 -21
  24. package/lib/config/versions/magento-2.3.5.js +2 -21
  25. package/lib/config/versions/magento-2.3.6-p1.js +2 -21
  26. package/lib/config/versions/magento-2.3.6.js +2 -21
  27. package/lib/config/versions/magento-2.3.7-p1.js +2 -19
  28. package/lib/config/versions/magento-2.3.7-p2.js +2 -19
  29. package/lib/config/versions/magento-2.3.7-p3.js +2 -19
  30. package/lib/config/versions/magento-2.3.7.js +2 -19
  31. package/lib/config/versions/magento-2.4.0-p1.js +2 -19
  32. package/lib/config/versions/magento-2.4.0.js +2 -19
  33. package/lib/config/versions/magento-2.4.1-p1.js +6 -19
  34. package/lib/config/versions/magento-2.4.1.js +2 -19
  35. package/lib/config/versions/magento-2.4.2-p1.js +6 -20
  36. package/lib/config/versions/magento-2.4.2-p2.js +6 -19
  37. package/lib/config/versions/magento-2.4.2.js +6 -19
  38. package/lib/config/versions/magento-2.4.3-p1.js +6 -19
  39. package/lib/config/versions/magento-2.4.3-p2.js +6 -19
  40. package/lib/config/versions/magento-2.4.3.js +6 -19
  41. package/lib/config/versions/magento-2.4.4.js +2 -22
  42. package/lib/tasks/composer/install-prestissimo.js +52 -2
  43. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/index.js +1 -3
  44. package/lib/tasks/file-system/create-ssl-terminator-config.js +3 -3
  45. package/lib/tasks/import-dump.js +13 -5
  46. package/lib/tasks/magento/enable-magento-composer-plugins.js +1 -1
  47. package/lib/tasks/magento/index.js +1 -1
  48. package/lib/tasks/magento/{install-magento.js → install-magento-project.js} +5 -4
  49. package/lib/tasks/magento/setup-magento/adjust-full-page-cache.js +13 -9
  50. package/lib/tasks/magento/setup-magento/configure-elasticsearch.js +1 -1
  51. package/lib/tasks/magento/setup-magento/create-admin.js +1 -1
  52. package/lib/tasks/magento/setup-magento/disable-2fa.js +1 -1
  53. package/lib/tasks/magento/setup-magento/disable-maintenance-mode.js +1 -1
  54. package/lib/tasks/magento/setup-magento/disable-page-builder.js +1 -1
  55. package/lib/tasks/magento/setup-magento/flush-redis-config.js +1 -1
  56. package/lib/tasks/magento/setup-magento/increase-admin-session-lifetime.js +1 -1
  57. package/lib/tasks/magento/setup-magento/index-products.js +1 -1
  58. package/lib/tasks/magento/setup-magento/index.js +5 -4
  59. package/lib/tasks/magento/setup-magento/install-magento.js +4 -2
  60. package/lib/tasks/magento/setup-magento/migrate-database.js +25 -10
  61. package/lib/tasks/magento/setup-magento/set-base-url.js +1 -1
  62. package/lib/tasks/magento/setup-magento/set-deployment-mode.js +1 -1
  63. package/lib/tasks/magento/setup-magento/set-url-rewrite.js +1 -3
  64. package/lib/tasks/magento/setup-magento/upgrade-magento.js +1 -1
  65. package/lib/tasks/magento/setup-magento/urn-highlighter.js +4 -4
  66. package/lib/tasks/magento/setup-magento/varnish-config.js +1 -2
  67. package/lib/tasks/magento/setup-magento/waiting-for-redis.js +1 -1
  68. package/lib/tasks/magento/setup-magento/waiting-for-varnish.js +1 -1
  69. package/lib/tasks/php/bundled-extensions.js +0 -1
  70. package/lib/tasks/php/extensions/index.js +3 -5
  71. package/lib/tasks/php/update-env-php.js +34 -2
  72. package/lib/tasks/php/update-env.php +22 -8
  73. package/lib/tasks/requirements/dependency/mac.js +102 -25
  74. package/lib/tasks/requirements/phpbrew/install.js +4 -74
  75. package/lib/tasks/start.js +2 -2
  76. package/lib/tasks/status/index.js +7 -3
  77. package/lib/tasks/theme/link-theme.js +0 -2
  78. package/lib/tasks/theme/setup-themes.js +1 -5
  79. package/lib/util/exec-async-command.js +20 -12
  80. package/lib/util/install-dependencies-task.js +4 -6
  81. package/lib/util/is-running-root.js +3 -1
  82. package/package.json +2 -2
  83. package/typings/context.d.ts +1 -0
  84. package/lib/tasks/theme/setup-persisted-query.js +0 -63
@@ -1,7 +1,10 @@
1
1
  const path = require('path');
2
+ const envPhpToJson = require('../../util/env-php-json');
3
+ const getJsonfileData = require('../../util/get-jsonfile-data');
2
4
  const pathExists = require('../../util/path-exists');
3
5
  const phpTask = require('../../util/php-task');
4
6
 
7
+ const composerLockPath = path.join(process.cwd(), 'composer.lock');
5
8
  /**
6
9
  * @type {() => import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
7
10
  */
@@ -9,7 +12,7 @@ const updateEnvPHP = () => ({
9
12
  title: 'Updating env.php',
10
13
  task: async (ctx, task) => {
11
14
  // update env.php only if it's exist
12
- if (!await pathExists(path.resolve('app', 'etc', 'env.php'))) {
15
+ if (!await pathExists(path.join(process.cwd(), 'app', 'etc', 'env.php'))) {
13
16
  task.skip();
14
17
  return;
15
18
  }
@@ -21,6 +24,32 @@ const updateEnvPHP = () => ({
21
24
  ? ctx.cachedPorts.varnish
22
25
  : ctx.cachedPorts;
23
26
 
27
+ let SETUP_PQ = '1';
28
+
29
+ if (await pathExists(composerLockPath)) {
30
+ const composerLockData = await getJsonfileData(composerLockPath);
31
+
32
+ if (composerLockData.packages.some(({ name }) => name === 'scandipwa/persisted-query')) {
33
+ if (typeof ctx.CSAThemeInstalled !== 'boolean') {
34
+ ctx.CSAThemeInstalled = true;
35
+ }
36
+
37
+ const envPhp = await envPhpToJson(process.cwd(), { magentoVersion: ctx.magentoVersion });
38
+
39
+ const persistedQueryConfig = envPhp.cache && envPhp.cache['persisted-query'];
40
+
41
+ if (
42
+ persistedQueryConfig
43
+ && persistedQueryConfig.redis
44
+ && persistedQueryConfig.redis.port === `${ ctx.ports.redis }`
45
+ && persistedQueryConfig.redis.host === 'localhost'
46
+ ) {
47
+ SETUP_PQ = '';
48
+ return;
49
+ }
50
+ }
51
+ }
52
+
24
53
  return task.newListr(
25
54
  phpTask(`-f ${ path.join(__dirname, 'update-env.php') }`, {
26
55
  noTitle: true,
@@ -28,7 +57,10 @@ const updateEnvPHP = () => ({
28
57
  USE_VARNISH: useVarnish,
29
58
  VARNISH_PORT: `${ varnishPort }`,
30
59
  VARNISH_HOST: varnishHost,
31
- PREVIOUS_VARNISH_PORT: `${ previousVarnishPort }`
60
+ PREVIOUS_VARNISH_PORT: `${ previousVarnishPort }`,
61
+ SETUP_PQ,
62
+ REDIS_PORT: ctx.ports.redis,
63
+ ADMIN_URI: ctx.config.overridenConfiguration.magento.adminuri
32
64
  }
33
65
  })
34
66
  );
@@ -78,6 +78,9 @@ class EnvUpdater
78
78
 
79
79
  public function modifyConfig()
80
80
  {
81
+ // set admin uri
82
+ $this->config['backend']['frontName'] = getenv('ADMIN_URI');
83
+
81
84
  // update mysql config
82
85
  if (isset($this->config['db']['connection']['default'])) {
83
86
  $conn = &$this->config['db']['connection']['default'];
@@ -120,19 +123,30 @@ class EnvUpdater
120
123
  }
121
124
 
122
125
  // update persisted query redis config
123
- if (isset($this->config['cache']['persisted-query'])) {
124
- $persistedQuery = &$this->config['cache']['persisted-query'];
126
+ if (getenv('SETUP_PQ') == '1') {
127
+ $cacheConfig = &$this->config['cache'];
128
+ $redisPort = getenv('REDIS_PORT');
125
129
 
126
- if (isset($persistedQuery['redis'])) {
127
- if ($persistedQuery['redis']['port'] !== strval($this->portConfig['redis'])) {
128
- $persistedQuery['redis']['port'] = strval($this->portConfig['redis']);
129
- }
130
- if ($persistedQuery['redis']['host'] !== 'localhost') {
131
- $persistedQuery['redis']['host'] = 'localhost';
130
+ if (isset($cacheConfig) && isset($cacheConfig['persisted-query']) && isset($cacheConfig['persisted-query']['redis']) && $cacheConfig['persisted-query']['redis']['port'] != $redisPort) {
131
+ $cacheConfig['persisted-query']['redis']['port'] = $redisPort;
132
+ } else {
133
+ if (!isset($cacheConfig)) {
134
+ $this->config['cache'] = [];
132
135
  }
136
+ $this->config['cache']['persisted-query'] = [
137
+ 'redis' => [
138
+ 'host' => 'localhost',
139
+ 'port' => $redisPort,
140
+ 'database' => '5',
141
+ 'scheme' => 'tcp'
142
+ ]
143
+ ];
133
144
  }
145
+ } else {
146
+ unset($this->config['cache']['persisted-query']);
134
147
  }
135
148
 
149
+ // set varnish config
136
150
  $httpCacheHosts = &$this->config['http_cache_hosts'];
137
151
  $httpCacheHosts = [];
138
152
 
@@ -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(),
@@ -89,11 +89,15 @@ const prettyStatus = async (ctx) => {
89
89
  .addLine(`Image: ${logger.style.file(container.image)}`)
90
90
  .addLine(`Network: ${logger.style.link(container.network)}`);
91
91
 
92
- if (container.ports && container.ports.length > 0) {
92
+ if (container.forwardedPorts && container.forwardedPorts.length > 0) {
93
93
  block.addLine('Port forwarding:');
94
- container.ports.forEach((port) => {
94
+ container.forwardedPorts.forEach((port) => {
95
95
  const { host, hostPort, containerPort } = parsePort(port);
96
- block.addLine(`${' '.repeat(3)} ${logger.style.link(`${host}:${hostPort}`)} -> ${logger.style.file(containerPort)}`);
96
+ if (container.network !== 'host') {
97
+ block.addLine(`${' '.repeat(3)} ${logger.style.link(`${host}:${hostPort}`)} -> ${logger.style.file(containerPort)} (${logger.style.link('host')} -> ${logger.style.file('container')})`);
98
+ } else {
99
+ block.addLine(`${' '.repeat(3)} ${logger.style.link(`Running on host network - ${host}:${hostPort}`)}`);
100
+ }
97
101
  });
98
102
  }
99
103
 
@@ -4,7 +4,6 @@ const adjustFullPageCache = require('../magento/setup-magento/adjust-full-page-c
4
4
  const disablePageBuilder = require('../magento/setup-magento/disable-page-builder');
5
5
  const buildTheme = require('./build-theme');
6
6
  const upgradeMagento = require('../magento/setup-magento/upgrade-magento');
7
- const setupPersistedQuery = require('./setup-persisted-query');
8
7
  const updateEnvPHP = require('../php/update-env-php');
9
8
  const semver = require('semver');
10
9
 
@@ -51,7 +50,6 @@ const linkTheme = () => ({
51
50
  symlinkTheme(theme),
52
51
  installTheme(theme),
53
52
  updateEnvPHP(),
54
- setupPersistedQuery(),
55
53
  upgradeMagento(),
56
54
  adjustFullPageCache(),
57
55
  ...(isPageBuilderInstalled && Number(isPagebuilderEnabled) ? [disablePageBuilder()] : []),
@@ -3,9 +3,7 @@ const getJsonfileData = require('../../util/get-jsonfile-data');
3
3
  const pathExists = require('../../util/path-exists');
4
4
  const symlinkTheme = require('./symlink-theme');
5
5
  const installTheme = require('./install-theme');
6
- const setupPersistedQuery = require('./setup-persisted-query');
7
6
  const upgradeMagento = require('../magento/setup-magento/upgrade-magento');
8
- const adjustFullPageCache = require('../magento/setup-magento/adjust-full-page-cache');
9
7
  const buildTheme = require('./build-theme');
10
8
  const KnownError = require('../../errors/known-error');
11
9
 
@@ -87,9 +85,7 @@ const setupThemes = () => ({
87
85
  buildTheme(theme)
88
86
  ])
89
87
  })).concat([
90
- upgradeMagento(),
91
- adjustFullPageCache(),
92
- setupPersistedQuery()
88
+ upgradeMagento()
93
89
  ])
94
90
  );
95
91
  }
@@ -16,6 +16,10 @@ const execAsyncSpawn = (command, {
16
16
  stdio: pipeInput ? ['inherit', 'pipe', 'pipe'] : 'pipe',
17
17
  cwd
18
18
  };
19
+
20
+ /**
21
+ * @type {import('child_process').ChildProcessWithoutNullStreams}
22
+ */
19
23
  let childProcess;
20
24
  if (useRosetta2 && os.platform() === 'darwin' && getArchSync() === 'arm64') {
21
25
  childProcess = spawn(
@@ -39,36 +43,40 @@ const execAsyncSpawn = (command, {
39
43
  }
40
44
 
41
45
  return new Promise((resolve, reject) => {
42
- let stdout = '';
46
+ const chunks = [];
43
47
 
44
48
  /**
45
- * @param {Buffer} data
49
+ * @param {Buffer} chunk
46
50
  */
47
- function addLine(data) {
48
- stdout += data.toString();
49
- data.toString().split('\n').map((str) => str.trim()).forEach((str) => {
51
+ const addChunk = (chunk) => {
52
+ chunks.push(Buffer.from(chunk));
53
+ const newData = chunk.toString('utf-8');
54
+ newData.split('\n').map((str) => str.trim()).forEach((str) => {
50
55
  callback(str);
51
56
  });
52
57
  if (logOutput) {
53
- data.toString().split('\n').filter(Boolean).forEach((line) => {
58
+ newData.split('\n').filter(Boolean).forEach((line) => {
54
59
  logger.log(line);
55
60
  });
56
61
  }
57
- }
58
- childProcess.stdout.on('data', addLine);
59
- childProcess.stderr.on('data', addLine);
62
+ };
63
+
64
+ childProcess.stdout.on('data', addChunk);
65
+ childProcess.stderr.on('data', addChunk);
66
+
60
67
  childProcess.on('error', (error) => {
61
68
  reject(error);
62
69
  });
63
70
  childProcess.on('close', (code) => {
71
+ const result = Buffer.concat(chunks).toString('utf8').trim();
64
72
  if (withCode) {
65
- resolve({ code, result: stdout.trim() });
73
+ resolve({ code, result });
66
74
  return;
67
75
  }
68
76
  if (code > 0) {
69
- reject(stdout.trim());
77
+ reject(result);
70
78
  } else {
71
- resolve(stdout.trim());
79
+ resolve(result);
72
80
  }
73
81
  });
74
82
  });
@@ -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
  }
@@ -1,3 +1,5 @@
1
- const isRunningRoot = () => process.getuid() === 0; // UID 0 is always root
1
+ const os = require('os');
2
+
3
+ const isRunningRoot = () => ['linux', 'darwin'].includes(os.platform()) && process.getuid() === 0; // UID 0 is always root
2
4
 
3
5
  module.exports = isRunningRoot;
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.16.0-alpha.1",
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": "ebd76eb7a1fac6dd0acbf589f52655ec01c64db2"
57
57
  }
@@ -5,6 +5,7 @@ import { PHPStormConfig } from './phpstorm';
5
5
 
6
6
  export interface ListrContext {
7
7
  magentoVersion: string
8
+ composerVersion: string
8
9
  port?: number
9
10
  ports?: {
10
11
  app: number
@@ -1,63 +0,0 @@
1
- const path = require('path');
2
- const UnknownError = require('../../errors/unknown-error');
3
- const envPhpToJson = require('../../util/env-php-json');
4
- const getJsonfileData = require('../../util/get-jsonfile-data');
5
- const runMagentoCommand = require('../../util/run-magento');
6
-
7
- /**
8
- * TODO move this block inside theme folder as post installation command
9
- * @type {() => import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
10
- */
11
- const persistedQuerySetup = () => ({
12
- title: 'Setting up Redis configuration for persisted queries',
13
- task: async (ctx, task) => {
14
- const { ports, magentoVersion, verbose = false } = ctx;
15
- const composerLockData = await getJsonfileData(path.join(process.cwd(), 'composer.lock'));
16
-
17
- if (!composerLockData.packages.some(({ name }) => name === 'scandipwa/persisted-query')) {
18
- /**
19
- * No persisted query package available, skipping its setup
20
- */
21
- task.skip();
22
- return;
23
- }
24
- ctx.CSAThemeInstalled = true;
25
-
26
- const envPhp = await envPhpToJson(process.cwd(), { magentoVersion });
27
-
28
- const persistedQueryConfig = envPhp.cache && envPhp.cache['persisted-query'];
29
-
30
- if (
31
- persistedQueryConfig
32
- && persistedQueryConfig.redis
33
- && persistedQueryConfig.redis.port === `${ ports.redis }`
34
- && persistedQueryConfig.redis.host === 'localhost'
35
- ) {
36
- task.skip();
37
- return;
38
- }
39
-
40
- task.output = 'Setting up persisted query...';
41
-
42
- try {
43
- await runMagentoCommand(`setup:config:set \
44
- --pq-host=localhost \
45
- --pq-port=${ports.redis} \
46
- --pq-database=5 \
47
- --pq-scheme=tcp \
48
- -n`, {
49
- callback: !verbose ? undefined : (t) => {
50
- task.output = t;
51
- },
52
- magentoVersion
53
- });
54
- } catch (e) {
55
- throw new UnknownError(
56
- `Unexpected error while setting redis for pq!.
57
- See ERROR log below.\n\n${e}`
58
- );
59
- }
60
- }
61
- });
62
-
63
- module.exports = persistedQuerySetup;