@scandipwa/magento-scripts 1.14.1-alpha.8 → 1.15.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commands/cli.js +9 -4
- package/lib/commands/logs.js +1 -0
- package/lib/commands/start.js +18 -5
- package/lib/config/check-configuration-file.js +16 -1
- package/lib/config/cma-config.js +16 -0
- package/lib/config/dependencies-for-platforms.js +15 -3
- package/lib/config/docker.js +45 -12
- package/lib/config/get-port-config.js +7 -2
- package/lib/config/index.js +2 -1
- package/lib/config/php/extensions/libsodium.js +2 -1
- package/lib/config/port-config.js +2 -1
- package/lib/config/scandipwa-versions.js +2 -1
- package/lib/config/ssl-terminator/index.js +10 -0
- package/lib/config/system-config.js +34 -5
- package/lib/config/templates/magentorc.template +2 -0
- package/lib/config/templates/nginx.template.conf +0 -31
- package/lib/config/templates/ssl-terminator.template.conf +27 -0
- package/lib/config/templates/varnish.template.vcl +9 -4
- package/lib/config/versions/magento-2.3.0.js +3 -1
- package/lib/config/versions/magento-2.3.1.js +3 -1
- package/lib/config/versions/magento-2.3.2-p2.js +3 -1
- package/lib/config/versions/magento-2.3.2.js +3 -1
- package/lib/config/versions/magento-2.3.3-p1.js +3 -1
- package/lib/config/versions/magento-2.3.3.js +3 -1
- package/lib/config/versions/magento-2.3.4-p2.js +3 -1
- package/lib/config/versions/magento-2.3.4.js +3 -1
- package/lib/config/versions/magento-2.3.5-p1.js +3 -1
- package/lib/config/versions/magento-2.3.5-p2.js +3 -1
- package/lib/config/versions/magento-2.3.5.js +3 -1
- package/lib/config/versions/magento-2.3.6-p1.js +3 -1
- package/lib/config/versions/magento-2.3.6.js +3 -1
- package/lib/config/versions/magento-2.3.7-p1.js +3 -1
- package/lib/config/versions/magento-2.3.7-p2.js +3 -1
- package/lib/config/versions/magento-2.3.7-p3.js +3 -1
- package/lib/config/versions/magento-2.3.7.js +3 -1
- package/lib/config/versions/magento-2.4.0-p1.js +3 -1
- package/lib/config/versions/magento-2.4.0.js +3 -1
- package/lib/config/versions/magento-2.4.1-p1.js +3 -1
- package/lib/config/versions/magento-2.4.1.js +3 -1
- package/lib/config/versions/magento-2.4.2-p1.js +3 -1
- package/lib/config/versions/magento-2.4.2-p2.js +3 -1
- package/lib/config/versions/magento-2.4.2.js +3 -1
- package/lib/config/versions/magento-2.4.3-p1.js +3 -1
- package/lib/config/versions/magento-2.4.3-p2.js +3 -1
- package/lib/config/versions/magento-2.4.3.js +3 -1
- package/lib/config/versions/magento-2.4.4.js +3 -1
- package/lib/config/xml-parser.js +63 -0
- package/lib/errors/known-error.js +15 -0
- package/lib/errors/unknown-error.js +15 -0
- package/lib/tasks/cli/create-bashrc-config.js +2 -1
- package/lib/tasks/composer/index.js +5 -3
- package/lib/tasks/composer/local-auth-json.js +8 -4
- package/lib/tasks/docker/network.js +2 -1
- package/lib/tasks/execute/index.js +2 -3
- package/lib/tasks/file-system/create-nginx-config.js +4 -43
- package/lib/tasks/file-system/create-php-config.js +2 -1
- package/lib/tasks/file-system/create-php-fpm-config.js +2 -1
- package/lib/tasks/file-system/create-phpstorm-config/database-config.js +249 -0
- package/lib/tasks/file-system/create-phpstorm-config/eslint-config.js +85 -0
- package/lib/tasks/file-system/create-phpstorm-config/exclude-folder-config.js +154 -0
- package/lib/tasks/file-system/create-phpstorm-config/index.js +27 -0
- package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/coding-standard-config.js +26 -0
- package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/config.js +54 -0
- package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/custom-ruleset-path-config.js +28 -0
- package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/default-properties-config.js +42 -0
- package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/eslint-inspection-config.js +37 -0
- package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/index.js +80 -0
- package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/magento-coding-standard-config.js +26 -0
- package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/mess-detector-validation-inspection-config.js +142 -0
- package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/paths.js +20 -0
- package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/php-cs-fixer-validation-inspection-config.js +60 -0
- package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/php-cs-validation-inspection-config.js +116 -0
- package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/stylelint-inspection-config.js +37 -0
- package/lib/tasks/file-system/create-phpstorm-config/keys.js +14 -0
- package/lib/tasks/file-system/create-phpstorm-config/php-config/index.js +67 -0
- package/lib/tasks/file-system/create-phpstorm-config/php-config/mess-detector-config.js +54 -0
- package/lib/tasks/file-system/create-phpstorm-config/php-config/php-code-sniffer-config.js +66 -0
- package/lib/tasks/file-system/create-phpstorm-config/php-config/php-cs-fixer-config.js +58 -0
- package/lib/tasks/file-system/create-phpstorm-config/php-config/php-project-shared-configuration-config.js +59 -0
- package/lib/tasks/file-system/create-phpstorm-config/stylelint-config.js +77 -0
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/composer-settings-config.js +97 -0
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/format-setting-config.js +57 -0
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/index.js +66 -0
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/php-debug-general-config.js +64 -0
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/php-server-config.js +57 -0
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/properties-component-config.js +49 -0
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/run-manager-config.js +64 -0
- package/lib/tasks/file-system/create-phpstorm-config/xml-utils.js +5 -0
- package/lib/tasks/file-system/create-ssl-terminator-config.js +96 -0
- package/lib/tasks/file-system/create-varnish-config.js +2 -1
- package/lib/tasks/file-system/create-vscode-config.js +3 -2
- package/lib/tasks/file-system/index.js +3 -1
- package/lib/tasks/magento/enable-magento-composer-plugins.js +3 -2
- package/lib/tasks/magento/install-magento.js +7 -5
- package/lib/tasks/magento/setup-magento/adjust-full-page-cache.js +26 -0
- package/lib/tasks/magento/setup-magento/delete-admin-users.js +1 -1
- package/lib/tasks/magento/setup-magento/delete-customers.js +7 -4
- package/lib/tasks/magento/setup-magento/delete-orders.js +6 -4
- package/lib/tasks/magento/setup-magento/flush-redis-config.js +2 -1
- package/lib/tasks/magento/setup-magento/index.js +3 -1
- package/lib/tasks/magento/setup-magento/install-magento.js +2 -1
- package/lib/tasks/magento/setup-magento/set-base-url.js +7 -2
- package/lib/tasks/magento/setup-magento/upgrade-magento.js +11 -1
- package/lib/tasks/magento/setup-magento/waiting-for-varnish.js +41 -0
- package/lib/tasks/mysql/connect-to-mysql.js +2 -1
- package/lib/tasks/mysql/import-dump-to-mysql.js +13 -2
- package/lib/tasks/mysql/import-remote-db/index.js +2 -1
- package/lib/tasks/mysql/import-remote-db/ssh/index.js +2 -1
- package/lib/tasks/mysql/import-remote-db/ssh/regular-server.js +2 -1
- package/lib/tasks/php/bundled-extensions.js +28 -0
- package/lib/tasks/php/compile-options.js +27 -54
- package/lib/tasks/php/compile.js +6 -4
- package/lib/tasks/php/configure.js +7 -66
- package/lib/tasks/php/extensions/disable.js +2 -1
- package/lib/tasks/php/extensions/enable.js +2 -1
- package/lib/tasks/php/extensions/index.js +74 -0
- package/lib/tasks/php/extensions/install.js +3 -3
- package/lib/tasks/php/index.js +7 -6
- package/lib/tasks/php/install-sodium.js +93 -0
- package/lib/tasks/php/update-phpbrew.js +7 -3
- package/lib/tasks/php/validate-php.js +67 -0
- package/lib/tasks/php-fpm/start-php-fpm.js +4 -2
- package/lib/tasks/requirements/composer.js +59 -5
- package/lib/tasks/requirements/dependency/arch.js +2 -1
- package/lib/tasks/requirements/dependency/centos.js +2 -1
- package/lib/tasks/requirements/dependency/fedora.js +2 -1
- package/lib/tasks/requirements/dependency/mac.js +18 -3
- package/lib/tasks/requirements/docker/index.js +94 -40
- package/lib/tasks/requirements/docker/install-on-mac.js +29 -0
- package/lib/tasks/requirements/docker/install.js +2 -1
- package/lib/tasks/requirements/docker/running-status.js +32 -31
- package/lib/tasks/requirements/docker/version.js +2 -1
- package/lib/tasks/requirements/index.js +3 -0
- package/lib/tasks/requirements/node-version.js +2 -1
- package/lib/tasks/requirements/php-version.js +26 -24
- package/lib/tasks/requirements/phpbrew/index.js +2 -1
- package/lib/tasks/requirements/phpbrew/install.js +14 -2
- package/lib/tasks/requirements/phpbrew/version.js +2 -1
- package/lib/tasks/requirements/platform.js +5 -3
- package/lib/tasks/requirements/rosetta.js +32 -0
- package/lib/tasks/start.js +10 -2
- package/lib/tasks/status/index.js +24 -8
- package/lib/tasks/theme/build-theme.js +2 -1
- package/lib/tasks/theme/install-theme.js +2 -1
- package/lib/tasks/theme/link-theme.js +2 -2
- package/lib/tasks/theme/retrieve-theme-data.js +2 -1
- package/lib/tasks/theme/setup-persisted-query.js +2 -1
- package/lib/tasks/theme/setup-themes.js +10 -3
- package/lib/tasks/theme/symlink-theme.js +8 -1
- package/lib/util/CSA-theme.js +4 -0
- package/lib/util/analytics.js +320 -0
- package/lib/util/arch.js +1 -1
- package/lib/util/config-file-validator.js +4 -2
- package/lib/util/config-php-json.js +3 -2
- package/lib/util/env-php-json.js +3 -2
- package/lib/util/exec-async-command.d.ts +2 -0
- package/lib/util/exec-async-command.js +31 -15
- package/lib/util/exec-async.js +9 -0
- package/lib/util/get-brew-bin-path.js +64 -0
- package/lib/util/get-installed-magento-version.js +3 -2
- package/lib/util/get-jsonfile-data.js +2 -1
- package/lib/util/install-dependencies-task.js +15 -5
- package/lib/util/instance-metadata.js +11 -4
- package/lib/util/ip.js +47 -1
- package/lib/util/magento-task.js +20 -9
- package/lib/util/php-task.js +7 -7
- package/lib/util/request.js +0 -0
- package/lib/util/resolve-configuration-with-overrides.js +2 -1
- package/lib/util/run-composer.js +5 -3
- package/lib/util/run-magento.js +3 -2
- package/lib/util/run-php.js +7 -2
- package/lib/util/wait-for-it.js +3 -2
- package/package.json +5 -3
- package/typings/context.d.ts +4 -0
- package/typings/index.d.ts +13 -1
- package/typings/phpstorm.d.ts +33 -0
- package/lib/tasks/file-system/create-php-storm-config.js +0 -82
- package/lib/tasks/magento/setup-magento/disable-full-page-cache.js +0 -20
|
@@ -0,0 +1,320 @@
|
|
|
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
|
+
if (process.env.GA_DEBUG) {
|
|
257
|
+
logger.error(e);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
trackError(error, isFatal = true) {
|
|
263
|
+
// return; // nothing
|
|
264
|
+
return this._collect({
|
|
265
|
+
hit: {
|
|
266
|
+
type: 'exception'
|
|
267
|
+
},
|
|
268
|
+
exception: {
|
|
269
|
+
description: anonymizeError(typeof error === 'string' ? error : error.message),
|
|
270
|
+
fatal: isFatal
|
|
271
|
+
}
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
trackTiming(label, time, category = UNKNOWN) {
|
|
276
|
+
return this._collect({
|
|
277
|
+
hit: {
|
|
278
|
+
type: 'timing'
|
|
279
|
+
},
|
|
280
|
+
timing: {
|
|
281
|
+
userTimingCategory: category,
|
|
282
|
+
userTimingVariableName: label,
|
|
283
|
+
userTimingLabel: this.currentUrl,
|
|
284
|
+
userTimingTime: Math.round(time)
|
|
285
|
+
}
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
trackPageView() {
|
|
290
|
+
return this._collect({
|
|
291
|
+
hit: {
|
|
292
|
+
type: 'pageview'
|
|
293
|
+
}
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
trackEvent(action, label, value, category = UNKNOWN) {
|
|
298
|
+
return this._collect({
|
|
299
|
+
hit: {
|
|
300
|
+
type: 'event'
|
|
301
|
+
},
|
|
302
|
+
event: {
|
|
303
|
+
category,
|
|
304
|
+
action,
|
|
305
|
+
label,
|
|
306
|
+
value
|
|
307
|
+
}
|
|
308
|
+
});
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
printAboutAnalytics() {
|
|
312
|
+
if (!this.isGaDisabled) {
|
|
313
|
+
logger.log('We collect analytics data to make our products more stable and reliable!');
|
|
314
|
+
logger.log('If you want to know more go here https://docs.scandipwa.com/about/data-analytics');
|
|
315
|
+
logger.logN();
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
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;
|
|
@@ -111,7 +112,8 @@ const configurationSchema = Joi.object({
|
|
|
111
112
|
elasticsearch: serviceConfigurationSchema.optional(),
|
|
112
113
|
redis: serviceConfigurationSchema.optional(),
|
|
113
114
|
composer: composerConfigurationSchema.optional(),
|
|
114
|
-
varnish: varnishConfigurationSchema.optional()
|
|
115
|
+
varnish: varnishConfigurationSchema.optional(),
|
|
116
|
+
sslTerminator: nginxConfigurationSchema.optional()
|
|
115
117
|
});
|
|
116
118
|
|
|
117
119
|
/**
|
|
@@ -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
|
/**
|
|
@@ -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
|
|
|
@@ -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
|
};
|