1 | 'use strict';
|
2 |
|
3 | Object.defineProperty(exports, '__esModule', {
|
4 | value: true
|
5 | });
|
6 | exports.default = getSelectProjectsMessage;
|
7 | function _chalk() {
|
8 | const data = _interopRequireDefault(require('chalk'));
|
9 | _chalk = function () {
|
10 | return data;
|
11 | };
|
12 | return data;
|
13 | }
|
14 | var _getProjectDisplayName = _interopRequireDefault(
|
15 | require('./getProjectDisplayName')
|
16 | );
|
17 | function _interopRequireDefault(obj) {
|
18 | return obj && obj.__esModule ? obj : {default: obj};
|
19 | }
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 | function getSelectProjectsMessage(projectConfigs, opts) {
|
28 | if (projectConfigs.length === 0) {
|
29 | return getNoSelectionWarning(opts);
|
30 | }
|
31 | return getProjectsRunningMessage(projectConfigs);
|
32 | }
|
33 | function getNoSelectionWarning(opts) {
|
34 | if (opts.ignoreProjects && opts.selectProjects) {
|
35 | return _chalk().default.yellow(
|
36 | 'You provided values for --selectProjects and --ignoreProjects, but no projects were found matching the selection.\n' +
|
37 | 'Are you ignoring all the selected projects?\n'
|
38 | );
|
39 | } else if (opts.ignoreProjects) {
|
40 | return _chalk().default.yellow(
|
41 | 'You provided values for --ignoreProjects, but no projects were found matching the selection.\n' +
|
42 | 'Are you ignoring all projects?\n'
|
43 | );
|
44 | } else if (opts.selectProjects) {
|
45 | return _chalk().default.yellow(
|
46 | 'You provided values for --selectProjects but no projects were found matching the selection.\n'
|
47 | );
|
48 | } else {
|
49 | return _chalk().default.yellow('No projects were found.\n');
|
50 | }
|
51 | }
|
52 | function getProjectsRunningMessage(projectConfigs) {
|
53 | if (projectConfigs.length === 1) {
|
54 | const name =
|
55 | (0, _getProjectDisplayName.default)(projectConfigs[0]) ??
|
56 | '<unnamed project>';
|
57 | return `Running one project: ${_chalk().default.bold(name)}\n`;
|
58 | }
|
59 | const projectsList = projectConfigs
|
60 | .map(getProjectNameListElement)
|
61 | .sort()
|
62 | .join('\n');
|
63 | return `Running ${projectConfigs.length} projects:\n${projectsList}\n`;
|
64 | }
|
65 | function getProjectNameListElement(projectConfig) {
|
66 | const name = (0, _getProjectDisplayName.default)(projectConfig);
|
67 | const elementContent = name
|
68 | ? _chalk().default.bold(name)
|
69 | : '<unnamed project>';
|
70 | return `- ${elementContent}`;
|
71 | }
|