Socket
Socket
Sign inDemoInstall

configure-env

Package Overview
Dependencies
37
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.0 to 2.0.0-0

dist/parser.d.ts

30

CHANGELOG.md

@@ -5,2 +5,32 @@ # Changelog

## [2.0.0-0](https://github.com/twilio-labs/configure-env/compare/v1.0.0...v2.0.0-0) (2020-08-05)
### ⚠ BREAKING CHANGES
* delete old parser
### Features
* add new parser to library ([299d05d](https://github.com/twilio-labs/configure-env/commit/299d05de6ec43bfcfc3d71e1b009c650edc1f84d))
* add type based validators ([f83ec19](https://github.com/twilio-labs/configure-env/commit/f83ec198c4205c6dfad6256dfd85d7888c0c2273))
* change configurable default ([2f702f4](https://github.com/twilio-labs/configure-env/commit/2f702f4b06d1ebe3c590de7faa7946221cea3b4f))
* expose validators to main lib ([081f5da](https://github.com/twilio-labs/configure-env/commit/081f5da11844a09af8b1dbab52c546dd3346443f))
* rename nested_list to map ([fc186e4](https://github.com/twilio-labs/configure-env/commit/fc186e4ada1ef461da64f02812c7435c3cd92611))
* upgrade @types/node from 12.12.9 to 14.0.13 ([ce42843](https://github.com/twilio-labs/configure-env/commit/ce428439b82162c5d91090b46ab39642bc73eb32))
* use new parser in CLI tool ([fa0345e](https://github.com/twilio-labs/configure-env/commit/fa0345e21dead27fdc2bf76574d07ac6b300f29c))
### Bug Fixes
* enable float numbers in prompt ([b5df843](https://github.com/twilio-labs/configure-env/commit/b5df84397f1b57f67eedc3b3b1fc9bee9f73bc5b))
* upgrade prompts from 2.3.0 to 2.3.2 ([fc673ab](https://github.com/twilio-labs/configure-env/commit/fc673abb8ef3d533b2df1823a158dc6935e923b6))
* upgrade yargs from 15.0.2 to 15.3.1 ([1af2cfe](https://github.com/twilio-labs/configure-env/commit/1af2cfe9931a20612d4c808c7c288ddef71778b0))
* **index:** change amount of lines that are cleared ([406e9e0](https://github.com/twilio-labs/configure-env/commit/406e9e09e57531468b69a897ee32abd25ad80260))
* **parser:** improve edge case handling ([6f944b3](https://github.com/twilio-labs/configure-env/commit/6f944b37fe4b52bde97506b6bdab587d05dd6af2))
* **parser:** list format parsing ([0d8ee9c](https://github.com/twilio-labs/configure-env/commit/0d8ee9ceb36108af4542c783051ccbf35b650e8c))
* delete old parser ([0ba92e1](https://github.com/twilio-labs/configure-env/commit/0ba92e14ab9c61f5701a4492776c9c10f8cba93a))
## 1.0.0 (2019-11-19)

@@ -7,0 +37,0 @@

4

dist/index.d.ts
/// <reference types="node" />
import * as fs from 'fs';
import * as tty from 'tty';
import * as parserLib from './parser';
import * as validatorLib from './validators';
export declare type Config = {

@@ -10,1 +12,3 @@ output: fs.WriteStream;

export declare function configureEnv(config: Config): Promise<void>;
export declare const parser: typeof parserLib;
export declare const validators: typeof validatorLib;
"use strict";
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const log_symbols_1 = require("log-symbols");
const sisteransi_1 = require("sisteransi");
const exampleFileParser_1 = require("./exampleFileParser");
const output_1 = require("./output");
const parserLib = __importStar(require("./parser"));
const prompts_1 = require("./prompts");
const validatorLib = __importStar(require("./validators"));
async function configureEnv(config) {
const parsedExample = exampleFileParser_1.parseExampleFile(config.exampleFileContent);
const parsedExample = parserLib.parse(config.exampleFileContent);
config.promptStream.write(`Configuring your environment. Please fill out the following info\n`);

@@ -14,3 +22,3 @@ config.promptStream.write(`${log_symbols_1.info} To skip any field press Ctrl+C\n`);

const output = output_1.createOutput(parsedExample, answers);
config.promptStream.write(sisteransi_1.erase.lines(parsedExample.variablesToSet.length + 3));
config.promptStream.write(sisteransi_1.erase.lines(parsedExample.variables.length + 2));
config.output.write(output, 'utf8');

@@ -24,1 +32,3 @@ config.promptStream.write(`${log_symbols_1.success} Environment has been configured.\n`);

exports.configureEnv = configureEnv;
exports.parser = parserLib;
exports.validators = validatorLib;

4

dist/output.d.ts

@@ -1,4 +0,4 @@

import { ParsedExample } from './exampleFileParser';
export declare function createOutput(parsedExample: ParsedExample, answers: {
import { ParseResult } from './parser';
export declare function createOutput(parsedExample: ParseResult, answers: {
[x: string]: string;
}): string;

@@ -5,4 +5,6 @@ "use strict";

let output = parsedExample.outputTemplate;
for (let variableToSet of parsedExample.variablesToSet) {
let value = answers[variableToSet.name];
for (let variableToSet of parsedExample.variables) {
let value = (answers[variableToSet.key] ||
variableToSet.default ||
'').toString();
if (value) {

@@ -14,3 +16,3 @@ value = `"${value.replace(/"/, '"')}"`;

}
output = output.replace(`{{${variableToSet.name}}}`, value);
output = output.replace(`{{${variableToSet.key}}}`, value);
}

@@ -17,0 +19,0 @@ return output;

/// <reference types="node" />
import prompts, { Answers, PromptObject } from 'prompts';
import prompts, { Answers, PromptObject, PromptType } from 'prompts';
import { WriteStream } from 'tty';
import { ParsedExample } from './exampleFileParser';
export declare function createQuestions(parsedExample: ParsedExample, promptStream: WriteStream): PromptObject[];
import { ParseResult, VariableFormat } from './parser';
export declare function getPromptType(format: VariableFormat): PromptType;
export declare function createQuestions(parsedExample: ParseResult, promptStream: WriteStream): PromptObject[];
export declare function handleCancel(prompt: PromptObject, answers: Answers<string>): boolean;
export declare function promptForVariables(parsedExample: ParsedExample, promptStream: WriteStream): Promise<prompts.Answers<string>>;
export declare function promptForVariables(parsedExample: ParseResult, promptStream: WriteStream): Promise<prompts.Answers<string>>;

@@ -7,10 +7,27 @@ "use strict";

const prompts_1 = __importDefault(require("prompts"));
const validators_1 = require("./validators");
function getPromptType(format) {
switch (format) {
case 'secret':
return 'invisible';
case 'integer':
case 'number':
return 'number';
default:
return 'text';
}
}
exports.getPromptType = getPromptType;
function createQuestions(parsedExample, promptStream) {
return parsedExample.variablesToSet.map(entry => {
return parsedExample.variables
.filter(entry => entry.configurable)
.map(entry => {
return {
type: 'text',
name: entry.name,
message: entry.comment,
initial: entry.defaultValue,
type: getPromptType(entry.format),
name: entry.key,
message: entry.description || `Please enter a value for ${entry.key}`,
initial: entry.default || undefined,
validate: validators_1.getValidator(entry.format),
stdout: promptStream,
float: entry.format === 'number' ? true : undefined,
};

@@ -17,0 +34,0 @@ });

{
"name": "configure-env",
"version": "1.0.0",
"version": "2.0.0-0",
"description": "Configures your project's environment by creating a .env file.",

@@ -29,2 +29,3 @@ "main": "dist/index.js",

"@types/common-tags": "^1.8.0",
"@types/google-libphonenumber": "^7.4.19",
"@types/jest": "^24.0.23",

@@ -41,6 +42,7 @@ "@types/mock-fs": "^4.10.0",

"mock-fs": "^4.10.3",
"normalize-newline": "^3.0.0",
"npm-run-all": "^4.1.5",
"prettier": "^1.19.1",
"rimraf": "^3.0.0",
"standard-version": "^7.0.1",
"standard-version": "^8.0.1",
"ts-jest": "^24.1.0",

@@ -50,6 +52,8 @@ "typescript": "^3.7.2"

"dependencies": {
"@types/node": "^12.12.9",
"@types/node": "^14.0.13",
"email-regex": "^4.0.0",
"google-libphonenumber": "^3.2.10",
"log-symbols": "^3.0.0",
"prompts": "^2.3.0",
"yargs": "^15.0.2"
"prompts": "^2.3.2",
"yargs": "^15.3.1"
},

@@ -56,0 +60,0 @@ "config": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc