@scandipwa/magento-scripts 1.14.1-alpha.8 → 1.15.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 +9 -4
- package/lib/commands/logs.js +1 -0
- package/lib/commands/start.js +18 -5
- package/lib/config/check-configuration-file.js +16 -1
- package/lib/config/cma-config.js +16 -0
- package/lib/config/dependencies-for-platforms.js +15 -3
- package/lib/config/docker.js +45 -12
- package/lib/config/get-port-config.js +7 -2
- package/lib/config/index.js +2 -1
- package/lib/config/php/extensions/libsodium.js +2 -1
- package/lib/config/port-config.js +2 -1
- package/lib/config/scandipwa-versions.js +2 -1
- package/lib/config/ssl-terminator/index.js +10 -0
- package/lib/config/system-config.js +34 -5
- package/lib/config/templates/magentorc.template +2 -0
- package/lib/config/templates/nginx.template.conf +0 -31
- package/lib/config/templates/ssl-terminator.template.conf +27 -0
- package/lib/config/templates/varnish.template.vcl +9 -4
- package/lib/config/versions/magento-2.3.0.js +3 -1
- package/lib/config/versions/magento-2.3.1.js +3 -1
- package/lib/config/versions/magento-2.3.2-p2.js +3 -1
- package/lib/config/versions/magento-2.3.2.js +3 -1
- package/lib/config/versions/magento-2.3.3-p1.js +3 -1
- package/lib/config/versions/magento-2.3.3.js +3 -1
- package/lib/config/versions/magento-2.3.4-p2.js +3 -1
- package/lib/config/versions/magento-2.3.4.js +3 -1
- package/lib/config/versions/magento-2.3.5-p1.js +3 -1
- package/lib/config/versions/magento-2.3.5-p2.js +3 -1
- package/lib/config/versions/magento-2.3.5.js +3 -1
- package/lib/config/versions/magento-2.3.6-p1.js +3 -1
- package/lib/config/versions/magento-2.3.6.js +3 -1
- package/lib/config/versions/magento-2.3.7-p1.js +3 -1
- package/lib/config/versions/magento-2.3.7-p2.js +3 -1
- package/lib/config/versions/magento-2.3.7-p3.js +3 -1
- package/lib/config/versions/magento-2.3.7.js +3 -1
- package/lib/config/versions/magento-2.4.0-p1.js +3 -1
- package/lib/config/versions/magento-2.4.0.js +3 -1
- package/lib/config/versions/magento-2.4.1-p1.js +3 -1
- package/lib/config/versions/magento-2.4.1.js +3 -1
- package/lib/config/versions/magento-2.4.2-p1.js +3 -1
- package/lib/config/versions/magento-2.4.2-p2.js +3 -1
- package/lib/config/versions/magento-2.4.2.js +3 -1
- package/lib/config/versions/magento-2.4.3-p1.js +3 -1
- package/lib/config/versions/magento-2.4.3-p2.js +3 -1
- package/lib/config/versions/magento-2.4.3.js +3 -1
- package/lib/config/versions/magento-2.4.4.js +3 -1
- package/lib/config/xml-parser.js +63 -0
- package/lib/errors/known-error.js +15 -0
- package/lib/errors/unknown-error.js +15 -0
- package/lib/tasks/cli/create-bashrc-config.js +2 -1
- package/lib/tasks/composer/index.js +5 -3
- package/lib/tasks/composer/local-auth-json.js +8 -4
- package/lib/tasks/docker/network.js +2 -1
- package/lib/tasks/execute/index.js +2 -3
- package/lib/tasks/file-system/create-nginx-config.js +4 -43
- package/lib/tasks/file-system/create-php-config.js +2 -1
- package/lib/tasks/file-system/create-php-fpm-config.js +2 -1
- package/lib/tasks/file-system/create-phpstorm-config/database-config.js +249 -0
- package/lib/tasks/file-system/create-phpstorm-config/eslint-config.js +85 -0
- package/lib/tasks/file-system/create-phpstorm-config/exclude-folder-config.js +154 -0
- package/lib/tasks/file-system/create-phpstorm-config/index.js +27 -0
- package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/coding-standard-config.js +26 -0
- package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/config.js +54 -0
- package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/custom-ruleset-path-config.js +28 -0
- package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/default-properties-config.js +42 -0
- package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/eslint-inspection-config.js +37 -0
- package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/index.js +80 -0
- package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/magento-coding-standard-config.js +26 -0
- package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/mess-detector-validation-inspection-config.js +142 -0
- package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/paths.js +20 -0
- package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/php-cs-fixer-validation-inspection-config.js +60 -0
- package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/php-cs-validation-inspection-config.js +116 -0
- package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/stylelint-inspection-config.js +37 -0
- package/lib/tasks/file-system/create-phpstorm-config/keys.js +14 -0
- package/lib/tasks/file-system/create-phpstorm-config/php-config/index.js +67 -0
- package/lib/tasks/file-system/create-phpstorm-config/php-config/mess-detector-config.js +54 -0
- package/lib/tasks/file-system/create-phpstorm-config/php-config/php-code-sniffer-config.js +66 -0
- package/lib/tasks/file-system/create-phpstorm-config/php-config/php-cs-fixer-config.js +58 -0
- package/lib/tasks/file-system/create-phpstorm-config/php-config/php-project-shared-configuration-config.js +59 -0
- package/lib/tasks/file-system/create-phpstorm-config/stylelint-config.js +77 -0
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/composer-settings-config.js +97 -0
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/format-setting-config.js +57 -0
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/index.js +66 -0
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/php-debug-general-config.js +64 -0
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/php-server-config.js +57 -0
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/properties-component-config.js +49 -0
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/run-manager-config.js +64 -0
- package/lib/tasks/file-system/create-phpstorm-config/xml-utils.js +5 -0
- package/lib/tasks/file-system/create-ssl-terminator-config.js +96 -0
- package/lib/tasks/file-system/create-varnish-config.js +2 -1
- package/lib/tasks/file-system/create-vscode-config.js +3 -2
- package/lib/tasks/file-system/index.js +3 -1
- package/lib/tasks/magento/enable-magento-composer-plugins.js +3 -2
- package/lib/tasks/magento/install-magento.js +7 -5
- package/lib/tasks/magento/setup-magento/adjust-full-page-cache.js +26 -0
- package/lib/tasks/magento/setup-magento/delete-admin-users.js +1 -1
- package/lib/tasks/magento/setup-magento/delete-customers.js +7 -4
- package/lib/tasks/magento/setup-magento/delete-orders.js +6 -4
- package/lib/tasks/magento/setup-magento/flush-redis-config.js +2 -1
- package/lib/tasks/magento/setup-magento/index.js +3 -1
- package/lib/tasks/magento/setup-magento/install-magento.js +2 -1
- package/lib/tasks/magento/setup-magento/set-base-url.js +7 -2
- package/lib/tasks/magento/setup-magento/upgrade-magento.js +11 -1
- package/lib/tasks/magento/setup-magento/waiting-for-varnish.js +41 -0
- package/lib/tasks/mysql/connect-to-mysql.js +2 -1
- package/lib/tasks/mysql/import-dump-to-mysql.js +13 -2
- package/lib/tasks/mysql/import-remote-db/index.js +2 -1
- package/lib/tasks/mysql/import-remote-db/ssh/index.js +2 -1
- package/lib/tasks/mysql/import-remote-db/ssh/regular-server.js +2 -1
- package/lib/tasks/php/bundled-extensions.js +28 -0
- package/lib/tasks/php/compile-options.js +27 -54
- package/lib/tasks/php/compile.js +6 -4
- package/lib/tasks/php/configure.js +7 -66
- package/lib/tasks/php/extensions/disable.js +2 -1
- package/lib/tasks/php/extensions/enable.js +2 -1
- package/lib/tasks/php/extensions/index.js +74 -0
- package/lib/tasks/php/extensions/install.js +3 -3
- package/lib/tasks/php/index.js +7 -6
- package/lib/tasks/php/install-sodium.js +93 -0
- package/lib/tasks/php/update-phpbrew.js +7 -3
- package/lib/tasks/php/validate-php.js +67 -0
- package/lib/tasks/php-fpm/start-php-fpm.js +4 -2
- package/lib/tasks/requirements/composer.js +59 -5
- package/lib/tasks/requirements/dependency/arch.js +2 -1
- package/lib/tasks/requirements/dependency/centos.js +2 -1
- package/lib/tasks/requirements/dependency/fedora.js +2 -1
- package/lib/tasks/requirements/dependency/mac.js +18 -3
- package/lib/tasks/requirements/docker/index.js +94 -40
- package/lib/tasks/requirements/docker/install-on-mac.js +29 -0
- package/lib/tasks/requirements/docker/install.js +2 -1
- package/lib/tasks/requirements/docker/running-status.js +32 -31
- package/lib/tasks/requirements/docker/version.js +2 -1
- package/lib/tasks/requirements/index.js +3 -0
- package/lib/tasks/requirements/node-version.js +2 -1
- package/lib/tasks/requirements/php-version.js +26 -24
- package/lib/tasks/requirements/phpbrew/index.js +2 -1
- package/lib/tasks/requirements/phpbrew/install.js +14 -2
- package/lib/tasks/requirements/phpbrew/version.js +2 -1
- package/lib/tasks/requirements/platform.js +5 -3
- package/lib/tasks/requirements/rosetta.js +32 -0
- package/lib/tasks/start.js +10 -2
- package/lib/tasks/status/index.js +24 -8
- package/lib/tasks/theme/build-theme.js +2 -1
- package/lib/tasks/theme/install-theme.js +2 -1
- package/lib/tasks/theme/link-theme.js +2 -2
- package/lib/tasks/theme/retrieve-theme-data.js +2 -1
- package/lib/tasks/theme/setup-persisted-query.js +2 -1
- package/lib/tasks/theme/setup-themes.js +10 -3
- package/lib/tasks/theme/symlink-theme.js +8 -1
- package/lib/util/CSA-theme.js +4 -0
- package/lib/util/analytics.js +320 -0
- package/lib/util/arch.js +1 -1
- package/lib/util/config-file-validator.js +4 -2
- package/lib/util/config-php-json.js +3 -2
- package/lib/util/env-php-json.js +3 -2
- package/lib/util/exec-async-command.d.ts +2 -0
- package/lib/util/exec-async-command.js +31 -15
- package/lib/util/exec-async.js +9 -0
- package/lib/util/get-brew-bin-path.js +64 -0
- package/lib/util/get-installed-magento-version.js +3 -2
- package/lib/util/get-jsonfile-data.js +2 -1
- package/lib/util/install-dependencies-task.js +15 -5
- package/lib/util/instance-metadata.js +11 -4
- package/lib/util/ip.js +47 -1
- package/lib/util/magento-task.js +20 -9
- package/lib/util/php-task.js +7 -7
- package/lib/util/request.js +0 -0
- package/lib/util/resolve-configuration-with-overrides.js +2 -1
- package/lib/util/run-composer.js +5 -3
- package/lib/util/run-magento.js +3 -2
- package/lib/util/run-php.js +7 -2
- package/lib/util/wait-for-it.js +3 -2
- package/package.json +5 -3
- package/typings/context.d.ts +4 -0
- package/typings/index.d.ts +13 -1
- package/typings/phpstorm.d.ts +33 -0
- package/lib/tasks/file-system/create-php-storm-config.js +0 -82
- package/lib/tasks/magento/setup-magento/disable-full-page-cache.js +0 -20
package/lib/commands/cli.js
CHANGED
|
@@ -4,10 +4,10 @@ const createBashrcConfigFile = require('../tasks/cli/create-bashrc-config');
|
|
|
4
4
|
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
|
-
const localAuthJson = require('../tasks/composer/local-auth-json');
|
|
8
7
|
const checkConfigurationFile = require('../config/check-configuration-file');
|
|
9
8
|
const { installComposer, installPrestissimo } = require('../tasks/composer');
|
|
10
9
|
const ConsoleBlock = require('../util/console-block');
|
|
10
|
+
const checkComposerCredentials = require('../tasks/requirements/composer');
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* @param {import('yargs')} yargs
|
|
@@ -21,7 +21,7 @@ module.exports = (yargs) => {
|
|
|
21
21
|
installComposer(),
|
|
22
22
|
installPrestissimo(),
|
|
23
23
|
createBashrcConfigFile(),
|
|
24
|
-
|
|
24
|
+
checkComposerCredentials()
|
|
25
25
|
], {
|
|
26
26
|
concurrent: false,
|
|
27
27
|
exitOnError: true,
|
|
@@ -55,13 +55,18 @@ module.exports = (yargs) => {
|
|
|
55
55
|
block
|
|
56
56
|
.addLine(`Clear Magento cache: ${logger.style.command('m c:c')}`)
|
|
57
57
|
.addLine(`Magento setup upgrade: ${logger.style.command('m se:up')}`)
|
|
58
|
-
.addLine(`Magento DI compile: ${logger.style.command('m s:d:c')}`)
|
|
58
|
+
.addLine(`Magento DI compile: ${logger.style.command('m s:d:c')}`)
|
|
59
|
+
.addEmptyLine();
|
|
59
60
|
|
|
60
61
|
block
|
|
61
|
-
.addEmptyLine()
|
|
62
62
|
.addLine(`Clear Composer cache: ${logger.style.command('c cc')}`)
|
|
63
63
|
.addEmptyLine();
|
|
64
64
|
|
|
65
|
+
block
|
|
66
|
+
.addLine(`Connect to MySQL server: ${logger.style.command('mysql')}`)
|
|
67
|
+
.addLine(`Connect to MySQL server as root: ${logger.style.command('mysqlroot')}`)
|
|
68
|
+
.addEmptyLine();
|
|
69
|
+
|
|
65
70
|
block.log();
|
|
66
71
|
|
|
67
72
|
return cli();
|
package/lib/commands/logs.js
CHANGED
package/lib/commands/start.js
CHANGED
|
@@ -4,12 +4,14 @@ const { Listr } = require('listr2');
|
|
|
4
4
|
const { start } = require('../tasks/start');
|
|
5
5
|
const pathExists = require('../util/path-exists');
|
|
6
6
|
const { baseConfig } = require('../config');
|
|
7
|
-
const googleAnalytics = require('
|
|
7
|
+
const googleAnalytics = require('../util/analytics');
|
|
8
8
|
const systeminformation = require('systeminformation');
|
|
9
9
|
const { getCSAThemes } = require('../util/CSA-theme');
|
|
10
10
|
const shouldUseYarn = require('@scandipwa/scandipwa-dev-utils/should-use-yarn');
|
|
11
11
|
const ConsoleBlock = require('../util/console-block');
|
|
12
12
|
const { getInstanceMetadata } = require('../util/instance-metadata');
|
|
13
|
+
const UnknownError = require('../errors/unknown-error');
|
|
14
|
+
const KnownError = require('../errors/known-error');
|
|
13
15
|
|
|
14
16
|
const cmaGaTrackingId = 'UA-127741417-7';
|
|
15
17
|
|
|
@@ -156,8 +158,8 @@ module.exports = (yargs) => {
|
|
|
156
158
|
}
|
|
157
159
|
|
|
158
160
|
try {
|
|
161
|
+
await googleAnalytics.trackTiming('CMA start time', Date.now() - timeStamp);
|
|
159
162
|
if (!process.isFirstStart) {
|
|
160
|
-
await googleAnalytics.trackTiming('CMA start time', Date.now() - timeStamp);
|
|
161
163
|
googleAnalytics.printAboutAnalytics();
|
|
162
164
|
process.exit(0);
|
|
163
165
|
}
|
|
@@ -171,7 +173,6 @@ module.exports = (yargs) => {
|
|
|
171
173
|
const paramInfo = `Platform: ${platform} ${kernel}, CPU model: ${manufacturer} ${brand}, RAM amount: ${totalRam}MB`;
|
|
172
174
|
|
|
173
175
|
await googleAnalytics.trackEvent('Params', paramInfo, 0, 'OS');
|
|
174
|
-
await googleAnalytics.trackTiming('CMA first start time', Date.now() - timeStamp);
|
|
175
176
|
googleAnalytics.printAboutAnalytics();
|
|
176
177
|
} catch (e) {
|
|
177
178
|
await googleAnalytics.trackError(e.message || e);
|
|
@@ -179,8 +180,20 @@ module.exports = (yargs) => {
|
|
|
179
180
|
|
|
180
181
|
process.exit(0);
|
|
181
182
|
} catch (e) {
|
|
182
|
-
|
|
183
|
-
|
|
183
|
+
if (e instanceof UnknownError || e instanceof KnownError) {
|
|
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}`);
|
|
189
|
+
}
|
|
190
|
+
} else if (e instanceof Error) {
|
|
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
|
|
196
|
+
}
|
|
184
197
|
process.exit(1);
|
|
185
198
|
}
|
|
186
199
|
}
|
|
@@ -5,6 +5,7 @@ const pathExists = require('../util/path-exists');
|
|
|
5
5
|
const { deepmerge } = require('../util/deepmerge');
|
|
6
6
|
const { defaultMagentoConfig } = require('./magento-config');
|
|
7
7
|
const setConfigFile = require('../util/set-config');
|
|
8
|
+
const getJsonfileData = require('../util/get-jsonfile-data');
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* @type {() => import('listr2').ListrTask<import('../../typings/context').ListrContext>}
|
|
@@ -16,6 +17,8 @@ const checkConfigurationFile = () => ({
|
|
|
16
17
|
const { cacheDir, templateDir } = getBaseConfig(projectPath);
|
|
17
18
|
const configJSFilePath = path.join(projectPath, 'cma.js');
|
|
18
19
|
const magentoConfigFilePath = path.join(cacheDir, 'app-config.json');
|
|
20
|
+
const composerJsonPath = path.join(process.cwd(), 'composer.json');
|
|
21
|
+
const composerData = await getJsonfileData(composerJsonPath);
|
|
19
22
|
|
|
20
23
|
if (!await pathExists(configJSFilePath)) {
|
|
21
24
|
const legacyMagentoConfigExists = await pathExists(magentoConfigFilePath);
|
|
@@ -28,7 +31,19 @@ const checkConfigurationFile = () => ({
|
|
|
28
31
|
);
|
|
29
32
|
|
|
30
33
|
magentoConfiguration = legacyMagentoConfig.magento || legacyMagentoConfig;
|
|
31
|
-
} else {
|
|
34
|
+
} else if (composerData) {
|
|
35
|
+
if (composerData.require['magento/product-community-edition']) {
|
|
36
|
+
magentoConfiguration = deepmerge(defaultMagentoConfig, {
|
|
37
|
+
edition: 'community'
|
|
38
|
+
});
|
|
39
|
+
} else if (composerData.require['magento/product-enterprise-edition']) {
|
|
40
|
+
magentoConfiguration = deepmerge(defaultMagentoConfig, {
|
|
41
|
+
edition: 'enterprise'
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (!magentoConfiguration) {
|
|
32
47
|
const magentoEdition = await task.prompt({
|
|
33
48
|
type: 'Select',
|
|
34
49
|
message: `Please select Magento edition you want to install.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const Conf = require('conf');
|
|
2
|
+
|
|
3
|
+
const pkg = require('../../package.json');
|
|
4
|
+
/**
|
|
5
|
+
* @type {import('conf/dist/source').default}
|
|
6
|
+
*/
|
|
7
|
+
const cmaGlobalConfig = new Conf({
|
|
8
|
+
configName: 'config',
|
|
9
|
+
projectName: 'create-magento-app',
|
|
10
|
+
projectVersion: pkg.version,
|
|
11
|
+
defaults: {}
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
module.exports = {
|
|
15
|
+
cmaGlobalConfig
|
|
16
|
+
};
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
const { getBrewCommandSync } = require('../util/get-brew-bin-path');
|
|
2
|
+
|
|
1
3
|
const dependenciesForPlatforms = {
|
|
2
4
|
darwin: {
|
|
3
5
|
dependencies: [
|
|
@@ -15,7 +17,7 @@ const dependenciesForPlatforms = {
|
|
|
15
17
|
'libxml2',
|
|
16
18
|
'openssl@1.1'
|
|
17
19
|
],
|
|
18
|
-
installCommand: (deps) =>
|
|
20
|
+
installCommand: (deps, { native } = { native: false }) => `${getBrewCommandSync({ native })} install ${deps}`,
|
|
19
21
|
packageManager: 'brew'
|
|
20
22
|
},
|
|
21
23
|
'Arch Linux': {
|
|
@@ -51,7 +53,12 @@ const dependenciesForPlatforms = {
|
|
|
51
53
|
'libsodium',
|
|
52
54
|
'libsodium-devel',
|
|
53
55
|
'libtool-ltdl-devel',
|
|
54
|
-
'oniguruma-devel'
|
|
56
|
+
'oniguruma-devel',
|
|
57
|
+
'libxml2-devel',
|
|
58
|
+
'bzip2-devel',
|
|
59
|
+
'curl-devel',
|
|
60
|
+
'libxslt-devel',
|
|
61
|
+
'autoconf'
|
|
55
62
|
],
|
|
56
63
|
installCommand: (deps) => `sudo yum install ${deps} -y`,
|
|
57
64
|
packageManager: 'yum'
|
|
@@ -68,7 +75,12 @@ const dependenciesForPlatforms = {
|
|
|
68
75
|
'libsodium',
|
|
69
76
|
'libsodium-devel',
|
|
70
77
|
'libtool-ltdl-devel',
|
|
71
|
-
'oniguruma-devel'
|
|
78
|
+
'oniguruma-devel',
|
|
79
|
+
'libxml2-devel',
|
|
80
|
+
'bzip2-devel',
|
|
81
|
+
'curl-devel',
|
|
82
|
+
'libxslt-devel',
|
|
83
|
+
'autoconf'
|
|
72
84
|
],
|
|
73
85
|
installCommand: (deps) => `sudo yum install --enablerepo=PowerTools ${deps} -y`,
|
|
74
86
|
packageManager: 'yum'
|
package/lib/config/docker.js
CHANGED
|
@@ -54,7 +54,7 @@ module.exports = async ({ configuration, ssl, host }, config) => {
|
|
|
54
54
|
name: `${ prefix }_nginx-data`,
|
|
55
55
|
opts: {
|
|
56
56
|
type: 'nfs',
|
|
57
|
-
device:
|
|
57
|
+
device: path.join(cacheDir, 'nginx', 'conf.d'),
|
|
58
58
|
o: 'bind'
|
|
59
59
|
}
|
|
60
60
|
};
|
|
@@ -62,7 +62,7 @@ module.exports = async ({ configuration, ssl, host }, config) => {
|
|
|
62
62
|
name: `${ prefix }_pub-data`,
|
|
63
63
|
opts: {
|
|
64
64
|
type: 'nfs',
|
|
65
|
-
device:
|
|
65
|
+
device: path.join(magentoDir, 'pub'),
|
|
66
66
|
o: 'bind'
|
|
67
67
|
}
|
|
68
68
|
};
|
|
@@ -70,7 +70,15 @@ module.exports = async ({ configuration, ssl, host }, config) => {
|
|
|
70
70
|
name: `${ prefix }_setup-data`,
|
|
71
71
|
opts: {
|
|
72
72
|
type: 'nfs',
|
|
73
|
-
device:
|
|
73
|
+
device: path.join(magentoDir, 'setup'),
|
|
74
|
+
o: 'bind'
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
volumes.sslTerminator = {
|
|
78
|
+
name: `${ prefix }_ssl-terminator-data`,
|
|
79
|
+
opts: {
|
|
80
|
+
type: 'nfs',
|
|
81
|
+
device: path.join(cacheDir, 'ssl-terminator', 'conf.d'),
|
|
74
82
|
o: 'bind'
|
|
75
83
|
}
|
|
76
84
|
};
|
|
@@ -80,7 +88,7 @@ module.exports = async ({ configuration, ssl, host }, config) => {
|
|
|
80
88
|
name: `${ prefix }_varnish-data`,
|
|
81
89
|
opts: {
|
|
82
90
|
type: 'nfs',
|
|
83
|
-
device:
|
|
91
|
+
device: path.join(cacheDir, 'varnish'),
|
|
84
92
|
o: 'bind'
|
|
85
93
|
}
|
|
86
94
|
};
|
|
@@ -89,6 +97,31 @@ module.exports = async ({ configuration, ssl, host }, config) => {
|
|
|
89
97
|
|
|
90
98
|
const getContainers = (ports = {}) => {
|
|
91
99
|
const dockerConfig = {
|
|
100
|
+
sslTerminator: {
|
|
101
|
+
_: 'SSL Terminator (Nginx)',
|
|
102
|
+
ports: isNotNativeLinux ? [
|
|
103
|
+
`${ isIpAddress(host) ? host : '127.0.0.1' }:${ ports.sslTerminator }:80`
|
|
104
|
+
] : [],
|
|
105
|
+
healthCheck: {
|
|
106
|
+
cmd: 'service nginx status'
|
|
107
|
+
},
|
|
108
|
+
/**
|
|
109
|
+
* Mount volumes directly on linux
|
|
110
|
+
*/
|
|
111
|
+
mountVolumes: [
|
|
112
|
+
`${ isLinux ? path.join(cacheDir, 'ssl-terminator', 'conf.d') : volumes.sslTerminator.name }:/etc/nginx/conf.d`
|
|
113
|
+
],
|
|
114
|
+
restart: 'on-failure:5',
|
|
115
|
+
// TODO: use connect instead
|
|
116
|
+
network: isNotNativeLinux ? network.name : 'host',
|
|
117
|
+
image: `nginx:${ nginx.version }`,
|
|
118
|
+
imageDetails: {
|
|
119
|
+
name: 'nginx',
|
|
120
|
+
tag: nginx.version
|
|
121
|
+
},
|
|
122
|
+
name: `${ prefix }_ssl-terminator`,
|
|
123
|
+
command: "nginx -g 'daemon off;'"
|
|
124
|
+
},
|
|
92
125
|
nginx: {
|
|
93
126
|
_: 'Nginx',
|
|
94
127
|
ports: isNotNativeLinux ? [
|
|
@@ -160,7 +193,8 @@ module.exports = async ({ configuration, ssl, host }, config) => {
|
|
|
160
193
|
command: [
|
|
161
194
|
'--log_bin_trust_function_creators=1',
|
|
162
195
|
'--default-authentication-plugin=mysql_native_password',
|
|
163
|
-
'--max_allowed_packet=1GB'
|
|
196
|
+
'--max_allowed_packet=1GB',
|
|
197
|
+
'--bind-address=0.0.0.0'
|
|
164
198
|
].join(' '),
|
|
165
199
|
securityOptions: [
|
|
166
200
|
'seccomp=unconfined'
|
|
@@ -192,9 +226,9 @@ module.exports = async ({ configuration, ssl, host }, config) => {
|
|
|
192
226
|
'xpack.ml.enabled': ['sse4.2', 'sse4_2'].some((sse42Flag) => cpuSupportedFlags.includes(sse42Flag))
|
|
193
227
|
},
|
|
194
228
|
network: network.name,
|
|
195
|
-
image: `
|
|
229
|
+
image: `elasticsearch:${ elasticsearch.version }`,
|
|
196
230
|
imageDetails: {
|
|
197
|
-
name: '
|
|
231
|
+
name: 'elasticsearch',
|
|
198
232
|
tag: elasticsearch.version
|
|
199
233
|
},
|
|
200
234
|
name: `${ prefix }_elasticsearch`
|
|
@@ -216,10 +250,8 @@ module.exports = async ({ configuration, ssl, host }, config) => {
|
|
|
216
250
|
tag: varnish.version
|
|
217
251
|
},
|
|
218
252
|
name: `${ prefix }_varnish`,
|
|
219
|
-
mountVolumes:
|
|
220
|
-
`${ path.join(cacheDir, 'varnish') }:/etc/varnish`
|
|
221
|
-
] : [
|
|
222
|
-
`${ volumes.varnish.name }:/etc/varnish`
|
|
253
|
+
mountVolumes: [
|
|
254
|
+
`${ isLinux ? path.join(cacheDir, 'varnish') : volumes.varnish.name }:/etc/varnish`
|
|
223
255
|
],
|
|
224
256
|
ports: isNotNativeLinux ? [
|
|
225
257
|
`${ isIpAddress(host) ? host : '127.0.0.1' }:${ ports.varnish }:80`
|
|
@@ -229,7 +261,8 @@ module.exports = async ({ configuration, ssl, host }, config) => {
|
|
|
229
261
|
},
|
|
230
262
|
restart: 'on-failure:30',
|
|
231
263
|
network: isNotNativeLinux ? network.name : 'host',
|
|
232
|
-
|
|
264
|
+
// eslint-disable-next-line max-len
|
|
265
|
+
command: `/bin/bash -c "varnishd -a :${ isNotNativeLinux ? 80 : ports.varnish } -t 600 -f /etc/varnish/default.vcl -s malloc,512m && varnishlog"`,
|
|
233
266
|
tmpfs: [
|
|
234
267
|
'/var/lib/varnish:exec'
|
|
235
268
|
]
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const fs = require('fs');
|
|
2
2
|
const path = require('path');
|
|
3
3
|
const { baseConfig } = require('.');
|
|
4
|
+
const KnownError = require('../errors/known-error');
|
|
4
5
|
const pathExists = require('../util/path-exists');
|
|
5
6
|
const {
|
|
6
7
|
getPort,
|
|
@@ -26,6 +27,10 @@ const getAvailablePorts = () => ({
|
|
|
26
27
|
'utf-8'
|
|
27
28
|
)
|
|
28
29
|
);
|
|
30
|
+
if (!ports.sslTerminator) {
|
|
31
|
+
ports.sslTerminator = ports.app;
|
|
32
|
+
ports.app = defaultPorts.app;
|
|
33
|
+
}
|
|
29
34
|
}
|
|
30
35
|
const {
|
|
31
36
|
systemConfiguration: {
|
|
@@ -39,9 +44,9 @@ const getAvailablePorts = () => ({
|
|
|
39
44
|
if (ctx.port) {
|
|
40
45
|
const isPortAvailable = (await getPort(ctx.port)) === ctx.port;
|
|
41
46
|
if (!isPortAvailable) {
|
|
42
|
-
throw new
|
|
47
|
+
throw new KnownError(`Port ${ctx.port} is not available`);
|
|
43
48
|
} else {
|
|
44
|
-
availablePorts.
|
|
49
|
+
availablePorts.sslTerminator = ctx.port;
|
|
45
50
|
}
|
|
46
51
|
}
|
|
47
52
|
|
package/lib/config/index.js
CHANGED
|
@@ -10,6 +10,7 @@ const { getMagentoConfig } = require('./magento-config');
|
|
|
10
10
|
const { getPhpStormConfig } = require('./phpstorm/debug-config');
|
|
11
11
|
const resolveConfigurationWithOverrides = require('../util/resolve-configuration-with-overrides');
|
|
12
12
|
const { getPrefix, folderName } = require('../util/prefix');
|
|
13
|
+
const UnknownError = require('../errors/unknown-error');
|
|
13
14
|
|
|
14
15
|
const platforms = ['linux', 'darwin'];
|
|
15
16
|
const darwinMinimalVersion = '10.5';
|
|
@@ -38,7 +39,7 @@ module.exports = {
|
|
|
38
39
|
const newBaseConfig = getBaseConfig(projectPath, prefix);
|
|
39
40
|
const configurations = getConfigurations(newBaseConfig);
|
|
40
41
|
if (!configurations[magentoVersion]) {
|
|
41
|
-
throw new
|
|
42
|
+
throw new UnknownError(`No config found for magento version ${magentoVersion}`);
|
|
42
43
|
}
|
|
43
44
|
|
|
44
45
|
const {
|
|
@@ -2,6 +2,7 @@ const path = require('path');
|
|
|
2
2
|
const fs = require('fs');
|
|
3
3
|
const os = require('os');
|
|
4
4
|
const pathExists = require('../../../util/path-exists');
|
|
5
|
+
const UnknownError = require('../../../errors/unknown-error');
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* @type {import('../../../../typings/index').PHPExtension}
|
|
@@ -21,7 +22,7 @@ module.exports = {
|
|
|
21
22
|
);
|
|
22
23
|
|
|
23
24
|
if (!await pathExists(sodiumDynamicLibraryPath)) {
|
|
24
|
-
throw new
|
|
25
|
+
throw new UnknownError(`libsodium dynamic library file configuration not found: ${sodiumDynamicLibraryPath}`);
|
|
25
26
|
}
|
|
26
27
|
const fileContent = await fs.promises.readFile(sodiumDynamicLibraryPath, 'utf-8');
|
|
27
28
|
|
|
@@ -4,6 +4,8 @@ const fs = require('fs');
|
|
|
4
4
|
const pathExists = require('../util/path-exists');
|
|
5
5
|
const { systemConfigurationSchema } = require('../util/config-file-validator');
|
|
6
6
|
const { deepmerge } = require('../util/deepmerge');
|
|
7
|
+
const pathExistsSync = require('../util/path-exists-sync');
|
|
8
|
+
const KnownError = require('../errors/known-error');
|
|
7
9
|
|
|
8
10
|
const defaultSystemConfig = {
|
|
9
11
|
analytics: true,
|
|
@@ -14,19 +16,45 @@ const systemConfigPath = path.join(os.homedir(), '.cmarc');
|
|
|
14
16
|
/**
|
|
15
17
|
* @returns {Promise<typeof defaultSystemConfig>}
|
|
16
18
|
*/
|
|
17
|
-
const getSystemConfig = async () => {
|
|
19
|
+
const getSystemConfig = async ({ validate = true } = {}) => {
|
|
18
20
|
if (await pathExists(systemConfigPath)) {
|
|
19
21
|
const userSystemConfig = await fs.promises.readFile(systemConfigPath, 'utf-8');
|
|
20
22
|
let userSystemConfigParsed;
|
|
21
23
|
try {
|
|
22
24
|
userSystemConfigParsed = JSON.parse(userSystemConfig);
|
|
23
25
|
} catch (e) {
|
|
24
|
-
throw new
|
|
26
|
+
throw new KnownError(`System configuration file is not a valid JSON!\n\nFile location: ${systemConfigPath}`);
|
|
25
27
|
}
|
|
28
|
+
|
|
29
|
+
if (validate) {
|
|
30
|
+
try {
|
|
31
|
+
await systemConfigurationSchema.validateAsync(userSystemConfigParsed);
|
|
32
|
+
} catch (e) {
|
|
33
|
+
throw new KnownError(`Configuration file validation error!\n\n${e.message}`);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return deepmerge(defaultSystemConfig, userSystemConfigParsed);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return defaultSystemConfig;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const getSystemConfigSync = ({ validate = true } = {}) => {
|
|
44
|
+
if (pathExistsSync(systemConfigPath)) {
|
|
45
|
+
const userSystemConfig = fs.readFileSync(systemConfigPath, { encoding: 'utf-8' });
|
|
46
|
+
let userSystemConfigParsed;
|
|
26
47
|
try {
|
|
27
|
-
|
|
48
|
+
userSystemConfigParsed = JSON.parse(userSystemConfig);
|
|
28
49
|
} catch (e) {
|
|
29
|
-
throw new
|
|
50
|
+
throw new KnownError(`System configuration file is not a valid JSON!\n\nFile location: ${systemConfigPath}`);
|
|
51
|
+
}
|
|
52
|
+
if (validate) {
|
|
53
|
+
try {
|
|
54
|
+
systemConfigurationSchema.validate(userSystemConfigParsed);
|
|
55
|
+
} catch (e) {
|
|
56
|
+
throw new KnownError(`Configuration file validation error!\n\n${e.message}`);
|
|
57
|
+
}
|
|
30
58
|
}
|
|
31
59
|
|
|
32
60
|
return deepmerge(defaultSystemConfig, userSystemConfigParsed);
|
|
@@ -48,5 +76,6 @@ const getSystemConfigTask = () => ({
|
|
|
48
76
|
module.exports = {
|
|
49
77
|
defaultSystemConfig,
|
|
50
78
|
getSystemConfigTask,
|
|
51
|
-
getSystemConfig
|
|
79
|
+
getSystemConfig,
|
|
80
|
+
getSystemConfigSync
|
|
52
81
|
};
|
|
@@ -6,5 +6,7 @@ alias c="composer"
|
|
|
6
6
|
<% if (it.varnishEnabled) { %>
|
|
7
7
|
alias cvc="npm run exec varnish varnishadm ban req.url '~ /' && echo 'Varnish cache cleared!'"
|
|
8
8
|
<% } %>
|
|
9
|
+
alias mysql="npm run exec mysql 'mysql -umagento -pmagento'"
|
|
10
|
+
alias mysqlroot="npm run exec mysql 'mysql -uroot -pscandipwa'"
|
|
9
11
|
|
|
10
12
|
export BASH_SILENCE_DEPRECATION_WARNING=1
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
real_ip_header X-Forwarded-For;
|
|
2
|
-
set_real_ip_from 10.0.0.0/8;
|
|
3
|
-
set_real_ip_from 172.0.0.0/8;
|
|
4
|
-
real_ip_recursive on;
|
|
5
|
-
|
|
6
1
|
upstream fastcgi_backend {
|
|
7
2
|
# use tcp connection
|
|
8
3
|
server <%= it.hostMachine %>:<%= it.ports.fpm %>;
|
|
@@ -10,16 +5,7 @@ upstream fastcgi_backend {
|
|
|
10
5
|
|
|
11
6
|
server {
|
|
12
7
|
listen <%= it.hostPort %>;
|
|
13
|
-
<% if (it.config.ssl.enabled) { %>listen 443 ssl;<% } %>
|
|
14
|
-
|
|
15
|
-
<% if (it.config.ssl.enabled) { %>server_name <%= it.networkToBindTo %>;
|
|
16
|
-
|
|
17
|
-
ssl_certificate /etc/nginx/conf.d/ssl_certificate.pem;
|
|
18
|
-
ssl_certificate_key /etc/nginx/conf.d/ssl_certificate-key.pem;
|
|
19
|
-
ssl_protocols TLSv1.2;<% } else if (it.config.host) { %>server_name <%= it.config.host %>;
|
|
20
|
-
<% } else { %>
|
|
21
8
|
server_name _;
|
|
22
|
-
<% } %>
|
|
23
9
|
|
|
24
10
|
set $MAGE_ROOT <%= it.mageRoot %>;
|
|
25
11
|
resolver 127.0.0.11;
|
|
@@ -39,16 +25,6 @@ server {
|
|
|
39
25
|
}
|
|
40
26
|
|
|
41
27
|
location / {
|
|
42
|
-
# proxy_set_header X-Real-IP $remote_addr;
|
|
43
|
-
# proxy_set_header X-Forwarded-For $remote_addr;
|
|
44
|
-
# proxy_set_header Host $http_host;
|
|
45
|
-
|
|
46
|
-
# if ($request_method = PURGE) {
|
|
47
|
-
# rewrite ^/(.*)$ $1 break;
|
|
48
|
-
# proxy_pass http://<%= it.hostMachine %>:<%= it.ports.varnish %>/;
|
|
49
|
-
# break;
|
|
50
|
-
# }
|
|
51
|
-
|
|
52
28
|
try_files $uri $uri/ /index.php$is_args$args;
|
|
53
29
|
}
|
|
54
30
|
|
|
@@ -222,11 +198,4 @@ server {
|
|
|
222
198
|
location @webp-to-jpg {
|
|
223
199
|
rewrite ^(.*)\.webp$ $1.jpg last;
|
|
224
200
|
}
|
|
225
|
-
|
|
226
|
-
# location @purgepass {
|
|
227
|
-
# # some other configuration
|
|
228
|
-
# proxy_pass http://<%= it.hostMachine %>:<%= it.ports.varnish %>;
|
|
229
|
-
# proxy_set_header Host $host;
|
|
230
|
-
# proxy_set_header X-Real-IP $remote_addr;
|
|
231
|
-
# }
|
|
232
201
|
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
real_ip_header X-Forwarded-For;
|
|
2
|
+
set_real_ip_from 10.0.0.0/8;
|
|
3
|
+
set_real_ip_from 172.0.0.0/8;
|
|
4
|
+
real_ip_recursive on;
|
|
5
|
+
|
|
6
|
+
server {
|
|
7
|
+
listen <%= it.hostPort %>;
|
|
8
|
+
<% if (it.config.ssl.enabled) { %> listen 443 ssl;
|
|
9
|
+
server_name <%= it.networkToBindTo %>;
|
|
10
|
+
|
|
11
|
+
ssl_certificate /etc/nginx/conf.d/ssl_certificate.pem;
|
|
12
|
+
ssl_certificate_key /etc/nginx/conf.d/ssl_certificate-key.pem;
|
|
13
|
+
ssl_protocols TLSv1.2;<% } %>
|
|
14
|
+
|
|
15
|
+
server_name <% if (it.config.host) { %><%= it.config.host %><% } else { %>_<% } %>;
|
|
16
|
+
|
|
17
|
+
location / {
|
|
18
|
+
proxy_buffer_size 128k;
|
|
19
|
+
proxy_buffers 4 256k;
|
|
20
|
+
proxy_busy_buffers_size 256k;
|
|
21
|
+
proxy_set_header X-Real-IP $remote_addr;
|
|
22
|
+
proxy_set_header X-Forwarded-For $remote_addr;
|
|
23
|
+
proxy_set_header Host $http_host;
|
|
24
|
+
|
|
25
|
+
proxy_pass http://<%= it.hostMachine %>:<% if (it.config.configuration.varnish.enabled) { %><%= it.ports.varnish %><% } else { %><%= it.ports.app %><% } %>;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -81,6 +81,11 @@ sub vcl_recv {
|
|
|
81
81
|
return (pass);
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
+
# Bypass frontend static file caching
|
|
85
|
+
if (req.url ~ "^/static/frontend") {
|
|
86
|
+
return (pass);
|
|
87
|
+
}
|
|
88
|
+
|
|
84
89
|
# Set initial grace period usage status
|
|
85
90
|
set req.http.grace = "none";
|
|
86
91
|
|
|
@@ -114,12 +119,12 @@ sub vcl_recv {
|
|
|
114
119
|
# Static files caching
|
|
115
120
|
if (req.url ~ "^/(pub/)?(media|static)/") {
|
|
116
121
|
# Static files should not be cached by default
|
|
117
|
-
return (pass);
|
|
122
|
+
# return (pass);
|
|
118
123
|
|
|
119
124
|
# But if you use a few locales and don't use CDN you can enable caching static files by commenting previous line (#return (pass);) and uncommenting next 3 lines
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
125
|
+
unset req.http.Https;
|
|
126
|
+
unset req.http.X-Forwarded-Proto;
|
|
127
|
+
unset req.http.Cookie;
|
|
123
128
|
}
|
|
124
129
|
|
|
125
130
|
# Authenticated GraphQL requests should not be cached by default
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
2
|
const { defaultMagentoConfig } = require('../magento-config');
|
|
3
|
+
const { sslTerminator } = require('../ssl-terminator');
|
|
3
4
|
const { varnish66 } = require('../varnish/varnish-6-6');
|
|
4
5
|
|
|
5
6
|
module.exports = ({ templateDir } = {}) => ({
|
|
@@ -45,7 +46,8 @@ module.exports = ({ templateDir } = {}) => ({
|
|
|
45
46
|
composer: {
|
|
46
47
|
version: '1'
|
|
47
48
|
},
|
|
48
|
-
varnish: varnish66({ templateDir })
|
|
49
|
+
varnish: varnish66({ templateDir }),
|
|
50
|
+
sslTerminator: sslTerminator({ templateDir })
|
|
49
51
|
},
|
|
50
52
|
magento: defaultMagentoConfig,
|
|
51
53
|
host: 'localhost',
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
2
|
const { defaultMagentoConfig } = require('../magento-config');
|
|
3
|
+
const { sslTerminator } = require('../ssl-terminator');
|
|
3
4
|
const { varnish66 } = require('../varnish/varnish-6-6');
|
|
4
5
|
|
|
5
6
|
module.exports = ({ templateDir } = {}) => ({
|
|
@@ -45,7 +46,8 @@ module.exports = ({ templateDir } = {}) => ({
|
|
|
45
46
|
composer: {
|
|
46
47
|
version: '1'
|
|
47
48
|
},
|
|
48
|
-
varnish: varnish66({ templateDir })
|
|
49
|
+
varnish: varnish66({ templateDir }),
|
|
50
|
+
sslTerminator: sslTerminator({ templateDir })
|
|
49
51
|
},
|
|
50
52
|
magento: defaultMagentoConfig,
|
|
51
53
|
host: 'localhost',
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
2
|
const { defaultMagentoConfig } = require('../magento-config');
|
|
3
|
+
const { sslTerminator } = require('../ssl-terminator');
|
|
3
4
|
const { varnish66 } = require('../varnish/varnish-6-6');
|
|
4
5
|
|
|
5
6
|
module.exports = ({ templateDir } = {}) => ({
|
|
@@ -45,7 +46,8 @@ module.exports = ({ templateDir } = {}) => ({
|
|
|
45
46
|
composer: {
|
|
46
47
|
version: '1'
|
|
47
48
|
},
|
|
48
|
-
varnish: varnish66({ templateDir })
|
|
49
|
+
varnish: varnish66({ templateDir }),
|
|
50
|
+
sslTerminator: sslTerminator({ templateDir })
|
|
49
51
|
},
|
|
50
52
|
magento: defaultMagentoConfig,
|
|
51
53
|
host: 'localhost',
|