Switch to dist folder and output typescript declaration files

This commit is contained in:
Todd Bluhm 2019-05-04 05:45:52 -05:00
parent 3534069ece
commit cd3018f25b
No known key found for this signature in database
GPG Key ID: 9CF312607477B8AB
24 changed files with 150 additions and 6 deletions

View File

@ -1,2 +1,2 @@
#! /usr/bin/env node
require('../lib').CLI(process.argv.slice(2))
require('../dist').CLI(process.argv.slice(2))

21
dist/env-cmd.d.ts vendored Normal file
View File

@ -0,0 +1,21 @@
import { EnvCmdOptions } from './types';
/**
* Executes env - cmd using command line arguments
* @export
* @param {string[]} args Command line argument to pass in ['-f', './.env']
* @returns {Promise<{ [key: string]: any }>}
*/
export declare function CLI(args: string[]): Promise<{
[key: string]: any;
}>;
/**
* The main env-cmd program. This will spawn a new process and run the given command using
* various environment file solutions.
*
* @export
* @param {EnvCmdOptions} { command, commandArgs, envFile, rc, options }
* @returns {Promise<{ [key: string]: any }>} Returns an object containing [environment variable name]: value
*/
export declare function EnvCmd({ command, commandArgs, envFile, rc, options }: EnvCmdOptions): Promise<{
[key: string]: any;
}>;

View File

16
dist/get-env-vars.d.ts vendored Normal file
View File

@ -0,0 +1,16 @@
import { GetEnvVarOptions } from './types';
export declare function getEnvVars(options?: GetEnvVarOptions): Promise<{
[key: string]: any;
}>;
export declare function getEnvFile({ filePath, fallback }: {
filePath?: string;
fallback?: boolean;
}): Promise<{
[key: string]: any;
}>;
export declare function getRCFile({ environments, filePath }: {
environments: string[];
filePath?: string;
}): Promise<{
[key: string]: any;
}>;

View File

4
dist/index.d.ts vendored Normal file
View File

@ -0,0 +1,4 @@
import { getEnvVars } from './get-env-vars';
export * from './types';
export * from './env-cmd';
export declare const GetEnvVars: typeof getEnvVars;

View File

5
dist/parse-args.d.ts vendored Normal file
View File

@ -0,0 +1,5 @@
import { EnvCmdOptions } from './types';
/**
* Parses the arguments passed into the cli
*/
export declare function parseArgs(args: string[]): EnvCmdOptions;

26
dist/parse-env-file.d.ts vendored Normal file
View File

@ -0,0 +1,26 @@
/**
* Gets the environment vars from an env file
*/
export declare function getEnvFileVars(envFilePath: string): Promise<{
[key: string]: any;
}>;
/**
* Parse out all env vars from a given env file string and return an object
*/
export declare function parseEnvString(envFileString: string): {
[key: string]: string;
};
/**
* Parse out all env vars from an env file string
*/
export declare function parseEnvVars(envString: string): {
[key: string]: string;
};
/**
* Strips out comments from env file string
*/
export declare function stripComments(envString: string): string;
/**
* Strips out newlines from env file string
*/
export declare function stripEmptyLines(envString: string): string;

15
dist/parse-rc-file.d.ts vendored Normal file
View File

@ -0,0 +1,15 @@
/**
* Gets the env vars from the rc file and rc environments
*/
export declare function getRCFileVars({ environments, filePath }: {
environments: string[];
filePath: string;
}): Promise<{
[key: string]: any;
}>;
/**
* Reads and parses the .rc file
*/
export declare function parseRCFile(fileData: string): {
[key: string]: any;
};

23
dist/signal-termination.d.ts vendored Normal file
View File

@ -0,0 +1,23 @@
/// <reference types="node" />
import { ChildProcess } from 'child_process';
export declare class TermSignals {
private terminateSpawnedProcessFuncHandlers;
_exitCalled: boolean;
handleTermSignals(proc: ChildProcess): void;
/**
* Enables catching of unhandled exceptions
*/
handleUncaughtExceptions(): void;
/**
* Terminate parent process helper
*/
_terminateProcess(code?: number, signal?: string): void;
/**
* Exit event listener clean up helper
*/
_removeProcessListeners(): void;
/**
* General exception handler
*/
_uncaughtExceptionHandler(e: Error): void;
}

2
dist/spawn.d.ts vendored Normal file
View File

@ -0,0 +1,2 @@
import * as spawn from 'cross-spawn';
export { spawn };

View File

18
dist/types.d.ts vendored Normal file
View File

@ -0,0 +1,18 @@
export interface GetEnvVarOptions {
envFile?: {
filePath?: string;
fallback?: boolean;
};
rc?: {
environments: string[];
filePath?: string;
};
}
export interface EnvCmdOptions extends GetEnvVarOptions {
command: string;
commandArgs: string[];
options?: {
noOverride?: boolean;
useShell?: boolean;
};
}

View File

12
dist/utils.d.ts vendored Normal file
View File

@ -0,0 +1,12 @@
/**
* A simple function for resolving the path the user entered
*/
export declare function resolveEnvFilePath(userPath: string): string;
/**
* A simple function that parses a comma separated string into an array of strings
*/
export declare function parseArgList(list: string): string[];
/**
* A simple function to test if the value is a promise
*/
export declare function isPromise(value: any | PromiseLike<Object>): boolean;

View File

View File

@ -2,7 +2,8 @@
"name": "env-cmd",
"version": "9.0.0",
"description": "Executes a command using the envs in the provided env file",
"main": "lib/index.js",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"engines": {
"node": ">=8.0.0"
},
@ -10,11 +11,11 @@
"env-cmd": "bin/env-cmd.js"
},
"scripts": {
"test": "mocha -r ts-node/register ./**/*.ts",
"test": "mocha -r ts-node/register ./test/**/*.ts",
"test-cover": "nyc --reporter=lcov --reporter=text npm test",
"test-lint": "eslint ./**/*.ts",
"test-lint": "eslint ./src/**/*.ts ./test/**/*.ts",
"coveralls": "coveralls < coverage/lcov.info",
"lint": "eslint --fix ./**/*.ts",
"lint": "eslint --fix ./src/**/*.ts ./test/**/*.ts",
"build": "tsc"
},
"repository": {

View File

@ -1,9 +1,10 @@
{
"compilerOptions": {
"outDir": "./lib",
"outDir": "./dist",
"target": "es2015",
"module": "commonjs",
"strict": true,
"declaration": true,
"lib": [
"es2015",
"es2016",