@scandipwa/magento-scripts 1.13.1 → 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/mysql/connect-to-mysql.js +1 -1
- package/lib/tasks/mysql/dump-theme-config.js +15 -19
- package/lib/tasks/requirements/php-version.js +2 -2
- 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(`
|
|
@@ -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 = {
|
|
@@ -99,9 +99,9 @@ const checkPHPVersion = () => ({
|
|
|
99
99
|
task: async (ctx, task) => {
|
|
100
100
|
const phpVersionResponse = await execAsyncSpawn('php --version');
|
|
101
101
|
|
|
102
|
-
const phpVersionResponseResult = phpVersionResponse.match(
|
|
102
|
+
const phpVersionResponseResult = phpVersionResponse.match(/PHP\s(\d\.\d\.\d)/i);
|
|
103
103
|
|
|
104
|
-
if (phpVersionResponseResult.length > 0) {
|
|
104
|
+
if (phpVersionResponseResult && phpVersionResponseResult.length > 0) {
|
|
105
105
|
const phpVersion = phpVersionResponseResult[1];
|
|
106
106
|
|
|
107
107
|
if (semver.satisfies(phpVersion, '>=8.1.x')) {
|
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
|
}
|