@scandipwa/magento-scripts 2.4.7 → 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.
- package/lib/config/docker.js +2 -2
- package/lib/config/port-config.js +26 -0
- package/lib/config/templates/git-postcheckout-hook.template +21 -5
- package/lib/tasks/docker/containers/container-api.js +26 -22
- package/lib/tasks/file-system/create-git-hook-notification.js +6 -1
- package/lib/tasks/php/update-env-php.js +1 -1
- package/lib/tasks/requirements/node-version.js +1 -1
- 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
|
|
@@ -33,12 +33,13 @@ OLD_BRANCH=$(git name-rev --name-only "$OLD_REF" 2>/dev/null | sed 's/^remotes\/
|
|
|
33
33
|
NEW_BRANCH=$(git name-rev --name-only "$NEW_REF" 2>/dev/null | sed 's/^remotes\///' || echo "$NEW_REF")
|
|
34
34
|
|
|
35
35
|
MESSAGE_TITLE="Composer dependencies changed"
|
|
36
|
-
MESSAGE_BODY="Changes detected in: $CHANGED_DIR\nBranch: $OLD_BRANCH → $NEW_BRANCH\n\nPlease run composer install or npm run start"
|
|
36
|
+
MESSAGE_BODY="Changes detected in: $CHANGED_DIR\nBranch: $OLD_BRANCH → $NEW_BRANCH\n\nPlease run composer install (in CLI) or npm run start"
|
|
37
37
|
|
|
38
38
|
# Cross-platform desktop notification with multiple fallbacks
|
|
39
39
|
send_notification() {
|
|
40
40
|
local title="$1"
|
|
41
41
|
local body="$2"
|
|
42
|
+
local mac_alert_file="/tmp/.git_postcheckout_alert_shown"
|
|
42
43
|
|
|
43
44
|
# Try Linux notify-send first
|
|
44
45
|
if command -v notify-send >/dev/null 2>&1; then
|
|
@@ -46,15 +47,25 @@ send_notification() {
|
|
|
46
47
|
return 0
|
|
47
48
|
fi
|
|
48
49
|
|
|
49
|
-
# Try macOS terminal-notifier
|
|
50
|
+
# Try macOS terminal-notifier (alert once, then notification)
|
|
50
51
|
if command -v terminal-notifier >/dev/null 2>&1; then
|
|
51
|
-
|
|
52
|
+
if [ ! -f "$mac_alert_file" ]; then
|
|
53
|
+
terminal-notifier -title "$title" -message "$body" -sound Basso
|
|
54
|
+
touch "$mac_alert_file"
|
|
55
|
+
else
|
|
56
|
+
terminal-notifier -title "$title" -message "$body" -timeout 8
|
|
57
|
+
fi
|
|
52
58
|
return 0
|
|
53
59
|
fi
|
|
54
60
|
|
|
55
|
-
# Try macOS osascript (AppleScript) as fallback
|
|
61
|
+
# Try macOS osascript (AppleScript) as fallback (alert once, then notification)
|
|
56
62
|
if command -v osascript >/dev/null 2>&1; then
|
|
57
|
-
|
|
63
|
+
if [ ! -f "$mac_alert_file" ]; then
|
|
64
|
+
osascript -e "display alert \"$title\" message \"$body\""
|
|
65
|
+
touch "$mac_alert_file"
|
|
66
|
+
else
|
|
67
|
+
osascript -e "display notification \"$body\" with title \"$title\""
|
|
68
|
+
fi
|
|
58
69
|
return 0
|
|
59
70
|
fi
|
|
60
71
|
|
|
@@ -64,3 +75,8 @@ send_notification() {
|
|
|
64
75
|
}
|
|
65
76
|
|
|
66
77
|
send_notification "$MESSAGE_TITLE" "$MESSAGE_BODY"
|
|
78
|
+
|
|
79
|
+
echo ""
|
|
80
|
+
echo "$MESSAGE_TITLE"
|
|
81
|
+
echo ""
|
|
82
|
+
echo "$MESSAGE_BODY"
|
|
@@ -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 =
|
|
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}` : ''
|
|
@@ -36,6 +36,11 @@ const createGitHookNotification = () => ({
|
|
|
36
36
|
})
|
|
37
37
|
])
|
|
38
38
|
|
|
39
|
+
if (gitRootResult.code === 128) {
|
|
40
|
+
task.skip('not a git repository')
|
|
41
|
+
return
|
|
42
|
+
}
|
|
43
|
+
|
|
39
44
|
if (gitRootResult.code !== 0) {
|
|
40
45
|
throw new UnknownError(
|
|
41
46
|
`Unexpected error accrued during git hook notification creation\n\n${gitRootResult.result}`
|
|
@@ -68,7 +73,7 @@ const createGitHookNotification = () => ({
|
|
|
68
73
|
|
|
69
74
|
tasks.push({
|
|
70
75
|
title: 'Copying Git Hook Template',
|
|
71
|
-
skip: async () =>
|
|
76
|
+
skip: async () => await pathExists(gitHookPath),
|
|
72
77
|
task: async () => {
|
|
73
78
|
await fs.promises.cp(gitHookTemplatePath, gitHookPath)
|
|
74
79
|
}
|
|
@@ -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!`
|
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.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": "
|
|
62
|
+
"gitHead": "70cc10b1dbc83ddd0917ae02fef3b09e8bcaba52"
|
|
63
63
|
}
|