@scandipwa/magento-scripts 2.0.0-alpha.9 → 2.0.1

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 (183) hide show
  1. package/lib/commands/cli.js +18 -1
  2. package/lib/commands/logs.js +28 -2
  3. package/lib/commands/start.js +24 -3
  4. package/lib/commands/status.js +19 -1
  5. package/lib/config/config.js +20 -2
  6. package/lib/config/dependencies-for-platforms.js +1 -113
  7. package/lib/config/docker.js +94 -54
  8. package/lib/config/get-project-configuration.js +5 -0
  9. package/lib/config/index.js +10 -3
  10. package/lib/config/magento/required-php-extensions/index.js +1 -1
  11. package/lib/config/php-config.js +4 -3
  12. package/lib/config/port-config.js +3 -1
  13. package/lib/config/services/composer/versions/composer-1.js +13 -0
  14. package/lib/config/services/composer/versions/composer-2.js +8 -0
  15. package/lib/config/services/composer/versions/index.js +4 -0
  16. package/lib/config/services/elasticsearch/versions/elasticsearch-7.10.js +11 -0
  17. package/lib/config/services/elasticsearch/versions/elasticsearch-7.12.js +11 -0
  18. package/lib/config/services/elasticsearch/versions/elasticsearch-7.16.js +11 -0
  19. package/lib/config/services/elasticsearch/versions/elasticsearch-7.17.js +11 -0
  20. package/lib/config/services/elasticsearch/versions/elasticsearch-7.6.js +11 -0
  21. package/lib/config/services/elasticsearch/versions/elasticsearch-7.7.js +11 -0
  22. package/lib/config/services/elasticsearch/versions/elasticsearch-7.9.js +11 -0
  23. package/lib/config/services/elasticsearch/versions/index.js +15 -1
  24. package/lib/config/services/maildev/index.js +7 -0
  25. package/lib/config/services/mariadb/versions/index.js +5 -0
  26. package/lib/config/services/mariadb/versions/mariadb-10.2.js +8 -0
  27. package/lib/config/services/mariadb/versions/mariadb-10.3.js +8 -0
  28. package/lib/config/services/mariadb/versions/mariadb-10.4.js +8 -0
  29. package/lib/config/services/nginx/versions/index.js +3 -0
  30. package/lib/config/services/nginx/versions/nginx-1.18.js +11 -0
  31. package/lib/config/{php → services/php}/base-repo.js +0 -0
  32. package/lib/config/{php → services/php}/extensions/apcu.js +0 -0
  33. package/lib/config/{php → services/php}/extensions/bcmath.js +0 -0
  34. package/lib/config/{php → services/php}/extensions/curl.js +0 -0
  35. package/lib/config/{php → services/php}/extensions/gd.js +0 -0
  36. package/lib/config/{php → services/php}/extensions/index.js +0 -0
  37. package/lib/config/{php → services/php}/extensions/intl.js +0 -0
  38. package/lib/config/{php → services/php}/extensions/opcache.js +0 -0
  39. package/lib/config/{php → services/php}/extensions/pdo_mysql.js +0 -0
  40. package/lib/config/{php → services/php}/extensions/soap.js +0 -0
  41. package/lib/config/{php → services/php}/extensions/sodium.js +0 -0
  42. package/lib/config/{php → services/php}/extensions/xdebug.js +0 -0
  43. package/lib/config/{php → services/php}/extensions/xsl.js +0 -0
  44. package/lib/config/{php → services/php}/extensions/zip.js +0 -0
  45. package/lib/config/{php → services/php}/versions/index.js +0 -0
  46. package/lib/config/{php → services/php}/versions/php-7.2.js +1 -0
  47. package/lib/config/{php → services/php}/versions/php-7.3.js +1 -0
  48. package/lib/config/{php → services/php}/versions/php-7.4.js +1 -0
  49. package/lib/config/{php → services/php}/versions/php-8.1.js +1 -0
  50. package/lib/config/services/redis/index.js +5 -0
  51. package/lib/config/services/redis/redis-5.0.js +8 -0
  52. package/lib/config/services/redis/redis-6.0.js +8 -0
  53. package/lib/config/services/redis/redis-6.2.js +8 -0
  54. package/lib/config/{ssl-terminator → services/ssl-terminator}/index.js +3 -0
  55. package/lib/config/services/varnish/index.js +5 -0
  56. package/lib/config/{varnish → services/varnish}/varnish-6-0.js +5 -3
  57. package/lib/config/{varnish → services/varnish}/varnish-6-6.js +5 -3
  58. package/lib/config/{varnish → services/varnish}/varnish-7-0.js +5 -3
  59. package/lib/config/templates/magentorc.template +12 -5
  60. package/lib/config/templates/nginx.fastcgi_params.template +29 -0
  61. package/lib/config/templates/nginx.template.conf +1 -1
  62. package/lib/config/templates/php-debug.template.ini +31 -0
  63. package/lib/config/templates/php-fpm.template.conf +1 -2
  64. package/lib/config/templates/php.template.ini +5 -201
  65. package/lib/config/templates/ssl-terminator.template.conf +2 -0
  66. package/lib/config/templates/varnish.template.vcl +20 -13
  67. package/lib/config/versions/magento-2.2.10.js +39 -0
  68. package/lib/config/versions/magento-2.3.0.js +15 -19
  69. package/lib/config/versions/magento-2.3.1.js +15 -19
  70. package/lib/config/versions/magento-2.3.2-p1.js +15 -19
  71. package/lib/config/versions/magento-2.3.2-p2.js +15 -19
  72. package/lib/config/versions/magento-2.3.2.js +15 -19
  73. package/lib/config/versions/magento-2.3.3-p1.js +15 -19
  74. package/lib/config/versions/magento-2.3.3.js +15 -19
  75. package/lib/config/versions/magento-2.3.4-p1.js +15 -19
  76. package/lib/config/versions/magento-2.3.4-p2.js +15 -19
  77. package/lib/config/versions/magento-2.3.4.js +15 -19
  78. package/lib/config/versions/magento-2.3.5-p1.js +17 -22
  79. package/lib/config/versions/magento-2.3.5-p2.js +17 -22
  80. package/lib/config/versions/magento-2.3.5.js +17 -22
  81. package/lib/config/versions/magento-2.3.6-p1.js +17 -22
  82. package/lib/config/versions/magento-2.3.6.js +17 -22
  83. package/lib/config/versions/magento-2.3.7-p1.js +17 -22
  84. package/lib/config/versions/magento-2.3.7-p2.js +17 -22
  85. package/lib/config/versions/magento-2.3.7-p3.js +17 -22
  86. package/lib/config/versions/magento-2.3.7-p4.js +17 -22
  87. package/lib/config/versions/magento-2.3.7.js +17 -22
  88. package/lib/config/versions/magento-2.4.0-p1.js +17 -22
  89. package/lib/config/versions/magento-2.4.0.js +17 -22
  90. package/lib/config/versions/magento-2.4.1-p1.js +18 -23
  91. package/lib/config/versions/magento-2.4.1.js +18 -23
  92. package/lib/config/versions/magento-2.4.2-p1.js +18 -23
  93. package/lib/config/versions/magento-2.4.2-p2.js +18 -23
  94. package/lib/config/versions/magento-2.4.2.js +18 -23
  95. package/lib/config/versions/magento-2.4.3-p1.js +18 -23
  96. package/lib/config/versions/magento-2.4.3-p2.js +18 -23
  97. package/lib/config/versions/magento-2.4.3-p3.js +18 -23
  98. package/lib/config/versions/magento-2.4.3.js +18 -23
  99. package/lib/config/versions/magento-2.4.4-p1.js +18 -23
  100. package/lib/config/versions/magento-2.4.4-p2.js +41 -0
  101. package/lib/config/versions/magento-2.4.4.js +18 -23
  102. package/lib/config/versions/magento-2.4.5-p1.js +41 -0
  103. package/lib/config/versions/magento-2.4.5.js +18 -23
  104. package/lib/tasks/cli/create-bashrc-config.js +4 -2
  105. package/lib/tasks/composer/local-auth-json.js +1 -1
  106. package/lib/tasks/database/connect-to-database.js +6 -3
  107. package/lib/tasks/database/create-magento-database.js +5 -2
  108. package/lib/tasks/database/create-magento-user.js +50 -0
  109. package/lib/tasks/database/default-magento-database.js +3 -0
  110. package/lib/tasks/database/default-magento-user.js +7 -0
  111. package/lib/tasks/database/import-dump-to-database.js +3 -2
  112. package/lib/tasks/docker/api.d.ts +25 -1
  113. package/lib/tasks/docker/api.js +31 -1
  114. package/lib/tasks/docker/containers/container-api.d.ts +17 -0
  115. package/lib/tasks/docker/containers/container-api.js +64 -9
  116. package/lib/tasks/docker/containers/tasks.js +44 -13
  117. package/lib/tasks/docker/convert-composer-home-to-composer-cache-volume.js +52 -0
  118. package/lib/tasks/docker/convert-mysql-to-mariadb.js +2 -2
  119. package/lib/tasks/docker/image/image-api.d.ts +44 -0
  120. package/lib/tasks/docker/image/image-api.js +30 -2
  121. package/lib/tasks/docker/index.js +6 -1
  122. package/lib/tasks/docker/network/tasks.js +19 -14
  123. package/lib/tasks/docker/project-image-builder.js +39 -14
  124. package/lib/tasks/docker/system/index.js +5 -0
  125. package/lib/tasks/docker/system/system-api.d.ts +71 -0
  126. package/lib/tasks/docker/system/system-api.js +35 -0
  127. package/lib/tasks/docker/volume/index.js +2 -1
  128. package/lib/tasks/docker/volume/tasks.js +67 -9
  129. package/lib/tasks/docker/volume/volume-api.d.ts +40 -0
  130. package/lib/tasks/docker/volume/volume-api.js +55 -2
  131. package/lib/tasks/execute.js +5 -2
  132. package/lib/tasks/file-system/create-nginx-config.js +3 -5
  133. package/lib/tasks/file-system/create-php-config.js +2 -23
  134. package/lib/tasks/file-system/create-php-debug-config.js +45 -0
  135. package/lib/tasks/file-system/create-php-fpm-config.js +2 -4
  136. package/lib/tasks/file-system/create-phpstorm-config/database-config.js +24 -5
  137. package/lib/tasks/file-system/create-phpstorm-config/eslint-config.js +25 -13
  138. package/lib/tasks/file-system/create-phpstorm-config/exclude-folder-config.js +13 -3
  139. package/lib/tasks/file-system/create-phpstorm-config/index.js +2 -1
  140. package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/custom-ruleset-path-config.js +18 -7
  141. package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/paths.js +4 -0
  142. package/lib/tasks/file-system/create-ssl-terminator-config.js +23 -8
  143. package/lib/tasks/file-system/create-varnish-config.js +4 -7
  144. package/lib/tasks/file-system/create-vscode-config.js +2 -1
  145. package/lib/tasks/file-system/index.js +3 -2
  146. package/lib/tasks/magento/setup-magento/configure-elasticsearch.js +2 -4
  147. package/lib/tasks/magento/setup-magento/flush-redis-config.js +3 -6
  148. package/lib/tasks/magento/setup-magento/index.js +2 -0
  149. package/lib/tasks/magento/setup-magento/install-magento.js +8 -13
  150. package/lib/tasks/magento/setup-magento/set-base-url.js +2 -1
  151. package/lib/tasks/magento/setup-magento/set-mail-config.js +22 -0
  152. package/lib/tasks/magento/setup-magento/varnish-config.js +4 -9
  153. package/lib/tasks/magento/setup-magento/waiting-for-varnish.js +15 -16
  154. package/lib/tasks/php/php-container.js +1 -1
  155. package/lib/tasks/php/update-env-php.js +4 -6
  156. package/lib/tasks/{prefix → project-config}/index.js +6 -6
  157. package/lib/tasks/requirements/composer-credentials.js +7 -3
  158. package/lib/tasks/requirements/docker/context.js +88 -0
  159. package/lib/tasks/requirements/docker/index.js +111 -19
  160. package/lib/tasks/requirements/docker/install.js +21 -7
  161. package/lib/tasks/requirements/docker/permissions.js +2 -11
  162. package/lib/tasks/requirements/docker/running-status.js +94 -24
  163. package/lib/tasks/requirements/docker/version.js +1 -0
  164. package/lib/tasks/requirements/index.js +0 -2
  165. package/lib/tasks/requirements/php-version.js +4 -2
  166. package/lib/tasks/start.js +27 -8
  167. package/lib/tasks/status/index.js +86 -21
  168. package/lib/tasks/stop.js +2 -0
  169. package/lib/tasks/theme/retrieve-theme-data.js +12 -2
  170. package/lib/util/config-file-validator.js +17 -3
  171. package/lib/util/connection-string.js +62 -0
  172. package/lib/util/execute-in-container.js +7 -8
  173. package/lib/util/instance-metadata.js +14 -2
  174. package/lib/util/systemctl.js +62 -13
  175. package/package.json +2 -2
  176. package/typings/context.d.ts +11 -0
  177. package/typings/index.d.ts +46 -1
  178. package/lib/tasks/requirements/dependency/arch.js +0 -50
  179. package/lib/tasks/requirements/dependency/centos.js +0 -36
  180. package/lib/tasks/requirements/dependency/fedora.js +0 -36
  181. package/lib/tasks/requirements/dependency/index.js +0 -33
  182. package/lib/tasks/requirements/dependency/mac.js +0 -124
  183. package/lib/tasks/requirements/dependency/ubuntu.js +0 -83
@@ -1,11 +1,14 @@
1
1
  import mysql2 from 'mysql2';
2
2
 
3
+ import { ProjectConfig } from '../lib/config/config';
4
+ import { DockerVersionResult } from '../lib/tasks/docker/api';
3
5
  import { CMAConfiguration, PHPExtensions } from './index';
4
6
  import { PHPStormConfig } from './phpstorm';
5
7
 
6
8
  export interface ListrContext {
7
9
  magentoVersion: string
8
10
  composerVersion: string
11
+ phpVersion: string
9
12
  port?: number
10
13
  ports?: {
11
14
  app: number
@@ -16,6 +19,8 @@ export interface ListrContext {
16
19
  elasticsearch: number
17
20
  varnish: number
18
21
  sslTerminator: number
22
+ maildevSMTP: number
23
+ maildevWeb: number
19
24
  }
20
25
  arch: 'arm64' | 'x64'
21
26
  isArm: boolean
@@ -67,6 +72,7 @@ export interface ListrContext {
67
72
  network: string
68
73
  image: string
69
74
  debugImage?: string
75
+ remoteImages?: string[]
70
76
  name: string
71
77
  command: string
72
78
  connectCommand: string[]
@@ -83,6 +89,7 @@ export interface ListrContext {
83
89
  userConfiguration: Omit<CMAConfiguration, 'prefix' | 'useNonOverlappingPorts'>
84
90
  nonOverridenConfiguration: Omit<CMAConfiguration, 'prefix' | 'useNonOverlappingPorts'>
85
91
  phpStorm: PHPStormConfig
92
+ projectConfig: ProjectConfig
86
93
  }
87
94
  systemConfiguration: {
88
95
  analytics: boolean
@@ -90,4 +97,8 @@ export interface ListrContext {
90
97
  }
91
98
  databaseConnection: mysql2.Connection
92
99
  isSetupUpgradeNeeded?: boolean
100
+ isDockerDesktop?: boolean
101
+ dockerServerData?: DockerVersionResult['Server']
102
+ dockerClientData?: DockerVersionResult['Client']
103
+ dockerVersion?: DockerVersionResult['Server']['Version']
93
104
  }
@@ -52,16 +52,53 @@ export interface VarnishConfiguration extends ServiceWithImage {
52
52
  * @example ./my-varnish-config.vcl
53
53
  */
54
54
  configTemplate: string
55
+
56
+ /**
57
+ * Enable or disable healthcheck in the project
58
+ */
59
+ healthCheck: boolean
55
60
  }
56
61
 
57
62
  export interface ComposerConfiguration {
58
63
  /**
59
64
  * Composer version
65
+ *
66
+ * This will become part of the url (`https://getcomposer.org/download/<version>/composer.phar`) so you can use the following variants as well:
67
+ * ```
68
+ * 'latest-stable'
69
+ * 'latest-preview'
70
+ * 'latest-1.x'
71
+ * 'latest-2.x'
72
+ * 'latest-2.2.x'
73
+ *
74
+ * '2.4.1'
75
+ * '2.3.10'
76
+ * '2.2.18'
77
+ * '2.1.14'
78
+ * ```
79
+ *
80
+ * @url https://getcomposer.org/download/
60
81
  */
61
82
  version: string
83
+
84
+ /**
85
+ * Composer global plugins that will be added to Docker image
86
+ */
87
+ plugins: Record<string, {
88
+ version?: string
89
+ options?: string
90
+ /**
91
+ * Enable composer plugin
92
+ */
93
+ enabled?: boolean
94
+ }>
62
95
  }
63
96
 
64
97
  export interface PHPExtensionInstallationInstruction {
98
+ /**
99
+ * Main extension name that will be used for `docker-php-ext-install` command
100
+ */
101
+ name?: string
65
102
  /**
66
103
  * Alternative name for extension
67
104
  *
@@ -80,7 +117,9 @@ export interface PHPExtensionInstallationInstruction {
80
117
  * pecl install xdebug && docker-php-ext-enable xdebug
81
118
  * ```
82
119
  */
83
- command: (arg0: (Omit<PHPExtensionInstallationInstruction, 'command'> & { ctx: ListrContext})) => string | string
120
+ command: string |
121
+ ((arg0: (Omit<PHPExtensionInstallationInstruction, 'command'> & { ctx: ListrContext})) => string) |
122
+ ((arg0: (Omit<PHPExtensionInstallationInstruction, 'command'> & { ctx: ListrContext})) => Promise<string>)
84
123
 
85
124
  /**
86
125
  * System dependencies required by the extension
@@ -118,6 +157,12 @@ export interface PHPConfiguration {
118
157
  * @example ./my-php-template.ini
119
158
  */
120
159
  configTemplate: string
160
+ /**
161
+ * PHP XDebug file template location
162
+ *
163
+ * @example ./my-php-debug-template.ini
164
+ */
165
+ debugTemplate: string
121
166
 
122
167
  /**
123
168
  * PHP-FPM configuration file template location
@@ -1,50 +0,0 @@
1
- const dependenciesForPlatforms = require('../../../config/dependencies-for-platforms');
2
- const UnknownError = require('../../../errors/unknown-error');
3
- const { execAsyncSpawn } = require('../../../util/exec-async-command');
4
- const installDependenciesTask = require('../../../util/install-dependencies-task');
5
-
6
- const pkgRegex = /(\S+)\s(\S+)/i;
7
-
8
- /**
9
- * @type {() => import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
10
- */
11
- const archDependenciesCheck = () => ({
12
- title: 'Checking Arch Linux dependencies',
13
- task: async (ctx, task) => {
14
- const installedDependencies = (await execAsyncSpawn('pacman -Q')).split('\n')
15
- .map((pkg) => {
16
- const result = pkg.match(pkgRegex);
17
-
18
- if (!result) {
19
- throw new UnknownError(`Package without a version!\n\n${pkg}\n\nHOW?`);
20
- }
21
-
22
- return result[1];
23
- });
24
-
25
- const dependenciesToInstall = dependenciesForPlatforms['Arch Linux']
26
- .dependencies
27
- .filter((dep) => {
28
- if (Array.isArray(dep)) {
29
- return !dep.some((dp) => installedDependencies.includes(dp));
30
- }
31
-
32
- return !installedDependencies.includes(dep);
33
- })
34
- .map((dep) => (Array.isArray(dep) ? dep[0] : dep));
35
-
36
- if (dependenciesToInstall.length > 0) {
37
- return task.newListr(
38
- installDependenciesTask({
39
- platform: 'Arch Linux',
40
- dependenciesToInstall
41
- })
42
- );
43
- }
44
- },
45
- options: {
46
- bottomBar: 10
47
- }
48
- });
49
-
50
- module.exports = archDependenciesCheck;
@@ -1,36 +0,0 @@
1
- const dependenciesForPlatforms = require('../../../config/dependencies-for-platforms');
2
- const { execAsyncSpawn } = require('../../../util/exec-async-command');
3
- const installDependenciesTask = require('../../../util/install-dependencies-task');
4
-
5
- /**
6
- * @type {() => import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
7
- */
8
- const centosDependenciesCheck = () => ({
9
- title: 'Checking CentOS dependencies',
10
- task: async (ctx, task) => {
11
- const installedDependencies = (await execAsyncSpawn('yum list installed')).split('\n')
12
- .filter((pkg) => !pkg.toLowerCase().includes('installed packages'))
13
- .map((pkg) => pkg.match(/^(\S+)/i))
14
- .filter(Boolean)
15
- .map((pkg) => pkg[1])
16
- .map((pkg) => pkg.match(/^(\S+)\.\S+/i))
17
- .filter(Boolean)
18
- .map((pkg) => pkg[1]);
19
-
20
- const dependenciesToInstall = dependenciesForPlatforms
21
- .CentOS
22
- .dependencies
23
- .filter((dep) => !installedDependencies.includes(dep));
24
-
25
- if (dependenciesToInstall.length > 0) {
26
- return task.newListr(
27
- installDependenciesTask({
28
- platform: 'CentOS',
29
- dependenciesToInstall
30
- })
31
- );
32
- }
33
- }
34
- });
35
-
36
- module.exports = centosDependenciesCheck;
@@ -1,36 +0,0 @@
1
- const dependenciesForPlatforms = require('../../../config/dependencies-for-platforms');
2
- const { execAsyncSpawn } = require('../../../util/exec-async-command');
3
- const installDependenciesTask = require('../../../util/install-dependencies-task');
4
-
5
- /**
6
- * @type {() => import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
7
- */
8
- const fedoraDependenciesCheck = () => ({
9
- title: 'Checking Fedora Linux dependencies',
10
- task: async (ctx, task) => {
11
- const installedDependencies = (await execAsyncSpawn('yum list installed')).split('\n')
12
- .filter((pkg) => !pkg.toLowerCase().includes('installed packages'))
13
- .map((pkg) => pkg.match(/^(\S+)/i))
14
- .filter(Boolean)
15
- .map((pkg) => pkg[1])
16
- .map((pkg) => pkg.match(/^(\S+)\.\S+/i))
17
- .filter(Boolean)
18
- .map((pkg) => pkg[1]);
19
-
20
- const dependenciesToInstall = dependenciesForPlatforms
21
- .Fedora
22
- .dependencies
23
- .filter((dep) => !installedDependencies.includes(dep));
24
-
25
- if (dependenciesToInstall.length > 0) {
26
- return task.newListr(
27
- installDependenciesTask({
28
- platform: 'Fedora',
29
- dependenciesToInstall
30
- })
31
- );
32
- }
33
- }
34
- });
35
-
36
- module.exports = fedoraDependenciesCheck;
@@ -1,33 +0,0 @@
1
- const archDependenciesCheck = require('./arch');
2
- const fedoraDependenciesCheck = require('./fedora');
3
- const centosDependenciesCheck = require('./centos');
4
- const ubuntuDependenciesCheck = require('./ubuntu');
5
- const macDependenciesCheck = require('./mac');
6
- const osPlatform = require('../../../util/os-platform');
7
-
8
- const dependencyCheck = async () => {
9
- if (process.platform === 'darwin') {
10
- return macDependenciesCheck();
11
- }
12
-
13
- const distro = await osPlatform();
14
- switch (distro) {
15
- case 'Arch Linux': {
16
- return archDependenciesCheck();
17
- }
18
- case 'Fedora': {
19
- return fedoraDependenciesCheck();
20
- }
21
- case 'CentOS': {
22
- return centosDependenciesCheck();
23
- }
24
- case 'Ubuntu': {
25
- return ubuntuDependenciesCheck();
26
- }
27
- default: {
28
- // skip check
29
- }
30
- }
31
- };
32
-
33
- module.exports = dependencyCheck;
@@ -1,124 +0,0 @@
1
- const dependenciesForPlatforms = require('../../../config/dependencies-for-platforms');
2
- const { execAsyncSpawn, execCommandTask } = require('../../../util/exec-async-command');
3
- const {
4
- BREW_BIN_PATH_ARM_NATIVE,
5
- BREW_BIN_PATH_ARM_ROSETTA,
6
- BREW_BIN_PATH_INTEL,
7
- getBrewCommand
8
- } = require('../../../util/get-brew-bin-path');
9
- const installDependenciesTask = require('../../../util/install-dependencies-task');
10
- const pathExists = require('../../../util/path-exists');
11
-
12
- const brewInstallCommand = '$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)';
13
-
14
- /**
15
- * @returns {import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
16
- */
17
- const installBrewRosettaTask = () => ({
18
- title: 'Installing Brew using Rosetta 2',
19
- task: async (ctx, task) => {
20
- if (await pathExists(BREW_BIN_PATH_ARM_ROSETTA)) {
21
- task.skip('Brew in Rosetta is already installed');
22
- return;
23
- }
24
-
25
- return task.newListr(
26
- execCommandTask(brewInstallCommand, {
27
- useRosetta2: true
28
- })
29
- );
30
- }
31
- });
32
-
33
- /**
34
- * @returns {import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
35
- */
36
- const installBrewNativeTask = () => ({
37
- title: 'Installing Brew',
38
- task: async (ctx, task) => {
39
- if (
40
- (ctx.arch === 'arm64' && await pathExists(BREW_BIN_PATH_ARM_NATIVE))
41
- || (ctx.arch === 'x64' && await pathExists(BREW_BIN_PATH_INTEL))
42
- ) {
43
- task.skip('Brew in native path is already installed');
44
- return;
45
- }
46
-
47
- return task.newListr(
48
- execCommandTask(brewInstallCommand, {
49
- useRosetta2: false
50
- })
51
- );
52
- }
53
- });
54
-
55
- /**
56
- * @returns {import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
57
- */
58
- const macDependenciesCheck = () => ({
59
- title: 'Checking MacOS dependencies',
60
- task: async (ctx, task) => {
61
- const tasks = [installBrewNativeTask()];
62
-
63
- if (ctx.arch === 'arm64') {
64
- tasks.push(installBrewRosettaTask());
65
- }
66
-
67
- return task.newListr(
68
- tasks.concat([
69
- {
70
- task: async () => {
71
- const installDependenciesTasks = [];
72
- if (ctx.arch === 'arm64') {
73
- const installedNativeDependencies = (
74
- await execAsyncSpawn(`${await getBrewCommand({ native: true })} list`, { useRosetta2: false })
75
- ).split('\n');
76
- const dependenciesToInstallOnArm = dependenciesForPlatforms['darwin-arm']
77
- .dependencies
78
- .filter((dep) => !installedNativeDependencies.includes(dep));
79
-
80
- if (dependenciesToInstallOnArm.length > 0) {
81
- installDependenciesTasks.push(
82
- installDependenciesTask({
83
- platform: 'darwin-arm',
84
- dependenciesToInstall: dependenciesToInstallOnArm,
85
- useMacNativeEnvironment: true
86
- })
87
- );
88
- }
89
- }
90
-
91
- const installedDependencies = (
92
- await execAsyncSpawn(`${await getBrewCommand({ native: false })} list`, { useRosetta2: true })
93
- ).split('\n');
94
- const dependenciesToInstall = dependenciesForPlatforms
95
- .darwin
96
- .dependencies
97
- .filter((dep) => !installedDependencies.includes(dep));
98
-
99
- if (dependenciesToInstall.length > 0) {
100
- installDependenciesTasks.push(
101
- installDependenciesTask({
102
- platform: 'darwin',
103
- dependenciesToInstall,
104
- useMacNativeEnvironment: false
105
- })
106
- );
107
- }
108
-
109
- if (installDependenciesTasks.length > 0) {
110
- return task.newListr(installDependenciesTasks);
111
- }
112
-
113
- task.skip();
114
- }
115
- }
116
- ])
117
- );
118
- },
119
- options: {
120
- bottomBar: 10
121
- }
122
- });
123
-
124
- module.exports = macDependenciesCheck;
@@ -1,83 +0,0 @@
1
- const logger = require('@scandipwa/scandipwa-dev-utils/logger');
2
- const os = require('os');
3
- const dependenciesForPlatforms = require('../../../config/dependencies-for-platforms');
4
- const { execAsyncSpawn, execCommandTask } = require('../../../util/exec-async-command');
5
- const installDependenciesTask = require('../../../util/install-dependencies-task');
6
-
7
- const pkgRegex = /^(\S+)\/\S+\s(\S+)\s\S+\s\S+$/i;
8
-
9
- const updateSystem = () => ({
10
- title: 'Updating Ubuntu system',
11
- task: async (ctx, task) => {
12
- task.output = 'Enter your sudo password!';
13
- task.output = logger.style.command(`>[sudo] password for ${ os.userInfo().username }:`);
14
-
15
- return task.newListr(
16
- execCommandTask('sudo apt update', {
17
- callback: (t) => {
18
- task.output = t;
19
- },
20
- pipeInput: true
21
- })
22
- );
23
- },
24
- options: {
25
- bottomBar: 10
26
- }
27
- });
28
-
29
- /**
30
- * @type {() => import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
31
- */
32
- const ubuntuDependenciesCheck = () => ({
33
- title: 'Checking Ubuntu Linux dependencies',
34
- task: async (ctx, task) => {
35
- const installedDependencies = (await execAsyncSpawn('apt list --installed')).split('\n')
36
- .filter((pkg) => pkgRegex.test(pkg))
37
- .map((pkg) => pkg.match(pkgRegex))
38
- .map((pkg) => pkg[1]);
39
-
40
- const dependenciesToInstall = dependenciesForPlatforms
41
- .Ubuntu
42
- .dependencies
43
- .filter((dep) => {
44
- if (Array.isArray(dep)) {
45
- return !dep.some((dp) => installedDependencies.includes(dp));
46
- }
47
-
48
- return !installedDependencies.includes(dep);
49
- })
50
- .map((dep) => (Array.isArray(dep) ? dep[0] : dep));
51
-
52
- if (dependenciesToInstall.length > 0) {
53
- const runSystemUpdate = await task.prompt({
54
- type: 'Confirm',
55
- message: `Would you like to run ${logger.style.command('apt update')} before installing missing ${dependenciesToInstall.length} dependenc${dependenciesToInstall.length > 1 ? 'ies' : 'y'}?`
56
- });
57
-
58
- if (runSystemUpdate) {
59
- return task.newListr([
60
- updateSystem(),
61
- installDependenciesTask({
62
- platform: 'Ubuntu',
63
- dependenciesToInstall
64
- })
65
- ], {
66
- concurrent: false
67
- });
68
- }
69
-
70
- return task.newListr(
71
- installDependenciesTask({
72
- platform: 'Ubuntu',
73
- dependenciesToInstall
74
- })
75
- );
76
- }
77
- },
78
- options: {
79
- bottomBar: 10
80
- }
81
- });
82
-
83
- module.exports = ubuntuDependenciesCheck;