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
- Read
tsconfig.json: The CLI should look for tsconfig.json (and its variants like tsconfig.app.json, tsconfig.base.json, etc.) and parse it.
- Suggest Defaults based on
rootDir: Use the rootDir from tsconfig.json to suggest a default path for env.ts.
- 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.
- Path Resolution: Respect
baseUrl and paths from tsconfig.json if it ever needs to resolve other imports or files.
- 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.
Description
Currently, the ArkEnv CLI is opinionated about the project structure, defaulting to
./src/env.tsfor the configuration file. This doesn't work well for all project structures, such as simple Node.js apps that don't use asrc/directory.The CLI should be more flexible and respect the settings defined in
tsconfig.json.Proposed Changes
tsconfig.json: The CLI should look fortsconfig.json(and its variants liketsconfig.app.json,tsconfig.base.json, etc.) and parse it.rootDir: Use therootDirfromtsconfig.jsonto suggest a default path forenv.ts.src/directory is found and norootDiris specified, it should fallback to a more sensible default (e.g.,./env.tsin the root) instead of always forcing./src/env.ts.baseUrlandpathsfromtsconfig.jsonif it ever needs to resolve other imports or files.detectFrameworkanddetectPackageManagerlogic to also considertsconfig.jsonsettings where applicable.Example Scenario
A Node.js project with the following structure:
Currently, ArkEnv CLI will prompt to use
./src/env.tsby default and create thesrc/directory, which is incorrect for this project.Implementation Notes
The logic in
packages/cli/src/scaffold.tsandpackages/cli/src/prompts.tscurrently hardcodes./src/env.ts. This should be refactored to use a dynamic default based on project analysis.