@scandipwa/magento-scripts 1.13.4 → 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.
@@ -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: [
@@ -95,7 +99,8 @@ const dependenciesForPlatforms = {
95
99
  'autoconf',
96
100
  'cmake'
97
101
  ],
98
- installCommand: (deps) => `sudo apt-get install ${deps} -y`
102
+ installCommand: (deps) => `sudo apt install ${deps} -y`,
103
+ packageManager: 'apt'
99
104
  }
100
105
  };
101
106
 
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
  ])
@@ -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;
@@ -1,4 +1,4 @@
1
- const osPlatform = require('../../util/os-platform');
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 { dist } = await osPlatform();
15
- if (['Fedora', 'Manjaro'].some((distro) => dist.includes(distro))) {
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 { dist } = await osPlatform();
14
- switch (dist) {
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
  }
@@ -16,10 +16,9 @@ const postInstallSteps = [
16
16
  const installDocker = () => ({
17
17
  title: 'Installing Docker',
18
18
  task: async (ctx, task) => {
19
- const { dist } = await osPlatform();
20
- switch (dist) {
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 ${dist} is not supported by automatic installation.`);
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 -v', {
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 = safeRegexExtract({
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 { dist } = await osPlatform();
24
- switch (dist) {
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({
@@ -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 { absoluteThemePath, themePath, composerData } = ctx;
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
  },
@@ -1,9 +1,51 @@
1
- const getos = require('getos');
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<import('getos').OS>}
12
+ * @returns {Promise<keyof typeof dependenciesForPlatforms>}
6
13
  */
7
- const osPlatform = () => new Promise((resolve, reject) => getos((err, os) => (err ? reject(err) : resolve(os))));
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;
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.4",
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.0.3",
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.4.2",
33
- "listr2": "3.13.0",
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.9.8",
40
- "yargs": "17.2.1"
38
+ "systeminformation": "5.11.7",
39
+ "yargs": "17.3.1"
41
40
  },
42
41
  "publishConfig": {
43
42
  "access": "public"
44
43
  },
45
- "gitHead": "fa0d2c77e7d3a8c639cbebeef05b1322b20895f4"
44
+ "gitHead": "d441da5928b8f8cf0fb6034ffe09ce186a0370d6"
46
45
  }