36 lines
759 B
TypeScript
Executable File
36 lines
759 B
TypeScript
Executable File
#!/usr/bin/env bun
|
|
import minimist from "minimist";
|
|
import { generateEnvTypes } from "./generate/env.generate.js";
|
|
import path from "path";
|
|
|
|
const args = minimist(process.argv.slice(2));
|
|
|
|
const help = `
|
|
g3n [command] [options]
|
|
|
|
Commands:
|
|
env Generate env.d.ts from .env file
|
|
|
|
Options:
|
|
--env Path ke file .env (default: .env)
|
|
--out Path file output (default: types/env.d.ts)
|
|
|
|
Examples:
|
|
g3n env --env .env.local --out src/types/env.d.ts
|
|
`;
|
|
|
|
(async () => {
|
|
const cmd = args._[0];
|
|
|
|
if (cmd === "env") {
|
|
generateEnvTypes({
|
|
envFilePath: args.env,
|
|
outputDir: args.out ? path.dirname(args.out) : undefined,
|
|
outputFileName: args.out ? path.basename(args.out) : undefined,
|
|
});
|
|
return;
|
|
}
|
|
|
|
console.error(help);
|
|
})();
|