@scandipwa/magento-scripts 1.12.0-alpha.0 → 1.13.0-alpha.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/.eslintrc +0 -0
- package/LICENSE +0 -0
- package/lib/config/check-configuration-file.js +10 -8
- package/lib/config/dependencies-for-platforms.js +0 -1
- package/lib/config/index.js +2 -2
- package/lib/config/{php.js → php-config.js} +0 -0
- package/lib/config/phpbrew.js +12 -0
- package/lib/config/{php-storm.js → phpstorm/debug-config.js} +0 -0
- package/lib/config/save-config.js +0 -0
- package/lib/config/templates/cma-config.template.js +0 -0
- package/lib/config/templates/magentorc.template +0 -0
- package/lib/config/templates/php-fpm.template.conf +0 -0
- package/lib/config/templates/vscode-launch.template.json +15 -0
- package/lib/config/versions/magento-2.3.0.js +1 -1
- package/lib/config/versions/magento-2.3.1.js +1 -1
- package/lib/config/versions/magento-2.3.2-p2.js +1 -1
- package/lib/config/versions/magento-2.3.2.js +1 -1
- package/lib/config/versions/magento-2.3.3-p1.js +1 -1
- package/lib/config/versions/magento-2.3.3.js +1 -1
- package/lib/config/versions/magento-2.3.4-p2.js +1 -1
- package/lib/config/versions/magento-2.3.4.js +1 -1
- package/lib/config/versions/magento-2.3.5-p1.js +1 -1
- package/lib/config/versions/magento-2.3.5-p2.js +1 -1
- package/lib/config/versions/magento-2.3.5.js +1 -1
- package/lib/config/versions/magento-2.3.6-p1.js +1 -1
- package/lib/config/versions/magento-2.3.6.js +1 -1
- package/lib/config/versions/magento-2.3.7-p1.js +2 -2
- package/lib/config/versions/magento-2.3.7.js +2 -2
- package/lib/config/versions/magento-2.4.0-p1.js +2 -2
- package/lib/config/versions/magento-2.4.0.js +2 -2
- package/lib/config/versions/magento-2.4.1-p1.js +2 -2
- package/lib/config/versions/magento-2.4.1.js +2 -2
- package/lib/config/versions/magento-2.4.2-p1.js +2 -2
- package/lib/config/versions/magento-2.4.2-p2.js +2 -2
- package/lib/config/versions/magento-2.4.2.js +2 -2
- package/lib/config/versions/magento-2.4.3-p1.js +2 -2
- package/lib/config/versions/magento-2.4.3.js +2 -2
- package/lib/tasks/cache/index.js +0 -0
- package/lib/tasks/cli/index.js +0 -0
- package/lib/tasks/composer/index.js +27 -5
- package/lib/tasks/execute/index.js +0 -0
- package/lib/tasks/file-system/create-vscode-config.js +111 -0
- package/lib/tasks/file-system/index.js +3 -1
- package/lib/tasks/magento/enable-magento-composer-plugins.js +173 -0
- package/lib/tasks/magento/index.js +0 -0
- package/lib/tasks/magento/setup-magento/adjust-magento-configuration.js +0 -0
- package/lib/tasks/magento/setup-magento/configure-elasticsearch.js +0 -0
- package/lib/tasks/magento/setup-magento/create-admin.js +0 -0
- package/lib/tasks/magento/setup-magento/delete-admin-users.js +0 -0
- package/lib/tasks/magento/setup-magento/flush-redis-config.js +0 -0
- package/lib/tasks/magento/setup-magento/increase-admin-session-lifetime.js +0 -0
- package/lib/tasks/magento/setup-magento/set-base-url.js +0 -0
- package/lib/tasks/magento/setup-magento/set-deployment-mode.js +0 -0
- package/lib/tasks/magento/setup-magento/set-url-rewrite.js +0 -0
- package/lib/tasks/magento/setup-magento/waiting-for-redis.js +0 -0
- package/lib/tasks/mysql/index.js +0 -0
- package/lib/tasks/php/compile.js +4 -5
- package/lib/tasks/php/configure.js +28 -3
- package/lib/tasks/php/extensions/disable.js +2 -1
- package/lib/tasks/php/extensions/enable.js +2 -1
- package/lib/tasks/php/extensions/install.js +2 -1
- package/lib/tasks/php/index.js +10 -4
- package/lib/tasks/php/update-phpbrew.js +0 -0
- package/lib/tasks/php-fpm/index.js +0 -0
- package/lib/tasks/php-fpm/start-php-fpm.js +1 -1
- package/lib/tasks/php-fpm/stop-php-fpm.js +1 -1
- package/lib/tasks/requirements/dependency/arch.js +0 -0
- package/lib/tasks/requirements/dependency/centos.js +2 -2
- package/lib/tasks/requirements/dependency/fedora.js +0 -0
- package/lib/tasks/requirements/dependency/index.js +1 -4
- package/lib/tasks/requirements/dependency/mac.js +0 -0
- package/lib/tasks/requirements/dependency/ubuntu.js +0 -0
- package/lib/tasks/requirements/docker/install.js +1 -1
- package/lib/tasks/requirements/index.js +5 -3
- package/lib/tasks/requirements/php-version.js +113 -0
- package/lib/tasks/requirements/phpbrew/install.js +2 -4
- package/lib/tasks/start.js +2 -0
- package/lib/util/clean-object.js +0 -0
- package/lib/util/config-file-validator.js +7 -1
- package/lib/util/download-file.js +0 -0
- package/lib/util/ip.js +0 -0
- package/lib/util/match-filesystem.js +0 -0
- package/lib/util/move-file.js +0 -0
- package/lib/util/path-exists-sync.js +0 -0
- package/lib/util/portscanner.js +0 -0
- package/lib/util/run-composer.js +0 -0
- package/lib/util/run-magento.js +0 -0
- package/lib/util/run-php.js +0 -0
- package/lib/util/set-config.js +0 -0
- package/lib/util/sleep.js +0 -0
- package/lib/util/wait-for-it.js +0 -0
- package/lib/util/wait-for-logs.js +0 -0
- package/package.json +3 -2
|
@@ -2,6 +2,7 @@ const createNginxConfig = require('./create-nginx-config');
|
|
|
2
2
|
const createPhpConfig = require('./create-php-config');
|
|
3
3
|
const createPhpFpmConfig = require('./create-php-fpm-config');
|
|
4
4
|
const createPhpStormConfig = require('./create-php-storm-config');
|
|
5
|
+
const createVSCodeConfig = require('./create-vscode-config');
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* @type {() => import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
|
|
@@ -12,7 +13,8 @@ const prepareFileSystem = () => ({
|
|
|
12
13
|
createNginxConfig(),
|
|
13
14
|
createPhpFpmConfig(),
|
|
14
15
|
createPhpConfig(),
|
|
15
|
-
createPhpStormConfig()
|
|
16
|
+
createPhpStormConfig(),
|
|
17
|
+
createVSCodeConfig()
|
|
16
18
|
], {
|
|
17
19
|
concurrent: true
|
|
18
20
|
})
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
const fs = require('fs');
|
|
3
|
+
const logger = require('@scandipwa/scandipwa-dev-utils/logger');
|
|
4
|
+
const semver = require('semver');
|
|
5
|
+
const pathExists = require('../../util/path-exists');
|
|
6
|
+
const getJsonfileData = require('../../util/get-jsonfile-data');
|
|
7
|
+
|
|
8
|
+
const vendorPath = path.join(process.cwd(), 'vendor');
|
|
9
|
+
const composerJsonPath = path.join(process.cwd(), 'composer.json');
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @returns {Promise<string[]}
|
|
13
|
+
*/
|
|
14
|
+
const getInstalledComposerPlugins = async () => {
|
|
15
|
+
const rootVendorFolders = await fs.promises.readdir(vendorPath, {
|
|
16
|
+
encoding: 'utf-8',
|
|
17
|
+
withFileTypes: true
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
const composerPlugins = (await Promise.all(
|
|
21
|
+
rootVendorFolders.map(async (f) => {
|
|
22
|
+
if (f.isDirectory()) {
|
|
23
|
+
const vendorDirectoryPath = path.join(vendorPath, f.name);
|
|
24
|
+
|
|
25
|
+
const vendorPackages = await fs.promises.readdir(vendorDirectoryPath, {
|
|
26
|
+
encoding: 'utf-8',
|
|
27
|
+
withFileTypes: true
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
const vendorPackagesComposerPlugins = (await Promise.all(
|
|
31
|
+
vendorPackages.map(async (p) => {
|
|
32
|
+
if (p.isDirectory()) {
|
|
33
|
+
const vendorPackageComposerJsonPath = path.join(vendorDirectoryPath, p.name, 'composer.json');
|
|
34
|
+
|
|
35
|
+
if (await pathExists(vendorPackageComposerJsonPath)) {
|
|
36
|
+
const {
|
|
37
|
+
name: vendorPackageName,
|
|
38
|
+
type: vendorPackageType
|
|
39
|
+
} = JSON.parse(await fs.promises.readFile(vendorPackageComposerJsonPath, {
|
|
40
|
+
encoding: 'utf-8'
|
|
41
|
+
}));
|
|
42
|
+
|
|
43
|
+
if (vendorPackageType === 'composer-plugin') {
|
|
44
|
+
return vendorPackageName;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return null;
|
|
52
|
+
})
|
|
53
|
+
)).filter((p) => typeof p === 'string');
|
|
54
|
+
|
|
55
|
+
return vendorPackagesComposerPlugins;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return null;
|
|
59
|
+
})
|
|
60
|
+
))
|
|
61
|
+
.reduce((acc, val) => acc.concat(val), []) // flattens the array
|
|
62
|
+
.filter((p) => typeof p === 'string');
|
|
63
|
+
|
|
64
|
+
return composerPlugins;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* @type {() => import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
|
|
69
|
+
*/
|
|
70
|
+
const enableMagentoComposerPlugins = () => ({
|
|
71
|
+
task: async (ctx, task) => {
|
|
72
|
+
if (!semver.satisfies(ctx.composerVersion, '^2.2.0')) {
|
|
73
|
+
task.skip();
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
task.title = 'Checking allowed composer plugins...';
|
|
78
|
+
|
|
79
|
+
const composerPlugins = await getInstalledComposerPlugins();
|
|
80
|
+
const composerJsonData = await getJsonfileData(composerJsonPath);
|
|
81
|
+
const {
|
|
82
|
+
config: {
|
|
83
|
+
'allow-plugins': allowPlugins = {}
|
|
84
|
+
}
|
|
85
|
+
} = composerJsonData;
|
|
86
|
+
const allowPluginsKeys = Object.keys(allowPlugins);
|
|
87
|
+
|
|
88
|
+
if (
|
|
89
|
+
allowPluginsKeys.length === 0
|
|
90
|
+
|| composerPlugins.some((p) => !allowPluginsKeys.includes(p))
|
|
91
|
+
) {
|
|
92
|
+
const missingPlugins = composerPlugins.filter((p) => !allowPluginsKeys.includes(p));
|
|
93
|
+
const answerForEnablingPlugins = await task.prompt({
|
|
94
|
+
type: 'Select',
|
|
95
|
+
message: `Composer 2.2 requires manually allowing composer-plugins to run.
|
|
96
|
+
Magento requires the following plugins to correctly operate:
|
|
97
|
+
|
|
98
|
+
${missingPlugins.map((p) => logger.style.code(p)).join('\n')}
|
|
99
|
+
|
|
100
|
+
Do you want to enable them all or disable some of them?`,
|
|
101
|
+
choices: ['Enable all', 'Configure manually', 'Skip this step']
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
switch (answerForEnablingPlugins.toLowerCase()) {
|
|
105
|
+
case 'enable all': {
|
|
106
|
+
const userConfirmation = await task.prompt({
|
|
107
|
+
type: 'Confirm',
|
|
108
|
+
message: `Please confirm enabling of the following plugins:\n\n${missingPlugins.map((p) => logger.style.code(p)).join('\n')}\n`
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
if (userConfirmation) {
|
|
112
|
+
composerJsonData.config = {
|
|
113
|
+
...composerJsonData.config,
|
|
114
|
+
'allow-plugins': {
|
|
115
|
+
...allowPlugins,
|
|
116
|
+
...missingPlugins.reduce((acc, val) => ({ ...acc, [val]: true }), {})
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
await fs.promises.writeFile(composerJsonPath, JSON.stringify(composerJsonData, null, 4), {
|
|
121
|
+
encoding: 'utf-8'
|
|
122
|
+
});
|
|
123
|
+
} else {
|
|
124
|
+
throw new Error('Please confirm your choice or choose other option.');
|
|
125
|
+
}
|
|
126
|
+
break;
|
|
127
|
+
}
|
|
128
|
+
case 'configure manually': {
|
|
129
|
+
const userEnabledPlugins = await task.prompt({
|
|
130
|
+
type: 'MultiSelect',
|
|
131
|
+
message: 'Please pick plugins you want to enable!',
|
|
132
|
+
choices: missingPlugins.map((p) => ({ name: p }))
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
const userConfirmation = await task.prompt({
|
|
136
|
+
type: 'Confirm',
|
|
137
|
+
message: `Please confirm enabling of the following plugins:\n\n${userEnabledPlugins.map((p) => logger.style.code(p)).join('\n')}\n`
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
if (userConfirmation) {
|
|
141
|
+
const disabledPlugins = composerPlugins.filter((p) => !userEnabledPlugins.includes(p));
|
|
142
|
+
|
|
143
|
+
composerJsonData.config = {
|
|
144
|
+
...composerJsonData.config,
|
|
145
|
+
'allow-plugins': {
|
|
146
|
+
...allowPlugins,
|
|
147
|
+
...disabledPlugins.reduce((acc, val) => ({ ...acc, [val]: false }), {}),
|
|
148
|
+
...userEnabledPlugins.reduce((acc, val) => ({ ...acc, [val]: true }), {})
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
await fs.promises.writeFile(composerJsonPath, JSON.stringify(composerJsonData, null, 4), {
|
|
153
|
+
encoding: 'utf-8'
|
|
154
|
+
});
|
|
155
|
+
} else {
|
|
156
|
+
throw new Error('Please confirm your choice or choose other option.');
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
break;
|
|
160
|
+
}
|
|
161
|
+
case 'skip this step': {
|
|
162
|
+
task.skip();
|
|
163
|
+
break;
|
|
164
|
+
}
|
|
165
|
+
default: {
|
|
166
|
+
//
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
module.exports = enableMagentoComposerPlugins;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/lib/tasks/mysql/index.js
CHANGED
|
File without changes
|
package/lib/tasks/php/compile.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
const os = require('os');
|
|
2
1
|
const osPlatform = require('../../util/os-platform');
|
|
3
2
|
const logger = require('@scandipwa/scandipwa-dev-utils/logger');
|
|
4
3
|
const { execAsyncSpawn } = require('../../util/exec-async-command');
|
|
@@ -10,15 +9,15 @@ const compileOptions = require('./compile-options');
|
|
|
10
9
|
const compile = () => ({
|
|
11
10
|
title: 'Compiling PHP',
|
|
12
11
|
task: async ({ config: { php } }, task) => {
|
|
13
|
-
const platformCompileOptions = compileOptions[
|
|
14
|
-
if (
|
|
12
|
+
const platformCompileOptions = compileOptions[process.platform];
|
|
13
|
+
if (process.platform === 'linux') {
|
|
15
14
|
const { dist } = await osPlatform();
|
|
16
15
|
if (['Fedora', 'Manjaro'].some((distro) => dist.includes(distro))) {
|
|
17
16
|
platformCompileOptions.extraOptions.push('--with-libdir=lib64');
|
|
18
17
|
}
|
|
19
18
|
}
|
|
20
|
-
const
|
|
21
|
-
const phpCompileCommand = `${
|
|
19
|
+
const commandEnv = Object.entries(platformCompileOptions.env || {}).map(([key, value]) => `${key}="${value}"`).join(' && ');
|
|
20
|
+
const phpCompileCommand = `${commandEnv ? `${commandEnv} && ` : ''} \
|
|
22
21
|
phpbrew install -j ${platformCompileOptions.cpuCount} ${php.version} ${platformCompileOptions.variants.join(' ')} \
|
|
23
22
|
-- ${platformCompileOptions.extraOptions.join(' ')}`;
|
|
24
23
|
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
/* eslint-disable max-len */
|
|
2
2
|
const path = require('path');
|
|
3
|
-
const os = require('os');
|
|
4
3
|
const fs = require('fs');
|
|
5
4
|
const { execAsyncSpawn } = require('../../util/exec-async-command');
|
|
5
|
+
const pathExists = require('../../util/path-exists');
|
|
6
6
|
const enableExtension = require('./extensions/enable');
|
|
7
7
|
const installExtension = require('./extensions/install');
|
|
8
8
|
const disableExtension = require('./extensions/disable');
|
|
9
|
+
const phpbrewConfig = require('../../config/phpbrew');
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* Get enabled extensions list with versions
|
|
@@ -28,13 +29,36 @@ const getEnabledExtensions = async ({ php }) => {
|
|
|
28
29
|
.reduce((acc, [name, version]) => ({ ...acc, [name]: version }), {});
|
|
29
30
|
};
|
|
30
31
|
|
|
32
|
+
/**
|
|
33
|
+
* Get disabled extensions list
|
|
34
|
+
* @param {import('../../../typings/context').ListrContext['config']} param0
|
|
35
|
+
* @returns {Promise<string[]>}
|
|
36
|
+
*/
|
|
37
|
+
const getDisabledExtensions = async ({ php }) => {
|
|
38
|
+
const extensionsIniDirectory = path.join(phpbrewConfig.phpPath, `php-${php.version}`, 'var', 'db');
|
|
39
|
+
|
|
40
|
+
if (!await pathExists(extensionsIniDirectory)) {
|
|
41
|
+
return [];
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const extensionIniList = await fs.promises.readdir(
|
|
45
|
+
extensionsIniDirectory,
|
|
46
|
+
{
|
|
47
|
+
encoding: 'utf-8',
|
|
48
|
+
withFileTypes: true
|
|
49
|
+
}
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
return extensionIniList.filter((f) => f.isFile() && f.name.endsWith('.disabled')).map((f) => f.name.replace('.disabled', ''));
|
|
53
|
+
};
|
|
54
|
+
|
|
31
55
|
/**
|
|
32
56
|
* Get installed extensions
|
|
33
57
|
* @param {import('../../../typings/context').ListrContext['config']} param0
|
|
34
58
|
* @returns {Promise<string[]>}
|
|
35
59
|
*/
|
|
36
60
|
const getInstalledExtensions = async ({ php }) => {
|
|
37
|
-
const extensionDirectory = path.join(
|
|
61
|
+
const extensionDirectory = path.join(phpbrewConfig.buildPath, `php-${php.version}`, 'ext');
|
|
38
62
|
|
|
39
63
|
const availableExtensions = await fs.promises.readdir(extensionDirectory, {
|
|
40
64
|
encoding: 'utf-8'
|
|
@@ -52,6 +76,7 @@ const configure = () => ({
|
|
|
52
76
|
const { php, php: { disabledExtensions = [] } } = config;
|
|
53
77
|
const enabledExtensions = await getEnabledExtensions(config);
|
|
54
78
|
const installedExtensions = await getInstalledExtensions(config);
|
|
79
|
+
const disabledExtensionsInPHP = await getDisabledExtensions(config);
|
|
55
80
|
|
|
56
81
|
if (!debug && enabledExtensions.xdebug && !disabledExtensions.includes('xdebug')) {
|
|
57
82
|
disabledExtensions.push('xdebug');
|
|
@@ -86,7 +111,7 @@ const configure = () => ({
|
|
|
86
111
|
|
|
87
112
|
if (missingExtensions.length > 0) {
|
|
88
113
|
missingExtensions.forEach(([extensionName, extensionOptions]) => {
|
|
89
|
-
if (installedExtensions.includes(extensionName)) {
|
|
114
|
+
if (installedExtensions.includes(extensionName) && disabledExtensionsInPHP.includes(extensionName)) {
|
|
90
115
|
extensionTasks.push(enableExtension(extensionName, extensionOptions));
|
|
91
116
|
} else {
|
|
92
117
|
extensionTasks.push(installExtension(extensionName, extensionOptions));
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/* eslint-disable max-len */
|
|
2
|
+
const phpbrewConfig = require('../../../config/phpbrew');
|
|
2
3
|
const { execAsyncSpawn } = require('../../../util/exec-async-command');
|
|
3
4
|
|
|
4
5
|
/**
|
|
@@ -20,7 +21,7 @@ const disableExtension = (extensionName) => ({
|
|
|
20
21
|
if (hooks && hooks.preDisable) {
|
|
21
22
|
await Promise.resolve(hooks.preDisable(config));
|
|
22
23
|
}
|
|
23
|
-
await execAsyncSpawn(`source
|
|
24
|
+
await execAsyncSpawn(`source ${phpbrewConfig.bashrcPath} && \
|
|
24
25
|
phpbrew use ${ php.version } && \
|
|
25
26
|
phpbrew ext disable ${ extensionName }`,
|
|
26
27
|
{
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/* eslint-disable max-len */
|
|
2
|
+
const phpbrewConfig = require('../../../config/phpbrew');
|
|
2
3
|
const { execAsyncSpawn } = require('../../../util/exec-async-command');
|
|
3
4
|
|
|
4
5
|
/**
|
|
@@ -22,7 +23,7 @@ const enableExtension = (extensionName, extensionOptions) => ({
|
|
|
22
23
|
await Promise.resolve(hooks.postEnable(config));
|
|
23
24
|
}
|
|
24
25
|
|
|
25
|
-
await execAsyncSpawn(`source
|
|
26
|
+
await execAsyncSpawn(`source ${phpbrewConfig.bashrcPath} && \
|
|
26
27
|
phpbrew use ${ php.version } && \
|
|
27
28
|
phpbrew ext enable ${ extensionName }`,
|
|
28
29
|
{
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/* eslint-disable max-len */
|
|
2
2
|
const macosVersion = require('macos-version');
|
|
3
|
+
const phpbrewConfig = require('../../../config/phpbrew');
|
|
3
4
|
const { execAsyncSpawn } = require('../../../util/exec-async-command');
|
|
4
5
|
|
|
5
6
|
/**
|
|
@@ -25,7 +26,7 @@ const installExtension = (extensionName, extensionOptions) => ({
|
|
|
25
26
|
await Promise.resolve(hooks.preInstall(config));
|
|
26
27
|
}
|
|
27
28
|
|
|
28
|
-
await execAsyncSpawn(`source
|
|
29
|
+
await execAsyncSpawn(`source ${phpbrewConfig.bashrcPath} && \
|
|
29
30
|
phpbrew use ${ php.version } && \
|
|
30
31
|
phpbrew ext install ${ extensionName }${ extensionOptions.version ? ` ${extensionOptions.version}` : ''}${ options ? ` -- ${ options }` : ''}`,
|
|
31
32
|
{
|
package/lib/tasks/php/index.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
1
2
|
const logger = require('@scandipwa/scandipwa-dev-utils/logger');
|
|
2
|
-
const { execAsyncSpawn } = require('../../util/exec-async-command');
|
|
3
3
|
const pathExists = require('../../util/path-exists');
|
|
4
4
|
const compile = require('./compile');
|
|
5
5
|
const configure = require('./configure');
|
|
6
6
|
const updatePhpBrew = require('./update-phpbrew');
|
|
7
|
+
const phpbrewConfig = require('../../config/phpbrew');
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* @type {() => import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
|
|
@@ -21,12 +22,17 @@ const installPhp = () => ({
|
|
|
21
22
|
}
|
|
22
23
|
|
|
23
24
|
task.title = `Installing PHP ${php.version}`;
|
|
24
|
-
const versionRegex = new RegExp(php.version);
|
|
25
25
|
|
|
26
26
|
try {
|
|
27
|
-
const
|
|
27
|
+
const hasPHPVersion = (
|
|
28
|
+
await fs.promises.readdir(phpbrewConfig.phpPath, {
|
|
29
|
+
encoding: 'utf-8',
|
|
30
|
+
withFileTypes: true
|
|
31
|
+
})
|
|
32
|
+
)
|
|
33
|
+
.some((f) => f.isDirectory() && f.name === `php-${php.version}`);
|
|
28
34
|
|
|
29
|
-
if (
|
|
35
|
+
if (hasPHPVersion && !recompilePhp) {
|
|
30
36
|
task.skip();
|
|
31
37
|
// eslint-disable-next-line consistent-return
|
|
32
38
|
return;
|
|
File without changes
|
|
File without changes
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const { execAsyncSpawn } = require('../../util/exec-async-command');
|
|
2
|
-
const getPhpConfig = require('../../config/php');
|
|
2
|
+
const getPhpConfig = require('../../config/php-config');
|
|
3
3
|
const { getBaseConfig } = require('../../config/index');
|
|
4
4
|
const getProcessId = require('./get-process-id');
|
|
5
5
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const fs = require('fs');
|
|
2
2
|
const { execAsyncSpawn } = require('../../util/exec-async-command');
|
|
3
3
|
const pathExists = require('../../util/path-exists');
|
|
4
|
-
const getPhpConfig = require('../../config/php');
|
|
4
|
+
const getPhpConfig = require('../../config/php-config');
|
|
5
5
|
const { getBaseConfig } = require('../../config/index');
|
|
6
6
|
const getProcessId = require('./get-process-id');
|
|
7
7
|
|
|
File without changes
|
|
@@ -5,7 +5,7 @@ const installDependenciesTask = require('../../../util/install-dependencies-task
|
|
|
5
5
|
/**
|
|
6
6
|
* @type {() => import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
|
|
7
7
|
*/
|
|
8
|
-
const
|
|
8
|
+
const centosDependenciesCheck = () => ({
|
|
9
9
|
title: 'Checking CentOS dependencies',
|
|
10
10
|
task: async (ctx, task) => {
|
|
11
11
|
const installedDependencies = (await execAsyncSpawn('yum list installed')).split('\n')
|
|
@@ -32,4 +32,4 @@ const fedoraDependenciesCheck = () => ({
|
|
|
32
32
|
}
|
|
33
33
|
});
|
|
34
34
|
|
|
35
|
-
module.exports =
|
|
35
|
+
module.exports = centosDependenciesCheck;
|
|
File without changes
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
const os = require('os');
|
|
2
1
|
const osPlatform = require('../../../util/os-platform');
|
|
3
2
|
const archDependenciesCheck = require('./arch');
|
|
4
3
|
const fedoraDependenciesCheck = require('./fedora');
|
|
@@ -7,9 +6,7 @@ const ubuntuDependenciesCheck = require('./ubuntu');
|
|
|
7
6
|
const macDependenciesCheck = require('./mac');
|
|
8
7
|
|
|
9
8
|
const dependencyCheck = async () => {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
if (currentPlatform === 'darwin') {
|
|
9
|
+
if (process.platform === 'darwin') {
|
|
13
10
|
return macDependenciesCheck();
|
|
14
11
|
}
|
|
15
12
|
|
|
File without changes
|
|
File without changes
|
|
@@ -45,7 +45,7 @@ const installDocker = () => ({
|
|
|
45
45
|
execCommandTask('curl -fsSL https://get.docker.com -o get-docker.sh'),
|
|
46
46
|
executeSudoCommand('sudo sh get-docker.sh'),
|
|
47
47
|
executeSudoCommand('sudo service docker start'),
|
|
48
|
-
executeSudoCommand('sudo
|
|
48
|
+
executeSudoCommand('sudo systemctl enable docker.service'),
|
|
49
49
|
...postInstallSteps
|
|
50
50
|
]);
|
|
51
51
|
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
const checkPlatform = require('./platform');
|
|
2
|
-
const
|
|
2
|
+
const checkPHPbrew = require('./phpbrew');
|
|
3
3
|
const checkComposer = require('./composer');
|
|
4
4
|
const checkDocker = require('./docker');
|
|
5
5
|
const checkNodeVersion = require('./node-version');
|
|
6
|
+
const checkPHPVersion = require('./php-version');
|
|
6
7
|
const localAuthJson = require('../composer/local-auth-json');
|
|
7
8
|
|
|
8
9
|
/**
|
|
@@ -11,11 +12,12 @@ const localAuthJson = require('../composer/local-auth-json');
|
|
|
11
12
|
const checkRequirements = () => ({
|
|
12
13
|
title: 'Checking requirements',
|
|
13
14
|
task: (ctx, task) => task.newListr([
|
|
14
|
-
// TODO add support for mac
|
|
15
15
|
// checking if user is on supported platform
|
|
16
16
|
checkPlatform(),
|
|
17
17
|
// check the PHPBrew installation
|
|
18
|
-
|
|
18
|
+
checkPHPbrew(),
|
|
19
|
+
// check installed PHP version
|
|
20
|
+
checkPHPVersion(),
|
|
19
21
|
// check the Docker installation
|
|
20
22
|
checkDocker(),
|
|
21
23
|
// check for COMPOSER_AUTH or auth.json
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
const logger = require('@scandipwa/scandipwa-dev-utils/logger');
|
|
2
|
+
const fs = require('fs');
|
|
3
|
+
const path = require('path');
|
|
4
|
+
const semver = require('semver');
|
|
5
|
+
const phpbrewConfig = require('../../config/phpbrew');
|
|
6
|
+
const { execAsyncSpawn } = require('../../util/exec-async-command');
|
|
7
|
+
const pathExists = require('../../util/path-exists');
|
|
8
|
+
const compileOptions = require('../php/compile-options');
|
|
9
|
+
|
|
10
|
+
const latestStablePHP74 = '7.4.27';
|
|
11
|
+
const phpbrewPHPName = `php-${latestStablePHP74}-phpbrew`;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @type {() => import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
|
|
15
|
+
*/
|
|
16
|
+
const installPHPForPHPBrew = () => ({
|
|
17
|
+
title: `Installing PHP ${latestStablePHP74} for PHPBrew...`,
|
|
18
|
+
task: async (ctx, task) => {
|
|
19
|
+
const platformCompileOptions = compileOptions[process.platform];
|
|
20
|
+
|
|
21
|
+
if (!await pathExists(path.join(phpbrewConfig.phpPath, `${phpbrewPHPName}`, 'bin'))) {
|
|
22
|
+
try {
|
|
23
|
+
await execAsyncSpawn(
|
|
24
|
+
// eslint-disable-next-line max-len
|
|
25
|
+
`phpbrew install -j ${platformCompileOptions.cpuCount} ${latestStablePHP74} as ${phpbrewPHPName}`,
|
|
26
|
+
{
|
|
27
|
+
callback: (t) => {
|
|
28
|
+
task.output = t;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
);
|
|
32
|
+
} catch (e) {
|
|
33
|
+
throw new Error(
|
|
34
|
+
`Failed to compile the required by PHPBrew PHP version.
|
|
35
|
+
Tried compiling the PHP version ${ latestStablePHP74 }.
|
|
36
|
+
Use your favorite search engine to resolve the issue.
|
|
37
|
+
See error details in the output below.\n\n${e}`
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
try {
|
|
43
|
+
const phpbrewInitFileContent = `# DO NOT EDIT THIS FILE
|
|
44
|
+
|
|
45
|
+
export PHPBREW_ROOT=${phpbrewConfig.homePath}
|
|
46
|
+
export PHPBREW_HOME=${phpbrewConfig.homePath}
|
|
47
|
+
export PHPBREW_PHP=${phpbrewPHPName}
|
|
48
|
+
export PHPBREW_PATH=${phpbrewConfig.homePath}/php/${phpbrewPHPName}/bin
|
|
49
|
+
# Run this command to configure your shell:
|
|
50
|
+
# eval "$(phpbrew env)"\n`;
|
|
51
|
+
|
|
52
|
+
await fs.promises.writeFile(
|
|
53
|
+
path.join(phpbrewConfig.homePath, 'init'),
|
|
54
|
+
phpbrewInitFileContent,
|
|
55
|
+
{
|
|
56
|
+
encoding: 'utf-8'
|
|
57
|
+
}
|
|
58
|
+
);
|
|
59
|
+
} catch (e) {
|
|
60
|
+
throw new Error(`Something went wrong when trying to switch PHP to ${phpbrewPHPName}!\n\n${e}`);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
throw new Error(`You will need to restart your terminal and run ${logger.style.command('start')} again.
|
|
64
|
+
|
|
65
|
+
You can use keyboard shortcut ${logger.style.command('CTRL+D')} to close terminal.`);
|
|
66
|
+
},
|
|
67
|
+
options: {
|
|
68
|
+
bottomBar: 10
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* @type {() => import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
|
|
74
|
+
*/
|
|
75
|
+
const checkPHPVersion = () => ({
|
|
76
|
+
title: 'Checking system PHP version',
|
|
77
|
+
task: async (ctx, task) => {
|
|
78
|
+
const phpVersionResponse = await execAsyncSpawn('php --version');
|
|
79
|
+
|
|
80
|
+
const phpVersionResponseResult = phpVersionResponse.match(/^PHP\s(\d\.\d\.\d)/i);
|
|
81
|
+
|
|
82
|
+
if (phpVersionResponseResult.length > 0) {
|
|
83
|
+
const phpVersion = phpVersionResponseResult[1];
|
|
84
|
+
|
|
85
|
+
if (semver.satisfies(phpVersion, '<=7.2.x')) {
|
|
86
|
+
throw new Error(`Your installed PHP version ${phpVersion} is not supported by PHPBrew.
|
|
87
|
+
Please install PHP 7.3 and newer to operate!`);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
if (semver.satisfies(phpVersion, '>=8.1.x')) {
|
|
91
|
+
const userConfirmation = await task.prompt({
|
|
92
|
+
type: 'Confirm',
|
|
93
|
+
message: `You have PHP ${phpVersion} installed in the system.
|
|
94
|
+
PHPBrew can work with this version but it will have a lot of warning.
|
|
95
|
+
To fix that we will build special PHP version that will be used by PHPBrew, please confirm this action.`
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
if (userConfirmation) {
|
|
99
|
+
return task.newListr(
|
|
100
|
+
installPHPForPHPBrew,
|
|
101
|
+
{
|
|
102
|
+
rendererOptions: {
|
|
103
|
+
collapse: false
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
module.exports = checkPHPVersion;
|
|
@@ -12,7 +12,7 @@ const installDependenciesTask = require('../../../util/install-dependencies-task
|
|
|
12
12
|
const installPHPBrewDependencies = () => ({
|
|
13
13
|
title: 'Installing PHPBrew dependencies',
|
|
14
14
|
task: async (ctx, task) => {
|
|
15
|
-
if (
|
|
15
|
+
if (process.platform === 'darwin') {
|
|
16
16
|
return task.newListr(
|
|
17
17
|
installDependenciesTask({
|
|
18
18
|
platform: 'darwin',
|
|
@@ -183,9 +183,7 @@ Then you can continue installation.`);
|
|
|
183
183
|
const installPHPBrew = () => ({
|
|
184
184
|
title: 'Installing PHPBrew',
|
|
185
185
|
task: async (ctx, task) => {
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
if (currentPlatform === 'darwin') {
|
|
186
|
+
if (process.platform === 'darwin') {
|
|
189
187
|
return task.newListr([
|
|
190
188
|
installXcode(),
|
|
191
189
|
installPHPBrewDependencies(),
|
package/lib/tasks/start.js
CHANGED
|
@@ -26,6 +26,7 @@ const setupThemes = require('./theme/setup-themes');
|
|
|
26
26
|
const pkg = require('../../package.json');
|
|
27
27
|
const checkConfigurationFile = require('../config/check-configuration-file');
|
|
28
28
|
const convertLegacyVolumes = require('./docker/convert-legacy-volumes');
|
|
29
|
+
const enableMagentoComposerPlugins = require('./magento/enable-magento-composer-plugins');
|
|
29
30
|
|
|
30
31
|
/**
|
|
31
32
|
* @type {() => import('listr2').ListrTask<import('../../typings/context').ListrContext>}
|
|
@@ -111,6 +112,7 @@ const configureProject = () => ({
|
|
|
111
112
|
configurePhp(),
|
|
112
113
|
installPrestissimo(),
|
|
113
114
|
installMagento(),
|
|
115
|
+
enableMagentoComposerPlugins(),
|
|
114
116
|
startServices(),
|
|
115
117
|
startPhpFpm(),
|
|
116
118
|
connectToMySQL()
|
package/lib/util/clean-object.js
CHANGED
|
File without changes
|