From a3be0955c8359eac1dbdf946d6bec1f223d515db Mon Sep 17 00:00:00 2001 From: Yuya Hirayama Date: Thu, 3 Jul 2025 15:37:39 +0900 Subject: [PATCH] fix: change lockfile only field from string array to object array MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Update lockfile structure to match cccsc.json format where the "only" field contains objects with name, path, and alias properties instead of just strings. This improves consistency between config and lock files. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- src/commands/install.js | 6 +++++- src/commands/remove.js | 4 +++- src/utils/config.js | 11 +++++++++-- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/commands/install.js b/src/commands/install.js index b16d7da..ed9c40d 100644 --- a/src/commands/install.js +++ b/src/commands/install.js @@ -85,7 +85,11 @@ export async function installCommand(options) { // Update lock file with actually installed commands if (lock.repositories[repoKey]) { - lock.repositories[repoKey].only = installedCommandNames; + lock.repositories[repoKey].only = installedCommandNames.map(name => ({ + name: name, + path: `${name}.md`, + alias: null + })); } else { // This should not happen normally, but let's be safe logWarning(`Lock file entry for ${repoKey} not found, skipping lock update`); diff --git a/src/commands/remove.js b/src/commands/remove.js index 4c27775..5d09d77 100644 --- a/src/commands/remove.js +++ b/src/commands/remove.js @@ -48,7 +48,9 @@ async function removeCommandFromLock(commandName, repoKey, lock) { const repoLock = lock.repositories[repoKey]; if (repoLock.only && repoLock.only.length > 0) { - const commandIndex = repoLock.only.indexOf(commandName); + const commandIndex = repoLock.only.findIndex(item => + typeof item === 'string' ? item === commandName : item.name === commandName + ); if (commandIndex !== -1) { repoLock.only.splice(commandIndex, 1); diff --git a/src/utils/config.js b/src/utils/config.js index 8355bd1..84d14b6 100644 --- a/src/utils/config.js +++ b/src/utils/config.js @@ -119,8 +119,15 @@ export async function addRepositoryToLock(user, repo, revision, commandPath = nu // Add new command to "only" list if specified if (commandPath) { const commandName = commandPath.split('/').pop().replace('.md', ''); - if (!repoEntry.only.includes(commandName)) { - repoEntry.only.push(commandName); + const commandExists = repoEntry.only.some(item => + typeof item === 'string' ? item === commandName : item.name === commandName + ); + if (!commandExists) { + repoEntry.only.push({ + name: commandName, + path: commandPath, + alias: null + }); } } else if (!existingRepo || !existingRepo.only || existingRepo.only.length === 0) { // If no specific command and no existing "only" list, keep empty (all commands)