claude-code-templates 1.21.11 → 1.21.12

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/index.js +41 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-code-templates",
3
- "version": "1.21.11",
3
+ "version": "1.21.12",
4
4
  "description": "CLI tool to setup Claude Code configurations with framework-specific commands, automation hooks and MCP Servers for your projects",
5
5
  "main": "src/index.js",
6
6
  "bin": {
package/src/index.js CHANGED
@@ -959,6 +959,28 @@ async function installIndividualHook(hookName, targetDir, options) {
959
959
  const hookConfigText = await response.text();
960
960
  const hookConfig = JSON.parse(hookConfigText);
961
961
 
962
+ // Check if there are additional files to download (e.g., Python scripts for hooks)
963
+ const additionalFiles = {};
964
+
965
+ // Check if there's a corresponding Python file for ANY hook
966
+ const pythonUrl = githubUrl.replace('.json', '.py');
967
+ const hookBaseName = hookName.includes('/') ? hookName.split('/').pop() : hookName;
968
+
969
+ try {
970
+ console.log(chalk.gray(`📥 Checking for additional Python script...`));
971
+ const pythonResponse = await fetch(pythonUrl);
972
+ if (pythonResponse.ok) {
973
+ const pythonContent = await pythonResponse.text();
974
+ additionalFiles[`.claude/hooks/${hookBaseName}.py`] = {
975
+ content: pythonContent,
976
+ executable: true
977
+ };
978
+ console.log(chalk.green(`✓ Found Python script: ${hookBaseName}.py`));
979
+ }
980
+ } catch (error) {
981
+ // Python file is optional, silently continue if not found
982
+ }
983
+
962
984
  // Remove description field before merging
963
985
  if (hookConfig && typeof hookConfig === 'object') {
964
986
  delete hookConfig.description;
@@ -1148,7 +1170,25 @@ async function installIndividualHook(hookName, targetDir, options) {
1148
1170
 
1149
1171
  // Write the merged configuration
1150
1172
  await fs.writeJson(actualTargetFile, mergedConfig, { spaces: 2 });
1151
-
1173
+
1174
+ // Install additional files (e.g., Python scripts)
1175
+ if (Object.keys(additionalFiles).length > 0) {
1176
+ for (const [relativePath, fileData] of Object.entries(additionalFiles)) {
1177
+ const absolutePath = path.join(currentTargetDir, relativePath);
1178
+ const dir = path.dirname(absolutePath);
1179
+
1180
+ // Ensure directory exists
1181
+ await fs.ensureDir(dir);
1182
+
1183
+ // Write file
1184
+ await fs.writeFile(absolutePath, fileData.content, { mode: fileData.executable ? 0o755 : 0o644 });
1185
+
1186
+ if (!options.silent) {
1187
+ console.log(chalk.green(`✓ Installed additional file: ${relativePath}`));
1188
+ }
1189
+ }
1190
+ }
1191
+
1152
1192
  if (!options.silent) {
1153
1193
  console.log(chalk.green(`✅ Hook "${hookName}" installed successfully in ${installLocation}!`));
1154
1194
  console.log(chalk.cyan(`📁 Configuration merged into: ${actualTargetFile}`));