@scandipwa/magento-scripts 2.4.0-alpha.4 → 2.4.1

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.
@@ -132,7 +132,7 @@ module.exports = (yargs) => {
132
132
  .addLine('1. Start debugger in VSCode or PHPStorm')
133
133
  .addLine(
134
134
  `2. Go to PHP container: ${logger.style.command(
135
- 'exec phpWithDebug'
135
+ 'exec phpWithXdebug'
136
136
  )}`
137
137
  )
138
138
  .addLine(
@@ -73,6 +73,8 @@ const defaultPorts = {
73
73
  sslTerminator: 80,
74
74
  fpm: 9000,
75
75
  fpmXdebug: 9001,
76
+ // for xdebug server running in the editor
77
+ xdebug: 9003,
76
78
  mariadb: 3306,
77
79
  redis: 6379,
78
80
  elasticsearch: 9200,
@@ -99,10 +101,12 @@ const getPortsConfig = async (ports, options = {}) => {
99
101
  p = p.concat(await getUsedByOtherCMAProjectsPorts())
100
102
  }
101
103
 
104
+ const { xdebug: _, ...portsWithoutXDebug } = mergedPorts
105
+
102
106
  /**
103
107
  * @type {Record<string, string>}
104
108
  */
105
- const portsToCheck = Object.entries(mergedPorts).reduce(
109
+ const portsToCheck = Object.entries(portsWithoutXDebug).reduce(
106
110
  (acc, [name, port]) => {
107
111
  if (acc[port]) {
108
112
  let i = 0
@@ -146,6 +150,21 @@ const getPortsConfig = async (ports, options = {}) => {
146
150
  }
147
151
  }
148
152
 
153
+ // XDebug port will be occupied by the editor
154
+ // so we can expect default port to be free
155
+ // if setup ran more than once
156
+ // first time: default port (9003) is free
157
+ // second time: default port (9003) is occupied by the editor, we choose 9004
158
+ // third time: default port (9004) is occupied by the editor, we choose 9003
159
+ // that way port number will not grow indefinitely
160
+ const xdebugPort = await getPort(defaultPorts.xdebug, {
161
+ portIgnoreList: Object.keys(availablePorts).map((item) =>
162
+ Number.parseInt(item)
163
+ )
164
+ })
165
+
166
+ availablePorts.xdebug = xdebugPort
167
+
149
168
  return availablePorts
150
169
  }
151
170
 
@@ -9,7 +9,7 @@ xdebug.remote_enable=1
9
9
 
10
10
  xdebug.remote_host=<%~ it.hostMachine %>
11
11
 
12
- xdebug.remote_port=9003
12
+ xdebug.remote_port=<%~ it.xdebugPort %>
13
13
 
14
14
  xdebug.remote_log=<%~ it.mageRoot %>/var/log/xdebug.log
15
15
 
@@ -18,7 +18,7 @@ xdebug.remote_log=<%~ it.mageRoot %>/var/log/xdebug.log
18
18
  xdebug.mode=debug
19
19
  xdebug.client_host=<%~ it.hostMachine %>
20
20
 
21
- xdebug.client_port=9003
21
+ xdebug.client_port=<%~ it.xdebugPort %>
22
22
 
23
23
  ; THIS THING WILL BREAK PHP
24
24
  ; xdebug.start_with_request=yes
@@ -175,6 +175,12 @@ const buildDockerFileInstructions = async (
175
175
  `addgroup -g ${gid} ${username} && adduser -u ${gid} -G ${username} -H -s /sbin/nologin -D ${username} && \
176
176
  addgroup www-data ${username}`
177
177
  )
178
+
179
+ if (ctx.isDockerDesktop) {
180
+ dockerFileInstructions.run(
181
+ `chown -R ${username}:${username} /composer/home/cache`
182
+ )
183
+ }
178
184
  }
179
185
 
180
186
  dockerFileInstructions.workDir(ctx.config.baseConfig.containerMagentoDir)
@@ -34,7 +34,7 @@ const createNginxConfig = () => ({
34
34
  networkSettings.phpWithXdebugNetwork = containers.phpWithXdebug.name
35
35
 
36
36
  networkSettings.fpmPort = 9000
37
- networkSettings.fpmXdebugPort = 9001
37
+ networkSettings.fpmXdebugPort = 9000
38
38
 
39
39
  networkSettings.hostPort = 80
40
40
  }
@@ -26,6 +26,8 @@ const createPhpDebugConfig = () => ({
26
26
  ? '127.0.0.1'
27
27
  : 'host.docker.internal'
28
28
 
29
+ const { xdebug: xdebugPort } = ctx.ports
30
+
29
31
  try {
30
32
  await setConfigFile({
31
33
  configPathname: php.debugIniPath,
@@ -35,7 +37,8 @@ const createPhpDebugConfig = () => ({
35
37
  debug,
36
38
  mageRoot: baseConfig.containerMagentoDir,
37
39
  isXDebug2,
38
- hostMachine
40
+ hostMachine,
41
+ xdebugPort
39
42
  }
40
43
  })
41
44
  } catch (e) {
@@ -36,7 +36,7 @@ const setupWorkspaceConfig = () => ({
36
36
  setupPHPStanProjectConfiguration(workspaceConfigs),
37
37
  setupPSalmProjectConfiguration(workspaceConfigs),
38
38
  setupPHPWorkspaceProjectConfiguration(workspaceConfigs, ctx),
39
- setupPHPDebugGeneral(workspaceConfigs),
39
+ setupPHPDebugGeneral(workspaceConfigs, ctx),
40
40
  setupPHPServers(workspaceConfigs, workspaceConfig, ctx),
41
41
  setupComposerSettings(workspaceConfigs, ctx),
42
42
  setupRunManager(workspaceConfigs, workspaceConfig),
@@ -61,7 +61,7 @@ const setupWorkspaceConfig = () => ({
61
61
  setupPHPCodeSnifferProjectConfiguration(workspaceConfigs),
62
62
  setupPHPStanProjectConfiguration(workspaceConfigs),
63
63
  setupPSalmProjectConfiguration(workspaceConfigs),
64
- setupPHPDebugGeneral(workspaceConfigs),
64
+ setupPHPDebugGeneral(workspaceConfigs, ctx),
65
65
  setupPHPServers(workspaceConfigs, workspaceConfig, ctx),
66
66
  setupPHPWorkspaceProjectConfiguration(workspaceConfigs, ctx),
67
67
  setupRunManager(workspaceConfigs, workspaceConfig),
@@ -7,13 +7,16 @@ const xdebugDebugPortKey = '@_xdebug_debug_port'
7
7
  const ignoreConnectionsThroughUnregisteredServersKey =
8
8
  '@_ignore_connections_through_unregistered_servers'
9
9
 
10
- const xdebugPort = '9003'
11
-
12
10
  /**
13
11
  * @param {Array} workspaceConfigs
12
+ * @param {import('../../../../../typings/context').ListrContext} ctx
14
13
  * @returns {Promise<Boolean>}
15
14
  */
16
- const setupPHPDebugGeneral = async (workspaceConfigs) => {
15
+ const setupPHPDebugGeneral = async (workspaceConfigs, ctx) => {
16
+ const { ports } = ctx
17
+
18
+ const xdebugPort = `${ports.xdebug}`
19
+
17
20
  let hasChanges = false
18
21
  const phpDebugGeneralComponent = workspaceConfigs.find(
19
22
  (workspaceConfig) =>
@@ -7,8 +7,6 @@ const UnknownError = require('../../errors/unknown-error')
7
7
 
8
8
  const listenForXDebugConfigName = 'Listen for XDebug'
9
9
 
10
- const xdebugPort = 9003
11
-
12
10
  const vscodeLaunchConfigPath = path.join(
13
11
  process.cwd(),
14
12
  '.vscode',
@@ -19,6 +17,7 @@ const vscodeLaunchConfigPath = path.join(
19
17
  * @param {import('../../../typings/context').ListrContext} ctx
20
18
  */
21
19
  const addPHPDebugConfig = (vscodeLaunchConfig, ctx) => {
20
+ const { ports } = ctx
22
21
  const phpXDebugConfig = vscodeLaunchConfig.configurations.find(
23
22
  ({ name }) => name === listenForXDebugConfigName
24
23
  )
@@ -29,7 +28,8 @@ const addPHPDebugConfig = (vscodeLaunchConfig, ctx) => {
29
28
  name: listenForXDebugConfigName,
30
29
  type: 'php',
31
30
  request: 'launch',
32
- port: xdebugPort,
31
+ // port: xdebugPort,
32
+ port: ports.xdebug,
33
33
  pathMappings: {
34
34
  // eslint-disable-next-line no-template-curly-in-string
35
35
  [ctx.config.baseConfig.containerMagentoDir]: '${workspaceFolder}'
@@ -52,8 +52,8 @@ const addPHPDebugConfig = (vscodeLaunchConfig, ctx) => {
52
52
  return true
53
53
  }
54
54
 
55
- if (!phpXDebugConfig.port || phpXDebugConfig.port !== xdebugPort) {
56
- phpXDebugConfig.port = xdebugPort
55
+ if (!phpXDebugConfig.port || phpXDebugConfig.port !== ports.xdebug) {
56
+ phpXDebugConfig.port = ports.xdebug
57
57
 
58
58
  hasChanges = true
59
59
  }
@@ -129,7 +129,7 @@ const createVSCodeConfig = () => ({
129
129
  template: vscodeLaunchConfigTemplatePath,
130
130
  configPathname: vscodeLaunchConfigPath,
131
131
  templateArgs: {
132
- XDebugPort: xdebugPort,
132
+ XDebugPort: ctx.ports.xdebug,
133
133
  baseConfig: ctx.config.baseConfig
134
134
  }
135
135
  })
@@ -277,13 +277,17 @@ const installMagentoProject = () => ({
277
277
  title: 'Installing Magento dependencies',
278
278
  task: async () => {
279
279
  try {
280
- await runComposerCommand(ctx, 'install', {
281
- callback: !ctx.verbose
282
- ? undefined
283
- : (t) => {
284
- task.output = t
285
- }
286
- })
280
+ await runComposerCommand(
281
+ ctx,
282
+ `install${ctx.verbose ? ' -v' : ''}`,
283
+ {
284
+ callback: !ctx.verbose
285
+ ? undefined
286
+ : (t) => {
287
+ task.output = t
288
+ }
289
+ }
290
+ )
287
291
  } catch (e) {
288
292
  if (
289
293
  e instanceof UnknownError &&
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.0-alpha.4",
6
+ "version": "2.4.1",
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": "44e76144f6979996e604a6a57088ac139ae88731"
62
+ "gitHead": "54272cb4f12f8684d032dd611027ec4fe3877cab"
63
63
  }