composable.env 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/examples/fullstack/env/.env.local +18 -0
- package/examples/fullstack/env/.env.shared +19 -0
- package/examples/fullstack/env/components/auth.env +19 -0
- package/examples/fullstack/env/components/database.env +21 -0
- package/examples/fullstack/env/components/redis.env +22 -0
- package/examples/fullstack/env/components/storage.env +22 -0
- package/examples/fullstack/env/contracts/api.contract.ts +24 -0
- package/examples/fullstack/env/contracts/web.contract.ts +20 -0
- package/examples/fullstack/env/contracts/worker.contract.ts +28 -0
- package/examples/fullstack/env/profiles/default.json +5 -0
- package/examples/fullstack/env/profiles/development.json +7 -0
- package/examples/fullstack/env/profiles/production.json +4 -0
- package/examples/fullstack/env/profiles/staging.json +5 -0
- package/package.json +3 -2
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Personal overrides — DO NOT commit this file (gitignored)
|
|
2
|
+
# Applied last, overrides everything else
|
|
3
|
+
# Each developer can customize their local environment
|
|
4
|
+
|
|
5
|
+
# Use a custom local database port (e.g., if 5432 is taken)
|
|
6
|
+
DATABASE_PORT=5433
|
|
7
|
+
|
|
8
|
+
# Verbose logging during development
|
|
9
|
+
LOG_LEVEL=debug
|
|
10
|
+
|
|
11
|
+
# Point the web app at your local API
|
|
12
|
+
API_URL=http://localhost:4000
|
|
13
|
+
|
|
14
|
+
# Staging secrets (for testing against staging — get from team vault)
|
|
15
|
+
# DATABASE_STAGING_PASSWORD=ask-your-team-lead
|
|
16
|
+
# AUTH_STAGING_JWT_SECRET=ask-your-team-lead
|
|
17
|
+
# STORAGE_STAGING_ACCESS_KEY=ask-your-team-lead
|
|
18
|
+
# STORAGE_STAGING_SECRET_KEY=ask-your-team-lead
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Shared team values — commit this file to version control
|
|
2
|
+
# These are applied AFTER components, BEFORE .env.local
|
|
3
|
+
# No secrets here — use .env.local or a secrets manager for those
|
|
4
|
+
|
|
5
|
+
# Staging hosts
|
|
6
|
+
DATABASE_STAGING_HOST=db-staging.example.com
|
|
7
|
+
DATABASE_STAGING_USER=app_staging
|
|
8
|
+
REDIS_STAGING_HOST=redis-staging.example.com
|
|
9
|
+
STORAGE_STAGING_BUCKET=myapp-uploads-staging
|
|
10
|
+
|
|
11
|
+
# Production hosts
|
|
12
|
+
DATABASE_PROD_HOST=db.example.com
|
|
13
|
+
DATABASE_PROD_USER=app_prod
|
|
14
|
+
REDIS_PROD_HOST=redis.example.com
|
|
15
|
+
STORAGE_PROD_BUCKET=myapp-uploads-prod
|
|
16
|
+
|
|
17
|
+
# Shared across all environments
|
|
18
|
+
API_URL=http://localhost:4000
|
|
19
|
+
APP_NAME=MyApp
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
NAMESPACE=AUTH
|
|
2
|
+
|
|
3
|
+
[default]
|
|
4
|
+
JWT_SECRET=dev-secret-change-me
|
|
5
|
+
JWT_EXPIRES_IN=7d
|
|
6
|
+
BCRYPT_ROUNDS=10
|
|
7
|
+
SESSION_TTL=86400
|
|
8
|
+
|
|
9
|
+
[staging]
|
|
10
|
+
JWT_SECRET=${AUTH_STAGING_JWT_SECRET}
|
|
11
|
+
JWT_EXPIRES_IN=1d
|
|
12
|
+
BCRYPT_ROUNDS=12
|
|
13
|
+
SESSION_TTL=3600
|
|
14
|
+
|
|
15
|
+
[production]
|
|
16
|
+
JWT_SECRET=${AUTH_PROD_JWT_SECRET}
|
|
17
|
+
JWT_EXPIRES_IN=1d
|
|
18
|
+
BCRYPT_ROUNDS=14
|
|
19
|
+
SESSION_TTL=3600
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
NAMESPACE=DATABASE
|
|
2
|
+
|
|
3
|
+
[default]
|
|
4
|
+
HOST=localhost
|
|
5
|
+
PORT=5432
|
|
6
|
+
NAME=myapp_dev
|
|
7
|
+
USER=postgres
|
|
8
|
+
PASSWORD=postgres
|
|
9
|
+
|
|
10
|
+
[staging]
|
|
11
|
+
HOST=${DATABASE_STAGING_HOST}
|
|
12
|
+
NAME=myapp_staging
|
|
13
|
+
USER=${DATABASE_STAGING_USER}
|
|
14
|
+
PASSWORD=${DATABASE_STAGING_PASSWORD}
|
|
15
|
+
|
|
16
|
+
[production]
|
|
17
|
+
HOST=${DATABASE_PROD_HOST}
|
|
18
|
+
PORT=5432
|
|
19
|
+
NAME=myapp
|
|
20
|
+
USER=${DATABASE_PROD_USER}
|
|
21
|
+
PASSWORD=${DATABASE_PROD_PASSWORD}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
NAMESPACE=REDIS
|
|
2
|
+
|
|
3
|
+
[default]
|
|
4
|
+
HOST=localhost
|
|
5
|
+
PORT=6379
|
|
6
|
+
URL=redis://localhost:6379
|
|
7
|
+
DB=0
|
|
8
|
+
|
|
9
|
+
[staging]
|
|
10
|
+
HOST=${REDIS_STAGING_HOST}
|
|
11
|
+
PORT=6379
|
|
12
|
+
URL=redis://${REDIS_STAGING_HOST}:6379
|
|
13
|
+
DB=0
|
|
14
|
+
|
|
15
|
+
[development]
|
|
16
|
+
DB=1
|
|
17
|
+
|
|
18
|
+
[production]
|
|
19
|
+
HOST=${REDIS_PROD_HOST}
|
|
20
|
+
PORT=6379
|
|
21
|
+
URL=redis://${REDIS_PROD_HOST}:6379
|
|
22
|
+
DB=0
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
NAMESPACE=STORAGE
|
|
2
|
+
|
|
3
|
+
[default]
|
|
4
|
+
PROVIDER=local
|
|
5
|
+
LOCAL_PATH=./uploads
|
|
6
|
+
MAX_FILE_SIZE=10485760
|
|
7
|
+
|
|
8
|
+
[staging]
|
|
9
|
+
PROVIDER=s3
|
|
10
|
+
S3_BUCKET=${STORAGE_STAGING_BUCKET}
|
|
11
|
+
S3_REGION=us-east-1
|
|
12
|
+
S3_ACCESS_KEY=${STORAGE_STAGING_ACCESS_KEY}
|
|
13
|
+
S3_SECRET_KEY=${STORAGE_STAGING_SECRET_KEY}
|
|
14
|
+
MAX_FILE_SIZE=52428800
|
|
15
|
+
|
|
16
|
+
[production]
|
|
17
|
+
PROVIDER=s3
|
|
18
|
+
S3_BUCKET=${STORAGE_PROD_BUCKET}
|
|
19
|
+
S3_REGION=us-east-1
|
|
20
|
+
S3_ACCESS_KEY=${STORAGE_PROD_ACCESS_KEY}
|
|
21
|
+
S3_SECRET_KEY=${STORAGE_PROD_SECRET_KEY}
|
|
22
|
+
MAX_FILE_SIZE=104857600
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { ServiceContract } from 'composable.env';
|
|
2
|
+
|
|
3
|
+
export const ApiContract: ServiceContract = {
|
|
4
|
+
name: 'api',
|
|
5
|
+
location: 'apps/api',
|
|
6
|
+
|
|
7
|
+
// Template mappings — compose variables into connection strings
|
|
8
|
+
required: {
|
|
9
|
+
DATABASE_URL: 'postgresql://${DATABASE_USER}:${DATABASE_PASSWORD}@${DATABASE_HOST}:${DATABASE_PORT}/${DATABASE_NAME}',
|
|
10
|
+
REDIS_URL: 'REDIS_URL',
|
|
11
|
+
JWT_SECRET: 'AUTH_JWT_SECRET',
|
|
12
|
+
},
|
|
13
|
+
|
|
14
|
+
// Optional vars with fallback defaults
|
|
15
|
+
optional: {
|
|
16
|
+
LOG_LEVEL: 'LOG_LEVEL',
|
|
17
|
+
CORS_ORIGIN: 'CORS_ORIGIN',
|
|
18
|
+
},
|
|
19
|
+
|
|
20
|
+
defaults: {
|
|
21
|
+
LOG_LEVEL: 'info',
|
|
22
|
+
CORS_ORIGIN: 'http://localhost:3000',
|
|
23
|
+
},
|
|
24
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { ServiceContract } from 'composable.env';
|
|
2
|
+
|
|
3
|
+
export const WebContract: ServiceContract = {
|
|
4
|
+
name: 'web',
|
|
5
|
+
location: 'apps/web',
|
|
6
|
+
|
|
7
|
+
required: {
|
|
8
|
+
NEXT_PUBLIC_API_URL: 'API_URL',
|
|
9
|
+
},
|
|
10
|
+
|
|
11
|
+
optional: {
|
|
12
|
+
NEXT_PUBLIC_APP_NAME: 'APP_NAME',
|
|
13
|
+
NEXT_PUBLIC_SESSION_TTL: 'AUTH_SESSION_TTL',
|
|
14
|
+
},
|
|
15
|
+
|
|
16
|
+
defaults: {
|
|
17
|
+
NEXT_PUBLIC_API_URL: 'http://localhost:4000',
|
|
18
|
+
NEXT_PUBLIC_APP_NAME: 'MyApp',
|
|
19
|
+
},
|
|
20
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { ServiceContract } from 'composable.env';
|
|
2
|
+
|
|
3
|
+
export const WorkerContract: ServiceContract = {
|
|
4
|
+
name: 'worker',
|
|
5
|
+
location: 'apps/worker',
|
|
6
|
+
|
|
7
|
+
required: {
|
|
8
|
+
DATABASE_URL: 'postgresql://${DATABASE_USER}:${DATABASE_PASSWORD}@${DATABASE_HOST}:${DATABASE_PORT}/${DATABASE_NAME}',
|
|
9
|
+
REDIS_URL: 'REDIS_URL',
|
|
10
|
+
},
|
|
11
|
+
|
|
12
|
+
// Secret vars — validated the same as required, but semantically separated
|
|
13
|
+
secret: {
|
|
14
|
+
STORAGE_ACCESS_KEY: 'STORAGE_S3_ACCESS_KEY',
|
|
15
|
+
STORAGE_SECRET_KEY: 'STORAGE_S3_SECRET_KEY',
|
|
16
|
+
},
|
|
17
|
+
|
|
18
|
+
optional: {
|
|
19
|
+
STORAGE_BUCKET: 'STORAGE_S3_BUCKET',
|
|
20
|
+
STORAGE_REGION: 'STORAGE_S3_REGION',
|
|
21
|
+
MAX_FILE_SIZE: 'STORAGE_MAX_FILE_SIZE',
|
|
22
|
+
},
|
|
23
|
+
|
|
24
|
+
defaults: {
|
|
25
|
+
STORAGE_REGION: 'us-east-1',
|
|
26
|
+
MAX_FILE_SIZE: '10485760',
|
|
27
|
+
},
|
|
28
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "composable.env",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Composable environment management: build .env files for every service from reusable components, profiles, and contracts.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/src/index.js",
|
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
"cenv": "dist/cli/index.js"
|
|
10
10
|
},
|
|
11
11
|
"files": [
|
|
12
|
-
"dist/"
|
|
12
|
+
"dist/",
|
|
13
|
+
"examples/"
|
|
13
14
|
],
|
|
14
15
|
"scripts": {
|
|
15
16
|
"build": "tsc",
|