@scandipwa/magento-scripts 1.14.1-alpha.1 → 1.14.1-alpha.12
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/index.js +13 -0
- package/lib/commands/cli.js +28 -1
- package/lib/commands/execute.js +2 -1
- package/lib/commands/logs.js +1 -0
- package/lib/commands/start.js +18 -5
- package/lib/config/cma-config.js +16 -0
- package/lib/config/dependencies-for-platforms.js +15 -3
- package/lib/config/docker.js +89 -15
- package/lib/config/get-port-config.js +9 -3
- package/lib/config/index.js +2 -1
- package/lib/config/php/extensions/libsodium.js +2 -1
- package/lib/config/port-config.js +3 -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 +3 -5
- package/lib/config/templates/nginx.template.conf +0 -14
- package/lib/config/templates/php.template.ini +6 -4
- package/lib/config/templates/ssl-terminator.template.conf +27 -0
- package/lib/config/templates/varnish.template.vcl +255 -0
- package/lib/config/varnish/varnish-6-0.js +11 -0
- package/lib/config/varnish/varnish-6-6.js +11 -0
- package/lib/config/varnish/varnish-7-0.js +11 -0
- package/lib/config/versions/magento-2.3.0.js +9 -1
- package/lib/config/versions/magento-2.3.1.js +9 -1
- package/lib/config/versions/magento-2.3.2-p2.js +9 -1
- package/lib/config/versions/magento-2.3.2.js +9 -1
- package/lib/config/versions/magento-2.3.3-p1.js +9 -1
- package/lib/config/versions/magento-2.3.3.js +9 -1
- package/lib/config/versions/magento-2.3.4-p2.js +9 -1
- package/lib/config/versions/magento-2.3.4.js +9 -1
- package/lib/config/versions/magento-2.3.5-p1.js +9 -1
- package/lib/config/versions/magento-2.3.5-p2.js +9 -1
- package/lib/config/versions/magento-2.3.5.js +9 -1
- package/lib/config/versions/magento-2.3.6-p1.js +9 -1
- package/lib/config/versions/magento-2.3.6.js +9 -1
- package/lib/config/versions/magento-2.3.7-p1.js +9 -1
- package/lib/config/versions/magento-2.3.7-p2.js +9 -1
- package/lib/config/versions/magento-2.3.7-p3.js +9 -1
- package/lib/config/versions/magento-2.3.7.js +9 -1
- package/lib/config/versions/magento-2.4.0-p1.js +9 -1
- package/lib/config/versions/magento-2.4.0.js +9 -1
- package/lib/config/versions/magento-2.4.1-p1.js +9 -1
- package/lib/config/versions/magento-2.4.1.js +9 -1
- package/lib/config/versions/magento-2.4.2-p1.js +9 -1
- package/lib/config/versions/magento-2.4.2-p2.js +9 -1
- package/lib/config/versions/magento-2.4.2.js +9 -1
- package/lib/config/versions/magento-2.4.3-p1.js +9 -1
- package/lib/config/versions/magento-2.4.3-p2.js +9 -1
- package/lib/config/versions/magento-2.4.3.js +9 -1
- package/lib/config/versions/magento-2.4.4.js +9 -1
- package/lib/config/xml-parser.js +5 -3
- package/lib/errors/known-error.js +15 -0
- package/lib/errors/unknown-error.js +15 -0
- package/lib/tasks/cli/create-bashrc-config.js +7 -3
- package/lib/tasks/composer/index.js +5 -3
- package/lib/tasks/composer/local-auth-json.js +4 -2
- package/lib/tasks/docker/containers.js +13 -8
- package/lib/tasks/docker/network.js +2 -1
- package/lib/tasks/docker/volumes.js +4 -4
- package/lib/tasks/file-system/create-nginx-config.js +9 -40
- 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 +5 -4
- package/lib/tasks/file-system/create-phpstorm-config/eslint-config.js +12 -10
- package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/coding-standard-config.js +0 -3
- package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/custom-ruleset-path-config.js +0 -3
- package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/default-properties-config.js +1 -1
- package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/magento-coding-standard-config.js +0 -3
- package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/mess-detector-validation-inspection-config.js +0 -3
- package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/php-cs-validation-inspection-config.js +1 -4
- package/lib/tasks/file-system/create-phpstorm-config/php-config/mess-detector-config.js +1 -4
- package/lib/tasks/file-system/create-phpstorm-config/php-config/php-code-sniffer-config.js +1 -11
- package/lib/tasks/file-system/create-phpstorm-config/php-config/php-cs-fixer-config.js +1 -6
- package/lib/tasks/file-system/create-phpstorm-config/php-config/php-project-shared-configuration-config.js +1 -11
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/composer-settings-config.js +2 -3
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/php-server-config.js +1 -4
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/properties-component-config.js +2 -4
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/run-manager-config.js +1 -11
- package/lib/tasks/file-system/create-ssl-terminator-config.js +96 -0
- package/lib/tasks/file-system/create-varnish-config.js +53 -0
- package/lib/tasks/file-system/create-vscode-config.js +3 -2
- package/lib/tasks/file-system/index.js +5 -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/configure-elasticsearch.js +1 -1
- 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/disable-2fa.js +4 -12
- package/lib/tasks/magento/setup-magento/flush-redis-config.js +2 -1
- package/lib/tasks/magento/setup-magento/increase-admin-session-lifetime.js +14 -16
- 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/migrate-database.js +24 -11
- package/lib/tasks/magento/setup-magento/set-base-url.js +7 -2
- package/lib/tasks/magento/setup-magento/upgrade-magento.js +27 -3
- package/lib/tasks/magento/setup-magento/varnish-config.js +69 -0
- 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/fix-db.js +2 -2
- 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 +8 -7
- package/lib/tasks/php/install-sodium.js +93 -0
- package/lib/tasks/php/update-env-php.js +16 -1
- package/lib/tasks/php/update-env.php +56 -12
- 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 +7 -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 +96 -40
- package/lib/tasks/requirements/docker/install-on-mac.js +29 -0
- package/lib/tasks/requirements/docker/install.js +13 -12
- package/lib/tasks/requirements/docker/running-status.js +138 -0
- package/lib/tasks/requirements/docker/version.js +3 -0
- package/lib/tasks/requirements/index.js +8 -5
- package/lib/tasks/requirements/node-version.js +2 -1
- package/lib/tasks/requirements/php-version.js +29 -25
- 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 +8 -9
- package/lib/tasks/status/index.js +25 -9
- package/lib/tasks/theme/build-theme.js +27 -8
- package/lib/tasks/theme/install-theme.js +18 -5
- 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 +5 -4
- package/lib/tasks/theme/setup-themes.js +11 -3
- package/lib/tasks/theme/symlink-theme.js +26 -4
- package/lib/util/CSA-theme.js +4 -0
- package/lib/util/analytics.js +337 -0
- package/lib/util/arch.js +1 -1
- package/lib/util/config-file-validator.js +14 -2
- package/lib/util/config-php-json.js +20 -0
- 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 +4 -3
- package/lib/util/ip.js +45 -1
- package/lib/util/is-running-root.js +3 -0
- package/lib/util/magento-task.js +20 -9
- package/lib/util/match-filesystem.js +2 -1
- package/lib/util/php-task.js +7 -3
- 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 +14 -3
- package/lib/util/systemctl.js +46 -0
- package/lib/util/wait-for-it.js +3 -2
- package/package.json +4 -3
- package/typings/context.d.ts +6 -1
- package/typings/index.d.ts +32 -1
- package/lib/tasks/magento/setup-magento/adjust-magento-configuration.js +0 -27
- package/lib/tasks/magento/setup-magento/disable-page-cache.js +0 -11
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
const { getArch, getArchSync } = require('./arch');
|
|
2
|
+
|
|
3
|
+
const BREW_BIN_PATH_INTEL = '/usr/local/bin/brew';
|
|
4
|
+
const BREW_BIN_PATH_ARM_ROSETTA = '/usr/local/homebrew/bin/brew';
|
|
5
|
+
// native is not used ATM
|
|
6
|
+
const BREW_BIN_PATH_ARM_NATIVE = '/opt/homebrew/bin/brew';
|
|
7
|
+
|
|
8
|
+
const getBrewBinPath = async () => {
|
|
9
|
+
const arch = await getArch();
|
|
10
|
+
|
|
11
|
+
if (arch === 'arm64') {
|
|
12
|
+
return BREW_BIN_PATH_ARM_ROSETTA;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
return BREW_BIN_PATH_INTEL;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const getBrewBinPathSync = () => {
|
|
19
|
+
const arch = getArchSync();
|
|
20
|
+
|
|
21
|
+
if (arch === 'arm64') {
|
|
22
|
+
return BREW_BIN_PATH_ARM_ROSETTA;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return BREW_BIN_PATH_INTEL;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const getBrewCommand = async ({ native } = { native: false }) => {
|
|
29
|
+
const arch = await getArch();
|
|
30
|
+
|
|
31
|
+
if (arch === 'arm64') {
|
|
32
|
+
if (native) {
|
|
33
|
+
return `arch -arm64 ${BREW_BIN_PATH_ARM_NATIVE}`;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return `arch -x86_64 ${BREW_BIN_PATH_ARM_ROSETTA}`;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return BREW_BIN_PATH_INTEL;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const getBrewCommandSync = ({ native } = { native: false }) => {
|
|
43
|
+
const arch = getArchSync();
|
|
44
|
+
|
|
45
|
+
if (arch === 'arm64') {
|
|
46
|
+
if (native) {
|
|
47
|
+
return `arch -arm64 ${BREW_BIN_PATH_ARM_NATIVE}`;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return `arch -x86_64 ${BREW_BIN_PATH_ARM_ROSETTA}`;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return BREW_BIN_PATH_INTEL;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
module.exports = {
|
|
57
|
+
getBrewBinPath,
|
|
58
|
+
getBrewBinPathSync,
|
|
59
|
+
getBrewCommand,
|
|
60
|
+
getBrewCommandSync,
|
|
61
|
+
BREW_BIN_PATH_INTEL,
|
|
62
|
+
BREW_BIN_PATH_ARM_ROSETTA,
|
|
63
|
+
BREW_BIN_PATH_ARM_NATIVE
|
|
64
|
+
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const fs = require('fs');
|
|
2
2
|
const path = require('path');
|
|
3
|
+
const KnownError = require('../errors/known-error');
|
|
3
4
|
const pathExists = require('./path-exists');
|
|
4
5
|
|
|
5
6
|
const getComposerData = async (composerPath) => {
|
|
@@ -16,7 +17,7 @@ const getInstalledMagentoVersion = async (projectPath = process.cwd()) => {
|
|
|
16
17
|
const composerData = await getComposerData(path.join(projectPath, 'composer.json'));
|
|
17
18
|
|
|
18
19
|
if (!composerData) {
|
|
19
|
-
throw new
|
|
20
|
+
throw new KnownError('composer.json not found');
|
|
20
21
|
}
|
|
21
22
|
const magentoDependency = [
|
|
22
23
|
'magento/product-community-edition',
|
|
@@ -24,7 +25,7 @@ const getInstalledMagentoVersion = async (projectPath = process.cwd()) => {
|
|
|
24
25
|
].find((magentoEdition) => composerData.require[magentoEdition]);
|
|
25
26
|
|
|
26
27
|
if (!magentoDependency) {
|
|
27
|
-
throw new
|
|
28
|
+
throw new KnownError('No Magento dependency found in composer.json');
|
|
28
29
|
}
|
|
29
30
|
|
|
30
31
|
return composerData.require[magentoDependency].replace(/\^/i, '');
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const fs = require('fs');
|
|
2
|
+
const UnknownError = require('../errors/unknown-error');
|
|
2
3
|
const pathExists = require('./path-exists');
|
|
3
4
|
|
|
4
5
|
const getJsonfileData = async (filePath) => {
|
|
@@ -11,7 +12,7 @@ const getJsonfileData = async (filePath) => {
|
|
|
11
12
|
try {
|
|
12
13
|
return JSON.parse(await fs.promises.readFile(filePath, 'utf-8'));
|
|
13
14
|
} catch (e) {
|
|
14
|
-
throw new
|
|
15
|
+
throw new UnknownError(`Ooops! Something went wrong when trying to json parse ${filePath} file!\n\n${e}`);
|
|
15
16
|
}
|
|
16
17
|
};
|
|
17
18
|
|
|
@@ -3,19 +3,30 @@ const logger = require('@scandipwa/scandipwa-dev-utils/logger');
|
|
|
3
3
|
const sleep = require('./sleep');
|
|
4
4
|
const { execCommandTask } = require('./exec-async-command');
|
|
5
5
|
const dependenciesForPlatforms = require('../config/dependencies-for-platforms');
|
|
6
|
+
const KnownError = require('../errors/known-error');
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* Install dependencies
|
|
9
10
|
* @param {object} options
|
|
10
11
|
* @param {keyof dependenciesForPlatforms} options.platform Platform
|
|
11
12
|
* @param {string[]} options.dependenciesToInstall List of dependencies to install
|
|
13
|
+
* @param {boolean} options.useMacNativeEnvironment Use Mac native environment
|
|
12
14
|
* @returns {import('listr2').ListrTask<import('../../typings/context').ListrContext>}
|
|
13
15
|
*/
|
|
14
16
|
const installDependenciesTask = (options) => ({
|
|
15
17
|
title: 'Installing missing dependencies',
|
|
16
18
|
task: async (ctx, task) => {
|
|
17
19
|
const { dependenciesToInstall, platform } = options;
|
|
18
|
-
|
|
20
|
+
let cmd;
|
|
21
|
+
if (os.platform() === 'darwin') {
|
|
22
|
+
if (options.useMacNativeEnvironment) {
|
|
23
|
+
cmd = dependenciesForPlatforms[platform].installCommand(dependenciesToInstall.join(' '), { native: true });
|
|
24
|
+
} else {
|
|
25
|
+
cmd = dependenciesForPlatforms[platform].installCommand(dependenciesToInstall.join(' '));
|
|
26
|
+
}
|
|
27
|
+
} else {
|
|
28
|
+
cmd = dependenciesForPlatforms[platform].installCommand(dependenciesToInstall.join(' '));
|
|
29
|
+
}
|
|
19
30
|
const installCommand = logger.style.code(cmd);
|
|
20
31
|
const dependenciesWordFormatter = `dependenc${dependenciesToInstall.length > 1 ? 'ies' : 'y'}`;
|
|
21
32
|
task.title = `Installing missing dependencies: ${ logger.style.code(dependenciesToInstall.join(', ')) }`;
|
|
@@ -56,15 +67,14 @@ const installDependenciesTask = (options) => ({
|
|
|
56
67
|
promptSkipper = true;
|
|
57
68
|
|
|
58
69
|
if (installAnswer === 'timeout') {
|
|
59
|
-
throw new
|
|
70
|
+
throw new KnownError(`Timeout!
|
|
60
71
|
|
|
61
72
|
To install missing ${ dependenciesWordFormatter } manually, run the following command: ${ installCommand }`);
|
|
62
73
|
}
|
|
63
74
|
|
|
64
75
|
if (installAnswer === 'not-install') {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
To install missing ${ dependenciesWordFormatter } manually, run the following command: ${ installCommand }`);
|
|
76
|
+
task.skip(`User chose to skip installation of ${ dependenciesWordFormatter }`);
|
|
77
|
+
return;
|
|
68
78
|
}
|
|
69
79
|
|
|
70
80
|
if (installAnswer === 'install') {
|
|
@@ -7,7 +7,8 @@ const WEB_ADMIN_CREDENTIALS_TITLE = 'Panel credentials';
|
|
|
7
7
|
|
|
8
8
|
const mapDataStyle = ({ title, text }) => ({
|
|
9
9
|
title,
|
|
10
|
-
text: logger.style.link(text)
|
|
10
|
+
text: logger.style.link(text),
|
|
11
|
+
link: text
|
|
11
12
|
});
|
|
12
13
|
|
|
13
14
|
/**
|
|
@@ -38,7 +39,7 @@ const getInstanceMetadata = (ctx) => {
|
|
|
38
39
|
if (isNgrok) {
|
|
39
40
|
frontend.push({
|
|
40
41
|
title: WEB_LOCAL_LOCATION_TITLE,
|
|
41
|
-
text: `${ssl.enabled ? 'https' : 'http'}://localhost${ssl.enabled || ports.
|
|
42
|
+
text: `${ssl.enabled ? 'https' : 'http'}://localhost${ssl.enabled || ports.sslTerminator === 80 ? '' : `:${ports.sslTerminator}`}/`
|
|
42
43
|
});
|
|
43
44
|
frontend.push({
|
|
44
45
|
title: WEB_LOCATION_TITLE,
|
|
@@ -47,7 +48,7 @@ const getInstanceMetadata = (ctx) => {
|
|
|
47
48
|
} else {
|
|
48
49
|
frontend.push({
|
|
49
50
|
title: WEB_LOCATION_TITLE,
|
|
50
|
-
text: `${ssl.enabled ? 'https' : 'http'}://${host}${ssl.enabled || ports.
|
|
51
|
+
text: `${ssl.enabled ? 'https' : 'http'}://${host}${ssl.enabled || ports.sslTerminator === 80 ? '' : `:${ports.sslTerminator}`}/`
|
|
51
52
|
});
|
|
52
53
|
}
|
|
53
54
|
|
package/lib/util/ip.js
CHANGED
|
@@ -1,8 +1,52 @@
|
|
|
1
|
+
const { request } = require('smol-request');
|
|
2
|
+
|
|
1
3
|
const ipRegex = /^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/;
|
|
2
4
|
|
|
3
5
|
const isIpAddress = (text) => ipRegex.test(text);
|
|
4
6
|
|
|
7
|
+
const externalIpProviders = [
|
|
8
|
+
'http://api.ipify.org/',
|
|
9
|
+
'http://icanhazip.com/',
|
|
10
|
+
'http://ifconfig.io/ip',
|
|
11
|
+
'http://ip.appspot.com/',
|
|
12
|
+
'http://ident.me/',
|
|
13
|
+
'http://whatismyip.akamai.com/',
|
|
14
|
+
'http://tnx.nl/ip',
|
|
15
|
+
'http://myip.dnsomatic.com/',
|
|
16
|
+
'http://ipecho.net/plain',
|
|
17
|
+
'http://diagnostic.opendns.com/myip',
|
|
18
|
+
'http://trackip.net/ip'
|
|
19
|
+
];
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Get an external IP address
|
|
23
|
+
* @returns {Promise<string>}
|
|
24
|
+
*/
|
|
25
|
+
const getExternalIpAddress = async () => {
|
|
26
|
+
let ip;
|
|
27
|
+
|
|
28
|
+
for (const ipProvider of externalIpProviders) {
|
|
29
|
+
try {
|
|
30
|
+
const response = await request(ipProvider, {
|
|
31
|
+
responseType: 'text'
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
ip = response.data;
|
|
35
|
+
break;
|
|
36
|
+
} catch (e) {
|
|
37
|
+
//
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (!ip) {
|
|
42
|
+
throw new Error('External IP address is not available!');
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return ip;
|
|
46
|
+
};
|
|
47
|
+
|
|
5
48
|
module.exports = {
|
|
6
49
|
ipRegex,
|
|
7
|
-
isIpAddress
|
|
50
|
+
isIpAddress,
|
|
51
|
+
getExternalIpAddress
|
|
8
52
|
};
|
package/lib/util/magento-task.js
CHANGED
|
@@ -1,17 +1,28 @@
|
|
|
1
1
|
const runMagentoCommand = require('./run-magento');
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* @
|
|
4
|
+
* @param {String} command
|
|
5
|
+
* @param {Object} [options]
|
|
6
|
+
* @param {(e: Error) => void} [options.onError]
|
|
7
|
+
* @returns {import('listr2').ListrTask<import('../../typings/context').ListrContext>}
|
|
5
8
|
*/
|
|
6
|
-
const magentoTask = (command) => ({
|
|
9
|
+
const magentoTask = (command, options = {}) => ({
|
|
7
10
|
title: `Running command 'magento ${command}'`,
|
|
8
|
-
task: ({ magentoVersion, verbose }, task) =>
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
task: async ({ magentoVersion, verbose }, task) => {
|
|
12
|
+
try {
|
|
13
|
+
await runMagentoCommand(command, {
|
|
14
|
+
callback: !verbose ? undefined : (t) => {
|
|
15
|
+
task.output = t;
|
|
16
|
+
},
|
|
17
|
+
magentoVersion,
|
|
18
|
+
throwNonZeroCode: true
|
|
19
|
+
});
|
|
20
|
+
} catch (e) {
|
|
21
|
+
if (options.onError) {
|
|
22
|
+
options.onError(e);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
},
|
|
15
26
|
options: {
|
|
16
27
|
bottomBar: 10
|
|
17
28
|
}
|
|
@@ -13,7 +13,8 @@ const matchFilesystem = async (cwd, structure) => {
|
|
|
13
13
|
.every((value) => value === true);
|
|
14
14
|
|
|
15
15
|
return ok;
|
|
16
|
-
}
|
|
16
|
+
}
|
|
17
|
+
if (typeof structure === 'object') {
|
|
17
18
|
const ok = (await Promise.all(Object.entries(structure).map(([key, value]) => {
|
|
18
19
|
if (typeof value === 'boolean') {
|
|
19
20
|
return pathExists(path.join(cwd, key));
|
package/lib/util/php-task.js
CHANGED
|
@@ -1,16 +1,20 @@
|
|
|
1
1
|
const runPhpCode = require('./run-php');
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* @
|
|
4
|
+
* @param {String} command
|
|
5
|
+
* @param {{ noTitle: boolean, env: Record<string, string> }} options
|
|
6
|
+
* @returns {import('listr2').ListrTask<import('../../typings/context').ListrContext>}
|
|
5
7
|
*/
|
|
6
8
|
const phpTask = (command, options = {}) => ({
|
|
7
9
|
title: !options.noTitle ? `Running command 'php ${command}` : undefined,
|
|
8
|
-
task: (
|
|
10
|
+
task: (ctx, task) => runPhpCode(command, {
|
|
9
11
|
callback: (t) => {
|
|
10
12
|
task.output = t;
|
|
11
13
|
},
|
|
12
14
|
throwNonZeroCode: true,
|
|
13
|
-
magentoVersion
|
|
15
|
+
magentoVersion: ctx.magentoVersion,
|
|
16
|
+
env: options.env,
|
|
17
|
+
useRosettaOnMac: ctx.arch === 'arm64' && ctx.platform === 'darwin'
|
|
14
18
|
})
|
|
15
19
|
});
|
|
16
20
|
|
|
File without changes
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
|
+
const UnknownError = require('../errors/unknown-error');
|
|
2
3
|
const { configFileSchema } = require('./config-file-validator');
|
|
3
4
|
const { deepmerge } = require('./deepmerge');
|
|
4
5
|
const pathExists = require('./path-exists');
|
|
@@ -11,7 +12,7 @@ const resolveConfigurationWithOverrides = async (configuration, baseConfig, proj
|
|
|
11
12
|
try {
|
|
12
13
|
await configFileSchema.validateAsync(userConfiguration);
|
|
13
14
|
} catch (e) {
|
|
14
|
-
throw new
|
|
15
|
+
throw new UnknownError(`Configuration file validation error!\n\n${e.message}`);
|
|
15
16
|
}
|
|
16
17
|
|
|
17
18
|
const overridenConfiguration = deepmerge(configuration, userConfiguration);
|
package/lib/util/run-composer.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const { execAsyncSpawn } = require('./exec-async-command');
|
|
2
2
|
const { getConfigFromMagentoVersion, defaultConfiguration } = require('../config');
|
|
3
|
+
const UnknownError = require('../errors/unknown-error');
|
|
3
4
|
/**
|
|
4
5
|
* Execute composer command
|
|
5
6
|
* @param {String} command composer command
|
|
@@ -20,12 +21,13 @@ const runComposerCommand = async (command, options = {}) => {
|
|
|
20
21
|
const { code, result } = await execAsyncSpawn(`${php.binPath} -c ${php.iniPath} ${composer.binPath} ${command}`, {
|
|
21
22
|
...options,
|
|
22
23
|
cwd: magentoDir,
|
|
23
|
-
withCode: true
|
|
24
|
+
withCode: true,
|
|
25
|
+
useRosetta2: true
|
|
24
26
|
});
|
|
25
27
|
|
|
26
28
|
if (throwNonZeroCode && code !== 0) {
|
|
27
|
-
throw new
|
|
28
|
-
|
|
29
|
+
throw new UnknownError(`Code: ${code}
|
|
30
|
+
Response: ${result}`);
|
|
29
31
|
}
|
|
30
32
|
|
|
31
33
|
return { code, result };
|
package/lib/util/run-magento.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const { execAsyncSpawn } = require('./exec-async-command');
|
|
2
2
|
const { getConfigFromMagentoVersion, defaultConfiguration, magento } = require('../config');
|
|
3
|
+
const UnknownError = require('../errors/unknown-error');
|
|
3
4
|
/**
|
|
4
5
|
* Execute magento command
|
|
5
6
|
* @param {String} command magento command
|
|
@@ -27,8 +28,8 @@ const runMagentoCommand = async (command, options = {}) => {
|
|
|
27
28
|
});
|
|
28
29
|
|
|
29
30
|
if (throwNonZeroCode && code !== 0) {
|
|
30
|
-
throw new
|
|
31
|
-
|
|
31
|
+
throw new UnknownError(`Code: ${code}
|
|
32
|
+
Response: ${result}`);
|
|
32
33
|
}
|
|
33
34
|
|
|
34
35
|
return { code, result };
|
package/lib/util/run-php.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const { execAsyncSpawn } = require('./exec-async-command');
|
|
2
2
|
const { getConfigFromMagentoVersion, defaultConfiguration } = require('../config');
|
|
3
|
+
const UnknownError = require('../errors/unknown-error');
|
|
3
4
|
/**
|
|
4
5
|
* Execute PHP code
|
|
5
6
|
* @param {String} command magento command
|
|
@@ -10,6 +11,8 @@ const { getConfigFromMagentoVersion, defaultConfiguration } = require('../config
|
|
|
10
11
|
* @param {() => {}} options.callback
|
|
11
12
|
* @param {Boolean} options.throwNonZeroCode Throw if command return non 0 code.
|
|
12
13
|
* @param {String} options.magentoVersion Magento version for config
|
|
14
|
+
* @param {Record<string, string>} options.env Environment variables
|
|
15
|
+
* @param {Boolean} options.useRosettaOnMac Use Rosetta 2 on MacOS
|
|
13
16
|
*/
|
|
14
17
|
const runPhpCode = async (command, options = {}) => {
|
|
15
18
|
const {
|
|
@@ -17,14 +20,22 @@ const runPhpCode = async (command, options = {}) => {
|
|
|
17
20
|
magentoVersion = defaultConfiguration.magentoVersion
|
|
18
21
|
} = options;
|
|
19
22
|
const { php } = await getConfigFromMagentoVersion(magentoVersion);
|
|
20
|
-
|
|
23
|
+
let spawnCommand = `${php.binPath} -c ${php.iniPath} ${command}`;
|
|
24
|
+
if (options.env && Object.keys(options.env).length > 0) {
|
|
25
|
+
const env = Object.entries(options.env).map(([key, value]) => `${key}=${value}`).join(' ');
|
|
26
|
+
spawnCommand = `${env} ${spawnCommand}`;
|
|
27
|
+
}
|
|
28
|
+
if (options.useRosettaOnMac) {
|
|
29
|
+
spawnCommand = `arch -x86_64 bash -c '${spawnCommand}'`;
|
|
30
|
+
}
|
|
31
|
+
const { code, result } = await execAsyncSpawn(spawnCommand, {
|
|
21
32
|
...options,
|
|
22
33
|
withCode: true
|
|
23
34
|
});
|
|
24
35
|
|
|
25
36
|
if (throwNonZeroCode && code !== 0) {
|
|
26
|
-
throw new
|
|
27
|
-
|
|
37
|
+
throw new UnknownError(`Code: ${code}
|
|
38
|
+
Response: ${result}`);
|
|
28
39
|
}
|
|
29
40
|
|
|
30
41
|
return { code, result };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
const { execAsyncSpawn } = require('./exec-async-command');
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @param {String} cmd
|
|
5
|
+
* @param {String} serviceName
|
|
6
|
+
* @param {{ now: boolean }} options
|
|
7
|
+
*/
|
|
8
|
+
const run = (cmd, serviceName, options = {}) => execAsyncSpawn(
|
|
9
|
+
`systemctl ${ cmd }${ serviceName ? ` ${ serviceName }` : '' }${ options.now ? ' --now' : ''}`,
|
|
10
|
+
{
|
|
11
|
+
withCode: true
|
|
12
|
+
}
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
const daemonReload = () => run('daemon-reload');
|
|
16
|
+
|
|
17
|
+
const systemctlControl = (serviceName) => ({
|
|
18
|
+
disable: () => run('disable', serviceName),
|
|
19
|
+
enable: () => run('enable', serviceName),
|
|
20
|
+
enableAndStart: () => run('enable', serviceName, { now: true }),
|
|
21
|
+
restart: () => run('restart', serviceName),
|
|
22
|
+
start: () => run('start', serviceName),
|
|
23
|
+
stop: () => run('stop', serviceName),
|
|
24
|
+
isEnabled: async () => {
|
|
25
|
+
try {
|
|
26
|
+
const { result } = await run('is-enabled', serviceName);
|
|
27
|
+
return result.includes('enabled');
|
|
28
|
+
} catch (e) {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
isRunning: async () => {
|
|
33
|
+
try {
|
|
34
|
+
const { result } = await run('status', serviceName);
|
|
35
|
+
|
|
36
|
+
return result.includes('active (running)');
|
|
37
|
+
} catch (e) {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
module.exports = {
|
|
44
|
+
systemctlControl,
|
|
45
|
+
daemonReload
|
|
46
|
+
};
|
package/lib/util/wait-for-it.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const net = require('net');
|
|
2
|
+
const UnknownError = require('../errors/unknown-error');
|
|
2
3
|
const sleep = require('./sleep');
|
|
3
4
|
|
|
4
5
|
const connectToHostPort = ({ host, port }) => new Promise((resolve, reject) => {
|
|
@@ -14,7 +15,7 @@ const connectToHostPort = ({ host, port }) => new Promise((resolve, reject) => {
|
|
|
14
15
|
});
|
|
15
16
|
socket.on('timeout', () => {
|
|
16
17
|
socket.end();
|
|
17
|
-
reject(new
|
|
18
|
+
reject(new UnknownError('Connection timeout'));
|
|
18
19
|
});
|
|
19
20
|
});
|
|
20
21
|
|
|
@@ -29,7 +30,7 @@ const waitForIt = async ({
|
|
|
29
30
|
// eslint-disable-next-line no-await-in-loop
|
|
30
31
|
await Promise.race([
|
|
31
32
|
sleep(300).then(() => {
|
|
32
|
-
throw new
|
|
33
|
+
throw new UnknownError('Connection timeout');
|
|
33
34
|
}),
|
|
34
35
|
connectToHostPort({ host, port })
|
|
35
36
|
]);
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "Scripts and configuration used by CMA.",
|
|
4
4
|
"homepage": "https://docs.create-magento-app.com/",
|
|
5
5
|
"repository": "github:scandipwa/create-magento-app",
|
|
6
|
-
"version": "1.14.1-alpha.
|
|
6
|
+
"version": "1.14.1-alpha.12",
|
|
7
7
|
"main": "./index.js",
|
|
8
8
|
"types": "./typings/index.d.ts",
|
|
9
9
|
"license": "OSL-3.0",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"arm64"
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@scandipwa/scandipwa-dev-utils": "0.1.
|
|
25
|
+
"@scandipwa/scandipwa-dev-utils": "0.1.13",
|
|
26
26
|
"conf": "10.1.1",
|
|
27
27
|
"enquirer": "2.3.6",
|
|
28
28
|
"eta": "1.12.3",
|
|
@@ -36,6 +36,7 @@
|
|
|
36
36
|
"mysql2": "2.3.2",
|
|
37
37
|
"node-ssh": "12.0.0",
|
|
38
38
|
"semver": "7.3.5",
|
|
39
|
+
"smol-request": "2.1.1",
|
|
39
40
|
"systeminformation": "5.11.7",
|
|
40
41
|
"yargs": "17.3.1"
|
|
41
42
|
},
|
|
@@ -52,5 +53,5 @@
|
|
|
52
53
|
"mysql",
|
|
53
54
|
"scandipwa"
|
|
54
55
|
],
|
|
55
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "c765f4fe97f9d09cabfd928fc127484eb2cac911"
|
|
56
57
|
}
|
package/typings/context.d.ts
CHANGED
|
@@ -13,9 +13,13 @@ export interface ListrContext {
|
|
|
13
13
|
mysql: number
|
|
14
14
|
redis: number
|
|
15
15
|
elasticsearch: number
|
|
16
|
+
varnish: number
|
|
17
|
+
sslTerminator: number
|
|
16
18
|
}
|
|
17
19
|
arch: 'arm64' | 'x64'
|
|
18
20
|
isArm: boolean
|
|
21
|
+
isWsl: boolean
|
|
22
|
+
isArmMac: boolean
|
|
19
23
|
platform?: NodeJS.Platform
|
|
20
24
|
platformVersion?: string
|
|
21
25
|
/**
|
|
@@ -52,7 +56,7 @@ export interface ListrContext {
|
|
|
52
56
|
o: string
|
|
53
57
|
}
|
|
54
58
|
}>
|
|
55
|
-
getContainers(): Record<'nginx' | 'redis' | 'mysql' | 'elasticsearch', {
|
|
59
|
+
getContainers(): Record<'nginx' | 'redis' | 'mysql' | 'elasticsearch' | 'varnish', {
|
|
56
60
|
_: string
|
|
57
61
|
ports: string[]
|
|
58
62
|
healthCheck: {
|
|
@@ -90,4 +94,5 @@ export interface ListrContext {
|
|
|
90
94
|
useNonOverlappingPorts: boolean
|
|
91
95
|
}
|
|
92
96
|
mysqlConnection: mysql2.Connection
|
|
97
|
+
isSetupUpgradeNeeded?: boolean
|
|
93
98
|
}
|
package/typings/index.d.ts
CHANGED
|
@@ -10,7 +10,14 @@ export interface ServiceWithVersion {
|
|
|
10
10
|
version: string
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
export interface SSLTerminatorConfiguration extends ServiceWithVersion {
|
|
14
|
+
/**
|
|
15
|
+
* Configuration file location
|
|
16
|
+
*
|
|
17
|
+
* @example ./my-ssl-terminator-config.conf
|
|
18
|
+
*/
|
|
19
|
+
configTemplate: string
|
|
20
|
+
}
|
|
14
21
|
|
|
15
22
|
export interface NginxConfiguration extends ServiceWithVersion {
|
|
16
23
|
/**
|
|
@@ -21,6 +28,20 @@ export interface NginxConfiguration extends ServiceWithVersion {
|
|
|
21
28
|
configTemplate: string
|
|
22
29
|
}
|
|
23
30
|
|
|
31
|
+
export interface VarnishConfiguration extends ServiceWithVersion {
|
|
32
|
+
/**
|
|
33
|
+
* Enable or disable Varnish in the project
|
|
34
|
+
*/
|
|
35
|
+
enabled: boolean
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Configuration file location
|
|
39
|
+
*
|
|
40
|
+
* @example ./my-varnish-config.vcl
|
|
41
|
+
*/
|
|
42
|
+
configTemplate: string
|
|
43
|
+
}
|
|
44
|
+
|
|
24
45
|
export interface PHPExtension extends Record<string, unknown> {
|
|
25
46
|
version?: string
|
|
26
47
|
/**
|
|
@@ -175,6 +196,16 @@ export interface CMAConfiguration {
|
|
|
175
196
|
* Composer configuration
|
|
176
197
|
*/
|
|
177
198
|
composer: ServiceWithVersion
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Varnish configuration
|
|
202
|
+
*/
|
|
203
|
+
varnish: VarnishConfiguration
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* SSL Terminator configuration
|
|
207
|
+
*/
|
|
208
|
+
sslTerminator: SSLTerminatorConfiguration
|
|
178
209
|
}
|
|
179
210
|
/**
|
|
180
211
|
* Magento configuration
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
const { isTableExists } = require('../../../util/database');
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @type {() => import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
|
|
5
|
-
*/
|
|
6
|
-
const adjustMagentoConfiguration = () => ({
|
|
7
|
-
title: 'Adjusting Magento Database Configuration',
|
|
8
|
-
skip: async (ctx) => !(await isTableExists('magento', 'core_config_data', ctx)),
|
|
9
|
-
task: async (ctx) => {
|
|
10
|
-
const { mysqlConnection } = ctx;
|
|
11
|
-
|
|
12
|
-
// delete varnish configuration if exists
|
|
13
|
-
await mysqlConnection.query(`
|
|
14
|
-
DELETE FROM core_config_data WHERE path LIKE '%varnish%';
|
|
15
|
-
`);
|
|
16
|
-
|
|
17
|
-
// update cache policy to not use varnish
|
|
18
|
-
// 0 - magento cache, 2 - varnish cache
|
|
19
|
-
await mysqlConnection.query(`
|
|
20
|
-
UPDATE core_config_data
|
|
21
|
-
SET value = ?
|
|
22
|
-
WHERE path = ?;
|
|
23
|
-
`, ['0', 'system/full_page_cache/caching_application']);
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
module.exports = adjustMagentoConfiguration;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
const magentoTask = require('../../../util/magento-task');
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @type {() => import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
|
|
5
|
-
*/
|
|
6
|
-
const disablePageCache = () => ({
|
|
7
|
-
title: 'Disabling full_page cache in Magento',
|
|
8
|
-
task: (ctx, task) => task.newListr(magentoTask('cache:disable full_page'))
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
module.exports = disablePageCache;
|