@lsst/pik 0.4.0 → 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 +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -2
- package/dist/lib/commands/list.d.ts.map +1 -1
- package/dist/lib/commands/list.js +22 -2
- package/dist/lib/program.d.ts.map +1 -1
- package/dist/lib/program.js +40 -8
- package/package.json +3 -4
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -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,
|
|
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
|
-
//
|
|
2
|
-
export { defineConfig } from '
|
|
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":"list.d.ts","sourceRoot":"","sources":["../../../src/lib/commands/list.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../../src/lib/commands/list.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAUpC,eAAO,MAAM,WAAW,SA6DpB,CAAC"}
|
|
@@ -6,14 +6,34 @@ import { Scanner } from '../scanner.js';
|
|
|
6
6
|
export const listCommand = new Command('list')
|
|
7
7
|
.alias('ls')
|
|
8
8
|
.description('List all selectors and their current state')
|
|
9
|
-
.
|
|
9
|
+
.option('--json', 'Output in JSON format')
|
|
10
|
+
.action(async (options) => {
|
|
10
11
|
const config = await loadConfig();
|
|
11
12
|
if (!config) {
|
|
12
|
-
|
|
13
|
+
if (options.json) {
|
|
14
|
+
console.log(JSON.stringify({ error: 'No pik.config.ts found' }));
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
console.error(pc.red('No pik.config.ts found'));
|
|
18
|
+
}
|
|
13
19
|
process.exit(1);
|
|
14
20
|
}
|
|
15
21
|
const scanner = new Scanner(config);
|
|
16
22
|
const results = await scanner.scan();
|
|
23
|
+
if (options.json) {
|
|
24
|
+
const jsonOutput = results.flatMap((file) => file.selectors.map((selector) => ({
|
|
25
|
+
name: selector.name,
|
|
26
|
+
file: relative(process.cwd(), file.path),
|
|
27
|
+
line: selector.line,
|
|
28
|
+
activeOption: selector.options.find((o) => o.isActive)?.name ?? null,
|
|
29
|
+
options: selector.options.map((o) => ({
|
|
30
|
+
name: o.name,
|
|
31
|
+
isActive: o.isActive,
|
|
32
|
+
})),
|
|
33
|
+
})));
|
|
34
|
+
console.log(JSON.stringify(jsonOutput, null, 2));
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
17
37
|
if (results.length === 0) {
|
|
18
38
|
console.log(pc.yellow('No selectors found'));
|
|
19
39
|
return;
|
|
@@ -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;
|
|
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"}
|
package/dist/lib/program.js
CHANGED
|
@@ -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
|
-
|
|
4
|
-
|
|
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
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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
|
-
|
|
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.
|
|
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
|
-
"
|
|
46
|
-
"picocolors": "^1.1.1",
|
|
47
|
-
"tslib": "^2.3.0"
|
|
46
|
+
"picocolors": "^1.1.1"
|
|
48
47
|
}
|
|
49
48
|
}
|