Skip to content

Add warning at delete contents for Linux users on @fedify/init - #992

Open
lego37yoon wants to merge 4 commits into
fedify-dev:mainfrom
lego37yoon:fix/init-permanent-delete
Open

Add warning at delete contents for Linux users on @fedify/init#992
lego37yoon wants to merge 4 commits into
fedify-dev:mainfrom
lego37yoon:fix/init-permanent-delete

Conversation

@lego37yoon

Copy link
Copy Markdown

Summary

@fedify/init project initialization asks users to use non-empty directory, and confirm to move existing contents to Trash. However, its behavior actually permanently delete all of existing contents without back up for Linux or UNIX-like system users.

This pull request notices users who are using Linux or UNIX-like systems that this action deletes existing data permanently. Furthermore, refactored messages and action structure in dir.ts file to easily add conditions or supported systems.

Fixes #989

Test Plan

  • mise run check-each init
  • mise run test-each init

@netlify

netlify Bot commented Aug 9, 2026

Copy link
Copy Markdown

Deploy Preview for fedify-json-schema canceled.

Name Link
🔨 Latest commit 836efa9
🔍 Latest deploy log https://app.netlify.com/projects/fedify-json-schema/deploys/6a7897ba17d174000894f136

@coderabbitai

coderabbitai Bot commented Aug 9, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 4882a4fc-02f8-4f16-8cc8-7f3b941a33c8

📥 Commits

Reviewing files that changed from the base of the PR and between 27fea34 and 836efa9.

📒 Files selected for processing (2)
  • CHANGES.md
  • changes.d/init/permanent-delete.md

📝 Walkthrough

Walkthrough

fedify init now selects trash or permanent deletion by operating system. Linux and other UNIX-like systems receive a permanent-delete warning. Changelog entries reference issue #989.

Changes

Project directory cleanup

Layer / File(s) Summary
OS-aware cleanup flow
packages/init/src/ask/dir.ts, changes.d/init/permanent-delete.md, CHANGES.md
The directory workflow selects platform-specific cleanup commands, asks mode-specific confirmations, and reports mode-specific failures. Changelog entries document permanent deletion on UNIX-like systems and reference issue #989.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Suggested reviewers: dahlia, 2chanhaeng

Sequence Diagram(s)

sequenceDiagram
  participant FedifyInit
  participant ActionPlanner
  participant CommandExecutor
  FedifyInit->>ActionPlanner: Select cleanup mode by operating system
  ActionPlanner->>FedifyInit: Request mode-specific confirmation
  FedifyInit->>CommandExecutor: Execute trash or permanent-delete command
  CommandExecutor-->>FedifyInit: Return success or mode-specific failure
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main change: adding a deletion warning for Linux users in @fedify/init.
Description check ✅ Passed The description explains the Linux and UNIX-like system deletion behavior, the warning, the refactor, and the linked issue.
Linked Issues check ✅ Passed The changes address issue #989 by distinguishing permanent deletion from trash moves and warning affected users before removal.
Out of Scope Changes check ✅ Passed The refactor and changelog update directly support the warning and system-specific deletion behavior described in issue #989.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@changes.d/init/permanent-delete.md`:
- Around line 1-2: Correct the release-note grammar in
changes.d/init/permanent-delete.md lines 1-2 and CHANGES.md lines 178-179 by
changing “before delete” to “before deleting” and referring to the existing
contents.

In `@packages/init/src/ask/dir.ts`:
- Around line 123-127: Update the command builder around
getPowershellTrashCommand to escape apostrophes in dir by doubling them before
interpolation into the PowerShell single-quoted literal. Preserve existing path
behavior and add a Windows test covering a directory path containing an
apostrophe.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 593d4915-bb1e-4486-9907-cc88fd8527b3

📥 Commits

Reviewing files that changed from the base of the PR and between 15ad151 and 27fea34.

📒 Files selected for processing (3)
  • CHANGES.md
  • changes.d/init/permanent-delete.md
  • packages/init/src/ask/dir.ts

Comment thread changes.d/init/permanent-delete.md Outdated
Comment on lines +123 to +127
command: (dir: string) => [
"powershell",
"-Command",
getPowershellTrashCommand(dir),
],

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "Files matching dir.ts:"
fd -a 'dir\.ts$' . || true

file="$(fd 'dir\.ts$' . | grep 'packages/init/src/ask/dir.ts' | head -n 1 || true)"
echo "Target file: $file"
if [ -n "$file" ]; then
  wc -l "$file"
  sed -n '1,180p' "$file" | cat -n
fi

echo
echo "Search PowerShell command construction:"
rg -n "getPowershellTrashCommand|powershell|DeleteDirectory|Trash|trash" packages/init/src -S || true

echo
echo "Search dir input paths/usages in init ask flow:"
rg -n "command:\s*\(dir: string\) => \[|getPowershellTrashCommand|selectDirectory|ask.*dir|dir" packages/init/src -S || true

Repository: fedify-dev/fedify

Length of output: 40650


🌐 Web query:

PowerShell single-quoted string escaping single quote doubled two single quotes

💡 Result:

To include a single quotation mark within a PowerShell single-quoted string, you must use two consecutive single quotation marks ('') [1][2]. This effectively escapes the quote by "doubling" it, which tells the PowerShell parser to treat the pair as a single literal quote character [3][4]. For example, to represent the word don't in a single-quoted string, you would write: 'don''t' Because single-quoted strings are treated as verbatim literals, other common escape methods—such as the backtick character (`)—do not function as escape sequences inside them [1][5][3]. The backtick is treated as a literal character when placed within single quotes [1][6]. If you require complex quoting or find doubling single quotes difficult to manage, you can alternatively use a here-string (@'... '@), which preserves the content literally without requiring special escaping for single quotes [2][4].

Citations:


Escape dir in the PowerShell trash command.

getPowershellTrashCommand() inserts dir into a PowerShell single-quoted literal, so a name like C:\O'Brien terminates the string. In PowerShell single quotes, escape an apostrophe by doubling it (''). Add a Windows test with an apostrophe-containing directory path.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/init/src/ask/dir.ts` around lines 123 - 127, Update the command
builder around getPowershellTrashCommand to escape apostrophes in dir by
doubling them before interpolation into the PowerShell single-quoted literal.
Preserve existing path behavior and add a Windows test covering a directory path
containing an apostrophe.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Linux] fedify init 'move the contents to the trash' actually remove contents permanently

1 participant