Skip to content

Commit

Permalink
fix(index): type checks
Browse files Browse the repository at this point in the history
fixing types autogenerates
  • Loading branch information
Yuri-Lima committed Apr 18, 2023
1 parent 94923d7 commit 1055d9d
Show file tree
Hide file tree
Showing 7 changed files with 12,210 additions and 9,792 deletions.
21,917 changes: 12,167 additions & 9,750 deletions package-lock.json

Large diffs are not rendered by default.

21 changes: 11 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dynamic.envs",
"version": "1.0.3",
"version": "1.0.4",
"description": "Converts json to .env file",
"author": "Yuri Lima",
"license": "MIT",
Expand Down Expand Up @@ -36,21 +36,22 @@
"package": "^1.0.1",
"package.json": "^0.0.0",
"save-dev": "^0.0.1-security",
"tsconfig-paths": "^4.1.2",
"typescript": "^4.9.3"
"tsconfig-paths": "^4.2.0",
"typescript": "^5.0.4",
"zod": "^3.21.4"
},
"devDependencies": {
"@semantic-release/git": "^10.0.1",
"@types/jest": "^29.2.3",
"commitizen": "^4.2.5",
"@types/jest": "^29.5.0",
"commitizen": "^4.3.0",
"cz-conventional-changelog": "^3.3.0",
"cz-emoji": "^1.3.2-canary.2",
"jest": "^29.3.1",
"npm-check-updates": "^16.4.3",
"semantic-release": "^19.0.5",
"ts-jest": "^29.0.3",
"jest": "^29.5.0",
"npm-check-updates": "^16.10.8",
"semantic-release": "^21.0.1",
"ts-jest": "^29.1.0",
"ts-node-dev": "^2.0.0",
"tsup": "^6.5.0"
"tsup": "^6.7.0"
},
"homepage": "https://yurilima.uk/",
"repository": {
Expand Down
18 changes: 7 additions & 11 deletions src/.env.DoNotDelete.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,19 @@
{
"PORT": 6666,
"PORT": "6666",
"ARRAY_0": "a",
"ARRAY_1": "b",
"ARRAY_2": "c",
"DBURI_HOST": "127.0.0.1",
"DBURI_PORT": 666,
"DBURI_PORT": "666",
"DBURI_DB_NAME": "DB_X1",
"DBURI_DB_ARRAY_2_0": "1",
"DBURI_DB_ARRAY_2_1": "2",
"DBURI_DB_ARRAY_2_2": "3",
"DBURI_DB_USER_NAME": "ABC",
"DBURI_DB_USER_PASSWORD": null,
"DBURI_DB_USER_PASSWORD": "null",
"DBURI_DB_USER_ROLE_NAME": "'ADMIN'",
"DBURI_DB_USER_ROLE_PERMISSIONS": [
"READ",
"WRITE",
"DELETE"
],
"DBURI_DB_USER_NUMBER": 789,
"DBURI_DB_PASSWORD": 12345678,
"LOGLEVEL": true
"DBURI_DB_USER_ROLE_PERMISSIONS": "READ,WRITE,DELETE",
"DBURI_DB_USER_NUMBER": "789",
"DBURI_DB_PASSWORD": "12345678",
"LOGLEVEL": "true"
}
24 changes: 23 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
import fs from 'node:fs';
import { infer, input, TypeOf, output } from "zod";
import envs from './.env.DoNotDelete.json';

type Env = typeof envs;
/* eslint-disable no-var */
declare global {
namespace NodeJS {
interface ProcessEnv extends Env {} // extends process.env
}
}

import { Set_Env, Options } from './types/types';

type T = keyof typeof Object; // TODO: fix this
Expand Down Expand Up @@ -250,7 +261,18 @@ export default class JsonToEnv {
);
}
// Internal use to generate types definition for process.env
const destination = `${__dirname}/.env.DoNotDelete.json`;
const destination = `${__dirname}/.env.DoNotDelete.json`;
//convert the object values to string
type ObjectString = {
[key: string]: string;
}

this.objectobecomeJson = Object.keys(this.objectobecomeJson).reduce((acc:ObjectString, key:string) => {
// @ts-ignore
acc[key] = String(this.objectobecomeJson[key])
return acc;
}, {});

fs.writeFileSync(
destination,
JSON.stringify(this.objectobecomeJson, null, 4),
Expand Down
5 changes: 0 additions & 5 deletions src/types/envs.ts

This file was deleted.

14 changes: 0 additions & 14 deletions src/types/global.d.ts

This file was deleted.

3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@
},
"include": [
"src/**/*",
"test/**/*"
"test/**/*",
"src/.env.DoNotDelete.json",
],
"exclude": [
".env",
Expand Down

0 comments on commit 1055d9d

Please sign in to comment.