@scandipwa/magento-scripts 1.13.2 → 1.13.5-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/lib/commands/execute.js +33 -20
- package/lib/commands/logs.js +13 -1
- package/lib/commands/start.js +8 -3
- package/lib/config/dependencies-for-platforms.js +12 -6
- package/lib/tasks/cleanup.js +2 -0
- package/lib/tasks/link.js +2 -0
- package/lib/tasks/magento/enable-magento-composer-plugins.js +3 -3
- package/lib/tasks/magento/remove-magento.js +18 -20
- package/lib/tasks/magento/setup-magento/disable-page-builder.js +11 -0
- package/lib/tasks/magento/setup-magento/install-magento.js +6 -3
- package/lib/tasks/magento/setup-magento/migrate-database.js +2 -4
- package/lib/tasks/magento/setup-magento/set-base-url.js +3 -3
- package/lib/tasks/mysql/connect-to-mysql.js +1 -0
- package/lib/tasks/php/compile.js +3 -3
- package/lib/tasks/requirements/dependency/index.js +4 -6
- package/lib/tasks/requirements/dependency/ubuntu.js +40 -1
- package/lib/tasks/requirements/docker/install.js +4 -6
- package/lib/tasks/requirements/docker/version.js +2 -9
- package/lib/tasks/requirements/phpbrew/install.js +4 -6
- package/lib/tasks/start.js +18 -2
- package/lib/tasks/theme/link-theme.js +25 -1
- package/lib/util/open-browser.js +2 -1
- package/lib/util/os-platform.js +45 -3
- package/lib/util/xdg-open-exists.js +27 -0
- package/package.json +7 -8
package/lib/commands/execute.js
CHANGED
|
@@ -6,33 +6,46 @@ const executeInContainer = require('../tasks/execute');
|
|
|
6
6
|
* @param {import('yargs')} yargs
|
|
7
7
|
*/
|
|
8
8
|
module.exports = (yargs) => {
|
|
9
|
-
yargs.command(
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
yargs.command(
|
|
10
|
+
'exec <container name> [commands...]',
|
|
11
|
+
'Execute command in docker container',
|
|
12
|
+
(yargs) => {
|
|
13
|
+
yargs.usage(`Usage: npm run exec <container name> [commands...]
|
|
12
14
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
Available containers:
|
|
16
|
+
- mysql
|
|
17
|
+
- nginx
|
|
18
|
+
- redis
|
|
19
|
+
- elasticsearch`);
|
|
20
|
+
},
|
|
21
|
+
async (argv) => {
|
|
22
|
+
const containers = (await docker).getContainers();
|
|
23
|
+
const services = Object.keys(containers);
|
|
17
24
|
|
|
18
|
-
if (argv.
|
|
25
|
+
if (services.includes(argv.containername) || services.some((service) => service.includes(argv.containername))) {
|
|
26
|
+
const container = containers[argv.containername]
|
|
27
|
+
? containers[argv.containername]
|
|
28
|
+
: Object.entries(containers).find(([key]) => key.includes(argv.containername))[1];
|
|
29
|
+
|
|
30
|
+
if (argv.commands.length === 0) {
|
|
19
31
|
// if we have default connect command then use it
|
|
20
|
-
|
|
32
|
+
if (container.connectCommand) {
|
|
21
33
|
// eslint-disable-next-line no-param-reassign
|
|
22
|
-
|
|
23
|
-
|
|
34
|
+
argv.commands = container.connectCommand;
|
|
35
|
+
} else {
|
|
24
36
|
// otherwise fall back to bash (if it exists inside container)
|
|
25
|
-
|
|
37
|
+
argv.commands.push('bash');
|
|
38
|
+
}
|
|
26
39
|
}
|
|
40
|
+
await executeInContainer({
|
|
41
|
+
containerName: container.name,
|
|
42
|
+
commands: argv.commands
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
return;
|
|
27
46
|
}
|
|
28
|
-
await executeInContainer({
|
|
29
|
-
containerName: container.name,
|
|
30
|
-
commands: argv.commands
|
|
31
|
-
});
|
|
32
47
|
|
|
33
|
-
|
|
48
|
+
logger.error(`No container found "${argv.containername}"`);
|
|
34
49
|
}
|
|
35
|
-
|
|
36
|
-
logger.error(`No container found "${argv.containername}"`);
|
|
37
|
-
});
|
|
50
|
+
);
|
|
38
51
|
};
|
package/lib/commands/logs.js
CHANGED
|
@@ -10,6 +10,18 @@ module.exports = (yargs) => {
|
|
|
10
10
|
'logs <scope>',
|
|
11
11
|
'Display application logs.',
|
|
12
12
|
(yargs) => {
|
|
13
|
+
yargs.usage(`Usage: npm run logs <scope>
|
|
14
|
+
|
|
15
|
+
Available scopes:
|
|
16
|
+
- magento
|
|
17
|
+
- mysql
|
|
18
|
+
- redis
|
|
19
|
+
- nginx
|
|
20
|
+
- elasticsearch
|
|
21
|
+
|
|
22
|
+
And you can use name matching:
|
|
23
|
+
npm run logs ma (will match magento)
|
|
24
|
+
npm run logs re (will match redis)`);
|
|
13
25
|
yargs.option(
|
|
14
26
|
'tail',
|
|
15
27
|
{
|
|
@@ -91,7 +103,7 @@ module.exports = (yargs) => {
|
|
|
91
103
|
|
|
92
104
|
return;
|
|
93
105
|
}
|
|
94
|
-
|
|
106
|
+
console.log(argv);
|
|
95
107
|
logger.error(`No service found "${argv.scope}"`);
|
|
96
108
|
process.exit(1);
|
|
97
109
|
}
|
package/lib/commands/start.js
CHANGED
|
@@ -95,12 +95,14 @@ module.exports = (yargs) => {
|
|
|
95
95
|
systemConfiguration: { analytics }
|
|
96
96
|
} = ctx;
|
|
97
97
|
|
|
98
|
+
const webLocation = `${ssl.enabled ? 'https' : 'http'}://${host}${ssl.enabled || ports.app === 80 ? '' : `:${ports.app}`}/`;
|
|
99
|
+
|
|
98
100
|
const block = new ConsoleBlock();
|
|
99
101
|
block
|
|
100
102
|
.addHeader('Magento 2')
|
|
101
103
|
.addEmptyLine()
|
|
102
|
-
.addLine(`Web location: ${logger.style.link(
|
|
103
|
-
.addLine(`Magento Admin panel location: ${logger.style.link(`${
|
|
104
|
+
.addLine(`Web location: ${logger.style.link(webLocation)}`)
|
|
105
|
+
.addLine(`Magento Admin panel location: ${logger.style.link(`${webLocation}${magentoConfiguration.adminuri}`)}`)
|
|
104
106
|
.addLine(`Magento Admin panel credentials: ${logger.style.misc(magentoConfiguration.user)} - ${logger.style.misc(magentoConfiguration.password)}`);
|
|
105
107
|
|
|
106
108
|
const themes = await getCSAThemes();
|
|
@@ -130,7 +132,10 @@ module.exports = (yargs) => {
|
|
|
130
132
|
|
|
131
133
|
block.log();
|
|
132
134
|
|
|
133
|
-
logger.note(
|
|
135
|
+
logger.note(
|
|
136
|
+
`MySQL credentials, containers status and project information available in ${logger.style.code('npm run status')} command.
|
|
137
|
+
To access Magento CLI, Composer and PHP for this project use ${logger.style.code('npm run cli')} command.`
|
|
138
|
+
);
|
|
134
139
|
logger.log('');
|
|
135
140
|
|
|
136
141
|
if (!analytics) {
|
|
@@ -15,7 +15,8 @@ const dependenciesForPlatforms = {
|
|
|
15
15
|
'libxml2',
|
|
16
16
|
'openssl@1.1'
|
|
17
17
|
],
|
|
18
|
-
installCommand: (deps) => `brew install ${deps}
|
|
18
|
+
installCommand: (deps) => `brew install ${deps}`,
|
|
19
|
+
packageManager: 'brew'
|
|
19
20
|
},
|
|
20
21
|
'Arch Linux': {
|
|
21
22
|
dependencies: [
|
|
@@ -35,7 +36,8 @@ const dependenciesForPlatforms = {
|
|
|
35
36
|
'perl',
|
|
36
37
|
'libsodium'
|
|
37
38
|
],
|
|
38
|
-
installCommand: (deps) => `sudo pacman -S ${deps} --noconfirm
|
|
39
|
+
installCommand: (deps) => `sudo pacman -S ${deps} --noconfirm`,
|
|
40
|
+
packageManager: 'pacman'
|
|
39
41
|
},
|
|
40
42
|
Fedora: {
|
|
41
43
|
dependencies: [
|
|
@@ -51,7 +53,8 @@ const dependenciesForPlatforms = {
|
|
|
51
53
|
'libtool-ltdl-devel',
|
|
52
54
|
'oniguruma-devel'
|
|
53
55
|
],
|
|
54
|
-
installCommand: (deps) => `sudo yum install ${deps} -y
|
|
56
|
+
installCommand: (deps) => `sudo yum install ${deps} -y`,
|
|
57
|
+
packageManager: 'yum'
|
|
55
58
|
},
|
|
56
59
|
CentOS: {
|
|
57
60
|
dependencies: [
|
|
@@ -67,7 +70,8 @@ const dependenciesForPlatforms = {
|
|
|
67
70
|
'libtool-ltdl-devel',
|
|
68
71
|
'oniguruma-devel'
|
|
69
72
|
],
|
|
70
|
-
installCommand: (deps) => `sudo yum install --enablerepo=PowerTools ${deps} -y
|
|
73
|
+
installCommand: (deps) => `sudo yum install --enablerepo=PowerTools ${deps} -y`,
|
|
74
|
+
packageManager: 'yum'
|
|
71
75
|
},
|
|
72
76
|
Ubuntu: {
|
|
73
77
|
dependencies: [
|
|
@@ -92,9 +96,11 @@ const dependenciesForPlatforms = {
|
|
|
92
96
|
'php-cli',
|
|
93
97
|
'php-bz2',
|
|
94
98
|
'pkg-config',
|
|
95
|
-
'autoconf'
|
|
99
|
+
'autoconf',
|
|
100
|
+
'cmake'
|
|
96
101
|
],
|
|
97
|
-
installCommand: (deps) => `sudo apt
|
|
102
|
+
installCommand: (deps) => `sudo apt install ${deps} -y`,
|
|
103
|
+
packageManager: 'apt'
|
|
98
104
|
}
|
|
99
105
|
};
|
|
100
106
|
|
package/lib/tasks/cleanup.js
CHANGED
|
@@ -5,6 +5,7 @@ const {
|
|
|
5
5
|
uninstallMagento,
|
|
6
6
|
removeMagento
|
|
7
7
|
} = require('./magento');
|
|
8
|
+
const getMagentoVersionConfig = require('../config/get-magento-version-config');
|
|
8
9
|
const { stopPhpFpm } = require('./php-fpm');
|
|
9
10
|
const getProjectConfiguration = require('../config/get-project-configuration');
|
|
10
11
|
const checkConfigurationFile = require('../config/check-configuration-file');
|
|
@@ -16,6 +17,7 @@ const cleanup = () => ({
|
|
|
16
17
|
title: 'Cleanup project',
|
|
17
18
|
task: (ctx, task) => task.newListr([
|
|
18
19
|
checkConfigurationFile(),
|
|
20
|
+
getMagentoVersionConfig(),
|
|
19
21
|
getProjectConfiguration(),
|
|
20
22
|
stopPhpFpm(),
|
|
21
23
|
stopServices(),
|
package/lib/tasks/link.js
CHANGED
|
@@ -6,6 +6,7 @@ const linkTheme = require('./theme/link-theme');
|
|
|
6
6
|
const { startServices } = require('./docker');
|
|
7
7
|
const { startPhpFpm } = require('./php-fpm');
|
|
8
8
|
const checkConfigurationFile = require('../config/check-configuration-file');
|
|
9
|
+
const { connectToMySQL } = require('./mysql');
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* @type {(theme: string) => import('listr2').ListrTask<import('../../typings/context').ListrContext>}
|
|
@@ -18,6 +19,7 @@ const linkTask = (themePath) => ({
|
|
|
18
19
|
getCachedPorts(),
|
|
19
20
|
startServices(),
|
|
20
21
|
startPhpFpm(),
|
|
22
|
+
connectToMySQL(),
|
|
21
23
|
retrieveThemeData(themePath),
|
|
22
24
|
linkTheme()
|
|
23
25
|
])
|
|
@@ -81,7 +81,7 @@ const enableMagentoComposerPlugins = () => ({
|
|
|
81
81
|
const {
|
|
82
82
|
config: {
|
|
83
83
|
'allow-plugins': allowPlugins = {}
|
|
84
|
-
}
|
|
84
|
+
} = {}
|
|
85
85
|
} = composerJsonData;
|
|
86
86
|
const allowPluginsKeys = Object.keys(allowPlugins);
|
|
87
87
|
|
|
@@ -110,7 +110,7 @@ Do you want to enable them all or disable some of them?`,
|
|
|
110
110
|
|
|
111
111
|
if (userConfirmation) {
|
|
112
112
|
composerJsonData.config = {
|
|
113
|
-
...composerJsonData.config,
|
|
113
|
+
...(composerJsonData.config || {}),
|
|
114
114
|
'allow-plugins': {
|
|
115
115
|
...allowPlugins,
|
|
116
116
|
...missingPlugins.reduce((acc, val) => ({ ...acc, [val]: true }), {})
|
|
@@ -141,7 +141,7 @@ Do you want to enable them all or disable some of them?`,
|
|
|
141
141
|
const disabledPlugins = composerPlugins.filter((p) => !userEnabledPlugins.includes(p));
|
|
142
142
|
|
|
143
143
|
composerJsonData.config = {
|
|
144
|
-
...composerJsonData.config,
|
|
144
|
+
...(composerJsonData.config || {}),
|
|
145
145
|
'allow-plugins': {
|
|
146
146
|
...allowPlugins,
|
|
147
147
|
...disabledPlugins.reduce((acc, val) => ({ ...acc, [val]: false }), {}),
|
|
@@ -37,29 +37,27 @@ const magentoFiles = [
|
|
|
37
37
|
*/
|
|
38
38
|
const removeMagento = () => ({
|
|
39
39
|
title: 'Remove magento application folder',
|
|
40
|
-
|
|
40
|
+
skip: async (ctx) => {
|
|
41
41
|
const { config: { baseConfig } } = ctx;
|
|
42
42
|
const appPathExists = await pathExists(baseConfig.magentoDir);
|
|
43
43
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}))
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
task.skip();
|
|
44
|
+
return !(appPathExists && ctx.force);
|
|
45
|
+
},
|
|
46
|
+
task: async (ctx) => {
|
|
47
|
+
const { config: { baseConfig } } = ctx;
|
|
48
|
+
await Promise.all(magentoFiles.map(async (fileName) => {
|
|
49
|
+
const filePath = path.join(baseConfig.magentoDir, fileName);
|
|
50
|
+
const fileExists = await pathExists(filePath);
|
|
51
|
+
if (!fileExists) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
const file = await fs.promises.stat(filePath);
|
|
55
|
+
if (file.isFile()) {
|
|
56
|
+
await fs.promises.unlink(filePath);
|
|
57
|
+
} else if (file.isDirectory()) {
|
|
58
|
+
await fs.promises.rmdir(filePath, { recursive: true });
|
|
59
|
+
}
|
|
60
|
+
}));
|
|
63
61
|
}
|
|
64
62
|
});
|
|
65
63
|
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
const magentoTask = require('../../../util/magento-task');
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @type {() => import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
|
|
5
|
+
*/
|
|
6
|
+
const disablePageBuilder = () => ({
|
|
7
|
+
title: 'Disabling page builder in Magento',
|
|
8
|
+
task: (ctx, task) => task.newListr(magentoTask('config:set cms/pagebuilder/enabled 0'))
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
module.exports = disablePageBuilder;
|
|
@@ -2,11 +2,14 @@ const semver = require('semver');
|
|
|
2
2
|
const runMagentoCommand = require('../../../util/run-magento');
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
* @type {() => import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
|
|
5
|
+
* @type {({ isDbEmpty }: { isDbEmpty: boolean }) => import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
|
|
6
6
|
*/
|
|
7
|
-
const installMagento = () => ({
|
|
8
|
-
title: 'Installing magento
|
|
7
|
+
const installMagento = ({ isDbEmpty = false } = {}) => ({
|
|
8
|
+
title: 'Installing magento',
|
|
9
9
|
task: async (ctx, task) => {
|
|
10
|
+
if (isDbEmpty) {
|
|
11
|
+
task.output = 'No Magento is installed in DB!\nInstalling...';
|
|
12
|
+
}
|
|
10
13
|
const {
|
|
11
14
|
magentoVersion,
|
|
12
15
|
config: {
|
|
@@ -24,16 +24,14 @@ const migrateDatabase = (options = {}) => ({
|
|
|
24
24
|
`);
|
|
25
25
|
|
|
26
26
|
if (tableCount === 0) {
|
|
27
|
-
task.output = 'No Magento is installed in DB!\nInstalling...';
|
|
28
|
-
|
|
29
27
|
if (options.onlyInstallMagento) {
|
|
30
28
|
return task.newListr(
|
|
31
|
-
installMagento()
|
|
29
|
+
installMagento({ isDbEmpty: true })
|
|
32
30
|
);
|
|
33
31
|
}
|
|
34
32
|
|
|
35
33
|
return task.newListr([
|
|
36
|
-
installMagento(),
|
|
34
|
+
installMagento({ isDbEmpty: true }),
|
|
37
35
|
setupPersistedQuery(),
|
|
38
36
|
upgradeMagento(),
|
|
39
37
|
magentoTask('cache:enable'),
|
|
@@ -11,11 +11,11 @@ module.exports = () => ({
|
|
|
11
11
|
config: { overridenConfiguration: { host, ssl } },
|
|
12
12
|
mysqlConnection
|
|
13
13
|
} = ctx;
|
|
14
|
+
const enableSecureFrontend = ssl.enabled ? '1' : '0';
|
|
14
15
|
const location = `${host}${ ports.app !== 80 ? `:${ports.app}` : '' }/`;
|
|
16
|
+
const secureLocation = `${host}/`; // SSL will work only on port 443, so you cannot run multiple projects with SSL at the same time.
|
|
15
17
|
const httpUrl = `http://${location}`;
|
|
16
|
-
const httpsUrl = `https://${
|
|
17
|
-
|
|
18
|
-
const enableSecureFrontend = ssl.enabled ? '1' : '0';
|
|
18
|
+
const httpsUrl = `https://${secureLocation}`;
|
|
19
19
|
|
|
20
20
|
await updateTableValues('core_config_data', [
|
|
21
21
|
{ path: 'web/unsecure/base_url', value: httpUrl },
|
|
@@ -7,6 +7,7 @@ const sleep = require('../../util/sleep');
|
|
|
7
7
|
*/
|
|
8
8
|
const connectToMySQL = () => ({
|
|
9
9
|
title: 'Connecting to MySQL server...',
|
|
10
|
+
skip: (ctx) => ctx.skipSetup,
|
|
10
11
|
task: async (ctx, task) => {
|
|
11
12
|
const { config: { docker }, ports } = ctx;
|
|
12
13
|
const { mysql: { env, name } } = docker.getContainers();
|
package/lib/tasks/php/compile.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const systeminformation = require('systeminformation');
|
|
2
2
|
const logger = require('@scandipwa/scandipwa-dev-utils/logger');
|
|
3
3
|
const { execAsyncSpawn } = require('../../util/exec-async-command');
|
|
4
4
|
const compileOptions = require('./compile-options');
|
|
@@ -11,8 +11,8 @@ const compile = () => ({
|
|
|
11
11
|
task: async ({ config: { php } }, task) => {
|
|
12
12
|
const platformCompileOptions = compileOptions[process.platform];
|
|
13
13
|
if (process.platform === 'linux') {
|
|
14
|
-
const {
|
|
15
|
-
if (['Fedora', 'Manjaro'].some((
|
|
14
|
+
const { distro } = await systeminformation.osInfo();
|
|
15
|
+
if (['Fedora', 'Manjaro'].some((d) => distro.includes(d))) {
|
|
16
16
|
platformCompileOptions.extraOptions.push('--with-libdir=lib64');
|
|
17
17
|
}
|
|
18
18
|
}
|
|
@@ -1,19 +1,18 @@
|
|
|
1
|
-
const osPlatform = require('../../../util/os-platform');
|
|
2
1
|
const archDependenciesCheck = require('./arch');
|
|
3
2
|
const fedoraDependenciesCheck = require('./fedora');
|
|
4
3
|
const centosDependenciesCheck = require('./centos');
|
|
5
4
|
const ubuntuDependenciesCheck = require('./ubuntu');
|
|
6
5
|
const macDependenciesCheck = require('./mac');
|
|
6
|
+
const osPlatform = require('../../../util/os-platform');
|
|
7
7
|
|
|
8
8
|
const dependencyCheck = async () => {
|
|
9
9
|
if (process.platform === 'darwin') {
|
|
10
10
|
return macDependenciesCheck();
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
const
|
|
14
|
-
switch (
|
|
15
|
-
case 'Arch Linux':
|
|
16
|
-
case 'Manjaro Linux': {
|
|
13
|
+
const distro = await osPlatform();
|
|
14
|
+
switch (distro) {
|
|
15
|
+
case 'Arch Linux': {
|
|
17
16
|
return archDependenciesCheck();
|
|
18
17
|
}
|
|
19
18
|
case 'Fedora': {
|
|
@@ -22,7 +21,6 @@ const dependencyCheck = async () => {
|
|
|
22
21
|
case 'CentOS': {
|
|
23
22
|
return centosDependenciesCheck();
|
|
24
23
|
}
|
|
25
|
-
case 'Linux Mint':
|
|
26
24
|
case 'Ubuntu': {
|
|
27
25
|
return ubuntuDependenciesCheck();
|
|
28
26
|
}
|
|
@@ -1,9 +1,31 @@
|
|
|
1
|
+
const logger = require('@scandipwa/scandipwa-dev-utils/logger');
|
|
2
|
+
const os = require('os');
|
|
1
3
|
const dependenciesForPlatforms = require('../../../config/dependencies-for-platforms');
|
|
2
|
-
const { execAsyncSpawn } = require('../../../util/exec-async-command');
|
|
4
|
+
const { execAsyncSpawn, execCommandTask } = require('../../../util/exec-async-command');
|
|
3
5
|
const installDependenciesTask = require('../../../util/install-dependencies-task');
|
|
4
6
|
|
|
5
7
|
const pkgRegex = /^(\S+)\/\S+\s(\S+)\s\S+\s\S+$/i;
|
|
6
8
|
|
|
9
|
+
const updateSystem = () => ({
|
|
10
|
+
title: 'Updating Ubuntu system',
|
|
11
|
+
task: async (ctx, task) => {
|
|
12
|
+
task.output = 'Enter your sudo password!';
|
|
13
|
+
task.output = logger.style.command(`>[sudo] password for ${ os.userInfo().username }:`);
|
|
14
|
+
|
|
15
|
+
return task.newListr(
|
|
16
|
+
execCommandTask('sudo apt update', {
|
|
17
|
+
callback: (t) => {
|
|
18
|
+
task.output = t;
|
|
19
|
+
},
|
|
20
|
+
pipeInput: true
|
|
21
|
+
})
|
|
22
|
+
);
|
|
23
|
+
},
|
|
24
|
+
options: {
|
|
25
|
+
bottomBar: 10
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
|
|
7
29
|
/**
|
|
8
30
|
* @type {() => import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
|
|
9
31
|
*/
|
|
@@ -28,6 +50,23 @@ const ubuntuDependenciesCheck = () => ({
|
|
|
28
50
|
.map((dep) => (Array.isArray(dep) ? dep[0] : dep));
|
|
29
51
|
|
|
30
52
|
if (dependenciesToInstall.length > 0) {
|
|
53
|
+
const runSystemUpdate = await task.prompt({
|
|
54
|
+
type: 'Confirm',
|
|
55
|
+
message: `Would you like to run ${logger.style.command('apt update')} before installing missing ${dependenciesToInstall.length} dependenc${dependenciesToInstall.length > 1 ? 'ies' : 'y'}?`
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
if (runSystemUpdate) {
|
|
59
|
+
return task.newListr([
|
|
60
|
+
updateSystem(),
|
|
61
|
+
installDependenciesTask({
|
|
62
|
+
platform: 'Ubuntu',
|
|
63
|
+
dependenciesToInstall
|
|
64
|
+
})
|
|
65
|
+
], {
|
|
66
|
+
concurrent: false
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
|
|
31
70
|
return task.newListr(
|
|
32
71
|
installDependenciesTask({
|
|
33
72
|
platform: 'Ubuntu',
|
|
@@ -16,10 +16,9 @@ const postInstallSteps = [
|
|
|
16
16
|
const installDocker = () => ({
|
|
17
17
|
title: 'Installing Docker',
|
|
18
18
|
task: async (ctx, task) => {
|
|
19
|
-
const
|
|
20
|
-
switch (
|
|
21
|
-
case 'Arch Linux':
|
|
22
|
-
case 'Manjaro Linux': {
|
|
19
|
+
const distro = await osPlatform();
|
|
20
|
+
switch (distro) {
|
|
21
|
+
case 'Arch Linux': {
|
|
23
22
|
return task.newListr([
|
|
24
23
|
installDependenciesTask({
|
|
25
24
|
platform: 'Arch Linux',
|
|
@@ -39,7 +38,6 @@ const installDocker = () => ({
|
|
|
39
38
|
executeSudoCommand('sudo systemctl enable docker')
|
|
40
39
|
]);
|
|
41
40
|
}
|
|
42
|
-
case 'Linux Mint':
|
|
43
41
|
case 'Ubuntu': {
|
|
44
42
|
return task.newListr([
|
|
45
43
|
execCommandTask('curl -fsSL https://get.docker.com -o get-docker.sh'),
|
|
@@ -51,7 +49,7 @@ const installDocker = () => ({
|
|
|
51
49
|
}
|
|
52
50
|
default: {
|
|
53
51
|
throw new Error(`Docker is not installed!
|
|
54
|
-
Your distro ${
|
|
52
|
+
Your distro ${distro} is not supported by automatic installation.`);
|
|
55
53
|
}
|
|
56
54
|
}
|
|
57
55
|
}
|
|
@@ -1,23 +1,16 @@
|
|
|
1
1
|
const { execAsyncSpawn } = require('../../../util/exec-async-command');
|
|
2
|
-
const safeRegexExtract = require('../../../util/safe-regex-extract');
|
|
3
2
|
|
|
4
3
|
/**
|
|
5
4
|
* @type {() => import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
|
|
6
5
|
*/
|
|
7
6
|
const getDockerVersion = () => ({
|
|
8
7
|
task: async (ctx) => {
|
|
9
|
-
const { result, code } = await execAsyncSpawn('docker
|
|
8
|
+
const { result, code } = await execAsyncSpawn('docker version --format {{.Server.Version}}', {
|
|
10
9
|
withCode: true
|
|
11
10
|
});
|
|
12
11
|
|
|
13
12
|
if (code === 0) {
|
|
14
|
-
const dockerVersion =
|
|
15
|
-
string: result,
|
|
16
|
-
regex: /docker version ([\d.]+)/i,
|
|
17
|
-
onNoMatch: () => {
|
|
18
|
-
throw new Error(`No docker version found in docker version output!\n\n${result}`);
|
|
19
|
-
}
|
|
20
|
-
});
|
|
13
|
+
const dockerVersion = result.split('').filter((c) => /[\d.]/i.test(c)).join('') || result;
|
|
21
14
|
|
|
22
15
|
ctx.dockerVersion = dockerVersion;
|
|
23
16
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
const os = require('os');
|
|
2
2
|
const path = require('path');
|
|
3
3
|
const fs = require('fs');
|
|
4
|
-
const osPlatform = require('../../../util/os-platform');
|
|
5
4
|
const { execAsyncSpawn } = require('../../../util/exec-async-command');
|
|
6
5
|
const logger = require('@scandipwa/scandipwa-dev-utils/logger');
|
|
7
6
|
const installDependenciesTask = require('../../../util/install-dependencies-task');
|
|
7
|
+
const osPlatform = require('../../../util/os-platform');
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* @type {() => import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
|
|
@@ -20,10 +20,9 @@ const installPHPBrewDependencies = () => ({
|
|
|
20
20
|
})
|
|
21
21
|
);
|
|
22
22
|
}
|
|
23
|
-
const
|
|
24
|
-
switch (
|
|
25
|
-
case 'Arch Linux':
|
|
26
|
-
case 'Manjaro Linux': {
|
|
23
|
+
const distro = await osPlatform();
|
|
24
|
+
switch (distro) {
|
|
25
|
+
case 'Arch Linux': {
|
|
27
26
|
return task.newListr(
|
|
28
27
|
installDependenciesTask({
|
|
29
28
|
platform: 'Arch Linux',
|
|
@@ -47,7 +46,6 @@ const installPHPBrewDependencies = () => ({
|
|
|
47
46
|
})
|
|
48
47
|
);
|
|
49
48
|
}
|
|
50
|
-
case 'Linux Mint':
|
|
51
49
|
case 'Ubuntu': {
|
|
52
50
|
return task.newListr(
|
|
53
51
|
installDependenciesTask({
|
package/lib/tasks/start.js
CHANGED
|
@@ -27,6 +27,8 @@ const pkg = require('../../package.json');
|
|
|
27
27
|
const checkConfigurationFile = require('../config/check-configuration-file');
|
|
28
28
|
const convertLegacyVolumes = require('./docker/convert-legacy-volumes');
|
|
29
29
|
const enableMagentoComposerPlugins = require('./magento/enable-magento-composer-plugins');
|
|
30
|
+
const getIsWsl = require('../util/is-wsl');
|
|
31
|
+
const checkForXDGOpen = require('../util/xdg-open-exists');
|
|
30
32
|
|
|
31
33
|
/**
|
|
32
34
|
* @type {() => import('listr2').ListrTask<import('../../typings/context').ListrContext>}
|
|
@@ -172,9 +174,23 @@ const start = () => ({
|
|
|
172
174
|
finishProjectConfiguration(),
|
|
173
175
|
{
|
|
174
176
|
title: 'Opening browser',
|
|
175
|
-
skip: (ctx) =>
|
|
177
|
+
skip: async (ctx) => {
|
|
178
|
+
if (ctx.noOpen) {
|
|
179
|
+
return true;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
if (await getIsWsl()) {
|
|
183
|
+
const canOpenBrowser = await checkForXDGOpen();
|
|
184
|
+
|
|
185
|
+
if (!canOpenBrowser) {
|
|
186
|
+
return 'Cannot open the browser, xdg-open is not available.';
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
return false;
|
|
191
|
+
},
|
|
176
192
|
task: ({ ports, config: { overridenConfiguration: { host, ssl } } }) => {
|
|
177
|
-
openBrowser(`${ssl.enabled ? 'https' : 'http'}://${host}${ports.app === 80 ? '' : `:${ports.app}`}/`);
|
|
193
|
+
openBrowser(`${ssl.enabled ? 'https' : 'http'}://${host}${ssl.enabled || ports.app === 80 ? '' : `:${ports.app}`}/`);
|
|
178
194
|
},
|
|
179
195
|
options: {
|
|
180
196
|
showTimer: false
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
const symlinkTheme = require('./symlink-theme');
|
|
2
2
|
const installTheme = require('./install-theme');
|
|
3
3
|
const disablePageCache = require('../magento/setup-magento/disable-page-cache');
|
|
4
|
+
const disablePageBuilder = require('../magento/setup-magento/disable-page-builder');
|
|
4
5
|
const buildTheme = require('./build-theme');
|
|
5
6
|
const upgradeMagento = require('../magento/setup-magento/upgrade-magento');
|
|
6
7
|
const setupPersistedQuery = require('./setup-persisted-query');
|
|
7
8
|
const updateEnvPHP = require('../php/update-env-php');
|
|
9
|
+
const semver = require('semver');
|
|
8
10
|
|
|
9
11
|
/**
|
|
10
12
|
* @type {() => import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
|
|
@@ -12,7 +14,28 @@ const updateEnvPHP = require('../php/update-env-php');
|
|
|
12
14
|
const linkTheme = () => ({
|
|
13
15
|
title: 'Linking theme',
|
|
14
16
|
task: async (ctx, task) => {
|
|
15
|
-
const {
|
|
17
|
+
const {
|
|
18
|
+
config: { overridenConfiguration },
|
|
19
|
+
absoluteThemePath,
|
|
20
|
+
themePath,
|
|
21
|
+
composerData,
|
|
22
|
+
mysqlConnection
|
|
23
|
+
} = ctx;
|
|
24
|
+
const {
|
|
25
|
+
magento: { edition: magentoEdition },
|
|
26
|
+
magentoVersion
|
|
27
|
+
} = overridenConfiguration;
|
|
28
|
+
|
|
29
|
+
const isEnterprise = magentoEdition === 'enterprise';
|
|
30
|
+
const isPageBuilderInstalled = isEnterprise && semver.satisfies(semver.coerce(magentoVersion), '^2.4');
|
|
31
|
+
const [queryResult] = await mysqlConnection.query(`
|
|
32
|
+
SELECT value AS isPagebuilderEnabled
|
|
33
|
+
FROM core_config_data
|
|
34
|
+
WHERE path = 'cms/pagebuilder/enabled'
|
|
35
|
+
`);
|
|
36
|
+
|
|
37
|
+
const [{ isPagebuilderEnabled = 1 }] = queryResult.length ? queryResult : [{}];
|
|
38
|
+
|
|
16
39
|
/**
|
|
17
40
|
* @type {import('../../../typings/theme').Theme}
|
|
18
41
|
*/
|
|
@@ -31,6 +54,7 @@ const linkTheme = () => ({
|
|
|
31
54
|
setupPersistedQuery(),
|
|
32
55
|
upgradeMagento(),
|
|
33
56
|
disablePageCache(),
|
|
57
|
+
...(isPageBuilderInstalled && Number(isPagebuilderEnabled) ? [disablePageBuilder()] : []),
|
|
34
58
|
buildTheme(theme)
|
|
35
59
|
]);
|
|
36
60
|
},
|
package/lib/util/open-browser.js
CHANGED
|
@@ -2,7 +2,8 @@ const { execAsync } = require('./exec-async-command');
|
|
|
2
2
|
|
|
3
3
|
const openBrowser = async (url) => {
|
|
4
4
|
const start = process.platform === 'darwin' ? 'open' : 'xdg-open';
|
|
5
|
-
|
|
5
|
+
|
|
6
|
+
await execAsync(`${ start } ${ url }`);
|
|
6
7
|
};
|
|
7
8
|
|
|
8
9
|
module.exports = openBrowser;
|
package/lib/util/os-platform.js
CHANGED
|
@@ -1,9 +1,51 @@
|
|
|
1
|
-
const
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const systeminformation = require('systeminformation');
|
|
3
|
+
const pathExists = require('./path-exists');
|
|
4
|
+
const dependenciesForPlatforms = require('../config/dependencies-for-platforms');
|
|
2
5
|
|
|
6
|
+
const packageManagers = Object.entries(dependenciesForPlatforms).map((d) => ({
|
|
7
|
+
platform: d[0],
|
|
8
|
+
packageManager: d[1].packageManager
|
|
9
|
+
}));
|
|
3
10
|
/**
|
|
4
11
|
*
|
|
5
|
-
* @returns {Promise<
|
|
12
|
+
* @returns {Promise<keyof typeof dependenciesForPlatforms>}
|
|
6
13
|
*/
|
|
7
|
-
const osPlatform =
|
|
14
|
+
const osPlatform = async () => {
|
|
15
|
+
const binPaths = process.env.PATH.split(':');
|
|
16
|
+
|
|
17
|
+
const platforms = await Promise.all(binPaths.map(async (binPath) => {
|
|
18
|
+
if (!await pathExists(binPath)) {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
const bins = await fs.promises.readdir(binPath);
|
|
22
|
+
|
|
23
|
+
for (const bin of bins) {
|
|
24
|
+
const possiblePlatforms = packageManagers.filter((p) => p.packageManager === bin);
|
|
25
|
+
|
|
26
|
+
if (possiblePlatforms.length > 0) {
|
|
27
|
+
if (possiblePlatforms.length > 1) {
|
|
28
|
+
const { distro } = await systeminformation.osInfo();
|
|
29
|
+
|
|
30
|
+
const foundDistro = possiblePlatforms.find((p) => p.platform.toLowerCase().includes(distro.toLowerCase()));
|
|
31
|
+
|
|
32
|
+
if (foundDistro) {
|
|
33
|
+
return foundDistro.platform;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return possiblePlatforms[0].platform;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return possiblePlatforms[0].platform;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return null;
|
|
44
|
+
}));
|
|
45
|
+
|
|
46
|
+
const filteredPlatforms = platforms.filter(Boolean);
|
|
47
|
+
|
|
48
|
+
return filteredPlatforms.shift();
|
|
49
|
+
};
|
|
8
50
|
|
|
9
51
|
module.exports = osPlatform;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const pathExists = require('./path-exists');
|
|
3
|
+
|
|
4
|
+
const checkForXDGOpen = async () => {
|
|
5
|
+
const pathParts = process.env.PATH.split(':');
|
|
6
|
+
|
|
7
|
+
const results = await Promise.all(
|
|
8
|
+
pathParts.map(
|
|
9
|
+
async (pathPart) => {
|
|
10
|
+
if (!await pathExists(pathPart)) {
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const files = await fs.promises.readdir(pathPart, {
|
|
15
|
+
encoding: 'utf-8',
|
|
16
|
+
withFileTypes: true
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
return files.some((file) => file.isFile() && file.name === 'xdg-open');
|
|
20
|
+
}
|
|
21
|
+
)
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
return results.includes(true);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
module.exports = checkForXDGOpen;
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "Scripts and configuration used by CMA.",
|
|
4
4
|
"homepage": "https://docs.create-magento-app.com/",
|
|
5
5
|
"repository": "github:scandipwa/create-magento-app",
|
|
6
|
-
"version": "1.13.
|
|
6
|
+
"version": "1.13.5-alpha.0",
|
|
7
7
|
"main": "./index.js",
|
|
8
8
|
"types": "./typings/index.d.ts",
|
|
9
9
|
"license": "OSL-3.0",
|
|
@@ -23,24 +23,23 @@
|
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@scandipwa/scandipwa-dev-utils": "0.1.12",
|
|
26
|
-
"conf": "10.
|
|
26
|
+
"conf": "10.1.1",
|
|
27
27
|
"enquirer": "2.3.6",
|
|
28
28
|
"eta": "1.12.3",
|
|
29
|
-
"getos": "3.2.1",
|
|
30
29
|
"hjson": "^3.2.2",
|
|
31
30
|
"is-installed-globally": "0.4.0",
|
|
32
|
-
"joi": "17.
|
|
33
|
-
"listr2": "
|
|
31
|
+
"joi": "17.6.0",
|
|
32
|
+
"listr2": "4.0.5",
|
|
34
33
|
"macos-version": "5.2.1",
|
|
35
34
|
"merge-files": "0.1.2",
|
|
36
35
|
"mysql2": "2.3.2",
|
|
37
36
|
"node-ssh": "12.0.0",
|
|
38
37
|
"semver": "7.3.5",
|
|
39
|
-
"systeminformation": "5.
|
|
40
|
-
"yargs": "17.
|
|
38
|
+
"systeminformation": "5.11.7",
|
|
39
|
+
"yargs": "17.3.1"
|
|
41
40
|
},
|
|
42
41
|
"publishConfig": {
|
|
43
42
|
"access": "public"
|
|
44
43
|
},
|
|
45
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "d441da5928b8f8cf0fb6034ffe09ce186a0370d6"
|
|
46
45
|
}
|