Skip to content

fix(cli): make project location + github repo optional, guard bad dirs#42

Merged
jal-co merged 1 commit into
mainfrom
fix/cli-optional-paths-and-mkdir-crash
Jun 15, 2026
Merged

fix(cli): make project location + github repo optional, guard bad dirs#42
jal-co merged 1 commit into
mainfrom
fix/cli-optional-paths-and-mkdir-crash

Conversation

@jal-co

@jal-co jal-co commented Jun 15, 2026

Copy link
Copy Markdown
Owner

What

Three fixes to the scaffold flow, all surfaced by user feedback:

  1. Project location is optional. Pressing Enter accepts the default ./<name>. The prompt no longer errors Project location is required. when left blank, and absolute paths are rejected up front with a clear message. Scaffolding into . still works.
  2. GitHub repo (owner/repo) is optional. Leaving it blank scaffolds with a <owner>/<name> placeholder (already the convention in --yes mode) so people can try the project without creating a repo first, then fill in the real slug later.
  3. No more mkdir crash. An out-of-tree directory (e.g. an absolute /orc) previously crashed with a raw Unexpected error: ENOENT: no such file or directory, mkdir '/orc' stack trace. The CLI now refuses any target outside the current working directory (and home/root) with a friendly message and a non-zero exit.

Why

From feedback while trying the CLI:

"this one should be optional, especially for people to just try out your project, forcing repo creation will make them give up"

"here when I hit enter, it should give me that default which is displayed"

"and epic fail 😅" — ENOENT: no such file or directory, mkdir '/orc'

Required-by-default prompts and an unhandled crash are exactly the friction that makes people bail before their first successful scaffold.

How

  • validateProjectLocation accepts empty (falls back to default) and rejects absolute paths.
  • The GitHub slug prompt accepts empty; the existing <owner>/<name> placeholder fallback handles the rest.
  • scaffold() resolves and validates the target dir before any mkdir, using path.relative containment plus explicit home/root checks; "." (current directory) stays allowed.

Type

  • feat — New feature
  • fix — Bug fix
  • docs — Documentation
  • refactor — Code restructuring
  • perf — Performance improvement
  • style — Formatting / code style
  • chore — Maintenance / deps
  • ci — CI/CD changes
  • test — Tests

Checklist

  • Branch follows conventional naming (fix/)
  • Commits follow Conventional Commits
  • npm run lint passes
  • npm test passes (103 tests, +2 new)
  • Tests added or updated (optional GitHub slug + directory guard)
  • Docs updated (cli/prompts.mdx, cli/options.mdx note both as optional)

Screenshots

Verified locally with the built CLI:

# Absolute / out-of-tree dir — friendly cancel, no crash, nothing created
$ create-scn-stack orc --yes --directory /orc
└  Can't scaffold into /orc — it's outside the current directory. Use a relative path like ./orc.

# GitHub registry with no slug — placeholder, scaffolds fine
$ create-scn-stack ghkit --yes --github
│  npx shadcn@latest add <owner>/ghkit/button
└  ghkit ready as a GitHub source registry 🎉

# "." still scaffolds into the current directory
$ create-scn-stack dotkit --yes --directory .
└  dotkit ready with Next.js + Fumadocs 🎉

Lower the barrier to trying the CLI and stop a raw mkdir crash.

- Project location is now optional: an empty value falls back to the
  default ./<name>, and absolute paths are rejected up front with a
  clear message instead of "Project location is required."
- GitHub repo (owner/repo) is now optional: leaving it blank scaffolds
  with a <owner>/<name> placeholder you can fill in later
- Refuse to scaffold into a directory outside the current working
  directory (or into home/root), which previously surfaced as an
  unhandled "ENOENT: mkdir '/orc'" stack trace. Scaffolding into "."
  still works.
- Add integration tests for the optional GitHub slug and the directory
  guard; document both as optional in the CLI docs
@vercel

vercel Bot commented Jun 15, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
scn-stack Ready Ready Preview, Comment Jun 15, 2026 3:02am

Request Review

@github-actions github-actions Bot added bug Something isn't working docs Documentation changes website Changes to www/ (scnstack.sh) test Tests labels Jun 15, 2026
@jal-co jal-co merged commit 2e15918 into main Jun 15, 2026
5 checks passed
@jal-co jal-co deleted the fix/cli-optional-paths-and-mkdir-crash branch June 15, 2026 03:44
@jal-co jal-co mentioned this pull request Jun 15, 2026
15 tasks
jal-co added a commit that referenced this pull request Jun 15, 2026
## What

Release **v0.12.1** — a patch bump in `package.json` (and lockfile) to
ship the merged CLI fixes to npm.

## Why

[#42](#42) is on `main` but not
yet published, so users still get the old behaviour (required prompts +
the `mkdir '/orc'` crash). This bump lets a GitHub Release publish the
fix.

Since the package is in initial development (`0.y.z`) and #42 is a bug
fix, this is a **PATCH** bump per [SemVer](https://semver.org/) —
`0.12.0 → 0.12.1`.

### Included since v0.12.0

- `fix(cli): make project location + github repo optional, guard bad
dirs` (#42)
  - Project location optional (falls back to `./<name>`)
  - GitHub `owner/repo` optional (`<owner>/<name>` placeholder)
- Refuse out-of-tree scaffold dirs instead of crashing with `mkdir
ENOENT`

> Note: #41 (website light mode) is `www/`-only and ships via Vercel —
not part of the npm package.

## How

`npm version 0.12.1 --no-git-tag-version` (the `vX.Y.Z` tag is created
by the GitHub Release, which triggers `publish.yml`).

## Type

- [ ] `feat` — New feature
- [ ] `fix` — Bug fix
- [ ] `docs` — Documentation
- [ ] `refactor` — Code restructuring
- [ ] `perf` — Performance improvement
- [ ] `style` — Formatting / code style
- [x] `chore` — Maintenance / deps
- [ ] `ci` — CI/CD changes
- [ ] `test` — Tests

## Checklist

- [x] Branch follows conventional naming (`release/`)
- [x] Commits follow [Conventional
Commits](https://www.conventionalcommits.org/)
- [x] `npm run lint` passes
- [x] `npm test` passes (103 tests)
- [ ] Tests added or updated (n/a — version bump only)
- [ ] Docs updated (n/a)

## Release steps (after merge)

1. Merge this PR (release branches use a **merge commit**).
2. Create a GitHub Release tagged `v0.12.1` targeting `main` →
`publish.yml` lints, builds, tests, and runs `npm publish --provenance`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working docs Documentation changes test Tests website Changes to www/ (scnstack.sh)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant