@scandipwa/magento-scripts 2.0.0-alpha.0 → 2.0.0-alpha.11
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/exec.js +71 -0
- package/index.js +1 -1
- package/lib/commands/cli.js +7 -2
- package/lib/commands/execute.js +3 -58
- package/lib/commands/import-db.js +1 -1
- package/lib/commands/logs.js +1 -1
- package/lib/commands/start.js +18 -8
- package/lib/commands/status.js +9 -1
- package/lib/config/config.js +20 -2
- package/lib/config/docker.js +79 -85
- package/lib/config/index.js +2 -2
- package/lib/config/php/versions/php-7.2.js +1 -0
- package/lib/config/php/versions/php-7.3.js +1 -0
- package/lib/config/php/versions/php-7.4.js +1 -0
- package/lib/config/php/versions/php-8.1.js +1 -0
- package/lib/config/php-config.js +4 -3
- package/lib/config/port-config.js +1 -1
- package/lib/config/services/composer/versions/composer-1.js +8 -0
- package/lib/config/services/composer/versions/composer-2.js +8 -0
- package/lib/config/services/composer/versions/index.js +4 -0
- package/lib/config/services/elasticsearch/base-repo.js +3 -0
- package/lib/config/services/elasticsearch/default-es-env.js +6 -0
- package/lib/config/services/elasticsearch/versions/elasticsearch-6.8.js +19 -0
- package/lib/config/services/elasticsearch/versions/index.js +5 -0
- package/lib/config/services/nginx/versions/index.js +3 -0
- package/lib/config/services/nginx/versions/nginx-1.18.js +11 -0
- package/lib/config/{ssl-terminator → services/ssl-terminator}/index.js +3 -0
- package/lib/config/templates/magentorc.template +6 -5
- package/lib/config/templates/mariadb.template.cnf +191 -0
- package/lib/config/templates/php-debug.template.ini +31 -0
- package/lib/config/templates/php-fpm.template.conf +1 -2
- package/lib/config/templates/php.template.ini +6 -202
- package/lib/config/templates/ssl-terminator.template.conf +10 -3
- package/lib/config/templates/varnish.template.vcl +20 -13
- package/lib/config/varnish/varnish-6-0.js +4 -0
- package/lib/config/varnish/varnish-6-6.js +4 -0
- package/lib/config/varnish/varnish-7-0.js +4 -0
- package/lib/config/versions/magento-2.3.0.js +7 -12
- package/lib/config/versions/magento-2.3.1.js +7 -12
- package/lib/config/versions/magento-2.3.2-p1.js +7 -12
- package/lib/config/versions/magento-2.3.2-p2.js +7 -12
- package/lib/config/versions/magento-2.3.2.js +7 -12
- package/lib/config/versions/magento-2.3.3-p1.js +7 -12
- package/lib/config/versions/magento-2.3.3.js +7 -12
- package/lib/config/versions/magento-2.3.4-p1.js +7 -12
- package/lib/config/versions/magento-2.3.4-p2.js +7 -12
- package/lib/config/versions/magento-2.3.4.js +7 -12
- package/lib/config/versions/magento-2.3.5-p1.js +5 -9
- package/lib/config/versions/magento-2.3.5-p2.js +5 -9
- package/lib/config/versions/magento-2.3.5.js +5 -9
- package/lib/config/versions/magento-2.3.6-p1.js +5 -9
- package/lib/config/versions/magento-2.3.6.js +5 -9
- package/lib/config/versions/magento-2.3.7-p1.js +5 -9
- package/lib/config/versions/magento-2.3.7-p2.js +5 -9
- package/lib/config/versions/magento-2.3.7-p3.js +5 -9
- package/lib/config/versions/magento-2.3.7-p4.js +40 -0
- package/lib/config/versions/magento-2.3.7.js +5 -9
- package/lib/config/versions/magento-2.4.0-p1.js +5 -9
- package/lib/config/versions/magento-2.4.0.js +5 -9
- package/lib/config/versions/magento-2.4.1-p1.js +5 -9
- package/lib/config/versions/magento-2.4.1.js +5 -9
- package/lib/config/versions/magento-2.4.2-p1.js +5 -9
- package/lib/config/versions/magento-2.4.2-p2.js +5 -9
- package/lib/config/versions/magento-2.4.2.js +5 -9
- package/lib/config/versions/magento-2.4.3-p1.js +5 -9
- package/lib/config/versions/magento-2.4.3-p2.js +5 -9
- package/lib/config/versions/magento-2.4.3-p3.js +42 -0
- package/lib/config/versions/magento-2.4.3.js +5 -9
- package/lib/config/versions/magento-2.4.4-p1.js +42 -0
- package/lib/config/versions/magento-2.4.4.js +5 -9
- package/lib/config/versions/magento-2.4.5.js +42 -0
- package/lib/tasks/cleanup.js +1 -1
- package/lib/tasks/composer/local-auth-json.js +1 -1
- package/lib/tasks/database/connect-to-database.js +120 -0
- package/lib/tasks/database/create-magento-database.js +21 -0
- package/lib/tasks/database/create-magento-user.js +50 -0
- package/lib/tasks/database/default-magento-database.js +3 -0
- package/lib/tasks/database/default-magento-user.js +7 -0
- package/lib/tasks/{mysql → database}/dump-theme-config.js +3 -3
- package/lib/tasks/{mysql → database}/fix-db.js +2 -2
- package/lib/tasks/{mysql/import-dump-to-mysql.js → database/import-dump-to-database.js} +21 -20
- package/lib/tasks/{mysql → database}/import-remote-db/index.js +0 -0
- package/lib/tasks/{mysql/import-remote-db/ssh/mysqldump-command.js → database/import-remote-db/ssh/database-dump-command.js} +2 -2
- package/lib/tasks/{mysql → database}/import-remote-db/ssh/index.js +0 -0
- package/lib/tasks/{mysql → database}/import-remote-db/ssh/readymage.js +4 -4
- package/lib/tasks/{mysql → database}/import-remote-db/ssh/regular-server.js +2 -2
- package/lib/tasks/{mysql → database}/index.js +2 -2
- package/lib/tasks/{mysql → database}/magento-tables.js +0 -0
- package/lib/tasks/{mysql → database}/restore-theme-config.js +4 -4
- package/lib/tasks/docker/api.d.ts +25 -1
- package/lib/tasks/docker/api.js +31 -1
- package/lib/tasks/docker/containers/container-api.d.ts +18 -0
- package/lib/tasks/docker/containers/container-api.js +76 -17
- package/lib/tasks/docker/containers/tasks.js +32 -1
- package/lib/tasks/docker/convert-legacy-volumes.js +8 -7
- package/lib/tasks/docker/convert-mysql-to-mariadb.js +284 -0
- package/lib/tasks/docker/index.js +6 -1
- package/lib/tasks/docker/network/network-api.d.ts +1 -1
- package/lib/tasks/docker/project-image-builder.js +7 -9
- package/lib/tasks/docker/volume/index.js +9 -0
- package/lib/tasks/docker/volume/tasks.js +94 -0
- package/lib/tasks/docker/volume/volume-api.d.ts +49 -0
- package/lib/tasks/docker/volume/volume-api.js +90 -0
- package/lib/tasks/execute.js +100 -0
- package/lib/tasks/file-system/create-mariadb-config.js +23 -0
- package/lib/tasks/file-system/create-nginx-config.js +3 -5
- package/lib/tasks/file-system/create-php-config.js +2 -23
- package/lib/tasks/file-system/create-php-debug-config.js +45 -0
- package/lib/tasks/file-system/create-php-fpm-config.js +2 -4
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/php-workspace-project-configuration-config.js +1 -1
- package/lib/tasks/file-system/create-ssl-terminator-config.js +4 -7
- package/lib/tasks/file-system/create-varnish-config.js +4 -7
- package/lib/tasks/file-system/index.js +5 -1
- package/lib/tasks/import-dump.js +6 -6
- package/lib/tasks/link.js +4 -2
- package/lib/tasks/magento/enable-magento-composer-plugins.js +85 -30
- package/lib/tasks/magento/install-magento-project.js +3 -2
- package/lib/tasks/magento/setup-magento/configure-elasticsearch.js +3 -5
- package/lib/tasks/magento/setup-magento/create-admin.js +1 -1
- package/lib/tasks/magento/setup-magento/delete-admin-users.js +2 -2
- package/lib/tasks/magento/setup-magento/delete-customers.js +4 -4
- package/lib/tasks/magento/setup-magento/delete-orders.js +4 -4
- package/lib/tasks/magento/setup-magento/flush-redis-config.js +3 -6
- package/lib/tasks/magento/setup-magento/increase-admin-session-lifetime.js +2 -2
- package/lib/tasks/magento/setup-magento/index.js +2 -0
- package/lib/tasks/magento/setup-magento/install-magento.js +15 -17
- package/lib/tasks/magento/setup-magento/migrate-database.js +5 -11
- package/lib/tasks/magento/setup-magento/set-base-url.js +3 -3
- package/lib/tasks/magento/setup-magento/set-url-rewrite.js +2 -2
- package/lib/tasks/magento/setup-magento/varnish-config.js +8 -13
- package/lib/tasks/magento/setup-magento/waiting-for-varnish.js +17 -16
- package/lib/tasks/php/php-container.js +7 -3
- package/lib/tasks/php/update-env-php.js +7 -6
- package/lib/tasks/php/update-env.php +12 -12
- package/lib/tasks/requirements/composer-credentials.js +7 -3
- package/lib/tasks/requirements/docker/context.js +88 -0
- package/lib/tasks/requirements/docker/index.js +110 -19
- package/lib/tasks/requirements/docker/install.js +21 -7
- package/lib/tasks/requirements/docker/permissions.js +2 -11
- package/lib/tasks/requirements/docker/running-status.js +94 -24
- package/lib/tasks/requirements/docker/version.js +1 -0
- package/lib/tasks/requirements/index.js +0 -2
- package/lib/tasks/requirements/php-version.js +4 -2
- package/lib/tasks/start.js +32 -31
- package/lib/tasks/status/index.js +17 -13
- package/lib/tasks/stop.js +2 -0
- package/lib/tasks/theme/link-theme.js +2 -2
- package/lib/util/config-file-validator.js +29 -13
- package/lib/util/database.js +7 -7
- package/lib/util/execute-in-container.js +63 -0
- package/lib/util/prefix.js +1 -1
- package/lib/util/systemctl.js +62 -13
- package/package.json +4 -3
- package/typings/context.d.ts +12 -5
- package/typings/index.d.ts +69 -31
- package/lib/tasks/docker/volumes.js +0 -63
- package/lib/tasks/execute/index.js +0 -23
- package/lib/tasks/mysql/connect-to-mysql.js +0 -127
- package/lib/tasks/mysql/create-magento-database.js +0 -18
- package/lib/tasks/requirements/dependency/arch.js +0 -50
- package/lib/tasks/requirements/dependency/centos.js +0 -36
- package/lib/tasks/requirements/dependency/fedora.js +0 -36
- package/lib/tasks/requirements/dependency/index.js +0 -33
- package/lib/tasks/requirements/dependency/mac.js +0 -124
- package/lib/tasks/requirements/dependency/ubuntu.js +0 -83
|
@@ -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
|
}
|
|
@@ -97,8 +97,9 @@ const createMagentoProject = async (ctx, task, {
|
|
|
97
97
|
`"${tempDir}"`
|
|
98
98
|
];
|
|
99
99
|
|
|
100
|
-
await runPHPContainerCommand(ctx, `
|
|
101
|
-
|
|
100
|
+
await runPHPContainerCommand(ctx, `bash -c 'mkdir ${tempDir} && \
|
|
101
|
+
composer ${installCommand.join(' ')} && \
|
|
102
|
+
mv ${tempDir}/composer.json ${ctx.config.baseConfig.containerMagentoDir}/composer.json'`);
|
|
102
103
|
};
|
|
103
104
|
|
|
104
105
|
/**
|
|
@@ -7,14 +7,12 @@ module.exports = () => ({
|
|
|
7
7
|
title: 'Configuring Elasticsearch',
|
|
8
8
|
skip: async (ctx) => !(await isTableExists('magento', 'core_config_data', ctx)),
|
|
9
9
|
task: async (ctx, task) => {
|
|
10
|
-
const { ports,
|
|
11
|
-
const
|
|
12
|
-
const isNativeLinux = isLinux && !ctx.isWsl;
|
|
13
|
-
const hostMachine = isNativeLinux ? '127.0.0.1' : 'host.docker.internal';
|
|
10
|
+
const { ports, databaseConnection, isDockerDesktop } = ctx;
|
|
11
|
+
const hostMachine = !isDockerDesktop ? '127.0.0.1' : 'host.docker.internal';
|
|
14
12
|
await updateTableValues('core_config_data', [
|
|
15
13
|
{ path: 'catalog/search/engine', value: 'elasticsearch7' },
|
|
16
14
|
{ path: 'catalog/search/elasticsearch7_server_hostname', value: hostMachine },
|
|
17
15
|
{ path: 'catalog/search/elasticsearch7_server_port', value: `${ports.elasticsearch}` }
|
|
18
|
-
], {
|
|
16
|
+
], { databaseConnection, task });
|
|
19
17
|
}
|
|
20
18
|
});
|
|
@@ -7,7 +7,7 @@ module.exports = () => ({
|
|
|
7
7
|
title: 'Creating admin user',
|
|
8
8
|
task: async (ctx, task) => {
|
|
9
9
|
const { config: { magentoConfiguration } } = ctx;
|
|
10
|
-
const [[{ userCount }]] = await ctx.
|
|
10
|
+
const [[{ userCount }]] = await ctx.databaseConnection.query(`
|
|
11
11
|
SELECT count(*) AS userCount
|
|
12
12
|
FROM admin_user
|
|
13
13
|
WHERE username = ?;
|
|
@@ -7,8 +7,8 @@ const deleteAdminUsers = () => ({
|
|
|
7
7
|
title: 'Deleting old admin users',
|
|
8
8
|
skip: async (ctx) => !(await isTableExists('magento', 'admin_user', ctx)),
|
|
9
9
|
task: async (ctx) => {
|
|
10
|
-
const {
|
|
11
|
-
await
|
|
10
|
+
const { databaseConnection } = ctx;
|
|
11
|
+
await databaseConnection.query(`
|
|
12
12
|
TRUNCATE TABLE admin_user;
|
|
13
13
|
`);
|
|
14
14
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const { customerTables } = require('../../
|
|
1
|
+
const { customerTables } = require('../../database/magento-tables');
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* @returns {import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
|
|
@@ -6,19 +6,19 @@ const { customerTables } = require('../../mysql/magento-tables');
|
|
|
6
6
|
const deleteCustomers = () => ({
|
|
7
7
|
title: 'Deleting customers',
|
|
8
8
|
task: async (ctx, task) => {
|
|
9
|
-
const {
|
|
9
|
+
const { databaseConnection, withCustomersData } = ctx;
|
|
10
10
|
|
|
11
11
|
if (withCustomersData) {
|
|
12
12
|
task.skip();
|
|
13
13
|
return;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
const [rows] = await
|
|
16
|
+
const [rows] = await databaseConnection.query('select TABLE_NAME from information_schema.TABLES;');
|
|
17
17
|
|
|
18
18
|
await Promise.all(
|
|
19
19
|
customerTables
|
|
20
20
|
.filter((tableName) => rows.some((row) => row.TABLE_NAME === tableName))
|
|
21
|
-
.map((tableName) =>
|
|
21
|
+
.map((tableName) => databaseConnection.query(`TRUNCATE TABLE \`${ tableName }\`;`))
|
|
22
22
|
);
|
|
23
23
|
}
|
|
24
24
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const { orderTables } = require('../../
|
|
1
|
+
const { orderTables } = require('../../database/magento-tables');
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* @returns {import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
|
|
@@ -6,19 +6,19 @@ const { orderTables } = require('../../mysql/magento-tables');
|
|
|
6
6
|
const deleteOrders = () => ({
|
|
7
7
|
title: 'Deleting orders',
|
|
8
8
|
task: async (ctx, task) => {
|
|
9
|
-
const {
|
|
9
|
+
const { databaseConnection, withCustomersData } = ctx;
|
|
10
10
|
|
|
11
11
|
if (withCustomersData) {
|
|
12
12
|
task.skip();
|
|
13
13
|
return;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
const [rows] = await
|
|
16
|
+
const [rows] = await databaseConnection.query('select TABLE_NAME from information_schema.TABLES;');
|
|
17
17
|
|
|
18
18
|
await Promise.all(
|
|
19
19
|
orderTables
|
|
20
20
|
.filter((tableName) => rows.some((row) => row.TABLE_NAME === tableName))
|
|
21
|
-
.map((tableName) =>
|
|
21
|
+
.map((tableName) => databaseConnection.query(`TRUNCATE TABLE \`${ tableName }\`;`))
|
|
22
22
|
);
|
|
23
23
|
}
|
|
24
24
|
});
|
|
@@ -1,18 +1,15 @@
|
|
|
1
1
|
const { execAsyncSpawn } = require('../../../util/exec-async-command');
|
|
2
|
-
const os = require('os');
|
|
3
2
|
const UnknownError = require('../../../errors/unknown-error');
|
|
4
3
|
|
|
5
|
-
const isLinux = os.platform() === 'linux';
|
|
6
|
-
|
|
7
4
|
/**
|
|
8
5
|
* @returns {import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
|
|
9
6
|
*/
|
|
10
7
|
module.exports = () => ({
|
|
11
8
|
title: 'Flushing Magento redis cache',
|
|
12
|
-
task: async ({ ports, config: { docker } }) => {
|
|
9
|
+
task: async ({ ports, config: { docker }, isDockerDesktop }) => {
|
|
13
10
|
const { redis: { name } } = docker.getContainers(ports);
|
|
14
|
-
const host =
|
|
15
|
-
const port =
|
|
11
|
+
const host = !isDockerDesktop ? 'localhost' : 'host.docker.internal';
|
|
12
|
+
const port = !isDockerDesktop ? '6379' : ports.redis;
|
|
16
13
|
const result = await execAsyncSpawn(`docker exec ${ name } redis-cli -h ${ host } -p ${ port } -n 0 flushdb`);
|
|
17
14
|
|
|
18
15
|
if (!result.trim().includes('OK')) {
|
|
@@ -5,7 +5,7 @@ const { updateTableValues } = require('../../../util/database');
|
|
|
5
5
|
*/
|
|
6
6
|
const increaseAdminSessionLifetime = () => ({
|
|
7
7
|
title: 'Increase admin session lifetime to 1 month',
|
|
8
|
-
task: async ({
|
|
8
|
+
task: async ({ databaseConnection }, task) => updateTableValues('core_config_data', [
|
|
9
9
|
{
|
|
10
10
|
path: 'admin/security/session_lifetime',
|
|
11
11
|
value: '2800000'
|
|
@@ -15,7 +15,7 @@ const increaseAdminSessionLifetime = () => ({
|
|
|
15
15
|
value: null
|
|
16
16
|
}
|
|
17
17
|
], {
|
|
18
|
-
|
|
18
|
+
databaseConnection,
|
|
19
19
|
task
|
|
20
20
|
})
|
|
21
21
|
|
|
@@ -11,6 +11,7 @@ const increaseAdminSessionLifetime = require('./increase-admin-session-lifetime'
|
|
|
11
11
|
const magentoTask = require('../../../util/magento-task');
|
|
12
12
|
const urnHighlighter = require('./urn-highlighter');
|
|
13
13
|
const adjustFullPageCache = require('./adjust-full-page-cache');
|
|
14
|
+
const updateEnvPHP = require('../../php/update-env-php');
|
|
14
15
|
|
|
15
16
|
/**
|
|
16
17
|
* @param {Object} [options]
|
|
@@ -32,6 +33,7 @@ const setupMagento = (options = {}) => ({
|
|
|
32
33
|
return task.newListr([
|
|
33
34
|
flushRedisConfig(),
|
|
34
35
|
waitingForRedis(),
|
|
36
|
+
updateEnvPHP(),
|
|
35
37
|
migrateDatabase(),
|
|
36
38
|
{
|
|
37
39
|
title: 'Configuring Magento settings',
|
|
@@ -5,6 +5,8 @@ const UnknownError = require('../../../errors/unknown-error');
|
|
|
5
5
|
const runMagentoCommand = require('../../../util/run-magento');
|
|
6
6
|
const envPhpToJson = require('../../../util/env-php-json');
|
|
7
7
|
const logger = require('@scandipwa/scandipwa-dev-utils/logger');
|
|
8
|
+
const { defaultMagentoDatabase } = require('../../database/default-magento-database');
|
|
9
|
+
const defaultMagentoUser = require('../../database/default-magento-user');
|
|
8
10
|
|
|
9
11
|
/**
|
|
10
12
|
* @param {Object} [param0]
|
|
@@ -20,23 +22,21 @@ const installMagento = ({ isDbEmpty = false } = {}) => ({
|
|
|
20
22
|
const {
|
|
21
23
|
magentoVersion,
|
|
22
24
|
config: {
|
|
23
|
-
docker,
|
|
24
25
|
magentoConfiguration
|
|
25
26
|
},
|
|
26
27
|
ports,
|
|
27
|
-
|
|
28
|
+
databaseConnection,
|
|
29
|
+
isDockerDesktop
|
|
28
30
|
} = ctx;
|
|
29
31
|
|
|
30
|
-
const
|
|
31
|
-
const isNativeLinux = isLinux && !ctx.isWsl;
|
|
32
|
-
const hostMachine = isNativeLinux ? '127.0.0.1' : 'host.docker.internal';
|
|
32
|
+
const hostMachine = !isDockerDesktop ? '127.0.0.1' : 'host.docker.internal';
|
|
33
33
|
|
|
34
|
-
const [tableResponse] = await
|
|
34
|
+
const [tableResponse] = await databaseConnection.query(
|
|
35
35
|
'SELECT * FROM information_schema.tables WHERE table_schema = \'magento\' AND table_name = \'admin_user\' LIMIT 1;'
|
|
36
36
|
);
|
|
37
37
|
|
|
38
38
|
if (tableResponse.length > 0) {
|
|
39
|
-
const response = await
|
|
39
|
+
const response = await databaseConnection.query(
|
|
40
40
|
'select * from admin_user where username=\'admin\';'
|
|
41
41
|
);
|
|
42
42
|
|
|
@@ -58,23 +58,21 @@ const installMagento = ({ isDbEmpty = false } = {}) => ({
|
|
|
58
58
|
]
|
|
59
59
|
});
|
|
60
60
|
|
|
61
|
-
await
|
|
61
|
+
await databaseConnection.query('SET FOREIGN_KEY_CHECKS = 0;');
|
|
62
62
|
|
|
63
63
|
if (confirmDeleteAdminUsers === 'delete-all') {
|
|
64
|
-
await
|
|
64
|
+
await databaseConnection.query(`
|
|
65
65
|
TRUNCATE TABLE admin_user;
|
|
66
66
|
`);
|
|
67
67
|
} else {
|
|
68
|
-
await
|
|
68
|
+
await databaseConnection.query(`
|
|
69
69
|
DELETE FROM admin_user WHERE username='admin';
|
|
70
70
|
`);
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
await
|
|
73
|
+
await databaseConnection.query('SET FOREIGN_KEY_CHECKS = 1;');
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
|
-
|
|
77
|
-
const { mysql: { env } } = docker.getContainers(ports);
|
|
78
76
|
const envPhpData = await envPhpToJson(ctx);
|
|
79
77
|
|
|
80
78
|
const envPhpHaveEncryptionKey = envPhpData && envPhpData.crypt && envPhpData.crypt.key && envPhpData.crypt.key;
|
|
@@ -126,10 +124,10 @@ const installMagento = ({ isDbEmpty = false } = {}) => ({
|
|
|
126
124
|
--cache-backend-redis-server='${ hostMachine }' \
|
|
127
125
|
--cache-backend-redis-port='${ ports.redis }' \
|
|
128
126
|
--cache-backend-redis-db='0't \
|
|
129
|
-
--db-host='${ hostMachine }:${ ports.
|
|
130
|
-
--db-name='${
|
|
131
|
-
--db-user='${
|
|
132
|
-
--db-password='${
|
|
127
|
+
--db-host='${ hostMachine }:${ ports.mariadb }' \
|
|
128
|
+
--db-name='${ defaultMagentoDatabase }' \
|
|
129
|
+
--db-user='${ defaultMagentoUser.user }' \
|
|
130
|
+
--db-password='${ defaultMagentoUser.password }' \
|
|
133
131
|
--backend-frontname='${ magentoConfiguration.adminuri }' \
|
|
134
132
|
--no-interaction`;
|
|
135
133
|
|
|
@@ -8,6 +8,7 @@ const upgradeMagento = require('./upgrade-magento');
|
|
|
8
8
|
const varnishConfigSetup = require('./varnish-config');
|
|
9
9
|
const pathExists = require('../../../util/path-exists');
|
|
10
10
|
const updateEnvPHP = require('../../php/update-env-php');
|
|
11
|
+
const UnknownError = require('../../../errors/unknown-error');
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
14
|
* @param {Object} [options]
|
|
@@ -17,9 +18,9 @@ const updateEnvPHP = require('../../php/update-env-php');
|
|
|
17
18
|
const migrateDatabase = (options = {}) => ({
|
|
18
19
|
title: 'Migrating database',
|
|
19
20
|
task: async (ctx, task) => {
|
|
20
|
-
const {
|
|
21
|
+
const { databaseConnection } = ctx;
|
|
21
22
|
|
|
22
|
-
const [[{ tableCount }]] = await
|
|
23
|
+
const [[{ tableCount }]] = await databaseConnection.query(`
|
|
23
24
|
SELECT count(*) AS tableCount
|
|
24
25
|
FROM INFORMATION_SCHEMA.TABLES
|
|
25
26
|
WHERE TABLE_SCHEMA = 'magento';
|
|
@@ -33,13 +34,11 @@ const migrateDatabase = (options = {}) => ({
|
|
|
33
34
|
if (options.onlyInstallMagento) {
|
|
34
35
|
ctx.isSetupUpgradeNeeded = false;
|
|
35
36
|
return task.newListr([
|
|
36
|
-
updateEnvPHP(),
|
|
37
37
|
installMagento({ isDbEmpty: true })
|
|
38
38
|
]);
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
return task.newListr([
|
|
42
|
-
updateEnvPHP(),
|
|
43
42
|
installMagento({ isDbEmpty: true }),
|
|
44
43
|
updateEnvPHP(),
|
|
45
44
|
varnishConfigSetup(),
|
|
@@ -56,7 +55,7 @@ const migrateDatabase = (options = {}) => ({
|
|
|
56
55
|
});
|
|
57
56
|
}
|
|
58
57
|
|
|
59
|
-
const { code } = await runMagentoCommand(ctx, 'setup:db:status', {
|
|
58
|
+
const { code, result } = await runMagentoCommand(ctx, 'setup:db:status', {
|
|
60
59
|
throwNonZeroCode: false
|
|
61
60
|
});
|
|
62
61
|
|
|
@@ -65,7 +64,6 @@ const migrateDatabase = (options = {}) => ({
|
|
|
65
64
|
ctx.isSetupUpgradeNeeded = false;
|
|
66
65
|
// no setup is needed, but still to be sure configure ES
|
|
67
66
|
return task.newListr([
|
|
68
|
-
updateEnvPHP(),
|
|
69
67
|
varnishConfigSetup(),
|
|
70
68
|
configureElasticsearch()
|
|
71
69
|
], {
|
|
@@ -88,7 +86,6 @@ const migrateDatabase = (options = {}) => ({
|
|
|
88
86
|
|
|
89
87
|
return task.newListr([
|
|
90
88
|
installMagentoProject(),
|
|
91
|
-
updateEnvPHP(),
|
|
92
89
|
installMagento(),
|
|
93
90
|
updateEnvPHP(),
|
|
94
91
|
varnishConfigSetup(),
|
|
@@ -106,7 +103,6 @@ const migrateDatabase = (options = {}) => ({
|
|
|
106
103
|
}
|
|
107
104
|
case 2: {
|
|
108
105
|
return task.newListr([
|
|
109
|
-
updateEnvPHP(),
|
|
110
106
|
varnishConfigSetup(),
|
|
111
107
|
configureElasticsearch(),
|
|
112
108
|
upgradeMagento()
|
|
@@ -120,9 +116,7 @@ const migrateDatabase = (options = {}) => ({
|
|
|
120
116
|
});
|
|
121
117
|
}
|
|
122
118
|
default: {
|
|
123
|
-
|
|
124
|
-
task.title = 'Migrating database failed: manual action is required!';
|
|
125
|
-
break;
|
|
119
|
+
throw new UnknownError(`Migrating database failed: manual action is required!\n\n${result}`);
|
|
126
120
|
}
|
|
127
121
|
}
|
|
128
122
|
},
|
|
@@ -14,10 +14,10 @@ module.exports = () => ({
|
|
|
14
14
|
ssl
|
|
15
15
|
}
|
|
16
16
|
},
|
|
17
|
-
|
|
17
|
+
databaseConnection
|
|
18
18
|
} = ctx;
|
|
19
19
|
const isNgrok = host.endsWith('ngrok.io');
|
|
20
|
-
const enableSecureFrontend = ssl.enabled ? '1' : '0';
|
|
20
|
+
const enableSecureFrontend = (ctx.config.overridenConfiguration.configuration.varnish.enabled && ssl.enabled) ? '1' : '0';
|
|
21
21
|
const location = `${host}${ !isNgrok && ports.sslTerminator !== 80 ? `:${ports.sslTerminator }` : '' }/`;
|
|
22
22
|
const secureLocation = `${host}/`; // SSL will work only on port 443, so you cannot run multiple projects with SSL at the same time.
|
|
23
23
|
const httpUrl = `http://${location}`;
|
|
@@ -29,6 +29,6 @@ module.exports = () => ({
|
|
|
29
29
|
{ path: 'web/secure/use_in_frontend', value: enableSecureFrontend },
|
|
30
30
|
{ path: 'web/secure/use_in_adminhtml', value: enableSecureFrontend },
|
|
31
31
|
{ path: 'web/cookie/cookie_domain', value: null }
|
|
32
|
-
], {
|
|
32
|
+
], { databaseConnection, task });
|
|
33
33
|
}
|
|
34
34
|
});
|
|
@@ -5,13 +5,13 @@ const { updateTableValues } = require('../../../util/database');
|
|
|
5
5
|
*/
|
|
6
6
|
const setUrlRewrite = () => ({
|
|
7
7
|
title: 'Setting up url-rewrites',
|
|
8
|
-
task: async ({
|
|
8
|
+
task: async ({ databaseConnection }, task) => {
|
|
9
9
|
await updateTableValues('core_config_data', [
|
|
10
10
|
{
|
|
11
11
|
path: 'web/seo/use_rewrites',
|
|
12
12
|
value: '1'
|
|
13
13
|
}
|
|
14
|
-
], {
|
|
14
|
+
], { databaseConnection, task });
|
|
15
15
|
}
|
|
16
16
|
});
|
|
17
17
|
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
const os = require('os');
|
|
2
1
|
const { updateTableValues } = require('../../../util/database');
|
|
3
|
-
const getIsWsl = require('../../../util/is-wsl');
|
|
4
2
|
|
|
5
3
|
/**
|
|
6
4
|
* @returns {import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
|
|
@@ -18,20 +16,17 @@ const varnishConfigSetup = () => ({
|
|
|
18
16
|
}
|
|
19
17
|
}
|
|
20
18
|
},
|
|
21
|
-
|
|
19
|
+
databaseConnection,
|
|
22
20
|
ports,
|
|
23
|
-
debug
|
|
21
|
+
debug,
|
|
22
|
+
isDockerDesktop
|
|
24
23
|
} = ctx;
|
|
25
24
|
|
|
26
|
-
const isLinux = os.platform() === 'linux';
|
|
27
|
-
const isWsl = await getIsWsl();
|
|
28
|
-
const isNativeLinux = isLinux && !isWsl;
|
|
29
|
-
|
|
30
25
|
if (!debug && varnishEnabled) {
|
|
31
26
|
await updateTableValues('core_config_data', [
|
|
32
27
|
{
|
|
33
28
|
path: 'system/full_page_cache/varnish/backend_host',
|
|
34
|
-
value:
|
|
29
|
+
value: isDockerDesktop ? 'host.docker.internal' : 'localhost'
|
|
35
30
|
},
|
|
36
31
|
{
|
|
37
32
|
path: 'system/full_page_cache/varnish/backend_port',
|
|
@@ -39,16 +34,16 @@ const varnishConfigSetup = () => ({
|
|
|
39
34
|
},
|
|
40
35
|
{
|
|
41
36
|
path: 'system/full_page_cache/varnish/access_list',
|
|
42
|
-
value:
|
|
37
|
+
value: isDockerDesktop ? 'host.docker.internal,localhost' : 'localhost'
|
|
43
38
|
},
|
|
44
39
|
{
|
|
45
40
|
path: 'system/full_page_cache/caching_application',
|
|
46
41
|
value: '2'
|
|
47
42
|
}
|
|
48
|
-
], {
|
|
43
|
+
], { databaseConnection, task });
|
|
49
44
|
} else {
|
|
50
45
|
// delete varnish configuration if exists
|
|
51
|
-
await
|
|
46
|
+
await databaseConnection.query(`
|
|
52
47
|
DELETE FROM core_config_data WHERE path LIKE '%varnish%';
|
|
53
48
|
`);
|
|
54
49
|
|
|
@@ -59,7 +54,7 @@ const varnishConfigSetup = () => ({
|
|
|
59
54
|
path: 'system/full_page_cache/caching_application',
|
|
60
55
|
value: '0'
|
|
61
56
|
}
|
|
62
|
-
], {
|
|
57
|
+
], { databaseConnection, task });
|
|
63
58
|
}
|
|
64
59
|
},
|
|
65
60
|
options: {
|
|
@@ -4,9 +4,9 @@ const fs = require('fs');
|
|
|
4
4
|
const path = require('path');
|
|
5
5
|
const { request } = require('smol-request');
|
|
6
6
|
const KnownError = require('../../../errors/known-error');
|
|
7
|
-
const { execAsyncSpawn } = require('../../../util/exec-async-command');
|
|
8
7
|
const { NginxParser } = require('../../../util/nginx-logs-parser');
|
|
9
8
|
const sleep = require('../../../util/sleep');
|
|
9
|
+
const { containerApi } = require('../../docker/containers');
|
|
10
10
|
|
|
11
11
|
const pathToWorkingHealthCheckPhp = path.join(__dirname, '..', '..', 'php', 'working_health_check.php');
|
|
12
12
|
const pathToProjectsHealthCheckPhp = path.join(process.cwd(), 'pub', 'health_check.php');
|
|
@@ -17,19 +17,18 @@ const pathToHealthCheckBackupPhp = path.join(process.cwd(), 'pub', 'health_check
|
|
|
17
17
|
*/
|
|
18
18
|
const getIsHealthCheckRequestBroken = async (ctx) => {
|
|
19
19
|
const { nginx } = ctx.config.docker.getContainers(ctx.ports);
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
const
|
|
24
|
-
.
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
return parsedRequests.every((parsedRequest) => parsedRequest.status !== '200');
|
|
20
|
+
const parser = new NginxParser(
|
|
21
|
+
'$remote_addr - $remote_user [$time_local] "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent"'
|
|
22
|
+
);
|
|
23
|
+
const parsedLogs = await containerApi.logs({
|
|
24
|
+
name: nginx.name,
|
|
25
|
+
parser: (line) => parser.parseLine(line)
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
const healthCheckRequests = parsedLogs
|
|
29
|
+
.filter((line) => line.request.includes('/health_check.php'));
|
|
30
|
+
|
|
31
|
+
return healthCheckRequests.every((parsedRequest) => parsedRequest.status !== '200');
|
|
33
32
|
};
|
|
34
33
|
|
|
35
34
|
/**
|
|
@@ -37,12 +36,14 @@ const getIsHealthCheckRequestBroken = async (ctx) => {
|
|
|
37
36
|
*/
|
|
38
37
|
const waitingForVarnish = () => ({
|
|
39
38
|
title: 'Waiting for Varnish to return code 200',
|
|
40
|
-
skip: (ctx) => ctx.debug
|
|
39
|
+
skip: (ctx) => ctx.debug
|
|
40
|
+
|| !ctx.config.overridenConfiguration.configuration.varnish.enabled
|
|
41
|
+
|| ctx.config.overridenConfiguration.ssl.enabled
|
|
42
|
+
|| !ctx.config.overridenConfiguration.configuration.varnish.healthCheck,
|
|
41
43
|
task: async (ctx, task) => {
|
|
42
44
|
const pureMagentoVersion = ctx.magentoVersion.match(/^([0-9]+\.[0-9]+\.[0-9]+)/)[1];
|
|
43
45
|
|
|
44
46
|
const isMagento23 = semver.satisfies(pureMagentoVersion, '<2.4');
|
|
45
|
-
|
|
46
47
|
let tries = 0;
|
|
47
48
|
while (tries < 10) {
|
|
48
49
|
try {
|