Path Codegen

Path Codegen is a tool that automates path-based code generation for TypeScript projects. It analyzes the project's directory structure and generates type-safe path constants for each file and folder. By using generated constants instead of hard-coded strings, developers can reduce errors caused by typos or path changes and improve code maintainability.

usage#

You can run this tool directly using npx without any installation.

  • <source-directory>: (Required) The path to the directory you want to scan.
  • -o, --output <file>: The name for the generated output file. (Default: path-codegen.ts)

Given a directory structure like this:

Running the following command:

Will generate the following file at src/generated/paths.ts:

Path Codegen - Type-safe Path Utilities | ilokesto - React Library Collection