@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
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
|
+
const UnknownError = require('../errors/unknown-error');
|
|
2
3
|
const runPhpCode = require('./run-php');
|
|
3
4
|
|
|
4
5
|
const configPhpToJson = async (projectPath = process.cwd(), { magentoVersion }) => {
|
|
@@ -7,12 +8,12 @@ const configPhpToJson = async (projectPath = process.cwd(), { magentoVersion })
|
|
|
7
8
|
});
|
|
8
9
|
|
|
9
10
|
if (code !== 0) {
|
|
10
|
-
throw new
|
|
11
|
+
throw new UnknownError(`Received non-zero code during converting app/etc/config.php to json:\n\n${result}`);
|
|
11
12
|
}
|
|
12
13
|
try {
|
|
13
14
|
return JSON.parse(result);
|
|
14
15
|
} catch (e) {
|
|
15
|
-
throw new
|
|
16
|
+
throw new UnknownError(`Ooops! Something went wrong when trying to parse app/etc/config.php file!\n\n${e}\n\nFile result: ${result}`);
|
|
16
17
|
}
|
|
17
18
|
};
|
|
18
19
|
|
package/lib/util/env-php-json.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
|
+
const UnknownError = require('../errors/unknown-error');
|
|
2
3
|
const runPhpCode = require('./run-php');
|
|
3
4
|
|
|
4
5
|
const envPhpToJson = async (projectPath = process.cwd(), { magentoVersion }) => {
|
|
@@ -7,12 +8,12 @@ const envPhpToJson = async (projectPath = process.cwd(), { magentoVersion }) =>
|
|
|
7
8
|
});
|
|
8
9
|
|
|
9
10
|
if (code !== 0) {
|
|
10
|
-
throw new
|
|
11
|
+
throw new UnknownError(`Received non-zero code during converting app/etc/env.php to json:\n\n${result}`);
|
|
11
12
|
}
|
|
12
13
|
try {
|
|
13
14
|
return JSON.parse(result);
|
|
14
15
|
} catch (e) {
|
|
15
|
-
throw new
|
|
16
|
+
throw new UnknownError(`Ooops! Something went wrong when trying to parse app/etc/env.php file!\n\n${e}\n\nFile result: ${result}`);
|
|
16
17
|
}
|
|
17
18
|
};
|
|
18
19
|
|
|
@@ -1,25 +1,42 @@
|
|
|
1
|
+
const os = require('os');
|
|
1
2
|
const logger = require('@scandipwa/scandipwa-dev-utils/logger');
|
|
2
|
-
const {
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
exec(command, options, (err, stdout) => (err ? reject(err) : resolve(stdout)));
|
|
6
|
-
});
|
|
3
|
+
const { spawn } = require('child_process');
|
|
4
|
+
const { getArchSync } = require('./arch');
|
|
5
|
+
const compileOptions = require('../tasks/php/compile-options');
|
|
7
6
|
|
|
8
7
|
const execAsyncSpawn = (command, {
|
|
9
8
|
callback = () => {},
|
|
10
9
|
pipeInput,
|
|
11
10
|
logOutput = false,
|
|
12
11
|
cwd,
|
|
13
|
-
withCode = false
|
|
12
|
+
withCode = false,
|
|
13
|
+
useRosetta2 = false
|
|
14
14
|
} = {}) => {
|
|
15
|
-
const
|
|
16
|
-
'
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
15
|
+
const spawnOptions = {
|
|
16
|
+
stdio: pipeInput ? ['inherit', 'pipe', 'pipe'] : 'pipe',
|
|
17
|
+
cwd
|
|
18
|
+
};
|
|
19
|
+
let childProcess;
|
|
20
|
+
if (useRosetta2 && os.platform() === 'darwin' && getArchSync() === 'arm64') {
|
|
21
|
+
childProcess = spawn(
|
|
22
|
+
'arch',
|
|
23
|
+
// eslint-disable-next-line max-len
|
|
24
|
+
['-x86_64', 'bash', '-c', command],
|
|
25
|
+
{
|
|
26
|
+
...spawnOptions,
|
|
27
|
+
env: {
|
|
28
|
+
...process.env,
|
|
29
|
+
PATH: compileOptions.darwin.env.PATH
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
);
|
|
33
|
+
} else {
|
|
34
|
+
childProcess = spawn(
|
|
35
|
+
'bash',
|
|
36
|
+
['-c', command],
|
|
37
|
+
spawnOptions
|
|
38
|
+
);
|
|
39
|
+
}
|
|
23
40
|
|
|
24
41
|
return new Promise((resolve, reject) => {
|
|
25
42
|
let stdout = '';
|
|
@@ -71,7 +88,6 @@ const execCommandTask = (command, options = {}) => ({
|
|
|
71
88
|
});
|
|
72
89
|
|
|
73
90
|
module.exports = {
|
|
74
|
-
execAsync,
|
|
75
91
|
execAsyncSpawn,
|
|
76
92
|
execCommandTask
|
|
77
93
|
};
|
|
@@ -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
|
/**
|
|
@@ -70,5 +71,11 @@ const getInstanceMetadata = (ctx) => {
|
|
|
70
71
|
};
|
|
71
72
|
|
|
72
73
|
module.exports = {
|
|
73
|
-
getInstanceMetadata
|
|
74
|
+
getInstanceMetadata,
|
|
75
|
+
constants: {
|
|
76
|
+
WEB_LOCAL_LOCATION_TITLE,
|
|
77
|
+
WEB_LOCATION_TITLE,
|
|
78
|
+
WEB_ADMIN_LOCATION_TITLE,
|
|
79
|
+
WEB_ADMIN_CREDENTIALS_TITLE
|
|
80
|
+
}
|
|
74
81
|
};
|
package/lib/util/ip.js
CHANGED
|
@@ -1,8 +1,54 @@
|
|
|
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
|
+
if (response.status === 200) {
|
|
35
|
+
ip = response.data;
|
|
36
|
+
break;
|
|
37
|
+
}
|
|
38
|
+
} catch (e) {
|
|
39
|
+
//
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (!ip) {
|
|
44
|
+
throw new Error('External IP address is not available!');
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return ip;
|
|
48
|
+
};
|
|
49
|
+
|
|
5
50
|
module.exports = {
|
|
6
51
|
ipRegex,
|
|
7
|
-
isIpAddress
|
|
52
|
+
isIpAddress,
|
|
53
|
+
getExternalIpAddress
|
|
8
54
|
};
|
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
|
}
|
package/lib/util/php-task.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
const runPhpCode = require('./run-php');
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* @
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* ) => import('listr2').ListrTask<import('../../typings/context').ListrContext>}
|
|
4
|
+
* @param {String} command
|
|
5
|
+
* @param {{ noTitle: boolean, env: Record<string, string> }} options
|
|
6
|
+
* @returns {import('listr2').ListrTask<import('../../typings/context').ListrContext>}
|
|
8
7
|
*/
|
|
9
8
|
const phpTask = (command, options = {}) => ({
|
|
10
9
|
title: !options.noTitle ? `Running command 'php ${command}` : undefined,
|
|
11
|
-
task: (
|
|
10
|
+
task: (ctx, task) => runPhpCode(command, {
|
|
12
11
|
callback: (t) => {
|
|
13
12
|
task.output = t;
|
|
14
13
|
},
|
|
15
14
|
throwNonZeroCode: true,
|
|
16
|
-
magentoVersion,
|
|
17
|
-
env: options.env
|
|
15
|
+
magentoVersion: ctx.magentoVersion,
|
|
16
|
+
env: options.env,
|
|
17
|
+
useRosettaOnMac: ctx.arch === 'arm64' && ctx.platform === 'darwin'
|
|
18
18
|
})
|
|
19
19
|
});
|
|
20
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
|
|
@@ -11,6 +12,7 @@ const { getConfigFromMagentoVersion, defaultConfiguration } = require('../config
|
|
|
11
12
|
* @param {Boolean} options.throwNonZeroCode Throw if command return non 0 code.
|
|
12
13
|
* @param {String} options.magentoVersion Magento version for config
|
|
13
14
|
* @param {Record<string, string>} options.env Environment variables
|
|
15
|
+
* @param {Boolean} options.useRosettaOnMac Use Rosetta 2 on MacOS
|
|
14
16
|
*/
|
|
15
17
|
const runPhpCode = async (command, options = {}) => {
|
|
16
18
|
const {
|
|
@@ -23,14 +25,17 @@ const runPhpCode = async (command, options = {}) => {
|
|
|
23
25
|
const env = Object.entries(options.env).map(([key, value]) => `${key}=${value}`).join(' ');
|
|
24
26
|
spawnCommand = `${env} ${spawnCommand}`;
|
|
25
27
|
}
|
|
28
|
+
if (options.useRosettaOnMac) {
|
|
29
|
+
spawnCommand = `arch -x86_64 bash -c '${spawnCommand}'`;
|
|
30
|
+
}
|
|
26
31
|
const { code, result } = await execAsyncSpawn(spawnCommand, {
|
|
27
32
|
...options,
|
|
28
33
|
withCode: true
|
|
29
34
|
});
|
|
30
35
|
|
|
31
36
|
if (throwNonZeroCode && code !== 0) {
|
|
32
|
-
throw new
|
|
33
|
-
|
|
37
|
+
throw new UnknownError(`Code: ${code}
|
|
38
|
+
Response: ${result}`);
|
|
34
39
|
}
|
|
35
40
|
|
|
36
41
|
return { code, result };
|
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.
|
|
6
|
+
"version": "1.15.2",
|
|
7
7
|
"main": "./index.js",
|
|
8
8
|
"types": "./typings/index.d.ts",
|
|
9
9
|
"license": "OSL-3.0",
|
|
@@ -22,10 +22,11 @@
|
|
|
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",
|
|
29
|
+
"fast-xml-parser": "^4.0.7",
|
|
29
30
|
"hjson": "^3.2.2",
|
|
30
31
|
"is-installed-globally": "0.4.0",
|
|
31
32
|
"joi": "17.6.0",
|
|
@@ -35,6 +36,7 @@
|
|
|
35
36
|
"mysql2": "2.3.2",
|
|
36
37
|
"node-ssh": "12.0.0",
|
|
37
38
|
"semver": "7.3.5",
|
|
39
|
+
"smol-request": "^2.1.2",
|
|
38
40
|
"systeminformation": "5.11.7",
|
|
39
41
|
"yargs": "17.3.1"
|
|
40
42
|
},
|
|
@@ -51,5 +53,5 @@
|
|
|
51
53
|
"mysql",
|
|
52
54
|
"scandipwa"
|
|
53
55
|
],
|
|
54
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "6ddbd68e15d1868386f559f7edd6610dbc80a8e4"
|
|
55
57
|
}
|
package/typings/context.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import mysql2 from 'mysql2';
|
|
2
2
|
|
|
3
3
|
import { CMAConfiguration, PHPExtensions } from './index';
|
|
4
|
+
import { PHPStormConfig } from './phpstorm';
|
|
4
5
|
|
|
5
6
|
export interface ListrContext {
|
|
6
7
|
magentoVersion: string
|
|
@@ -13,10 +14,12 @@ export interface ListrContext {
|
|
|
13
14
|
redis: number
|
|
14
15
|
elasticsearch: number
|
|
15
16
|
varnish: number
|
|
17
|
+
sslTerminator: number
|
|
16
18
|
}
|
|
17
19
|
arch: 'arm64' | 'x64'
|
|
18
20
|
isArm: boolean
|
|
19
21
|
isWsl: boolean
|
|
22
|
+
isArmMac: boolean
|
|
20
23
|
platform?: NodeJS.Platform
|
|
21
24
|
platformVersion?: string
|
|
22
25
|
/**
|
|
@@ -84,6 +87,7 @@ export interface ListrContext {
|
|
|
84
87
|
overridenConfiguration: Omit<CMAConfiguration, 'prefix' | 'useNonOverlappingPorts'>
|
|
85
88
|
userConfiguration: Omit<CMAConfiguration, 'prefix' | 'useNonOverlappingPorts'>
|
|
86
89
|
nonOverridenConfiguration: Omit<CMAConfiguration, 'prefix' | 'useNonOverlappingPorts'>
|
|
90
|
+
phpStorm: PHPStormConfig
|
|
87
91
|
}
|
|
88
92
|
systemConfiguration: {
|
|
89
93
|
analytics: boolean
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export interface PHPStormConfig {
|
|
2
|
+
xdebug: {
|
|
3
|
+
v2Port: string;
|
|
4
|
+
v3Port: string;
|
|
5
|
+
debugServerAddress: string;
|
|
6
|
+
serverName: string;
|
|
7
|
+
runManagerName: string;
|
|
8
|
+
sessionId: string;
|
|
9
|
+
path: string;
|
|
10
|
+
templatePath: string;
|
|
11
|
+
}
|
|
12
|
+
php: {
|
|
13
|
+
phpLanguageLevel: string;
|
|
14
|
+
path: string;
|
|
15
|
+
templatePath: string;
|
|
16
|
+
}
|
|
17
|
+
database: {
|
|
18
|
+
driver: string;
|
|
19
|
+
dataSourceManagerName: string;
|
|
20
|
+
dataSourcesLocal: {
|
|
21
|
+
path: string;
|
|
22
|
+
templatePath: string;
|
|
23
|
+
}
|
|
24
|
+
dataSources: {
|
|
25
|
+
path: string;
|
|
26
|
+
templatePath: string;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
inspectionTools: {
|
|
30
|
+
path: string;
|
|
31
|
+
templatePath: string;
|
|
32
|
+
}
|
|
33
|
+
}
|