remove dotenv (#39164)

* remove dotenv

* add missing dependencies

* Add TS header
This commit is contained in:
Max Beatty 2019-10-27 08:50:18 -07:00 committed by John Reilly
parent a2bceed52a
commit 46322caeb1
12 changed files with 19 additions and 204 deletions

View File

@ -756,6 +756,12 @@
"sourceRepoURL": "https://github.com/sindresorhus/dot-prop",
"asOfVersion": "5.0.0"
},
{
"libraryName": "dotenv",
"typingsPackageName": "dotenv",
"sourceRepoURL": "https://github.com/motdotla/dotenv",
"asOfVersion": "8.2.0"
},
{
"libraryName": "dva",
"typingsPackageName": "dva",

View File

@ -2,6 +2,7 @@
// Project: https://github.com/rolodato/dotenv-safe
// Definitions by: Stan Goldmann <https://github.com/krenor>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
import env = require("dotenv")

View File

@ -0,0 +1,6 @@
{
"private": true,
"dependencies": {
"dotenv": "^8.2.0"
}
}

View File

@ -1,18 +0,0 @@
import dotenv = require("dotenv");
const env = dotenv.config();
const dbUrl: string | null = env.error || !env.parsed ? null : env.parsed["BASIC"];
dotenv.config({
path: ".env-example",
encoding: "utf8",
debug: true
});
const parsed = dotenv.parse("NODE_ENV=production\nDB_HOST=a.b.c");
const dbHost: string = parsed["DB_HOST"];
const parsedFromBuffer = dotenv.parse(new Buffer("JUSTICE=league\n"), {
debug: true
});
const justice: string = parsedFromBuffer["JUSTICE"];

View File

@ -1,66 +0,0 @@
// Type definitions for dotenv 6.1
// Project: https://github.com/motdotla/dotenv
// Definitions by: Jussi Kinnula <https://github.com/jussikinnula>
// Borek Bernard <https://github.com/borekb>
// Eric Naeseth <https://github.com/enaeseth>
// Max Beatty <https://github.com/maxbeatty>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="node" />
export interface DotenvParseOptions {
/**
* You may turn on logging to help debug why certain keys or values are not being set as you expect.
*/
debug?: boolean;
}
export interface DotenvParseOutput {
[name: string]: string;
}
/**
* Parses a string or buffer in the .env file format into an object.
*
* @param src - contents to be parsed
* @param options - additional options
* @returns an object with keys and values based on `src`
*/
export function parse(
src: string | Buffer,
options?: DotenvParseOptions
): DotenvParseOutput;
export interface DotenvConfigOptions {
/**
* You may specify a custom path if your file containing environment variables is located elsewhere.
*/
path?: string;
/**
* You may specify the encoding of your file containing environment variables.
*/
encoding?: string;
/**
* You may turn on logging to help debug why certain keys or values are not being set as you expect.
*/
debug?: boolean;
}
export interface DotenvConfigOutput {
error?: Error;
parsed?: DotenvParseOutput;
}
/**
* Loads `.env` file contents into {@link https://nodejs.org/api/process.html#process_process_env | `process.env`}.
* Example: 'KEY=value' becomes { parsed: { KEY: 'value' } }
*
* @param options - controls behavior
* @returns an object with a `parsed` key if successful or `error` key if an error occurred
*
*/
export function config(options?: DotenvConfigOptions): DotenvConfigOutput;
/** @deprecated since v7.0.0 Use config instead. */
export const load: typeof config;

View File

@ -1,23 +0,0 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"dotenv-tests.ts"
]
}

View File

@ -1 +0,0 @@
{ "extends": "dtslint/dt.json" }

View File

@ -1,26 +0,0 @@
import dotenv = require('dotenv');
// typically, result will be an Object
const env = dotenv.config({
silent: true
});
const dbUrl: string | null = !env ? null : env['DATABASE_URL'];
// ... but it might also be `false`
const result = dotenv.config({
path: '.non-existing-env'
});
dotenv.config({
path: '.env'
});
dotenv.config({
encoding: 'utf8'
});
const parsed = dotenv.parse("ENVIRONMENT=production\nDEBUG=no\n");
const debug: string = parsed['DEBUG'];
const parsedFromBuffer = dotenv.parse(new Buffer("JUSTICE=league\n"));
const justice: string = parsedFromBuffer['JUSTICE'];

View File

@ -1,41 +0,0 @@
// Type definitions for dotenv 2.0
// Project: https://github.com/motdotla/dotenv
// Definitions by: Jussi Kinnula <https://github.com/jussikinnula>, Borek Bernard <https://github.com/borekb>, Eric Naeseth <https://github.com/enaeseth>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="node" />
/**
* Parses a string or buffer in the .env file format into an object.
*/
export function parse(src: string | Buffer): {[name: string]: string};
/**
* Loads `.env` into `process.env`.
*
* @return Object Object with the parsed keys and values, e.g., 'KEY=value' becomes { KEY: 'value' }
*/
export function config(options?: DotenvOptions): {[name: string]: string} | false;
export interface DotenvOptions {
/**
* Dotenv outputs a warning to your console if missing a .env file. Suppress this warning using silent.
*
* @default false
*/
silent?: boolean;
/**
* You can specify a custom path if your file containing environment variables is named or located differently.
*
* @default '.env'
*/
path?: string;
/**
* You may specify the encoding of your file containing environment variables using this option.
*
* @default 'utf8'
*/
encoding?: string;
}

View File

@ -1,28 +0,0 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../../",
"typeRoots": [
"../../"
],
"paths": {
"dotenv": [
"dotenv/v2"
]
},
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"dotenv-tests.ts"
]
}

View File

@ -1 +0,0 @@
{ "extends": "dtslint/dt.json" }

View File

@ -0,0 +1,6 @@
{
"private": true,
"dependencies": {
"dotenv": "^8.2.0"
}
}