@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
@@ -3,10 +3,10 @@ const { execAsyncSpawn } = require('./exec-async-command');
3
3
  /**
4
4
  * @param {String} cmd
5
5
  * @param {String} serviceName
6
- * @param {{ now: boolean }} options
6
+ * @param {{ now: boolean, user: boolean }} options
7
7
  */
8
8
  const run = (cmd, serviceName, options = {}) => execAsyncSpawn(
9
- `systemctl ${ cmd }${ serviceName ? ` ${ serviceName }` : '' }${ options.now ? ' --now' : ''}`,
9
+ `systemctl ${ options.user ? '--user ' : '' }${ cmd }${ serviceName ? ` ${ serviceName }` : '' }${ options.now ? ' --now' : ''}`,
10
10
  {
11
11
  withCode: true
12
12
  }
@@ -14,29 +14,78 @@ const run = (cmd, serviceName, options = {}) => execAsyncSpawn(
14
14
 
15
15
  const daemonReload = () => run('daemon-reload');
16
16
 
17
- const systemctlControl = (serviceName) => ({
18
- disable: () => run('disable', serviceName),
19
- enable: () => run('enable', serviceName),
20
- enableAndStart: () => run('enable', serviceName, { now: true }),
21
- restart: () => run('restart', serviceName),
22
- start: () => run('start', serviceName),
23
- stop: () => run('stop', serviceName),
24
- isEnabled: async () => {
17
+ /**
18
+ * @param {String} serviceName
19
+ * @param {{ now: boolean, user: boolean }} defaultOptions
20
+ */
21
+ const systemctlControl = (serviceName, defaultOptions = {}) => ({
22
+ /**
23
+ * @param {{ now: boolean, user: boolean }} options
24
+ */
25
+ disable: (options = {}) => run('disable', serviceName, { ...defaultOptions, ...options }),
26
+ /**
27
+ * @param {{ now: boolean, user: boolean }} options
28
+ */
29
+ enable: (options = {}) => run('enable', serviceName, { ...defaultOptions, ...options }),
30
+ /**
31
+ * @param {{ now: boolean, user: boolean }} options
32
+ */
33
+ enableAndStart: (options = {}) => run('enable', serviceName, { now: true, ...defaultOptions, ...options }),
34
+ /**
35
+ * @param {{ now: boolean, user: boolean }} options
36
+ */
37
+ restart: (options = {}) => run('restart', serviceName, { ...defaultOptions, ...options }),
38
+ /**
39
+ * @param {{ now: boolean, user: boolean }} options
40
+ */
41
+ start: (options = {}) => run('start', serviceName, { ...defaultOptions, ...options }),
42
+ /**
43
+ * @param {{ now: boolean, user: boolean }} options
44
+ */
45
+ stop: (options = {}) => run('stop', serviceName, { ...defaultOptions, ...options }),
46
+ /**
47
+ * @param {{ now: boolean, user: boolean }} options
48
+ */
49
+ isEnabled: async (options = {}) => {
25
50
  try {
26
- const { result } = await run('is-enabled', serviceName);
51
+ const { result } = await run('is-enabled', serviceName, { ...defaultOptions, ...options });
27
52
  return result.includes('enabled');
28
53
  } catch (e) {
29
54
  return false;
30
55
  }
31
56
  },
32
- isRunning: async () => {
57
+ /**
58
+ * @param {{ now: boolean, user: boolean }} options
59
+ */
60
+ isRunning: async (options = {}) => {
33
61
  try {
34
- const { result } = await run('status', serviceName);
62
+ const { result } = await run('status', serviceName, { ...defaultOptions, ...options });
35
63
 
36
64
  return result.includes('active (running)');
37
65
  } catch (e) {
38
66
  return false;
39
67
  }
68
+ },
69
+ /**
70
+ * @param {{ user: boolean }} options
71
+ */
72
+ exists: async (options = {}) => {
73
+ const optionsToUse = { ...defaultOptions, ...options };
74
+ try {
75
+ // eslint-disable-next-line max-len, no-useless-escape
76
+ const command = `if [[ $(systemctl ${ optionsToUse.user ? '--user ' : ''}list-units --all -t service --full --no-legend "${ serviceName }.service" | sed 's/^\\s*//g' | cut -f1 -d' ') == ${ serviceName }.service ]]; then
77
+ echo "1"
78
+ else
79
+ echo "0"
80
+ fi`;
81
+ const result = await execAsyncSpawn(
82
+ command
83
+ );
84
+
85
+ return result === '1';
86
+ } catch (e) {
87
+ return false;
88
+ }
40
89
  }
41
90
  });
42
91
 
package/package.json CHANGED
@@ -3,12 +3,13 @@
3
3
  "description": "Scripts and configuration used by CMA.",
4
4
  "homepage": "https://docs.create-magento-app.com/",
5
5
  "repository": "github:scandipwa/create-magento-app",
6
- "version": "2.0.0-alpha.2",
6
+ "version": "2.0.0-alpha.20",
7
7
  "main": "./index.js",
8
8
  "types": "./typings/index.d.ts",
9
9
  "license": "OSL-3.0",
10
10
  "bin": {
11
- "magento-scripts": "./index.js"
11
+ "magento-scripts": "./index.js",
12
+ "magento-scripts-exec": "./exec.js"
12
13
  },
13
14
  "engines": {
14
15
  "node": ">=12"
@@ -53,5 +54,5 @@
53
54
  "mysql",
54
55
  "scandipwa"
55
56
  ],
56
- "gitHead": "feac3f9df219e0a033bacf1f04afe154064bbf2f"
57
+ "gitHead": "6c6e5821a2da7ca52685724a56c72770004f3a5a"
57
58
  }
@@ -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,13 +52,46 @@ 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 {
@@ -80,7 +113,9 @@ export interface PHPExtensionInstallationInstruction {
80
113
  * pecl install xdebug && docker-php-ext-enable xdebug
81
114
  * ```
82
115
  */
83
- command: (arg0: (Omit<PHPExtensionInstallationInstruction, 'command'> & { ctx: ListrContext})) => string | string
116
+ command: string |
117
+ ((arg0: (Omit<PHPExtensionInstallationInstruction, 'command'> & { ctx: ListrContext})) => string) |
118
+ ((arg0: (Omit<PHPExtensionInstallationInstruction, 'command'> & { ctx: ListrContext})) => Promise<string>)
84
119
 
85
120
  /**
86
121
  * System dependencies required by the extension
@@ -118,6 +153,12 @@ export interface PHPConfiguration {
118
153
  * @example ./my-php-template.ini
119
154
  */
120
155
  configTemplate: string
156
+ /**
157
+ * PHP XDebug file template location
158
+ *
159
+ * @example ./my-php-debug-template.ini
160
+ */
161
+ debugTemplate: string
121
162
 
122
163
  /**
123
164
  * PHP-FPM configuration file template location
@@ -1,26 +0,0 @@
1
- const os = require('os');
2
- const { spawn } = require('child_process');
3
-
4
- const executeInContainer = ({ containerName, commands }) => {
5
- if (!process.stdin.isTTY) {
6
- process.stderr.write('This app works only in TTY mode');
7
- process.exit(1);
8
- }
9
-
10
- const userArg = os.platform() === 'linux' && `--user=${os.userInfo().uid}:${os.userInfo().gid}`;
11
-
12
- spawn('docker', [
13
- 'exec',
14
- '-it',
15
- userArg,
16
- containerName
17
- ].filter(Boolean).concat(...commands.map((command) => command.split(' '))), {
18
- stdio: [0, 1, 2]
19
- });
20
-
21
- return new Promise((_resolve) => {
22
- // never resolve
23
- });
24
- };
25
-
26
- module.exports = executeInContainer;
@@ -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;