nf build deletes the whole project when the output dir is . or a parent folder
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 55/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- bun, node.js, typescript
Hướng nghiên cứu
Start with src/lib/utils/files.ts and the resetFolder call in src/action/actions/build.action.ts; trace how the client and server output directories are resolved before deletion. Check how out.dir is validated in libs/config/src/parse/validate-config.ts. Add coverage for unsafe paths, including ., a parent folder, and paths containing the entry file or assets; done means builds reject them before deleting project files.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Which package is this bug report for?
@nanoforge-dev/cli
Which command is this bug report for?
build
Issue description
nf build deletes the whole project when the output folder is . (or a parent folder). Before each build, resetFolder runs rmSync(join(directory, outDir), { recursive: true, force: true }) (src/lib/utils/files.ts#L14-L15, called from src/action/actions/build.action.ts#L139). Neither --client-out-dir/--server-out-dir nor the config's out.dir (libs/config/src/parse/validate-config.ts#L10, a bare z.string()) refuses ., .., an absolute path or a folder that holds the sources.
Steps to reproduce (reproduced with dist/nf.js on a throwaway project):
- A project with
nanoforge.config.ts(export default { type: "client" };),src/main.tsandassets/sprites/b.png. nf build -d <project> --client-out-dir .- The output is
ENOENT opening root directory "src"/Build of Client failed!, and the project folder is now empty: config,src/andassets/are gone.
Expected: the build refuses an output folder that is the project folder, one of its parents, outside the project, or one that contains the entry file or the assets folder, before anything is deleted. The same rule is checked on out.dir in @nanoforge-dev/config, and a test covers it.
Found during a read-only audit of main at e95b881 (2026-11-11).
Code sample
// nanoforge.config.ts
export default { type: "client" };
// then: nf build --client-out-dir . -> the project folder is emptied
Versions
- @nanoforge-dev/cli 3.0.1 (main, e95b881)
- Node.js 26.7.0
- Bun 1.3.14 (bundled)
- Linux
Issue priority
High (immediate attention needed)
I have tested this issue on a development release
e95b881
- Ngôn ngữ chính
- TypeScript
- Star
- 2
- Fork
- 2
- Merge trung bình
- 2 ngày 18 giờ
- Pull request đã merge (30 ngày)
- 17
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của NanoForge-dev/CLI
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
NanoForge-dev/CLI#294 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
NanoForge-dev/CLI#293 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
NanoForge-dev/CLI#292 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
command:dev enhancement good first issue refactor
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
NanoForge-dev/CLI#281 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug command:build good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
NanoForge-dev/CLI#276 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của NanoForge-dev/CLI
Issue tương tự
-
Mend: dependency security vulnerability
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 65/100
fdm-monster/fdm-monster#5563 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
be-BOP-io-SA/be-BOP#2849 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 79/100
Maintainer thường phản hồi trong vòng 1 ngày
-
1️⃣ phase/under-investigation flaky/confirmed flaky/needs-decision type/bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
growilabs/growi#12246 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
🐛 The Rulekeeper - An index run that gives up on the lock ends SucceededCó thể đã có người làm @github-actions đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
SSWConsulting/SSW.Rules#2809 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày