@scandipwa/magento-scripts 1.16.1 → 2.0.0-alpha.10
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 +4 -6
- package/lib/commands/execute.js +3 -33
- package/lib/commands/import-db.js +1 -1
- package/lib/commands/logs.js +1 -1
- package/lib/commands/start.js +38 -20
- package/lib/commands/status.js +2 -0
- package/lib/config/docker.js +103 -85
- package/lib/config/get-project-configuration.js +3 -1
- package/lib/config/index.js +10 -7
- package/lib/config/magento/required-php-extensions/index.js +29 -0
- package/lib/config/magento/required-php-extensions/magento-2.3.js +19 -0
- package/lib/config/magento/required-php-extensions/magento-2.4.js +29 -0
- package/lib/config/php/base-repo.js +3 -0
- package/lib/config/php/extensions/apcu.js +12 -0
- package/lib/config/php/extensions/bcmath.js +7 -0
- package/lib/config/php/extensions/curl.js +11 -0
- package/lib/config/php/extensions/gd.js +14 -0
- package/lib/config/php/extensions/index.js +18 -2
- package/lib/config/php/extensions/intl.js +10 -0
- package/lib/config/php/extensions/opcache.js +10 -0
- package/lib/config/php/extensions/pdo_mysql.js +7 -0
- package/lib/config/php/extensions/soap.js +10 -0
- package/lib/config/php/extensions/sodium.js +10 -0
- package/lib/config/php/extensions/xdebug.js +8 -5
- package/lib/config/php/extensions/xsl.js +10 -0
- package/lib/config/php/extensions/zip.js +10 -0
- package/lib/config/php/{releases → versions}/index.js +0 -0
- package/lib/config/php/versions/php-7.2.js +23 -0
- package/lib/config/php/versions/php-7.3.js +23 -0
- package/lib/config/php/versions/php-7.4.js +23 -0
- package/lib/config/php/versions/php-8.1.js +23 -0
- package/lib/config/php-config.js +8 -12
- package/lib/config/port-config.js +2 -6
- 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/templates/magentorc.template +6 -6
- package/lib/config/templates/mariadb.template.cnf +191 -0
- package/lib/config/templates/php-fpm.template.conf +3 -3
- package/lib/config/templates/php.template.ini +12 -6
- package/lib/config/templates/ssl-terminator.template.conf +9 -4
- package/lib/config/templates/vscode-launch.template.json +3 -1
- package/lib/config/versions/magento-2.3.0.js +10 -5
- package/lib/config/versions/magento-2.3.1.js +10 -5
- package/lib/config/versions/magento-2.3.2-p1.js +43 -0
- package/lib/config/versions/magento-2.3.2-p2.js +10 -5
- package/lib/config/versions/magento-2.3.2.js +10 -5
- package/lib/config/versions/magento-2.3.3-p1.js +10 -5
- package/lib/config/versions/magento-2.3.3.js +10 -5
- package/lib/config/versions/magento-2.3.4-p1.js +43 -0
- package/lib/config/versions/magento-2.3.4-p2.js +10 -5
- package/lib/config/versions/magento-2.3.4.js +10 -5
- package/lib/config/versions/magento-2.3.5-p1.js +8 -2
- package/lib/config/versions/magento-2.3.5-p2.js +8 -2
- package/lib/config/versions/magento-2.3.5.js +8 -2
- package/lib/config/versions/magento-2.3.6-p1.js +8 -2
- package/lib/config/versions/magento-2.3.6.js +8 -2
- package/lib/config/versions/magento-2.3.7-p1.js +8 -2
- package/lib/config/versions/magento-2.3.7-p2.js +8 -2
- package/lib/config/versions/magento-2.3.7-p3.js +8 -2
- package/lib/config/versions/magento-2.3.7-p4.js +44 -0
- package/lib/config/versions/magento-2.3.7.js +8 -2
- package/lib/config/versions/magento-2.4.0-p1.js +9 -3
- package/lib/config/versions/magento-2.4.0.js +9 -3
- package/lib/config/versions/magento-2.4.1-p1.js +6 -5
- package/lib/config/versions/magento-2.4.1.js +9 -2
- package/lib/config/versions/magento-2.4.2-p1.js +6 -5
- package/lib/config/versions/magento-2.4.2-p2.js +6 -6
- package/lib/config/versions/magento-2.4.2.js +6 -6
- package/lib/config/versions/magento-2.4.3-p1.js +7 -7
- package/lib/config/versions/magento-2.4.3-p2.js +7 -7
- package/lib/config/versions/magento-2.4.3-p3.js +46 -0
- package/lib/config/versions/magento-2.4.3.js +7 -7
- package/lib/config/versions/magento-2.4.4-p1.js +46 -0
- package/lib/config/versions/magento-2.4.4.js +9 -2
- package/lib/config/versions/magento-2.4.5.js +46 -0
- package/lib/tasks/cleanup.js +3 -3
- package/lib/tasks/composer/index.js +14 -104
- package/lib/tasks/database/connect-to-database.js +117 -0
- package/lib/tasks/database/create-magento-database.js +18 -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} +65 -22
- 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 +71 -0
- package/lib/tasks/docker/api.js +30 -0
- package/lib/tasks/docker/containers/container-api.d.ts +132 -0
- package/lib/tasks/docker/containers/container-api.js +163 -0
- package/lib/tasks/docker/containers/index.js +19 -0
- package/lib/tasks/docker/containers/tasks.js +215 -0
- package/lib/tasks/docker/convert-legacy-volumes.js +15 -10
- package/lib/tasks/docker/convert-mysql-to-mariadb.js +284 -0
- package/lib/tasks/docker/image/image-api.d.ts +34 -0
- package/lib/tasks/docker/image/image-api.js +49 -0
- package/lib/tasks/docker/image/index.js +5 -0
- package/lib/tasks/docker/index.js +1 -13
- package/lib/tasks/docker/network/index.js +7 -0
- package/lib/tasks/docker/network/network-api.d.ts +103 -0
- package/lib/tasks/docker/network/network-api.js +99 -0
- package/lib/tasks/docker/{network.js → network/tasks.js} +17 -10
- package/lib/tasks/docker/project-image-builder.js +167 -0
- package/lib/tasks/docker/volume/index.js +8 -0
- package/lib/tasks/docker/{volumes.js → volume/tasks.js} +5 -19
- package/lib/tasks/docker/volume/volume-api.d.ts +39 -0
- package/lib/tasks/docker/volume/volume-api.js +66 -0
- package/lib/tasks/execute.js +97 -0
- package/lib/tasks/file-system/create-mariadb-config.js +23 -0
- package/lib/tasks/file-system/create-nginx-config.js +2 -3
- package/lib/tasks/file-system/create-php-config.js +20 -5
- package/lib/tasks/file-system/create-php-fpm-config.js +8 -4
- package/lib/tasks/file-system/create-phpstorm-config/exclude-folder-config.js +41 -29
- package/lib/tasks/file-system/create-phpstorm-config/index.js +2 -0
- package/lib/tasks/file-system/create-phpstorm-config/keys.js +15 -1
- package/lib/tasks/file-system/create-phpstorm-config/php-config/index.js +4 -1
- package/lib/tasks/file-system/create-phpstorm-config/php-config/php-config.js +3 -3
- package/lib/tasks/file-system/create-phpstorm-config/php-config/php-interpreters-config.js +81 -0
- package/lib/tasks/file-system/create-phpstorm-config/php-docker-settings-config/index.js +42 -0
- package/lib/tasks/file-system/create-phpstorm-config/php-docker-settings-config/php-docker-settings-config.js +9 -0
- package/lib/tasks/file-system/create-phpstorm-config/php-docker-settings-config/setup-php-docker-container-settings-config.js +66 -0
- package/lib/tasks/file-system/create-phpstorm-config/setup-xml-structure.js +11 -9
- package/lib/tasks/file-system/create-phpstorm-config/stylelint-config.js +2 -1
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/composer-settings-config.js +15 -30
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/index.js +24 -5
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/mess-detector-project-configuration-config.js +50 -0
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/php-code-sniffer-project-configuration-config.js +50 -0
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/php-cs-fixer-project-configuration-config.js +50 -0
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/php-debug-general-config.js +15 -15
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/php-server-config.js +29 -3
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/php-stan-project-configuration-config.js.js +50 -0
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/php-workspace-project-configuration-config.js +42 -0
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/psalm-project-configuration-config.js.js +50 -0
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/workspace-config.js +0 -2
- package/lib/tasks/file-system/create-ssl-terminator-config.js +4 -2
- package/lib/tasks/file-system/create-vscode-config.js +57 -42
- package/lib/tasks/file-system/index.js +5 -2
- package/lib/tasks/import-dump.js +6 -6
- package/lib/tasks/link.js +5 -4
- package/lib/tasks/magento/enable-magento-composer-plugins.js +85 -30
- package/lib/tasks/magento/install-magento-project.js +32 -63
- package/lib/tasks/magento/setup-magento/adjust-full-page-cache.js +4 -4
- package/lib/tasks/magento/setup-magento/configure-elasticsearch.js +7 -3
- package/lib/tasks/magento/setup-magento/create-admin.js +5 -6
- 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/disable-2fa.js +3 -5
- package/lib/tasks/magento/setup-magento/disable-maintenance-mode.js +3 -4
- 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 +21 -20
- package/lib/tasks/magento/setup-magento/migrate-database.js +7 -14
- package/lib/tasks/magento/setup-magento/set-base-url.js +3 -3
- package/lib/tasks/magento/setup-magento/set-deployment-mode.js +4 -4
- package/lib/tasks/magento/setup-magento/set-url-rewrite.js +2 -2
- package/lib/tasks/magento/setup-magento/varnish-config.js +10 -8
- package/lib/tasks/magento/setup-magento/waiting-for-varnish.js +130 -3
- package/lib/tasks/php/php-container.js +112 -0
- package/lib/tasks/php/update-env-php.js +39 -21
- package/lib/tasks/php/update-env.php +66 -61
- package/lib/tasks/php/working_health_check.php +85 -0
- package/lib/tasks/requirements/{composer.js → composer-credentials.js} +3 -1
- package/lib/tasks/requirements/docker/index.js +18 -13
- package/lib/tasks/requirements/docker/performance.js +54 -0
- package/lib/tasks/requirements/docker/version.js +8 -8
- package/lib/tasks/requirements/index.js +5 -8
- package/lib/tasks/requirements/php-version.js +8 -116
- package/lib/tasks/requirements/platform.js +12 -25
- package/lib/tasks/start.js +21 -50
- package/lib/tasks/status/index.js +8 -12
- package/lib/tasks/stop.js +0 -2
- package/lib/tasks/theme/install-theme.js +1 -1
- package/lib/tasks/theme/link-theme.js +2 -2
- package/lib/tasks/theme/symlink-theme.js +2 -3
- package/lib/util/config-file-validator.js +27 -13
- package/lib/util/config-php-json.js +13 -4
- package/lib/util/database.js +7 -7
- package/lib/util/dockerfile-builder/build-instructions.js +197 -0
- package/lib/util/dockerfile-builder/index.js +276 -0
- package/lib/util/dockerfile-builder/types.d.ts +123 -0
- package/lib/util/env-php-json.js +10 -6
- package/lib/util/exec-async-command.js +3 -9
- package/lib/util/execute-in-container.js +63 -0
- package/lib/util/macos-version.js +20 -0
- package/lib/util/magento-task.js +3 -4
- package/lib/util/nginx-logs-parser.js +122 -0
- package/lib/util/php-task.js +3 -6
- package/lib/util/run-composer.js +6 -14
- package/lib/util/run-container-image.js +17 -0
- package/lib/util/run-magento.js +6 -14
- package/lib/util/run-php.js +6 -17
- package/package.json +11 -10
- package/typings/context.d.ts +7 -13
- package/typings/index.d.ts +67 -85
- package/lib/config/composer.js +0 -11
- package/lib/config/php/extensions/libsodium.js +0 -36
- package/lib/config/php/releases/php-7.2.js +0 -25
- package/lib/config/php/releases/php-7.3.js +0 -25
- package/lib/config/php/releases/php-7.4.js +0 -23
- package/lib/config/php/releases/php-8.1.js +0 -25
- package/lib/config/phpbrew.js +0 -12
- package/lib/tasks/composer/install-prestissimo.js +0 -103
- package/lib/tasks/docker/containers.js +0 -231
- package/lib/tasks/execute/index.js +0 -23
- package/lib/tasks/mysql/connect-to-mysql.js +0 -114
- package/lib/tasks/mysql/create-magento-database.js +0 -18
- package/lib/tasks/php/bundled-extensions.js +0 -27
- package/lib/tasks/php/compile-options.js +0 -56
- package/lib/tasks/php/compile.js +0 -55
- package/lib/tasks/php/configure.js +0 -89
- package/lib/tasks/php/extensions/disable.js +0 -49
- package/lib/tasks/php/extensions/enable.js +0 -52
- package/lib/tasks/php/extensions/index.js +0 -80
- package/lib/tasks/php/extensions/install.js +0 -54
- package/lib/tasks/php/index.js +0 -79
- package/lib/tasks/php/install-sodium.js +0 -93
- package/lib/tasks/php/update-phpbrew.js +0 -45
- package/lib/tasks/php/validate-php.js +0 -67
- package/lib/tasks/php-fpm/get-process-id.js +0 -14
- package/lib/tasks/php-fpm/index.js +0 -4
- package/lib/tasks/php-fpm/start-php-fpm.js +0 -49
- package/lib/tasks/php-fpm/stop-php-fpm.js +0 -48
- package/lib/tasks/requirements/phpbrew/index.js +0 -61
- package/lib/tasks/requirements/phpbrew/install.js +0 -159
- package/lib/tasks/requirements/phpbrew/version.js +0 -28
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
/* eslint-disable no-param-reassign */
|
|
1
2
|
/* eslint-disable max-len */
|
|
2
3
|
const { stopServices } = require('./index');
|
|
3
4
|
const { getBaseConfig, getConfigFromMagentoVersion } = require('../../config');
|
|
4
5
|
const getDockerConfig = require('../../config/docker');
|
|
5
6
|
const { execAsyncSpawn } = require('../../util/exec-async-command');
|
|
6
7
|
const { folderName, legacyFolderName } = require('../../util/prefix');
|
|
7
|
-
const {
|
|
8
|
+
const { volumeApi } = require('./volume');
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* @type {() => import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
|
|
@@ -12,24 +13,28 @@ const { createVolume } = require('./volumes');
|
|
|
12
13
|
const convertLegacyVolumes = () => ({
|
|
13
14
|
task: async (ctx, task) => {
|
|
14
15
|
const { config: { overridenConfiguration } } = ctx;
|
|
15
|
-
const newDockerConfig = await getDockerConfig(overridenConfiguration, getBaseConfig(process.cwd(), folderName));
|
|
16
|
+
const newDockerConfig = await getDockerConfig(ctx, overridenConfiguration, getBaseConfig(process.cwd(), folderName));
|
|
16
17
|
|
|
17
|
-
const newVolumeNames = Object.values(newDockerConfig.volumes).filter((v) => !v.
|
|
18
|
+
const newVolumeNames = Object.values(newDockerConfig.volumes).filter((v) => !v.opt).map(({ name }) => name);
|
|
18
19
|
|
|
19
|
-
const existingVolumes =
|
|
20
|
+
const existingVolumes = await volumeApi.ls({ formatToJSON: true });
|
|
20
21
|
|
|
21
22
|
if (newVolumeNames.every((v) => existingVolumes.includes(v))) {
|
|
22
23
|
return;
|
|
23
24
|
}
|
|
24
25
|
|
|
25
|
-
const legacyDockerConfig = await getDockerConfig(overridenConfiguration, getBaseConfig(process.cwd(), legacyFolderName));
|
|
26
|
-
const legacyVolumeNames = Object.values(legacyDockerConfig.volumes).filter((v) => !v.
|
|
26
|
+
const legacyDockerConfig = await getDockerConfig(ctx, overridenConfiguration, getBaseConfig(process.cwd(), legacyFolderName));
|
|
27
|
+
const legacyVolumeNames = Object.values(legacyDockerConfig.volumes).filter((v) => !v.opt).map(({ name }) => name);
|
|
27
28
|
|
|
28
29
|
if (
|
|
29
|
-
newVolumeNames.every((name) => !existingVolumes.
|
|
30
|
-
&& legacyVolumeNames.every((name) => existingVolumes.
|
|
30
|
+
newVolumeNames.every((name) => !existingVolumes.some((v) => v.Name === name))
|
|
31
|
+
&& legacyVolumeNames.every((name) => existingVolumes.some((v) => v.Name === name))
|
|
31
32
|
) {
|
|
32
|
-
ctx.config = await getConfigFromMagentoVersion(ctx
|
|
33
|
+
ctx.config = await getConfigFromMagentoVersion(ctx, {
|
|
34
|
+
magentoVersion: ctx.magentoVersion,
|
|
35
|
+
projectPath: process.cwd(),
|
|
36
|
+
prefix: legacyFolderName
|
|
37
|
+
});
|
|
33
38
|
|
|
34
39
|
return task.newListr([
|
|
35
40
|
stopServices(),
|
|
@@ -42,7 +47,7 @@ const convertLegacyVolumes = () => ({
|
|
|
42
47
|
const legacyVolumeConfig = legacyDockerConfig.volumes[volumeName];
|
|
43
48
|
|
|
44
49
|
subTask.output = `Creating volume ${volumeConfig.name}...`;
|
|
45
|
-
await
|
|
50
|
+
await volumeApi.create(volumeConfig);
|
|
46
51
|
subTask.output = `Copying data from ${legacyVolumeConfig.name} to ${volumeConfig.name}...`;
|
|
47
52
|
await execAsyncSpawn(
|
|
48
53
|
`docker run --rm -v ${legacyVolumeConfig.name}:/from:ro -v ${volumeConfig.name}:/to alpine ash -c "cd /from; cp -av . /to"`, {
|
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
const fs = require('fs');
|
|
3
|
+
const logger = require('@scandipwa/scandipwa-dev-utils/logger');
|
|
4
|
+
const { volumeApi, createVolumes } = require('./volume');
|
|
5
|
+
const { execAsyncSpawn } = require('../../util/exec-async-command');
|
|
6
|
+
const { containerApi, stopContainers, pullImages } = require('./containers');
|
|
7
|
+
const { importDumpToDatabase, connectToDatabase } = require('../database');
|
|
8
|
+
const { setPrefix } = require('../prefix');
|
|
9
|
+
const getProjectConfiguration = require('../../config/get-project-configuration');
|
|
10
|
+
const { getAvailablePorts, getCachedPorts } = require('../../config/get-port-config');
|
|
11
|
+
const { saveConfiguration } = require('../../config/save-config');
|
|
12
|
+
const { buildProjectImage, buildDebugProjectImage } = require('./project-image-builder');
|
|
13
|
+
const checkPHPVersion = require('../requirements/php-version');
|
|
14
|
+
const { getComposerVersionTask } = require('../composer');
|
|
15
|
+
const { prepareFileSystem } = require('../file-system');
|
|
16
|
+
const { installMagentoProject } = require('../magento');
|
|
17
|
+
const enableMagentoComposerPlugins = require('../magento/enable-magento-composer-plugins');
|
|
18
|
+
const { startServices } = require('./index');
|
|
19
|
+
const dockerNetwork = require('./network');
|
|
20
|
+
const KnownError = require('../../errors/known-error');
|
|
21
|
+
const { createCacheFolder } = require('../cache');
|
|
22
|
+
const { getSystemConfigTask } = require('../../config/system-config');
|
|
23
|
+
const sleep = require('../../util/sleep');
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* @type {() => import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
|
|
27
|
+
*/
|
|
28
|
+
const convertMySQLDatabaseToMariaDB = () => ({
|
|
29
|
+
task: async (ctx, task) => {
|
|
30
|
+
const mysqlVolumeName = `${ ctx.config.baseConfig.prefix }_mysql-data`;
|
|
31
|
+
const volumes = await volumeApi.ls({ formatToJSON: true });
|
|
32
|
+
if (ctx.isArmMac) {
|
|
33
|
+
if (volumes.some(
|
|
34
|
+
(volume) => volume.Name === mysqlVolumeName
|
|
35
|
+
) && !volumes.some(
|
|
36
|
+
(volume) => volume.Name === ctx.config.docker.volumes.mariadb.name
|
|
37
|
+
)
|
|
38
|
+
) {
|
|
39
|
+
task.title = 'Converting MySQL database to MariaDB';
|
|
40
|
+
return task.newListr([
|
|
41
|
+
stopContainers(),
|
|
42
|
+
{
|
|
43
|
+
title: 'Converting MySQL volume to MariaDB',
|
|
44
|
+
task: async (subCtx, subTask) => {
|
|
45
|
+
subTask.output = `Creating volume ${subCtx.config.docker.volumes.mariadb.name}...`;
|
|
46
|
+
await volumeApi.create(subCtx.config.docker.volumes.mariadb);
|
|
47
|
+
subTask.output = `Copying data from ${mysqlVolumeName} to ${subCtx.config.docker.volumes.mariadb.name}...`;
|
|
48
|
+
await execAsyncSpawn(
|
|
49
|
+
// eslint-disable-next-line max-len
|
|
50
|
+
`docker run --rm -v ${mysqlVolumeName}:/from:ro -v ${subCtx.config.docker.volumes.mariadb.name}:/to alpine ash -c "cd /from; cp -av . /to"`, {
|
|
51
|
+
callback: (t) => {
|
|
52
|
+
subTask.output = t;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
);
|
|
56
|
+
subTask.output = 'Deleting old volume...';
|
|
57
|
+
await execAsyncSpawn(`docker volume rm ${mysqlVolumeName}`);
|
|
58
|
+
},
|
|
59
|
+
options: {
|
|
60
|
+
bottomBar: 10
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
]);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (volumes.some(
|
|
70
|
+
(volume) => volume.Name === mysqlVolumeName
|
|
71
|
+
) && !volumes.some(
|
|
72
|
+
(volume) => volume.Name === ctx.config.docker.volumes.mariadb.name
|
|
73
|
+
)
|
|
74
|
+
) {
|
|
75
|
+
task.title = 'Converting MySQL database to MariaDB';
|
|
76
|
+
const confirmConvert = await task.prompt({
|
|
77
|
+
type: 'Select',
|
|
78
|
+
message: `We see that you have old mysql-data volume in the project!
|
|
79
|
+
Since ${logger.style.code('magento-scripts@2.0.0')} ${logger.style.misc('MariaDB')} is used as database instead of MySQL.
|
|
80
|
+
|
|
81
|
+
To use MariaDB with data from MySQL we need to convert your database.
|
|
82
|
+
`,
|
|
83
|
+
choices: [
|
|
84
|
+
{
|
|
85
|
+
name: 'yes',
|
|
86
|
+
message: 'Okay, let\'s do that!'
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
name: 'no',
|
|
90
|
+
message: 'ABORT ABORT ABORT'
|
|
91
|
+
}
|
|
92
|
+
]
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
if (confirmConvert === 'yes') {
|
|
96
|
+
const pathToMySQLDumpFile = path.join(process.cwd(), 'mysql-database.sql');
|
|
97
|
+
const containerName = 'mysql-database';
|
|
98
|
+
task.output = 'Creating dump file from MySQL database...';
|
|
99
|
+
|
|
100
|
+
const existingContainers = await containerApi.ls({ formatToJSON: true, all: true });
|
|
101
|
+
|
|
102
|
+
if (existingContainers.some((c) => c.Names === containerName)) {
|
|
103
|
+
await execAsyncSpawn(`docker container stop ${containerName}`);
|
|
104
|
+
await execAsyncSpawn(`docker container rm ${containerName}`);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
task.output = 'Starting MySQL server...';
|
|
108
|
+
|
|
109
|
+
await containerApi.run(
|
|
110
|
+
{
|
|
111
|
+
mounts: [
|
|
112
|
+
`source=${ mysqlVolumeName },target=/var/lib/mysql`
|
|
113
|
+
],
|
|
114
|
+
env: {
|
|
115
|
+
MYSQL_PORT: 3306,
|
|
116
|
+
MYSQL_ROOT_PASSWORD: 'scandipwa',
|
|
117
|
+
MYSQL_USER: 'magento',
|
|
118
|
+
MYSQL_PASSWORD: 'magento',
|
|
119
|
+
MYSQL_DATABASE: 'magento'
|
|
120
|
+
},
|
|
121
|
+
command: [
|
|
122
|
+
'--log_bin_trust_function_creators=1',
|
|
123
|
+
'--default-authentication-plugin=mysql_native_password',
|
|
124
|
+
'--max_allowed_packet=1GB',
|
|
125
|
+
'--bind-address=0.0.0.0'
|
|
126
|
+
]
|
|
127
|
+
.join(' '),
|
|
128
|
+
securityOptions: [
|
|
129
|
+
'seccomp=unconfined'
|
|
130
|
+
],
|
|
131
|
+
name: containerName,
|
|
132
|
+
image: `mysql:${ ctx.config.overridenConfiguration.configuration.mysql.version }`
|
|
133
|
+
}
|
|
134
|
+
);
|
|
135
|
+
|
|
136
|
+
task.output = 'Waiting for MySQL to initialize...';
|
|
137
|
+
|
|
138
|
+
let mysqlReadyForConnections = false;
|
|
139
|
+
|
|
140
|
+
while (!mysqlReadyForConnections) {
|
|
141
|
+
const mysqlOutput = await execAsyncSpawn(`docker logs ${containerName}`);
|
|
142
|
+
if (mysqlOutput.includes('ready for connections')) {
|
|
143
|
+
mysqlReadyForConnections = true;
|
|
144
|
+
task.output = 'MySQL is ready!';
|
|
145
|
+
break;
|
|
146
|
+
} else if (mysqlOutput.includes('Initializing database files')) {
|
|
147
|
+
task.output = `MySQL is initializing database files!
|
|
148
|
+
Please wait, this will take some time and do not restart the MySQL container until initialization is finished!`;
|
|
149
|
+
|
|
150
|
+
let mysqlFinishedInitialization = false;
|
|
151
|
+
while (!mysqlFinishedInitialization) {
|
|
152
|
+
const mysqlOutput = await execAsyncSpawn(`docker logs ${containerName}`);
|
|
153
|
+
if (mysqlOutput.includes('init process done.') && !mysqlFinishedInitialization) {
|
|
154
|
+
mysqlFinishedInitialization = true;
|
|
155
|
+
task.output = 'MySQL is initialized!';
|
|
156
|
+
break;
|
|
157
|
+
}
|
|
158
|
+
await sleep(2000);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
await sleep(2000);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
task.output = 'Dumping MySQL database to dump file...';
|
|
166
|
+
|
|
167
|
+
await containerApi.exec(
|
|
168
|
+
[
|
|
169
|
+
'mysqldump',
|
|
170
|
+
'--user=root',
|
|
171
|
+
'--password=scandipwa',
|
|
172
|
+
'magento',
|
|
173
|
+
`--result-file=${ path.parse(pathToMySQLDumpFile).base }`
|
|
174
|
+
].join(' '),
|
|
175
|
+
containerName,
|
|
176
|
+
{},
|
|
177
|
+
{
|
|
178
|
+
callback: (t) => {
|
|
179
|
+
task.output = t;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
);
|
|
183
|
+
|
|
184
|
+
task.output = 'Copying dump file from container to system...';
|
|
185
|
+
|
|
186
|
+
await execAsyncSpawn(
|
|
187
|
+
`docker cp ${containerName}:/${ path.parse(pathToMySQLDumpFile).base } ${ pathToMySQLDumpFile }`
|
|
188
|
+
);
|
|
189
|
+
|
|
190
|
+
task.output = 'Removing migration container...';
|
|
191
|
+
|
|
192
|
+
await execAsyncSpawn(
|
|
193
|
+
`docker container stop ${containerName}`
|
|
194
|
+
);
|
|
195
|
+
await execAsyncSpawn(
|
|
196
|
+
`docker container rm ${containerName}`
|
|
197
|
+
);
|
|
198
|
+
|
|
199
|
+
ctx.importDb = pathToMySQLDumpFile;
|
|
200
|
+
|
|
201
|
+
return task.newListr([
|
|
202
|
+
createCacheFolder(),
|
|
203
|
+
getSystemConfigTask(),
|
|
204
|
+
getCachedPorts(),
|
|
205
|
+
stopContainers(),
|
|
206
|
+
setPrefix(),
|
|
207
|
+
getProjectConfiguration(),
|
|
208
|
+
// get fresh ports
|
|
209
|
+
getAvailablePorts(),
|
|
210
|
+
saveConfiguration(),
|
|
211
|
+
pullImages(),
|
|
212
|
+
dockerNetwork.tasks.createNetwork(),
|
|
213
|
+
createVolumes(),
|
|
214
|
+
{
|
|
215
|
+
task: (ctx, task) => task.newListr([
|
|
216
|
+
buildProjectImage(),
|
|
217
|
+
buildDebugProjectImage()
|
|
218
|
+
], {
|
|
219
|
+
concurrent: true
|
|
220
|
+
})
|
|
221
|
+
},
|
|
222
|
+
checkPHPVersion(),
|
|
223
|
+
getComposerVersionTask(),
|
|
224
|
+
prepareFileSystem(),
|
|
225
|
+
installMagentoProject(),
|
|
226
|
+
enableMagentoComposerPlugins(),
|
|
227
|
+
startServices(),
|
|
228
|
+
connectToDatabase(),
|
|
229
|
+
importDumpToDatabase(),
|
|
230
|
+
{
|
|
231
|
+
task: async (subCtx, subTask) => {
|
|
232
|
+
const confirmDeleteOldVolume = await subTask.prompt({
|
|
233
|
+
type: 'Select',
|
|
234
|
+
message: 'Okay, looks like conversion went well, do you want to delete old mysql-data volume?',
|
|
235
|
+
choices: [
|
|
236
|
+
{
|
|
237
|
+
name: 'yes',
|
|
238
|
+
message: 'Sure'
|
|
239
|
+
},
|
|
240
|
+
{
|
|
241
|
+
name: 'no',
|
|
242
|
+
message: 'No, I want to keep it'
|
|
243
|
+
}
|
|
244
|
+
]
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
if (confirmDeleteOldVolume === 'yes') {
|
|
248
|
+
await execAsyncSpawn(`docker volume rm ${ mysqlVolumeName }`);
|
|
249
|
+
|
|
250
|
+
const confirmDeleteDump = await subTask.prompt({
|
|
251
|
+
type: 'Select',
|
|
252
|
+
message: `Last question for today.
|
|
253
|
+
Do you want to keep database dump created during conversion process? (${logger.style.file(pathToMySQLDumpFile)})`,
|
|
254
|
+
choices: [
|
|
255
|
+
{
|
|
256
|
+
name: 'yes',
|
|
257
|
+
message: 'I don\'t need it, thanks'
|
|
258
|
+
},
|
|
259
|
+
{
|
|
260
|
+
name: 'no',
|
|
261
|
+
message: 'I would like to keep it, thanks'
|
|
262
|
+
}
|
|
263
|
+
]
|
|
264
|
+
});
|
|
265
|
+
|
|
266
|
+
if (confirmDeleteDump === 'yes') {
|
|
267
|
+
await fs.promises.rm(pathToMySQLDumpFile);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
]);
|
|
273
|
+
}
|
|
274
|
+
throw new KnownError('ABORTING');
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
task.skip();
|
|
278
|
+
},
|
|
279
|
+
options: {
|
|
280
|
+
bottomBar: 10
|
|
281
|
+
}
|
|
282
|
+
});
|
|
283
|
+
|
|
284
|
+
module.exports = convertMySQLDatabaseToMariaDB;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { ExecAsyncSpawnOptions } from '../../../util/exec-async-command';
|
|
2
|
+
|
|
3
|
+
export interface ImagesLsOptions<T extends boolean = false> {
|
|
4
|
+
all?: boolean
|
|
5
|
+
digests?: boolean
|
|
6
|
+
filter?: string | string[]
|
|
7
|
+
format?: string
|
|
8
|
+
quiet?: boolean
|
|
9
|
+
noTrunc?: boolean
|
|
10
|
+
formatToJSON?: T
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface ImagesLsResult {
|
|
14
|
+
Containers: string
|
|
15
|
+
CreatedAt: string
|
|
16
|
+
CreatedSince: string
|
|
17
|
+
Digest: string
|
|
18
|
+
ID: string
|
|
19
|
+
Repository: string
|
|
20
|
+
SharedSize: string
|
|
21
|
+
Size: string
|
|
22
|
+
Tag: string
|
|
23
|
+
UniqueSize: string
|
|
24
|
+
VirtualSize: string
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function ls(
|
|
28
|
+
options?: ImagesLsOptions,
|
|
29
|
+
execOptions?: ExecAsyncSpawnOptions<false>
|
|
30
|
+
): Promise<string>
|
|
31
|
+
export function ls(
|
|
32
|
+
options?: ImagesLsOptions<true>,
|
|
33
|
+
execOptions?: ExecAsyncSpawnOptions<false>
|
|
34
|
+
): Promise<ImagesLsResult[]>
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
const { execAsyncSpawn } = require('../../../util/exec-async-command');
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
* @param {import('./image-api').ImagesLsOptions} options
|
|
6
|
+
* @param {import('../../../util/exec-async-command').ExecAsyncSpawnOptions} execOptions
|
|
7
|
+
*/
|
|
8
|
+
const ls = async (options, execOptions = {}) => {
|
|
9
|
+
const {
|
|
10
|
+
all,
|
|
11
|
+
filter,
|
|
12
|
+
format,
|
|
13
|
+
formatToJSON = false,
|
|
14
|
+
noTrunc,
|
|
15
|
+
quiet,
|
|
16
|
+
digests
|
|
17
|
+
} = options;
|
|
18
|
+
|
|
19
|
+
const allArg = all && '--all';
|
|
20
|
+
const filterArg = filter && typeof filter === 'string'
|
|
21
|
+
? `--filter=${filter}`
|
|
22
|
+
: filter && Array.isArray(filter) && filter.every((f) => typeof f === 'string') && filter.map((f) => `--filter=${f}`).join(' ');
|
|
23
|
+
const formatArg = !formatToJSON && format
|
|
24
|
+
? `--format=${format}`
|
|
25
|
+
: formatToJSON && '--format=\'{{json .}}\'';
|
|
26
|
+
const digestsArg = digests && '--digests';
|
|
27
|
+
const noTruncArg = noTrunc && '--no-trunc';
|
|
28
|
+
const quietArg = quiet && '--quiet';
|
|
29
|
+
|
|
30
|
+
const args = [
|
|
31
|
+
allArg,
|
|
32
|
+
filterArg,
|
|
33
|
+
formatArg,
|
|
34
|
+
digestsArg,
|
|
35
|
+
noTruncArg,
|
|
36
|
+
quietArg
|
|
37
|
+
].filter(Boolean).join(' ');
|
|
38
|
+
|
|
39
|
+
if (formatToJSON) {
|
|
40
|
+
const result = await execAsyncSpawn(`docker image ls ${args}`, execOptions);
|
|
41
|
+
return JSON.parse(`[${result.split('\n').join(', ')}]`);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return execAsyncSpawn(`docker image ls ${args}`, execOptions);
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
module.exports = {
|
|
48
|
+
ls
|
|
49
|
+
};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
const containers = require('./containers');
|
|
2
2
|
const network = require('./network');
|
|
3
|
-
const volumes = require('./volumes');
|
|
4
3
|
|
|
5
4
|
/**
|
|
6
5
|
* @type {() => import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
|
|
@@ -8,17 +7,6 @@ const volumes = require('./volumes');
|
|
|
8
7
|
const startServices = () => ({
|
|
9
8
|
title: 'Starting Docker services',
|
|
10
9
|
task: (ctx, task) => task.newListr([
|
|
11
|
-
{
|
|
12
|
-
title: 'Preparing services',
|
|
13
|
-
task: (ctx, task) => task.newListr([
|
|
14
|
-
network.createNetwork(),
|
|
15
|
-
volumes.createVolumes()
|
|
16
|
-
], {
|
|
17
|
-
concurrent: true,
|
|
18
|
-
exitOnError: true,
|
|
19
|
-
ctx
|
|
20
|
-
})
|
|
21
|
-
},
|
|
22
10
|
containers.startContainers(),
|
|
23
11
|
containers.checkContainersAreRunning()
|
|
24
12
|
], {
|
|
@@ -33,7 +21,7 @@ const startServices = () => ({
|
|
|
33
21
|
const stopServices = () => ({
|
|
34
22
|
task: (ctx, task) => task.newListr([
|
|
35
23
|
containers.stopContainers(),
|
|
36
|
-
network.removeNetwork()
|
|
24
|
+
network.tasks.removeNetwork()
|
|
37
25
|
])
|
|
38
26
|
});
|
|
39
27
|
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { ExecAsyncSpawnOptions } from '../../../util/exec-async-command';
|
|
2
|
+
|
|
3
|
+
export interface NetworkLsOptions<T extends boolean = false> {
|
|
4
|
+
filter?: string | string[]
|
|
5
|
+
format?: string
|
|
6
|
+
formatToJSON?: T
|
|
7
|
+
quiet?: boolean
|
|
8
|
+
noTrunc?: boolean
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface NetworkLsResult {
|
|
12
|
+
CreatedAt: string
|
|
13
|
+
Driver: string
|
|
14
|
+
ID: string
|
|
15
|
+
IPv6: string
|
|
16
|
+
Internal: string
|
|
17
|
+
Labels: string
|
|
18
|
+
Name: string
|
|
19
|
+
Scope: string
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function ls(
|
|
23
|
+
options?: NetworkLsOptions,
|
|
24
|
+
execOptions?: ExecAsyncSpawnOptions<false>
|
|
25
|
+
): Promise<string>
|
|
26
|
+
export function ls(
|
|
27
|
+
options?: NetworkLsOptions<true>,
|
|
28
|
+
execOptions?: ExecAsyncSpawnOptions<false>
|
|
29
|
+
): Promise<NetworkLsResult[]>
|
|
30
|
+
|
|
31
|
+
export interface NetworkInspectOptions<T extends boolean = false> {
|
|
32
|
+
network: string | string[]
|
|
33
|
+
format?: string
|
|
34
|
+
formatToJSON?: T
|
|
35
|
+
verbose?: boolean
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface NetworkInspectResult {
|
|
39
|
+
Name: string
|
|
40
|
+
Id: string
|
|
41
|
+
Created: string
|
|
42
|
+
Scope: string
|
|
43
|
+
EnableIPv6: boolean
|
|
44
|
+
IPAM: {
|
|
45
|
+
Driver: string
|
|
46
|
+
Options: Record<string, unknown>
|
|
47
|
+
Config: {
|
|
48
|
+
Subnet: string
|
|
49
|
+
Gateway: string
|
|
50
|
+
}[]
|
|
51
|
+
}
|
|
52
|
+
Internal: boolean
|
|
53
|
+
Attachable: boolean
|
|
54
|
+
Ingress: boolean
|
|
55
|
+
ConfigFrom: {
|
|
56
|
+
Network: string
|
|
57
|
+
}
|
|
58
|
+
ConfigOnly: boolean
|
|
59
|
+
Containers: Record<string, {
|
|
60
|
+
Name: string
|
|
61
|
+
EndpointID: string
|
|
62
|
+
MacAddress: string
|
|
63
|
+
IPv4Address: string
|
|
64
|
+
IPv6Address: string
|
|
65
|
+
}>
|
|
66
|
+
Options: Record<string, unknown>
|
|
67
|
+
Labels: Record<string, unknown>
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export function inspect(
|
|
71
|
+
options?: NetworkInspectOptions,
|
|
72
|
+
execOptions?: ExecAsyncSpawnOptions<false>
|
|
73
|
+
): Promise<string>
|
|
74
|
+
|
|
75
|
+
export function inspect(
|
|
76
|
+
options?: NetworkInspectOptions<true>,
|
|
77
|
+
execOptions?: ExecAsyncSpawnOptions<false>
|
|
78
|
+
): Promise<NetworkInspectResult>
|
|
79
|
+
|
|
80
|
+
export interface NetworkCreateOptions {
|
|
81
|
+
network: string | string[]
|
|
82
|
+
attachable?: boolean
|
|
83
|
+
auxAddress?: string
|
|
84
|
+
configFrom?: string
|
|
85
|
+
configOnly?: string
|
|
86
|
+
driver?: string
|
|
87
|
+
gateway?: string
|
|
88
|
+
ingress?: boolean
|
|
89
|
+
internal?: boolean
|
|
90
|
+
ipRange?: string
|
|
91
|
+
ipamDriver?: string
|
|
92
|
+
ipamOpt?: string
|
|
93
|
+
ipv6?: boolean
|
|
94
|
+
label?: string
|
|
95
|
+
opt?: string
|
|
96
|
+
scope?: string
|
|
97
|
+
subnet?: string
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export function create(
|
|
101
|
+
options?: NetworkCreateOptions,
|
|
102
|
+
execOptions?: ExecAsyncSpawnOptions<false>
|
|
103
|
+
): Promise<string>
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
const { execAsyncSpawn } = require('../../../util/exec-async-command');
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @param {import('./network-api').NetworkLsOptions} options
|
|
5
|
+
* @param {import('../../../util/exec-async-command').ExecAsyncSpawnOptions} execOptions
|
|
6
|
+
*/
|
|
7
|
+
const ls = async (options, execOptions = {}) => {
|
|
8
|
+
const {
|
|
9
|
+
filter,
|
|
10
|
+
format,
|
|
11
|
+
formatToJSON = false,
|
|
12
|
+
noTrunc,
|
|
13
|
+
quiet
|
|
14
|
+
} = options;
|
|
15
|
+
|
|
16
|
+
const formatArg = !formatToJSON && format
|
|
17
|
+
? `--format=${format}`
|
|
18
|
+
: formatToJSON && '--format=\'{{json .}}\'';
|
|
19
|
+
const filterArg = filter && typeof filter === 'string'
|
|
20
|
+
? `--filter=${filter}`
|
|
21
|
+
: filter && Array.isArray(filter) && filter.every((f) => typeof f === 'string') && filter.map((f) => `--filter=${f}`).join(' ');
|
|
22
|
+
const noTruncArg = noTrunc && '--no-trunc';
|
|
23
|
+
const quietArg = quiet && '--quiet';
|
|
24
|
+
const args = [
|
|
25
|
+
filterArg,
|
|
26
|
+
formatArg,
|
|
27
|
+
noTruncArg,
|
|
28
|
+
quietArg
|
|
29
|
+
].filter(Boolean).join(' ');
|
|
30
|
+
|
|
31
|
+
if (formatToJSON) {
|
|
32
|
+
const result = await execAsyncSpawn(`docker network ls ${args}`, execOptions);
|
|
33
|
+
return JSON.parse(`[${result.split('\n').join(', ')}]`);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return execAsyncSpawn(`docker network ls ${args}`, execOptions);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* @param {import('./network-api').NetworkInspectOptions} options
|
|
41
|
+
* @param {import('../../../util/exec-async-command').ExecAsyncSpawnOptions} execOptions
|
|
42
|
+
*/
|
|
43
|
+
const inspect = async (options, execOptions = {}) => {
|
|
44
|
+
const {
|
|
45
|
+
network,
|
|
46
|
+
format,
|
|
47
|
+
formatToJSON = false,
|
|
48
|
+
verbose
|
|
49
|
+
} = options;
|
|
50
|
+
|
|
51
|
+
const formatArg = !formatToJSON && format
|
|
52
|
+
? `--format=${format}`
|
|
53
|
+
: formatToJSON && '--format=\'{{json .}}\'';
|
|
54
|
+
const verboseArg = verbose && '--verbose';
|
|
55
|
+
const networks = typeof network === 'string'
|
|
56
|
+
? network
|
|
57
|
+
: network.join(' ');
|
|
58
|
+
|
|
59
|
+
const args = [
|
|
60
|
+
formatArg,
|
|
61
|
+
verboseArg
|
|
62
|
+
].filter(Boolean).join(' ');
|
|
63
|
+
|
|
64
|
+
if (formatToJSON) {
|
|
65
|
+
const result = await execAsyncSpawn(`docker network inspect ${args} ${networks}`, execOptions);
|
|
66
|
+
return JSON.parse(result);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return execAsyncSpawn(`docker network inspect ${args} ${networks}`, execOptions);
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* @param {import('./network-api').NetworkCreateOptions} options
|
|
74
|
+
* @param {import('../../../util/exec-async-command').ExecAsyncSpawnOptions} execOptions
|
|
75
|
+
*/
|
|
76
|
+
const create = async (options, execOptions = {}) => {
|
|
77
|
+
const {
|
|
78
|
+
network,
|
|
79
|
+
driver
|
|
80
|
+
} = options;
|
|
81
|
+
|
|
82
|
+
const networks = typeof network === 'string'
|
|
83
|
+
? network
|
|
84
|
+
: network.join(' ');
|
|
85
|
+
|
|
86
|
+
const driverArg = driver && `--driver='${ driver }'`;
|
|
87
|
+
|
|
88
|
+
const args = [
|
|
89
|
+
driverArg
|
|
90
|
+
].filter(Boolean).join(' ');
|
|
91
|
+
|
|
92
|
+
return execAsyncSpawn(`docker network create ${args} ${networks}`, execOptions);
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
module.exports = {
|
|
96
|
+
ls,
|
|
97
|
+
inspect,
|
|
98
|
+
create
|
|
99
|
+
};
|