@bakers-build/addon-dropsh 0.5.1-next.758 → 0.5.1-next.776

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/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  # @bakers-build/addon-dropsh
2
2
 
3
- bakers.build dropsh command plugin: the `bakers dropsh` JSON:API shell bound to the split connection config.
3
+ bakers.build tools and auth command plugins using the shared connection config.
4
4
 
5
5
  Part of the bakers.build CLI. Install the meta package `@bakers-build/bakers` to get the `bakers` CLI with all addons. Source: https://git.key-tec.de/bakers-build/bakers-build (bakers-cli/).
@@ -1,6 +1,7 @@
1
1
  import { type BbCommandHost, type BbCommandPlugin, type WorkspaceRecoveryOptions } from '@bakers-build/core';
2
2
  export declare function dropshConfigHint(resolvedPath?: string): string;
3
3
  export interface DropshDispatchOptions extends WorkspaceRecoveryOptions {
4
+ publicCommand?: 'tools' | 'auth';
4
5
  stdout?: (text: string) => void;
5
6
  stderr?: (text: string) => void;
6
7
  }
@@ -8,3 +9,5 @@ export interface DropshDispatchOptions extends WorkspaceRecoveryOptions {
8
9
  export declare function dispatchBbDropsh(host: BbCommandHost, argv: string[], options?: DropshDispatchOptions): Promise<void>;
9
10
  declare const dropshCommandPlugin: BbCommandPlugin;
10
11
  export default dropshCommandPlugin;
12
+ export declare const toolsCommandPlugin: BbCommandPlugin;
13
+ export declare const authCommandPlugin: BbCommandPlugin;
package/dist/src/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { createBbConnectionContext, discoverBbWorkspaces, loadBbConnectionBootstrap, loadReadyBbConnection, } from '@bakers-build/core';
2
2
  import { toolPlugin } from '@dropsh/plugin-tool';
3
+ import { Help } from 'commander';
3
4
  import { buildProgram as buildDropshProgram } from 'dropsh';
4
5
  import { registerTemplateCommand } from './template.js';
5
6
  import { hideUnpublishedComments } from './unpublished-comments.js';
@@ -45,6 +46,8 @@ function invocation(argv) {
45
46
  connection = token.slice(13);
46
47
  if (token.startsWith('--format='))
47
48
  format = token.slice(9);
49
+ if (token.startsWith('--auth-profile='))
50
+ profile = token.slice(15);
48
51
  forwarded.push(token);
49
52
  }
50
53
  // Global options can appear late, after the command's positional arguments.
@@ -114,6 +117,19 @@ export async function dispatchBbDropsh(host, argv, options = {}) {
114
117
  }
115
118
  : {}),
116
119
  });
120
+ if (options.publicCommand) {
121
+ program.name('bakers');
122
+ const command = program.commands.find((entry) => entry.name() === (options.publicCommand === 'tools' ? 'tool' : 'auth'));
123
+ for (const entry of command ? [command, ...command.commands] : []) {
124
+ entry.exitOverride();
125
+ entry.configureHelp({
126
+ showGlobalOptions: true,
127
+ commandUsage: (entry) => new Help()
128
+ .commandUsage(entry)
129
+ .replace(/^bakers tool\b/, 'bakers tools'),
130
+ });
131
+ }
132
+ }
117
133
  if (connection) {
118
134
  registerTemplateCommand(program, {
119
135
  contextFactory: () => createBbConnectionContext(connection, {
@@ -140,7 +156,7 @@ const dropshCommandPlugin = {
140
156
  describe: 'JSON:API shell (dropsh) bound to the bakers.build connection config',
141
157
  register(program, host) {
142
158
  program
143
- .command('dropsh')
159
+ .command('dropsh', { hidden: true })
144
160
  .description('JSON:API shell bound to the bakers.build connection')
145
161
  .helpOption(false)
146
162
  .allowUnknownOption()
@@ -151,3 +167,33 @@ const dropshCommandPlugin = {
151
167
  },
152
168
  };
153
169
  export default dropshCommandPlugin;
170
+ function publicAlias(name, verb) {
171
+ return {
172
+ kind: 'command',
173
+ name,
174
+ describe: name === 'tools'
175
+ ? 'discover, inspect and execute named tools'
176
+ : 'manage connection authentication and profiles',
177
+ register(program, host) {
178
+ program
179
+ .command(name)
180
+ .description(this.describe)
181
+ .helpOption(false)
182
+ .allowUnknownOption()
183
+ .argument('[args...]')
184
+ .action(async (args) => {
185
+ try {
186
+ await dispatchBbDropsh(host, [verb, ...args], {
187
+ publicCommand: name,
188
+ });
189
+ }
190
+ catch (error) {
191
+ if (error.code !== 'commander.helpDisplayed')
192
+ throw error;
193
+ }
194
+ });
195
+ },
196
+ };
197
+ }
198
+ export const toolsCommandPlugin = publicAlias('tools', 'tool');
199
+ export const authCommandPlugin = publicAlias('auth', 'auth');
@@ -2,7 +2,22 @@ export const commands = (acc) => [
2
2
  ...acc,
3
3
  {
4
4
  name: 'dropsh',
5
+ hidden: true,
5
6
  plugin: '@bakers-build/addon-dropsh',
6
7
  describe: 'JSON:API shell (dropsh) bound to the bakers.build connection config',
7
8
  },
9
+ {
10
+ name: 'tools',
11
+ plugin: '@bakers-build/addon-dropsh',
12
+ export: 'toolsCommandPlugin',
13
+ forwardHelp: true,
14
+ describe: 'discover, inspect and execute named tools',
15
+ },
16
+ {
17
+ name: 'auth',
18
+ plugin: '@bakers-build/addon-dropsh',
19
+ export: 'authCommandPlugin',
20
+ forwardHelp: true,
21
+ describe: 'manage connection authentication and profiles',
22
+ },
8
23
  ];
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@bakers-build/addon-dropsh",
3
- "version": "0.5.1-next.758",
4
- "description": "bakers.build dropsh command plugin: the `bakers dropsh` JSON:API shell bound to the split connection config.",
3
+ "version": "0.5.1-next.776",
4
+ "description": "bakers.build tools and auth command plugins using the shared connection config.",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "exports": {
@@ -27,6 +27,6 @@
27
27
  "dropsh": "^0.8.2"
28
28
  },
29
29
  "peerDependencies": {
30
- "@bakers-build/core": "^0.5.1-next.758"
30
+ "@bakers-build/core": "^0.5.1-next.776"
31
31
  }
32
32
  }