@lsst/pik 0.4.1 → 0.4.2

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/index.d.ts CHANGED
@@ -1,2 +1,3 @@
1
- export { defineConfig, type PikConfig } from './lib/config.js';
1
+ export { defineConfig, type PikConfig } from '@lsst/pik-core';
2
+ export { program } from './lib/program.js';
2
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,KAAK,SAAS,EAAE,MAAM,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,KAAK,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAG9D,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC"}
package/dist/index.js CHANGED
@@ -1,2 +1,4 @@
1
- // Config helper for pik.config.ts
2
- export { defineConfig } from './lib/config.js';
1
+ // Re-export config helper for pik.config.ts
2
+ export { defineConfig } from '@lsst/pik-core';
3
+ // Re-export the program for programmatic usage
4
+ export { program } from './lib/program.js';
@@ -1 +1 @@
1
- {"version":3,"file":"program.d.ts","sourceRoot":"","sources":["../../src/lib/program.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAMpC,eAAO,MAAM,OAAO,SAGG,CAAC"}
1
+ {"version":3,"file":"program.d.ts","sourceRoot":"","sources":["../../src/lib/program.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAUpC,eAAO,MAAM,OAAO,SAGG,CAAC"}
@@ -1,16 +1,48 @@
1
1
  import { Command } from 'commander';
2
+ import { select, Separator } from '@inquirer/prompts';
3
+ import pc from 'picocolors';
4
+ import { selectPlugin } from '@lsst/pik-plugin-select';
2
5
  import pkg from '../../package.json' with { type: 'json' };
3
- import { listCommand } from './commands/list.js';
4
- import { setCommand } from './commands/set.js';
5
- import { switchCommand } from './commands/switch.js';
6
+ // List of available plugins
7
+ const plugins = [selectPlugin];
6
8
  export const program = new Command()
7
9
  .name(pkg.name)
8
10
  .description(pkg.description)
9
11
  .version(pkg.version);
10
- program.addCommand(listCommand);
11
- program.addCommand(setCommand);
12
- program.addCommand(switchCommand);
13
- // Default command: interactive switch
12
+ // Register all plugins
13
+ for (const plugin of plugins) {
14
+ plugin.register(program);
15
+ }
16
+ // Default action: show main menu if multiple plugins, otherwise run default plugin
14
17
  program.action(async () => {
15
- await switchCommand.parseAsync([]);
18
+ if (plugins.length === 1) {
19
+ // Single plugin - run its default command
20
+ const plugin = plugins[0];
21
+ const cmd = program.commands.find((c) => c.name() === plugin.command);
22
+ if (cmd) {
23
+ await cmd.parseAsync([], { from: 'user' });
24
+ }
25
+ }
26
+ else {
27
+ // Multiple plugins - show selection menu
28
+ const EXIT_VALUE = Symbol('exit');
29
+ const selectedPlugin = await select({
30
+ message: 'Select a tool',
31
+ choices: [
32
+ ...plugins.map((plugin) => ({
33
+ name: `${pc.bold(plugin.name)} - ${plugin.description}`,
34
+ value: plugin,
35
+ })),
36
+ new Separator(),
37
+ { name: pc.dim('Exit'), value: EXIT_VALUE },
38
+ ],
39
+ });
40
+ if (selectedPlugin === EXIT_VALUE) {
41
+ return;
42
+ }
43
+ const cmd = program.commands.find((c) => c.name() === selectedPlugin.command);
44
+ if (cmd) {
45
+ await cmd.parseAsync([], { from: 'user' });
46
+ }
47
+ }
16
48
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lsst/pik",
3
- "version": "0.4.1",
3
+ "version": "0.4.2",
4
4
  "description": "CLI tool for switching config options in source files",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -41,9 +41,8 @@
41
41
  "dependencies": {
42
42
  "@inquirer/prompts": "^8.1.0",
43
43
  "@lsst/pik-core": "*",
44
+ "@lsst/pik-plugin-select": "*",
44
45
  "commander": "^14.0.2",
45
- "glob": "^10.5.0",
46
- "picocolors": "^1.1.1",
47
- "tslib": "^2.3.0"
46
+ "picocolors": "^1.1.1"
48
47
  }
49
48
  }