@scandipwa/magento-scripts 2.4.9 → 2.4.10-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.
@@ -92,11 +92,38 @@ const checkSearchEngineVersion = () => ({
92
92
  }
93
93
  )
94
94
  } else {
95
- await waitForLogs({
96
- containerName: elasticsearch.name,
97
- matchText:
98
- searchengine === 'elasticsearch' ? '"started"' : '] started'
99
- })
95
+ await waitForLogs(
96
+ searchengine === 'elasticsearch'
97
+ ? {
98
+ containerName: elasticsearch.name,
99
+ customLineParser: (line) => {
100
+ try {
101
+ const logObject = JSON.parse(line)
102
+
103
+ return logObject.message.startsWith('started')
104
+ } catch {
105
+ return false
106
+ }
107
+ }
108
+ }
109
+ : {
110
+ containerName: elasticsearch.name,
111
+ customLineParser: (line) => {
112
+ if (!line.startsWith('[')) {
113
+ return false
114
+ }
115
+ try {
116
+ const message = line
117
+ .replaceAll(/\[[\s\S]+\]/g, '')
118
+ .trim()
119
+
120
+ return message.startsWith('started')
121
+ } catch {
122
+ return false
123
+ }
124
+ }
125
+ }
126
+ )
100
127
 
101
128
  try {
102
129
  const response = await request(
@@ -2,10 +2,15 @@ const { execAsyncSpawn } = require('./exec-async-command')
2
2
  const sleep = require('./sleep')
3
3
 
4
4
  /**
5
- * @param {{ containerName: string, timeout?: number, matchText: string }} param0
5
+ * @param {{ containerName: string, timeout?: number, matchText?: string | string[], customLineParser?: (line: string) => boolean }} param0
6
6
  * @returns {Promise<void>}
7
7
  */
8
- const waitForLogs = ({ containerName, timeout = 30 * 1000, matchText }) =>
8
+ const waitForLogs = ({
9
+ containerName,
10
+ timeout = 30 * 1000,
11
+ matchText,
12
+ customLineParser
13
+ }) =>
9
14
  // eslint-disable-next-line no-async-promise-executor
10
15
  new Promise(async (resolve, reject) => {
11
16
  let matched = false
@@ -26,9 +31,22 @@ const waitForLogs = ({ containerName, timeout = 30 * 1000, matchText }) =>
26
31
  }
27
32
 
28
33
  result.split('\n').forEach((line) => {
29
- if (line.includes(matchText)) {
30
- matched = true
31
- resolve()
34
+ if (customLineParser) {
35
+ if (customLineParser(line)) {
36
+ matched = true
37
+ resolve()
38
+ }
39
+ } else if (matchText) {
40
+ if (
41
+ Array.isArray(matchText)
42
+ ? matchText.some((text) =>
43
+ line.includes(text)
44
+ )
45
+ : line.includes(matchText)
46
+ ) {
47
+ matched = true
48
+ resolve()
49
+ }
32
50
  }
33
51
  })
34
52
 
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.9",
6
+ "version": "2.4.10-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": "84df2774959c2bac35204a36d92383b82dfd54b0"
62
+ "gitHead": "2bed7f4719e34e41ed38776eadc6961a88189eab"
63
63
  }