@scandipwa/magento-scripts 2.0.0-alpha.2 → 2.0.0-alpha.21

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.
Files changed (146) hide show
  1. package/exec.js +71 -0
  2. package/index.js +1 -1
  3. package/lib/commands/cli.js +18 -1
  4. package/lib/commands/execute.js +2 -57
  5. package/lib/commands/logs.js +28 -2
  6. package/lib/commands/start.js +24 -3
  7. package/lib/commands/status.js +9 -1
  8. package/lib/config/config.js +20 -2
  9. package/lib/config/docker.js +90 -53
  10. package/lib/config/get-project-configuration.js +5 -0
  11. package/lib/config/index.js +10 -3
  12. package/lib/config/php/versions/php-7.2.js +1 -0
  13. package/lib/config/php/versions/php-7.3.js +1 -0
  14. package/lib/config/php/versions/php-7.4.js +1 -0
  15. package/lib/config/php/versions/php-8.1.js +1 -0
  16. package/lib/config/php-config.js +4 -3
  17. package/lib/config/port-config.js +3 -1
  18. package/lib/config/services/composer/versions/composer-1.js +13 -0
  19. package/lib/config/services/composer/versions/composer-2.js +8 -0
  20. package/lib/config/services/composer/versions/index.js +4 -0
  21. package/lib/config/services/maildev/index.js +7 -0
  22. package/lib/config/services/nginx/versions/index.js +3 -0
  23. package/lib/config/services/nginx/versions/nginx-1.18.js +11 -0
  24. package/lib/config/{ssl-terminator → services/ssl-terminator}/index.js +3 -0
  25. package/lib/config/templates/magentorc.template +12 -5
  26. package/lib/config/templates/php-debug.template.ini +31 -0
  27. package/lib/config/templates/php-fpm.template.conf +1 -2
  28. package/lib/config/templates/php.template.ini +5 -201
  29. package/lib/config/templates/ssl-terminator.template.conf +10 -3
  30. package/lib/config/templates/varnish.template.vcl +20 -13
  31. package/lib/config/varnish/varnish-6-0.js +4 -0
  32. package/lib/config/varnish/varnish-6-6.js +4 -0
  33. package/lib/config/varnish/varnish-7-0.js +4 -0
  34. package/lib/config/versions/magento-2.2.10.js +41 -0
  35. package/lib/config/versions/magento-2.3.0.js +8 -10
  36. package/lib/config/versions/magento-2.3.1.js +8 -10
  37. package/lib/config/versions/magento-2.3.2-p1.js +8 -10
  38. package/lib/config/versions/magento-2.3.2-p2.js +8 -10
  39. package/lib/config/versions/magento-2.3.2.js +8 -10
  40. package/lib/config/versions/magento-2.3.3-p1.js +8 -10
  41. package/lib/config/versions/magento-2.3.3.js +8 -10
  42. package/lib/config/versions/magento-2.3.4-p1.js +8 -10
  43. package/lib/config/versions/magento-2.3.4-p2.js +8 -10
  44. package/lib/config/versions/magento-2.3.4.js +8 -10
  45. package/lib/config/versions/magento-2.3.5-p1.js +8 -10
  46. package/lib/config/versions/magento-2.3.5-p2.js +8 -10
  47. package/lib/config/versions/magento-2.3.5.js +8 -10
  48. package/lib/config/versions/magento-2.3.6-p1.js +8 -10
  49. package/lib/config/versions/magento-2.3.6.js +8 -10
  50. package/lib/config/versions/magento-2.3.7-p1.js +8 -10
  51. package/lib/config/versions/magento-2.3.7-p2.js +8 -10
  52. package/lib/config/versions/magento-2.3.7-p3.js +8 -10
  53. package/lib/config/versions/magento-2.3.7-p4.js +42 -0
  54. package/lib/config/versions/magento-2.3.7.js +8 -10
  55. package/lib/config/versions/magento-2.4.0-p1.js +8 -10
  56. package/lib/config/versions/magento-2.4.0.js +8 -10
  57. package/lib/config/versions/magento-2.4.1-p1.js +8 -10
  58. package/lib/config/versions/magento-2.4.1.js +8 -10
  59. package/lib/config/versions/magento-2.4.2-p1.js +8 -10
  60. package/lib/config/versions/magento-2.4.2-p2.js +8 -10
  61. package/lib/config/versions/magento-2.4.2.js +8 -10
  62. package/lib/config/versions/magento-2.4.3-p1.js +8 -10
  63. package/lib/config/versions/magento-2.4.3-p2.js +8 -10
  64. package/lib/config/versions/magento-2.4.3-p3.js +44 -0
  65. package/lib/config/versions/magento-2.4.3.js +8 -10
  66. package/lib/config/versions/magento-2.4.4-p1.js +44 -0
  67. package/lib/config/versions/magento-2.4.4.js +8 -10
  68. package/lib/config/versions/magento-2.4.5.js +44 -0
  69. package/lib/tasks/cli/create-bashrc-config.js +4 -2
  70. package/lib/tasks/composer/local-auth-json.js +1 -1
  71. package/lib/tasks/database/connect-to-database.js +6 -3
  72. package/lib/tasks/database/create-magento-database.js +5 -2
  73. package/lib/tasks/database/create-magento-user.js +50 -0
  74. package/lib/tasks/database/default-magento-database.js +3 -0
  75. package/lib/tasks/database/default-magento-user.js +7 -0
  76. package/lib/tasks/database/import-dump-to-database.js +3 -2
  77. package/lib/tasks/docker/api.d.ts +25 -1
  78. package/lib/tasks/docker/api.js +31 -1
  79. package/lib/tasks/docker/containers/container-api.d.ts +21 -0
  80. package/lib/tasks/docker/containers/container-api.js +82 -17
  81. package/lib/tasks/docker/containers/tasks.js +44 -13
  82. package/lib/tasks/docker/convert-composer-home-to-composer-cache-volume.js +52 -0
  83. package/lib/tasks/docker/convert-mysql-to-mariadb.js +2 -2
  84. package/lib/tasks/docker/image/image-api.d.ts +44 -0
  85. package/lib/tasks/docker/image/image-api.js +30 -2
  86. package/lib/tasks/docker/index.js +6 -1
  87. package/lib/tasks/docker/project-image-builder.js +37 -14
  88. package/lib/tasks/docker/system/index.js +5 -0
  89. package/lib/tasks/docker/system/system-api.d.ts +71 -0
  90. package/lib/tasks/docker/system/system-api.js +29 -0
  91. package/lib/tasks/docker/volume/index.js +2 -1
  92. package/lib/tasks/docker/volume/tasks.js +67 -9
  93. package/lib/tasks/docker/volume/volume-api.d.ts +40 -0
  94. package/lib/tasks/docker/volume/volume-api.js +54 -1
  95. package/lib/tasks/execute.js +100 -0
  96. package/lib/tasks/file-system/create-nginx-config.js +3 -5
  97. package/lib/tasks/file-system/create-php-config.js +2 -23
  98. package/lib/tasks/file-system/create-php-debug-config.js +45 -0
  99. package/lib/tasks/file-system/create-php-fpm-config.js +2 -4
  100. package/lib/tasks/file-system/create-phpstorm-config/exclude-folder-config.js +13 -3
  101. package/lib/tasks/file-system/create-phpstorm-config/index.js +2 -1
  102. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/php-workspace-project-configuration-config.js +1 -1
  103. package/lib/tasks/file-system/create-ssl-terminator-config.js +4 -7
  104. package/lib/tasks/file-system/create-varnish-config.js +4 -7
  105. package/lib/tasks/file-system/create-vscode-config.js +2 -1
  106. package/lib/tasks/file-system/index.js +3 -2
  107. package/lib/tasks/magento/enable-magento-composer-plugins.js +85 -30
  108. package/lib/tasks/magento/install-magento-project.js +3 -2
  109. package/lib/tasks/magento/setup-magento/configure-elasticsearch.js +2 -4
  110. package/lib/tasks/magento/setup-magento/flush-redis-config.js +3 -6
  111. package/lib/tasks/magento/setup-magento/index.js +2 -0
  112. package/lib/tasks/magento/setup-magento/install-magento.js +8 -13
  113. package/lib/tasks/magento/setup-magento/set-base-url.js +1 -1
  114. package/lib/tasks/magento/setup-magento/set-mail-config.js +22 -0
  115. package/lib/tasks/magento/setup-magento/varnish-config.js +4 -9
  116. package/lib/tasks/magento/setup-magento/waiting-for-varnish.js +17 -16
  117. package/lib/tasks/php/php-container.js +7 -3
  118. package/lib/tasks/php/update-env-php.js +3 -4
  119. package/lib/tasks/{prefix → project-config}/index.js +6 -6
  120. package/lib/tasks/requirements/composer-credentials.js +7 -3
  121. package/lib/tasks/requirements/docker/context.js +88 -0
  122. package/lib/tasks/requirements/docker/index.js +114 -20
  123. package/lib/tasks/requirements/docker/install.js +21 -7
  124. package/lib/tasks/requirements/docker/permissions.js +2 -11
  125. package/lib/tasks/requirements/docker/running-status.js +94 -24
  126. package/lib/tasks/requirements/docker/version.js +1 -0
  127. package/lib/tasks/requirements/index.js +0 -2
  128. package/lib/tasks/requirements/php-version.js +4 -2
  129. package/lib/tasks/start.js +27 -8
  130. package/lib/tasks/status/index.js +60 -21
  131. package/lib/tasks/stop.js +2 -0
  132. package/lib/tasks/theme/retrieve-theme-data.js +12 -2
  133. package/lib/util/config-file-validator.js +17 -3
  134. package/lib/util/execute-in-container.js +62 -0
  135. package/lib/util/instance-metadata.js +14 -2
  136. package/lib/util/systemctl.js +62 -13
  137. package/package.json +4 -3
  138. package/typings/context.d.ts +11 -0
  139. package/typings/index.d.ts +46 -1
  140. package/lib/tasks/execute/index.js +0 -26
  141. package/lib/tasks/requirements/dependency/arch.js +0 -50
  142. package/lib/tasks/requirements/dependency/centos.js +0 -36
  143. package/lib/tasks/requirements/dependency/fedora.js +0 -36
  144. package/lib/tasks/requirements/dependency/index.js +0 -33
  145. package/lib/tasks/requirements/dependency/mac.js +0 -124
  146. package/lib/tasks/requirements/dependency/ubuntu.js +0 -83
@@ -6,6 +6,8 @@ const { isIpAddress } = require('../util/ip');
6
6
  const systeminformation = require('systeminformation');
7
7
  const { deepmerge } = require('../util/deepmerge');
8
8
  const defaultEsEnv = require('./services/elasticsearch/default-es-env');
9
+ const logger = require('@scandipwa/scandipwa-dev-utils/logger');
10
+ const defaultMagentoUser = require('../tasks/database/default-magento-user');
9
11
 
10
12
  /**
11
13
  *
@@ -21,10 +23,11 @@ module.exports = async (ctx, overridenConfiguration, baseConfig) => {
21
23
  redis,
22
24
  elasticsearch,
23
25
  mariadb,
24
- varnish
26
+ varnish,
27
+ maildev
25
28
  } = configuration;
26
29
 
27
- const php = getPhpConfig(configuration, baseConfig);
30
+ const php = getPhpConfig(overridenConfiguration, baseConfig);
28
31
  const {
29
32
  prefix,
30
33
  magentoDir,
@@ -48,56 +51,65 @@ module.exports = async (ctx, overridenConfiguration, baseConfig) => {
48
51
  elasticsearch: {
49
52
  name: `${ prefix }_elasticsearch-data`
50
53
  },
51
- composer_home: {
52
- name: 'composer_home-data'
54
+ composer_cache: {
55
+ name: 'composer_cache-data',
56
+ opts: {
57
+ mode: 'z'
58
+ }
59
+ },
60
+ maildev: {
61
+ name: `${ prefix }_maildev-data`
53
62
  }
54
63
  };
55
64
 
56
- const isLinux = ctx.platform === 'linux';
57
- const { isWsl } = ctx;
58
- const isNotNativeLinux = (!isLinux || isWsl);
65
+ const { isDockerDesktop } = ctx;
59
66
 
60
- if (!isLinux) {
67
+ if (isDockerDesktop) {
61
68
  /**
62
- * When CMA is running in non-native linux environment,
63
- * we need also create named volumes for nginx to avoid performance penalty
69
+ * When CMA is running with Docker Desktop,
70
+ * we need create named volumes to avoid performance penalty
64
71
  */
65
72
  volumes.php = {
66
73
  name: `${ prefix }_project-data`,
74
+ driver: 'local',
67
75
  opt: {
68
- type: 'nfs',
76
+ type: 'none',
69
77
  device: path.join(magentoDir),
70
78
  o: 'bind'
71
79
  }
72
80
  };
73
81
  volumes.nginx = {
74
82
  name: `${ prefix }_nginx-data`,
83
+ driver: 'local',
75
84
  opt: {
76
- type: 'nfs',
85
+ type: 'none',
77
86
  device: path.join(cacheDir, 'nginx', 'conf.d'),
78
87
  o: 'bind'
79
88
  }
80
89
  };
81
90
  volumes.appPub = {
82
91
  name: `${ prefix }_pub-data`,
92
+ driver: 'local',
83
93
  opt: {
84
- type: 'nfs',
94
+ type: 'none',
85
95
  device: path.join(magentoDir, 'pub'),
86
96
  o: 'bind'
87
97
  }
88
98
  };
89
99
  volumes.appSetup = {
90
100
  name: `${ prefix }_setup-data`,
101
+ driver: 'local',
91
102
  opt: {
92
- type: 'nfs',
103
+ type: 'none',
93
104
  device: path.join(magentoDir, 'setup'),
94
105
  o: 'bind'
95
106
  }
96
107
  };
97
108
  volumes.sslTerminator = {
98
109
  name: `${ prefix }_ssl-terminator-data`,
110
+ driver: 'local',
99
111
  opt: {
100
- type: 'nfs',
112
+ type: 'none',
101
113
  device: path.join(cacheDir, 'ssl-terminator', 'conf.d'),
102
114
  o: 'bind'
103
115
  }
@@ -106,8 +118,9 @@ module.exports = async (ctx, overridenConfiguration, baseConfig) => {
106
118
  if (varnish.enabled) {
107
119
  volumes.varnish = {
108
120
  name: `${ prefix }_varnish-data`,
121
+ driver: 'local',
109
122
  opt: {
110
- type: 'nfs',
123
+ type: 'none',
111
124
  device: path.join(cacheDir, 'varnish'),
112
125
  o: 'bind'
113
126
  }
@@ -122,24 +135,23 @@ module.exports = async (ctx, overridenConfiguration, baseConfig) => {
122
135
  const dockerConfig = {
123
136
  php: {
124
137
  _: 'PHP',
125
- ports: isNotNativeLinux ? [
138
+ ports: isDockerDesktop ? [
126
139
  `${ isIpAddress(host) ? host : '127.0.0.1' }:${ ports.fpm }:9000`
127
140
  ] : [],
128
141
  forwardedPorts: [
129
- isNotNativeLinux
142
+ isDockerDesktop
130
143
  ? `127.0.0.1:${ ports.fpm }:9000`
131
144
  : `127.0.0.1:${ ports.fpm }`
132
145
  ],
133
- network: isNotNativeLinux ? network.name : 'host',
146
+ network: isDockerDesktop ? network.name : 'host',
134
147
  mountVolumes: [
135
- `${ isLinux ? magentoDir : volumes.php.name }:${containerMagentoDir}`,
136
- `${ volumes.composer_home.name }:/composer/home`,
148
+ `${ !isDockerDesktop ? magentoDir : volumes.php.name }:${containerMagentoDir}`,
149
+ `${ volumes.composer_cache.name }:/composer/home/cache`,
137
150
  `${ php.iniPath }:/usr/local/etc/php/php.ini`,
138
151
  `${ php.fpmConfPath }:/usr/local/etc/php-fpm.d/zz-docker.conf`
139
- ],
152
+ ].concat(ctx.debug ? [`${ php.debugIniPath }:/usr/local/etc/php/conf.d/00-xdebug.ini`] : []),
140
153
  env: {
141
- COMPOSER_AUTH: process.env.COMPOSER_AUTH || '',
142
- COMPOSER_HOME: '/composer/home'
154
+ COMPOSER_AUTH: JSON.stringify(JSON.parse(process.env.COMPOSER_AUTH), null, 0) || ''
143
155
  },
144
156
  restart: 'on-failure:5',
145
157
  image: `local-cma-project:${ prefix }`,
@@ -150,15 +162,15 @@ module.exports = async (ctx, overridenConfiguration, baseConfig) => {
150
162
  ],
151
163
  name: `${ prefix }_php`,
152
164
  connectCommand: ['/bin/sh'],
153
- user: isLinux ? `${os.userInfo().uid}:${os.userInfo().gid}` : ''
165
+ user: ((ctx.platform === 'linux' && isDockerDesktop) || !isDockerDesktop) ? `${os.userInfo().uid}:${os.userInfo().gid}` : ''
154
166
  },
155
167
  sslTerminator: {
156
168
  _: 'SSL Terminator (Nginx)',
157
- ports: isNotNativeLinux ? [
169
+ ports: isDockerDesktop ? [
158
170
  `${ isIpAddress(host) ? host : '127.0.0.1' }:${ ports.sslTerminator }:80`
159
171
  ] : [],
160
172
  forwardedPorts: [
161
- isNotNativeLinux
173
+ isDockerDesktop
162
174
  ? `127.0.0.1:${ ports.sslTerminator }:80`
163
175
  : `127.0.0.1:${ ports.sslTerminator }`
164
176
  ],
@@ -169,21 +181,21 @@ module.exports = async (ctx, overridenConfiguration, baseConfig) => {
169
181
  * Mount volumes directly on linux
170
182
  */
171
183
  mountVolumes: [
172
- `${ isLinux ? path.join(cacheDir, 'ssl-terminator', 'conf.d') : volumes.sslTerminator.name }:/etc/nginx/conf.d`
184
+ `${ !isDockerDesktop ? path.join(cacheDir, 'ssl-terminator', 'conf.d') : volumes.sslTerminator.name }:/etc/nginx/conf.d`
173
185
  ],
174
186
  restart: 'on-failure:5',
175
- network: isNotNativeLinux ? network.name : 'host',
187
+ network: isDockerDesktop ? network.name : 'host',
176
188
  image: `${ nginx.version ? `nginx:${ nginx.version }` : nginx.image }`,
177
189
  name: `${ prefix }_ssl-terminator`,
178
190
  command: "nginx -g 'daemon off;'"
179
191
  },
180
192
  nginx: {
181
193
  _: 'Nginx',
182
- ports: isNotNativeLinux ? [
194
+ ports: isDockerDesktop ? [
183
195
  `${ isIpAddress(host) ? host : '127.0.0.1' }:${ ports.app }:80`
184
196
  ] : [],
185
197
  forwardedPorts: [
186
- isNotNativeLinux
198
+ isDockerDesktop
187
199
  ? `127.0.0.1:${ ports.app }:80`
188
200
  : `127.0.0.1:${ ports.app }`
189
201
  ],
@@ -193,7 +205,7 @@ module.exports = async (ctx, overridenConfiguration, baseConfig) => {
193
205
  /**
194
206
  * Mount volumes directly on linux
195
207
  */
196
- mountVolumes: isLinux ? [
208
+ mountVolumes: !isDockerDesktop ? [
197
209
  `${ cacheDir }/nginx/conf.d:/etc/nginx/conf.d`,
198
210
  `${ path.join(magentoDir, 'pub') }:${path.join(containerMagentoDir, 'pub')}`,
199
211
  `${ path.join(magentoDir, 'setup') }:${path.join(containerMagentoDir, 'setup')}`
@@ -203,8 +215,7 @@ module.exports = async (ctx, overridenConfiguration, baseConfig) => {
203
215
  `${ volumes.appSetup.name }:${path.join(containerMagentoDir, 'setup')}`
204
216
  ],
205
217
  restart: 'on-failure:5',
206
- // TODO: use connect instead
207
- network: isNotNativeLinux ? network.name : 'host',
218
+ network: isDockerDesktop ? network.name : 'host',
208
219
  image: `${ nginx.version ? `nginx:${ nginx.version }` : nginx.image }`,
209
220
  name: `${ prefix }_nginx`,
210
221
  command: "nginx -g 'daemon off;'"
@@ -217,7 +228,6 @@ module.exports = async (ctx, overridenConfiguration, baseConfig) => {
217
228
  ports: [`127.0.0.1:${ ports.redis }:6379`],
218
229
  forwardedPorts: [`127.0.0.1:${ ports.redis }:6379`],
219
230
  mounts: [`source=${ volumes.redis.name },target=/data`],
220
- // TODO: use connect instead
221
231
  network: network.name,
222
232
  image: `${ redis.version ? `redis:${ redis.version }` : redis.image }`,
223
233
  name: `${ prefix }_redis`,
@@ -235,22 +245,18 @@ module.exports = async (ctx, overridenConfiguration, baseConfig) => {
235
245
  `${ path.join(baseConfig.cacheDir, 'mariadb.cnf') }:/etc/mysql/my.cnf`
236
246
  ],
237
247
  env: {
238
- MARIADB_PORT: 3306,
239
- MARIADB_ROOT_PASSWORD: 'scandipwa',
240
- MARIADB_USER: 'magento',
241
- MARIADB_PASSWORD: 'magento',
242
- MARIADB_DATABASE: 'magento'
248
+ MARIADB_ROOT_PASSWORD: 'scandipwa'
243
249
  },
244
- command: [
245
- '--log_bin_trust_function_creators=1'
246
- ]
247
- .join(' '),
250
+ command: '--log_bin_trust_function_creators=1',
248
251
  securityOptions: [
249
252
  'seccomp=unconfined'
250
253
  ],
251
254
  network: network.name,
252
255
  image: `${ mariadb.version ? `mariadb:${ mariadb.version }` : mariadb.image }`,
253
- name: `${ prefix }_mariadb`
256
+ name: `${ prefix }_mariadb`,
257
+ description: `To connect to MariaDB you can use the following users:
258
+ - User ${ logger.style.command('root') } with password ${ logger.style.command('scandipwa') }
259
+ - User ${ logger.style.command(defaultMagentoUser.user) } with password ${ logger.style.command(defaultMagentoUser.password) }`
254
260
  },
255
261
  elasticsearch: {
256
262
  _: 'ElasticSearch',
@@ -269,11 +275,41 @@ module.exports = async (ctx, overridenConfiguration, baseConfig) => {
269
275
  network: network.name,
270
276
  image: `${ elasticsearch.version ? `elasticsearch:${ elasticsearch.version }` : elasticsearch.image }`,
271
277
  name: `${ prefix }_elasticsearch`
278
+ },
279
+ maildev: {
280
+ _: 'MailDev',
281
+ ports: isDockerDesktop ? [
282
+ `127.0.0.1:${ ports.maildevWeb }:1080`,
283
+ `127.0.0.1:${ ports.maildevSMTP }:1025`
284
+ ] : [],
285
+ forwardedPorts: isDockerDesktop ? [
286
+ `127.0.0.1:${ ports.maildevWeb }:1080`,
287
+ `127.0.0.1:${ ports.maildevSMTP }:1025`
288
+ ] : [
289
+ `127.0.0.1:${ ports.maildevWeb }`,
290
+ `127.0.0.1:${ ports.maildevSMTP }`
291
+ ],
292
+ mountVolumes: [
293
+ `${ volumes.maildev.name }:/tmp/maildev`
294
+ ],
295
+ env: {
296
+ MAILDEV_SMTP_PORT: isDockerDesktop ? '1025' : ports.maildevSMTP,
297
+ MAILDEV_WEB_PORT: isDockerDesktop ? '1080' : ports.maildevWeb,
298
+ MAILDEV_MAIL_DIRECTORY: '/tmp/maildev'
299
+ },
300
+ name: `${ prefix }_maildev`,
301
+ network: isDockerDesktop ? network.name : 'host',
302
+ image: maildev.image,
303
+ user: !isDockerDesktop ? 'root:root' : '',
304
+ connectCommand: ['/bin/sh'],
305
+ healthCheck: {
306
+ cmd: `wget -O - http://127.0.0.1:${ isDockerDesktop ? '1080' : ports.maildevWeb }/healthz || exit 1`
307
+ }
272
308
  }
273
309
  };
274
310
 
275
- if (ssl.enabled) {
276
- dockerConfig.nginx.ports.push(
311
+ if (ssl.enabled && isDockerDesktop) {
312
+ dockerConfig.sslTerminator.ports.push(
277
313
  `${isIpAddress(host) ? host : '127.0.0.1'}:443:443`
278
314
  );
279
315
  }
@@ -284,13 +320,13 @@ module.exports = async (ctx, overridenConfiguration, baseConfig) => {
284
320
  image: `${ varnish.version ? `varnish:${ varnish.version }` : varnish.image }`,
285
321
  name: `${ prefix }_varnish`,
286
322
  mountVolumes: [
287
- `${ isLinux ? path.join(cacheDir, 'varnish') : volumes.varnish.name }:/etc/varnish`
323
+ `${ !isDockerDesktop ? path.join(cacheDir, 'varnish') : volumes.varnish.name }:/etc/varnish`
288
324
  ],
289
- ports: isNotNativeLinux ? [
325
+ ports: isDockerDesktop ? [
290
326
  `${ isIpAddress(host) ? host : '127.0.0.1' }:${ ports.varnish }:80`
291
327
  ] : [],
292
328
  forwardedPorts: [
293
- isNotNativeLinux
329
+ isDockerDesktop
294
330
  ? `127.0.0.1:${ ports.varnish }:80`
295
331
  : `127.0.0.1:${ ports.varnish }`
296
332
  ],
@@ -298,12 +334,13 @@ module.exports = async (ctx, overridenConfiguration, baseConfig) => {
298
334
  VARNISH_SIZE: '2G'
299
335
  },
300
336
  restart: 'on-failure:30',
301
- network: isNotNativeLinux ? network.name : 'host',
337
+ network: isDockerDesktop ? network.name : 'host',
302
338
  // eslint-disable-next-line max-len
303
- command: `/bin/bash -c "varnishd -a :${ isNotNativeLinux ? 80 : ports.varnish } -t 600 -f /etc/varnish/default.vcl -s malloc,512m -p http_resp_hdr_len=70000 -p http_resp_size=100000 && varnishlog"`,
339
+ command: `/bin/bash -c "varnishd -a :${ isDockerDesktop ? 80 : ports.varnish } -t 600 -f /etc/varnish/default.vcl -s Cache=malloc,2048m -s Transient=malloc,512m -p http_resp_hdr_len=70000 -p http_resp_size=100000 && varnishlog"`,
304
340
  tmpfs: [
305
341
  '/var/lib/varnish:exec'
306
- ]
342
+ ],
343
+ description: `Varnish HealthCheck status: ${ logger.style.command(varnish.healthCheck ? 'enabled' : 'disabled') }`
307
344
  };
308
345
  }
309
346
 
@@ -1,3 +1,4 @@
1
+ const { getProjectConfig } = require('./config');
1
2
  const { getConfigFromMagentoVersion } = require('./index');
2
3
 
3
4
  /**
@@ -8,6 +9,10 @@ const getProjectConfiguration = () => ({
8
9
  task: async (ctx) => {
9
10
  const { magentoVersion } = ctx;
10
11
 
12
+ if (typeof ctx.debug !== 'boolean') {
13
+ ctx.debug = getProjectConfig().debug;
14
+ }
15
+
11
16
  ctx.config = await getConfigFromMagentoVersion(ctx, {
12
17
  magentoVersion
13
18
  });
@@ -9,6 +9,7 @@ const { getMagentoConfig } = require('./magento-config');
9
9
  const resolveConfigurationWithOverrides = require('../util/resolve-configuration-with-overrides');
10
10
  const { getPrefix, folderName } = require('../util/prefix');
11
11
  const UnknownError = require('../errors/unknown-error');
12
+ const { getProjectConfig } = require('./config');
12
13
 
13
14
  const platforms = ['linux', 'darwin'];
14
15
  const darwinMinimalVersion = '10.5';
@@ -33,7 +34,11 @@ const magento = {
33
34
 
34
35
  module.exports = {
35
36
  /**
36
- * @param {string} magentoVersion
37
+ * @param {import('../../typings/context')} ctx
38
+ * @param {Object} param1
39
+ * @param {String} [param1.magentoVersion]
40
+ * @param {String} [param1.projectPath]
41
+ * @param {String} [param1.prefix]
37
42
  */
38
43
  async getConfigFromMagentoVersion(ctx, {
39
44
  magentoVersion,
@@ -45,6 +50,7 @@ module.exports = {
45
50
  if (!configurations[magentoVersion]) {
46
51
  throw new UnknownError(`No config found for magento version ${magentoVersion}`);
47
52
  }
53
+ const projectConfig = getProjectConfig();
48
54
 
49
55
  const {
50
56
  overridenConfiguration,
@@ -56,13 +62,14 @@ module.exports = {
56
62
  );
57
63
 
58
64
  return {
59
- php: getPhpConfig(overridenConfiguration.configuration, newBaseConfig),
65
+ php: getPhpConfig(overridenConfiguration, newBaseConfig),
60
66
  docker: await getDockerConfig(ctx, overridenConfiguration, newBaseConfig),
61
67
  magentoConfiguration: getMagentoConfig(overridenConfiguration.magento),
62
68
  baseConfig: newBaseConfig,
63
69
  overridenConfiguration,
64
70
  userConfiguration,
65
- nonOverridenConfiguration: configurations[magentoVersion]
71
+ nonOverridenConfiguration: configurations[magentoVersion],
72
+ projectConfig
66
73
  };
67
74
  },
68
75
  baseConfig,
@@ -14,6 +14,7 @@ const php72 = ({
14
14
  debugImage: `${ baseImage }-debug`,
15
15
  configTemplate: path.join(templateDir || '', 'php.template.ini'),
16
16
  fpmConfigTemplate: path.join(templateDir || '', 'php-fpm.template.conf'),
17
+ debugTemplate: path.join(templateDir || '', 'php-debug.template.ini'),
17
18
  extensions: {
18
19
  xdebug,
19
20
  ...extensions
@@ -14,6 +14,7 @@ const php73 = ({
14
14
  debugImage: `${ baseImage }-debug`,
15
15
  configTemplate: path.join(templateDir || '', 'php.template.ini'),
16
16
  fpmConfigTemplate: path.join(templateDir || '', 'php-fpm.template.conf'),
17
+ debugTemplate: path.join(templateDir || '', 'php-debug.template.ini'),
17
18
  extensions: {
18
19
  xdebug,
19
20
  ...extensions
@@ -14,6 +14,7 @@ const php74 = ({
14
14
  debugImage: `${ baseImage }-debug`,
15
15
  configTemplate: path.join(templateDir || '', 'php.template.ini'),
16
16
  fpmConfigTemplate: path.join(templateDir || '', 'php-fpm.template.conf'),
17
+ debugTemplate: path.join(templateDir || '', 'php-debug.template.ini'),
17
18
  extensions: {
18
19
  xdebug,
19
20
  ...extensions
@@ -14,6 +14,7 @@ const php81 = ({
14
14
  debugImage: `${ baseImage }-debug`,
15
15
  configTemplate: path.join(templateDir || '', 'php.template.ini'),
16
16
  fpmConfigTemplate: path.join(templateDir || '', 'php-fpm.template.conf'),
17
+ debugTemplate: path.join(templateDir || '', 'php-debug.template.ini'),
17
18
  extensions: {
18
19
  xdebug,
19
20
  ...extensions
@@ -5,17 +5,18 @@ const path = require('path');
5
5
  * @param {import('../../typings/context').ListrContext['config']['baseConfig']} baseConfig
6
6
  */
7
7
  module.exports = (overridenConfiguration, baseConfig) => {
8
- const { php } = overridenConfiguration;
8
+ const { configuration: { php } } = overridenConfiguration;
9
9
 
10
10
  const { cacheDir } = baseConfig;
11
11
 
12
12
  const phpConfiguration = {
13
13
  iniPath: path.join(cacheDir, 'php.ini'),
14
14
  iniTemplatePath: php.configTemplate,
15
+ debugIniPath: path.join(cacheDir, 'xdebug.ini'),
16
+ debugTemplatePath: php.debugTemplate,
15
17
  fpmTemplatePath: php.fpmConfigTemplate,
16
18
  fpmConfPath: path.join(cacheDir, 'php-fpm.conf'),
17
- extensions: php.extensions,
18
- version: php.version
19
+ extensions: php.extensions
19
20
  };
20
21
 
21
22
  return phpConfiguration;
@@ -60,7 +60,9 @@ const defaultPorts = {
60
60
  fpm: 9000,
61
61
  mariadb: 3306,
62
62
  redis: 6379,
63
- elasticsearch: 9200
63
+ elasticsearch: 9200,
64
+ maildevSMTP: 1025,
65
+ maildevWeb: 1080
64
66
  };
65
67
 
66
68
  /**
@@ -0,0 +1,13 @@
1
+ /**
2
+ * @returns {import('../../../../../typings/index').ComposerConfiguration}
3
+ */
4
+ const composer1 = () => ({
5
+ version: '1',
6
+ plugins: {
7
+ 'hirak/prestissimo': {
8
+ enabled: true
9
+ }
10
+ }
11
+ });
12
+
13
+ module.exports = composer1;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @returns {import('../../../../../typings/index').ComposerConfiguration}
3
+ */
4
+ const composer2 = () => ({
5
+ version: '2'
6
+ });
7
+
8
+ module.exports = composer2;
@@ -0,0 +1,4 @@
1
+ module.exports = {
2
+ composer1: require('./composer-1'),
3
+ composer2: require('./composer-2')
4
+ };
@@ -0,0 +1,7 @@
1
+ const maildev = () => ({
2
+ image: 'maildev/maildev'
3
+ });
4
+
5
+ module.exports = {
6
+ maildev
7
+ };
@@ -0,0 +1,3 @@
1
+ module.exports = {
2
+ nginx118: require('./nginx-1.18')
3
+ };
@@ -0,0 +1,11 @@
1
+ const path = require('path');
2
+
3
+ /**
4
+ * @returns {import('../../../../../typings/index').NginxConfiguration}
5
+ */
6
+ const nginx118 = ({ templateDir }) => ({
7
+ version: '1.18.0',
8
+ configTemplate: path.join(templateDir || '', 'nginx.template.conf')
9
+ });
10
+
11
+ module.exports = nginx118;
@@ -1,5 +1,8 @@
1
1
  const path = require('path');
2
2
 
3
+ /**
4
+ * @returns {import('../../../../typings/index').SSLTerminatorConfiguration}
5
+ */
3
6
  const sslTerminator = ({ templateDir }) => ({
4
7
  version: '1.18.0',
5
8
  configTemplate: path.join(templateDir || '', 'ssl-terminator.template.conf')
@@ -1,17 +1,24 @@
1
1
  RED='\033[0;31m'
2
2
  GREEN='\033[0;32m'
3
+ YELLOW='\033[1;33m'
4
+ ORANGE='\033[0;33m'
5
+ BLUE='\033[0;34m'
3
6
  NC='\033[0m' # No Color
4
7
 
5
- alias php="npm run exec php php"
8
+ alias exec="node ./node_modules/.bin/magento-scripts-exec"
9
+ alias php="exec php php"
6
10
  alias magento="php bin/magento"
7
11
  alias magneto="echo -e 'Not ${RED}magneto${NC} but ${GREEN}magento${NC} please! or at least ${GREEN}m${NC}!' && magento"
8
12
  alias m="magento"
9
- alias composer="npm run exec php composer"
13
+ alias composer="exec php composer"
10
14
  alias c="composer"
11
15
  <% if (it.varnishEnabled) { %>
12
- alias cvc="npm run exec varnish varnishadm ban req.url '~ /' && echo 'Varnish cache cleared!'"
16
+ alias cvc="exec varnish varnishadm ban req.url '~ /' && echo 'Varnish cache cleared!'"
13
17
  <% } %>
14
- alias mariadb="npm run exec mariadb 'mysql -umagento -pmagento'"
15
- alias mariadbroot="npm run exec mariadb 'mysql -uroot -pscandipwa'"
18
+ alias mariadb="exec mariadb 'mysql -umagento -pmagento'"
19
+ alias mariadbroot="exec mariadb 'mysql -uroot -pscandipwa'"
16
20
 
21
+ # silence warning on macos
17
22
  export BASH_SILENCE_DEPRECATION_WARNING=1
23
+
24
+ export PS1="[${YELLOW}cli${NC}] \w [${YELLOW}<%~ it.magentoVersion %>${NC}] [${GREEN}\t${NC}] \nbash \v: "
@@ -0,0 +1,31 @@
1
+ [xdebug]
2
+ error_reporting=E_ALL
3
+
4
+ xdebug.idekey=PHPSTORM
5
+
6
+ <% if (it.isXDebug2) { %>
7
+ xdebug.remote_autostart=1
8
+ xdebug.remote_enable=1
9
+
10
+ xdebug.remote_host=<%~ it.hostMachine %>
11
+
12
+ xdebug.remote_port=9003
13
+
14
+ xdebug.remote_log=<%~ it.mageRoot %>/var/log/xdebug.log
15
+
16
+ <% } else { %>
17
+
18
+ xdebug.mode=debug
19
+ xdebug.client_host=<%~ it.hostMachine %>
20
+
21
+ xdebug.client_port=9003
22
+
23
+ ; THIS THING WILL BREAK PHP
24
+ ; xdebug.start_with_request=yes
25
+
26
+ xdebug.discover_client_host=false
27
+ xdebug.start_upon_error=yes
28
+
29
+ xdebug.log=<%~ it.mageRoot %>/var/log/xdebug.log
30
+
31
+ <% } %>
@@ -3,6 +3,7 @@ daemonize = no
3
3
  log_level = debug
4
4
 
5
5
  [www]
6
+ clear_env = no
6
7
  user = nobody
7
8
  ;; Commented because if it is not set, php-fpm will use default group.
8
9
  ;; https://www.php.net/manual/en/install.fpm.configuration.php#group
@@ -17,5 +18,3 @@ pm.max_requests = 5000
17
18
  pm.process_idle_timeout = 10s
18
19
  pm.status_path = /fpmstatus
19
20
  listen = <%~ it.port %>
20
-
21
- env[PATH] = $PATH