@scandipwa/magento-scripts 1.16.0-alpha.4 → 1.17.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/config/dependencies-for-platforms.js +1 -1
- package/lib/config/php/releases/php-7.2.js +0 -1
- package/lib/config/php/releases/php-7.3.js +0 -1
- package/lib/config/php/releases/php-7.4.js +0 -1
- package/lib/config/php/releases/php-8.1.js +0 -1
- package/lib/config/versions/magento-2.3.2-p1.js +38 -0
- package/lib/config/versions/magento-2.3.4-p1.js +38 -0
- package/lib/config/versions/magento-2.3.7-p4.js +38 -0
- package/lib/config/versions/magento-2.4.3-p3.js +46 -0
- package/lib/config/versions/magento-2.4.4-p1.js +39 -0
- package/lib/config/versions/magento-2.4.5.js +39 -0
- package/lib/tasks/cache/create-cache-folder.js +3 -1
- package/lib/tasks/composer/install-prestissimo.js +15 -0
- package/lib/tasks/magento/enable-magento-composer-plugins.js +85 -30
- package/lib/tasks/magento/install-magento-project.js +8 -1
- package/lib/tasks/magento/setup-magento/index.js +1 -3
- package/lib/tasks/magento/setup-magento/install-magento.js +47 -2
- package/lib/tasks/magento/setup-magento/migrate-database.js +5 -3
- package/lib/tasks/magento/setup-magento/varnish-config.js +1 -1
- package/lib/tasks/mysql/connect-to-mysql.js +12 -0
- package/lib/tasks/mysql/import-dump-to-mysql.js +115 -22
- package/lib/tasks/requirements/index.js +2 -2
- package/lib/tasks/start.js +4 -2
- package/package.json +2 -2
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
const { defaultMagentoConfig } = require('../magento-config');
|
|
3
|
+
const { php72 } = require('../php/releases');
|
|
4
|
+
const { sslTerminator } = require('../ssl-terminator');
|
|
5
|
+
const { varnish66 } = require('../varnish/varnish-6-6');
|
|
6
|
+
|
|
7
|
+
module.exports = ({ templateDir } = {}) => ({
|
|
8
|
+
magentoVersion: '2.3.2-p1',
|
|
9
|
+
configuration: {
|
|
10
|
+
php: php72({ templateDir }),
|
|
11
|
+
nginx: {
|
|
12
|
+
version: '1.18.0',
|
|
13
|
+
configTemplate: path.join(templateDir || '', 'nginx.template.conf')
|
|
14
|
+
},
|
|
15
|
+
redis: {
|
|
16
|
+
version: '5'
|
|
17
|
+
},
|
|
18
|
+
mysql: {
|
|
19
|
+
version: '5.7'
|
|
20
|
+
},
|
|
21
|
+
mariadb: {
|
|
22
|
+
version: '10.2'
|
|
23
|
+
},
|
|
24
|
+
elasticsearch: {
|
|
25
|
+
version: '6.8.16'
|
|
26
|
+
},
|
|
27
|
+
composer: {
|
|
28
|
+
version: '1'
|
|
29
|
+
},
|
|
30
|
+
varnish: varnish66({ templateDir }),
|
|
31
|
+
sslTerminator: sslTerminator({ templateDir })
|
|
32
|
+
},
|
|
33
|
+
magento: defaultMagentoConfig,
|
|
34
|
+
host: 'localhost',
|
|
35
|
+
ssl: {
|
|
36
|
+
enabled: false
|
|
37
|
+
}
|
|
38
|
+
});
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
const { defaultMagentoConfig } = require('../magento-config');
|
|
3
|
+
const { php73 } = require('../php/releases');
|
|
4
|
+
const { sslTerminator } = require('../ssl-terminator');
|
|
5
|
+
const { varnish66 } = require('../varnish/varnish-6-6');
|
|
6
|
+
|
|
7
|
+
module.exports = ({ templateDir } = {}) => ({
|
|
8
|
+
magentoVersion: '2.3.4-p1',
|
|
9
|
+
configuration: {
|
|
10
|
+
php: php73({ templateDir }),
|
|
11
|
+
nginx: {
|
|
12
|
+
version: '1.18.0',
|
|
13
|
+
configTemplate: path.join(templateDir || '', 'nginx.template.conf')
|
|
14
|
+
},
|
|
15
|
+
redis: {
|
|
16
|
+
version: '5'
|
|
17
|
+
},
|
|
18
|
+
mysql: {
|
|
19
|
+
version: '5.7'
|
|
20
|
+
},
|
|
21
|
+
mariadb: {
|
|
22
|
+
version: '10.2'
|
|
23
|
+
},
|
|
24
|
+
elasticsearch: {
|
|
25
|
+
version: '6.8.16'
|
|
26
|
+
},
|
|
27
|
+
composer: {
|
|
28
|
+
version: '1'
|
|
29
|
+
},
|
|
30
|
+
varnish: varnish66({ templateDir }),
|
|
31
|
+
sslTerminator: sslTerminator({ templateDir })
|
|
32
|
+
},
|
|
33
|
+
magento: defaultMagentoConfig,
|
|
34
|
+
host: 'localhost',
|
|
35
|
+
ssl: {
|
|
36
|
+
enabled: false
|
|
37
|
+
}
|
|
38
|
+
});
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
const { defaultMagentoConfig } = require('../magento-config');
|
|
3
|
+
const { php74 } = require('../php/releases');
|
|
4
|
+
const { sslTerminator } = require('../ssl-terminator');
|
|
5
|
+
const { varnish66 } = require('../varnish/varnish-6-6');
|
|
6
|
+
|
|
7
|
+
module.exports = ({ templateDir } = {}) => ({
|
|
8
|
+
magentoVersion: '2.3.7-p4',
|
|
9
|
+
configuration: {
|
|
10
|
+
php: php74({ templateDir }),
|
|
11
|
+
nginx: {
|
|
12
|
+
version: '1.18.0',
|
|
13
|
+
configTemplate: path.join(templateDir || '', 'nginx.template.conf')
|
|
14
|
+
},
|
|
15
|
+
redis: {
|
|
16
|
+
version: '6'
|
|
17
|
+
},
|
|
18
|
+
mysql: {
|
|
19
|
+
version: '5.7'
|
|
20
|
+
},
|
|
21
|
+
mariadb: {
|
|
22
|
+
version: '10.2'
|
|
23
|
+
},
|
|
24
|
+
elasticsearch: {
|
|
25
|
+
version: '7.9.3'
|
|
26
|
+
},
|
|
27
|
+
composer: {
|
|
28
|
+
version: '2'
|
|
29
|
+
},
|
|
30
|
+
varnish: varnish66({ templateDir }),
|
|
31
|
+
sslTerminator: sslTerminator({ templateDir })
|
|
32
|
+
},
|
|
33
|
+
magento: defaultMagentoConfig,
|
|
34
|
+
host: 'localhost',
|
|
35
|
+
ssl: {
|
|
36
|
+
enabled: false
|
|
37
|
+
}
|
|
38
|
+
});
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
const { defaultMagentoConfig } = require('../magento-config');
|
|
3
|
+
const { libsodium } = require('../php/extensions');
|
|
4
|
+
const { php74 } = require('../php/releases');
|
|
5
|
+
const { sslTerminator } = require('../ssl-terminator');
|
|
6
|
+
const { varnish66 } = require('../varnish/varnish-6-6');
|
|
7
|
+
|
|
8
|
+
module.exports = ({ templateDir } = {}) => ({
|
|
9
|
+
magentoVersion: '2.4.3-p3',
|
|
10
|
+
isDefault: true,
|
|
11
|
+
configuration: {
|
|
12
|
+
php: php74({
|
|
13
|
+
templateDir,
|
|
14
|
+
additionalExtensions: {
|
|
15
|
+
libsodium,
|
|
16
|
+
fileinfo: {}
|
|
17
|
+
}
|
|
18
|
+
}),
|
|
19
|
+
nginx: {
|
|
20
|
+
version: '1.18.0',
|
|
21
|
+
configTemplate: path.join(templateDir || '', 'nginx.template.conf')
|
|
22
|
+
},
|
|
23
|
+
redis: {
|
|
24
|
+
version: '6.0'
|
|
25
|
+
},
|
|
26
|
+
mysql: {
|
|
27
|
+
version: '8.0'
|
|
28
|
+
},
|
|
29
|
+
mariadb: {
|
|
30
|
+
version: '10.4'
|
|
31
|
+
},
|
|
32
|
+
elasticsearch: {
|
|
33
|
+
version: '7.12.1'
|
|
34
|
+
},
|
|
35
|
+
composer: {
|
|
36
|
+
version: '2'
|
|
37
|
+
},
|
|
38
|
+
varnish: varnish66({ templateDir }),
|
|
39
|
+
sslTerminator: sslTerminator({ templateDir })
|
|
40
|
+
},
|
|
41
|
+
magento: defaultMagentoConfig,
|
|
42
|
+
host: 'localhost',
|
|
43
|
+
ssl: {
|
|
44
|
+
enabled: false
|
|
45
|
+
}
|
|
46
|
+
});
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
const { defaultMagentoConfig } = require('../magento-config');
|
|
3
|
+
const { php81 } = require('../php/releases');
|
|
4
|
+
const { sslTerminator } = require('../ssl-terminator');
|
|
5
|
+
const { varnish70 } = require('../varnish/varnish-7-0');
|
|
6
|
+
|
|
7
|
+
module.exports = ({ templateDir } = {}) => ({
|
|
8
|
+
magentoVersion: '2.4.4-p1',
|
|
9
|
+
isDefault: true,
|
|
10
|
+
configuration: {
|
|
11
|
+
php: php81({ templateDir }),
|
|
12
|
+
nginx: {
|
|
13
|
+
version: '1.18.0',
|
|
14
|
+
configTemplate: path.join(templateDir || '', 'nginx.template.conf')
|
|
15
|
+
},
|
|
16
|
+
redis: {
|
|
17
|
+
version: '6.0'
|
|
18
|
+
},
|
|
19
|
+
mysql: {
|
|
20
|
+
version: '8.0'
|
|
21
|
+
},
|
|
22
|
+
mariadb: {
|
|
23
|
+
version: '10.4'
|
|
24
|
+
},
|
|
25
|
+
elasticsearch: {
|
|
26
|
+
version: '7.16.3'
|
|
27
|
+
},
|
|
28
|
+
composer: {
|
|
29
|
+
version: '2'
|
|
30
|
+
},
|
|
31
|
+
varnish: varnish70({ templateDir }),
|
|
32
|
+
sslTerminator: sslTerminator({ templateDir })
|
|
33
|
+
},
|
|
34
|
+
magento: defaultMagentoConfig,
|
|
35
|
+
host: 'localhost',
|
|
36
|
+
ssl: {
|
|
37
|
+
enabled: false
|
|
38
|
+
}
|
|
39
|
+
});
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
const { defaultMagentoConfig } = require('../magento-config');
|
|
3
|
+
const { php81 } = require('../php/releases');
|
|
4
|
+
const { sslTerminator } = require('../ssl-terminator');
|
|
5
|
+
const { varnish70 } = require('../varnish/varnish-7-0');
|
|
6
|
+
|
|
7
|
+
module.exports = ({ templateDir } = {}) => ({
|
|
8
|
+
magentoVersion: '2.4.5',
|
|
9
|
+
isDefault: true,
|
|
10
|
+
configuration: {
|
|
11
|
+
php: php81({ templateDir }),
|
|
12
|
+
nginx: {
|
|
13
|
+
version: '1.18.0',
|
|
14
|
+
configTemplate: path.join(templateDir || '', 'nginx.template.conf')
|
|
15
|
+
},
|
|
16
|
+
redis: {
|
|
17
|
+
version: '6.0'
|
|
18
|
+
},
|
|
19
|
+
mysql: {
|
|
20
|
+
version: '8.0'
|
|
21
|
+
},
|
|
22
|
+
mariadb: {
|
|
23
|
+
version: '10.4'
|
|
24
|
+
},
|
|
25
|
+
elasticsearch: {
|
|
26
|
+
version: '7.16.3'
|
|
27
|
+
},
|
|
28
|
+
composer: {
|
|
29
|
+
version: '2'
|
|
30
|
+
},
|
|
31
|
+
varnish: varnish70({ templateDir }),
|
|
32
|
+
sslTerminator: sslTerminator({ templateDir })
|
|
33
|
+
},
|
|
34
|
+
magento: defaultMagentoConfig,
|
|
35
|
+
host: 'localhost',
|
|
36
|
+
ssl: {
|
|
37
|
+
enabled: false
|
|
38
|
+
}
|
|
39
|
+
});
|
|
@@ -46,6 +46,10 @@ Would you like to disable it in your project?`,
|
|
|
46
46
|
name: 'disable',
|
|
47
47
|
message: 'Disable it, thanks'
|
|
48
48
|
},
|
|
49
|
+
{
|
|
50
|
+
name: 'remove',
|
|
51
|
+
message: `Remove ${prestissimoPluginName} from your system`
|
|
52
|
+
},
|
|
49
53
|
{
|
|
50
54
|
name: 'skip',
|
|
51
55
|
message: 'Skip this step'
|
|
@@ -56,6 +60,17 @@ Would you like to disable it in your project?`,
|
|
|
56
60
|
if (disableConfirmation === 'disable') {
|
|
57
61
|
localComposerJsonData.config['allow-plugins'][prestissimoPluginName] = false;
|
|
58
62
|
await fs.promises.writeFile(localComposerJsonPath, JSON.stringify(localComposerJsonData, null, 4), 'utf-8');
|
|
63
|
+
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (disableConfirmation === 'remove') {
|
|
68
|
+
await runComposerCommand(`global remove ${prestissimoPluginName}`, {
|
|
69
|
+
throwNonZeroCode: false,
|
|
70
|
+
magentoVersion
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
return;
|
|
59
74
|
}
|
|
60
75
|
}
|
|
61
76
|
}
|
|
@@ -4,7 +4,6 @@ const logger = require('@scandipwa/scandipwa-dev-utils/logger');
|
|
|
4
4
|
const semver = require('semver');
|
|
5
5
|
const pathExists = require('../../util/path-exists');
|
|
6
6
|
const getJsonfileData = require('../../util/get-jsonfile-data');
|
|
7
|
-
const KnownError = require('../../errors/known-error');
|
|
8
7
|
|
|
9
8
|
const vendorPath = path.join(process.cwd(), 'vendor');
|
|
10
9
|
const composerJsonPath = path.join(process.cwd(), 'composer.json');
|
|
@@ -86,29 +85,80 @@ const enableMagentoComposerPlugins = () => ({
|
|
|
86
85
|
} = composerJsonData;
|
|
87
86
|
const allowPluginsKeys = Object.keys(allowPlugins);
|
|
88
87
|
|
|
88
|
+
const missingPluginsFromAllowPlugins = composerPlugins.filter((plugin) => {
|
|
89
|
+
const [pluginVendor, pluginName] = plugin.split('/');
|
|
90
|
+
return !allowPluginsKeys.some((allowedPlugin) => {
|
|
91
|
+
const [allowedPluginVendor, allowedPluginName] = allowedPlugin.split('/');
|
|
92
|
+
if (allowedPluginVendor === pluginVendor) {
|
|
93
|
+
if (allowedPluginName === '*') {
|
|
94
|
+
return true;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return allowedPluginName === pluginName;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return false;
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
|
|
89
104
|
if (
|
|
90
105
|
allowPluginsKeys.length === 0
|
|
91
|
-
||
|
|
106
|
+
|| missingPluginsFromAllowPlugins.length > 0
|
|
92
107
|
) {
|
|
93
|
-
const
|
|
108
|
+
const missingVendors = missingPluginsFromAllowPlugins.reduce((acc, val) => {
|
|
109
|
+
const [pluginVendor] = val.split('/');
|
|
110
|
+
|
|
111
|
+
if (acc.length === 0) {
|
|
112
|
+
return [pluginVendor];
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
if (!acc.includes(pluginVendor)) {
|
|
116
|
+
return [...acc, pluginVendor];
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
return acc;
|
|
120
|
+
}, []);
|
|
121
|
+
|
|
122
|
+
const pluginOptions = [
|
|
123
|
+
{
|
|
124
|
+
name: 'all-individual',
|
|
125
|
+
message: 'Enable all individually'
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
name: 'manual',
|
|
129
|
+
message: 'Configure manually'
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
name: 'skip',
|
|
133
|
+
message: 'Skip this step'
|
|
134
|
+
}
|
|
135
|
+
];
|
|
136
|
+
|
|
137
|
+
if (missingVendors.length === 1) {
|
|
138
|
+
pluginOptions.unshift({
|
|
139
|
+
name: 'all',
|
|
140
|
+
message: `Enable all (${logger.style.code(`"${missingVendors[0]}/*"`)})`
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
|
|
94
144
|
const answerForEnablingPlugins = await task.prompt({
|
|
95
145
|
type: 'Select',
|
|
96
146
|
message: `Composer 2.2 requires manually allowing composer-plugins to run.
|
|
97
147
|
Magento requires the following plugins to correctly operate:
|
|
98
148
|
|
|
99
|
-
${
|
|
149
|
+
${missingPluginsFromAllowPlugins.map((p) => logger.style.code(p)).join('\n')}
|
|
100
150
|
|
|
101
151
|
Do you want to enable them all or disable some of them?`,
|
|
102
|
-
choices:
|
|
152
|
+
choices: pluginOptions
|
|
103
153
|
});
|
|
104
154
|
|
|
105
155
|
switch (answerForEnablingPlugins.toLowerCase()) {
|
|
106
|
-
case '
|
|
156
|
+
case 'all': {
|
|
107
157
|
composerJsonData.config = {
|
|
108
158
|
...(composerJsonData.config || {}),
|
|
109
159
|
'allow-plugins': {
|
|
110
160
|
...allowPlugins,
|
|
111
|
-
|
|
161
|
+
[`${missingVendors[0]}/*`]: true
|
|
112
162
|
}
|
|
113
163
|
};
|
|
114
164
|
|
|
@@ -117,36 +167,41 @@ Do you want to enable them all or disable some of them?`,
|
|
|
117
167
|
});
|
|
118
168
|
break;
|
|
119
169
|
}
|
|
120
|
-
case '
|
|
170
|
+
case 'all-individual': {
|
|
171
|
+
composerJsonData.config = {
|
|
172
|
+
...(composerJsonData.config || {}),
|
|
173
|
+
'allow-plugins': {
|
|
174
|
+
...allowPlugins,
|
|
175
|
+
...missingPluginsFromAllowPlugins.reduce((acc, val) => ({ ...acc, [val]: true }), {})
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
await fs.promises.writeFile(composerJsonPath, JSON.stringify(composerJsonData, null, 4), {
|
|
180
|
+
encoding: 'utf-8'
|
|
181
|
+
});
|
|
182
|
+
break;
|
|
183
|
+
}
|
|
184
|
+
case 'manual': {
|
|
121
185
|
const userEnabledPlugins = await task.prompt({
|
|
122
186
|
type: 'MultiSelect',
|
|
123
187
|
message: 'Please pick plugins you want to enable!',
|
|
124
|
-
choices:
|
|
188
|
+
choices: missingPluginsFromAllowPlugins.map((p) => ({ name: p }))
|
|
125
189
|
});
|
|
126
190
|
|
|
127
|
-
const
|
|
128
|
-
type: 'Confirm',
|
|
129
|
-
message: `Please confirm enabling of the following plugins:\n\n${userEnabledPlugins.map((p) => logger.style.code(p)).join('\n')}\n`
|
|
130
|
-
});
|
|
191
|
+
const disabledPlugins = composerPlugins.filter((p) => !userEnabledPlugins.includes(p));
|
|
131
192
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
...(
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
...userEnabledPlugins.reduce((acc, val) => ({ ...acc, [val]: true }), {})
|
|
141
|
-
}
|
|
142
|
-
};
|
|
193
|
+
composerJsonData.config = {
|
|
194
|
+
...(composerJsonData.config || {}),
|
|
195
|
+
'allow-plugins': {
|
|
196
|
+
...allowPlugins,
|
|
197
|
+
...disabledPlugins.reduce((acc, val) => ({ ...acc, [val]: false }), {}),
|
|
198
|
+
...userEnabledPlugins.reduce((acc, val) => ({ ...acc, [val]: true }), {})
|
|
199
|
+
}
|
|
200
|
+
};
|
|
143
201
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
} else {
|
|
148
|
-
throw new KnownError('Please confirm your choice or choose other option.');
|
|
149
|
-
}
|
|
202
|
+
await fs.promises.writeFile(composerJsonPath, JSON.stringify(composerJsonData, null, 4), {
|
|
203
|
+
encoding: 'utf-8'
|
|
204
|
+
});
|
|
150
205
|
|
|
151
206
|
break;
|
|
152
207
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
|
+
const fs = require('fs');
|
|
2
3
|
const os = require('os');
|
|
3
4
|
const runComposerCommand = require('../../util/run-composer');
|
|
4
5
|
const matchFilesystem = require('../../util/match-filesystem');
|
|
@@ -128,7 +129,7 @@ const createMagentoProject = async ({
|
|
|
128
129
|
* @returns {import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
|
|
129
130
|
*/
|
|
130
131
|
const installMagentoProject = () => ({
|
|
131
|
-
title: 'Installing Magento',
|
|
132
|
+
title: 'Installing Magento Project',
|
|
132
133
|
task: async (ctx, task) => {
|
|
133
134
|
const { magentoVersion, config: { baseConfig, overridenConfiguration }, verbose } = ctx;
|
|
134
135
|
const {
|
|
@@ -180,6 +181,12 @@ const installMagentoProject = () => ({
|
|
|
180
181
|
verbose
|
|
181
182
|
});
|
|
182
183
|
}
|
|
184
|
+
|
|
185
|
+
if (!await pathExists(path.join(process.cwd(), 'app', 'etc'))) {
|
|
186
|
+
await fs.promises.mkdir(path.join(process.cwd(), 'app', 'etc'), {
|
|
187
|
+
recursive: true
|
|
188
|
+
});
|
|
189
|
+
}
|
|
183
190
|
try {
|
|
184
191
|
await runComposerCommand('install',
|
|
185
192
|
{
|
|
@@ -10,7 +10,6 @@ const setUrlRewrite = require('./set-url-rewrite');
|
|
|
10
10
|
const increaseAdminSessionLifetime = require('./increase-admin-session-lifetime');
|
|
11
11
|
const magentoTask = require('../../../util/magento-task');
|
|
12
12
|
const urnHighlighter = require('./urn-highlighter');
|
|
13
|
-
const waitingForVarnish = require('./waiting-for-varnish');
|
|
14
13
|
const adjustFullPageCache = require('./adjust-full-page-cache');
|
|
15
14
|
|
|
16
15
|
/**
|
|
@@ -50,8 +49,7 @@ const setupMagento = (options = {}) => ({
|
|
|
50
49
|
disable2fa(),
|
|
51
50
|
urnHighlighter(),
|
|
52
51
|
adjustFullPageCache(),
|
|
53
|
-
magentoTask('cache:flush')
|
|
54
|
-
waitingForVarnish()
|
|
52
|
+
magentoTask('cache:flush')
|
|
55
53
|
], {
|
|
56
54
|
concurrent: false,
|
|
57
55
|
exitOnError: true,
|
|
@@ -12,7 +12,7 @@ const logger = require('@scandipwa/scandipwa-dev-utils/logger');
|
|
|
12
12
|
* @returns {import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
|
|
13
13
|
*/
|
|
14
14
|
const installMagento = ({ isDbEmpty = false } = {}) => ({
|
|
15
|
-
title: 'Installing
|
|
15
|
+
title: 'Installing Magento in Database',
|
|
16
16
|
task: async (ctx, task) => {
|
|
17
17
|
if (isDbEmpty) {
|
|
18
18
|
task.output = 'No Magento is installed in DB!\nInstalling...';
|
|
@@ -23,8 +23,53 @@ const installMagento = ({ isDbEmpty = false } = {}) => ({
|
|
|
23
23
|
docker,
|
|
24
24
|
magentoConfiguration
|
|
25
25
|
},
|
|
26
|
-
ports
|
|
26
|
+
ports,
|
|
27
|
+
mysqlConnection
|
|
27
28
|
} = ctx;
|
|
29
|
+
|
|
30
|
+
const [tableResponse] = await mysqlConnection.query(
|
|
31
|
+
'SELECT * FROM information_schema.tables WHERE table_schema = \'magento\' AND table_name = \'admin_user\' LIMIT 1;'
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
if (tableResponse.length > 0) {
|
|
35
|
+
const response = await mysqlConnection.query(
|
|
36
|
+
'select * from admin_user where username=\'admin\';'
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
const usersWithUsernameAdmin = response && response.length > 0 && response[0];
|
|
40
|
+
|
|
41
|
+
if (usersWithUsernameAdmin && usersWithUsernameAdmin.length > 0) {
|
|
42
|
+
const confirmDeleteAdminUsers = await task.prompt({
|
|
43
|
+
type: 'Select',
|
|
44
|
+
message: `In order to install Magento in database you will need to delete admin user with username ${logger.style.command('admin')}`,
|
|
45
|
+
choices: [
|
|
46
|
+
{
|
|
47
|
+
name: 'delete-all',
|
|
48
|
+
message: `Delete all admin users (${logger.style.code('Recommended')})`
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
name: 'delete-only-admin',
|
|
52
|
+
message: `Delete only admin user with ${logger.style.command('admin')} username`
|
|
53
|
+
}
|
|
54
|
+
]
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
await mysqlConnection.query('SET FOREIGN_KEY_CHECKS = 0;');
|
|
58
|
+
|
|
59
|
+
if (confirmDeleteAdminUsers === 'delete-all') {
|
|
60
|
+
await mysqlConnection.query(`
|
|
61
|
+
TRUNCATE TABLE admin_user;
|
|
62
|
+
`);
|
|
63
|
+
} else {
|
|
64
|
+
await mysqlConnection.query(`
|
|
65
|
+
DELETE FROM admin_user WHERE username='admin';
|
|
66
|
+
`);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
await mysqlConnection.query('SET FOREIGN_KEY_CHECKS = 1;');
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
28
73
|
const { mysql: { env } } = docker.getContainers(ports);
|
|
29
74
|
const envPhpData = await envPhpToJson(process.cwd(), {
|
|
30
75
|
magentoVersion: ctx.magentoVersion
|
|
@@ -82,13 +82,15 @@ const migrateDatabase = (options = {}) => ({
|
|
|
82
82
|
case 1: {
|
|
83
83
|
if (options.onlyInstallMagento) {
|
|
84
84
|
ctx.isSetupUpgradeNeeded = false;
|
|
85
|
-
return task.newListr(
|
|
86
|
-
installMagentoProject()
|
|
87
|
-
|
|
85
|
+
return task.newListr([
|
|
86
|
+
installMagentoProject(),
|
|
87
|
+
installMagento()
|
|
88
|
+
]);
|
|
88
89
|
}
|
|
89
90
|
|
|
90
91
|
return task.newListr([
|
|
91
92
|
installMagentoProject(),
|
|
93
|
+
installMagento(),
|
|
92
94
|
updateEnvPHP(),
|
|
93
95
|
varnishConfigSetup(),
|
|
94
96
|
configureElasticsearch(),
|
|
@@ -6,7 +6,7 @@ const getIsWsl = require('../../../util/is-wsl');
|
|
|
6
6
|
* @returns {import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
|
|
7
7
|
*/
|
|
8
8
|
const varnishConfigSetup = () => ({
|
|
9
|
-
title: 'Varnish setup',
|
|
9
|
+
title: 'Varnish Database setup',
|
|
10
10
|
task: async (ctx, task) => {
|
|
11
11
|
const {
|
|
12
12
|
config: {
|
|
@@ -78,6 +78,17 @@ const gettingMySQLConnection = () => ({
|
|
|
78
78
|
}
|
|
79
79
|
});
|
|
80
80
|
|
|
81
|
+
/**
|
|
82
|
+
* @returns {import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
|
|
83
|
+
*/
|
|
84
|
+
const terminatingExistingConnection = () => ({
|
|
85
|
+
title: 'Terminating existing MySQL connection',
|
|
86
|
+
skip: (ctx) => !ctx.mysqlConnection,
|
|
87
|
+
task: (ctx) => {
|
|
88
|
+
ctx.mysqlConnection.destroy();
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
|
|
81
92
|
/**
|
|
82
93
|
* @returns {import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
|
|
83
94
|
*/
|
|
@@ -87,6 +98,7 @@ const connectToMySQL = () => ({
|
|
|
87
98
|
task: (ctx, task) => task.newListr([
|
|
88
99
|
waitForMySQLInitialization(),
|
|
89
100
|
createMagentoDatabase(),
|
|
101
|
+
terminatingExistingConnection(),
|
|
90
102
|
gettingMySQLConnection()
|
|
91
103
|
], {
|
|
92
104
|
concurrent: false,
|
|
@@ -2,23 +2,100 @@
|
|
|
2
2
|
const logger = require('@scandipwa/scandipwa-dev-utils/logger');
|
|
3
3
|
const KnownError = require('../../errors/known-error');
|
|
4
4
|
const UnknownError = require('../../errors/unknown-error');
|
|
5
|
-
const { execAsyncSpawn } = require('../../util/exec-async-command');
|
|
5
|
+
const { execAsyncSpawn, execCommandTask } = require('../../util/exec-async-command');
|
|
6
6
|
const pathExists = require('../../util/path-exists');
|
|
7
|
+
const connectToMySQL = require('./connect-to-mysql');
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* @type {() => import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
|
|
10
11
|
*/
|
|
11
|
-
const
|
|
12
|
-
title: '
|
|
12
|
+
const copyDatabaseDumpIntoContainer = () => ({
|
|
13
|
+
title: 'Copying database dump into container',
|
|
13
14
|
task: async (ctx, task) => {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
15
|
+
const { config: { docker }, ports } = ctx;
|
|
16
|
+
const { mysql } = docker.getContainers(ports);
|
|
17
17
|
|
|
18
|
+
return task.newListr(
|
|
19
|
+
execCommandTask(`docker cp ${ctx.importDb} ${mysql.name}:/dump.sql`, {
|
|
20
|
+
logOutput: true
|
|
21
|
+
})
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* @type {() => import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
|
|
28
|
+
*/
|
|
29
|
+
const runSetGlobalLogBinTrustFunctionCreatorsCommand = () => ({
|
|
30
|
+
task: async (ctx, task) => {
|
|
18
31
|
const { config: { docker }, ports } = ctx;
|
|
32
|
+
const { mysql } = docker.getContainers(ports);
|
|
19
33
|
|
|
34
|
+
return task.newListr(
|
|
35
|
+
execCommandTask(`docker exec ${mysql.name} bash -c 'mysql -uroot -p${mysql.env.MYSQL_ROOT_PASSWORD} -e "SET GLOBAL log_bin_trust_function_creators = 1;"'`)
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* @type {() => import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
|
|
42
|
+
*/
|
|
43
|
+
const deleteDatabaseBeforeImportingDumpPrompt = () => ({
|
|
44
|
+
title: 'Deleting magento database before importing dump',
|
|
45
|
+
task: async (ctx, task) => {
|
|
46
|
+
const deleteDatabaseMagentoChoice = await task.prompt({
|
|
47
|
+
type: 'Select',
|
|
48
|
+
message: `Before importing database dump, would you like to delete existing database?
|
|
49
|
+
|
|
50
|
+
It is possible that dump might interfere with existing data in database.
|
|
51
|
+
|
|
52
|
+
Note that you will lose your existing database!`,
|
|
53
|
+
choices: [
|
|
54
|
+
{
|
|
55
|
+
name: 'delete',
|
|
56
|
+
message: 'YES I AM SURE I WANT TO DELETE magento DATABASE!'
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
name: 'skip',
|
|
60
|
+
message: 'Skip this step'
|
|
61
|
+
}
|
|
62
|
+
]
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
if (deleteDatabaseMagentoChoice === 'delete') {
|
|
66
|
+
await ctx.mysqlConnection.query('DROP DATABASE IF EXISTS magento;');
|
|
67
|
+
await ctx.mysqlConnection.query('CREATE DATABASE magento;');
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
task.skip();
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* @type {() => import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
|
|
76
|
+
*/
|
|
77
|
+
const executeImportDumpSQL = () => ({
|
|
78
|
+
task: async (ctx, task) => {
|
|
79
|
+
const { config: { docker }, ports } = ctx;
|
|
20
80
|
const { mysql } = docker.getContainers(ports);
|
|
21
81
|
|
|
82
|
+
const userCredentialsForMySQLCLI = await task.prompt({
|
|
83
|
+
type: 'Select',
|
|
84
|
+
message: 'Which user do you want to use to import db in MySQL client?',
|
|
85
|
+
choices: [
|
|
86
|
+
{
|
|
87
|
+
name: `--user=root --password=${mysql.env.MYSQL_ROOT_PASSWORD}`,
|
|
88
|
+
message: `root (${logger.style.command('Probably safest option')})`
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
name: `--user=${mysql.env.MYSQL_USER} --password=${mysql.env.MYSQL_PASSWORD}`,
|
|
92
|
+
message: `${mysql.env.MYSQL_USER}`
|
|
93
|
+
}
|
|
94
|
+
]
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
const importCommand = `docker exec ${mysql.name} bash -c "mysql ${userCredentialsForMySQLCLI} magento < ./dump.sql"`;
|
|
98
|
+
|
|
22
99
|
const startImportTime = Date.now();
|
|
23
100
|
const tickInterval = setInterval(() => {
|
|
24
101
|
task.title = `Importing Database Dump To MySQL, ${Math.floor((Date.now() - startImportTime) / 1000)}s in progress...`;
|
|
@@ -26,18 +103,7 @@ const importDumpToMySQL = () => ({
|
|
|
26
103
|
|
|
27
104
|
try {
|
|
28
105
|
await execAsyncSpawn(
|
|
29
|
-
|
|
30
|
-
);
|
|
31
|
-
|
|
32
|
-
await execAsyncSpawn(
|
|
33
|
-
`docker exec ${mysql.name} bash -c 'mysql -uroot -p${mysql.env.MYSQL_ROOT_PASSWORD} -e "SET GLOBAL log_bin_trust_function_creators = 1;"'`
|
|
34
|
-
);
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Using `mysql` instead of `mysqlimport` because `mysqlimport` has permission issues during import
|
|
38
|
-
*/
|
|
39
|
-
await execAsyncSpawn(
|
|
40
|
-
`docker exec ${mysql.name} bash -c "mysql -umagento -pmagento magento < ./dump.sql"`,
|
|
106
|
+
importCommand,
|
|
41
107
|
{
|
|
42
108
|
callback: (t) => {
|
|
43
109
|
task.output = t;
|
|
@@ -54,15 +120,42 @@ You can try replacing all occurrences of ${logger.style.misc('utf8mb4_0900_ai_ci
|
|
|
54
120
|
}
|
|
55
121
|
|
|
56
122
|
throw new UnknownError(`Unexpected error during dump import.\n\n${e}`);
|
|
123
|
+
} finally {
|
|
124
|
+
clearInterval(tickInterval);
|
|
57
125
|
}
|
|
58
|
-
|
|
59
|
-
clearInterval(tickInterval);
|
|
60
|
-
|
|
61
|
-
task.title = 'Database imported!';
|
|
62
126
|
},
|
|
63
127
|
options: {
|
|
64
128
|
bottomBar: 10
|
|
65
129
|
}
|
|
66
130
|
});
|
|
67
131
|
|
|
132
|
+
/**
|
|
133
|
+
* @type {() => import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
|
|
134
|
+
*/
|
|
135
|
+
const importDumpToMySQL = () => ({
|
|
136
|
+
title: 'Importing Database Dump To MySQL',
|
|
137
|
+
task: async (ctx, task) => {
|
|
138
|
+
if (!await pathExists(ctx.importDb)) {
|
|
139
|
+
throw new KnownError(`Dump file at ${ctx.importDb} does not exist. Please provide correct relative path to the file`);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
return task.newListr([
|
|
143
|
+
copyDatabaseDumpIntoContainer(),
|
|
144
|
+
deleteDatabaseBeforeImportingDumpPrompt(),
|
|
145
|
+
runSetGlobalLogBinTrustFunctionCreatorsCommand(),
|
|
146
|
+
executeImportDumpSQL(),
|
|
147
|
+
connectToMySQL(),
|
|
148
|
+
{
|
|
149
|
+
task: () => {
|
|
150
|
+
task.title = 'Database imported!';
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
], {
|
|
154
|
+
rendererOptions: {
|
|
155
|
+
collapse: false
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
|
|
68
161
|
module.exports = importDumpToMySQL;
|
|
@@ -12,10 +12,10 @@ const checkRosetta = require('./rosetta');
|
|
|
12
12
|
const checkRequirements = () => ({
|
|
13
13
|
title: 'Checking requirements',
|
|
14
14
|
task: (ctx, task) => task.newListr([
|
|
15
|
-
// checking if user is on supported platform
|
|
16
|
-
checkPlatform(),
|
|
17
15
|
// check if rosetta 2 is installed or not on m1 macs
|
|
18
16
|
checkRosetta(),
|
|
17
|
+
// checking if user is on supported platform
|
|
18
|
+
checkPlatform(),
|
|
19
19
|
// check the Docker installation
|
|
20
20
|
checkDocker(),
|
|
21
21
|
// check for Node.js version
|
package/lib/tasks/start.js
CHANGED
|
@@ -32,6 +32,7 @@ const checkForXDGOpen = require('../util/xdg-open-exists');
|
|
|
32
32
|
const { getInstanceMetadata, constants: { WEB_LOCATION_TITLE } } = require('../util/instance-metadata');
|
|
33
33
|
const validatePHPInstallation = require('./php/validate-php');
|
|
34
34
|
const installSodiumExtension = require('./php/install-sodium');
|
|
35
|
+
const waitingForVarnish = require('./magento/setup-magento/waiting-for-varnish');
|
|
35
36
|
|
|
36
37
|
/**
|
|
37
38
|
* @type {() => import('listr2').ListrTask<import('../../typings/context').ListrContext>}
|
|
@@ -120,8 +121,8 @@ const configureProject = () => ({
|
|
|
120
121
|
installPrestissimo(),
|
|
121
122
|
installMagentoProject(),
|
|
122
123
|
enableMagentoComposerPlugins(),
|
|
123
|
-
startServices(),
|
|
124
124
|
startPhpFpm(),
|
|
125
|
+
startServices(),
|
|
125
126
|
connectToMySQL()
|
|
126
127
|
])
|
|
127
128
|
});
|
|
@@ -149,7 +150,8 @@ const finishProjectConfiguration = () => ({
|
|
|
149
150
|
});
|
|
150
151
|
}
|
|
151
152
|
},
|
|
152
|
-
setupThemes()
|
|
153
|
+
setupThemes(),
|
|
154
|
+
waitingForVarnish()
|
|
153
155
|
], {
|
|
154
156
|
rendererOptions: {
|
|
155
157
|
collapse: false
|
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.
|
|
6
|
+
"version": "1.17.0",
|
|
7
7
|
"main": "./index.js",
|
|
8
8
|
"types": "./typings/index.d.ts",
|
|
9
9
|
"license": "OSL-3.0",
|
|
@@ -53,5 +53,5 @@
|
|
|
53
53
|
"mysql",
|
|
54
54
|
"scandipwa"
|
|
55
55
|
],
|
|
56
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "0698c02d64c2570c0f546e6c99747232242e7123"
|
|
57
57
|
}
|