@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,21 +1,26 @@
|
|
|
1
1
|
const logger = require('@scandipwa/scandipwa-dev-utils/logger');
|
|
2
|
-
const KnownError = require('
|
|
3
|
-
const
|
|
2
|
+
const KnownError = require('../../../errors/known-error');
|
|
3
|
+
const UnknownError = require('../../../errors/unknown-error');
|
|
4
|
+
const { execAsyncSpawn } = require('../../../util/exec-async-command');
|
|
5
|
+
const networkApi = require('./network-api');
|
|
4
6
|
|
|
5
7
|
/**
|
|
6
|
-
* @type {() => import('listr2').ListrTask<import('
|
|
8
|
+
* @type {() => import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
|
|
7
9
|
*/
|
|
8
10
|
const createNetwork = () => ({
|
|
9
11
|
title: 'Deploying Docker network',
|
|
10
12
|
task: async ({ config: { docker } }, task) => {
|
|
11
|
-
const networkList =
|
|
13
|
+
const networkList = await networkApi.ls({ formatToJSON: true });
|
|
12
14
|
|
|
13
|
-
if (networkList.
|
|
15
|
+
if (networkList.some((network) => network.Name === docker.network.name)) {
|
|
14
16
|
task.skip();
|
|
15
17
|
return;
|
|
16
18
|
}
|
|
17
19
|
try {
|
|
18
|
-
await
|
|
20
|
+
await networkApi.create({
|
|
21
|
+
network: docker.network.name,
|
|
22
|
+
driver: 'bridge'
|
|
23
|
+
});
|
|
19
24
|
} catch (e) {
|
|
20
25
|
if (e.includes('could not find an available, non-overlapping IPv4 address pool')) {
|
|
21
26
|
const pruneNetworks = await task.prompt({
|
|
@@ -34,19 +39,21 @@ Do you want remove all custom networks not used by at least one container?`
|
|
|
34
39
|
You need to delete unused networks yourself.
|
|
35
40
|
Use command ${logger.style.command('docker network prune')}`);
|
|
36
41
|
}
|
|
42
|
+
|
|
43
|
+
throw new UnknownError(`Unable to create network!\n\n${e}`);
|
|
37
44
|
}
|
|
38
45
|
}
|
|
39
46
|
});
|
|
40
47
|
|
|
41
48
|
/**
|
|
42
|
-
* @type {() => import('listr2').ListrTask<import('
|
|
49
|
+
* @type {() => import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
|
|
43
50
|
*/
|
|
44
51
|
const removeNetwork = () => ({
|
|
45
52
|
title: 'Removing Docker network',
|
|
46
53
|
task: async ({ config: { docker } }, task) => {
|
|
47
|
-
const networkList =
|
|
54
|
+
const networkList = await networkApi.ls({ formatToJSON: true });
|
|
48
55
|
|
|
49
|
-
if (!networkList.
|
|
56
|
+
if (!networkList.some((network) => network.Name === docker.network.name)) {
|
|
50
57
|
task.skip();
|
|
51
58
|
return;
|
|
52
59
|
}
|
|
@@ -56,7 +63,7 @@ const removeNetwork = () => ({
|
|
|
56
63
|
});
|
|
57
64
|
|
|
58
65
|
/**
|
|
59
|
-
* @type {() => import('listr2').ListrTask<import('
|
|
66
|
+
* @type {() => import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
|
|
60
67
|
*/
|
|
61
68
|
const pruneNetworks = () => ({
|
|
62
69
|
title: 'Removing custom networks not used by at least one container',
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
const { DockerFileBuilder } = require('../../util/dockerfile-builder');
|
|
2
|
+
const semver = require('semver');
|
|
3
|
+
const { execAsyncSpawn } = require('../../util/exec-async-command');
|
|
4
|
+
const KnownError = require('../../errors/known-error');
|
|
5
|
+
const { runContainerImage } = require('../../util/run-container-image');
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Get enabled extensions list with versions
|
|
9
|
+
* @param {string} imageWithTag
|
|
10
|
+
* @returns {Promise<{[key: string]: string}}>}
|
|
11
|
+
*/
|
|
12
|
+
const getEnabledExtensionsFromImage = async (imageWithTag) => {
|
|
13
|
+
const output = await runContainerImage(
|
|
14
|
+
imageWithTag,
|
|
15
|
+
// eslint-disable-next-line quotes
|
|
16
|
+
`php -r 'foreach (get_loaded_extensions() as $extension) echo "$extension:" . phpversion($extension) . "\n";'`
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
return output
|
|
20
|
+
.split('\n')
|
|
21
|
+
.map((m) => {
|
|
22
|
+
// eslint-disable-next-line no-unused-vars
|
|
23
|
+
const [_, moduleName, moduleVersion] = m.match(/(.+):(.+)/i);
|
|
24
|
+
|
|
25
|
+
return [moduleName, moduleVersion];
|
|
26
|
+
})
|
|
27
|
+
.reduce((acc, [name, version]) => ({ ...acc, [name]: version }), {});
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const addExtensionToBuilder = (builder, ctx) => ([extensionName, extensionInstructions]) => {
|
|
31
|
+
const { command, ...extensionInstructionsWithoutCommand } = extensionInstructions;
|
|
32
|
+
let runCommand = '';
|
|
33
|
+
if (typeof command === 'string') {
|
|
34
|
+
runCommand += ` ${command}`;
|
|
35
|
+
} else if (typeof command === 'function') {
|
|
36
|
+
runCommand += ` ${command({ ...extensionInstructionsWithoutCommand, ctx })}`;
|
|
37
|
+
} else {
|
|
38
|
+
runCommand += ` docker-php-ext-install ${extensionInstructionsWithoutCommand.name}`;
|
|
39
|
+
}
|
|
40
|
+
builder
|
|
41
|
+
.comment(`extension ${extensionName} installation command`)
|
|
42
|
+
.run(runCommand.trim());
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* @param {import('../../../typings/context').ListrContext} ctx
|
|
47
|
+
* @param {{ image: string, tag: string}} param1
|
|
48
|
+
*/
|
|
49
|
+
const buildDockerFileInstructions = async (ctx, { image, tag }) => {
|
|
50
|
+
const { composer } = ctx.config.overridenConfiguration.configuration;
|
|
51
|
+
const existingPHPExtensions = await getEnabledExtensionsFromImage(`${image}:${tag}`);
|
|
52
|
+
|
|
53
|
+
const missingExtensions = Object.entries(
|
|
54
|
+
ctx.config.overridenConfiguration.configuration.php.extensions
|
|
55
|
+
).filter(
|
|
56
|
+
([extensionName, extensionInstructions]) => !Object.entries(existingPHPExtensions)
|
|
57
|
+
.map(([n, i]) => [n.toLowerCase(), i])
|
|
58
|
+
.some(
|
|
59
|
+
([n]) => extensionName === n || (
|
|
60
|
+
extensionInstructions.alternativeName && extensionInstructions.alternativeName.map(
|
|
61
|
+
(s) => s.toLowerCase()
|
|
62
|
+
).includes(n)
|
|
63
|
+
)
|
|
64
|
+
)
|
|
65
|
+
).filter(([extensionName]) => extensionName.toLowerCase() !== 'xdebug');
|
|
66
|
+
|
|
67
|
+
const dockerFileInstructions = new DockerFileBuilder()
|
|
68
|
+
.comment('project image')
|
|
69
|
+
.from({ image, tag });
|
|
70
|
+
|
|
71
|
+
// install bash and patch in image
|
|
72
|
+
dockerFileInstructions
|
|
73
|
+
.run('apk add --no-cache bash patch');
|
|
74
|
+
|
|
75
|
+
if (missingExtensions.length > 0) {
|
|
76
|
+
const allDependencies = missingExtensions.map(
|
|
77
|
+
([_extensionName, extensionInstructions]) => (extensionInstructions.dependencies || [])
|
|
78
|
+
)
|
|
79
|
+
.reduce((acc, val) => acc.concat(val.filter((ex) => !acc.includes(ex))), []);
|
|
80
|
+
|
|
81
|
+
dockerFileInstructions.run(`apk add --no-cache ${allDependencies.join(' ')}`);
|
|
82
|
+
missingExtensions.forEach(addExtensionToBuilder(dockerFileInstructions, ctx));
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const composerVersion = /^\d$/.test(composer.version)
|
|
86
|
+
? `latest-${composer.version}.x`
|
|
87
|
+
: composer.version;
|
|
88
|
+
|
|
89
|
+
dockerFileInstructions
|
|
90
|
+
.comment('download composer')
|
|
91
|
+
.run(`curl https://getcomposer.org/download/${composerVersion}/composer.phar --output composer`)
|
|
92
|
+
.comment('make composer executable')
|
|
93
|
+
.run('chmod +x ./composer')
|
|
94
|
+
.comment('move composer to bin directory')
|
|
95
|
+
.run('mv composer /usr/local/bin/composer');
|
|
96
|
+
|
|
97
|
+
if (semver.satisfies(composer.version, '^1')) {
|
|
98
|
+
dockerFileInstructions
|
|
99
|
+
.comment('install prestissimo composer plugin')
|
|
100
|
+
.run('composer global require hirak/prestissimo');
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
dockerFileInstructions
|
|
104
|
+
.workDir(ctx.config.baseConfig.containerMagentoDir);
|
|
105
|
+
|
|
106
|
+
return dockerFileInstructions;
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* @type {() => import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
|
|
111
|
+
*/
|
|
112
|
+
const buildProjectImage = () => ({
|
|
113
|
+
title: 'Building Project Image',
|
|
114
|
+
task: async (ctx, task) => {
|
|
115
|
+
const containers = ctx.config.docker.getContainers(ctx.ports);
|
|
116
|
+
const [image, tag = 'latest'] = ctx.config.overridenConfiguration.configuration.php.baseImage.split(':');
|
|
117
|
+
const dockerFileInstructions = await buildDockerFileInstructions(ctx, { image, tag });
|
|
118
|
+
|
|
119
|
+
try {
|
|
120
|
+
await execAsyncSpawn(`docker build -t ${containers.php.image} -<<EOF
|
|
121
|
+
${dockerFileInstructions.build()}
|
|
122
|
+
EOF`, {
|
|
123
|
+
callback: (r) => {
|
|
124
|
+
task.output = r;
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
} catch (e) {
|
|
128
|
+
throw new KnownError(`Unexpected error during project image building!\n\n${e}`);
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
options: {
|
|
132
|
+
bottomBar: 10
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* @type {() => import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
|
|
138
|
+
*/
|
|
139
|
+
const buildDebugProjectImage = () => ({
|
|
140
|
+
title: 'Building Debug Project Image',
|
|
141
|
+
task: async (ctx, task) => {
|
|
142
|
+
const containers = ctx.config.docker.getContainers(ctx.ports);
|
|
143
|
+
const [image, tag = 'latest'] = ctx.config.overridenConfiguration.configuration.php.debugImage.split(':');
|
|
144
|
+
const dockerFileInstructions = await buildDockerFileInstructions(ctx, { image, tag });
|
|
145
|
+
|
|
146
|
+
try {
|
|
147
|
+
await execAsyncSpawn(`docker build -t ${containers.php.debugImage} -<<EOF
|
|
148
|
+
${dockerFileInstructions.build()}
|
|
149
|
+
EOF`, {
|
|
150
|
+
callback: (r) => {
|
|
151
|
+
task.output = r;
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
} catch (e) {
|
|
155
|
+
throw new KnownError(`Unexpected error during debug project image building!\n\n${e}`);
|
|
156
|
+
}
|
|
157
|
+
},
|
|
158
|
+
options: {
|
|
159
|
+
bottomBar: 10
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
module.exports = {
|
|
164
|
+
buildProjectImage,
|
|
165
|
+
buildDebugProjectImage,
|
|
166
|
+
getEnabledExtensionsFromImage
|
|
167
|
+
};
|
|
@@ -1,21 +1,8 @@
|
|
|
1
|
-
const { execAsyncSpawn } = require('
|
|
2
|
-
|
|
3
|
-
const create = ({
|
|
4
|
-
driver,
|
|
5
|
-
opts = {},
|
|
6
|
-
name
|
|
7
|
-
}) => {
|
|
8
|
-
let command = `docker volume create ${ Object.entries(opts).map(([name, value]) => `--opt ${name}=${value}`).join(' ') } `;
|
|
9
|
-
|
|
10
|
-
if (driver) {
|
|
11
|
-
command += `--driver ${ driver }`;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
return execAsyncSpawn(`${ command } ${ name }`);
|
|
15
|
-
};
|
|
1
|
+
const { execAsyncSpawn } = require('../../../util/exec-async-command');
|
|
2
|
+
const { create } = require('./volume-api');
|
|
16
3
|
|
|
17
4
|
/**
|
|
18
|
-
* @type {() => import('listr2').ListrTask<import('
|
|
5
|
+
* @type {() => import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
|
|
19
6
|
*/
|
|
20
7
|
const createVolumes = () => ({
|
|
21
8
|
title: 'Creating volumes',
|
|
@@ -36,7 +23,7 @@ const createVolumes = () => ({
|
|
|
36
23
|
});
|
|
37
24
|
|
|
38
25
|
/**
|
|
39
|
-
* @type {() => import('listr2').ListrTask<import('
|
|
26
|
+
* @type {() => import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
|
|
40
27
|
*/
|
|
41
28
|
const removeVolumes = () => ({
|
|
42
29
|
title: 'Removing volumes',
|
|
@@ -58,6 +45,5 @@ const removeVolumes = () => ({
|
|
|
58
45
|
|
|
59
46
|
module.exports = {
|
|
60
47
|
createVolumes,
|
|
61
|
-
removeVolumes
|
|
62
|
-
createVolume: create
|
|
48
|
+
removeVolumes
|
|
63
49
|
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { ExecAsyncSpawnOptions } from '../../../util/exec-async-command';
|
|
2
|
+
|
|
3
|
+
export interface VolumeLsOptions<T extends boolean = false> {
|
|
4
|
+
filter?: string | string[]
|
|
5
|
+
format?: string
|
|
6
|
+
formatToJSON?: T
|
|
7
|
+
quiet?: boolean
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface VolumeLsResult {
|
|
11
|
+
Driver: string
|
|
12
|
+
Labels: string
|
|
13
|
+
Links: string
|
|
14
|
+
MountPoint: string
|
|
15
|
+
Name: string
|
|
16
|
+
Scope: string
|
|
17
|
+
Size: string
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function ls(
|
|
21
|
+
options?: VolumeLsOptions,
|
|
22
|
+
execOptions?: ExecAsyncSpawnOptions<false>
|
|
23
|
+
): Promise<string>
|
|
24
|
+
export function ls(
|
|
25
|
+
options?: VolumeLsOptions<true>,
|
|
26
|
+
execOptions?: ExecAsyncSpawnOptions<false>
|
|
27
|
+
): Promise<VolumeLsResult[]>
|
|
28
|
+
|
|
29
|
+
export interface VolumeCreateOptions {
|
|
30
|
+
driver?: string
|
|
31
|
+
label?: string
|
|
32
|
+
name: string
|
|
33
|
+
opt?: Record<string, string>
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function create(
|
|
37
|
+
options?: VolumeCreateOptions,
|
|
38
|
+
execOptions?: ExecAsyncSpawnOptions<false>
|
|
39
|
+
): Promise<string>
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
const { execAsyncSpawn } = require('../../../util/exec-async-command');
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @param {import('./volume-api').VolumeCreateOptions} options
|
|
5
|
+
* @param {import('../../../util/exec-async-command').ExecAsyncSpawnOptions} execOptions
|
|
6
|
+
*/
|
|
7
|
+
const create = async (options, execOptions = {}) => {
|
|
8
|
+
const {
|
|
9
|
+
driver,
|
|
10
|
+
label,
|
|
11
|
+
opt,
|
|
12
|
+
name
|
|
13
|
+
} = options;
|
|
14
|
+
|
|
15
|
+
const driverArg = driver && `--driver=${driver}`;
|
|
16
|
+
const labelArg = label && `--label=${label}`;
|
|
17
|
+
const optArg = opt && Object.entries(opt).map(([name, value]) => `--opt ${name}='${value}'`).join(' ');
|
|
18
|
+
|
|
19
|
+
const args = [
|
|
20
|
+
driverArg,
|
|
21
|
+
labelArg,
|
|
22
|
+
optArg,
|
|
23
|
+
name
|
|
24
|
+
].filter(Boolean).join(' ');
|
|
25
|
+
|
|
26
|
+
return execAsyncSpawn(`docker volume create ${args}`, execOptions);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* @param {import('./volume-api').VolumeLsOptions} options
|
|
31
|
+
* @param {import('../../../util/exec-async-command').ExecAsyncSpawnOptions} execOptions
|
|
32
|
+
*/
|
|
33
|
+
const ls = async (options, execOptions = {}) => {
|
|
34
|
+
const {
|
|
35
|
+
filter,
|
|
36
|
+
format,
|
|
37
|
+
formatToJSON = false,
|
|
38
|
+
quiet
|
|
39
|
+
} = options;
|
|
40
|
+
|
|
41
|
+
const formatArg = !formatToJSON && format
|
|
42
|
+
? `--format=${format}`
|
|
43
|
+
: formatToJSON && '--format=\'{{json .}}\'';
|
|
44
|
+
const filterArg = filter && typeof filter === 'string'
|
|
45
|
+
? `--filter=${filter}`
|
|
46
|
+
: filter && Array.isArray(filter) && filter.every((f) => typeof f === 'string') && filter.map((f) => `--filter=${f}`).join(' ');
|
|
47
|
+
const quietArg = quiet && '--quiet';
|
|
48
|
+
|
|
49
|
+
const args = [
|
|
50
|
+
filterArg,
|
|
51
|
+
formatArg,
|
|
52
|
+
quietArg
|
|
53
|
+
].filter(Boolean).join(' ');
|
|
54
|
+
|
|
55
|
+
if (formatToJSON) {
|
|
56
|
+
const result = await execAsyncSpawn(`docker volume ls ${args}`, execOptions);
|
|
57
|
+
return JSON.parse(`[${result.split('\n').join(', ')}]`);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return execAsyncSpawn(`docker volume ls ${args}`, execOptions);
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
module.exports = {
|
|
64
|
+
create,
|
|
65
|
+
ls
|
|
66
|
+
};
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
const { Listr } = require('listr2');
|
|
2
|
+
const logger = require('@scandipwa/scandipwa-dev-utils/logger');
|
|
3
|
+
const { checkRequirements } = require('./requirements');
|
|
4
|
+
const getMagentoVersionConfig = require('../config/get-magento-version-config');
|
|
5
|
+
const checkConfigurationFile = require('../config/check-configuration-file');
|
|
6
|
+
const getProjectConfiguration = require('../config/get-project-configuration');
|
|
7
|
+
const { getCachedPorts } = require('../config/get-port-config');
|
|
8
|
+
const { executeInContainer, runInContainer } = require('../util/execute-in-container');
|
|
9
|
+
const { containerApi } = require('./docker/containers');
|
|
10
|
+
const KnownError = require('../errors/known-error');
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
*
|
|
14
|
+
* @param {{ containername: string, commands?: string[] }} argv
|
|
15
|
+
* @returns
|
|
16
|
+
*/
|
|
17
|
+
const executeTask = async (argv) => {
|
|
18
|
+
const tasks = new Listr([
|
|
19
|
+
checkRequirements(),
|
|
20
|
+
getMagentoVersionConfig(),
|
|
21
|
+
checkConfigurationFile(),
|
|
22
|
+
getProjectConfiguration(),
|
|
23
|
+
getCachedPorts()
|
|
24
|
+
], {
|
|
25
|
+
concurrent: false,
|
|
26
|
+
exitOnError: true,
|
|
27
|
+
ctx: { throwMagentoVersionMissing: true },
|
|
28
|
+
rendererOptions: { collapse: false, clearOutput: true }
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
let ctx;
|
|
32
|
+
try {
|
|
33
|
+
ctx = await tasks.run();
|
|
34
|
+
} catch (e) {
|
|
35
|
+
logger.error(e.message || e);
|
|
36
|
+
process.exit(1);
|
|
37
|
+
}
|
|
38
|
+
const containers = ctx.config.docker.getContainers(ctx.ports);
|
|
39
|
+
const services = Object.keys(containers);
|
|
40
|
+
|
|
41
|
+
if (services.includes(argv.containername) || services.some((service) => service.includes(argv.containername))) {
|
|
42
|
+
/**
|
|
43
|
+
* @type {import('./docker/containers/container-api').ContainerRunOptions}
|
|
44
|
+
*/
|
|
45
|
+
const container = containers[argv.containername]
|
|
46
|
+
? containers[argv.containername]
|
|
47
|
+
: Object.entries(containers).find(([key]) => key.includes(argv.containername))[1];
|
|
48
|
+
|
|
49
|
+
if (argv.commands.length === 0) {
|
|
50
|
+
// if we have default connect command then use it
|
|
51
|
+
if (container.connectCommand) {
|
|
52
|
+
// eslint-disable-next-line no-param-reassign
|
|
53
|
+
argv.commands = container.connectCommand;
|
|
54
|
+
} else {
|
|
55
|
+
// otherwise fall back to bash (if it exists inside container)
|
|
56
|
+
argv.commands.push('bash');
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const containerList = await containerApi.ls({
|
|
61
|
+
formatToJSON: true,
|
|
62
|
+
all: true,
|
|
63
|
+
filter: `name=${container.name}`
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
if (containerList.length > 0) {
|
|
67
|
+
logger.logN(`Executing container ${logger.style.misc(container._)} (command: ${logger.style.command(argv.commands.join(' '))})`);
|
|
68
|
+
const result = await executeInContainer({
|
|
69
|
+
containerName: container.name,
|
|
70
|
+
commands: argv.commands
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
return result;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (container.name.endsWith('php')) {
|
|
77
|
+
logger.logN(`Starting container ${logger.style.misc(container._)} with command: ${logger.style.command(argv.commands.join(' '))}`);
|
|
78
|
+
const result = await runInContainer(
|
|
79
|
+
{
|
|
80
|
+
...container,
|
|
81
|
+
name: `${container.name}_exec-${Date.now()}`
|
|
82
|
+
},
|
|
83
|
+
argv.commands
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
return result;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
throw new KnownError(`Container ${container.name} is not running!`);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
logger.error(`No container found "${argv.containername}"`);
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
module.exports = {
|
|
96
|
+
executeTask
|
|
97
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
const UnknownError = require('../../errors/unknown-error');
|
|
3
|
+
const setConfigFile = require('../../util/set-config');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @type {() => import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
|
|
7
|
+
*/
|
|
8
|
+
const createMariaDBConfig = () => ({
|
|
9
|
+
title: 'Setting MariaDB config',
|
|
10
|
+
task: async (ctx) => {
|
|
11
|
+
try {
|
|
12
|
+
await setConfigFile({
|
|
13
|
+
configPathname: path.join(ctx.config.baseConfig.cacheDir, 'mariadb.cnf'),
|
|
14
|
+
template: path.join(ctx.config.baseConfig.templateDir, 'mariadb.template.cnf'),
|
|
15
|
+
overwrite: true
|
|
16
|
+
});
|
|
17
|
+
} catch (e) {
|
|
18
|
+
throw new UnknownError(`Unexpected error accrued during php-fpm config creation\n\n${e}`);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
module.exports = createMariaDBConfig;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
const os = require('os');
|
|
2
1
|
const path = require('path');
|
|
3
2
|
const setConfigFile = require('../../util/set-config');
|
|
4
3
|
const UnknownError = require('../../errors/unknown-error');
|
|
@@ -24,7 +23,7 @@ const createNginxConfig = () => ({
|
|
|
24
23
|
}
|
|
25
24
|
} = overridenConfiguration;
|
|
26
25
|
|
|
27
|
-
const isLinux =
|
|
26
|
+
const isLinux = ctx.platform === 'linux';
|
|
28
27
|
const isNativeLinux = isLinux && !isWsl;
|
|
29
28
|
const hostMachine = isNativeLinux ? '127.0.0.1' : 'host.docker.internal';
|
|
30
29
|
const hostPort = isNativeLinux ? ports.app : 80;
|
|
@@ -41,7 +40,7 @@ const createNginxConfig = () => ({
|
|
|
41
40
|
overwrite: true,
|
|
42
41
|
templateArgs: {
|
|
43
42
|
ports,
|
|
44
|
-
mageRoot: baseConfig.
|
|
43
|
+
mageRoot: baseConfig.containerMagentoDir,
|
|
45
44
|
hostMachine,
|
|
46
45
|
hostPort,
|
|
47
46
|
config: overridenConfiguration
|
|
@@ -1,24 +1,39 @@
|
|
|
1
1
|
const semver = require('semver');
|
|
2
2
|
const UnknownError = require('../../errors/unknown-error');
|
|
3
3
|
const setConfigFile = require('../../util/set-config');
|
|
4
|
+
const { getEnabledExtensionsFromImage } = require('../docker/project-image-builder');
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* @type {() => import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
|
|
7
8
|
*/
|
|
8
9
|
const createPhpConfig = () => ({
|
|
9
10
|
title: 'Setting PHP config',
|
|
10
|
-
task: async (
|
|
11
|
-
const
|
|
11
|
+
task: async (ctx) => {
|
|
12
|
+
const {
|
|
13
|
+
config: {
|
|
14
|
+
php,
|
|
15
|
+
baseConfig
|
|
16
|
+
},
|
|
17
|
+
debug
|
|
18
|
+
} = ctx;
|
|
19
|
+
const containers = ctx.config.docker.getContainers(ctx.ports);
|
|
20
|
+
const phpExtensions = await getEnabledExtensionsFromImage(containers.php.debugImage);
|
|
21
|
+
const isXDebug2 = semver.satisfies(phpExtensions.xdebug, '2');
|
|
22
|
+
|
|
23
|
+
const isLinux = ctx.platform === 'linux';
|
|
24
|
+
const isNativeLinux = isLinux && !ctx.isWsl;
|
|
25
|
+
const hostMachine = isNativeLinux ? '127.0.0.1' : 'host.docker.internal';
|
|
26
|
+
|
|
12
27
|
try {
|
|
13
28
|
await setConfigFile({
|
|
14
29
|
configPathname: php.iniPath,
|
|
15
30
|
template: php.iniTemplatePath,
|
|
16
31
|
overwrite: true,
|
|
17
32
|
templateArgs: {
|
|
18
|
-
ports,
|
|
19
33
|
debug,
|
|
20
|
-
mageRoot: baseConfig.
|
|
21
|
-
isXDebug2
|
|
34
|
+
mageRoot: baseConfig.containerMagentoDir,
|
|
35
|
+
isXDebug2,
|
|
36
|
+
hostMachine
|
|
22
37
|
}
|
|
23
38
|
});
|
|
24
39
|
} catch (e) {
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
const path = require('path');
|
|
2
1
|
const UnknownError = require('../../errors/unknown-error');
|
|
3
2
|
const setConfigFile = require('../../util/set-config');
|
|
4
3
|
|
|
@@ -7,14 +6,19 @@ const setConfigFile = require('../../util/set-config');
|
|
|
7
6
|
*/
|
|
8
7
|
const createPhpFpmConfig = () => ({
|
|
9
8
|
title: 'Setting php-fpm config',
|
|
10
|
-
task: async (
|
|
9
|
+
task: async (ctx) => {
|
|
10
|
+
const { config: { php } } = ctx;
|
|
11
|
+
const isLinux = ctx.platform === 'linux';
|
|
12
|
+
const isNativeLinux = isLinux && !ctx.isWsl;
|
|
13
|
+
const port = isNativeLinux ? ctx.ports.fpm : 9000;
|
|
14
|
+
|
|
11
15
|
try {
|
|
12
16
|
await setConfigFile({
|
|
13
17
|
configPathname: php.fpmConfPath,
|
|
14
|
-
template:
|
|
18
|
+
template: php.fpmTemplatePath,
|
|
15
19
|
overwrite: true,
|
|
16
20
|
templateArgs: {
|
|
17
|
-
|
|
21
|
+
port
|
|
18
22
|
}
|
|
19
23
|
});
|
|
20
24
|
} catch (e) {
|