@scandipwa/magento-scripts 2.0.0-alpha.8 → 2.0.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/commands/cli.js +18 -1
- 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/dependencies-for-platforms.js +1 -1
- package/lib/config/docker.js +94 -54
- 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/nginx.fastcgi_params.template +29 -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 +5 -201
- package/lib/config/templates/ssl-terminator.template.conf +2 -0
- 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 +8 -10
- 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 +8 -10
- package/lib/config/versions/magento-2.4.3.js +8 -10
- package/lib/config/versions/magento-2.4.4-p1.js +8 -10
- package/lib/config/versions/magento-2.4.4.js +8 -10
- package/lib/config/versions/magento-2.4.5.js +8 -10
- 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 +11 -9
- 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-ssl-terminator-config.js +23 -8
- 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/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 +2 -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 +15 -16
- package/lib/tasks/php/php-container.js +1 -1
- package/lib/tasks/php/update-env-php.js +3 -5
- 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 +111 -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 +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 +35 -5
- package/lib/util/instance-metadata.js +14 -2
- package/lib/util/systemctl.js +62 -13
- package/package.json +2 -2
- package/typings/context.d.ts +11 -0
- package/typings/index.d.ts +46 -1
- 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
|
@@ -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;
|
|
@@ -1,17 +1,23 @@
|
|
|
1
|
+
const os = require('os');
|
|
1
2
|
const logger = require('@scandipwa/scandipwa-dev-utils/logger');
|
|
3
|
+
const { cmaGlobalConfig } = require('../../../config/cma-config');
|
|
2
4
|
const KnownError = require('../../../errors/known-error');
|
|
3
5
|
const { execAsyncSpawn } = require('../../../util/exec-async-command');
|
|
4
6
|
const openBrowser = require('../../../util/open-browser');
|
|
5
|
-
const
|
|
7
|
+
const checkDockerDesktopContext = require('./context');
|
|
8
|
+
const { installDockerEngine } = require('./install');
|
|
6
9
|
const installDockerOnMac = require('./install-on-mac');
|
|
7
10
|
const { checkDockerPerformance } = require('./performance');
|
|
8
11
|
const { checkDockerSocketPermissions } = require('./permissions');
|
|
9
|
-
const checkDockerStatus = require('./running-status');
|
|
12
|
+
const { checkDockerStatus, getDockerEngineAndDesktopServiceStatus } = require('./running-status');
|
|
10
13
|
const getDockerVersion = require('./version');
|
|
14
|
+
const getIsWsl = require('../../../util/is-wsl');
|
|
15
|
+
|
|
16
|
+
const USE_DOCKER_ENGINE_WITH_DOCKER_DESKTOP_ANSWER = 'useDockerEngineWithDockerDesktop';
|
|
11
17
|
|
|
12
18
|
const setVersionInContextTask = (task) => ({
|
|
13
19
|
task: (ctx) => {
|
|
14
|
-
if (
|
|
20
|
+
if (os.platform() === 'darwin' && ctx.dockerServerData && ctx.dockerServerData.Platform && ctx.dockerServerData.Platform.Name) {
|
|
15
21
|
task.title = `Using ${ctx.dockerServerData.Platform.Name} for Mac`;
|
|
16
22
|
} else {
|
|
17
23
|
task.title = `Using Docker version ${ctx.dockerVersion}`;
|
|
@@ -19,33 +25,72 @@ const setVersionInContextTask = (task) => ({
|
|
|
19
25
|
}
|
|
20
26
|
});
|
|
21
27
|
|
|
22
|
-
const dockerInstallPromptLinux = async (task) => {
|
|
23
|
-
const automaticallyInstallDocker = await task.prompt({
|
|
24
|
-
type: '
|
|
28
|
+
const dockerInstallPromptLinux = async (task, { skipPrompt = false } = {}) => {
|
|
29
|
+
const automaticallyInstallDocker = skipPrompt ? 'yes' : await task.prompt({
|
|
30
|
+
type: 'Select',
|
|
25
31
|
message: `You don't have Docker installed!
|
|
26
32
|
Do you want to install it automatically?
|
|
27
|
-
|
|
33
|
+
`,
|
|
34
|
+
choices: [
|
|
35
|
+
{
|
|
36
|
+
name: 'yes',
|
|
37
|
+
message: 'Yes, I to install Docker automatically'
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
name: 'no',
|
|
41
|
+
message: 'No, I want to install Docker myself'
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
name: 'skip',
|
|
45
|
+
message: 'Skip installing Docker'
|
|
46
|
+
}
|
|
47
|
+
]
|
|
28
48
|
});
|
|
29
49
|
|
|
30
|
-
if (automaticallyInstallDocker) {
|
|
50
|
+
if (automaticallyInstallDocker === 'yes') {
|
|
31
51
|
return task.newListr([
|
|
32
|
-
|
|
52
|
+
installDockerEngine(),
|
|
33
53
|
checkDockerSocketPermissions(),
|
|
34
54
|
getDockerVersion(),
|
|
35
55
|
{
|
|
36
|
-
task: (ctx) => {
|
|
56
|
+
task: async (ctx) => {
|
|
37
57
|
task.title = `Using docker version ${ctx.dockerVersion}`;
|
|
38
58
|
|
|
59
|
+
const confirmLogOut = await task.prompt({
|
|
60
|
+
type: 'Select',
|
|
61
|
+
message: 'Docker installed successfully!\n',
|
|
62
|
+
choices: [
|
|
63
|
+
{
|
|
64
|
+
name: 'log-out',
|
|
65
|
+
message: `${logger.style.command('[Recommended]')} Now I will log out and log back it (or restart my system) to re-evaluate group membership`
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
name: 'skip',
|
|
69
|
+
message: 'Skip log out and proceed with installation'
|
|
70
|
+
}
|
|
71
|
+
]
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
if (confirmLogOut === 'skip') {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
|
|
39
78
|
throw new KnownError(
|
|
40
79
|
`Docker is installed successfully!
|
|
41
|
-
Please log out and log back
|
|
80
|
+
Please log out and log back in (or restart your system) so your group membership is re-evaluated!
|
|
42
81
|
Learn more here: ${ logger.style.link('https://docs.docker.com/engine/install/linux-postinstall/') }`
|
|
43
82
|
);
|
|
44
83
|
}
|
|
45
|
-
}
|
|
84
|
+
},
|
|
85
|
+
checkDockerStatus(),
|
|
86
|
+
checkDockerDesktopContext()
|
|
46
87
|
]);
|
|
47
88
|
}
|
|
48
89
|
|
|
90
|
+
if (automaticallyInstallDocker === 'skip') {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
|
|
49
94
|
throw new KnownError('Docker is not installed!');
|
|
50
95
|
};
|
|
51
96
|
|
|
@@ -65,7 +110,8 @@ const dockerInstallPromptMacOS = async (task) => {
|
|
|
65
110
|
const confirmationToInstallDocker = await task.prompt({
|
|
66
111
|
type: 'Select',
|
|
67
112
|
message: `You don't have Docker installed!
|
|
68
|
-
Would you like to install it automatically using brew cask or you prefer to install it manually
|
|
113
|
+
Would you like to install it automatically using brew cask or you prefer to install it manually?
|
|
114
|
+
`,
|
|
69
115
|
choices: [
|
|
70
116
|
{
|
|
71
117
|
name: 'automatic',
|
|
@@ -108,25 +154,71 @@ const checkDocker = () => ({
|
|
|
108
154
|
});
|
|
109
155
|
|
|
110
156
|
if (code !== 0) {
|
|
111
|
-
if (
|
|
112
|
-
const
|
|
113
|
-
if (
|
|
114
|
-
|
|
157
|
+
if (os.platform() === 'linux') {
|
|
158
|
+
const isWsl = await getIsWsl();
|
|
159
|
+
if (!isWsl) {
|
|
160
|
+
const { engine } = await getDockerEngineAndDesktopServiceStatus();
|
|
161
|
+
if (!engine.exists) {
|
|
162
|
+
const result = await dockerInstallPromptLinux(task);
|
|
163
|
+
if (result) {
|
|
164
|
+
return result;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
} else if (isWsl) {
|
|
168
|
+
dockerInstallPromptWindows();
|
|
115
169
|
}
|
|
116
|
-
} else if (ctx.isWsl) {
|
|
117
|
-
dockerInstallPromptWindows();
|
|
118
170
|
} else {
|
|
119
171
|
const result = await dockerInstallPromptMacOS(task);
|
|
120
172
|
if (result) {
|
|
121
173
|
return result;
|
|
122
174
|
}
|
|
123
175
|
}
|
|
176
|
+
} else if (os.platform() === 'linux') {
|
|
177
|
+
const { engine, desktop } = await getDockerEngineAndDesktopServiceStatus();
|
|
178
|
+
if (!engine.exists
|
|
179
|
+
&& desktop.exists
|
|
180
|
+
&& cmaGlobalConfig.get(USE_DOCKER_ENGINE_WITH_DOCKER_DESKTOP_ANSWER) !== false
|
|
181
|
+
) {
|
|
182
|
+
const confirmInstallingDockerEngine = await task.prompt({
|
|
183
|
+
type: 'Select',
|
|
184
|
+
message: `Looks like you have Docker Desktop installed on Linux system, but Docker Engine is not installed.
|
|
185
|
+
Do you want to install it and use it's context together with Docker Desktop?
|
|
186
|
+
`,
|
|
187
|
+
choices: [
|
|
188
|
+
{
|
|
189
|
+
name: 'yes',
|
|
190
|
+
message: 'Sure, if it means I will have less issues with my setup!'
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
name: 'no',
|
|
194
|
+
message: 'No. But you can ask me again later.'
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
name: 'skip',
|
|
198
|
+
message: 'No. And don\'t ask me again.'
|
|
199
|
+
}
|
|
200
|
+
]
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
if (confirmInstallingDockerEngine === 'skip') {
|
|
204
|
+
cmaGlobalConfig.set(USE_DOCKER_ENGINE_WITH_DOCKER_DESKTOP_ANSWER, false);
|
|
205
|
+
} else if (confirmInstallingDockerEngine === 'yes') {
|
|
206
|
+
const result = await dockerInstallPromptLinux(task, {
|
|
207
|
+
skipPrompt: true
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
if (result) {
|
|
211
|
+
return result;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
124
215
|
}
|
|
125
216
|
|
|
126
217
|
return task.newListr([
|
|
127
218
|
checkDockerSocketPermissions(),
|
|
128
219
|
checkDockerStatus(),
|
|
129
220
|
getDockerVersion(),
|
|
221
|
+
checkDockerDesktopContext(),
|
|
130
222
|
setVersionInContextTask(task)
|
|
131
223
|
]);
|
|
132
224
|
}
|
|
@@ -17,8 +17,8 @@ const postInstallSteps = [
|
|
|
17
17
|
/**
|
|
18
18
|
* @type {() => import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
|
|
19
19
|
*/
|
|
20
|
-
const
|
|
21
|
-
title: 'Installing Docker',
|
|
20
|
+
const installDockerEngine = () => ({
|
|
21
|
+
title: 'Installing Docker Engine',
|
|
22
22
|
task: async (ctx, task) => {
|
|
23
23
|
const distro = await osPlatform();
|
|
24
24
|
switch (distro) {
|
|
@@ -32,12 +32,21 @@ const installDocker = () => ({
|
|
|
32
32
|
...postInstallSteps
|
|
33
33
|
]);
|
|
34
34
|
}
|
|
35
|
-
case 'Fedora':
|
|
35
|
+
case 'Fedora': {
|
|
36
|
+
return task.newListr([
|
|
37
|
+
executeSudoCommand('sudo dnf -y install dnf-plugins-core'),
|
|
38
|
+
executeSudoCommand('sudo dnf config-manager --add-repo https://download.docker.com/linux/fedora/docker-ce.repo'),
|
|
39
|
+
executeSudoCommand('sudo dnf -y install docker-ce docker-ce-cli containerd.io docker-compose-plugin'),
|
|
40
|
+
enableAndStartDockerCommand(),
|
|
41
|
+
...postInstallSteps
|
|
42
|
+
]);
|
|
43
|
+
}
|
|
36
44
|
case 'CentOS': {
|
|
37
45
|
return task.newListr([
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
46
|
+
executeSudoCommand('sudo yum install -y yum-utils'),
|
|
47
|
+
executeSudoCommand('sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo'),
|
|
48
|
+
executeSudoCommand('sudo yum install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin'),
|
|
49
|
+
...postInstallSteps
|
|
41
50
|
]);
|
|
42
51
|
}
|
|
43
52
|
case 'Ubuntu': {
|
|
@@ -53,7 +62,12 @@ const installDocker = () => ({
|
|
|
53
62
|
Your distro ${distro} is not supported by automatic installation.`);
|
|
54
63
|
}
|
|
55
64
|
}
|
|
65
|
+
},
|
|
66
|
+
options: {
|
|
67
|
+
bottomBar: 10
|
|
56
68
|
}
|
|
57
69
|
});
|
|
58
70
|
|
|
59
|
-
module.exports =
|
|
71
|
+
module.exports = {
|
|
72
|
+
installDockerEngine
|
|
73
|
+
};
|
|
@@ -2,7 +2,7 @@ const os = require('os');
|
|
|
2
2
|
const fs = require('fs');
|
|
3
3
|
const logger = require('@scandipwa/scandipwa-dev-utils/logger');
|
|
4
4
|
const pathExists = require('../../../util/path-exists');
|
|
5
|
-
const
|
|
5
|
+
const executeSudoCommand = require('../../../util/execute-sudo-command');
|
|
6
6
|
|
|
7
7
|
const dockerSocketPath = '/var/run/docker.sock';
|
|
8
8
|
|
|
@@ -33,16 +33,7 @@ Otherwise installation will likely fail.`
|
|
|
33
33
|
});
|
|
34
34
|
|
|
35
35
|
if (confirmPrompt) {
|
|
36
|
-
task.
|
|
37
|
-
task.output = logger.style.command(`>[sudo] password for ${ os.userInfo().username }:`);
|
|
38
|
-
return task.newListr(
|
|
39
|
-
execCommandTask(fixCommand, {
|
|
40
|
-
callback: (t) => {
|
|
41
|
-
task.output = t;
|
|
42
|
-
},
|
|
43
|
-
pipeInput: true
|
|
44
|
-
})
|
|
45
|
-
);
|
|
36
|
+
return task.newListr(executeSudoCommand(fixCommand));
|
|
46
37
|
}
|
|
47
38
|
task.skip(`Permission issue detected in ${ logger.style.file(dockerSocketPath) } but user decided not to fix it.`);
|
|
48
39
|
}
|
|
@@ -10,6 +10,41 @@ const getDockerVersion = () => execAsyncSpawn('docker version --format {{.Server
|
|
|
10
10
|
withCode: true
|
|
11
11
|
});
|
|
12
12
|
|
|
13
|
+
const getDockerEngineAndDesktopServiceStatus = async () => {
|
|
14
|
+
const dockerEngineService = systemctlControl('docker');
|
|
15
|
+
const dockerDesktopService = systemctlControl('docker-desktop', { user: true });
|
|
16
|
+
const [
|
|
17
|
+
dockerEngineServiceExists,
|
|
18
|
+
dockerDesktopServiceExists,
|
|
19
|
+
dockerEngineServiceIsRunning,
|
|
20
|
+
dockerDesktopServiceIsRunning,
|
|
21
|
+
dockerEngineServiceIsEnabled,
|
|
22
|
+
dockerDesktopServiceIsEnabled
|
|
23
|
+
] = await Promise.all([
|
|
24
|
+
dockerEngineService.exists(),
|
|
25
|
+
dockerDesktopService.exists(),
|
|
26
|
+
dockerEngineService.isRunning(),
|
|
27
|
+
dockerDesktopService.isRunning(),
|
|
28
|
+
dockerEngineService.isEnabled(),
|
|
29
|
+
dockerDesktopService.isEnabled()
|
|
30
|
+
]);
|
|
31
|
+
|
|
32
|
+
return {
|
|
33
|
+
engine: {
|
|
34
|
+
service: dockerEngineService,
|
|
35
|
+
exists: dockerEngineServiceExists,
|
|
36
|
+
isRunning: dockerEngineServiceIsRunning,
|
|
37
|
+
isEnabled: dockerEngineServiceIsEnabled
|
|
38
|
+
},
|
|
39
|
+
desktop: {
|
|
40
|
+
service: dockerDesktopService,
|
|
41
|
+
exists: dockerDesktopServiceExists,
|
|
42
|
+
isRunning: dockerDesktopServiceIsRunning,
|
|
43
|
+
isEnabled: dockerDesktopServiceIsEnabled
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
|
|
13
48
|
/**
|
|
14
49
|
* @type {() => import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
|
|
15
50
|
*/
|
|
@@ -81,39 +116,71 @@ Please open Docker Desktop application for Windows and make sure that Docker is
|
|
|
81
116
|
const checkDockerStatusLinux = () => ({
|
|
82
117
|
title: 'Checking Docker status on Linux',
|
|
83
118
|
task: async (ctx, task) => {
|
|
84
|
-
const
|
|
119
|
+
const {
|
|
120
|
+
engine,
|
|
121
|
+
desktop
|
|
122
|
+
} = await getDockerEngineAndDesktopServiceStatus();
|
|
123
|
+
|
|
124
|
+
if (engine.exists) {
|
|
125
|
+
if (!engine.isEnabled && !engine.isRunning) {
|
|
126
|
+
const dockerStartConfirmation = await task.prompt({
|
|
127
|
+
type: 'Confirm',
|
|
128
|
+
message: `Looks like Docker Engine is not enabled and not running, would you like to enable and run it?
|
|
85
129
|
|
|
86
|
-
|
|
87
|
-
|
|
130
|
+
This action requires root privileges.`
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
if (dockerStartConfirmation) {
|
|
134
|
+
await engine.service.enableAndStart();
|
|
88
135
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
task.skip('User skipped running Docker');
|
|
139
|
+
} else if (!engine.isRunning) {
|
|
140
|
+
const dockerStartConfirmation = await task.prompt({
|
|
141
|
+
type: 'Confirm',
|
|
142
|
+
message: `Looks like Docker Engine is not running, would you like to run it?
|
|
93
143
|
|
|
94
|
-
This action requires root privileges.`
|
|
95
|
-
|
|
144
|
+
This action requires root privileges.`
|
|
145
|
+
});
|
|
96
146
|
|
|
97
|
-
|
|
98
|
-
|
|
147
|
+
if (dockerStartConfirmation) {
|
|
148
|
+
await engine.service.start();
|
|
99
149
|
|
|
100
|
-
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
task.skip('User skipped running Docker Engine');
|
|
101
153
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
154
|
+
} else if (desktop.exists) {
|
|
155
|
+
if (!desktop.isEnabled && !desktop.isRunning) {
|
|
156
|
+
const dockerStartConfirmation = await task.prompt({
|
|
157
|
+
type: 'Confirm',
|
|
158
|
+
message: `Looks like Docker Desktop is not enabled and not running, would you like to enable and run it?
|
|
159
|
+
|
|
160
|
+
This action requires root privileges.`
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
if (dockerStartConfirmation) {
|
|
164
|
+
await desktop.service.enableAndStart();
|
|
165
|
+
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
task.skip('User skipped running Docker');
|
|
169
|
+
} else if (!desktop.isRunning) {
|
|
170
|
+
const dockerStartConfirmation = await task.prompt({
|
|
171
|
+
type: 'Confirm',
|
|
172
|
+
message: `Looks like Docker Desktop is not running, would you like to run it?
|
|
107
173
|
|
|
108
|
-
This action requires root privileges.`
|
|
109
|
-
|
|
174
|
+
This action requires root privileges.`
|
|
175
|
+
});
|
|
110
176
|
|
|
111
|
-
|
|
112
|
-
|
|
177
|
+
if (dockerStartConfirmation) {
|
|
178
|
+
await desktop.service.start();
|
|
113
179
|
|
|
114
|
-
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
task.skip('User skipped running Docker Desktop');
|
|
115
183
|
}
|
|
116
|
-
task.skip('User skipped running Docker');
|
|
117
184
|
}
|
|
118
185
|
}
|
|
119
186
|
});
|
|
@@ -135,4 +202,7 @@ const checkDockerStatus = () => ({
|
|
|
135
202
|
}
|
|
136
203
|
});
|
|
137
204
|
|
|
138
|
-
module.exports =
|
|
205
|
+
module.exports = {
|
|
206
|
+
checkDockerStatus,
|
|
207
|
+
getDockerEngineAndDesktopServiceStatus
|
|
208
|
+
};
|
|
@@ -14,6 +14,7 @@ const getDockerVersion = () => ({
|
|
|
14
14
|
ctx.dockerServerData = dockerVersion.Server;
|
|
15
15
|
ctx.dockerClientData = dockerVersion.Client;
|
|
16
16
|
ctx.dockerVersion = dockerVersion.Server.Version;
|
|
17
|
+
ctx.isDockerDesktop = dockerVersion.Server.Platform.Name.includes('Desktop');
|
|
17
18
|
} else {
|
|
18
19
|
throw new UnknownError(`Got unexpected result during Docker version retrieval!\n\n${ dockerVersion }`);
|
|
19
20
|
}
|
|
@@ -7,8 +7,10 @@ const { runContainerImage } = require('../../util/run-container-image');
|
|
|
7
7
|
const checkPHPVersion = () => ({
|
|
8
8
|
title: 'Checking container PHP version',
|
|
9
9
|
task: async (ctx, task) => {
|
|
10
|
-
const
|
|
11
|
-
|
|
10
|
+
const phpVersionResponse = await runContainerImage(
|
|
11
|
+
ctx.config.overridenConfiguration.configuration.php.baseImage,
|
|
12
|
+
'php --version'
|
|
13
|
+
);
|
|
12
14
|
|
|
13
15
|
const phpVersionResponseResult = phpVersionResponse.match(/PHP\s(\d+\.\d+\.\d+)/i);
|
|
14
16
|
|
package/lib/tasks/start.js
CHANGED
|
@@ -11,7 +11,6 @@ const { prepareFileSystem } = require('./file-system');
|
|
|
11
11
|
const { installMagentoProject, setupMagento } = require('./magento');
|
|
12
12
|
const { pullImages, stopContainers } = require('./docker/containers');
|
|
13
13
|
const dockerNetwork = require('./docker/network');
|
|
14
|
-
const { setPrefix } = require('./prefix');
|
|
15
14
|
const { connectToDatabase } = require('./database');
|
|
16
15
|
const { buildProjectImage, buildDebugProjectImage } = require('./docker/project-image-builder');
|
|
17
16
|
const getProjectConfiguration = require('../config/get-project-configuration');
|
|
@@ -28,6 +27,19 @@ const waitingForVarnish = require('./magento/setup-magento/waiting-for-varnish')
|
|
|
28
27
|
const checkPHPVersion = require('./requirements/php-version');
|
|
29
28
|
const volumes = require('./docker/volume/tasks');
|
|
30
29
|
const convertMySQLDatabaseToMariaDB = require('./docker/convert-mysql-to-mariadb');
|
|
30
|
+
const { cmaGlobalConfig } = require('../config/cma-config');
|
|
31
|
+
const { setProjectConfigTask } = require('./project-config');
|
|
32
|
+
const { convertComposerHomeToComposerCacheVolume } = require('./docker/convert-composer-home-to-composer-cache-volume');
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* @type {() => import('listr2').ListrTask<import('../../typings/context').ListrContext>}
|
|
36
|
+
*/
|
|
37
|
+
const resetCmaGlobalConfig = () => ({
|
|
38
|
+
skip: (ctx) => !ctx.resetGlobalConfig,
|
|
39
|
+
task: () => {
|
|
40
|
+
cmaGlobalConfig.clear();
|
|
41
|
+
}
|
|
42
|
+
});
|
|
31
43
|
|
|
32
44
|
/**
|
|
33
45
|
* @type {() => import('listr2').ListrTask<import('../../typings/context').ListrContext>}
|
|
@@ -39,7 +51,6 @@ const retrieveProjectConfiguration = () => ({
|
|
|
39
51
|
checkConfigurationFile(),
|
|
40
52
|
getProjectConfiguration(),
|
|
41
53
|
convertLegacyVolumes(),
|
|
42
|
-
convertMySQLDatabaseToMariaDB(),
|
|
43
54
|
createCacheFolder(),
|
|
44
55
|
getSystemConfigTask(),
|
|
45
56
|
getCachedPorts()
|
|
@@ -59,7 +70,8 @@ const retrieveProjectConfiguration = () => ({
|
|
|
59
70
|
const stopProject = () => ({
|
|
60
71
|
title: 'Stopping project',
|
|
61
72
|
task: (ctx, task) => task.newListr([
|
|
62
|
-
stopContainers()
|
|
73
|
+
stopContainers(),
|
|
74
|
+
volumes.removeLocalVolumes()
|
|
63
75
|
]),
|
|
64
76
|
options: {
|
|
65
77
|
showTimer: false
|
|
@@ -72,7 +84,7 @@ const stopProject = () => ({
|
|
|
72
84
|
const retrieveFreshProjectConfiguration = () => ({
|
|
73
85
|
title: 'Retrieving fresh project configuration',
|
|
74
86
|
task: (ctx, task) => task.newListr([
|
|
75
|
-
|
|
87
|
+
setProjectConfigTask(),
|
|
76
88
|
getProjectConfiguration(),
|
|
77
89
|
// get fresh ports
|
|
78
90
|
getAvailablePorts(),
|
|
@@ -93,9 +105,14 @@ const retrieveFreshProjectConfiguration = () => ({
|
|
|
93
105
|
const configureProject = () => ({
|
|
94
106
|
title: 'Configuring project',
|
|
95
107
|
task: (ctx, task) => task.newListr([
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
108
|
+
convertMySQLDatabaseToMariaDB(),
|
|
109
|
+
{
|
|
110
|
+
task: (ctx, task) => task.newListr([
|
|
111
|
+
pullImages(),
|
|
112
|
+
dockerNetwork.tasks.createNetwork()
|
|
113
|
+
], { concurrent: true })
|
|
114
|
+
},
|
|
115
|
+
checkPHPVersion(),
|
|
99
116
|
{
|
|
100
117
|
task: (ctx, task) => task.newListr([
|
|
101
118
|
buildProjectImage(),
|
|
@@ -104,9 +121,10 @@ const configureProject = () => ({
|
|
|
104
121
|
concurrent: true
|
|
105
122
|
})
|
|
106
123
|
},
|
|
107
|
-
checkPHPVersion(),
|
|
108
124
|
getComposerVersionTask(),
|
|
109
125
|
prepareFileSystem(),
|
|
126
|
+
volumes.createVolumes(),
|
|
127
|
+
convertComposerHomeToComposerCacheVolume(),
|
|
110
128
|
installMagentoProject(),
|
|
111
129
|
enableMagentoComposerPlugins(),
|
|
112
130
|
startServices(),
|
|
@@ -138,6 +156,7 @@ const start = () => ({
|
|
|
138
156
|
task: (ctx, task) => {
|
|
139
157
|
task.title = `Starting project (magento-scripts@${pkg.version})`;
|
|
140
158
|
return task.newListr([
|
|
159
|
+
resetCmaGlobalConfig(),
|
|
141
160
|
checkRequirements(),
|
|
142
161
|
retrieveProjectConfiguration(),
|
|
143
162
|
stopProject(),
|