githits 0.4.10 → 0.4.11

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.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  version
3
- } from "./shared/chunk-fvpvx4x4.js";
3
+ } from "./shared/chunk-agpezzpd.js";
4
4
  export {
5
5
  version
6
6
  };
@@ -4,8 +4,8 @@ import {
4
4
  createAuthStatusDependencies,
5
5
  createContainer,
6
6
  loadAutoLoginAuthSessionMetadata
7
- } from "./chunk-p9ak72j0.js";
8
- import"./chunk-fvpvx4x4.js";
7
+ } from "./chunk-5xd5rcm9.js";
8
+ import"./chunk-agpezzpd.js";
9
9
  export {
10
10
  loadAutoLoginAuthSessionMetadata,
11
11
  createContainer,
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  __require,
3
3
  version
4
- } from "./chunk-fvpvx4x4.js";
4
+ } from "./chunk-agpezzpd.js";
5
5
 
6
6
  // src/services/app-config-paths.ts
7
7
  var APP_DIR = "githits";
@@ -3481,21 +3481,42 @@ function getEnvApiToken() {
3481
3481
  }
3482
3482
  // src/services/exec-service.ts
3483
3483
  import { spawn } from "node:child_process";
3484
- function isWindowsAbsolutePath(command) {
3485
- return /^[a-zA-Z]:[\\/]/.test(command) || command.startsWith("\\\\");
3484
+ var WINDOWS_CMD_META_CHARS = /([()[\]%!^"`<>&|;, *?])/g;
3485
+ function escapeWindowsCommand(value) {
3486
+ return value.replace(WINDOWS_CMD_META_CHARS, "^$1");
3487
+ }
3488
+ function escapeWindowsArgument(value) {
3489
+ let arg = `${value}`;
3490
+ arg = arg.replace(/(?=(\\+?)?)\1"/g, "$1$1\\\"");
3491
+ arg = arg.replace(/(?=(\\+?)?)\1$/, "$1$1");
3492
+ return `"${arg}"`.replace(WINDOWS_CMD_META_CHARS, "^$1");
3493
+ }
3494
+ function buildWindowsShellCommand(command, args) {
3495
+ return [
3496
+ escapeWindowsCommand(command),
3497
+ ...args.map(escapeWindowsArgument)
3498
+ ].join(" ");
3499
+ }
3500
+ function isWindowsCommandNotFound(exitCode, stderr, platform = process.platform) {
3501
+ return platform === "win32" && exitCode !== 0 && /^\s*'[^']+'\s+is not recognized as an internal or external command,/i.test(stderr);
3502
+ }
3503
+ function createCommandNotFoundError(command) {
3504
+ const error = new Error(`spawn ${command} ENOENT`);
3505
+ error.code = "ENOENT";
3506
+ error.syscall = "spawn";
3507
+ error.path = command;
3508
+ return error;
3486
3509
  }
3487
3510
  function normalizeSpawnCommand(command, args, platform = process.platform) {
3488
3511
  if (platform !== "win32") {
3489
3512
  return { command, args };
3490
3513
  }
3491
- if (isWindowsAbsolutePath(command) && /\s/.test(command)) {
3492
- return {
3493
- command: `"${command.replaceAll('"', "\\\"")}"`,
3494
- args,
3495
- shell: true
3496
- };
3497
- }
3498
- return { command, args, shell: true };
3514
+ const shellCommand = buildWindowsShellCommand(command, args);
3515
+ return {
3516
+ command: process.env.ComSpec ?? "cmd.exe",
3517
+ args: ["/d", "/s", "/c", `"${shellCommand}"`],
3518
+ windowsVerbatimArguments: true
3519
+ };
3499
3520
  }
3500
3521
 
3501
3522
  class ExecServiceImpl {
@@ -3505,7 +3526,10 @@ class ExecServiceImpl {
3505
3526
  const child = spawn(spawnCommand.command, spawnCommand.args, {
3506
3527
  stdio: ["ignore", "pipe", "pipe"],
3507
3528
  env: { ...process.env },
3508
- ...spawnCommand.shell !== undefined && { shell: spawnCommand.shell }
3529
+ ...spawnCommand.shell !== undefined && { shell: spawnCommand.shell },
3530
+ ...spawnCommand.windowsVerbatimArguments !== undefined && {
3531
+ windowsVerbatimArguments: spawnCommand.windowsVerbatimArguments
3532
+ }
3509
3533
  });
3510
3534
  const stdoutChunks = [];
3511
3535
  const stderrChunks = [];
@@ -3515,10 +3539,16 @@ class ExecServiceImpl {
3515
3539
  reject(error);
3516
3540
  });
3517
3541
  child.on("close", (code) => {
3542
+ const exitCode = code ?? 1;
3543
+ const stderr = Buffer.concat(stderrChunks).toString("utf-8");
3544
+ if (isWindowsCommandNotFound(exitCode, stderr)) {
3545
+ reject(createCommandNotFoundError(command));
3546
+ return;
3547
+ }
3518
3548
  resolve({
3519
- exitCode: code ?? 1,
3549
+ exitCode,
3520
3550
  stdout: Buffer.concat(stdoutChunks).toString("utf-8"),
3521
- stderr: Buffer.concat(stderrChunks).toString("utf-8")
3551
+ stderr
3522
3552
  });
3523
3553
  });
3524
3554
  });
@@ -6234,7 +6264,7 @@ function parseVersionList(raw) {
6234
6264
  return versions.length > 0 ? versions : undefined;
6235
6265
  }
6236
6266
  // src/services/prompt-service.ts
6237
- import { checkbox, select } from "@inquirer/prompts";
6267
+ import { checkbox, confirm, select } from "@inquirer/prompts";
6238
6268
 
6239
6269
  class PromptServiceImpl {
6240
6270
  async select(message, choices, defaultValue) {
@@ -6243,9 +6273,13 @@ class PromptServiceImpl {
6243
6273
  async checkbox(message, choices) {
6244
6274
  return checkbox({ message, choices });
6245
6275
  }
6246
- async confirm3(message) {
6276
+ async confirm(message, defaultValue) {
6277
+ return confirm({ message, default: defaultValue });
6278
+ }
6279
+ async confirm3(message, defaultValue) {
6247
6280
  return select({
6248
6281
  message,
6282
+ default: defaultValue,
6249
6283
  choices: [
6250
6284
  { value: "yes", name: "Yes" },
6251
6285
  { value: "no", name: "No" },
@@ -1,6 +1,6 @@
1
1
  import { createRequire } from "node:module";
2
2
  var __require = /* @__PURE__ */ createRequire(import.meta.url);
3
3
  // package.json
4
- var version = "0.4.10";
4
+ var version = "0.4.11";
5
5
 
6
6
  export { __require, version };
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "githits",
3
- "version": "0.4.10",
3
+ "version": "0.4.11",
4
4
  "description": "Code examples from global open source for developers and AI assistants.",
5
5
  "mcpServers": {
6
6
  "githits": {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "githits",
3
3
  "description": "CLI companion for GitHits - code examples from global open source for developers and AI assistants",
4
- "version": "0.4.10",
4
+ "version": "0.4.11",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "dist",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "githits",
3
- "version": "0.4.10",
3
+ "version": "0.4.11",
4
4
  "description": "Code examples from global open source for developers and AI assistants",
5
5
  "author": {
6
6
  "name": "GitHits"