@scandipwa/magento-scripts 2.0.0-alpha.2 → 2.0.0-alpha.21
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 +18 -1
- package/lib/commands/execute.js +2 -57
- package/lib/commands/logs.js +28 -2
- package/lib/commands/start.js +24 -3
- package/lib/commands/status.js +9 -1
- package/lib/config/config.js +20 -2
- package/lib/config/docker.js +90 -53
- package/lib/config/get-project-configuration.js +5 -0
- package/lib/config/index.js +10 -3
- 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 +3 -1
- package/lib/config/services/composer/versions/composer-1.js +13 -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/maildev/index.js +7 -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 +12 -5
- 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 +5 -201
- 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.2.10.js +41 -0
- package/lib/config/versions/magento-2.3.0.js +8 -10
- package/lib/config/versions/magento-2.3.1.js +8 -10
- package/lib/config/versions/magento-2.3.2-p1.js +8 -10
- package/lib/config/versions/magento-2.3.2-p2.js +8 -10
- package/lib/config/versions/magento-2.3.2.js +8 -10
- package/lib/config/versions/magento-2.3.3-p1.js +8 -10
- package/lib/config/versions/magento-2.3.3.js +8 -10
- package/lib/config/versions/magento-2.3.4-p1.js +8 -10
- package/lib/config/versions/magento-2.3.4-p2.js +8 -10
- package/lib/config/versions/magento-2.3.4.js +8 -10
- package/lib/config/versions/magento-2.3.5-p1.js +8 -10
- package/lib/config/versions/magento-2.3.5-p2.js +8 -10
- package/lib/config/versions/magento-2.3.5.js +8 -10
- package/lib/config/versions/magento-2.3.6-p1.js +8 -10
- package/lib/config/versions/magento-2.3.6.js +8 -10
- package/lib/config/versions/magento-2.3.7-p1.js +8 -10
- package/lib/config/versions/magento-2.3.7-p2.js +8 -10
- package/lib/config/versions/magento-2.3.7-p3.js +8 -10
- package/lib/config/versions/magento-2.3.7-p4.js +42 -0
- package/lib/config/versions/magento-2.3.7.js +8 -10
- package/lib/config/versions/magento-2.4.0-p1.js +8 -10
- package/lib/config/versions/magento-2.4.0.js +8 -10
- package/lib/config/versions/magento-2.4.1-p1.js +8 -10
- package/lib/config/versions/magento-2.4.1.js +8 -10
- package/lib/config/versions/magento-2.4.2-p1.js +8 -10
- package/lib/config/versions/magento-2.4.2-p2.js +8 -10
- package/lib/config/versions/magento-2.4.2.js +8 -10
- package/lib/config/versions/magento-2.4.3-p1.js +8 -10
- package/lib/config/versions/magento-2.4.3-p2.js +8 -10
- package/lib/config/versions/magento-2.4.3-p3.js +44 -0
- package/lib/config/versions/magento-2.4.3.js +8 -10
- package/lib/config/versions/magento-2.4.4-p1.js +44 -0
- package/lib/config/versions/magento-2.4.4.js +8 -10
- package/lib/config/versions/magento-2.4.5.js +44 -0
- package/lib/tasks/cli/create-bashrc-config.js +4 -2
- package/lib/tasks/composer/local-auth-json.js +1 -1
- package/lib/tasks/database/connect-to-database.js +6 -3
- package/lib/tasks/database/create-magento-database.js +5 -2
- 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/database/import-dump-to-database.js +3 -2
- 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 +21 -0
- package/lib/tasks/docker/containers/container-api.js +82 -17
- package/lib/tasks/docker/containers/tasks.js +44 -13
- package/lib/tasks/docker/convert-composer-home-to-composer-cache-volume.js +52 -0
- package/lib/tasks/docker/convert-mysql-to-mariadb.js +2 -2
- package/lib/tasks/docker/image/image-api.d.ts +44 -0
- package/lib/tasks/docker/image/image-api.js +30 -2
- package/lib/tasks/docker/index.js +6 -1
- package/lib/tasks/docker/project-image-builder.js +37 -14
- package/lib/tasks/docker/system/index.js +5 -0
- package/lib/tasks/docker/system/system-api.d.ts +71 -0
- package/lib/tasks/docker/system/system-api.js +29 -0
- package/lib/tasks/docker/volume/index.js +2 -1
- package/lib/tasks/docker/volume/tasks.js +67 -9
- package/lib/tasks/docker/volume/volume-api.d.ts +40 -0
- package/lib/tasks/docker/volume/volume-api.js +54 -1
- package/lib/tasks/execute.js +100 -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/exclude-folder-config.js +13 -3
- package/lib/tasks/file-system/create-phpstorm-config/index.js +2 -1
- 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/create-vscode-config.js +2 -1
- package/lib/tasks/file-system/index.js +3 -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 +2 -4
- package/lib/tasks/magento/setup-magento/flush-redis-config.js +3 -6
- package/lib/tasks/magento/setup-magento/index.js +2 -0
- package/lib/tasks/magento/setup-magento/install-magento.js +8 -13
- package/lib/tasks/magento/setup-magento/set-base-url.js +1 -1
- package/lib/tasks/magento/setup-magento/set-mail-config.js +22 -0
- package/lib/tasks/magento/setup-magento/varnish-config.js +4 -9
- 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 +3 -4
- package/lib/tasks/{prefix → project-config}/index.js +6 -6
- 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 +114 -20
- 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 +27 -8
- package/lib/tasks/status/index.js +60 -21
- package/lib/tasks/stop.js +2 -0
- package/lib/tasks/theme/retrieve-theme-data.js +12 -2
- package/lib/util/config-file-validator.js +17 -3
- package/lib/util/execute-in-container.js +62 -0
- package/lib/util/instance-metadata.js +14 -2
- package/lib/util/systemctl.js +62 -13
- package/package.json +4 -3
- package/typings/context.d.ts +11 -0
- package/typings/index.d.ts +46 -1
- package/lib/tasks/execute/index.js +0 -26
- 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
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const createMariaDBConfig = require('./create-mariadb-config');
|
|
2
2
|
const createNginxConfig = require('./create-nginx-config');
|
|
3
3
|
const createPhpConfig = require('./create-php-config');
|
|
4
|
+
const createPhpDebugConfig = require('./create-php-debug-config');
|
|
4
5
|
const createPhpFpmConfig = require('./create-php-fpm-config');
|
|
5
6
|
const createPhpStormConfig = require('./create-phpstorm-config');
|
|
6
7
|
const createSSLTerminatorConfig = require('./create-ssl-terminator-config');
|
|
@@ -17,13 +18,13 @@ const prepareFileSystem = () => ({
|
|
|
17
18
|
createNginxConfig(),
|
|
18
19
|
createPhpFpmConfig(),
|
|
19
20
|
createPhpConfig(),
|
|
21
|
+
createPhpDebugConfig(),
|
|
20
22
|
createPhpStormConfig(),
|
|
21
23
|
createVSCodeConfig(),
|
|
22
24
|
createVarnishConfig(),
|
|
23
25
|
createMariaDBConfig()
|
|
24
26
|
], {
|
|
25
|
-
concurrent: true
|
|
26
|
-
exitOnError: false
|
|
27
|
+
concurrent: true
|
|
27
28
|
})
|
|
28
29
|
});
|
|
29
30
|
|
|
@@ -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,10 +7,8 @@ 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, databaseConnection } = ctx;
|
|
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 },
|
|
@@ -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')) {
|
|
@@ -12,6 +12,7 @@ const magentoTask = require('../../../util/magento-task');
|
|
|
12
12
|
const urnHighlighter = require('./urn-highlighter');
|
|
13
13
|
const adjustFullPageCache = require('./adjust-full-page-cache');
|
|
14
14
|
const updateEnvPHP = require('../../php/update-env-php');
|
|
15
|
+
const setMailConfig = require('./set-mail-config');
|
|
15
16
|
|
|
16
17
|
/**
|
|
17
18
|
* @param {Object} [options]
|
|
@@ -40,6 +41,7 @@ const setupMagento = (options = {}) => ({
|
|
|
40
41
|
task: (ctx, task) => task.newListr([
|
|
41
42
|
setBaseUrl(),
|
|
42
43
|
setUrlRewrite(),
|
|
44
|
+
setMailConfig(),
|
|
43
45
|
increaseAdminSessionLifetime()
|
|
44
46
|
], {
|
|
45
47
|
concurrent: true
|
|
@@ -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,16 +22,14 @@ const installMagento = ({ isDbEmpty = false } = {}) => ({
|
|
|
20
22
|
const {
|
|
21
23
|
magentoVersion,
|
|
22
24
|
config: {
|
|
23
|
-
docker,
|
|
24
25
|
magentoConfiguration
|
|
25
26
|
},
|
|
26
27
|
ports,
|
|
27
|
-
databaseConnection
|
|
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
34
|
const [tableResponse] = await databaseConnection.query(
|
|
35
35
|
'SELECT * FROM information_schema.tables WHERE table_schema = \'magento\' AND table_name = \'admin_user\' LIMIT 1;'
|
|
@@ -73,8 +73,6 @@ const installMagento = ({ isDbEmpty = false } = {}) => ({
|
|
|
73
73
|
await databaseConnection.query('SET FOREIGN_KEY_CHECKS = 1;');
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
|
-
|
|
77
|
-
const { mariadb: { 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;
|
|
@@ -127,9 +125,9 @@ const installMagento = ({ isDbEmpty = false } = {}) => ({
|
|
|
127
125
|
--cache-backend-redis-port='${ ports.redis }' \
|
|
128
126
|
--cache-backend-redis-db='0't \
|
|
129
127
|
--db-host='${ hostMachine }:${ ports.mariadb }' \
|
|
130
|
-
--db-name='${
|
|
131
|
-
--db-user='${
|
|
132
|
-
--db-password='${
|
|
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
|
|
|
@@ -143,9 +141,6 @@ const installMagento = ({ isDbEmpty = false } = {}) => ({
|
|
|
143
141
|
installed = true;
|
|
144
142
|
} catch (e) {
|
|
145
143
|
errors.push(e);
|
|
146
|
-
if (tries === 2) {
|
|
147
|
-
throw e;
|
|
148
|
-
}
|
|
149
144
|
}
|
|
150
145
|
|
|
151
146
|
if (installed) {
|
|
@@ -17,7 +17,7 @@ module.exports = () => ({
|
|
|
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}`;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
const { updateTableValues } = require('../../../util/database');
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @type {() => import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
|
|
5
|
+
*/
|
|
6
|
+
const setMailConfig = () => ({
|
|
7
|
+
title: 'Setting up mail configuration',
|
|
8
|
+
task: async ({ databaseConnection, ports, isDockerDesktop }, task) => {
|
|
9
|
+
await updateTableValues('core_config_data', [
|
|
10
|
+
{
|
|
11
|
+
path: 'smtp/configuration_option/port',
|
|
12
|
+
value: `${ ports.maildevSMTP }`
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
path: 'smtp/configuration_option/host',
|
|
16
|
+
value: isDockerDesktop ? 'host.docker.internal' : 'localhost'
|
|
17
|
+
}
|
|
18
|
+
], { databaseConnection, task });
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
module.exports = setMailConfig;
|
|
@@ -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>}
|
|
@@ -20,18 +18,15 @@ const varnishConfigSetup = () => ({
|
|
|
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,7 +34,7 @@ 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',
|
|
@@ -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 {
|
|
@@ -10,9 +10,13 @@ const { containerApi } = require('../docker/containers');
|
|
|
10
10
|
const runPHPContainerCommand = async (ctx, command, options = {}) => {
|
|
11
11
|
const { php } = ctx.config.docker.getContainers(ctx.ports);
|
|
12
12
|
|
|
13
|
-
const containers = await containerApi.ls({
|
|
13
|
+
const containers = await containerApi.ls({
|
|
14
|
+
formatToJSON: true,
|
|
15
|
+
all: true,
|
|
16
|
+
filter: `name=${php.name}`
|
|
17
|
+
});
|
|
14
18
|
|
|
15
|
-
if (containers.
|
|
19
|
+
if (containers.length > 0) {
|
|
16
20
|
return execPHPContainerCommand(ctx, command, options);
|
|
17
21
|
}
|
|
18
22
|
|
|
@@ -25,7 +29,7 @@ const runPHPContainerCommand = async (ctx, command, options = {}) => {
|
|
|
25
29
|
},
|
|
26
30
|
options.useXDebugContainer
|
|
27
31
|
? {
|
|
28
|
-
image:
|
|
32
|
+
image: php.debugImage
|
|
29
33
|
}
|
|
30
34
|
: {},
|
|
31
35
|
{
|
|
@@ -19,11 +19,10 @@ const updateEnvPHP = () => ({
|
|
|
19
19
|
return;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
+
const { isDockerDesktop, platform } = ctx;
|
|
22
23
|
const { php } = ctx.config.docker.getContainers(ctx.ports);
|
|
23
24
|
|
|
24
|
-
const
|
|
25
|
-
const isNativeLinux = isLinux && !ctx.isWsl;
|
|
26
|
-
const hostMachine = isNativeLinux ? '127.0.0.1' : 'host.docker.internal';
|
|
25
|
+
const hostMachine = !isDockerDesktop ? '127.0.0.1' : 'host.docker.internal';
|
|
27
26
|
|
|
28
27
|
const useVarnish = (!ctx.debug && ctx.config.overridenConfiguration.configuration.varnish.enabled) ? '1' : '';
|
|
29
28
|
const varnishHost = hostMachine;
|
|
@@ -78,7 +77,7 @@ const updateEnvPHP = () => ({
|
|
|
78
77
|
image: php.image,
|
|
79
78
|
detach: false,
|
|
80
79
|
rm: true,
|
|
81
|
-
user:
|
|
80
|
+
user: platform === 'linux' ? `${os.userInfo().uid}:${os.userInfo().gid}` : ''
|
|
82
81
|
});
|
|
83
82
|
|
|
84
83
|
task.output = result;
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
+
const { setProjectConfig } = require('../../config/config');
|
|
1
2
|
const { setPrefix: setPrefixUtil } = require('../../util/prefix');
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* @type {() => import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
|
|
5
6
|
*/
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
title: 'Settings project prefix',
|
|
7
|
+
const setProjectConfigTask = () => ({
|
|
8
|
+
title: 'Settings project config',
|
|
9
9
|
task: (ctx) => {
|
|
10
10
|
const { config: { overridenConfiguration: { prefix } } } = ctx;
|
|
11
11
|
|
|
12
12
|
setPrefixUtil(prefix);
|
|
13
|
+
|
|
14
|
+
setProjectConfig('debug', ctx.debug);
|
|
13
15
|
},
|
|
14
16
|
options: {
|
|
15
17
|
showTimer: false
|
|
16
18
|
}
|
|
17
19
|
});
|
|
18
20
|
|
|
19
|
-
module.exports = {
|
|
20
|
-
setPrefix
|
|
21
|
-
};
|
|
21
|
+
module.exports = { setProjectConfigTask };
|
|
@@ -96,9 +96,9 @@ ${ logger.style.misc('Password') } (${ logger.style.misc('Private key') }):`,
|
|
|
96
96
|
};
|
|
97
97
|
|
|
98
98
|
const authJsonContent = JSON.stringify(authContent, null, 4);
|
|
99
|
-
const authEnvContent = `export COMPOSER_AUTH='${JSON.stringify(authContent)}'`;
|
|
99
|
+
const authEnvContent = `export COMPOSER_AUTH='${JSON.stringify(authContent, null, 0)}'`;
|
|
100
100
|
|
|
101
|
-
process.env.COMPOSER_AUTH = authJsonContent;
|
|
101
|
+
process.env.COMPOSER_AUTH = JSON.stringify(JSON.parse(authJsonContent), null, 0);
|
|
102
102
|
|
|
103
103
|
if (configureLocation === 'auth.json') {
|
|
104
104
|
await fs.promises.writeFile(authJsonPath, authJsonContent, 'utf-8');
|
|
@@ -175,7 +175,11 @@ Would you like to load them now?`
|
|
|
175
175
|
|
|
176
176
|
if (loadCredentialsFrom) {
|
|
177
177
|
const credentialsLine = lines.find((line) => line.startsWith('export COMPOSER_AUTH='));
|
|
178
|
-
process.env.COMPOSER_AUTH =
|
|
178
|
+
process.env.COMPOSER_AUTH = JSON.stringify(
|
|
179
|
+
JSON.parse(credentialsLine.replace('export COMPOSER_AUTH=', '').replace(/'/ig, '').trim()),
|
|
180
|
+
null,
|
|
181
|
+
0
|
|
182
|
+
);
|
|
179
183
|
problems.delete(MISSING_COMPOSER_AUTH_ENV);
|
|
180
184
|
}
|
|
181
185
|
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
const logger = require('@scandipwa/scandipwa-dev-utils/logger');
|
|
2
|
+
const os = require('os');
|
|
3
|
+
const { cmaGlobalConfig } = require('../../../config/cma-config');
|
|
4
|
+
const { getCachedPorts } = require('../../../config/get-port-config');
|
|
5
|
+
const { getSystemConfigTask } = require('../../../config/system-config');
|
|
6
|
+
const UnknownError = require('../../../errors/unknown-error');
|
|
7
|
+
const { execCommandTask } = require('../../../util/exec-async-command');
|
|
8
|
+
const createCacheFolder = require('../../cache/create-cache-folder');
|
|
9
|
+
const { dockerApi } = require('../../docker');
|
|
10
|
+
const { stopContainers } = require('../../docker/containers');
|
|
11
|
+
const { getDockerEngineAndDesktopServiceStatus } = require('./running-status');
|
|
12
|
+
const getMagentoVersionConfig = require('../../../config/get-magento-version-config');
|
|
13
|
+
const checkConfigurationFile = require('../../../config/check-configuration-file');
|
|
14
|
+
const getProjectConfiguration = require('../../../config/get-project-configuration');
|
|
15
|
+
const getDockerVersion = require('./version');
|
|
16
|
+
|
|
17
|
+
const USE_DEFAULT_DOCKER_DESKTOP_CONTEXT_ANSWER = 'useDefaultDockerDesktopContext';
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* @type {() => import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
|
|
21
|
+
*/
|
|
22
|
+
const checkDockerDesktopContext = () => ({
|
|
23
|
+
task: async (ctx, task) => {
|
|
24
|
+
if (os.platform() !== 'linux' || !ctx.isDockerDesktop) {
|
|
25
|
+
task.skip();
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
task.title = 'Checking contexts for Docker Desktop';
|
|
30
|
+
|
|
31
|
+
const contexts = await dockerApi.context({ formatToJSON: true });
|
|
32
|
+
const currentlyUsedContext = contexts.find((c) => c.Current);
|
|
33
|
+
|
|
34
|
+
if (!currentlyUsedContext) {
|
|
35
|
+
throw new UnknownError('We haven\'t found contexts in Docker...');
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const { engine } = await getDockerEngineAndDesktopServiceStatus();
|
|
39
|
+
|
|
40
|
+
if (currentlyUsedContext.Name !== 'default' && engine.exists) {
|
|
41
|
+
if (cmaGlobalConfig.get(USE_DEFAULT_DOCKER_DESKTOP_CONTEXT_ANSWER) === false) {
|
|
42
|
+
task.skip();
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const confirmContextChange = await task.prompt({
|
|
47
|
+
type: 'Select',
|
|
48
|
+
message: `Do you want to change current Docker Desktop context (${logger.style.code(currentlyUsedContext.Name)}) to ${logger.style.code('default')}?`,
|
|
49
|
+
choices: [
|
|
50
|
+
{
|
|
51
|
+
name: 'yes',
|
|
52
|
+
message: 'Yes'
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
name: 'no',
|
|
56
|
+
message: 'No, I don\'t know what this means, but you can ask again on next start.'
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
name: 'skip',
|
|
60
|
+
// eslint-disable-next-line max-len
|
|
61
|
+
message: 'I do know what this means and I DON\'T want to change context for Docker. Also, save this answer to never ask again.'
|
|
62
|
+
}
|
|
63
|
+
]
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
if (confirmContextChange === 'skip') {
|
|
67
|
+
cmaGlobalConfig.set(USE_DEFAULT_DOCKER_DESKTOP_CONTEXT_ANSWER, false);
|
|
68
|
+
task.skip();
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (confirmContextChange === 'yes') {
|
|
72
|
+
return task.newListr([
|
|
73
|
+
getMagentoVersionConfig(),
|
|
74
|
+
checkConfigurationFile(),
|
|
75
|
+
getProjectConfiguration(),
|
|
76
|
+
createCacheFolder(),
|
|
77
|
+
getSystemConfigTask(),
|
|
78
|
+
getCachedPorts(),
|
|
79
|
+
stopContainers(),
|
|
80
|
+
execCommandTask('docker context use default'),
|
|
81
|
+
getDockerVersion()
|
|
82
|
+
]);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
module.exports = checkDockerDesktopContext;
|