postgresdk 0.1.2-alpha.0 → 0.1.2-alpha.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/README.md +27 -1
- package/dist/cli.d.ts +1 -1
- package/dist/cli.js +462 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +462 -0
- package/package.json +4 -3
package/README.md
CHANGED
@@ -230,7 +230,33 @@ export default {
|
|
230
230
|
};
|
231
231
|
```
|
232
232
|
|
233
|
-
Environment variables work directly in the config file - no function wrapper needed.
|
233
|
+
Environment variables work directly in the config file - no function wrapper needed. postgresdk automatically loads `.env` files using dotenv.
|
234
|
+
|
235
|
+
### Environment Variables
|
236
|
+
|
237
|
+
postgresdk automatically loads environment variables from `.env` files in your project root. You can use them directly in your config:
|
238
|
+
|
239
|
+
```bash
|
240
|
+
# .env
|
241
|
+
DATABASE_URL=postgres://user:pass@localhost:5432/mydb
|
242
|
+
JWT_SECRET=my-super-secret-key
|
243
|
+
API_KEYS=key1,key2,key3
|
244
|
+
```
|
245
|
+
|
246
|
+
```typescript
|
247
|
+
// postgresdk.config.ts
|
248
|
+
export default {
|
249
|
+
connectionString: process.env.DATABASE_URL,
|
250
|
+
auth: {
|
251
|
+
strategy: "jwt-hs256",
|
252
|
+
jwt: {
|
253
|
+
sharedSecret: process.env.JWT_SECRET,
|
254
|
+
}
|
255
|
+
}
|
256
|
+
};
|
257
|
+
```
|
258
|
+
|
259
|
+
No additional setup required - dotenv is automatically configured before loading your config file.
|
234
260
|
|
235
261
|
## Generated SDK Features
|
236
262
|
|
package/dist/cli.d.ts
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
#!/usr/bin/env node
|
2
|
-
|
2
|
+
import "dotenv/config";
|
package/dist/cli.js
CHANGED
@@ -1,6 +1,467 @@
|
|
1
1
|
#!/usr/bin/env node
|
2
|
+
import { createRequire } from "node:module";
|
3
|
+
var __create = Object.create;
|
4
|
+
var __getProtoOf = Object.getPrototypeOf;
|
5
|
+
var __defProp = Object.defineProperty;
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
8
|
+
var __toESM = (mod, isNodeMode, target) => {
|
9
|
+
target = mod != null ? __create(__getProtoOf(mod)) : {};
|
10
|
+
const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
11
|
+
for (let key of __getOwnPropNames(mod))
|
12
|
+
if (!__hasOwnProp.call(to, key))
|
13
|
+
__defProp(to, key, {
|
14
|
+
get: () => mod[key],
|
15
|
+
enumerable: true
|
16
|
+
});
|
17
|
+
return to;
|
18
|
+
};
|
19
|
+
var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
20
|
+
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
21
|
+
|
22
|
+
// node_modules/dotenv/package.json
|
23
|
+
var require_package = __commonJS((exports, module) => {
|
24
|
+
module.exports = {
|
25
|
+
name: "dotenv",
|
26
|
+
version: "17.2.1",
|
27
|
+
description: "Loads environment variables from .env file",
|
28
|
+
main: "lib/main.js",
|
29
|
+
types: "lib/main.d.ts",
|
30
|
+
exports: {
|
31
|
+
".": {
|
32
|
+
types: "./lib/main.d.ts",
|
33
|
+
require: "./lib/main.js",
|
34
|
+
default: "./lib/main.js"
|
35
|
+
},
|
36
|
+
"./config": "./config.js",
|
37
|
+
"./config.js": "./config.js",
|
38
|
+
"./lib/env-options": "./lib/env-options.js",
|
39
|
+
"./lib/env-options.js": "./lib/env-options.js",
|
40
|
+
"./lib/cli-options": "./lib/cli-options.js",
|
41
|
+
"./lib/cli-options.js": "./lib/cli-options.js",
|
42
|
+
"./package.json": "./package.json"
|
43
|
+
},
|
44
|
+
scripts: {
|
45
|
+
"dts-check": "tsc --project tests/types/tsconfig.json",
|
46
|
+
lint: "standard",
|
47
|
+
pretest: "npm run lint && npm run dts-check",
|
48
|
+
test: "tap run --allow-empty-coverage --disable-coverage --timeout=60000",
|
49
|
+
"test:coverage": "tap run --show-full-coverage --timeout=60000 --coverage-report=text --coverage-report=lcov",
|
50
|
+
prerelease: "npm test",
|
51
|
+
release: "standard-version"
|
52
|
+
},
|
53
|
+
repository: {
|
54
|
+
type: "git",
|
55
|
+
url: "git://github.com/motdotla/dotenv.git"
|
56
|
+
},
|
57
|
+
homepage: "https://github.com/motdotla/dotenv#readme",
|
58
|
+
funding: "https://dotenvx.com",
|
59
|
+
keywords: [
|
60
|
+
"dotenv",
|
61
|
+
"env",
|
62
|
+
".env",
|
63
|
+
"environment",
|
64
|
+
"variables",
|
65
|
+
"config",
|
66
|
+
"settings"
|
67
|
+
],
|
68
|
+
readmeFilename: "README.md",
|
69
|
+
license: "BSD-2-Clause",
|
70
|
+
devDependencies: {
|
71
|
+
"@types/node": "^18.11.3",
|
72
|
+
decache: "^4.6.2",
|
73
|
+
sinon: "^14.0.1",
|
74
|
+
standard: "^17.0.0",
|
75
|
+
"standard-version": "^9.5.0",
|
76
|
+
tap: "^19.2.0",
|
77
|
+
typescript: "^4.8.4"
|
78
|
+
},
|
79
|
+
engines: {
|
80
|
+
node: ">=12"
|
81
|
+
},
|
82
|
+
browser: {
|
83
|
+
fs: false
|
84
|
+
}
|
85
|
+
};
|
86
|
+
});
|
87
|
+
|
88
|
+
// node_modules/dotenv/lib/main.js
|
89
|
+
var require_main = __commonJS((exports, module) => {
|
90
|
+
var fs = __require("fs");
|
91
|
+
var path = __require("path");
|
92
|
+
var os = __require("os");
|
93
|
+
var crypto = __require("crypto");
|
94
|
+
var packageJson = require_package();
|
95
|
+
var version = packageJson.version;
|
96
|
+
var TIPS = [
|
97
|
+
"\uD83D\uDD10 encrypt with Dotenvx: https://dotenvx.com",
|
98
|
+
"\uD83D\uDD10 prevent committing .env to code: https://dotenvx.com/precommit",
|
99
|
+
"\uD83D\uDD10 prevent building .env in docker: https://dotenvx.com/prebuild",
|
100
|
+
"\uD83D\uDCE1 observe env with Radar: https://dotenvx.com/radar",
|
101
|
+
"\uD83D\uDCE1 auto-backup env with Radar: https://dotenvx.com/radar",
|
102
|
+
"\uD83D\uDCE1 version env with Radar: https://dotenvx.com/radar",
|
103
|
+
"\uD83D\uDEE0️ run anywhere with `dotenvx run -- yourcommand`",
|
104
|
+
"⚙️ specify custom .env file path with { path: '/custom/path/.env' }",
|
105
|
+
"⚙️ enable debug logging with { debug: true }",
|
106
|
+
"⚙️ override existing env vars with { override: true }",
|
107
|
+
"⚙️ suppress all logs with { quiet: true }",
|
108
|
+
"⚙️ write to custom object with { processEnv: myObject }",
|
109
|
+
"⚙️ load multiple .env files with { path: ['.env.local', '.env'] }"
|
110
|
+
];
|
111
|
+
function _getRandomTip() {
|
112
|
+
return TIPS[Math.floor(Math.random() * TIPS.length)];
|
113
|
+
}
|
114
|
+
function parseBoolean(value) {
|
115
|
+
if (typeof value === "string") {
|
116
|
+
return !["false", "0", "no", "off", ""].includes(value.toLowerCase());
|
117
|
+
}
|
118
|
+
return Boolean(value);
|
119
|
+
}
|
120
|
+
function supportsAnsi() {
|
121
|
+
return process.stdout.isTTY;
|
122
|
+
}
|
123
|
+
function dim(text) {
|
124
|
+
return supportsAnsi() ? `\x1B[2m${text}\x1B[0m` : text;
|
125
|
+
}
|
126
|
+
var LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg;
|
127
|
+
function parse(src) {
|
128
|
+
const obj = {};
|
129
|
+
let lines = src.toString();
|
130
|
+
lines = lines.replace(/\r\n?/mg, `
|
131
|
+
`);
|
132
|
+
let match;
|
133
|
+
while ((match = LINE.exec(lines)) != null) {
|
134
|
+
const key = match[1];
|
135
|
+
let value = match[2] || "";
|
136
|
+
value = value.trim();
|
137
|
+
const maybeQuote = value[0];
|
138
|
+
value = value.replace(/^(['"`])([\s\S]*)\1$/mg, "$2");
|
139
|
+
if (maybeQuote === '"') {
|
140
|
+
value = value.replace(/\\n/g, `
|
141
|
+
`);
|
142
|
+
value = value.replace(/\\r/g, "\r");
|
143
|
+
}
|
144
|
+
obj[key] = value;
|
145
|
+
}
|
146
|
+
return obj;
|
147
|
+
}
|
148
|
+
function _parseVault(options) {
|
149
|
+
options = options || {};
|
150
|
+
const vaultPath = _vaultPath(options);
|
151
|
+
options.path = vaultPath;
|
152
|
+
const result = DotenvModule.configDotenv(options);
|
153
|
+
if (!result.parsed) {
|
154
|
+
const err = new Error(`MISSING_DATA: Cannot parse ${vaultPath} for an unknown reason`);
|
155
|
+
err.code = "MISSING_DATA";
|
156
|
+
throw err;
|
157
|
+
}
|
158
|
+
const keys = _dotenvKey(options).split(",");
|
159
|
+
const length = keys.length;
|
160
|
+
let decrypted;
|
161
|
+
for (let i = 0;i < length; i++) {
|
162
|
+
try {
|
163
|
+
const key = keys[i].trim();
|
164
|
+
const attrs = _instructions(result, key);
|
165
|
+
decrypted = DotenvModule.decrypt(attrs.ciphertext, attrs.key);
|
166
|
+
break;
|
167
|
+
} catch (error) {
|
168
|
+
if (i + 1 >= length) {
|
169
|
+
throw error;
|
170
|
+
}
|
171
|
+
}
|
172
|
+
}
|
173
|
+
return DotenvModule.parse(decrypted);
|
174
|
+
}
|
175
|
+
function _warn(message) {
|
176
|
+
console.error(`[dotenv@${version}][WARN] ${message}`);
|
177
|
+
}
|
178
|
+
function _debug(message) {
|
179
|
+
console.log(`[dotenv@${version}][DEBUG] ${message}`);
|
180
|
+
}
|
181
|
+
function _log(message) {
|
182
|
+
console.log(`[dotenv@${version}] ${message}`);
|
183
|
+
}
|
184
|
+
function _dotenvKey(options) {
|
185
|
+
if (options && options.DOTENV_KEY && options.DOTENV_KEY.length > 0) {
|
186
|
+
return options.DOTENV_KEY;
|
187
|
+
}
|
188
|
+
if (process.env.DOTENV_KEY && process.env.DOTENV_KEY.length > 0) {
|
189
|
+
return process.env.DOTENV_KEY;
|
190
|
+
}
|
191
|
+
return "";
|
192
|
+
}
|
193
|
+
function _instructions(result, dotenvKey) {
|
194
|
+
let uri;
|
195
|
+
try {
|
196
|
+
uri = new URL(dotenvKey);
|
197
|
+
} catch (error) {
|
198
|
+
if (error.code === "ERR_INVALID_URL") {
|
199
|
+
const err = new Error("INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=development");
|
200
|
+
err.code = "INVALID_DOTENV_KEY";
|
201
|
+
throw err;
|
202
|
+
}
|
203
|
+
throw error;
|
204
|
+
}
|
205
|
+
const key = uri.password;
|
206
|
+
if (!key) {
|
207
|
+
const err = new Error("INVALID_DOTENV_KEY: Missing key part");
|
208
|
+
err.code = "INVALID_DOTENV_KEY";
|
209
|
+
throw err;
|
210
|
+
}
|
211
|
+
const environment = uri.searchParams.get("environment");
|
212
|
+
if (!environment) {
|
213
|
+
const err = new Error("INVALID_DOTENV_KEY: Missing environment part");
|
214
|
+
err.code = "INVALID_DOTENV_KEY";
|
215
|
+
throw err;
|
216
|
+
}
|
217
|
+
const environmentKey = `DOTENV_VAULT_${environment.toUpperCase()}`;
|
218
|
+
const ciphertext = result.parsed[environmentKey];
|
219
|
+
if (!ciphertext) {
|
220
|
+
const err = new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${environmentKey} in your .env.vault file.`);
|
221
|
+
err.code = "NOT_FOUND_DOTENV_ENVIRONMENT";
|
222
|
+
throw err;
|
223
|
+
}
|
224
|
+
return { ciphertext, key };
|
225
|
+
}
|
226
|
+
function _vaultPath(options) {
|
227
|
+
let possibleVaultPath = null;
|
228
|
+
if (options && options.path && options.path.length > 0) {
|
229
|
+
if (Array.isArray(options.path)) {
|
230
|
+
for (const filepath of options.path) {
|
231
|
+
if (fs.existsSync(filepath)) {
|
232
|
+
possibleVaultPath = filepath.endsWith(".vault") ? filepath : `${filepath}.vault`;
|
233
|
+
}
|
234
|
+
}
|
235
|
+
} else {
|
236
|
+
possibleVaultPath = options.path.endsWith(".vault") ? options.path : `${options.path}.vault`;
|
237
|
+
}
|
238
|
+
} else {
|
239
|
+
possibleVaultPath = path.resolve(process.cwd(), ".env.vault");
|
240
|
+
}
|
241
|
+
if (fs.existsSync(possibleVaultPath)) {
|
242
|
+
return possibleVaultPath;
|
243
|
+
}
|
244
|
+
return null;
|
245
|
+
}
|
246
|
+
function _resolveHome(envPath) {
|
247
|
+
return envPath[0] === "~" ? path.join(os.homedir(), envPath.slice(1)) : envPath;
|
248
|
+
}
|
249
|
+
function _configVault(options) {
|
250
|
+
const debug = parseBoolean(process.env.DOTENV_CONFIG_DEBUG || options && options.debug);
|
251
|
+
const quiet = parseBoolean(process.env.DOTENV_CONFIG_QUIET || options && options.quiet);
|
252
|
+
if (debug || !quiet) {
|
253
|
+
_log("Loading env from encrypted .env.vault");
|
254
|
+
}
|
255
|
+
const parsed = DotenvModule._parseVault(options);
|
256
|
+
let processEnv = process.env;
|
257
|
+
if (options && options.processEnv != null) {
|
258
|
+
processEnv = options.processEnv;
|
259
|
+
}
|
260
|
+
DotenvModule.populate(processEnv, parsed, options);
|
261
|
+
return { parsed };
|
262
|
+
}
|
263
|
+
function configDotenv(options) {
|
264
|
+
const dotenvPath = path.resolve(process.cwd(), ".env");
|
265
|
+
let encoding = "utf8";
|
266
|
+
let processEnv = process.env;
|
267
|
+
if (options && options.processEnv != null) {
|
268
|
+
processEnv = options.processEnv;
|
269
|
+
}
|
270
|
+
let debug = parseBoolean(processEnv.DOTENV_CONFIG_DEBUG || options && options.debug);
|
271
|
+
let quiet = parseBoolean(processEnv.DOTENV_CONFIG_QUIET || options && options.quiet);
|
272
|
+
if (options && options.encoding) {
|
273
|
+
encoding = options.encoding;
|
274
|
+
} else {
|
275
|
+
if (debug) {
|
276
|
+
_debug("No encoding is specified. UTF-8 is used by default");
|
277
|
+
}
|
278
|
+
}
|
279
|
+
let optionPaths = [dotenvPath];
|
280
|
+
if (options && options.path) {
|
281
|
+
if (!Array.isArray(options.path)) {
|
282
|
+
optionPaths = [_resolveHome(options.path)];
|
283
|
+
} else {
|
284
|
+
optionPaths = [];
|
285
|
+
for (const filepath of options.path) {
|
286
|
+
optionPaths.push(_resolveHome(filepath));
|
287
|
+
}
|
288
|
+
}
|
289
|
+
}
|
290
|
+
let lastError;
|
291
|
+
const parsedAll = {};
|
292
|
+
for (const path2 of optionPaths) {
|
293
|
+
try {
|
294
|
+
const parsed = DotenvModule.parse(fs.readFileSync(path2, { encoding }));
|
295
|
+
DotenvModule.populate(parsedAll, parsed, options);
|
296
|
+
} catch (e) {
|
297
|
+
if (debug) {
|
298
|
+
_debug(`Failed to load ${path2} ${e.message}`);
|
299
|
+
}
|
300
|
+
lastError = e;
|
301
|
+
}
|
302
|
+
}
|
303
|
+
const populated = DotenvModule.populate(processEnv, parsedAll, options);
|
304
|
+
debug = parseBoolean(processEnv.DOTENV_CONFIG_DEBUG || debug);
|
305
|
+
quiet = parseBoolean(processEnv.DOTENV_CONFIG_QUIET || quiet);
|
306
|
+
if (debug || !quiet) {
|
307
|
+
const keysCount = Object.keys(populated).length;
|
308
|
+
const shortPaths = [];
|
309
|
+
for (const filePath of optionPaths) {
|
310
|
+
try {
|
311
|
+
const relative = path.relative(process.cwd(), filePath);
|
312
|
+
shortPaths.push(relative);
|
313
|
+
} catch (e) {
|
314
|
+
if (debug) {
|
315
|
+
_debug(`Failed to load ${filePath} ${e.message}`);
|
316
|
+
}
|
317
|
+
lastError = e;
|
318
|
+
}
|
319
|
+
}
|
320
|
+
_log(`injecting env (${keysCount}) from ${shortPaths.join(",")} ${dim(`-- tip: ${_getRandomTip()}`)}`);
|
321
|
+
}
|
322
|
+
if (lastError) {
|
323
|
+
return { parsed: parsedAll, error: lastError };
|
324
|
+
} else {
|
325
|
+
return { parsed: parsedAll };
|
326
|
+
}
|
327
|
+
}
|
328
|
+
function config(options) {
|
329
|
+
if (_dotenvKey(options).length === 0) {
|
330
|
+
return DotenvModule.configDotenv(options);
|
331
|
+
}
|
332
|
+
const vaultPath = _vaultPath(options);
|
333
|
+
if (!vaultPath) {
|
334
|
+
_warn(`You set DOTENV_KEY but you are missing a .env.vault file at ${vaultPath}. Did you forget to build it?`);
|
335
|
+
return DotenvModule.configDotenv(options);
|
336
|
+
}
|
337
|
+
return DotenvModule._configVault(options);
|
338
|
+
}
|
339
|
+
function decrypt(encrypted, keyStr) {
|
340
|
+
const key = Buffer.from(keyStr.slice(-64), "hex");
|
341
|
+
let ciphertext = Buffer.from(encrypted, "base64");
|
342
|
+
const nonce = ciphertext.subarray(0, 12);
|
343
|
+
const authTag = ciphertext.subarray(-16);
|
344
|
+
ciphertext = ciphertext.subarray(12, -16);
|
345
|
+
try {
|
346
|
+
const aesgcm = crypto.createDecipheriv("aes-256-gcm", key, nonce);
|
347
|
+
aesgcm.setAuthTag(authTag);
|
348
|
+
return `${aesgcm.update(ciphertext)}${aesgcm.final()}`;
|
349
|
+
} catch (error) {
|
350
|
+
const isRange = error instanceof RangeError;
|
351
|
+
const invalidKeyLength = error.message === "Invalid key length";
|
352
|
+
const decryptionFailed = error.message === "Unsupported state or unable to authenticate data";
|
353
|
+
if (isRange || invalidKeyLength) {
|
354
|
+
const err = new Error("INVALID_DOTENV_KEY: It must be 64 characters long (or more)");
|
355
|
+
err.code = "INVALID_DOTENV_KEY";
|
356
|
+
throw err;
|
357
|
+
} else if (decryptionFailed) {
|
358
|
+
const err = new Error("DECRYPTION_FAILED: Please check your DOTENV_KEY");
|
359
|
+
err.code = "DECRYPTION_FAILED";
|
360
|
+
throw err;
|
361
|
+
} else {
|
362
|
+
throw error;
|
363
|
+
}
|
364
|
+
}
|
365
|
+
}
|
366
|
+
function populate(processEnv, parsed, options = {}) {
|
367
|
+
const debug = Boolean(options && options.debug);
|
368
|
+
const override = Boolean(options && options.override);
|
369
|
+
const populated = {};
|
370
|
+
if (typeof parsed !== "object") {
|
371
|
+
const err = new Error("OBJECT_REQUIRED: Please check the processEnv argument being passed to populate");
|
372
|
+
err.code = "OBJECT_REQUIRED";
|
373
|
+
throw err;
|
374
|
+
}
|
375
|
+
for (const key of Object.keys(parsed)) {
|
376
|
+
if (Object.prototype.hasOwnProperty.call(processEnv, key)) {
|
377
|
+
if (override === true) {
|
378
|
+
processEnv[key] = parsed[key];
|
379
|
+
populated[key] = parsed[key];
|
380
|
+
}
|
381
|
+
if (debug) {
|
382
|
+
if (override === true) {
|
383
|
+
_debug(`"${key}" is already defined and WAS overwritten`);
|
384
|
+
} else {
|
385
|
+
_debug(`"${key}" is already defined and was NOT overwritten`);
|
386
|
+
}
|
387
|
+
}
|
388
|
+
} else {
|
389
|
+
processEnv[key] = parsed[key];
|
390
|
+
populated[key] = parsed[key];
|
391
|
+
}
|
392
|
+
}
|
393
|
+
return populated;
|
394
|
+
}
|
395
|
+
var DotenvModule = {
|
396
|
+
configDotenv,
|
397
|
+
_configVault,
|
398
|
+
_parseVault,
|
399
|
+
config,
|
400
|
+
decrypt,
|
401
|
+
parse,
|
402
|
+
populate
|
403
|
+
};
|
404
|
+
exports.configDotenv = DotenvModule.configDotenv;
|
405
|
+
exports._configVault = DotenvModule._configVault;
|
406
|
+
exports._parseVault = DotenvModule._parseVault;
|
407
|
+
exports.config = DotenvModule.config;
|
408
|
+
exports.decrypt = DotenvModule.decrypt;
|
409
|
+
exports.parse = DotenvModule.parse;
|
410
|
+
exports.populate = DotenvModule.populate;
|
411
|
+
module.exports = DotenvModule;
|
412
|
+
});
|
413
|
+
|
414
|
+
// node_modules/dotenv/lib/env-options.js
|
415
|
+
var require_env_options = __commonJS((exports, module) => {
|
416
|
+
var options = {};
|
417
|
+
if (process.env.DOTENV_CONFIG_ENCODING != null) {
|
418
|
+
options.encoding = process.env.DOTENV_CONFIG_ENCODING;
|
419
|
+
}
|
420
|
+
if (process.env.DOTENV_CONFIG_PATH != null) {
|
421
|
+
options.path = process.env.DOTENV_CONFIG_PATH;
|
422
|
+
}
|
423
|
+
if (process.env.DOTENV_CONFIG_QUIET != null) {
|
424
|
+
options.quiet = process.env.DOTENV_CONFIG_QUIET;
|
425
|
+
}
|
426
|
+
if (process.env.DOTENV_CONFIG_DEBUG != null) {
|
427
|
+
options.debug = process.env.DOTENV_CONFIG_DEBUG;
|
428
|
+
}
|
429
|
+
if (process.env.DOTENV_CONFIG_OVERRIDE != null) {
|
430
|
+
options.override = process.env.DOTENV_CONFIG_OVERRIDE;
|
431
|
+
}
|
432
|
+
if (process.env.DOTENV_CONFIG_DOTENV_KEY != null) {
|
433
|
+
options.DOTENV_KEY = process.env.DOTENV_CONFIG_DOTENV_KEY;
|
434
|
+
}
|
435
|
+
module.exports = options;
|
436
|
+
});
|
437
|
+
|
438
|
+
// node_modules/dotenv/lib/cli-options.js
|
439
|
+
var require_cli_options = __commonJS((exports, module) => {
|
440
|
+
var re = /^dotenv_config_(encoding|path|quiet|debug|override|DOTENV_KEY)=(.+)$/;
|
441
|
+
module.exports = function optionMatcher(args) {
|
442
|
+
const options = args.reduce(function(acc, cur) {
|
443
|
+
const matches = cur.match(re);
|
444
|
+
if (matches) {
|
445
|
+
acc[matches[1]] = matches[2];
|
446
|
+
}
|
447
|
+
return acc;
|
448
|
+
}, {});
|
449
|
+
if (!("quiet" in options)) {
|
450
|
+
options.quiet = "true";
|
451
|
+
}
|
452
|
+
return options;
|
453
|
+
};
|
454
|
+
});
|
455
|
+
|
456
|
+
// node_modules/dotenv/config.js
|
457
|
+
var require_config = __commonJS(() => {
|
458
|
+
(function() {
|
459
|
+
require_main().config(Object.assign({}, require_env_options(), require_cli_options()(process.argv)));
|
460
|
+
})();
|
461
|
+
});
|
2
462
|
|
3
463
|
// src/index.ts
|
464
|
+
var import_config = __toESM(require_config(), 1);
|
4
465
|
import { join } from "node:path";
|
5
466
|
import { pathToFileURL } from "node:url";
|
6
467
|
|
@@ -1353,6 +1814,7 @@ async function generate(configPath) {
|
|
1353
1814
|
}
|
1354
1815
|
|
1355
1816
|
// src/cli.ts
|
1817
|
+
var import_config2 = __toESM(require_config(), 1);
|
1356
1818
|
import { resolve } from "node:path";
|
1357
1819
|
import { readFileSync } from "node:fs";
|
1358
1820
|
import { fileURLToPath } from "node:url";
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
@@ -1,4 +1,466 @@
|
|
1
|
+
import { createRequire } from "node:module";
|
2
|
+
var __create = Object.create;
|
3
|
+
var __getProtoOf = Object.getPrototypeOf;
|
4
|
+
var __defProp = Object.defineProperty;
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
7
|
+
var __toESM = (mod, isNodeMode, target) => {
|
8
|
+
target = mod != null ? __create(__getProtoOf(mod)) : {};
|
9
|
+
const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
10
|
+
for (let key of __getOwnPropNames(mod))
|
11
|
+
if (!__hasOwnProp.call(to, key))
|
12
|
+
__defProp(to, key, {
|
13
|
+
get: () => mod[key],
|
14
|
+
enumerable: true
|
15
|
+
});
|
16
|
+
return to;
|
17
|
+
};
|
18
|
+
var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
19
|
+
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
20
|
+
|
21
|
+
// node_modules/dotenv/package.json
|
22
|
+
var require_package = __commonJS((exports, module) => {
|
23
|
+
module.exports = {
|
24
|
+
name: "dotenv",
|
25
|
+
version: "17.2.1",
|
26
|
+
description: "Loads environment variables from .env file",
|
27
|
+
main: "lib/main.js",
|
28
|
+
types: "lib/main.d.ts",
|
29
|
+
exports: {
|
30
|
+
".": {
|
31
|
+
types: "./lib/main.d.ts",
|
32
|
+
require: "./lib/main.js",
|
33
|
+
default: "./lib/main.js"
|
34
|
+
},
|
35
|
+
"./config": "./config.js",
|
36
|
+
"./config.js": "./config.js",
|
37
|
+
"./lib/env-options": "./lib/env-options.js",
|
38
|
+
"./lib/env-options.js": "./lib/env-options.js",
|
39
|
+
"./lib/cli-options": "./lib/cli-options.js",
|
40
|
+
"./lib/cli-options.js": "./lib/cli-options.js",
|
41
|
+
"./package.json": "./package.json"
|
42
|
+
},
|
43
|
+
scripts: {
|
44
|
+
"dts-check": "tsc --project tests/types/tsconfig.json",
|
45
|
+
lint: "standard",
|
46
|
+
pretest: "npm run lint && npm run dts-check",
|
47
|
+
test: "tap run --allow-empty-coverage --disable-coverage --timeout=60000",
|
48
|
+
"test:coverage": "tap run --show-full-coverage --timeout=60000 --coverage-report=text --coverage-report=lcov",
|
49
|
+
prerelease: "npm test",
|
50
|
+
release: "standard-version"
|
51
|
+
},
|
52
|
+
repository: {
|
53
|
+
type: "git",
|
54
|
+
url: "git://github.com/motdotla/dotenv.git"
|
55
|
+
},
|
56
|
+
homepage: "https://github.com/motdotla/dotenv#readme",
|
57
|
+
funding: "https://dotenvx.com",
|
58
|
+
keywords: [
|
59
|
+
"dotenv",
|
60
|
+
"env",
|
61
|
+
".env",
|
62
|
+
"environment",
|
63
|
+
"variables",
|
64
|
+
"config",
|
65
|
+
"settings"
|
66
|
+
],
|
67
|
+
readmeFilename: "README.md",
|
68
|
+
license: "BSD-2-Clause",
|
69
|
+
devDependencies: {
|
70
|
+
"@types/node": "^18.11.3",
|
71
|
+
decache: "^4.6.2",
|
72
|
+
sinon: "^14.0.1",
|
73
|
+
standard: "^17.0.0",
|
74
|
+
"standard-version": "^9.5.0",
|
75
|
+
tap: "^19.2.0",
|
76
|
+
typescript: "^4.8.4"
|
77
|
+
},
|
78
|
+
engines: {
|
79
|
+
node: ">=12"
|
80
|
+
},
|
81
|
+
browser: {
|
82
|
+
fs: false
|
83
|
+
}
|
84
|
+
};
|
85
|
+
});
|
86
|
+
|
87
|
+
// node_modules/dotenv/lib/main.js
|
88
|
+
var require_main = __commonJS((exports, module) => {
|
89
|
+
var fs = __require("fs");
|
90
|
+
var path = __require("path");
|
91
|
+
var os = __require("os");
|
92
|
+
var crypto = __require("crypto");
|
93
|
+
var packageJson = require_package();
|
94
|
+
var version = packageJson.version;
|
95
|
+
var TIPS = [
|
96
|
+
"\uD83D\uDD10 encrypt with Dotenvx: https://dotenvx.com",
|
97
|
+
"\uD83D\uDD10 prevent committing .env to code: https://dotenvx.com/precommit",
|
98
|
+
"\uD83D\uDD10 prevent building .env in docker: https://dotenvx.com/prebuild",
|
99
|
+
"\uD83D\uDCE1 observe env with Radar: https://dotenvx.com/radar",
|
100
|
+
"\uD83D\uDCE1 auto-backup env with Radar: https://dotenvx.com/radar",
|
101
|
+
"\uD83D\uDCE1 version env with Radar: https://dotenvx.com/radar",
|
102
|
+
"\uD83D\uDEE0️ run anywhere with `dotenvx run -- yourcommand`",
|
103
|
+
"⚙️ specify custom .env file path with { path: '/custom/path/.env' }",
|
104
|
+
"⚙️ enable debug logging with { debug: true }",
|
105
|
+
"⚙️ override existing env vars with { override: true }",
|
106
|
+
"⚙️ suppress all logs with { quiet: true }",
|
107
|
+
"⚙️ write to custom object with { processEnv: myObject }",
|
108
|
+
"⚙️ load multiple .env files with { path: ['.env.local', '.env'] }"
|
109
|
+
];
|
110
|
+
function _getRandomTip() {
|
111
|
+
return TIPS[Math.floor(Math.random() * TIPS.length)];
|
112
|
+
}
|
113
|
+
function parseBoolean(value) {
|
114
|
+
if (typeof value === "string") {
|
115
|
+
return !["false", "0", "no", "off", ""].includes(value.toLowerCase());
|
116
|
+
}
|
117
|
+
return Boolean(value);
|
118
|
+
}
|
119
|
+
function supportsAnsi() {
|
120
|
+
return process.stdout.isTTY;
|
121
|
+
}
|
122
|
+
function dim(text) {
|
123
|
+
return supportsAnsi() ? `\x1B[2m${text}\x1B[0m` : text;
|
124
|
+
}
|
125
|
+
var LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg;
|
126
|
+
function parse(src) {
|
127
|
+
const obj = {};
|
128
|
+
let lines = src.toString();
|
129
|
+
lines = lines.replace(/\r\n?/mg, `
|
130
|
+
`);
|
131
|
+
let match;
|
132
|
+
while ((match = LINE.exec(lines)) != null) {
|
133
|
+
const key = match[1];
|
134
|
+
let value = match[2] || "";
|
135
|
+
value = value.trim();
|
136
|
+
const maybeQuote = value[0];
|
137
|
+
value = value.replace(/^(['"`])([\s\S]*)\1$/mg, "$2");
|
138
|
+
if (maybeQuote === '"') {
|
139
|
+
value = value.replace(/\\n/g, `
|
140
|
+
`);
|
141
|
+
value = value.replace(/\\r/g, "\r");
|
142
|
+
}
|
143
|
+
obj[key] = value;
|
144
|
+
}
|
145
|
+
return obj;
|
146
|
+
}
|
147
|
+
function _parseVault(options) {
|
148
|
+
options = options || {};
|
149
|
+
const vaultPath = _vaultPath(options);
|
150
|
+
options.path = vaultPath;
|
151
|
+
const result = DotenvModule.configDotenv(options);
|
152
|
+
if (!result.parsed) {
|
153
|
+
const err = new Error(`MISSING_DATA: Cannot parse ${vaultPath} for an unknown reason`);
|
154
|
+
err.code = "MISSING_DATA";
|
155
|
+
throw err;
|
156
|
+
}
|
157
|
+
const keys = _dotenvKey(options).split(",");
|
158
|
+
const length = keys.length;
|
159
|
+
let decrypted;
|
160
|
+
for (let i = 0;i < length; i++) {
|
161
|
+
try {
|
162
|
+
const key = keys[i].trim();
|
163
|
+
const attrs = _instructions(result, key);
|
164
|
+
decrypted = DotenvModule.decrypt(attrs.ciphertext, attrs.key);
|
165
|
+
break;
|
166
|
+
} catch (error) {
|
167
|
+
if (i + 1 >= length) {
|
168
|
+
throw error;
|
169
|
+
}
|
170
|
+
}
|
171
|
+
}
|
172
|
+
return DotenvModule.parse(decrypted);
|
173
|
+
}
|
174
|
+
function _warn(message) {
|
175
|
+
console.error(`[dotenv@${version}][WARN] ${message}`);
|
176
|
+
}
|
177
|
+
function _debug(message) {
|
178
|
+
console.log(`[dotenv@${version}][DEBUG] ${message}`);
|
179
|
+
}
|
180
|
+
function _log(message) {
|
181
|
+
console.log(`[dotenv@${version}] ${message}`);
|
182
|
+
}
|
183
|
+
function _dotenvKey(options) {
|
184
|
+
if (options && options.DOTENV_KEY && options.DOTENV_KEY.length > 0) {
|
185
|
+
return options.DOTENV_KEY;
|
186
|
+
}
|
187
|
+
if (process.env.DOTENV_KEY && process.env.DOTENV_KEY.length > 0) {
|
188
|
+
return process.env.DOTENV_KEY;
|
189
|
+
}
|
190
|
+
return "";
|
191
|
+
}
|
192
|
+
function _instructions(result, dotenvKey) {
|
193
|
+
let uri;
|
194
|
+
try {
|
195
|
+
uri = new URL(dotenvKey);
|
196
|
+
} catch (error) {
|
197
|
+
if (error.code === "ERR_INVALID_URL") {
|
198
|
+
const err = new Error("INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=development");
|
199
|
+
err.code = "INVALID_DOTENV_KEY";
|
200
|
+
throw err;
|
201
|
+
}
|
202
|
+
throw error;
|
203
|
+
}
|
204
|
+
const key = uri.password;
|
205
|
+
if (!key) {
|
206
|
+
const err = new Error("INVALID_DOTENV_KEY: Missing key part");
|
207
|
+
err.code = "INVALID_DOTENV_KEY";
|
208
|
+
throw err;
|
209
|
+
}
|
210
|
+
const environment = uri.searchParams.get("environment");
|
211
|
+
if (!environment) {
|
212
|
+
const err = new Error("INVALID_DOTENV_KEY: Missing environment part");
|
213
|
+
err.code = "INVALID_DOTENV_KEY";
|
214
|
+
throw err;
|
215
|
+
}
|
216
|
+
const environmentKey = `DOTENV_VAULT_${environment.toUpperCase()}`;
|
217
|
+
const ciphertext = result.parsed[environmentKey];
|
218
|
+
if (!ciphertext) {
|
219
|
+
const err = new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${environmentKey} in your .env.vault file.`);
|
220
|
+
err.code = "NOT_FOUND_DOTENV_ENVIRONMENT";
|
221
|
+
throw err;
|
222
|
+
}
|
223
|
+
return { ciphertext, key };
|
224
|
+
}
|
225
|
+
function _vaultPath(options) {
|
226
|
+
let possibleVaultPath = null;
|
227
|
+
if (options && options.path && options.path.length > 0) {
|
228
|
+
if (Array.isArray(options.path)) {
|
229
|
+
for (const filepath of options.path) {
|
230
|
+
if (fs.existsSync(filepath)) {
|
231
|
+
possibleVaultPath = filepath.endsWith(".vault") ? filepath : `${filepath}.vault`;
|
232
|
+
}
|
233
|
+
}
|
234
|
+
} else {
|
235
|
+
possibleVaultPath = options.path.endsWith(".vault") ? options.path : `${options.path}.vault`;
|
236
|
+
}
|
237
|
+
} else {
|
238
|
+
possibleVaultPath = path.resolve(process.cwd(), ".env.vault");
|
239
|
+
}
|
240
|
+
if (fs.existsSync(possibleVaultPath)) {
|
241
|
+
return possibleVaultPath;
|
242
|
+
}
|
243
|
+
return null;
|
244
|
+
}
|
245
|
+
function _resolveHome(envPath) {
|
246
|
+
return envPath[0] === "~" ? path.join(os.homedir(), envPath.slice(1)) : envPath;
|
247
|
+
}
|
248
|
+
function _configVault(options) {
|
249
|
+
const debug = parseBoolean(process.env.DOTENV_CONFIG_DEBUG || options && options.debug);
|
250
|
+
const quiet = parseBoolean(process.env.DOTENV_CONFIG_QUIET || options && options.quiet);
|
251
|
+
if (debug || !quiet) {
|
252
|
+
_log("Loading env from encrypted .env.vault");
|
253
|
+
}
|
254
|
+
const parsed = DotenvModule._parseVault(options);
|
255
|
+
let processEnv = process.env;
|
256
|
+
if (options && options.processEnv != null) {
|
257
|
+
processEnv = options.processEnv;
|
258
|
+
}
|
259
|
+
DotenvModule.populate(processEnv, parsed, options);
|
260
|
+
return { parsed };
|
261
|
+
}
|
262
|
+
function configDotenv(options) {
|
263
|
+
const dotenvPath = path.resolve(process.cwd(), ".env");
|
264
|
+
let encoding = "utf8";
|
265
|
+
let processEnv = process.env;
|
266
|
+
if (options && options.processEnv != null) {
|
267
|
+
processEnv = options.processEnv;
|
268
|
+
}
|
269
|
+
let debug = parseBoolean(processEnv.DOTENV_CONFIG_DEBUG || options && options.debug);
|
270
|
+
let quiet = parseBoolean(processEnv.DOTENV_CONFIG_QUIET || options && options.quiet);
|
271
|
+
if (options && options.encoding) {
|
272
|
+
encoding = options.encoding;
|
273
|
+
} else {
|
274
|
+
if (debug) {
|
275
|
+
_debug("No encoding is specified. UTF-8 is used by default");
|
276
|
+
}
|
277
|
+
}
|
278
|
+
let optionPaths = [dotenvPath];
|
279
|
+
if (options && options.path) {
|
280
|
+
if (!Array.isArray(options.path)) {
|
281
|
+
optionPaths = [_resolveHome(options.path)];
|
282
|
+
} else {
|
283
|
+
optionPaths = [];
|
284
|
+
for (const filepath of options.path) {
|
285
|
+
optionPaths.push(_resolveHome(filepath));
|
286
|
+
}
|
287
|
+
}
|
288
|
+
}
|
289
|
+
let lastError;
|
290
|
+
const parsedAll = {};
|
291
|
+
for (const path2 of optionPaths) {
|
292
|
+
try {
|
293
|
+
const parsed = DotenvModule.parse(fs.readFileSync(path2, { encoding }));
|
294
|
+
DotenvModule.populate(parsedAll, parsed, options);
|
295
|
+
} catch (e) {
|
296
|
+
if (debug) {
|
297
|
+
_debug(`Failed to load ${path2} ${e.message}`);
|
298
|
+
}
|
299
|
+
lastError = e;
|
300
|
+
}
|
301
|
+
}
|
302
|
+
const populated = DotenvModule.populate(processEnv, parsedAll, options);
|
303
|
+
debug = parseBoolean(processEnv.DOTENV_CONFIG_DEBUG || debug);
|
304
|
+
quiet = parseBoolean(processEnv.DOTENV_CONFIG_QUIET || quiet);
|
305
|
+
if (debug || !quiet) {
|
306
|
+
const keysCount = Object.keys(populated).length;
|
307
|
+
const shortPaths = [];
|
308
|
+
for (const filePath of optionPaths) {
|
309
|
+
try {
|
310
|
+
const relative = path.relative(process.cwd(), filePath);
|
311
|
+
shortPaths.push(relative);
|
312
|
+
} catch (e) {
|
313
|
+
if (debug) {
|
314
|
+
_debug(`Failed to load ${filePath} ${e.message}`);
|
315
|
+
}
|
316
|
+
lastError = e;
|
317
|
+
}
|
318
|
+
}
|
319
|
+
_log(`injecting env (${keysCount}) from ${shortPaths.join(",")} ${dim(`-- tip: ${_getRandomTip()}`)}`);
|
320
|
+
}
|
321
|
+
if (lastError) {
|
322
|
+
return { parsed: parsedAll, error: lastError };
|
323
|
+
} else {
|
324
|
+
return { parsed: parsedAll };
|
325
|
+
}
|
326
|
+
}
|
327
|
+
function config(options) {
|
328
|
+
if (_dotenvKey(options).length === 0) {
|
329
|
+
return DotenvModule.configDotenv(options);
|
330
|
+
}
|
331
|
+
const vaultPath = _vaultPath(options);
|
332
|
+
if (!vaultPath) {
|
333
|
+
_warn(`You set DOTENV_KEY but you are missing a .env.vault file at ${vaultPath}. Did you forget to build it?`);
|
334
|
+
return DotenvModule.configDotenv(options);
|
335
|
+
}
|
336
|
+
return DotenvModule._configVault(options);
|
337
|
+
}
|
338
|
+
function decrypt(encrypted, keyStr) {
|
339
|
+
const key = Buffer.from(keyStr.slice(-64), "hex");
|
340
|
+
let ciphertext = Buffer.from(encrypted, "base64");
|
341
|
+
const nonce = ciphertext.subarray(0, 12);
|
342
|
+
const authTag = ciphertext.subarray(-16);
|
343
|
+
ciphertext = ciphertext.subarray(12, -16);
|
344
|
+
try {
|
345
|
+
const aesgcm = crypto.createDecipheriv("aes-256-gcm", key, nonce);
|
346
|
+
aesgcm.setAuthTag(authTag);
|
347
|
+
return `${aesgcm.update(ciphertext)}${aesgcm.final()}`;
|
348
|
+
} catch (error) {
|
349
|
+
const isRange = error instanceof RangeError;
|
350
|
+
const invalidKeyLength = error.message === "Invalid key length";
|
351
|
+
const decryptionFailed = error.message === "Unsupported state or unable to authenticate data";
|
352
|
+
if (isRange || invalidKeyLength) {
|
353
|
+
const err = new Error("INVALID_DOTENV_KEY: It must be 64 characters long (or more)");
|
354
|
+
err.code = "INVALID_DOTENV_KEY";
|
355
|
+
throw err;
|
356
|
+
} else if (decryptionFailed) {
|
357
|
+
const err = new Error("DECRYPTION_FAILED: Please check your DOTENV_KEY");
|
358
|
+
err.code = "DECRYPTION_FAILED";
|
359
|
+
throw err;
|
360
|
+
} else {
|
361
|
+
throw error;
|
362
|
+
}
|
363
|
+
}
|
364
|
+
}
|
365
|
+
function populate(processEnv, parsed, options = {}) {
|
366
|
+
const debug = Boolean(options && options.debug);
|
367
|
+
const override = Boolean(options && options.override);
|
368
|
+
const populated = {};
|
369
|
+
if (typeof parsed !== "object") {
|
370
|
+
const err = new Error("OBJECT_REQUIRED: Please check the processEnv argument being passed to populate");
|
371
|
+
err.code = "OBJECT_REQUIRED";
|
372
|
+
throw err;
|
373
|
+
}
|
374
|
+
for (const key of Object.keys(parsed)) {
|
375
|
+
if (Object.prototype.hasOwnProperty.call(processEnv, key)) {
|
376
|
+
if (override === true) {
|
377
|
+
processEnv[key] = parsed[key];
|
378
|
+
populated[key] = parsed[key];
|
379
|
+
}
|
380
|
+
if (debug) {
|
381
|
+
if (override === true) {
|
382
|
+
_debug(`"${key}" is already defined and WAS overwritten`);
|
383
|
+
} else {
|
384
|
+
_debug(`"${key}" is already defined and was NOT overwritten`);
|
385
|
+
}
|
386
|
+
}
|
387
|
+
} else {
|
388
|
+
processEnv[key] = parsed[key];
|
389
|
+
populated[key] = parsed[key];
|
390
|
+
}
|
391
|
+
}
|
392
|
+
return populated;
|
393
|
+
}
|
394
|
+
var DotenvModule = {
|
395
|
+
configDotenv,
|
396
|
+
_configVault,
|
397
|
+
_parseVault,
|
398
|
+
config,
|
399
|
+
decrypt,
|
400
|
+
parse,
|
401
|
+
populate
|
402
|
+
};
|
403
|
+
exports.configDotenv = DotenvModule.configDotenv;
|
404
|
+
exports._configVault = DotenvModule._configVault;
|
405
|
+
exports._parseVault = DotenvModule._parseVault;
|
406
|
+
exports.config = DotenvModule.config;
|
407
|
+
exports.decrypt = DotenvModule.decrypt;
|
408
|
+
exports.parse = DotenvModule.parse;
|
409
|
+
exports.populate = DotenvModule.populate;
|
410
|
+
module.exports = DotenvModule;
|
411
|
+
});
|
412
|
+
|
413
|
+
// node_modules/dotenv/lib/env-options.js
|
414
|
+
var require_env_options = __commonJS((exports, module) => {
|
415
|
+
var options = {};
|
416
|
+
if (process.env.DOTENV_CONFIG_ENCODING != null) {
|
417
|
+
options.encoding = process.env.DOTENV_CONFIG_ENCODING;
|
418
|
+
}
|
419
|
+
if (process.env.DOTENV_CONFIG_PATH != null) {
|
420
|
+
options.path = process.env.DOTENV_CONFIG_PATH;
|
421
|
+
}
|
422
|
+
if (process.env.DOTENV_CONFIG_QUIET != null) {
|
423
|
+
options.quiet = process.env.DOTENV_CONFIG_QUIET;
|
424
|
+
}
|
425
|
+
if (process.env.DOTENV_CONFIG_DEBUG != null) {
|
426
|
+
options.debug = process.env.DOTENV_CONFIG_DEBUG;
|
427
|
+
}
|
428
|
+
if (process.env.DOTENV_CONFIG_OVERRIDE != null) {
|
429
|
+
options.override = process.env.DOTENV_CONFIG_OVERRIDE;
|
430
|
+
}
|
431
|
+
if (process.env.DOTENV_CONFIG_DOTENV_KEY != null) {
|
432
|
+
options.DOTENV_KEY = process.env.DOTENV_CONFIG_DOTENV_KEY;
|
433
|
+
}
|
434
|
+
module.exports = options;
|
435
|
+
});
|
436
|
+
|
437
|
+
// node_modules/dotenv/lib/cli-options.js
|
438
|
+
var require_cli_options = __commonJS((exports, module) => {
|
439
|
+
var re = /^dotenv_config_(encoding|path|quiet|debug|override|DOTENV_KEY)=(.+)$/;
|
440
|
+
module.exports = function optionMatcher(args) {
|
441
|
+
const options = args.reduce(function(acc, cur) {
|
442
|
+
const matches = cur.match(re);
|
443
|
+
if (matches) {
|
444
|
+
acc[matches[1]] = matches[2];
|
445
|
+
}
|
446
|
+
return acc;
|
447
|
+
}, {});
|
448
|
+
if (!("quiet" in options)) {
|
449
|
+
options.quiet = "true";
|
450
|
+
}
|
451
|
+
return options;
|
452
|
+
};
|
453
|
+
});
|
454
|
+
|
455
|
+
// node_modules/dotenv/config.js
|
456
|
+
var require_config = __commonJS(() => {
|
457
|
+
(function() {
|
458
|
+
require_main().config(Object.assign({}, require_env_options(), require_cli_options()(process.argv)));
|
459
|
+
})();
|
460
|
+
});
|
461
|
+
|
1
462
|
// src/index.ts
|
463
|
+
var import_config = __toESM(require_config(), 1);
|
2
464
|
import { join } from "node:path";
|
3
465
|
import { pathToFileURL } from "node:url";
|
4
466
|
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "postgresdk",
|
3
|
-
"version": "0.1.2-alpha.
|
3
|
+
"version": "0.1.2-alpha.1",
|
4
4
|
"description": "Generate a typed server/client SDK from a Postgres schema (includes, Zod, Hono).",
|
5
5
|
"type": "module",
|
6
6
|
"bin": {
|
@@ -29,9 +29,10 @@
|
|
29
29
|
"publish:major": "./publish.sh"
|
30
30
|
},
|
31
31
|
"dependencies": {
|
32
|
+
"dotenv": "^17.2.1",
|
33
|
+
"hono": "^4.9.0",
|
32
34
|
"pg": "^8.16.3",
|
33
|
-
"zod": "^4.0.15"
|
34
|
-
"hono": "^4.9.0"
|
35
|
+
"zod": "^4.0.15"
|
35
36
|
},
|
36
37
|
"devDependencies": {
|
37
38
|
"@types/node": "^20.0.0",
|