feat(cli): add folder CRUD commands (create/update/delete)#40
Merged
Conversation
Add createFolder, updateFolder, deleteFolder methods on ApiClient plus the supporting types (FolderDetail, FolderResponse, CreateFolderRequest, UpdateFolderRequest) for the v1 /folders endpoints. Single-folder responses use FolderDetail because the API does not include linkCount on POST/PATCH/GET-by-id (only the list endpoint computes it). Refs: GH #38
New `zhe folder` subcommand with: zhe folder create <name> [--icon <emoji>] zhe folder update <name|id> [--name <new>] [--icon <emoji>] zhe folder delete <name|id> [--yes] The plural `zhe folders` (list-only) is preserved unchanged. Each new subcommand supports --json for machine-readable output and mirrors the auth/error-handling style of the existing folders and idea commands. Folder references accept either a name or a UUID via the existing resolveFolderName helper. delete refuses to run without --yes when stdin is not a TTY, to prevent accidental scripted deletions. Closes GH #38
Cover createFolder (with icon, without icon, 400 error), updateFolder (full body, name-only, 404 error), and deleteFolder (success, 404 error). 8 new tests, all passing alongside the existing 96. Refs: GH #38
Merge type imports, adjust confirm() call formatting per Biome rules.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #38
Summary
Adds
zhe folder create / update / deleteso folders can be managed entirely from the CLI without the web UI.The plural
zhe folders(list-only) is unchanged.<name|id>accepts either a folder name or a UUID via the existingresolveFolderNamehelper.deleterefuses to run without--yeswhen stdin is not a TTY.Changes
cli/src/api/types.ts—FolderDetail,FolderResponse,CreateFolderRequest,UpdateFolderRequest. Single-folder responses useFolderDetailbecause the API only returnslinkCounton the list endpoint.cli/src/api/client.ts—createFolder,updateFolder,deleteFoldermethods.cli/src/commands/folder.ts— newfolderCommandwith three subcommands, mirroring the auth/error/confirm style ofcommands/idea.tsandcommands/delete.ts.cli/src/index.ts— registerfolderalongside existingfolders.cli/tests/api-client.test.ts— 8 new unit tests covering happy paths and 400/404 errors.Verification
bun run typecheck✅bun run build✅bun run test✅ (104 passed, 1 skipped — was 96)node dist/index.js folder --helpand per-subcommand--helprender correctly.Pre-commit hooks (typecheck + eslint + gitleaks) ran on each of the 3 atomic commits.