A cli tool that to ntrospect configuration files and output a typescript type declarations.
```yaml calling-birds: - huey - dewey - louie - fred doe: "a deer, a female deer" french-hens: 3 pi: 3.14159 ray: "a drop of golden sun" xmas: true xmas-fifth-day: calling-birds: four french-hens: 3 golden-rings: 5 partridges: count: 1 location: "a pear tree"
calling-birds: - huey - dewey - louie - fred
hello: world ```
becomes
ts
declare namespace TestMultiple {
export type Document0 = {
"calling-birds": ["huey", "dewey", "louie", "fred"];
doe: "a deer, a female deer";
"french-hens": 3;
pi: 3.14159;
ray: "a drop of golden sun";
xmas: true;
"xmas-fifth-day": {
"calling-birds": "four";
"french-hens": 3;
"golden-rings": 5;
partridges: { count: 1; location: "a pear tree" };
"turtle-doves": "two";
};
};
export type Document1 = {
"calling-birds": ["huey", "dewey", "louie", "fred"];
doe: "a deer, a female deer";
};
export type Document2 = { hello: "world" };
export type All = [Document0, Document1, Document2];
}
```
Usage: ntro yaml [OPTIONS]
Arguments:
Options:
-o
```env NAME="value" NEXTPUBLICKEY="yoa",
NAME2=value KEY = "value" # asdfa
keys= 'city'
keys2 ='city' ```
*.d.ts
```ts declare namespace NodeJS { interface ProcessEnv { KEY?: string;
NAME?: string;
NAME2?: string;
NEXT_PUBLIC_KEY: string;
keys?: string;
keys2?: string;
} } ```
You can also generate a typescript module that parses environment variables with extra type safety using zod. The advantage is that type hint comment are collected and used to define the zod schema.
```ts import z, { ZodTypeAny } from "zod";
const clientEnvSchemas = { NEXTPUBLICKEY: z.string(), };
const serverEnvSchemas = { ...clientEnvSchemas, NAME: z.string(), NAME2: z.enum(["a", "b"]), keys: z.string(), keys2: z.coerce.string(), };
//... more implementation details are generated ```
``` Usage: ntro dotenv [OPTIONS] [SOURCE_FILES]...
Arguments: [SOURCE_FILES]... Path(s) to some .env files
Options:
-o