UNPKG

2.34 kBJavaScriptView Raw
1'use strict';
2
3Object.defineProperty(exports, '__esModule', {
4 value: true
5});
6exports.default = getSelectProjectsMessage;
7function _chalk() {
8 const data = _interopRequireDefault(require('chalk'));
9 _chalk = function () {
10 return data;
11 };
12 return data;
13}
14var _getProjectDisplayName = _interopRequireDefault(
15 require('./getProjectDisplayName')
16);
17function _interopRequireDefault(obj) {
18 return obj && obj.__esModule ? obj : {default: obj};
19}
20/**
21 * Copyright (c) Meta Platforms, Inc. and affiliates.
22 *
23 * This source code is licensed under the MIT license found in the
24 * LICENSE file in the root directory of this source tree.
25 */
26
27function getSelectProjectsMessage(projectConfigs, opts) {
28 if (projectConfigs.length === 0) {
29 return getNoSelectionWarning(opts);
30 }
31 return getProjectsRunningMessage(projectConfigs);
32}
33function 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}
52function 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}
65function 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}