@swmansion/argent 0.29.1-next.2 → 0.29.1-next.21

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/dist/client.js CHANGED
@@ -35,322 +35,395 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
35
35
  mod
36
36
  ));
37
37
 
38
- // ../../node_modules/dotenv/lib/main.js
39
- var require_main = __commonJS({
40
- "../../node_modules/dotenv/lib/main.js"(exports, module) {
41
- var fs7 = __require("fs");
42
- var path13 = __require("path");
43
- var os2 = __require("os");
44
- var crypto2 = __require("crypto");
45
- var TIPS = [
46
- "\u25C8 encrypted .env [www.dotenvx.com]",
47
- "\u25C8 secrets for agents [www.dotenvx.com]",
48
- "\u2301 auth for agents [www.vestauth.com]",
49
- "\u2318 custom filepath { path: '/custom/path/.env' }",
50
- "\u2318 enable debugging { debug: true }",
51
- "\u2318 override existing { override: true }",
52
- "\u2318 suppress logs { quiet: true }",
53
- "\u2318 multiple files { path: ['.env.local', '.env'] }"
54
- ];
55
- function _getRandomTip() {
56
- return TIPS[Math.floor(Math.random() * TIPS.length)];
57
- }
58
- function parseBoolean(value) {
59
- if (typeof value === "string") {
60
- return !["false", "0", "no", "off", ""].includes(value.toLowerCase());
61
- }
62
- return Boolean(value);
63
- }
64
- function supportsAnsi() {
65
- return process.stdout.isTTY;
66
- }
67
- function dim(text) {
68
- return supportsAnsi() ? `\x1B[2m${text}\x1B[0m` : text;
69
- }
70
- var LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg;
71
- function parse(src) {
72
- const obj = {};
73
- let lines = src.toString();
74
- lines = lines.replace(/\r\n?/mg, "\n");
75
- let match;
76
- while ((match = LINE.exec(lines)) != null) {
77
- const key = match[1];
78
- let value = match[2] || "";
79
- value = value.trim();
80
- const maybeQuote = value[0];
81
- value = value.replace(/^(['"`])([\s\S]*)\1$/mg, "$2");
82
- if (maybeQuote === '"') {
83
- value = value.replace(/\\n/g, "\n");
84
- value = value.replace(/\\r/g, "\r");
85
- }
86
- obj[key] = value;
87
- }
88
- return obj;
89
- }
90
- function _parseVault(options) {
91
- options = options || {};
92
- const vaultPath = _vaultPath(options);
93
- options.path = vaultPath;
94
- const result = DotenvModule.configDotenv(options);
95
- if (!result.parsed) {
96
- const err = new Error(`MISSING_DATA: Cannot parse ${vaultPath} for an unknown reason`);
97
- err.code = "MISSING_DATA";
98
- throw err;
99
- }
100
- const keys = _dotenvKey(options).split(",");
101
- const length = keys.length;
102
- let decrypted;
103
- for (let i = 0; i < length; i++) {
104
- try {
105
- const key = keys[i].trim();
106
- const attrs = _instructions(result, key);
107
- decrypted = DotenvModule.decrypt(attrs.ciphertext, attrs.key);
108
- break;
109
- } catch (error) {
110
- if (i + 1 >= length) {
111
- throw error;
112
- }
38
+ // ../../node_modules/dotenv/dist/index.cjs
39
+ var require_dist = __commonJS({
40
+ "../../node_modules/dotenv/dist/index.cjs"(exports, module) {
41
+ var j = (e, n) => () => {
42
+ try {
43
+ return n || e((n = { exports: {} }).exports, n), n.exports;
44
+ } catch (t) {
45
+ throw n = 0, t;
46
+ }
47
+ };
48
+ var k = j((xe, U) => {
49
+ function G(e) {
50
+ return typeof e == "string" ? !["false", "0", "no", "off", ""].includes(e.toLowerCase()) : !!e;
51
+ }
52
+ function Y(e = process.env) {
53
+ let n = {};
54
+ for (let t of ["ENCODING", "PATH", "QUIET", "DEBUG", "OVERRIDE", "FAST"]) {
55
+ let o = e[`DOTENV_${t}`] != null ? e[`DOTENV_${t}`] : e[`DOTENV_CONFIG_${t}`];
56
+ o != null && (n[t.toLowerCase()] = t === "ENCODING" || t === "PATH" ? o : G(o));
113
57
  }
58
+ return n;
114
59
  }
115
- return DotenvModule.parse(decrypted);
116
- }
117
- function _warn(message) {
118
- console.error(`\u26A0 ${message}`);
119
- }
120
- function _debug(message) {
121
- console.log(`\u2506 ${message}`);
122
- }
123
- function _log(message) {
124
- console.log(`\u25C7 ${message}`);
125
- }
126
- function _dotenvKey(options) {
127
- if (options && options.DOTENV_KEY && options.DOTENV_KEY.length > 0) {
128
- return options.DOTENV_KEY;
60
+ U.exports = { parseBoolean: G, optionsFromEnv: Y };
61
+ });
62
+ var N = j((ye, x) => {
63
+ var z = __require("fs"), I = __require("path"), Z = __require("os"), { URL: ee, fileURLToPath: te } = __require("url"), { parseBoolean: $, optionsFromEnv: B } = k(), re = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg, b = new Uint8Array(256);
64
+ for (let e = 48; e <= 57; e++) b[e] = 1;
65
+ for (let e = 65; e <= 90; e++) b[e] = 1;
66
+ for (let e = 97; e <= 122; e++) b[e] = 1;
67
+ b[45] = 1;
68
+ b[46] = 1;
69
+ b[95] = 1;
70
+ function ne(e) {
71
+ let n = {}, t = e.toString();
72
+ t = t.replace(/\r\n?/mg, `
73
+ `);
74
+ let o;
75
+ for (; (o = re.exec(t)) != null; ) {
76
+ let r = o[1], s = o[2] || "";
77
+ s = s.trim();
78
+ let i = s[0];
79
+ s = s.replace(/^(['"`])([\s\S]*)\1$/mg, "$2"), i === '"' && (s = s.replace(/\\n/g, `
80
+ `), s = s.replace(/\\r/g, "\r")), n[r] = s;
81
+ }
82
+ return n;
129
83
  }
130
- if (process.env.DOTENV_KEY && process.env.DOTENV_KEY.length > 0) {
131
- return process.env.DOTENV_KEY;
84
+ function w(e) {
85
+ return e <= 32 ? e === 32 || e >= 9 && e <= 13 : e >= 160 && (e === 160 || e === 5760 || e >= 8192 && e <= 8202 || e === 8232 || e === 8233 || e === 8239 || e === 8287 || e === 12288 || e === 65279);
132
86
  }
133
- return "";
134
- }
135
- function _instructions(result, dotenvKey) {
136
- let uri;
137
- try {
138
- uri = new URL(dotenvKey);
139
- } catch (error) {
140
- if (error.code === "ERR_INVALID_URL") {
141
- 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");
142
- err.code = "INVALID_DOTENV_KEY";
143
- throw err;
144
- }
145
- throw error;
146
- }
147
- const key = uri.password;
148
- if (!key) {
149
- const err = new Error("INVALID_DOTENV_KEY: Missing key part");
150
- err.code = "INVALID_DOTENV_KEY";
151
- throw err;
152
- }
153
- const environment = uri.searchParams.get("environment");
154
- if (!environment) {
155
- const err = new Error("INVALID_DOTENV_KEY: Missing environment part");
156
- err.code = "INVALID_DOTENV_KEY";
157
- throw err;
158
- }
159
- const environmentKey = `DOTENV_VAULT_${environment.toUpperCase()}`;
160
- const ciphertext = result.parsed[environmentKey];
161
- if (!ciphertext) {
162
- const err = new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${environmentKey} in your .env.vault file.`);
163
- err.code = "NOT_FOUND_DOTENV_ENVIRONMENT";
164
- throw err;
165
- }
166
- return { ciphertext, key };
167
- }
168
- function _vaultPath(options) {
169
- let possibleVaultPath = null;
170
- if (options && options.path && options.path.length > 0) {
171
- if (Array.isArray(options.path)) {
172
- for (const filepath of options.path) {
173
- if (fs7.existsSync(filepath)) {
174
- possibleVaultPath = filepath.endsWith(".vault") ? filepath : `${filepath}.vault`;
87
+ function q(e) {
88
+ return e === 10 || e === 8232 || e === 8233;
89
+ }
90
+ function oe(e) {
91
+ let n = {}, t = typeof e == "string" ? e : e.toString();
92
+ t.indexOf("\r") !== -1 && (t = t.replace(/\r\n?/g, `
93
+ `));
94
+ let o = t.length, r = 0;
95
+ for (; r < o; ) {
96
+ let s = t.charCodeAt(r);
97
+ for (; r < o && w(s); ) r++, s = t.charCodeAt(r);
98
+ if (r >= o) break;
99
+ if (s === 35) {
100
+ for (; r < o && !q(t.charCodeAt(r)); ) r++;
101
+ continue;
102
+ }
103
+ let i = -1;
104
+ if (s === 101 && r + 6 < o && t.charCodeAt(r + 1) === 120 && t.charCodeAt(r + 2) === 112 && t.charCodeAt(r + 3) === 111 && t.charCodeAt(r + 4) === 114 && t.charCodeAt(r + 5) === 116) {
105
+ let v = t.charCodeAt(r + 6);
106
+ if (w(v)) {
107
+ let u = r + 7;
108
+ for (; u < o && w(t.charCodeAt(u)); ) u++;
109
+ b[t.charCodeAt(u)] && (i = r + 6, r = u);
110
+ } else s = t.charCodeAt(r);
111
+ }
112
+ let l = r, d = 0;
113
+ for (; r < o && (d = t.charCodeAt(r), b[d]); ) r++;
114
+ if (r === l) {
115
+ for (; r < o && !q(t.charCodeAt(r)); ) r++;
116
+ continue;
117
+ }
118
+ let h = t.slice(l, r), f = r;
119
+ if (r >= o && (d = 0), w(d)) do
120
+ r++, d = r < o ? t.charCodeAt(r) : 0;
121
+ while (w(d));
122
+ if (d === 61) r++;
123
+ else if (d === 58 && r === f && r + 1 < o && w(t.charCodeAt(r + 1))) r += 2;
124
+ else {
125
+ for (r = i === -1 ? f : i; r < o && !q(t.charCodeAt(r)); ) r++;
126
+ continue;
127
+ }
128
+ let c = r, a = r;
129
+ for (; a < o && w(t.charCodeAt(a)); ) a++;
130
+ let g = t.charCodeAt(a), p, y = false;
131
+ if (g === 39 || g === 34 || g === 96) {
132
+ let v = t[a], u = t.indexOf(v, a + 1), m = -1, C = -1;
133
+ for (; u !== -1; ) {
134
+ let O = t.charCodeAt(u - 1) === 92, E = u + 1;
135
+ for (; E < o && !q(t.charCodeAt(E)) && w(t.charCodeAt(E)); ) E++;
136
+ if ((E === o || q(t.charCodeAt(E)) || t.charCodeAt(E) === 35) && (m = u, C = E), !O) break;
137
+ u = t.indexOf(v, u + 1);
138
+ }
139
+ if (m !== -1) {
140
+ if (p = t.slice(a + 1, m), r = C, t.charCodeAt(r) === 35) for (; r < o && !q(t.charCodeAt(r)); ) r++;
141
+ y = true;
175
142
  }
176
143
  }
177
- } else {
178
- possibleVaultPath = options.path.endsWith(".vault") ? options.path : `${options.path}.vault`;
144
+ if (!y) {
145
+ let v = t.indexOf(`
146
+ `, c);
147
+ v === -1 && (v = o);
148
+ let u;
149
+ if (o < 4096) u = t.indexOf("#", c), (u === -1 || u > v) && (u = v);
150
+ else for (u = c; u < v && t.charCodeAt(u) !== 35; ) u++;
151
+ let m = c, C = u;
152
+ for (; m < C && w(t.charCodeAt(m)); ) m++;
153
+ for (; C > m && w(t.charCodeAt(C - 1)); ) C--;
154
+ let O = t.charCodeAt(m);
155
+ if (p = t.slice(m, C), p.includes("\u2028") || p.includes("\u2029") ? p = p.replace(/^(['"`])([\s\S]*)\1$/mg, "$2") : C - m >= 2 && (O === 39 || O === 34 || O === 96) && t.charCodeAt(C - 1) === O && (p = t.slice(m + 1, C - 1)), r = u, u < v) for (; r < o && !q(t.charCodeAt(r)); ) r++;
156
+ }
157
+ g === 34 && (y || a < r) && p.indexOf("\\") !== -1 && (p = p.replace(/\\n/g, `
158
+ `).replace(/\\r/g, "\r")), n[h] = p;
179
159
  }
180
- } else {
181
- possibleVaultPath = path13.resolve(process.cwd(), ".env.vault");
160
+ return n;
182
161
  }
183
- if (fs7.existsSync(possibleVaultPath)) {
184
- return possibleVaultPath;
162
+ function se(e, n) {
163
+ return n && $(n.fast) ? oe(e) : ne(e);
185
164
  }
186
- return null;
187
- }
188
- function _resolveHome(envPath) {
189
- return envPath[0] === "~" ? path13.join(os2.homedir(), envPath.slice(1)) : envPath;
190
- }
191
- function _configVault(options) {
192
- const debug = parseBoolean(process.env.DOTENV_CONFIG_DEBUG || options && options.debug);
193
- const quiet = parseBoolean(process.env.DOTENV_CONFIG_QUIET || options && options.quiet);
194
- if (debug || !quiet) {
195
- _log("loading env from encrypted .env.vault");
196
- }
197
- const parsed = DotenvModule._parseVault(options);
198
- let processEnv = process.env;
199
- if (options && options.processEnv != null) {
200
- processEnv = options.processEnv;
201
- }
202
- DotenvModule.populate(processEnv, parsed, options);
203
- return { parsed };
204
- }
205
- function configDotenv(options) {
206
- const dotenvPath = path13.resolve(process.cwd(), ".env");
207
- let encoding = "utf8";
208
- let processEnv = process.env;
209
- if (options && options.processEnv != null) {
210
- processEnv = options.processEnv;
211
- }
212
- let debug = parseBoolean(processEnv.DOTENV_CONFIG_DEBUG || options && options.debug);
213
- let quiet = parseBoolean(processEnv.DOTENV_CONFIG_QUIET || options && options.quiet);
214
- if (options && options.encoding) {
215
- encoding = options.encoding;
216
- } else {
217
- if (debug) {
218
- _debug("no encoding is specified (UTF-8 is used by default)");
165
+ function T(e) {
166
+ console.log(`\u2506 ${e}`);
167
+ }
168
+ function ie(e) {
169
+ console.error(`\u25C7 ${e}`);
170
+ }
171
+ function V(e) {
172
+ return e[0] === "~" ? I.join(Z.homedir(), e.slice(1)) : e;
173
+ }
174
+ function ce(e = {}) {
175
+ let n = { ...e };
176
+ for (let t of Object.keys(n)) n[t] === void 0 && delete n[t];
177
+ return { ...B(), ...n };
178
+ }
179
+ function ae(e) {
180
+ e = ce(e);
181
+ let n = I.resolve(process.cwd(), ".env"), t = "utf8", o = process.env;
182
+ e && e.processEnv != null && (o = e.processEnv);
183
+ let r = $(e && e.debug);
184
+ e && e.encoding ? t = e.encoding : r && T("no encoding is specified (UTF-8 is used by default)");
185
+ let s = [n];
186
+ if (e && e.path) if (!Array.isArray(e.path)) s = [V(e.path)];
187
+ else {
188
+ s = [];
189
+ for (let c of e.path) s.push(V(c));
190
+ }
191
+ let i, l = {}, d = { fast: e.fast };
192
+ for (let c of s) try {
193
+ let a = A.parse(z.readFileSync(c, { encoding: t }), d);
194
+ A.populate(l, a, e);
195
+ } catch (a) {
196
+ r && T(`failed to load ${c} ${a.message}`), i = a;
197
+ }
198
+ let h = A.populate(o, l, e), f = $(Object.prototype.hasOwnProperty.call(e, "quiet") ? e.quiet : B(o).quiet);
199
+ if (r || !f) {
200
+ let c = Object.keys(h).length, a = [];
201
+ for (let g of s) try {
202
+ let p = I.relative(process.cwd(), g instanceof ee ? te(g) : g);
203
+ a.push(p);
204
+ } catch (p) {
205
+ r && T(`failed to load ${g} ${p.message}`), i = p;
206
+ }
207
+ ie(`injected env (${c}) from ${a.join(",")}`);
219
208
  }
209
+ return i ? { parsed: l, error: i } : { parsed: l };
220
210
  }
221
- let optionPaths = [dotenvPath];
222
- if (options && options.path) {
223
- if (!Array.isArray(options.path)) {
224
- optionPaths = [_resolveHome(options.path)];
225
- } else {
226
- optionPaths = [];
227
- for (const filepath of options.path) {
228
- optionPaths.push(_resolveHome(filepath));
211
+ function le(e) {
212
+ return A.configDotenv(e);
213
+ }
214
+ function fe(e, n, t = {}) {
215
+ let o = $(t && t.debug), r = $(t && t.override), s = {};
216
+ if (e === null || typeof e != "object" || n === null || typeof n != "object") {
217
+ let i = new Error("OBJECT_REQUIRED: Please check the processEnv argument being passed to populate");
218
+ throw i.code = "OBJECT_REQUIRED", i;
219
+ }
220
+ for (let i of Object.keys(n)) Object.prototype.hasOwnProperty.call(e, i) ? (r === true && (e[i] = n[i], s[i] = n[i]), o && T(r === true ? `"${i}" is already defined and WAS overwritten` : `"${i}" is already defined and was NOT overwritten`)) : (e[i] = n[i], s[i] = n[i]);
221
+ return s;
222
+ }
223
+ var A = { configDotenv: ae, config: le, parse: se, populate: fe };
224
+ x.exports.configDotenv = A.configDotenv;
225
+ x.exports.config = A.config;
226
+ x.exports.parse = A.parse;
227
+ x.exports.populate = A.populate;
228
+ x.exports = A;
229
+ });
230
+ var M = j((Te, W) => {
231
+ var _ = __require("child_process"), ue = __require("fs"), L = __require("path");
232
+ function de(e) {
233
+ let n = ['"'], t = 0;
234
+ for (let o of e) {
235
+ if (o === "\\") {
236
+ t++;
237
+ continue;
229
238
  }
239
+ o === '"' ? n.push("\\".repeat(t * 2 + 1), '"') : n.push("\\".repeat(t), o), t = 0;
230
240
  }
241
+ return n.push("\\".repeat(t * 2), '"'), n.join("");
231
242
  }
232
- let lastError;
233
- const parsedAll = {};
234
- for (const path14 of optionPaths) {
235
- try {
236
- const parsed = DotenvModule.parse(fs7.readFileSync(path14, { encoding }));
237
- DotenvModule.populate(parsedAll, parsed, options);
238
- } catch (e) {
239
- if (debug) {
240
- _debug(`failed to load ${path14} ${e.message}`);
241
- }
242
- lastError = e;
243
- }
244
- }
245
- const populated = DotenvModule.populate(processEnv, parsedAll, options);
246
- debug = parseBoolean(processEnv.DOTENV_CONFIG_DEBUG || debug);
247
- quiet = parseBoolean(processEnv.DOTENV_CONFIG_QUIET || quiet);
248
- if (debug || !quiet) {
249
- const keysCount = Object.keys(populated).length;
250
- const shortPaths = [];
251
- for (const filePath of optionPaths) {
252
- try {
253
- const relative2 = path13.relative(process.cwd(), filePath);
254
- shortPaths.push(relative2);
255
- } catch (e) {
256
- if (debug) {
257
- _debug(`failed to load ${filePath} ${e.message}`);
258
- }
259
- lastError = e;
243
+ function H(e, n = 1) {
244
+ for (let t = 0; t < n; t++) {
245
+ let o = [];
246
+ for (let r of e) {
247
+ let s = r.charCodeAt(0), i = s >= 48 && s <= 57 || s >= 65 && s <= 90 || s >= 97 && s <= 122, l = "\\/:._-".includes(r);
248
+ !i && !l && s < 128 && o.push("^"), o.push(r);
260
249
  }
250
+ e = o.join("");
261
251
  }
262
- _log(`injected env (${keysCount}) from ${shortPaths.join(",")} ${dim(`// tip: ${_getRandomTip()}`)}`);
252
+ return e;
263
253
  }
264
- if (lastError) {
265
- return { parsed: parsedAll, error: lastError };
266
- } else {
267
- return { parsed: parsedAll };
254
+ function P(e, n) {
255
+ let t = Object.keys(e).reverse().find((o) => o.toUpperCase() === n);
256
+ return t === void 0 ? void 0 : e[t];
268
257
  }
269
- }
270
- function config(options) {
271
- if (_dotenvKey(options).length === 0) {
272
- return DotenvModule.configDotenv(options);
258
+ function pe(e, n, t) {
259
+ let o = (P(n, "PATHEXT") || ".COM;.EXE;.BAT;.CMD").split(";").filter(Boolean), s = o.some((l) => e.toLowerCase().endsWith(l.toLowerCase())) ? ["", ...o] : [...o, ""], i = /[\\/]/.test(e) ? [t] : [t, ...(P(n, "PATH") || "").split(";")];
260
+ for (let l of i) for (let d of s) {
261
+ let h = L.resolve(t, l.replace(/^"|"$/g, ""), e + d);
262
+ try {
263
+ if (ue.statSync(h).isFile()) return h;
264
+ } catch {
265
+ }
266
+ }
273
267
  }
274
- const vaultPath = _vaultPath(options);
275
- if (!vaultPath) {
276
- _warn(`you set DOTENV_KEY but you are missing a .env.vault file at ${vaultPath}`);
277
- return DotenvModule.configDotenv(options);
268
+ function he(e, n, t) {
269
+ if (process.platform !== "win32") return _.spawn(e, n, t);
270
+ let o = t.env || process.env, r = pe(e, o, t.cwd || process.cwd());
271
+ if (r && /\.(?:exe|com)$/i.test(r)) return _.spawn(r, n, t);
272
+ let s = /\.(?:bat|cmd)$/i.test(r || e), i = [H(L.normalize(r || e))];
273
+ for (let d of n) i.push(H(de(d), s ? 2 : 1));
274
+ let l = i.join(" ");
275
+ return _.spawn(P(o, "COMSPEC") || "cmd.exe", ["/d", "/v:off", "/s", "/c", `"${l}"`], { ...t, windowsVerbatimArguments: true });
278
276
  }
279
- return DotenvModule._configVault(options);
280
- }
281
- function decrypt(encrypted, keyStr) {
282
- const key = Buffer.from(keyStr.slice(-64), "hex");
283
- let ciphertext = Buffer.from(encrypted, "base64");
284
- const nonce = ciphertext.subarray(0, 12);
285
- const authTag = ciphertext.subarray(-16);
286
- ciphertext = ciphertext.subarray(12, -16);
287
- try {
288
- const aesgcm = crypto2.createDecipheriv("aes-256-gcm", key, nonce);
289
- aesgcm.setAuthTag(authTag);
290
- return `${aesgcm.update(ciphertext)}${aesgcm.final()}`;
291
- } catch (error) {
292
- const isRange = error instanceof RangeError;
293
- const invalidKeyLength = error.message === "Invalid key length";
294
- const decryptionFailed = error.message === "Unsupported state or unable to authenticate data";
295
- if (isRange || invalidKeyLength) {
296
- const err = new Error("INVALID_DOTENV_KEY: It must be 64 characters long (or more)");
297
- err.code = "INVALID_DOTENV_KEY";
298
- throw err;
299
- } else if (decryptionFailed) {
300
- const err = new Error("DECRYPTION_FAILED: Please check your DOTENV_KEY");
301
- err.code = "DECRYPTION_FAILED";
302
- throw err;
303
- } else {
304
- throw error;
277
+ W.exports = he;
278
+ });
279
+ var X = j(($e, F) => {
280
+ var ge = __require("fs"), me = __require("os"), Q = __require("path"), ve = __require("child_process"), Ce = M(), R = N(), { optionsFromEnv: J } = k();
281
+ function D() {
282
+ console.log(["Usage: dotenv run [--help] [-q|--quiet] [--debug] [--override] [--fast] [-f|--file <paths>] [--] <command> [args...]", "", "Run a command with environment variables from a .env file.", "Place dotenv options before the command; all following arguments go to the command.", "", "Options:", " -f, --file <paths> .env paths, comma-separated or repeated (default: .env)", " -q, --quiet suppress the injected env message", " --debug enable debug logging", " --override override existing environment variables", " --fast use the faster character-scanner parser", "", "Environment variables (DOTENV_CONFIG_* names remain as fallbacks):", " DOTENV_PATH, DOTENV_ENCODING, DOTENV_QUIET,", " DOTENV_DEBUG, DOTENV_OVERRIDE,", " DOTENV_FAST"].join(`
283
+ `));
284
+ }
285
+ function we(e) {
286
+ let n = [], t = false, o, r, s, i, l = -1;
287
+ for (let h = 0; h < e.length; h++) {
288
+ let f = e[h];
289
+ if (f === "--") {
290
+ l = h + 1;
291
+ break;
292
+ }
293
+ if (f === "--help" || f === "-h") return { help: true };
294
+ if (f === "--quiet" || f === "-q") {
295
+ o = true;
296
+ continue;
297
+ }
298
+ if (f === "--debug") {
299
+ r = true;
300
+ continue;
301
+ }
302
+ if (f === "--override") {
303
+ s = true;
304
+ continue;
305
+ }
306
+ if (f === "--fast") {
307
+ i = true;
308
+ continue;
309
+ }
310
+ if (f === "-f" || f === "--file" || f.startsWith("-f=") || f.startsWith("--file=")) {
311
+ let c = f.indexOf("="), a = c === -1 ? f : f.slice(0, c), g = c === -1 ? e[++h] : f.slice(c + 1);
312
+ if (!g || g === "--") return { error: `${a} requires a path` };
313
+ let p = g.split(",").map((y) => y.trim()).filter(Boolean);
314
+ if (p.length === 0) return { error: `${a} requires a path` };
315
+ n.push(...p), t = true;
316
+ continue;
317
+ }
318
+ if (f.startsWith("-")) return { error: `unknown option: ${f}` };
319
+ l = h;
320
+ break;
305
321
  }
322
+ let d = l === -1 ? [] : e.slice(l);
323
+ return { paths: n, pathSet: t, quiet: o, debug: r, override: s, fast: i, command: d };
306
324
  }
307
- }
308
- function populate(processEnv, parsed, options = {}) {
309
- const debug = Boolean(options && options.debug);
310
- const override = Boolean(options && options.override);
311
- const populated = {};
312
- if (typeof parsed !== "object") {
313
- const err = new Error("OBJECT_REQUIRED: Please check the processEnv argument being passed to populate");
314
- err.code = "OBJECT_REQUIRED";
315
- throw err;
325
+ function Ae(e) {
326
+ return e[0] === "~" ? Q.join(me.homedir(), e.slice(1)) : e;
327
+ }
328
+ function Ee(e) {
329
+ let n = J(), t = { encoding: n.encoding || "utf8", quiet: n.quiet, debug: n.debug === true, override: n.override === true, fast: n.fast === true, paths: [".env"], defaultPath: true };
330
+ return n.path != null && (t.paths = [n.path], t.defaultPath = false), e.pathSet && (t.paths = e.paths, t.defaultPath = false), e.quiet != null && (t.quiet = e.quiet), e.debug != null && (t.debug = e.debug), e.override != null && (t.override = e.override), e.fast != null && (t.fast = e.fast), t;
316
331
  }
317
- for (const key of Object.keys(parsed)) {
318
- if (Object.prototype.hasOwnProperty.call(processEnv, key)) {
319
- if (override === true) {
320
- processEnv[key] = parsed[key];
321
- populated[key] = parsed[key];
332
+ function be(e) {
333
+ let n = {}, t = [], o = { override: e.override, debug: e.debug };
334
+ for (let s of e.paths) {
335
+ let i = Q.resolve(process.cwd(), Ae(s));
336
+ try {
337
+ let l = R.parse(ge.readFileSync(i, { encoding: e.encoding }), { fast: e.fast });
338
+ R.populate(n, l, o), t.push(s);
339
+ } catch (l) {
340
+ if (e.debug && console.log(`\u2506 failed to load ${s} ${l.message}`), !(e.defaultPath && l.code === "ENOENT")) throw l;
322
341
  }
323
- if (debug) {
324
- if (override === true) {
325
- _debug(`"${key}" is already defined and WAS overwritten`);
326
- } else {
327
- _debug(`"${key}" is already defined and was NOT overwritten`);
342
+ }
343
+ return { injected: R.populate(process.env, n, o), loadedPaths: t };
344
+ }
345
+ function K(e) {
346
+ let n = e[0];
347
+ if (n === "--help" || n === "-h") {
348
+ D();
349
+ return;
350
+ }
351
+ if (n !== "run") {
352
+ D(), process.exitCode = 1;
353
+ return;
354
+ }
355
+ let t = we(e.slice(1));
356
+ if (t.help) {
357
+ D();
358
+ return;
359
+ }
360
+ if (t.error) {
361
+ console.error(`dotenv: ${t.error}`), D(), process.exitCode = 1;
362
+ return;
363
+ }
364
+ if (t.command.length === 0) {
365
+ D(), process.exitCode = 1;
366
+ return;
367
+ }
368
+ let o = Ee(t);
369
+ try {
370
+ let c = be(o);
371
+ if (!(o.quiet == null ? J().quiet : o.quiet)) {
372
+ let g = `\u25C7 injected env (${Object.keys(c.injected).length})`;
373
+ c.loadedPaths.length > 0 && (g += ` from ${c.loadedPaths.join(", ")}`), console.error(g);
374
+ }
375
+ } catch (c) {
376
+ console.error(`dotenv: ${c.message}`), process.exitCode = 1;
377
+ return;
378
+ }
379
+ let r = !!process.stdin.isTTY, s = process.platform !== "win32" && !r, i = Ce(t.command[0], t.command.slice(1), { stdio: "inherit", detached: s }), l = /* @__PURE__ */ new Map(), d = 0;
380
+ function h(c) {
381
+ if (!(!i.pid || i.exitCode !== null || i.signalCode !== null)) {
382
+ if (process.platform === "win32") {
383
+ ve.spawnSync("taskkill", ["/pid", String(i.pid), "/T", "/F"], { stdio: "ignore" });
384
+ return;
385
+ }
386
+ try {
387
+ process.kill(s ? -i.pid : i.pid, c);
388
+ } catch (a) {
389
+ if (a.code !== "ESRCH") throw a;
328
390
  }
329
391
  }
330
- } else {
331
- processEnv[key] = parsed[key];
332
- populated[key] = parsed[key];
333
392
  }
393
+ function f() {
394
+ for (let [c, a] of l) process.removeListener(c, a);
395
+ }
396
+ for (let c of ["SIGINT", "SIGTERM", "SIGHUP", "SIGQUIT"]) {
397
+ let a = () => {
398
+ if (c === "SIGINT") {
399
+ if (d++, r && process.platform !== "win32" && d === 1) return;
400
+ if (d > 1) {
401
+ h(d === 2 ? "SIGTERM" : "SIGKILL");
402
+ return;
403
+ }
404
+ }
405
+ h(c);
406
+ };
407
+ l.set(c, a), process.on(c, a);
408
+ }
409
+ i.on("error", function(c) {
410
+ f(), console.error(`dotenv: ${c.message}`), process.exitCode = 1;
411
+ }), i.on("exit", function(c, a) {
412
+ f(), typeof c == "number" ? process.exit(c) : (setInterval(() => {
413
+ }, 1e3), process.kill(process.pid, a));
414
+ });
334
415
  }
335
- return populated;
336
- }
337
- var DotenvModule = {
338
- configDotenv,
339
- _configVault,
340
- _parseVault,
341
- config,
342
- decrypt,
343
- parse,
344
- populate
345
- };
346
- module.exports.configDotenv = DotenvModule.configDotenv;
347
- module.exports._configVault = DotenvModule._configVault;
348
- module.exports._parseVault = DotenvModule._parseVault;
349
- module.exports.config = DotenvModule.config;
350
- module.exports.decrypt = DotenvModule.decrypt;
351
- module.exports.parse = DotenvModule.parse;
352
- module.exports.populate = DotenvModule.populate;
353
- module.exports = DotenvModule;
416
+ F.exports = K;
417
+ __require.main === F && K(process.argv.slice(2));
418
+ });
419
+ var S = N();
420
+ var qe = X();
421
+ module.exports = S;
422
+ module.exports.config = S.config;
423
+ module.exports.configDotenv = S.configDotenv;
424
+ module.exports.parse = S.parse;
425
+ module.exports.populate = S.populate;
426
+ __require.main === module && qe(process.argv.slice(2));
354
427
  }
355
428
  });
356
429
 
@@ -978,36 +1051,38 @@ var require_Alias = __commonJS({
978
1051
  if (node.anchor === this.source)
979
1052
  found = node;
980
1053
  }
1054
+ if (found && ctx) {
1055
+ const { anchors: anchors2, doc: doc2, maxAliasCount } = ctx;
1056
+ let data = anchors2.get(found);
1057
+ if (!data) {
1058
+ toJS.toJS(found, null, ctx);
1059
+ data = anchors2.get(found);
1060
+ }
1061
+ if (data?.res === void 0) {
1062
+ const msg = "This should not happen: Alias anchor was not resolved?";
1063
+ throw new ReferenceError(msg);
1064
+ }
1065
+ if (maxAliasCount >= 0) {
1066
+ data.count += 1;
1067
+ if (data.aliasCount === 0)
1068
+ data.aliasCount = getAliasCount(doc2, found, anchors2);
1069
+ if (data.count * data.aliasCount > maxAliasCount) {
1070
+ const msg = "Excessive alias count indicates a resource exhaustion attack";
1071
+ throw new ReferenceError(msg);
1072
+ }
1073
+ }
1074
+ }
981
1075
  return found;
982
1076
  }
983
1077
  toJSON(_arg, ctx) {
984
1078
  if (!ctx)
985
1079
  return { source: this.source };
986
- const { anchors: anchors2, doc, maxAliasCount } = ctx;
987
- const source = this.resolve(doc, ctx);
1080
+ const source = this.resolve(ctx.doc, ctx);
988
1081
  if (!source) {
989
1082
  const msg = `Unresolved alias (the anchor must be set before the alias): ${this.source}`;
990
1083
  throw new ReferenceError(msg);
991
1084
  }
992
- let data = anchors2.get(source);
993
- if (!data) {
994
- toJS.toJS(source, null, ctx);
995
- data = anchors2.get(source);
996
- }
997
- if (data?.res === void 0) {
998
- const msg = "This should not happen: Alias anchor was not resolved?";
999
- throw new ReferenceError(msg);
1000
- }
1001
- if (maxAliasCount >= 0) {
1002
- data.count += 1;
1003
- if (data.aliasCount === 0)
1004
- data.aliasCount = getAliasCount(doc, source, anchors2);
1005
- if (data.count * data.aliasCount > maxAliasCount) {
1006
- const msg = "Excessive alias count indicates a resource exhaustion attack";
1007
- throw new ReferenceError(msg);
1008
- }
1009
- }
1010
- return data.res;
1085
+ return ctx.anchors.get(source).res;
1011
1086
  }
1012
1087
  toString(ctx, _onComment, _onChompKeep) {
1013
1088
  const src = `*${this.source}`;
@@ -5009,37 +5084,38 @@ var require_resolve_flow_scalar = __commonJS({
5009
5084
  }
5010
5085
  if (badChar)
5011
5086
  onError(0, "BAD_SCALAR_START", `Plain value cannot start with ${badChar}`);
5012
- return foldLines(source);
5087
+ return unfoldLines(source);
5013
5088
  }
5014
5089
  function singleQuotedValue(source, onError) {
5015
5090
  if (source[source.length - 1] !== "'" || source.length === 1)
5016
5091
  onError(source.length, "MISSING_CHAR", "Missing closing 'quote");
5017
- return foldLines(source.slice(1, -1)).replace(/''/g, "'");
5092
+ return unfoldLines(source.slice(1, -1)).replace(/''/g, "'");
5018
5093
  }
5019
- function foldLines(source) {
5020
- let first, line;
5094
+ function unfoldLines(source) {
5095
+ const line = /(.*?)\r?\n/sy;
5096
+ let match = line.exec(source);
5097
+ if (!match)
5098
+ return source;
5099
+ let trimEnd, trimBoth;
5021
5100
  try {
5022
- first = new RegExp("(.*?)(?<![ ])[ ]*\r?\n", "sy");
5023
- line = new RegExp("[ ]*(.*?)(?:(?<![ ])[ ]*)?\r?\n", "sy");
5101
+ trimEnd = new RegExp("(?<![ ])[ ]+$");
5102
+ trimBoth = new RegExp("^[ ]+|(?<![ ])[ ]+$", "g");
5024
5103
  } catch {
5025
- first = /(.*?)[ \t]*\r?\n/sy;
5026
- line = /[ \t]*(.*?)[ \t]*\r?\n/sy;
5104
+ trimEnd = /[ \t]+$/;
5105
+ trimBoth = /^[ \t]+|[ \t]+$/g;
5027
5106
  }
5028
- let match = first.exec(source);
5029
- if (!match)
5030
- return source;
5031
- let res = match[1];
5107
+ let res = match[1].replace(trimEnd, "");
5032
5108
  let sep6 = " ";
5033
- let pos = first.lastIndex;
5034
- line.lastIndex = pos;
5109
+ let pos = line.lastIndex;
5035
5110
  while (match = line.exec(source)) {
5036
- if (match[1] === "") {
5111
+ const lm = match[1].replace(trimBoth, "");
5112
+ if (lm === "") {
5037
5113
  if (sep6 === "\n")
5038
5114
  res += sep6;
5039
5115
  else
5040
5116
  sep6 = "\n";
5041
5117
  } else {
5042
- res += sep6 + match[1];
5118
+ res += sep6 + lm;
5043
5119
  sep6 = " ";
5044
5120
  }
5045
5121
  pos = line.lastIndex;
@@ -7630,7 +7706,7 @@ var require_public_api = __commonJS({
7630
7706
  });
7631
7707
 
7632
7708
  // ../../node_modules/yaml/dist/index.js
7633
- var require_dist = __commonJS({
7709
+ var require_dist2 = __commonJS({
7634
7710
  "../../node_modules/yaml/dist/index.js"(exports) {
7635
7711
  "use strict";
7636
7712
  var composer = require_composer();
@@ -7853,7 +7929,7 @@ function getAtPath(obj, dottedKey) {
7853
7929
  }
7854
7930
 
7855
7931
  // ../configuration-core/src/secrets.ts
7856
- var import_dotenv = __toESM(require_main(), 1);
7932
+ var import_dotenv = __toESM(require_dist(), 1);
7857
7933
  import * as fs3 from "node:fs";
7858
7934
  import * as path4 from "node:path";
7859
7935
 
@@ -8808,6 +8884,11 @@ var FAILURE_CODES = {
8808
8884
  // a device that is not foldable, no hinge route, a remote simulator.
8809
8885
  IOS_FOLD_FAILED: "IOS_FOLD_FAILED",
8810
8886
  IOS_FOLD_UNSUPPORTED: "IOS_FOLD_UNSUPPORTED",
8887
+ // The hinge of a foldable Android emulator: the console refused the move or
8888
+ // the guest never committed the state vs. nothing to fold — a phone profile,
8889
+ // a physical device.
8890
+ ANDROID_FOLD_FAILED: "ANDROID_FOLD_FAILED",
8891
+ ANDROID_FOLD_UNSUPPORTED: "ANDROID_FOLD_UNSUPPORTED",
8811
8892
  PASTE_CLIPBOARD_SET_FAILED: "PASTE_CLIPBOARD_SET_FAILED",
8812
8893
  PASTE_CLIPBOARD_UNSUPPORTED: "PASTE_CLIPBOARD_UNSUPPORTED",
8813
8894
  SETTINGS_PERMISSION_UNSUPPORTED: "SETTINGS_PERMISSION_UNSUPPORTED",
@@ -9355,7 +9436,7 @@ async function uploadFile(sourcePath, endpoint, signal) {
9355
9436
  const tarPath = path9.join(tmpdir(), `argent-upload-${randomUUID4()}.tar.gz`);
9356
9437
  trackArchive(tarPath);
9357
9438
  try {
9358
- await createTarGzFile(sourcePath, tarPath);
9439
+ await createTarGzFile(await realpath2(sourcePath), tarPath);
9359
9440
  const contentHash = await sha256File(tarPath);
9360
9441
  return { uploadId: await uploadTar(tarPath, endpoint, signal), contentHash };
9361
9442
  } finally {
@@ -9525,7 +9606,7 @@ async function applyClientFileDirectives(result, opts = {}) {
9525
9606
  }
9526
9607
 
9527
9608
  // ../argent-tools-client/src/flow-files.ts
9528
- var import_yaml = __toESM(require_dist(), 1);
9609
+ var import_yaml = __toESM(require_dist2(), 1);
9529
9610
  import { readdir as readdir4, readFile as readFile4, realpath as realpath3, stat as stat3 } from "node:fs/promises";
9530
9611
  import * as path10 from "node:path";
9531
9612
  var INLINE_MEMBERS_BYTES = 256 * 1024;