@_davideast/stitch-mcp 0.5.1 → 0.5.2
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/chunk-1fbzpreg.js +137 -0
- package/dist/chunk-1fbzpreg.js.map +10 -0
- package/dist/chunk-4zqw9exz.js +370 -0
- package/dist/chunk-4zqw9exz.js.map +16 -0
- package/dist/chunk-9g1t32qk.js +273 -0
- package/dist/chunk-9g1t32qk.js.map +10 -0
- package/dist/chunk-aa5ptn4s.js +768 -0
- package/dist/chunk-aa5ptn4s.js.map +18 -0
- package/dist/chunk-b9nzx4rf.js +19 -0
- package/dist/chunk-b9nzx4rf.js.map +9 -0
- package/dist/chunk-c87d10w8.js +109 -0
- package/dist/chunk-c87d10w8.js.map +10 -0
- package/dist/chunk-d0ffvq20.js +19 -0
- package/dist/chunk-d0ffvq20.js.map +9 -0
- package/dist/chunk-d8nttd6z.js +683 -0
- package/dist/chunk-d8nttd6z.js.map +17 -0
- package/dist/chunk-e4q3v109.js +31464 -0
- package/dist/chunk-e4q3v109.js.map +245 -0
- package/dist/chunk-etcps0m5.js +1495 -0
- package/dist/chunk-etcps0m5.js.map +23 -0
- package/dist/chunk-f89ve6pt.js +256 -0
- package/dist/chunk-f89ve6pt.js.map +11 -0
- package/dist/chunk-gydabgsn.js +10 -0
- package/dist/chunk-gydabgsn.js.map +9 -0
- package/dist/chunk-m4fp3pqc.js +167 -0
- package/dist/chunk-m4fp3pqc.js.map +10 -0
- package/dist/chunk-nnep362g.js +124 -0
- package/dist/chunk-nnep362g.js.map +12 -0
- package/dist/chunk-pgqvwkcy.js +736 -0
- package/dist/chunk-pgqvwkcy.js.map +16 -0
- package/dist/chunk-q8cr9t2z.js +415 -0
- package/dist/chunk-q8cr9t2z.js.map +20 -0
- package/dist/chunk-s2d39pkr.js +19 -0
- package/dist/chunk-s2d39pkr.js.map +9 -0
- package/dist/chunk-ststnnry.js +44150 -0
- package/dist/chunk-ststnnry.js.map +237 -0
- package/dist/chunk-sv2nt87j.js +24 -0
- package/dist/chunk-sv2nt87j.js.map +9 -0
- package/dist/chunk-t2razx5k.js +69 -0
- package/dist/chunk-t2razx5k.js.map +10 -0
- package/dist/commands/doctor/command.js +10 -6
- package/dist/commands/doctor/command.js.map +4 -4
- package/dist/commands/doctor/spec.d.ts +6 -0
- package/dist/commands/init/command.js +17 -9
- package/dist/commands/init/command.js.map +4 -4
- package/dist/commands/init/spec.d.ts +6 -0
- package/dist/commands/proxy/command.js +2 -3
- package/dist/commands/proxy/command.js.map +3 -3
- package/dist/commands/screens/command.js +2 -2
- package/dist/commands/serve/command.js +3 -3
- package/dist/commands/site/command.js +1 -1
- package/dist/commands/snapshot/command.js +1 -1
- package/dist/commands/tool/command.js +1 -1
- package/dist/commands/view/command.js +1 -1
- package/dist/index.js +2 -2
- package/package.json +1 -1
|
@@ -0,0 +1,768 @@
|
|
|
1
|
+
import {
|
|
2
|
+
StitchHandler,
|
|
3
|
+
createSpinner
|
|
4
|
+
} from "./chunk-py8fhw0k.js";
|
|
5
|
+
import {
|
|
6
|
+
ConsoleUI,
|
|
7
|
+
GcloudHandler
|
|
8
|
+
} from "./chunk-jyem6j6k.js";
|
|
9
|
+
import {
|
|
10
|
+
runSteps
|
|
11
|
+
} from "./chunk-f2hq6bfv.js";
|
|
12
|
+
import {
|
|
13
|
+
icons,
|
|
14
|
+
theme
|
|
15
|
+
} from "./chunk-kbtqrkwh.js";
|
|
16
|
+
import {
|
|
17
|
+
__commonJS,
|
|
18
|
+
__require,
|
|
19
|
+
__toESM
|
|
20
|
+
} from "./chunk-9wyra8hs.js";
|
|
21
|
+
|
|
22
|
+
// node_modules/dotenv/package.json
|
|
23
|
+
var require_package = __commonJS((exports, module) => {
|
|
24
|
+
module.exports = {
|
|
25
|
+
name: "dotenv",
|
|
26
|
+
version: "17.3.1",
|
|
27
|
+
description: "Loads environment variables from .env file",
|
|
28
|
+
main: "lib/main.js",
|
|
29
|
+
types: "lib/main.d.ts",
|
|
30
|
+
exports: {
|
|
31
|
+
".": {
|
|
32
|
+
types: "./lib/main.d.ts",
|
|
33
|
+
require: "./lib/main.js",
|
|
34
|
+
default: "./lib/main.js"
|
|
35
|
+
},
|
|
36
|
+
"./config": "./config.js",
|
|
37
|
+
"./config.js": "./config.js",
|
|
38
|
+
"./lib/env-options": "./lib/env-options.js",
|
|
39
|
+
"./lib/env-options.js": "./lib/env-options.js",
|
|
40
|
+
"./lib/cli-options": "./lib/cli-options.js",
|
|
41
|
+
"./lib/cli-options.js": "./lib/cli-options.js",
|
|
42
|
+
"./package.json": "./package.json"
|
|
43
|
+
},
|
|
44
|
+
scripts: {
|
|
45
|
+
"dts-check": "tsc --project tests/types/tsconfig.json",
|
|
46
|
+
lint: "standard",
|
|
47
|
+
pretest: "npm run lint && npm run dts-check",
|
|
48
|
+
test: "tap run tests/**/*.js --allow-empty-coverage --disable-coverage --timeout=60000",
|
|
49
|
+
"test:coverage": "tap run tests/**/*.js --show-full-coverage --timeout=60000 --coverage-report=text --coverage-report=lcov",
|
|
50
|
+
prerelease: "npm test",
|
|
51
|
+
release: "standard-version"
|
|
52
|
+
},
|
|
53
|
+
repository: {
|
|
54
|
+
type: "git",
|
|
55
|
+
url: "git://github.com/motdotla/dotenv.git"
|
|
56
|
+
},
|
|
57
|
+
homepage: "https://github.com/motdotla/dotenv#readme",
|
|
58
|
+
funding: "https://dotenvx.com",
|
|
59
|
+
keywords: [
|
|
60
|
+
"dotenv",
|
|
61
|
+
"env",
|
|
62
|
+
".env",
|
|
63
|
+
"environment",
|
|
64
|
+
"variables",
|
|
65
|
+
"config",
|
|
66
|
+
"settings"
|
|
67
|
+
],
|
|
68
|
+
readmeFilename: "README.md",
|
|
69
|
+
license: "BSD-2-Clause",
|
|
70
|
+
devDependencies: {
|
|
71
|
+
"@types/node": "^18.11.3",
|
|
72
|
+
decache: "^4.6.2",
|
|
73
|
+
sinon: "^14.0.1",
|
|
74
|
+
standard: "^17.0.0",
|
|
75
|
+
"standard-version": "^9.5.0",
|
|
76
|
+
tap: "^19.2.0",
|
|
77
|
+
typescript: "^4.8.4"
|
|
78
|
+
},
|
|
79
|
+
engines: {
|
|
80
|
+
node: ">=12"
|
|
81
|
+
},
|
|
82
|
+
browser: {
|
|
83
|
+
fs: false
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
// node_modules/dotenv/lib/main.js
|
|
89
|
+
var require_main = __commonJS((exports, module) => {
|
|
90
|
+
var fs = __require("fs");
|
|
91
|
+
var path = __require("path");
|
|
92
|
+
var os = __require("os");
|
|
93
|
+
var crypto = __require("crypto");
|
|
94
|
+
var packageJson = require_package();
|
|
95
|
+
var version = packageJson.version;
|
|
96
|
+
var TIPS = [
|
|
97
|
+
"\uD83D\uDD10 encrypt with Dotenvx: https://dotenvx.com",
|
|
98
|
+
"\uD83D\uDD10 prevent committing .env to code: https://dotenvx.com/precommit",
|
|
99
|
+
"\uD83D\uDD10 prevent building .env in docker: https://dotenvx.com/prebuild",
|
|
100
|
+
"\uD83E\uDD16 agentic secret storage: https://dotenvx.com/as2",
|
|
101
|
+
"⚡️ secrets for agents: https://dotenvx.com/as2",
|
|
102
|
+
"\uD83D\uDEE1️ auth for agents: https://vestauth.com",
|
|
103
|
+
"\uD83D\uDEE0️ run anywhere with `dotenvx run -- yourcommand`",
|
|
104
|
+
"⚙️ specify custom .env file path with { path: '/custom/path/.env' }",
|
|
105
|
+
"⚙️ enable debug logging with { debug: true }",
|
|
106
|
+
"⚙️ override existing env vars with { override: true }",
|
|
107
|
+
"⚙️ suppress all logs with { quiet: true }",
|
|
108
|
+
"⚙️ write to custom object with { processEnv: myObject }",
|
|
109
|
+
"⚙️ load multiple .env files with { path: ['.env.local', '.env'] }"
|
|
110
|
+
];
|
|
111
|
+
function _getRandomTip() {
|
|
112
|
+
return TIPS[Math.floor(Math.random() * TIPS.length)];
|
|
113
|
+
}
|
|
114
|
+
function parseBoolean(value) {
|
|
115
|
+
if (typeof value === "string") {
|
|
116
|
+
return !["false", "0", "no", "off", ""].includes(value.toLowerCase());
|
|
117
|
+
}
|
|
118
|
+
return Boolean(value);
|
|
119
|
+
}
|
|
120
|
+
function supportsAnsi() {
|
|
121
|
+
return process.stdout.isTTY;
|
|
122
|
+
}
|
|
123
|
+
function dim(text) {
|
|
124
|
+
return supportsAnsi() ? `\x1B[2m${text}\x1B[0m` : text;
|
|
125
|
+
}
|
|
126
|
+
var LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg;
|
|
127
|
+
function parse(src) {
|
|
128
|
+
const obj = {};
|
|
129
|
+
let lines = src.toString();
|
|
130
|
+
lines = lines.replace(/\r\n?/mg, `
|
|
131
|
+
`);
|
|
132
|
+
let match;
|
|
133
|
+
while ((match = LINE.exec(lines)) != null) {
|
|
134
|
+
const key = match[1];
|
|
135
|
+
let value = match[2] || "";
|
|
136
|
+
value = value.trim();
|
|
137
|
+
const maybeQuote = value[0];
|
|
138
|
+
value = value.replace(/^(['"`])([\s\S]*)\1$/mg, "$2");
|
|
139
|
+
if (maybeQuote === '"') {
|
|
140
|
+
value = value.replace(/\\n/g, `
|
|
141
|
+
`);
|
|
142
|
+
value = value.replace(/\\r/g, "\r");
|
|
143
|
+
}
|
|
144
|
+
obj[key] = value;
|
|
145
|
+
}
|
|
146
|
+
return obj;
|
|
147
|
+
}
|
|
148
|
+
function _parseVault(options) {
|
|
149
|
+
options = options || {};
|
|
150
|
+
const vaultPath = _vaultPath(options);
|
|
151
|
+
options.path = vaultPath;
|
|
152
|
+
const result = DotenvModule.configDotenv(options);
|
|
153
|
+
if (!result.parsed) {
|
|
154
|
+
const err = new Error(`MISSING_DATA: Cannot parse ${vaultPath} for an unknown reason`);
|
|
155
|
+
err.code = "MISSING_DATA";
|
|
156
|
+
throw err;
|
|
157
|
+
}
|
|
158
|
+
const keys = _dotenvKey(options).split(",");
|
|
159
|
+
const length = keys.length;
|
|
160
|
+
let decrypted;
|
|
161
|
+
for (let i = 0;i < length; i++) {
|
|
162
|
+
try {
|
|
163
|
+
const key = keys[i].trim();
|
|
164
|
+
const attrs = _instructions(result, key);
|
|
165
|
+
decrypted = DotenvModule.decrypt(attrs.ciphertext, attrs.key);
|
|
166
|
+
break;
|
|
167
|
+
} catch (error) {
|
|
168
|
+
if (i + 1 >= length) {
|
|
169
|
+
throw error;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
return DotenvModule.parse(decrypted);
|
|
174
|
+
}
|
|
175
|
+
function _warn(message) {
|
|
176
|
+
console.error(`[dotenv@${version}][WARN] ${message}`);
|
|
177
|
+
}
|
|
178
|
+
function _debug(message) {
|
|
179
|
+
console.log(`[dotenv@${version}][DEBUG] ${message}`);
|
|
180
|
+
}
|
|
181
|
+
function _log(message) {
|
|
182
|
+
console.log(`[dotenv@${version}] ${message}`);
|
|
183
|
+
}
|
|
184
|
+
function _dotenvKey(options) {
|
|
185
|
+
if (options && options.DOTENV_KEY && options.DOTENV_KEY.length > 0) {
|
|
186
|
+
return options.DOTENV_KEY;
|
|
187
|
+
}
|
|
188
|
+
if (process.env.DOTENV_KEY && process.env.DOTENV_KEY.length > 0) {
|
|
189
|
+
return process.env.DOTENV_KEY;
|
|
190
|
+
}
|
|
191
|
+
return "";
|
|
192
|
+
}
|
|
193
|
+
function _instructions(result, dotenvKey) {
|
|
194
|
+
let uri;
|
|
195
|
+
try {
|
|
196
|
+
uri = new URL(dotenvKey);
|
|
197
|
+
} catch (error) {
|
|
198
|
+
if (error.code === "ERR_INVALID_URL") {
|
|
199
|
+
const err = new Error("INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=development");
|
|
200
|
+
err.code = "INVALID_DOTENV_KEY";
|
|
201
|
+
throw err;
|
|
202
|
+
}
|
|
203
|
+
throw error;
|
|
204
|
+
}
|
|
205
|
+
const key = uri.password;
|
|
206
|
+
if (!key) {
|
|
207
|
+
const err = new Error("INVALID_DOTENV_KEY: Missing key part");
|
|
208
|
+
err.code = "INVALID_DOTENV_KEY";
|
|
209
|
+
throw err;
|
|
210
|
+
}
|
|
211
|
+
const environment = uri.searchParams.get("environment");
|
|
212
|
+
if (!environment) {
|
|
213
|
+
const err = new Error("INVALID_DOTENV_KEY: Missing environment part");
|
|
214
|
+
err.code = "INVALID_DOTENV_KEY";
|
|
215
|
+
throw err;
|
|
216
|
+
}
|
|
217
|
+
const environmentKey = `DOTENV_VAULT_${environment.toUpperCase()}`;
|
|
218
|
+
const ciphertext = result.parsed[environmentKey];
|
|
219
|
+
if (!ciphertext) {
|
|
220
|
+
const err = new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${environmentKey} in your .env.vault file.`);
|
|
221
|
+
err.code = "NOT_FOUND_DOTENV_ENVIRONMENT";
|
|
222
|
+
throw err;
|
|
223
|
+
}
|
|
224
|
+
return { ciphertext, key };
|
|
225
|
+
}
|
|
226
|
+
function _vaultPath(options) {
|
|
227
|
+
let possibleVaultPath = null;
|
|
228
|
+
if (options && options.path && options.path.length > 0) {
|
|
229
|
+
if (Array.isArray(options.path)) {
|
|
230
|
+
for (const filepath of options.path) {
|
|
231
|
+
if (fs.existsSync(filepath)) {
|
|
232
|
+
possibleVaultPath = filepath.endsWith(".vault") ? filepath : `${filepath}.vault`;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
} else {
|
|
236
|
+
possibleVaultPath = options.path.endsWith(".vault") ? options.path : `${options.path}.vault`;
|
|
237
|
+
}
|
|
238
|
+
} else {
|
|
239
|
+
possibleVaultPath = path.resolve(process.cwd(), ".env.vault");
|
|
240
|
+
}
|
|
241
|
+
if (fs.existsSync(possibleVaultPath)) {
|
|
242
|
+
return possibleVaultPath;
|
|
243
|
+
}
|
|
244
|
+
return null;
|
|
245
|
+
}
|
|
246
|
+
function _resolveHome(envPath) {
|
|
247
|
+
return envPath[0] === "~" ? path.join(os.homedir(), envPath.slice(1)) : envPath;
|
|
248
|
+
}
|
|
249
|
+
function _configVault(options) {
|
|
250
|
+
const debug = parseBoolean(process.env.DOTENV_CONFIG_DEBUG || options && options.debug);
|
|
251
|
+
const quiet = parseBoolean(process.env.DOTENV_CONFIG_QUIET || options && options.quiet);
|
|
252
|
+
if (debug || !quiet) {
|
|
253
|
+
_log("Loading env from encrypted .env.vault");
|
|
254
|
+
}
|
|
255
|
+
const parsed = DotenvModule._parseVault(options);
|
|
256
|
+
let processEnv = process.env;
|
|
257
|
+
if (options && options.processEnv != null) {
|
|
258
|
+
processEnv = options.processEnv;
|
|
259
|
+
}
|
|
260
|
+
DotenvModule.populate(processEnv, parsed, options);
|
|
261
|
+
return { parsed };
|
|
262
|
+
}
|
|
263
|
+
function configDotenv(options) {
|
|
264
|
+
const dotenvPath = path.resolve(process.cwd(), ".env");
|
|
265
|
+
let encoding = "utf8";
|
|
266
|
+
let processEnv = process.env;
|
|
267
|
+
if (options && options.processEnv != null) {
|
|
268
|
+
processEnv = options.processEnv;
|
|
269
|
+
}
|
|
270
|
+
let debug = parseBoolean(processEnv.DOTENV_CONFIG_DEBUG || options && options.debug);
|
|
271
|
+
let quiet = parseBoolean(processEnv.DOTENV_CONFIG_QUIET || options && options.quiet);
|
|
272
|
+
if (options && options.encoding) {
|
|
273
|
+
encoding = options.encoding;
|
|
274
|
+
} else {
|
|
275
|
+
if (debug) {
|
|
276
|
+
_debug("No encoding is specified. UTF-8 is used by default");
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
let optionPaths = [dotenvPath];
|
|
280
|
+
if (options && options.path) {
|
|
281
|
+
if (!Array.isArray(options.path)) {
|
|
282
|
+
optionPaths = [_resolveHome(options.path)];
|
|
283
|
+
} else {
|
|
284
|
+
optionPaths = [];
|
|
285
|
+
for (const filepath of options.path) {
|
|
286
|
+
optionPaths.push(_resolveHome(filepath));
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
let lastError;
|
|
291
|
+
const parsedAll = {};
|
|
292
|
+
for (const path2 of optionPaths) {
|
|
293
|
+
try {
|
|
294
|
+
const parsed = DotenvModule.parse(fs.readFileSync(path2, { encoding }));
|
|
295
|
+
DotenvModule.populate(parsedAll, parsed, options);
|
|
296
|
+
} catch (e) {
|
|
297
|
+
if (debug) {
|
|
298
|
+
_debug(`Failed to load ${path2} ${e.message}`);
|
|
299
|
+
}
|
|
300
|
+
lastError = e;
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
const populated = DotenvModule.populate(processEnv, parsedAll, options);
|
|
304
|
+
debug = parseBoolean(processEnv.DOTENV_CONFIG_DEBUG || debug);
|
|
305
|
+
quiet = parseBoolean(processEnv.DOTENV_CONFIG_QUIET || quiet);
|
|
306
|
+
if (debug || !quiet) {
|
|
307
|
+
const keysCount = Object.keys(populated).length;
|
|
308
|
+
const shortPaths = [];
|
|
309
|
+
for (const filePath of optionPaths) {
|
|
310
|
+
try {
|
|
311
|
+
const relative = path.relative(process.cwd(), filePath);
|
|
312
|
+
shortPaths.push(relative);
|
|
313
|
+
} catch (e) {
|
|
314
|
+
if (debug) {
|
|
315
|
+
_debug(`Failed to load ${filePath} ${e.message}`);
|
|
316
|
+
}
|
|
317
|
+
lastError = e;
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
_log(`injecting env (${keysCount}) from ${shortPaths.join(",")} ${dim(`-- tip: ${_getRandomTip()}`)}`);
|
|
321
|
+
}
|
|
322
|
+
if (lastError) {
|
|
323
|
+
return { parsed: parsedAll, error: lastError };
|
|
324
|
+
} else {
|
|
325
|
+
return { parsed: parsedAll };
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
function config(options) {
|
|
329
|
+
if (_dotenvKey(options).length === 0) {
|
|
330
|
+
return DotenvModule.configDotenv(options);
|
|
331
|
+
}
|
|
332
|
+
const vaultPath = _vaultPath(options);
|
|
333
|
+
if (!vaultPath) {
|
|
334
|
+
_warn(`You set DOTENV_KEY but you are missing a .env.vault file at ${vaultPath}. Did you forget to build it?`);
|
|
335
|
+
return DotenvModule.configDotenv(options);
|
|
336
|
+
}
|
|
337
|
+
return DotenvModule._configVault(options);
|
|
338
|
+
}
|
|
339
|
+
function decrypt(encrypted, keyStr) {
|
|
340
|
+
const key = Buffer.from(keyStr.slice(-64), "hex");
|
|
341
|
+
let ciphertext = Buffer.from(encrypted, "base64");
|
|
342
|
+
const nonce = ciphertext.subarray(0, 12);
|
|
343
|
+
const authTag = ciphertext.subarray(-16);
|
|
344
|
+
ciphertext = ciphertext.subarray(12, -16);
|
|
345
|
+
try {
|
|
346
|
+
const aesgcm = crypto.createDecipheriv("aes-256-gcm", key, nonce);
|
|
347
|
+
aesgcm.setAuthTag(authTag);
|
|
348
|
+
return `${aesgcm.update(ciphertext)}${aesgcm.final()}`;
|
|
349
|
+
} catch (error) {
|
|
350
|
+
const isRange = error instanceof RangeError;
|
|
351
|
+
const invalidKeyLength = error.message === "Invalid key length";
|
|
352
|
+
const decryptionFailed = error.message === "Unsupported state or unable to authenticate data";
|
|
353
|
+
if (isRange || invalidKeyLength) {
|
|
354
|
+
const err = new Error("INVALID_DOTENV_KEY: It must be 64 characters long (or more)");
|
|
355
|
+
err.code = "INVALID_DOTENV_KEY";
|
|
356
|
+
throw err;
|
|
357
|
+
} else if (decryptionFailed) {
|
|
358
|
+
const err = new Error("DECRYPTION_FAILED: Please check your DOTENV_KEY");
|
|
359
|
+
err.code = "DECRYPTION_FAILED";
|
|
360
|
+
throw err;
|
|
361
|
+
} else {
|
|
362
|
+
throw error;
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
function populate(processEnv, parsed, options = {}) {
|
|
367
|
+
const debug = Boolean(options && options.debug);
|
|
368
|
+
const override = Boolean(options && options.override);
|
|
369
|
+
const populated = {};
|
|
370
|
+
if (typeof parsed !== "object") {
|
|
371
|
+
const err = new Error("OBJECT_REQUIRED: Please check the processEnv argument being passed to populate");
|
|
372
|
+
err.code = "OBJECT_REQUIRED";
|
|
373
|
+
throw err;
|
|
374
|
+
}
|
|
375
|
+
for (const key of Object.keys(parsed)) {
|
|
376
|
+
if (Object.prototype.hasOwnProperty.call(processEnv, key)) {
|
|
377
|
+
if (override === true) {
|
|
378
|
+
processEnv[key] = parsed[key];
|
|
379
|
+
populated[key] = parsed[key];
|
|
380
|
+
}
|
|
381
|
+
if (debug) {
|
|
382
|
+
if (override === true) {
|
|
383
|
+
_debug(`"${key}" is already defined and WAS overwritten`);
|
|
384
|
+
} else {
|
|
385
|
+
_debug(`"${key}" is already defined and was NOT overwritten`);
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
} else {
|
|
389
|
+
processEnv[key] = parsed[key];
|
|
390
|
+
populated[key] = parsed[key];
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
return populated;
|
|
394
|
+
}
|
|
395
|
+
var DotenvModule = {
|
|
396
|
+
configDotenv,
|
|
397
|
+
_configVault,
|
|
398
|
+
_parseVault,
|
|
399
|
+
config,
|
|
400
|
+
decrypt,
|
|
401
|
+
parse,
|
|
402
|
+
populate
|
|
403
|
+
};
|
|
404
|
+
exports.configDotenv = DotenvModule.configDotenv;
|
|
405
|
+
exports._configVault = DotenvModule._configVault;
|
|
406
|
+
exports._parseVault = DotenvModule._parseVault;
|
|
407
|
+
exports.config = DotenvModule.config;
|
|
408
|
+
exports.decrypt = DotenvModule.decrypt;
|
|
409
|
+
exports.parse = DotenvModule.parse;
|
|
410
|
+
exports.populate = DotenvModule.populate;
|
|
411
|
+
module.exports = DotenvModule;
|
|
412
|
+
});
|
|
413
|
+
|
|
414
|
+
// src/commands/doctor/handler.ts
|
|
415
|
+
var import_dotenv = __toESM(require_main(), 1);
|
|
416
|
+
|
|
417
|
+
// src/commands/doctor/steps/ApiKeyDetectedStep.ts
|
|
418
|
+
class ApiKeyDetectedStep {
|
|
419
|
+
id = "api-key-detected";
|
|
420
|
+
name = "Checking API Key...";
|
|
421
|
+
async shouldRun(context) {
|
|
422
|
+
return context.authMode === "apiKey";
|
|
423
|
+
}
|
|
424
|
+
async run(context) {
|
|
425
|
+
const apiKey = context.apiKey;
|
|
426
|
+
if (!apiKey || apiKey.trim().length === 0) {
|
|
427
|
+
const message2 = "STITCH_API_KEY is set but empty";
|
|
428
|
+
context.checks.push({
|
|
429
|
+
name: "API Key",
|
|
430
|
+
passed: false,
|
|
431
|
+
message: message2,
|
|
432
|
+
suggestion: "Set a valid API key in STITCH_API_KEY environment variable or in your .env file"
|
|
433
|
+
});
|
|
434
|
+
return { success: false, error: new Error(message2) };
|
|
435
|
+
}
|
|
436
|
+
const masked = apiKey.length > 7 ? `${apiKey.slice(0, 4)}...${apiKey.slice(-3)}` : "***";
|
|
437
|
+
const message = `Detected (${masked})`;
|
|
438
|
+
context.checks.push({
|
|
439
|
+
name: "API Key",
|
|
440
|
+
passed: true,
|
|
441
|
+
message
|
|
442
|
+
});
|
|
443
|
+
return { success: true, detail: message };
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
// src/commands/doctor/steps/GcloudCheckStep.ts
|
|
448
|
+
class GcloudCheckStep {
|
|
449
|
+
id = "gcloud-check";
|
|
450
|
+
name = "Checking Google Cloud CLI...";
|
|
451
|
+
async shouldRun(context) {
|
|
452
|
+
return context.authMode === "oauth";
|
|
453
|
+
}
|
|
454
|
+
async run(context) {
|
|
455
|
+
const gcloudResult = await context.gcloudService.ensureInstalled({
|
|
456
|
+
minVersion: "400.0.0",
|
|
457
|
+
forceLocal: false
|
|
458
|
+
});
|
|
459
|
+
if (gcloudResult.success) {
|
|
460
|
+
const message = `Installed (${gcloudResult.data.location}): v${gcloudResult.data.version}
|
|
461
|
+
Path: ${gcloudResult.data.path}`;
|
|
462
|
+
context.checks.push({
|
|
463
|
+
name: "Google Cloud CLI",
|
|
464
|
+
passed: true,
|
|
465
|
+
message
|
|
466
|
+
});
|
|
467
|
+
return { success: true, detail: message };
|
|
468
|
+
} else {
|
|
469
|
+
const message = "Not found or invalid version";
|
|
470
|
+
context.checks.push({
|
|
471
|
+
name: "Google Cloud CLI",
|
|
472
|
+
passed: false,
|
|
473
|
+
message,
|
|
474
|
+
suggestion: "Run: npx @_davideast/stitch-mcp init"
|
|
475
|
+
});
|
|
476
|
+
return { success: false, error: new Error(message) };
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
// src/commands/doctor/steps/AuthCheckStep.ts
|
|
482
|
+
class AuthCheckStep {
|
|
483
|
+
id = "auth-check";
|
|
484
|
+
name = "Checking user authentication...";
|
|
485
|
+
async shouldRun(context) {
|
|
486
|
+
return context.authMode === "oauth";
|
|
487
|
+
}
|
|
488
|
+
async run(context) {
|
|
489
|
+
const authResult = await context.gcloudService.authenticate({ skipIfActive: true });
|
|
490
|
+
if (authResult.success) {
|
|
491
|
+
const message = `Authenticated: ${authResult.data.account}`;
|
|
492
|
+
context.checks.push({
|
|
493
|
+
name: "User Authentication",
|
|
494
|
+
passed: true,
|
|
495
|
+
message
|
|
496
|
+
});
|
|
497
|
+
return { success: true, detail: message };
|
|
498
|
+
} else {
|
|
499
|
+
const message = "Not authenticated";
|
|
500
|
+
context.checks.push({
|
|
501
|
+
name: "User Authentication",
|
|
502
|
+
passed: false,
|
|
503
|
+
message,
|
|
504
|
+
suggestion: "Run: gcloud auth login"
|
|
505
|
+
});
|
|
506
|
+
return { success: false, error: new Error(message) };
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
// src/commands/doctor/steps/AdcCheckStep.ts
|
|
512
|
+
class AdcCheckStep {
|
|
513
|
+
id = "adc-check";
|
|
514
|
+
name = "Checking application credentials...";
|
|
515
|
+
async shouldRun(context) {
|
|
516
|
+
return context.authMode === "oauth";
|
|
517
|
+
}
|
|
518
|
+
async run(context) {
|
|
519
|
+
const adcResult = await context.gcloudService.authenticateADC({ skipIfActive: true });
|
|
520
|
+
if (adcResult.success) {
|
|
521
|
+
const message = "Present";
|
|
522
|
+
context.checks.push({
|
|
523
|
+
name: "Application Credentials",
|
|
524
|
+
passed: true,
|
|
525
|
+
message
|
|
526
|
+
});
|
|
527
|
+
return { success: true, detail: message };
|
|
528
|
+
} else {
|
|
529
|
+
const message = "Not configured";
|
|
530
|
+
context.checks.push({
|
|
531
|
+
name: "Application Credentials",
|
|
532
|
+
passed: false,
|
|
533
|
+
message,
|
|
534
|
+
suggestion: "Run: gcloud auth application-default login"
|
|
535
|
+
});
|
|
536
|
+
return { success: false, error: new Error(message) };
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
// src/commands/doctor/steps/ProjectCheckStep.ts
|
|
542
|
+
class ProjectCheckStep {
|
|
543
|
+
id = "project-check";
|
|
544
|
+
name = "Checking active project...";
|
|
545
|
+
async shouldRun(context) {
|
|
546
|
+
return context.authMode === "oauth";
|
|
547
|
+
}
|
|
548
|
+
async run(context) {
|
|
549
|
+
const projectId = await context.gcloudService.getProjectId();
|
|
550
|
+
if (projectId) {
|
|
551
|
+
const message = `Set: ${projectId}`;
|
|
552
|
+
context.checks.push({
|
|
553
|
+
name: "Active Project",
|
|
554
|
+
passed: true,
|
|
555
|
+
message
|
|
556
|
+
});
|
|
557
|
+
return { success: true, detail: message };
|
|
558
|
+
} else {
|
|
559
|
+
const message = "No project configured";
|
|
560
|
+
context.checks.push({
|
|
561
|
+
name: "Active Project",
|
|
562
|
+
passed: false,
|
|
563
|
+
message,
|
|
564
|
+
suggestion: "Run: npx @_davideast/stitch-mcp init"
|
|
565
|
+
});
|
|
566
|
+
return { success: false, error: new Error(message) };
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
// src/commands/doctor/steps/ApiKeyConnectionStep.ts
|
|
572
|
+
class ApiKeyConnectionStep {
|
|
573
|
+
id = "api-key-connection";
|
|
574
|
+
name = "Testing Stitch API...";
|
|
575
|
+
async shouldRun(context) {
|
|
576
|
+
if (context.authMode !== "apiKey")
|
|
577
|
+
return false;
|
|
578
|
+
const apiKeyCheck = context.checks.find((c) => c.name === "API Key");
|
|
579
|
+
return !!apiKeyCheck && apiKeyCheck.passed;
|
|
580
|
+
}
|
|
581
|
+
async run(context) {
|
|
582
|
+
const testResult = await context.stitchService.testConnectionWithApiKey({
|
|
583
|
+
apiKey: context.apiKey
|
|
584
|
+
});
|
|
585
|
+
if (testResult.success) {
|
|
586
|
+
const message = `Healthy (${testResult.data.statusCode})`;
|
|
587
|
+
context.checks.push({
|
|
588
|
+
name: "Stitch API",
|
|
589
|
+
passed: true,
|
|
590
|
+
message
|
|
591
|
+
});
|
|
592
|
+
return { success: true, detail: message };
|
|
593
|
+
} else {
|
|
594
|
+
const message = testResult.error.message;
|
|
595
|
+
context.checks.push({
|
|
596
|
+
name: "Stitch API",
|
|
597
|
+
passed: false,
|
|
598
|
+
message,
|
|
599
|
+
suggestion: testResult.error.suggestion,
|
|
600
|
+
details: testResult.error.details
|
|
601
|
+
});
|
|
602
|
+
return { success: false, error: new Error(message) };
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
// src/commands/doctor/steps/ApiCheckStep.ts
|
|
608
|
+
class ApiCheckStep {
|
|
609
|
+
id = "api-check";
|
|
610
|
+
name = "Testing Stitch API...";
|
|
611
|
+
async shouldRun(context) {
|
|
612
|
+
if (context.authMode !== "oauth")
|
|
613
|
+
return false;
|
|
614
|
+
const projectCheck = context.checks.find((c) => c.name === "Active Project");
|
|
615
|
+
return !!projectCheck && projectCheck.passed;
|
|
616
|
+
}
|
|
617
|
+
async run(context) {
|
|
618
|
+
const projectId = await context.gcloudService.getProjectId();
|
|
619
|
+
const accessToken = await context.gcloudService.getAccessToken();
|
|
620
|
+
if (projectId && accessToken) {
|
|
621
|
+
const testResult = await context.stitchService.testConnection({
|
|
622
|
+
projectId,
|
|
623
|
+
accessToken
|
|
624
|
+
});
|
|
625
|
+
if (testResult.success) {
|
|
626
|
+
const message = `Healthy (${testResult.data.statusCode})`;
|
|
627
|
+
context.checks.push({
|
|
628
|
+
name: "Stitch API",
|
|
629
|
+
passed: true,
|
|
630
|
+
message
|
|
631
|
+
});
|
|
632
|
+
return { success: true, detail: message };
|
|
633
|
+
} else {
|
|
634
|
+
const message = testResult.error.message;
|
|
635
|
+
context.checks.push({
|
|
636
|
+
name: "Stitch API",
|
|
637
|
+
passed: false,
|
|
638
|
+
message,
|
|
639
|
+
suggestion: testResult.error.suggestion,
|
|
640
|
+
details: testResult.error.details
|
|
641
|
+
});
|
|
642
|
+
return { success: false, error: new Error(message) };
|
|
643
|
+
}
|
|
644
|
+
} else {
|
|
645
|
+
const message = "Could not obtain access token";
|
|
646
|
+
context.checks.push({
|
|
647
|
+
name: "Stitch API",
|
|
648
|
+
passed: false,
|
|
649
|
+
message,
|
|
650
|
+
suggestion: "Re-run authentication"
|
|
651
|
+
});
|
|
652
|
+
return { success: false, error: new Error(message) };
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
// src/commands/doctor/handler.ts
|
|
658
|
+
class DoctorHandler {
|
|
659
|
+
gcloudService;
|
|
660
|
+
stitchService;
|
|
661
|
+
steps;
|
|
662
|
+
ui;
|
|
663
|
+
constructor(gcloudService = new GcloudHandler, stitchService = new StitchHandler, ui) {
|
|
664
|
+
this.gcloudService = gcloudService;
|
|
665
|
+
this.stitchService = stitchService;
|
|
666
|
+
this.ui = ui || new ConsoleUI;
|
|
667
|
+
this.steps = [
|
|
668
|
+
new ApiKeyDetectedStep,
|
|
669
|
+
new GcloudCheckStep,
|
|
670
|
+
new AuthCheckStep,
|
|
671
|
+
new AdcCheckStep,
|
|
672
|
+
new ProjectCheckStep,
|
|
673
|
+
new ApiKeyConnectionStep,
|
|
674
|
+
new ApiCheckStep
|
|
675
|
+
];
|
|
676
|
+
}
|
|
677
|
+
async execute(input) {
|
|
678
|
+
import_dotenv.default.config({ quiet: true });
|
|
679
|
+
const apiKey = process.env.STITCH_API_KEY;
|
|
680
|
+
const context = {
|
|
681
|
+
input,
|
|
682
|
+
ui: this.ui,
|
|
683
|
+
gcloudService: this.gcloudService,
|
|
684
|
+
stitchService: this.stitchService,
|
|
685
|
+
authMode: apiKey ? "apiKey" : "oauth",
|
|
686
|
+
apiKey: apiKey || undefined,
|
|
687
|
+
checks: []
|
|
688
|
+
};
|
|
689
|
+
if (!input.json)
|
|
690
|
+
console.log(`
|
|
691
|
+
${theme.blue("Stitch Doctor")}
|
|
692
|
+
`);
|
|
693
|
+
try {
|
|
694
|
+
let spinner;
|
|
695
|
+
await runSteps(this.steps, context, {
|
|
696
|
+
onBeforeStep: (step) => {
|
|
697
|
+
if (input.json)
|
|
698
|
+
return;
|
|
699
|
+
spinner = createSpinner();
|
|
700
|
+
spinner.start(step.name);
|
|
701
|
+
},
|
|
702
|
+
onAfterStep: (_step, result2) => {
|
|
703
|
+
if (!input.json) {
|
|
704
|
+
if (result2.success) {
|
|
705
|
+
spinner.succeed(result2.detail || "Passed");
|
|
706
|
+
} else {
|
|
707
|
+
spinner.fail(result2.error?.message || "Failed");
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
return false;
|
|
711
|
+
}
|
|
712
|
+
});
|
|
713
|
+
const allPassed = context.checks.every((c) => c.passed);
|
|
714
|
+
const result = {
|
|
715
|
+
success: true,
|
|
716
|
+
data: { checks: context.checks, allPassed }
|
|
717
|
+
};
|
|
718
|
+
if (input.json) {
|
|
719
|
+
console.log(JSON.stringify(result, null, 2));
|
|
720
|
+
return result;
|
|
721
|
+
}
|
|
722
|
+
console.log(`
|
|
723
|
+
${theme.blue("─".repeat(60))}
|
|
724
|
+
`);
|
|
725
|
+
console.log(theme.blue(`Health Check Summary
|
|
726
|
+
`));
|
|
727
|
+
for (const check of context.checks) {
|
|
728
|
+
const icon = check.passed ? theme.green(icons.success) : theme.red(icons.error);
|
|
729
|
+
console.log(`${icon} ${check.name}: ${check.message}`);
|
|
730
|
+
if (check.suggestion && !check.passed) {
|
|
731
|
+
console.log(theme.gray(` → ${check.suggestion}`));
|
|
732
|
+
}
|
|
733
|
+
}
|
|
734
|
+
if (input.verbose) {
|
|
735
|
+
const failedChecksWithDetails = context.checks.filter((c) => !c.passed && c.details);
|
|
736
|
+
if (failedChecksWithDetails.length > 0) {
|
|
737
|
+
console.log(`
|
|
738
|
+
${theme.blue("Detailed Error Information")}
|
|
739
|
+
`);
|
|
740
|
+
for (const check of failedChecksWithDetails) {
|
|
741
|
+
console.log(theme.yellow(`${check.name}:`));
|
|
742
|
+
console.log(theme.gray(check.details.split(`
|
|
743
|
+
`).map((line) => ` ${line}`).join(`
|
|
744
|
+
`)));
|
|
745
|
+
console.log("");
|
|
746
|
+
}
|
|
747
|
+
}
|
|
748
|
+
}
|
|
749
|
+
console.log(`
|
|
750
|
+
${allPassed ? theme.green("All checks passed!") : theme.yellow("Some checks failed")}
|
|
751
|
+
`);
|
|
752
|
+
return result;
|
|
753
|
+
} catch (error) {
|
|
754
|
+
return {
|
|
755
|
+
success: false,
|
|
756
|
+
error: {
|
|
757
|
+
code: "UNKNOWN_ERROR",
|
|
758
|
+
message: error instanceof Error ? error.message : String(error),
|
|
759
|
+
recoverable: false
|
|
760
|
+
}
|
|
761
|
+
};
|
|
762
|
+
}
|
|
763
|
+
}
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
export { DoctorHandler };
|
|
767
|
+
|
|
768
|
+
//# debugId=955A67DE20DDEC2564756E2164756E21
|