@scandipwa/magento-scripts 2.4.12 → 2.4.13
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/.oxlintrc.json +32 -0
- package/exec.js +1 -1
- package/index.js +1 -1
- package/lib/config/docker.js +1 -1
- package/lib/config/system-config.js +2 -2
- package/lib/tasks/database/import-remote-db/ssh/readymage.js +2 -1
- package/lib/tasks/docker/containers/tasks.js +1 -1
- package/lib/tasks/file-system/create-git-hook-notification.js +1 -1
- package/lib/tasks/file-system/create-nginx-config.js +4 -1
- package/lib/tasks/file-system/create-phpstorm-config/php-docker-settings-config/index.js +6 -10
- package/lib/tasks/magento/install-magento-project.js +1 -1
- package/lib/tasks/magento/setup-magento/set-base-url.js +7 -19
- package/lib/tasks/magento/setup-magento/waiting-for-varnish.js +2 -2
- package/lib/tasks/requirements/docker/running-status.js +1 -1
- package/lib/tasks/requirements/searchengine-version.js +1 -1
- package/lib/tasks/status/index.js +1 -1
- package/lib/tasks/theme/build-theme.js +1 -1
- package/lib/util/analytics.js +2 -2
- package/lib/util/exec-async-command.js +1 -1
- package/lib/util/ip.js +1 -1
- package/lib/util/is-wsl.js +1 -1
- package/lib/util/path-exists-sync.js +1 -1
- package/lib/util/path-exists.js +1 -1
- package/lib/util/store-domains.js +71 -0
- package/lib/util/store-domains.test.js +52 -0
- package/lib/util/systemctl.js +3 -3
- package/package.json +6 -2
- package/.eslintrc +0 -10
package/.oxlintrc.json
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "../../node_modules/oxlint/configuration_schema.json",
|
|
3
|
+
"env": {
|
|
4
|
+
"node": true,
|
|
5
|
+
"es2022": true
|
|
6
|
+
},
|
|
7
|
+
"globals": {
|
|
8
|
+
"verbose": "readonly",
|
|
9
|
+
"NodeJS": "readonly",
|
|
10
|
+
"BufferEncoding": "readonly"
|
|
11
|
+
},
|
|
12
|
+
"categories": {
|
|
13
|
+
"correctness": "error"
|
|
14
|
+
},
|
|
15
|
+
"ignorePatterns": [
|
|
16
|
+
"**/node_modules/**",
|
|
17
|
+
"**/lib/config/templates/**",
|
|
18
|
+
"**/typings/**",
|
|
19
|
+
"**/*.d.ts"
|
|
20
|
+
],
|
|
21
|
+
"rules": {
|
|
22
|
+
"no-unused-vars": [
|
|
23
|
+
"warn",
|
|
24
|
+
{
|
|
25
|
+
"argsIgnorePattern": "^_",
|
|
26
|
+
"caughtErrorsIgnorePattern": "^_",
|
|
27
|
+
"varsIgnorePattern": "^_"
|
|
28
|
+
}
|
|
29
|
+
],
|
|
30
|
+
"unicorn/no-useless-fallback-in-spread": "off"
|
|
31
|
+
}
|
|
32
|
+
}
|
package/exec.js
CHANGED
|
@@ -93,7 +93,7 @@ const newVersionIsAPatch = (latestVersion, currentVersion) => {
|
|
|
93
93
|
process.isOutOfDateVersion = true
|
|
94
94
|
process.isOutOfDateVersionMessage = message
|
|
95
95
|
}
|
|
96
|
-
} catch
|
|
96
|
+
} catch {
|
|
97
97
|
logger.warn(`Package ${logger.style.misc(name)} is not yet published.`)
|
|
98
98
|
logger.log() // add empty line
|
|
99
99
|
}
|
package/index.js
CHANGED
|
@@ -115,7 +115,7 @@ const newVersionIsAPatch = (latestVersion, currentVersion) => {
|
|
|
115
115
|
process.isOutOfDateVersion = true
|
|
116
116
|
process.isOutOfDateVersionMessage = message
|
|
117
117
|
}
|
|
118
|
-
} catch
|
|
118
|
+
} catch {
|
|
119
119
|
logger.warn(`Package ${logger.style.misc(name)} is not yet published.`)
|
|
120
120
|
logger.log() // add empty line
|
|
121
121
|
}
|
package/lib/config/docker.js
CHANGED
|
@@ -23,7 +23,7 @@ const rosettaTranslatedContainers =
|
|
|
23
23
|
*/
|
|
24
24
|
const volumeDirectives = (directives) => {
|
|
25
25
|
const directivesResult = Object.entries(directives)
|
|
26
|
-
.filter(([
|
|
26
|
+
.filter(([, value]) => value === true)
|
|
27
27
|
.map(([name]) => name)
|
|
28
28
|
.join(',')
|
|
29
29
|
|
|
@@ -25,7 +25,7 @@ const getSystemConfig = async ({ validate = true } = {}) => {
|
|
|
25
25
|
let userSystemConfigParsed
|
|
26
26
|
try {
|
|
27
27
|
userSystemConfigParsed = JSON.parse(userSystemConfig)
|
|
28
|
-
} catch
|
|
28
|
+
} catch {
|
|
29
29
|
throw new KnownError(
|
|
30
30
|
`System configuration file is not a valid JSON!\n\nFile location: ${systemConfigPath}`
|
|
31
31
|
)
|
|
@@ -61,7 +61,7 @@ const getSystemConfigSync = ({ validate = true } = {}) => {
|
|
|
61
61
|
let userSystemConfigParsed
|
|
62
62
|
try {
|
|
63
63
|
userSystemConfigParsed = JSON.parse(userSystemConfig)
|
|
64
|
-
} catch
|
|
64
|
+
} catch {
|
|
65
65
|
throw new KnownError(
|
|
66
66
|
`System configuration file is not a valid JSON!\n\nFile location: ${systemConfigPath}`
|
|
67
67
|
)
|
|
@@ -172,7 +172,7 @@ const startContainers = () => ({
|
|
|
172
172
|
|
|
173
173
|
const missingContainers = Object.entries(containers)
|
|
174
174
|
.filter(
|
|
175
|
-
([
|
|
175
|
+
([, { name }]) =>
|
|
176
176
|
!containerList.some((c) => c.Names === name)
|
|
177
177
|
)
|
|
178
178
|
.map(([nameWithoutPrefix, containerOptions]) => ({
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
const path = require('path')
|
|
2
2
|
const setConfigFile = require('../../util/set-config')
|
|
3
3
|
const UnknownError = require('../../errors/unknown-error')
|
|
4
|
+
const {
|
|
5
|
+
shouldUseStoreDomainMapping
|
|
6
|
+
} = require('../../util/store-domains')
|
|
4
7
|
|
|
5
8
|
/**
|
|
6
9
|
* @returns {import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
|
|
@@ -35,7 +38,7 @@ const createNginxConfig = () => ({
|
|
|
35
38
|
}
|
|
36
39
|
|
|
37
40
|
const useStoreDomainMapping =
|
|
38
|
-
|
|
41
|
+
shouldUseStoreDomainMapping(storeDomains)
|
|
39
42
|
|
|
40
43
|
try {
|
|
41
44
|
await setConfigFile({
|
|
@@ -18,14 +18,12 @@ const setupPhpDockerSettingsConfig = () => ({
|
|
|
18
18
|
)
|
|
19
19
|
const phpDockerSettingsConfigs =
|
|
20
20
|
phpDockerSettingsConfigContent.project.component
|
|
21
|
-
const hasChanges = await
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
)
|
|
26
|
-
])
|
|
21
|
+
const hasChanges = await setupPHPDockerContainerSettingsConfig(
|
|
22
|
+
phpDockerSettingsConfigs,
|
|
23
|
+
ctx
|
|
24
|
+
)
|
|
27
25
|
|
|
28
|
-
if (hasChanges
|
|
26
|
+
if (hasChanges === true) {
|
|
29
27
|
await buildXmlFile(
|
|
30
28
|
phpDockerSettingsConfig.path,
|
|
31
29
|
phpDockerSettingsConfigContent
|
|
@@ -41,9 +39,7 @@ const setupPhpDockerSettingsConfig = () => ({
|
|
|
41
39
|
const phpDockerSettingsConfigs =
|
|
42
40
|
phpDockerSettingsConfigContent.project.component
|
|
43
41
|
|
|
44
|
-
await
|
|
45
|
-
setupPHPDockerContainerSettingsConfig(phpDockerSettingsConfigs, ctx)
|
|
46
|
-
])
|
|
42
|
+
await setupPHPDockerContainerSettingsConfig(phpDockerSettingsConfigs, ctx)
|
|
47
43
|
|
|
48
44
|
await buildXmlFile(
|
|
49
45
|
phpDockerSettingsConfig.path,
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
const { updateTableValues, databaseQuery } = require('../../../util/database')
|
|
2
2
|
const KnownError = require('../../../errors/known-error')
|
|
3
|
+
const {
|
|
4
|
+
resolveStoreDomainsForScopes
|
|
5
|
+
} = require('../../../util/store-domains')
|
|
3
6
|
|
|
4
7
|
/**
|
|
5
8
|
* @param {number} scopeId
|
|
@@ -129,25 +132,10 @@ const setBaseUrl = () => ({
|
|
|
129
132
|
)
|
|
130
133
|
}
|
|
131
134
|
|
|
132
|
-
const storeDomainsWithMapping =
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
(entity) => entity.code === key
|
|
137
|
-
)
|
|
138
|
-
if (entity) {
|
|
139
|
-
return {
|
|
140
|
-
...acc,
|
|
141
|
-
[entity.code]: {
|
|
142
|
-
scopeId: entity[idField],
|
|
143
|
-
domain: val
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
return acc
|
|
149
|
-
},
|
|
150
|
-
{}
|
|
135
|
+
const storeDomainsWithMapping = resolveStoreDomainsForScopes(
|
|
136
|
+
storeDomains,
|
|
137
|
+
entities,
|
|
138
|
+
idField
|
|
151
139
|
)
|
|
152
140
|
|
|
153
141
|
// Check for missing store codes when runType is 'store'
|
|
@@ -80,7 +80,7 @@ const waitingForVarnish = () => ({
|
|
|
80
80
|
} else {
|
|
81
81
|
break
|
|
82
82
|
}
|
|
83
|
-
} catch
|
|
83
|
+
} catch {
|
|
84
84
|
tries++
|
|
85
85
|
await sleep(200)
|
|
86
86
|
}
|
|
@@ -155,7 +155,7 @@ Do you want to try resolving this issue by replacing ${logger.style.file(
|
|
|
155
155
|
connectionFixed = true
|
|
156
156
|
break
|
|
157
157
|
}
|
|
158
|
-
} catch
|
|
158
|
+
} catch {
|
|
159
159
|
await sleep(200)
|
|
160
160
|
}
|
|
161
161
|
}
|
|
@@ -30,7 +30,7 @@ const buildTheme = ({ themePath }) => ({
|
|
|
30
30
|
task.output = t
|
|
31
31
|
}
|
|
32
32
|
})
|
|
33
|
-
} catch
|
|
33
|
+
} catch {
|
|
34
34
|
throw new UnknownError(`We were unable to install theme dependencies in ${themePath} using ${logger.style.code(
|
|
35
35
|
commandToInstallDependencies
|
|
36
36
|
)} command!
|
package/lib/util/analytics.js
CHANGED
|
@@ -168,7 +168,7 @@ class Analytics {
|
|
|
168
168
|
|
|
169
169
|
try {
|
|
170
170
|
this.setClientIdentifier(generateUUID())
|
|
171
|
-
} catch
|
|
171
|
+
} catch {
|
|
172
172
|
this.setClientIdentifier(`${Date.now()}`)
|
|
173
173
|
}
|
|
174
174
|
}
|
|
@@ -233,7 +233,7 @@ class Analytics {
|
|
|
233
233
|
analyticsParameters.session = {
|
|
234
234
|
ipOverride: await getExternalIpAddress()
|
|
235
235
|
}
|
|
236
|
-
} catch
|
|
236
|
+
} catch {
|
|
237
237
|
// Do nothing
|
|
238
238
|
}
|
|
239
239
|
|
package/lib/util/ip.js
CHANGED
package/lib/util/is-wsl.js
CHANGED
package/lib/util/path-exists.js
CHANGED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Enable nginx host → store mapping only when multiple stores use distinct domains.
|
|
3
|
+
* Duplicate hostnames produce invalid nginx map directives.
|
|
4
|
+
*
|
|
5
|
+
* @param {Record<string, string> | undefined} storeDomains
|
|
6
|
+
* @returns {boolean}
|
|
7
|
+
*/
|
|
8
|
+
const shouldUseStoreDomainMapping = (storeDomains) => {
|
|
9
|
+
if (!storeDomains) {
|
|
10
|
+
return false
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const entries = Object.entries(storeDomains)
|
|
14
|
+
|
|
15
|
+
if (entries.length <= 1) {
|
|
16
|
+
return false
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const domains = entries.map(([, domain]) => domain)
|
|
20
|
+
|
|
21
|
+
return new Set(domains).size === domains.length
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Map store/website entities to domains from storeDomains, falling back to admin
|
|
26
|
+
* for scopes not explicitly configured (e.g. website "base" on single-domain setups).
|
|
27
|
+
*
|
|
28
|
+
* @param {Record<string, string>} storeDomains
|
|
29
|
+
* @param {{ code: string }[]} entities
|
|
30
|
+
* @param {'website_id' | 'store_id'} idField
|
|
31
|
+
* @returns {Record<string, { scopeId: number, domain: string }>}
|
|
32
|
+
*/
|
|
33
|
+
const resolveStoreDomainsForScopes = (storeDomains, entities, idField) => {
|
|
34
|
+
const defaultDomain = storeDomains.admin
|
|
35
|
+
|
|
36
|
+
/** @type {Record<string, { scopeId: number, domain: string }>} */
|
|
37
|
+
const mapped = Object.entries(storeDomains).reduce(
|
|
38
|
+
(acc, [key, val]) => {
|
|
39
|
+
const entity = entities.find((entity) => entity.code === key)
|
|
40
|
+
|
|
41
|
+
if (entity) {
|
|
42
|
+
return {
|
|
43
|
+
...acc,
|
|
44
|
+
[entity.code]: {
|
|
45
|
+
scopeId: entity[idField],
|
|
46
|
+
domain: val
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return acc
|
|
52
|
+
},
|
|
53
|
+
{}
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
for (const entity of entities) {
|
|
57
|
+
if (!mapped[entity.code]) {
|
|
58
|
+
mapped[entity.code] = {
|
|
59
|
+
scopeId: entity[idField],
|
|
60
|
+
domain: defaultDomain
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return mapped
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
module.exports = {
|
|
69
|
+
shouldUseStoreDomainMapping,
|
|
70
|
+
resolveStoreDomainsForScopes
|
|
71
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
const assert = require('assert')
|
|
2
|
+
const {
|
|
3
|
+
shouldUseStoreDomainMapping,
|
|
4
|
+
resolveStoreDomainsForScopes
|
|
5
|
+
} = require('./store-domains')
|
|
6
|
+
|
|
7
|
+
assert.strictEqual(shouldUseStoreDomainMapping(undefined), false)
|
|
8
|
+
assert.strictEqual(shouldUseStoreDomainMapping({ admin: 'localhost' }), false)
|
|
9
|
+
assert.strictEqual(
|
|
10
|
+
shouldUseStoreDomainMapping({
|
|
11
|
+
admin: 'shop.local',
|
|
12
|
+
base: 'shop.local'
|
|
13
|
+
}),
|
|
14
|
+
false
|
|
15
|
+
)
|
|
16
|
+
assert.strictEqual(
|
|
17
|
+
shouldUseStoreDomainMapping({
|
|
18
|
+
admin: 'admin.local',
|
|
19
|
+
base: 'shop.local'
|
|
20
|
+
}),
|
|
21
|
+
true
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
const websites = [
|
|
25
|
+
{ website_id: 0, code: 'admin' },
|
|
26
|
+
{ website_id: 1, code: 'base' }
|
|
27
|
+
]
|
|
28
|
+
|
|
29
|
+
const resolved = resolveStoreDomainsForScopes(
|
|
30
|
+
{ admin: 'jollyes.local' },
|
|
31
|
+
websites,
|
|
32
|
+
'website_id'
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
assert.deepStrictEqual(resolved, {
|
|
36
|
+
admin: { scopeId: 0, domain: 'jollyes.local' },
|
|
37
|
+
base: { scopeId: 1, domain: 'jollyes.local' }
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
assert.deepStrictEqual(
|
|
41
|
+
resolveStoreDomainsForScopes(
|
|
42
|
+
{ admin: 'jollyes.local', base: 'other.local' },
|
|
43
|
+
websites,
|
|
44
|
+
'website_id'
|
|
45
|
+
),
|
|
46
|
+
{
|
|
47
|
+
admin: { scopeId: 0, domain: 'jollyes.local' },
|
|
48
|
+
base: { scopeId: 1, domain: 'other.local' }
|
|
49
|
+
}
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
console.log('store-domains.test.js: ok')
|
package/lib/util/systemctl.js
CHANGED
|
@@ -66,7 +66,7 @@ const systemctlControl = (serviceName, defaultOptions = {}) => ({
|
|
|
66
66
|
...options
|
|
67
67
|
})
|
|
68
68
|
return result.includes('enabled')
|
|
69
|
-
} catch
|
|
69
|
+
} catch {
|
|
70
70
|
return false
|
|
71
71
|
}
|
|
72
72
|
},
|
|
@@ -81,7 +81,7 @@ const systemctlControl = (serviceName, defaultOptions = {}) => ({
|
|
|
81
81
|
})
|
|
82
82
|
|
|
83
83
|
return result.includes('active (running)')
|
|
84
|
-
} catch
|
|
84
|
+
} catch {
|
|
85
85
|
return false
|
|
86
86
|
}
|
|
87
87
|
},
|
|
@@ -101,7 +101,7 @@ const systemctlControl = (serviceName, defaultOptions = {}) => ({
|
|
|
101
101
|
const result = await execAsyncSpawn(command)
|
|
102
102
|
|
|
103
103
|
return result === '1'
|
|
104
|
-
} catch
|
|
104
|
+
} catch {
|
|
105
105
|
return false
|
|
106
106
|
}
|
|
107
107
|
}
|
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.13",
|
|
7
7
|
"main": "./index.js",
|
|
8
8
|
"types": "./typings/index.d.ts",
|
|
9
9
|
"license": "OSL-3.0",
|
|
@@ -59,5 +59,9 @@
|
|
|
59
59
|
"@types/node": "^20.14.11",
|
|
60
60
|
"@types/yargs": "^17.0.32"
|
|
61
61
|
},
|
|
62
|
-
"
|
|
62
|
+
"scripts": {
|
|
63
|
+
"lint": "oxlint",
|
|
64
|
+
"test:store-domains": "node lib/util/store-domains.test.js"
|
|
65
|
+
},
|
|
66
|
+
"gitHead": "a6d5ac78bf24f1ebd5b725248bb775e3e7c3d3ef"
|
|
63
67
|
}
|