@scandipwa/magento-scripts 1.14.1-alpha.0 → 1.14.1-alpha.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +13 -0
- package/lib/commands/cli.js +28 -1
- package/lib/commands/execute.js +2 -1
- package/lib/commands/logs.js +1 -0
- package/lib/commands/start.js +18 -5
- package/lib/config/dependencies-for-platforms.js +12 -2
- package/lib/config/docker.js +89 -15
- package/lib/config/get-port-config.js +9 -3
- package/lib/config/index.js +2 -1
- package/lib/config/php/extensions/libsodium.js +2 -1
- package/lib/config/port-config.js +3 -1
- package/lib/config/scandipwa-versions.js +2 -1
- package/lib/config/ssl-terminator/index.js +10 -0
- package/lib/config/system-config.js +34 -5
- package/lib/config/templates/magentorc.template +3 -5
- package/lib/config/templates/nginx.template.conf +0 -14
- package/lib/config/templates/php.template.ini +6 -4
- package/lib/config/templates/ssl-terminator.template.conf +27 -0
- package/lib/config/templates/varnish.template.vcl +250 -0
- package/lib/config/varnish/varnish-6-0.js +11 -0
- package/lib/config/varnish/varnish-6-6.js +11 -0
- package/lib/config/varnish/varnish-7-0.js +11 -0
- package/lib/config/versions/magento-2.3.0.js +9 -1
- package/lib/config/versions/magento-2.3.1.js +9 -1
- package/lib/config/versions/magento-2.3.2-p2.js +9 -1
- package/lib/config/versions/magento-2.3.2.js +9 -1
- package/lib/config/versions/magento-2.3.3-p1.js +9 -1
- package/lib/config/versions/magento-2.3.3.js +9 -1
- package/lib/config/versions/magento-2.3.4-p2.js +9 -1
- package/lib/config/versions/magento-2.3.4.js +9 -1
- package/lib/config/versions/magento-2.3.5-p1.js +9 -1
- package/lib/config/versions/magento-2.3.5-p2.js +9 -1
- package/lib/config/versions/magento-2.3.5.js +9 -1
- package/lib/config/versions/magento-2.3.6-p1.js +9 -1
- package/lib/config/versions/magento-2.3.6.js +9 -1
- package/lib/config/versions/magento-2.3.7-p1.js +9 -1
- package/lib/config/versions/magento-2.3.7-p2.js +9 -1
- package/lib/config/versions/magento-2.3.7-p3.js +9 -1
- package/lib/config/versions/magento-2.3.7.js +9 -1
- package/lib/config/versions/magento-2.4.0-p1.js +9 -1
- package/lib/config/versions/magento-2.4.0.js +9 -1
- package/lib/config/versions/magento-2.4.1-p1.js +9 -1
- package/lib/config/versions/magento-2.4.1.js +9 -1
- package/lib/config/versions/magento-2.4.2-p1.js +9 -1
- package/lib/config/versions/magento-2.4.2-p2.js +9 -1
- package/lib/config/versions/magento-2.4.2.js +9 -1
- package/lib/config/versions/magento-2.4.3-p1.js +9 -1
- package/lib/config/versions/magento-2.4.3-p2.js +9 -1
- package/lib/config/versions/magento-2.4.3.js +9 -1
- package/lib/config/versions/magento-2.4.4.js +9 -1
- package/lib/errors/known-error.js +15 -0
- package/lib/errors/unknown-error.js +15 -0
- package/lib/tasks/cli/create-bashrc-config.js +7 -3
- package/lib/tasks/composer/index.js +5 -3
- package/lib/tasks/composer/local-auth-json.js +4 -2
- package/lib/tasks/docker/containers.js +13 -8
- package/lib/tasks/docker/network.js +2 -1
- package/lib/tasks/docker/volumes.js +4 -4
- package/lib/tasks/file-system/create-nginx-config.js +9 -40
- package/lib/tasks/file-system/create-php-config.js +2 -1
- package/lib/tasks/file-system/create-php-fpm-config.js +2 -1
- package/lib/tasks/file-system/create-php-storm-config.js +6 -5
- package/lib/tasks/file-system/create-ssl-terminator-config.js +96 -0
- package/lib/tasks/file-system/create-varnish-config.js +53 -0
- package/lib/tasks/file-system/create-vscode-config.js +3 -2
- package/lib/tasks/file-system/index.js +5 -1
- package/lib/tasks/magento/enable-magento-composer-plugins.js +3 -2
- package/lib/tasks/magento/install-magento.js +7 -5
- package/lib/tasks/magento/setup-magento/configure-elasticsearch.js +1 -1
- package/lib/tasks/magento/setup-magento/disable-2fa.js +4 -12
- package/lib/tasks/magento/setup-magento/disable-full-page-cache.js +20 -0
- package/lib/tasks/magento/setup-magento/flush-redis-config.js +2 -1
- package/lib/tasks/magento/setup-magento/increase-admin-session-lifetime.js +14 -16
- package/lib/tasks/magento/setup-magento/index.js +3 -1
- package/lib/tasks/magento/setup-magento/install-magento.js +2 -1
- package/lib/tasks/magento/setup-magento/migrate-database.js +24 -11
- package/lib/tasks/magento/setup-magento/set-base-url.js +7 -2
- package/lib/tasks/magento/setup-magento/upgrade-magento.js +27 -3
- package/lib/tasks/magento/setup-magento/varnish-config.js +69 -0
- package/lib/tasks/magento/setup-magento/waiting-for-varnish.js +41 -0
- package/lib/tasks/mysql/connect-to-mysql.js +2 -1
- package/lib/tasks/mysql/fix-db.js +2 -2
- package/lib/tasks/mysql/import-dump-to-mysql.js +4 -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 +18 -48
- package/lib/tasks/php/compile.js +4 -3
- package/lib/tasks/php/configure.js +7 -66
- package/lib/tasks/php/extensions/index.js +71 -0
- package/lib/tasks/php/index.js +8 -7
- package/lib/tasks/php/update-env-php.js +16 -1
- package/lib/tasks/php/update-env.php +56 -12
- package/lib/tasks/php/update-phpbrew.js +2 -1
- package/lib/tasks/php/validate-php.js +67 -0
- package/lib/tasks/php-fpm/start-php-fpm.js +2 -1
- package/lib/tasks/requirements/composer.js +5 -3
- 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/docker/index.js +7 -4
- package/lib/tasks/requirements/docker/install.js +13 -12
- package/lib/tasks/requirements/docker/running-status.js +138 -0
- package/lib/tasks/requirements/docker/version.js +3 -0
- package/lib/tasks/requirements/index.js +5 -5
- package/lib/tasks/requirements/node-version.js +2 -1
- package/lib/tasks/requirements/php-version.js +8 -4
- package/lib/tasks/requirements/phpbrew/index.js +2 -1
- package/lib/tasks/requirements/phpbrew/install.js +2 -1
- package/lib/tasks/requirements/phpbrew/version.js +2 -1
- package/lib/tasks/requirements/platform.js +3 -2
- package/lib/tasks/start.js +11 -10
- package/lib/tasks/status/index.js +25 -9
- package/lib/tasks/theme/build-theme.js +27 -8
- package/lib/tasks/theme/install-theme.js +18 -5
- package/lib/tasks/theme/link-theme.js +2 -2
- package/lib/tasks/theme/retrieve-theme-data.js +2 -1
- package/lib/tasks/theme/setup-persisted-query.js +5 -4
- package/lib/tasks/theme/setup-themes.js +5 -3
- package/lib/tasks/theme/symlink-theme.js +20 -4
- package/lib/util/analytics.js +337 -0
- package/lib/util/config-file-validator.js +14 -2
- package/lib/util/config-php-json.js +20 -0
- package/lib/util/env-php-json.js +3 -2
- package/lib/util/get-installed-magento-version.js +3 -2
- package/lib/util/get-jsonfile-data.js +2 -1
- package/lib/util/install-dependencies-task.js +4 -4
- package/lib/util/instance-metadata.js +11 -4
- package/lib/util/ip.js +45 -1
- package/lib/util/is-running-root.js +3 -0
- package/lib/util/magento-task.js +20 -9
- package/lib/util/match-filesystem.js +2 -1
- package/lib/util/php-task.js +6 -2
- package/lib/util/request.js +0 -0
- package/lib/util/resolve-configuration-with-overrides.js +2 -1
- package/lib/util/run-composer.js +3 -2
- package/lib/util/run-magento.js +3 -2
- package/lib/util/run-php.js +10 -3
- package/lib/util/systemctl.js +46 -0
- package/lib/util/wait-for-it.js +3 -2
- package/package.json +4 -3
- package/typings/context.d.ts +5 -1
- package/typings/index.d.ts +32 -1
- package/lib/tasks/magento/setup-magento/adjust-magento-configuration.js +0 -27
- package/lib/tasks/magento/setup-magento/disable-page-cache.js +0 -11
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
const os = require('os');
|
|
2
|
+
const KnownError = require('../../../errors/known-error');
|
|
3
|
+
const { execAsyncSpawn } = require('../../../util/exec-async-command');
|
|
4
|
+
const getIsWsl = require('../../../util/is-wsl');
|
|
5
|
+
const pathExists = require('../../../util/path-exists');
|
|
6
|
+
const sleep = require('../../../util/sleep');
|
|
7
|
+
const { systemctlControl } = require('../../../util/systemctl');
|
|
8
|
+
|
|
9
|
+
const pathToDockerApplication = '/Applications/Docker.app';
|
|
10
|
+
|
|
11
|
+
const getDockerVersion = () => execAsyncSpawn('docker version --format {{.Server.Version}}', {
|
|
12
|
+
withCode: true
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @type {() => import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
|
|
17
|
+
*/
|
|
18
|
+
const checkDockerStatusMacOS = () => ({
|
|
19
|
+
title: 'Checking Docker status on MacOS',
|
|
20
|
+
task: async (ctx, task) => {
|
|
21
|
+
const { result, code } = await getDockerVersion();
|
|
22
|
+
|
|
23
|
+
if (code !== 0 && result.includes('Is the docker daemon running?')) {
|
|
24
|
+
const dockerOpenAppConfirmation = await task.prompt({
|
|
25
|
+
type: 'Confirm',
|
|
26
|
+
message: 'Looks like Docker is not running, would you like us to open a Docker for Mac application and wait for it to start up?'
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
if (dockerOpenAppConfirmation && await pathExists(pathToDockerApplication)) {
|
|
30
|
+
await execAsyncSpawn(`open ${pathToDockerApplication}`);
|
|
31
|
+
let ready = false;
|
|
32
|
+
let attempts = 0;
|
|
33
|
+
while (!ready) {
|
|
34
|
+
if (attempts > 24 && !ready) {
|
|
35
|
+
throw new KnownError('Docker haven\'t started in 2 mins, exiting...');
|
|
36
|
+
}
|
|
37
|
+
try {
|
|
38
|
+
const { code: startupCode } = await getDockerVersion();
|
|
39
|
+
if (startupCode !== 0) {
|
|
40
|
+
task.output = `Waiting for Docker to startup for ${attempts * 5} seconds...`;
|
|
41
|
+
attempts++;
|
|
42
|
+
await sleep(5000);
|
|
43
|
+
} else {
|
|
44
|
+
ready = true;
|
|
45
|
+
}
|
|
46
|
+
} catch (e) {
|
|
47
|
+
//
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
task.skip('User skipped running Docker');
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
options: {
|
|
58
|
+
bottomBar: 10
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* @type {() => import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
|
|
64
|
+
*/
|
|
65
|
+
const checkDockerStatusWSL = () => ({
|
|
66
|
+
title: 'Checking Docker status on Windows WSL',
|
|
67
|
+
task: async () => {
|
|
68
|
+
const { result, code } = await getDockerVersion();
|
|
69
|
+
|
|
70
|
+
if (code !== 0 && result.includes('Is the docker daemon running?')) {
|
|
71
|
+
throw new KnownError(`Docker is not running!
|
|
72
|
+
|
|
73
|
+
Please open Docker Desktop application for Windows and make sure that Docker is running. Then you can try again!`);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* @type {() => import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
|
|
80
|
+
*/
|
|
81
|
+
const checkDockerStatusLinux = () => ({
|
|
82
|
+
title: 'Checking Docker status on Linux',
|
|
83
|
+
task: async (ctx, task) => {
|
|
84
|
+
const dockerService = systemctlControl('docker');
|
|
85
|
+
|
|
86
|
+
const isRunning = await dockerService.isRunning();
|
|
87
|
+
const isEnabled = await dockerService.isEnabled();
|
|
88
|
+
|
|
89
|
+
if (!isEnabled && !isRunning) {
|
|
90
|
+
const dockerStartConfirmation = await task.prompt({
|
|
91
|
+
type: 'Confirm',
|
|
92
|
+
message: `Looks like Docker is not enabled and not running, would you like to enable and run it?
|
|
93
|
+
|
|
94
|
+
This action requires root privileges.`
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
if (dockerStartConfirmation) {
|
|
98
|
+
await dockerService.enableAndStart();
|
|
99
|
+
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
task.skip('User skipped running Docker');
|
|
103
|
+
} else if (!isRunning) {
|
|
104
|
+
const dockerStartConfirmation = await task.prompt({
|
|
105
|
+
type: 'Confirm',
|
|
106
|
+
message: `Looks like Docker is not running, would you like to run it?
|
|
107
|
+
|
|
108
|
+
This action requires root privileges.`
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
if (dockerStartConfirmation) {
|
|
112
|
+
await dockerService.start();
|
|
113
|
+
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
task.skip('User skipped running Docker');
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* @type {() => import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
|
|
123
|
+
*/
|
|
124
|
+
const checkDockerStatus = () => ({
|
|
125
|
+
title: 'Checking Docker status',
|
|
126
|
+
task: async (ctx, task) => {
|
|
127
|
+
if (os.platform() === 'darwin') {
|
|
128
|
+
return task.newListr(checkDockerStatusMacOS());
|
|
129
|
+
}
|
|
130
|
+
if (!await getIsWsl()) {
|
|
131
|
+
return task.newListr(checkDockerStatusLinux());
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
return task.newListr(checkDockerStatusWSL());
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
module.exports = checkDockerStatus;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
const UnknownError = require('../../../errors/unknown-error');
|
|
1
2
|
const { execAsyncSpawn } = require('../../../util/exec-async-command');
|
|
2
3
|
|
|
3
4
|
/**
|
|
@@ -13,6 +14,8 @@ const getDockerVersion = () => ({
|
|
|
13
14
|
const dockerVersion = result.split('').filter((c) => /[\d.]/i.test(c)).join('') || result;
|
|
14
15
|
|
|
15
16
|
ctx.dockerVersion = dockerVersion;
|
|
17
|
+
} else {
|
|
18
|
+
throw new UnknownError(`Got unexpected result during Docker version retrieval!\n\n${ result }`);
|
|
16
19
|
}
|
|
17
20
|
}
|
|
18
21
|
});
|
|
@@ -13,17 +13,17 @@ const checkRequirements = () => ({
|
|
|
13
13
|
task: (ctx, task) => task.newListr([
|
|
14
14
|
// checking if user is on supported platform
|
|
15
15
|
checkPlatform(),
|
|
16
|
+
// check the Docker installation
|
|
17
|
+
checkDocker(),
|
|
18
|
+
// check for Node.js version
|
|
19
|
+
checkNodeVersion(),
|
|
16
20
|
// check the PHPBrew installation
|
|
17
21
|
checkPHPbrew(),
|
|
18
22
|
// check installed PHP version
|
|
19
23
|
checkPHPVersion(),
|
|
20
|
-
// check the Docker installation
|
|
21
|
-
checkDocker(),
|
|
22
24
|
// check for COMPOSER_AUTH or auth.json
|
|
23
25
|
// localAuthJson(),
|
|
24
|
-
checkComposer()
|
|
25
|
-
// check for Node.js version
|
|
26
|
-
checkNodeVersion()
|
|
26
|
+
checkComposer()
|
|
27
27
|
], {
|
|
28
28
|
concurrent: false,
|
|
29
29
|
exitOnError: true,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const semver = require('semver');
|
|
2
|
+
const KnownError = require('../../errors/known-error');
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* @type {() => import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
|
|
@@ -9,7 +10,7 @@ const checkNodeVersion = () => ({
|
|
|
9
10
|
const { node } = process.versions;
|
|
10
11
|
|
|
11
12
|
if (!semver.gte(node, '12.0.0')) {
|
|
12
|
-
throw new
|
|
13
|
+
throw new KnownError(
|
|
13
14
|
`Your Node.js version is out of date!
|
|
14
15
|
You need to upgrade Node.js to at lease version 12 to work with this software!`
|
|
15
16
|
);
|
|
@@ -3,6 +3,8 @@ const fs = require('fs');
|
|
|
3
3
|
const path = require('path');
|
|
4
4
|
const semver = require('semver');
|
|
5
5
|
const phpbrewConfig = require('../../config/phpbrew');
|
|
6
|
+
const KnownError = require('../../errors/known-error');
|
|
7
|
+
const UnknownError = require('../../errors/unknown-error');
|
|
6
8
|
const { execAsyncSpawn } = require('../../util/exec-async-command');
|
|
7
9
|
const pathExists = require('../../util/path-exists');
|
|
8
10
|
const compileOptions = require('../php/compile-options');
|
|
@@ -52,7 +54,7 @@ const installPHPForPHPBrew = () => ({
|
|
|
52
54
|
}
|
|
53
55
|
);
|
|
54
56
|
} catch (e) {
|
|
55
|
-
throw new
|
|
57
|
+
throw new KnownError(
|
|
56
58
|
`Failed to compile the required by PHPBrew PHP version.
|
|
57
59
|
Tried compiling the PHP version ${ latestStablePHP74 }.
|
|
58
60
|
Use your favorite search engine to resolve the issue.
|
|
@@ -79,10 +81,10 @@ export PHPBREW_PATH=${phpbrewConfig.homePath}/php/${phpbrewPHPName}/bin
|
|
|
79
81
|
}
|
|
80
82
|
);
|
|
81
83
|
} catch (e) {
|
|
82
|
-
throw new
|
|
84
|
+
throw new UnknownError(`Something went wrong when trying to switch PHP to ${phpbrewPHPName}!\n\n${e}`);
|
|
83
85
|
}
|
|
84
86
|
|
|
85
|
-
throw new
|
|
87
|
+
throw new KnownError(`You will need to restart your terminal and run ${logger.style.command('start')} again.
|
|
86
88
|
|
|
87
89
|
You can use keyboard shortcut ${logger.style.command('CTRL+D')} to close terminal.`);
|
|
88
90
|
},
|
|
@@ -99,7 +101,7 @@ const checkPHPVersion = () => ({
|
|
|
99
101
|
task: async (ctx, task) => {
|
|
100
102
|
const phpVersionResponse = await execAsyncSpawn('php --version');
|
|
101
103
|
|
|
102
|
-
const phpVersionResponseResult = phpVersionResponse.match(/PHP\s(\d
|
|
104
|
+
const phpVersionResponseResult = phpVersionResponse.match(/PHP\s(\d+\.\d+\.\d+)/i);
|
|
103
105
|
|
|
104
106
|
if (phpVersionResponseResult && phpVersionResponseResult.length > 0) {
|
|
105
107
|
const phpVersion = phpVersionResponseResult[1];
|
|
@@ -123,6 +125,8 @@ To fix that we will build special PHP version that will be used by PHPBrew, plea
|
|
|
123
125
|
);
|
|
124
126
|
}
|
|
125
127
|
}
|
|
128
|
+
|
|
129
|
+
task.title = `Using PHP version ${phpVersion} in system`;
|
|
126
130
|
}
|
|
127
131
|
}
|
|
128
132
|
});
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const logger = require('@scandipwa/scandipwa-dev-utils/logger');
|
|
2
|
+
const KnownError = require('../../../errors/known-error');
|
|
2
3
|
const { execAsyncSpawn } = require('../../../util/exec-async-command');
|
|
3
4
|
const installPHPBrew = require('./install');
|
|
4
5
|
const getPHPBrewVersion = require('./version');
|
|
@@ -32,7 +33,7 @@ Do you want to install it automatically?`
|
|
|
32
33
|
]);
|
|
33
34
|
}
|
|
34
35
|
|
|
35
|
-
throw new
|
|
36
|
+
throw new KnownError(
|
|
36
37
|
`To install PHPBrew, you must first make sure the requirements are met.
|
|
37
38
|
The requirements are available here: ${ logger.style.link('https://github.com/phpbrew/phpbrew/wiki/Requirement') }.
|
|
38
39
|
Then, you can follow the installation instruction, here: ${ logger.style.link('https://phpbrew.github.io/phpbrew/#installation') }.
|
|
@@ -5,6 +5,7 @@ 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');
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* @type {() => import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
|
|
@@ -167,7 +168,7 @@ When you ready, press select Yes and installation will continue.`
|
|
|
167
168
|
});
|
|
168
169
|
|
|
169
170
|
if (!continueInstall) {
|
|
170
|
-
throw new
|
|
171
|
+
throw new KnownError(`Add following string to your shells configuration file: ${logger.style.code('[[ -e ~/.phpbrew/bashrc ]] && source ~/.phpbrew/bashrc')}
|
|
171
172
|
|
|
172
173
|
Then you can continue installation.`);
|
|
173
174
|
}
|
|
@@ -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,6 +6,7 @@ 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
|
* @type {() => import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
|
|
@@ -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
|
);
|
package/lib/tasks/start.js
CHANGED
|
@@ -29,6 +29,8 @@ 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');
|
|
32
34
|
|
|
33
35
|
/**
|
|
34
36
|
* @type {() => import('listr2').ListrTask<import('../../typings/context').ListrContext>}
|
|
@@ -112,6 +114,7 @@ const configureProject = () => ({
|
|
|
112
114
|
})
|
|
113
115
|
},
|
|
114
116
|
configurePhp(),
|
|
117
|
+
validatePHPInstallation(),
|
|
115
118
|
installPrestissimo(),
|
|
116
119
|
installMagento(),
|
|
117
120
|
enableMagentoComposerPlugins(),
|
|
@@ -126,6 +129,7 @@ const configureProject = () => ({
|
|
|
126
129
|
*/
|
|
127
130
|
const finishProjectConfiguration = () => ({
|
|
128
131
|
title: 'Finishing project configuration',
|
|
132
|
+
skip: ({ skipSetup }) => skipSetup,
|
|
129
133
|
task: (ctx, task) => task.newListr([
|
|
130
134
|
{
|
|
131
135
|
skip: (ctx) => !ctx.importDb,
|
|
@@ -143,16 +147,10 @@ const finishProjectConfiguration = () => ({
|
|
|
143
147
|
});
|
|
144
148
|
}
|
|
145
149
|
},
|
|
146
|
-
|
|
147
|
-
title: 'Setting up themes',
|
|
148
|
-
skip: (ctx) => !ctx.magentoFirstInstall,
|
|
149
|
-
task: (subCtx, subTask) => subTask.newListr(
|
|
150
|
-
setupThemes()
|
|
151
|
-
)
|
|
152
|
-
}
|
|
150
|
+
setupThemes()
|
|
153
151
|
], {
|
|
154
152
|
rendererOptions: {
|
|
155
|
-
collapse:
|
|
153
|
+
collapse: false
|
|
156
154
|
}
|
|
157
155
|
})
|
|
158
156
|
});
|
|
@@ -189,8 +187,11 @@ const start = () => ({
|
|
|
189
187
|
|
|
190
188
|
return false;
|
|
191
189
|
},
|
|
192
|
-
task: (
|
|
193
|
-
|
|
190
|
+
task: (ctx) => {
|
|
191
|
+
const instanceMetadata = getInstanceMetadata(ctx);
|
|
192
|
+
const locationOnTheWeb = instanceMetadata.frontend.find(({ title }) => title === WEB_LOCATION_TITLE);
|
|
193
|
+
|
|
194
|
+
openBrowser(locationOnTheWeb.link);
|
|
194
195
|
},
|
|
195
196
|
options: {
|
|
196
197
|
showTimer: false
|
|
@@ -6,6 +6,7 @@ const { version: packageVersion } = require('../../../package.json');
|
|
|
6
6
|
const { getArchSync } = require('../../util/arch');
|
|
7
7
|
const ConsoleBlock = require('../../util/console-block');
|
|
8
8
|
const { getComposerVersion } = require('../composer');
|
|
9
|
+
const { getInstanceMetadata } = require('../../util/instance-metadata');
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* @param {string} port
|
|
@@ -23,11 +24,8 @@ const parsePort = (port) => {
|
|
|
23
24
|
|
|
24
25
|
const prettyStatus = async (ctx) => {
|
|
25
26
|
const {
|
|
26
|
-
ports,
|
|
27
27
|
config: {
|
|
28
|
-
magentoConfiguration,
|
|
29
28
|
baseConfig,
|
|
30
|
-
overridenConfiguration: { host, ssl },
|
|
31
29
|
php,
|
|
32
30
|
composer
|
|
33
31
|
},
|
|
@@ -91,7 +89,7 @@ const prettyStatus = async (ctx) => {
|
|
|
91
89
|
.addLine(`Image: ${logger.style.file(container.image)}`)
|
|
92
90
|
.addLine(`Network: ${logger.style.link(container.network)}`);
|
|
93
91
|
|
|
94
|
-
if (container.ports.length > 0) {
|
|
92
|
+
if (container.ports && container.ports.length > 0) {
|
|
95
93
|
block.addLine('Port forwarding:');
|
|
96
94
|
container.ports.forEach((port) => {
|
|
97
95
|
const { host, hostPort, containerPort } = parsePort(port);
|
|
@@ -107,15 +105,33 @@ const prettyStatus = async (ctx) => {
|
|
|
107
105
|
}
|
|
108
106
|
});
|
|
109
107
|
|
|
108
|
+
const instanceMetadata = getInstanceMetadata(ctx);
|
|
109
|
+
|
|
110
110
|
block
|
|
111
111
|
.addEmptyLine()
|
|
112
|
-
.addSeparator('Magento
|
|
113
|
-
.addEmptyLine()
|
|
114
|
-
.addLine(`Web location: ${logger.style.link(`${ssl.enabled ? 'https' : 'http'}://${host}${ports.app === 80 ? '' : `:${ports.app}`}/`)}`)
|
|
115
|
-
.addLine(`Magento Admin panel location: ${logger.style.link(`${ssl.enabled ? 'https' : 'http'}://${host}${ports.app === 80 ? '' : `:${ports.app}`}/${magentoConfiguration.adminuri}`)}`)
|
|
116
|
-
.addLine(`Magento Admin panel credentials: ${logger.style.misc(magentoConfiguration.user)} - ${logger.style.misc(magentoConfiguration.password)}`)
|
|
112
|
+
.addSeparator('Magento 2')
|
|
117
113
|
.addEmptyLine();
|
|
118
114
|
|
|
115
|
+
block.addLine(logger.style.misc('Frontend'));
|
|
116
|
+
instanceMetadata.frontend.forEach(({ title, text }) => {
|
|
117
|
+
block.addLine(` ${title}: ${text}`);
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
block.addEmptyLine();
|
|
121
|
+
|
|
122
|
+
block.addLine(logger.style.misc('Admin'));
|
|
123
|
+
instanceMetadata.admin.forEach(({ title, text }) => {
|
|
124
|
+
block.addLine(` ${title}: ${text}`);
|
|
125
|
+
});
|
|
126
|
+
// block
|
|
127
|
+
// .addEmptyLine()
|
|
128
|
+
// .addSeparator('Magento status')
|
|
129
|
+
// .addEmptyLine()
|
|
130
|
+
// .addLine(`Web location: ${logger.style.link(`${ssl.enabled ? 'https' : 'http'}://${host}${ports.app === 80 ? '' : `:${ports.app}`}/`)}`)
|
|
131
|
+
// .addLine(`Magento Admin panel location: ${logger.style.link(`${ssl.enabled ? 'https' : 'http'}://${host}${ports.app === 80 ? '' : `:${ports.app}`}/${magentoConfiguration.adminuri}`)}`)
|
|
132
|
+
// .addLine(`Magento Admin panel credentials: ${logger.style.misc(magentoConfiguration.user)} - ${logger.style.misc(magentoConfiguration.password)}`)
|
|
133
|
+
// .addEmptyLine();
|
|
134
|
+
|
|
119
135
|
block.log();
|
|
120
136
|
};
|
|
121
137
|
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
2
|
const pathExists = require('../../util/path-exists');
|
|
3
3
|
const { execAsyncSpawn } = require('../../util/exec-async-command');
|
|
4
|
-
const
|
|
4
|
+
const logger = require('@scandipwa/scandipwa-dev-utils/logger');
|
|
5
|
+
const matchFilesystem = require('../../util/match-filesystem');
|
|
6
|
+
const UnknownError = require('../../errors/unknown-error');
|
|
5
7
|
|
|
6
8
|
/**
|
|
7
9
|
* @type {(theme: import('../../../typings/theme').Theme) => import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
|
|
@@ -13,15 +15,32 @@ const buildTheme = ({ themePath }) => ({
|
|
|
13
15
|
|
|
14
16
|
if (!await pathExists(path.join(themePath, 'node_modules'))) {
|
|
15
17
|
task.output = 'Installing theme dependencies';
|
|
16
|
-
await
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
const commandToInstallDependencies = await pathExists(path.join(themePath, 'package-lock.json'))
|
|
19
|
+
? 'npm ci'
|
|
20
|
+
: 'npm i';
|
|
21
|
+
|
|
22
|
+
try {
|
|
23
|
+
await execAsyncSpawn(commandToInstallDependencies, {
|
|
24
|
+
cwd: path.join(process.cwd(), themePath),
|
|
25
|
+
callback: !verbose ? undefined : (t) => {
|
|
26
|
+
task.output = t;
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
} catch (e) {
|
|
30
|
+
throw new UnknownError(`We were unable to install theme dependencies in ${themePath} using ${logger.style.code(commandToInstallDependencies)} command!
|
|
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.`);
|
|
32
|
+
}
|
|
22
33
|
}
|
|
23
34
|
|
|
24
|
-
|
|
35
|
+
const magentoThemeDirPath = path.join(themePath, 'magento', 'Magento_Theme');
|
|
36
|
+
const isMagentoThemeDirMatching = await matchFilesystem(magentoThemeDirPath, {
|
|
37
|
+
templates: true,
|
|
38
|
+
web: [
|
|
39
|
+
'static'
|
|
40
|
+
]
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
if (isMagentoThemeDirMatching) {
|
|
25
44
|
task.skip();
|
|
26
45
|
return;
|
|
27
46
|
}
|
|
@@ -1,24 +1,37 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
const UnknownError = require('../../errors/unknown-error');
|
|
3
|
+
const getJsonfileData = require('../../util/get-jsonfile-data');
|
|
1
4
|
const runComposerCommand = require('../../util/run-composer');
|
|
2
5
|
|
|
3
6
|
/**
|
|
4
7
|
* @type {(theme: import('../../../typings/theme').Theme) => import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
|
|
5
8
|
*/
|
|
6
|
-
const installTheme = (
|
|
9
|
+
const installTheme = (theme) => ({
|
|
7
10
|
title: 'Installing theme in composer.json',
|
|
8
|
-
task: async (
|
|
11
|
+
task: async (ctx, task) => {
|
|
12
|
+
const { magentoVersion, verbose = false } = ctx;
|
|
13
|
+
const composerJsonData = await getJsonfileData(path.join(process.cwd(), 'composer.json'));
|
|
14
|
+
|
|
15
|
+
if (composerJsonData.require[theme.composerData.name]) {
|
|
16
|
+
task.skip();
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
|
|
9
20
|
try {
|
|
10
|
-
await runComposerCommand(`require ${composerData.name}`, {
|
|
21
|
+
await runComposerCommand(`require ${theme.composerData.name}`, {
|
|
11
22
|
magentoVersion,
|
|
12
23
|
callback: !verbose ? undefined : (t) => {
|
|
13
24
|
task.output = t;
|
|
14
25
|
}
|
|
15
26
|
});
|
|
16
27
|
} catch (e) {
|
|
17
|
-
throw new
|
|
28
|
+
throw new UnknownError(
|
|
18
29
|
`Unexpected error while installing theme.
|
|
19
|
-
|
|
30
|
+
See ERROR log below.\n\n${e}`
|
|
20
31
|
);
|
|
21
32
|
}
|
|
33
|
+
|
|
34
|
+
ctx.isSetupUpgradeNeeded = true;
|
|
22
35
|
},
|
|
23
36
|
options: {
|
|
24
37
|
bottomBar: 10
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const symlinkTheme = require('./symlink-theme');
|
|
2
2
|
const installTheme = require('./install-theme');
|
|
3
|
-
const
|
|
3
|
+
const disableFullPageCache = require('../magento/setup-magento/disable-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
|
+
disableFullPageCache(),
|
|
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');
|
|
@@ -8,7 +9,7 @@ const runMagentoCommand = require('../../util/run-magento');
|
|
|
8
9
|
* @type {() => import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
|
|
9
10
|
*/
|
|
10
11
|
const persistedQuerySetup = () => ({
|
|
11
|
-
title: 'Setting up
|
|
12
|
+
title: 'Setting up Redis configuration for persisted queries',
|
|
12
13
|
task: async (ctx, task) => {
|
|
13
14
|
const { ports, magentoVersion, verbose = false } = ctx;
|
|
14
15
|
const composerLockData = await getJsonfileData(path.join(process.cwd(), 'composer.lock'));
|
|
@@ -29,8 +30,8 @@ const persistedQuerySetup = () => ({
|
|
|
29
30
|
if (
|
|
30
31
|
persistedQueryConfig
|
|
31
32
|
&& persistedQueryConfig.redis
|
|
32
|
-
&& persistedQueryConfig.redis.port === ports.redis
|
|
33
|
-
&& persistedQueryConfig.redis.
|
|
33
|
+
&& persistedQueryConfig.redis.port === `${ ports.redis }`
|
|
34
|
+
&& persistedQueryConfig.redis.host === 'localhost'
|
|
34
35
|
) {
|
|
35
36
|
task.skip();
|
|
36
37
|
return;
|
|
@@ -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,13 +5,15 @@ 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 disableFullPageCache = require('../magento/setup-magento/disable-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>}
|
|
13
14
|
*/
|
|
14
15
|
const setupThemes = () => ({
|
|
16
|
+
title: 'Setting up themes',
|
|
15
17
|
task: async (ctx, task) => {
|
|
16
18
|
const { config: { baseConfig } } = ctx;
|
|
17
19
|
const composerData = await getJsonfileData(path.join(baseConfig.magentoDir, 'composer.json'));
|
|
@@ -60,7 +62,7 @@ const setupThemes = () => ({
|
|
|
60
62
|
const composerData = await getJsonfileData(path.join(absoluteThemePath, 'composer.json'));
|
|
61
63
|
|
|
62
64
|
if (!composerData) {
|
|
63
|
-
throw new
|
|
65
|
+
throw new KnownError(`composer.json file not found in "${themePath}"`);
|
|
64
66
|
}
|
|
65
67
|
|
|
66
68
|
return {
|
|
@@ -80,7 +82,7 @@ const setupThemes = () => ({
|
|
|
80
82
|
])
|
|
81
83
|
})).concat([
|
|
82
84
|
upgradeMagento(),
|
|
83
|
-
|
|
85
|
+
disableFullPageCache(),
|
|
84
86
|
setupPersistedQuery()
|
|
85
87
|
])
|
|
86
88
|
);
|