olly-molly 0.3.14 → 0.3.16
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/bin/cli.js +38 -0
- package/package.json +1 -1
package/bin/cli.js
CHANGED
|
@@ -88,6 +88,12 @@ ENVIRONMENT VARIABLES
|
|
|
88
88
|
OLLY_MOLLY_DATA_DIR App data directory (fallback)
|
|
89
89
|
OLLY_MOLLY_DB_PATH Database path (fallback)
|
|
90
90
|
|
|
91
|
+
You can also create ~/.olly-molly/.env file:
|
|
92
|
+
AWS_REGION=ap-northeast-2
|
|
93
|
+
AWS_ACCESS_KEY_ID=your-key
|
|
94
|
+
AWS_SECRET_ACCESS_KEY=your-secret
|
|
95
|
+
SES_FROM_EMAIL=noreply@example.com
|
|
96
|
+
|
|
91
97
|
EXAMPLES
|
|
92
98
|
olly-molly # Start with defaults
|
|
93
99
|
olly-molly -p 3000 # Use port 3000
|
|
@@ -108,12 +114,44 @@ if (args.version) {
|
|
|
108
114
|
process.exit(0);
|
|
109
115
|
}
|
|
110
116
|
|
|
117
|
+
// Load .env file from data directory
|
|
118
|
+
function loadEnvFile(dataDir) {
|
|
119
|
+
const envPath = path.join(dataDir, '.env');
|
|
120
|
+
if (!fs.existsSync(envPath)) return;
|
|
121
|
+
|
|
122
|
+
try {
|
|
123
|
+
const content = fs.readFileSync(envPath, 'utf8');
|
|
124
|
+
for (const line of content.split('\n')) {
|
|
125
|
+
const trimmed = line.trim();
|
|
126
|
+
if (!trimmed || trimmed.startsWith('#')) continue;
|
|
127
|
+
const eqIndex = trimmed.indexOf('=');
|
|
128
|
+
if (eqIndex === -1) continue;
|
|
129
|
+
const key = trimmed.slice(0, eqIndex).trim();
|
|
130
|
+
let value = trimmed.slice(eqIndex + 1).trim();
|
|
131
|
+
// Remove quotes if present
|
|
132
|
+
if ((value.startsWith('"') && value.endsWith('"')) ||
|
|
133
|
+
(value.startsWith("'") && value.endsWith("'"))) {
|
|
134
|
+
value = value.slice(1, -1);
|
|
135
|
+
}
|
|
136
|
+
// Only set if not already defined (CLI/system env takes priority)
|
|
137
|
+
if (!process.env[key]) {
|
|
138
|
+
process.env[key] = value;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
} catch (err) {
|
|
142
|
+
// Silently ignore read errors
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
111
146
|
// Configuration with priority: CLI args > env vars > defaults
|
|
112
147
|
function getConfig() {
|
|
113
148
|
const dataDir = args['data-dir']
|
|
114
149
|
|| process.env.OLLY_MOLLY_DATA_DIR
|
|
115
150
|
|| path.join(os.homedir(), '.olly-molly');
|
|
116
151
|
|
|
152
|
+
// Load .env from data directory
|
|
153
|
+
loadEnvFile(dataDir);
|
|
154
|
+
|
|
117
155
|
const port = args.port
|
|
118
156
|
|| process.env.OLLY_MOLLY_PORT
|
|
119
157
|
|| '1234';
|