@scandipwa/magento-scripts 2.0.0-alpha.10 → 2.0.0-alpha.13

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 (117) hide show
  1. package/lib/commands/cli.js +5 -0
  2. package/lib/commands/start.js +17 -3
  3. package/lib/commands/status.js +9 -1
  4. package/lib/config/config.js +20 -2
  5. package/lib/config/docker.js +43 -44
  6. package/lib/config/index.js +1 -1
  7. package/lib/config/php/versions/php-7.2.js +1 -0
  8. package/lib/config/php/versions/php-7.3.js +1 -0
  9. package/lib/config/php/versions/php-7.4.js +1 -0
  10. package/lib/config/php/versions/php-8.1.js +1 -0
  11. package/lib/config/php-config.js +4 -3
  12. package/lib/config/services/composer/versions/composer-1.js +8 -0
  13. package/lib/config/services/composer/versions/composer-2.js +8 -0
  14. package/lib/config/services/composer/versions/index.js +4 -0
  15. package/lib/config/services/nginx/versions/index.js +3 -0
  16. package/lib/config/services/nginx/versions/nginx-1.18.js +11 -0
  17. package/lib/config/{ssl-terminator → services/ssl-terminator}/index.js +3 -0
  18. package/lib/config/templates/magentorc.template +6 -5
  19. package/lib/config/templates/php-debug.template.ini +31 -0
  20. package/lib/config/templates/php-fpm.template.conf +1 -2
  21. package/lib/config/templates/php.template.ini +5 -201
  22. package/lib/config/templates/ssl-terminator.template.conf +2 -0
  23. package/lib/config/templates/varnish.template.vcl +20 -13
  24. package/lib/config/varnish/varnish-6-0.js +4 -0
  25. package/lib/config/varnish/varnish-6-6.js +4 -0
  26. package/lib/config/varnish/varnish-7-0.js +4 -0
  27. package/lib/config/versions/magento-2.3.0.js +5 -9
  28. package/lib/config/versions/magento-2.3.1.js +5 -9
  29. package/lib/config/versions/magento-2.3.2-p1.js +5 -9
  30. package/lib/config/versions/magento-2.3.2-p2.js +5 -9
  31. package/lib/config/versions/magento-2.3.2.js +5 -9
  32. package/lib/config/versions/magento-2.3.3-p1.js +5 -9
  33. package/lib/config/versions/magento-2.3.3.js +5 -9
  34. package/lib/config/versions/magento-2.3.4-p1.js +5 -9
  35. package/lib/config/versions/magento-2.3.4-p2.js +5 -9
  36. package/lib/config/versions/magento-2.3.4.js +5 -9
  37. package/lib/config/versions/magento-2.3.5-p1.js +5 -9
  38. package/lib/config/versions/magento-2.3.5-p2.js +5 -9
  39. package/lib/config/versions/magento-2.3.5.js +5 -9
  40. package/lib/config/versions/magento-2.3.6-p1.js +5 -9
  41. package/lib/config/versions/magento-2.3.6.js +5 -9
  42. package/lib/config/versions/magento-2.3.7-p1.js +5 -9
  43. package/lib/config/versions/magento-2.3.7-p2.js +5 -9
  44. package/lib/config/versions/magento-2.3.7-p3.js +5 -9
  45. package/lib/config/versions/magento-2.3.7-p4.js +5 -9
  46. package/lib/config/versions/magento-2.3.7.js +5 -9
  47. package/lib/config/versions/magento-2.4.0-p1.js +5 -9
  48. package/lib/config/versions/magento-2.4.0.js +5 -9
  49. package/lib/config/versions/magento-2.4.1-p1.js +5 -9
  50. package/lib/config/versions/magento-2.4.1.js +5 -9
  51. package/lib/config/versions/magento-2.4.2-p1.js +5 -9
  52. package/lib/config/versions/magento-2.4.2-p2.js +5 -9
  53. package/lib/config/versions/magento-2.4.2.js +5 -9
  54. package/lib/config/versions/magento-2.4.3-p1.js +5 -9
  55. package/lib/config/versions/magento-2.4.3-p2.js +5 -9
  56. package/lib/config/versions/magento-2.4.3-p3.js +5 -9
  57. package/lib/config/versions/magento-2.4.3.js +5 -9
  58. package/lib/config/versions/magento-2.4.4-p1.js +5 -9
  59. package/lib/config/versions/magento-2.4.4.js +5 -9
  60. package/lib/config/versions/magento-2.4.5.js +5 -9
  61. package/lib/tasks/composer/local-auth-json.js +1 -1
  62. package/lib/tasks/database/connect-to-database.js +6 -3
  63. package/lib/tasks/database/create-magento-database.js +5 -2
  64. package/lib/tasks/database/create-magento-user.js +50 -0
  65. package/lib/tasks/database/default-magento-database.js +3 -0
  66. package/lib/tasks/database/default-magento-user.js +7 -0
  67. package/lib/tasks/database/import-dump-to-database.js +3 -2
  68. package/lib/tasks/docker/api.d.ts +25 -1
  69. package/lib/tasks/docker/api.js +31 -1
  70. package/lib/tasks/docker/containers/container-api.d.ts +14 -0
  71. package/lib/tasks/docker/containers/container-api.js +50 -1
  72. package/lib/tasks/docker/containers/tasks.js +32 -1
  73. package/lib/tasks/docker/index.js +6 -1
  74. package/lib/tasks/docker/project-image-builder.js +6 -8
  75. package/lib/tasks/docker/volume/index.js +2 -1
  76. package/lib/tasks/docker/volume/tasks.js +54 -9
  77. package/lib/tasks/docker/volume/volume-api.d.ts +10 -0
  78. package/lib/tasks/docker/volume/volume-api.js +25 -1
  79. package/lib/tasks/execute.js +5 -2
  80. package/lib/tasks/file-system/create-nginx-config.js +3 -5
  81. package/lib/tasks/file-system/create-php-config.js +2 -23
  82. package/lib/tasks/file-system/create-php-debug-config.js +45 -0
  83. package/lib/tasks/file-system/create-php-fpm-config.js +2 -4
  84. package/lib/tasks/file-system/create-ssl-terminator-config.js +4 -7
  85. package/lib/tasks/file-system/create-varnish-config.js +4 -7
  86. package/lib/tasks/file-system/index.js +2 -0
  87. package/lib/tasks/magento/setup-magento/configure-elasticsearch.js +2 -4
  88. package/lib/tasks/magento/setup-magento/flush-redis-config.js +3 -6
  89. package/lib/tasks/magento/setup-magento/install-magento.js +8 -10
  90. package/lib/tasks/magento/setup-magento/varnish-config.js +4 -9
  91. package/lib/tasks/magento/setup-magento/waiting-for-varnish.js +15 -16
  92. package/lib/tasks/php/php-container.js +1 -1
  93. package/lib/tasks/php/update-env-php.js +3 -4
  94. package/lib/tasks/requirements/composer-credentials.js +7 -3
  95. package/lib/tasks/requirements/docker/context.js +88 -0
  96. package/lib/tasks/requirements/docker/index.js +107 -18
  97. package/lib/tasks/requirements/docker/install.js +21 -7
  98. package/lib/tasks/requirements/docker/permissions.js +2 -11
  99. package/lib/tasks/requirements/docker/running-status.js +94 -24
  100. package/lib/tasks/requirements/docker/version.js +1 -0
  101. package/lib/tasks/requirements/index.js +0 -2
  102. package/lib/tasks/requirements/php-version.js +4 -2
  103. package/lib/tasks/start.js +27 -6
  104. package/lib/tasks/status/index.js +13 -11
  105. package/lib/tasks/stop.js +2 -0
  106. package/lib/util/config-file-validator.js +2 -0
  107. package/lib/util/execute-in-container.js +3 -3
  108. package/lib/util/systemctl.js +62 -13
  109. package/package.json +2 -2
  110. package/typings/context.d.ts +7 -0
  111. package/typings/index.d.ts +38 -1
  112. package/lib/tasks/requirements/dependency/arch.js +0 -50
  113. package/lib/tasks/requirements/dependency/centos.js +0 -36
  114. package/lib/tasks/requirements/dependency/fedora.js +0 -36
  115. package/lib/tasks/requirements/dependency/index.js +0 -33
  116. package/lib/tasks/requirements/dependency/mac.js +0 -124
  117. package/lib/tasks/requirements/dependency/ubuntu.js +0 -83
@@ -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,6 +22,9 @@ 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: {
@@ -31,10 +34,10 @@ const prettyStatus = async (ctx) => {
31
34
  dockerVersion,
32
35
  platform,
33
36
  platformVersion,
34
- containers
37
+ containers,
38
+ composerVersion
35
39
  } = ctx;
36
40
  const projectCreatedAt = getProjectCreatedAt();
37
- const composerVersion = await getComposerVersion(ctx);
38
41
 
39
42
  const prefix = getPrefix();
40
43
 
@@ -103,6 +106,13 @@ const prettyStatus = async (ctx) => {
103
106
  block.addLine(`${' '.repeat(3)} ${logger.style.misc(envName)}=${logger.style.file(envValue)}`);
104
107
  }
105
108
  }
109
+
110
+ if (container.description) {
111
+ block.addLine('Description:');
112
+ container.description.split('\n').forEach((line) => {
113
+ block.addLine(line);
114
+ });
115
+ }
106
116
  });
107
117
 
108
118
  const instanceMetadata = getInstanceMetadata(ctx);
@@ -123,14 +133,6 @@ const prettyStatus = async (ctx) => {
123
133
  instanceMetadata.admin.forEach(({ title, text }) => {
124
134
  block.addLine(` ${title}: ${text}`);
125
135
  });
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
136
 
135
137
  block.log();
136
138
  };
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(),
@@ -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
  });
@@ -3,15 +3,15 @@ const { spawn } = require('child_process');
3
3
  const { runCommand } = require('../tasks/docker/containers/container-api');
4
4
 
5
5
  /**
6
- * @param {{ containerName: string, commands: string[] }} param0
6
+ * @param {{ containerName: string, commands: string[], isDockerDesktop: boolean }} param0
7
7
  */
8
- const executeInContainer = ({ containerName, commands }) => {
8
+ const executeInContainer = ({ containerName, commands, isDockerDesktop }) => {
9
9
  if (!process.stdin.isTTY) {
10
10
  process.stderr.write('This app works only in TTY mode');
11
11
  process.exit(1);
12
12
  }
13
13
 
14
- const userArg = os.platform() === 'linux' && `--user=${os.userInfo().uid}:${os.userInfo().gid}`;
14
+ const userArg = ((os.platform() === 'linux' && isDockerDesktop) || !isDockerDesktop) && `--user=${os.userInfo().uid}:${os.userInfo().gid}`;
15
15
 
16
16
  spawn('docker', [
17
17
  'exec',
@@ -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,7 +3,7 @@
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.10",
6
+ "version": "2.0.0-alpha.13",
7
7
  "main": "./index.js",
8
8
  "types": "./typings/index.d.ts",
9
9
  "license": "OSL-3.0",
@@ -54,5 +54,5 @@
54
54
  "mysql",
55
55
  "scandipwa"
56
56
  ],
57
- "gitHead": "8b34ad44642dc8b4decf57df42f45ab2cdd18e16"
57
+ "gitHead": "92a6255dbb6fb46334c0677be8f1ff2c7adab56f"
58
58
  }
@@ -1,11 +1,13 @@
1
1
  import mysql2 from 'mysql2';
2
2
 
3
+ import { DockerVersionResult } from '../lib/tasks/docker/api';
3
4
  import { CMAConfiguration, PHPExtensions } from './index';
4
5
  import { PHPStormConfig } from './phpstorm';
5
6
 
6
7
  export interface ListrContext {
7
8
  magentoVersion: string
8
9
  composerVersion: string
10
+ phpVersion: string
9
11
  port?: number
10
12
  ports?: {
11
13
  app: number
@@ -67,6 +69,7 @@ export interface ListrContext {
67
69
  network: string
68
70
  image: string
69
71
  debugImage?: string
72
+ remoteImages?: string[]
70
73
  name: string
71
74
  command: string
72
75
  connectCommand: string[]
@@ -90,4 +93,8 @@ export interface ListrContext {
90
93
  }
91
94
  databaseConnection: mysql2.Connection
92
95
  isSetupUpgradeNeeded?: boolean
96
+ isDockerDesktop?: boolean
97
+ dockerServerData?: DockerVersionResult['Server']
98
+ dockerClientData?: DockerVersionResult['Client']
99
+ dockerVersion?: DockerVersionResult['Server']['Version']
93
100
  }
@@ -52,13 +52,42 @@ 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
+ }>
62
91
  }
63
92
 
64
93
  export interface PHPExtensionInstallationInstruction {
@@ -80,7 +109,9 @@ export interface PHPExtensionInstallationInstruction {
80
109
  * pecl install xdebug && docker-php-ext-enable xdebug
81
110
  * ```
82
111
  */
83
- command: (arg0: (Omit<PHPExtensionInstallationInstruction, 'command'> & { ctx: ListrContext})) => string | string
112
+ command: string |
113
+ ((arg0: (Omit<PHPExtensionInstallationInstruction, 'command'> & { ctx: ListrContext})) => string) |
114
+ ((arg0: (Omit<PHPExtensionInstallationInstruction, 'command'> & { ctx: ListrContext})) => Promise<string>)
84
115
 
85
116
  /**
86
117
  * System dependencies required by the extension
@@ -118,6 +149,12 @@ export interface PHPConfiguration {
118
149
  * @example ./my-php-template.ini
119
150
  */
120
151
  configTemplate: string
152
+ /**
153
+ * PHP XDebug file template location
154
+ *
155
+ * @example ./my-php-debug-template.ini
156
+ */
157
+ debugTemplate: string
121
158
 
122
159
  /**
123
160
  * 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;