@lsst/pik 0.6.2 → 0.6.4

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.
@@ -1,3 +1,3 @@
1
- import type { PikPlugin } from '@lsst/pik-core';
1
+ import { type PikPlugin } from '@lsst/pik-core';
2
2
  export declare const killportPlugin: PikPlugin;
3
3
  //# sourceMappingURL=killport.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"killport.d.ts","sourceRoot":"","sources":["../../../src/lib/plugins/killport.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAyEhD,eAAO,MAAM,cAAc,EAAE,SAgD5B,CAAC"}
1
+ {"version":3,"file":"killport.d.ts","sourceRoot":"","sources":["../../../src/lib/plugins/killport.ts"],"names":[],"mappings":"AAIA,OAAO,EAAc,KAAK,SAAS,EAAE,MAAM,gBAAgB,CAAC;AA6E5D,eAAO,MAAM,cAAc,EAAE,SAgE5B,CAAC"}
@@ -1,6 +1,7 @@
1
1
  import { execSync } from 'child_process';
2
2
  import { confirm, input } from '@inquirer/prompts';
3
3
  import pc from 'picocolors';
4
+ import { loadConfig } from '@lsst/pik-core';
4
5
  function getProcessesOnPort(port) {
5
6
  try {
6
7
  const output = execSync(`lsof -ti:${port}`, { encoding: 'utf-8' });
@@ -74,7 +75,21 @@ export const killportPlugin = {
74
75
  .description('Kill process running on a specific port')
75
76
  .argument('[port]', 'Port number (interactive if not provided)')
76
77
  .option('-y, --yes', 'Skip confirmation')
78
+ .option('--config', 'Output plugin config as JSON')
79
+ .option('--json', 'Use JSON output format')
77
80
  .action(async (portArg, options) => {
81
+ const pikConfig = await loadConfig();
82
+ const killportConfig = pikConfig?.killport || {};
83
+ const defaultPort = killportConfig.defaultPort;
84
+ if (options.config) {
85
+ if (options.json) {
86
+ console.log(JSON.stringify(killportConfig));
87
+ }
88
+ else {
89
+ console.log('defaultPort:', defaultPort ?? 'not set');
90
+ }
91
+ return;
92
+ }
78
93
  if (portArg) {
79
94
  const port = parseInt(portArg, 10);
80
95
  if (isNaN(port) || port < 1 || port > 65535) {
@@ -84,10 +99,11 @@ export const killportPlugin = {
84
99
  await killPortInteractive(port, options.yes ?? false);
85
100
  }
86
101
  else {
87
- // Interactive mode - prompt for port number
102
+ // Interactive mode - prompt for port number with default
88
103
  try {
89
104
  const portInput = await input({
90
105
  message: 'Port number:',
106
+ default: defaultPort?.toString(),
91
107
  validate: (value) => {
92
108
  const num = parseInt(value, 10);
93
109
  if (isNaN(num) || num < 1 || num > 65535) {
@@ -101,7 +117,7 @@ export const killportPlugin = {
101
117
  }
102
118
  catch (error) {
103
119
  if (error instanceof Error && error.name === 'ExitPromptError') {
104
- return;
120
+ process.exit(0);
105
121
  }
106
122
  throw error;
107
123
  }
@@ -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;AAGpC,OAAO,EAA6B,KAAK,SAAS,EAAE,MAAM,gBAAgB,CAAC;AA8C3E,eAAO,MAAM,OAAO,SAGG,CAAC;AAExB;;GAEG;AACH,wBAAsB,iBAAiB,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC,CAgE9D"}
1
+ {"version":3,"file":"program.d.ts","sourceRoot":"","sources":["../../src/lib/program.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGpC,OAAO,EAA6B,KAAK,SAAS,EAAE,MAAM,gBAAgB,CAAC;AA8C3E,eAAO,MAAM,OAAO,SAGG,CAAC;AAExB;;GAEG;AACH,wBAAsB,iBAAiB,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC,CAkE9D"}
@@ -63,6 +63,7 @@ export async function initializeProgram() {
63
63
  }
64
64
  if (plugins.length === 1) {
65
65
  // Single plugin - run its default command
66
+ console.clear();
66
67
  const plugin = plugins[0];
67
68
  const cmd = program.commands.find((c) => c.name() === plugin.command);
68
69
  if (cmd) {
@@ -73,6 +74,7 @@ export async function initializeProgram() {
73
74
  // Multiple plugins - show selection menu in a loop
74
75
  const EXIT_VALUE = Symbol('exit');
75
76
  while (true) {
77
+ console.clear();
76
78
  let selectedPlugin;
77
79
  try {
78
80
  selectedPlugin = await select({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lsst/pik",
3
- "version": "0.6.2",
3
+ "version": "0.6.4",
4
4
  "description": "CLI tool for switching config options in source files",
5
5
  "type": "module",
6
6
  "license": "MIT",