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

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.
@@ -5,6 +5,7 @@ const { isIpAddress } = require('../util/ip');
5
5
 
6
6
  const systeminformation = require('systeminformation');
7
7
  const { deepmerge } = require('../util/deepmerge');
8
+ const defaultEsEnv = require('./services/elasticsearch/default-es-env');
8
9
 
9
10
  /**
10
11
  *
@@ -259,10 +260,12 @@ module.exports = async (ctx, overridenConfiguration, baseConfig) => {
259
260
  ports: [`127.0.0.1:${ ports.elasticsearch }:9200`],
260
261
  forwardedPorts: [`127.0.0.1:${ ports.elasticsearch }:9200`],
261
262
  mounts: [`source=${ volumes.elasticsearch.name },target=/usr/share/elasticsearch/data`],
262
- env: deepmerge({
263
+ env: deepmerge(
264
+ {
263
265
  // https://www.elastic.co/guide/en/elasticsearch/reference/master/ml-settings.html
264
- 'xpack.ml.enabled': ['sse4.2', 'sse4_2'].some((sse42Flag) => cpuSupportedFlags.includes(sse42Flag))
265
- }, elasticsearch.env),
266
+ 'xpack.ml.enabled': ['sse4.2', 'sse4_2'].some((sse42Flag) => cpuSupportedFlags.includes(sse42Flag))
267
+ }, elasticsearch.env || defaultEsEnv
268
+ ),
266
269
  network: network.name,
267
270
  image: `${ elasticsearch.version ? `elasticsearch:${ elasticsearch.version }` : elasticsearch.image }`,
268
271
  name: `${ prefix }_elasticsearch`
@@ -0,0 +1,6 @@
1
+ module.exports = {
2
+ 'bootstrap.memory_lock': true,
3
+ 'xpack.security.enabled': false,
4
+ 'discovery.type': 'single-node',
5
+ ES_JAVA_OPTS: '-Xms512m -Xmx512m'
6
+ };
@@ -2,6 +2,7 @@ const os = require('os');
2
2
  const { getArchSync } = require('../../../../util/arch');
3
3
  const { deepmerge } = require('../../../../util/deepmerge');
4
4
  const { repo } = require('../base-repo');
5
+ const defaultEnv = require('../default-es-env');
5
6
 
6
7
  /**
7
8
  * @returns {import('../../../../../typings/index').ServiceWithImage}
@@ -10,12 +11,7 @@ const elasticsearch68 = ({
10
11
  image = `${ repo }:elasticsearch-6.8`
11
12
  } = {}) => ({
12
13
  image,
13
- env: deepmerge({
14
- 'bootstrap.memory_lock': true,
15
- 'xpack.security.enabled': false,
16
- 'discovery.type': 'single-node',
17
- ES_JAVA_OPTS: '-Xms512m -Xmx512m'
18
- }, os.platform() === 'darwin' && getArchSync() === 'arm64' ? {
14
+ env: deepmerge(defaultEnv, os.platform() === 'darwin' && getArchSync() === 'arm64' ? {
19
15
  'xpack.ml.enabled': false
20
16
  } : {})
21
17
  });
@@ -31,7 +31,7 @@ const setupPHPWorkspaceProjectConfiguration = async (workspaceConfigs, ctx) => {
31
31
  hasChanges = true;
32
32
  workspaceConfigs.push({
33
33
  [nameKey]: PHP_WORKSPACE_PROJECT_CONFIGURATION_COMPONENT_NAME,
34
- [currentInterpreterImage]: currentInterpreterImage,
34
+ [interpreterNameKey]: currentInterpreterImage,
35
35
  include_path: []
36
36
  });
37
37
  }
@@ -4,7 +4,6 @@ const logger = require('@scandipwa/scandipwa-dev-utils/logger');
4
4
  const semver = require('semver');
5
5
  const pathExists = require('../../util/path-exists');
6
6
  const getJsonfileData = require('../../util/get-jsonfile-data');
7
- const KnownError = require('../../errors/known-error');
8
7
 
9
8
  const vendorPath = path.join(process.cwd(), 'vendor');
10
9
  const composerJsonPath = path.join(process.cwd(), 'composer.json');
@@ -86,29 +85,80 @@ const enableMagentoComposerPlugins = () => ({
86
85
  } = composerJsonData;
87
86
  const allowPluginsKeys = Object.keys(allowPlugins);
88
87
 
88
+ const missingPluginsFromAllowPlugins = composerPlugins.filter((plugin) => {
89
+ const [pluginVendor, pluginName] = plugin.split('/');
90
+ return !allowPluginsKeys.some((allowedPlugin) => {
91
+ const [allowedPluginVendor, allowedPluginName] = allowedPlugin.split('/');
92
+ if (allowedPluginVendor === pluginVendor) {
93
+ if (allowedPluginName === '*') {
94
+ return true;
95
+ }
96
+
97
+ return allowedPluginName === pluginName;
98
+ }
99
+
100
+ return false;
101
+ });
102
+ });
103
+
89
104
  if (
90
105
  allowPluginsKeys.length === 0
91
- || composerPlugins.some((p) => !allowPluginsKeys.includes(p))
106
+ || missingPluginsFromAllowPlugins.length > 0
92
107
  ) {
93
- const missingPlugins = composerPlugins.filter((p) => !allowPluginsKeys.includes(p));
108
+ const missingVendors = missingPluginsFromAllowPlugins.reduce((acc, val) => {
109
+ const [pluginVendor] = val.split('/');
110
+
111
+ if (acc.length === 0) {
112
+ return [pluginVendor];
113
+ }
114
+
115
+ if (!acc.includes(pluginVendor)) {
116
+ return [...acc, pluginVendor];
117
+ }
118
+
119
+ return acc;
120
+ }, []);
121
+
122
+ const pluginOptions = [
123
+ {
124
+ name: 'all-individual',
125
+ message: 'Enable all individually'
126
+ },
127
+ {
128
+ name: 'manual',
129
+ message: 'Configure manually'
130
+ },
131
+ {
132
+ name: 'skip',
133
+ message: 'Skip this step'
134
+ }
135
+ ];
136
+
137
+ if (missingVendors.length === 1) {
138
+ pluginOptions.unshift({
139
+ name: 'all',
140
+ message: `Enable all (${logger.style.code(`"${missingVendors[0]}/*"`)})`
141
+ });
142
+ }
143
+
94
144
  const answerForEnablingPlugins = await task.prompt({
95
145
  type: 'Select',
96
146
  message: `Composer 2.2 requires manually allowing composer-plugins to run.
97
147
  Magento requires the following plugins to correctly operate:
98
148
 
99
- ${missingPlugins.map((p) => logger.style.code(p)).join('\n')}
149
+ ${missingPluginsFromAllowPlugins.map((p) => logger.style.code(p)).join('\n')}
100
150
 
101
151
  Do you want to enable them all or disable some of them?`,
102
- choices: ['Enable all', 'Configure manually', 'Skip this step']
152
+ choices: pluginOptions
103
153
  });
104
154
 
105
155
  switch (answerForEnablingPlugins.toLowerCase()) {
106
- case 'enable all': {
156
+ case 'all': {
107
157
  composerJsonData.config = {
108
158
  ...(composerJsonData.config || {}),
109
159
  'allow-plugins': {
110
160
  ...allowPlugins,
111
- ...missingPlugins.reduce((acc, val) => ({ ...acc, [val]: true }), {})
161
+ [`${missingVendors[0]}/*`]: true
112
162
  }
113
163
  };
114
164
 
@@ -117,36 +167,41 @@ Do you want to enable them all or disable some of them?`,
117
167
  });
118
168
  break;
119
169
  }
120
- case 'configure manually': {
170
+ case 'all-individual': {
171
+ composerJsonData.config = {
172
+ ...(composerJsonData.config || {}),
173
+ 'allow-plugins': {
174
+ ...allowPlugins,
175
+ ...missingPluginsFromAllowPlugins.reduce((acc, val) => ({ ...acc, [val]: true }), {})
176
+ }
177
+ };
178
+
179
+ await fs.promises.writeFile(composerJsonPath, JSON.stringify(composerJsonData, null, 4), {
180
+ encoding: 'utf-8'
181
+ });
182
+ break;
183
+ }
184
+ case 'manual': {
121
185
  const userEnabledPlugins = await task.prompt({
122
186
  type: 'MultiSelect',
123
187
  message: 'Please pick plugins you want to enable!',
124
- choices: missingPlugins.map((p) => ({ name: p }))
188
+ choices: missingPluginsFromAllowPlugins.map((p) => ({ name: p }))
125
189
  });
126
190
 
127
- const userConfirmation = await task.prompt({
128
- type: 'Confirm',
129
- message: `Please confirm enabling of the following plugins:\n\n${userEnabledPlugins.map((p) => logger.style.code(p)).join('\n')}\n`
130
- });
191
+ const disabledPlugins = composerPlugins.filter((p) => !userEnabledPlugins.includes(p));
131
192
 
132
- if (userConfirmation) {
133
- const disabledPlugins = composerPlugins.filter((p) => !userEnabledPlugins.includes(p));
134
-
135
- composerJsonData.config = {
136
- ...(composerJsonData.config || {}),
137
- 'allow-plugins': {
138
- ...allowPlugins,
139
- ...disabledPlugins.reduce((acc, val) => ({ ...acc, [val]: false }), {}),
140
- ...userEnabledPlugins.reduce((acc, val) => ({ ...acc, [val]: true }), {})
141
- }
142
- };
193
+ composerJsonData.config = {
194
+ ...(composerJsonData.config || {}),
195
+ 'allow-plugins': {
196
+ ...allowPlugins,
197
+ ...disabledPlugins.reduce((acc, val) => ({ ...acc, [val]: false }), {}),
198
+ ...userEnabledPlugins.reduce((acc, val) => ({ ...acc, [val]: true }), {})
199
+ }
200
+ };
143
201
 
144
- await fs.promises.writeFile(composerJsonPath, JSON.stringify(composerJsonData, null, 4), {
145
- encoding: 'utf-8'
146
- });
147
- } else {
148
- throw new KnownError('Please confirm your choice or choose other option.');
149
- }
202
+ await fs.promises.writeFile(composerJsonPath, JSON.stringify(composerJsonData, null, 4), {
203
+ encoding: 'utf-8'
204
+ });
150
205
 
151
206
  break;
152
207
  }
@@ -97,8 +97,9 @@ const createMagentoProject = async (ctx, task, {
97
97
  `"${tempDir}"`
98
98
  ];
99
99
 
100
- await runPHPContainerCommand(ctx, `composer ${installCommand.join(' ')} \n
101
- && mv ${tempDir}/composer.json ${ctx.config.baseConfig.containerMagentoDir}/composer.json`);
100
+ await runPHPContainerCommand(ctx, `bash -c 'mkdir ${tempDir} && \
101
+ composer ${installCommand.join(' ')} && \
102
+ mv ${tempDir}/composer.json ${ctx.config.baseConfig.containerMagentoDir}/composer.json'`);
102
103
  };
103
104
 
104
105
  /**
@@ -30,6 +30,7 @@ NOTE: After installation it's recommended to log out and log back in so your gro
30
30
  if (automaticallyInstallDocker) {
31
31
  return task.newListr([
32
32
  installDocker(),
33
+ checkDockerSocketPermissions(),
33
34
  getDockerVersion(),
34
35
  {
35
36
  task: (ctx) => {
@@ -80,6 +81,7 @@ Would you like to install it automatically using brew cask or you prefer to inst
80
81
  if (confirmationToInstallDocker === 'automatic') {
81
82
  return task.newListr([
82
83
  installDockerOnMac(),
84
+ checkDockerSocketPermissions(),
83
85
  checkDockerStatus(),
84
86
  getDockerVersion(),
85
87
  setVersionInContextTask(task)
@@ -122,6 +124,7 @@ const checkDocker = () => ({
122
124
  }
123
125
 
124
126
  return task.newListr([
127
+ checkDockerSocketPermissions(),
125
128
  checkDockerStatus(),
126
129
  getDockerVersion(),
127
130
  setVersionInContextTask(task)
@@ -134,7 +137,6 @@ const checkDocker = () => ({
134
137
  */
135
138
  module.exports = () => ({
136
139
  task: (ctx, task) => task.newListr([
137
- checkDockerSocketPermissions(),
138
140
  checkDocker(),
139
141
  checkDockerPerformance()
140
142
  ], {
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.1",
6
+ "version": "2.0.0-alpha.4",
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": "0b205dcab6056cf07988525ce053c5299af840e9"
56
+ "gitHead": "f447e467a64cb3a4b83a22a9ac54055918266198"
57
57
  }