@scandipwa/magento-scripts 2.4.5 → 2.4.6
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 +49 -11
- package/lib/tasks/docker/containers/container-api.d.ts +5 -0
- package/lib/tasks/docker/containers/container-api.js +16 -3
- package/lib/tasks/docker/project-image-builder.js +27 -6
- package/lib/tasks/file-system/create-git-hook-notification.js +64 -30
- package/package.json +2 -2
- package/typings/context.d.ts +1 -0
package/lib/config/docker.js
CHANGED
|
@@ -9,6 +9,14 @@ const defaultEsEnv = require('./services/elasticsearch/default-es-env')
|
|
|
9
9
|
const logger = require('@scandipwa/scandipwa-dev-utils/logger')
|
|
10
10
|
const defaultMagentoUser = require('../tasks/database/default-magento-user')
|
|
11
11
|
const defaultOsEnv = require('./services/opensearch/default-os-env')
|
|
12
|
+
const { getArchSync } = require('../util/arch')
|
|
13
|
+
|
|
14
|
+
const rosettaTranslatedContainers =
|
|
15
|
+
os.platform() === 'darwin' &&
|
|
16
|
+
getArchSync() === 'arm64' &&
|
|
17
|
+
process.env.CMA_USE_AMD64_CONTAINERS
|
|
18
|
+
? process.env.CMA_USE_AMD64_CONTAINERS.split(',')
|
|
19
|
+
: []
|
|
12
20
|
|
|
13
21
|
/**
|
|
14
22
|
* @param {Partial<Record<'rw' | 'ro' | 'cached', boolean>>} directives
|
|
@@ -115,7 +123,7 @@ module.exports = async (ctx, overridenConfiguration, baseConfig) => {
|
|
|
115
123
|
: {}
|
|
116
124
|
|
|
117
125
|
/**
|
|
118
|
-
* @type {Record<string, import('../tasks/docker/containers/container-api').ContainerRunOptions & { _?: string, forwardedPorts?: string[], remoteImages?: string[], connectCommand?: string[], description?: string, pullImage?: boolean, dependsOn?: string[], serviceReadyLog?: string }>}
|
|
126
|
+
* @type {Record<string, import('../tasks/docker/containers/container-api').ContainerRunOptions & { _?: string, forwardedPorts?: string[], remoteImages?: string[], connectCommand?: string[], description?: string, pullImage?: boolean, dependsOn?: string[], serviceReadyLog?: string, platform?: string }>}
|
|
119
127
|
*/
|
|
120
128
|
const dockerConfig = {
|
|
121
129
|
php: {
|
|
@@ -168,7 +176,10 @@ module.exports = async (ctx, overridenConfiguration, baseConfig) => {
|
|
|
168
176
|
!isDockerDesktop
|
|
169
177
|
? `${os.userInfo().uid}:${os.userInfo().gid}`
|
|
170
178
|
: '',
|
|
171
|
-
serviceReadyLog: 'ready to handle connections'
|
|
179
|
+
serviceReadyLog: 'ready to handle connections',
|
|
180
|
+
platform: rosettaTranslatedContainers.includes('php')
|
|
181
|
+
? 'linux/amd64'
|
|
182
|
+
: undefined
|
|
172
183
|
},
|
|
173
184
|
phpWithXdebug: {
|
|
174
185
|
_: 'PHP with Xdebug',
|
|
@@ -226,7 +237,10 @@ module.exports = async (ctx, overridenConfiguration, baseConfig) => {
|
|
|
226
237
|
!isDockerDesktop
|
|
227
238
|
? `${os.userInfo().uid}:${os.userInfo().gid}`
|
|
228
239
|
: '',
|
|
229
|
-
serviceReadyLog: 'ready to handle connections'
|
|
240
|
+
serviceReadyLog: 'ready to handle connections',
|
|
241
|
+
platform: rosettaTranslatedContainers.includes('php')
|
|
242
|
+
? 'linux/amd64'
|
|
243
|
+
: undefined
|
|
230
244
|
},
|
|
231
245
|
sslTerminator: {
|
|
232
246
|
_: 'SSL Terminator (Nginx)',
|
|
@@ -270,7 +284,10 @@ module.exports = async (ctx, overridenConfiguration, baseConfig) => {
|
|
|
270
284
|
}`,
|
|
271
285
|
name: `${prefix}_ssl-terminator`,
|
|
272
286
|
command: "nginx -g 'daemon off;'",
|
|
273
|
-
dependsOn: ['nginx']
|
|
287
|
+
dependsOn: ['nginx'],
|
|
288
|
+
platform: rosettaTranslatedContainers.includes('nginx')
|
|
289
|
+
? 'linux/amd64'
|
|
290
|
+
: undefined
|
|
274
291
|
},
|
|
275
292
|
nginx: {
|
|
276
293
|
_: 'Nginx',
|
|
@@ -319,7 +336,10 @@ module.exports = async (ctx, overridenConfiguration, baseConfig) => {
|
|
|
319
336
|
}`,
|
|
320
337
|
name: `${prefix}_nginx`,
|
|
321
338
|
command: "nginx -g 'daemon off;'",
|
|
322
|
-
dependsOn: ['php', 'phpWithXdebug']
|
|
339
|
+
dependsOn: ['php', 'phpWithXdebug'],
|
|
340
|
+
platform: rosettaTranslatedContainers.includes('nginx')
|
|
341
|
+
? 'linux/amd64'
|
|
342
|
+
: undefined
|
|
323
343
|
},
|
|
324
344
|
redis: {
|
|
325
345
|
_: 'Redis',
|
|
@@ -335,7 +355,10 @@ module.exports = async (ctx, overridenConfiguration, baseConfig) => {
|
|
|
335
355
|
}`,
|
|
336
356
|
name: `${prefix}_redis`,
|
|
337
357
|
connectCommand: ['redis-cli'],
|
|
338
|
-
serviceReadyLog: 'Ready to accept connections'
|
|
358
|
+
serviceReadyLog: 'Ready to accept connections',
|
|
359
|
+
platform: rosettaTranslatedContainers.includes('redis')
|
|
360
|
+
? 'linux/amd64'
|
|
361
|
+
: undefined
|
|
339
362
|
},
|
|
340
363
|
mariadb: {
|
|
341
364
|
_: 'MariaDB',
|
|
@@ -376,7 +399,10 @@ module.exports = async (ctx, overridenConfiguration, baseConfig) => {
|
|
|
376
399
|
defaultMagentoUser.user
|
|
377
400
|
)} with password ${logger.style.command(
|
|
378
401
|
defaultMagentoUser.password
|
|
379
|
-
)}
|
|
402
|
+
)}`,
|
|
403
|
+
platform: rosettaTranslatedContainers.includes('mariadb')
|
|
404
|
+
? 'linux/amd64'
|
|
405
|
+
: undefined
|
|
380
406
|
},
|
|
381
407
|
elasticsearch: {
|
|
382
408
|
_:
|
|
@@ -419,7 +445,10 @@ module.exports = async (ctx, overridenConfiguration, baseConfig) => {
|
|
|
419
445
|
: elasticsearch.image
|
|
420
446
|
: opensearch.image
|
|
421
447
|
}`,
|
|
422
|
-
name: `${prefix}_${searchengine}
|
|
448
|
+
name: `${prefix}_${searchengine}`,
|
|
449
|
+
platform: rosettaTranslatedContainers.includes(searchengine)
|
|
450
|
+
? 'linux/amd64'
|
|
451
|
+
: undefined
|
|
423
452
|
},
|
|
424
453
|
maildev: {
|
|
425
454
|
_: 'MailDev',
|
|
@@ -462,7 +491,10 @@ module.exports = async (ctx, overridenConfiguration, baseConfig) => {
|
|
|
462
491
|
cmd: `wget -O - http://127.0.0.1:${
|
|
463
492
|
isDockerDesktop ? '1080' : ports.maildevWeb
|
|
464
493
|
}/healthz || exit 1`
|
|
465
|
-
}
|
|
494
|
+
},
|
|
495
|
+
platform: rosettaTranslatedContainers.includes('maildev')
|
|
496
|
+
? 'linux/amd64'
|
|
497
|
+
: undefined
|
|
466
498
|
}
|
|
467
499
|
}
|
|
468
500
|
|
|
@@ -515,7 +547,10 @@ module.exports = async (ctx, overridenConfiguration, baseConfig) => {
|
|
|
515
547
|
description: `Varnish HealthCheck status: ${logger.style.command(
|
|
516
548
|
varnish.healthCheck ? 'enabled' : 'disabled'
|
|
517
549
|
)}`,
|
|
518
|
-
dependsOn: ['nginx']
|
|
550
|
+
dependsOn: ['nginx'],
|
|
551
|
+
platform: rosettaTranslatedContainers.includes('varnish')
|
|
552
|
+
? 'linux/amd64'
|
|
553
|
+
: undefined
|
|
519
554
|
}
|
|
520
555
|
|
|
521
556
|
dockerConfig.sslTerminator.dependsOn.push('varnish')
|
|
@@ -527,7 +562,10 @@ module.exports = async (ctx, overridenConfiguration, baseConfig) => {
|
|
|
527
562
|
ports: [],
|
|
528
563
|
name: `${prefix}_newrelic-php-daemon`,
|
|
529
564
|
network: isDockerDesktop ? network.name : 'host',
|
|
530
|
-
image: 'newrelic/php-daemon'
|
|
565
|
+
image: 'newrelic/php-daemon',
|
|
566
|
+
platform: rosettaTranslatedContainers.includes('newrelic')
|
|
567
|
+
? 'linux/amd64'
|
|
568
|
+
: undefined
|
|
531
569
|
}
|
|
532
570
|
}
|
|
533
571
|
|
|
@@ -161,6 +161,11 @@ export interface ContainerRunOptions {
|
|
|
161
161
|
* Memory option [docs](https://docs.docker.com/engine/reference/commandline/run/#memory)
|
|
162
162
|
*/
|
|
163
163
|
memory?: string
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Platform option [docs](https://docs.docker.com/engine/reference/commandline/run/#platform)
|
|
167
|
+
*/
|
|
168
|
+
platform?: string
|
|
164
169
|
}
|
|
165
170
|
|
|
166
171
|
export function run<T>(
|
|
@@ -26,7 +26,8 @@ const runCommand = (options) => {
|
|
|
26
26
|
rm = false,
|
|
27
27
|
tty = false,
|
|
28
28
|
user,
|
|
29
|
-
memory
|
|
29
|
+
memory,
|
|
30
|
+
platform
|
|
30
31
|
} = options
|
|
31
32
|
|
|
32
33
|
const detachArg = (detach && '-d') || ''
|
|
@@ -49,7 +50,14 @@ const runCommand = (options) => {
|
|
|
49
50
|
''
|
|
50
51
|
const envArgs = !env
|
|
51
52
|
? ''
|
|
52
|
-
: Object.entries(env).map(
|
|
53
|
+
: Object.entries(env).map(
|
|
54
|
+
([key, value]) =>
|
|
55
|
+
`--env=${key}=${
|
|
56
|
+
typeof value === 'string'
|
|
57
|
+
? value.replaceAll(' ', '\\ ')
|
|
58
|
+
: value
|
|
59
|
+
}`
|
|
60
|
+
)
|
|
53
61
|
const nameArg = (name && `--name=${name}`) || ''
|
|
54
62
|
const entrypointArg = (entrypoint && `--entrypoint="${entrypoint}"`) || ''
|
|
55
63
|
const healthCheckArg =
|
|
@@ -67,6 +75,7 @@ const runCommand = (options) => {
|
|
|
67
75
|
const userArg = (user && `--user=${user}`) || ''
|
|
68
76
|
const addHostArg = (addHost && `--add-host=${addHost}`) || ''
|
|
69
77
|
const memoryArg = (memory && `--memory=${memory}`) || ''
|
|
78
|
+
const platformArg = (platform && `--platform=${platform}`) || ''
|
|
70
79
|
|
|
71
80
|
const dockerCommand = [
|
|
72
81
|
'docker',
|
|
@@ -89,6 +98,7 @@ const runCommand = (options) => {
|
|
|
89
98
|
userArg,
|
|
90
99
|
addHostArg,
|
|
91
100
|
memoryArg,
|
|
101
|
+
platformArg,
|
|
92
102
|
image,
|
|
93
103
|
command
|
|
94
104
|
]
|
|
@@ -113,7 +123,10 @@ const execCommand = (options) => {
|
|
|
113
123
|
const envArgs = !env
|
|
114
124
|
? ''
|
|
115
125
|
: Object.entries(env)
|
|
116
|
-
.map(
|
|
126
|
+
.map(
|
|
127
|
+
([key, value]) =>
|
|
128
|
+
`--env ${key}=${value.replaceAll(' ', '\\ ')}`
|
|
129
|
+
)
|
|
117
130
|
.join(' ')
|
|
118
131
|
const ttyArg = tty ? '--tty' : ''
|
|
119
132
|
const userArg = user ? `--user=${user}` : ''
|
|
@@ -5,7 +5,14 @@ const { execAsyncSpawn } = require('../../util/exec-async-command')
|
|
|
5
5
|
const KnownError = require('../../errors/known-error')
|
|
6
6
|
const { runContainerImage } = require('../../util/run-container-image')
|
|
7
7
|
const { imageApi } = require('./image')
|
|
8
|
-
|
|
8
|
+
const { getArchSync } = require('../../util/arch')
|
|
9
|
+
|
|
10
|
+
const rosettaTranslatedContainers =
|
|
11
|
+
os.platform() === 'darwin' &&
|
|
12
|
+
getArchSync() === 'arm64' &&
|
|
13
|
+
process.env.CMA_USE_AMD64_CONTAINERS
|
|
14
|
+
? process.env.CMA_USE_AMD64_CONTAINERS.split(',')
|
|
15
|
+
: []
|
|
9
16
|
/**
|
|
10
17
|
* Get enabled extensions list with versions
|
|
11
18
|
* @param {string} imageWithTag
|
|
@@ -297,13 +304,17 @@ const buildDebugDockerFileInstructions = async (ctx, { image, tag }) => {
|
|
|
297
304
|
* @returns {import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
|
|
298
305
|
*/
|
|
299
306
|
const buildProjectImage = () => ({
|
|
300
|
-
title: '
|
|
307
|
+
title: rosettaTranslatedContainers.includes('php')
|
|
308
|
+
? 'Building Project Images (for x86)'
|
|
309
|
+
: 'Building Project Images',
|
|
301
310
|
task: async (ctx, task) => {
|
|
302
311
|
const containers = ctx.config.docker.getContainers(ctx.ports)
|
|
303
312
|
|
|
304
313
|
return task.newListr([
|
|
305
314
|
{
|
|
306
|
-
title: '
|
|
315
|
+
title: rosettaTranslatedContainers.includes('php')
|
|
316
|
+
? 'Building PHP image (for x86)'
|
|
317
|
+
: 'Building PHP image',
|
|
307
318
|
task: async () => {
|
|
308
319
|
const [image, tag = 'latest'] =
|
|
309
320
|
ctx.config.overridenConfiguration.configuration.php.baseImage.split(
|
|
@@ -318,7 +329,11 @@ const buildProjectImage = () => ({
|
|
|
318
329
|
|
|
319
330
|
try {
|
|
320
331
|
await execAsyncSpawn(
|
|
321
|
-
`docker build -t ${containers.php.image}
|
|
332
|
+
`docker build -t ${containers.php.image}${
|
|
333
|
+
rosettaTranslatedContainers.includes('php')
|
|
334
|
+
? ' --platform linux/amd64'
|
|
335
|
+
: ''
|
|
336
|
+
} -<<EOF
|
|
322
337
|
${dockerFileInstructions}
|
|
323
338
|
EOF`,
|
|
324
339
|
{
|
|
@@ -337,7 +352,9 @@ EOF`,
|
|
|
337
352
|
}
|
|
338
353
|
},
|
|
339
354
|
{
|
|
340
|
-
title: '
|
|
355
|
+
title: rosettaTranslatedContainers.includes('php')
|
|
356
|
+
? 'Building PHP with XDebug image (for x86)'
|
|
357
|
+
: 'Building PHP with XDebug image',
|
|
341
358
|
task: async () => {
|
|
342
359
|
const [phpImage, phpTag] = containers.php.image.split(':')
|
|
343
360
|
const debugImageInstructions =
|
|
@@ -348,7 +365,11 @@ EOF`,
|
|
|
348
365
|
|
|
349
366
|
try {
|
|
350
367
|
await execAsyncSpawn(
|
|
351
|
-
`docker build -t ${containers.phpWithXdebug.image}
|
|
368
|
+
`docker build -t ${containers.phpWithXdebug.image}${
|
|
369
|
+
rosettaTranslatedContainers.includes('php')
|
|
370
|
+
? ' --platform linux/amd64'
|
|
371
|
+
: ''
|
|
372
|
+
} -<<EOF
|
|
352
373
|
${debugImageInstructions}
|
|
353
374
|
EOF`,
|
|
354
375
|
{
|
|
@@ -1,58 +1,92 @@
|
|
|
1
1
|
const path = require('path')
|
|
2
2
|
const fs = require('fs')
|
|
3
3
|
const UnknownError = require('../../errors/unknown-error')
|
|
4
|
-
const setConfigFile = require('../../util/set-config')
|
|
5
4
|
const { execAsyncSpawn } = require('../../util/exec-async-command')
|
|
5
|
+
const pathExists = require('../../util/path-exists')
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @param {string} p
|
|
9
|
+
*/
|
|
10
|
+
function isExec(p) {
|
|
11
|
+
try {
|
|
12
|
+
fs.accessSync(p, fs.constants.X_OK)
|
|
13
|
+
return true
|
|
14
|
+
} catch (e) {
|
|
15
|
+
return false
|
|
16
|
+
}
|
|
17
|
+
}
|
|
6
18
|
|
|
7
19
|
/**
|
|
8
20
|
* @returns {import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
|
|
9
21
|
*/
|
|
10
22
|
const createGitHookNotification = () => ({
|
|
11
|
-
title: 'Setting
|
|
12
|
-
task: async (ctx) => {
|
|
23
|
+
title: 'Setting Git Hook Notification',
|
|
24
|
+
task: async (ctx, task) => {
|
|
13
25
|
const gitHookTemplatePath = path.join(
|
|
14
26
|
ctx.config.baseConfig.templateDir,
|
|
15
27
|
'git-postcheckout-hook.template'
|
|
16
28
|
)
|
|
17
29
|
|
|
18
|
-
const
|
|
30
|
+
const [gitRootResult, currentGitHookPathResult] = await Promise.all([
|
|
31
|
+
execAsyncSpawn('git rev-parse --show-toplevel', {
|
|
32
|
+
withCode: true
|
|
33
|
+
}),
|
|
34
|
+
execAsyncSpawn(`git config --get core.hooksPath`, {
|
|
35
|
+
withCode: true
|
|
36
|
+
})
|
|
37
|
+
])
|
|
19
38
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
39
|
+
if (gitRootResult.code !== 0) {
|
|
40
|
+
throw new UnknownError(
|
|
41
|
+
`Unexpected error accrued during git hook notification creation\n\n${gitRootResult.result}`
|
|
42
|
+
)
|
|
43
|
+
}
|
|
23
44
|
|
|
24
|
-
|
|
25
|
-
await execAsyncSpawn(`git config core.hooksPath .git/hooks`)
|
|
45
|
+
const tasks = []
|
|
26
46
|
|
|
27
|
-
|
|
47
|
+
if (!currentGitHookPathResult.result.trim()) {
|
|
48
|
+
tasks.push({
|
|
49
|
+
title: 'Setting Git Hook Path',
|
|
50
|
+
task: async () => {
|
|
51
|
+
await execAsyncSpawn(
|
|
52
|
+
`git config core.hooksPath .git/hooks`,
|
|
53
|
+
{
|
|
54
|
+
withCode: true
|
|
55
|
+
}
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
currentGitHookPathResult.result = '.git/hooks'
|
|
59
|
+
}
|
|
60
|
+
})
|
|
28
61
|
}
|
|
29
62
|
|
|
30
63
|
const gitHookPath = path.join(
|
|
31
|
-
|
|
32
|
-
|
|
64
|
+
gitRootResult.result,
|
|
65
|
+
currentGitHookPathResult.result.trim(),
|
|
33
66
|
'post-checkout'
|
|
34
67
|
)
|
|
35
68
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
throw new UnknownError(
|
|
44
|
-
`Unexpected error accrued during git hook notification creation\n\n${e}`
|
|
45
|
-
)
|
|
46
|
-
}
|
|
69
|
+
tasks.push({
|
|
70
|
+
title: 'Copying Git Hook Template',
|
|
71
|
+
skip: async () => !(await pathExists(gitHookPath)),
|
|
72
|
+
task: async () => {
|
|
73
|
+
await fs.promises.cp(gitHookTemplatePath, gitHookPath)
|
|
74
|
+
}
|
|
75
|
+
})
|
|
47
76
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
77
|
+
tasks.push({
|
|
78
|
+
title: 'Making Git Hook Executable',
|
|
79
|
+
skip: () => isExec(gitHookPath),
|
|
80
|
+
task: async () => {
|
|
81
|
+
await execAsyncSpawn(`chmod +x ${gitHookPath}`, {
|
|
82
|
+
withCode: true
|
|
83
|
+
})
|
|
84
|
+
}
|
|
85
|
+
})
|
|
53
86
|
|
|
54
|
-
|
|
55
|
-
}
|
|
87
|
+
return task.newListr(tasks)
|
|
88
|
+
},
|
|
89
|
+
exitOnError: false
|
|
56
90
|
})
|
|
57
91
|
|
|
58
92
|
module.exports = createGitHookNotification
|
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.6",
|
|
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": "0a31342676df9251f4fcf01a3c628bd048788228"
|
|
63
63
|
}
|