@scandipwa/magento-scripts 2.4.8 → 2.4.9-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.
@@ -114,11 +114,11 @@ module.exports = async (ctx, overridenConfiguration, baseConfig) => {
114
114
  const getContainers = (ports = {}) => {
115
115
  const composerAuthEnv = process.env.COMPOSER_AUTH
116
116
  ? {
117
- COMPOSER_AUTH: `'${JSON.stringify(
117
+ COMPOSER_AUTH: `${JSON.stringify(
118
118
  JSON.parse(process.env.COMPOSER_AUTH),
119
119
  null,
120
120
  0
121
- )}'`
121
+ )}`
122
122
  }
123
123
  : {}
124
124
 
@@ -35,6 +35,30 @@ const getUsedByOtherCMAProjectsPorts = async () => {
35
35
  )
36
36
  }
37
37
 
38
+ const getUsedByOtherCMAProjectsXDebugPorts = async () => {
39
+ const portConfigs = await Promise.all(
40
+ Object.keys(getProjects())
41
+ .filter((projectPath) => projectPath !== process.cwd())
42
+ .map((projectPath) =>
43
+ getJsonfileData(
44
+ path.join(
45
+ projectPath,
46
+ 'node_modules',
47
+ '.create-magento-app-cache',
48
+ 'port-config.json'
49
+ )
50
+ )
51
+ )
52
+ )
53
+
54
+ const xdebugPorts = portConfigs
55
+ .filter(Boolean)
56
+ .map((portConfig) => portConfig.xdebug)
57
+ .filter(Boolean)
58
+
59
+ return Array.from(new Set(xdebugPorts))
60
+ }
61
+
38
62
  /**
39
63
  * @param {Number} port
40
64
  * @param {Object} [options]
@@ -99,6 +123,8 @@ const getPortsConfig = async (ports, options = {}) => {
99
123
 
100
124
  if (useNonOverlappingPorts) {
101
125
  p = p.concat(await getUsedByOtherCMAProjectsPorts())
126
+ } else {
127
+ p = p.concat(await getUsedByOtherCMAProjectsXDebugPorts())
102
128
  }
103
129
 
104
130
  const { xdebug: _, ...portsWithoutXDebug } = mergedPorts
@@ -1,6 +1,30 @@
1
1
  /* eslint-disable max-len */
2
2
  const { execAsyncSpawn } = require('../../../util/exec-async-command')
3
3
 
4
+ /**
5
+ * @param {Record<string, unknown> | undefined} value
6
+ */
7
+ const transformEnvValue = (value) => {
8
+ if (!value) {
9
+ return ''
10
+ }
11
+
12
+ // Yes, it is made using for loop for better readability
13
+
14
+ /** @type {string[]} */
15
+ const envArguments = []
16
+
17
+ for (const [key, val] of Object.entries(value)) {
18
+ if (typeof val === 'string') {
19
+ envArguments.push(`--env ${key}='${val.replaceAll("'", "\\'")}'`)
20
+ } else {
21
+ envArguments.push(`--env ${key}=${val}`)
22
+ }
23
+ }
24
+
25
+ return envArguments
26
+ }
27
+
4
28
  /**
5
29
  * @param {import('./container-api').ContainerRunOptions} options
6
30
  * @returns {string[]}
@@ -48,16 +72,7 @@ const runCommand = (options) => {
48
72
  (mount) => `-v=${mount.replaceAll(' ', '\\ ')}`
49
73
  )) ||
50
74
  ''
51
- const envArgs = !env
52
- ? ''
53
- : Object.entries(env).map(
54
- ([key, value]) =>
55
- `--env=${key}=${
56
- typeof value === 'string'
57
- ? value.replaceAll(' ', '\\ ')
58
- : value
59
- }`
60
- )
75
+ const envArgs = transformEnvValue(env)
61
76
  const nameArg = (name && `--name=${name}`) || ''
62
77
  const entrypointArg = (entrypoint && `--entrypoint="${entrypoint}"`) || ''
63
78
  const healthCheckArg =
@@ -120,18 +135,7 @@ const run = (options, execOptions = {}) =>
120
135
  */
121
136
  const execCommand = (options) => {
122
137
  const { command, container, env, tty, user, workdir, interactive } = options
123
- const envArgs = !env
124
- ? ''
125
- : Object.entries(env)
126
- .map(
127
- ([key, value]) =>
128
- `--env=${key}=${
129
- typeof value === 'string'
130
- ? value.replaceAll(' ', '\\ ')
131
- : value
132
- }`
133
- )
134
- .join(' ')
138
+ const envArgs = transformEnvValue(env)
135
139
  const ttyArg = tty ? '--tty' : ''
136
140
  const userArg = user ? `--user=${user}` : ''
137
141
  const workdirArg = workdir ? `--workdir=${workdir}` : ''
@@ -62,7 +62,7 @@ const updateEnvPHP = () => ({
62
62
  REDIS_PORT: ctx.ports.redis,
63
63
  ADMIN_URI: ctx.config.overridenConfiguration.magento.adminuri,
64
64
  HOST_MACHINE: hostMachine,
65
- PORTS: `'${JSON.stringify(ctx.ports)}'`
65
+ PORTS: `${JSON.stringify(ctx.ports)}`
66
66
  },
67
67
  command: 'php ./update-env.php',
68
68
  mountVolumes: [
@@ -9,7 +9,7 @@ const checkNodeVersion = () => ({
9
9
  task: (ctx, task) => {
10
10
  const { node } = process.versions
11
11
 
12
- if (!semver.gte(node, '12.0.0')) {
12
+ if (!semver.gte(node, '16.0.0')) {
13
13
  throw new KnownError(
14
14
  `Your Node.js version is out of date!
15
15
  You need to upgrade Node.js to at lease version 12 to work with this software!`
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.4.8",
6
+ "version": "2.4.9-alpha.0",
7
7
  "main": "./index.js",
8
8
  "types": "./typings/index.d.ts",
9
9
  "license": "OSL-3.0",
@@ -59,5 +59,5 @@
59
59
  "@types/node": "^20.14.11",
60
60
  "@types/yargs": "^17.0.32"
61
61
  },
62
- "gitHead": "f3b396e1d55aa323326cc49ebe03faed8b6eed46"
62
+ "gitHead": "70cc10b1dbc83ddd0917ae02fef3b09e8bcaba52"
63
63
  }