@scandipwa/magento-scripts 1.13.0-alpha.0 → 1.13.2
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/tasks/magento/setup-magento/adjust-magento-configuration.js +3 -0
- package/lib/tasks/magento/setup-magento/configure-elasticsearch.js +2 -1
- package/lib/tasks/magento/setup-magento/delete-admin-users.js +3 -0
- package/lib/tasks/magento/setup-magento/migrate-database.js +1 -1
- package/lib/tasks/mysql/connect-to-mysql.js +1 -1
- package/lib/tasks/mysql/dump-theme-config.js +15 -19
- package/lib/tasks/requirements/php-version.js +27 -10
- package/lib/util/database.js +21 -2
- package/package.json +2 -2
- package/typings/context.d.ts +3 -0
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
const { isTableExists } = require('../../../util/database');
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* @type {() => import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
|
|
3
5
|
*/
|
|
4
6
|
const adjustMagentoConfiguration = () => ({
|
|
5
7
|
title: 'Adjusting Magento Database Configuration',
|
|
8
|
+
skip: async (ctx) => !(await isTableExists('magento', 'core_config_data', ctx)),
|
|
6
9
|
task: async (ctx) => {
|
|
7
10
|
const { mysqlConnection } = ctx;
|
|
8
11
|
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
const { updateTableValues } = require('../../../util/database');
|
|
1
|
+
const { updateTableValues, isTableExists } = require('../../../util/database');
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* @type {() => import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
|
|
5
5
|
*/
|
|
6
6
|
module.exports = () => ({
|
|
7
7
|
title: 'Configuring elasticsearch',
|
|
8
|
+
skip: async (ctx) => !(await isTableExists('magento', 'core_config_data', ctx)),
|
|
8
9
|
task: async ({ ports, mysqlConnection }, task) => {
|
|
9
10
|
await updateTableValues('core_config_data', [
|
|
10
11
|
{ path: 'catalog/search/engine', value: 'elasticsearch7' },
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
const { isTableExists } = require('../../../util/database');
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* @type {() => import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
|
|
3
5
|
*/
|
|
4
6
|
const deleteAdminUsers = () => ({
|
|
5
7
|
title: 'Deleting old admin users',
|
|
8
|
+
skip: async (ctx) => !(await isTableExists('magento', 'admin_user', ctx)),
|
|
6
9
|
task: async (ctx) => {
|
|
7
10
|
const { mysqlConnection } = ctx;
|
|
8
11
|
await mysqlConnection.query(`
|
|
@@ -18,7 +18,7 @@ const migrateDatabase = (options = {}) => ({
|
|
|
18
18
|
} = ctx;
|
|
19
19
|
|
|
20
20
|
const [[{ tableCount }]] = await mysqlConnection.query(`
|
|
21
|
-
SELECT count
|
|
21
|
+
SELECT count(*) AS tableCount
|
|
22
22
|
FROM INFORMATION_SCHEMA.TABLES
|
|
23
23
|
WHERE TABLE_SCHEMA = 'magento';
|
|
24
24
|
`);
|
|
@@ -27,7 +27,7 @@ Please wait, this will take some time and do not restart the MySQL container unt
|
|
|
27
27
|
}
|
|
28
28
|
try {
|
|
29
29
|
const connection = await mysql.createConnection({
|
|
30
|
-
host: '
|
|
30
|
+
host: '127.0.0.1',
|
|
31
31
|
port: ports.mysql,
|
|
32
32
|
user: env.MYSQL_USER,
|
|
33
33
|
password: env.MYSQL_PASSWORD,
|
|
@@ -1,21 +1,13 @@
|
|
|
1
|
+
const { isTableExists } = require('../../util/database');
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* @type {() => import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
|
|
3
5
|
*/
|
|
4
6
|
const dumpThemeConfig = () => ({
|
|
5
7
|
title: 'Dumping themes and theme configuration',
|
|
6
|
-
task: async (ctx) => {
|
|
8
|
+
task: async (ctx, task) => {
|
|
7
9
|
const { mysqlConnection } = ctx;
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* @type {{ tableCount: number }[][]}
|
|
11
|
-
*/
|
|
12
|
-
const [[{ tableCount }]] = await mysqlConnection.query(`
|
|
13
|
-
SELECT count (*) AS tableCount
|
|
14
|
-
FROM INFORMATION_SCHEMA.TABLES
|
|
15
|
-
WHERE TABLE_SCHEMA = 'magento';
|
|
16
|
-
`);
|
|
17
|
-
|
|
18
|
-
if (tableCount !== 0) {
|
|
10
|
+
if (await isTableExists('magento', 'theme', ctx)) {
|
|
19
11
|
const [themes] = await mysqlConnection.query('select * from theme;');
|
|
20
12
|
if (themes.length === 0) {
|
|
21
13
|
ctx.themeDump = {
|
|
@@ -24,15 +16,19 @@ const dumpThemeConfig = () => ({
|
|
|
24
16
|
};
|
|
25
17
|
}
|
|
26
18
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
19
|
+
if (await isTableExists('magento', 'core_config_data', ctx)) {
|
|
20
|
+
const [themeIdConfig] = await mysqlConnection.query('select * from core_config_data where path = \'design/theme/theme_id\';');
|
|
21
|
+
if (themeIdConfig.length !== 0) {
|
|
22
|
+
ctx.themeDump = {
|
|
23
|
+
themes,
|
|
24
|
+
themeIdConfig: themeIdConfig[0]
|
|
25
|
+
};
|
|
33
26
|
|
|
34
|
-
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
35
29
|
}
|
|
30
|
+
} else {
|
|
31
|
+
task.skip();
|
|
36
32
|
}
|
|
37
33
|
|
|
38
34
|
ctx.themeDump = {
|
|
@@ -10,19 +10,41 @@ const compileOptions = require('../php/compile-options');
|
|
|
10
10
|
const latestStablePHP74 = '7.4.27';
|
|
11
11
|
const phpbrewPHPName = `php-${latestStablePHP74}-phpbrew`;
|
|
12
12
|
|
|
13
|
+
const compileOptionsForPhp = {
|
|
14
|
+
linux: {
|
|
15
|
+
...compileOptions.linux,
|
|
16
|
+
variants: [
|
|
17
|
+
'+default'
|
|
18
|
+
],
|
|
19
|
+
extraOptions: []
|
|
20
|
+
},
|
|
21
|
+
darwin: {
|
|
22
|
+
...compileOptions.darwin,
|
|
23
|
+
variants: [
|
|
24
|
+
'+default',
|
|
25
|
+
'+openssl=$(brew --prefix openssl@1.1)'
|
|
26
|
+
],
|
|
27
|
+
extraOptions: []
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
|
|
13
31
|
/**
|
|
14
32
|
* @type {() => import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
|
|
15
33
|
*/
|
|
16
34
|
const installPHPForPHPBrew = () => ({
|
|
17
35
|
title: `Installing PHP ${latestStablePHP74} for PHPBrew...`,
|
|
18
36
|
task: async (ctx, task) => {
|
|
19
|
-
const platformCompileOptions =
|
|
37
|
+
const platformCompileOptions = compileOptionsForPhp[process.platform];
|
|
20
38
|
|
|
21
39
|
if (!await pathExists(path.join(phpbrewConfig.phpPath, `${phpbrewPHPName}`, 'bin'))) {
|
|
40
|
+
const commandEnv = Object.entries(platformCompileOptions.env || {}).map(([key, value]) => `${key}="${value}"`).join(' ');
|
|
41
|
+
|
|
42
|
+
// eslint-disable-next-line max-len
|
|
43
|
+
const compileCommand = `${commandEnv ? `${commandEnv} && ` : ''}phpbrew install -j ${platformCompileOptions.cpuCount} ${latestStablePHP74} as ${phpbrewPHPName} ${platformCompileOptions.variants.join(' ')}`;
|
|
44
|
+
|
|
22
45
|
try {
|
|
23
46
|
await execAsyncSpawn(
|
|
24
|
-
|
|
25
|
-
`phpbrew install -j ${platformCompileOptions.cpuCount} ${latestStablePHP74} as ${phpbrewPHPName}`,
|
|
47
|
+
compileCommand,
|
|
26
48
|
{
|
|
27
49
|
callback: (t) => {
|
|
28
50
|
task.output = t;
|
|
@@ -77,16 +99,11 @@ const checkPHPVersion = () => ({
|
|
|
77
99
|
task: async (ctx, task) => {
|
|
78
100
|
const phpVersionResponse = await execAsyncSpawn('php --version');
|
|
79
101
|
|
|
80
|
-
const phpVersionResponseResult = phpVersionResponse.match(
|
|
102
|
+
const phpVersionResponseResult = phpVersionResponse.match(/PHP\s(\d\.\d\.\d)/i);
|
|
81
103
|
|
|
82
|
-
if (phpVersionResponseResult.length > 0) {
|
|
104
|
+
if (phpVersionResponseResult && phpVersionResponseResult.length > 0) {
|
|
83
105
|
const phpVersion = phpVersionResponseResult[1];
|
|
84
106
|
|
|
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
107
|
if (semver.satisfies(phpVersion, '>=8.1.x')) {
|
|
91
108
|
const userConfirmation = await task.prompt({
|
|
92
109
|
type: 'Confirm',
|
package/lib/util/database.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Update table in **magento** database
|
|
3
3
|
* @param {String} table Table name
|
|
4
4
|
* @param {{path: string, value: string}[]} values
|
|
5
|
-
* @param {
|
|
5
|
+
* @param {import('../../typings/context').ListrContext} param1
|
|
6
6
|
*/
|
|
7
7
|
const updateTableValues = async (table, values, { mysqlConnection, task }) => {
|
|
8
8
|
const [rows] = await mysqlConnection.query(`
|
|
@@ -58,6 +58,25 @@ const updateTableValues = async (table, values, { mysqlConnection, task }) => {
|
|
|
58
58
|
}
|
|
59
59
|
};
|
|
60
60
|
|
|
61
|
+
/**
|
|
62
|
+
* @param {String} database
|
|
63
|
+
* @param {String} tableName
|
|
64
|
+
* @param {import('../../typings/context').ListrContext} param2
|
|
65
|
+
*/
|
|
66
|
+
const isTableExists = async (database, tableName, { mysqlConnection }) => {
|
|
67
|
+
/**
|
|
68
|
+
* @type {{ tableCount: number }[][]}
|
|
69
|
+
*/
|
|
70
|
+
const [[{ tableCount }]] = await mysqlConnection.query(`
|
|
71
|
+
SELECT count(*) as tableCount
|
|
72
|
+
FROM information_schema.TABLES
|
|
73
|
+
WHERE (TABLE_SCHEMA = ?) AND (TABLE_NAME = ?);
|
|
74
|
+
`, [database, tableName]);
|
|
75
|
+
|
|
76
|
+
return tableCount > 0;
|
|
77
|
+
};
|
|
78
|
+
|
|
61
79
|
module.exports = {
|
|
62
|
-
updateTableValues
|
|
80
|
+
updateTableValues,
|
|
81
|
+
isTableExists
|
|
63
82
|
};
|
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.2",
|
|
7
7
|
"main": "./index.js",
|
|
8
8
|
"types": "./typings/index.d.ts",
|
|
9
9
|
"license": "OSL-3.0",
|
|
@@ -42,5 +42,5 @@
|
|
|
42
42
|
"publishConfig": {
|
|
43
43
|
"access": "public"
|
|
44
44
|
},
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "358a4bdd57aa7b87431915e27a9f063f93f7c644"
|
|
46
46
|
}
|
package/typings/context.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import mysql2 from 'mysql2';
|
|
2
|
+
|
|
1
3
|
import { CMAConfiguration, PHPExtensions } from './index';
|
|
2
4
|
|
|
3
5
|
export interface ListrContext {
|
|
@@ -85,4 +87,5 @@ export interface ListrContext {
|
|
|
85
87
|
analytics: boolean
|
|
86
88
|
useNonOverlappingPorts: boolean
|
|
87
89
|
}
|
|
90
|
+
mysqlConnection: mysql2.Connection
|
|
88
91
|
}
|