@scandipwa/magento-scripts 2.4.8 → 2.4.9-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.
- package/lib/config/docker.js +2 -2
- package/lib/config/port-config.js +26 -0
- package/lib/tasks/docker/containers/container-api.js +26 -22
- package/lib/tasks/php/update-env-php.js +1 -1
- package/lib/tasks/requirements/node-version.js +1 -1
- package/lib/util/exec-async-command.d.ts +1 -0
- package/lib/util/exec-async-command.js +10 -3
- package/lib/util/execute-in-container.js +16 -20
- package/package.json +2 -2
package/lib/config/docker.js
CHANGED
|
@@ -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:
|
|
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' && val) {
|
|
19
|
+
envArguments.push(`--env ${key}='${val.replaceAll("'", "\\'")}'`)
|
|
20
|
+
} else if (String(val)) {
|
|
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 =
|
|
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 =
|
|
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:
|
|
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
|
+
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!`
|
|
@@ -12,6 +12,7 @@ const execAsyncSpawn = (
|
|
|
12
12
|
{
|
|
13
13
|
callback,
|
|
14
14
|
pipeInput,
|
|
15
|
+
pipeOutput,
|
|
15
16
|
logOutput = false,
|
|
16
17
|
cwd,
|
|
17
18
|
withCode = false,
|
|
@@ -23,7 +24,11 @@ const execAsyncSpawn = (
|
|
|
23
24
|
* @type {import('child_process').SpawnOptionsWithoutStdio}
|
|
24
25
|
*/
|
|
25
26
|
const spawnOptions = {
|
|
26
|
-
stdio: pipeInput
|
|
27
|
+
stdio: pipeInput
|
|
28
|
+
? ['inherit', 'pipe', 'pipe']
|
|
29
|
+
: pipeOutput
|
|
30
|
+
? 'inherit'
|
|
31
|
+
: 'pipe',
|
|
27
32
|
cwd,
|
|
28
33
|
env
|
|
29
34
|
}
|
|
@@ -74,8 +79,10 @@ const execAsyncSpawn = (
|
|
|
74
79
|
}
|
|
75
80
|
}
|
|
76
81
|
|
|
77
|
-
|
|
78
|
-
|
|
82
|
+
if (!pipeOutput) {
|
|
83
|
+
childProcess.stdout.on('data', addChunk)
|
|
84
|
+
childProcess.stderr.on('data', addChunk)
|
|
85
|
+
}
|
|
79
86
|
|
|
80
87
|
childProcess.on('error', (error) => {
|
|
81
88
|
reject(error)
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
const { spawn } = require('child_process')
|
|
2
|
-
const {
|
|
3
|
-
runCommand,
|
|
4
|
-
execCommand
|
|
5
|
-
} = require('../tasks/docker/containers/container-api')
|
|
2
|
+
const { execCommand, run } = require('../tasks/docker/containers/container-api')
|
|
6
3
|
|
|
7
4
|
/**
|
|
8
5
|
* @param {{ containerName: string, commands: string[], user?: string }} param0
|
|
@@ -36,30 +33,29 @@ const executeInContainer = ({ containerName, commands, user }) => {
|
|
|
36
33
|
* @param {import('../tasks/docker/containers/container-api').ContainerRunOptions} options
|
|
37
34
|
* @param {string[]} commands
|
|
38
35
|
*/
|
|
39
|
-
const runInContainer = (options, commands) => {
|
|
36
|
+
const runInContainer = async (options, commands) => {
|
|
40
37
|
if (!process.stdin.isTTY) {
|
|
41
38
|
process.stderr.write('This app works only in TTY mode')
|
|
42
39
|
process.exit(1)
|
|
43
40
|
}
|
|
44
41
|
|
|
45
|
-
const runArgs = runCommand({
|
|
46
|
-
...options,
|
|
47
|
-
tty: true,
|
|
48
|
-
detach: false,
|
|
49
|
-
rm: true
|
|
50
|
-
})
|
|
51
|
-
|
|
52
42
|
const [commandBin, ...commandsArgs] = commands
|
|
53
43
|
|
|
54
|
-
const
|
|
44
|
+
const runResult = await run(
|
|
45
|
+
{
|
|
46
|
+
...options,
|
|
47
|
+
command: `${commandBin} ${commandsArgs.join(' ')}`,
|
|
48
|
+
tty: true,
|
|
49
|
+
detach: false,
|
|
50
|
+
rm: true
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
withCode: true,
|
|
54
|
+
pipeOutput: true
|
|
55
|
+
}
|
|
56
|
+
)
|
|
55
57
|
|
|
56
|
-
|
|
57
|
-
stdio: 'inherit'
|
|
58
|
-
})
|
|
59
|
-
|
|
60
|
-
child.on('close', (code) => {
|
|
61
|
-
process.exit(code)
|
|
62
|
-
})
|
|
58
|
+
process.exit(runResult.code)
|
|
63
59
|
}
|
|
64
60
|
|
|
65
61
|
module.exports = {
|
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.
|
|
6
|
+
"version": "2.4.9-alpha.1",
|
|
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": "
|
|
62
|
+
"gitHead": "b26dcbe7ae4d2334db66adf0fecd6668154bbd22"
|
|
63
63
|
}
|