@scandipwa/magento-scripts 1.14.1-alpha.9 → 1.15.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +4 -3
- package/lib/config/get-port-config.js +2 -1
- package/lib/config/index.js +2 -1
- package/lib/config/php/extensions/libsodium.js +2 -1
- package/lib/config/scandipwa-versions.js +2 -1
- package/lib/config/system-config.js +34 -5
- package/lib/config/templates/magentorc.template +2 -0
- package/lib/config/templates/varnish.template.vcl +9 -4
- 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 +2 -1
- 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 +5 -3
- package/lib/tasks/file-system/create-varnish-config.js +2 -23
- package/lib/tasks/file-system/create-vscode-config.js +3 -2
- package/lib/tasks/file-system/index.js +1 -1
- package/lib/tasks/magento/enable-magento-composer-plugins.js +3 -2
- package/lib/tasks/magento/install-magento.js +15 -13
- 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/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 +2 -1
- 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 +9 -2
- 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/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
|
@@ -193,7 +193,8 @@ module.exports = async ({ configuration, ssl, host }, config) => {
|
|
|
193
193
|
command: [
|
|
194
194
|
'--log_bin_trust_function_creators=1',
|
|
195
195
|
'--default-authentication-plugin=mysql_native_password',
|
|
196
|
-
'--max_allowed_packet=1GB'
|
|
196
|
+
'--max_allowed_packet=1GB',
|
|
197
|
+
'--bind-address=0.0.0.0'
|
|
197
198
|
].join(' '),
|
|
198
199
|
securityOptions: [
|
|
199
200
|
'seccomp=unconfined'
|
|
@@ -225,9 +226,9 @@ module.exports = async ({ configuration, ssl, host }, config) => {
|
|
|
225
226
|
'xpack.ml.enabled': ['sse4.2', 'sse4_2'].some((sse42Flag) => cpuSupportedFlags.includes(sse42Flag))
|
|
226
227
|
},
|
|
227
228
|
network: network.name,
|
|
228
|
-
image: `
|
|
229
|
+
image: `elasticsearch:${ elasticsearch.version }`,
|
|
229
230
|
imageDetails: {
|
|
230
|
-
name: '
|
|
231
|
+
name: 'elasticsearch',
|
|
231
232
|
tag: elasticsearch.version
|
|
232
233
|
},
|
|
233
234
|
name: `${ prefix }_elasticsearch`
|
|
@@ -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,
|
|
@@ -43,7 +44,7 @@ const getAvailablePorts = () => ({
|
|
|
43
44
|
if (ctx.port) {
|
|
44
45
|
const isPortAvailable = (await getPort(ctx.port)) === ctx.port;
|
|
45
46
|
if (!isPortAvailable) {
|
|
46
|
-
throw new
|
|
47
|
+
throw new KnownError(`Port ${ctx.port} is not available`);
|
|
47
48
|
} else {
|
|
48
49
|
availablePorts.sslTerminator = ctx.port;
|
|
49
50
|
}
|
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
|
|
@@ -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
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
const { XMLParser, XMLBuilder } = require('fast-xml-parser');
|
|
2
|
+
const fs = require('fs');
|
|
3
|
+
const path = require('path');
|
|
4
|
+
const pathExists = require('../util/path-exists');
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @type {import('fast-xml-parser').X2jOptions}
|
|
8
|
+
*/
|
|
9
|
+
const xmlParserConfig = {
|
|
10
|
+
ignoreAttributes: false,
|
|
11
|
+
parseAttributeValue: false,
|
|
12
|
+
trimValues: true,
|
|
13
|
+
allowBooleanAttributes: true,
|
|
14
|
+
cdataPropName: '_cdata'
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @type {Partial<import('fast-xml-parser').XmlBuilderOptions>}
|
|
19
|
+
*/
|
|
20
|
+
const xmlBuilderConfig = {
|
|
21
|
+
...xmlParserConfig,
|
|
22
|
+
format: true,
|
|
23
|
+
suppressEmptyNode: true,
|
|
24
|
+
suppressBooleanAttributes: false,
|
|
25
|
+
processEntities: true
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const parser = new XMLParser(xmlParserConfig);
|
|
29
|
+
const builder = new XMLBuilder(xmlBuilderConfig);
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Load xml file to js object
|
|
33
|
+
* @param {String} filePath
|
|
34
|
+
*/
|
|
35
|
+
const loadXmlFile = async (filePath) => {
|
|
36
|
+
const fileData = await fs.promises.readFile(filePath, 'utf-8');
|
|
37
|
+
|
|
38
|
+
return parser.parse(fileData);
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Build xml from js object and write it to file
|
|
43
|
+
* @param {String} filePath
|
|
44
|
+
* @param {String} fileData
|
|
45
|
+
*/
|
|
46
|
+
const buildXmlFile = async (filePath, fileData) => {
|
|
47
|
+
const xmlFileData = builder.build(fileData).replace(/"/ig, '"');
|
|
48
|
+
|
|
49
|
+
const { dir } = path.parse(filePath);
|
|
50
|
+
|
|
51
|
+
if (!await pathExists(dir)) {
|
|
52
|
+
await fs.promises.mkdir(dir, {
|
|
53
|
+
recursive: true
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
await fs.promises.writeFile(filePath, xmlFileData, 'utf-8');
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
module.exports = {
|
|
61
|
+
loadXmlFile,
|
|
62
|
+
buildXmlFile
|
|
63
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
class KnownError extends Error {
|
|
2
|
+
/**
|
|
3
|
+
* @param {String} message Error message
|
|
4
|
+
* @param {String} [name] Error name
|
|
5
|
+
* @param {{ reportToAnalytics?: boolean }} [param2]
|
|
6
|
+
*/
|
|
7
|
+
constructor(message, name = 'Known Error', { reportToAnalytics = true } = {}) {
|
|
8
|
+
super(message);
|
|
9
|
+
this.name = name;
|
|
10
|
+
|
|
11
|
+
this.reportToAnalytics = reportToAnalytics;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
module.exports = KnownError;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
class UnknownError extends Error {
|
|
2
|
+
/**
|
|
3
|
+
* @param {String} message Error message
|
|
4
|
+
* @param {String} [name] Error name
|
|
5
|
+
* @param {{ reportToAnalytics?: boolean }} [param2]
|
|
6
|
+
*/
|
|
7
|
+
constructor(message, name = 'Unknown Error', { reportToAnalytics = true } = {}) {
|
|
8
|
+
super(message);
|
|
9
|
+
this.name = name;
|
|
10
|
+
|
|
11
|
+
this.reportToAnalytics = reportToAnalytics;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
module.exports = UnknownError;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
|
+
const UnknownError = require('../../errors/unknown-error');
|
|
2
3
|
const setConfigFile = require('../../util/set-config');
|
|
3
4
|
|
|
4
5
|
/**
|
|
@@ -20,7 +21,7 @@ const createBashrcConfigFile = () => ({
|
|
|
20
21
|
}
|
|
21
22
|
});
|
|
22
23
|
} catch (e) {
|
|
23
|
-
throw new
|
|
24
|
+
throw new UnknownError(`Unexpected error accrued during php.ini config creation\n\n${e}`);
|
|
24
25
|
}
|
|
25
26
|
}
|
|
26
27
|
});
|
|
@@ -7,6 +7,8 @@ const { execAsyncSpawn } = require('../../util/exec-async-command');
|
|
|
7
7
|
const pathExists = require('../../util/path-exists');
|
|
8
8
|
const safeRegexExtract = require('../../util/safe-regex-extract');
|
|
9
9
|
const installPrestissimo = require('./install-prestissimo');
|
|
10
|
+
const UnknownError = require('../../errors/unknown-error');
|
|
11
|
+
const KnownError = require('../../errors/known-error');
|
|
10
12
|
|
|
11
13
|
/**
|
|
12
14
|
* @param {import('../../../typings/context').ListrContext['config']} param0
|
|
@@ -19,7 +21,7 @@ const getComposerVersion = async ({ composer, php }) => {
|
|
|
19
21
|
string: composerVersionOutput,
|
|
20
22
|
regex: /composer.+(\d+\.\d+\.\d+)/i,
|
|
21
23
|
onNoMatch: () => {
|
|
22
|
-
throw new
|
|
24
|
+
throw new UnknownError(`
|
|
23
25
|
No composer version found in composer version output!\n\n${composerVersionOutput}
|
|
24
26
|
|
|
25
27
|
Follow steps below to resolve this issue:
|
|
@@ -56,7 +58,7 @@ const downloadComposerBinary = async ({ composer }) => {
|
|
|
56
58
|
destination: composer.binPath
|
|
57
59
|
});
|
|
58
60
|
} catch (e) {
|
|
59
|
-
throw new
|
|
61
|
+
throw new UnknownError(
|
|
60
62
|
`Unexpected issue, while installing composer.
|
|
61
63
|
Please see the error log below.\n\n${e}`
|
|
62
64
|
);
|
|
@@ -108,7 +110,7 @@ const installComposer = () => ({
|
|
|
108
110
|
break;
|
|
109
111
|
}
|
|
110
112
|
case 'exit': {
|
|
111
|
-
throw new
|
|
113
|
+
throw new KnownError(`Current composer version ${logger.style.misc(`v${currentComposerVersion}`)} is not compatible with version ${logger.style.misc(expectedComposerVersion)}!`);
|
|
112
114
|
}
|
|
113
115
|
case 'continue':
|
|
114
116
|
default: {
|
|
@@ -2,25 +2,29 @@ const path = require('path');
|
|
|
2
2
|
const fs = require('fs');
|
|
3
3
|
const pathExists = require('../../util/path-exists');
|
|
4
4
|
const logger = require('@scandipwa/scandipwa-dev-utils/logger');
|
|
5
|
+
const UnknownError = require('../../errors/unknown-error');
|
|
6
|
+
const KnownError = require('../../errors/known-error');
|
|
7
|
+
|
|
8
|
+
const authJsonPath = path.join(process.cwd(), 'auth.json');
|
|
5
9
|
|
|
6
10
|
/**
|
|
7
11
|
* @type {() => import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
|
|
8
12
|
*/
|
|
9
13
|
const localAuthJson = () => ({
|
|
10
14
|
task: async (ctx, task) => {
|
|
11
|
-
if (await pathExists(
|
|
15
|
+
if (await pathExists(authJsonPath)) {
|
|
12
16
|
task.title = 'Using local auth.json';
|
|
13
|
-
const localAuthJson = await fs.promises.readFile(
|
|
17
|
+
const localAuthJson = await fs.promises.readFile(authJsonPath);
|
|
14
18
|
|
|
15
19
|
let localAuthJsonContent;
|
|
16
20
|
try {
|
|
17
21
|
localAuthJsonContent = JSON.parse(localAuthJson);
|
|
18
22
|
} catch (e) {
|
|
19
|
-
throw new
|
|
23
|
+
throw new UnknownError(`Could not parse ./auth.json file as JSON!\n\n${e}`);
|
|
20
24
|
}
|
|
21
25
|
|
|
22
26
|
if (!localAuthJsonContent || !localAuthJsonContent['http-basic'] || !localAuthJsonContent['http-basic']['repo.magento.com']) {
|
|
23
|
-
throw new
|
|
27
|
+
throw new KnownError(`Your ./auth.json file does not contain the ${ logger.style.misc("{ 'http-basic': { 'repo.magento.com': <> } }") } field.`);
|
|
24
28
|
}
|
|
25
29
|
|
|
26
30
|
process.env.COMPOSER_AUTH = localAuthJson;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const logger = require('@scandipwa/scandipwa-dev-utils/logger');
|
|
2
|
+
const KnownError = require('../../errors/known-error');
|
|
2
3
|
const { execAsyncSpawn } = require('../../util/exec-async-command');
|
|
3
4
|
|
|
4
5
|
/**
|
|
@@ -29,7 +30,7 @@ Do you want remove all custom networks not used by at least one container?`
|
|
|
29
30
|
);
|
|
30
31
|
}
|
|
31
32
|
|
|
32
|
-
throw new
|
|
33
|
+
throw new KnownError(`Unable to create network for your project.
|
|
33
34
|
You need to delete unused networks yourself.
|
|
34
35
|
Use command ${logger.style.command('docker network prune')}`);
|
|
35
36
|
}
|
|
@@ -10,9 +10,8 @@ const executeInContainer = ({ containerName, commands }) => {
|
|
|
10
10
|
spawn('docker', [
|
|
11
11
|
'exec',
|
|
12
12
|
'-it',
|
|
13
|
-
containerName
|
|
14
|
-
|
|
15
|
-
], {
|
|
13
|
+
containerName
|
|
14
|
+
].concat(...commands.map((command) => command.split(' '))), {
|
|
16
15
|
stdio: [0, 1, 2]
|
|
17
16
|
});
|
|
18
17
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const os = require('os');
|
|
2
2
|
const path = require('path');
|
|
3
3
|
const setConfigFile = require('../../util/set-config');
|
|
4
|
+
const UnknownError = require('../../errors/unknown-error');
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* @type {() => import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
|
|
@@ -47,7 +48,7 @@ const createNginxConfig = () => ({
|
|
|
47
48
|
}
|
|
48
49
|
});
|
|
49
50
|
} catch (e) {
|
|
50
|
-
throw new
|
|
51
|
+
throw new UnknownError(`Unexpected error accrued during nginx config creation\n\n${e}`);
|
|
51
52
|
}
|
|
52
53
|
}
|
|
53
54
|
});
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const semver = require('semver');
|
|
2
|
+
const UnknownError = require('../../errors/unknown-error');
|
|
2
3
|
const setConfigFile = require('../../util/set-config');
|
|
3
4
|
|
|
4
5
|
/**
|
|
@@ -21,7 +22,7 @@ const createPhpConfig = () => ({
|
|
|
21
22
|
}
|
|
22
23
|
});
|
|
23
24
|
} catch (e) {
|
|
24
|
-
throw new
|
|
25
|
+
throw new UnknownError(`Unexpected error accrued during php.ini config creation\n\n${e}`);
|
|
25
26
|
}
|
|
26
27
|
}
|
|
27
28
|
});
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
|
+
const UnknownError = require('../../errors/unknown-error');
|
|
2
3
|
const setConfigFile = require('../../util/set-config');
|
|
3
4
|
|
|
4
5
|
/**
|
|
@@ -17,7 +18,7 @@ const createPhpFpmConfig = () => ({
|
|
|
17
18
|
}
|
|
18
19
|
});
|
|
19
20
|
} catch (e) {
|
|
20
|
-
throw new
|
|
21
|
+
throw new UnknownError(`Unexpected error accrued during php-fpm config creation\n\n${e}`);
|
|
21
22
|
}
|
|
22
23
|
}
|
|
23
24
|
});
|