@scandipwa/magento-scripts 1.15.7 → 1.16.0-alpha.0

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 (53) hide show
  1. package/lib/commands/execute.js +4 -1
  2. package/lib/commands/logs.js +3 -0
  3. package/lib/config/docker.js +20 -1
  4. package/lib/config/php/extensions/index.js +2 -1
  5. package/lib/config/php/extensions/xdebug.js +9 -0
  6. package/lib/config/php/releases/index.js +6 -0
  7. package/lib/config/php/releases/php-7.2.js +25 -0
  8. package/lib/config/php/releases/php-7.3.js +25 -0
  9. package/lib/config/php/releases/php-7.4.js +23 -0
  10. package/lib/config/php/releases/php-8.1.js +25 -0
  11. package/lib/config/versions/magento-2.3.0.js +2 -21
  12. package/lib/config/versions/magento-2.3.1.js +2 -21
  13. package/lib/config/versions/magento-2.3.2-p2.js +2 -21
  14. package/lib/config/versions/magento-2.3.2.js +2 -21
  15. package/lib/config/versions/magento-2.3.3-p1.js +2 -21
  16. package/lib/config/versions/magento-2.3.3.js +2 -21
  17. package/lib/config/versions/magento-2.3.4-p2.js +2 -21
  18. package/lib/config/versions/magento-2.3.4.js +2 -21
  19. package/lib/config/versions/magento-2.3.5-p1.js +2 -21
  20. package/lib/config/versions/magento-2.3.5-p2.js +2 -21
  21. package/lib/config/versions/magento-2.3.5.js +2 -21
  22. package/lib/config/versions/magento-2.3.6-p1.js +2 -21
  23. package/lib/config/versions/magento-2.3.6.js +2 -21
  24. package/lib/config/versions/magento-2.3.7-p1.js +2 -19
  25. package/lib/config/versions/magento-2.3.7-p2.js +2 -19
  26. package/lib/config/versions/magento-2.3.7-p3.js +2 -19
  27. package/lib/config/versions/magento-2.3.7.js +2 -19
  28. package/lib/config/versions/magento-2.4.0-p1.js +2 -19
  29. package/lib/config/versions/magento-2.4.0.js +2 -19
  30. package/lib/config/versions/magento-2.4.1-p1.js +6 -19
  31. package/lib/config/versions/magento-2.4.1.js +2 -19
  32. package/lib/config/versions/magento-2.4.2-p1.js +6 -20
  33. package/lib/config/versions/magento-2.4.2-p2.js +6 -19
  34. package/lib/config/versions/magento-2.4.2.js +6 -19
  35. package/lib/config/versions/magento-2.4.3-p1.js +6 -19
  36. package/lib/config/versions/magento-2.4.3-p2.js +6 -19
  37. package/lib/config/versions/magento-2.4.3.js +6 -19
  38. package/lib/config/versions/magento-2.4.4.js +2 -22
  39. package/lib/tasks/composer/install-prestissimo.js +52 -2
  40. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/index.js +1 -3
  41. package/lib/tasks/magento/setup-magento/adjust-full-page-cache.js +12 -8
  42. package/lib/tasks/magento/setup-magento/index.js +2 -3
  43. package/lib/tasks/magento/setup-magento/migrate-database.js +5 -0
  44. package/lib/tasks/php/update-env-php.js +33 -1
  45. package/lib/tasks/php/update-env.php +22 -8
  46. package/lib/tasks/status/index.js +7 -3
  47. package/lib/tasks/theme/link-theme.js +0 -2
  48. package/lib/tasks/theme/setup-themes.js +1 -5
  49. package/lib/util/exec-async-command.js +20 -12
  50. package/lib/util/is-running-root.js +3 -1
  51. package/package.json +2 -2
  52. package/typings/context.d.ts +1 -0
  53. package/lib/tasks/theme/setup-persisted-query.js +0 -63
@@ -1,6 +1,5 @@
1
1
  const { loadXmlFile, buildXmlFile } = require('../../../../config/xml-parser');
2
2
  const pathExists = require('../../../../util/path-exists');
3
- const { getPhpConfig } = require('../php-config/php-config');
4
3
  const { setupXMLStructure } = require('../setup-xml-structure');
5
4
  const setupComposerSettings = require('./composer-settings-config');
6
5
  const setupFormatOnSave = require('./format-setting-config');
@@ -17,7 +16,6 @@ const setupWorkspaceConfig = () => ({
17
16
  title: 'Set up Workspace configuration',
18
17
  task: async (ctx, task) => {
19
18
  const workspaceConfig = getWorkspaceConfig(ctx.config.overridenConfiguration);
20
- const phpConfig = getPhpConfig(ctx.config.overridenConfiguration);
21
19
  if (await pathExists(workspaceConfig.path)) {
22
20
  const workspaceConfiguration = setupXMLStructure(await loadXmlFile(workspaceConfig.path));
23
21
  const workspaceConfigs = workspaceConfiguration.project.component;
@@ -29,7 +27,7 @@ const setupWorkspaceConfig = () => ({
29
27
  ]);
30
28
 
31
29
  if (hasChanges.includes(true)) {
32
- await buildXmlFile(phpConfig.path, workspaceConfiguration);
30
+ await buildXmlFile(workspaceConfig.path, workspaceConfiguration);
33
31
  } else {
34
32
  task.skip();
35
33
  }
@@ -8,15 +8,19 @@ const disableFullPageCache = () => ({
8
8
  title: 'Adjusting full_page cache setting',
9
9
  task: async ({ magentoVersion, config }, task) => {
10
10
  const { cache_types } = await envPhpToJson(process.cwd(), { magentoVersion });
11
+ if (cache_types && typeof cache_types.full_page === 'number') {
12
+ if (cache_types.full_page !== 0 && !config.overridenConfiguration.configuration.varnish.enabled) {
13
+ task.title = 'Disabling full_page cache in Magento';
14
+ return task.newListr(magentoTask('cache:disable full_page'));
15
+ }
11
16
 
12
- if (cache_types.full_page !== 0 && !config.overridenConfiguration.configuration.varnish.enabled) {
13
- task.title = 'Disabling full_page cache in Magento';
14
- return task.newListr(magentoTask('cache:disable full_page'));
15
- }
16
-
17
- if (config.overridenConfiguration.configuration.varnish.enabled && cache_types.full_page !== 1) {
18
- task.title = 'Enabling full_page cache in Magento (Varnish is enabled)';
19
- return task.newListr(magentoTask('cache:enable full_page'));
17
+ if (config.overridenConfiguration.configuration.varnish.enabled && cache_types.full_page !== 1) {
18
+ task.title = 'Enabling full_page cache in Magento (Varnish is enabled)';
19
+ return task.newListr(magentoTask('cache:enable full_page'));
20
+ }
21
+ } else {
22
+ task.skip('full_page cache type is not set in env.php');
23
+ return;
20
24
  }
21
25
 
22
26
  task.skip();
@@ -7,11 +7,11 @@ const setBaseUrl = require('./set-base-url');
7
7
  const disableMaintenanceMode = require('./disable-maintenance-mode');
8
8
  const disable2fa = require('./disable-2fa');
9
9
  const setUrlRewrite = require('./set-url-rewrite');
10
- const updateEnvPHP = require('../../php/update-env-php');
11
10
  const increaseAdminSessionLifetime = require('./increase-admin-session-lifetime');
12
11
  const magentoTask = require('../../../util/magento-task');
13
12
  const urnHighlighter = require('./urn-highlighter');
14
13
  const waitingForVarnish = require('./waiting-for-varnish');
14
+ const adjustFullPageCache = require('./adjust-full-page-cache');
15
15
 
16
16
  /**
17
17
  * @param {Object} [options]
@@ -26,7 +26,6 @@ const setupMagento = (options = {}) => ({
26
26
  return task.newListr([
27
27
  flushRedisConfig(),
28
28
  waitingForRedis(),
29
- updateEnvPHP(),
30
29
  migrateDatabase({ onlyInstallMagento: true })
31
30
  ]);
32
31
  }
@@ -34,7 +33,6 @@ const setupMagento = (options = {}) => ({
34
33
  return task.newListr([
35
34
  flushRedisConfig(),
36
35
  waitingForRedis(),
37
- updateEnvPHP(),
38
36
  migrateDatabase(),
39
37
  {
40
38
  title: 'Configuring Magento settings',
@@ -51,6 +49,7 @@ const setupMagento = (options = {}) => ({
51
49
  disableMaintenanceMode(),
52
50
  disable2fa(),
53
51
  urnHighlighter(),
52
+ adjustFullPageCache(),
54
53
  magentoTask('cache:flush'),
55
54
  waitingForVarnish()
56
55
  ], {
@@ -7,6 +7,7 @@ const installMagento = require('./install-magento');
7
7
  const upgradeMagento = require('./upgrade-magento');
8
8
  const varnishConfigSetup = require('./varnish-config');
9
9
  const pathExists = require('../../../util/path-exists');
10
+ const updateEnvPHP = require('../../php/update-env-php');
10
11
 
11
12
  /**
12
13
  * @param {Object} [options]
@@ -41,6 +42,7 @@ const migrateDatabase = (options = {}) => ({
41
42
 
42
43
  return task.newListr([
43
44
  installMagento({ isDbEmpty: true }),
45
+ updateEnvPHP(),
44
46
  varnishConfigSetup(),
45
47
  configureElasticsearch(),
46
48
  upgradeMagento(),
@@ -65,6 +67,7 @@ const migrateDatabase = (options = {}) => ({
65
67
  ctx.isSetupUpgradeNeeded = false;
66
68
  // no setup is needed, but still to be sure configure ES
67
69
  return task.newListr([
70
+ updateEnvPHP(),
68
71
  varnishConfigSetup(),
69
72
  configureElasticsearch()
70
73
  ], {
@@ -86,6 +89,7 @@ const migrateDatabase = (options = {}) => ({
86
89
 
87
90
  return task.newListr([
88
91
  installMagentoProject(),
92
+ updateEnvPHP(),
89
93
  varnishConfigSetup(),
90
94
  configureElasticsearch(),
91
95
  upgradeMagento(),
@@ -101,6 +105,7 @@ const migrateDatabase = (options = {}) => ({
101
105
  }
102
106
  case 2: {
103
107
  return task.newListr([
108
+ updateEnvPHP(),
104
109
  varnishConfigSetup(),
105
110
  configureElasticsearch(),
106
111
  upgradeMagento()
@@ -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
  */
@@ -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
 
@@ -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
  });
@@ -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.7",
6
+ "version": "1.16.0-alpha.0",
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": "f9e7474aca6c1a80ec37f6d51ab2a1a8a61582cc"
56
+ "gitHead": "e3d08c91ce20747b465b5b9edc1a4cd7737037ce"
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;