@scandipwa/magento-scripts 1.16.0 → 2.0.0-alpha.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.
- package/lib/commands/cli.js +4 -6
- package/lib/commands/execute.js +29 -4
- package/lib/commands/import-db.js +1 -1
- package/lib/commands/logs.js +1 -1
- package/lib/commands/start.js +38 -20
- package/lib/commands/status.js +2 -0
- package/lib/config/docker.js +98 -83
- package/lib/config/get-project-configuration.js +3 -1
- package/lib/config/index.js +10 -7
- package/lib/config/magento/required-php-extensions/index.js +29 -0
- package/lib/config/magento/required-php-extensions/magento-2.3.js +19 -0
- package/lib/config/magento/required-php-extensions/magento-2.4.js +29 -0
- package/lib/config/php/base-repo.js +3 -0
- package/lib/config/php/extensions/apcu.js +12 -0
- package/lib/config/php/extensions/bcmath.js +7 -0
- package/lib/config/php/extensions/curl.js +11 -0
- package/lib/config/php/extensions/gd.js +14 -0
- package/lib/config/php/extensions/index.js +18 -2
- package/lib/config/php/extensions/intl.js +10 -0
- package/lib/config/php/extensions/opcache.js +10 -0
- package/lib/config/php/extensions/pdo_mysql.js +7 -0
- package/lib/config/php/extensions/soap.js +10 -0
- package/lib/config/php/extensions/sodium.js +10 -0
- package/lib/config/php/extensions/xdebug.js +8 -5
- package/lib/config/php/extensions/xsl.js +10 -0
- package/lib/config/php/extensions/zip.js +10 -0
- package/lib/config/php/{releases → versions}/index.js +0 -0
- package/lib/config/php/versions/php-7.2.js +23 -0
- package/lib/config/php/versions/php-7.3.js +23 -0
- package/lib/config/php/versions/php-7.4.js +23 -0
- package/lib/config/php/versions/php-8.1.js +23 -0
- package/lib/config/php-config.js +8 -12
- package/lib/config/port-config.js +2 -6
- package/lib/config/services/elasticsearch/base-repo.js +3 -0
- package/lib/config/services/elasticsearch/versions/elasticsearch-6.8.js +23 -0
- package/lib/config/services/elasticsearch/versions/index.js +5 -0
- package/lib/config/templates/magentorc.template +5 -5
- package/lib/config/templates/mariadb.template.cnf +191 -0
- package/lib/config/templates/php-fpm.template.conf +3 -3
- package/lib/config/templates/php.template.ini +12 -6
- package/lib/config/templates/ssl-terminator.template.conf +1 -1
- package/lib/config/templates/vscode-launch.template.json +3 -1
- package/lib/config/versions/magento-2.3.0.js +10 -5
- package/lib/config/versions/magento-2.3.1.js +10 -5
- package/lib/config/versions/magento-2.3.2-p1.js +43 -0
- package/lib/config/versions/magento-2.3.2-p2.js +10 -5
- package/lib/config/versions/magento-2.3.2.js +10 -5
- package/lib/config/versions/magento-2.3.3-p1.js +10 -5
- package/lib/config/versions/magento-2.3.3.js +10 -5
- package/lib/config/versions/magento-2.3.4-p1.js +43 -0
- package/lib/config/versions/magento-2.3.4-p2.js +10 -5
- package/lib/config/versions/magento-2.3.4.js +10 -5
- package/lib/config/versions/magento-2.3.5-p1.js +8 -2
- package/lib/config/versions/magento-2.3.5-p2.js +8 -2
- package/lib/config/versions/magento-2.3.5.js +8 -2
- package/lib/config/versions/magento-2.3.6-p1.js +8 -2
- package/lib/config/versions/magento-2.3.6.js +8 -2
- package/lib/config/versions/magento-2.3.7-p1.js +8 -2
- package/lib/config/versions/magento-2.3.7-p2.js +8 -2
- package/lib/config/versions/magento-2.3.7-p3.js +8 -2
- package/lib/config/versions/magento-2.3.7.js +8 -2
- package/lib/config/versions/magento-2.4.0-p1.js +9 -3
- package/lib/config/versions/magento-2.4.0.js +9 -3
- package/lib/config/versions/magento-2.4.1-p1.js +6 -5
- package/lib/config/versions/magento-2.4.1.js +9 -2
- package/lib/config/versions/magento-2.4.2-p1.js +6 -5
- package/lib/config/versions/magento-2.4.2-p2.js +6 -6
- package/lib/config/versions/magento-2.4.2.js +6 -6
- package/lib/config/versions/magento-2.4.3-p1.js +7 -7
- package/lib/config/versions/magento-2.4.3-p2.js +7 -7
- package/lib/config/versions/magento-2.4.3.js +7 -7
- package/lib/config/versions/magento-2.4.4.js +9 -2
- package/lib/tasks/cleanup.js +3 -3
- package/lib/tasks/composer/index.js +14 -104
- package/lib/tasks/database/connect-to-database.js +117 -0
- package/lib/tasks/database/create-magento-database.js +18 -0
- package/lib/tasks/{mysql → database}/dump-theme-config.js +3 -3
- package/lib/tasks/{mysql → database}/fix-db.js +2 -2
- package/lib/tasks/{mysql/import-dump-to-mysql.js → database/import-dump-to-database.js} +65 -22
- package/lib/tasks/{mysql → database}/import-remote-db/index.js +0 -0
- package/lib/tasks/{mysql/import-remote-db/ssh/mysqldump-command.js → database/import-remote-db/ssh/database-dump-command.js} +2 -2
- package/lib/tasks/{mysql → database}/import-remote-db/ssh/index.js +0 -0
- package/lib/tasks/{mysql → database}/import-remote-db/ssh/readymage.js +4 -4
- package/lib/tasks/{mysql → database}/import-remote-db/ssh/regular-server.js +2 -2
- package/lib/tasks/{mysql → database}/index.js +2 -2
- package/lib/tasks/{mysql → database}/magento-tables.js +0 -0
- package/lib/tasks/{mysql → database}/restore-theme-config.js +4 -4
- package/lib/tasks/docker/api.d.ts +71 -0
- package/lib/tasks/docker/api.js +30 -0
- package/lib/tasks/docker/containers/container-api.d.ts +128 -0
- package/lib/tasks/docker/containers/container-api.js +153 -0
- package/lib/tasks/docker/containers/index.js +19 -0
- package/lib/tasks/docker/containers/tasks.js +215 -0
- package/lib/tasks/docker/convert-legacy-volumes.js +15 -10
- package/lib/tasks/docker/convert-mysql-to-mariadb.js +284 -0
- package/lib/tasks/docker/image/image-api.d.ts +34 -0
- package/lib/tasks/docker/image/image-api.js +49 -0
- package/lib/tasks/docker/image/index.js +5 -0
- package/lib/tasks/docker/index.js +1 -13
- package/lib/tasks/docker/network/index.js +7 -0
- package/lib/tasks/docker/network/network-api.d.ts +103 -0
- package/lib/tasks/docker/network/network-api.js +99 -0
- package/lib/tasks/docker/{network.js → network/tasks.js} +17 -10
- package/lib/tasks/docker/project-image-builder.js +167 -0
- package/lib/tasks/docker/volume/index.js +8 -0
- package/lib/tasks/docker/{volumes.js → volume/tasks.js} +5 -19
- package/lib/tasks/docker/volume/volume-api.d.ts +39 -0
- package/lib/tasks/docker/volume/volume-api.js +66 -0
- package/lib/tasks/execute/index.js +5 -2
- package/lib/tasks/file-system/create-mariadb-config.js +23 -0
- package/lib/tasks/file-system/create-nginx-config.js +2 -3
- package/lib/tasks/file-system/create-php-config.js +20 -5
- package/lib/tasks/file-system/create-php-fpm-config.js +8 -4
- package/lib/tasks/file-system/create-phpstorm-config/exclude-folder-config.js +41 -29
- package/lib/tasks/file-system/create-phpstorm-config/index.js +2 -0
- package/lib/tasks/file-system/create-phpstorm-config/keys.js +15 -1
- package/lib/tasks/file-system/create-phpstorm-config/php-config/index.js +4 -1
- package/lib/tasks/file-system/create-phpstorm-config/php-config/php-config.js +3 -3
- package/lib/tasks/file-system/create-phpstorm-config/php-config/php-interpreters-config.js +81 -0
- package/lib/tasks/file-system/create-phpstorm-config/php-docker-settings-config/index.js +42 -0
- package/lib/tasks/file-system/create-phpstorm-config/php-docker-settings-config/php-docker-settings-config.js +9 -0
- package/lib/tasks/file-system/create-phpstorm-config/php-docker-settings-config/setup-php-docker-container-settings-config.js +66 -0
- package/lib/tasks/file-system/create-phpstorm-config/setup-xml-structure.js +11 -9
- package/lib/tasks/file-system/create-phpstorm-config/stylelint-config.js +2 -1
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/composer-settings-config.js +15 -30
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/index.js +24 -5
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/mess-detector-project-configuration-config.js +50 -0
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/php-code-sniffer-project-configuration-config.js +50 -0
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/php-cs-fixer-project-configuration-config.js +50 -0
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/php-debug-general-config.js +15 -15
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/php-server-config.js +29 -3
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/php-stan-project-configuration-config.js.js +50 -0
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/php-workspace-project-configuration-config.js +42 -0
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/psalm-project-configuration-config.js.js +50 -0
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/workspace-config.js +0 -2
- package/lib/tasks/file-system/create-ssl-terminator-config.js +4 -2
- package/lib/tasks/file-system/create-vscode-config.js +57 -42
- package/lib/tasks/file-system/index.js +5 -2
- package/lib/tasks/import-dump.js +6 -6
- package/lib/tasks/link.js +5 -4
- package/lib/tasks/magento/install-magento-project.js +31 -63
- package/lib/tasks/magento/setup-magento/adjust-full-page-cache.js +4 -4
- package/lib/tasks/magento/setup-magento/configure-elasticsearch.js +7 -3
- package/lib/tasks/magento/setup-magento/create-admin.js +5 -6
- package/lib/tasks/magento/setup-magento/delete-admin-users.js +2 -2
- package/lib/tasks/magento/setup-magento/delete-customers.js +4 -4
- package/lib/tasks/magento/setup-magento/delete-orders.js +4 -4
- package/lib/tasks/magento/setup-magento/disable-2fa.js +3 -5
- package/lib/tasks/magento/setup-magento/disable-maintenance-mode.js +3 -4
- package/lib/tasks/magento/setup-magento/increase-admin-session-lifetime.js +2 -2
- package/lib/tasks/magento/setup-magento/index.js +3 -3
- package/lib/tasks/magento/setup-magento/install-magento.js +47 -40
- package/lib/tasks/magento/setup-magento/migrate-database.js +7 -14
- package/lib/tasks/magento/setup-magento/set-base-url.js +2 -2
- package/lib/tasks/magento/setup-magento/set-deployment-mode.js +4 -4
- package/lib/tasks/magento/setup-magento/set-url-rewrite.js +2 -2
- package/lib/tasks/magento/setup-magento/varnish-config.js +11 -9
- package/lib/tasks/magento/setup-magento/waiting-for-varnish.js +128 -3
- package/lib/tasks/php/php-container.js +108 -0
- package/lib/tasks/php/update-env-php.js +39 -21
- package/lib/tasks/php/update-env.php +66 -61
- package/lib/tasks/php/working_health_check.php +85 -0
- package/lib/tasks/requirements/{composer.js → composer-credentials.js} +3 -1
- package/lib/tasks/requirements/docker/index.js +15 -12
- package/lib/tasks/requirements/docker/performance.js +54 -0
- package/lib/tasks/requirements/docker/version.js +8 -8
- package/lib/tasks/requirements/index.js +5 -8
- package/lib/tasks/requirements/php-version.js +8 -116
- package/lib/tasks/requirements/platform.js +12 -25
- package/lib/tasks/start.js +24 -51
- package/lib/tasks/status/index.js +8 -12
- package/lib/tasks/stop.js +0 -2
- package/lib/tasks/theme/install-theme.js +1 -1
- package/lib/tasks/theme/link-theme.js +2 -2
- package/lib/tasks/theme/symlink-theme.js +2 -3
- package/lib/util/config-file-validator.js +27 -13
- package/lib/util/config-php-json.js +13 -4
- package/lib/util/database.js +7 -7
- package/lib/util/dockerfile-builder/build-instructions.js +197 -0
- package/lib/util/dockerfile-builder/index.js +276 -0
- package/lib/util/dockerfile-builder/types.d.ts +123 -0
- package/lib/util/env-php-json.js +10 -6
- package/lib/util/exec-async-command.js +3 -9
- package/lib/util/macos-version.js +20 -0
- package/lib/util/magento-task.js +3 -4
- package/lib/util/nginx-logs-parser.js +122 -0
- package/lib/util/php-task.js +3 -6
- package/lib/util/run-composer.js +6 -14
- package/lib/util/run-container-image.js +17 -0
- package/lib/util/run-magento.js +6 -14
- package/lib/util/run-php.js +6 -17
- package/package.json +9 -9
- package/typings/context.d.ts +7 -13
- package/typings/index.d.ts +67 -85
- package/yarn-error.log +9660 -0
- package/lib/config/composer.js +0 -11
- package/lib/config/php/extensions/libsodium.js +0 -36
- package/lib/config/php/releases/php-7.2.js +0 -25
- package/lib/config/php/releases/php-7.3.js +0 -25
- package/lib/config/php/releases/php-7.4.js +0 -23
- package/lib/config/php/releases/php-8.1.js +0 -25
- package/lib/config/phpbrew.js +0 -12
- package/lib/tasks/composer/install-prestissimo.js +0 -103
- package/lib/tasks/docker/containers.js +0 -231
- package/lib/tasks/mysql/connect-to-mysql.js +0 -114
- package/lib/tasks/mysql/create-magento-database.js +0 -18
- package/lib/tasks/php/bundled-extensions.js +0 -27
- package/lib/tasks/php/compile-options.js +0 -56
- package/lib/tasks/php/compile.js +0 -55
- package/lib/tasks/php/configure.js +0 -89
- package/lib/tasks/php/extensions/disable.js +0 -49
- package/lib/tasks/php/extensions/enable.js +0 -52
- package/lib/tasks/php/extensions/index.js +0 -80
- package/lib/tasks/php/extensions/install.js +0 -54
- package/lib/tasks/php/index.js +0 -79
- package/lib/tasks/php/install-sodium.js +0 -93
- package/lib/tasks/php/update-phpbrew.js +0 -45
- package/lib/tasks/php/validate-php.js +0 -67
- package/lib/tasks/php-fpm/get-process-id.js +0 -14
- package/lib/tasks/php-fpm/index.js +0 -4
- package/lib/tasks/php-fpm/start-php-fpm.js +0 -49
- package/lib/tasks/php-fpm/stop-php-fpm.js +0 -48
- package/lib/tasks/requirements/phpbrew/index.js +0 -61
- package/lib/tasks/requirements/phpbrew/install.js +0 -159
- package/lib/tasks/requirements/phpbrew/version.js +0 -28
|
@@ -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
|
+
};
|
package/lib/util/php-task.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
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) =>
|
|
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
|
|
package/lib/util/run-composer.js
CHANGED
|
@@ -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
|
-
|
|
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
|
+
};
|
package/lib/util/run-magento.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
const { execAsyncSpawn } = require('./exec-async-command');
|
|
2
|
-
const { getConfigFromMagentoVersion, defaultConfiguration, magento } = require('../config');
|
|
3
1
|
const UnknownError = require('../errors/unknown-error');
|
|
2
|
+
const { runPHPContainerCommand } = require('../tasks/php/php-container');
|
|
4
3
|
/**
|
|
5
4
|
* Execute magento command
|
|
5
|
+
*
|
|
6
|
+
* @param {import('../../typings/context').ListrContext} ctx
|
|
6
7
|
* @param {String} command magento command
|
|
7
8
|
* @param {Object} options
|
|
8
9
|
* @param {Boolean} options.logOutput Log output to console using logger
|
|
@@ -10,20 +11,11 @@ const UnknownError = require('../errors/unknown-error');
|
|
|
10
11
|
* @param {String} options.cwd
|
|
11
12
|
* @param {() => {}} options.callback
|
|
12
13
|
* @param {Boolean} options.throwNonZeroCode Throw if command return non 0 code.
|
|
13
|
-
* @param {String} options.magentoVersion Magento version for config
|
|
14
14
|
*/
|
|
15
|
-
const runMagentoCommand = async (command, options = {}) => {
|
|
16
|
-
const {
|
|
17
|
-
|
|
18
|
-
magentoVersion = defaultConfiguration.name
|
|
19
|
-
} = options;
|
|
20
|
-
const {
|
|
21
|
-
php,
|
|
22
|
-
baseConfig: { magentoDir }
|
|
23
|
-
} = await getConfigFromMagentoVersion(magentoVersion);
|
|
24
|
-
const { code, result } = await execAsyncSpawn(`${php.binPath} -c ${php.iniPath} ${magento.binPath} ${command}`, {
|
|
15
|
+
const runMagentoCommand = async (ctx, command, options = {}) => {
|
|
16
|
+
const { throwNonZeroCode = true } = options;
|
|
17
|
+
const { code, result } = await runPHPContainerCommand(ctx, `bin/magento ${command}`, {
|
|
25
18
|
...options,
|
|
26
|
-
cwd: magentoDir,
|
|
27
19
|
withCode: true
|
|
28
20
|
});
|
|
29
21
|
|
package/lib/util/run-php.js
CHANGED
|
@@ -1,34 +1,23 @@
|
|
|
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 PHP code
|
|
6
|
-
* @param {
|
|
5
|
+
* @param {import('../../typings/context').ListrContext} ctx
|
|
6
|
+
* @param {String} command php command
|
|
7
7
|
* @param {Object} options
|
|
8
8
|
* @param {Boolean} options.logOutput Log output to console using logger
|
|
9
9
|
* @param {Boolean} options.withCode
|
|
10
10
|
* @param {String} options.cwd
|
|
11
11
|
* @param {() => {}} options.callback
|
|
12
12
|
* @param {Boolean} options.throwNonZeroCode Throw if command return non 0 code.
|
|
13
|
-
* @param {String} options.magentoVersion Magento version for config
|
|
14
13
|
* @param {Record<string, string>} options.env Environment variables
|
|
15
14
|
* @param {Boolean} options.useRosettaOnMac Use Rosetta 2 on MacOS
|
|
16
15
|
*/
|
|
17
|
-
const runPhpCode = async (command, options = {}) => {
|
|
16
|
+
const runPhpCode = async (ctx, command, options = {}) => {
|
|
18
17
|
const {
|
|
19
|
-
throwNonZeroCode = true
|
|
20
|
-
magentoVersion = defaultConfiguration.magentoVersion
|
|
18
|
+
throwNonZeroCode = true
|
|
21
19
|
} = options;
|
|
22
|
-
const {
|
|
23
|
-
let spawnCommand = `${php.binPath} -c ${php.iniPath} ${command}`;
|
|
24
|
-
if (options.env && Object.keys(options.env).length > 0) {
|
|
25
|
-
const env = Object.entries(options.env).map(([key, value]) => `${key}=${value}`).join(' ');
|
|
26
|
-
spawnCommand = `${env} ${spawnCommand}`;
|
|
27
|
-
}
|
|
28
|
-
if (options.useRosettaOnMac) {
|
|
29
|
-
spawnCommand = `arch -x86_64 bash -c '${spawnCommand}'`;
|
|
30
|
-
}
|
|
31
|
-
const { code, result } = await execAsyncSpawn(spawnCommand, {
|
|
20
|
+
const { code, result } = await runPHPContainerCommand(ctx, `php ${command}`, {
|
|
32
21
|
...options,
|
|
33
22
|
withCode: true
|
|
34
23
|
});
|
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": "
|
|
6
|
+
"version": "2.0.0-alpha.1",
|
|
7
7
|
"main": "./index.js",
|
|
8
8
|
"types": "./typings/index.d.ts",
|
|
9
9
|
"license": "OSL-3.0",
|
|
@@ -23,22 +23,22 @@
|
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@scandipwa/scandipwa-dev-utils": "0.1.13",
|
|
26
|
-
"conf": "10.1.
|
|
26
|
+
"conf": "10.1.2",
|
|
27
27
|
"enquirer": "2.3.6",
|
|
28
28
|
"eta": "1.12.3",
|
|
29
|
-
"fast-xml-parser": "^4.0.
|
|
29
|
+
"fast-xml-parser": "^4.0.9",
|
|
30
30
|
"hjson": "^3.2.2",
|
|
31
31
|
"is-installed-globally": "0.4.0",
|
|
32
32
|
"joi": "17.6.0",
|
|
33
33
|
"listr2": "4.0.5",
|
|
34
34
|
"macos-version": "5.2.1",
|
|
35
35
|
"merge-files": "0.1.2",
|
|
36
|
-
"mysql2": "2.3.
|
|
37
|
-
"node-ssh": "12.0.
|
|
38
|
-
"semver": "7.3.
|
|
36
|
+
"mysql2": "2.3.3",
|
|
37
|
+
"node-ssh": "12.0.5",
|
|
38
|
+
"semver": "7.3.7",
|
|
39
39
|
"smol-request": "^2.1.2",
|
|
40
|
-
"systeminformation": "5.
|
|
41
|
-
"yargs": "17.
|
|
40
|
+
"systeminformation": "5.12.1",
|
|
41
|
+
"yargs": "17.5.1"
|
|
42
42
|
},
|
|
43
43
|
"publishConfig": {
|
|
44
44
|
"access": "public"
|
|
@@ -53,5 +53,5 @@
|
|
|
53
53
|
"mysql",
|
|
54
54
|
"scandipwa"
|
|
55
55
|
],
|
|
56
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "0b205dcab6056cf07988525ce053c5299af840e9"
|
|
57
57
|
}
|
package/typings/context.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ export interface ListrContext {
|
|
|
11
11
|
app: number
|
|
12
12
|
fpm: number
|
|
13
13
|
xdebug: number
|
|
14
|
-
|
|
14
|
+
mariadb: number
|
|
15
15
|
redis: number
|
|
16
16
|
elasticsearch: number
|
|
17
17
|
varnish: number
|
|
@@ -31,12 +31,8 @@ export interface ListrContext {
|
|
|
31
31
|
edition?: 'community' | 'enterprise'
|
|
32
32
|
config: {
|
|
33
33
|
php: {
|
|
34
|
-
binPath: string
|
|
35
|
-
iniPath: string
|
|
36
34
|
iniTemplatePath: string
|
|
37
|
-
fpmBinPath: string
|
|
38
35
|
fpmConfPath: string
|
|
39
|
-
fpmPidFilePath: string
|
|
40
36
|
extensions: PHPExtensions
|
|
41
37
|
version: string
|
|
42
38
|
}
|
|
@@ -49,15 +45,15 @@ export interface ListrContext {
|
|
|
49
45
|
network: {
|
|
50
46
|
name: string
|
|
51
47
|
}
|
|
52
|
-
volumes: Record<'
|
|
48
|
+
volumes: Record<'mariadb' | 'redis' | 'elasticsearch' | 'nginx' | 'appPub' | 'appSetup', {
|
|
53
49
|
name: string
|
|
54
|
-
|
|
50
|
+
opt?: {
|
|
55
51
|
type: string
|
|
56
52
|
device: string
|
|
57
53
|
o: string
|
|
58
54
|
}
|
|
59
55
|
}>
|
|
60
|
-
getContainers(): Record<'nginx' | 'redis' | '
|
|
56
|
+
getContainers(): Record<'php' | 'sslTerminator' | 'nginx' | 'redis' | 'mariadb' | 'elasticsearch' | 'varnish', {
|
|
61
57
|
_: string
|
|
62
58
|
ports: string[]
|
|
63
59
|
healthCheck: {
|
|
@@ -70,10 +66,7 @@ export interface ListrContext {
|
|
|
70
66
|
securityOptions: string[]
|
|
71
67
|
network: string
|
|
72
68
|
image: string
|
|
73
|
-
|
|
74
|
-
name: string
|
|
75
|
-
tag: string
|
|
76
|
-
}
|
|
69
|
+
debugImage?: string
|
|
77
70
|
name: string
|
|
78
71
|
command: string
|
|
79
72
|
connectCommand: string[]
|
|
@@ -84,6 +77,7 @@ export interface ListrContext {
|
|
|
84
77
|
magentoDir: string
|
|
85
78
|
templateDir: string
|
|
86
79
|
cacheDir: string
|
|
80
|
+
containerMagentoDir: string
|
|
87
81
|
}
|
|
88
82
|
overridenConfiguration: Omit<CMAConfiguration, 'prefix' | 'useNonOverlappingPorts'>
|
|
89
83
|
userConfiguration: Omit<CMAConfiguration, 'prefix' | 'useNonOverlappingPorts'>
|
|
@@ -94,6 +88,6 @@ export interface ListrContext {
|
|
|
94
88
|
analytics: boolean
|
|
95
89
|
useNonOverlappingPorts: boolean
|
|
96
90
|
}
|
|
97
|
-
|
|
91
|
+
databaseConnection: mysql2.Connection
|
|
98
92
|
isSetupUpgradeNeeded?: boolean
|
|
99
93
|
}
|
package/typings/index.d.ts
CHANGED
|
@@ -1,16 +1,21 @@
|
|
|
1
|
-
import { ListrTaskWrapper } from 'listr2';
|
|
2
|
-
|
|
3
1
|
import { ListrContext } from './context';
|
|
4
2
|
|
|
5
3
|
/* eslint-disable no-use-before-define */
|
|
6
|
-
export interface
|
|
4
|
+
export interface ServiceWithImage {
|
|
7
5
|
/**
|
|
8
6
|
* Service version
|
|
7
|
+
*
|
|
8
|
+
* @deprecated
|
|
9
9
|
*/
|
|
10
10
|
version: string
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Service Docker image
|
|
14
|
+
*/
|
|
15
|
+
image: string
|
|
11
16
|
}
|
|
12
17
|
|
|
13
|
-
export interface SSLTerminatorConfiguration extends
|
|
18
|
+
export interface SSLTerminatorConfiguration extends ServiceWithImage {
|
|
14
19
|
/**
|
|
15
20
|
* Configuration file location
|
|
16
21
|
*
|
|
@@ -19,7 +24,7 @@ export interface SSLTerminatorConfiguration extends ServiceWithVersion {
|
|
|
19
24
|
configTemplate: string
|
|
20
25
|
}
|
|
21
26
|
|
|
22
|
-
export interface NginxConfiguration extends
|
|
27
|
+
export interface NginxConfiguration extends ServiceWithImage {
|
|
23
28
|
/**
|
|
24
29
|
* Configuration file location
|
|
25
30
|
*
|
|
@@ -28,7 +33,14 @@ export interface NginxConfiguration extends ServiceWithVersion {
|
|
|
28
33
|
configTemplate: string
|
|
29
34
|
}
|
|
30
35
|
|
|
31
|
-
export interface
|
|
36
|
+
export interface ElasticSearchConfiguration extends ServiceWithImage {
|
|
37
|
+
/**
|
|
38
|
+
* Environmental variables used for Elasticsearch container
|
|
39
|
+
*/
|
|
40
|
+
env: Record<string, unknown>
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export interface VarnishConfiguration extends ServiceWithImage {
|
|
32
44
|
/**
|
|
33
45
|
* Enable or disable Varnish in the project
|
|
34
46
|
*/
|
|
@@ -42,80 +54,63 @@ export interface VarnishConfiguration extends ServiceWithVersion {
|
|
|
42
54
|
configTemplate: string
|
|
43
55
|
}
|
|
44
56
|
|
|
45
|
-
export interface
|
|
46
|
-
version?: string
|
|
57
|
+
export interface ComposerConfiguration {
|
|
47
58
|
/**
|
|
48
|
-
*
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
59
|
+
* Composer version
|
|
60
|
+
*/
|
|
61
|
+
version: string
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export interface PHPExtensionInstallationInstruction {
|
|
65
|
+
/**
|
|
66
|
+
* Alternative name for extension
|
|
52
67
|
*
|
|
53
|
-
* ```
|
|
54
|
-
*
|
|
55
|
-
* php: {
|
|
56
|
-
* extensions: {
|
|
57
|
-
* libsodium: {
|
|
58
|
-
* extensionName: 'sodium'
|
|
59
|
-
* }
|
|
60
|
-
* }
|
|
61
|
-
* }
|
|
62
|
-
* }
|
|
68
|
+
* @example ```js
|
|
69
|
+
* alternativeName: ['Zend OPcache']
|
|
63
70
|
* ```
|
|
64
71
|
*/
|
|
65
|
-
|
|
66
|
-
macosOptions?: string
|
|
67
|
-
extensionName?: string
|
|
68
|
-
hooks?: {
|
|
69
|
-
preEnable?: (config: CMAConfiguration['configuration']) => Promise<void> | void
|
|
70
|
-
postEnable?: (config: CMAConfiguration['configuration']) => Promise<void> | void
|
|
71
|
-
preDisable?: (config: CMAConfiguration['configuration']) => Promise<void> | void
|
|
72
|
-
postDisable?: (config: CMAConfiguration['configuration']) => Promise<void> | void
|
|
73
|
-
preInstall?: (config: CMAConfiguration['configuration']) => Promise<void> | void
|
|
74
|
-
postInstall?: (config: CMAConfiguration['configuration']) => Promise<void> | void
|
|
75
|
-
}
|
|
72
|
+
alternativeName?: string[]
|
|
76
73
|
/**
|
|
77
|
-
*
|
|
74
|
+
* Command to install extension
|
|
75
|
+
*
|
|
76
|
+
* @example ```bash
|
|
77
|
+
* docker-php-ext-install bcmath
|
|
78
|
+
* ```
|
|
79
|
+
* @example ```bash
|
|
80
|
+
* pecl install xdebug && docker-php-ext-enable xdebug
|
|
81
|
+
* ```
|
|
78
82
|
*/
|
|
79
|
-
|
|
80
|
-
ctx: ListrContext,
|
|
81
|
-
task: ListrTaskWrapper<ListrContext, any>
|
|
82
|
-
) => Promise<void> | void
|
|
83
|
+
command: (arg0: (Omit<PHPExtensionInstallationInstruction, 'command'> & { ctx: ListrContext})) => string | string
|
|
83
84
|
|
|
84
85
|
/**
|
|
85
|
-
*
|
|
86
|
+
* System dependencies required by the extension
|
|
87
|
+
*
|
|
88
|
+
* @example ```js
|
|
89
|
+
* dependencies: ['icu-dev']
|
|
90
|
+
* ```
|
|
86
91
|
*/
|
|
87
|
-
|
|
88
|
-
ctx: ListrContext,
|
|
89
|
-
task: ListrTaskWrapper<ListrContext, any>
|
|
90
|
-
) => Promise<void> | void
|
|
92
|
+
dependencies?: string[]
|
|
91
93
|
|
|
92
94
|
/**
|
|
93
|
-
*
|
|
95
|
+
* Extension version (if supported)
|
|
94
96
|
*/
|
|
95
|
-
|
|
96
|
-
ctx: ListrContext,
|
|
97
|
-
task: ListrTaskWrapper<ListrContext, any>
|
|
98
|
-
) => Promise<void> | void
|
|
97
|
+
version?: string
|
|
99
98
|
}
|
|
100
99
|
|
|
101
100
|
export interface PHPExtensions {
|
|
102
|
-
|
|
103
|
-
intl: PHPExtension
|
|
104
|
-
zlib: PHPExtension
|
|
105
|
-
openssl: PHPExtension
|
|
106
|
-
sockets: PHPExtension
|
|
107
|
-
simpleXML: PHPExtension
|
|
108
|
-
xdebug: PHPExtension
|
|
109
|
-
fileinfo: PHPExtension
|
|
110
|
-
libsodium: PHPExtension
|
|
111
|
-
[key: string]: PHPExtension
|
|
101
|
+
[key: string]: PHPExtensionInstallationInstruction
|
|
112
102
|
}
|
|
113
103
|
|
|
114
104
|
export interface PHPConfiguration {
|
|
115
105
|
/**
|
|
116
|
-
*
|
|
106
|
+
* Base image with tag
|
|
117
107
|
*/
|
|
118
|
-
|
|
108
|
+
baseImage?: string
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Image with XDebug enabled
|
|
112
|
+
*/
|
|
113
|
+
debugImage?: string
|
|
119
114
|
|
|
120
115
|
/**
|
|
121
116
|
* Configuration file template location
|
|
@@ -125,14 +120,16 @@ export interface PHPConfiguration {
|
|
|
125
120
|
configTemplate: string
|
|
126
121
|
|
|
127
122
|
/**
|
|
128
|
-
*
|
|
123
|
+
* PHP-FPM configuration file template location
|
|
124
|
+
*
|
|
125
|
+
* @example ./my-php-fpm-template.conf
|
|
129
126
|
*/
|
|
130
|
-
|
|
127
|
+
fpmConfigTemplate: string
|
|
131
128
|
|
|
132
129
|
/**
|
|
133
|
-
*
|
|
130
|
+
* Extensions for PHP
|
|
134
131
|
*/
|
|
135
|
-
|
|
132
|
+
extensions: PHPExtensions
|
|
136
133
|
}
|
|
137
134
|
export interface SSLConfiguration {
|
|
138
135
|
/**
|
|
@@ -172,30 +169,25 @@ export interface CMAConfiguration {
|
|
|
172
169
|
*/
|
|
173
170
|
nginx: NginxConfiguration
|
|
174
171
|
|
|
175
|
-
/**
|
|
176
|
-
* MySQL configuration
|
|
177
|
-
*/
|
|
178
|
-
mysql: ServiceWithVersion
|
|
179
|
-
|
|
180
172
|
/**
|
|
181
173
|
* MariaDB configuration
|
|
182
174
|
*/
|
|
183
|
-
mariadb:
|
|
175
|
+
mariadb: ServiceWithImage
|
|
184
176
|
|
|
185
177
|
/**
|
|
186
178
|
* ElasticSearch configuration
|
|
187
179
|
*/
|
|
188
|
-
elasticsearch:
|
|
180
|
+
elasticsearch: ElasticSearchConfiguration
|
|
189
181
|
|
|
190
182
|
/**
|
|
191
183
|
* Redis configuration
|
|
192
184
|
*/
|
|
193
|
-
redis:
|
|
185
|
+
redis: ServiceWithImage
|
|
194
186
|
|
|
195
187
|
/**
|
|
196
188
|
* Composer configuration
|
|
197
189
|
*/
|
|
198
|
-
composer:
|
|
190
|
+
composer: ComposerConfiguration
|
|
199
191
|
|
|
200
192
|
/**
|
|
201
193
|
* Varnish configuration
|
|
@@ -241,8 +233,8 @@ export interface CMAConfiguration {
|
|
|
241
233
|
}
|
|
242
234
|
/**
|
|
243
235
|
* Custom host for website base url
|
|
244
|
-
*
|
|
245
|
-
|
|
236
|
+
* @default 'localhost'
|
|
237
|
+
*/
|
|
246
238
|
host: string
|
|
247
239
|
|
|
248
240
|
/**
|
|
@@ -261,14 +253,4 @@ export interface CMAConfiguration {
|
|
|
261
253
|
* If prefix is set to `false` docker container and volume names will only include folder name **which is not safe and not recommended**.
|
|
262
254
|
*/
|
|
263
255
|
prefix: boolean
|
|
264
|
-
|
|
265
|
-
/**
|
|
266
|
-
* Non-overlapping ports config
|
|
267
|
-
* @default false
|
|
268
|
-
*
|
|
269
|
-
* @deprecated Use global configuration file.
|
|
270
|
-
* @description If set to `true` CMA will try retrieving others CMA projects port configuration
|
|
271
|
-
* and will not use their ports for itself.
|
|
272
|
-
*/
|
|
273
|
-
useNonOverlappingPorts: boolean
|
|
274
256
|
}
|