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

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 (226) hide show
  1. package/lib/commands/cli.js +4 -6
  2. package/lib/commands/execute.js +29 -4
  3. package/lib/commands/import-db.js +1 -1
  4. package/lib/commands/logs.js +1 -1
  5. package/lib/commands/start.js +38 -20
  6. package/lib/commands/status.js +2 -0
  7. package/lib/config/docker.js +102 -84
  8. package/lib/config/get-project-configuration.js +3 -1
  9. package/lib/config/index.js +10 -7
  10. package/lib/config/magento/required-php-extensions/index.js +29 -0
  11. package/lib/config/magento/required-php-extensions/magento-2.3.js +19 -0
  12. package/lib/config/magento/required-php-extensions/magento-2.4.js +29 -0
  13. package/lib/config/php/base-repo.js +3 -0
  14. package/lib/config/php/extensions/apcu.js +12 -0
  15. package/lib/config/php/extensions/bcmath.js +7 -0
  16. package/lib/config/php/extensions/curl.js +11 -0
  17. package/lib/config/php/extensions/gd.js +14 -0
  18. package/lib/config/php/extensions/index.js +18 -2
  19. package/lib/config/php/extensions/intl.js +10 -0
  20. package/lib/config/php/extensions/opcache.js +10 -0
  21. package/lib/config/php/extensions/pdo_mysql.js +7 -0
  22. package/lib/config/php/extensions/soap.js +10 -0
  23. package/lib/config/php/extensions/sodium.js +10 -0
  24. package/lib/config/php/extensions/xdebug.js +8 -5
  25. package/lib/config/php/extensions/xsl.js +10 -0
  26. package/lib/config/php/extensions/zip.js +10 -0
  27. package/lib/config/php/{releases → versions}/index.js +0 -0
  28. package/lib/config/php/versions/php-7.2.js +23 -0
  29. package/lib/config/php/versions/php-7.3.js +23 -0
  30. package/lib/config/php/versions/php-7.4.js +23 -0
  31. package/lib/config/php/versions/php-8.1.js +23 -0
  32. package/lib/config/php-config.js +8 -12
  33. package/lib/config/port-config.js +2 -6
  34. package/lib/config/services/elasticsearch/base-repo.js +3 -0
  35. package/lib/config/services/elasticsearch/default-es-env.js +6 -0
  36. package/lib/config/services/elasticsearch/versions/elasticsearch-6.8.js +19 -0
  37. package/lib/config/services/elasticsearch/versions/index.js +5 -0
  38. package/lib/config/templates/magentorc.template +5 -5
  39. package/lib/config/templates/mariadb.template.cnf +191 -0
  40. package/lib/config/templates/php-fpm.template.conf +3 -3
  41. package/lib/config/templates/php.template.ini +12 -6
  42. package/lib/config/templates/ssl-terminator.template.conf +1 -1
  43. package/lib/config/templates/vscode-launch.template.json +3 -1
  44. package/lib/config/versions/magento-2.3.0.js +10 -5
  45. package/lib/config/versions/magento-2.3.1.js +10 -5
  46. package/lib/config/versions/magento-2.3.2-p1.js +43 -0
  47. package/lib/config/versions/magento-2.3.2-p2.js +10 -5
  48. package/lib/config/versions/magento-2.3.2.js +10 -5
  49. package/lib/config/versions/magento-2.3.3-p1.js +10 -5
  50. package/lib/config/versions/magento-2.3.3.js +10 -5
  51. package/lib/config/versions/magento-2.3.4-p1.js +43 -0
  52. package/lib/config/versions/magento-2.3.4-p2.js +10 -5
  53. package/lib/config/versions/magento-2.3.4.js +10 -5
  54. package/lib/config/versions/magento-2.3.5-p1.js +8 -2
  55. package/lib/config/versions/magento-2.3.5-p2.js +8 -2
  56. package/lib/config/versions/magento-2.3.5.js +8 -2
  57. package/lib/config/versions/magento-2.3.6-p1.js +8 -2
  58. package/lib/config/versions/magento-2.3.6.js +8 -2
  59. package/lib/config/versions/magento-2.3.7-p1.js +8 -2
  60. package/lib/config/versions/magento-2.3.7-p2.js +8 -2
  61. package/lib/config/versions/magento-2.3.7-p3.js +8 -2
  62. package/lib/config/versions/magento-2.3.7.js +8 -2
  63. package/lib/config/versions/magento-2.4.0-p1.js +9 -3
  64. package/lib/config/versions/magento-2.4.0.js +9 -3
  65. package/lib/config/versions/magento-2.4.1-p1.js +6 -5
  66. package/lib/config/versions/magento-2.4.1.js +9 -2
  67. package/lib/config/versions/magento-2.4.2-p1.js +6 -5
  68. package/lib/config/versions/magento-2.4.2-p2.js +6 -6
  69. package/lib/config/versions/magento-2.4.2.js +6 -6
  70. package/lib/config/versions/magento-2.4.3-p1.js +7 -7
  71. package/lib/config/versions/magento-2.4.3-p2.js +7 -7
  72. package/lib/config/versions/magento-2.4.3.js +7 -7
  73. package/lib/config/versions/magento-2.4.4.js +9 -2
  74. package/lib/tasks/cleanup.js +3 -3
  75. package/lib/tasks/composer/index.js +14 -104
  76. package/lib/tasks/database/connect-to-database.js +117 -0
  77. package/lib/tasks/database/create-magento-database.js +18 -0
  78. package/lib/tasks/{mysql → database}/dump-theme-config.js +3 -3
  79. package/lib/tasks/{mysql → database}/fix-db.js +2 -2
  80. package/lib/tasks/{mysql/import-dump-to-mysql.js → database/import-dump-to-database.js} +65 -22
  81. package/lib/tasks/{mysql → database}/import-remote-db/index.js +0 -0
  82. package/lib/tasks/{mysql/import-remote-db/ssh/mysqldump-command.js → database/import-remote-db/ssh/database-dump-command.js} +2 -2
  83. package/lib/tasks/{mysql → database}/import-remote-db/ssh/index.js +0 -0
  84. package/lib/tasks/{mysql → database}/import-remote-db/ssh/readymage.js +4 -4
  85. package/lib/tasks/{mysql → database}/import-remote-db/ssh/regular-server.js +2 -2
  86. package/lib/tasks/{mysql → database}/index.js +2 -2
  87. package/lib/tasks/{mysql → database}/magento-tables.js +0 -0
  88. package/lib/tasks/{mysql → database}/restore-theme-config.js +4 -4
  89. package/lib/tasks/docker/api.d.ts +71 -0
  90. package/lib/tasks/docker/api.js +30 -0
  91. package/lib/tasks/docker/containers/container-api.d.ts +128 -0
  92. package/lib/tasks/docker/containers/container-api.js +153 -0
  93. package/lib/tasks/docker/containers/index.js +19 -0
  94. package/lib/tasks/docker/containers/tasks.js +215 -0
  95. package/lib/tasks/docker/convert-legacy-volumes.js +15 -10
  96. package/lib/tasks/docker/convert-mysql-to-mariadb.js +284 -0
  97. package/lib/tasks/docker/image/image-api.d.ts +34 -0
  98. package/lib/tasks/docker/image/image-api.js +49 -0
  99. package/lib/tasks/docker/image/index.js +5 -0
  100. package/lib/tasks/docker/index.js +1 -13
  101. package/lib/tasks/docker/network/index.js +7 -0
  102. package/lib/tasks/docker/network/network-api.d.ts +103 -0
  103. package/lib/tasks/docker/network/network-api.js +99 -0
  104. package/lib/tasks/docker/{network.js → network/tasks.js} +17 -10
  105. package/lib/tasks/docker/project-image-builder.js +167 -0
  106. package/lib/tasks/docker/volume/index.js +8 -0
  107. package/lib/tasks/docker/{volumes.js → volume/tasks.js} +5 -19
  108. package/lib/tasks/docker/volume/volume-api.d.ts +39 -0
  109. package/lib/tasks/docker/volume/volume-api.js +66 -0
  110. package/lib/tasks/execute/index.js +5 -2
  111. package/lib/tasks/file-system/create-mariadb-config.js +23 -0
  112. package/lib/tasks/file-system/create-nginx-config.js +2 -3
  113. package/lib/tasks/file-system/create-php-config.js +20 -5
  114. package/lib/tasks/file-system/create-php-fpm-config.js +8 -4
  115. package/lib/tasks/file-system/create-phpstorm-config/exclude-folder-config.js +41 -29
  116. package/lib/tasks/file-system/create-phpstorm-config/index.js +2 -0
  117. package/lib/tasks/file-system/create-phpstorm-config/keys.js +15 -1
  118. package/lib/tasks/file-system/create-phpstorm-config/php-config/index.js +4 -1
  119. package/lib/tasks/file-system/create-phpstorm-config/php-config/php-config.js +3 -3
  120. package/lib/tasks/file-system/create-phpstorm-config/php-config/php-interpreters-config.js +81 -0
  121. package/lib/tasks/file-system/create-phpstorm-config/php-docker-settings-config/index.js +42 -0
  122. package/lib/tasks/file-system/create-phpstorm-config/php-docker-settings-config/php-docker-settings-config.js +9 -0
  123. package/lib/tasks/file-system/create-phpstorm-config/php-docker-settings-config/setup-php-docker-container-settings-config.js +66 -0
  124. package/lib/tasks/file-system/create-phpstorm-config/setup-xml-structure.js +11 -9
  125. package/lib/tasks/file-system/create-phpstorm-config/stylelint-config.js +2 -1
  126. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/composer-settings-config.js +15 -30
  127. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/index.js +24 -5
  128. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/mess-detector-project-configuration-config.js +50 -0
  129. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/php-code-sniffer-project-configuration-config.js +50 -0
  130. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/php-cs-fixer-project-configuration-config.js +50 -0
  131. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/php-debug-general-config.js +15 -15
  132. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/php-server-config.js +29 -3
  133. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/php-stan-project-configuration-config.js.js +50 -0
  134. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/php-workspace-project-configuration-config.js +42 -0
  135. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/psalm-project-configuration-config.js.js +50 -0
  136. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/workspace-config.js +0 -2
  137. package/lib/tasks/file-system/create-ssl-terminator-config.js +4 -2
  138. package/lib/tasks/file-system/create-vscode-config.js +57 -42
  139. package/lib/tasks/file-system/index.js +5 -2
  140. package/lib/tasks/import-dump.js +6 -6
  141. package/lib/tasks/link.js +5 -4
  142. package/lib/tasks/magento/install-magento-project.js +31 -63
  143. package/lib/tasks/magento/setup-magento/adjust-full-page-cache.js +4 -4
  144. package/lib/tasks/magento/setup-magento/configure-elasticsearch.js +7 -3
  145. package/lib/tasks/magento/setup-magento/create-admin.js +5 -6
  146. package/lib/tasks/magento/setup-magento/delete-admin-users.js +2 -2
  147. package/lib/tasks/magento/setup-magento/delete-customers.js +4 -4
  148. package/lib/tasks/magento/setup-magento/delete-orders.js +4 -4
  149. package/lib/tasks/magento/setup-magento/disable-2fa.js +3 -5
  150. package/lib/tasks/magento/setup-magento/disable-maintenance-mode.js +3 -4
  151. package/lib/tasks/magento/setup-magento/increase-admin-session-lifetime.js +2 -2
  152. package/lib/tasks/magento/setup-magento/index.js +2 -0
  153. package/lib/tasks/magento/setup-magento/install-magento.js +21 -20
  154. package/lib/tasks/magento/setup-magento/migrate-database.js +7 -14
  155. package/lib/tasks/magento/setup-magento/set-base-url.js +2 -2
  156. package/lib/tasks/magento/setup-magento/set-deployment-mode.js +4 -4
  157. package/lib/tasks/magento/setup-magento/set-url-rewrite.js +2 -2
  158. package/lib/tasks/magento/setup-magento/varnish-config.js +10 -8
  159. package/lib/tasks/magento/setup-magento/waiting-for-varnish.js +128 -3
  160. package/lib/tasks/php/php-container.js +108 -0
  161. package/lib/tasks/php/update-env-php.js +39 -21
  162. package/lib/tasks/php/update-env.php +66 -61
  163. package/lib/tasks/php/working_health_check.php +85 -0
  164. package/lib/tasks/requirements/{composer.js → composer-credentials.js} +3 -1
  165. package/lib/tasks/requirements/docker/index.js +15 -12
  166. package/lib/tasks/requirements/docker/performance.js +54 -0
  167. package/lib/tasks/requirements/docker/version.js +8 -8
  168. package/lib/tasks/requirements/index.js +5 -8
  169. package/lib/tasks/requirements/php-version.js +8 -116
  170. package/lib/tasks/requirements/platform.js +12 -25
  171. package/lib/tasks/start.js +21 -50
  172. package/lib/tasks/status/index.js +8 -12
  173. package/lib/tasks/stop.js +0 -2
  174. package/lib/tasks/theme/install-theme.js +1 -1
  175. package/lib/tasks/theme/link-theme.js +2 -2
  176. package/lib/tasks/theme/symlink-theme.js +2 -3
  177. package/lib/util/config-file-validator.js +27 -13
  178. package/lib/util/config-php-json.js +13 -4
  179. package/lib/util/database.js +7 -7
  180. package/lib/util/dockerfile-builder/build-instructions.js +197 -0
  181. package/lib/util/dockerfile-builder/index.js +276 -0
  182. package/lib/util/dockerfile-builder/types.d.ts +123 -0
  183. package/lib/util/env-php-json.js +10 -6
  184. package/lib/util/exec-async-command.js +3 -9
  185. package/lib/util/macos-version.js +20 -0
  186. package/lib/util/magento-task.js +3 -4
  187. package/lib/util/nginx-logs-parser.js +122 -0
  188. package/lib/util/php-task.js +3 -6
  189. package/lib/util/run-composer.js +6 -14
  190. package/lib/util/run-container-image.js +17 -0
  191. package/lib/util/run-magento.js +6 -14
  192. package/lib/util/run-php.js +6 -17
  193. package/package.json +9 -9
  194. package/typings/context.d.ts +7 -13
  195. package/typings/index.d.ts +67 -85
  196. package/yarn-error.log +9660 -0
  197. package/lib/config/composer.js +0 -11
  198. package/lib/config/php/extensions/libsodium.js +0 -36
  199. package/lib/config/php/releases/php-7.2.js +0 -25
  200. package/lib/config/php/releases/php-7.3.js +0 -25
  201. package/lib/config/php/releases/php-7.4.js +0 -23
  202. package/lib/config/php/releases/php-8.1.js +0 -25
  203. package/lib/config/phpbrew.js +0 -12
  204. package/lib/tasks/composer/install-prestissimo.js +0 -103
  205. package/lib/tasks/docker/containers.js +0 -231
  206. package/lib/tasks/mysql/connect-to-mysql.js +0 -114
  207. package/lib/tasks/mysql/create-magento-database.js +0 -18
  208. package/lib/tasks/php/bundled-extensions.js +0 -27
  209. package/lib/tasks/php/compile-options.js +0 -56
  210. package/lib/tasks/php/compile.js +0 -55
  211. package/lib/tasks/php/configure.js +0 -89
  212. package/lib/tasks/php/extensions/disable.js +0 -49
  213. package/lib/tasks/php/extensions/enable.js +0 -52
  214. package/lib/tasks/php/extensions/index.js +0 -80
  215. package/lib/tasks/php/extensions/install.js +0 -54
  216. package/lib/tasks/php/index.js +0 -79
  217. package/lib/tasks/php/install-sodium.js +0 -93
  218. package/lib/tasks/php/update-phpbrew.js +0 -45
  219. package/lib/tasks/php/validate-php.js +0 -67
  220. package/lib/tasks/php-fpm/get-process-id.js +0 -14
  221. package/lib/tasks/php-fpm/index.js +0 -4
  222. package/lib/tasks/php-fpm/start-php-fpm.js +0 -49
  223. package/lib/tasks/php-fpm/stop-php-fpm.js +0 -48
  224. package/lib/tasks/requirements/phpbrew/index.js +0 -61
  225. package/lib/tasks/requirements/phpbrew/install.js +0 -159
  226. package/lib/tasks/requirements/phpbrew/version.js +0 -28
@@ -0,0 +1,276 @@
1
+ const { buildInstructions } = require('./build-instructions');
2
+
3
+ class DockerFileBuilder {
4
+ /**
5
+ * @type {import('./types').DockerfileInstruction[]}
6
+ */
7
+ instructions = [];
8
+
9
+ /**
10
+ * @param {Omit<import('./types').FromInstruction, 'type'>} param0
11
+ * @returns {this}
12
+ */
13
+ from({
14
+ image,
15
+ tag = 'latest',
16
+ platform,
17
+ name
18
+ }) {
19
+ this.instructions.push({
20
+ type: 'FROM',
21
+ image,
22
+ tag,
23
+ platform,
24
+ name
25
+ });
26
+
27
+ return this;
28
+ }
29
+
30
+ /**
31
+ * @param {import('./types').RunInstruction['command']} command
32
+ */
33
+ run(command) {
34
+ this.instructions.push({
35
+ type: 'RUN',
36
+ command
37
+ });
38
+
39
+ return this;
40
+ }
41
+
42
+ /**
43
+ * @param {import('./types').CmdInstruction['command']} command
44
+ */
45
+ cmd(command) {
46
+ this.instructions.push({
47
+ type: 'CMD',
48
+ command
49
+ });
50
+
51
+ return this;
52
+ }
53
+
54
+ /**
55
+ * @param {import('./types').LabelInstruction['labels']} labels
56
+ */
57
+ label(labels) {
58
+ this.instructions.push({
59
+ type: 'LABEL',
60
+ labels
61
+ });
62
+
63
+ return this;
64
+ }
65
+
66
+ /**
67
+ * @param {Omit<import('./types').ExposeInstruction, 'type'>} param0
68
+ */
69
+ expose({
70
+ port,
71
+ protocol
72
+ }) {
73
+ this.instructions.push({
74
+ type: 'EXPOSE',
75
+ port,
76
+ protocol
77
+ });
78
+
79
+ return this;
80
+ }
81
+
82
+ /**
83
+ * @param {Record<string, string>} env
84
+ */
85
+ env(env) {
86
+ Object.entries(env).forEach(([name, value]) => {
87
+ this.instructions.push({
88
+ type: 'ENV',
89
+ name,
90
+ value
91
+ });
92
+ });
93
+
94
+ return this;
95
+ }
96
+
97
+ /**
98
+ * @param {Omit<import('./types').AddInstruction, 'type'>} param0
99
+ */
100
+ add({
101
+ src,
102
+ dest,
103
+ chown
104
+ }) {
105
+ this.instructions.push({
106
+ type: 'ADD',
107
+ src,
108
+ dest,
109
+ chown
110
+ });
111
+
112
+ return this;
113
+ }
114
+
115
+ /**
116
+ * @param {Omit<import('./types').CopyInstruction, 'type'>} param0
117
+ */
118
+ copy({
119
+ src,
120
+ dest,
121
+ chown,
122
+ from
123
+ }) {
124
+ this.instructions.push({
125
+ type: 'COPY',
126
+ src,
127
+ dest,
128
+ chown,
129
+ from
130
+ });
131
+
132
+ return this;
133
+ }
134
+
135
+ /**
136
+ * @param {import('./types').EntrypointInstruction['command']} command
137
+ */
138
+ entrypoint(command) {
139
+ this.instructions.push({
140
+ type: 'ENTRYPOINT',
141
+ command
142
+ });
143
+
144
+ return this;
145
+ }
146
+
147
+ /**
148
+ * @param {import('./types').VolumeInstruction['volume']} volume
149
+ */
150
+ volume(volume) {
151
+ this.instructions.push({
152
+ type: 'VOLUME',
153
+ volume
154
+ });
155
+
156
+ return this;
157
+ }
158
+
159
+ /**
160
+ * @param {import('./types').UserInstruction['user']} user
161
+ */
162
+ user(user) {
163
+ this.instructions.push({
164
+ type: 'USER',
165
+ user
166
+ });
167
+
168
+ return this;
169
+ }
170
+
171
+ /**
172
+ * @param {import('./types').WorkDirInstruction['workdir']} workdir
173
+ */
174
+ workDir(workdir) {
175
+ this.instructions.push({
176
+ type: 'WORKDIR',
177
+ workdir
178
+ });
179
+
180
+ return this;
181
+ }
182
+
183
+ /**
184
+ * @param {Omit<import('./types').ArgInstruction, 'type'>} param0
185
+ */
186
+ arg({
187
+ name,
188
+ defaultValue
189
+ }) {
190
+ this.instructions.push({
191
+ type: 'ARG',
192
+ name,
193
+ defaultValue
194
+ });
195
+
196
+ return this;
197
+ }
198
+
199
+ /**
200
+ * @param {import('./types').OnBuildInstruction['instruction']} instruction
201
+ */
202
+ onBuild(instruction) {
203
+ this.instructions.push({
204
+ type: 'ONBUILD',
205
+ instruction
206
+ });
207
+
208
+ return this;
209
+ }
210
+
211
+ /**
212
+ * @param {import('./types').StopSignalInstruction['signal']} signal
213
+ */
214
+ stopSignal(signal) {
215
+ this.instructions.push({
216
+ type: 'STOPSIGNAL',
217
+ signal
218
+ });
219
+
220
+ return this;
221
+ }
222
+
223
+ /**
224
+ * @param {Omit<import('./types').HealthCheckInstruction, 'type'>} param0
225
+ */
226
+ healthCheck({
227
+ command,
228
+ interval,
229
+ timeout,
230
+ startPeriod,
231
+ retries
232
+ }) {
233
+ this.instructions.push({
234
+ type: 'HEALTHCHECK',
235
+ command,
236
+ interval,
237
+ retries,
238
+ startPeriod,
239
+ timeout
240
+ });
241
+
242
+ return this;
243
+ }
244
+
245
+ /**
246
+ * @param {import('./types').ShellInstruction['exec']} exec
247
+ */
248
+ shell(exec) {
249
+ this.instructions.push({
250
+ type: 'SHELL',
251
+ exec
252
+ });
253
+
254
+ return this;
255
+ }
256
+
257
+ /**
258
+ * @param {import('./types').CommentInstruction['comment']} comment
259
+ */
260
+ comment(comment) {
261
+ this.instructions.push({
262
+ type: 'COMMENT',
263
+ comment
264
+ });
265
+
266
+ return this;
267
+ }
268
+
269
+ build() {
270
+ return buildInstructions(this.instructions);
271
+ }
272
+ }
273
+
274
+ module.exports = {
275
+ DockerFileBuilder
276
+ };
@@ -0,0 +1,123 @@
1
+ export interface FromInstruction {
2
+ type: 'FROM'
3
+ image: string
4
+ tag?: string
5
+ platform?: string
6
+ name?: string
7
+ }
8
+
9
+ export interface RunInstruction {
10
+ type: 'RUN'
11
+ command: string | string[]
12
+ }
13
+
14
+ export interface CmdInstruction {
15
+ type: 'CMD'
16
+ command: string | string[]
17
+ }
18
+
19
+ export interface LabelInstruction {
20
+ type: 'LABEL'
21
+ labels: Record<string, string>
22
+ }
23
+
24
+ export interface ExposeInstruction {
25
+ type: 'EXPOSE'
26
+ port: number
27
+ protocol?: 'udp' | 'tcp'
28
+ }
29
+
30
+ export interface EnvInstruction {
31
+ type: 'ENV'
32
+ name: string
33
+ value: string
34
+ }
35
+
36
+ export interface AddInstruction {
37
+ type: 'ADD'
38
+ src: string[]
39
+ dest: string
40
+ chown?: string
41
+ }
42
+
43
+ export interface CopyInstruction {
44
+ type: 'COPY'
45
+ src: string[]
46
+ dest: string
47
+ chown?: string
48
+ from?: string
49
+ }
50
+
51
+ export interface EntrypointInstruction {
52
+ type: 'ENTRYPOINT'
53
+ command: string | string[]
54
+ }
55
+
56
+ export interface VolumeInstruction {
57
+ type: 'VOLUME'
58
+ volume: string | string[]
59
+ }
60
+
61
+ export interface UserInstruction {
62
+ type: 'USER'
63
+ user: string
64
+ }
65
+
66
+ export interface WorkDirInstruction {
67
+ type: 'WORKDIR'
68
+ workdir: string
69
+ }
70
+
71
+ export interface ArgInstruction {
72
+ type: 'ARG'
73
+ name: string
74
+ defaultValue?: string
75
+ }
76
+
77
+ export interface OnBuildInstruction {
78
+ type: 'ONBUILD'
79
+ instruction: string
80
+ }
81
+
82
+ export interface StopSignalInstruction {
83
+ type: 'STOPSIGNAL'
84
+ signal: string
85
+ }
86
+
87
+ export interface HealthCheckInstruction {
88
+ type: 'HEALTHCHECK'
89
+ command: string
90
+ interval?: string
91
+ timeout?: string
92
+ startPeriod?: string
93
+ retries?: number
94
+ }
95
+
96
+ export interface ShellInstruction {
97
+ type: 'SHELL'
98
+ exec: string[]
99
+ }
100
+
101
+ export interface CommentInstruction {
102
+ type: 'COMMENT'
103
+ comment: string
104
+ }
105
+
106
+ export type DockerfileInstruction = FromInstruction
107
+ | RunInstruction
108
+ | CmdInstruction
109
+ | LabelInstruction
110
+ | ExposeInstruction
111
+ | EnvInstruction
112
+ | AddInstruction
113
+ | CopyInstruction
114
+ | EntrypointInstruction
115
+ | VolumeInstruction
116
+ | UserInstruction
117
+ | WorkDirInstruction
118
+ | ArgInstruction
119
+ | OnBuildInstruction
120
+ | StopSignalInstruction
121
+ | HealthCheckInstruction
122
+ | ShellInstruction
123
+ | CommentInstruction
@@ -1,15 +1,19 @@
1
1
  const path = require('path');
2
2
  const UnknownError = require('../errors/unknown-error');
3
+ const { runPHPContainerCommand } = require('../tasks/php/php-container');
3
4
  const pathExists = require('./path-exists');
4
- const runPhpCode = require('./run-php');
5
5
 
6
- const envPhpToJson = async (projectPath = process.cwd(), { magentoVersion }) => {
7
- const envPhpPath = path.join(projectPath, 'app', 'etc', 'env.php');
8
- if (!await pathExists(envPhpPath)) {
6
+ /**
7
+ * @param {import('../../typings/context').ListrContext} ctx
8
+ */
9
+ const envPhpToJson = async (ctx) => {
10
+ const envPhpOnSystemPath = path.join(ctx.config.baseConfig.magentoDir, 'app', 'etc', 'env.php');
11
+ const envPhpInContainerPath = path.join(ctx.config.baseConfig.containerMagentoDir, 'app', 'etc', 'env.php');
12
+ if (!await pathExists(envPhpOnSystemPath)) {
9
13
  return null;
10
14
  }
11
- const { code, result } = await runPhpCode(`-r "echo json_encode(require '${envPhpPath}');"`, {
12
- magentoVersion
15
+ const { code, result } = await runPHPContainerCommand(ctx, `php -r "echo json_encode(require '${envPhpInContainerPath}');"`, {
16
+ withCode: true
13
17
  });
14
18
 
15
19
  if (code !== 0) {
@@ -2,7 +2,7 @@ const os = require('os');
2
2
  const logger = require('@scandipwa/scandipwa-dev-utils/logger');
3
3
  const { spawn } = require('child_process');
4
4
  const { getArchSync } = require('./arch');
5
- const compileOptions = require('../tasks/php/compile-options');
5
+ const UnknownError = require('../errors/unknown-error');
6
6
 
7
7
  const execAsyncSpawn = (command, {
8
8
  callback = () => {},
@@ -31,13 +31,7 @@ const execAsyncSpawn = (command, {
31
31
  'arch',
32
32
  // eslint-disable-next-line max-len
33
33
  ['-x86_64', 'bash', '-c', command],
34
- {
35
- ...spawnOptions,
36
- env: {
37
- ...process.env,
38
- PATH: compileOptions.darwin.env.PATH
39
- }
40
- }
34
+ spawnOptions
41
35
  );
42
36
  } else {
43
37
  childProcess = spawn(
@@ -79,7 +73,7 @@ const execAsyncSpawn = (command, {
79
73
  return;
80
74
  }
81
75
  if (code > 0) {
82
- reject(result);
76
+ reject(new UnknownError(result));
83
77
  } else {
84
78
  resolve(result);
85
79
  }
@@ -0,0 +1,20 @@
1
+ const semver = require('semver');
2
+ const macosVersion = require('macos-version');
3
+ const { execAsyncSpawn } = require('./exec-async-command');
4
+
5
+ const getMacOSVersion = async () => {
6
+ const { code, result } = await execAsyncSpawn('sw_vers -productVersion',
7
+ {
8
+ withCode: true
9
+ });
10
+
11
+ if (code !== 0) {
12
+ return macosVersion();
13
+ }
14
+
15
+ return semver.coerce(result).version;
16
+ };
17
+
18
+ module.exports = {
19
+ getMacOSVersion
20
+ };
@@ -8,13 +8,12 @@ const runMagentoCommand = require('./run-magento');
8
8
  */
9
9
  const magentoTask = (command, options = {}) => ({
10
10
  title: `Running command 'magento ${command}'`,
11
- task: async ({ magentoVersion, verbose }, task) => {
11
+ task: async (ctx, task) => {
12
12
  try {
13
- await runMagentoCommand(command, {
14
- callback: !verbose ? undefined : (t) => {
13
+ await runMagentoCommand(ctx, command, {
14
+ callback: !ctx.verbose ? undefined : (t) => {
15
15
  task.output = t;
16
16
  },
17
- magentoVersion,
18
17
  throwNonZeroCode: true
19
18
  });
20
19
  } catch (e) {
@@ -0,0 +1,122 @@
1
+ /* eslint-disable no-bitwise */
2
+ /* eslint-disable max-len */
3
+ class NginxParser {
4
+ constructor(format) {
5
+ this.directives = {};
6
+
7
+ const prefix = format.match(/^[^$]*/);
8
+ if (prefix) {
9
+ format = this.escape(prefix[0]) + format.slice(prefix[0].length);
10
+ }
11
+
12
+ this.parser = format;
13
+
14
+ const directive = /\$([a-z_]+)(.)?([^$]+)?/g;
15
+ let match;
16
+ let regex;
17
+ let boundary;
18
+ let i = 1;
19
+
20
+ // eslint-disable-next-line no-cond-assign
21
+ while ((match = directive.exec(format))) {
22
+ this.directives[match[1]] = i++;
23
+ if (match[2]) {
24
+ boundary = this.escape(match[2]);
25
+ regex = `([^${ boundary }]*?)${ boundary}`;
26
+ if (match[3]) {
27
+ regex += this.escape(match[3]);
28
+ }
29
+ } else {
30
+ regex = '(.+)$';
31
+ }
32
+ this.parser = this.parser.replace(match[0], regex);
33
+ }
34
+
35
+ this.parser = new RegExp(this.parser);
36
+ }
37
+
38
+ /**
39
+ * Parse a log line.
40
+ *
41
+ * @param {String} line
42
+ * @returns {Record<'msec' | 'time_iso8601' | 'remote_addr' | 'query_string' | 'http_x_forwarded_for' | 'http_user_agent' | 'http_referer' | 'time_local' | 'request' | 'status' | 'request_time' | 'request_length' | 'pipe' | 'connection' | 'bytes_sent' | 'body_bytes_sent' | 'date' | 'timestamp' | 'ip' | 'ip_str', string>}
43
+ */
44
+ parseLine(line) {
45
+ const match = line.match(this.parser);
46
+ if (!match) {
47
+ return;
48
+ }
49
+
50
+ const row = {
51
+ msec: null,
52
+ time_iso8601: null,
53
+ remote_addr: null,
54
+ query_string: null,
55
+ http_x_forwarded_for: null,
56
+ http_user_agent: null,
57
+ http_referer: null,
58
+ time_local: null,
59
+ request: null,
60
+ status: null,
61
+ request_time: null,
62
+ request_length: null,
63
+ pipe: null,
64
+ connection: null,
65
+ bytes_sent: null,
66
+ body_bytes_sent: null,
67
+
68
+ date: null,
69
+ timestamp: null,
70
+ ip: null,
71
+ ip_str: null
72
+ };
73
+
74
+ // eslint-disable-next-line guard-for-in
75
+ for (const key in this.directives) {
76
+ row[key] = match[this.directives[key]];
77
+ if (row[key] === '-') {
78
+ row[key] = null;
79
+ }
80
+ }
81
+
82
+ // Parse the timestamp
83
+ if (row.time_iso8601) {
84
+ row.date = new Date(row.time_iso8601);
85
+ } else if (row.msec) {
86
+ row.date = new Date(Number(row.msec.replace('.', '')));
87
+ }
88
+ if (row.date) {
89
+ row.timestamp = row.date.getTime();
90
+ }
91
+
92
+ // Parse the user's IP
93
+ if (row.http_x_forwarded_for) {
94
+ row.ip_str = row.http_x_forwarded_for;
95
+ } else if (row.remote_addr) {
96
+ row.ip_str = row.remote_addr;
97
+ }
98
+ if (row.ip_str) {
99
+ const ip = row.ip_str.split('.', 4);
100
+ row.ip = Number(ip[0]) * (2 << 23)
101
+ + Number(ip[1]) * (2 << 15)
102
+ + Number(ip[2]) * (2 << 7)
103
+ + Number(ip[3]);
104
+ }
105
+
106
+ return row;
107
+ }
108
+
109
+ /**
110
+ * Escape regular expression tokens.
111
+ *
112
+ * @param {String} str
113
+ * @return {String}
114
+ */
115
+ escape(str) {
116
+ return str.replace(new RegExp('[.*+?|()\\[\\]{}]', 'g'), '\\$&');
117
+ }
118
+ }
119
+
120
+ module.exports = {
121
+ NginxParser
122
+ };
@@ -1,4 +1,4 @@
1
- const runPhpCode = require('./run-php');
1
+ const { runPHPContainerCommand } = require('../tasks/php/php-container');
2
2
 
3
3
  /**
4
4
  * @param {String} command
@@ -7,14 +7,11 @@ const runPhpCode = require('./run-php');
7
7
  */
8
8
  const phpTask = (command, options = {}) => ({
9
9
  title: !options.noTitle ? `Running command 'php ${command}` : undefined,
10
- task: (ctx, task) => runPhpCode(command, {
10
+ task: (ctx, task) => runPHPContainerCommand(ctx, command, {
11
11
  callback: (t) => {
12
12
  task.output = t;
13
13
  },
14
- throwNonZeroCode: true,
15
- magentoVersion: ctx.magentoVersion,
16
- env: options.env,
17
- useRosettaOnMac: ctx.arch === 'arm64' && ctx.platform === 'darwin'
14
+ throwNonZeroCode: true
18
15
  })
19
16
  });
20
17
 
@@ -1,28 +1,20 @@
1
- const { execAsyncSpawn } = require('./exec-async-command');
2
- const { getConfigFromMagentoVersion, defaultConfiguration } = require('../config');
3
1
  const UnknownError = require('../errors/unknown-error');
2
+ const { runPHPContainerCommand } = require('../tasks/php/php-container');
4
3
  /**
5
4
  * Execute composer command
5
+ * @param {import('../../typings/context').ListrContext} ctx
6
6
  * @param {String} command composer command
7
7
  * @param {Object} options
8
8
  * @param {Boolean} options.throwNonZeroCode Throw if command return non 0 code.
9
9
  * @param {String} options.magentoVersion Magento version for config
10
10
  */
11
- const runComposerCommand = async (command, options = {}) => {
11
+ const runComposerCommand = async (ctx, command, options = {}) => {
12
12
  const {
13
- throwNonZeroCode = true,
14
- magentoVersion = defaultConfiguration.name
13
+ throwNonZeroCode = true
15
14
  } = options;
16
- const {
17
- php,
18
- composer,
19
- baseConfig: { magentoDir }
20
- } = await getConfigFromMagentoVersion(magentoVersion);
21
- const { code, result } = await execAsyncSpawn(`${php.binPath} -c ${php.iniPath} ${composer.binPath} ${command}`, {
15
+ const { code, result } = await runPHPContainerCommand(ctx, `composer ${command}`, {
22
16
  ...options,
23
- cwd: magentoDir,
24
- withCode: true,
25
- useRosetta2: true
17
+ withCode: true
26
18
  });
27
19
 
28
20
  if (throwNonZeroCode && code !== 0) {
@@ -0,0 +1,17 @@
1
+ const { execAsyncSpawn } = require('./exec-async-command');
2
+
3
+ const runContainerImage = async (imageWithTag, command) => execAsyncSpawn(`docker run --rm ${imageWithTag} ${command}`);
4
+
5
+ /**
6
+ * @param {string} imageWithTag
7
+ * @param {string} command
8
+ * @returns {import('listr2').ListrTask<import('../../typings/context').ListrContext>}
9
+ */
10
+ const runContainerImageTask = (imageWithTag, command) => ({
11
+ task: () => runContainerImage(imageWithTag, command)
12
+ });
13
+
14
+ module.exports = {
15
+ runContainerImage,
16
+ runContainerImageTask
17
+ };