@jeremyy_prt/cc-config 1.1.2 → 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.2",
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": {
@@ -11,6 +11,9 @@
11
11
  "lint": "biome check --write .",
12
12
  "format": "biome format --write ."
13
13
  },
14
+ "dependencies": {
15
+ "tsx": "^4.19.2"
16
+ },
14
17
  "devDependencies": {
15
18
  "@biomejs/biome": "^2.3.2",
16
19
  "@types/bun": "latest"
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env bun
1
+ #!/usr/bin/env node
2
2
 
3
3
  import type { StatuslineConfig } from "../statusline.config";
4
4
  import { defaultConfig } from "../statusline.config";
@@ -18,6 +18,21 @@ import { saveSession } from "./lib/spend";
18
18
  import type { HookInput } from "./lib/types";
19
19
  import { getUsageLimits } from "./lib/usage-limits";
20
20
 
21
+ // Fonction pour lire stdin de manière compatible Node.js et Bun
22
+ async function getStdin(): Promise<string> {
23
+ // Si Bun est disponible, utiliser Bun.stdin
24
+ if (typeof Bun !== "undefined") {
25
+ return await Bun.stdin.text();
26
+ }
27
+
28
+ // Sinon, utiliser process.stdin (Node.js)
29
+ const chunks: Buffer[] = [];
30
+ for await (const chunk of process.stdin) {
31
+ chunks.push(chunk as Buffer);
32
+ }
33
+ return Buffer.concat(chunks).toString("utf-8");
34
+ }
35
+
21
36
  function buildFirstLine(
22
37
  branch: string,
23
38
  dirPath: string,
@@ -122,7 +137,8 @@ function buildThirdLine(
122
137
 
123
138
  async function main() {
124
139
  try {
125
- const input: HookInput = await Bun.stdin.json();
140
+ const stdinData = await getStdin();
141
+ const input: HookInput = JSON.parse(stdinData);
126
142
 
127
143
  await saveSession(input);
128
144
 
@@ -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 {
package/settings.json CHANGED
@@ -14,7 +14,7 @@
14
14
  },
15
15
  "statusLine": {
16
16
  "type": "command",
17
- "command": "node ${CLAUDE_CONFIG_DIR}/scripts/statusline/src/index.ts",
17
+ "command": "npx tsx ${CLAUDE_CONFIG_DIR}/scripts/statusline/src/index.ts",
18
18
  "padding": 0
19
19
  }
20
20
  }