@scandipwa/magento-scripts 2.3.2 → 2.3.3

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.
@@ -365,6 +365,7 @@ module.exports = async (ctx, overridenConfiguration, baseConfig) => {
365
365
  env:
366
366
  searchengine === 'elasticsearch'
367
367
  ? deepmerge(
368
+ defaultEsEnv,
368
369
  {
369
370
  // https://www.elastic.co/guide/en/elasticsearch/reference/master/ml-settings.html
370
371
  'xpack.ml.enabled': ['sse4.2', 'sse4_2'].some(
@@ -372,9 +373,9 @@ module.exports = async (ctx, overridenConfiguration, baseConfig) => {
372
373
  cpuSupportedFlags.includes(sse42Flag)
373
374
  )
374
375
  },
375
- elasticsearch.env || defaultEsEnv
376
+ elasticsearch.env || {}
376
377
  )
377
- : deepmerge({}, opensearch.env || defaultOsEnv),
378
+ : deepmerge(defaultOsEnv, opensearch.env || {}),
378
379
  network: network.name,
379
380
  image: `${
380
381
  searchengine === 'elasticsearch'
@@ -45,15 +45,10 @@ const addExtensionToBuilder =
45
45
  let runCommand = ''
46
46
  if (typeof command === 'string') {
47
47
  runCommand += ` ${command}`
48
- } else if (command instanceof Promise) {
48
+ } else if (typeof command === 'function') {
49
49
  runCommand += ` ${await Promise.resolve(
50
50
  command({ ...extensionInstructionsWithoutCommand, ctx })
51
51
  )}`
52
- } else if (typeof command === 'function') {
53
- runCommand += ` ${command({
54
- ...extensionInstructionsWithoutCommand,
55
- ctx
56
- })}`
57
52
  } else {
58
53
  runCommand += ` docker-php-ext-install ${
59
54
  extensionInstructionsWithoutCommand.name || extensionName
@@ -146,14 +141,17 @@ const buildDockerFileInstructions = async (ctx, { image, tag }) => {
146
141
  composer.plugins
147
142
  )) {
148
143
  if (pluginOptions.enabled) {
144
+ const pluginVersion = pluginOptions.version
149
145
  dockerFileInstructions
150
- .comment(`install ${pluginName} composer global package`)
146
+ .comment(
147
+ `install ${pluginName}${
148
+ pluginVersion ? ` (version ${pluginVersion})` : ''
149
+ } composer global package`
150
+ )
151
151
 
152
152
  .run(
153
153
  `composer global require ${pluginName}${
154
- pluginOptions.options
155
- ? ` ${pluginOptions.options}`
156
- : ''
154
+ pluginVersion ? `:${pluginVersion}` : ''
157
155
  }${
158
156
  pluginOptions.options
159
157
  ? ` ${pluginOptions.options}`
@@ -1,3 +1,4 @@
1
+ const { getPort } = require('../../config/port-config')
1
2
  const UnknownError = require('../../errors/unknown-error')
2
3
  const { containerApi } = require('../docker/containers')
3
4
 
@@ -11,19 +12,40 @@ const checkElasticSearchVersion = () => ({
11
12
  ctx.config.overridenConfiguration.configuration
12
13
  const { ports } = ctx
13
14
 
15
+ const { elasticsearch: elasticSearchContainer } =
16
+ ctx.config.docker.getContainers(ports)
17
+
14
18
  let elasticSearchVersionResponse
15
19
 
16
- try {
17
- elasticSearchVersionResponse = await containerApi.run({
18
- ...elasticsearch,
19
- command: 'elasticsearch --version',
20
- detach: false,
21
- rm: true,
22
- ports: [`127.0.0.1:${ports.elasticsearch}:9200`],
23
- memory: '512mb'
24
- })
25
- } catch (e) {
26
- elasticSearchVersionResponse = e.message
20
+ const elasticSearchContainerRunning = await containerApi.ls({
21
+ filter: `name=${elasticSearchContainer.name}`,
22
+ formatToJSON: true
23
+ })
24
+
25
+ if (
26
+ elasticSearchContainerRunning.length !== 0 &&
27
+ elasticSearchContainerRunning[0].State === 'running'
28
+ ) {
29
+ elasticSearchVersionResponse = await containerApi.exec(
30
+ 'elasticsearch --version',
31
+ elasticSearchContainer.name
32
+ )
33
+ } else {
34
+ try {
35
+ const availableElasticSearchPort = await getPort(
36
+ ports.elasticsearch
37
+ )
38
+ elasticSearchVersionResponse = await containerApi.run({
39
+ ...elasticsearch,
40
+ command: 'elasticsearch --version',
41
+ detach: false,
42
+ rm: true,
43
+ ports: [`127.0.0.1:${availableElasticSearchPort}:9200`],
44
+ memory: '512mb'
45
+ })
46
+ } catch (e) {
47
+ elasticSearchVersionResponse = e.message
48
+ }
27
49
  }
28
50
 
29
51
  const elasticSearchVersionResponseResult =
@@ -1,3 +1,4 @@
1
+ const { getPort } = require('../../config/port-config')
1
2
  const UnknownError = require('../../errors/unknown-error')
2
3
  const { containerApi } = require('../docker/containers')
3
4
 
@@ -10,19 +11,40 @@ const checkOpenSearchVersion = () => ({
10
11
  const { opensearch } = ctx.config.overridenConfiguration.configuration
11
12
  const { ports } = ctx
12
13
 
14
+ const { elasticsearch: openSearchContainer } =
15
+ ctx.config.docker.getContainers(ports)
16
+
13
17
  let openSearchVersionResponse
14
18
 
15
- try {
16
- openSearchVersionResponse = await containerApi.run({
17
- ...opensearch,
18
- command: 'opensearch --version',
19
- detach: false,
20
- rm: true,
21
- ports: [`127.0.0.1:${ports.elasticsearch}:9200`],
22
- memory: '512mb'
23
- })
24
- } catch (e) {
25
- openSearchVersionResponse = e.message
19
+ const openSearchContainerRunning = await containerApi.ls({
20
+ filter: `name=${openSearchContainer.name}`,
21
+ formatToJSON: true
22
+ })
23
+
24
+ if (
25
+ openSearchContainerRunning.length !== 0 &&
26
+ openSearchContainerRunning[0].State === 'running'
27
+ ) {
28
+ openSearchVersionResponse = await containerApi.exec(
29
+ 'opensearch --version',
30
+ openSearchContainer.name
31
+ )
32
+ } else {
33
+ try {
34
+ const availableOpenSearchPort = await getPort(
35
+ ports.elasticsearch
36
+ )
37
+ openSearchVersionResponse = await containerApi.run({
38
+ ...opensearch,
39
+ command: 'opensearch --version',
40
+ detach: false,
41
+ rm: true,
42
+ ports: [`127.0.0.1:${availableOpenSearchPort}:9200`],
43
+ memory: '512mb'
44
+ })
45
+ } catch (e) {
46
+ openSearchVersionResponse = e.message
47
+ }
26
48
  }
27
49
 
28
50
  const openSearchVersionResponseResult = openSearchVersionResponse.match(
@@ -105,12 +105,17 @@ const prettyStatus = async (ctx) => {
105
105
  if (
106
106
  container.status &&
107
107
  container.status.State &&
108
- container.status.State.Health
108
+ container.status.State.Health &&
109
+ container.status.State.Status === 'running'
109
110
  ) {
110
111
  containerStatus = `✓ ${logger.style.file(
111
112
  container.status.State.Health.Status
112
113
  )} and ${logger.style.file('running')}`
113
- } else if (container.status && container.status.State) {
114
+ } else if (
115
+ container.status &&
116
+ container.status.State &&
117
+ container.status.State.Status !== 'exited'
118
+ ) {
114
119
  containerStatus = logger.style.file(container.status.State.Status)
115
120
  } else {
116
121
  containerStatus = '✖ Not running'
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.3.2",
6
+ "version": "2.3.3",
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.10.4",
60
60
  "@types/yargs": "^17.0.13"
61
61
  },
62
- "gitHead": "da589ac8f9aa56f6489c7b12d69e4cddaa617f36"
62
+ "gitHead": "041e92f309c8e1d513f8d12aacd8d262b302d905"
63
63
  }
@@ -91,7 +91,7 @@ export interface ListrContext {
91
91
  }
92
92
  }
93
93
  >
94
- getContainers(ports?: Record<string, number>): Record<string,
94
+ getContainers(ports?: ListrContext['ports']): Record<'php' | 'sslTerminator' | 'nginx' | 'redis' | 'mariadb' | 'elasticsearch' | 'maildev' | 'varnish',
95
95
  {
96
96
  _: string
97
97
  ports: string[]