nf build deletes the whole project when the output dir is . or a parent folder

オープン
#275 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
55/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
bun, node.js, typescript
領域
backend, cli

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

bug command:build lib:config
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):

  1. A project with nanoforge.config.ts (export default { type: "client" };), src/main.ts and assets/sprites/b.png.
  2. nf build -d <project> --client-out-dir .
  3. The output is ENOENT opening root directory "src" / Build of Client failed!, and the project folder is now empty: config, src/ and assets/ 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

主要言語
TypeScript
スター
2
フォーク
2
平均マージ
2日 18時間
マージ済み PR(30日)
17

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

NanoForge-dev/CLI のほかの issue

NanoForge-dev/CLI の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。