sheets2env
v1.2.4
Published
Read google sheet and create .env file from sheet column and tab
Downloads
9
Readme
Installation
With npm
npm install --save-dev sheets2envWith yarn
yarn add -D sheets2envSetup & Usage
CLI
$ sheets2envCI
$ sheets2env
-p config_path
-c base64_google_credentials
-t base64_authorized_tokenScript
import { SheetsEnv } from 'sheets2env'
const client = new SheetsEnv()
await client.sync()Example of token file
// This file is auto generated after sync()
// This file is placed to ~/.sheets2env/google-token
{
"access_token": "...",
"expiry_date": 1573214579858,
"refresh_token": "...",
"scope": "https://www.googleapis.com/auth/spreadsheets.readonly",
"token_type": "Bearer",
}Google Sheet Structure
From this table we decalre column develop as {column:1} and uat as {column:2} and production as {column:3}
key | develop | uat | production ---|---|--- | --- PROJECT_ID | example | example | example SECRET_KEY | example | example | example
You can find this config at your_project/sheets2env.config.json
{
"projects": [
{
"column": 3,
"dest": "path/to/your/1/.env",
"tab": "project_1"
},
{
"column": 1,
"dest": "path/to/your/2/.env.development",
"tab": "project_2"
},
{
"column": 2,
"dest": "path/to/your/2/.env.uat",
"tab": "project_2"
},
{
"column": 3,
"dest": "path/to/your/2/.env",
"tab": "project_2"
}
],
"sheetId": "your_sheets_id"
}