@shopware/api-gen 1.5.0 → 1.5.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 +12 -10
- package/dist/cli.mjs +27913 -25863
- package/dist/index.mjs +4 -4
- package/dist/shared/{api-gen.a71ec925.mjs → api-gen.DDkIkZIo.mjs} +904 -825
- package/package.json +10 -12
|
@@ -1,642 +1,16 @@
|
|
|
1
1
|
import { existsSync, readFileSync, writeFileSync, mkdirSync } from 'node:fs';
|
|
2
2
|
import { resolve, join, dirname } from 'node:path';
|
|
3
|
+
import { ofetch } from 'ofetch';
|
|
3
4
|
import openapiTS, { transformSchemaObjectWithComposition, astToString } from 'openapi-typescript';
|
|
4
5
|
import ts from 'typescript';
|
|
6
|
+
import { Project } from 'ts-morph';
|
|
5
7
|
import require$$0 from 'fs';
|
|
6
8
|
import require$$1 from 'path';
|
|
7
9
|
import require$$2 from 'os';
|
|
8
10
|
import require$$3 from 'crypto';
|
|
9
|
-
import {
|
|
10
|
-
import { format as format$1 } from 'prettier';
|
|
11
|
-
import { Project } from 'ts-morph';
|
|
11
|
+
import { format as format$1 } from 'oxfmt';
|
|
12
12
|
import { createAdminAPIClient, createAPIClient } from '@shopware/api-client';
|
|
13
13
|
|
|
14
|
-
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
15
|
-
|
|
16
|
-
function getDefaultExportFromCjs$2 (x) {
|
|
17
|
-
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
function getAugmentedNamespace(n) {
|
|
21
|
-
if (n.__esModule) return n;
|
|
22
|
-
var f = n.default;
|
|
23
|
-
if (typeof f == "function") {
|
|
24
|
-
var a = function a () {
|
|
25
|
-
if (this instanceof a) {
|
|
26
|
-
return Reflect.construct(f, arguments, this.constructor);
|
|
27
|
-
}
|
|
28
|
-
return f.apply(this, arguments);
|
|
29
|
-
};
|
|
30
|
-
a.prototype = f.prototype;
|
|
31
|
-
} else a = {};
|
|
32
|
-
Object.defineProperty(a, '__esModule', {value: true});
|
|
33
|
-
Object.keys(n).forEach(function (k) {
|
|
34
|
-
var d = Object.getOwnPropertyDescriptor(n, k);
|
|
35
|
-
Object.defineProperty(a, k, d.get ? d : {
|
|
36
|
-
enumerable: true,
|
|
37
|
-
get: function () {
|
|
38
|
-
return n[k];
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
});
|
|
42
|
-
return a;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
var main$1 = {exports: {}};
|
|
46
|
-
|
|
47
|
-
const name = "dotenv";
|
|
48
|
-
const version$1 = "17.3.1";
|
|
49
|
-
const description = "Loads environment variables from .env file";
|
|
50
|
-
const main = "lib/main.js";
|
|
51
|
-
const types = "lib/main.d.ts";
|
|
52
|
-
const exports = {
|
|
53
|
-
".": {
|
|
54
|
-
types: "./lib/main.d.ts",
|
|
55
|
-
require: "./lib/main.js",
|
|
56
|
-
"default": "./lib/main.js"
|
|
57
|
-
},
|
|
58
|
-
"./config": "./config.js",
|
|
59
|
-
"./config.js": "./config.js",
|
|
60
|
-
"./lib/env-options": "./lib/env-options.js",
|
|
61
|
-
"./lib/env-options.js": "./lib/env-options.js",
|
|
62
|
-
"./lib/cli-options": "./lib/cli-options.js",
|
|
63
|
-
"./lib/cli-options.js": "./lib/cli-options.js",
|
|
64
|
-
"./package.json": "./package.json"
|
|
65
|
-
};
|
|
66
|
-
const scripts = {
|
|
67
|
-
"dts-check": "tsc --project tests/types/tsconfig.json",
|
|
68
|
-
lint: "standard",
|
|
69
|
-
pretest: "npm run lint && npm run dts-check",
|
|
70
|
-
test: "tap run tests/**/*.js --allow-empty-coverage --disable-coverage --timeout=60000",
|
|
71
|
-
"test:coverage": "tap run tests/**/*.js --show-full-coverage --timeout=60000 --coverage-report=text --coverage-report=lcov",
|
|
72
|
-
prerelease: "npm test",
|
|
73
|
-
release: "standard-version"
|
|
74
|
-
};
|
|
75
|
-
const repository = {
|
|
76
|
-
type: "git",
|
|
77
|
-
url: "git://github.com/motdotla/dotenv.git"
|
|
78
|
-
};
|
|
79
|
-
const homepage = "https://github.com/motdotla/dotenv#readme";
|
|
80
|
-
const funding = "https://dotenvx.com";
|
|
81
|
-
const keywords = [
|
|
82
|
-
"dotenv",
|
|
83
|
-
"env",
|
|
84
|
-
".env",
|
|
85
|
-
"environment",
|
|
86
|
-
"variables",
|
|
87
|
-
"config",
|
|
88
|
-
"settings"
|
|
89
|
-
];
|
|
90
|
-
const readmeFilename = "README.md";
|
|
91
|
-
const license = "BSD-2-Clause";
|
|
92
|
-
const devDependencies = {
|
|
93
|
-
"@types/node": "^18.11.3",
|
|
94
|
-
decache: "^4.6.2",
|
|
95
|
-
sinon: "^14.0.1",
|
|
96
|
-
standard: "^17.0.0",
|
|
97
|
-
"standard-version": "^9.5.0",
|
|
98
|
-
tap: "^19.2.0",
|
|
99
|
-
typescript: "^4.8.4"
|
|
100
|
-
};
|
|
101
|
-
const engines = {
|
|
102
|
-
node: ">=12"
|
|
103
|
-
};
|
|
104
|
-
const browser = {
|
|
105
|
-
fs: false
|
|
106
|
-
};
|
|
107
|
-
const _package = {
|
|
108
|
-
name: name,
|
|
109
|
-
version: version$1,
|
|
110
|
-
description: description,
|
|
111
|
-
main: main,
|
|
112
|
-
types: types,
|
|
113
|
-
exports: exports,
|
|
114
|
-
scripts: scripts,
|
|
115
|
-
repository: repository,
|
|
116
|
-
homepage: homepage,
|
|
117
|
-
funding: funding,
|
|
118
|
-
keywords: keywords,
|
|
119
|
-
readmeFilename: readmeFilename,
|
|
120
|
-
license: license,
|
|
121
|
-
devDependencies: devDependencies,
|
|
122
|
-
engines: engines,
|
|
123
|
-
browser: browser
|
|
124
|
-
};
|
|
125
|
-
|
|
126
|
-
const _package$1 = {
|
|
127
|
-
__proto__: null,
|
|
128
|
-
browser: browser,
|
|
129
|
-
default: _package,
|
|
130
|
-
description: description,
|
|
131
|
-
devDependencies: devDependencies,
|
|
132
|
-
engines: engines,
|
|
133
|
-
exports: exports,
|
|
134
|
-
funding: funding,
|
|
135
|
-
homepage: homepage,
|
|
136
|
-
keywords: keywords,
|
|
137
|
-
license: license,
|
|
138
|
-
main: main,
|
|
139
|
-
name: name,
|
|
140
|
-
readmeFilename: readmeFilename,
|
|
141
|
-
repository: repository,
|
|
142
|
-
scripts: scripts,
|
|
143
|
-
types: types,
|
|
144
|
-
version: version$1
|
|
145
|
-
};
|
|
146
|
-
|
|
147
|
-
const require$$4 = /*@__PURE__*/getAugmentedNamespace(_package$1);
|
|
148
|
-
|
|
149
|
-
const fs = require$$0;
|
|
150
|
-
const path = require$$1;
|
|
151
|
-
const os = require$$2;
|
|
152
|
-
const crypto = require$$3;
|
|
153
|
-
const packageJson = require$$4;
|
|
154
|
-
|
|
155
|
-
const version = packageJson.version;
|
|
156
|
-
|
|
157
|
-
// Array of tips to display randomly
|
|
158
|
-
const TIPS = [
|
|
159
|
-
'🔐 encrypt with Dotenvx: https://dotenvx.com',
|
|
160
|
-
'🔐 prevent committing .env to code: https://dotenvx.com/precommit',
|
|
161
|
-
'🔐 prevent building .env in docker: https://dotenvx.com/prebuild',
|
|
162
|
-
'🤖 agentic secret storage: https://dotenvx.com/as2',
|
|
163
|
-
'⚡️ secrets for agents: https://dotenvx.com/as2',
|
|
164
|
-
'🛡️ auth for agents: https://vestauth.com',
|
|
165
|
-
'🛠️ run anywhere with `dotenvx run -- yourcommand`',
|
|
166
|
-
'⚙️ specify custom .env file path with { path: \'/custom/path/.env\' }',
|
|
167
|
-
'⚙️ enable debug logging with { debug: true }',
|
|
168
|
-
'⚙️ override existing env vars with { override: true }',
|
|
169
|
-
'⚙️ suppress all logs with { quiet: true }',
|
|
170
|
-
'⚙️ write to custom object with { processEnv: myObject }',
|
|
171
|
-
'⚙️ load multiple .env files with { path: [\'.env.local\', \'.env\'] }'
|
|
172
|
-
];
|
|
173
|
-
|
|
174
|
-
// Get a random tip from the tips array
|
|
175
|
-
function _getRandomTip () {
|
|
176
|
-
return TIPS[Math.floor(Math.random() * TIPS.length)]
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
function parseBoolean (value) {
|
|
180
|
-
if (typeof value === 'string') {
|
|
181
|
-
return !['false', '0', 'no', 'off', ''].includes(value.toLowerCase())
|
|
182
|
-
}
|
|
183
|
-
return Boolean(value)
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
function supportsAnsi () {
|
|
187
|
-
return process.stdout.isTTY // && process.env.TERM !== 'dumb'
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
function dim (text) {
|
|
191
|
-
return supportsAnsi() ? `\x1b[2m${text}\x1b[0m` : text
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
const LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg;
|
|
195
|
-
|
|
196
|
-
// Parse src into an Object
|
|
197
|
-
function parse$1 (src) {
|
|
198
|
-
const obj = {};
|
|
199
|
-
|
|
200
|
-
// Convert buffer to string
|
|
201
|
-
let lines = src.toString();
|
|
202
|
-
|
|
203
|
-
// Convert line breaks to same format
|
|
204
|
-
lines = lines.replace(/\r\n?/mg, '\n');
|
|
205
|
-
|
|
206
|
-
let match;
|
|
207
|
-
while ((match = LINE.exec(lines)) != null) {
|
|
208
|
-
const key = match[1];
|
|
209
|
-
|
|
210
|
-
// Default undefined or null to empty string
|
|
211
|
-
let value = (match[2] || '');
|
|
212
|
-
|
|
213
|
-
// Remove whitespace
|
|
214
|
-
value = value.trim();
|
|
215
|
-
|
|
216
|
-
// Check if double quoted
|
|
217
|
-
const maybeQuote = value[0];
|
|
218
|
-
|
|
219
|
-
// Remove surrounding quotes
|
|
220
|
-
value = value.replace(/^(['"`])([\s\S]*)\1$/mg, '$2');
|
|
221
|
-
|
|
222
|
-
// Expand newlines if double quoted
|
|
223
|
-
if (maybeQuote === '"') {
|
|
224
|
-
value = value.replace(/\\n/g, '\n');
|
|
225
|
-
value = value.replace(/\\r/g, '\r');
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
// Add to object
|
|
229
|
-
obj[key] = value;
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
return obj
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
function _parseVault (options) {
|
|
236
|
-
options = options || {};
|
|
237
|
-
|
|
238
|
-
const vaultPath = _vaultPath(options);
|
|
239
|
-
options.path = vaultPath; // parse .env.vault
|
|
240
|
-
const result = DotenvModule.configDotenv(options);
|
|
241
|
-
if (!result.parsed) {
|
|
242
|
-
const err = new Error(`MISSING_DATA: Cannot parse ${vaultPath} for an unknown reason`);
|
|
243
|
-
err.code = 'MISSING_DATA';
|
|
244
|
-
throw err
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
// handle scenario for comma separated keys - for use with key rotation
|
|
248
|
-
// example: DOTENV_KEY="dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=prod,dotenv://:key_7890@dotenvx.com/vault/.env.vault?environment=prod"
|
|
249
|
-
const keys = _dotenvKey(options).split(',');
|
|
250
|
-
const length = keys.length;
|
|
251
|
-
|
|
252
|
-
let decrypted;
|
|
253
|
-
for (let i = 0; i < length; i++) {
|
|
254
|
-
try {
|
|
255
|
-
// Get full key
|
|
256
|
-
const key = keys[i].trim();
|
|
257
|
-
|
|
258
|
-
// Get instructions for decrypt
|
|
259
|
-
const attrs = _instructions(result, key);
|
|
260
|
-
|
|
261
|
-
// Decrypt
|
|
262
|
-
decrypted = DotenvModule.decrypt(attrs.ciphertext, attrs.key);
|
|
263
|
-
|
|
264
|
-
break
|
|
265
|
-
} catch (error) {
|
|
266
|
-
// last key
|
|
267
|
-
if (i + 1 >= length) {
|
|
268
|
-
throw error
|
|
269
|
-
}
|
|
270
|
-
// try next key
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
// Parse decrypted .env string
|
|
275
|
-
return DotenvModule.parse(decrypted)
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
function _warn (message) {
|
|
279
|
-
console.error(`[dotenv@${version}][WARN] ${message}`);
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
function _debug (message) {
|
|
283
|
-
console.log(`[dotenv@${version}][DEBUG] ${message}`);
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
function _log (message) {
|
|
287
|
-
console.log(`[dotenv@${version}] ${message}`);
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
function _dotenvKey (options) {
|
|
291
|
-
// prioritize developer directly setting options.DOTENV_KEY
|
|
292
|
-
if (options && options.DOTENV_KEY && options.DOTENV_KEY.length > 0) {
|
|
293
|
-
return options.DOTENV_KEY
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
// secondary infra already contains a DOTENV_KEY environment variable
|
|
297
|
-
if (process.env.DOTENV_KEY && process.env.DOTENV_KEY.length > 0) {
|
|
298
|
-
return process.env.DOTENV_KEY
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
// fallback to empty string
|
|
302
|
-
return ''
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
function _instructions (result, dotenvKey) {
|
|
306
|
-
// Parse DOTENV_KEY. Format is a URI
|
|
307
|
-
let uri;
|
|
308
|
-
try {
|
|
309
|
-
uri = new URL(dotenvKey);
|
|
310
|
-
} catch (error) {
|
|
311
|
-
if (error.code === 'ERR_INVALID_URL') {
|
|
312
|
-
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');
|
|
313
|
-
err.code = 'INVALID_DOTENV_KEY';
|
|
314
|
-
throw err
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
throw error
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
// Get decrypt key
|
|
321
|
-
const key = uri.password;
|
|
322
|
-
if (!key) {
|
|
323
|
-
const err = new Error('INVALID_DOTENV_KEY: Missing key part');
|
|
324
|
-
err.code = 'INVALID_DOTENV_KEY';
|
|
325
|
-
throw err
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
// Get environment
|
|
329
|
-
const environment = uri.searchParams.get('environment');
|
|
330
|
-
if (!environment) {
|
|
331
|
-
const err = new Error('INVALID_DOTENV_KEY: Missing environment part');
|
|
332
|
-
err.code = 'INVALID_DOTENV_KEY';
|
|
333
|
-
throw err
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
// Get ciphertext payload
|
|
337
|
-
const environmentKey = `DOTENV_VAULT_${environment.toUpperCase()}`;
|
|
338
|
-
const ciphertext = result.parsed[environmentKey]; // DOTENV_VAULT_PRODUCTION
|
|
339
|
-
if (!ciphertext) {
|
|
340
|
-
const err = new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${environmentKey} in your .env.vault file.`);
|
|
341
|
-
err.code = 'NOT_FOUND_DOTENV_ENVIRONMENT';
|
|
342
|
-
throw err
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
return { ciphertext, key }
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
function _vaultPath (options) {
|
|
349
|
-
let possibleVaultPath = null;
|
|
350
|
-
|
|
351
|
-
if (options && options.path && options.path.length > 0) {
|
|
352
|
-
if (Array.isArray(options.path)) {
|
|
353
|
-
for (const filepath of options.path) {
|
|
354
|
-
if (fs.existsSync(filepath)) {
|
|
355
|
-
possibleVaultPath = filepath.endsWith('.vault') ? filepath : `${filepath}.vault`;
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
} else {
|
|
359
|
-
possibleVaultPath = options.path.endsWith('.vault') ? options.path : `${options.path}.vault`;
|
|
360
|
-
}
|
|
361
|
-
} else {
|
|
362
|
-
possibleVaultPath = path.resolve(process.cwd(), '.env.vault');
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
if (fs.existsSync(possibleVaultPath)) {
|
|
366
|
-
return possibleVaultPath
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
return null
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
function _resolveHome (envPath) {
|
|
373
|
-
return envPath[0] === '~' ? path.join(os.homedir(), envPath.slice(1)) : envPath
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
function _configVault (options) {
|
|
377
|
-
const debug = parseBoolean(process.env.DOTENV_CONFIG_DEBUG || (options && options.debug));
|
|
378
|
-
const quiet = parseBoolean(process.env.DOTENV_CONFIG_QUIET || (options && options.quiet));
|
|
379
|
-
|
|
380
|
-
if (debug || !quiet) {
|
|
381
|
-
_log('Loading env from encrypted .env.vault');
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
const parsed = DotenvModule._parseVault(options);
|
|
385
|
-
|
|
386
|
-
let processEnv = process.env;
|
|
387
|
-
if (options && options.processEnv != null) {
|
|
388
|
-
processEnv = options.processEnv;
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
DotenvModule.populate(processEnv, parsed, options);
|
|
392
|
-
|
|
393
|
-
return { parsed }
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
function configDotenv (options) {
|
|
397
|
-
const dotenvPath = path.resolve(process.cwd(), '.env');
|
|
398
|
-
let encoding = 'utf8';
|
|
399
|
-
let processEnv = process.env;
|
|
400
|
-
if (options && options.processEnv != null) {
|
|
401
|
-
processEnv = options.processEnv;
|
|
402
|
-
}
|
|
403
|
-
let debug = parseBoolean(processEnv.DOTENV_CONFIG_DEBUG || (options && options.debug));
|
|
404
|
-
let quiet = parseBoolean(processEnv.DOTENV_CONFIG_QUIET || (options && options.quiet));
|
|
405
|
-
|
|
406
|
-
if (options && options.encoding) {
|
|
407
|
-
encoding = options.encoding;
|
|
408
|
-
} else {
|
|
409
|
-
if (debug) {
|
|
410
|
-
_debug('No encoding is specified. UTF-8 is used by default');
|
|
411
|
-
}
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
let optionPaths = [dotenvPath]; // default, look for .env
|
|
415
|
-
if (options && options.path) {
|
|
416
|
-
if (!Array.isArray(options.path)) {
|
|
417
|
-
optionPaths = [_resolveHome(options.path)];
|
|
418
|
-
} else {
|
|
419
|
-
optionPaths = []; // reset default
|
|
420
|
-
for (const filepath of options.path) {
|
|
421
|
-
optionPaths.push(_resolveHome(filepath));
|
|
422
|
-
}
|
|
423
|
-
}
|
|
424
|
-
}
|
|
425
|
-
|
|
426
|
-
// Build the parsed data in a temporary object (because we need to return it). Once we have the final
|
|
427
|
-
// parsed data, we will combine it with process.env (or options.processEnv if provided).
|
|
428
|
-
let lastError;
|
|
429
|
-
const parsedAll = {};
|
|
430
|
-
for (const path of optionPaths) {
|
|
431
|
-
try {
|
|
432
|
-
// Specifying an encoding returns a string instead of a buffer
|
|
433
|
-
const parsed = DotenvModule.parse(fs.readFileSync(path, { encoding }));
|
|
434
|
-
|
|
435
|
-
DotenvModule.populate(parsedAll, parsed, options);
|
|
436
|
-
} catch (e) {
|
|
437
|
-
if (debug) {
|
|
438
|
-
_debug(`Failed to load ${path} ${e.message}`);
|
|
439
|
-
}
|
|
440
|
-
lastError = e;
|
|
441
|
-
}
|
|
442
|
-
}
|
|
443
|
-
|
|
444
|
-
const populated = DotenvModule.populate(processEnv, parsedAll, options);
|
|
445
|
-
|
|
446
|
-
// handle user settings DOTENV_CONFIG_ options inside .env file(s)
|
|
447
|
-
debug = parseBoolean(processEnv.DOTENV_CONFIG_DEBUG || debug);
|
|
448
|
-
quiet = parseBoolean(processEnv.DOTENV_CONFIG_QUIET || quiet);
|
|
449
|
-
|
|
450
|
-
if (debug || !quiet) {
|
|
451
|
-
const keysCount = Object.keys(populated).length;
|
|
452
|
-
const shortPaths = [];
|
|
453
|
-
for (const filePath of optionPaths) {
|
|
454
|
-
try {
|
|
455
|
-
const relative = path.relative(process.cwd(), filePath);
|
|
456
|
-
shortPaths.push(relative);
|
|
457
|
-
} catch (e) {
|
|
458
|
-
if (debug) {
|
|
459
|
-
_debug(`Failed to load ${filePath} ${e.message}`);
|
|
460
|
-
}
|
|
461
|
-
lastError = e;
|
|
462
|
-
}
|
|
463
|
-
}
|
|
464
|
-
|
|
465
|
-
_log(`injecting env (${keysCount}) from ${shortPaths.join(',')} ${dim(`-- tip: ${_getRandomTip()}`)}`);
|
|
466
|
-
}
|
|
467
|
-
|
|
468
|
-
if (lastError) {
|
|
469
|
-
return { parsed: parsedAll, error: lastError }
|
|
470
|
-
} else {
|
|
471
|
-
return { parsed: parsedAll }
|
|
472
|
-
}
|
|
473
|
-
}
|
|
474
|
-
|
|
475
|
-
// Populates process.env from .env file
|
|
476
|
-
function config$1 (options) {
|
|
477
|
-
// fallback to original dotenv if DOTENV_KEY is not set
|
|
478
|
-
if (_dotenvKey(options).length === 0) {
|
|
479
|
-
return DotenvModule.configDotenv(options)
|
|
480
|
-
}
|
|
481
|
-
|
|
482
|
-
const vaultPath = _vaultPath(options);
|
|
483
|
-
|
|
484
|
-
// dotenvKey exists but .env.vault file does not exist
|
|
485
|
-
if (!vaultPath) {
|
|
486
|
-
_warn(`You set DOTENV_KEY but you are missing a .env.vault file at ${vaultPath}. Did you forget to build it?`);
|
|
487
|
-
|
|
488
|
-
return DotenvModule.configDotenv(options)
|
|
489
|
-
}
|
|
490
|
-
|
|
491
|
-
return DotenvModule._configVault(options)
|
|
492
|
-
}
|
|
493
|
-
|
|
494
|
-
function decrypt (encrypted, keyStr) {
|
|
495
|
-
const key = Buffer.from(keyStr.slice(-64), 'hex');
|
|
496
|
-
let ciphertext = Buffer.from(encrypted, 'base64');
|
|
497
|
-
|
|
498
|
-
const nonce = ciphertext.subarray(0, 12);
|
|
499
|
-
const authTag = ciphertext.subarray(-16);
|
|
500
|
-
ciphertext = ciphertext.subarray(12, -16);
|
|
501
|
-
|
|
502
|
-
try {
|
|
503
|
-
const aesgcm = crypto.createDecipheriv('aes-256-gcm', key, nonce);
|
|
504
|
-
aesgcm.setAuthTag(authTag);
|
|
505
|
-
return `${aesgcm.update(ciphertext)}${aesgcm.final()}`
|
|
506
|
-
} catch (error) {
|
|
507
|
-
const isRange = error instanceof RangeError;
|
|
508
|
-
const invalidKeyLength = error.message === 'Invalid key length';
|
|
509
|
-
const decryptionFailed = error.message === 'Unsupported state or unable to authenticate data';
|
|
510
|
-
|
|
511
|
-
if (isRange || invalidKeyLength) {
|
|
512
|
-
const err = new Error('INVALID_DOTENV_KEY: It must be 64 characters long (or more)');
|
|
513
|
-
err.code = 'INVALID_DOTENV_KEY';
|
|
514
|
-
throw err
|
|
515
|
-
} else if (decryptionFailed) {
|
|
516
|
-
const err = new Error('DECRYPTION_FAILED: Please check your DOTENV_KEY');
|
|
517
|
-
err.code = 'DECRYPTION_FAILED';
|
|
518
|
-
throw err
|
|
519
|
-
} else {
|
|
520
|
-
throw error
|
|
521
|
-
}
|
|
522
|
-
}
|
|
523
|
-
}
|
|
524
|
-
|
|
525
|
-
// Populate process.env with parsed values
|
|
526
|
-
function populate (processEnv, parsed, options = {}) {
|
|
527
|
-
const debug = Boolean(options && options.debug);
|
|
528
|
-
const override = Boolean(options && options.override);
|
|
529
|
-
const populated = {};
|
|
530
|
-
|
|
531
|
-
if (typeof parsed !== 'object') {
|
|
532
|
-
const err = new Error('OBJECT_REQUIRED: Please check the processEnv argument being passed to populate');
|
|
533
|
-
err.code = 'OBJECT_REQUIRED';
|
|
534
|
-
throw err
|
|
535
|
-
}
|
|
536
|
-
|
|
537
|
-
// Set process.env
|
|
538
|
-
for (const key of Object.keys(parsed)) {
|
|
539
|
-
if (Object.prototype.hasOwnProperty.call(processEnv, key)) {
|
|
540
|
-
if (override === true) {
|
|
541
|
-
processEnv[key] = parsed[key];
|
|
542
|
-
populated[key] = parsed[key];
|
|
543
|
-
}
|
|
544
|
-
|
|
545
|
-
if (debug) {
|
|
546
|
-
if (override === true) {
|
|
547
|
-
_debug(`"${key}" is already defined and WAS overwritten`);
|
|
548
|
-
} else {
|
|
549
|
-
_debug(`"${key}" is already defined and was NOT overwritten`);
|
|
550
|
-
}
|
|
551
|
-
}
|
|
552
|
-
} else {
|
|
553
|
-
processEnv[key] = parsed[key];
|
|
554
|
-
populated[key] = parsed[key];
|
|
555
|
-
}
|
|
556
|
-
}
|
|
557
|
-
|
|
558
|
-
return populated
|
|
559
|
-
}
|
|
560
|
-
|
|
561
|
-
const DotenvModule = {
|
|
562
|
-
configDotenv,
|
|
563
|
-
_configVault,
|
|
564
|
-
_parseVault,
|
|
565
|
-
config: config$1,
|
|
566
|
-
decrypt,
|
|
567
|
-
parse: parse$1,
|
|
568
|
-
populate
|
|
569
|
-
};
|
|
570
|
-
|
|
571
|
-
main$1.exports.configDotenv = DotenvModule.configDotenv;
|
|
572
|
-
main$1.exports._configVault = DotenvModule._configVault;
|
|
573
|
-
main$1.exports._parseVault = DotenvModule._parseVault;
|
|
574
|
-
main$1.exports.config = DotenvModule.config;
|
|
575
|
-
main$1.exports.decrypt = DotenvModule.decrypt;
|
|
576
|
-
main$1.exports.parse = DotenvModule.parse;
|
|
577
|
-
main$1.exports.populate = DotenvModule.populate;
|
|
578
|
-
|
|
579
|
-
main$1.exports = DotenvModule;
|
|
580
|
-
|
|
581
|
-
var mainExports = main$1.exports;
|
|
582
|
-
|
|
583
|
-
// ../config.js accepts options via environment variables
|
|
584
|
-
const options = {};
|
|
585
|
-
|
|
586
|
-
if (process.env.DOTENV_CONFIG_ENCODING != null) {
|
|
587
|
-
options.encoding = process.env.DOTENV_CONFIG_ENCODING;
|
|
588
|
-
}
|
|
589
|
-
|
|
590
|
-
if (process.env.DOTENV_CONFIG_PATH != null) {
|
|
591
|
-
options.path = process.env.DOTENV_CONFIG_PATH;
|
|
592
|
-
}
|
|
593
|
-
|
|
594
|
-
if (process.env.DOTENV_CONFIG_QUIET != null) {
|
|
595
|
-
options.quiet = process.env.DOTENV_CONFIG_QUIET;
|
|
596
|
-
}
|
|
597
|
-
|
|
598
|
-
if (process.env.DOTENV_CONFIG_DEBUG != null) {
|
|
599
|
-
options.debug = process.env.DOTENV_CONFIG_DEBUG;
|
|
600
|
-
}
|
|
601
|
-
|
|
602
|
-
if (process.env.DOTENV_CONFIG_OVERRIDE != null) {
|
|
603
|
-
options.override = process.env.DOTENV_CONFIG_OVERRIDE;
|
|
604
|
-
}
|
|
605
|
-
|
|
606
|
-
if (process.env.DOTENV_CONFIG_DOTENV_KEY != null) {
|
|
607
|
-
options.DOTENV_KEY = process.env.DOTENV_CONFIG_DOTENV_KEY;
|
|
608
|
-
}
|
|
609
|
-
|
|
610
|
-
var envOptions = options;
|
|
611
|
-
|
|
612
|
-
const re = /^dotenv_config_(encoding|path|quiet|debug|override|DOTENV_KEY)=(.+)$/;
|
|
613
|
-
|
|
614
|
-
var cliOptions = function optionMatcher (args) {
|
|
615
|
-
const options = args.reduce(function (acc, cur) {
|
|
616
|
-
const matches = cur.match(re);
|
|
617
|
-
if (matches) {
|
|
618
|
-
acc[matches[1]] = matches[2];
|
|
619
|
-
}
|
|
620
|
-
return acc
|
|
621
|
-
}, {});
|
|
622
|
-
|
|
623
|
-
if (!('quiet' in options)) {
|
|
624
|
-
options.quiet = 'true';
|
|
625
|
-
}
|
|
626
|
-
|
|
627
|
-
return options
|
|
628
|
-
};
|
|
629
|
-
|
|
630
|
-
(function () {
|
|
631
|
-
mainExports.config(
|
|
632
|
-
Object.assign(
|
|
633
|
-
{},
|
|
634
|
-
envOptions,
|
|
635
|
-
cliOptions(process.argv)
|
|
636
|
-
)
|
|
637
|
-
);
|
|
638
|
-
})();
|
|
639
|
-
|
|
640
14
|
// This is a generated file. Do not edit.
|
|
641
15
|
var Space_Separator = /[\u1680\u2000-\u200A\u202F\u205F\u3000]/;
|
|
642
16
|
var ID_Start = /[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08BD\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312E\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FEA\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDF00-\uDF19]|\uD806[\uDCA0-\uDCDF\uDCFF\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE83\uDE86-\uDE89\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50\uDF93-\uDF9F\uDFE0\uDFE1]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00-\uDD1E\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]/;
|
|
@@ -2062,87 +1436,672 @@ const JSON5 = {
|
|
|
2062
1436
|
|
|
2063
1437
|
var lib = JSON5;
|
|
2064
1438
|
|
|
1439
|
+
function getDefaultExportFromCjs$2 (x) {
|
|
1440
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
1441
|
+
}
|
|
1442
|
+
|
|
1443
|
+
function getAugmentedNamespace(n) {
|
|
1444
|
+
if (Object.prototype.hasOwnProperty.call(n, '__esModule')) return n;
|
|
1445
|
+
var f = n.default;
|
|
1446
|
+
if (typeof f == "function") {
|
|
1447
|
+
var a = function a () {
|
|
1448
|
+
var isInstance = false;
|
|
1449
|
+
try {
|
|
1450
|
+
isInstance = this instanceof a;
|
|
1451
|
+
} catch {}
|
|
1452
|
+
if (isInstance) {
|
|
1453
|
+
return Reflect.construct(f, arguments, this.constructor);
|
|
1454
|
+
}
|
|
1455
|
+
return f.apply(this, arguments);
|
|
1456
|
+
};
|
|
1457
|
+
a.prototype = f.prototype;
|
|
1458
|
+
} else a = {};
|
|
1459
|
+
Object.defineProperty(a, '__esModule', {value: true});
|
|
1460
|
+
Object.keys(n).forEach(function (k) {
|
|
1461
|
+
var d = Object.getOwnPropertyDescriptor(n, k);
|
|
1462
|
+
Object.defineProperty(a, k, d.get ? d : {
|
|
1463
|
+
enumerable: true,
|
|
1464
|
+
get: function () {
|
|
1465
|
+
return n[k];
|
|
1466
|
+
}
|
|
1467
|
+
});
|
|
1468
|
+
});
|
|
1469
|
+
return a;
|
|
1470
|
+
}
|
|
1471
|
+
|
|
1472
|
+
var config$1 = {};
|
|
1473
|
+
|
|
1474
|
+
var main = {exports: {}};
|
|
1475
|
+
|
|
1476
|
+
var hasRequiredMain;
|
|
1477
|
+
|
|
1478
|
+
function requireMain () {
|
|
1479
|
+
if (hasRequiredMain) return main.exports;
|
|
1480
|
+
hasRequiredMain = 1;
|
|
1481
|
+
const fs = require$$0;
|
|
1482
|
+
const path = require$$1;
|
|
1483
|
+
const os = require$$2;
|
|
1484
|
+
const crypto = require$$3;
|
|
1485
|
+
|
|
1486
|
+
// Array of tips to display randomly
|
|
1487
|
+
const TIPS = [
|
|
1488
|
+
'◈ encrypted .env [www.dotenvx.com]',
|
|
1489
|
+
'◈ secrets for agents [www.dotenvx.com]',
|
|
1490
|
+
'⌁ auth for agents [www.vestauth.com]',
|
|
1491
|
+
'⌘ custom filepath { path: \'/custom/path/.env\' }',
|
|
1492
|
+
'⌘ enable debugging { debug: true }',
|
|
1493
|
+
'⌘ override existing { override: true }',
|
|
1494
|
+
'⌘ suppress logs { quiet: true }',
|
|
1495
|
+
'⌘ multiple files { path: [\'.env.local\', \'.env\'] }'
|
|
1496
|
+
];
|
|
1497
|
+
|
|
1498
|
+
// Get a random tip from the tips array
|
|
1499
|
+
function _getRandomTip () {
|
|
1500
|
+
return TIPS[Math.floor(Math.random() * TIPS.length)]
|
|
1501
|
+
}
|
|
1502
|
+
|
|
1503
|
+
function parseBoolean (value) {
|
|
1504
|
+
if (typeof value === 'string') {
|
|
1505
|
+
return !['false', '0', 'no', 'off', ''].includes(value.toLowerCase())
|
|
1506
|
+
}
|
|
1507
|
+
return Boolean(value)
|
|
1508
|
+
}
|
|
1509
|
+
|
|
1510
|
+
function supportsAnsi () {
|
|
1511
|
+
return process.stdout.isTTY // && process.env.TERM !== 'dumb'
|
|
1512
|
+
}
|
|
1513
|
+
|
|
1514
|
+
function dim (text) {
|
|
1515
|
+
return supportsAnsi() ? `\x1b[2m${text}\x1b[0m` : text
|
|
1516
|
+
}
|
|
1517
|
+
|
|
1518
|
+
const LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg;
|
|
1519
|
+
|
|
1520
|
+
// Parse src into an Object
|
|
1521
|
+
function parse (src) {
|
|
1522
|
+
const obj = {};
|
|
1523
|
+
|
|
1524
|
+
// Convert buffer to string
|
|
1525
|
+
let lines = src.toString();
|
|
1526
|
+
|
|
1527
|
+
// Convert line breaks to same format
|
|
1528
|
+
lines = lines.replace(/\r\n?/mg, '\n');
|
|
1529
|
+
|
|
1530
|
+
let match;
|
|
1531
|
+
while ((match = LINE.exec(lines)) != null) {
|
|
1532
|
+
const key = match[1];
|
|
1533
|
+
|
|
1534
|
+
// Default undefined or null to empty string
|
|
1535
|
+
let value = (match[2] || '');
|
|
1536
|
+
|
|
1537
|
+
// Remove whitespace
|
|
1538
|
+
value = value.trim();
|
|
1539
|
+
|
|
1540
|
+
// Check if double quoted
|
|
1541
|
+
const maybeQuote = value[0];
|
|
1542
|
+
|
|
1543
|
+
// Remove surrounding quotes
|
|
1544
|
+
value = value.replace(/^(['"`])([\s\S]*)\1$/mg, '$2');
|
|
1545
|
+
|
|
1546
|
+
// Expand newlines if double quoted
|
|
1547
|
+
if (maybeQuote === '"') {
|
|
1548
|
+
value = value.replace(/\\n/g, '\n');
|
|
1549
|
+
value = value.replace(/\\r/g, '\r');
|
|
1550
|
+
}
|
|
1551
|
+
|
|
1552
|
+
// Add to object
|
|
1553
|
+
obj[key] = value;
|
|
1554
|
+
}
|
|
1555
|
+
|
|
1556
|
+
return obj
|
|
1557
|
+
}
|
|
1558
|
+
|
|
1559
|
+
function _parseVault (options) {
|
|
1560
|
+
options = options || {};
|
|
1561
|
+
|
|
1562
|
+
const vaultPath = _vaultPath(options);
|
|
1563
|
+
options.path = vaultPath; // parse .env.vault
|
|
1564
|
+
const result = DotenvModule.configDotenv(options);
|
|
1565
|
+
if (!result.parsed) {
|
|
1566
|
+
const err = new Error(`MISSING_DATA: Cannot parse ${vaultPath} for an unknown reason`);
|
|
1567
|
+
err.code = 'MISSING_DATA';
|
|
1568
|
+
throw err
|
|
1569
|
+
}
|
|
1570
|
+
|
|
1571
|
+
// handle scenario for comma separated keys - for use with key rotation
|
|
1572
|
+
// example: DOTENV_KEY="dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=prod,dotenv://:key_7890@dotenvx.com/vault/.env.vault?environment=prod"
|
|
1573
|
+
const keys = _dotenvKey(options).split(',');
|
|
1574
|
+
const length = keys.length;
|
|
1575
|
+
|
|
1576
|
+
let decrypted;
|
|
1577
|
+
for (let i = 0; i < length; i++) {
|
|
1578
|
+
try {
|
|
1579
|
+
// Get full key
|
|
1580
|
+
const key = keys[i].trim();
|
|
1581
|
+
|
|
1582
|
+
// Get instructions for decrypt
|
|
1583
|
+
const attrs = _instructions(result, key);
|
|
1584
|
+
|
|
1585
|
+
// Decrypt
|
|
1586
|
+
decrypted = DotenvModule.decrypt(attrs.ciphertext, attrs.key);
|
|
1587
|
+
|
|
1588
|
+
break
|
|
1589
|
+
} catch (error) {
|
|
1590
|
+
// last key
|
|
1591
|
+
if (i + 1 >= length) {
|
|
1592
|
+
throw error
|
|
1593
|
+
}
|
|
1594
|
+
// try next key
|
|
1595
|
+
}
|
|
1596
|
+
}
|
|
1597
|
+
|
|
1598
|
+
// Parse decrypted .env string
|
|
1599
|
+
return DotenvModule.parse(decrypted)
|
|
1600
|
+
}
|
|
1601
|
+
|
|
1602
|
+
function _warn (message) {
|
|
1603
|
+
console.error(`⚠ ${message}`);
|
|
1604
|
+
}
|
|
1605
|
+
|
|
1606
|
+
function _debug (message) {
|
|
1607
|
+
console.log(`┆ ${message}`);
|
|
1608
|
+
}
|
|
1609
|
+
|
|
1610
|
+
function _log (message) {
|
|
1611
|
+
console.log(`◇ ${message}`);
|
|
1612
|
+
}
|
|
1613
|
+
|
|
1614
|
+
function _dotenvKey (options) {
|
|
1615
|
+
// prioritize developer directly setting options.DOTENV_KEY
|
|
1616
|
+
if (options && options.DOTENV_KEY && options.DOTENV_KEY.length > 0) {
|
|
1617
|
+
return options.DOTENV_KEY
|
|
1618
|
+
}
|
|
1619
|
+
|
|
1620
|
+
// secondary infra already contains a DOTENV_KEY environment variable
|
|
1621
|
+
if (process.env.DOTENV_KEY && process.env.DOTENV_KEY.length > 0) {
|
|
1622
|
+
return process.env.DOTENV_KEY
|
|
1623
|
+
}
|
|
1624
|
+
|
|
1625
|
+
// fallback to empty string
|
|
1626
|
+
return ''
|
|
1627
|
+
}
|
|
1628
|
+
|
|
1629
|
+
function _instructions (result, dotenvKey) {
|
|
1630
|
+
// Parse DOTENV_KEY. Format is a URI
|
|
1631
|
+
let uri;
|
|
1632
|
+
try {
|
|
1633
|
+
uri = new URL(dotenvKey);
|
|
1634
|
+
} catch (error) {
|
|
1635
|
+
if (error.code === 'ERR_INVALID_URL') {
|
|
1636
|
+
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');
|
|
1637
|
+
err.code = 'INVALID_DOTENV_KEY';
|
|
1638
|
+
throw err
|
|
1639
|
+
}
|
|
1640
|
+
|
|
1641
|
+
throw error
|
|
1642
|
+
}
|
|
1643
|
+
|
|
1644
|
+
// Get decrypt key
|
|
1645
|
+
const key = uri.password;
|
|
1646
|
+
if (!key) {
|
|
1647
|
+
const err = new Error('INVALID_DOTENV_KEY: Missing key part');
|
|
1648
|
+
err.code = 'INVALID_DOTENV_KEY';
|
|
1649
|
+
throw err
|
|
1650
|
+
}
|
|
1651
|
+
|
|
1652
|
+
// Get environment
|
|
1653
|
+
const environment = uri.searchParams.get('environment');
|
|
1654
|
+
if (!environment) {
|
|
1655
|
+
const err = new Error('INVALID_DOTENV_KEY: Missing environment part');
|
|
1656
|
+
err.code = 'INVALID_DOTENV_KEY';
|
|
1657
|
+
throw err
|
|
1658
|
+
}
|
|
1659
|
+
|
|
1660
|
+
// Get ciphertext payload
|
|
1661
|
+
const environmentKey = `DOTENV_VAULT_${environment.toUpperCase()}`;
|
|
1662
|
+
const ciphertext = result.parsed[environmentKey]; // DOTENV_VAULT_PRODUCTION
|
|
1663
|
+
if (!ciphertext) {
|
|
1664
|
+
const err = new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${environmentKey} in your .env.vault file.`);
|
|
1665
|
+
err.code = 'NOT_FOUND_DOTENV_ENVIRONMENT';
|
|
1666
|
+
throw err
|
|
1667
|
+
}
|
|
1668
|
+
|
|
1669
|
+
return { ciphertext, key }
|
|
1670
|
+
}
|
|
1671
|
+
|
|
1672
|
+
function _vaultPath (options) {
|
|
1673
|
+
let possibleVaultPath = null;
|
|
1674
|
+
|
|
1675
|
+
if (options && options.path && options.path.length > 0) {
|
|
1676
|
+
if (Array.isArray(options.path)) {
|
|
1677
|
+
for (const filepath of options.path) {
|
|
1678
|
+
if (fs.existsSync(filepath)) {
|
|
1679
|
+
possibleVaultPath = filepath.endsWith('.vault') ? filepath : `${filepath}.vault`;
|
|
1680
|
+
}
|
|
1681
|
+
}
|
|
1682
|
+
} else {
|
|
1683
|
+
possibleVaultPath = options.path.endsWith('.vault') ? options.path : `${options.path}.vault`;
|
|
1684
|
+
}
|
|
1685
|
+
} else {
|
|
1686
|
+
possibleVaultPath = path.resolve(process.cwd(), '.env.vault');
|
|
1687
|
+
}
|
|
1688
|
+
|
|
1689
|
+
if (fs.existsSync(possibleVaultPath)) {
|
|
1690
|
+
return possibleVaultPath
|
|
1691
|
+
}
|
|
1692
|
+
|
|
1693
|
+
return null
|
|
1694
|
+
}
|
|
1695
|
+
|
|
1696
|
+
function _resolveHome (envPath) {
|
|
1697
|
+
return envPath[0] === '~' ? path.join(os.homedir(), envPath.slice(1)) : envPath
|
|
1698
|
+
}
|
|
1699
|
+
|
|
1700
|
+
function _configVault (options) {
|
|
1701
|
+
const debug = parseBoolean(process.env.DOTENV_CONFIG_DEBUG || (options && options.debug));
|
|
1702
|
+
const quiet = parseBoolean(process.env.DOTENV_CONFIG_QUIET || (options && options.quiet));
|
|
1703
|
+
|
|
1704
|
+
if (debug || !quiet) {
|
|
1705
|
+
_log('loading env from encrypted .env.vault');
|
|
1706
|
+
}
|
|
1707
|
+
|
|
1708
|
+
const parsed = DotenvModule._parseVault(options);
|
|
1709
|
+
|
|
1710
|
+
let processEnv = process.env;
|
|
1711
|
+
if (options && options.processEnv != null) {
|
|
1712
|
+
processEnv = options.processEnv;
|
|
1713
|
+
}
|
|
1714
|
+
|
|
1715
|
+
DotenvModule.populate(processEnv, parsed, options);
|
|
1716
|
+
|
|
1717
|
+
return { parsed }
|
|
1718
|
+
}
|
|
1719
|
+
|
|
1720
|
+
function configDotenv (options) {
|
|
1721
|
+
const dotenvPath = path.resolve(process.cwd(), '.env');
|
|
1722
|
+
let encoding = 'utf8';
|
|
1723
|
+
let processEnv = process.env;
|
|
1724
|
+
if (options && options.processEnv != null) {
|
|
1725
|
+
processEnv = options.processEnv;
|
|
1726
|
+
}
|
|
1727
|
+
let debug = parseBoolean(processEnv.DOTENV_CONFIG_DEBUG || (options && options.debug));
|
|
1728
|
+
let quiet = parseBoolean(processEnv.DOTENV_CONFIG_QUIET || (options && options.quiet));
|
|
1729
|
+
|
|
1730
|
+
if (options && options.encoding) {
|
|
1731
|
+
encoding = options.encoding;
|
|
1732
|
+
} else {
|
|
1733
|
+
if (debug) {
|
|
1734
|
+
_debug('no encoding is specified (UTF-8 is used by default)');
|
|
1735
|
+
}
|
|
1736
|
+
}
|
|
1737
|
+
|
|
1738
|
+
let optionPaths = [dotenvPath]; // default, look for .env
|
|
1739
|
+
if (options && options.path) {
|
|
1740
|
+
if (!Array.isArray(options.path)) {
|
|
1741
|
+
optionPaths = [_resolveHome(options.path)];
|
|
1742
|
+
} else {
|
|
1743
|
+
optionPaths = []; // reset default
|
|
1744
|
+
for (const filepath of options.path) {
|
|
1745
|
+
optionPaths.push(_resolveHome(filepath));
|
|
1746
|
+
}
|
|
1747
|
+
}
|
|
1748
|
+
}
|
|
1749
|
+
|
|
1750
|
+
// Build the parsed data in a temporary object (because we need to return it). Once we have the final
|
|
1751
|
+
// parsed data, we will combine it with process.env (or options.processEnv if provided).
|
|
1752
|
+
let lastError;
|
|
1753
|
+
const parsedAll = {};
|
|
1754
|
+
for (const path of optionPaths) {
|
|
1755
|
+
try {
|
|
1756
|
+
// Specifying an encoding returns a string instead of a buffer
|
|
1757
|
+
const parsed = DotenvModule.parse(fs.readFileSync(path, { encoding }));
|
|
1758
|
+
|
|
1759
|
+
DotenvModule.populate(parsedAll, parsed, options);
|
|
1760
|
+
} catch (e) {
|
|
1761
|
+
if (debug) {
|
|
1762
|
+
_debug(`failed to load ${path} ${e.message}`);
|
|
1763
|
+
}
|
|
1764
|
+
lastError = e;
|
|
1765
|
+
}
|
|
1766
|
+
}
|
|
1767
|
+
|
|
1768
|
+
const populated = DotenvModule.populate(processEnv, parsedAll, options);
|
|
1769
|
+
|
|
1770
|
+
// handle user settings DOTENV_CONFIG_ options inside .env file(s)
|
|
1771
|
+
debug = parseBoolean(processEnv.DOTENV_CONFIG_DEBUG || debug);
|
|
1772
|
+
quiet = parseBoolean(processEnv.DOTENV_CONFIG_QUIET || quiet);
|
|
1773
|
+
|
|
1774
|
+
if (debug || !quiet) {
|
|
1775
|
+
const keysCount = Object.keys(populated).length;
|
|
1776
|
+
const shortPaths = [];
|
|
1777
|
+
for (const filePath of optionPaths) {
|
|
1778
|
+
try {
|
|
1779
|
+
const relative = path.relative(process.cwd(), filePath);
|
|
1780
|
+
shortPaths.push(relative);
|
|
1781
|
+
} catch (e) {
|
|
1782
|
+
if (debug) {
|
|
1783
|
+
_debug(`failed to load ${filePath} ${e.message}`);
|
|
1784
|
+
}
|
|
1785
|
+
lastError = e;
|
|
1786
|
+
}
|
|
1787
|
+
}
|
|
1788
|
+
|
|
1789
|
+
_log(`injected env (${keysCount}) from ${shortPaths.join(',')} ${dim(`// tip: ${_getRandomTip()}`)}`);
|
|
1790
|
+
}
|
|
1791
|
+
|
|
1792
|
+
if (lastError) {
|
|
1793
|
+
return { parsed: parsedAll, error: lastError }
|
|
1794
|
+
} else {
|
|
1795
|
+
return { parsed: parsedAll }
|
|
1796
|
+
}
|
|
1797
|
+
}
|
|
1798
|
+
|
|
1799
|
+
// Populates process.env from .env file
|
|
1800
|
+
function config (options) {
|
|
1801
|
+
// fallback to original dotenv if DOTENV_KEY is not set
|
|
1802
|
+
if (_dotenvKey(options).length === 0) {
|
|
1803
|
+
return DotenvModule.configDotenv(options)
|
|
1804
|
+
}
|
|
1805
|
+
|
|
1806
|
+
const vaultPath = _vaultPath(options);
|
|
1807
|
+
|
|
1808
|
+
// dotenvKey exists but .env.vault file does not exist
|
|
1809
|
+
if (!vaultPath) {
|
|
1810
|
+
_warn(`you set DOTENV_KEY but you are missing a .env.vault file at ${vaultPath}`);
|
|
1811
|
+
|
|
1812
|
+
return DotenvModule.configDotenv(options)
|
|
1813
|
+
}
|
|
1814
|
+
|
|
1815
|
+
return DotenvModule._configVault(options)
|
|
1816
|
+
}
|
|
1817
|
+
|
|
1818
|
+
function decrypt (encrypted, keyStr) {
|
|
1819
|
+
const key = Buffer.from(keyStr.slice(-64), 'hex');
|
|
1820
|
+
let ciphertext = Buffer.from(encrypted, 'base64');
|
|
1821
|
+
|
|
1822
|
+
const nonce = ciphertext.subarray(0, 12);
|
|
1823
|
+
const authTag = ciphertext.subarray(-16);
|
|
1824
|
+
ciphertext = ciphertext.subarray(12, -16);
|
|
1825
|
+
|
|
1826
|
+
try {
|
|
1827
|
+
const aesgcm = crypto.createDecipheriv('aes-256-gcm', key, nonce);
|
|
1828
|
+
aesgcm.setAuthTag(authTag);
|
|
1829
|
+
return `${aesgcm.update(ciphertext)}${aesgcm.final()}`
|
|
1830
|
+
} catch (error) {
|
|
1831
|
+
const isRange = error instanceof RangeError;
|
|
1832
|
+
const invalidKeyLength = error.message === 'Invalid key length';
|
|
1833
|
+
const decryptionFailed = error.message === 'Unsupported state or unable to authenticate data';
|
|
1834
|
+
|
|
1835
|
+
if (isRange || invalidKeyLength) {
|
|
1836
|
+
const err = new Error('INVALID_DOTENV_KEY: It must be 64 characters long (or more)');
|
|
1837
|
+
err.code = 'INVALID_DOTENV_KEY';
|
|
1838
|
+
throw err
|
|
1839
|
+
} else if (decryptionFailed) {
|
|
1840
|
+
const err = new Error('DECRYPTION_FAILED: Please check your DOTENV_KEY');
|
|
1841
|
+
err.code = 'DECRYPTION_FAILED';
|
|
1842
|
+
throw err
|
|
1843
|
+
} else {
|
|
1844
|
+
throw error
|
|
1845
|
+
}
|
|
1846
|
+
}
|
|
1847
|
+
}
|
|
1848
|
+
|
|
1849
|
+
// Populate process.env with parsed values
|
|
1850
|
+
function populate (processEnv, parsed, options = {}) {
|
|
1851
|
+
const debug = Boolean(options && options.debug);
|
|
1852
|
+
const override = Boolean(options && options.override);
|
|
1853
|
+
const populated = {};
|
|
1854
|
+
|
|
1855
|
+
if (typeof parsed !== 'object') {
|
|
1856
|
+
const err = new Error('OBJECT_REQUIRED: Please check the processEnv argument being passed to populate');
|
|
1857
|
+
err.code = 'OBJECT_REQUIRED';
|
|
1858
|
+
throw err
|
|
1859
|
+
}
|
|
1860
|
+
|
|
1861
|
+
// Set process.env
|
|
1862
|
+
for (const key of Object.keys(parsed)) {
|
|
1863
|
+
if (Object.prototype.hasOwnProperty.call(processEnv, key)) {
|
|
1864
|
+
if (override === true) {
|
|
1865
|
+
processEnv[key] = parsed[key];
|
|
1866
|
+
populated[key] = parsed[key];
|
|
1867
|
+
}
|
|
1868
|
+
|
|
1869
|
+
if (debug) {
|
|
1870
|
+
if (override === true) {
|
|
1871
|
+
_debug(`"${key}" is already defined and WAS overwritten`);
|
|
1872
|
+
} else {
|
|
1873
|
+
_debug(`"${key}" is already defined and was NOT overwritten`);
|
|
1874
|
+
}
|
|
1875
|
+
}
|
|
1876
|
+
} else {
|
|
1877
|
+
processEnv[key] = parsed[key];
|
|
1878
|
+
populated[key] = parsed[key];
|
|
1879
|
+
}
|
|
1880
|
+
}
|
|
1881
|
+
|
|
1882
|
+
return populated
|
|
1883
|
+
}
|
|
1884
|
+
|
|
1885
|
+
const DotenvModule = {
|
|
1886
|
+
configDotenv,
|
|
1887
|
+
_configVault,
|
|
1888
|
+
_parseVault,
|
|
1889
|
+
config,
|
|
1890
|
+
decrypt,
|
|
1891
|
+
parse,
|
|
1892
|
+
populate
|
|
1893
|
+
};
|
|
1894
|
+
|
|
1895
|
+
main.exports.configDotenv = DotenvModule.configDotenv;
|
|
1896
|
+
main.exports._configVault = DotenvModule._configVault;
|
|
1897
|
+
main.exports._parseVault = DotenvModule._parseVault;
|
|
1898
|
+
main.exports.config = DotenvModule.config;
|
|
1899
|
+
main.exports.decrypt = DotenvModule.decrypt;
|
|
1900
|
+
main.exports.parse = DotenvModule.parse;
|
|
1901
|
+
main.exports.populate = DotenvModule.populate;
|
|
1902
|
+
|
|
1903
|
+
main.exports = DotenvModule;
|
|
1904
|
+
return main.exports;
|
|
1905
|
+
}
|
|
1906
|
+
|
|
1907
|
+
var envOptions;
|
|
1908
|
+
var hasRequiredEnvOptions;
|
|
1909
|
+
|
|
1910
|
+
function requireEnvOptions () {
|
|
1911
|
+
if (hasRequiredEnvOptions) return envOptions;
|
|
1912
|
+
hasRequiredEnvOptions = 1;
|
|
1913
|
+
// ../config.js accepts options via environment variables
|
|
1914
|
+
const options = {};
|
|
1915
|
+
|
|
1916
|
+
if (process.env.DOTENV_CONFIG_ENCODING != null) {
|
|
1917
|
+
options.encoding = process.env.DOTENV_CONFIG_ENCODING;
|
|
1918
|
+
}
|
|
1919
|
+
|
|
1920
|
+
if (process.env.DOTENV_CONFIG_PATH != null) {
|
|
1921
|
+
options.path = process.env.DOTENV_CONFIG_PATH;
|
|
1922
|
+
}
|
|
1923
|
+
|
|
1924
|
+
if (process.env.DOTENV_CONFIG_QUIET != null) {
|
|
1925
|
+
options.quiet = process.env.DOTENV_CONFIG_QUIET;
|
|
1926
|
+
}
|
|
1927
|
+
|
|
1928
|
+
if (process.env.DOTENV_CONFIG_DEBUG != null) {
|
|
1929
|
+
options.debug = process.env.DOTENV_CONFIG_DEBUG;
|
|
1930
|
+
}
|
|
1931
|
+
|
|
1932
|
+
if (process.env.DOTENV_CONFIG_OVERRIDE != null) {
|
|
1933
|
+
options.override = process.env.DOTENV_CONFIG_OVERRIDE;
|
|
1934
|
+
}
|
|
1935
|
+
|
|
1936
|
+
if (process.env.DOTENV_CONFIG_DOTENV_KEY != null) {
|
|
1937
|
+
options.DOTENV_KEY = process.env.DOTENV_CONFIG_DOTENV_KEY;
|
|
1938
|
+
}
|
|
1939
|
+
|
|
1940
|
+
envOptions = options;
|
|
1941
|
+
return envOptions;
|
|
1942
|
+
}
|
|
1943
|
+
|
|
1944
|
+
var cliOptions;
|
|
1945
|
+
var hasRequiredCliOptions;
|
|
1946
|
+
|
|
1947
|
+
function requireCliOptions () {
|
|
1948
|
+
if (hasRequiredCliOptions) return cliOptions;
|
|
1949
|
+
hasRequiredCliOptions = 1;
|
|
1950
|
+
const re = /^dotenv_config_(encoding|path|quiet|debug|override|DOTENV_KEY)=(.+)$/;
|
|
1951
|
+
|
|
1952
|
+
cliOptions = function optionMatcher (args) {
|
|
1953
|
+
const options = args.reduce(function (acc, cur) {
|
|
1954
|
+
const matches = cur.match(re);
|
|
1955
|
+
if (matches) {
|
|
1956
|
+
acc[matches[1]] = matches[2];
|
|
1957
|
+
}
|
|
1958
|
+
return acc
|
|
1959
|
+
}, {});
|
|
1960
|
+
|
|
1961
|
+
if (!('quiet' in options)) {
|
|
1962
|
+
options.quiet = 'true';
|
|
1963
|
+
}
|
|
1964
|
+
|
|
1965
|
+
return options
|
|
1966
|
+
};
|
|
1967
|
+
return cliOptions;
|
|
1968
|
+
}
|
|
1969
|
+
|
|
1970
|
+
var hasRequiredConfig;
|
|
1971
|
+
|
|
1972
|
+
function requireConfig () {
|
|
1973
|
+
if (hasRequiredConfig) return config$1;
|
|
1974
|
+
hasRequiredConfig = 1;
|
|
1975
|
+
(function () {
|
|
1976
|
+
requireMain().config(
|
|
1977
|
+
Object.assign(
|
|
1978
|
+
{},
|
|
1979
|
+
requireEnvOptions(),
|
|
1980
|
+
requireCliOptions()(process.argv)
|
|
1981
|
+
)
|
|
1982
|
+
);
|
|
1983
|
+
})();
|
|
1984
|
+
return config$1;
|
|
1985
|
+
}
|
|
1986
|
+
|
|
1987
|
+
requireConfig();
|
|
1988
|
+
|
|
2065
1989
|
var picocolors = {exports: {}};
|
|
2066
1990
|
|
|
2067
|
-
|
|
2068
|
-
let isColorSupported =
|
|
2069
|
-
!(!!env.NO_COLOR || argv.includes("--no-color")) &&
|
|
2070
|
-
(!!env.FORCE_COLOR || argv.includes("--color") || p.platform === "win32" || ((p.stdout || {}).isTTY && env.TERM !== "dumb") || !!env.CI);
|
|
1991
|
+
var hasRequiredPicocolors;
|
|
2071
1992
|
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
1993
|
+
function requirePicocolors () {
|
|
1994
|
+
if (hasRequiredPicocolors) return picocolors.exports;
|
|
1995
|
+
hasRequiredPicocolors = 1;
|
|
1996
|
+
let p = process || {}, argv = p.argv || [], env = p.env || {};
|
|
1997
|
+
let isColorSupported =
|
|
1998
|
+
!(!!env.NO_COLOR || argv.includes("--no-color")) &&
|
|
1999
|
+
(!!env.FORCE_COLOR || argv.includes("--color") || p.platform === "win32" || ((p.stdout || {}).isTTY && env.TERM !== "dumb") || !!env.CI);
|
|
2000
|
+
|
|
2001
|
+
let formatter = (open, close, replace = open) =>
|
|
2002
|
+
input => {
|
|
2003
|
+
let string = "" + input, index = string.indexOf(close, open.length);
|
|
2004
|
+
return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close
|
|
2005
|
+
};
|
|
2006
|
+
|
|
2007
|
+
let replaceClose = (string, close, replace, index) => {
|
|
2008
|
+
let result = "", cursor = 0;
|
|
2009
|
+
do {
|
|
2010
|
+
result += string.substring(cursor, index) + replace;
|
|
2011
|
+
cursor = index + close.length;
|
|
2012
|
+
index = string.indexOf(close, cursor);
|
|
2013
|
+
} while (~index)
|
|
2014
|
+
return result + string.substring(cursor)
|
|
2076
2015
|
};
|
|
2077
2016
|
|
|
2078
|
-
let
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2017
|
+
let createColors = (enabled = isColorSupported) => {
|
|
2018
|
+
let f = enabled ? formatter : () => String;
|
|
2019
|
+
return {
|
|
2020
|
+
isColorSupported: enabled,
|
|
2021
|
+
reset: f("\x1b[0m", "\x1b[0m"),
|
|
2022
|
+
bold: f("\x1b[1m", "\x1b[22m", "\x1b[22m\x1b[1m"),
|
|
2023
|
+
dim: f("\x1b[2m", "\x1b[22m", "\x1b[22m\x1b[2m"),
|
|
2024
|
+
italic: f("\x1b[3m", "\x1b[23m"),
|
|
2025
|
+
underline: f("\x1b[4m", "\x1b[24m"),
|
|
2026
|
+
inverse: f("\x1b[7m", "\x1b[27m"),
|
|
2027
|
+
hidden: f("\x1b[8m", "\x1b[28m"),
|
|
2028
|
+
strikethrough: f("\x1b[9m", "\x1b[29m"),
|
|
2029
|
+
|
|
2030
|
+
black: f("\x1b[30m", "\x1b[39m"),
|
|
2031
|
+
red: f("\x1b[31m", "\x1b[39m"),
|
|
2032
|
+
green: f("\x1b[32m", "\x1b[39m"),
|
|
2033
|
+
yellow: f("\x1b[33m", "\x1b[39m"),
|
|
2034
|
+
blue: f("\x1b[34m", "\x1b[39m"),
|
|
2035
|
+
magenta: f("\x1b[35m", "\x1b[39m"),
|
|
2036
|
+
cyan: f("\x1b[36m", "\x1b[39m"),
|
|
2037
|
+
white: f("\x1b[37m", "\x1b[39m"),
|
|
2038
|
+
gray: f("\x1b[90m", "\x1b[39m"),
|
|
2039
|
+
|
|
2040
|
+
bgBlack: f("\x1b[40m", "\x1b[49m"),
|
|
2041
|
+
bgRed: f("\x1b[41m", "\x1b[49m"),
|
|
2042
|
+
bgGreen: f("\x1b[42m", "\x1b[49m"),
|
|
2043
|
+
bgYellow: f("\x1b[43m", "\x1b[49m"),
|
|
2044
|
+
bgBlue: f("\x1b[44m", "\x1b[49m"),
|
|
2045
|
+
bgMagenta: f("\x1b[45m", "\x1b[49m"),
|
|
2046
|
+
bgCyan: f("\x1b[46m", "\x1b[49m"),
|
|
2047
|
+
bgWhite: f("\x1b[47m", "\x1b[49m"),
|
|
2048
|
+
|
|
2049
|
+
blackBright: f("\x1b[90m", "\x1b[39m"),
|
|
2050
|
+
redBright: f("\x1b[91m", "\x1b[39m"),
|
|
2051
|
+
greenBright: f("\x1b[92m", "\x1b[39m"),
|
|
2052
|
+
yellowBright: f("\x1b[93m", "\x1b[39m"),
|
|
2053
|
+
blueBright: f("\x1b[94m", "\x1b[39m"),
|
|
2054
|
+
magentaBright: f("\x1b[95m", "\x1b[39m"),
|
|
2055
|
+
cyanBright: f("\x1b[96m", "\x1b[39m"),
|
|
2056
|
+
whiteBright: f("\x1b[97m", "\x1b[39m"),
|
|
2057
|
+
|
|
2058
|
+
bgBlackBright: f("\x1b[100m", "\x1b[49m"),
|
|
2059
|
+
bgRedBright: f("\x1b[101m", "\x1b[49m"),
|
|
2060
|
+
bgGreenBright: f("\x1b[102m", "\x1b[49m"),
|
|
2061
|
+
bgYellowBright: f("\x1b[103m", "\x1b[49m"),
|
|
2062
|
+
bgBlueBright: f("\x1b[104m", "\x1b[49m"),
|
|
2063
|
+
bgMagentaBright: f("\x1b[105m", "\x1b[49m"),
|
|
2064
|
+
bgCyanBright: f("\x1b[106m", "\x1b[49m"),
|
|
2065
|
+
bgWhiteBright: f("\x1b[107m", "\x1b[49m"),
|
|
2066
|
+
}
|
|
2067
|
+
};
|
|
2087
2068
|
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
return
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
dim: f("\x1b[2m", "\x1b[22m", "\x1b[22m\x1b[2m"),
|
|
2095
|
-
italic: f("\x1b[3m", "\x1b[23m"),
|
|
2096
|
-
underline: f("\x1b[4m", "\x1b[24m"),
|
|
2097
|
-
inverse: f("\x1b[7m", "\x1b[27m"),
|
|
2098
|
-
hidden: f("\x1b[8m", "\x1b[28m"),
|
|
2099
|
-
strikethrough: f("\x1b[9m", "\x1b[29m"),
|
|
2100
|
-
|
|
2101
|
-
black: f("\x1b[30m", "\x1b[39m"),
|
|
2102
|
-
red: f("\x1b[31m", "\x1b[39m"),
|
|
2103
|
-
green: f("\x1b[32m", "\x1b[39m"),
|
|
2104
|
-
yellow: f("\x1b[33m", "\x1b[39m"),
|
|
2105
|
-
blue: f("\x1b[34m", "\x1b[39m"),
|
|
2106
|
-
magenta: f("\x1b[35m", "\x1b[39m"),
|
|
2107
|
-
cyan: f("\x1b[36m", "\x1b[39m"),
|
|
2108
|
-
white: f("\x1b[37m", "\x1b[39m"),
|
|
2109
|
-
gray: f("\x1b[90m", "\x1b[39m"),
|
|
2110
|
-
|
|
2111
|
-
bgBlack: f("\x1b[40m", "\x1b[49m"),
|
|
2112
|
-
bgRed: f("\x1b[41m", "\x1b[49m"),
|
|
2113
|
-
bgGreen: f("\x1b[42m", "\x1b[49m"),
|
|
2114
|
-
bgYellow: f("\x1b[43m", "\x1b[49m"),
|
|
2115
|
-
bgBlue: f("\x1b[44m", "\x1b[49m"),
|
|
2116
|
-
bgMagenta: f("\x1b[45m", "\x1b[49m"),
|
|
2117
|
-
bgCyan: f("\x1b[46m", "\x1b[49m"),
|
|
2118
|
-
bgWhite: f("\x1b[47m", "\x1b[49m"),
|
|
2119
|
-
|
|
2120
|
-
blackBright: f("\x1b[90m", "\x1b[39m"),
|
|
2121
|
-
redBright: f("\x1b[91m", "\x1b[39m"),
|
|
2122
|
-
greenBright: f("\x1b[92m", "\x1b[39m"),
|
|
2123
|
-
yellowBright: f("\x1b[93m", "\x1b[39m"),
|
|
2124
|
-
blueBright: f("\x1b[94m", "\x1b[39m"),
|
|
2125
|
-
magentaBright: f("\x1b[95m", "\x1b[39m"),
|
|
2126
|
-
cyanBright: f("\x1b[96m", "\x1b[39m"),
|
|
2127
|
-
whiteBright: f("\x1b[97m", "\x1b[39m"),
|
|
2128
|
-
|
|
2129
|
-
bgBlackBright: f("\x1b[100m", "\x1b[49m"),
|
|
2130
|
-
bgRedBright: f("\x1b[101m", "\x1b[49m"),
|
|
2131
|
-
bgGreenBright: f("\x1b[102m", "\x1b[49m"),
|
|
2132
|
-
bgYellowBright: f("\x1b[103m", "\x1b[49m"),
|
|
2133
|
-
bgBlueBright: f("\x1b[104m", "\x1b[49m"),
|
|
2134
|
-
bgMagentaBright: f("\x1b[105m", "\x1b[49m"),
|
|
2135
|
-
bgCyanBright: f("\x1b[106m", "\x1b[49m"),
|
|
2136
|
-
bgWhiteBright: f("\x1b[107m", "\x1b[49m"),
|
|
2137
|
-
}
|
|
2138
|
-
};
|
|
2139
|
-
|
|
2140
|
-
picocolors.exports = createColors();
|
|
2141
|
-
picocolors.exports.createColors = createColors;
|
|
2142
|
-
|
|
2143
|
-
var picocolorsExports = picocolors.exports;
|
|
2069
|
+
picocolors.exports = createColors();
|
|
2070
|
+
picocolors.exports.createColors = createColors;
|
|
2071
|
+
return picocolors.exports;
|
|
2072
|
+
}
|
|
2073
|
+
|
|
2074
|
+
var picocolorsExports = /*@__PURE__*/ requirePicocolors();
|
|
2144
2075
|
const c = /*@__PURE__*/getDefaultExportFromCjs$2(picocolorsExports);
|
|
2145
2076
|
|
|
2077
|
+
const formatConfig = {
|
|
2078
|
+
arrowParens: "always",
|
|
2079
|
+
bracketSameLine: false,
|
|
2080
|
+
bracketSpacing: true,
|
|
2081
|
+
endOfLine: "lf",
|
|
2082
|
+
printWidth: 80,
|
|
2083
|
+
quoteProps: "as-needed",
|
|
2084
|
+
semi: true,
|
|
2085
|
+
singleQuote: false,
|
|
2086
|
+
tabWidth: 2,
|
|
2087
|
+
trailingComma: "all",
|
|
2088
|
+
useTabs: false
|
|
2089
|
+
};
|
|
2090
|
+
async function formatSource(fileName, sourceText, options) {
|
|
2091
|
+
const result = await format$1(fileName, sourceText, {
|
|
2092
|
+
...formatConfig,
|
|
2093
|
+
...options
|
|
2094
|
+
});
|
|
2095
|
+
if (result.errors.length) {
|
|
2096
|
+
const messages = result.errors.map((error) => error.message).filter(Boolean).join("\n");
|
|
2097
|
+
throw new Error(
|
|
2098
|
+
`Could not format ${fileName}${messages ? `:
|
|
2099
|
+
${messages}` : ""}`
|
|
2100
|
+
);
|
|
2101
|
+
}
|
|
2102
|
+
return result.code;
|
|
2103
|
+
}
|
|
2104
|
+
|
|
2146
2105
|
function isPlainObject$1(value) {
|
|
2147
2106
|
if (value === null || typeof value !== "object") {
|
|
2148
2107
|
return false;
|
|
@@ -2164,8 +2123,8 @@ function _defu(baseObject, defaults, namespace = ".", merger) {
|
|
|
2164
2123
|
if (!isPlainObject$1(defaults)) {
|
|
2165
2124
|
return _defu(baseObject, {}, namespace, merger);
|
|
2166
2125
|
}
|
|
2167
|
-
const object =
|
|
2168
|
-
for (const key
|
|
2126
|
+
const object = { ...defaults };
|
|
2127
|
+
for (const key of Object.keys(baseObject)) {
|
|
2169
2128
|
if (key === "__proto__" || key === "constructor") {
|
|
2170
2129
|
continue;
|
|
2171
2130
|
}
|
|
@@ -2200,7 +2159,7 @@ function createDefu(merger) {
|
|
|
2200
2159
|
const defu = createDefu();
|
|
2201
2160
|
|
|
2202
2161
|
// src/index.ts
|
|
2203
|
-
var
|
|
2162
|
+
var b = {
|
|
2204
2163
|
reset: [0, 0],
|
|
2205
2164
|
bold: [1, 22, "\x1B[22m\x1B[1m"],
|
|
2206
2165
|
dim: [2, 22, "\x1B[22m\x1B[2m"],
|
|
@@ -2243,44 +2202,45 @@ var d = {
|
|
|
2243
2202
|
bgCyanBright: [106, 49],
|
|
2244
2203
|
bgWhiteBright: [107, 49]
|
|
2245
2204
|
};
|
|
2246
|
-
function
|
|
2205
|
+
function i(e) {
|
|
2247
2206
|
return String(e);
|
|
2248
2207
|
}
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
function
|
|
2252
|
-
let e = typeof process != "undefined" ? process : void 0,
|
|
2253
|
-
return !("NO_COLOR" in
|
|
2208
|
+
i.open = "";
|
|
2209
|
+
i.close = "";
|
|
2210
|
+
function B() {
|
|
2211
|
+
let e = typeof process != "undefined" ? process : void 0, r = (e == null ? void 0 : e.env) || {}, a = r.FORCE_TTY !== "false", l = (e == null ? void 0 : e.argv) || [];
|
|
2212
|
+
return !("NO_COLOR" in r || l.includes("--no-color")) && ("FORCE_COLOR" in r || l.includes("--color") || (e == null ? void 0 : e.platform) === "win32" || a && r.TERM !== "dumb" || "CI" in r) || typeof window != "undefined" && !!window.chrome;
|
|
2254
2213
|
}
|
|
2255
|
-
function
|
|
2256
|
-
let
|
|
2257
|
-
let
|
|
2214
|
+
function C({ force: e } = {}) {
|
|
2215
|
+
let r = e || B(), a = (t, o, u, n) => {
|
|
2216
|
+
let g = "", s = 0;
|
|
2258
2217
|
do
|
|
2259
|
-
|
|
2260
|
-
while (~
|
|
2261
|
-
return
|
|
2262
|
-
},
|
|
2263
|
-
let
|
|
2264
|
-
let s = String(
|
|
2265
|
-
return ~
|
|
2218
|
+
g += t.substring(s, n) + u, s = n + o.length, n = t.indexOf(o, s);
|
|
2219
|
+
while (~n);
|
|
2220
|
+
return g + t.substring(s);
|
|
2221
|
+
}, l = (t, o, u = t) => {
|
|
2222
|
+
let n = (g) => {
|
|
2223
|
+
let s = String(g), h = s.indexOf(o, t.length);
|
|
2224
|
+
return ~h ? t + a(s, o, u, h) + o : t + s + o;
|
|
2266
2225
|
};
|
|
2267
|
-
return
|
|
2268
|
-
},
|
|
2269
|
-
isColorSupported:
|
|
2270
|
-
},
|
|
2271
|
-
for (let
|
|
2272
|
-
let
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
) :
|
|
2278
|
-
}
|
|
2279
|
-
return
|
|
2280
|
-
}
|
|
2281
|
-
var
|
|
2282
|
-
|
|
2283
|
-
|
|
2226
|
+
return n.open = t, n.close = o, n;
|
|
2227
|
+
}, c = {
|
|
2228
|
+
isColorSupported: r
|
|
2229
|
+
}, f = (t) => `\x1B[${t}m`;
|
|
2230
|
+
for (let t in b) {
|
|
2231
|
+
let o = b[t];
|
|
2232
|
+
c[t] = r ? l(
|
|
2233
|
+
f(o[0]),
|
|
2234
|
+
f(o[1]),
|
|
2235
|
+
o[2]
|
|
2236
|
+
) : i;
|
|
2237
|
+
}
|
|
2238
|
+
return c;
|
|
2239
|
+
}
|
|
2240
|
+
var d = C();
|
|
2241
|
+
var y = d;
|
|
2242
|
+
|
|
2243
|
+
function _mergeNamespaces$1(n, m) {
|
|
2284
2244
|
m.forEach(function (e) {
|
|
2285
2245
|
e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) {
|
|
2286
2246
|
if (k !== 'default' && !(k in n)) {
|
|
@@ -2575,7 +2535,7 @@ function nodeIsComment(node) {
|
|
|
2575
2535
|
function nodeIsFragment(node) {
|
|
2576
2536
|
return node.nodeType === FRAGMENT_NODE;
|
|
2577
2537
|
}
|
|
2578
|
-
|
|
2538
|
+
function serializeDOM(node, config, indentation, depth, refs, printer, filterNode) {
|
|
2579
2539
|
if (nodeIsText(node)) {
|
|
2580
2540
|
return printText(node.data, config);
|
|
2581
2541
|
}
|
|
@@ -2586,11 +2546,16 @@ const serialize$3 = (node, config, indentation, depth, refs, printer) => {
|
|
|
2586
2546
|
if (++depth > config.maxDepth) {
|
|
2587
2547
|
return printElementAsLeaf(type, config);
|
|
2588
2548
|
}
|
|
2549
|
+
const children = Array.prototype.slice.call(node.childNodes || node.children);
|
|
2550
|
+
const shadowChildren = nodeIsFragment(node) || !node.shadowRoot ? [] : Array.prototype.slice.call(node.shadowRoot.children);
|
|
2551
|
+
const resolvedChildren = children;
|
|
2552
|
+
const resolvedShadowChildren = shadowChildren;
|
|
2589
2553
|
return printElement(type, printProps(nodeIsFragment(node) ? [] : Array.from(node.attributes, (attr) => attr.name).sort(), nodeIsFragment(node) ? {} : [...node.attributes].reduce((props, attribute) => {
|
|
2590
2554
|
props[attribute.name] = attribute.value;
|
|
2591
2555
|
return props;
|
|
2592
|
-
}, {}), config, indentation + config.indent, depth, refs, printer), (
|
|
2593
|
-
}
|
|
2556
|
+
}, {}), config, indentation + config.indent, depth, refs, printer), (resolvedShadowChildren.length > 0 ? printShadowRoot(resolvedShadowChildren, config, indentation + config.indent, depth, refs, printer) : "") + printChildren(resolvedChildren, config, indentation + config.indent, depth, refs, printer), config, indentation);
|
|
2557
|
+
}
|
|
2558
|
+
const serialize$3 = (node, config, indentation, depth, refs, printer) => serializeDOM(node, config, indentation, depth, refs, printer);
|
|
2594
2559
|
const plugin$3 = {
|
|
2595
2560
|
serialize: serialize$3,
|
|
2596
2561
|
test: test$3
|
|
@@ -2836,7 +2801,7 @@ function requireReactIs$1 () {
|
|
|
2836
2801
|
var reactIsExports$1 = requireReactIs$1();
|
|
2837
2802
|
var index$1 = /*@__PURE__*/getDefaultExportFromCjs$1(reactIsExports$1);
|
|
2838
2803
|
|
|
2839
|
-
var ReactIs19 = /*#__PURE__*/_mergeNamespaces({
|
|
2804
|
+
var ReactIs19 = /*#__PURE__*/_mergeNamespaces$1({
|
|
2840
2805
|
__proto__: null,
|
|
2841
2806
|
default: index$1
|
|
2842
2807
|
}, [reactIsExports$1]);
|
|
@@ -2883,7 +2848,7 @@ function requireReactIs () {
|
|
|
2883
2848
|
var reactIsExports = requireReactIs();
|
|
2884
2849
|
var index = /*@__PURE__*/getDefaultExportFromCjs$1(reactIsExports);
|
|
2885
2850
|
|
|
2886
|
-
var ReactIs18 = /*#__PURE__*/_mergeNamespaces({
|
|
2851
|
+
var ReactIs18 = /*#__PURE__*/_mergeNamespaces$1({
|
|
2887
2852
|
__proto__: null,
|
|
2888
2853
|
default: index
|
|
2889
2854
|
}, [reactIsExports]);
|
|
@@ -3172,15 +3137,30 @@ function findPlugin(plugins, val) {
|
|
|
3172
3137
|
return null;
|
|
3173
3138
|
}
|
|
3174
3139
|
function printer(val, config, indentation, depth, refs, hasCalledToJSON) {
|
|
3140
|
+
let result;
|
|
3175
3141
|
const plugin = findPlugin(config.plugins, val);
|
|
3176
3142
|
if (plugin !== null) {
|
|
3177
|
-
|
|
3143
|
+
result = printPlugin(plugin, val, config, indentation, depth, refs);
|
|
3144
|
+
} else {
|
|
3145
|
+
const basicResult = printBasicValue(val, config.printFunctionName, config.escapeRegex, config.escapeString);
|
|
3146
|
+
if (basicResult !== null) {
|
|
3147
|
+
result = basicResult;
|
|
3148
|
+
} else {
|
|
3149
|
+
result = printComplexValue(val, config, indentation, depth, refs, hasCalledToJSON);
|
|
3150
|
+
}
|
|
3178
3151
|
}
|
|
3179
|
-
|
|
3180
|
-
|
|
3181
|
-
|
|
3152
|
+
// Per-depth output budget (inspired by Node's util.inspect).
|
|
3153
|
+
// Each depth level tracks output independently, so nested results
|
|
3154
|
+
// don't inflate a single counter (which would undercount by ~Nx for
|
|
3155
|
+
// N levels of nesting). Nodes at the same depth produce disjoint spans
|
|
3156
|
+
// in the output string, so each bucket accurately reflects output at
|
|
3157
|
+
// that level. Total output is bounded by maxDepth × maxOutputLength.
|
|
3158
|
+
config._outputLengthPerDepth[depth] ??= 0;
|
|
3159
|
+
config._outputLengthPerDepth[depth] += result.length;
|
|
3160
|
+
if (config._outputLengthPerDepth[depth] > config.maxOutputLength) {
|
|
3161
|
+
config.maxDepth = 0;
|
|
3182
3162
|
}
|
|
3183
|
-
return
|
|
3163
|
+
return result;
|
|
3184
3164
|
}
|
|
3185
3165
|
const DEFAULT_THEME = {
|
|
3186
3166
|
comment: "gray",
|
|
@@ -3198,6 +3178,7 @@ const DEFAULT_OPTIONS = {
|
|
|
3198
3178
|
highlight: false,
|
|
3199
3179
|
indent: 2,
|
|
3200
3180
|
maxDepth: Number.POSITIVE_INFINITY,
|
|
3181
|
+
maxOutputLength: 1e6,
|
|
3201
3182
|
maxWidth: Number.POSITIVE_INFINITY,
|
|
3202
3183
|
min: false,
|
|
3203
3184
|
plugins: [],
|
|
@@ -3219,7 +3200,7 @@ function validateOptions(options) {
|
|
|
3219
3200
|
function getColorsHighlight() {
|
|
3220
3201
|
return DEFAULT_THEME_KEYS.reduce((colors, key) => {
|
|
3221
3202
|
const value = DEFAULT_THEME[key];
|
|
3222
|
-
const color = value &&
|
|
3203
|
+
const color = value && y[value];
|
|
3223
3204
|
if (color && typeof color.close === "string" && typeof color.open === "string") {
|
|
3224
3205
|
colors[key] = color;
|
|
3225
3206
|
} else {
|
|
@@ -3262,7 +3243,9 @@ function getConfig(options) {
|
|
|
3262
3243
|
printFunctionName: getPrintFunctionName(options),
|
|
3263
3244
|
printShadowRoot: options?.printShadowRoot ?? true,
|
|
3264
3245
|
spacingInner: options?.min ? " " : "\n",
|
|
3265
|
-
spacingOuter: options?.min ? "" : "\n"
|
|
3246
|
+
spacingOuter: options?.min ? "" : "\n",
|
|
3247
|
+
maxOutputLength: options?.maxOutputLength ?? DEFAULT_OPTIONS.maxOutputLength,
|
|
3248
|
+
_outputLengthPerDepth: []
|
|
3266
3249
|
};
|
|
3267
3250
|
}
|
|
3268
3251
|
function createIndent(indent) {
|
|
@@ -3299,10 +3282,6 @@ const plugins = {
|
|
|
3299
3282
|
Error: ErrorPlugin
|
|
3300
3283
|
};
|
|
3301
3284
|
|
|
3302
|
-
function getDefaultExportFromCjs(x) {
|
|
3303
|
-
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
|
3304
|
-
}
|
|
3305
|
-
|
|
3306
3285
|
/**
|
|
3307
3286
|
* Diff Match and Patch
|
|
3308
3287
|
* Copyright 2018 The diff-match-patch Authors.
|
|
@@ -3367,6 +3346,10 @@ class Diff {
|
|
|
3367
3346
|
const NO_DIFF_MESSAGE = "Compared values have no visual difference.";
|
|
3368
3347
|
const SIMILAR_MESSAGE = "Compared values serialize to the same structure.\n" + "Printing internal object structure without calling `toJSON` instead.";
|
|
3369
3348
|
|
|
3349
|
+
function getDefaultExportFromCjs(x) {
|
|
3350
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
|
3351
|
+
}
|
|
3352
|
+
|
|
3370
3353
|
var build = {};
|
|
3371
3354
|
|
|
3372
3355
|
var hasRequiredBuild;
|
|
@@ -4362,14 +4345,14 @@ const DIFF_TRUNCATE_THRESHOLD_DEFAULT = 0;
|
|
|
4362
4345
|
function getDefaultOptions() {
|
|
4363
4346
|
return {
|
|
4364
4347
|
aAnnotation: "Expected",
|
|
4365
|
-
aColor:
|
|
4348
|
+
aColor: y.green,
|
|
4366
4349
|
aIndicator: "-",
|
|
4367
4350
|
bAnnotation: "Received",
|
|
4368
|
-
bColor:
|
|
4351
|
+
bColor: y.red,
|
|
4369
4352
|
bIndicator: "+",
|
|
4370
|
-
changeColor:
|
|
4353
|
+
changeColor: y.inverse,
|
|
4371
4354
|
changeLineTrailingSpaceColor: noColor,
|
|
4372
|
-
commonColor:
|
|
4355
|
+
commonColor: y.dim,
|
|
4373
4356
|
commonIndicator: " ",
|
|
4374
4357
|
commonLineTrailingSpaceColor: noColor,
|
|
4375
4358
|
compareKeys: undefined,
|
|
@@ -4378,7 +4361,7 @@ function getDefaultOptions() {
|
|
|
4378
4361
|
expand: false,
|
|
4379
4362
|
includeChangeCounts: false,
|
|
4380
4363
|
omitAnnotationLines: false,
|
|
4381
|
-
patchColor:
|
|
4364
|
+
patchColor: y.yellow,
|
|
4382
4365
|
printBasicPrototype: false,
|
|
4383
4366
|
truncateThreshold: DIFF_TRUNCATE_THRESHOLD_DEFAULT,
|
|
4384
4367
|
truncateAnnotation: "... Diff result is truncated",
|
|
@@ -4495,8 +4478,8 @@ function diffLinesUnified2(aLinesDisplay, bLinesDisplay, aLinesCompare, bLinesCo
|
|
|
4495
4478
|
}
|
|
4496
4479
|
// Compare two arrays of strings line-by-line.
|
|
4497
4480
|
function diffLinesRaw(aLines, bLines, options) {
|
|
4498
|
-
const truncate =
|
|
4499
|
-
const truncateThreshold = Math.max(Math.floor(
|
|
4481
|
+
const truncate = options?.truncateThreshold ?? false;
|
|
4482
|
+
const truncateThreshold = Math.max(Math.floor(options?.truncateThreshold ?? 0), 0);
|
|
4500
4483
|
const aLength = truncate ? Math.min(aLines.length, truncateThreshold) : aLines.length;
|
|
4501
4484
|
const bLength = truncate ? Math.min(bLines.length, truncateThreshold) : bLines.length;
|
|
4502
4485
|
const truncated = aLength !== aLines.length || bLength !== bLines.length;
|
|
@@ -4587,6 +4570,7 @@ const FALLBACK_FORMAT_OPTIONS = {
|
|
|
4587
4570
|
maxDepth: 8,
|
|
4588
4571
|
plugins: PLUGINS
|
|
4589
4572
|
};
|
|
4573
|
+
const DEFAULT_MEMORIZE = (_, v) => v;
|
|
4590
4574
|
// Generate a string that will highlight the difference between two values
|
|
4591
4575
|
// with green and red. (similar to how github does code diffing)
|
|
4592
4576
|
/**
|
|
@@ -4595,7 +4579,7 @@ const FALLBACK_FORMAT_OPTIONS = {
|
|
|
4595
4579
|
* @param options Diff options
|
|
4596
4580
|
* @returns {string | null} a string diff
|
|
4597
4581
|
*/
|
|
4598
|
-
function diff(a, b, options) {
|
|
4582
|
+
function diff(a, b, options, memorize = DEFAULT_MEMORIZE) {
|
|
4599
4583
|
if (Object.is(a, b)) {
|
|
4600
4584
|
return "";
|
|
4601
4585
|
}
|
|
@@ -4629,10 +4613,10 @@ function diff(a, b, options) {
|
|
|
4629
4613
|
function truncate(s) {
|
|
4630
4614
|
return s.length <= MAX_LENGTH ? s : `${s.slice(0, MAX_LENGTH)}...`;
|
|
4631
4615
|
}
|
|
4632
|
-
aDisplay = truncate(aDisplay);
|
|
4633
|
-
bDisplay = truncate(bDisplay);
|
|
4634
|
-
const aDiff = `${aColor(`${aIndicator} ${aAnnotation}:`)}
|
|
4635
|
-
const bDiff = `${bColor(`${bIndicator} ${bAnnotation}:`)}
|
|
4616
|
+
aDisplay = memorize("expected", truncate(aDisplay));
|
|
4617
|
+
bDisplay = memorize("actual", truncate(bDisplay));
|
|
4618
|
+
const aDiff = `${aColor(`${aIndicator} ${aAnnotation}:`)}\n${aDisplay}`;
|
|
4619
|
+
const bDiff = `${bColor(`${bIndicator} ${bAnnotation}:`)}\n${bDisplay}`;
|
|
4636
4620
|
return `${aDiff}\n\n${bDiff}`;
|
|
4637
4621
|
}
|
|
4638
4622
|
if (omitDifference) {
|
|
@@ -4641,15 +4625,15 @@ function diff(a, b, options) {
|
|
|
4641
4625
|
switch (aType) {
|
|
4642
4626
|
case "string": return diffLinesUnified(a.split("\n"), b.split("\n"), options);
|
|
4643
4627
|
case "boolean":
|
|
4644
|
-
case "number": return comparePrimitive(a, b, options);
|
|
4645
|
-
case "map": return compareObjects(sortMap(a), sortMap(b), options);
|
|
4646
|
-
case "set": return compareObjects(sortSet(a), sortSet(b), options);
|
|
4647
|
-
default: return compareObjects(a, b, options);
|
|
4628
|
+
case "number": return comparePrimitive(a, b, options, memorize);
|
|
4629
|
+
case "map": return compareObjects(sortMap(a), sortMap(b), options, memorize);
|
|
4630
|
+
case "set": return compareObjects(sortSet(a), sortSet(b), options, memorize);
|
|
4631
|
+
default: return compareObjects(a, b, options, memorize);
|
|
4648
4632
|
}
|
|
4649
4633
|
}
|
|
4650
|
-
function comparePrimitive(a, b, options) {
|
|
4651
|
-
const aFormat = format(a, FORMAT_OPTIONS);
|
|
4652
|
-
const bFormat = format(b, FORMAT_OPTIONS);
|
|
4634
|
+
function comparePrimitive(a, b, options, memorize = DEFAULT_MEMORIZE) {
|
|
4635
|
+
const aFormat = memorize("expected", format(a, FORMAT_OPTIONS));
|
|
4636
|
+
const bFormat = memorize("actual", format(b, FORMAT_OPTIONS));
|
|
4653
4637
|
return aFormat === bFormat ? "" : diffLinesUnified(aFormat.split("\n"), bFormat.split("\n"), options);
|
|
4654
4638
|
}
|
|
4655
4639
|
function sortMap(map) {
|
|
@@ -4658,12 +4642,12 @@ function sortMap(map) {
|
|
|
4658
4642
|
function sortSet(set) {
|
|
4659
4643
|
return new Set(Array.from(set.values()).sort());
|
|
4660
4644
|
}
|
|
4661
|
-
function compareObjects(a, b, options) {
|
|
4645
|
+
function compareObjects(a, b, options, memorize = DEFAULT_MEMORIZE) {
|
|
4662
4646
|
let difference;
|
|
4663
4647
|
let hasThrown = false;
|
|
4664
4648
|
try {
|
|
4665
4649
|
const formatOptions = getFormatOptions(FORMAT_OPTIONS, options);
|
|
4666
|
-
difference = getObjectsDifference(a, b, formatOptions, options);
|
|
4650
|
+
difference = getObjectsDifference(a, b, formatOptions, options, memorize);
|
|
4667
4651
|
} catch {
|
|
4668
4652
|
hasThrown = true;
|
|
4669
4653
|
}
|
|
@@ -4672,7 +4656,7 @@ function compareObjects(a, b, options) {
|
|
|
4672
4656
|
// without calling `toJSON`. It's also possible that toJSON might throw.
|
|
4673
4657
|
if (difference === undefined || difference === noDiffMessage) {
|
|
4674
4658
|
const formatOptions = getFormatOptions(FALLBACK_FORMAT_OPTIONS, options);
|
|
4675
|
-
difference = getObjectsDifference(a, b, formatOptions, options);
|
|
4659
|
+
difference = getObjectsDifference(a, b, formatOptions, options, memorize);
|
|
4676
4660
|
if (difference !== noDiffMessage && !hasThrown) {
|
|
4677
4661
|
difference = `${getCommonMessage(SIMILAR_MESSAGE, options)}\n\n${difference}`;
|
|
4678
4662
|
}
|
|
@@ -4688,7 +4672,7 @@ function getFormatOptions(formatOptions, options) {
|
|
|
4688
4672
|
maxDepth: maxDepth ?? formatOptions.maxDepth
|
|
4689
4673
|
};
|
|
4690
4674
|
}
|
|
4691
|
-
function getObjectsDifference(a, b, formatOptions, options) {
|
|
4675
|
+
function getObjectsDifference(a, b, formatOptions, options, memorize = DEFAULT_MEMORIZE) {
|
|
4692
4676
|
const formatOptionsZeroIndent = {
|
|
4693
4677
|
...formatOptions,
|
|
4694
4678
|
indent: 0
|
|
@@ -4698,8 +4682,8 @@ function getObjectsDifference(a, b, formatOptions, options) {
|
|
|
4698
4682
|
if (aCompare === bCompare) {
|
|
4699
4683
|
return getCommonMessage(NO_DIFF_MESSAGE, options);
|
|
4700
4684
|
} else {
|
|
4701
|
-
const aDisplay = format(a, formatOptions);
|
|
4702
|
-
const bDisplay = format(b, formatOptions);
|
|
4685
|
+
const aDisplay = memorize("expected", format(a, formatOptions));
|
|
4686
|
+
const bDisplay = memorize("actual", format(b, formatOptions));
|
|
4703
4687
|
return diffLinesUnified2(aDisplay.split("\n"), bDisplay.split("\n"), aCompare.split("\n"), bCompare.split("\n"), options);
|
|
4704
4688
|
}
|
|
4705
4689
|
}
|
|
@@ -5244,9 +5228,8 @@ var escapeCharacters = {
|
|
|
5244
5228
|
"\\": "\\\\"
|
|
5245
5229
|
};
|
|
5246
5230
|
var hex = 16;
|
|
5247
|
-
var unicodeLength = 4;
|
|
5248
5231
|
function escape(char) {
|
|
5249
|
-
return escapeCharacters[char] || `\\u${`0000${char.charCodeAt(0).toString(hex)}`.slice(-
|
|
5232
|
+
return escapeCharacters[char] || `\\u${`0000${char.charCodeAt(0).toString(hex)}`.slice(-4)}`;
|
|
5250
5233
|
}
|
|
5251
5234
|
__name(escape, "escape");
|
|
5252
5235
|
function inspectString(string, options) {
|
|
@@ -8871,11 +8854,11 @@ const JEST_MATCHERS_OBJECT = Symbol.for("$$jest-matchers-object");
|
|
|
8871
8854
|
const GLOBAL_EXPECT = Symbol.for("expect-global");
|
|
8872
8855
|
const ASYMMETRIC_MATCHERS_OBJECT = Symbol.for("asymmetric-matchers-object");
|
|
8873
8856
|
|
|
8874
|
-
|
|
8875
|
-
|
|
8876
|
-
|
|
8877
|
-
|
|
8878
|
-
|
|
8857
|
+
y.green;
|
|
8858
|
+
y.red;
|
|
8859
|
+
y.inverse;
|
|
8860
|
+
y.bold;
|
|
8861
|
+
y.dim;
|
|
8879
8862
|
|
|
8880
8863
|
// Extracted out of jasmine 2.5.2
|
|
8881
8864
|
function equals(a, b, customTesters, strictCheck) {
|
|
@@ -8898,6 +8881,18 @@ function asymmetricMatch(a, b, customTesters) {
|
|
|
8898
8881
|
return b.asymmetricMatch(a, customTesters);
|
|
8899
8882
|
}
|
|
8900
8883
|
}
|
|
8884
|
+
// https://github.com/jestjs/jest/blob/905bcbced3d40cdf7aadc4cdf6fb731c4bb3dbe3/packages/expect-utils/src/utils.ts#L509
|
|
8885
|
+
function isError(value) {
|
|
8886
|
+
if (typeof Error.isError === "function") {
|
|
8887
|
+
return Error.isError(value);
|
|
8888
|
+
}
|
|
8889
|
+
switch (Object.prototype.toString.call(value)) {
|
|
8890
|
+
case "[object Error]":
|
|
8891
|
+
case "[object Exception]":
|
|
8892
|
+
case "[object DOMException]": return true;
|
|
8893
|
+
default: return value instanceof Error;
|
|
8894
|
+
}
|
|
8895
|
+
}
|
|
8901
8896
|
// Equality function lovingly adapted from isEqual in
|
|
8902
8897
|
// [Underscore](http://underscorejs.org)
|
|
8903
8898
|
function eq(a, b, aStack, bStack, customTesters, hasKey) {
|
|
@@ -8986,7 +8981,7 @@ function eq(a, b, aStack, bStack, customTesters, hasKey) {
|
|
|
8986
8981
|
if (className === "[object Array]" && a.length !== b.length) {
|
|
8987
8982
|
return false;
|
|
8988
8983
|
}
|
|
8989
|
-
if (a
|
|
8984
|
+
if (isError(a) && isError(b)) {
|
|
8990
8985
|
try {
|
|
8991
8986
|
return isErrorEqual(a, b, aStack, bStack, customTesters, hasKey);
|
|
8992
8987
|
} finally {
|
|
@@ -9020,17 +9015,17 @@ function isErrorEqual(a, b, aStack, bStack, customTesters, hasKey) {
|
|
|
9020
9015
|
// - [[Prototype]] of objects are compared using the === operator.
|
|
9021
9016
|
// - Only enumerable "own" properties are considered.
|
|
9022
9017
|
// - Error names, messages, causes, and errors are always compared, even if these are not enumerable properties. errors is also compared.
|
|
9023
|
-
let result = Object.
|
|
9018
|
+
let result = Object.prototype.toString.call(a) === Object.prototype.toString.call(b) && a.name === b.name && a.message === b.message;
|
|
9024
9019
|
// check Error.cause asymmetrically
|
|
9025
9020
|
if (typeof b.cause !== "undefined") {
|
|
9026
|
-
result
|
|
9021
|
+
result &&= eq(a.cause, b.cause, aStack, bStack, customTesters, hasKey);
|
|
9027
9022
|
}
|
|
9028
9023
|
// AggregateError.errors
|
|
9029
9024
|
if (a instanceof AggregateError && b instanceof AggregateError) {
|
|
9030
|
-
result
|
|
9025
|
+
result &&= eq(a.errors, b.errors, aStack, bStack, customTesters, hasKey);
|
|
9031
9026
|
}
|
|
9032
9027
|
// spread to compare enumerable properties
|
|
9033
|
-
result
|
|
9028
|
+
result &&= eq({ ...a }, { ...b }, aStack, bStack, customTesters, hasKey);
|
|
9034
9029
|
return result;
|
|
9035
9030
|
}
|
|
9036
9031
|
function keys(obj, hasKey) {
|
|
@@ -9112,11 +9107,10 @@ function patchJsonSchema({
|
|
|
9112
9107
|
openApiSchema,
|
|
9113
9108
|
jsonOverrides
|
|
9114
9109
|
}) {
|
|
9115
|
-
var _a;
|
|
9116
9110
|
const patchedSchema = lib.parse(lib.stringify(openApiSchema));
|
|
9117
|
-
patchedSchema.components
|
|
9118
|
-
|
|
9119
|
-
patchedSchema.paths
|
|
9111
|
+
patchedSchema.components ??= {};
|
|
9112
|
+
patchedSchema.components.schemas ??= {};
|
|
9113
|
+
patchedSchema.paths ??= {};
|
|
9120
9114
|
let alreadyApliedPatches = 0;
|
|
9121
9115
|
const outdatedPatches = [];
|
|
9122
9116
|
let appliedPatches = 0;
|
|
@@ -9155,9 +9149,8 @@ ${c.cyan(
|
|
|
9155
9149
|
return patchedObject;
|
|
9156
9150
|
}
|
|
9157
9151
|
function _applyPathPatches(pathName, httpMethod, overridePatches) {
|
|
9158
|
-
|
|
9159
|
-
|
|
9160
|
-
(_b = patchedSchema.paths[pathName])[httpMethod] ?? (_b[httpMethod] = {});
|
|
9152
|
+
patchedSchema.paths[pathName] ??= {};
|
|
9153
|
+
patchedSchema.paths[pathName][httpMethod] ??= {};
|
|
9161
9154
|
patchedSchema.paths[pathName][httpMethod] = _applyPatches(
|
|
9162
9155
|
patchedSchema.paths[pathName][httpMethod],
|
|
9163
9156
|
`${pathName} ${httpMethod}`,
|
|
@@ -9166,8 +9159,7 @@ ${c.cyan(
|
|
|
9166
9159
|
);
|
|
9167
9160
|
}
|
|
9168
9161
|
function _applyComponentsPatches(pathName, overridePatches) {
|
|
9169
|
-
|
|
9170
|
-
(_a2 = patchedSchema.components.schemas)[pathName] ?? (_a2[pathName] = {});
|
|
9162
|
+
patchedSchema.components.schemas[pathName] ??= {};
|
|
9171
9163
|
patchedSchema.components.schemas[pathName] = _applyPatches(
|
|
9172
9164
|
patchedSchema.components.schemas[pathName],
|
|
9173
9165
|
pathName,
|
|
@@ -9674,9 +9666,7 @@ async function prepareFileContent({
|
|
|
9674
9666
|
*/
|
|
9675
9667
|
`;
|
|
9676
9668
|
x += sourceFile.getFullText();
|
|
9677
|
-
const formatted = await
|
|
9678
|
-
parser: "typescript"
|
|
9679
|
-
});
|
|
9669
|
+
const formatted = await formatSource(filepath, x);
|
|
9680
9670
|
sourceFile.replaceWithText(formatted);
|
|
9681
9671
|
return project;
|
|
9682
9672
|
}
|
|
@@ -10090,6 +10080,8 @@ function transformOpenApiTypes(schema) {
|
|
|
10090
10080
|
return [operationsMap, componentsMap, existingTypes, parametersMap];
|
|
10091
10081
|
}
|
|
10092
10082
|
|
|
10083
|
+
const customFieldsTypes = `type CustomFields = { [key: string]: CustomFieldValue };
|
|
10084
|
+
type CustomFieldValue = null | string | string[] | number | boolean | CustomFieldValue[] | { [key: string]: CustomFieldValue };`;
|
|
10093
10085
|
async function generate(args) {
|
|
10094
10086
|
const inputFilename = args.filename ? args.filename : `${args.apiType}ApiSchema.json`;
|
|
10095
10087
|
try {
|
|
@@ -10187,6 +10179,7 @@ async function generate(args) {
|
|
|
10187
10179
|
*/
|
|
10188
10180
|
inject: `
|
|
10189
10181
|
type GenericRecord = never | null | string | string[] | number | { [key: string]: GenericRecord };
|
|
10182
|
+
${customFieldsTypes}
|
|
10190
10183
|
`,
|
|
10191
10184
|
transform(schemaObject, metadata) {
|
|
10192
10185
|
if (!schemaObject) {
|
|
@@ -10220,7 +10213,7 @@ async function generate(args) {
|
|
|
10220
10213
|
const { translated: _, ...propertiesWithoutTranslated } = schemaObject.properties;
|
|
10221
10214
|
schemaObject.properties = propertiesWithoutTranslated;
|
|
10222
10215
|
} else {
|
|
10223
|
-
schemaObject.required
|
|
10216
|
+
schemaObject.required ??= [];
|
|
10224
10217
|
schemaObject.required.push("translated");
|
|
10225
10218
|
schemaObject.properties.translated = extendedDefu(
|
|
10226
10219
|
{
|
|
@@ -10242,21 +10235,18 @@ async function generate(args) {
|
|
|
10242
10235
|
}
|
|
10243
10236
|
});
|
|
10244
10237
|
}
|
|
10245
|
-
return runTransformations(schemaObject);
|
|
10238
|
+
return runTransformations(schemaObject, metadata);
|
|
10246
10239
|
}
|
|
10247
10240
|
});
|
|
10248
10241
|
schema = astToString(astSchema);
|
|
10242
|
+
schema = normalizeCustomFieldsTypes(schema);
|
|
10249
10243
|
schema = schema.replace(/@description /g, "");
|
|
10250
10244
|
if (args.debug) {
|
|
10251
10245
|
writeFileSync(fullOutputFilePath, schema, {
|
|
10252
10246
|
encoding: "utf-8"
|
|
10253
10247
|
});
|
|
10254
10248
|
console.log(`[DEBUG]: Debug Schema saved to ${fullOutputFilePath}`);
|
|
10255
|
-
schema = await
|
|
10256
|
-
// semi: false,
|
|
10257
|
-
parser: "typescript"
|
|
10258
|
-
// plugins: [tsParser],
|
|
10259
|
-
});
|
|
10249
|
+
schema = await formatSource(fullOutputFilePath, schema);
|
|
10260
10250
|
schema = schema.trim();
|
|
10261
10251
|
}
|
|
10262
10252
|
processedSchemaAst = transformOpenApiTypes(schema);
|
|
@@ -10278,6 +10268,7 @@ async function generate(args) {
|
|
|
10278
10268
|
`https://raw.githubusercontent.com/shopware/frontends/main/packages/api-client/api-types/${args.apiType}ApiTypes.d.ts`
|
|
10279
10269
|
);
|
|
10280
10270
|
}
|
|
10271
|
+
schema = normalizeCustomFieldsTypes(schema);
|
|
10281
10272
|
processedSchemaAst = transformSchemaTypes(schema);
|
|
10282
10273
|
}
|
|
10283
10274
|
if (typeof schema === "string") {
|
|
@@ -10336,12 +10327,24 @@ async function generate(args) {
|
|
|
10336
10327
|
process.exit(1);
|
|
10337
10328
|
}
|
|
10338
10329
|
}
|
|
10339
|
-
function runTransformations(schemaObject) {
|
|
10330
|
+
function runTransformations(schemaObject, metadata) {
|
|
10331
|
+
const constLiteralType = createConstLiteralType(schemaObject);
|
|
10332
|
+
if (constLiteralType) {
|
|
10333
|
+
return constLiteralType;
|
|
10334
|
+
}
|
|
10340
10335
|
if (schemaObject.format === "binary") {
|
|
10341
10336
|
return ts.factory.createTypeReferenceNode(
|
|
10342
10337
|
ts.factory.createIdentifier("Blob")
|
|
10343
10338
|
);
|
|
10344
10339
|
}
|
|
10340
|
+
if (isCustomFieldsSchema(metadata)) {
|
|
10341
|
+
return ts.factory.createUnionTypeNode([
|
|
10342
|
+
ts.factory.createTypeReferenceNode(
|
|
10343
|
+
ts.factory.createIdentifier("CustomFields")
|
|
10344
|
+
),
|
|
10345
|
+
ts.factory.createLiteralTypeNode(ts.factory.createNull())
|
|
10346
|
+
]);
|
|
10347
|
+
}
|
|
10345
10348
|
if (
|
|
10346
10349
|
// for object types
|
|
10347
10350
|
schemaObject.type === "object" && // without properties, items, anyOf, allOf
|
|
@@ -10353,6 +10356,66 @@ function runTransformations(schemaObject) {
|
|
|
10353
10356
|
}
|
|
10354
10357
|
return void 0;
|
|
10355
10358
|
}
|
|
10359
|
+
function createConstLiteralType(schemaObject) {
|
|
10360
|
+
if (!("const" in schemaObject)) {
|
|
10361
|
+
return void 0;
|
|
10362
|
+
}
|
|
10363
|
+
const constValue = schemaObject.const;
|
|
10364
|
+
if (hasSchemaType(schemaObject, "string")) {
|
|
10365
|
+
return ts.factory.createLiteralTypeNode(
|
|
10366
|
+
ts.factory.createStringLiteral(String(constValue))
|
|
10367
|
+
);
|
|
10368
|
+
}
|
|
10369
|
+
if (constValue === null) {
|
|
10370
|
+
return ts.factory.createLiteralTypeNode(ts.factory.createNull());
|
|
10371
|
+
}
|
|
10372
|
+
if (typeof constValue === "string") {
|
|
10373
|
+
return ts.factory.createLiteralTypeNode(
|
|
10374
|
+
ts.factory.createStringLiteral(constValue)
|
|
10375
|
+
);
|
|
10376
|
+
}
|
|
10377
|
+
if (typeof constValue === "number" && Number.isFinite(constValue)) {
|
|
10378
|
+
const numericLiteral = ts.factory.createNumericLiteral(
|
|
10379
|
+
Math.abs(constValue)
|
|
10380
|
+
);
|
|
10381
|
+
return ts.factory.createLiteralTypeNode(
|
|
10382
|
+
constValue < 0 ? ts.factory.createPrefixUnaryExpression(
|
|
10383
|
+
ts.SyntaxKind.MinusToken,
|
|
10384
|
+
numericLiteral
|
|
10385
|
+
) : numericLiteral
|
|
10386
|
+
);
|
|
10387
|
+
}
|
|
10388
|
+
if (typeof constValue === "boolean") {
|
|
10389
|
+
return ts.factory.createLiteralTypeNode(
|
|
10390
|
+
constValue ? ts.factory.createTrue() : ts.factory.createFalse()
|
|
10391
|
+
);
|
|
10392
|
+
}
|
|
10393
|
+
return void 0;
|
|
10394
|
+
}
|
|
10395
|
+
function hasSchemaType(schemaObject, type) {
|
|
10396
|
+
return Array.isArray(schemaObject.type) ? schemaObject.type.includes(type) : schemaObject.type === type;
|
|
10397
|
+
}
|
|
10398
|
+
function isCustomFieldsSchema(metadata) {
|
|
10399
|
+
const path = Array.isArray(metadata?.path) ? metadata.path.join("/") : metadata?.path;
|
|
10400
|
+
return typeof path === "string" && (path.endsWith("/customFields") || path.endsWith(".customFields") || path.includes("/properties/customFields"));
|
|
10401
|
+
}
|
|
10402
|
+
function normalizeCustomFieldsTypes(schema) {
|
|
10403
|
+
const normalizedSchema = schema.replace(
|
|
10404
|
+
/\bcustomFields\?: GenericRecord;/g,
|
|
10405
|
+
"customFields?: CustomFields | null;"
|
|
10406
|
+
).replace(
|
|
10407
|
+
/\bcustomFields\?: string;/g,
|
|
10408
|
+
"customFields?: CustomFields | null;"
|
|
10409
|
+
);
|
|
10410
|
+
if (normalizedSchema.includes("type CustomFields =")) {
|
|
10411
|
+
return normalizedSchema;
|
|
10412
|
+
}
|
|
10413
|
+
return normalizedSchema.replace(
|
|
10414
|
+
/(type GenericRecord =[\s\S]*?\{ \[key: string\]: GenericRecord \};)/,
|
|
10415
|
+
`$1
|
|
10416
|
+
${customFieldsTypes}`
|
|
10417
|
+
);
|
|
10418
|
+
}
|
|
10356
10419
|
|
|
10357
10420
|
let adminApiClient;
|
|
10358
10421
|
let storeApiClient;
|
|
@@ -10463,10 +10526,10 @@ Check whether the .env file is created.
|
|
|
10463
10526
|
);
|
|
10464
10527
|
apiJSON = result.data;
|
|
10465
10528
|
}
|
|
10466
|
-
const formatted = await
|
|
10467
|
-
|
|
10468
|
-
|
|
10469
|
-
|
|
10529
|
+
const formatted = await formatSource(
|
|
10530
|
+
outputFilename,
|
|
10531
|
+
JSON.stringify(apiJSON, null, 2)
|
|
10532
|
+
);
|
|
10470
10533
|
const content = formatted.trim();
|
|
10471
10534
|
const dir = args.cwd;
|
|
10472
10535
|
const apiTypesDir = join(dir, "api-types");
|
|
@@ -10507,7 +10570,7 @@ function isUppercase(char = "") {
|
|
|
10507
10570
|
return char !== char.toLowerCase();
|
|
10508
10571
|
}
|
|
10509
10572
|
function splitByCase(str, separators) {
|
|
10510
|
-
const splitters =
|
|
10573
|
+
const splitters = STR_SPLITTERS;
|
|
10511
10574
|
const parts = [];
|
|
10512
10575
|
if (!str || typeof str !== "string") {
|
|
10513
10576
|
return parts;
|
|
@@ -10550,34 +10613,39 @@ function upperFirst(str) {
|
|
|
10550
10613
|
return str ? str[0].toUpperCase() + str.slice(1) : "";
|
|
10551
10614
|
}
|
|
10552
10615
|
function pascalCase(str, opts) {
|
|
10553
|
-
return str ? (Array.isArray(str) ? str : splitByCase(str)).map((p) => upperFirst(
|
|
10616
|
+
return str ? (Array.isArray(str) ? str : splitByCase(str)).map((p) => upperFirst(p)).join("") : "";
|
|
10554
10617
|
}
|
|
10555
10618
|
function kebabCase(str, joiner) {
|
|
10556
|
-
return str ? (Array.isArray(str) ? str : splitByCase(str)).map((p) => p.toLowerCase()).join(joiner
|
|
10619
|
+
return str ? (Array.isArray(str) ? str : splitByCase(str)).map((p) => p.toLowerCase()).join(joiner) : "";
|
|
10557
10620
|
}
|
|
10558
10621
|
function snakeCase(str) {
|
|
10559
10622
|
return kebabCase(str || "", "_");
|
|
10560
10623
|
}
|
|
10561
10624
|
|
|
10562
10625
|
const componentsApiAliasRule = (componentName, body) => {
|
|
10563
|
-
const
|
|
10626
|
+
const properEnumAliasDefinition = {
|
|
10564
10627
|
type: "string",
|
|
10565
10628
|
enum: [snakeCase(componentName)]
|
|
10566
10629
|
};
|
|
10630
|
+
const properConstAliasDefinition = {
|
|
10631
|
+
type: "string",
|
|
10632
|
+
const: snakeCase(componentName)
|
|
10633
|
+
};
|
|
10567
10634
|
const bodyValue = body?.properties?.apiAlias;
|
|
10568
10635
|
if (!bodyValue) {
|
|
10569
10636
|
return null;
|
|
10570
10637
|
}
|
|
10571
|
-
const result = equals(
|
|
10638
|
+
const result = equals(properEnumAliasDefinition, bodyValue) || equals(properConstAliasDefinition, bodyValue);
|
|
10572
10639
|
if (!result) {
|
|
10573
10640
|
let additionalMessage = "";
|
|
10574
|
-
const
|
|
10575
|
-
if (
|
|
10576
|
-
additionalMessage = `It's also possible, that the schema component name is not correct and apiApias is proper. In that case schema component name should be ${c.bold(pascalCase(
|
|
10641
|
+
const bodyLiteralValue = getStringLiteralValue(bodyValue);
|
|
10642
|
+
if (bodyLiteralValue && properEnumAliasDefinition.enum[0] !== bodyLiteralValue) {
|
|
10643
|
+
additionalMessage = `It's also possible, that the schema component name is not correct and apiApias is proper. In that case schema component name should be ${c.bold(pascalCase(bodyLiteralValue))}. Confirm proper solution with the source code.`;
|
|
10577
10644
|
}
|
|
10645
|
+
const expectedAliasDefinition = "const" in bodyValue ? properConstAliasDefinition : properEnumAliasDefinition;
|
|
10578
10646
|
return `Component ${c.bold(componentName)} has invalid ${c.bold("apiAlias")} definition. Diff:
|
|
10579
10647
|
${diff(
|
|
10580
|
-
|
|
10648
|
+
expectedAliasDefinition,
|
|
10581
10649
|
bodyValue,
|
|
10582
10650
|
{
|
|
10583
10651
|
aColor: c.green,
|
|
@@ -10591,6 +10659,17 @@ ${additionalMessage}` : ""}`;
|
|
|
10591
10659
|
}
|
|
10592
10660
|
return null;
|
|
10593
10661
|
};
|
|
10662
|
+
function getStringLiteralValue(bodyValue) {
|
|
10663
|
+
const enumValue = bodyValue?.enum?.[0];
|
|
10664
|
+
if (typeof enumValue === "string") {
|
|
10665
|
+
return enumValue;
|
|
10666
|
+
}
|
|
10667
|
+
const constValue = bodyValue?.const;
|
|
10668
|
+
if (typeof constValue === "string") {
|
|
10669
|
+
return constValue;
|
|
10670
|
+
}
|
|
10671
|
+
return void 0;
|
|
10672
|
+
}
|
|
10594
10673
|
|
|
10595
10674
|
const validationRules = {
|
|
10596
10675
|
COMPONENTS_API_ALIAS: componentsApiAliasRule
|
|
@@ -10767,4 +10846,4 @@ async function validateJson(args) {
|
|
|
10767
10846
|
}
|
|
10768
10847
|
}
|
|
10769
10848
|
|
|
10770
|
-
export {
|
|
10849
|
+
export { getAugmentedNamespace as a, formatSource as f, generate as g, loadSchema as l, validateJson as v };
|