@wpmoo/toolkit 0.9.19 → 0.9.21

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.
package/dist/cli.js CHANGED
@@ -280,8 +280,8 @@ async function showStartup(argv, skipUpdateCheck, details) {
280
280
  }
281
281
  console.log();
282
282
  }
283
- async function selectCockpitCommandFromMenu(serviceStatus, moduleCount) {
284
- const selection = await selectCockpitTopLevelMenu({ serviceStatus, moduleCount });
283
+ async function selectCockpitCommandFromMenu(serviceStatus, moduleCount, sourceRepoCount) {
284
+ const selection = await selectCockpitTopLevelMenu({ serviceStatus, moduleCount, sourceRepoCount });
285
285
  if (selection.kind === 'exit') {
286
286
  return 'exit';
287
287
  }
@@ -1453,7 +1453,7 @@ export async function runCli(cliArgv = process.argv.slice(2), cwd = process.cwd(
1453
1453
  };
1454
1454
  while (true) {
1455
1455
  try {
1456
- const command = await selectCockpitCommandFromMenu(serviceStatus, status.kind === 'environment' ? status.moduleCandidateCount : undefined);
1456
+ const command = await selectCockpitCommandFromMenu(serviceStatus, status.kind === 'environment' ? status.moduleCandidateCount : undefined, status.kind === 'environment' ? status.sourceRepoCount : undefined);
1457
1457
  if (command === 'exit') {
1458
1458
  return;
1459
1459
  }
@@ -48,8 +48,13 @@ function serviceDisabledReason(command, serviceStatus) {
48
48
  function moduleDisabledReason(command, moduleCount) {
49
49
  return moduleCount === 0 && moduleDependentCommandIds.has(command.id) ? 'No modules found.' : undefined;
50
50
  }
51
- function disabledReason(command, serviceStatus, moduleCount) {
52
- return serviceDisabledReason(command, serviceStatus) ?? moduleDisabledReason(command, moduleCount);
51
+ function sourceRepoDisabledReason(command, sourceRepoCount) {
52
+ return sourceRepoCount === 0 && command.id === 'add-module' ? 'No source repos found.' : undefined;
53
+ }
54
+ function disabledReason(command, serviceStatus, moduleCount, sourceRepoCount) {
55
+ return (serviceDisabledReason(command, serviceStatus) ??
56
+ moduleDisabledReason(command, moduleCount) ??
57
+ sourceRepoDisabledReason(command, sourceRepoCount));
53
58
  }
54
59
  function disabledError() {
55
60
  return 'This option is disabled and cannot be selected.';
@@ -60,7 +65,7 @@ function commandDisabledValue(reason) {
60
65
  }
61
66
  return reason;
62
67
  }
63
- function categoryChoices(category, index, serviceStatus, moduleCount) {
68
+ function categoryChoices(category, index, serviceStatus, moduleCount, sourceRepoCount) {
64
69
  const choices = [
65
70
  promptSeparator(categoryHeading(category)),
66
71
  ...topLevelCommands
@@ -70,7 +75,7 @@ function categoryChoices(category, index, serviceStatus, moduleCount) {
70
75
  value: command,
71
76
  name: commandName(command),
72
77
  short: command.label,
73
- disabled: commandDisabledValue(disabledReason(command, serviceStatus, moduleCount)),
78
+ disabled: commandDisabledValue(disabledReason(command, serviceStatus, moduleCount, sourceRepoCount)),
74
79
  };
75
80
  }),
76
81
  ];
@@ -103,8 +108,8 @@ function menuDeps(deps = {}) {
103
108
  function isCockpitCommand(value) {
104
109
  return typeof value === 'object' && value !== null && 'id' in value && 'slashAlias' in value;
105
110
  }
106
- function topLevelChoices(serviceStatus, moduleCount) {
107
- return topLevelCategoryOrder.flatMap((category, index) => categoryChoices(category, index, serviceStatus, moduleCount));
111
+ function topLevelChoices(serviceStatus, moduleCount, sourceRepoCount) {
112
+ return topLevelCategoryOrder.flatMap((category, index) => categoryChoices(category, index, serviceStatus, moduleCount, sourceRepoCount));
108
113
  }
109
114
  function defaultCommand(serviceStatus) {
110
115
  if (serviceStatus?.kind === 'running') {
@@ -117,7 +122,7 @@ function defaultCommand(serviceStatus) {
117
122
  }
118
123
  export async function selectCockpitTopLevelMenu(options = {}) {
119
124
  const deps = menuDeps(options);
120
- const choices = topLevelChoices(options.serviceStatus, options.moduleCount);
125
+ const choices = topLevelChoices(options.serviceStatus, options.moduleCount, options.sourceRepoCount);
121
126
  const cancelAction = 'back';
122
127
  const selected = await deps.select({
123
128
  message: '',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wpmoo/toolkit",
3
- "version": "0.9.19",
3
+ "version": "0.9.21",
4
4
  "description": "WPMoo Toolkit for development, staging, and production lifecycle workflows.",
5
5
  "type": "module",
6
6
  "repository": {