@scandipwa/magento-scripts 1.16.1 → 2.0.0-alpha.0
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 +2 -4
- package/lib/commands/execute.js +28 -3
- package/lib/commands/start.js +37 -15
- package/lib/commands/status.js +2 -0
- package/lib/config/docker.js +65 -42
- 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 +1 -5
- package/lib/config/templates/magentorc.template +3 -3
- 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 +8 -2
- package/lib/config/versions/magento-2.3.1.js +8 -2
- package/lib/config/versions/magento-2.3.2-p1.js +44 -0
- package/lib/config/versions/magento-2.3.2-p2.js +8 -2
- package/lib/config/versions/magento-2.3.2.js +8 -2
- package/lib/config/versions/magento-2.3.3-p1.js +8 -2
- package/lib/config/versions/magento-2.3.3.js +8 -2
- package/lib/config/versions/magento-2.3.4-p1.js +44 -0
- package/lib/config/versions/magento-2.3.4-p2.js +8 -2
- package/lib/config/versions/magento-2.3.4.js +8 -2
- 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 +2 -2
- package/lib/tasks/composer/index.js +14 -104
- 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 +7 -3
- 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/volumes.js +1 -1
- 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 +2 -1
- package/lib/tasks/link.js +1 -2
- 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 +6 -2
- package/lib/tasks/magento/setup-magento/create-admin.js +5 -6
- 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/install-magento.js +10 -9
- package/lib/tasks/magento/setup-magento/migrate-database.js +7 -8
- package/lib/tasks/magento/setup-magento/set-deployment-mode.js +4 -4
- package/lib/tasks/magento/setup-magento/varnish-config.js +6 -4
- package/lib/tasks/magento/setup-magento/waiting-for-varnish.js +128 -3
- package/lib/tasks/mysql/connect-to-mysql.js +34 -21
- package/lib/tasks/mysql/import-dump-to-mysql.js +46 -3
- package/lib/tasks/php/php-container.js +108 -0
- package/lib/tasks/php/update-env-php.js +35 -19
- package/lib/tasks/php/update-env.php +61 -56
- 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 +38 -47
- package/lib/tasks/status/index.js +4 -10
- package/lib/tasks/stop.js +0 -2
- package/lib/tasks/theme/install-theme.js +1 -1
- package/lib/tasks/theme/symlink-theme.js +2 -3
- package/lib/util/config-php-json.js +13 -4
- 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/prefix.js +1 -1
- 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 +3 -9
- package/typings/index.d.ts +38 -57
- 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/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
package/lib/commands/cli.js
CHANGED
|
@@ -5,9 +5,9 @@ const getMagentoVersionConfig = require('../config/get-magento-version-config');
|
|
|
5
5
|
const logger = require('@scandipwa/scandipwa-dev-utils/logger');
|
|
6
6
|
const getProjectConfiguration = require('../config/get-project-configuration');
|
|
7
7
|
const checkConfigurationFile = require('../config/check-configuration-file');
|
|
8
|
-
const { installComposer, installPrestissimo } = require('../tasks/composer');
|
|
8
|
+
// const { installComposer, installPrestissimo } = require('../tasks/composer');
|
|
9
9
|
const ConsoleBlock = require('../util/console-block');
|
|
10
|
-
const checkComposerCredentials = require('../tasks/requirements/composer');
|
|
10
|
+
const { checkComposerCredentials } = require('../tasks/requirements/composer-credentials');
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* @param {import('yargs')} yargs
|
|
@@ -18,8 +18,6 @@ module.exports = (yargs) => {
|
|
|
18
18
|
getMagentoVersionConfig(),
|
|
19
19
|
checkConfigurationFile(),
|
|
20
20
|
getProjectConfiguration(),
|
|
21
|
-
installComposer(),
|
|
22
|
-
installPrestissimo(),
|
|
23
21
|
createBashrcConfigFile(),
|
|
24
22
|
checkComposerCredentials()
|
|
25
23
|
], {
|
package/lib/commands/execute.js
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
const logger = require('@scandipwa/scandipwa-dev-utils/logger');
|
|
2
|
-
const {
|
|
2
|
+
const { Listr } = require('listr2');
|
|
3
|
+
const checkConfigurationFile = require('../config/check-configuration-file');
|
|
4
|
+
const getProjectConfiguration = require('../config/get-project-configuration');
|
|
3
5
|
const executeInContainer = require('../tasks/execute');
|
|
6
|
+
const getMagentoVersionConfig = require('../config/get-magento-version-config');
|
|
7
|
+
const { checkRequirements } = require('../tasks/requirements');
|
|
8
|
+
const { getCachedPorts } = require('../config/get-port-config');
|
|
4
9
|
|
|
5
10
|
/**
|
|
6
11
|
* @param {import('yargs')} yargs
|
|
@@ -21,7 +26,27 @@ Available containers:
|
|
|
21
26
|
- sslTerminator`);
|
|
22
27
|
},
|
|
23
28
|
async (argv) => {
|
|
24
|
-
const
|
|
29
|
+
const tasks = new Listr([
|
|
30
|
+
checkRequirements(),
|
|
31
|
+
getMagentoVersionConfig(),
|
|
32
|
+
checkConfigurationFile(),
|
|
33
|
+
getProjectConfiguration(),
|
|
34
|
+
getCachedPorts()
|
|
35
|
+
], {
|
|
36
|
+
concurrent: false,
|
|
37
|
+
exitOnError: true,
|
|
38
|
+
ctx: { throwMagentoVersionMissing: true },
|
|
39
|
+
rendererOptions: { collapse: false, clearOutput: true }
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
let ctx;
|
|
43
|
+
try {
|
|
44
|
+
ctx = await tasks.run();
|
|
45
|
+
} catch (e) {
|
|
46
|
+
logger.error(e.message || e);
|
|
47
|
+
process.exit(1);
|
|
48
|
+
}
|
|
49
|
+
const containers = ctx.config.docker.getContainers(ctx.ports);
|
|
25
50
|
const services = Object.keys(containers);
|
|
26
51
|
|
|
27
52
|
if (services.includes(argv.containername) || services.some((service) => service.includes(argv.containername))) {
|
|
@@ -40,7 +65,7 @@ Available containers:
|
|
|
40
65
|
}
|
|
41
66
|
}
|
|
42
67
|
|
|
43
|
-
logger.logN(`Executing container ${logger.style.misc(container._)}`);
|
|
68
|
+
logger.logN(`Executing container ${logger.style.misc(container._)} (command: ${logger.style.command(argv.commands[0])})`);
|
|
44
69
|
await executeInContainer({
|
|
45
70
|
containerName: container.name,
|
|
46
71
|
commands: argv.commands
|
package/lib/commands/start.js
CHANGED
|
@@ -17,6 +17,26 @@ const cmaGaTrackingId = 'UA-127741417-7';
|
|
|
17
17
|
|
|
18
18
|
googleAnalytics.setGaTrackingId(cmaGaTrackingId);
|
|
19
19
|
|
|
20
|
+
const reportErrors = async (errors) => {
|
|
21
|
+
for (const error of errors) {
|
|
22
|
+
const path = (error.path && ` Error path: ${error.path} `) || '';
|
|
23
|
+
if (error instanceof UnknownError || error instanceof KnownError) {
|
|
24
|
+
logger.error(error.message);
|
|
25
|
+
if (error instanceof UnknownError) {
|
|
26
|
+
await googleAnalytics.trackError(`Unknown Error:${path}${error.stack}`);
|
|
27
|
+
} else {
|
|
28
|
+
await googleAnalytics.trackError(`Known Error:${path}${error.message}`);
|
|
29
|
+
}
|
|
30
|
+
} else if (error instanceof Error) {
|
|
31
|
+
logger.error(error.message);
|
|
32
|
+
await googleAnalytics.trackError(`Regular Error:${path}${error.message}`);
|
|
33
|
+
} else {
|
|
34
|
+
logger.error(error);
|
|
35
|
+
await googleAnalytics.trackError(`Non Error:${path}${error}`); // track non-errors throws
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
|
|
20
40
|
/**
|
|
21
41
|
* @param {import('yargs')} yargs
|
|
22
42
|
*/
|
|
@@ -80,7 +100,8 @@ module.exports = (yargs) => {
|
|
|
80
100
|
rendererOptions: {
|
|
81
101
|
showErrorMessage: false,
|
|
82
102
|
showTimer: true
|
|
83
|
-
}
|
|
103
|
+
},
|
|
104
|
+
collectErrors: 'minimal'
|
|
84
105
|
}
|
|
85
106
|
);
|
|
86
107
|
const timeStamp = Date.now();
|
|
@@ -153,6 +174,13 @@ module.exports = (yargs) => {
|
|
|
153
174
|
);
|
|
154
175
|
logger.log('');
|
|
155
176
|
|
|
177
|
+
if (!analytics && tasks.err && tasks.err.length > 0) {
|
|
178
|
+
logger.warn('You have disabled analytics, but we\'ve encountered errors during startup!');
|
|
179
|
+
for (const err of tasks.err) {
|
|
180
|
+
logger.error(`${err.path}\n${err.message}\n\n${err.stack}`);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
156
184
|
if (!analytics) {
|
|
157
185
|
process.exit(0);
|
|
158
186
|
}
|
|
@@ -178,22 +206,16 @@ module.exports = (yargs) => {
|
|
|
178
206
|
await googleAnalytics.trackError(e.message || e);
|
|
179
207
|
}
|
|
180
208
|
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
logger.error(e.message);
|
|
185
|
-
if (e instanceof UnknownError) {
|
|
186
|
-
await googleAnalytics.trackError(`Unknown Error: ${e.stack}`);
|
|
187
|
-
} else {
|
|
188
|
-
await googleAnalytics.trackError(`Known Error: ${e.message}`);
|
|
209
|
+
if (tasks.err && tasks.err.length > 0) {
|
|
210
|
+
for (const err of tasks.err) {
|
|
211
|
+
console.log(err);
|
|
189
212
|
}
|
|
190
|
-
|
|
191
|
-
logger.error(e.message);
|
|
192
|
-
await googleAnalytics.trackError(`Regular Error: ${e.message}`);
|
|
193
|
-
} else {
|
|
194
|
-
logger.error(e);
|
|
195
|
-
await googleAnalytics.trackError(`Non Error: ${e}`); // track non-errors throws
|
|
213
|
+
await reportErrors(tasks.err);
|
|
196
214
|
}
|
|
215
|
+
|
|
216
|
+
process.exit(0);
|
|
217
|
+
} catch (e) {
|
|
218
|
+
await reportErrors([e]);
|
|
197
219
|
process.exit(1);
|
|
198
220
|
}
|
|
199
221
|
}
|
package/lib/commands/status.js
CHANGED
|
@@ -8,6 +8,7 @@ const { checkRequirements } = require('../tasks/requirements');
|
|
|
8
8
|
const { statusContainers } = require('../tasks/docker/containers');
|
|
9
9
|
const getProjectConfiguration = require('../config/get-project-configuration');
|
|
10
10
|
const checkConfigurationFile = require('../config/check-configuration-file');
|
|
11
|
+
const checkPHPVersion = require('../tasks/requirements/php-version');
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
14
|
* @param {import('yargs')} yargs
|
|
@@ -20,6 +21,7 @@ module.exports = (yargs) => {
|
|
|
20
21
|
checkConfigurationFile(),
|
|
21
22
|
getProjectConfiguration(),
|
|
22
23
|
getCachedPorts(),
|
|
24
|
+
checkPHPVersion(),
|
|
23
25
|
statusContainers()
|
|
24
26
|
], {
|
|
25
27
|
concurrent: false,
|
package/lib/config/docker.js
CHANGED
|
@@ -1,26 +1,34 @@
|
|
|
1
1
|
const os = require('os');
|
|
2
2
|
const path = require('path');
|
|
3
|
-
const
|
|
4
|
-
const getIsWsl = require('../util/is-wsl');
|
|
3
|
+
const getPhpConfig = require('./php-config');
|
|
5
4
|
const { isIpAddress } = require('../util/ip');
|
|
6
5
|
|
|
7
6
|
const systeminformation = require('systeminformation');
|
|
8
7
|
|
|
9
|
-
|
|
8
|
+
/**
|
|
9
|
+
*
|
|
10
|
+
* @param {import('../../typings/context').ListrContext} ctx
|
|
11
|
+
* @param {import('../../typings/context').ListrContext['config']['overridenConfiguration']} overridenConfiguration
|
|
12
|
+
* @param {import('../../typings/context').ListrContext['config']['baseConfig']} baseConfig
|
|
13
|
+
* @returns
|
|
14
|
+
*/
|
|
15
|
+
module.exports = async (ctx, overridenConfiguration, baseConfig) => {
|
|
16
|
+
const { configuration, ssl, host } = overridenConfiguration;
|
|
10
17
|
const {
|
|
11
18
|
nginx,
|
|
12
19
|
redis,
|
|
13
|
-
mysql,
|
|
14
20
|
elasticsearch,
|
|
15
21
|
mariadb,
|
|
16
22
|
varnish
|
|
17
23
|
} = configuration;
|
|
18
24
|
|
|
25
|
+
const php = getPhpConfig(configuration, baseConfig);
|
|
19
26
|
const {
|
|
20
27
|
prefix,
|
|
21
28
|
magentoDir,
|
|
29
|
+
containerMagentoDir,
|
|
22
30
|
cacheDir
|
|
23
|
-
} =
|
|
31
|
+
} = baseConfig;
|
|
24
32
|
|
|
25
33
|
const cpuSupportedFlags = await systeminformation.cpuFlags();
|
|
26
34
|
|
|
@@ -40,9 +48,8 @@ module.exports = async ({ configuration, ssl, host }, config) => {
|
|
|
40
48
|
}
|
|
41
49
|
};
|
|
42
50
|
|
|
43
|
-
const isLinux =
|
|
44
|
-
const isWsl =
|
|
45
|
-
const isArm = (await getArch()) === 'arm64';
|
|
51
|
+
const isLinux = ctx.platform === 'linux';
|
|
52
|
+
const { isWsl } = ctx;
|
|
46
53
|
const isNotNativeLinux = (!isLinux || isWsl);
|
|
47
54
|
|
|
48
55
|
if (!isLinux) {
|
|
@@ -50,6 +57,14 @@ module.exports = async ({ configuration, ssl, host }, config) => {
|
|
|
50
57
|
* When CMA is running in non-native linux environment,
|
|
51
58
|
* we need also create named volumes for nginx to avoid performance penalty
|
|
52
59
|
*/
|
|
60
|
+
volumes.php = {
|
|
61
|
+
name: `${ prefix }_project-data`,
|
|
62
|
+
opts: {
|
|
63
|
+
type: 'nfs',
|
|
64
|
+
device: path.join(magentoDir),
|
|
65
|
+
o: 'bind'
|
|
66
|
+
}
|
|
67
|
+
};
|
|
53
68
|
volumes.nginx = {
|
|
54
69
|
name: `${ prefix }_nginx-data`,
|
|
55
70
|
opts: {
|
|
@@ -96,7 +111,40 @@ module.exports = async ({ configuration, ssl, host }, config) => {
|
|
|
96
111
|
}
|
|
97
112
|
|
|
98
113
|
const getContainers = (ports = {}) => {
|
|
114
|
+
/**
|
|
115
|
+
* @type {Record<string, import('../tasks/docker/containers/container-api').ContainerRunOptions>}
|
|
116
|
+
*/
|
|
99
117
|
const dockerConfig = {
|
|
118
|
+
php: {
|
|
119
|
+
_: 'PHP',
|
|
120
|
+
ports: isNotNativeLinux ? [
|
|
121
|
+
`${ isIpAddress(host) ? host : '127.0.0.1' }:${ ports.fpm }:9000`
|
|
122
|
+
] : [],
|
|
123
|
+
forwardedPorts: [
|
|
124
|
+
isNotNativeLinux
|
|
125
|
+
? `127.0.0.1:${ ports.fpm }:9000`
|
|
126
|
+
: `127.0.0.1:${ ports.fpm }`
|
|
127
|
+
],
|
|
128
|
+
network: isNotNativeLinux ? network.name : 'host',
|
|
129
|
+
mountVolumes: [
|
|
130
|
+
`${ isLinux ? magentoDir : volumes.php.name }:${containerMagentoDir}`,
|
|
131
|
+
`${ php.iniPath }:/usr/local/etc/php/php.ini`,
|
|
132
|
+
`${ php.fpmConfPath }:/usr/local/etc/php-fpm.d/zz-docker.conf`
|
|
133
|
+
],
|
|
134
|
+
env: {
|
|
135
|
+
COMPOSER_AUTH: process.env.COMPOSER_AUTH || ''
|
|
136
|
+
},
|
|
137
|
+
restart: 'on-failure:5',
|
|
138
|
+
image: `local-cma-project:${ prefix }`,
|
|
139
|
+
debugImage: `local-cma-project:${ prefix }.debug`,
|
|
140
|
+
remoteImages: [
|
|
141
|
+
configuration.php.baseImage,
|
|
142
|
+
configuration.php.debugImage
|
|
143
|
+
],
|
|
144
|
+
name: `${ prefix }_php`,
|
|
145
|
+
connectCommand: ['/bin/sh'],
|
|
146
|
+
user: isLinux ? `${os.userInfo().uid}:${os.userInfo().gid}` : ''
|
|
147
|
+
},
|
|
100
148
|
sslTerminator: {
|
|
101
149
|
_: 'SSL Terminator (Nginx)',
|
|
102
150
|
ports: isNotNativeLinux ? [
|
|
@@ -117,13 +165,8 @@ module.exports = async ({ configuration, ssl, host }, config) => {
|
|
|
117
165
|
`${ isLinux ? path.join(cacheDir, 'ssl-terminator', 'conf.d') : volumes.sslTerminator.name }:/etc/nginx/conf.d`
|
|
118
166
|
],
|
|
119
167
|
restart: 'on-failure:5',
|
|
120
|
-
// TODO: use connect instead
|
|
121
168
|
network: isNotNativeLinux ? network.name : 'host',
|
|
122
169
|
image: `nginx:${ nginx.version }`,
|
|
123
|
-
imageDetails: {
|
|
124
|
-
name: 'nginx',
|
|
125
|
-
tag: nginx.version
|
|
126
|
-
},
|
|
127
170
|
name: `${ prefix }_ssl-terminator`,
|
|
128
171
|
command: "nginx -g 'daemon off;'"
|
|
129
172
|
},
|
|
@@ -145,21 +188,17 @@ module.exports = async ({ configuration, ssl, host }, config) => {
|
|
|
145
188
|
*/
|
|
146
189
|
mountVolumes: isLinux ? [
|
|
147
190
|
`${ cacheDir }/nginx/conf.d:/etc/nginx/conf.d`,
|
|
148
|
-
`${ path.join(magentoDir, 'pub') }:${path.join(
|
|
149
|
-
`${ path.join(magentoDir, 'setup') }:${path.join(
|
|
191
|
+
`${ path.join(magentoDir, 'pub') }:${path.join(containerMagentoDir, 'pub')}`,
|
|
192
|
+
`${ path.join(magentoDir, 'setup') }:${path.join(containerMagentoDir, 'setup')}`
|
|
150
193
|
] : [
|
|
151
194
|
`${ volumes.nginx.name }:/etc/nginx/conf.d`,
|
|
152
|
-
`${ volumes.appPub.name }:${path.join(
|
|
153
|
-
`${ volumes.appSetup.name }:${path.join(
|
|
195
|
+
`${ volumes.appPub.name }:${path.join(containerMagentoDir, 'pub')}`,
|
|
196
|
+
`${ volumes.appSetup.name }:${path.join(containerMagentoDir, 'setup')}`
|
|
154
197
|
],
|
|
155
198
|
restart: 'on-failure:5',
|
|
156
199
|
// TODO: use connect instead
|
|
157
200
|
network: isNotNativeLinux ? network.name : 'host',
|
|
158
201
|
image: `nginx:${ nginx.version }`,
|
|
159
|
-
imageDetails: {
|
|
160
|
-
name: 'nginx',
|
|
161
|
-
tag: nginx.version
|
|
162
|
-
},
|
|
163
202
|
name: `${ prefix }_nginx`,
|
|
164
203
|
command: "nginx -g 'daemon off;'"
|
|
165
204
|
},
|
|
@@ -182,7 +221,7 @@ module.exports = async ({ configuration, ssl, host }, config) => {
|
|
|
182
221
|
connectCommand: ['redis-cli']
|
|
183
222
|
},
|
|
184
223
|
mysql: {
|
|
185
|
-
_:
|
|
224
|
+
_: 'MariaDB',
|
|
186
225
|
healthCheck: {
|
|
187
226
|
cmd: 'mysqladmin ping --silent'
|
|
188
227
|
},
|
|
@@ -208,21 +247,13 @@ module.exports = async ({ configuration, ssl, host }, config) => {
|
|
|
208
247
|
'--max_allowed_packet=1GB',
|
|
209
248
|
'--bind-address=0.0.0.0'
|
|
210
249
|
]
|
|
211
|
-
.concat(!isArm ? ['--secure-file-priv=NULL'] : [])
|
|
212
250
|
.join(' '),
|
|
213
251
|
securityOptions: [
|
|
214
252
|
'seccomp=unconfined'
|
|
215
253
|
],
|
|
216
254
|
network: network.name,
|
|
217
|
-
image:
|
|
218
|
-
|
|
219
|
-
name: 'mysql',
|
|
220
|
-
tag: mysql.version
|
|
221
|
-
} : {
|
|
222
|
-
name: 'mariadb',
|
|
223
|
-
tag: mariadb.version
|
|
224
|
-
},
|
|
225
|
-
name: !isArm ? `${ prefix }_mysql` : `${ prefix }_mariadb`
|
|
255
|
+
image: `mariadb:${ mariadb.version }`,
|
|
256
|
+
name: `${ prefix }_mariadb`
|
|
226
257
|
},
|
|
227
258
|
elasticsearch: {
|
|
228
259
|
_: 'ElasticSearch',
|
|
@@ -236,16 +267,12 @@ module.exports = async ({ configuration, ssl, host }, config) => {
|
|
|
236
267
|
'bootstrap.memory_lock': true,
|
|
237
268
|
'xpack.security.enabled': false,
|
|
238
269
|
'discovery.type': 'single-node',
|
|
239
|
-
ES_JAVA_OPTS: '
|
|
270
|
+
ES_JAVA_OPTS: '-Xms512m -Xmx512m',
|
|
240
271
|
// https://www.elastic.co/guide/en/elasticsearch/reference/master/ml-settings.html
|
|
241
272
|
'xpack.ml.enabled': ['sse4.2', 'sse4_2'].some((sse42Flag) => cpuSupportedFlags.includes(sse42Flag))
|
|
242
273
|
},
|
|
243
274
|
network: network.name,
|
|
244
275
|
image: `elasticsearch:${ elasticsearch.version }`,
|
|
245
|
-
imageDetails: {
|
|
246
|
-
name: 'elasticsearch',
|
|
247
|
-
tag: elasticsearch.version
|
|
248
|
-
},
|
|
249
276
|
name: `${ prefix }_elasticsearch`
|
|
250
277
|
}
|
|
251
278
|
};
|
|
@@ -256,14 +283,10 @@ module.exports = async ({ configuration, ssl, host }, config) => {
|
|
|
256
283
|
);
|
|
257
284
|
}
|
|
258
285
|
|
|
259
|
-
if (varnish.enabled) {
|
|
286
|
+
if (!ctx.debug && varnish.enabled) {
|
|
260
287
|
dockerConfig.varnish = {
|
|
261
288
|
_: 'Varnish',
|
|
262
289
|
image: `varnish:${ varnish.version }`,
|
|
263
|
-
imageDetails: {
|
|
264
|
-
name: 'varnish',
|
|
265
|
-
tag: varnish.version
|
|
266
|
-
},
|
|
267
290
|
name: `${ prefix }_varnish`,
|
|
268
291
|
mountVolumes: [
|
|
269
292
|
`${ isLinux ? path.join(cacheDir, 'varnish') : volumes.varnish.name }:/etc/varnish`
|
|
@@ -8,7 +8,9 @@ const getProjectConfiguration = () => ({
|
|
|
8
8
|
task: async (ctx) => {
|
|
9
9
|
const { magentoVersion } = ctx;
|
|
10
10
|
|
|
11
|
-
ctx.config = await getConfigFromMagentoVersion(
|
|
11
|
+
ctx.config = await getConfigFromMagentoVersion(ctx, {
|
|
12
|
+
magentoVersion
|
|
13
|
+
});
|
|
12
14
|
}
|
|
13
15
|
});
|
|
14
16
|
|
package/lib/config/index.js
CHANGED
|
@@ -5,7 +5,6 @@ const {
|
|
|
5
5
|
defaultConfiguration
|
|
6
6
|
} = require('./versions');
|
|
7
7
|
const getPhpConfig = require('./php-config');
|
|
8
|
-
const getComposerConfig = require('./composer');
|
|
9
8
|
const { getMagentoConfig } = require('./magento-config');
|
|
10
9
|
const resolveConfigurationWithOverrides = require('../util/resolve-configuration-with-overrides');
|
|
11
10
|
const { getPrefix, folderName } = require('../util/prefix');
|
|
@@ -15,11 +14,12 @@ const platforms = ['linux', 'darwin'];
|
|
|
15
14
|
const darwinMinimalVersion = '10.5';
|
|
16
15
|
|
|
17
16
|
/**
|
|
18
|
-
* @returns {
|
|
17
|
+
* @returns {import('../../typings/context').ListrContext['config']['baseConfig']}
|
|
19
18
|
*/
|
|
20
19
|
const getBaseConfig = (projectPath = process.cwd(), prefix = folderName) => ({
|
|
21
20
|
prefix: getPrefix(prefix),
|
|
22
21
|
magentoDir: projectPath,
|
|
22
|
+
containerMagentoDir: '/var/www/html',
|
|
23
23
|
templateDir: path.join(__dirname, 'templates'),
|
|
24
24
|
cacheDir: path.join(projectPath, 'node_modules', '.create-magento-app-cache')
|
|
25
25
|
});
|
|
@@ -27,14 +27,19 @@ const getBaseConfig = (projectPath = process.cwd(), prefix = folderName) => ({
|
|
|
27
27
|
const baseConfig = getBaseConfig();
|
|
28
28
|
|
|
29
29
|
const magento = {
|
|
30
|
-
binPath: path.join(baseConfig.magentoDir, 'bin', 'magento')
|
|
30
|
+
binPath: path.join(baseConfig.magentoDir, 'bin', 'magento'),
|
|
31
|
+
containerBinPath: path.join(baseConfig.containerMagentoDir, 'bin', 'magento')
|
|
31
32
|
};
|
|
32
33
|
|
|
33
34
|
module.exports = {
|
|
34
35
|
/**
|
|
35
36
|
* @param {string} magentoVersion
|
|
36
37
|
*/
|
|
37
|
-
async getConfigFromMagentoVersion(
|
|
38
|
+
async getConfigFromMagentoVersion(ctx, {
|
|
39
|
+
magentoVersion,
|
|
40
|
+
projectPath = process.cwd(),
|
|
41
|
+
prefix = folderName
|
|
42
|
+
}) {
|
|
38
43
|
const newBaseConfig = getBaseConfig(projectPath, prefix);
|
|
39
44
|
const configurations = getConfigurations(newBaseConfig);
|
|
40
45
|
if (!configurations[magentoVersion]) {
|
|
@@ -52,8 +57,7 @@ module.exports = {
|
|
|
52
57
|
|
|
53
58
|
return {
|
|
54
59
|
php: getPhpConfig(overridenConfiguration.configuration, newBaseConfig),
|
|
55
|
-
docker: await getDockerConfig(overridenConfiguration, newBaseConfig),
|
|
56
|
-
composer: getComposerConfig(overridenConfiguration.configuration, newBaseConfig),
|
|
60
|
+
docker: await getDockerConfig(ctx, overridenConfiguration, newBaseConfig),
|
|
57
61
|
magentoConfiguration: getMagentoConfig(overridenConfiguration.magento),
|
|
58
62
|
baseConfig: newBaseConfig,
|
|
59
63
|
overridenConfiguration,
|
|
@@ -65,7 +69,6 @@ module.exports = {
|
|
|
65
69
|
getBaseConfig,
|
|
66
70
|
magento,
|
|
67
71
|
platforms,
|
|
68
|
-
docker: getDockerConfig(defaultConfiguration, baseConfig),
|
|
69
72
|
darwinMinimalVersion,
|
|
70
73
|
defaultConfiguration
|
|
71
74
|
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
const magento23RequiredPHPExtensions = require('./magento-2.3');
|
|
2
|
+
const magento24RequiredPHPExtensions = require('./magento-2.4');
|
|
3
|
+
|
|
4
|
+
const { phpExtensionInstallationInstructions } = require('../../php/extensions');
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @param {string[]} requiredPHPExtensions
|
|
8
|
+
* @returns {Record<string, import('../../../../typings/index').PHPExtensionInstallationInstruction>}
|
|
9
|
+
*/
|
|
10
|
+
const mapMagentoRequiredExtensionsToInstructions = (requiredPHPExtensions) => requiredPHPExtensions.map((extensionName) => {
|
|
11
|
+
if (phpExtensionInstallationInstructions[extensionName]) {
|
|
12
|
+
return phpExtensionInstallationInstructions[extensionName];
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
for (const [extensionName, extensionData] of Object.entries(phpExtensionInstallationInstructions)) {
|
|
16
|
+
if (extensionData.alternativeName && extensionData.alternativeName.includes(extensionName)) {
|
|
17
|
+
return extensionData;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return {
|
|
22
|
+
name: extensionName
|
|
23
|
+
};
|
|
24
|
+
}).reduce((acc, val) => ({ ...acc, [val.name]: val }), {});
|
|
25
|
+
|
|
26
|
+
module.exports = {
|
|
27
|
+
magento23PHPExtensionList: mapMagentoRequiredExtensionsToInstructions(magento23RequiredPHPExtensions),
|
|
28
|
+
magento24PHPExtensionList: mapMagentoRequiredExtensionsToInstructions(magento24RequiredPHPExtensions)
|
|
29
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
const magento23RequiredPHPExtensions = [
|
|
2
|
+
'bcmath',
|
|
3
|
+
'ctype',
|
|
4
|
+
'curl',
|
|
5
|
+
'dom',
|
|
6
|
+
'gd',
|
|
7
|
+
'hash',
|
|
8
|
+
'iconv',
|
|
9
|
+
'intl',
|
|
10
|
+
'mbstring',
|
|
11
|
+
'openssl',
|
|
12
|
+
'pdo_mysql',
|
|
13
|
+
'simplexml',
|
|
14
|
+
'soap',
|
|
15
|
+
'xsl',
|
|
16
|
+
'zip'
|
|
17
|
+
];
|
|
18
|
+
|
|
19
|
+
module.exports = magento23RequiredPHPExtensions;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
const magento24RequiredPHPExtensions = [
|
|
2
|
+
'bcmath',
|
|
3
|
+
'ctype',
|
|
4
|
+
'curl',
|
|
5
|
+
'dom',
|
|
6
|
+
'fileinfo',
|
|
7
|
+
'gd',
|
|
8
|
+
'hash',
|
|
9
|
+
'iconv',
|
|
10
|
+
'intl',
|
|
11
|
+
'json',
|
|
12
|
+
'libxml',
|
|
13
|
+
'mbstring',
|
|
14
|
+
'openssl',
|
|
15
|
+
'pcre',
|
|
16
|
+
'pdo_mysql',
|
|
17
|
+
'simplexml',
|
|
18
|
+
'soap',
|
|
19
|
+
'sockets',
|
|
20
|
+
'sodium',
|
|
21
|
+
'tokenizer',
|
|
22
|
+
'xmlwriter',
|
|
23
|
+
'xsl',
|
|
24
|
+
'zip',
|
|
25
|
+
'libxml',
|
|
26
|
+
'openssl'
|
|
27
|
+
];
|
|
28
|
+
|
|
29
|
+
module.exports = magento24RequiredPHPExtensions;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/* eslint-disable max-len */
|
|
2
|
+
/**
|
|
3
|
+
* @type {import('../../../../typings/index').PHPExtensionInstallationInstruction}
|
|
4
|
+
*/
|
|
5
|
+
module.exports = {
|
|
6
|
+
name: 'apcu',
|
|
7
|
+
// eslint-disable-next-line quotes
|
|
8
|
+
command: `apk add --no-cache --virtual .build-deps \\$PHPIZE_DEPS \
|
|
9
|
+
&& pecl install apcu \
|
|
10
|
+
&& docker-php-ext-enable apcu \
|
|
11
|
+
&& apk del -f .build-deps`
|
|
12
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @type {import('../../../../typings/index').PHPExtensionInstallationInstruction}
|
|
3
|
+
*/
|
|
4
|
+
module.exports = {
|
|
5
|
+
name: 'gd',
|
|
6
|
+
command: 'docker-php-ext-configure gd --with-freetype --with-jpeg --with-webp && docker-php-ext-install gd',
|
|
7
|
+
dependencies: [
|
|
8
|
+
'freetype-dev',
|
|
9
|
+
'libjpeg-turbo-dev',
|
|
10
|
+
'libpng-dev',
|
|
11
|
+
'zlib-dev',
|
|
12
|
+
'libwebp-dev'
|
|
13
|
+
]
|
|
14
|
+
};
|
|
@@ -1,4 +1,20 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
const fs = require('fs');
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @type {Record<string, import('../../../../typings/index').PHPExtensionInstallationInstruction>}
|
|
6
|
+
*/
|
|
7
|
+
const phpExtensionInstallationInstructions = fs.readdirSync(__dirname, {
|
|
8
|
+
withFileTypes: true
|
|
9
|
+
})
|
|
10
|
+
.filter((f) => f.isFile())
|
|
11
|
+
.filter((f) => f.name !== 'index.js')
|
|
12
|
+
.map((f) => ({
|
|
13
|
+
name: path.parse(f.name).name,
|
|
14
|
+
extension: require(path.join(__dirname, f.name))
|
|
15
|
+
}))
|
|
16
|
+
.reduce((acc, val) => ({ ...acc, [val.name]: val.extension }), {});
|
|
17
|
+
|
|
1
18
|
module.exports = {
|
|
2
|
-
|
|
3
|
-
xdebug: require('./xdebug')
|
|
19
|
+
phpExtensionInstallationInstructions
|
|
4
20
|
};
|