@scandipwa/magento-scripts 2.0.0-alpha.2 → 2.0.0-alpha.20

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 (144) hide show
  1. package/exec.js +71 -0
  2. package/index.js +1 -1
  3. package/lib/commands/cli.js +14 -1
  4. package/lib/commands/execute.js +2 -57
  5. package/lib/commands/start.js +24 -3
  6. package/lib/commands/status.js +9 -1
  7. package/lib/config/config.js +20 -2
  8. package/lib/config/docker.js +86 -53
  9. package/lib/config/get-project-configuration.js +5 -0
  10. package/lib/config/index.js +10 -3
  11. package/lib/config/php/versions/php-7.2.js +1 -0
  12. package/lib/config/php/versions/php-7.3.js +1 -0
  13. package/lib/config/php/versions/php-7.4.js +1 -0
  14. package/lib/config/php/versions/php-8.1.js +1 -0
  15. package/lib/config/php-config.js +4 -3
  16. package/lib/config/port-config.js +3 -1
  17. package/lib/config/services/composer/versions/composer-1.js +13 -0
  18. package/lib/config/services/composer/versions/composer-2.js +8 -0
  19. package/lib/config/services/composer/versions/index.js +4 -0
  20. package/lib/config/services/maildev/index.js +7 -0
  21. package/lib/config/services/nginx/versions/index.js +3 -0
  22. package/lib/config/services/nginx/versions/nginx-1.18.js +11 -0
  23. package/lib/config/{ssl-terminator → services/ssl-terminator}/index.js +3 -0
  24. package/lib/config/templates/magentorc.template +6 -5
  25. package/lib/config/templates/php-debug.template.ini +31 -0
  26. package/lib/config/templates/php-fpm.template.conf +1 -2
  27. package/lib/config/templates/php.template.ini +5 -201
  28. package/lib/config/templates/ssl-terminator.template.conf +10 -3
  29. package/lib/config/templates/varnish.template.vcl +20 -13
  30. package/lib/config/varnish/varnish-6-0.js +4 -0
  31. package/lib/config/varnish/varnish-6-6.js +4 -0
  32. package/lib/config/varnish/varnish-7-0.js +4 -0
  33. package/lib/config/versions/magento-2.2.10.js +41 -0
  34. package/lib/config/versions/magento-2.3.0.js +8 -10
  35. package/lib/config/versions/magento-2.3.1.js +8 -10
  36. package/lib/config/versions/magento-2.3.2-p1.js +8 -10
  37. package/lib/config/versions/magento-2.3.2-p2.js +8 -10
  38. package/lib/config/versions/magento-2.3.2.js +8 -10
  39. package/lib/config/versions/magento-2.3.3-p1.js +8 -10
  40. package/lib/config/versions/magento-2.3.3.js +8 -10
  41. package/lib/config/versions/magento-2.3.4-p1.js +8 -10
  42. package/lib/config/versions/magento-2.3.4-p2.js +8 -10
  43. package/lib/config/versions/magento-2.3.4.js +8 -10
  44. package/lib/config/versions/magento-2.3.5-p1.js +8 -10
  45. package/lib/config/versions/magento-2.3.5-p2.js +8 -10
  46. package/lib/config/versions/magento-2.3.5.js +8 -10
  47. package/lib/config/versions/magento-2.3.6-p1.js +8 -10
  48. package/lib/config/versions/magento-2.3.6.js +8 -10
  49. package/lib/config/versions/magento-2.3.7-p1.js +8 -10
  50. package/lib/config/versions/magento-2.3.7-p2.js +8 -10
  51. package/lib/config/versions/magento-2.3.7-p3.js +8 -10
  52. package/lib/config/versions/magento-2.3.7-p4.js +42 -0
  53. package/lib/config/versions/magento-2.3.7.js +8 -10
  54. package/lib/config/versions/magento-2.4.0-p1.js +8 -10
  55. package/lib/config/versions/magento-2.4.0.js +8 -10
  56. package/lib/config/versions/magento-2.4.1-p1.js +8 -10
  57. package/lib/config/versions/magento-2.4.1.js +8 -10
  58. package/lib/config/versions/magento-2.4.2-p1.js +8 -10
  59. package/lib/config/versions/magento-2.4.2-p2.js +8 -10
  60. package/lib/config/versions/magento-2.4.2.js +8 -10
  61. package/lib/config/versions/magento-2.4.3-p1.js +8 -10
  62. package/lib/config/versions/magento-2.4.3-p2.js +8 -10
  63. package/lib/config/versions/magento-2.4.3-p3.js +44 -0
  64. package/lib/config/versions/magento-2.4.3.js +8 -10
  65. package/lib/config/versions/magento-2.4.4-p1.js +44 -0
  66. package/lib/config/versions/magento-2.4.4.js +8 -10
  67. package/lib/config/versions/magento-2.4.5.js +44 -0
  68. package/lib/tasks/cli/create-bashrc-config.js +1 -1
  69. package/lib/tasks/composer/local-auth-json.js +1 -1
  70. package/lib/tasks/database/connect-to-database.js +6 -3
  71. package/lib/tasks/database/create-magento-database.js +5 -2
  72. package/lib/tasks/database/create-magento-user.js +50 -0
  73. package/lib/tasks/database/default-magento-database.js +3 -0
  74. package/lib/tasks/database/default-magento-user.js +7 -0
  75. package/lib/tasks/database/import-dump-to-database.js +3 -2
  76. package/lib/tasks/docker/api.d.ts +25 -1
  77. package/lib/tasks/docker/api.js +31 -1
  78. package/lib/tasks/docker/containers/container-api.d.ts +21 -0
  79. package/lib/tasks/docker/containers/container-api.js +82 -17
  80. package/lib/tasks/docker/containers/tasks.js +44 -13
  81. package/lib/tasks/docker/convert-composer-home-to-composer-cache-volume.js +52 -0
  82. package/lib/tasks/docker/convert-mysql-to-mariadb.js +2 -2
  83. package/lib/tasks/docker/image/image-api.d.ts +44 -0
  84. package/lib/tasks/docker/image/image-api.js +30 -2
  85. package/lib/tasks/docker/index.js +6 -1
  86. package/lib/tasks/docker/project-image-builder.js +36 -13
  87. package/lib/tasks/docker/system/index.js +5 -0
  88. package/lib/tasks/docker/system/system-api.d.ts +71 -0
  89. package/lib/tasks/docker/system/system-api.js +29 -0
  90. package/lib/tasks/docker/volume/index.js +2 -1
  91. package/lib/tasks/docker/volume/tasks.js +67 -9
  92. package/lib/tasks/docker/volume/volume-api.d.ts +40 -0
  93. package/lib/tasks/docker/volume/volume-api.js +54 -1
  94. package/lib/tasks/execute.js +100 -0
  95. package/lib/tasks/file-system/create-nginx-config.js +3 -5
  96. package/lib/tasks/file-system/create-php-config.js +2 -23
  97. package/lib/tasks/file-system/create-php-debug-config.js +45 -0
  98. package/lib/tasks/file-system/create-php-fpm-config.js +2 -4
  99. package/lib/tasks/file-system/create-phpstorm-config/exclude-folder-config.js +13 -3
  100. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/php-workspace-project-configuration-config.js +1 -1
  101. package/lib/tasks/file-system/create-ssl-terminator-config.js +4 -7
  102. package/lib/tasks/file-system/create-varnish-config.js +4 -7
  103. package/lib/tasks/file-system/index.js +2 -0
  104. package/lib/tasks/magento/enable-magento-composer-plugins.js +85 -30
  105. package/lib/tasks/magento/install-magento-project.js +3 -2
  106. package/lib/tasks/magento/setup-magento/configure-elasticsearch.js +2 -4
  107. package/lib/tasks/magento/setup-magento/flush-redis-config.js +3 -6
  108. package/lib/tasks/magento/setup-magento/index.js +2 -0
  109. package/lib/tasks/magento/setup-magento/install-magento.js +8 -10
  110. package/lib/tasks/magento/setup-magento/set-base-url.js +1 -1
  111. package/lib/tasks/magento/setup-magento/set-mail-config.js +26 -0
  112. package/lib/tasks/magento/setup-magento/varnish-config.js +4 -9
  113. package/lib/tasks/magento/setup-magento/waiting-for-varnish.js +17 -16
  114. package/lib/tasks/php/php-container.js +7 -3
  115. package/lib/tasks/php/update-env-php.js +3 -4
  116. package/lib/tasks/{prefix → project-config}/index.js +6 -6
  117. package/lib/tasks/requirements/composer-credentials.js +7 -3
  118. package/lib/tasks/requirements/docker/context.js +88 -0
  119. package/lib/tasks/requirements/docker/index.js +114 -20
  120. package/lib/tasks/requirements/docker/install.js +21 -7
  121. package/lib/tasks/requirements/docker/permissions.js +2 -11
  122. package/lib/tasks/requirements/docker/running-status.js +94 -24
  123. package/lib/tasks/requirements/docker/version.js +1 -0
  124. package/lib/tasks/requirements/index.js +0 -2
  125. package/lib/tasks/requirements/php-version.js +4 -2
  126. package/lib/tasks/start.js +27 -8
  127. package/lib/tasks/status/index.js +29 -20
  128. package/lib/tasks/stop.js +2 -0
  129. package/lib/tasks/theme/retrieve-theme-data.js +11 -1
  130. package/lib/util/config-file-validator.js +15 -2
  131. package/lib/util/execute-in-container.js +62 -0
  132. package/lib/util/instance-metadata.js +14 -2
  133. package/lib/util/systemctl.js +62 -13
  134. package/package.json +4 -3
  135. package/typings/context.d.ts +11 -0
  136. package/typings/index.d.ts +42 -1
  137. package/lib/tasks/execute/index.js +0 -26
  138. package/lib/tasks/requirements/dependency/arch.js +0 -50
  139. package/lib/tasks/requirements/dependency/centos.js +0 -36
  140. package/lib/tasks/requirements/dependency/fedora.js +0 -36
  141. package/lib/tasks/requirements/dependency/index.js +0 -33
  142. package/lib/tasks/requirements/dependency/mac.js +0 -124
  143. package/lib/tasks/requirements/dependency/ubuntu.js +0 -83
  144. package/yarn-error.log +0 -9660
@@ -2,7 +2,7 @@ const os = require('os');
2
2
  const fs = require('fs');
3
3
  const logger = require('@scandipwa/scandipwa-dev-utils/logger');
4
4
  const pathExists = require('../../../util/path-exists');
5
- const { execCommandTask } = require('../../../util/exec-async-command');
5
+ const executeSudoCommand = require('../../../util/execute-sudo-command');
6
6
 
7
7
  const dockerSocketPath = '/var/run/docker.sock';
8
8
 
@@ -33,16 +33,7 @@ Otherwise installation will likely fail.`
33
33
  });
34
34
 
35
35
  if (confirmPrompt) {
36
- task.output = 'Enter your sudo password!';
37
- task.output = logger.style.command(`>[sudo] password for ${ os.userInfo().username }:`);
38
- return task.newListr(
39
- execCommandTask(fixCommand, {
40
- callback: (t) => {
41
- task.output = t;
42
- },
43
- pipeInput: true
44
- })
45
- );
36
+ return task.newListr(executeSudoCommand(fixCommand));
46
37
  }
47
38
  task.skip(`Permission issue detected in ${ logger.style.file(dockerSocketPath) } but user decided not to fix it.`);
48
39
  }
@@ -10,6 +10,41 @@ const getDockerVersion = () => execAsyncSpawn('docker version --format {{.Server
10
10
  withCode: true
11
11
  });
12
12
 
13
+ const getDockerEngineAndDesktopServiceStatus = async () => {
14
+ const dockerEngineService = systemctlControl('docker');
15
+ const dockerDesktopService = systemctlControl('docker-desktop', { user: true });
16
+ const [
17
+ dockerEngineServiceExists,
18
+ dockerDesktopServiceExists,
19
+ dockerEngineServiceIsRunning,
20
+ dockerDesktopServiceIsRunning,
21
+ dockerEngineServiceIsEnabled,
22
+ dockerDesktopServiceIsEnabled
23
+ ] = await Promise.all([
24
+ dockerEngineService.exists(),
25
+ dockerDesktopService.exists(),
26
+ dockerEngineService.isRunning(),
27
+ dockerDesktopService.isRunning(),
28
+ dockerEngineService.isEnabled(),
29
+ dockerDesktopService.isEnabled()
30
+ ]);
31
+
32
+ return {
33
+ engine: {
34
+ service: dockerEngineService,
35
+ exists: dockerEngineServiceExists,
36
+ isRunning: dockerEngineServiceIsRunning,
37
+ isEnabled: dockerEngineServiceIsEnabled
38
+ },
39
+ desktop: {
40
+ service: dockerDesktopService,
41
+ exists: dockerDesktopServiceExists,
42
+ isRunning: dockerDesktopServiceIsRunning,
43
+ isEnabled: dockerDesktopServiceIsEnabled
44
+ }
45
+ };
46
+ };
47
+
13
48
  /**
14
49
  * @type {() => import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
15
50
  */
@@ -81,39 +116,71 @@ Please open Docker Desktop application for Windows and make sure that Docker is
81
116
  const checkDockerStatusLinux = () => ({
82
117
  title: 'Checking Docker status on Linux',
83
118
  task: async (ctx, task) => {
84
- const dockerService = systemctlControl('docker');
119
+ const {
120
+ engine,
121
+ desktop
122
+ } = await getDockerEngineAndDesktopServiceStatus();
123
+
124
+ if (engine.exists) {
125
+ if (!engine.isEnabled && !engine.isRunning) {
126
+ const dockerStartConfirmation = await task.prompt({
127
+ type: 'Confirm',
128
+ message: `Looks like Docker Engine is not enabled and not running, would you like to enable and run it?
85
129
 
86
- const isRunning = await dockerService.isRunning();
87
- const isEnabled = await dockerService.isEnabled();
130
+ This action requires root privileges.`
131
+ });
132
+
133
+ if (dockerStartConfirmation) {
134
+ await engine.service.enableAndStart();
88
135
 
89
- if (!isEnabled && !isRunning) {
90
- const dockerStartConfirmation = await task.prompt({
91
- type: 'Confirm',
92
- message: `Looks like Docker is not enabled and not running, would you like to enable and run it?
136
+ return;
137
+ }
138
+ task.skip('User skipped running Docker');
139
+ } else if (!engine.isRunning) {
140
+ const dockerStartConfirmation = await task.prompt({
141
+ type: 'Confirm',
142
+ message: `Looks like Docker Engine is not running, would you like to run it?
93
143
 
94
- This action requires root privileges.`
95
- });
144
+ This action requires root privileges.`
145
+ });
96
146
 
97
- if (dockerStartConfirmation) {
98
- await dockerService.enableAndStart();
147
+ if (dockerStartConfirmation) {
148
+ await engine.service.start();
99
149
 
100
- return;
150
+ return;
151
+ }
152
+ task.skip('User skipped running Docker Engine');
101
153
  }
102
- task.skip('User skipped running Docker');
103
- } else if (!isRunning) {
104
- const dockerStartConfirmation = await task.prompt({
105
- type: 'Confirm',
106
- message: `Looks like Docker is not running, would you like to run it?
154
+ } else if (desktop.exists) {
155
+ if (!desktop.isEnabled && !desktop.isRunning) {
156
+ const dockerStartConfirmation = await task.prompt({
157
+ type: 'Confirm',
158
+ message: `Looks like Docker Desktop is not enabled and not running, would you like to enable and run it?
159
+
160
+ This action requires root privileges.`
161
+ });
162
+
163
+ if (dockerStartConfirmation) {
164
+ await desktop.service.enableAndStart();
165
+
166
+ return;
167
+ }
168
+ task.skip('User skipped running Docker');
169
+ } else if (!desktop.isRunning) {
170
+ const dockerStartConfirmation = await task.prompt({
171
+ type: 'Confirm',
172
+ message: `Looks like Docker Desktop is not running, would you like to run it?
107
173
 
108
- This action requires root privileges.`
109
- });
174
+ This action requires root privileges.`
175
+ });
110
176
 
111
- if (dockerStartConfirmation) {
112
- await dockerService.start();
177
+ if (dockerStartConfirmation) {
178
+ await desktop.service.start();
113
179
 
114
- return;
180
+ return;
181
+ }
182
+ task.skip('User skipped running Docker Desktop');
115
183
  }
116
- task.skip('User skipped running Docker');
117
184
  }
118
185
  }
119
186
  });
@@ -135,4 +202,7 @@ const checkDockerStatus = () => ({
135
202
  }
136
203
  });
137
204
 
138
- module.exports = checkDockerStatus;
205
+ module.exports = {
206
+ checkDockerStatus,
207
+ getDockerEngineAndDesktopServiceStatus
208
+ };
@@ -14,6 +14,7 @@ const getDockerVersion = () => ({
14
14
  ctx.dockerServerData = dockerVersion.Server;
15
15
  ctx.dockerClientData = dockerVersion.Client;
16
16
  ctx.dockerVersion = dockerVersion.Server.Version;
17
+ ctx.isDockerDesktop = dockerVersion.Server.Platform.Name.includes('Desktop');
17
18
  } else {
18
19
  throw new UnknownError(`Got unexpected result during Docker version retrieval!\n\n${ dockerVersion }`);
19
20
  }
@@ -19,8 +19,6 @@ const checkRequirements = () => ({
19
19
  checkDocker(),
20
20
  // check for Node.js version
21
21
  checkNodeVersion(),
22
- // check installed PHP version
23
- // checkPHPVersion(),
24
22
  // check for COMPOSER_AUTH or auth.json
25
23
  localAuthJson(),
26
24
  checkComposerCredentials()
@@ -7,8 +7,10 @@ const { runContainerImage } = require('../../util/run-container-image');
7
7
  const checkPHPVersion = () => ({
8
8
  title: 'Checking container PHP version',
9
9
  task: async (ctx, task) => {
10
- const { php } = ctx.config.docker.getContainers(ctx.ports);
11
- const phpVersionResponse = await runContainerImage(php.image, 'php --version');
10
+ const phpVersionResponse = await runContainerImage(
11
+ ctx.config.overridenConfiguration.configuration.php.baseImage,
12
+ 'php --version'
13
+ );
12
14
 
13
15
  const phpVersionResponseResult = phpVersionResponse.match(/PHP\s(\d+\.\d+\.\d+)/i);
14
16
 
@@ -11,7 +11,6 @@ const { prepareFileSystem } = require('./file-system');
11
11
  const { installMagentoProject, setupMagento } = require('./magento');
12
12
  const { pullImages, stopContainers } = require('./docker/containers');
13
13
  const dockerNetwork = require('./docker/network');
14
- const { setPrefix } = require('./prefix');
15
14
  const { connectToDatabase } = require('./database');
16
15
  const { buildProjectImage, buildDebugProjectImage } = require('./docker/project-image-builder');
17
16
  const getProjectConfiguration = require('../config/get-project-configuration');
@@ -28,6 +27,19 @@ const waitingForVarnish = require('./magento/setup-magento/waiting-for-varnish')
28
27
  const checkPHPVersion = require('./requirements/php-version');
29
28
  const volumes = require('./docker/volume/tasks');
30
29
  const convertMySQLDatabaseToMariaDB = require('./docker/convert-mysql-to-mariadb');
30
+ const { cmaGlobalConfig } = require('../config/cma-config');
31
+ const { setProjectConfigTask } = require('./project-config');
32
+ const { convertComposerHomeToComposerCacheVolume } = require('./docker/convert-composer-home-to-composer-cache-volume');
33
+
34
+ /**
35
+ * @type {() => import('listr2').ListrTask<import('../../typings/context').ListrContext>}
36
+ */
37
+ const resetCmaGlobalConfig = () => ({
38
+ skip: (ctx) => !ctx.resetGlobalConfig,
39
+ task: () => {
40
+ cmaGlobalConfig.clear();
41
+ }
42
+ });
31
43
 
32
44
  /**
33
45
  * @type {() => import('listr2').ListrTask<import('../../typings/context').ListrContext>}
@@ -39,7 +51,6 @@ const retrieveProjectConfiguration = () => ({
39
51
  checkConfigurationFile(),
40
52
  getProjectConfiguration(),
41
53
  convertLegacyVolumes(),
42
- convertMySQLDatabaseToMariaDB(),
43
54
  createCacheFolder(),
44
55
  getSystemConfigTask(),
45
56
  getCachedPorts()
@@ -59,7 +70,8 @@ const retrieveProjectConfiguration = () => ({
59
70
  const stopProject = () => ({
60
71
  title: 'Stopping project',
61
72
  task: (ctx, task) => task.newListr([
62
- stopContainers()
73
+ stopContainers(),
74
+ volumes.removeLocalVolumes()
63
75
  ]),
64
76
  options: {
65
77
  showTimer: false
@@ -72,7 +84,7 @@ const stopProject = () => ({
72
84
  const retrieveFreshProjectConfiguration = () => ({
73
85
  title: 'Retrieving fresh project configuration',
74
86
  task: (ctx, task) => task.newListr([
75
- setPrefix(),
87
+ setProjectConfigTask(),
76
88
  getProjectConfiguration(),
77
89
  // get fresh ports
78
90
  getAvailablePorts(),
@@ -93,9 +105,14 @@ const retrieveFreshProjectConfiguration = () => ({
93
105
  const configureProject = () => ({
94
106
  title: 'Configuring project',
95
107
  task: (ctx, task) => task.newListr([
96
- pullImages(),
97
- dockerNetwork.tasks.createNetwork(),
98
- volumes.createVolumes(),
108
+ convertMySQLDatabaseToMariaDB(),
109
+ {
110
+ task: (ctx, task) => task.newListr([
111
+ pullImages(),
112
+ dockerNetwork.tasks.createNetwork()
113
+ ], { concurrent: true })
114
+ },
115
+ checkPHPVersion(),
99
116
  {
100
117
  task: (ctx, task) => task.newListr([
101
118
  buildProjectImage(),
@@ -104,9 +121,10 @@ const configureProject = () => ({
104
121
  concurrent: true
105
122
  })
106
123
  },
107
- checkPHPVersion(),
108
124
  getComposerVersionTask(),
109
125
  prepareFileSystem(),
126
+ volumes.createVolumes(),
127
+ convertComposerHomeToComposerCacheVolume(),
110
128
  installMagentoProject(),
111
129
  enableMagentoComposerPlugins(),
112
130
  startServices(),
@@ -138,6 +156,7 @@ const start = () => ({
138
156
  task: (ctx, task) => {
139
157
  task.title = `Starting project (magento-scripts@${pkg.version})`;
140
158
  return task.newListr([
159
+ resetCmaGlobalConfig(),
141
160
  checkRequirements(),
142
161
  retrieveProjectConfiguration(),
143
162
  stopProject(),
@@ -1,3 +1,4 @@
1
+ /* eslint-disable max-len */
1
2
  const path = require('path');
2
3
  const logger = require('@scandipwa/scandipwa-dev-utils/logger');
3
4
  const { getProjectCreatedAt, getPrefix } = require('../../util/prefix');
@@ -5,7 +6,6 @@ const { getProjectCreatedAt, getPrefix } = require('../../util/prefix');
5
6
  const { version: packageVersion } = require('../../../package.json');
6
7
  const { getArchSync } = require('../../util/arch');
7
8
  const ConsoleBlock = require('../../util/console-block');
8
- const { getComposerVersion } = require('../composer');
9
9
  const { getInstanceMetadata } = require('../../util/instance-metadata');
10
10
 
11
11
  /**
@@ -22,19 +22,23 @@ const parsePort = (port) => {
22
22
  };
23
23
  };
24
24
 
25
+ /**
26
+ * @param {import('../../../typings/context').ListrContext & { containers: ReturnType<Awaited<ReturnType<import('../../config/docker')>>['getContainers']> }} ctx
27
+ */
25
28
  const prettyStatus = async (ctx) => {
26
29
  const {
27
30
  config: {
28
- baseConfig
31
+ baseConfig,
32
+ projectConfig
29
33
  },
30
34
  magentoVersion,
31
35
  dockerVersion,
32
36
  platform,
33
37
  platformVersion,
34
- containers
38
+ containers,
39
+ composerVersion
35
40
  } = ctx;
36
41
  const projectCreatedAt = getProjectCreatedAt();
37
- const composerVersion = await getComposerVersion(ctx);
38
42
 
39
43
  const prefix = getPrefix();
40
44
 
@@ -45,7 +49,7 @@ const prettyStatus = async (ctx) => {
45
49
  block
46
50
  .addHeader(`magento-scripts version: ${ logger.style.link(packageVersion) }`)
47
51
  .addEmptyLine()
48
- .addLine(`Project: ${logger.style.file(baseConfig.prefix)} ${prefix === folderName ? '(without prefix)' : '(with prefix)'} (with php container)`)
52
+ .addLine(`Project: ${logger.style.file(baseConfig.prefix)} ${prefix === folderName ? '(without prefix)' : '(with prefix)'} (with php container)${ projectConfig.debug ? ' (with debugging)' : '' }`)
49
53
  .addLine(`Project location: ${logger.style.link(process.cwd())}`);
50
54
 
51
55
  if (projectCreatedAt) {
@@ -71,19 +75,25 @@ const prettyStatus = async (ctx) => {
71
75
 
72
76
  let containerStatus;
73
77
 
74
- if (container.status && container.status.Health) {
75
- containerStatus = `✓ ${ logger.style.file(container.status.Health.Status) } and ${ logger.style.file('running') }`;
76
- } else if (container.status) {
77
- containerStatus = logger.style.file(container.status.Status);
78
+ if (container.status && container.status.State && container.status.State.Health) {
79
+ containerStatus = `✓ ${ logger.style.file(container.status.State.Health.Status) } and ${ logger.style.file('running') }`;
80
+ } else if (container.status && container.status.State) {
81
+ containerStatus = logger.style.file(container.status.State.Status);
78
82
  } else {
79
83
  containerStatus = '✖ Not running';
80
84
  }
81
85
 
82
86
  block
83
87
  .addLine(`Status: ${containerStatus}`)
84
- .addLine(`Name: ${logger.style.misc(container.name)}`)
85
- .addLine(`Image: ${logger.style.file(container.image)}`)
86
- .addLine(`Network: ${logger.style.link(container.network)}`);
88
+ .addLine(`Name: ${logger.style.misc(container.name)}`);
89
+
90
+ if (container.status && container.status.Config && container.status.Config.Image) {
91
+ block.addLine(`Image: ${logger.style.file(container.status.Config.Image)}`);
92
+ } else {
93
+ block.addLine(`Image: ${logger.style.file(container.image)}`);
94
+ }
95
+
96
+ block.addLine(`Network: ${logger.style.link(container.network)}`);
87
97
 
88
98
  if (!containerStatus.includes('Not running') && container.forwardedPorts && container.forwardedPorts.length > 0) {
89
99
  block.addLine('Port forwarding:');
@@ -103,6 +113,13 @@ const prettyStatus = async (ctx) => {
103
113
  block.addLine(`${' '.repeat(3)} ${logger.style.misc(envName)}=${logger.style.file(envValue)}`);
104
114
  }
105
115
  }
116
+
117
+ if (container.description) {
118
+ block.addLine('Description:');
119
+ container.description.split('\n').forEach((line) => {
120
+ block.addLine(line);
121
+ });
122
+ }
106
123
  });
107
124
 
108
125
  const instanceMetadata = getInstanceMetadata(ctx);
@@ -123,14 +140,6 @@ const prettyStatus = async (ctx) => {
123
140
  instanceMetadata.admin.forEach(({ title, text }) => {
124
141
  block.addLine(` ${title}: ${text}`);
125
142
  });
126
- // block
127
- // .addEmptyLine()
128
- // .addSeparator('Magento status')
129
- // .addEmptyLine()
130
- // .addLine(`Web location: ${logger.style.link(`${ssl.enabled ? 'https' : 'http'}://${host}${ports.app === 80 ? '' : `:${ports.app}`}/`)}`)
131
- // .addLine(`Magento Admin panel location: ${logger.style.link(`${ssl.enabled ? 'https' : 'http'}://${host}${ports.app === 80 ? '' : `:${ports.app}`}/${magentoConfiguration.adminuri}`)}`)
132
- // .addLine(`Magento Admin panel credentials: ${logger.style.misc(magentoConfiguration.user)} - ${logger.style.misc(magentoConfiguration.password)}`)
133
- // .addEmptyLine();
134
143
 
135
144
  block.log();
136
145
  };
package/lib/tasks/stop.js CHANGED
@@ -2,6 +2,7 @@ const { stopServices } = require('./docker');
2
2
  const getMagentoVersionConfig = require('../config/get-magento-version-config');
3
3
  const getProjectConfiguration = require('../config/get-project-configuration');
4
4
  const checkConfigurationFile = require('../config/check-configuration-file');
5
+ const getDockerVersion = require('./requirements/docker/version');
5
6
 
6
7
  /**
7
8
  * @type {() => import('listr2').ListrTask<import('../../typings/context').ListrContext>}
@@ -9,6 +10,7 @@ const checkConfigurationFile = require('../config/check-configuration-file');
9
10
  const stop = () => ({
10
11
  title: 'Stopping project',
11
12
  task: async (ctx, task) => task.newListr([
13
+ getDockerVersion(),
12
14
  getMagentoVersionConfig(),
13
15
  checkConfigurationFile(),
14
16
  getProjectConfiguration(),
@@ -1,3 +1,4 @@
1
+ const logger = require('@scandipwa/scandipwa-dev-utils/logger');
1
2
  const path = require('path');
2
3
  const KnownError = require('../../errors/known-error');
3
4
  const getJsonfileData = require('../../util/get-jsonfile-data');
@@ -11,10 +12,19 @@ const retrieveThemeData = (themePath) => ({
11
12
  task: async (ctx) => {
12
13
  let absoluteThemePath = path.join(process.cwd(), themePath);
13
14
 
15
+ // validate if theme is located inside magento directory
16
+ if (!absoluteThemePath.includes(process.cwd())) {
17
+ throw new KnownError(`You are trying to link the theme from outside of your Magento project!
18
+
19
+ This is not supported in ${ logger.style.command('magento-scripts') } version 2.
20
+
21
+ Move your theme inside Magento project!`);
22
+ }
23
+
14
24
  // check if path not relative
15
25
  if (!(await pathExists(path.join(absoluteThemePath, 'composer.json')))) {
16
26
  // if composer.json is not found, then it's not correct path
17
- // and we need to test if it's alsolute one
27
+ // and we need to test if it's absolute one
18
28
  if (await pathExists(path.join(themePath, 'composer.json'))) {
19
29
  // if so, use it as absolute path
20
30
  absoluteThemePath = themePath;
@@ -69,6 +69,7 @@ const phpConfigurationSchema = Joi.object({
69
69
  debugImage: Joi.string().optional(),
70
70
  fpmConfigTemplate: Joi.string().optional(),
71
71
  configTemplate: Joi.string().optional().custom(fileExistsValidator),
72
+ debugTemplate: Joi.string().optional().custom(fileExistsValidator),
72
73
  extensions: phpExtensionConfiguration.optional()
73
74
  });
74
75
 
@@ -85,6 +86,7 @@ const nginxConfigurationSchema = Joi.object({
85
86
  */
86
87
  const varnishConfigurationSchema = Joi.object({
87
88
  enabled: Joi.boolean().optional(),
89
+ healthCheck: Joi.boolean().optional(),
88
90
  image: Joi.string().optional(),
89
91
  configTemplate: Joi.string().optional().custom(fileExistsValidator)
90
92
  });
@@ -114,7 +116,17 @@ const composerConfigurationSchema = Joi.object({
114
116
  }
115
117
 
116
118
  return versionValidator(value);
117
- })
119
+ }),
120
+ plugins: Joi.object()
121
+ .pattern(
122
+ Joi.string(),
123
+ Joi.object({
124
+ version: Joi.string().optional(),
125
+ options: Joi.string().optional(),
126
+ enabled: Joi.boolean().optional()
127
+ })
128
+ .unknown()
129
+ )
118
130
  });
119
131
 
120
132
  /**
@@ -128,7 +140,8 @@ const configurationSchema = Joi.object({
128
140
  redis: serviceConfigurationSchema.optional(),
129
141
  composer: composerConfigurationSchema.optional(),
130
142
  varnish: varnishConfigurationSchema.optional(),
131
- sslTerminator: nginxConfigurationSchema.optional()
143
+ sslTerminator: nginxConfigurationSchema.optional(),
144
+ maildev: serviceConfigurationSchema.optional()
132
145
  });
133
146
 
134
147
  /**
@@ -0,0 +1,62 @@
1
+ const { spawn } = require('child_process');
2
+ const { runCommand } = require('../tasks/docker/containers/container-api');
3
+
4
+ /**
5
+ * @param {{ containerName: string, commands: string[], user?: string }} param0
6
+ */
7
+ const executeInContainer = ({
8
+ containerName, commands, user
9
+ }) => {
10
+ if (!process.stdin.isTTY) {
11
+ process.stderr.write('This app works only in TTY mode');
12
+ process.exit(1);
13
+ }
14
+
15
+ const userArg = user && `--user=${user}`;
16
+
17
+ spawn('docker', [
18
+ 'exec',
19
+ '-it',
20
+ userArg,
21
+ containerName
22
+ ]
23
+ .filter(Boolean)
24
+ .concat(...commands.map((command) => command.split(' ')).flat()),
25
+ {
26
+ stdio: [0, 1, 2]
27
+ });
28
+
29
+ return new Promise((_resolve) => {
30
+ // never resolve
31
+ });
32
+ };
33
+
34
+ /**
35
+ * @param {import('../tasks/docker/containers/container-api').ContainerRunOptions} options
36
+ * @param {string[]} commands
37
+ */
38
+ const runInContainer = (options, commands) => {
39
+ if (!process.stdin.isTTY) {
40
+ process.stderr.write('This app works only in TTY mode');
41
+ process.exit(1);
42
+ }
43
+
44
+ const runArgs = runCommand({
45
+ ...options,
46
+ tty: true,
47
+ detach: false,
48
+ rm: true,
49
+ command: commands.join(' ')
50
+ });
51
+
52
+ spawn('bash', ['-c', runArgs.join(' ')], { stdio: [0, 1, 2] });
53
+
54
+ return new Promise((_resolve) => {
55
+ // never resolve
56
+ });
57
+ };
58
+
59
+ module.exports = {
60
+ executeInContainer,
61
+ runInContainer
62
+ };
@@ -4,6 +4,7 @@ const WEB_LOCAL_LOCATION_TITLE = `Location on ${ logger.style.misc('localhost')
4
4
  const WEB_LOCATION_TITLE = 'Location on the Web';
5
5
  const WEB_ADMIN_LOCATION_TITLE = 'Panel location';
6
6
  const WEB_ADMIN_CREDENTIALS_TITLE = 'Panel credentials';
7
+ const WEB_MAILDEV_LOCATION_TITLE = 'Panel location';
7
8
 
8
9
  const mapDataStyle = ({ title, text }) => ({
9
10
  title,
@@ -13,7 +14,7 @@ const mapDataStyle = ({ title, text }) => ({
13
14
 
14
15
  /**
15
16
  * @param {import("../../typings/context").ListrContext} ctx
16
- * @return {{ frontend: { title: string, text: string }[], admin: { title: string, url: string }[]}}
17
+ * @return {{ frontend: { title: string, text: string }[], admin: { title: string, url: string }[], maildev: { title: string, text: string }[] }}
17
18
  */
18
19
  const getInstanceMetadata = (ctx) => {
19
20
  const {
@@ -34,6 +35,11 @@ const getInstanceMetadata = (ctx) => {
34
35
  */
35
36
  const admin = [];
36
37
 
38
+ /**
39
+ * @type {{ title: string, text: string }[]}
40
+ */
41
+ const maildev = [];
42
+
37
43
  const isNgrok = host.endsWith('ngrok.io');
38
44
 
39
45
  if (isNgrok) {
@@ -64,9 +70,15 @@ const getInstanceMetadata = (ctx) => {
64
70
  text: `${logger.style.misc(magentoConfiguration.user)} - ${logger.style.misc(magentoConfiguration.password)}`
65
71
  });
66
72
 
73
+ maildev.push({
74
+ title: WEB_MAILDEV_LOCATION_TITLE,
75
+ text: `http://${host}:${ports.maildevWeb}/`
76
+ });
77
+
67
78
  return {
68
79
  admin,
69
- frontend: frontend.map(mapDataStyle)
80
+ frontend: frontend.map(mapDataStyle),
81
+ maildev: maildev.map(mapDataStyle)
70
82
  };
71
83
  };
72
84