@jeremyy_prt/cc-config 1.1.3 → 1.1.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jeremyy_prt/cc-config",
3
- "version": "1.1.3",
3
+ "version": "1.1.4",
4
4
  "description": "Configuration personnalisée pour Claude Code avec commandes et agents en français",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -1,4 +1,4 @@
1
- import { $ } from "bun";
1
+ import { execSync } from "node:child_process";
2
2
 
3
3
  export interface GitStatus {
4
4
  branch: string;
@@ -15,9 +15,24 @@ export interface GitStatus {
15
15
  };
16
16
  }
17
17
 
18
+ function exec(command: string): { stdout: string; exitCode: number } {
19
+ try {
20
+ const stdout = execSync(command, {
21
+ encoding: "utf-8",
22
+ stdio: ["pipe", "pipe", "pipe"],
23
+ });
24
+ return { stdout, exitCode: 0 };
25
+ } catch (error: any) {
26
+ return {
27
+ stdout: error.stdout?.toString() || "",
28
+ exitCode: error.status || 1,
29
+ };
30
+ }
31
+ }
32
+
18
33
  export async function getGitStatus(): Promise<GitStatus> {
19
34
  try {
20
- const isGitRepo = await $`git rev-parse --git-dir`.quiet().nothrow();
35
+ const isGitRepo = exec("git rev-parse --git-dir");
21
36
  if (isGitRepo.exitCode !== 0) {
22
37
  return {
23
38
  branch: "no-git",
@@ -27,21 +42,17 @@ export async function getGitStatus(): Promise<GitStatus> {
27
42
  };
28
43
  }
29
44
 
30
- const branchResult = await $`git branch --show-current`.quiet().text();
31
- const branch = branchResult.trim() || "detached";
45
+ const branchResult = exec("git branch --show-current");
46
+ const branch = branchResult.stdout.trim() || "detached";
32
47
 
33
- const diffCheck = await $`git diff-index --quiet HEAD --`.quiet().nothrow();
34
- const cachedCheck = await $`git diff-index --quiet --cached HEAD --`
35
- .quiet()
36
- .nothrow();
48
+ const diffCheck = exec("git diff-index --quiet HEAD --");
49
+ const cachedCheck = exec("git diff-index --quiet --cached HEAD --");
37
50
 
38
51
  if (diffCheck.exitCode !== 0 || cachedCheck.exitCode !== 0) {
39
- const unstagedDiff = await $`git diff --numstat`.quiet().text();
40
- const stagedDiff = await $`git diff --cached --numstat`.quiet().text();
41
- const stagedFilesResult = await $`git diff --cached --name-only`
42
- .quiet()
43
- .text();
44
- const unstagedFilesResult = await $`git diff --name-only`.quiet().text();
52
+ const unstagedDiff = exec("git diff --numstat").stdout;
53
+ const stagedDiff = exec("git diff --cached --numstat").stdout;
54
+ const stagedFilesResult = exec("git diff --cached --name-only").stdout;
55
+ const unstagedFilesResult = exec("git diff --name-only").stdout;
45
56
 
46
57
  const parseStats = (diff: string) => {
47
58
  let added = 0;
@@ -1,7 +1,7 @@
1
1
  import { existsSync } from "node:fs";
2
2
  import { readFile, writeFile } from "node:fs/promises";
3
3
  import { join } from "node:path";
4
- import { $ } from "bun";
4
+ import { execSync } from "node:child_process";
5
5
 
6
6
  export interface UsageLimits {
7
7
  five_hour: {
@@ -22,7 +22,8 @@ interface CachedUsageLimits {
22
22
  const CACHE_DURATION_MS = 60 * 1000; // 1 minute
23
23
 
24
24
  function getCacheFilePath(): string {
25
- const projectRoot = join(import.meta.dir, "..", "..");
25
+ // Utiliser __dirname pour Node.js au lieu de import.meta.dir (Bun)
26
+ const projectRoot = join(__dirname, "..", "..");
26
27
  return join(projectRoot, "data", "usage-limits-cache.json");
27
28
  }
28
29
 
@@ -38,10 +39,16 @@ interface Credentials {
38
39
 
39
40
  export async function getCredentials(): Promise<string | null> {
40
41
  try {
41
- const result =
42
- await $`security find-generic-password -s "Claude Code-credentials" -w`
43
- .quiet()
44
- .text();
42
+ // Cette commande ne fonctionne que sur macOS
43
+ // Sur Windows, retourner null (la statusline affichera sans les limites)
44
+ if (process.platform !== "darwin") {
45
+ return null;
46
+ }
47
+
48
+ const result = execSync(
49
+ 'security find-generic-password -s "Claude Code-credentials" -w',
50
+ { encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] },
51
+ );
45
52
  const creds: Credentials = JSON.parse(result.trim());
46
53
  return creds.claudeAiOauth.accessToken;
47
54
  } catch {