项目作者: mathieu-bour

项目描述 :
Convert your dotenv files to their YAML equivalent.
高级语言: TypeScript
项目地址: git://github.com/mathieu-bour/dotenv-to-yaml.git
创建时间: 2021-04-13T14:45:16Z
项目社区:https://github.com/mathieu-bour/dotenv-to-yaml

开源协议:MIT License

下载


dotenv-to-yaml

Convert your dotenv files to their YAML equivalent.

Motivations

I initially developed this package to easily deploy Google Cloud Functions because the gcloud CLI does not understand
dotenv files.

Extracted from the gcloud functions deploy docs:

--env-vars-file=FILE_PATH

Path to a local YAML file with definitions for all environment variables. All existing environment variables will be removed before the new environment variables are added.

Installation

Install locally (inside a project where a package.json is defined):

  1. npm install dotenv-to-yaml

Note: you may want to use the --dev flag if you are only interested in the CLI feature.

Usage

Command Line Interface

Global usage:

  1. dotenv-to-yaml [source] [destination]
  2. Transform a dotenv file to YAML one
  3. Positionals:
  4. source The source dotenv file or `-` if the file content is piped to
  5. STDIN. [string] [default: ".env"]
  6. destination The destination YAML file or `-` to pipe the conversion result to
  7. STDOUT. [string] [default: ".env.yaml"]

Piping from STDIN

dotenv-to-yaml supports piping the dotenv content through STDIN; the converted output will be sent to STDOUT.

Example:

  1. dotenv-to-yaml < samples/bedrock.env

will print:

  1. AUTH_KEY: qVQ9646_?j*46vlO^j$;cGY/|;4i7z%&&bk/O#rex[.72@*R8_{9h8#D$|8@7_Wj
  2. SECURE_AUTH_KEY: SoHEtm!HO3M2r#Z$3l]PX}aSc-hyLq95m_w7oY=a]fOM4b[/Q^=L`MB^lb`qAU-y
  3. LOGGED_IN_KEY: dt{MU>/B9YO.V)M#3Ho=QmJc4s:/WC58r%CZTrQkx7jpgRvrO@iDYo[COU8X*=C|
  4. NONCE_KEY: '*#XT#t,y2ucBk87C;88;0(Cwq+zA1()WIwsR!P4TIzJQZPA2P$Saww8xQ(GDx_y]'
  5. AUTH_SALT: .J2bEZQvDKMM%kWwdgXFf/q/&10c7AtSbl%NLH.3j.}.4.|MPdC,Tnp$:|i#sF)y
  6. SECURE_AUTH_SALT: /DdIXg_TI|E`;/C#t24^>i[@WG/1SsnoQU*bfmdf#p9e%Zo(xe?b9CJ(tZD;:^o3
  7. LOGGED_IN_SALT: c5AMtWe?Nut`]sVo5Sdw4:)N,togVS6L{IvRvCxi>;VJyz4xDE$&X#q4)JB<#LUH
  8. NONCE_SALT: Nmfdg*9@x$tdb[TZj.1-p)(<ay]:k=:5u(lmH2bpi8]A|qAMm_AGajQ90ZQQI.f<

Specifying source and destination

  1. dotenv-to-yaml .env .env.yaml

Node.js

  1. const { dotenvToYAML } = require('dotenv-to-yaml');

ESM / TypeScript

  1. import { dotenvToYAML } from 'dotenv-to-yaml';
  2. // OR with default import:
  3. import dotenvToYAML from 'dotenv-to-yaml';