@makerkit/cli 2.0.2 → 2.0.4
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 +1 -1
- package/dist/index.d.mts +1 -0
- package/dist/index.mjs +1333 -0
- package/dist/index.mjs.map +1 -0
- package/dist/mcp.mjs +1354 -0
- package/dist/mcp.mjs.map +1 -0
- package/package.json +14 -14
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1697
- package/dist/index.js.map +0 -1
- package/dist/mcp.js +0 -1541
- package/dist/mcp.js.map +0 -1
package/dist/mcp.mjs
ADDED
|
@@ -0,0 +1,1354 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import path, { dirname, join } from "path";
|
|
3
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
4
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
5
|
+
import { config } from "dotenv";
|
|
6
|
+
import { z } from "zod/v3";
|
|
7
|
+
import fs from "fs-extra";
|
|
8
|
+
import invariant from "tiny-invariant";
|
|
9
|
+
import { homedir, tmpdir } from "os";
|
|
10
|
+
import { execa, execaCommand } from "execa";
|
|
11
|
+
import "prompts";
|
|
12
|
+
//#region src/utils/plugins-cache.ts
|
|
13
|
+
const CACHE_DIR = join(homedir(), ".makerkit");
|
|
14
|
+
const CACHE_FILE = join(CACHE_DIR, "plugins.json");
|
|
15
|
+
const CACHE_TTL_MS = 3600 * 1e3;
|
|
16
|
+
async function readCache() {
|
|
17
|
+
try {
|
|
18
|
+
if (!await fs.pathExists(CACHE_FILE)) return null;
|
|
19
|
+
return await fs.readJson(CACHE_FILE);
|
|
20
|
+
} catch {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
async function writeCache(plugins) {
|
|
25
|
+
try {
|
|
26
|
+
await fs.ensureDir(CACHE_DIR);
|
|
27
|
+
await fs.writeJson(CACHE_FILE, {
|
|
28
|
+
fetchedAt: Date.now(),
|
|
29
|
+
plugins
|
|
30
|
+
}, { spaces: 2 });
|
|
31
|
+
} catch {}
|
|
32
|
+
}
|
|
33
|
+
async function fetchPluginRegistry(registryUrl, fallback) {
|
|
34
|
+
if (!registryUrl) return fallback;
|
|
35
|
+
const cached = await readCache();
|
|
36
|
+
if (cached && Date.now() - cached.fetchedAt < CACHE_TTL_MS) return cached.plugins;
|
|
37
|
+
try {
|
|
38
|
+
const response = await fetch(registryUrl);
|
|
39
|
+
if (response.ok) {
|
|
40
|
+
const plugins = (await response.json()).plugins;
|
|
41
|
+
await writeCache(plugins);
|
|
42
|
+
return plugins;
|
|
43
|
+
}
|
|
44
|
+
} catch {}
|
|
45
|
+
return cached?.plugins ?? fallback;
|
|
46
|
+
}
|
|
47
|
+
//#endregion
|
|
48
|
+
//#region src/plugins-model.ts
|
|
49
|
+
const DEFAULT_PLUGINS = {
|
|
50
|
+
feedback: {
|
|
51
|
+
name: "Feedback",
|
|
52
|
+
id: "feedback",
|
|
53
|
+
description: "Add a feedback popup to your site.",
|
|
54
|
+
postInstallMessage: "Run database migrations: pnpm db:migrate",
|
|
55
|
+
variants: { "next-supabase": {
|
|
56
|
+
envVars: [],
|
|
57
|
+
path: "packages/plugins/feedback"
|
|
58
|
+
} }
|
|
59
|
+
},
|
|
60
|
+
waitlist: {
|
|
61
|
+
name: "Waitlist",
|
|
62
|
+
id: "waitlist",
|
|
63
|
+
description: "Add a waitlist to your site.",
|
|
64
|
+
postInstallMessage: "Run database migrations: pnpm db:migrate",
|
|
65
|
+
variants: { "next-supabase": {
|
|
66
|
+
envVars: [],
|
|
67
|
+
path: "packages/plugins/waitlist"
|
|
68
|
+
} }
|
|
69
|
+
},
|
|
70
|
+
testimonial: {
|
|
71
|
+
name: "Testimonial",
|
|
72
|
+
id: "testimonial",
|
|
73
|
+
description: "Add a testimonial widget to your site.",
|
|
74
|
+
postInstallMessage: "Run database migrations: pnpm db:migrate",
|
|
75
|
+
variants: { "next-supabase": {
|
|
76
|
+
envVars: [],
|
|
77
|
+
path: "packages/plugins/testimonial"
|
|
78
|
+
} }
|
|
79
|
+
},
|
|
80
|
+
roadmap: {
|
|
81
|
+
name: "Roadmap",
|
|
82
|
+
id: "roadmap",
|
|
83
|
+
description: "Add a roadmap to your site.",
|
|
84
|
+
postInstallMessage: "Run database migrations: pnpm db:migrate",
|
|
85
|
+
variants: { "next-supabase": {
|
|
86
|
+
envVars: [],
|
|
87
|
+
path: "packages/plugins/roadmap"
|
|
88
|
+
} }
|
|
89
|
+
},
|
|
90
|
+
"google-analytics": {
|
|
91
|
+
name: "Google Analytics",
|
|
92
|
+
id: "google-analytics",
|
|
93
|
+
description: "Add Google Analytics to your site.",
|
|
94
|
+
variants: {
|
|
95
|
+
"next-supabase": {
|
|
96
|
+
envVars: [{
|
|
97
|
+
key: "NEXT_PUBLIC_GOOGLE_ANALYTICS_ID",
|
|
98
|
+
description: "Google Analytics Measurement ID"
|
|
99
|
+
}],
|
|
100
|
+
path: "packages/plugins/analytics/google-analytics"
|
|
101
|
+
},
|
|
102
|
+
"next-drizzle": {
|
|
103
|
+
envVars: [{
|
|
104
|
+
key: "NEXT_PUBLIC_GOOGLE_ANALYTICS_ID",
|
|
105
|
+
description: "Google Analytics Measurement ID"
|
|
106
|
+
}],
|
|
107
|
+
path: "packages/plugins/analytics/google-analytics"
|
|
108
|
+
},
|
|
109
|
+
"next-prisma": {
|
|
110
|
+
envVars: [{
|
|
111
|
+
key: "NEXT_PUBLIC_GOOGLE_ANALYTICS_ID",
|
|
112
|
+
description: "Google Analytics Measurement ID"
|
|
113
|
+
}],
|
|
114
|
+
path: "packages/plugins/analytics/google-analytics"
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
honeybadger: {
|
|
119
|
+
name: "Honeybadger",
|
|
120
|
+
id: "honeybadger",
|
|
121
|
+
description: "Add Honeybadger Error Tracking to your site.",
|
|
122
|
+
variants: {
|
|
123
|
+
"next-supabase": {
|
|
124
|
+
envVars: [
|
|
125
|
+
{
|
|
126
|
+
key: "HONEYBADGER_API_KEY",
|
|
127
|
+
description: "Honeybadger private API key"
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
key: "NEXT_PUBLIC_HONEYBADGER_ENVIRONMENT",
|
|
131
|
+
description: "Honeybadger environment"
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
key: "NEXT_PUBLIC_HONEYBADGER_REVISION",
|
|
135
|
+
description: "Honeybadger log revision"
|
|
136
|
+
}
|
|
137
|
+
],
|
|
138
|
+
path: "packages/plugins/honeybadger"
|
|
139
|
+
},
|
|
140
|
+
"next-drizzle": {
|
|
141
|
+
envVars: [
|
|
142
|
+
{
|
|
143
|
+
key: "HONEYBADGER_API_KEY",
|
|
144
|
+
description: "Honeybadger private API key"
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
key: "NEXT_PUBLIC_HONEYBADGER_ENVIRONMENT",
|
|
148
|
+
description: "Honeybadger environment"
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
key: "NEXT_PUBLIC_HONEYBADGER_REVISION",
|
|
152
|
+
description: "Honeybadger log revision"
|
|
153
|
+
}
|
|
154
|
+
],
|
|
155
|
+
path: "packages/plugins/honeybadger"
|
|
156
|
+
},
|
|
157
|
+
"next-prisma": { envVars: [
|
|
158
|
+
{
|
|
159
|
+
key: "HONEYBADGER_API_KEY",
|
|
160
|
+
description: "Honeybadger private API key"
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
key: "NEXT_PUBLIC_HONEYBADGER_ENVIRONMENT",
|
|
164
|
+
description: "Honeybadger environment"
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
key: "NEXT_PUBLIC_HONEYBADGER_REVISION",
|
|
168
|
+
description: "Honeybadger log revision"
|
|
169
|
+
}
|
|
170
|
+
] }
|
|
171
|
+
}
|
|
172
|
+
},
|
|
173
|
+
posthog: {
|
|
174
|
+
name: "PostHog",
|
|
175
|
+
id: "posthog",
|
|
176
|
+
description: "Add PostHog Analytics to your site.",
|
|
177
|
+
variants: {
|
|
178
|
+
"next-supabase": {
|
|
179
|
+
envVars: [{
|
|
180
|
+
key: "NEXT_PUBLIC_POSTHOG_KEY",
|
|
181
|
+
description: "PostHog project API key"
|
|
182
|
+
}, {
|
|
183
|
+
key: "NEXT_PUBLIC_POSTHOG_HOST",
|
|
184
|
+
description: "PostHog host URL",
|
|
185
|
+
defaultValue: "https://app.posthog.com"
|
|
186
|
+
}],
|
|
187
|
+
path: "packages/plugins/analytics/posthog"
|
|
188
|
+
},
|
|
189
|
+
"next-drizzle": {
|
|
190
|
+
envVars: [{
|
|
191
|
+
key: "NEXT_PUBLIC_POSTHOG_KEY",
|
|
192
|
+
description: "PostHog project API key"
|
|
193
|
+
}, {
|
|
194
|
+
key: "NEXT_PUBLIC_POSTHOG_HOST",
|
|
195
|
+
description: "PostHog host URL",
|
|
196
|
+
defaultValue: "https://app.posthog.com"
|
|
197
|
+
}],
|
|
198
|
+
path: "packages/plugins/analytics/posthog"
|
|
199
|
+
},
|
|
200
|
+
"next-prisma": {
|
|
201
|
+
envVars: [{
|
|
202
|
+
key: "NEXT_PUBLIC_POSTHOG_KEY",
|
|
203
|
+
description: "PostHog project API key"
|
|
204
|
+
}, {
|
|
205
|
+
key: "NEXT_PUBLIC_POSTHOG_HOST",
|
|
206
|
+
description: "PostHog host URL",
|
|
207
|
+
defaultValue: "https://app.posthog.com"
|
|
208
|
+
}],
|
|
209
|
+
path: "packages/plugins/analytics/posthog"
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
},
|
|
213
|
+
umami: {
|
|
214
|
+
name: "Umami",
|
|
215
|
+
id: "umami",
|
|
216
|
+
description: "Add Umami Analytics to your site.",
|
|
217
|
+
variants: {
|
|
218
|
+
"next-supabase": {
|
|
219
|
+
envVars: [{
|
|
220
|
+
key: "NEXT_PUBLIC_UMAMI_WEBSITE_ID",
|
|
221
|
+
description: "Umami website ID"
|
|
222
|
+
}, {
|
|
223
|
+
key: "NEXT_PUBLIC_UMAMI_HOST",
|
|
224
|
+
description: "Umami host URL"
|
|
225
|
+
}],
|
|
226
|
+
path: "packages/plugins/analytics/umami"
|
|
227
|
+
},
|
|
228
|
+
"next-drizzle": {
|
|
229
|
+
envVars: [{
|
|
230
|
+
key: "NEXT_PUBLIC_UMAMI_WEBSITE_ID",
|
|
231
|
+
description: "Umami website ID"
|
|
232
|
+
}, {
|
|
233
|
+
key: "NEXT_PUBLIC_UMAMI_HOST",
|
|
234
|
+
description: "Umami host URL"
|
|
235
|
+
}],
|
|
236
|
+
path: "packages/plugins/analytics/umami"
|
|
237
|
+
},
|
|
238
|
+
"next-prisma": {
|
|
239
|
+
envVars: [{
|
|
240
|
+
key: "NEXT_PUBLIC_UMAMI_WEBSITE_ID",
|
|
241
|
+
description: "Umami website ID"
|
|
242
|
+
}, {
|
|
243
|
+
key: "NEXT_PUBLIC_UMAMI_HOST",
|
|
244
|
+
description: "Umami host URL"
|
|
245
|
+
}],
|
|
246
|
+
path: "packages/plugins/analytics/umami"
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
},
|
|
250
|
+
signoz: {
|
|
251
|
+
name: "SigNoz",
|
|
252
|
+
id: "signoz",
|
|
253
|
+
description: "Add SigNoz Monitoring to your app.",
|
|
254
|
+
variants: {
|
|
255
|
+
"next-supabase": {
|
|
256
|
+
envVars: [{
|
|
257
|
+
key: "OTEL_EXPORTER_OTLP_ENDPOINT",
|
|
258
|
+
description: "SigNoz OTLP endpoint URL"
|
|
259
|
+
}],
|
|
260
|
+
path: "packages/plugins/signoz"
|
|
261
|
+
},
|
|
262
|
+
"next-drizzle": {
|
|
263
|
+
envVars: [{
|
|
264
|
+
key: "OTEL_EXPORTER_OTLP_ENDPOINT",
|
|
265
|
+
description: "SigNoz OTLP endpoint URL"
|
|
266
|
+
}],
|
|
267
|
+
path: "packages/plugins/signoz"
|
|
268
|
+
},
|
|
269
|
+
"next-prisma": {
|
|
270
|
+
envVars: [{
|
|
271
|
+
key: "OTEL_EXPORTER_OTLP_ENDPOINT",
|
|
272
|
+
description: "SigNoz OTLP endpoint URL"
|
|
273
|
+
}],
|
|
274
|
+
path: "packages/plugins/signoz"
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
},
|
|
278
|
+
paddle: {
|
|
279
|
+
name: "Paddle",
|
|
280
|
+
id: "paddle",
|
|
281
|
+
description: "Add Paddle Billing to your app.",
|
|
282
|
+
variants: { "next-supabase": {
|
|
283
|
+
envVars: [
|
|
284
|
+
{
|
|
285
|
+
key: "NEXT_PUBLIC_PADDLE_CLIENT_TOKEN",
|
|
286
|
+
description: "Paddle client-side token"
|
|
287
|
+
},
|
|
288
|
+
{
|
|
289
|
+
key: "PADDLE_API_KEY",
|
|
290
|
+
description: "Paddle API key"
|
|
291
|
+
},
|
|
292
|
+
{
|
|
293
|
+
key: "PADDLE_WEBHOOK_SECRET",
|
|
294
|
+
description: "Paddle webhook secret"
|
|
295
|
+
}
|
|
296
|
+
],
|
|
297
|
+
path: "packages/plugins/paddle"
|
|
298
|
+
} }
|
|
299
|
+
},
|
|
300
|
+
"supabase-cms": {
|
|
301
|
+
name: "Supabase CMS",
|
|
302
|
+
id: "supabase-cms",
|
|
303
|
+
description: "Add Supabase CMS provider to your app.",
|
|
304
|
+
postInstallMessage: "Run database migrations: pnpm db:migrate",
|
|
305
|
+
variants: { "next-supabase": {
|
|
306
|
+
envVars: [],
|
|
307
|
+
path: "packages/plugins/supabase-cms"
|
|
308
|
+
} }
|
|
309
|
+
},
|
|
310
|
+
"meshes-analytics": {
|
|
311
|
+
name: "Meshes Analytics",
|
|
312
|
+
id: "meshes-analytics",
|
|
313
|
+
description: "Add Meshes Analytics to your app.",
|
|
314
|
+
variants: { "next-supabase": {
|
|
315
|
+
envVars: [{
|
|
316
|
+
key: "NEXT_PUBLIC_MESHES_PUBLISHABLE_KEY",
|
|
317
|
+
description: "The Meshes publishable key"
|
|
318
|
+
}],
|
|
319
|
+
path: "packages/plugins/meshes-analytics"
|
|
320
|
+
} }
|
|
321
|
+
},
|
|
322
|
+
directus: {
|
|
323
|
+
name: "Directus CMS",
|
|
324
|
+
id: "directus",
|
|
325
|
+
description: "Add Directus as your CMS.",
|
|
326
|
+
variants: {
|
|
327
|
+
"next-supabase": {
|
|
328
|
+
envVars: [{
|
|
329
|
+
key: "NEXT_PUBLIC_DIRECTUS_URL",
|
|
330
|
+
description: "The Directus URL"
|
|
331
|
+
}, {
|
|
332
|
+
key: "DIRECTUS_ACCESS_TOKEN",
|
|
333
|
+
description: "The Directus access token"
|
|
334
|
+
}],
|
|
335
|
+
path: "packages/plugins/directus"
|
|
336
|
+
},
|
|
337
|
+
"next-drizzle": {
|
|
338
|
+
envVars: [{
|
|
339
|
+
key: "NEXT_PUBLIC_DIRECTUS_URL",
|
|
340
|
+
description: "The Directus URL"
|
|
341
|
+
}, {
|
|
342
|
+
key: "DIRECTUS_ACCESS_TOKEN",
|
|
343
|
+
description: "The Directus access token"
|
|
344
|
+
}],
|
|
345
|
+
path: "packages/plugins/directus"
|
|
346
|
+
},
|
|
347
|
+
"next-prisma": {
|
|
348
|
+
envVars: [{
|
|
349
|
+
key: "NEXT_PUBLIC_DIRECTUS_URL",
|
|
350
|
+
description: "The Directus URL"
|
|
351
|
+
}, {
|
|
352
|
+
key: "DIRECTUS_ACCESS_TOKEN",
|
|
353
|
+
description: "The Directus access token"
|
|
354
|
+
}],
|
|
355
|
+
path: "packages/plugins/directus"
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
};
|
|
360
|
+
var PluginRegistry = class PluginRegistry {
|
|
361
|
+
constructor(plugins) {
|
|
362
|
+
this.plugins = plugins;
|
|
363
|
+
}
|
|
364
|
+
static async load() {
|
|
365
|
+
const registryUrl = process.env.MAKERKIT_PLUGINS_REGISTRY_URL;
|
|
366
|
+
return new PluginRegistry(await fetchPluginRegistry(registryUrl, DEFAULT_PLUGINS));
|
|
367
|
+
}
|
|
368
|
+
getPluginById(id) {
|
|
369
|
+
return this.plugins[id];
|
|
370
|
+
}
|
|
371
|
+
getPluginsForVariant(variant) {
|
|
372
|
+
return Object.values(this.plugins).filter((p) => variant in p.variants);
|
|
373
|
+
}
|
|
374
|
+
validatePlugin(pluginId, variant) {
|
|
375
|
+
const plugin = this.getPluginById(pluginId);
|
|
376
|
+
invariant(plugin, `Plugin "${pluginId}" not found`);
|
|
377
|
+
invariant(plugin.variants[variant], `Plugin "${pluginId}" is not available for the ${variant} variant`);
|
|
378
|
+
return plugin;
|
|
379
|
+
}
|
|
380
|
+
};
|
|
381
|
+
function getEnvVars(plugin, variant) {
|
|
382
|
+
return plugin.variants[variant]?.envVars ?? [];
|
|
383
|
+
}
|
|
384
|
+
function getPath(plugin, variant) {
|
|
385
|
+
return plugin.variants[variant]?.path;
|
|
386
|
+
}
|
|
387
|
+
async function isInstalled(plugin, variant) {
|
|
388
|
+
const pluginPath = getPath(plugin, variant);
|
|
389
|
+
if (!pluginPath) return false;
|
|
390
|
+
const pkgJsonPath = join(process.cwd(), pluginPath, "package.json");
|
|
391
|
+
if (!await fs.pathExists(pkgJsonPath)) return false;
|
|
392
|
+
try {
|
|
393
|
+
const pkg = await fs.readJson(pkgJsonPath);
|
|
394
|
+
return !!pkg.name && !!pkg.exports;
|
|
395
|
+
} catch {
|
|
396
|
+
return false;
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
//#endregion
|
|
400
|
+
//#region src/utils/base-store.ts
|
|
401
|
+
function basesDir(pluginId) {
|
|
402
|
+
return join(process.cwd(), "node_modules", ".cache", "makerkit", "bases", pluginId);
|
|
403
|
+
}
|
|
404
|
+
async function saveBaseVersions(pluginId, files) {
|
|
405
|
+
const dir = basesDir(pluginId);
|
|
406
|
+
for (const file of files) {
|
|
407
|
+
const targetPath = join(dir, file.target);
|
|
408
|
+
await fs.ensureDir(dirname(targetPath));
|
|
409
|
+
await fs.writeFile(targetPath, file.content);
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
async function readBaseVersion(pluginId, fileTarget) {
|
|
413
|
+
const filePath = join(basesDir(pluginId), fileTarget);
|
|
414
|
+
try {
|
|
415
|
+
return await fs.readFile(filePath, "utf-8");
|
|
416
|
+
} catch {
|
|
417
|
+
return;
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
async function hasBaseVersions(pluginId) {
|
|
421
|
+
return fs.pathExists(basesDir(pluginId));
|
|
422
|
+
}
|
|
423
|
+
function computeFileStatus(params) {
|
|
424
|
+
const { base, local, remote } = params;
|
|
425
|
+
if (local !== void 0 && local === remote) return "unchanged";
|
|
426
|
+
if (base === void 0) {
|
|
427
|
+
if (local === void 0) return "added";
|
|
428
|
+
return "no_base";
|
|
429
|
+
}
|
|
430
|
+
if (local === void 0) return "deleted_locally";
|
|
431
|
+
if (base === local) return "updated";
|
|
432
|
+
if (base === remote) return "unchanged";
|
|
433
|
+
return "conflict";
|
|
434
|
+
}
|
|
435
|
+
//#endregion
|
|
436
|
+
//#region src/utils/git.ts
|
|
437
|
+
function getErrorOutput(error) {
|
|
438
|
+
if (error instanceof Error && "stderr" in error) {
|
|
439
|
+
const stderr = String(error.stderr);
|
|
440
|
+
if (stderr) return stderr;
|
|
441
|
+
}
|
|
442
|
+
if (error instanceof Error && "stdout" in error) {
|
|
443
|
+
const stdout = String(error.stdout);
|
|
444
|
+
if (stdout) return stdout;
|
|
445
|
+
}
|
|
446
|
+
return error instanceof Error ? error.message : String(error);
|
|
447
|
+
}
|
|
448
|
+
async function isGitClean() {
|
|
449
|
+
const { stdout } = await execaCommand("git status --porcelain");
|
|
450
|
+
return stdout.trim() === "";
|
|
451
|
+
}
|
|
452
|
+
//#endregion
|
|
453
|
+
//#region src/utils/install-registry-files.ts
|
|
454
|
+
async function fetchRegistryItem(variant, pluginId, username, majorVersion) {
|
|
455
|
+
const url = `https://makerkit.dev/r/${variant}${majorVersion != null ? `/v${majorVersion}` : ""}/${pluginId}.json?username=${username}`;
|
|
456
|
+
const response = await fetch(url);
|
|
457
|
+
if (!response.ok) throw new Error(`Failed to fetch plugin registry for "${pluginId}" (${response.status}): ${response.statusText}`);
|
|
458
|
+
const item = await response.json();
|
|
459
|
+
if (!item.files || item.files.length === 0) throw new Error(`Plugin "${pluginId}" has no files in the registry.`);
|
|
460
|
+
return item;
|
|
461
|
+
}
|
|
462
|
+
async function installRegistryFiles(variant, pluginId, username, majorVersion) {
|
|
463
|
+
const item = await fetchRegistryItem(variant, pluginId, username, majorVersion);
|
|
464
|
+
const cwd = process.cwd();
|
|
465
|
+
for (const file of item.files) {
|
|
466
|
+
const targetPath = join(cwd, file.target);
|
|
467
|
+
await fs.ensureDir(dirname(targetPath));
|
|
468
|
+
await fs.writeFile(targetPath, file.content);
|
|
469
|
+
}
|
|
470
|
+
return item;
|
|
471
|
+
}
|
|
472
|
+
//#endregion
|
|
473
|
+
//#region src/utils/run-codemod.ts
|
|
474
|
+
const CODEMOD_TIMEOUT_MS = 300 * 1e3;
|
|
475
|
+
async function runCodemod(variant, pluginId, codemodVersion, options) {
|
|
476
|
+
try {
|
|
477
|
+
const localPath = process.env.MAKERKIT_CODEMODS_PATH;
|
|
478
|
+
const runner = process.env.MAKERKIT_PACKAGE_RUNNER ?? "npx --yes";
|
|
479
|
+
const versionTag = codemodVersion ? `@${codemodVersion}` : "";
|
|
480
|
+
const { stdout, stderr } = await execaCommand(localPath ? `${runner} codemod workflow run --allow-dirty -w ${localPath}/codemods/${variant}/${pluginId}` : `${runner} codemod --allow-dirty @makerkit/${variant}-${pluginId}${versionTag}`, {
|
|
481
|
+
stdio: options?.captureOutput ? "pipe" : "inherit",
|
|
482
|
+
timeout: CODEMOD_TIMEOUT_MS
|
|
483
|
+
});
|
|
484
|
+
return {
|
|
485
|
+
success: true,
|
|
486
|
+
output: stdout || stderr || ""
|
|
487
|
+
};
|
|
488
|
+
} catch (error) {
|
|
489
|
+
let message = "Unknown error during codemod";
|
|
490
|
+
if (error instanceof Error) {
|
|
491
|
+
message = error.message;
|
|
492
|
+
if ("stderr" in error && error.stderr) message += `\n${error.stderr}`;
|
|
493
|
+
if ("timedOut" in error && error.timedOut) message = `Codemod timed out after ${CODEMOD_TIMEOUT_MS / 1e3}s (the workflow engine may have stalled after an error)`;
|
|
494
|
+
}
|
|
495
|
+
return {
|
|
496
|
+
success: false,
|
|
497
|
+
output: message
|
|
498
|
+
};
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
//#endregion
|
|
502
|
+
//#region src/utils/username-cache.ts
|
|
503
|
+
const USERNAME_FILE = join(tmpdir(), "makerkit-username");
|
|
504
|
+
function getCachedUsername() {
|
|
505
|
+
try {
|
|
506
|
+
const username = fs.readFileSync(USERNAME_FILE, "utf-8").trim();
|
|
507
|
+
return username.length > 0 ? username : void 0;
|
|
508
|
+
} catch {
|
|
509
|
+
return;
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
function cacheUsername(username) {
|
|
513
|
+
fs.writeFileSync(USERNAME_FILE, username, "utf-8");
|
|
514
|
+
}
|
|
515
|
+
//#endregion
|
|
516
|
+
//#region src/utils/workspace.ts
|
|
517
|
+
async function readDeps(pkgPath) {
|
|
518
|
+
if (!await fs.pathExists(pkgPath)) return {};
|
|
519
|
+
const pkg = await fs.readJson(pkgPath);
|
|
520
|
+
return {
|
|
521
|
+
...pkg.dependencies,
|
|
522
|
+
...pkg.devDependencies
|
|
523
|
+
};
|
|
524
|
+
}
|
|
525
|
+
async function detectVariant() {
|
|
526
|
+
const cwd = process.cwd();
|
|
527
|
+
const rootPkgPath = join(cwd, "package.json");
|
|
528
|
+
if (!await fs.pathExists(rootPkgPath)) throw new Error("No package.json found. Please run this command from a MakerKit project root.");
|
|
529
|
+
if (!(await readDeps(rootPkgPath))["turbo"]) throw new Error("This does not appear to be a MakerKit Turbo monorepo. The \"turbo\" dependency was not found in package.json.");
|
|
530
|
+
const webDeps = await readDeps(join(cwd, "apps", "web", "package.json"));
|
|
531
|
+
const dbDeps = await readDeps(join(cwd, "packages", "database", "package.json"));
|
|
532
|
+
const hasSupabase = !!webDeps["@supabase/supabase-js"];
|
|
533
|
+
const hasReactRouter = !!webDeps["@react-router/node"];
|
|
534
|
+
const hasDrizzle = !!webDeps["drizzle-orm"] || !!dbDeps["drizzle-orm"];
|
|
535
|
+
const hasPrisma = !!webDeps["@prisma/client"] || !!dbDeps["@prisma/client"];
|
|
536
|
+
if (hasReactRouter && hasSupabase) return "react-router-supabase";
|
|
537
|
+
if (hasSupabase) return "next-supabase";
|
|
538
|
+
if (hasDrizzle) return "next-drizzle";
|
|
539
|
+
if (hasPrisma) return "next-prisma";
|
|
540
|
+
throw new Error("Unrecognized MakerKit project. Could not detect variant from dependencies.");
|
|
541
|
+
}
|
|
542
|
+
async function validateProject() {
|
|
543
|
+
const variant = await detectVariant();
|
|
544
|
+
const version = (await fs.readJson(join(process.cwd(), "package.json"))).version ?? "unknown";
|
|
545
|
+
const major = parseInt(version.split(".")[0], 10);
|
|
546
|
+
return {
|
|
547
|
+
variant,
|
|
548
|
+
version,
|
|
549
|
+
majorVersion: isNaN(major) ? void 0 : major
|
|
550
|
+
};
|
|
551
|
+
}
|
|
552
|
+
//#endregion
|
|
553
|
+
//#region src/utils/add-plugin.ts
|
|
554
|
+
async function addPlugin(options) {
|
|
555
|
+
if (!options.skipGitCheck) {
|
|
556
|
+
if (!await isGitClean()) return {
|
|
557
|
+
success: false,
|
|
558
|
+
reason: "Git working directory has uncommitted changes. Please commit or stash them before adding a plugin."
|
|
559
|
+
};
|
|
560
|
+
}
|
|
561
|
+
const { variant, majorVersion } = await validateProject();
|
|
562
|
+
const username = options.githubUsername?.trim() || getCachedUsername();
|
|
563
|
+
if (!username) return {
|
|
564
|
+
success: false,
|
|
565
|
+
reason: "No GitHub username cached and none provided. Call makerkit_init_registry first or pass githubUsername."
|
|
566
|
+
};
|
|
567
|
+
cacheUsername(username);
|
|
568
|
+
const plugin = (await PluginRegistry.load()).validatePlugin(options.pluginId, variant);
|
|
569
|
+
if (await isInstalled(plugin, variant)) return {
|
|
570
|
+
success: false,
|
|
571
|
+
reason: `Plugin "${plugin.name}" is already installed.`
|
|
572
|
+
};
|
|
573
|
+
const item = await installRegistryFiles(variant, options.pluginId, username, majorVersion);
|
|
574
|
+
await saveBaseVersions(options.pluginId, item.files);
|
|
575
|
+
const codemodResult = await runCodemod(variant, options.pluginId, item.codemodVersion, { captureOutput: options.captureCodemodOutput ?? true });
|
|
576
|
+
const envVars = getEnvVars(plugin, variant);
|
|
577
|
+
return {
|
|
578
|
+
success: true,
|
|
579
|
+
pluginName: plugin.name,
|
|
580
|
+
pluginId: plugin.id,
|
|
581
|
+
variant,
|
|
582
|
+
envVars: envVars.map((e) => ({
|
|
583
|
+
key: e.key,
|
|
584
|
+
description: e.description
|
|
585
|
+
})),
|
|
586
|
+
postInstallMessage: plugin.postInstallMessage ?? null,
|
|
587
|
+
codemodOutput: codemodResult.output,
|
|
588
|
+
codemodWarning: codemodResult.success ? void 0 : `The automated codemod did not complete successfully. Plugin files were installed but some wiring steps may have failed.\n${codemodResult.output}`
|
|
589
|
+
};
|
|
590
|
+
}
|
|
591
|
+
//#endregion
|
|
592
|
+
//#region src/utils/apply-plugin-update.ts
|
|
593
|
+
async function applyPluginUpdate(options) {
|
|
594
|
+
const { variant, majorVersion } = await validateProject();
|
|
595
|
+
const username = options.githubUsername?.trim() || getCachedUsername();
|
|
596
|
+
if (!username) return {
|
|
597
|
+
success: false,
|
|
598
|
+
reason: "No GitHub username cached and none provided. Call makerkit_init_registry first or pass githubUsername."
|
|
599
|
+
};
|
|
600
|
+
cacheUsername(username);
|
|
601
|
+
(await PluginRegistry.load()).validatePlugin(options.pluginId, variant);
|
|
602
|
+
const item = await fetchRegistryItem(variant, options.pluginId, username, majorVersion);
|
|
603
|
+
const remoteByPath = new Map(item.files.map((f) => [f.target, f.content]));
|
|
604
|
+
const cwd = process.cwd();
|
|
605
|
+
const written = [];
|
|
606
|
+
const skipped = [];
|
|
607
|
+
const deleted = [];
|
|
608
|
+
for (const file of options.files) {
|
|
609
|
+
const targetPath = join(cwd, file.path);
|
|
610
|
+
switch (file.action) {
|
|
611
|
+
case "write":
|
|
612
|
+
if (file.content === void 0) return {
|
|
613
|
+
success: false,
|
|
614
|
+
reason: `File "${file.path}" has action "write" but no content provided.`
|
|
615
|
+
};
|
|
616
|
+
await fs.ensureDir(dirname(targetPath));
|
|
617
|
+
await fs.writeFile(targetPath, file.content);
|
|
618
|
+
written.push(file.path);
|
|
619
|
+
break;
|
|
620
|
+
case "skip":
|
|
621
|
+
skipped.push(file.path);
|
|
622
|
+
break;
|
|
623
|
+
case "delete":
|
|
624
|
+
if (await fs.pathExists(targetPath)) await fs.remove(targetPath);
|
|
625
|
+
deleted.push(file.path);
|
|
626
|
+
break;
|
|
627
|
+
}
|
|
628
|
+
if (file.action !== "delete") {
|
|
629
|
+
const remoteContent = remoteByPath.get(file.path);
|
|
630
|
+
if (remoteContent !== void 0) await saveBaseVersions(options.pluginId, [{
|
|
631
|
+
path: "",
|
|
632
|
+
content: remoteContent,
|
|
633
|
+
type: "",
|
|
634
|
+
target: file.path
|
|
635
|
+
}]);
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
return {
|
|
639
|
+
success: true,
|
|
640
|
+
pluginId: options.pluginId,
|
|
641
|
+
variant,
|
|
642
|
+
written,
|
|
643
|
+
skipped,
|
|
644
|
+
deleted
|
|
645
|
+
};
|
|
646
|
+
}
|
|
647
|
+
//#endregion
|
|
648
|
+
//#region src/utils/check-plugin-update.ts
|
|
649
|
+
async function checkPluginUpdate(options) {
|
|
650
|
+
const { variant, majorVersion } = await validateProject();
|
|
651
|
+
const username = options.githubUsername?.trim() || getCachedUsername();
|
|
652
|
+
if (!username) return {
|
|
653
|
+
success: false,
|
|
654
|
+
reason: "No GitHub username cached and none provided. Call makerkit_init_registry first or pass githubUsername."
|
|
655
|
+
};
|
|
656
|
+
cacheUsername(username);
|
|
657
|
+
(await PluginRegistry.load()).validatePlugin(options.pluginId, variant);
|
|
658
|
+
const item = await fetchRegistryItem(variant, options.pluginId, username, majorVersion);
|
|
659
|
+
const cwd = process.cwd();
|
|
660
|
+
const hasBase = await hasBaseVersions(options.pluginId);
|
|
661
|
+
const counts = {
|
|
662
|
+
unchanged: 0,
|
|
663
|
+
updated: 0,
|
|
664
|
+
conflict: 0,
|
|
665
|
+
added: 0,
|
|
666
|
+
deleted_locally: 0,
|
|
667
|
+
no_base: 0
|
|
668
|
+
};
|
|
669
|
+
const files = await Promise.all(item.files.map(async (file) => {
|
|
670
|
+
const localPath = join(cwd, file.target);
|
|
671
|
+
let local;
|
|
672
|
+
try {
|
|
673
|
+
local = await fs.readFile(localPath, "utf-8");
|
|
674
|
+
} catch {
|
|
675
|
+
local = void 0;
|
|
676
|
+
}
|
|
677
|
+
const base = await readBaseVersion(options.pluginId, file.target);
|
|
678
|
+
const remote = file.content;
|
|
679
|
+
const status = computeFileStatus({
|
|
680
|
+
base,
|
|
681
|
+
local,
|
|
682
|
+
remote
|
|
683
|
+
});
|
|
684
|
+
counts[status]++;
|
|
685
|
+
const result = {
|
|
686
|
+
path: file.target,
|
|
687
|
+
status
|
|
688
|
+
};
|
|
689
|
+
switch (status) {
|
|
690
|
+
case "unchanged": break;
|
|
691
|
+
case "updated":
|
|
692
|
+
result.remote = remote;
|
|
693
|
+
break;
|
|
694
|
+
case "conflict":
|
|
695
|
+
result.base = base;
|
|
696
|
+
result.local = local;
|
|
697
|
+
result.remote = remote;
|
|
698
|
+
break;
|
|
699
|
+
case "no_base":
|
|
700
|
+
result.local = local;
|
|
701
|
+
result.remote = remote;
|
|
702
|
+
break;
|
|
703
|
+
case "added":
|
|
704
|
+
result.remote = remote;
|
|
705
|
+
break;
|
|
706
|
+
case "deleted_locally":
|
|
707
|
+
result.base = base;
|
|
708
|
+
result.remote = remote;
|
|
709
|
+
break;
|
|
710
|
+
}
|
|
711
|
+
return result;
|
|
712
|
+
}));
|
|
713
|
+
return {
|
|
714
|
+
success: true,
|
|
715
|
+
pluginId: options.pluginId,
|
|
716
|
+
variant,
|
|
717
|
+
hasBaseVersions: hasBase,
|
|
718
|
+
counts,
|
|
719
|
+
files
|
|
720
|
+
};
|
|
721
|
+
}
|
|
722
|
+
//#endregion
|
|
723
|
+
//#region src/version.ts
|
|
724
|
+
const CLI_VERSION = "2.0.3";
|
|
725
|
+
//#endregion
|
|
726
|
+
//#region src/utils/marker-file.ts
|
|
727
|
+
async function writeMarkerFile(projectPath, variant, kitRepo) {
|
|
728
|
+
const dir = join(projectPath, ".makerkit");
|
|
729
|
+
await fs.ensureDir(dir);
|
|
730
|
+
const config = {
|
|
731
|
+
version: 1,
|
|
732
|
+
variant,
|
|
733
|
+
kit_repo: kitRepo,
|
|
734
|
+
created_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
735
|
+
cli_version: CLI_VERSION
|
|
736
|
+
};
|
|
737
|
+
await fs.writeJson(join(dir, "config.json"), config, { spaces: 2 });
|
|
738
|
+
}
|
|
739
|
+
//#endregion
|
|
740
|
+
//#region src/utils/upstream.ts
|
|
741
|
+
const VARIANT_REPO_MAP = {
|
|
742
|
+
"next-supabase": "makerkit/next-supabase-saas-kit-turbo",
|
|
743
|
+
"next-drizzle": "makerkit/next-drizzle-saas-kit-turbo",
|
|
744
|
+
"next-prisma": "makerkit/next-prisma-saas-kit-turbo",
|
|
745
|
+
"react-router-supabase": "makerkit/react-router-supabase-saas-kit-turbo"
|
|
746
|
+
};
|
|
747
|
+
function sshUrl(repo) {
|
|
748
|
+
return `git@github.com:${repo}`;
|
|
749
|
+
}
|
|
750
|
+
function httpsUrl(repo) {
|
|
751
|
+
return `https://github.com/${repo}`;
|
|
752
|
+
}
|
|
753
|
+
async function hasSshAccess() {
|
|
754
|
+
try {
|
|
755
|
+
await execaCommand("ssh -T git@github.com -o StrictHostKeyChecking=no", { timeout: 1e4 });
|
|
756
|
+
return true;
|
|
757
|
+
} catch (error) {
|
|
758
|
+
return (error instanceof Error && "stderr" in error ? String(error.stderr) : "").includes("successfully authenticated");
|
|
759
|
+
}
|
|
760
|
+
}
|
|
761
|
+
function getUpstreamUrl(variant, useSsh) {
|
|
762
|
+
const repo = VARIANT_REPO_MAP[variant];
|
|
763
|
+
return useSsh ? sshUrl(repo) : httpsUrl(repo);
|
|
764
|
+
}
|
|
765
|
+
/**
|
|
766
|
+
* Check if a remote URL points to the correct repo for the given variant,
|
|
767
|
+
* regardless of whether it uses SSH or HTTPS.
|
|
768
|
+
* Handles trailing `.git` and `/` in URLs.
|
|
769
|
+
*/
|
|
770
|
+
function isUpstreamUrlValid(url, variant) {
|
|
771
|
+
const normalized = url.replace(/\/+$/, "").replace(/\.git$/, "");
|
|
772
|
+
const repo = VARIANT_REPO_MAP[variant];
|
|
773
|
+
return normalized === sshUrl(repo) || normalized === httpsUrl(repo);
|
|
774
|
+
}
|
|
775
|
+
async function getUpstreamRemoteUrl() {
|
|
776
|
+
try {
|
|
777
|
+
const { stdout } = await execaCommand("git remote get-url upstream");
|
|
778
|
+
return stdout.trim() || void 0;
|
|
779
|
+
} catch {
|
|
780
|
+
return;
|
|
781
|
+
}
|
|
782
|
+
}
|
|
783
|
+
async function setUpstreamRemote(url) {
|
|
784
|
+
if (await getUpstreamRemoteUrl()) await execaCommand(`git remote set-url upstream ${url}`);
|
|
785
|
+
else await execaCommand(`git remote add upstream ${url}`);
|
|
786
|
+
}
|
|
787
|
+
//#endregion
|
|
788
|
+
//#region src/utils/create-project.ts
|
|
789
|
+
async function createProject(options) {
|
|
790
|
+
const { variant, name, directory, githubToken } = options;
|
|
791
|
+
const projectPath = join(directory, name);
|
|
792
|
+
const repo = VARIANT_REPO_MAP[variant];
|
|
793
|
+
if (await fs.pathExists(projectPath)) throw new Error(`Target directory "${projectPath}" already exists. Choose a different name or remove it first.`);
|
|
794
|
+
if (!await fs.pathExists(directory)) throw new Error(`Parent directory "${directory}" does not exist.`);
|
|
795
|
+
let cloneUrl;
|
|
796
|
+
if (githubToken) cloneUrl = `https://${githubToken}@github.com/${repo}`;
|
|
797
|
+
else cloneUrl = await hasSshAccess() ? `git@github.com:${repo}` : `https://github.com/${repo}`;
|
|
798
|
+
await execa("git", [
|
|
799
|
+
"clone",
|
|
800
|
+
cloneUrl,
|
|
801
|
+
name
|
|
802
|
+
], { cwd: directory });
|
|
803
|
+
if (githubToken) await execa("git", [
|
|
804
|
+
"remote",
|
|
805
|
+
"set-url",
|
|
806
|
+
"origin",
|
|
807
|
+
`https://github.com/${repo}`
|
|
808
|
+
], { cwd: projectPath });
|
|
809
|
+
await execa("pnpm", ["install"], { cwd: projectPath });
|
|
810
|
+
await writeMarkerFile(projectPath, variant, repo);
|
|
811
|
+
return {
|
|
812
|
+
success: true,
|
|
813
|
+
projectPath,
|
|
814
|
+
variant,
|
|
815
|
+
kitRepo: repo,
|
|
816
|
+
message: `Project "${name}" created successfully with variant "${variant}".`
|
|
817
|
+
};
|
|
818
|
+
}
|
|
819
|
+
//#endregion
|
|
820
|
+
//#region src/utils/get-project-status.ts
|
|
821
|
+
async function getProjectStatus(options) {
|
|
822
|
+
const { variant, version } = await validateProject();
|
|
823
|
+
const gitClean = await isGitClean();
|
|
824
|
+
const registryConfigured = !!getCachedUsername();
|
|
825
|
+
const plugins = (await PluginRegistry.load()).getPluginsForVariant(variant);
|
|
826
|
+
return {
|
|
827
|
+
variant,
|
|
828
|
+
version,
|
|
829
|
+
gitClean,
|
|
830
|
+
registryConfigured,
|
|
831
|
+
plugins: await Promise.all(plugins.map(async (p) => ({
|
|
832
|
+
id: p.id,
|
|
833
|
+
name: p.name,
|
|
834
|
+
installed: await isInstalled(p, variant)
|
|
835
|
+
})))
|
|
836
|
+
};
|
|
837
|
+
}
|
|
838
|
+
//#endregion
|
|
839
|
+
//#region src/utils/init-registry.ts
|
|
840
|
+
async function initRegistry(options) {
|
|
841
|
+
const variant = await detectVariant();
|
|
842
|
+
cacheUsername(options.githubUsername);
|
|
843
|
+
return {
|
|
844
|
+
success: true,
|
|
845
|
+
variant,
|
|
846
|
+
username: options.githubUsername
|
|
847
|
+
};
|
|
848
|
+
}
|
|
849
|
+
//#endregion
|
|
850
|
+
//#region src/utils/list-plugins.ts
|
|
851
|
+
async function listPlugins(options) {
|
|
852
|
+
const variant = await detectVariant();
|
|
853
|
+
const plugins = (await PluginRegistry.load()).getPluginsForVariant(variant);
|
|
854
|
+
return {
|
|
855
|
+
variant,
|
|
856
|
+
plugins: await Promise.all(plugins.map(async (p) => ({
|
|
857
|
+
id: p.id,
|
|
858
|
+
name: p.name,
|
|
859
|
+
description: p.description,
|
|
860
|
+
installed: await isInstalled(p, variant),
|
|
861
|
+
envVars: getEnvVars(p, variant).map((e) => e.key),
|
|
862
|
+
postInstallMessage: p.postInstallMessage ?? null
|
|
863
|
+
})))
|
|
864
|
+
};
|
|
865
|
+
}
|
|
866
|
+
//#endregion
|
|
867
|
+
//#region src/utils/outdated-plugins.ts
|
|
868
|
+
async function isOutdated(plugin, variant, username, majorVersion) {
|
|
869
|
+
const item = await fetchRegistryItem(variant, plugin.id, username, majorVersion);
|
|
870
|
+
const cwd = process.cwd();
|
|
871
|
+
for (const file of item.files) {
|
|
872
|
+
const localPath = join(cwd, file.target);
|
|
873
|
+
if (!await fs.pathExists(localPath)) return true;
|
|
874
|
+
if (await fs.readFile(localPath, "utf-8") !== file.content) return true;
|
|
875
|
+
}
|
|
876
|
+
return false;
|
|
877
|
+
}
|
|
878
|
+
async function outdatedPlugins(options) {
|
|
879
|
+
const { variant, majorVersion } = await validateProject();
|
|
880
|
+
const username = options.githubUsername?.trim() || getCachedUsername();
|
|
881
|
+
if (!username) return {
|
|
882
|
+
success: false,
|
|
883
|
+
reason: "No GitHub username cached and none provided. Call makerkit_init_registry first or pass githubUsername."
|
|
884
|
+
};
|
|
885
|
+
cacheUsername(username);
|
|
886
|
+
const plugins = (await PluginRegistry.load()).getPluginsForVariant(variant);
|
|
887
|
+
const installed = [];
|
|
888
|
+
for (const p of plugins) if (await isInstalled(p, variant)) installed.push(p);
|
|
889
|
+
if (installed.length === 0) return {
|
|
890
|
+
success: true,
|
|
891
|
+
variant,
|
|
892
|
+
outdated: []
|
|
893
|
+
};
|
|
894
|
+
const outdated = [];
|
|
895
|
+
for (const plugin of installed) try {
|
|
896
|
+
if (await isOutdated(plugin, variant, username, majorVersion)) outdated.push({
|
|
897
|
+
id: plugin.id,
|
|
898
|
+
name: plugin.name,
|
|
899
|
+
path: getPath(plugin, variant)
|
|
900
|
+
});
|
|
901
|
+
} catch {}
|
|
902
|
+
return {
|
|
903
|
+
success: true,
|
|
904
|
+
variant,
|
|
905
|
+
outdated
|
|
906
|
+
};
|
|
907
|
+
}
|
|
908
|
+
//#endregion
|
|
909
|
+
//#region src/utils/list-variants.ts
|
|
910
|
+
const VARIANT_CATALOG = [
|
|
911
|
+
{
|
|
912
|
+
id: "next-supabase",
|
|
913
|
+
name: "Next.js + Supabase",
|
|
914
|
+
description: "Full-stack SaaS kit with Next.js App Router and Supabase",
|
|
915
|
+
repo: VARIANT_REPO_MAP["next-supabase"],
|
|
916
|
+
tech: [
|
|
917
|
+
"Next.js",
|
|
918
|
+
"Supabase",
|
|
919
|
+
"Tailwind CSS",
|
|
920
|
+
"shadcn/ui"
|
|
921
|
+
],
|
|
922
|
+
database: "PostgreSQL (Supabase)",
|
|
923
|
+
auth: "Supabase Auth",
|
|
924
|
+
status: "stable"
|
|
925
|
+
},
|
|
926
|
+
{
|
|
927
|
+
id: "next-drizzle",
|
|
928
|
+
name: "Next.js + Drizzle",
|
|
929
|
+
description: "Full-stack SaaS kit with Next.js and Drizzle ORM",
|
|
930
|
+
repo: VARIANT_REPO_MAP["next-drizzle"],
|
|
931
|
+
tech: [
|
|
932
|
+
"Next.js",
|
|
933
|
+
"Drizzle",
|
|
934
|
+
"Tailwind CSS",
|
|
935
|
+
"shadcn/ui"
|
|
936
|
+
],
|
|
937
|
+
database: "PostgreSQL",
|
|
938
|
+
auth: "Better Auth",
|
|
939
|
+
status: "stable"
|
|
940
|
+
},
|
|
941
|
+
{
|
|
942
|
+
id: "next-prisma",
|
|
943
|
+
name: "Next.js + Prisma",
|
|
944
|
+
description: "Full-stack SaaS kit with Next.js and Prisma ORM",
|
|
945
|
+
repo: VARIANT_REPO_MAP["next-prisma"],
|
|
946
|
+
tech: [
|
|
947
|
+
"Next.js",
|
|
948
|
+
"Prisma",
|
|
949
|
+
"Tailwind CSS",
|
|
950
|
+
"shadcn/ui"
|
|
951
|
+
],
|
|
952
|
+
database: "PostgreSQL",
|
|
953
|
+
auth: "Better Auth",
|
|
954
|
+
status: "stable"
|
|
955
|
+
},
|
|
956
|
+
{
|
|
957
|
+
id: "react-router-supabase",
|
|
958
|
+
name: "React Router + Supabase",
|
|
959
|
+
description: "Full-stack SaaS kit with React Router and Supabase",
|
|
960
|
+
repo: VARIANT_REPO_MAP["react-router-supabase"],
|
|
961
|
+
tech: [
|
|
962
|
+
"React Router",
|
|
963
|
+
"Supabase",
|
|
964
|
+
"Tailwind CSS",
|
|
965
|
+
"shadcn/ui"
|
|
966
|
+
],
|
|
967
|
+
database: "PostgreSQL (Supabase)",
|
|
968
|
+
auth: "Supabase Auth",
|
|
969
|
+
status: "stable"
|
|
970
|
+
}
|
|
971
|
+
];
|
|
972
|
+
function listVariants() {
|
|
973
|
+
return { variants: VARIANT_CATALOG };
|
|
974
|
+
}
|
|
975
|
+
//#endregion
|
|
976
|
+
//#region src/utils/project-pull.ts
|
|
977
|
+
async function projectPull(options) {
|
|
978
|
+
const { variant } = await validateProject();
|
|
979
|
+
if (!await isGitClean()) return {
|
|
980
|
+
success: false,
|
|
981
|
+
reason: "Git working directory has uncommitted changes. Please commit or stash them before pulling upstream updates."
|
|
982
|
+
};
|
|
983
|
+
let currentUrl = await getUpstreamRemoteUrl();
|
|
984
|
+
if (!currentUrl) {
|
|
985
|
+
const url = getUpstreamUrl(variant, await hasSshAccess());
|
|
986
|
+
await setUpstreamRemote(url);
|
|
987
|
+
currentUrl = url;
|
|
988
|
+
} else if (!isUpstreamUrlValid(currentUrl, variant)) {
|
|
989
|
+
const expectedUrl = getUpstreamUrl(variant, currentUrl.startsWith("git@"));
|
|
990
|
+
return {
|
|
991
|
+
success: false,
|
|
992
|
+
reason: `Upstream remote points to "${currentUrl}" but expected "${expectedUrl}" for variant "${variant}". Please ask the user whether to update the upstream URL, then run: git remote set-url upstream <correct-url>`
|
|
993
|
+
};
|
|
994
|
+
}
|
|
995
|
+
await execaCommand("git fetch upstream");
|
|
996
|
+
try {
|
|
997
|
+
const { stdout } = await execaCommand("git merge upstream/main --no-edit");
|
|
998
|
+
const alreadyUpToDate = stdout.includes("Already up to date");
|
|
999
|
+
return {
|
|
1000
|
+
success: true,
|
|
1001
|
+
variant,
|
|
1002
|
+
upstreamUrl: currentUrl,
|
|
1003
|
+
alreadyUpToDate,
|
|
1004
|
+
message: alreadyUpToDate ? "Already up to date." : "Successfully merged upstream changes."
|
|
1005
|
+
};
|
|
1006
|
+
} catch (mergeError) {
|
|
1007
|
+
const output = getErrorOutput(mergeError);
|
|
1008
|
+
if (!(output.includes("CONFLICT") || output.includes("Automatic merge failed"))) throw new Error(`Merge failed: ${output}`);
|
|
1009
|
+
const { stdout: statusOutput } = await execaCommand("git diff --name-only --diff-filter=U");
|
|
1010
|
+
const conflictPaths = statusOutput.trim().split("\n").filter(Boolean);
|
|
1011
|
+
const cwd = process.cwd();
|
|
1012
|
+
const conflicts = await Promise.all(conflictPaths.map(async (filePath) => {
|
|
1013
|
+
let conflicted;
|
|
1014
|
+
try {
|
|
1015
|
+
conflicted = await fs.readFile(join(cwd, filePath), "utf-8");
|
|
1016
|
+
} catch {
|
|
1017
|
+
conflicted = void 0;
|
|
1018
|
+
}
|
|
1019
|
+
let base;
|
|
1020
|
+
let ours;
|
|
1021
|
+
let theirs;
|
|
1022
|
+
try {
|
|
1023
|
+
const { stdout: b } = await execa("git", ["show", `:1:${filePath}`]);
|
|
1024
|
+
base = b;
|
|
1025
|
+
} catch {
|
|
1026
|
+
base = void 0;
|
|
1027
|
+
}
|
|
1028
|
+
try {
|
|
1029
|
+
const { stdout: o } = await execa("git", ["show", `:2:${filePath}`]);
|
|
1030
|
+
ours = o;
|
|
1031
|
+
} catch {
|
|
1032
|
+
ours = void 0;
|
|
1033
|
+
}
|
|
1034
|
+
try {
|
|
1035
|
+
const { stdout: t } = await execa("git", ["show", `:3:${filePath}`]);
|
|
1036
|
+
theirs = t;
|
|
1037
|
+
} catch {
|
|
1038
|
+
theirs = void 0;
|
|
1039
|
+
}
|
|
1040
|
+
return {
|
|
1041
|
+
path: filePath,
|
|
1042
|
+
conflicted,
|
|
1043
|
+
base,
|
|
1044
|
+
ours,
|
|
1045
|
+
theirs
|
|
1046
|
+
};
|
|
1047
|
+
}));
|
|
1048
|
+
return {
|
|
1049
|
+
success: false,
|
|
1050
|
+
variant,
|
|
1051
|
+
upstreamUrl: currentUrl,
|
|
1052
|
+
hasConflicts: true,
|
|
1053
|
+
conflictCount: conflicts.length,
|
|
1054
|
+
conflicts,
|
|
1055
|
+
instructions: "Merge conflicts detected. For each conflict: review base, ours (local), and theirs (upstream) versions. Produce resolved content and call makerkit_project_resolve_conflicts. Ask the user for guidance when the intent behind local changes is unclear."
|
|
1056
|
+
};
|
|
1057
|
+
}
|
|
1058
|
+
}
|
|
1059
|
+
//#endregion
|
|
1060
|
+
//#region src/utils/resolve-conflicts.ts
|
|
1061
|
+
async function resolveConflicts(options) {
|
|
1062
|
+
const cwd = process.cwd();
|
|
1063
|
+
for (const file of options.files) {
|
|
1064
|
+
const targetPath = join(cwd, file.path);
|
|
1065
|
+
await fs.ensureDir(dirname(targetPath));
|
|
1066
|
+
await fs.writeFile(targetPath, file.content);
|
|
1067
|
+
}
|
|
1068
|
+
const paths = options.files.map((f) => f.path);
|
|
1069
|
+
await execa("git", ["add", ...paths]);
|
|
1070
|
+
let remainingConflicts = [];
|
|
1071
|
+
try {
|
|
1072
|
+
const { stdout } = await execaCommand("git diff --name-only --diff-filter=U");
|
|
1073
|
+
remainingConflicts = stdout.trim().split("\n").filter(Boolean);
|
|
1074
|
+
} catch {
|
|
1075
|
+
remainingConflicts = [];
|
|
1076
|
+
}
|
|
1077
|
+
if (remainingConflicts.length > 0) return {
|
|
1078
|
+
success: false,
|
|
1079
|
+
resolved: paths,
|
|
1080
|
+
remaining: remainingConflicts,
|
|
1081
|
+
message: `${paths.length} file(s) resolved, but ${remainingConflicts.length} conflict(s) remain. Resolve the remaining files and call makerkit_project_resolve_conflicts again.`
|
|
1082
|
+
};
|
|
1083
|
+
if (options.commitMessage) await execa("git", [
|
|
1084
|
+
"commit",
|
|
1085
|
+
"-m",
|
|
1086
|
+
options.commitMessage
|
|
1087
|
+
]);
|
|
1088
|
+
else await execaCommand("git commit --no-edit");
|
|
1089
|
+
return {
|
|
1090
|
+
success: true,
|
|
1091
|
+
resolved: paths,
|
|
1092
|
+
message: "All conflicts resolved and merge commit created."
|
|
1093
|
+
};
|
|
1094
|
+
}
|
|
1095
|
+
//#endregion
|
|
1096
|
+
//#region src/utils/with-project-dir.ts
|
|
1097
|
+
async function withProjectDir(projectPath, fn) {
|
|
1098
|
+
const original = process.cwd();
|
|
1099
|
+
try {
|
|
1100
|
+
process.chdir(projectPath);
|
|
1101
|
+
return await fn();
|
|
1102
|
+
} finally {
|
|
1103
|
+
process.chdir(original);
|
|
1104
|
+
}
|
|
1105
|
+
}
|
|
1106
|
+
//#endregion
|
|
1107
|
+
//#region src/mcp.ts
|
|
1108
|
+
config({
|
|
1109
|
+
path: ".env.local",
|
|
1110
|
+
quiet: true
|
|
1111
|
+
});
|
|
1112
|
+
function textContent(text) {
|
|
1113
|
+
return { content: [{
|
|
1114
|
+
type: "text",
|
|
1115
|
+
text
|
|
1116
|
+
}] };
|
|
1117
|
+
}
|
|
1118
|
+
function errorContent(message) {
|
|
1119
|
+
return {
|
|
1120
|
+
content: [{
|
|
1121
|
+
type: "text",
|
|
1122
|
+
text: message
|
|
1123
|
+
}],
|
|
1124
|
+
isError: true
|
|
1125
|
+
};
|
|
1126
|
+
}
|
|
1127
|
+
const server = new McpServer({
|
|
1128
|
+
name: "makerkit-cli",
|
|
1129
|
+
version: CLI_VERSION
|
|
1130
|
+
});
|
|
1131
|
+
server.registerTool("makerkit_status", {
|
|
1132
|
+
description: "Project introspection: detect variant, git status, registry config, and plugin install status",
|
|
1133
|
+
inputSchema: { projectPath: z.string().describe("Absolute path to the MakerKit project root") }
|
|
1134
|
+
}, async ({ projectPath }) => {
|
|
1135
|
+
try {
|
|
1136
|
+
const result = await withProjectDir(projectPath, () => getProjectStatus({ projectPath }));
|
|
1137
|
+
return textContent(JSON.stringify(result, null, 2));
|
|
1138
|
+
} catch (error) {
|
|
1139
|
+
return errorContent(error instanceof Error ? error.message : "Unknown error");
|
|
1140
|
+
}
|
|
1141
|
+
});
|
|
1142
|
+
server.registerTool("makerkit_list_variants", {
|
|
1143
|
+
description: "List available MakerKit kit variants with metadata for the project creation wizard",
|
|
1144
|
+
inputSchema: {}
|
|
1145
|
+
}, async () => {
|
|
1146
|
+
try {
|
|
1147
|
+
return textContent(JSON.stringify(listVariants(), null, 2));
|
|
1148
|
+
} catch (error) {
|
|
1149
|
+
return errorContent(error instanceof Error ? error.message : "Unknown error");
|
|
1150
|
+
}
|
|
1151
|
+
});
|
|
1152
|
+
server.registerTool("makerkit_create_project", {
|
|
1153
|
+
description: "Create a new MakerKit project: clones the selected kit variant, installs dependencies, and writes a .makerkit/config.json marker file.",
|
|
1154
|
+
inputSchema: {
|
|
1155
|
+
variant: z.enum(VARIANT_CATALOG.map((v) => v.id)).describe("Kit variant to create"),
|
|
1156
|
+
name: z.string().min(1).describe("Project directory name"),
|
|
1157
|
+
directory: z.string().describe("Absolute path to the parent directory where the project will be created"),
|
|
1158
|
+
github_token: z.string().optional().describe("Optional GitHub PAT for HTTPS cloning (token is stripped from remote after clone)")
|
|
1159
|
+
}
|
|
1160
|
+
}, async ({ variant, name, directory, github_token }) => {
|
|
1161
|
+
try {
|
|
1162
|
+
if (!path.isAbsolute(directory)) return errorContent(`"directory" must be an absolute path. Received: "${directory}"`);
|
|
1163
|
+
const result = await createProject({
|
|
1164
|
+
variant,
|
|
1165
|
+
name,
|
|
1166
|
+
directory,
|
|
1167
|
+
githubToken: github_token
|
|
1168
|
+
});
|
|
1169
|
+
return textContent(JSON.stringify({
|
|
1170
|
+
success: result.success,
|
|
1171
|
+
project_path: result.projectPath,
|
|
1172
|
+
variant: result.variant,
|
|
1173
|
+
message: result.message
|
|
1174
|
+
}, null, 2));
|
|
1175
|
+
} catch (error) {
|
|
1176
|
+
return errorContent(error instanceof Error ? error.message : "Unknown error");
|
|
1177
|
+
}
|
|
1178
|
+
});
|
|
1179
|
+
server.registerTool("makerkit_list_plugins", {
|
|
1180
|
+
description: "List all available plugins for the detected project variant with install status and metadata",
|
|
1181
|
+
inputSchema: { projectPath: z.string().describe("Absolute path to the MakerKit project root") }
|
|
1182
|
+
}, async ({ projectPath }) => {
|
|
1183
|
+
try {
|
|
1184
|
+
const result = await withProjectDir(projectPath, () => listPlugins({ projectPath }));
|
|
1185
|
+
return textContent(JSON.stringify(result, null, 2));
|
|
1186
|
+
} catch (error) {
|
|
1187
|
+
return errorContent(error instanceof Error ? error.message : "Unknown error");
|
|
1188
|
+
}
|
|
1189
|
+
});
|
|
1190
|
+
server.registerTool("makerkit_add_plugin", {
|
|
1191
|
+
description: "Install a MakerKit plugin: runs codemod, adds env vars, and returns structured result",
|
|
1192
|
+
inputSchema: {
|
|
1193
|
+
projectPath: z.string().describe("Absolute path to the MakerKit project root"),
|
|
1194
|
+
pluginId: z.string().describe("Plugin identifier (e.g. feedback, waitlist, posthog)"),
|
|
1195
|
+
githubUsername: z.string().optional().describe("GitHub username for registry auth (skips interactive prompt)"),
|
|
1196
|
+
skipGitCheck: z.boolean().optional().describe("Skip git clean check (useful when installing multiple plugins in sequence)")
|
|
1197
|
+
}
|
|
1198
|
+
}, async ({ projectPath, pluginId, githubUsername, skipGitCheck }) => {
|
|
1199
|
+
try {
|
|
1200
|
+
const result = await withProjectDir(projectPath, () => addPlugin({
|
|
1201
|
+
projectPath,
|
|
1202
|
+
pluginId,
|
|
1203
|
+
githubUsername,
|
|
1204
|
+
skipGitCheck
|
|
1205
|
+
}));
|
|
1206
|
+
if (!result.success) return errorContent(result.reason);
|
|
1207
|
+
return textContent(JSON.stringify(result, null, 2));
|
|
1208
|
+
} catch (error) {
|
|
1209
|
+
return errorContent(error instanceof Error ? error.message : "Unknown error");
|
|
1210
|
+
}
|
|
1211
|
+
});
|
|
1212
|
+
server.registerTool("makerkit_init_registry", {
|
|
1213
|
+
description: "Cache the GitHub username used for MakerKit plugin registry authentication",
|
|
1214
|
+
inputSchema: {
|
|
1215
|
+
projectPath: z.string().describe("Absolute path to the MakerKit project root"),
|
|
1216
|
+
githubUsername: z.string().describe("GitHub username registered with your MakerKit account")
|
|
1217
|
+
}
|
|
1218
|
+
}, async ({ projectPath, githubUsername }) => {
|
|
1219
|
+
try {
|
|
1220
|
+
const result = await withProjectDir(projectPath, () => initRegistry({
|
|
1221
|
+
projectPath,
|
|
1222
|
+
githubUsername
|
|
1223
|
+
}));
|
|
1224
|
+
return textContent(JSON.stringify(result, null, 2));
|
|
1225
|
+
} catch (error) {
|
|
1226
|
+
return errorContent(error instanceof Error ? error.message : "Unknown error");
|
|
1227
|
+
}
|
|
1228
|
+
});
|
|
1229
|
+
server.registerTool("makerkit_check_update", {
|
|
1230
|
+
description: "Analyze a plugin update using three-way diff (base/local/remote). Returns per-file status and content for AI-powered merge resolution.",
|
|
1231
|
+
inputSchema: {
|
|
1232
|
+
projectPath: z.string().describe("Absolute path to the MakerKit project root"),
|
|
1233
|
+
pluginId: z.string().describe("Plugin identifier (e.g. feedback, waitlist)"),
|
|
1234
|
+
githubUsername: z.string().optional().describe("GitHub username for registry auth (uses cached if omitted)")
|
|
1235
|
+
}
|
|
1236
|
+
}, async ({ projectPath, pluginId, githubUsername }) => {
|
|
1237
|
+
try {
|
|
1238
|
+
const result = await withProjectDir(projectPath, () => checkPluginUpdate({
|
|
1239
|
+
projectPath,
|
|
1240
|
+
pluginId,
|
|
1241
|
+
githubUsername
|
|
1242
|
+
}));
|
|
1243
|
+
if (!result.success) return errorContent(result.reason);
|
|
1244
|
+
return textContent(JSON.stringify({
|
|
1245
|
+
...result,
|
|
1246
|
+
note: "For conflict files, produce a merged version and pass it to makerkit_apply_update."
|
|
1247
|
+
}, null, 2));
|
|
1248
|
+
} catch (error) {
|
|
1249
|
+
return errorContent(error instanceof Error ? error.message : "Unknown error");
|
|
1250
|
+
}
|
|
1251
|
+
});
|
|
1252
|
+
server.registerTool("makerkit_apply_update", {
|
|
1253
|
+
description: "Apply AI-resolved plugin update files. Writes merged content to disk and updates base versions for future three-way merges.",
|
|
1254
|
+
inputSchema: {
|
|
1255
|
+
projectPath: z.string().describe("Absolute path to the MakerKit project root"),
|
|
1256
|
+
pluginId: z.string().describe("Plugin identifier"),
|
|
1257
|
+
files: z.array(z.object({
|
|
1258
|
+
path: z.string().describe("File path relative to project root (from check_update)"),
|
|
1259
|
+
content: z.string().optional().describe("Resolved file content (required for write action)"),
|
|
1260
|
+
action: z.enum([
|
|
1261
|
+
"write",
|
|
1262
|
+
"skip",
|
|
1263
|
+
"delete"
|
|
1264
|
+
]).describe("write: write content to disk, skip: keep local version, delete: remove file from disk")
|
|
1265
|
+
})).describe("Array of file resolutions"),
|
|
1266
|
+
installDependencies: z.boolean().optional().describe("Whether to install plugin dependencies (default true)"),
|
|
1267
|
+
githubUsername: z.string().optional().describe("GitHub username for registry auth (uses cached if omitted)")
|
|
1268
|
+
}
|
|
1269
|
+
}, async ({ projectPath, pluginId, files, installDependencies, githubUsername }) => {
|
|
1270
|
+
try {
|
|
1271
|
+
const result = await withProjectDir(projectPath, () => applyPluginUpdate({
|
|
1272
|
+
projectPath,
|
|
1273
|
+
pluginId,
|
|
1274
|
+
files,
|
|
1275
|
+
installDependencies,
|
|
1276
|
+
githubUsername
|
|
1277
|
+
}));
|
|
1278
|
+
if (!result.success) return errorContent(result.reason);
|
|
1279
|
+
return textContent(JSON.stringify({
|
|
1280
|
+
...result,
|
|
1281
|
+
note: "Base versions updated. Run makerkit_check_update again to verify all files show as unchanged."
|
|
1282
|
+
}, null, 2));
|
|
1283
|
+
} catch (error) {
|
|
1284
|
+
return errorContent(error instanceof Error ? error.message : "Unknown error");
|
|
1285
|
+
}
|
|
1286
|
+
});
|
|
1287
|
+
server.registerTool("makerkit_project_pull", {
|
|
1288
|
+
description: "Pull latest upstream changes into a MakerKit project. Auto-detects kit variant, configures the upstream remote (SSH or HTTPS), fetches, and merges. Returns conflict details with base/local/remote content when merge conflicts occur so the AI can resolve them. After resolving, call makerkit_project_resolve_conflicts.",
|
|
1289
|
+
inputSchema: { projectPath: z.string().describe("Absolute path to the MakerKit project root") }
|
|
1290
|
+
}, async ({ projectPath }) => {
|
|
1291
|
+
try {
|
|
1292
|
+
const result = await withProjectDir(projectPath, () => projectPull({ projectPath }));
|
|
1293
|
+
if (!result.success) {
|
|
1294
|
+
if ("hasConflicts" in result) return textContent(JSON.stringify(result, null, 2));
|
|
1295
|
+
return errorContent(result.reason);
|
|
1296
|
+
}
|
|
1297
|
+
return textContent(JSON.stringify(result, null, 2));
|
|
1298
|
+
} catch (error) {
|
|
1299
|
+
return errorContent(error instanceof Error ? error.message : "Unknown error");
|
|
1300
|
+
}
|
|
1301
|
+
});
|
|
1302
|
+
server.registerTool("makerkit_project_resolve_conflicts", {
|
|
1303
|
+
description: "Resolve merge conflicts from makerkit_project_pull. Write resolved file contents, stage them, and complete the merge commit.",
|
|
1304
|
+
inputSchema: {
|
|
1305
|
+
projectPath: z.string().describe("Absolute path to the MakerKit project root"),
|
|
1306
|
+
files: z.array(z.object({
|
|
1307
|
+
path: z.string().describe("File path relative to project root"),
|
|
1308
|
+
content: z.string().describe("Resolved file content")
|
|
1309
|
+
})).describe("Array of resolved files"),
|
|
1310
|
+
commitMessage: z.string().optional().describe("Custom merge commit message (defaults to auto-generated merge message)")
|
|
1311
|
+
}
|
|
1312
|
+
}, async ({ projectPath, files, commitMessage }) => {
|
|
1313
|
+
try {
|
|
1314
|
+
const result = await withProjectDir(projectPath, () => resolveConflicts({
|
|
1315
|
+
projectPath,
|
|
1316
|
+
files,
|
|
1317
|
+
commitMessage
|
|
1318
|
+
}));
|
|
1319
|
+
if (!result.success) return textContent(JSON.stringify(result, null, 2));
|
|
1320
|
+
return textContent(JSON.stringify(result, null, 2));
|
|
1321
|
+
} catch (error) {
|
|
1322
|
+
return errorContent(error instanceof Error ? error.message : "Unknown error");
|
|
1323
|
+
}
|
|
1324
|
+
});
|
|
1325
|
+
server.registerTool("makerkit_outdated_plugins", {
|
|
1326
|
+
description: "Check all installed plugins for available updates. Returns a list of plugins whose remote files differ from the local copies.",
|
|
1327
|
+
inputSchema: {
|
|
1328
|
+
projectPath: z.string().describe("Absolute path to the MakerKit project root"),
|
|
1329
|
+
githubUsername: z.string().optional().describe("GitHub username for registry auth (uses cached if omitted)")
|
|
1330
|
+
}
|
|
1331
|
+
}, async ({ projectPath, githubUsername }) => {
|
|
1332
|
+
try {
|
|
1333
|
+
const result = await withProjectDir(projectPath, () => outdatedPlugins({
|
|
1334
|
+
projectPath,
|
|
1335
|
+
githubUsername
|
|
1336
|
+
}));
|
|
1337
|
+
if (!result.success) return errorContent(result.reason);
|
|
1338
|
+
return textContent(JSON.stringify({
|
|
1339
|
+
...result,
|
|
1340
|
+
note: result.outdated.length > 0 ? "Use makerkit_check_update on each plugin to see detailed diffs." : "All installed plugins are up to date."
|
|
1341
|
+
}, null, 2));
|
|
1342
|
+
} catch (error) {
|
|
1343
|
+
return errorContent(error instanceof Error ? error.message : "Unknown error");
|
|
1344
|
+
}
|
|
1345
|
+
});
|
|
1346
|
+
async function main() {
|
|
1347
|
+
const transport = new StdioServerTransport();
|
|
1348
|
+
await server.connect(transport);
|
|
1349
|
+
}
|
|
1350
|
+
main();
|
|
1351
|
+
//#endregion
|
|
1352
|
+
export {};
|
|
1353
|
+
|
|
1354
|
+
//# sourceMappingURL=mcp.mjs.map
|