@jeremyy_prt/cc-config 1.1.1 → 1.1.3

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/cli.js CHANGED
@@ -91,79 +91,96 @@ function mergeSettings() {
91
91
  function installShellAliases() {
92
92
  const isWindows = process.platform === 'win32';
93
93
 
94
- try {
95
- console.log('🔧 Installation des alias shell...');
96
-
97
- if (isWindows) {
98
- // PowerShell profile - try both locations
99
- const possiblePaths = [
100
- path.join(process.env.USERPROFILE, 'Documents', 'PowerShell', 'Microsoft.PowerShell_profile.ps1'),
101
- path.join(process.env.USERPROFILE, 'Documents', 'WindowsPowerShell', 'Microsoft.PowerShell_profile.ps1')
102
- ];
103
-
104
- // Find existing profile or use first path
105
- let profilePath = possiblePaths.find(p => fs.existsSync(p)) || possiblePaths[0];
106
-
107
- // Create profile directory if it doesn't exist
108
- const profileDir = path.dirname(profilePath);
109
- if (!fs.existsSync(profileDir)) {
110
- fs.mkdirSync(profileDir, { recursive: true });
111
- }
94
+ console.log('🔧 Installation des alias shell...');
95
+
96
+ if (isWindows) {
97
+ // PowerShell profiles - install in both locations
98
+ const profilePaths = [
99
+ path.join(process.env.USERPROFILE, 'Documents', 'WindowsPowerShell', 'Microsoft.PowerShell_profile.ps1'), // PowerShell 5.1
100
+ path.join(process.env.USERPROFILE, 'Documents', 'PowerShell', 'Microsoft.PowerShell_profile.ps1') // PowerShell 7+
101
+ ];
112
102
 
113
- const aliases = `
103
+ const aliases = `
114
104
  # Claude Code aliases
115
105
  function cc { claude --dangerously-skip-permissions @args }
116
106
  function ccc { claude --dangerously-skip-permissions -c @args }
117
107
  `;
118
108
 
119
- // Check if aliases already exist
120
- let content = '';
121
- if (fs.existsSync(profilePath)) {
122
- content = fs.readFileSync(profilePath, 'utf8');
123
- }
109
+ let installed = false;
110
+ let alreadyExists = false;
111
+
112
+ for (const profilePath of profilePaths) {
113
+ try {
114
+ const profileDir = path.dirname(profilePath);
115
+ const profileName = path.basename(path.dirname(profilePath));
116
+
117
+ // Create profile directory if it doesn't exist
118
+ if (!fs.existsSync(profileDir)) {
119
+ fs.mkdirSync(profileDir, { recursive: true });
120
+ console.log(` 📁 Dossier créé: ${profileName}`);
121
+ }
122
+
123
+ // Check if aliases already exist
124
+ let content = '';
125
+ if (fs.existsSync(profilePath)) {
126
+ content = fs.readFileSync(profilePath, 'utf8');
127
+ }
124
128
 
125
- if (!content.includes('Claude Code aliases')) {
126
- fs.appendFileSync(profilePath, aliases);
127
- console.log(` ✓ Alias PowerShell installés dans ${path.basename(profilePath)}`);
128
- console.log(' → Redémarre PowerShell pour les activer');
129
- } else {
130
- console.log(` ✓ Alias déjà présents dans ${path.basename(profilePath)}`);
129
+ if (!content.includes('Claude Code aliases')) {
130
+ fs.appendFileSync(profilePath, aliases);
131
+
132
+ // Verify it was written
133
+ if (fs.existsSync(profilePath)) {
134
+ console.log(` ✓ Alias installés dans ${profileName}`);
135
+ installed = true;
136
+ } else {
137
+ console.log(` ⚠️ Échec création profil ${profileName}`);
138
+ }
139
+ } else {
140
+ alreadyExists = true;
141
+ }
142
+ } catch (error) {
143
+ console.log(` ⚠️ Erreur ${path.basename(path.dirname(profilePath))}: ${error.message}`);
131
144
  }
132
- } else {
133
- // Unix-like (Mac/Linux)
134
- const homeDir = os.homedir();
135
- const shellFiles = [
136
- path.join(homeDir, '.zshrc'),
137
- path.join(homeDir, '.bashrc')
138
- ];
139
-
140
- const aliases = `
145
+ }
146
+
147
+ if (installed) {
148
+ console.log(' → Redémarre PowerShell pour les activer');
149
+ } else if (alreadyExists) {
150
+ console.log(' ✓ Alias déjà présents');
151
+ }
152
+ } else {
153
+ // Unix-like (Mac/Linux)
154
+ const homeDir = os.homedir();
155
+ const shellFiles = [
156
+ path.join(homeDir, '.zshrc'),
157
+ path.join(homeDir, '.bashrc')
158
+ ];
159
+
160
+ const aliases = `
141
161
  # Claude Code aliases
142
162
  alias cc='claude --dangerously-skip-permissions'
143
163
  alias ccc='claude --dangerously-skip-permissions -c'
144
164
  `;
145
165
 
146
- let installed = false;
147
- for (const shellFile of shellFiles) {
148
- if (fs.existsSync(shellFile)) {
149
- let content = fs.readFileSync(shellFile, 'utf8');
166
+ let installed = false;
167
+ for (const shellFile of shellFiles) {
168
+ if (fs.existsSync(shellFile)) {
169
+ let content = fs.readFileSync(shellFile, 'utf8');
150
170
 
151
- if (!content.includes('Claude Code aliases')) {
152
- fs.appendFileSync(shellFile, aliases);
153
- console.log(` ✓ Alias installés dans ${path.basename(shellFile)}`);
154
- installed = true;
155
- }
171
+ if (!content.includes('Claude Code aliases')) {
172
+ fs.appendFileSync(shellFile, aliases);
173
+ console.log(` ✓ Alias installés dans ${path.basename(shellFile)}`);
174
+ installed = true;
156
175
  }
157
176
  }
177
+ }
158
178
 
159
- if (installed) {
160
- console.log(' → Redémarre ton terminal pour les activer');
161
- } else {
162
- console.log(' ✓ Alias déjà installés');
163
- }
179
+ if (installed) {
180
+ console.log(' → Redémarre ton terminal pour les activer');
181
+ } else {
182
+ console.log(' ✓ Alias déjà installés');
164
183
  }
165
- } catch (error) {
166
- console.log(' ⚠️ Impossible d\'installer les alias');
167
184
  }
168
185
  }
169
186
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jeremyy_prt/cc-config",
3
- "version": "1.1.1",
3
+ "version": "1.1.3",
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
 
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
  }