@scandipwa/magento-scripts 2.0.0-alpha.0 → 2.0.0-alpha.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (165) hide show
  1. package/exec.js +71 -0
  2. package/index.js +1 -1
  3. package/lib/commands/cli.js +7 -2
  4. package/lib/commands/execute.js +3 -58
  5. package/lib/commands/import-db.js +1 -1
  6. package/lib/commands/logs.js +1 -1
  7. package/lib/commands/start.js +18 -8
  8. package/lib/commands/status.js +9 -1
  9. package/lib/config/config.js +20 -2
  10. package/lib/config/docker.js +79 -85
  11. package/lib/config/index.js +2 -2
  12. package/lib/config/php/versions/php-7.2.js +1 -0
  13. package/lib/config/php/versions/php-7.3.js +1 -0
  14. package/lib/config/php/versions/php-7.4.js +1 -0
  15. package/lib/config/php/versions/php-8.1.js +1 -0
  16. package/lib/config/php-config.js +4 -3
  17. package/lib/config/port-config.js +1 -1
  18. package/lib/config/services/composer/versions/composer-1.js +8 -0
  19. package/lib/config/services/composer/versions/composer-2.js +8 -0
  20. package/lib/config/services/composer/versions/index.js +4 -0
  21. package/lib/config/services/elasticsearch/base-repo.js +3 -0
  22. package/lib/config/services/elasticsearch/default-es-env.js +6 -0
  23. package/lib/config/services/elasticsearch/versions/elasticsearch-6.8.js +19 -0
  24. package/lib/config/services/elasticsearch/versions/index.js +5 -0
  25. package/lib/config/services/nginx/versions/index.js +3 -0
  26. package/lib/config/services/nginx/versions/nginx-1.18.js +11 -0
  27. package/lib/config/{ssl-terminator → services/ssl-terminator}/index.js +3 -0
  28. package/lib/config/templates/magentorc.template +6 -5
  29. package/lib/config/templates/mariadb.template.cnf +191 -0
  30. package/lib/config/templates/php-debug.template.ini +31 -0
  31. package/lib/config/templates/php-fpm.template.conf +1 -2
  32. package/lib/config/templates/php.template.ini +6 -202
  33. package/lib/config/templates/ssl-terminator.template.conf +10 -3
  34. package/lib/config/templates/varnish.template.vcl +20 -13
  35. package/lib/config/varnish/varnish-6-0.js +4 -0
  36. package/lib/config/varnish/varnish-6-6.js +4 -0
  37. package/lib/config/varnish/varnish-7-0.js +4 -0
  38. package/lib/config/versions/magento-2.3.0.js +7 -12
  39. package/lib/config/versions/magento-2.3.1.js +7 -12
  40. package/lib/config/versions/magento-2.3.2-p1.js +7 -12
  41. package/lib/config/versions/magento-2.3.2-p2.js +7 -12
  42. package/lib/config/versions/magento-2.3.2.js +7 -12
  43. package/lib/config/versions/magento-2.3.3-p1.js +7 -12
  44. package/lib/config/versions/magento-2.3.3.js +7 -12
  45. package/lib/config/versions/magento-2.3.4-p1.js +7 -12
  46. package/lib/config/versions/magento-2.3.4-p2.js +7 -12
  47. package/lib/config/versions/magento-2.3.4.js +7 -12
  48. package/lib/config/versions/magento-2.3.5-p1.js +5 -9
  49. package/lib/config/versions/magento-2.3.5-p2.js +5 -9
  50. package/lib/config/versions/magento-2.3.5.js +5 -9
  51. package/lib/config/versions/magento-2.3.6-p1.js +5 -9
  52. package/lib/config/versions/magento-2.3.6.js +5 -9
  53. package/lib/config/versions/magento-2.3.7-p1.js +5 -9
  54. package/lib/config/versions/magento-2.3.7-p2.js +5 -9
  55. package/lib/config/versions/magento-2.3.7-p3.js +5 -9
  56. package/lib/config/versions/magento-2.3.7-p4.js +40 -0
  57. package/lib/config/versions/magento-2.3.7.js +5 -9
  58. package/lib/config/versions/magento-2.4.0-p1.js +5 -9
  59. package/lib/config/versions/magento-2.4.0.js +5 -9
  60. package/lib/config/versions/magento-2.4.1-p1.js +5 -9
  61. package/lib/config/versions/magento-2.4.1.js +5 -9
  62. package/lib/config/versions/magento-2.4.2-p1.js +5 -9
  63. package/lib/config/versions/magento-2.4.2-p2.js +5 -9
  64. package/lib/config/versions/magento-2.4.2.js +5 -9
  65. package/lib/config/versions/magento-2.4.3-p1.js +5 -9
  66. package/lib/config/versions/magento-2.4.3-p2.js +5 -9
  67. package/lib/config/versions/magento-2.4.3-p3.js +42 -0
  68. package/lib/config/versions/magento-2.4.3.js +5 -9
  69. package/lib/config/versions/magento-2.4.4-p1.js +42 -0
  70. package/lib/config/versions/magento-2.4.4.js +5 -9
  71. package/lib/config/versions/magento-2.4.5.js +42 -0
  72. package/lib/tasks/cleanup.js +1 -1
  73. package/lib/tasks/composer/local-auth-json.js +1 -1
  74. package/lib/tasks/database/connect-to-database.js +120 -0
  75. package/lib/tasks/database/create-magento-database.js +21 -0
  76. package/lib/tasks/database/create-magento-user.js +50 -0
  77. package/lib/tasks/database/default-magento-database.js +3 -0
  78. package/lib/tasks/database/default-magento-user.js +7 -0
  79. package/lib/tasks/{mysql → database}/dump-theme-config.js +3 -3
  80. package/lib/tasks/{mysql → database}/fix-db.js +2 -2
  81. package/lib/tasks/{mysql/import-dump-to-mysql.js → database/import-dump-to-database.js} +21 -20
  82. package/lib/tasks/{mysql → database}/import-remote-db/index.js +0 -0
  83. package/lib/tasks/{mysql/import-remote-db/ssh/mysqldump-command.js → database/import-remote-db/ssh/database-dump-command.js} +2 -2
  84. package/lib/tasks/{mysql → database}/import-remote-db/ssh/index.js +0 -0
  85. package/lib/tasks/{mysql → database}/import-remote-db/ssh/readymage.js +4 -4
  86. package/lib/tasks/{mysql → database}/import-remote-db/ssh/regular-server.js +2 -2
  87. package/lib/tasks/{mysql → database}/index.js +2 -2
  88. package/lib/tasks/{mysql → database}/magento-tables.js +0 -0
  89. package/lib/tasks/{mysql → database}/restore-theme-config.js +4 -4
  90. package/lib/tasks/docker/api.d.ts +25 -1
  91. package/lib/tasks/docker/api.js +31 -1
  92. package/lib/tasks/docker/containers/container-api.d.ts +18 -0
  93. package/lib/tasks/docker/containers/container-api.js +76 -17
  94. package/lib/tasks/docker/containers/tasks.js +32 -1
  95. package/lib/tasks/docker/convert-legacy-volumes.js +8 -7
  96. package/lib/tasks/docker/convert-mysql-to-mariadb.js +284 -0
  97. package/lib/tasks/docker/index.js +6 -1
  98. package/lib/tasks/docker/network/network-api.d.ts +1 -1
  99. package/lib/tasks/docker/project-image-builder.js +7 -9
  100. package/lib/tasks/docker/volume/index.js +9 -0
  101. package/lib/tasks/docker/volume/tasks.js +94 -0
  102. package/lib/tasks/docker/volume/volume-api.d.ts +49 -0
  103. package/lib/tasks/docker/volume/volume-api.js +90 -0
  104. package/lib/tasks/execute.js +100 -0
  105. package/lib/tasks/file-system/create-mariadb-config.js +23 -0
  106. package/lib/tasks/file-system/create-nginx-config.js +3 -5
  107. package/lib/tasks/file-system/create-php-config.js +2 -23
  108. package/lib/tasks/file-system/create-php-debug-config.js +45 -0
  109. package/lib/tasks/file-system/create-php-fpm-config.js +2 -4
  110. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/php-workspace-project-configuration-config.js +1 -1
  111. package/lib/tasks/file-system/create-ssl-terminator-config.js +4 -7
  112. package/lib/tasks/file-system/create-varnish-config.js +4 -7
  113. package/lib/tasks/file-system/index.js +5 -1
  114. package/lib/tasks/import-dump.js +6 -6
  115. package/lib/tasks/link.js +4 -2
  116. package/lib/tasks/magento/enable-magento-composer-plugins.js +85 -30
  117. package/lib/tasks/magento/install-magento-project.js +3 -2
  118. package/lib/tasks/magento/setup-magento/configure-elasticsearch.js +3 -5
  119. package/lib/tasks/magento/setup-magento/create-admin.js +1 -1
  120. package/lib/tasks/magento/setup-magento/delete-admin-users.js +2 -2
  121. package/lib/tasks/magento/setup-magento/delete-customers.js +4 -4
  122. package/lib/tasks/magento/setup-magento/delete-orders.js +4 -4
  123. package/lib/tasks/magento/setup-magento/flush-redis-config.js +3 -6
  124. package/lib/tasks/magento/setup-magento/increase-admin-session-lifetime.js +2 -2
  125. package/lib/tasks/magento/setup-magento/index.js +2 -0
  126. package/lib/tasks/magento/setup-magento/install-magento.js +15 -17
  127. package/lib/tasks/magento/setup-magento/migrate-database.js +5 -11
  128. package/lib/tasks/magento/setup-magento/set-base-url.js +3 -3
  129. package/lib/tasks/magento/setup-magento/set-url-rewrite.js +2 -2
  130. package/lib/tasks/magento/setup-magento/varnish-config.js +8 -13
  131. package/lib/tasks/magento/setup-magento/waiting-for-varnish.js +17 -16
  132. package/lib/tasks/php/php-container.js +7 -3
  133. package/lib/tasks/php/update-env-php.js +7 -6
  134. package/lib/tasks/php/update-env.php +12 -12
  135. package/lib/tasks/requirements/composer-credentials.js +7 -3
  136. package/lib/tasks/requirements/docker/context.js +88 -0
  137. package/lib/tasks/requirements/docker/index.js +110 -19
  138. package/lib/tasks/requirements/docker/install.js +21 -7
  139. package/lib/tasks/requirements/docker/permissions.js +2 -11
  140. package/lib/tasks/requirements/docker/running-status.js +94 -24
  141. package/lib/tasks/requirements/docker/version.js +1 -0
  142. package/lib/tasks/requirements/index.js +0 -2
  143. package/lib/tasks/requirements/php-version.js +4 -2
  144. package/lib/tasks/start.js +32 -31
  145. package/lib/tasks/status/index.js +17 -13
  146. package/lib/tasks/stop.js +2 -0
  147. package/lib/tasks/theme/link-theme.js +2 -2
  148. package/lib/util/config-file-validator.js +29 -13
  149. package/lib/util/database.js +7 -7
  150. package/lib/util/execute-in-container.js +63 -0
  151. package/lib/util/prefix.js +1 -1
  152. package/lib/util/systemctl.js +62 -13
  153. package/package.json +4 -3
  154. package/typings/context.d.ts +12 -5
  155. package/typings/index.d.ts +69 -31
  156. package/lib/tasks/docker/volumes.js +0 -63
  157. package/lib/tasks/execute/index.js +0 -23
  158. package/lib/tasks/mysql/connect-to-mysql.js +0 -127
  159. package/lib/tasks/mysql/create-magento-database.js +0 -18
  160. package/lib/tasks/requirements/dependency/arch.js +0 -50
  161. package/lib/tasks/requirements/dependency/centos.js +0 -36
  162. package/lib/tasks/requirements/dependency/fedora.js +0 -36
  163. package/lib/tasks/requirements/dependency/index.js +0 -33
  164. package/lib/tasks/requirements/dependency/mac.js +0 -124
  165. package/lib/tasks/requirements/dependency/ubuntu.js +0 -83
@@ -0,0 +1,94 @@
1
+ const fs = require('fs');
2
+ const pathExists = require('../../../util/path-exists');
3
+ const volumeApi = require('./volume-api');
4
+
5
+ /**
6
+ * @type {() => import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
7
+ */
8
+ const createVolumes = () => ({
9
+ title: 'Creating volumes',
10
+ task: async ({ config: { docker } }, task) => {
11
+ const volumeList = await volumeApi.ls({
12
+ formatToJSON: true
13
+ });
14
+
15
+ const missingVolumes = Object.values(docker.volumes).filter(
16
+ ({ name }) => !volumeList.some((v) => v.Name === name)
17
+ );
18
+
19
+ if (missingVolumes.length === 0) {
20
+ task.skip();
21
+ return;
22
+ }
23
+
24
+ await Promise.all(missingVolumes.map(async (volume) => {
25
+ if (volume.opt && volume.opt.device && !await pathExists(volume.opt.device)) {
26
+ await fs.promises.mkdir(volume.opt.device, {
27
+ recursive: true
28
+ });
29
+ }
30
+ }));
31
+
32
+ await Promise.all(missingVolumes.map((volume) => volumeApi.create(volume)));
33
+ }
34
+ });
35
+
36
+ /**
37
+ * @type {() => import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
38
+ */
39
+ const removeVolumes = () => ({
40
+ title: 'Removing volumes',
41
+ task: async ({ config: { docker } }, task) => {
42
+ const volumeList = await volumeApi.ls({
43
+ formatToJSON: true
44
+ });
45
+
46
+ const deployedVolumes = Object.values(docker.volumes).filter(
47
+ ({ name }) => volumeList.some((v) => v.Name === name)
48
+ );
49
+
50
+ if (deployedVolumes.length === 0) {
51
+ task.skip();
52
+ return;
53
+ }
54
+
55
+ await volumeApi.rm({
56
+ volumes: deployedVolumes.map(({ name }) => name)
57
+ });
58
+ }
59
+ });
60
+
61
+ /**
62
+ * @type {() => import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
63
+ */
64
+ const removeLocalVolumes = () => ({
65
+ title: 'Removing local volumes',
66
+ task: async (ctx, task) => {
67
+ const volumeList = await volumeApi.ls({
68
+ formatToJSON: true
69
+ });
70
+ const { volumes } = ctx.config.docker;
71
+
72
+ const localVolumes = Object.values(volumes).filter(
73
+ (volume) => volume.opt && volume.opt.device
74
+ );
75
+
76
+ const existingLocalVolumes = localVolumes.filter(
77
+ (volume) => volumeList.some((v) => v.Name === volume.name)
78
+ );
79
+
80
+ if (existingLocalVolumes.length > 0) {
81
+ await volumeApi.rm({
82
+ volumes: existingLocalVolumes.map((volume) => volume.name)
83
+ });
84
+ } else {
85
+ task.skip();
86
+ }
87
+ }
88
+ });
89
+
90
+ module.exports = {
91
+ createVolumes,
92
+ removeVolumes,
93
+ removeLocalVolumes
94
+ };
@@ -0,0 +1,49 @@
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>
40
+
41
+ export interface VolumeRmOptions {
42
+ force?: boolean
43
+ volumes: string[]
44
+ }
45
+
46
+ export function rm(
47
+ options?: VolumeRmOptions,
48
+ execOptions?: ExecAsyncSpawnOptions<false>
49
+ ): Promise<string>
@@ -0,0 +1,90 @@
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
+ /**
64
+ * @param {import('./volume-api').VolumeRmOptions} options
65
+ * @param {import('../../../util/exec-async-command').ExecAsyncSpawnOptions} execOptions
66
+ */
67
+ const rm = async (options, execOptions = {}) => {
68
+ const {
69
+ force,
70
+ volumes
71
+ } = options;
72
+
73
+ const forceArg = force && '--force';
74
+
75
+ const command = [
76
+ 'docker',
77
+ 'volume',
78
+ 'rm',
79
+ forceArg,
80
+ ...volumes
81
+ ].filter(Boolean).join(' ');
82
+
83
+ return execAsyncSpawn(command, execOptions);
84
+ };
85
+
86
+ module.exports = {
87
+ create,
88
+ ls,
89
+ rm
90
+ };
@@ -0,0 +1,100 @@
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 dockerNetwork = require('./docker/network');
11
+ const KnownError = require('../errors/known-error');
12
+
13
+ /**
14
+ *
15
+ * @param {{ containername: string, commands?: string[] }} argv
16
+ * @returns
17
+ */
18
+ const executeTask = async (argv) => {
19
+ const tasks = new Listr([
20
+ checkRequirements(),
21
+ getMagentoVersionConfig(),
22
+ checkConfigurationFile(),
23
+ getProjectConfiguration(),
24
+ getCachedPorts(),
25
+ dockerNetwork.tasks.createNetwork()
26
+ ], {
27
+ concurrent: false,
28
+ exitOnError: true,
29
+ ctx: { throwMagentoVersionMissing: true },
30
+ rendererOptions: { collapse: false, clearOutput: true }
31
+ });
32
+
33
+ let ctx;
34
+ try {
35
+ ctx = await tasks.run();
36
+ } catch (e) {
37
+ logger.error(e.message || e);
38
+ process.exit(1);
39
+ }
40
+ const containers = ctx.config.docker.getContainers(ctx.ports);
41
+ const services = Object.keys(containers);
42
+
43
+ if (services.includes(argv.containername) || services.some((service) => service.includes(argv.containername))) {
44
+ /**
45
+ * @type {import('./docker/containers/container-api').ContainerRunOptions}
46
+ */
47
+ const container = containers[argv.containername]
48
+ ? containers[argv.containername]
49
+ : Object.entries(containers).find(([key]) => key.includes(argv.containername))[1];
50
+
51
+ if (argv.commands.length === 0) {
52
+ // if we have default connect command then use it
53
+ if (container.connectCommand) {
54
+ // eslint-disable-next-line no-param-reassign
55
+ argv.commands = container.connectCommand;
56
+ } else {
57
+ // otherwise fall back to bash (if it exists inside container)
58
+ argv.commands.push('bash');
59
+ }
60
+ }
61
+
62
+ const containerList = await containerApi.ls({
63
+ formatToJSON: true,
64
+ all: true,
65
+ filter: `name=${container.name}`
66
+ });
67
+
68
+ if (containerList.length > 0) {
69
+ logger.logN(`Executing container ${logger.style.misc(container._)} (command: ${logger.style.command(argv.commands.join(' '))})`);
70
+ const result = await executeInContainer({
71
+ containerName: container.name,
72
+ commands: argv.commands,
73
+ isDockerDesktop: ctx.isDockerDesktop
74
+ });
75
+
76
+ return result;
77
+ }
78
+
79
+ if (container.name.endsWith('php')) {
80
+ logger.logN(`Starting container ${logger.style.misc(container._)} with command: ${logger.style.command(argv.commands.join(' '))}`);
81
+ const result = await runInContainer(
82
+ {
83
+ ...container,
84
+ name: `${container.name}_exec-${Date.now()}`
85
+ },
86
+ argv.commands
87
+ );
88
+
89
+ return result;
90
+ }
91
+
92
+ throw new KnownError(`Container ${container.name} is not running!`);
93
+ }
94
+
95
+ logger.error(`No container found "${argv.containername}"`);
96
+ };
97
+
98
+ module.exports = {
99
+ executeTask
100
+ };
@@ -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;
@@ -14,7 +14,7 @@ const createNginxConfig = () => ({
14
14
  overridenConfiguration,
15
15
  baseConfig
16
16
  },
17
- isWsl
17
+ isDockerDesktop
18
18
  } = ctx;
19
19
 
20
20
  const {
@@ -23,10 +23,8 @@ const createNginxConfig = () => ({
23
23
  }
24
24
  } = overridenConfiguration;
25
25
 
26
- const isLinux = ctx.platform === 'linux';
27
- const isNativeLinux = isLinux && !isWsl;
28
- const hostMachine = isNativeLinux ? '127.0.0.1' : 'host.docker.internal';
29
- const hostPort = isNativeLinux ? ports.app : 80;
26
+ const hostMachine = !isDockerDesktop ? '127.0.0.1' : 'host.docker.internal';
27
+ const hostPort = !isDockerDesktop ? ports.app : 80;
30
28
 
31
29
  try {
32
30
  await setConfigFile({
@@ -1,7 +1,5 @@
1
- const semver = require('semver');
2
1
  const UnknownError = require('../../errors/unknown-error');
3
2
  const setConfigFile = require('../../util/set-config');
4
- const { getEnabledExtensionsFromImage } = require('../docker/project-image-builder');
5
3
 
6
4
  /**
7
5
  * @type {() => import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
@@ -9,32 +7,13 @@ const { getEnabledExtensionsFromImage } = require('../docker/project-image-build
9
7
  const createPhpConfig = () => ({
10
8
  title: 'Setting PHP config',
11
9
  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';
10
+ const { config: { php } } = ctx;
26
11
 
27
12
  try {
28
13
  await setConfigFile({
29
14
  configPathname: php.iniPath,
30
15
  template: php.iniTemplatePath,
31
- overwrite: true,
32
- templateArgs: {
33
- debug,
34
- mageRoot: baseConfig.containerMagentoDir,
35
- isXDebug2,
36
- hostMachine
37
- }
16
+ overwrite: true
38
17
  });
39
18
  } catch (e) {
40
19
  throw new UnknownError(`Unexpected error accrued during php.ini config creation\n\n${e}`);
@@ -0,0 +1,45 @@
1
+ const semver = require('semver');
2
+ const UnknownError = require('../../errors/unknown-error');
3
+ const setConfigFile = require('../../util/set-config');
4
+ const { getEnabledExtensionsFromImage } = require('../docker/project-image-builder');
5
+
6
+ /**
7
+ * @type {() => import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
8
+ */
9
+ const createPhpDebugConfig = () => ({
10
+ title: 'Setting PHP XDebug config',
11
+ skip: (ctx) => !ctx.debug,
12
+ task: async (ctx) => {
13
+ const {
14
+ config: {
15
+ php,
16
+ baseConfig
17
+ },
18
+ debug,
19
+ isDockerDesktop
20
+ } = ctx;
21
+ const containers = ctx.config.docker.getContainers(ctx.ports);
22
+ const phpExtensions = await getEnabledExtensionsFromImage(containers.php.debugImage);
23
+ const isXDebug2 = semver.satisfies(phpExtensions.xdebug, '2');
24
+
25
+ const hostMachine = !isDockerDesktop ? '127.0.0.1' : 'host.docker.internal';
26
+
27
+ try {
28
+ await setConfigFile({
29
+ configPathname: php.debugIniPath,
30
+ template: php.debugTemplatePath,
31
+ overwrite: true,
32
+ templateArgs: {
33
+ debug,
34
+ mageRoot: baseConfig.containerMagentoDir,
35
+ isXDebug2,
36
+ hostMachine
37
+ }
38
+ });
39
+ } catch (e) {
40
+ throw new UnknownError(`Unexpected error accrued during xdebug.ini config creation\n\n${e}`);
41
+ }
42
+ }
43
+ });
44
+
45
+ module.exports = createPhpDebugConfig;
@@ -7,10 +7,8 @@ const setConfigFile = require('../../util/set-config');
7
7
  const createPhpFpmConfig = () => ({
8
8
  title: 'Setting php-fpm config',
9
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;
10
+ const { config: { php }, isDockerDesktop } = ctx;
11
+ const port = !isDockerDesktop ? ctx.ports.fpm : 9000;
14
12
 
15
13
  try {
16
14
  await setConfigFile({
@@ -31,7 +31,7 @@ const setupPHPWorkspaceProjectConfiguration = async (workspaceConfigs, ctx) => {
31
31
  hasChanges = true;
32
32
  workspaceConfigs.push({
33
33
  [nameKey]: PHP_WORKSPACE_PROJECT_CONFIGURATION_COMPONENT_NAME,
34
- [currentInterpreterImage]: currentInterpreterImage,
34
+ [interpreterNameKey]: currentInterpreterImage,
35
35
  include_path: []
36
36
  });
37
37
  }
@@ -1,4 +1,3 @@
1
- const os = require('os');
2
1
  const path = require('path');
3
2
  const fs = require('fs');
4
3
  const setConfigFile = require('../../util/set-config');
@@ -19,8 +18,8 @@ const createSSLTerminatorConfig = () => ({
19
18
  overridenConfiguration,
20
19
  baseConfig
21
20
  },
22
- isWsl,
23
- debug
21
+ debug,
22
+ isDockerDesktop
24
23
  } = ctx;
25
24
 
26
25
  const {
@@ -65,10 +64,8 @@ const createSSLTerminatorConfig = () => ({
65
64
  }
66
65
 
67
66
  const networkToBindTo = isIpAddress(host) ? host : '127.0.0.1';
68
- const isLinux = os.platform() === 'linux';
69
- const isNativeLinux = isLinux && !isWsl;
70
- const hostMachine = isNativeLinux ? '127.0.0.1' : 'host.docker.internal';
71
- const hostPort = isNativeLinux ? ports.sslTerminator : 80;
67
+ const hostMachine = !isDockerDesktop ? '127.0.0.1' : 'host.docker.internal';
68
+ const hostPort = !isDockerDesktop ? ports.sslTerminator : 80;
72
69
 
73
70
  try {
74
71
  await setConfigFile({
@@ -17,8 +17,7 @@ const createVarnishConfig = () => ({
17
17
  cacheDir
18
18
  }
19
19
  },
20
- isWsl,
21
- platform
20
+ isDockerDesktop
22
21
  } = ctx;
23
22
 
24
23
  const {
@@ -27,9 +26,6 @@ const createVarnishConfig = () => ({
27
26
  }
28
27
  } = overridenConfiguration;
29
28
 
30
- const isLinux = platform === 'linux';
31
- const isNativeLinux = isLinux && !isWsl;
32
-
33
29
  try {
34
30
  await setConfigFile({
35
31
  configPathname: path.join(
@@ -40,8 +36,9 @@ const createVarnishConfig = () => ({
40
36
  template: varnish.configTemplate,
41
37
  overwrite: true,
42
38
  templateArgs: {
43
- hostMachine: isNativeLinux ? '127.0.0.1' : 'host.docker.internal',
44
- nginxPort: ports.app
39
+ hostMachine: !isDockerDesktop ? '127.0.0.1' : 'host.docker.internal',
40
+ nginxPort: ports.app,
41
+ healthCheck: varnish.healthCheck
45
42
  }
46
43
  });
47
44
  } catch (e) {
@@ -1,5 +1,7 @@
1
+ const createMariaDBConfig = require('./create-mariadb-config');
1
2
  const createNginxConfig = require('./create-nginx-config');
2
3
  const createPhpConfig = require('./create-php-config');
4
+ const createPhpDebugConfig = require('./create-php-debug-config');
3
5
  const createPhpFpmConfig = require('./create-php-fpm-config');
4
6
  const createPhpStormConfig = require('./create-phpstorm-config');
5
7
  const createSSLTerminatorConfig = require('./create-ssl-terminator-config');
@@ -16,9 +18,11 @@ const prepareFileSystem = () => ({
16
18
  createNginxConfig(),
17
19
  createPhpFpmConfig(),
18
20
  createPhpConfig(),
21
+ createPhpDebugConfig(),
19
22
  createPhpStormConfig(),
20
23
  createVSCodeConfig(),
21
- createVarnishConfig()
24
+ createVarnishConfig(),
25
+ createMariaDBConfig()
22
26
  ], {
23
27
  concurrent: true,
24
28
  exitOnError: false
@@ -1,11 +1,11 @@
1
1
  const path = require('path');
2
2
  const { checkRequirements } = require('./requirements');
3
3
  const {
4
- importDumpToMySQL,
4
+ importDumpToDatabase,
5
5
  fixDB,
6
6
  dumpThemeConfig,
7
7
  restoreThemeConfig
8
- } = require('./mysql');
8
+ } = require('./database');
9
9
  const { setupMagento } = require('./magento');
10
10
  const indexProducts = require('./magento/setup-magento/index-products');
11
11
  const {
@@ -14,7 +14,7 @@ const {
14
14
  retrieveFreshProjectConfiguration,
15
15
  configureProject
16
16
  } = require('./start');
17
- const importRemoteDb = require('./mysql/import-remote-db');
17
+ const importRemoteDb = require('./database/import-remote-db');
18
18
  const matchFilesystem = require('../util/match-filesystem');
19
19
 
20
20
  /**
@@ -34,8 +34,8 @@ const importDump = () => ({
34
34
  // skip setup if env.php and config.php are present in app/etc folder and db is not empty
35
35
  skip: async (ctx) => {
36
36
  const isFsMatching = await matchFilesystem(path.join(process.cwd(), 'app', 'etc'), ['config.php', 'env.php']);
37
- const { mysqlConnection } = ctx;
38
- const [[{ tableCount }]] = await mysqlConnection.query(`
37
+ const { databaseConnection } = ctx;
38
+ const [[{ tableCount }]] = await databaseConnection.query(`
39
39
  SELECT count(*) AS tableCount
40
40
  FROM INFORMATION_SCHEMA.TABLES
41
41
  WHERE TABLE_SCHEMA = 'magento';
@@ -48,7 +48,7 @@ const importDump = () => ({
48
48
  )
49
49
  },
50
50
  dumpThemeConfig(),
51
- importDumpToMySQL(),
51
+ importDumpToDatabase(),
52
52
  restoreThemeConfig(),
53
53
  fixDB(),
54
54
  setupMagento(),
package/lib/tasks/link.js CHANGED
@@ -5,20 +5,22 @@ const retrieveThemeData = require('./theme/retrieve-theme-data');
5
5
  const linkTheme = require('./theme/link-theme');
6
6
  const { startServices } = require('./docker');
7
7
  const checkConfigurationFile = require('../config/check-configuration-file');
8
- const { connectToMySQL } = require('./mysql');
8
+ const { connectToDatabase } = require('./database');
9
+ const { checkRequirements } = require('./requirements');
9
10
 
10
11
  /**
11
12
  * @type {(theme: string) => import('listr2').ListrTask<import('../../typings/context').ListrContext>}
12
13
  */
13
14
  const linkTask = (themePath) => ({
14
15
  task: (ctx, task) => task.newListr([
16
+ checkRequirements(),
15
17
  getMagentoVersionConfig(),
16
18
  checkConfigurationFile(),
17
19
  getProjectConfiguration(),
18
20
  getCachedPorts(),
19
21
  startServices(),
20
22
  // startPhpFpm(),
21
- connectToMySQL(),
23
+ connectToDatabase(),
22
24
  retrieveThemeData(themePath),
23
25
  linkTheme()
24
26
  ])