Skip to content

Commit 503629b

Browse files
committed
feat: Updated README, added first configless properties to sync
1 parent 0e45bc1 commit 503629b

File tree

9 files changed

+257
-133
lines changed

9 files changed

+257
-133
lines changed

README.md

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# envsync
22

3+
> Effortless environment file synchronization
4+
35
[![npm version](https://img.shields.io/npm/v/envsync?style=flat&colorA=222&colorB=448aff)](https://npmjs.com//envsync)
46
[![License](https://img.shields.io/github/license/visorian/envsync?style=flat&colorA=222&colorB=448aff)](./LICENSE)
57

6-
> Effortless environment file synchronization and management for modern projects.
7-
88
> *Did you receive the .env file I shared in Discord?*
99
1010
**envsync** helps you keep your `.env` files in sync across local and remote backends (local, Azure Storage, Azure Key Vault, Azure App Configuration). It provides a simple CLI to initialize, sync, update, check status, and clear environment files for your project.
@@ -15,9 +15,8 @@
1515

1616
- 🔍 **Auto-detects** `.env` files in your project (root and subfolders)
1717
- 🗂️ **Supports multiple backends powered by unstorage**: Currently supported Azure Storage, Azure Key Vault, Azure App Configuration
18-
- 📝 **Interactive CLI** for setup and management
19-
- 🛡️ **Respects `.gitignore`** for file discovery
20-
- 🔄 **Sync, update, status, and clear** commands
18+
- **Supports merging**: Supports merging with existing settings in .env files. Duplicate keys will be overwritten by the remote state
19+
- 📝 **Interactive CLI** for setup and management - Run `envsync --help` for available options
2120

2221
### Planned
2322

@@ -27,6 +26,22 @@
2726

2827
---
2928

29+
## Quickstart
30+
31+
1. Initialize new envsync config with `envsync init`
32+
2. Execute `envsync update` to push the configured `.env` files to the remote location
33+
3. Execute `envsync sync` anywhere you want to pull the current version from the remote location
34+
35+
### For syncing only
36+
37+
1. Execute `envsync sync`
38+
39+
⚠️ **Important**
40+
41+
- The preferred way of authenticating to remote storage (for example Azure Key Vault) should be an interactive login session with `az login` or `Connect-AzAccount`. Adding more env variables to authenticate to a service is not what we want to achieve.
42+
- Please cofigure permissions for reading and writing with your storage provider. For example in Azure you should only provide write permissions to people you want to update the .env files by assigning the respective RBAC (Role-Based Access Control) roles.
43+
- Remember that secrets stored in `.env` files are unecrypted and should only be for local services or extremely temporary. They cannot be recalled once they are on someones computer.
44+
3045
## Install
3146

3247
```bash

biome.jsonc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
33
"formatter": {
44
"enabled": true,
5-
"indentStyle": "space" // default is `tab`
5+
"indentStyle": "space"
66
},
77
"linter": {
88
"enabled": true,
@@ -24,11 +24,12 @@
2424
},
2525
"json": {
2626
"parser": {
27-
"allowComments": true,
27+
"allowComments": true
2828
}
2929
},
3030
"javascript": {
3131
"formatter": {
32+
"lineWidth": 100,
3233
"quoteStyle": "single",
3334
"semicolons": "asNeeded",
3435
"indentStyle": "space",

envsync.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"mergeEnvFiles": false,
3+
"recursive": true,
4+
"exclude": [
5+
"node_modules",
6+
"dist"
7+
],
8+
"backend": {
9+
"type": "local",
10+
"name": "local",
11+
"config": {}
12+
},
13+
"files": [
14+
{
15+
"name": ".env.test",
16+
"path": "test/.env.test",
17+
"extension": ".test"
18+
},
19+
{
20+
"name": ".env.test",
21+
"path": "test/packages/app21/.env.test",
22+
"extension": ".test"
23+
},
24+
{
25+
"name": ".env.test",
26+
"path": "test/packages/test/.env.test",
27+
"extension": ".test"
28+
}
29+
]
30+
}

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
"c12": "^3.0.4",
3838
"consola": "^3.4.2",
3939
"defu": "^6.1.4",
40+
"destr": "^2.0.5",
4041
"magicast": "^0.3.5",
4142
"ohash": "^2.0.11",
4243
"pathe": "^2.0.3",

pnpm-lock.yaml

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/config.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,15 @@ export const { config, configFile, layers } = await loadConfig<EnvsyncConfig>({
1919

2020
export const envsyncConfig = layers?.length ? config : undefined
2121

22-
export function verifyConfig(
23-
config: typeof envsyncConfig = envsyncConfig,
24-
): NonNullable<typeof envsyncConfig> {
22+
export function verifyConfig(config: typeof envsyncConfig = envsyncConfig): {
23+
config: NonNullable<typeof envsyncConfig>
24+
valid: boolean
25+
} {
2526
if (!config) {
26-
consola.error(
27-
'No configuration found. Please run init first or provide the required parameters.',
28-
)
29-
throw new Error('No configuration found.')
27+
consola.error('No configuration found. Please run init first.')
28+
return { config: {}, valid: false }
3029
}
31-
return config
30+
return { config, valid: true }
3231
}
3332
export function createEnvsyncConfig(config: EnvsyncConfig, pwd?: string) {
3433
const configPath = path.join(pwd ?? process.cwd(), 'envsync.json')

0 commit comments

Comments
 (0)