@scandipwa/magento-scripts 2.0.5 → 2.1.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.
@@ -439,7 +439,7 @@ module.exports = async (ctx, overridenConfiguration, baseConfig) => {
439
439
  command: `/bin/bash -c "varnishd -a :${
440
440
  isDockerDesktop ? 80 : ports.varnish
441
441
  } -t 600 -f /etc/varnish/default.vcl -s Cache=malloc,2048m -s Transient=malloc,512m -p http_resp_hdr_len=70000 -p http_resp_size=100000 && varnishlog"`,
442
- tmpfs: ['/var/lib/varnish:exec'],
442
+ tmpfs: ['/var/lib/varnish/varnishd:exec'],
443
443
  description: `Varnish HealthCheck status: ${logger.style.command(
444
444
  varnish.healthCheck ? 'enabled' : 'disabled'
445
445
  )}`
@@ -4,7 +4,7 @@ const defaultEnv = require('../default-es-env')
4
4
  * @returns {import('../../../../../typings/index').ElasticSearchConfiguration}
5
5
  */
6
6
  const elasticsearch717 = () => ({
7
- image: 'elasticsearch:7.17.6',
7
+ image: 'elasticsearch:7.17.9',
8
8
  env: defaultEnv
9
9
  })
10
10
 
@@ -0,0 +1,11 @@
1
+ const defaultEnv = require('../default-es-env')
2
+
3
+ /**
4
+ * @returns {import('../../../../../typings/index').ElasticSearchConfiguration}
5
+ */
6
+ const elasticsearch84 = () => ({
7
+ image: 'elasticsearch:8.4.3',
8
+ env: defaultEnv
9
+ })
10
+
11
+ module.exports = elasticsearch84
@@ -6,6 +6,7 @@ const elasticsearch710 = require('./elasticsearch-7.10')
6
6
  const elasticsearch712 = require('./elasticsearch-7.12')
7
7
  const elasticsearch716 = require('./elasticsearch-7.16')
8
8
  const elasticsearch717 = require('./elasticsearch-7.17')
9
+ const elasticsearch84 = require('./elasticsearch-8.4')
9
10
 
10
11
  module.exports = {
11
12
  elasticsearch68,
@@ -15,5 +16,6 @@ module.exports = {
15
16
  elasticsearch710,
16
17
  elasticsearch712,
17
18
  elasticsearch716,
18
- elasticsearch717
19
+ elasticsearch717,
20
+ elasticsearch84
19
21
  }
@@ -1,5 +1,6 @@
1
1
  module.exports = {
2
2
  mariadb102: require('./mariadb-10.2'),
3
3
  mariadb103: require('./mariadb-10.3'),
4
- mariadb104: require('./mariadb-10.4')
4
+ mariadb104: require('./mariadb-10.4'),
5
+ mariadb106: require('./mariadb-10.6')
5
6
  }
@@ -0,0 +1,9 @@
1
+ /**
2
+ * @returns {import('../../../../../typings/index').MariaDBConfiguration}
3
+ */
4
+ const mariadb106 = () => ({
5
+ image: 'mariadb:10.6',
6
+ useOptimizerSwitch: true
7
+ })
8
+
9
+ module.exports = mariadb106
@@ -0,0 +1,9 @@
1
+ const mysql57 = require('./mysql-5.7')
2
+ const mysql80 = require('./mysql-8.0')
3
+ const mysql8028 = require('./mysql-8.0.28')
4
+
5
+ module.exports = {
6
+ mysql57,
7
+ mysql80,
8
+ mysql8028
9
+ }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @returns {import('../../../../../typings/index').ServiceWithImage}
3
+ */
4
+ const mysql57 = () => ({
5
+ image: 'mysql:5.7'
6
+ })
7
+
8
+ module.exports = mysql57
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @returns {import('../../../../../typings/index').ServiceWithImage}
3
+ */
4
+ const mysql8028 = () => ({
5
+ image: 'mysql:8.0.28'
6
+ })
7
+
8
+ module.exports = mysql8028
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @returns {import('../../../../../typings/index').ServiceWithImage}
3
+ */
4
+ const mysql80 = () => ({
5
+ image: 'mysql:8.0'
6
+ })
7
+
8
+ module.exports = mysql80
@@ -10,5 +10,5 @@ module.exports = {
10
10
  && pecl install xdebug${version ? `-${version}` : ''} \
11
11
  && docker-php-ext-enable xdebug \
12
12
  && apk del -f .build-deps`,
13
- version: '3.1.5'
13
+ version: '3.1.6'
14
14
  }
@@ -2,5 +2,6 @@ module.exports = {
2
2
  php72: require('./php-7.2'),
3
3
  php73: require('./php-7.3'),
4
4
  php74: require('./php-7.4'),
5
- php81: require('./php-8.1')
5
+ php81: require('./php-8.1'),
6
+ php82: require('./php-8.2')
6
7
  }
@@ -0,0 +1,31 @@
1
+ const path = require('path')
2
+ const { repo } = require('../base-repo')
3
+ const xdebug = require('../extensions/xdebug')
4
+
5
+ /**
6
+ * @param {Object} param0
7
+ * @param {string} param0.templateDir
8
+ * @param {import('../../../../../typings/index').PHPExtensions} [param0.extensions]
9
+ * @param {string} [param0.baseImage]
10
+ * @returns {import('../../../../../typings/index').PHPConfiguration}
11
+ */
12
+ const php82 = ({
13
+ templateDir,
14
+ extensions = {},
15
+ baseImage = `${repo}:php-8.2`
16
+ }) => ({
17
+ baseImage,
18
+ debugImage: `${baseImage}-debug`,
19
+ configTemplate: path.join(templateDir || '', 'php.template.ini'),
20
+ fpmConfigTemplate: path.join(templateDir || '', 'php-fpm.template.conf'),
21
+ debugTemplate: path.join(templateDir || '', 'php-debug.template.ini'),
22
+ extensions: {
23
+ xdebug: {
24
+ ...xdebug,
25
+ version: '3.2.1'
26
+ },
27
+ ...extensions
28
+ }
29
+ })
30
+
31
+ module.exports = php82
@@ -1,5 +1,6 @@
1
1
  module.exports = {
2
2
  redis50: require('./redis-5.0'),
3
3
  redis60: require('./redis-6.0'),
4
- redis62: require('./redis-6.2')
4
+ redis62: require('./redis-6.2'),
5
+ redis70: require('./redis-7.0')
5
6
  }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @returns {import('../../../../typings/index').ServiceWithImage}
3
+ */
4
+ const redis70 = () => ({
5
+ image: 'redis:7.0-alpine'
6
+ })
7
+
8
+ module.exports = redis70
@@ -1,5 +1,6 @@
1
1
  module.exports = {
2
2
  varnish60: require('./varnish-6-0'),
3
3
  varnish66: require('./varnish-6-6'),
4
- varnish70: require('./varnish-7-0')
4
+ varnish70: require('./varnish-7-0'),
5
+ varnish71: require('./varnish-7-1')
5
6
  }
@@ -0,0 +1,15 @@
1
+ const path = require('path')
2
+
3
+ /**
4
+ * @param {Object} param0
5
+ * @param {string} param0.templateDir
6
+ * @returns {import('../../../../typings/index').VarnishConfiguration}
7
+ */
8
+ const varnish71 = ({ templateDir }) => ({
9
+ enabled: true,
10
+ healthCheck: false,
11
+ image: 'varnish:7.1',
12
+ configTemplate: path.join(templateDir || '', 'varnish.template.vcl')
13
+ })
14
+
15
+ module.exports = varnish71
@@ -134,8 +134,8 @@ sub vcl_recv {
134
134
  unset req.http.Cookie;
135
135
  }
136
136
 
137
- # Authenticated GraphQL requests should not be cached by default
138
- if (req.url ~ "/graphql" && req.http.Authorization ~ "^Bearer") {
137
+ # Bypass authenticated GraphQL requests without a X-Magento-Cache-Id
138
+ if (req.url ~ "/graphql" && !req.http.X-Magento-Cache-Id && req.http.Authorization ~ "^Bearer") {
139
139
  return (pass);
140
140
  }
141
141
 
@@ -143,7 +143,7 @@ sub vcl_recv {
143
143
  }
144
144
 
145
145
  sub vcl_hash {
146
- if (req.http.cookie ~ "X-Magento-Vary=") {
146
+ if ((req.url !~ "/graphql" || !req.http.X-Magento-Cache-Id) && req.http.cookie ~ "X-Magento-Vary=") {
147
147
  hash_data(regsub(req.http.cookie, "^.*?X-Magento-Vary=([^;]+);*.*$", "\1"));
148
148
  }
149
149
 
@@ -158,6 +158,15 @@ sub vcl_hash {
158
158
  }
159
159
 
160
160
  sub process_graphql_headers {
161
+ if (req.http.X-Magento-Cache-Id) {
162
+ hash_data(req.http.X-Magento-Cache-Id);
163
+
164
+ # When the frontend stops sending the auth token, make sure users stop getting results cached for logged-in users
165
+ if (req.http.Authorization ~ "^Bearer") {
166
+ hash_data("Authorized");
167
+ }
168
+ }
169
+
161
170
  if (req.http.Store) {
162
171
  hash_data(req.http.Store);
163
172
  }
@@ -182,12 +191,10 @@ sub vcl_backend_response {
182
191
  set beresp.http.X-Magento-Cache-Control = beresp.http.Cache-Control;
183
192
  }
184
193
 
185
- # cache only successfully responses and 404s
186
- if (beresp.status != 200 && beresp.status != 404) {
187
- set beresp.ttl = 0s;
188
- set beresp.uncacheable = true;
189
- return (deliver);
190
- } elsif (beresp.http.Cache-Control ~ "private") {
194
+ # cache only successfully responses and 404s that are not marked as private
195
+ if (beresp.status != 200 &&
196
+ beresp.status != 404 &&
197
+ beresp.http.Cache-Control ~ "private") {
191
198
  set beresp.uncacheable = true;
192
199
  set beresp.ttl = 86400s;
193
200
  return (deliver);
@@ -207,21 +214,23 @@ sub vcl_backend_response {
207
214
  # Mark as Hit-For-Pass for the next 2 minutes
208
215
  set beresp.ttl = 120s;
209
216
  set beresp.uncacheable = true;
217
+ }
218
+
219
+ # If the cache key in the Magento response doesn't match the one that was sent in the request, don't cache under the request's key
220
+ if (bereq.url ~ "/graphql" && bereq.http.X-Magento-Cache-Id && bereq.http.X-Magento-Cache-Id != beresp.http.X-Magento-Cache-Id) {
221
+ set beresp.ttl = 0s;
222
+ set beresp.uncacheable = true;
210
223
  }
211
224
 
212
225
  return (deliver);
213
226
  }
214
227
 
215
228
  sub vcl_deliver {
216
- if (resp.http.X-Magento-Debug) {
217
- if (resp.http.x-varnish ~ " ") {
218
- set resp.http.X-Magento-Cache-Debug = "HIT";
219
- set resp.http.Grace = req.http.grace;
220
- } else {
221
- set resp.http.X-Magento-Cache-Debug = "MISS";
222
- }
229
+ if (resp.http.x-varnish ~ " ") {
230
+ set resp.http.X-Magento-Cache-Debug = "HIT";
231
+ set resp.http.Grace = req.http.grace;
223
232
  } else {
224
- unset resp.http.Age;
233
+ set resp.http.X-Magento-Cache-Debug = "MISS";
225
234
  }
226
235
 
227
236
  # Not letting browser to cache non-static files.
@@ -231,6 +240,10 @@ sub vcl_deliver {
231
240
  set resp.http.Cache-Control = "no-store, no-cache, must-revalidate, max-age=0";
232
241
  }
233
242
 
243
+ if (!resp.http.X-Magento-Debug) {
244
+ unset resp.http.Age;
245
+ }
246
+
234
247
  unset resp.http.X-Magento-Debug;
235
248
  unset resp.http.X-Magento-Tags;
236
249
  unset resp.http.X-Powered-By;
@@ -0,0 +1,48 @@
1
+ const { defaultMagentoConfig } = require('../magento-config')
2
+ const sodium = require('../services/php/extensions/sodium')
3
+ const {
4
+ magento24PHPExtensionList
5
+ } = require('../magento/required-php-extensions')
6
+ const { php81 } = require('../services/php/versions')
7
+ const { sslTerminator } = require('../services/ssl-terminator')
8
+ const { varnish71 } = require('../services/varnish')
9
+ const { repo } = require('../services/php/base-repo')
10
+ const { nginx118 } = require('../services/nginx/versions')
11
+ const { composer2 } = require('../services/composer/versions')
12
+ const { maildev } = require('../services/maildev')
13
+ const { redis62 } = require('../services/redis')
14
+ const { mariadb104 } = require('../services/mariadb/versions')
15
+ const { elasticsearch717 } = require('../services/elasticsearch/versions')
16
+
17
+ /**
18
+ * @param {Object} param0
19
+ * @param {string} param0.templateDir
20
+ * @returns {import('../../../typings/index').CMAConfiguration & { magentoVersion: string, isDefault?: boolean }}
21
+ */
22
+ module.exports = ({ templateDir }) => ({
23
+ magentoVersion: '2.4.4-p3',
24
+ isDefault: true,
25
+ configuration: {
26
+ php: php81({
27
+ templateDir,
28
+ extensions: { ...magento24PHPExtensionList, sodium },
29
+ baseImage: `${repo}:php-8.1-magento-2.4`
30
+ }),
31
+ nginx: nginx118({ templateDir }),
32
+ redis: redis62(),
33
+ mysql: {
34
+ version: '8.0'
35
+ },
36
+ mariadb: mariadb104(),
37
+ elasticsearch: elasticsearch717(),
38
+ composer: composer2(),
39
+ varnish: varnish71({ templateDir }),
40
+ sslTerminator: sslTerminator({ templateDir }),
41
+ maildev: maildev()
42
+ },
43
+ magento: defaultMagentoConfig,
44
+ host: 'localhost',
45
+ ssl: {
46
+ enabled: false
47
+ }
48
+ })
@@ -0,0 +1,48 @@
1
+ const { defaultMagentoConfig } = require('../magento-config')
2
+ const sodium = require('../services/php/extensions/sodium')
3
+ const {
4
+ magento24PHPExtensionList
5
+ } = require('../magento/required-php-extensions')
6
+ const { php81 } = require('../services/php/versions')
7
+ const { sslTerminator } = require('../services/ssl-terminator')
8
+ const { varnish71 } = require('../services/varnish')
9
+ const { repo } = require('../services/php/base-repo')
10
+ const { nginx118 } = require('../services/nginx/versions')
11
+ const { composer2 } = require('../services/composer/versions')
12
+ const { maildev } = require('../services/maildev')
13
+ const { redis62 } = require('../services/redis')
14
+ const { mariadb104 } = require('../services/mariadb/versions')
15
+ const { elasticsearch717 } = require('../services/elasticsearch/versions')
16
+
17
+ /**
18
+ * @param {Object} param0
19
+ * @param {string} param0.templateDir
20
+ * @returns {import('../../../typings/index').CMAConfiguration & { magentoVersion: string, isDefault?: boolean }}
21
+ */
22
+ module.exports = ({ templateDir }) => ({
23
+ magentoVersion: '2.4.5-p2',
24
+ isDefault: true,
25
+ configuration: {
26
+ php: php81({
27
+ templateDir,
28
+ extensions: { ...magento24PHPExtensionList, sodium },
29
+ baseImage: `${repo}:php-8.1-magento-2.4`
30
+ }),
31
+ nginx: nginx118({ templateDir }),
32
+ redis: redis62(),
33
+ mysql: {
34
+ version: '8.0'
35
+ },
36
+ mariadb: mariadb104(),
37
+ elasticsearch: elasticsearch717(),
38
+ composer: composer2(),
39
+ varnish: varnish71({ templateDir }),
40
+ sslTerminator: sslTerminator({ templateDir }),
41
+ maildev: maildev()
42
+ },
43
+ magento: defaultMagentoConfig,
44
+ host: 'localhost',
45
+ ssl: {
46
+ enabled: false
47
+ }
48
+ })
@@ -0,0 +1,47 @@
1
+ const { defaultMagentoConfig } = require('../magento-config')
2
+ const sodium = require('../services/php/extensions/sodium')
3
+ const {
4
+ magento24PHPExtensionList
5
+ } = require('../magento/required-php-extensions')
6
+ const { php81 } = require('../services/php/versions')
7
+ const { sslTerminator } = require('../services/ssl-terminator')
8
+ const { varnish71 } = require('../services/varnish')
9
+ const { repo } = require('../services/php/base-repo')
10
+ const { nginx118 } = require('../services/nginx/versions')
11
+ const { composer2 } = require('../services/composer/versions')
12
+ const { maildev } = require('../services/maildev')
13
+ const { redis70 } = require('../services/redis')
14
+ const { mariadb104 } = require('../services/mariadb/versions')
15
+ const { elasticsearch84 } = require('../services/elasticsearch/versions')
16
+ const { mysql80 } = require('../services/mysql/versions')
17
+
18
+ /**
19
+ * @param {Object} param0
20
+ * @param {string} param0.templateDir
21
+ * @returns {import('../../../typings/index').CMAConfiguration & { magentoVersion: string, isDefault?: boolean }}
22
+ */
23
+ module.exports = ({ templateDir }) => ({
24
+ magentoVersion: '2.4.6',
25
+ isDefault: true,
26
+ configuration: {
27
+ php: php81({
28
+ templateDir,
29
+ extensions: { ...magento24PHPExtensionList, sodium },
30
+ baseImage: `${repo}:php-8.1-magento-2.4`
31
+ }),
32
+ nginx: nginx118({ templateDir }),
33
+ redis: redis70(),
34
+ mysql: mysql80(),
35
+ mariadb: mariadb104(),
36
+ elasticsearch: elasticsearch84(),
37
+ composer: composer2(),
38
+ varnish: varnish71({ templateDir }),
39
+ sslTerminator: sslTerminator({ templateDir }),
40
+ maildev: maildev()
41
+ },
42
+ magento: defaultMagentoConfig,
43
+ host: 'localhost',
44
+ ssl: {
45
+ enabled: false
46
+ }
47
+ })
@@ -14,7 +14,6 @@ const { imageApi } = require('./image')
14
14
  const getEnabledExtensionsFromImage = async (imageWithTag) => {
15
15
  const output = await runContainerImage(
16
16
  imageWithTag,
17
-
18
17
  `php -r 'foreach (get_loaded_extensions() as $extension) echo "$extension:" . phpversion($extension) . "\n";'`
19
18
  )
20
19
 
@@ -49,10 +49,34 @@ const importDump = () => ({
49
49
 
50
50
  return tableCount !== 0 || !isFsMatching
51
51
  },
52
- task: (subCtx, subTask) =>
53
- subTask.newListr(
52
+ task: async (subCtx, subTask) => {
53
+ const doYouWantToRunSetupOnEmptyDB =
54
+ await subTask.prompt({
55
+ type: 'Select',
56
+ message: `We detected that Magento is not installed in database. Do you want to install Magento in database BEFORE importing database dump?`,
57
+ choices: [
58
+ {
59
+ name: 'try-install',
60
+ message:
61
+ 'Try installing Magento before importing database'
62
+ },
63
+ {
64
+ name: 'skip',
65
+ message:
66
+ 'Skip installing Magento and import database dump right away!'
67
+ }
68
+ ]
69
+ })
70
+
71
+ if (doYouWantToRunSetupOnEmptyDB === 'skip') {
72
+ subTask.skip()
73
+ return
74
+ }
75
+
76
+ return subTask.newListr(
54
77
  setupMagento({ onlyInstallMagento: true })
55
78
  )
79
+ }
56
80
  },
57
81
  dumpThemeConfig(),
58
82
  importDumpToDatabase(),
@@ -9,12 +9,25 @@ module.exports = () => ({
9
9
  task: async (ctx, task) => {
10
10
  const { modules } = await configPhpToJson(ctx)
11
11
 
12
- if (
12
+ const isMagentoTFAEnabled =
13
13
  modules.Magento_TwoFactorAuth !== undefined &&
14
14
  modules.Magento_TwoFactorAuth !== 0
15
- ) {
15
+
16
+ const isMagentoAdminAdobeImsTwoFactorAuthEnabled =
17
+ modules.Magento_AdminAdobeImsTwoFactorAuth !== undefined &&
18
+ modules.Magento_AdminAdobeImsTwoFactorAuth !== 0
19
+
20
+ if (isMagentoAdminAdobeImsTwoFactorAuthEnabled) {
21
+ await runMagentoCommand(
22
+ ctx,
23
+ 'module:disable Magento_AdminAdobeImsTwoFactorAuth'
24
+ )
25
+ }
26
+ if (isMagentoTFAEnabled) {
16
27
  await runMagentoCommand(ctx, 'module:disable Magento_TwoFactorAuth')
28
+ }
17
29
 
30
+ if (isMagentoAdminAdobeImsTwoFactorAuthEnabled || isMagentoTFAEnabled) {
18
31
  return
19
32
  }
20
33
 
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.5",
6
+ "version": "2.1.0-alpha.0",
7
7
  "main": "./index.js",
8
8
  "types": "./typings/index.d.ts",
9
9
  "license": "OSL-3.0",
@@ -58,5 +58,5 @@
58
58
  "devDependencies": {
59
59
  "@types/yargs": "^17.0.13"
60
60
  },
61
- "gitHead": "d12aab28f4ee25c341951dd1df962aa84ddf2782"
61
+ "gitHead": "889405f4c430f5a89f31ddd7bd0caf7beed2ec90"
62
62
  }
@@ -274,9 +274,7 @@ export interface CMAConfiguration {
274
274
  /**
275
275
  * @deprecated MySQL configuration
276
276
  */
277
- mysql: {
278
- version: string
279
- }
277
+ mysql: ServiceWithImage
280
278
  }
281
279
  /**
282
280
  * Magento configuration