mirror of
https://github.com/affaan-m/ECC.git
synced 2026-09-11 04:07:54 +02:00
fix(install): harden Claude settings lifecycle
This commit is contained in:
@@ -1,6 +1,10 @@
|
||||
const fs = require('fs');
|
||||
const os = require('os');
|
||||
const path = require('path');
|
||||
const {
|
||||
CLAUDE_HOOKS_CONFIG_PATH,
|
||||
getClaudeSettingsPath,
|
||||
} = require('../install/claude-settings');
|
||||
|
||||
const PLATFORM_SOURCE_PATH_OWNERS = Object.freeze({
|
||||
'.claude-plugin': 'claude',
|
||||
@@ -146,6 +150,42 @@ function createRemappedOperation(adapter, moduleId, sourceRelativePath, destinat
|
||||
});
|
||||
}
|
||||
|
||||
function planClaudeHooksOperations(adapter, module, input) {
|
||||
const operations = [
|
||||
createRemappedOperation(
|
||||
adapter,
|
||||
module.id,
|
||||
CLAUDE_HOOKS_CONFIG_PATH,
|
||||
getClaudeSettingsPath(adapter.resolveRoot(input)),
|
||||
{
|
||||
kind: 'update-claude-settings',
|
||||
strategy: 'merge-hook-ids',
|
||||
}
|
||||
),
|
||||
];
|
||||
|
||||
if (!input.repoRoot) {
|
||||
return operations;
|
||||
}
|
||||
|
||||
const sourceHooksRoot = path.join(input.repoRoot, 'hooks');
|
||||
if (!fs.existsSync(sourceHooksRoot)) {
|
||||
return operations;
|
||||
}
|
||||
|
||||
return [
|
||||
...operations,
|
||||
...fs.readdirSync(sourceHooksRoot, { withFileTypes: true })
|
||||
.filter(entry => entry.name !== 'hooks.json')
|
||||
.sort((left, right) => left.name.localeCompare(right.name))
|
||||
.map(entry => adapter.createScaffoldOperation(
|
||||
module.id,
|
||||
path.join('hooks', entry.name),
|
||||
input
|
||||
)),
|
||||
];
|
||||
}
|
||||
|
||||
function createNamespacedFlatRuleOperations(adapter, moduleId, sourceRelativePath, input = {}) {
|
||||
const normalizedSourcePath = normalizeRelativePath(sourceRelativePath);
|
||||
const sourceRoot = path.join(input.repoRoot || '', normalizedSourcePath);
|
||||
@@ -373,4 +413,5 @@ module.exports = {
|
||||
createRemappedOperation,
|
||||
isForeignPlatformPath,
|
||||
normalizeRelativePath,
|
||||
planClaudeHooksOperations,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user