ReviewOS

craft-native/craft

Validate create-craft template names before creating the project directory

#278
Closed glennmichael123 opened this 9 days ago ·
9 days ago

Problem

create-craft creates the destination directory before validating --template. A typo therefore leaves an empty project directory behind, and the corrected retry immediately fails because that directory now exists.

Reproduction

Run:

create-craft demo --template todo --skip-install
create-craft demo --template todo-app --skip-install

The first command reports the valid templates but creates demo first. The second command then reports that demo already exists.

Cause

packages/create-craft/bin/cli.ts calls mkdirSync(projectPath) before its minimal/full-featured/todo-app dispatch and unknown-template branch.

Expected

Validate and normalize the template name before any filesystem mutation. An invalid template should exit nonzero and leave no destination behind. Add a regression test covering both the exit status and absence of the directory.

Discovered by installing the v0.0.92-shaped tarball from current main into a clean temporary consumer during the post-merge release audit for #254, #242, and #220.

Sign in to comment on this issue.