Skip to content

CLI should respect tsconfig.json for path resolution and general configuration #908

@yamcodes

Description

@yamcodes

Description

Currently, the ArkEnv CLI is opinionated about the project structure, defaulting to ./src/env.ts for the configuration file. This doesn't work well for all project structures, such as simple Node.js apps that don't use a src/ directory.

The CLI should be more flexible and respect the settings defined in tsconfig.json.

Proposed Changes

  1. Read tsconfig.json: The CLI should look for tsconfig.json (and its variants like tsconfig.app.json, tsconfig.base.json, etc.) and parse it.
  2. Suggest Defaults based on rootDir: Use the rootDir from tsconfig.json to suggest a default path for env.ts.
  3. Flexible Fallback: If no src/ directory is found and no rootDir is specified, it should fallback to a more sensible default (e.g., ./env.ts in the root) instead of always forcing ./src/env.ts.
  4. Path Resolution: Respect baseUrl and paths from tsconfig.json if it ever needs to resolve other imports or files.
  5. Improved Detection: Enhance detectFramework and detectPackageManager logic to also consider tsconfig.json settings where applicable.

Example Scenario

A Node.js project with the following structure:

project/
├── env.ts
├── index.ts
├── package.json
└── tsconfig.json

Currently, ArkEnv CLI will prompt to use ./src/env.ts by default and create the src/ directory, which is incorrect for this project.

Implementation Notes

The logic in packages/cli/src/scaffold.ts and packages/cli/src/prompts.ts currently hardcodes ./src/env.ts. This should be refactored to use a dynamic default based on project analysis.

Metadata

Metadata

Assignees

No one assigned

    Labels

    @arkenv/cliIssues or Pull Requests involving the ArkEnv CLIbugSomething isn't workingenhancementNew feature or requestready for agentFully specified, ready for an AI agent to implement

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions