@getmonoceros/workbench 1.1.0 → 1.2.0

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/bin.js CHANGED
@@ -122,12 +122,13 @@ function renderCommandsBlock(entries) {
122
122
  const renderSection = (label, items) => {
123
123
  if (items.length === 0) return;
124
124
  lines.push("");
125
- lines.push(` ${grey(label)}`);
125
+ lines.push(underline(grey(label)));
126
+ lines.push("");
126
127
  const rows = items.map((e) => [
127
128
  cyan(e.name),
128
129
  e.description
129
130
  ]);
130
- lines.push(alignTable(rows, " "));
131
+ lines.push(alignTable(rows, ""));
131
132
  };
132
133
  for (const { key, label } of GROUPS) {
133
134
  renderSection(label, byGroup.get(key) ?? []);
@@ -2362,7 +2363,7 @@ function warnOnDeprecatedFeatureRefs(containerFeatures, globalConfig, logger) {
2362
2363
  }
2363
2364
 
2364
2365
  // src/version.ts
2365
- var CLI_VERSION = "1.1.0";
2366
+ var CLI_VERSION = "1.2.0";
2366
2367
 
2367
2368
  // src/commands/_dispatch.ts
2368
2369
  import { consola as consola11 } from "consola";
@@ -2451,7 +2452,7 @@ var COMMANDS_WITH_CONTAINER_ARG = [
2451
2452
  "remove-from-url",
2452
2453
  "remove-repo"
2453
2454
  ];
2454
- var SHELLS = ["bash", "zsh"];
2455
+ var SHELLS = ["bash", "zsh", "pwsh"];
2455
2456
  function renderCompletionScript(shell) {
2456
2457
  const commands = ALL_COMMANDS.join(" ");
2457
2458
  const containerCommandsRegex = COMMANDS_WITH_CONTAINER_ARG.join("|");
@@ -2492,6 +2493,54 @@ function renderCompletionScript(shell) {
2492
2493
  ""
2493
2494
  ].join("\n");
2494
2495
  }
2496
+ if (shell === "pwsh") {
2497
+ return [
2498
+ "# PowerShell completion for monoceros",
2499
+ "# install: dot-source this file from your $PROFILE, e.g.",
2500
+ "# monoceros completion pwsh > $HOME/.config/monoceros/completion.ps1",
2501
+ "# Add-Content $PROFILE '. $HOME/.config/monoceros/completion.ps1'",
2502
+ "",
2503
+ "Register-ArgumentCompleter -Native -CommandName monoceros -ScriptBlock {",
2504
+ " param($wordToComplete, $commandAst, $cursorPosition)",
2505
+ "",
2506
+ " $commands = @(",
2507
+ ...ALL_COMMANDS.map((c) => ` '${c}'`),
2508
+ " )",
2509
+ ` $shells = @('${SHELLS.join("', '")}')`,
2510
+ " $containerCommands = @(",
2511
+ ...COMMANDS_WITH_CONTAINER_ARG.map((c) => ` '${c}'`),
2512
+ " )",
2513
+ "",
2514
+ " $tokens = $commandAst.CommandElements",
2515
+ " $position = $tokens.Count",
2516
+ " if ($wordToComplete) { $position-- }",
2517
+ "",
2518
+ " if ($position -eq 1) {",
2519
+ ' $commands | Where-Object { $_ -like "$wordToComplete*" } |',
2520
+ ' ForEach-Object { [System.Management.Automation.CompletionResult]::new($_, $_, "ParameterValue", $_) }',
2521
+ " return",
2522
+ " }",
2523
+ "",
2524
+ " if ($position -eq 2) {",
2525
+ " $cmd = $tokens[1].Value",
2526
+ " if ($containerCommands -contains $cmd) {",
2527
+ ' $home = if ($env:MONOCEROS_HOME) { $env:MONOCEROS_HOME } else { Join-Path $env:USERPROFILE ".monoceros" }',
2528
+ ' $configsDir = Join-Path $home "container-configs"',
2529
+ " if (Test-Path $configsDir) {",
2530
+ ' Get-ChildItem -Path $configsDir -Filter "*.yml" |',
2531
+ " ForEach-Object { $_.BaseName } |",
2532
+ ' Where-Object { $_ -like "$wordToComplete*" } |',
2533
+ ' ForEach-Object { [System.Management.Automation.CompletionResult]::new($_, $_, "ParameterValue", $_) }',
2534
+ " }",
2535
+ ' } elseif ($cmd -eq "completion") {',
2536
+ ' $shells | Where-Object { $_ -like "$wordToComplete*" } |',
2537
+ ' ForEach-Object { [System.Management.Automation.CompletionResult]::new($_, $_, "ParameterValue", $_) }',
2538
+ " }",
2539
+ " }",
2540
+ "}",
2541
+ ""
2542
+ ].join("\n");
2543
+ }
2495
2544
  return [
2496
2545
  "#compdef monoceros",
2497
2546
  "# zsh completion for monoceros",
@@ -2538,18 +2587,18 @@ var completionCommand = defineCommand8({
2538
2587
  meta: {
2539
2588
  name: "completion",
2540
2589
  group: "tooling",
2541
- description: "Print a shell completion script for bash or zsh to stdout. Pipe the output into a file your shell loads at startup."
2590
+ description: "Print a shell completion script for bash, zsh or PowerShell to stdout. Pipe the output into a file your shell loads at startup. The install scripts (install.sh / install.ps1) call this automatically."
2542
2591
  },
2543
2592
  args: {
2544
2593
  shell: {
2545
2594
  type: "positional",
2546
- description: "Target shell. One of: 'bash', 'zsh'.",
2595
+ description: "Target shell. One of: 'bash', 'zsh', 'pwsh'.",
2547
2596
  required: true
2548
2597
  }
2549
2598
  },
2550
2599
  run({ args }) {
2551
2600
  const shell = args.shell;
2552
- if (shell !== "bash" && shell !== "zsh") {
2601
+ if (shell !== "bash" && shell !== "zsh" && shell !== "pwsh") {
2553
2602
  process.stderr.write(
2554
2603
  `Unknown shell: ${JSON.stringify(shell)}. Supported: ${SHELLS.join(", ")}.
2555
2604
  `