@jacebenson/jsn 0.0.5 → 0.0.7

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jacebenson/jsn",
3
- "version": "0.0.5",
3
+ "version": "0.0.7",
4
4
  "description": "A command-line interface for ServiceNow that follows the Unix philosophy: simple, composable, and scriptable.",
5
5
  "type": "module",
6
6
  "bin": {
package/src/auth.js CHANGED
@@ -177,10 +177,20 @@ export class AuthManager {
177
177
  // Try to open browser
178
178
  const open = (await import('node:child_process')).spawn;
179
179
  const platform = process.platform;
180
- const cmd = platform === 'darwin' ? 'open' : platform === 'win32' ? 'start' : 'xdg-open';
181
- const child = open(cmd, [authURL], { detached: true, stdio: 'ignore' });
180
+ let cmd, args;
181
+ if (platform === 'darwin') {
182
+ cmd = 'open';
183
+ args = [authURL];
184
+ } else if (platform === 'win32') {
185
+ cmd = 'cmd';
186
+ args = ['/c', 'start', authURL];
187
+ } else {
188
+ cmd = 'xdg-open';
189
+ args = [authURL];
190
+ }
191
+ const child = open(cmd, args, { detached: true, stdio: 'ignore' });
182
192
  child.on('error', () => {
183
- // xdg-open not installed — user will open the URL manually
193
+ // Browser open command not available — user will open the URL manually
184
194
  });
185
195
  child.unref();
186
196
 
@@ -1,5 +1,5 @@
1
1
  import readline from 'node:readline';
2
- import { getEffectiveInstance, normalizeInstanceURL, setProfile } from '../config.js';
2
+ import { getEffectiveInstance, normalizeInstanceURL, saveConfig, setProfile } from '../config.js';
3
3
 
4
4
  export function setupCmd(wrap) {
5
5
  return {
@@ -21,6 +21,10 @@ export function setupCmd(wrap) {
21
21
 
22
22
  const profileName = await ask('Profile name (default): ') || 'default';
23
23
  await setProfile(app.config, profileName, { instance_url: instance });
24
+ // Set as active profile so subsequent commands know which instance to use
25
+ app.config.activeProfile = profileName;
26
+ app.config.defaultProfile = profileName;
27
+ saveConfig(app.config);
24
28
 
25
29
  const loginNow = await ask('Login now? [Y/n]: ');
26
30
  if (!loginNow || loginNow.toLowerCase() !== 'n') {