Skip to content

Adds support for a next-typesafe-url configuration file#148

Merged
ethanniser merged 8 commits intoethanniser:mainfrom
JasonPaff:JasonPaff/support-config-file
Oct 21, 2025
Merged

Adds support for a next-typesafe-url configuration file#148
ethanniser merged 8 commits intoethanniser:mainfrom
JasonPaff:JasonPaff/support-config-file

Conversation

@JasonPaff
Copy link
Copy Markdown
Contributor

@JasonPaff JasonPaff commented Oct 15, 2025

For Issue #142

This PR:

Adds TypeScript configuration file support to next-typesafe-url, allowing users to configure the CLI via a next-typesafe-url.config.ts file instead of passing CLI arguments.

Features Added

  1. Configuration File Support
  • Added support for multiple config file formats:
    • next-typesafe-url.config.ts (TypeScript)
    • next-typesafe-url.config.js (JavaScript)
    • next-typesafe-url.config.mjs (ES Module)
    • next-typesafe-url.config.cjs (CommonJS)
    • package.json (under "next-typesafe-url" key)
  • Fully type-safe configuration
  • Config file values override defaults, CLI arguments override config file
  1. New Files
  • src/config.ts - Type definitions and default config
  • src/loadConfig.ts - Config file discovery and loading logic using cosmiconfig and jiti
  • test/loadConfig.test.ts - 18 tests for config file loading
  • test/configMerging.test.ts - 21 tests for config merging logic
  • examples/with-config/ - New example demonstrating config file usage with Next.js 15
  1. Dependencies
  • Added jiti (^1.21.0) for loading TypeScript config files
  • Added cosmiconfig (^9.0.0) for flexible config file discovery
  1. CLI Updates
  • Updated src/cli.ts to load and merge config files
  • Removed default values from meow flags to enable proper config merging
  • Updated help text to mention config file support
  • Exported Config type from main package for user imports
  1. Example Project
  • Created examples/with-config - minimal Next.js 15 + React 19 example
  • Demonstrates type-safe config file usage
  • Shows config file with all available options
image
  • [✅] (if ready to be merged) Yes I have made a changeset

@vercel
Copy link
Copy Markdown

vercel Bot commented Oct 15, 2025

@JasonPaff is attempting to deploy a commit to the ethanniser Team on Vercel.

A member of the Team first needs to authorize it.

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Oct 15, 2025

Open in StackBlitz

npm i https://pkg.pr.new/ethanniser/next-typesafe-url@148

commit: beac941

Copy link
Copy Markdown
Owner

@ethanniser ethanniser left a comment

Choose a reason for hiding this comment

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

hey this looks great just needs a changeset
thanks for the contribution

@JasonPaff
Copy link
Copy Markdown
Contributor Author

JasonPaff commented Oct 16, 2025

hey this looks great just needs a changeset thanks for the contribution

@ethanniser Changeset has been added

@ethanniser
Copy link
Copy Markdown
Owner

Tyty 🫡

@ethanniser ethanniser merged commit 06e9f8a into ethanniser:main Oct 21, 2025
2 of 3 checks passed
@ethanniser
Copy link
Copy Markdown
Owner

just published this- sorry for the delay

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.

2 participants