@scandipwa/magento-scripts 1.14.1-alpha.9 → 1.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commands/cli.js +9 -4
- 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 +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 +7 -5
- package/lib/tasks/magento/setup-magento/adjust-full-page-cache.js +26 -0
- package/lib/tasks/magento/setup-magento/delete-admin-users.js +1 -1
- package/lib/tasks/magento/setup-magento/delete-customers.js +7 -4
- package/lib/tasks/magento/setup-magento/delete-orders.js +6 -4
- package/lib/tasks/magento/setup-magento/flush-redis-config.js +2 -1
- package/lib/tasks/magento/setup-magento/index.js +3 -1
- package/lib/tasks/magento/setup-magento/install-magento.js +2 -1
- package/lib/tasks/magento/setup-magento/set-base-url.js +7 -2
- package/lib/tasks/magento/setup-magento/upgrade-magento.js +11 -1
- package/lib/tasks/magento/setup-magento/waiting-for-varnish.js +41 -0
- package/lib/tasks/mysql/connect-to-mysql.js +2 -1
- package/lib/tasks/mysql/import-dump-to-mysql.js +13 -2
- package/lib/tasks/mysql/import-remote-db/index.js +2 -1
- package/lib/tasks/mysql/import-remote-db/ssh/index.js +2 -1
- package/lib/tasks/mysql/import-remote-db/ssh/regular-server.js +2 -1
- package/lib/tasks/php/bundled-extensions.js +28 -0
- package/lib/tasks/php/compile-options.js +27 -54
- package/lib/tasks/php/compile.js +6 -4
- package/lib/tasks/php/configure.js +7 -66
- package/lib/tasks/php/extensions/disable.js +2 -1
- package/lib/tasks/php/extensions/enable.js +2 -1
- package/lib/tasks/php/extensions/index.js +74 -0
- package/lib/tasks/php/extensions/install.js +3 -3
- package/lib/tasks/php/index.js +7 -6
- package/lib/tasks/php/install-sodium.js +93 -0
- package/lib/tasks/php/update-phpbrew.js +7 -3
- package/lib/tasks/php/validate-php.js +67 -0
- package/lib/tasks/php-fpm/start-php-fpm.js +4 -2
- package/lib/tasks/requirements/composer.js +59 -5
- package/lib/tasks/requirements/dependency/arch.js +2 -1
- package/lib/tasks/requirements/dependency/centos.js +2 -1
- package/lib/tasks/requirements/dependency/fedora.js +2 -1
- package/lib/tasks/requirements/dependency/mac.js +18 -3
- package/lib/tasks/requirements/docker/index.js +94 -40
- package/lib/tasks/requirements/docker/install-on-mac.js +29 -0
- package/lib/tasks/requirements/docker/install.js +2 -1
- package/lib/tasks/requirements/docker/running-status.js +32 -31
- package/lib/tasks/requirements/docker/version.js +2 -1
- package/lib/tasks/requirements/index.js +3 -0
- package/lib/tasks/requirements/node-version.js +2 -1
- package/lib/tasks/requirements/php-version.js +26 -24
- package/lib/tasks/requirements/phpbrew/index.js +2 -1
- package/lib/tasks/requirements/phpbrew/install.js +14 -2
- package/lib/tasks/requirements/phpbrew/version.js +2 -1
- package/lib/tasks/requirements/platform.js +5 -3
- package/lib/tasks/requirements/rosetta.js +32 -0
- package/lib/tasks/start.js +10 -2
- package/lib/tasks/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 +317 -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
|
@@ -5,6 +5,8 @@ const { execAsyncSpawn } = require('../../../util/exec-async-command');
|
|
|
5
5
|
const logger = require('@scandipwa/scandipwa-dev-utils/logger');
|
|
6
6
|
const installDependenciesTask = require('../../../util/install-dependencies-task');
|
|
7
7
|
const osPlatform = require('../../../util/os-platform');
|
|
8
|
+
const KnownError = require('../../../errors/known-error');
|
|
9
|
+
const { getBrewCommand } = require('../../../util/get-brew-bin-path');
|
|
8
10
|
|
|
9
11
|
/**
|
|
10
12
|
* @type {() => import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
|
|
@@ -13,10 +15,20 @@ const installPHPBrewDependencies = () => ({
|
|
|
13
15
|
title: 'Installing PHPBrew dependencies',
|
|
14
16
|
task: async (ctx, task) => {
|
|
15
17
|
if (process.platform === 'darwin') {
|
|
18
|
+
const installedDependencies = (await execAsyncSpawn(`${await getBrewCommand({ native: true })} list`)).split('\n');
|
|
19
|
+
|
|
20
|
+
const dependenciesToInstall = ['php', 'autoconf', 'pkg-config'].filter((dep) => !installedDependencies.includes(dep));
|
|
21
|
+
|
|
22
|
+
if (dependenciesToInstall.length === 0) {
|
|
23
|
+
task.skip();
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
|
|
16
27
|
return task.newListr(
|
|
17
28
|
installDependenciesTask({
|
|
18
29
|
platform: 'darwin',
|
|
19
|
-
dependenciesToInstall
|
|
30
|
+
dependenciesToInstall,
|
|
31
|
+
useMacNativeEnvironment: true
|
|
20
32
|
})
|
|
21
33
|
);
|
|
22
34
|
}
|
|
@@ -167,7 +179,7 @@ When you ready, press select Yes and installation will continue.`
|
|
|
167
179
|
});
|
|
168
180
|
|
|
169
181
|
if (!continueInstall) {
|
|
170
|
-
throw new
|
|
182
|
+
throw new KnownError(`Add following string to your shells configuration file: ${logger.style.code('[[ -e ~/.phpbrew/bashrc ]] && source ~/.phpbrew/bashrc')}
|
|
171
183
|
|
|
172
184
|
Then you can continue installation.`);
|
|
173
185
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
const UnknownError = require('../../../errors/unknown-error');
|
|
1
2
|
const { execAsyncSpawn } = require('../../../util/exec-async-command');
|
|
2
3
|
const safeRegexExtract = require('../../../util/safe-regex-extract');
|
|
3
4
|
|
|
@@ -15,7 +16,7 @@ const getPHPBrewVersion = () => ({
|
|
|
15
16
|
string: result,
|
|
16
17
|
regex: /phpbrew - ([\d.]+)/i,
|
|
17
18
|
onNoMatch: () => {
|
|
18
|
-
throw new
|
|
19
|
+
throw new UnknownError(`No phpbrew version found in phpbrew version output!\n\n${result}`);
|
|
19
20
|
}
|
|
20
21
|
});
|
|
21
22
|
|
|
@@ -6,9 +6,10 @@ const { platforms, darwinMinimalVersion } = require('../../config');
|
|
|
6
6
|
const dependencyCheck = require('./dependency');
|
|
7
7
|
const { getArch } = require('../../util/arch');
|
|
8
8
|
const getIsWsl = require('../../util/is-wsl');
|
|
9
|
+
const KnownError = require('../../errors/known-error');
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
|
-
* @
|
|
12
|
+
* @returns {import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
|
|
12
13
|
*/
|
|
13
14
|
const checkPlatform = () => ({
|
|
14
15
|
title: 'Checking platform',
|
|
@@ -16,14 +17,14 @@ const checkPlatform = () => ({
|
|
|
16
17
|
const currentPlatform = os.platform();
|
|
17
18
|
|
|
18
19
|
if (!platforms.includes(currentPlatform)) {
|
|
19
|
-
throw new
|
|
20
|
+
throw new KnownError(
|
|
20
21
|
`Your current OS platform is ${ logger.style.misc(currentPlatform) }.
|
|
21
22
|
Unfortunately, currently we only support ${ platforms.map((platform) => logger.style.misc(platform)).join(',') }.`
|
|
22
23
|
);
|
|
23
24
|
}
|
|
24
25
|
|
|
25
26
|
if (macosVersion.isMacOS && !macosVersion.isGreaterThanOrEqualTo(darwinMinimalVersion)) {
|
|
26
|
-
throw new
|
|
27
|
+
throw new KnownError(
|
|
27
28
|
'Please update your system!',
|
|
28
29
|
`MacOS bellow version ${ logger.style.misc(darwinMinimalVersion) } is not supported.`
|
|
29
30
|
);
|
|
@@ -36,6 +37,7 @@ const checkPlatform = () => ({
|
|
|
36
37
|
|
|
37
38
|
ctx.platform = currentPlatform;
|
|
38
39
|
ctx.platformVersion = currentPlatform !== 'darwin' ? os.release() : macosVersion();
|
|
40
|
+
ctx.isArmMac = ctx.isArm && ctx.platform === 'darwin';
|
|
39
41
|
|
|
40
42
|
const { manufacturer, brand, cores } = await systeminformation.cpu();
|
|
41
43
|
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
const { execAsyncSpawn, execCommandTask } = require('../../util/exec-async-command');
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @returns {import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
|
|
5
|
+
*/
|
|
6
|
+
const checkRosetta = () => ({
|
|
7
|
+
skip: (ctx) => !ctx.isArmMac,
|
|
8
|
+
task: async (ctx, task) => {
|
|
9
|
+
task.title = 'Checking Rosetta 2 status';
|
|
10
|
+
|
|
11
|
+
const { code } = await execAsyncSpawn('arch -x86_64 echo "test"', {
|
|
12
|
+
withCode: true
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
if (code === 1) {
|
|
16
|
+
task.output = 'Rosetta 2 is not installed, installing...';
|
|
17
|
+
return task.newListr(
|
|
18
|
+
execCommandTask('softwareupdate --install-rosetta --agree-to-license', {
|
|
19
|
+
pipeInput: true,
|
|
20
|
+
callback: (t) => {
|
|
21
|
+
task.output = t;
|
|
22
|
+
}
|
|
23
|
+
})
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
options: {
|
|
28
|
+
bottomBar: 10
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
module.exports = checkRosetta;
|
package/lib/tasks/start.js
CHANGED
|
@@ -29,6 +29,9 @@ const convertLegacyVolumes = require('./docker/convert-legacy-volumes');
|
|
|
29
29
|
const enableMagentoComposerPlugins = require('./magento/enable-magento-composer-plugins');
|
|
30
30
|
const getIsWsl = require('../util/is-wsl');
|
|
31
31
|
const checkForXDGOpen = require('../util/xdg-open-exists');
|
|
32
|
+
const { getInstanceMetadata, constants: { WEB_LOCATION_TITLE } } = require('../util/instance-metadata');
|
|
33
|
+
const validatePHPInstallation = require('./php/validate-php');
|
|
34
|
+
const installSodiumExtension = require('./php/install-sodium');
|
|
32
35
|
|
|
33
36
|
/**
|
|
34
37
|
* @type {() => import('listr2').ListrTask<import('../../typings/context').ListrContext>}
|
|
@@ -111,7 +114,9 @@ const configureProject = () => ({
|
|
|
111
114
|
exitOnError: true
|
|
112
115
|
})
|
|
113
116
|
},
|
|
117
|
+
installSodiumExtension(),
|
|
114
118
|
configurePhp(),
|
|
119
|
+
validatePHPInstallation(),
|
|
115
120
|
installPrestissimo(),
|
|
116
121
|
installMagento(),
|
|
117
122
|
enableMagentoComposerPlugins(),
|
|
@@ -184,8 +189,11 @@ const start = () => ({
|
|
|
184
189
|
|
|
185
190
|
return false;
|
|
186
191
|
},
|
|
187
|
-
task: (
|
|
188
|
-
|
|
192
|
+
task: (ctx) => {
|
|
193
|
+
const instanceMetadata = getInstanceMetadata(ctx);
|
|
194
|
+
const locationOnTheWeb = instanceMetadata.frontend.find(({ title }) => title === WEB_LOCATION_TITLE);
|
|
195
|
+
|
|
196
|
+
openBrowser(locationOnTheWeb.link);
|
|
189
197
|
},
|
|
190
198
|
options: {
|
|
191
199
|
showTimer: false
|
|
@@ -3,6 +3,7 @@ const pathExists = require('../../util/path-exists');
|
|
|
3
3
|
const { execAsyncSpawn } = require('../../util/exec-async-command');
|
|
4
4
|
const logger = require('@scandipwa/scandipwa-dev-utils/logger');
|
|
5
5
|
const matchFilesystem = require('../../util/match-filesystem');
|
|
6
|
+
const UnknownError = require('../../errors/unknown-error');
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* @type {(theme: import('../../../typings/theme').Theme) => import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
|
|
@@ -26,7 +27,7 @@ const buildTheme = ({ themePath }) => ({
|
|
|
26
27
|
}
|
|
27
28
|
});
|
|
28
29
|
} catch (e) {
|
|
29
|
-
throw new
|
|
30
|
+
throw new UnknownError(`We were unable to install theme dependencies in ${themePath} using ${logger.style.code(commandToInstallDependencies)} command!
|
|
30
31
|
If you have ${logger.style.file('package-lock.json')} in theme directory make sure it's up to date with ${logger.style.file('package.json')} file content.`);
|
|
31
32
|
}
|
|
32
33
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
|
+
const UnknownError = require('../../errors/unknown-error');
|
|
2
3
|
const getJsonfileData = require('../../util/get-jsonfile-data');
|
|
3
4
|
const runComposerCommand = require('../../util/run-composer');
|
|
4
5
|
|
|
@@ -24,7 +25,7 @@ const installTheme = (theme) => ({
|
|
|
24
25
|
}
|
|
25
26
|
});
|
|
26
27
|
} catch (e) {
|
|
27
|
-
throw new
|
|
28
|
+
throw new UnknownError(
|
|
28
29
|
`Unexpected error while installing theme.
|
|
29
30
|
See ERROR log below.\n\n${e}`
|
|
30
31
|
);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const symlinkTheme = require('./symlink-theme');
|
|
2
2
|
const installTheme = require('./install-theme');
|
|
3
|
-
const
|
|
3
|
+
const adjustFullPageCache = require('../magento/setup-magento/adjust-full-page-cache');
|
|
4
4
|
const disablePageBuilder = require('../magento/setup-magento/disable-page-builder');
|
|
5
5
|
const buildTheme = require('./build-theme');
|
|
6
6
|
const upgradeMagento = require('../magento/setup-magento/upgrade-magento');
|
|
@@ -53,7 +53,7 @@ const linkTheme = () => ({
|
|
|
53
53
|
updateEnvPHP(),
|
|
54
54
|
setupPersistedQuery(),
|
|
55
55
|
upgradeMagento(),
|
|
56
|
-
|
|
56
|
+
adjustFullPageCache(),
|
|
57
57
|
...(isPageBuilderInstalled && Number(isPagebuilderEnabled) ? [disablePageBuilder()] : []),
|
|
58
58
|
buildTheme(theme)
|
|
59
59
|
]);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
|
+
const KnownError = require('../../errors/known-error');
|
|
2
3
|
const getJsonfileData = require('../../util/get-jsonfile-data');
|
|
3
4
|
const pathExists = require('../../util/path-exists');
|
|
4
5
|
|
|
@@ -26,7 +27,7 @@ const retrieveThemeData = (themePath) => ({
|
|
|
26
27
|
const composerData = await getJsonfileData(path.join(absoluteThemePath, 'composer.json'));
|
|
27
28
|
|
|
28
29
|
if (!composerData) {
|
|
29
|
-
throw new
|
|
30
|
+
throw new KnownError(`composer.json file not found in "${themePath}"`);
|
|
30
31
|
}
|
|
31
32
|
|
|
32
33
|
ctx.themePath = themePath;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
|
+
const UnknownError = require('../../errors/unknown-error');
|
|
2
3
|
const envPhpToJson = require('../../util/env-php-json');
|
|
3
4
|
const getJsonfileData = require('../../util/get-jsonfile-data');
|
|
4
5
|
const runMagentoCommand = require('../../util/run-magento');
|
|
@@ -51,7 +52,7 @@ const persistedQuerySetup = () => ({
|
|
|
51
52
|
magentoVersion
|
|
52
53
|
});
|
|
53
54
|
} catch (e) {
|
|
54
|
-
throw new
|
|
55
|
+
throw new UnknownError(
|
|
55
56
|
`Unexpected error while setting redis for pq!.
|
|
56
57
|
See ERROR log below.\n\n${e}`
|
|
57
58
|
);
|
|
@@ -5,8 +5,9 @@ const symlinkTheme = require('./symlink-theme');
|
|
|
5
5
|
const installTheme = require('./install-theme');
|
|
6
6
|
const setupPersistedQuery = require('./setup-persisted-query');
|
|
7
7
|
const upgradeMagento = require('../magento/setup-magento/upgrade-magento');
|
|
8
|
-
const
|
|
8
|
+
const adjustFullPageCache = require('../magento/setup-magento/adjust-full-page-cache');
|
|
9
9
|
const buildTheme = require('./build-theme');
|
|
10
|
+
const KnownError = require('../../errors/known-error');
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
13
|
* @type {() => import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
|
|
@@ -16,6 +17,12 @@ const setupThemes = () => ({
|
|
|
16
17
|
task: async (ctx, task) => {
|
|
17
18
|
const { config: { baseConfig } } = ctx;
|
|
18
19
|
const composerData = await getJsonfileData(path.join(baseConfig.magentoDir, 'composer.json'));
|
|
20
|
+
|
|
21
|
+
if (!composerData.repositories) {
|
|
22
|
+
task.skip();
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
|
|
19
26
|
const composerLocalPaths = Array.isArray(composerData.repositories)
|
|
20
27
|
? composerData.repositories.filter((repo) => repo.type === 'path')
|
|
21
28
|
: Object.values(composerData.repositories).filter((repo) => repo.type === 'path');
|
|
@@ -61,7 +68,7 @@ const setupThemes = () => ({
|
|
|
61
68
|
const composerData = await getJsonfileData(path.join(absoluteThemePath, 'composer.json'));
|
|
62
69
|
|
|
63
70
|
if (!composerData) {
|
|
64
|
-
throw new
|
|
71
|
+
throw new KnownError(`composer.json file not found in "${themePath}"`);
|
|
65
72
|
}
|
|
66
73
|
|
|
67
74
|
return {
|
|
@@ -81,7 +88,7 @@ const setupThemes = () => ({
|
|
|
81
88
|
])
|
|
82
89
|
})).concat([
|
|
83
90
|
upgradeMagento(),
|
|
84
|
-
|
|
91
|
+
adjustFullPageCache(),
|
|
85
92
|
setupPersistedQuery()
|
|
86
93
|
])
|
|
87
94
|
);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
|
+
const UnknownError = require('../../errors/unknown-error');
|
|
2
3
|
const getJsonfileData = require('../../util/get-jsonfile-data');
|
|
3
4
|
const runComposerCommand = require('../../util/run-composer');
|
|
4
5
|
|
|
@@ -10,6 +11,12 @@ const symlinkTheme = (theme) => ({
|
|
|
10
11
|
task: async (ctx, task) => {
|
|
11
12
|
const { magentoVersion, verbose = false } = ctx;
|
|
12
13
|
const composerJsonData = await getJsonfileData(path.join(process.cwd(), 'composer.json'));
|
|
14
|
+
|
|
15
|
+
if (!composerJsonData.repositories) {
|
|
16
|
+
task.skip();
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
|
|
13
20
|
const repositories = Array.isArray(composerJsonData.repositories)
|
|
14
21
|
? composerJsonData.repositories.reduce((acc, repo, index) => ({ ...acc, [`${index}`]: repo }), {})
|
|
15
22
|
: composerJsonData.repositories;
|
|
@@ -27,7 +34,7 @@ const symlinkTheme = (theme) => ({
|
|
|
27
34
|
}
|
|
28
35
|
});
|
|
29
36
|
} catch (e) {
|
|
30
|
-
throw new
|
|
37
|
+
throw new UnknownError(
|
|
31
38
|
`Unexpected error while configuring theme symbolic link.
|
|
32
39
|
See ERROR log above.\n\n${e}`
|
|
33
40
|
);
|
package/lib/util/CSA-theme.js
CHANGED
|
@@ -6,6 +6,10 @@ const getCSAThemes = async ({ cwd = process.cwd() } = {}) => {
|
|
|
6
6
|
path.join(cwd, 'composer.json')
|
|
7
7
|
);
|
|
8
8
|
|
|
9
|
+
if (!composerData.repositories) {
|
|
10
|
+
return [];
|
|
11
|
+
}
|
|
12
|
+
|
|
9
13
|
const pathRepositories = Object.entries(composerData.repositories)
|
|
10
14
|
.filter(([_, repoOptions]) => repoOptions.type === 'path');
|
|
11
15
|
|
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
const os = require('os');
|
|
2
|
+
const { request } = require('smol-request');
|
|
3
|
+
const logger = require('@scandipwa/scandipwa-dev-utils/logger');
|
|
4
|
+
const generateUUID = require('@tilework/mosaic-dev-utils/uuid');
|
|
5
|
+
const { getSystemConfigSync } = require('../config/system-config');
|
|
6
|
+
const { getExternalIpAddress } = require('./ip');
|
|
7
|
+
const pkg = require('../../package.json');
|
|
8
|
+
|
|
9
|
+
const GA_TRACKING_ID = process.env.GA_TRACKING_ID || 'UA-127741417-8';
|
|
10
|
+
const UNKNOWN = 'unknown';
|
|
11
|
+
|
|
12
|
+
const anonymizeError = (text) => text.replace(new RegExp(`${os.homedir()}`, 'gi'), '/home/magento-scripts-user');
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Google Analytics Parameters
|
|
16
|
+
* @typedef {Object} GAParameters
|
|
17
|
+
* @property {String} version
|
|
18
|
+
* @property {String} trackingID
|
|
19
|
+
* @property {String} [dataSource]
|
|
20
|
+
* @property {Object} [user]
|
|
21
|
+
* @property {String} [user.clientID]
|
|
22
|
+
* @property {String} [user.userID]
|
|
23
|
+
* @property {Object} [session]
|
|
24
|
+
* @property {String} [session.sessionControl]
|
|
25
|
+
* @property {String} [session.ipOverride]
|
|
26
|
+
* @property {String} [session.userAgentOverride]
|
|
27
|
+
* @property {Object} [systemInfo]
|
|
28
|
+
* @property {String} [systemInfo.userLanguage]
|
|
29
|
+
* @property {Object} [contentInformation]
|
|
30
|
+
* @property {String} [contentInformation.documentLocationUrl]
|
|
31
|
+
* @property {String} [contentInformation.documentPath]
|
|
32
|
+
* @property {String} [contentInformation.documentHostName]
|
|
33
|
+
* @property {Object} [timing]
|
|
34
|
+
* @property {String} [timing.userTimingCategory]
|
|
35
|
+
* @property {String} [timing.userTimingVariableName]
|
|
36
|
+
* @property {String} [timing.userTimingTime]
|
|
37
|
+
* @property {String} [timing.userTimingLabel]
|
|
38
|
+
* @property {Object} [hit]
|
|
39
|
+
* @property {String} [hit.type]
|
|
40
|
+
* @property {Object} [exception]
|
|
41
|
+
* @property {String} [exception.description]
|
|
42
|
+
* @property {Boolean} [exception.fatal]
|
|
43
|
+
* @property {Object} [event]
|
|
44
|
+
* @property {String} event.category
|
|
45
|
+
* @property {String} event.action
|
|
46
|
+
* @property {String} [event.label]
|
|
47
|
+
* @property {String} [event.value]
|
|
48
|
+
* @property {Object} [app]
|
|
49
|
+
* @property {String} [app.name]
|
|
50
|
+
* @property {String} [app.id]
|
|
51
|
+
* @property {String} [app.version]
|
|
52
|
+
* @property {String} [app.installedID]
|
|
53
|
+
* @property {Record<string, string>} [customDimension]
|
|
54
|
+
*/
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* @type {GAParameters}
|
|
58
|
+
*/
|
|
59
|
+
const gaParametersMapping = {
|
|
60
|
+
version: 'v',
|
|
61
|
+
trackingID: 'tid',
|
|
62
|
+
user: {
|
|
63
|
+
clientID: 'cid',
|
|
64
|
+
userID: 'uid'
|
|
65
|
+
},
|
|
66
|
+
session: {
|
|
67
|
+
sessionControl: 'sc',
|
|
68
|
+
ipOverride: 'uip',
|
|
69
|
+
userAgentOverride: 'ua'
|
|
70
|
+
},
|
|
71
|
+
systemInfo: {
|
|
72
|
+
userLanguage: 'ul'
|
|
73
|
+
},
|
|
74
|
+
contentInformation: {
|
|
75
|
+
documentLocationUrl: 'dl',
|
|
76
|
+
documentPath: 'dp',
|
|
77
|
+
documentHostName: 'dh'
|
|
78
|
+
},
|
|
79
|
+
timing: {
|
|
80
|
+
userTimingCategory: 'utc',
|
|
81
|
+
userTimingVariableName: 'utv',
|
|
82
|
+
userTimingTime: 'utt',
|
|
83
|
+
userTimingLabel: 'utl'
|
|
84
|
+
},
|
|
85
|
+
hit: {
|
|
86
|
+
type: 't'
|
|
87
|
+
},
|
|
88
|
+
exception: {
|
|
89
|
+
description: 'exd',
|
|
90
|
+
fatal: 'exf'
|
|
91
|
+
},
|
|
92
|
+
event: {
|
|
93
|
+
category: 'ec',
|
|
94
|
+
action: 'ea',
|
|
95
|
+
label: 'el',
|
|
96
|
+
value: 'ev'
|
|
97
|
+
},
|
|
98
|
+
app: {
|
|
99
|
+
name: 'an',
|
|
100
|
+
id: 'aid',
|
|
101
|
+
version: 'av',
|
|
102
|
+
installedID: 'aiid'
|
|
103
|
+
},
|
|
104
|
+
customDimension: Array.from({ length: 200 }, (_, i) => i + 1).reduce((acc, val) => ({
|
|
105
|
+
...acc,
|
|
106
|
+
[`customDimension${val}`]: `cd${val}`
|
|
107
|
+
}), {})
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
const getAppData = () => ({
|
|
111
|
+
name: pkg.name,
|
|
112
|
+
version: pkg.version
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* @param {GAParameters} parameters
|
|
117
|
+
*/
|
|
118
|
+
const collectAnalyticsParameters = (parameters) => {
|
|
119
|
+
const parsedParameters = {};
|
|
120
|
+
|
|
121
|
+
for (const [firstLevelKey, firstLevelValue] of Object.entries(gaParametersMapping)) {
|
|
122
|
+
if (typeof firstLevelValue === 'object' && firstLevelValue !== null) {
|
|
123
|
+
for (const [secondLevelKey, secondLevelValue] of Object.entries(firstLevelValue)) {
|
|
124
|
+
if (parameters[firstLevelKey] && parameters[firstLevelKey][secondLevelKey]) {
|
|
125
|
+
parsedParameters[secondLevelValue] = parameters[firstLevelKey][secondLevelKey];
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
} else if (parameters[firstLevelKey]) {
|
|
129
|
+
parsedParameters[firstLevelValue] = parameters[firstLevelKey];
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
return parsedParameters;
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
class Analytics {
|
|
137
|
+
constructor() {
|
|
138
|
+
this.isGaDisabled = this.getIsGaDisabled();
|
|
139
|
+
this.gaTrackingId = GA_TRACKING_ID;
|
|
140
|
+
this.clientIdentifier = UNKNOWN;
|
|
141
|
+
this.currentUrl = UNKNOWN;
|
|
142
|
+
this.lang = UNKNOWN;
|
|
143
|
+
|
|
144
|
+
try {
|
|
145
|
+
this.setClientIdentifier(
|
|
146
|
+
generateUUID()
|
|
147
|
+
);
|
|
148
|
+
} catch (e) {
|
|
149
|
+
this.setClientIdentifier(
|
|
150
|
+
Date.now()
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
setLang(lang) {
|
|
156
|
+
this.lang = lang;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
setCurrentUrl(currentUrl) {
|
|
160
|
+
this.currentUrl = currentUrl;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
setClientIdentifier(id) {
|
|
164
|
+
this.clientIdentifier = id;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
setGaTrackingId(id) {
|
|
168
|
+
this.gaTrackingId = id;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
getIsGaDisabled() {
|
|
172
|
+
const { analytics } = getSystemConfigSync({ validate: false });
|
|
173
|
+
|
|
174
|
+
return !analytics;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* @param {GAParameters} data
|
|
179
|
+
*/
|
|
180
|
+
async _collect(data) {
|
|
181
|
+
if (this.isGaDisabled) {
|
|
182
|
+
// skip GA
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* @type {GAParameters}
|
|
188
|
+
*/
|
|
189
|
+
const analyticsParameters = {
|
|
190
|
+
...data,
|
|
191
|
+
version: '1',
|
|
192
|
+
trackingID: this.gaTrackingId,
|
|
193
|
+
user: {
|
|
194
|
+
clientID: this.clientIdentifier
|
|
195
|
+
},
|
|
196
|
+
app: getAppData()
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
try {
|
|
200
|
+
analyticsParameters.systemInfo = {
|
|
201
|
+
ipOverride: await getExternalIpAddress()
|
|
202
|
+
};
|
|
203
|
+
} catch (e) {
|
|
204
|
+
// Do nothing
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
if (this.lang !== UNKNOWN) {
|
|
208
|
+
// get system language here
|
|
209
|
+
analyticsParameters.systemInfo = {
|
|
210
|
+
userLanguage: this.lang
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
if (this.currentUrl !== UNKNOWN) {
|
|
215
|
+
const {
|
|
216
|
+
hostname,
|
|
217
|
+
pathname
|
|
218
|
+
} = new URL(this.currentUrl);
|
|
219
|
+
|
|
220
|
+
analyticsParameters.contentInformation = {
|
|
221
|
+
documentLocationUrl: this.currentUrl,
|
|
222
|
+
documentPath: pathname,
|
|
223
|
+
documentHostName: hostname
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
const params = new URLSearchParams(collectAnalyticsParameters(analyticsParameters)).toString();
|
|
228
|
+
|
|
229
|
+
try {
|
|
230
|
+
if (!process.env.GA_DEBUG) {
|
|
231
|
+
await request(
|
|
232
|
+
`https://www.google-analytics.com/collect?${ params }`,
|
|
233
|
+
{
|
|
234
|
+
headers: { 'User-Agent': 'Google-Cloud-Functions' },
|
|
235
|
+
responseType: 'headers'
|
|
236
|
+
}
|
|
237
|
+
);
|
|
238
|
+
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
const { data: jsonResponse } = await request(
|
|
243
|
+
`https://www.google-analytics.com/debug/collect?${ params }`,
|
|
244
|
+
{
|
|
245
|
+
headers: { 'User-Agent': 'Google-Cloud-Functions' },
|
|
246
|
+
responseType: 'json'
|
|
247
|
+
}
|
|
248
|
+
);
|
|
249
|
+
|
|
250
|
+
logger.log(analyticsParameters);
|
|
251
|
+
logger.log(JSON.stringify(jsonResponse, null, 2));
|
|
252
|
+
|
|
253
|
+
// eslint-disable-next-line no-empty
|
|
254
|
+
} catch (e) {
|
|
255
|
+
console.log('Failed to report telemetry data');
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
trackError(error, isFatal = true) {
|
|
260
|
+
// return; // nothing
|
|
261
|
+
return this._collect({
|
|
262
|
+
hit: {
|
|
263
|
+
type: 'exception'
|
|
264
|
+
},
|
|
265
|
+
exception: {
|
|
266
|
+
description: anonymizeError(typeof error === 'string' ? error : error.message),
|
|
267
|
+
fatal: isFatal
|
|
268
|
+
}
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
trackTiming(label, time, category = UNKNOWN) {
|
|
273
|
+
return this._collect({
|
|
274
|
+
hit: {
|
|
275
|
+
type: 'timing'
|
|
276
|
+
},
|
|
277
|
+
timing: {
|
|
278
|
+
userTimingCategory: category,
|
|
279
|
+
userTimingVariableName: label,
|
|
280
|
+
userTimingLabel: this.currentUrl,
|
|
281
|
+
userTimingTime: Math.round(time)
|
|
282
|
+
}
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
trackPageView() {
|
|
287
|
+
return this._collect({
|
|
288
|
+
hit: {
|
|
289
|
+
type: 'pageview'
|
|
290
|
+
}
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
trackEvent(action, label, value, category = UNKNOWN) {
|
|
295
|
+
return this._collect({
|
|
296
|
+
hit: {
|
|
297
|
+
type: 'event'
|
|
298
|
+
},
|
|
299
|
+
event: {
|
|
300
|
+
category,
|
|
301
|
+
action,
|
|
302
|
+
label,
|
|
303
|
+
value
|
|
304
|
+
}
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
printAboutAnalytics() {
|
|
309
|
+
if (!this.isGaDisabled) {
|
|
310
|
+
logger.log('We collect analytics data to make our products more stable and reliable!');
|
|
311
|
+
logger.log('If you want to know more go here https://docs.scandipwa.com/about/data-analytics');
|
|
312
|
+
logger.logN();
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
module.exports = new Analytics();
|
package/lib/util/arch.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
const Joi = require('joi');
|
|
2
2
|
const semver = require('semver');
|
|
3
|
+
const KnownError = require('../errors/known-error');
|
|
3
4
|
const pathExistsSync = require('./path-exists-sync');
|
|
4
5
|
|
|
5
6
|
const fileExistsValidator = (value) => {
|
|
6
7
|
const fileExists = pathExistsSync(value);
|
|
7
8
|
|
|
8
9
|
if (!fileExists) {
|
|
9
|
-
throw new
|
|
10
|
+
throw new KnownError(`File "${value}" does not exists!`);
|
|
10
11
|
}
|
|
11
12
|
|
|
12
13
|
return undefined;
|