@makerkit/cli 2.0.3 → 2.0.5
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 +1338 -0
- package/dist/index.mjs.map +1 -0
- package/dist/mcp.mjs +1359 -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 -1698
- package/dist/index.js.map +0 -1
- package/dist/mcp.js +0 -1541
- package/dist/mcp.js.map +0 -1
package/dist/index.js
DELETED
|
@@ -1,1698 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
// src/commands/new/new.command.ts
|
|
4
|
-
import chalk from "chalk";
|
|
5
|
-
import { Command } from "commander";
|
|
6
|
-
import ora from "ora";
|
|
7
|
-
import prompts from "prompts";
|
|
8
|
-
|
|
9
|
-
// src/utils/create-project.ts
|
|
10
|
-
import { join as join2 } from "path";
|
|
11
|
-
import { execa } from "execa";
|
|
12
|
-
import fs2 from "fs-extra";
|
|
13
|
-
|
|
14
|
-
// src/utils/marker-file.ts
|
|
15
|
-
import { join } from "path";
|
|
16
|
-
import fs from "fs-extra";
|
|
17
|
-
|
|
18
|
-
// src/version.ts
|
|
19
|
-
var CLI_VERSION = "2.0.3";
|
|
20
|
-
|
|
21
|
-
// src/utils/marker-file.ts
|
|
22
|
-
async function writeMarkerFile(projectPath, variant, kitRepo) {
|
|
23
|
-
const dir = join(projectPath, ".makerkit");
|
|
24
|
-
await fs.ensureDir(dir);
|
|
25
|
-
const config2 = {
|
|
26
|
-
version: 1,
|
|
27
|
-
variant,
|
|
28
|
-
kit_repo: kitRepo,
|
|
29
|
-
created_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
30
|
-
cli_version: CLI_VERSION
|
|
31
|
-
};
|
|
32
|
-
await fs.writeJson(join(dir, "config.json"), config2, { spaces: 2 });
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
// src/utils/upstream.ts
|
|
36
|
-
import { execaCommand } from "execa";
|
|
37
|
-
var VARIANT_REPO_MAP = {
|
|
38
|
-
"next-supabase": "makerkit/next-supabase-saas-kit-turbo",
|
|
39
|
-
"next-drizzle": "makerkit/next-drizzle-saas-kit-turbo",
|
|
40
|
-
"next-prisma": "makerkit/next-prisma-saas-kit-turbo",
|
|
41
|
-
"react-router-supabase": "makerkit/react-router-supabase-saas-kit-turbo"
|
|
42
|
-
};
|
|
43
|
-
function sshUrl(repo) {
|
|
44
|
-
return `git@github.com:${repo}`;
|
|
45
|
-
}
|
|
46
|
-
function httpsUrl(repo) {
|
|
47
|
-
return `https://github.com/${repo}`;
|
|
48
|
-
}
|
|
49
|
-
async function hasSshAccess() {
|
|
50
|
-
try {
|
|
51
|
-
await execaCommand("ssh -T git@github.com -o StrictHostKeyChecking=no", {
|
|
52
|
-
timeout: 1e4
|
|
53
|
-
});
|
|
54
|
-
return true;
|
|
55
|
-
} catch (error) {
|
|
56
|
-
const stderr = error instanceof Error && "stderr" in error ? String(error.stderr) : "";
|
|
57
|
-
return stderr.includes("successfully authenticated");
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
function getUpstreamUrl(variant, useSsh) {
|
|
61
|
-
const repo = VARIANT_REPO_MAP[variant];
|
|
62
|
-
return useSsh ? sshUrl(repo) : httpsUrl(repo);
|
|
63
|
-
}
|
|
64
|
-
function isUpstreamUrlValid(url, variant) {
|
|
65
|
-
const normalized = url.replace(/\/+$/, "").replace(/\.git$/, "");
|
|
66
|
-
const repo = VARIANT_REPO_MAP[variant];
|
|
67
|
-
return normalized === sshUrl(repo) || normalized === httpsUrl(repo);
|
|
68
|
-
}
|
|
69
|
-
async function getUpstreamRemoteUrl() {
|
|
70
|
-
try {
|
|
71
|
-
const { stdout } = await execaCommand("git remote get-url upstream");
|
|
72
|
-
return stdout.trim() || void 0;
|
|
73
|
-
} catch {
|
|
74
|
-
return void 0;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
async function setUpstreamRemote(url) {
|
|
78
|
-
const currentUrl = await getUpstreamRemoteUrl();
|
|
79
|
-
if (currentUrl) {
|
|
80
|
-
await execaCommand(`git remote set-url upstream ${url}`);
|
|
81
|
-
} else {
|
|
82
|
-
await execaCommand(`git remote add upstream ${url}`);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
// src/utils/create-project.ts
|
|
87
|
-
async function createProject(options) {
|
|
88
|
-
const { variant, name, directory, githubToken } = options;
|
|
89
|
-
const projectPath = join2(directory, name);
|
|
90
|
-
const repo = VARIANT_REPO_MAP[variant];
|
|
91
|
-
if (await fs2.pathExists(projectPath)) {
|
|
92
|
-
throw new Error(
|
|
93
|
-
`Target directory "${projectPath}" already exists. Choose a different name or remove it first.`
|
|
94
|
-
);
|
|
95
|
-
}
|
|
96
|
-
if (!await fs2.pathExists(directory)) {
|
|
97
|
-
throw new Error(
|
|
98
|
-
`Parent directory "${directory}" does not exist.`
|
|
99
|
-
);
|
|
100
|
-
}
|
|
101
|
-
let cloneUrl;
|
|
102
|
-
if (githubToken) {
|
|
103
|
-
cloneUrl = `https://${githubToken}@github.com/${repo}`;
|
|
104
|
-
} else {
|
|
105
|
-
const useSsh = await hasSshAccess();
|
|
106
|
-
cloneUrl = useSsh ? `git@github.com:${repo}` : `https://github.com/${repo}`;
|
|
107
|
-
}
|
|
108
|
-
await execa("git", ["clone", cloneUrl, name], { cwd: directory });
|
|
109
|
-
if (githubToken) {
|
|
110
|
-
await execa(
|
|
111
|
-
"git",
|
|
112
|
-
["remote", "set-url", "origin", `https://github.com/${repo}`],
|
|
113
|
-
{ cwd: projectPath }
|
|
114
|
-
);
|
|
115
|
-
}
|
|
116
|
-
await execa("pnpm", ["install"], { cwd: projectPath });
|
|
117
|
-
await writeMarkerFile(projectPath, variant, repo);
|
|
118
|
-
return {
|
|
119
|
-
success: true,
|
|
120
|
-
projectPath,
|
|
121
|
-
variant,
|
|
122
|
-
kitRepo: repo,
|
|
123
|
-
message: `Project "${name}" created successfully with variant "${variant}".`
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
// src/utils/list-variants.ts
|
|
128
|
-
var VARIANT_CATALOG = [
|
|
129
|
-
{
|
|
130
|
-
id: "next-supabase",
|
|
131
|
-
name: "Next.js + Supabase",
|
|
132
|
-
description: "Full-stack SaaS kit with Next.js App Router and Supabase",
|
|
133
|
-
repo: VARIANT_REPO_MAP["next-supabase"],
|
|
134
|
-
tech: ["Next.js", "Supabase", "Tailwind CSS", "shadcn/ui"],
|
|
135
|
-
database: "PostgreSQL (Supabase)",
|
|
136
|
-
auth: "Supabase Auth",
|
|
137
|
-
status: "stable"
|
|
138
|
-
},
|
|
139
|
-
{
|
|
140
|
-
id: "next-drizzle",
|
|
141
|
-
name: "Next.js + Drizzle",
|
|
142
|
-
description: "Full-stack SaaS kit with Next.js and Drizzle ORM",
|
|
143
|
-
repo: VARIANT_REPO_MAP["next-drizzle"],
|
|
144
|
-
tech: ["Next.js", "Drizzle", "Tailwind CSS", "shadcn/ui"],
|
|
145
|
-
database: "PostgreSQL",
|
|
146
|
-
auth: "Better Auth",
|
|
147
|
-
status: "stable"
|
|
148
|
-
},
|
|
149
|
-
{
|
|
150
|
-
id: "next-prisma",
|
|
151
|
-
name: "Next.js + Prisma",
|
|
152
|
-
description: "Full-stack SaaS kit with Next.js and Prisma ORM",
|
|
153
|
-
repo: VARIANT_REPO_MAP["next-prisma"],
|
|
154
|
-
tech: ["Next.js", "Prisma", "Tailwind CSS", "shadcn/ui"],
|
|
155
|
-
database: "PostgreSQL",
|
|
156
|
-
auth: "Better Auth",
|
|
157
|
-
status: "stable"
|
|
158
|
-
},
|
|
159
|
-
{
|
|
160
|
-
id: "react-router-supabase",
|
|
161
|
-
name: "React Router + Supabase",
|
|
162
|
-
description: "Full-stack SaaS kit with React Router and Supabase",
|
|
163
|
-
repo: VARIANT_REPO_MAP["react-router-supabase"],
|
|
164
|
-
tech: ["React Router", "Supabase", "Tailwind CSS", "shadcn/ui"],
|
|
165
|
-
database: "PostgreSQL (Supabase)",
|
|
166
|
-
auth: "Supabase Auth",
|
|
167
|
-
status: "stable"
|
|
168
|
-
}
|
|
169
|
-
];
|
|
170
|
-
|
|
171
|
-
// src/commands/new/new.command.ts
|
|
172
|
-
var newCommand = new Command().name("new").description("Initialize a new Makerkit project").action(async () => {
|
|
173
|
-
const choices = VARIANT_CATALOG.map((v) => ({
|
|
174
|
-
title: v.name,
|
|
175
|
-
value: v.id
|
|
176
|
-
}));
|
|
177
|
-
const { kit, name: projectName } = await prompts([
|
|
178
|
-
{
|
|
179
|
-
type: "select",
|
|
180
|
-
name: "kit",
|
|
181
|
-
message: `Select the ${chalk.cyan(`SaaS Kit`)} you want to clone`,
|
|
182
|
-
choices
|
|
183
|
-
},
|
|
184
|
-
{
|
|
185
|
-
type: "text",
|
|
186
|
-
name: "name",
|
|
187
|
-
message: `Enter your ${chalk.cyan("Project Name")}.`
|
|
188
|
-
}
|
|
189
|
-
]);
|
|
190
|
-
const selected = VARIANT_CATALOG.find((v) => v.id === kit);
|
|
191
|
-
if (!selected) {
|
|
192
|
-
console.log("Invalid kit selection. Aborting...");
|
|
193
|
-
process.exit(1);
|
|
194
|
-
}
|
|
195
|
-
const { confirm } = await prompts([
|
|
196
|
-
{
|
|
197
|
-
type: "confirm",
|
|
198
|
-
name: "confirm",
|
|
199
|
-
message: `Are you sure you want to clone ${chalk.cyan(
|
|
200
|
-
selected.name
|
|
201
|
-
)} to ${chalk.cyan(projectName)}?`
|
|
202
|
-
}
|
|
203
|
-
]);
|
|
204
|
-
if (!confirm) {
|
|
205
|
-
console.log("Aborting...");
|
|
206
|
-
process.exit(0);
|
|
207
|
-
}
|
|
208
|
-
const spinner = ora(`Cloning ${selected.name}...`).start();
|
|
209
|
-
try {
|
|
210
|
-
const result = await createProject({
|
|
211
|
-
variant: selected.id,
|
|
212
|
-
name: projectName,
|
|
213
|
-
directory: process.cwd()
|
|
214
|
-
});
|
|
215
|
-
spinner.succeed(`${result.message}`);
|
|
216
|
-
console.log(
|
|
217
|
-
`You can now get started. Open the project in your IDE and read the README.md file for more information.`
|
|
218
|
-
);
|
|
219
|
-
} catch (e) {
|
|
220
|
-
console.error(e);
|
|
221
|
-
spinner.fail(`Failed to create project`);
|
|
222
|
-
process.exit(1);
|
|
223
|
-
}
|
|
224
|
-
});
|
|
225
|
-
|
|
226
|
-
// src/plugins-model.ts
|
|
227
|
-
import { join as join4 } from "path";
|
|
228
|
-
import fs4 from "fs-extra";
|
|
229
|
-
import invariant from "tiny-invariant";
|
|
230
|
-
|
|
231
|
-
// src/utils/plugins-cache.ts
|
|
232
|
-
import { join as join3 } from "path";
|
|
233
|
-
import { homedir } from "os";
|
|
234
|
-
import fs3 from "fs-extra";
|
|
235
|
-
var CACHE_DIR = join3(homedir(), ".makerkit");
|
|
236
|
-
var CACHE_FILE = join3(CACHE_DIR, "plugins.json");
|
|
237
|
-
var CACHE_TTL_MS = 60 * 60 * 1e3;
|
|
238
|
-
async function readCache() {
|
|
239
|
-
try {
|
|
240
|
-
if (!await fs3.pathExists(CACHE_FILE)) {
|
|
241
|
-
return null;
|
|
242
|
-
}
|
|
243
|
-
return await fs3.readJson(CACHE_FILE);
|
|
244
|
-
} catch {
|
|
245
|
-
return null;
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
async function writeCache(plugins) {
|
|
249
|
-
try {
|
|
250
|
-
await fs3.ensureDir(CACHE_DIR);
|
|
251
|
-
await fs3.writeJson(
|
|
252
|
-
CACHE_FILE,
|
|
253
|
-
{ fetchedAt: Date.now(), plugins },
|
|
254
|
-
{ spaces: 2 }
|
|
255
|
-
);
|
|
256
|
-
} catch {
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
async function fetchPluginRegistry(registryUrl, fallback) {
|
|
260
|
-
if (!registryUrl) {
|
|
261
|
-
return fallback;
|
|
262
|
-
}
|
|
263
|
-
const cached = await readCache();
|
|
264
|
-
if (cached && Date.now() - cached.fetchedAt < CACHE_TTL_MS) {
|
|
265
|
-
return cached.plugins;
|
|
266
|
-
}
|
|
267
|
-
try {
|
|
268
|
-
const response = await fetch(registryUrl);
|
|
269
|
-
if (response.ok) {
|
|
270
|
-
const data = await response.json();
|
|
271
|
-
const plugins = data.plugins;
|
|
272
|
-
await writeCache(plugins);
|
|
273
|
-
return plugins;
|
|
274
|
-
}
|
|
275
|
-
} catch {
|
|
276
|
-
}
|
|
277
|
-
return cached?.plugins ?? fallback;
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
// src/plugins-model.ts
|
|
281
|
-
var DEFAULT_PLUGINS = {
|
|
282
|
-
feedback: {
|
|
283
|
-
name: "Feedback",
|
|
284
|
-
id: "feedback",
|
|
285
|
-
description: "Add a feedback popup to your site.",
|
|
286
|
-
postInstallMessage: "Run database migrations: pnpm db:migrate",
|
|
287
|
-
variants: {
|
|
288
|
-
"next-supabase": {
|
|
289
|
-
envVars: [],
|
|
290
|
-
path: "packages/plugins/feedback"
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
},
|
|
294
|
-
waitlist: {
|
|
295
|
-
name: "Waitlist",
|
|
296
|
-
id: "waitlist",
|
|
297
|
-
description: "Add a waitlist to your site.",
|
|
298
|
-
postInstallMessage: "Run database migrations: pnpm db:migrate",
|
|
299
|
-
variants: {
|
|
300
|
-
"next-supabase": {
|
|
301
|
-
envVars: [],
|
|
302
|
-
path: "packages/plugins/waitlist"
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
},
|
|
306
|
-
testimonial: {
|
|
307
|
-
name: "Testimonial",
|
|
308
|
-
id: "testimonial",
|
|
309
|
-
description: "Add a testimonial widget to your site.",
|
|
310
|
-
postInstallMessage: "Run database migrations: pnpm db:migrate",
|
|
311
|
-
variants: {
|
|
312
|
-
"next-supabase": {
|
|
313
|
-
envVars: [],
|
|
314
|
-
path: "packages/plugins/testimonial"
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
},
|
|
318
|
-
roadmap: {
|
|
319
|
-
name: "Roadmap",
|
|
320
|
-
id: "roadmap",
|
|
321
|
-
description: "Add a roadmap to your site.",
|
|
322
|
-
postInstallMessage: "Run database migrations: pnpm db:migrate",
|
|
323
|
-
variants: {
|
|
324
|
-
"next-supabase": {
|
|
325
|
-
envVars: [],
|
|
326
|
-
path: "packages/plugins/roadmap"
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
},
|
|
330
|
-
"google-analytics": {
|
|
331
|
-
name: "Google Analytics",
|
|
332
|
-
id: "google-analytics",
|
|
333
|
-
description: "Add Google Analytics to your site.",
|
|
334
|
-
variants: {
|
|
335
|
-
"next-supabase": {
|
|
336
|
-
envVars: [
|
|
337
|
-
{
|
|
338
|
-
key: "NEXT_PUBLIC_GOOGLE_ANALYTICS_ID",
|
|
339
|
-
description: "Google Analytics Measurement ID"
|
|
340
|
-
}
|
|
341
|
-
],
|
|
342
|
-
path: "packages/plugins/analytics/google-analytics"
|
|
343
|
-
},
|
|
344
|
-
"next-drizzle": {
|
|
345
|
-
envVars: [
|
|
346
|
-
{
|
|
347
|
-
key: "NEXT_PUBLIC_GOOGLE_ANALYTICS_ID",
|
|
348
|
-
description: "Google Analytics Measurement ID"
|
|
349
|
-
}
|
|
350
|
-
],
|
|
351
|
-
path: "packages/plugins/analytics/google-analytics"
|
|
352
|
-
},
|
|
353
|
-
"next-prisma": {
|
|
354
|
-
envVars: [
|
|
355
|
-
{
|
|
356
|
-
key: "NEXT_PUBLIC_GOOGLE_ANALYTICS_ID",
|
|
357
|
-
description: "Google Analytics Measurement ID"
|
|
358
|
-
}
|
|
359
|
-
],
|
|
360
|
-
path: "packages/plugins/analytics/google-analytics"
|
|
361
|
-
}
|
|
362
|
-
}
|
|
363
|
-
},
|
|
364
|
-
honeybadger: {
|
|
365
|
-
name: "Honeybadger",
|
|
366
|
-
id: "honeybadger",
|
|
367
|
-
description: "Add Honeybadger Error Tracking to your site.",
|
|
368
|
-
variants: {
|
|
369
|
-
"next-supabase": {
|
|
370
|
-
envVars: [
|
|
371
|
-
{
|
|
372
|
-
key: "HONEYBADGER_API_KEY",
|
|
373
|
-
description: "Honeybadger private API key"
|
|
374
|
-
},
|
|
375
|
-
{
|
|
376
|
-
key: "NEXT_PUBLIC_HONEYBADGER_ENVIRONMENT",
|
|
377
|
-
description: "Honeybadger environment"
|
|
378
|
-
},
|
|
379
|
-
{
|
|
380
|
-
key: "NEXT_PUBLIC_HONEYBADGER_REVISION",
|
|
381
|
-
description: "Honeybadger log revision"
|
|
382
|
-
}
|
|
383
|
-
],
|
|
384
|
-
path: "packages/plugins/honeybadger"
|
|
385
|
-
},
|
|
386
|
-
"next-drizzle": {
|
|
387
|
-
envVars: [
|
|
388
|
-
{
|
|
389
|
-
key: "HONEYBADGER_API_KEY",
|
|
390
|
-
description: "Honeybadger private API key"
|
|
391
|
-
},
|
|
392
|
-
{
|
|
393
|
-
key: "NEXT_PUBLIC_HONEYBADGER_ENVIRONMENT",
|
|
394
|
-
description: "Honeybadger environment"
|
|
395
|
-
},
|
|
396
|
-
{
|
|
397
|
-
key: "NEXT_PUBLIC_HONEYBADGER_REVISION",
|
|
398
|
-
description: "Honeybadger log revision"
|
|
399
|
-
}
|
|
400
|
-
],
|
|
401
|
-
path: "packages/plugins/honeybadger"
|
|
402
|
-
},
|
|
403
|
-
"next-prisma": {
|
|
404
|
-
envVars: [
|
|
405
|
-
{
|
|
406
|
-
key: "HONEYBADGER_API_KEY",
|
|
407
|
-
description: "Honeybadger private API key"
|
|
408
|
-
},
|
|
409
|
-
{
|
|
410
|
-
key: "NEXT_PUBLIC_HONEYBADGER_ENVIRONMENT",
|
|
411
|
-
description: "Honeybadger environment"
|
|
412
|
-
},
|
|
413
|
-
{
|
|
414
|
-
key: "NEXT_PUBLIC_HONEYBADGER_REVISION",
|
|
415
|
-
description: "Honeybadger log revision"
|
|
416
|
-
}
|
|
417
|
-
]
|
|
418
|
-
}
|
|
419
|
-
}
|
|
420
|
-
},
|
|
421
|
-
posthog: {
|
|
422
|
-
name: "PostHog",
|
|
423
|
-
id: "posthog",
|
|
424
|
-
description: "Add PostHog Analytics to your site.",
|
|
425
|
-
variants: {
|
|
426
|
-
"next-supabase": {
|
|
427
|
-
envVars: [
|
|
428
|
-
{
|
|
429
|
-
key: "NEXT_PUBLIC_POSTHOG_KEY",
|
|
430
|
-
description: "PostHog project API key"
|
|
431
|
-
},
|
|
432
|
-
{
|
|
433
|
-
key: "NEXT_PUBLIC_POSTHOG_HOST",
|
|
434
|
-
description: "PostHog host URL",
|
|
435
|
-
defaultValue: "https://app.posthog.com"
|
|
436
|
-
}
|
|
437
|
-
],
|
|
438
|
-
path: "packages/plugins/analytics/posthog"
|
|
439
|
-
},
|
|
440
|
-
"next-drizzle": {
|
|
441
|
-
envVars: [
|
|
442
|
-
{
|
|
443
|
-
key: "NEXT_PUBLIC_POSTHOG_KEY",
|
|
444
|
-
description: "PostHog project API key"
|
|
445
|
-
},
|
|
446
|
-
{
|
|
447
|
-
key: "NEXT_PUBLIC_POSTHOG_HOST",
|
|
448
|
-
description: "PostHog host URL",
|
|
449
|
-
defaultValue: "https://app.posthog.com"
|
|
450
|
-
}
|
|
451
|
-
],
|
|
452
|
-
path: "packages/plugins/analytics/posthog"
|
|
453
|
-
},
|
|
454
|
-
"next-prisma": {
|
|
455
|
-
envVars: [
|
|
456
|
-
{
|
|
457
|
-
key: "NEXT_PUBLIC_POSTHOG_KEY",
|
|
458
|
-
description: "PostHog project API key"
|
|
459
|
-
},
|
|
460
|
-
{
|
|
461
|
-
key: "NEXT_PUBLIC_POSTHOG_HOST",
|
|
462
|
-
description: "PostHog host URL",
|
|
463
|
-
defaultValue: "https://app.posthog.com"
|
|
464
|
-
}
|
|
465
|
-
],
|
|
466
|
-
path: "packages/plugins/analytics/posthog"
|
|
467
|
-
}
|
|
468
|
-
}
|
|
469
|
-
},
|
|
470
|
-
umami: {
|
|
471
|
-
name: "Umami",
|
|
472
|
-
id: "umami",
|
|
473
|
-
description: "Add Umami Analytics to your site.",
|
|
474
|
-
variants: {
|
|
475
|
-
"next-supabase": {
|
|
476
|
-
envVars: [
|
|
477
|
-
{
|
|
478
|
-
key: "NEXT_PUBLIC_UMAMI_WEBSITE_ID",
|
|
479
|
-
description: "Umami website ID"
|
|
480
|
-
},
|
|
481
|
-
{
|
|
482
|
-
key: "NEXT_PUBLIC_UMAMI_HOST",
|
|
483
|
-
description: "Umami host URL"
|
|
484
|
-
}
|
|
485
|
-
],
|
|
486
|
-
path: "packages/plugins/analytics/umami"
|
|
487
|
-
},
|
|
488
|
-
"next-drizzle": {
|
|
489
|
-
envVars: [
|
|
490
|
-
{
|
|
491
|
-
key: "NEXT_PUBLIC_UMAMI_WEBSITE_ID",
|
|
492
|
-
description: "Umami website ID"
|
|
493
|
-
},
|
|
494
|
-
{
|
|
495
|
-
key: "NEXT_PUBLIC_UMAMI_HOST",
|
|
496
|
-
description: "Umami host URL"
|
|
497
|
-
}
|
|
498
|
-
],
|
|
499
|
-
path: "packages/plugins/analytics/umami"
|
|
500
|
-
},
|
|
501
|
-
"next-prisma": {
|
|
502
|
-
envVars: [
|
|
503
|
-
{
|
|
504
|
-
key: "NEXT_PUBLIC_UMAMI_WEBSITE_ID",
|
|
505
|
-
description: "Umami website ID"
|
|
506
|
-
},
|
|
507
|
-
{
|
|
508
|
-
key: "NEXT_PUBLIC_UMAMI_HOST",
|
|
509
|
-
description: "Umami host URL"
|
|
510
|
-
}
|
|
511
|
-
],
|
|
512
|
-
path: "packages/plugins/analytics/umami"
|
|
513
|
-
}
|
|
514
|
-
}
|
|
515
|
-
},
|
|
516
|
-
signoz: {
|
|
517
|
-
name: "SigNoz",
|
|
518
|
-
id: "signoz",
|
|
519
|
-
description: "Add SigNoz Monitoring to your app.",
|
|
520
|
-
variants: {
|
|
521
|
-
"next-supabase": {
|
|
522
|
-
envVars: [
|
|
523
|
-
{
|
|
524
|
-
key: "OTEL_EXPORTER_OTLP_ENDPOINT",
|
|
525
|
-
description: "SigNoz OTLP endpoint URL"
|
|
526
|
-
}
|
|
527
|
-
],
|
|
528
|
-
path: "packages/plugins/signoz"
|
|
529
|
-
},
|
|
530
|
-
"next-drizzle": {
|
|
531
|
-
envVars: [
|
|
532
|
-
{
|
|
533
|
-
key: "OTEL_EXPORTER_OTLP_ENDPOINT",
|
|
534
|
-
description: "SigNoz OTLP endpoint URL"
|
|
535
|
-
}
|
|
536
|
-
],
|
|
537
|
-
path: "packages/plugins/signoz"
|
|
538
|
-
},
|
|
539
|
-
"next-prisma": {
|
|
540
|
-
envVars: [
|
|
541
|
-
{
|
|
542
|
-
key: "OTEL_EXPORTER_OTLP_ENDPOINT",
|
|
543
|
-
description: "SigNoz OTLP endpoint URL"
|
|
544
|
-
}
|
|
545
|
-
],
|
|
546
|
-
path: "packages/plugins/signoz"
|
|
547
|
-
}
|
|
548
|
-
}
|
|
549
|
-
},
|
|
550
|
-
paddle: {
|
|
551
|
-
name: "Paddle",
|
|
552
|
-
id: "paddle",
|
|
553
|
-
description: "Add Paddle Billing to your app.",
|
|
554
|
-
variants: {
|
|
555
|
-
"next-supabase": {
|
|
556
|
-
envVars: [
|
|
557
|
-
{
|
|
558
|
-
key: "NEXT_PUBLIC_PADDLE_CLIENT_TOKEN",
|
|
559
|
-
description: "Paddle client-side token"
|
|
560
|
-
},
|
|
561
|
-
{
|
|
562
|
-
key: "PADDLE_API_KEY",
|
|
563
|
-
description: "Paddle API key"
|
|
564
|
-
},
|
|
565
|
-
{
|
|
566
|
-
key: "PADDLE_WEBHOOK_SECRET",
|
|
567
|
-
description: "Paddle webhook secret"
|
|
568
|
-
}
|
|
569
|
-
],
|
|
570
|
-
path: "packages/plugins/paddle"
|
|
571
|
-
}
|
|
572
|
-
}
|
|
573
|
-
},
|
|
574
|
-
"supabase-cms": {
|
|
575
|
-
name: "Supabase CMS",
|
|
576
|
-
id: "supabase-cms",
|
|
577
|
-
description: "Add Supabase CMS provider to your app.",
|
|
578
|
-
postInstallMessage: "Run database migrations: pnpm db:migrate",
|
|
579
|
-
variants: {
|
|
580
|
-
"next-supabase": {
|
|
581
|
-
envVars: [],
|
|
582
|
-
path: "packages/plugins/supabase-cms"
|
|
583
|
-
}
|
|
584
|
-
}
|
|
585
|
-
},
|
|
586
|
-
"meshes-analytics": {
|
|
587
|
-
name: "Meshes Analytics",
|
|
588
|
-
id: "meshes-analytics",
|
|
589
|
-
description: "Add Meshes Analytics to your app.",
|
|
590
|
-
variants: {
|
|
591
|
-
"next-supabase": {
|
|
592
|
-
envVars: [
|
|
593
|
-
{
|
|
594
|
-
key: "NEXT_PUBLIC_MESHES_PUBLISHABLE_KEY",
|
|
595
|
-
description: "The Meshes publishable key"
|
|
596
|
-
}
|
|
597
|
-
],
|
|
598
|
-
path: "packages/plugins/meshes-analytics"
|
|
599
|
-
}
|
|
600
|
-
}
|
|
601
|
-
},
|
|
602
|
-
directus: {
|
|
603
|
-
name: "Directus CMS",
|
|
604
|
-
id: "directus",
|
|
605
|
-
description: "Add Directus as your CMS.",
|
|
606
|
-
variants: {
|
|
607
|
-
"next-supabase": {
|
|
608
|
-
envVars: [
|
|
609
|
-
{
|
|
610
|
-
key: "NEXT_PUBLIC_DIRECTUS_URL",
|
|
611
|
-
description: "The Directus URL"
|
|
612
|
-
},
|
|
613
|
-
{
|
|
614
|
-
key: "DIRECTUS_ACCESS_TOKEN",
|
|
615
|
-
description: "The Directus access token"
|
|
616
|
-
}
|
|
617
|
-
],
|
|
618
|
-
path: "packages/plugins/directus"
|
|
619
|
-
},
|
|
620
|
-
"next-drizzle": {
|
|
621
|
-
envVars: [
|
|
622
|
-
{
|
|
623
|
-
key: "NEXT_PUBLIC_DIRECTUS_URL",
|
|
624
|
-
description: "The Directus URL"
|
|
625
|
-
},
|
|
626
|
-
{
|
|
627
|
-
key: "DIRECTUS_ACCESS_TOKEN",
|
|
628
|
-
description: "The Directus access token"
|
|
629
|
-
}
|
|
630
|
-
],
|
|
631
|
-
path: "packages/plugins/directus"
|
|
632
|
-
},
|
|
633
|
-
"next-prisma": {
|
|
634
|
-
envVars: [
|
|
635
|
-
{
|
|
636
|
-
key: "NEXT_PUBLIC_DIRECTUS_URL",
|
|
637
|
-
description: "The Directus URL"
|
|
638
|
-
},
|
|
639
|
-
{
|
|
640
|
-
key: "DIRECTUS_ACCESS_TOKEN",
|
|
641
|
-
description: "The Directus access token"
|
|
642
|
-
}
|
|
643
|
-
],
|
|
644
|
-
path: "packages/plugins/directus"
|
|
645
|
-
}
|
|
646
|
-
}
|
|
647
|
-
}
|
|
648
|
-
};
|
|
649
|
-
var PluginRegistry = class _PluginRegistry {
|
|
650
|
-
constructor(plugins) {
|
|
651
|
-
this.plugins = plugins;
|
|
652
|
-
}
|
|
653
|
-
static async load() {
|
|
654
|
-
const registryUrl = process.env.MAKERKIT_PLUGINS_REGISTRY_URL;
|
|
655
|
-
const plugins = await fetchPluginRegistry(registryUrl, DEFAULT_PLUGINS);
|
|
656
|
-
return new _PluginRegistry(plugins);
|
|
657
|
-
}
|
|
658
|
-
getPluginById(id) {
|
|
659
|
-
return this.plugins[id];
|
|
660
|
-
}
|
|
661
|
-
getPluginsForVariant(variant) {
|
|
662
|
-
return Object.values(this.plugins).filter((p) => variant in p.variants);
|
|
663
|
-
}
|
|
664
|
-
validatePlugin(pluginId, variant) {
|
|
665
|
-
const plugin = this.getPluginById(pluginId);
|
|
666
|
-
invariant(plugin, `Plugin "${pluginId}" not found`);
|
|
667
|
-
invariant(
|
|
668
|
-
plugin.variants[variant],
|
|
669
|
-
`Plugin "${pluginId}" is not available for the ${variant} variant`
|
|
670
|
-
);
|
|
671
|
-
return plugin;
|
|
672
|
-
}
|
|
673
|
-
};
|
|
674
|
-
function getEnvVars(plugin, variant) {
|
|
675
|
-
return plugin.variants[variant]?.envVars ?? [];
|
|
676
|
-
}
|
|
677
|
-
function getPath(plugin, variant) {
|
|
678
|
-
return plugin.variants[variant]?.path;
|
|
679
|
-
}
|
|
680
|
-
async function isInstalled(plugin, variant) {
|
|
681
|
-
const pluginPath = getPath(plugin, variant);
|
|
682
|
-
if (!pluginPath) {
|
|
683
|
-
return false;
|
|
684
|
-
}
|
|
685
|
-
const pkgJsonPath = join4(process.cwd(), pluginPath, "package.json");
|
|
686
|
-
if (!await fs4.pathExists(pkgJsonPath)) {
|
|
687
|
-
return false;
|
|
688
|
-
}
|
|
689
|
-
try {
|
|
690
|
-
const pkg = await fs4.readJson(pkgJsonPath);
|
|
691
|
-
return !!pkg.name && !!pkg.exports;
|
|
692
|
-
} catch {
|
|
693
|
-
return false;
|
|
694
|
-
}
|
|
695
|
-
}
|
|
696
|
-
|
|
697
|
-
// src/utils/base-store.ts
|
|
698
|
-
import { dirname, join as join5 } from "path";
|
|
699
|
-
import fs5 from "fs-extra";
|
|
700
|
-
function basesDir(pluginId) {
|
|
701
|
-
return join5(process.cwd(), "node_modules", ".cache", "makerkit", "bases", pluginId);
|
|
702
|
-
}
|
|
703
|
-
async function saveBaseVersions(pluginId, files) {
|
|
704
|
-
const dir = basesDir(pluginId);
|
|
705
|
-
for (const file of files) {
|
|
706
|
-
const targetPath = join5(dir, file.target);
|
|
707
|
-
await fs5.ensureDir(dirname(targetPath));
|
|
708
|
-
await fs5.writeFile(targetPath, file.content);
|
|
709
|
-
}
|
|
710
|
-
}
|
|
711
|
-
|
|
712
|
-
// src/utils/git.ts
|
|
713
|
-
import { execaCommand as execaCommand2 } from "execa";
|
|
714
|
-
function getErrorOutput(error) {
|
|
715
|
-
if (error instanceof Error && "stderr" in error) {
|
|
716
|
-
const stderr = String(error.stderr);
|
|
717
|
-
if (stderr) return stderr;
|
|
718
|
-
}
|
|
719
|
-
if (error instanceof Error && "stdout" in error) {
|
|
720
|
-
const stdout = String(error.stdout);
|
|
721
|
-
if (stdout) return stdout;
|
|
722
|
-
}
|
|
723
|
-
return error instanceof Error ? error.message : String(error);
|
|
724
|
-
}
|
|
725
|
-
async function isGitClean() {
|
|
726
|
-
const { stdout } = await execaCommand2("git status --porcelain");
|
|
727
|
-
return stdout.trim() === "";
|
|
728
|
-
}
|
|
729
|
-
async function getGitUsername() {
|
|
730
|
-
try {
|
|
731
|
-
const { stdout } = await execaCommand2("git config --get user.username");
|
|
732
|
-
const username = stdout.trim();
|
|
733
|
-
return username.length > 0 ? username : void 0;
|
|
734
|
-
} catch {
|
|
735
|
-
return void 0;
|
|
736
|
-
}
|
|
737
|
-
}
|
|
738
|
-
|
|
739
|
-
// src/utils/install-registry-files.ts
|
|
740
|
-
import { dirname as dirname2, join as join6 } from "path";
|
|
741
|
-
import fs6 from "fs-extra";
|
|
742
|
-
async function fetchRegistryItem(variant, pluginId, username) {
|
|
743
|
-
const url = `https://makerkit.dev/r/${variant}/${pluginId}.json?username=${username}`;
|
|
744
|
-
const response = await fetch(url);
|
|
745
|
-
if (!response.ok) {
|
|
746
|
-
throw new Error(
|
|
747
|
-
`Failed to fetch plugin registry for "${pluginId}" (${response.status}): ${response.statusText}`
|
|
748
|
-
);
|
|
749
|
-
}
|
|
750
|
-
const item = await response.json();
|
|
751
|
-
if (!item.files || item.files.length === 0) {
|
|
752
|
-
throw new Error(`Plugin "${pluginId}" has no files in the registry.`);
|
|
753
|
-
}
|
|
754
|
-
return item;
|
|
755
|
-
}
|
|
756
|
-
async function installRegistryFiles(variant, pluginId, username) {
|
|
757
|
-
const item = await fetchRegistryItem(variant, pluginId, username);
|
|
758
|
-
const cwd = process.cwd();
|
|
759
|
-
for (const file of item.files) {
|
|
760
|
-
const targetPath = join6(cwd, file.target);
|
|
761
|
-
await fs6.ensureDir(dirname2(targetPath));
|
|
762
|
-
await fs6.writeFile(targetPath, file.content);
|
|
763
|
-
}
|
|
764
|
-
return item;
|
|
765
|
-
}
|
|
766
|
-
|
|
767
|
-
// src/utils/run-codemod.ts
|
|
768
|
-
import { execaCommand as execaCommand3 } from "execa";
|
|
769
|
-
var CODEMOD_TIMEOUT_MS = 5 * 60 * 1e3;
|
|
770
|
-
async function runCodemod(variant, pluginId, options) {
|
|
771
|
-
try {
|
|
772
|
-
const localPath = process.env.MAKERKIT_CODEMODS_PATH;
|
|
773
|
-
const runner = process.env.MAKERKIT_PACKAGE_RUNNER ?? "npx --yes";
|
|
774
|
-
const command = localPath ? `${runner} codemod workflow run --allow-dirty -w ${localPath}/codemods/${variant}/${pluginId}` : `${runner} codemod --allow-dirty @makerkit/${variant}-${pluginId}`;
|
|
775
|
-
const { stdout, stderr } = await execaCommand3(command, {
|
|
776
|
-
stdio: options?.captureOutput ? "pipe" : "inherit",
|
|
777
|
-
timeout: CODEMOD_TIMEOUT_MS
|
|
778
|
-
});
|
|
779
|
-
return {
|
|
780
|
-
success: true,
|
|
781
|
-
output: stdout || stderr || ""
|
|
782
|
-
};
|
|
783
|
-
} catch (error) {
|
|
784
|
-
let message = "Unknown error during codemod";
|
|
785
|
-
if (error instanceof Error) {
|
|
786
|
-
message = error.message;
|
|
787
|
-
if ("stderr" in error && error.stderr) {
|
|
788
|
-
message += `
|
|
789
|
-
${error.stderr}`;
|
|
790
|
-
}
|
|
791
|
-
if ("timedOut" in error && error.timedOut) {
|
|
792
|
-
message = `Codemod timed out after ${CODEMOD_TIMEOUT_MS / 1e3}s (the workflow engine may have stalled after an error)`;
|
|
793
|
-
}
|
|
794
|
-
}
|
|
795
|
-
return {
|
|
796
|
-
success: false,
|
|
797
|
-
output: message
|
|
798
|
-
};
|
|
799
|
-
}
|
|
800
|
-
}
|
|
801
|
-
|
|
802
|
-
// src/utils/username-cache.ts
|
|
803
|
-
import { join as join7 } from "path";
|
|
804
|
-
import { tmpdir } from "os";
|
|
805
|
-
import fs7 from "fs-extra";
|
|
806
|
-
import prompts2 from "prompts";
|
|
807
|
-
var USERNAME_FILE = join7(tmpdir(), "makerkit-username");
|
|
808
|
-
function getCachedUsername() {
|
|
809
|
-
try {
|
|
810
|
-
const username = fs7.readFileSync(USERNAME_FILE, "utf-8").trim();
|
|
811
|
-
return username.length > 0 ? username : void 0;
|
|
812
|
-
} catch {
|
|
813
|
-
return void 0;
|
|
814
|
-
}
|
|
815
|
-
}
|
|
816
|
-
function cacheUsername(username) {
|
|
817
|
-
fs7.writeFileSync(USERNAME_FILE, username, "utf-8");
|
|
818
|
-
}
|
|
819
|
-
function clearCachedUsername() {
|
|
820
|
-
try {
|
|
821
|
-
fs7.removeSync(USERNAME_FILE);
|
|
822
|
-
} catch {
|
|
823
|
-
}
|
|
824
|
-
}
|
|
825
|
-
async function promptForUsername() {
|
|
826
|
-
const gitUsername = await getGitUsername();
|
|
827
|
-
const response = await prompts2({
|
|
828
|
-
type: "text",
|
|
829
|
-
name: "githubUsername",
|
|
830
|
-
message: "Enter the GitHub username registered with your Makerkit account",
|
|
831
|
-
initial: gitUsername,
|
|
832
|
-
validate: (value) => {
|
|
833
|
-
return value.trim().length > 0 ? true : "GitHub username is required";
|
|
834
|
-
}
|
|
835
|
-
});
|
|
836
|
-
const username = response.githubUsername?.trim();
|
|
837
|
-
if (!username) {
|
|
838
|
-
throw new Error("Setup cancelled. GitHub username is required.");
|
|
839
|
-
}
|
|
840
|
-
cacheUsername(username);
|
|
841
|
-
return username;
|
|
842
|
-
}
|
|
843
|
-
async function getOrPromptUsername(providedUsername) {
|
|
844
|
-
if (providedUsername?.trim()) {
|
|
845
|
-
const username = providedUsername.trim();
|
|
846
|
-
cacheUsername(username);
|
|
847
|
-
return username;
|
|
848
|
-
}
|
|
849
|
-
const cached = getCachedUsername();
|
|
850
|
-
if (cached) {
|
|
851
|
-
return cached;
|
|
852
|
-
}
|
|
853
|
-
return promptForUsername();
|
|
854
|
-
}
|
|
855
|
-
|
|
856
|
-
// src/utils/workspace.ts
|
|
857
|
-
import { join as join8 } from "path";
|
|
858
|
-
import fs8 from "fs-extra";
|
|
859
|
-
async function readDeps(pkgPath) {
|
|
860
|
-
if (!await fs8.pathExists(pkgPath)) {
|
|
861
|
-
return {};
|
|
862
|
-
}
|
|
863
|
-
const pkg = await fs8.readJson(pkgPath);
|
|
864
|
-
return {
|
|
865
|
-
...pkg.dependencies,
|
|
866
|
-
...pkg.devDependencies
|
|
867
|
-
};
|
|
868
|
-
}
|
|
869
|
-
async function detectVariant() {
|
|
870
|
-
const cwd = process.cwd();
|
|
871
|
-
const rootPkgPath = join8(cwd, "package.json");
|
|
872
|
-
if (!await fs8.pathExists(rootPkgPath)) {
|
|
873
|
-
throw new Error(
|
|
874
|
-
"No package.json found. Please run this command from a MakerKit project root."
|
|
875
|
-
);
|
|
876
|
-
}
|
|
877
|
-
const rootDeps = await readDeps(rootPkgPath);
|
|
878
|
-
if (!rootDeps["turbo"]) {
|
|
879
|
-
throw new Error(
|
|
880
|
-
'This does not appear to be a MakerKit Turbo monorepo. The "turbo" dependency was not found in package.json.'
|
|
881
|
-
);
|
|
882
|
-
}
|
|
883
|
-
const webDeps = await readDeps(join8(cwd, "apps", "web", "package.json"));
|
|
884
|
-
const dbDeps = await readDeps(
|
|
885
|
-
join8(cwd, "packages", "database", "package.json")
|
|
886
|
-
);
|
|
887
|
-
const hasSupabase = !!webDeps["@supabase/supabase-js"];
|
|
888
|
-
const hasReactRouter = !!webDeps["@react-router/node"];
|
|
889
|
-
const hasDrizzle = !!webDeps["drizzle-orm"] || !!dbDeps["drizzle-orm"];
|
|
890
|
-
const hasPrisma = !!webDeps["@prisma/client"] || !!dbDeps["@prisma/client"];
|
|
891
|
-
if (hasReactRouter && hasSupabase) {
|
|
892
|
-
return "react-router-supabase";
|
|
893
|
-
}
|
|
894
|
-
if (hasSupabase) {
|
|
895
|
-
return "next-supabase";
|
|
896
|
-
}
|
|
897
|
-
if (hasDrizzle) {
|
|
898
|
-
return "next-drizzle";
|
|
899
|
-
}
|
|
900
|
-
if (hasPrisma) {
|
|
901
|
-
return "next-prisma";
|
|
902
|
-
}
|
|
903
|
-
throw new Error(
|
|
904
|
-
"Unrecognized MakerKit project. Could not detect variant from dependencies."
|
|
905
|
-
);
|
|
906
|
-
}
|
|
907
|
-
async function validateProject() {
|
|
908
|
-
const variant = await detectVariant();
|
|
909
|
-
const rootPkg = await fs8.readJson(join8(process.cwd(), "package.json"));
|
|
910
|
-
return {
|
|
911
|
-
variant,
|
|
912
|
-
version: rootPkg.version ?? "unknown"
|
|
913
|
-
};
|
|
914
|
-
}
|
|
915
|
-
|
|
916
|
-
// src/utils/add-plugin.ts
|
|
917
|
-
async function addPlugin(options) {
|
|
918
|
-
if (!options.skipGitCheck) {
|
|
919
|
-
const gitClean = await isGitClean();
|
|
920
|
-
if (!gitClean) {
|
|
921
|
-
return {
|
|
922
|
-
success: false,
|
|
923
|
-
reason: "Git working directory has uncommitted changes. Please commit or stash them before adding a plugin."
|
|
924
|
-
};
|
|
925
|
-
}
|
|
926
|
-
}
|
|
927
|
-
const { variant } = await validateProject();
|
|
928
|
-
const username = options.githubUsername?.trim() || getCachedUsername();
|
|
929
|
-
if (!username) {
|
|
930
|
-
return {
|
|
931
|
-
success: false,
|
|
932
|
-
reason: "No GitHub username cached and none provided. Call makerkit_init_registry first or pass githubUsername."
|
|
933
|
-
};
|
|
934
|
-
}
|
|
935
|
-
cacheUsername(username);
|
|
936
|
-
const registry = await PluginRegistry.load();
|
|
937
|
-
const plugin = registry.validatePlugin(options.pluginId, variant);
|
|
938
|
-
if (await isInstalled(plugin, variant)) {
|
|
939
|
-
return {
|
|
940
|
-
success: false,
|
|
941
|
-
reason: `Plugin "${plugin.name}" is already installed.`
|
|
942
|
-
};
|
|
943
|
-
}
|
|
944
|
-
const item = await installRegistryFiles(variant, options.pluginId, username);
|
|
945
|
-
await saveBaseVersions(options.pluginId, item.files);
|
|
946
|
-
const codemodResult = await runCodemod(variant, options.pluginId, {
|
|
947
|
-
captureOutput: options.captureCodemodOutput ?? true
|
|
948
|
-
});
|
|
949
|
-
const envVars = getEnvVars(plugin, variant);
|
|
950
|
-
return {
|
|
951
|
-
success: true,
|
|
952
|
-
pluginName: plugin.name,
|
|
953
|
-
pluginId: plugin.id,
|
|
954
|
-
variant,
|
|
955
|
-
envVars: envVars.map((e) => ({ key: e.key, description: e.description })),
|
|
956
|
-
postInstallMessage: plugin.postInstallMessage ?? null,
|
|
957
|
-
codemodOutput: codemodResult.output,
|
|
958
|
-
codemodWarning: codemodResult.success ? void 0 : `The automated codemod did not complete successfully. Plugin files were installed but some wiring steps may have failed.
|
|
959
|
-
${codemodResult.output}`
|
|
960
|
-
};
|
|
961
|
-
}
|
|
962
|
-
|
|
963
|
-
// src/utils/list-plugins.ts
|
|
964
|
-
async function listPlugins(options) {
|
|
965
|
-
const variant = await detectVariant();
|
|
966
|
-
const registry = await PluginRegistry.load();
|
|
967
|
-
const plugins = registry.getPluginsForVariant(variant);
|
|
968
|
-
const pluginList = await Promise.all(
|
|
969
|
-
plugins.map(async (p) => ({
|
|
970
|
-
id: p.id,
|
|
971
|
-
name: p.name,
|
|
972
|
-
description: p.description,
|
|
973
|
-
installed: await isInstalled(p, variant),
|
|
974
|
-
envVars: getEnvVars(p, variant).map((e) => e.key),
|
|
975
|
-
postInstallMessage: p.postInstallMessage ?? null
|
|
976
|
-
}))
|
|
977
|
-
);
|
|
978
|
-
return { variant, plugins: pluginList };
|
|
979
|
-
}
|
|
980
|
-
|
|
981
|
-
// src/commands/plugins/add/add.command.ts
|
|
982
|
-
import chalk2 from "chalk";
|
|
983
|
-
import ora2 from "ora";
|
|
984
|
-
import prompts3 from "prompts";
|
|
985
|
-
function createAddCommand(parentCommand) {
|
|
986
|
-
return parentCommand.command("add").argument("[plugin-id...]", "Plugins to install (e.g. feedback waitlist)").description("Install one or more MakerKit plugins.").action(async (pluginIds) => {
|
|
987
|
-
try {
|
|
988
|
-
const gitClean = await isGitClean();
|
|
989
|
-
if (!gitClean) {
|
|
990
|
-
console.error(
|
|
991
|
-
chalk2.red(
|
|
992
|
-
"Your git working directory has uncommitted changes. Please commit or stash them before adding a plugin."
|
|
993
|
-
)
|
|
994
|
-
);
|
|
995
|
-
process.exit(1);
|
|
996
|
-
}
|
|
997
|
-
if (!pluginIds || pluginIds.length === 0) {
|
|
998
|
-
const pluginsResult = await listPlugins({ projectPath: process.cwd() });
|
|
999
|
-
const available = pluginsResult.plugins.filter((p) => !p.installed);
|
|
1000
|
-
if (available.length === 0) {
|
|
1001
|
-
console.log(chalk2.green("All plugins are already installed."));
|
|
1002
|
-
return;
|
|
1003
|
-
}
|
|
1004
|
-
const response = await prompts3({
|
|
1005
|
-
type: "multiselect",
|
|
1006
|
-
name: "pluginIds",
|
|
1007
|
-
message: "Select plugins to install",
|
|
1008
|
-
choices: available.map((p) => ({
|
|
1009
|
-
title: `${p.name} ${chalk2.gray(`(${p.id})`)}`,
|
|
1010
|
-
value: p.id
|
|
1011
|
-
}))
|
|
1012
|
-
});
|
|
1013
|
-
pluginIds = response.pluginIds ?? [];
|
|
1014
|
-
if (pluginIds.length === 0) {
|
|
1015
|
-
return;
|
|
1016
|
-
}
|
|
1017
|
-
}
|
|
1018
|
-
let username = await getOrPromptUsername();
|
|
1019
|
-
for (const pluginId of pluginIds) {
|
|
1020
|
-
console.log(
|
|
1021
|
-
`
|
|
1022
|
-
Installing ${chalk2.cyan(pluginId)}...
|
|
1023
|
-
`
|
|
1024
|
-
);
|
|
1025
|
-
const filesSpinner = ora2("Installing plugin...").start();
|
|
1026
|
-
let result;
|
|
1027
|
-
try {
|
|
1028
|
-
result = await addPlugin({
|
|
1029
|
-
projectPath: process.cwd(),
|
|
1030
|
-
pluginId,
|
|
1031
|
-
githubUsername: username,
|
|
1032
|
-
skipGitCheck: true,
|
|
1033
|
-
captureCodemodOutput: false
|
|
1034
|
-
});
|
|
1035
|
-
} catch (error) {
|
|
1036
|
-
filesSpinner.fail("Failed to install plugin.");
|
|
1037
|
-
clearCachedUsername();
|
|
1038
|
-
console.log(
|
|
1039
|
-
chalk2.yellow("\nRetrying with a different username...\n")
|
|
1040
|
-
);
|
|
1041
|
-
username = await getOrPromptUsername();
|
|
1042
|
-
const retrySpinner = ora2("Installing plugin...").start();
|
|
1043
|
-
try {
|
|
1044
|
-
result = await addPlugin({
|
|
1045
|
-
projectPath: process.cwd(),
|
|
1046
|
-
pluginId,
|
|
1047
|
-
githubUsername: username,
|
|
1048
|
-
skipGitCheck: true,
|
|
1049
|
-
captureCodemodOutput: false
|
|
1050
|
-
});
|
|
1051
|
-
} catch (retryError) {
|
|
1052
|
-
retrySpinner.fail("Failed to install plugin.");
|
|
1053
|
-
const message = retryError instanceof Error ? retryError.message : "Unknown error";
|
|
1054
|
-
console.error(chalk2.red(`
|
|
1055
|
-
Error installing "${pluginId}": ${message}`));
|
|
1056
|
-
console.log(
|
|
1057
|
-
chalk2.yellow(
|
|
1058
|
-
"\nTo revert changes, run: git checkout . && git clean -fd"
|
|
1059
|
-
)
|
|
1060
|
-
);
|
|
1061
|
-
process.exit(1);
|
|
1062
|
-
}
|
|
1063
|
-
if (result.success) {
|
|
1064
|
-
retrySpinner.succeed("Plugin installed.");
|
|
1065
|
-
} else {
|
|
1066
|
-
retrySpinner.stop();
|
|
1067
|
-
}
|
|
1068
|
-
}
|
|
1069
|
-
if (!result.success) {
|
|
1070
|
-
if (result.reason.includes("already installed")) {
|
|
1071
|
-
filesSpinner.warn(result.reason + " Skipping.");
|
|
1072
|
-
continue;
|
|
1073
|
-
}
|
|
1074
|
-
filesSpinner.fail("Failed to install plugin.");
|
|
1075
|
-
console.error(chalk2.red(`
|
|
1076
|
-
${result.reason}`));
|
|
1077
|
-
console.log(
|
|
1078
|
-
chalk2.yellow(
|
|
1079
|
-
"\nTo revert changes, run: git checkout . && git clean -fd"
|
|
1080
|
-
)
|
|
1081
|
-
);
|
|
1082
|
-
process.exit(1);
|
|
1083
|
-
}
|
|
1084
|
-
if (result.codemodWarning) {
|
|
1085
|
-
filesSpinner.warn(
|
|
1086
|
-
`${result.pluginName} installed with warnings \u2014 some automated steps may not have completed.`
|
|
1087
|
-
);
|
|
1088
|
-
console.log(chalk2.yellow(`
|
|
1089
|
-
${result.codemodWarning}`));
|
|
1090
|
-
console.log(
|
|
1091
|
-
chalk2.yellow(
|
|
1092
|
-
"\nPlugin files were written successfully. Review the changes with `git diff` and complete any missing steps manually."
|
|
1093
|
-
)
|
|
1094
|
-
);
|
|
1095
|
-
} else if (filesSpinner.isSpinning) {
|
|
1096
|
-
filesSpinner.succeed(`${result.pluginName} installed successfully!`);
|
|
1097
|
-
}
|
|
1098
|
-
if (result.envVars.length > 0) {
|
|
1099
|
-
console.log(chalk2.white("\nEnvironment variables to configure:"));
|
|
1100
|
-
for (const envVar of result.envVars) {
|
|
1101
|
-
console.log(
|
|
1102
|
-
` ${chalk2.cyan(envVar.key)} - ${envVar.description}`
|
|
1103
|
-
);
|
|
1104
|
-
}
|
|
1105
|
-
}
|
|
1106
|
-
if (result.postInstallMessage) {
|
|
1107
|
-
console.log(chalk2.white("\nNext steps:"));
|
|
1108
|
-
console.log(` ${chalk2.cyan(result.postInstallMessage)}`);
|
|
1109
|
-
}
|
|
1110
|
-
}
|
|
1111
|
-
console.log("");
|
|
1112
|
-
console.log(chalk2.yellow("Important:"));
|
|
1113
|
-
console.log(
|
|
1114
|
-
chalk2.yellow(
|
|
1115
|
-
" This plugin was installed using an automated migration."
|
|
1116
|
-
)
|
|
1117
|
-
);
|
|
1118
|
-
console.log(
|
|
1119
|
-
chalk2.yellow(
|
|
1120
|
-
" Please review the changes manually and test thoroughly before committing."
|
|
1121
|
-
)
|
|
1122
|
-
);
|
|
1123
|
-
console.log("");
|
|
1124
|
-
console.log(chalk2.white("Tips:"));
|
|
1125
|
-
console.log(
|
|
1126
|
-
` ${chalk2.gray("-")} Run ${chalk2.cyan("git diff")} to review all changes made by the migration.`
|
|
1127
|
-
);
|
|
1128
|
-
console.log(
|
|
1129
|
-
` ${chalk2.gray("-")} Use an AI assistant (e.g. Claude) as a first pass to review the diff for issues.`
|
|
1130
|
-
);
|
|
1131
|
-
console.log(
|
|
1132
|
-
` ${chalk2.gray("-")} Run your test suite and verify the app builds before committing.`
|
|
1133
|
-
);
|
|
1134
|
-
console.log(
|
|
1135
|
-
` ${chalk2.gray("-")} To undo all changes: ${chalk2.cyan("git checkout . && git clean -fd")}`
|
|
1136
|
-
);
|
|
1137
|
-
console.log("");
|
|
1138
|
-
} catch (error) {
|
|
1139
|
-
const message = error instanceof Error ? error.message : "Unknown error";
|
|
1140
|
-
console.error(chalk2.red(`Error: ${message}`));
|
|
1141
|
-
console.log(
|
|
1142
|
-
chalk2.yellow(
|
|
1143
|
-
"\nTo revert changes, run: git checkout . && git clean -fd"
|
|
1144
|
-
)
|
|
1145
|
-
);
|
|
1146
|
-
process.exit(1);
|
|
1147
|
-
}
|
|
1148
|
-
});
|
|
1149
|
-
}
|
|
1150
|
-
|
|
1151
|
-
// src/commands/plugins/diff/diff.command.ts
|
|
1152
|
-
import { dirname as dirname3, join as join9 } from "path";
|
|
1153
|
-
import { tmpdir as tmpdir2 } from "os";
|
|
1154
|
-
import chalk3 from "chalk";
|
|
1155
|
-
import { execa as execa2 } from "execa";
|
|
1156
|
-
import fs9 from "fs-extra";
|
|
1157
|
-
import ora3 from "ora";
|
|
1158
|
-
import prompts4 from "prompts";
|
|
1159
|
-
function createDiffCommand(parentCommand) {
|
|
1160
|
-
return parentCommand.command("diff").argument("[plugin-id]", "Plugin to diff (e.g. feedback, waitlist)").description("Show differences between installed plugin files and the latest registry version.").action(async (pluginId) => {
|
|
1161
|
-
try {
|
|
1162
|
-
const { variant } = await validateProject();
|
|
1163
|
-
const registry = await PluginRegistry.load();
|
|
1164
|
-
if (!pluginId) {
|
|
1165
|
-
const plugins = registry.getPluginsForVariant(variant);
|
|
1166
|
-
const installed = [];
|
|
1167
|
-
for (const p of plugins) {
|
|
1168
|
-
if (await isInstalled(p, variant)) {
|
|
1169
|
-
installed.push(p);
|
|
1170
|
-
}
|
|
1171
|
-
}
|
|
1172
|
-
if (installed.length === 0) {
|
|
1173
|
-
console.log(chalk3.yellow("No plugins installed."));
|
|
1174
|
-
return;
|
|
1175
|
-
}
|
|
1176
|
-
const response = await prompts4({
|
|
1177
|
-
type: "select",
|
|
1178
|
-
name: "pluginId",
|
|
1179
|
-
message: "Select a plugin to diff",
|
|
1180
|
-
choices: installed.map((p) => ({
|
|
1181
|
-
title: `${p.name} ${chalk3.gray(`(${p.id})`)}`,
|
|
1182
|
-
value: p.id
|
|
1183
|
-
}))
|
|
1184
|
-
});
|
|
1185
|
-
pluginId = response.pluginId;
|
|
1186
|
-
if (!pluginId) {
|
|
1187
|
-
return;
|
|
1188
|
-
}
|
|
1189
|
-
}
|
|
1190
|
-
const plugin = registry.validatePlugin(pluginId, variant);
|
|
1191
|
-
if (!await isInstalled(plugin, variant)) {
|
|
1192
|
-
console.error(
|
|
1193
|
-
chalk3.yellow(`Plugin "${plugin.name}" is not installed.`)
|
|
1194
|
-
);
|
|
1195
|
-
return;
|
|
1196
|
-
}
|
|
1197
|
-
const username = await getOrPromptUsername();
|
|
1198
|
-
const spinner = ora3("Fetching latest plugin files...").start();
|
|
1199
|
-
const item = await fetchRegistryItem(variant, pluginId, username);
|
|
1200
|
-
spinner.succeed("Fetched latest plugin files.");
|
|
1201
|
-
const tempDir = join9(tmpdir2(), `makerkit-diff-${pluginId}`);
|
|
1202
|
-
await fs9.ensureDir(tempDir);
|
|
1203
|
-
try {
|
|
1204
|
-
const cwd = process.cwd();
|
|
1205
|
-
let hasDiff = false;
|
|
1206
|
-
for (const file of item.files) {
|
|
1207
|
-
const localPath = join9(cwd, file.target);
|
|
1208
|
-
const remotePath = join9(tempDir, file.target);
|
|
1209
|
-
await fs9.ensureDir(dirname3(join9(tempDir, file.target)));
|
|
1210
|
-
await fs9.writeFile(remotePath, file.content);
|
|
1211
|
-
if (!await fs9.pathExists(localPath)) {
|
|
1212
|
-
console.log(chalk3.green(`
|
|
1213
|
-
New file: ${file.target}`));
|
|
1214
|
-
hasDiff = true;
|
|
1215
|
-
continue;
|
|
1216
|
-
}
|
|
1217
|
-
const localContent = await fs9.readFile(localPath, "utf-8");
|
|
1218
|
-
if (localContent !== file.content) {
|
|
1219
|
-
hasDiff = true;
|
|
1220
|
-
console.log(chalk3.white(`
|
|
1221
|
-
--- ${file.target}`));
|
|
1222
|
-
await execa2("git", ["diff", "--no-index", "--color", "--", localPath, remotePath], {
|
|
1223
|
-
stdio: "inherit",
|
|
1224
|
-
reject: false
|
|
1225
|
-
});
|
|
1226
|
-
}
|
|
1227
|
-
}
|
|
1228
|
-
if (!hasDiff) {
|
|
1229
|
-
console.log(
|
|
1230
|
-
chalk3.green(`
|
|
1231
|
-
${plugin.name} is up to date.`)
|
|
1232
|
-
);
|
|
1233
|
-
}
|
|
1234
|
-
} finally {
|
|
1235
|
-
await fs9.remove(tempDir);
|
|
1236
|
-
}
|
|
1237
|
-
} catch (error) {
|
|
1238
|
-
const message = error instanceof Error ? error.message : "Unknown error";
|
|
1239
|
-
console.error(chalk3.red(`Error: ${message}`));
|
|
1240
|
-
process.exit(1);
|
|
1241
|
-
}
|
|
1242
|
-
});
|
|
1243
|
-
}
|
|
1244
|
-
|
|
1245
|
-
// src/utils/init-registry.ts
|
|
1246
|
-
async function initRegistry(options) {
|
|
1247
|
-
const variant = await detectVariant();
|
|
1248
|
-
cacheUsername(options.githubUsername);
|
|
1249
|
-
return {
|
|
1250
|
-
success: true,
|
|
1251
|
-
variant,
|
|
1252
|
-
username: options.githubUsername
|
|
1253
|
-
};
|
|
1254
|
-
}
|
|
1255
|
-
|
|
1256
|
-
// src/commands/plugins/init/init.command.ts
|
|
1257
|
-
import chalk4 from "chalk";
|
|
1258
|
-
function createInitCommand(parentCommand) {
|
|
1259
|
-
return parentCommand.command("init").description(
|
|
1260
|
-
"Initialize MakerKit plugin registry in your project (one-time setup)."
|
|
1261
|
-
).action(async () => {
|
|
1262
|
-
try {
|
|
1263
|
-
const username = await getOrPromptUsername();
|
|
1264
|
-
const initResult = await initRegistry({
|
|
1265
|
-
projectPath: process.cwd(),
|
|
1266
|
-
githubUsername: username
|
|
1267
|
-
});
|
|
1268
|
-
console.log(
|
|
1269
|
-
`Detected project variant: ${chalk4.cyan(initResult.variant)}
|
|
1270
|
-
`
|
|
1271
|
-
);
|
|
1272
|
-
console.log(chalk4.green("Registry configured.\n"));
|
|
1273
|
-
const pluginsResult = await listPlugins({ projectPath: process.cwd() });
|
|
1274
|
-
console.log(chalk4.white("Available plugins:\n"));
|
|
1275
|
-
for (const plugin of pluginsResult.plugins) {
|
|
1276
|
-
console.log(
|
|
1277
|
-
` ${chalk4.green(plugin.name)} ${chalk4.gray(`(${plugin.id})`)}`
|
|
1278
|
-
);
|
|
1279
|
-
}
|
|
1280
|
-
console.log(
|
|
1281
|
-
`
|
|
1282
|
-
Run ${chalk4.cyan("makerkit plugins add <plugin-id>")} to install a plugin.`
|
|
1283
|
-
);
|
|
1284
|
-
} catch (error) {
|
|
1285
|
-
const message = error instanceof Error ? error.message : "Unknown error";
|
|
1286
|
-
console.error(chalk4.red(`Error: ${message}`));
|
|
1287
|
-
process.exit(1);
|
|
1288
|
-
}
|
|
1289
|
-
});
|
|
1290
|
-
}
|
|
1291
|
-
|
|
1292
|
-
// src/commands/plugins/list/list-plugins.command.ts
|
|
1293
|
-
import chalk5 from "chalk";
|
|
1294
|
-
function createListPluginsCommand(parentCommand) {
|
|
1295
|
-
return parentCommand.command("list").description("List available and installed plugins.").action(async () => {
|
|
1296
|
-
const result = await listPlugins({ projectPath: process.cwd() });
|
|
1297
|
-
console.log(
|
|
1298
|
-
chalk5.white(`MakerKit Plugins ${chalk5.gray(`(${result.variant})`)}
|
|
1299
|
-
`)
|
|
1300
|
-
);
|
|
1301
|
-
console.log(
|
|
1302
|
-
` ${chalk5.green("Plugin Name")} ${chalk5.gray("(plugin-id)")} \u2014 Status
|
|
1303
|
-
`
|
|
1304
|
-
);
|
|
1305
|
-
let installedCount = 0;
|
|
1306
|
-
for (const plugin of result.plugins) {
|
|
1307
|
-
if (plugin.installed) {
|
|
1308
|
-
installedCount++;
|
|
1309
|
-
}
|
|
1310
|
-
const status = plugin.installed ? chalk5.green("installed") : chalk5.gray("available");
|
|
1311
|
-
console.log(
|
|
1312
|
-
` ${chalk5.cyan(plugin.name)} ${chalk5.gray(`(${plugin.id})`)} \u2014 ${status}`
|
|
1313
|
-
);
|
|
1314
|
-
}
|
|
1315
|
-
console.log(
|
|
1316
|
-
`
|
|
1317
|
-
${chalk5.white(`${installedCount} installed`)} / ${chalk5.gray(`${result.plugins.length} available`)}
|
|
1318
|
-
`
|
|
1319
|
-
);
|
|
1320
|
-
if (installedCount === 0) {
|
|
1321
|
-
console.log(
|
|
1322
|
-
`Run ${chalk5.cyan("makerkit plugins init")} to set up the registry, then ${chalk5.cyan("makerkit plugins add <plugin-id>")} to install.`
|
|
1323
|
-
);
|
|
1324
|
-
}
|
|
1325
|
-
});
|
|
1326
|
-
}
|
|
1327
|
-
|
|
1328
|
-
// src/commands/plugins/outdated/outdated.command.ts
|
|
1329
|
-
import { join as join10 } from "path";
|
|
1330
|
-
import chalk6 from "chalk";
|
|
1331
|
-
import fs10 from "fs-extra";
|
|
1332
|
-
import ora4 from "ora";
|
|
1333
|
-
async function isOutdated(plugin, variant, username) {
|
|
1334
|
-
const item = await fetchRegistryItem(variant, plugin.id, username);
|
|
1335
|
-
const cwd = process.cwd();
|
|
1336
|
-
for (const file of item.files) {
|
|
1337
|
-
const localPath = join10(cwd, file.target);
|
|
1338
|
-
if (!await fs10.pathExists(localPath)) {
|
|
1339
|
-
return true;
|
|
1340
|
-
}
|
|
1341
|
-
const localContent = await fs10.readFile(localPath, "utf-8");
|
|
1342
|
-
if (localContent !== file.content) {
|
|
1343
|
-
return true;
|
|
1344
|
-
}
|
|
1345
|
-
}
|
|
1346
|
-
return false;
|
|
1347
|
-
}
|
|
1348
|
-
function createOutdatedCommand(parentCommand) {
|
|
1349
|
-
return parentCommand.command("outdated").description("Check installed plugins for updates.").action(async () => {
|
|
1350
|
-
try {
|
|
1351
|
-
const { variant } = await validateProject();
|
|
1352
|
-
const registry = await PluginRegistry.load();
|
|
1353
|
-
const plugins = registry.getPluginsForVariant(variant);
|
|
1354
|
-
const installed = [];
|
|
1355
|
-
for (const p of plugins) {
|
|
1356
|
-
if (await isInstalled(p, variant)) {
|
|
1357
|
-
installed.push(p);
|
|
1358
|
-
}
|
|
1359
|
-
}
|
|
1360
|
-
if (installed.length === 0) {
|
|
1361
|
-
console.log(chalk6.yellow("No plugins installed."));
|
|
1362
|
-
return;
|
|
1363
|
-
}
|
|
1364
|
-
const username = await getOrPromptUsername();
|
|
1365
|
-
const spinner = ora4(
|
|
1366
|
-
`Checking ${installed.length} plugin${installed.length > 1 ? "s" : ""} for updates...`
|
|
1367
|
-
).start();
|
|
1368
|
-
const outdated = [];
|
|
1369
|
-
for (const plugin of installed) {
|
|
1370
|
-
try {
|
|
1371
|
-
if (await isOutdated(plugin, variant, username)) {
|
|
1372
|
-
outdated.push(plugin);
|
|
1373
|
-
}
|
|
1374
|
-
} catch {
|
|
1375
|
-
}
|
|
1376
|
-
}
|
|
1377
|
-
spinner.stop();
|
|
1378
|
-
if (outdated.length === 0) {
|
|
1379
|
-
console.log(chalk6.green("All plugins are up to date."));
|
|
1380
|
-
return;
|
|
1381
|
-
}
|
|
1382
|
-
console.log(
|
|
1383
|
-
chalk6.yellow(
|
|
1384
|
-
`
|
|
1385
|
-
${outdated.length} plugin${outdated.length > 1 ? "s have" : " has"} updates available:
|
|
1386
|
-
`
|
|
1387
|
-
)
|
|
1388
|
-
);
|
|
1389
|
-
for (const plugin of outdated) {
|
|
1390
|
-
const pluginPath = getPath(plugin, variant);
|
|
1391
|
-
console.log(
|
|
1392
|
-
` ${chalk6.cyan(plugin.name)} ${chalk6.gray(`(${plugin.id})`)}${pluginPath ? chalk6.gray(` \u2014 ${pluginPath}`) : ""}`
|
|
1393
|
-
);
|
|
1394
|
-
}
|
|
1395
|
-
console.log(
|
|
1396
|
-
`
|
|
1397
|
-
Run ${chalk6.cyan("makerkit plugins diff <plugin-id>")} to see what changed.`
|
|
1398
|
-
);
|
|
1399
|
-
} catch (error) {
|
|
1400
|
-
const message = error instanceof Error ? error.message : "Unknown error";
|
|
1401
|
-
console.error(chalk6.red(`Error: ${message}`));
|
|
1402
|
-
process.exit(1);
|
|
1403
|
-
}
|
|
1404
|
-
});
|
|
1405
|
-
}
|
|
1406
|
-
|
|
1407
|
-
// src/commands/plugins/update/update.command.ts
|
|
1408
|
-
import { dirname as dirname4, join as join11 } from "path";
|
|
1409
|
-
import chalk7 from "chalk";
|
|
1410
|
-
import fs11 from "fs-extra";
|
|
1411
|
-
import ora5 from "ora";
|
|
1412
|
-
import prompts5 from "prompts";
|
|
1413
|
-
function createUpdateCommand(parentCommand) {
|
|
1414
|
-
return parentCommand.command("update").argument("[plugin-id...]", "Plugins to update (e.g. feedback waitlist)").description("Update installed plugins to the latest registry version.").action(async (pluginIds) => {
|
|
1415
|
-
try {
|
|
1416
|
-
const { variant } = await validateProject();
|
|
1417
|
-
const registry = await PluginRegistry.load();
|
|
1418
|
-
if (!pluginIds || pluginIds.length === 0) {
|
|
1419
|
-
const plugins = registry.getPluginsForVariant(variant);
|
|
1420
|
-
const installed = [];
|
|
1421
|
-
for (const p of plugins) {
|
|
1422
|
-
if (await isInstalled(p, variant)) {
|
|
1423
|
-
installed.push(p);
|
|
1424
|
-
}
|
|
1425
|
-
}
|
|
1426
|
-
if (installed.length === 0) {
|
|
1427
|
-
console.log(chalk7.yellow("No plugins installed."));
|
|
1428
|
-
return;
|
|
1429
|
-
}
|
|
1430
|
-
const response = await prompts5({
|
|
1431
|
-
type: "multiselect",
|
|
1432
|
-
name: "pluginIds",
|
|
1433
|
-
message: "Select plugins to update",
|
|
1434
|
-
choices: installed.map((p) => ({
|
|
1435
|
-
title: `${p.name} ${chalk7.gray(`(${p.id})`)}`,
|
|
1436
|
-
value: p.id
|
|
1437
|
-
}))
|
|
1438
|
-
});
|
|
1439
|
-
pluginIds = response.pluginIds ?? [];
|
|
1440
|
-
if (pluginIds.length === 0) {
|
|
1441
|
-
return;
|
|
1442
|
-
}
|
|
1443
|
-
}
|
|
1444
|
-
const username = await getOrPromptUsername();
|
|
1445
|
-
for (const pluginId of pluginIds) {
|
|
1446
|
-
const plugin = registry.validatePlugin(pluginId, variant);
|
|
1447
|
-
if (!await isInstalled(plugin, variant)) {
|
|
1448
|
-
console.log(
|
|
1449
|
-
chalk7.yellow(
|
|
1450
|
-
`Plugin "${plugin.name}" is not installed. Use "plugins add ${pluginId}" to install it.`
|
|
1451
|
-
)
|
|
1452
|
-
);
|
|
1453
|
-
continue;
|
|
1454
|
-
}
|
|
1455
|
-
const spinner = ora5(`Fetching latest ${plugin.name} files...`).start();
|
|
1456
|
-
const item = await fetchRegistryItem(variant, pluginId, username);
|
|
1457
|
-
spinner.succeed(`Fetched latest ${plugin.name} files.`);
|
|
1458
|
-
const cwd = process.cwd();
|
|
1459
|
-
const modifiedFiles = [];
|
|
1460
|
-
for (const file of item.files) {
|
|
1461
|
-
const localPath = join11(cwd, file.target);
|
|
1462
|
-
if (await fs11.pathExists(localPath)) {
|
|
1463
|
-
const localContent = await fs11.readFile(localPath, "utf-8");
|
|
1464
|
-
if (localContent !== file.content) {
|
|
1465
|
-
modifiedFiles.push(file.target);
|
|
1466
|
-
}
|
|
1467
|
-
}
|
|
1468
|
-
}
|
|
1469
|
-
if (modifiedFiles.length === 0) {
|
|
1470
|
-
console.log(chalk7.green(`${plugin.name} is already up to date.`));
|
|
1471
|
-
continue;
|
|
1472
|
-
}
|
|
1473
|
-
console.log(
|
|
1474
|
-
chalk7.yellow(
|
|
1475
|
-
`
|
|
1476
|
-
${modifiedFiles.length} file${modifiedFiles.length > 1 ? "s" : ""} will be overwritten:`
|
|
1477
|
-
)
|
|
1478
|
-
);
|
|
1479
|
-
for (const file of modifiedFiles) {
|
|
1480
|
-
console.log(` ${chalk7.gray(file)}`);
|
|
1481
|
-
}
|
|
1482
|
-
const { confirm } = await prompts5({
|
|
1483
|
-
type: "confirm",
|
|
1484
|
-
name: "confirm",
|
|
1485
|
-
message: `Update ${plugin.name}? Local changes will be lost.`,
|
|
1486
|
-
initial: false
|
|
1487
|
-
});
|
|
1488
|
-
if (!confirm) {
|
|
1489
|
-
console.log(chalk7.gray(`Skipped ${plugin.name}.`));
|
|
1490
|
-
continue;
|
|
1491
|
-
}
|
|
1492
|
-
const writeSpinner = ora5(`Updating ${plugin.name}...`).start();
|
|
1493
|
-
for (const file of item.files) {
|
|
1494
|
-
const targetPath = join11(cwd, file.target);
|
|
1495
|
-
await fs11.ensureDir(dirname4(targetPath));
|
|
1496
|
-
await fs11.writeFile(targetPath, file.content);
|
|
1497
|
-
}
|
|
1498
|
-
await saveBaseVersions(pluginId, item.files);
|
|
1499
|
-
writeSpinner.succeed(`${plugin.name} updated.`);
|
|
1500
|
-
}
|
|
1501
|
-
} catch (error) {
|
|
1502
|
-
const message = error instanceof Error ? error.message : "Unknown error";
|
|
1503
|
-
console.error(chalk7.red(`Error: ${message}`));
|
|
1504
|
-
process.exit(1);
|
|
1505
|
-
}
|
|
1506
|
-
});
|
|
1507
|
-
}
|
|
1508
|
-
|
|
1509
|
-
// src/commands/plugins/plugins.command.ts
|
|
1510
|
-
import { Command as Command2 } from "commander";
|
|
1511
|
-
var pluginsCommand = new Command2().name("plugins").description("Manage MakerKit plugins.");
|
|
1512
|
-
createInitCommand(pluginsCommand);
|
|
1513
|
-
createAddCommand(pluginsCommand);
|
|
1514
|
-
createUpdateCommand(pluginsCommand);
|
|
1515
|
-
createDiffCommand(pluginsCommand);
|
|
1516
|
-
createOutdatedCommand(pluginsCommand);
|
|
1517
|
-
createListPluginsCommand(pluginsCommand);
|
|
1518
|
-
|
|
1519
|
-
// src/utils/project-pull.ts
|
|
1520
|
-
import { join as join12 } from "path";
|
|
1521
|
-
import { execa as execa3, execaCommand as execaCommand4 } from "execa";
|
|
1522
|
-
import fs12 from "fs-extra";
|
|
1523
|
-
async function projectPull(options) {
|
|
1524
|
-
const { variant } = await validateProject();
|
|
1525
|
-
const gitClean = await isGitClean();
|
|
1526
|
-
if (!gitClean) {
|
|
1527
|
-
return {
|
|
1528
|
-
success: false,
|
|
1529
|
-
reason: "Git working directory has uncommitted changes. Please commit or stash them before pulling upstream updates."
|
|
1530
|
-
};
|
|
1531
|
-
}
|
|
1532
|
-
let currentUrl = await getUpstreamRemoteUrl();
|
|
1533
|
-
if (!currentUrl) {
|
|
1534
|
-
const useSsh = await hasSshAccess();
|
|
1535
|
-
const url = getUpstreamUrl(variant, useSsh);
|
|
1536
|
-
await setUpstreamRemote(url);
|
|
1537
|
-
currentUrl = url;
|
|
1538
|
-
} else if (!isUpstreamUrlValid(currentUrl, variant)) {
|
|
1539
|
-
const useSsh = currentUrl.startsWith("git@");
|
|
1540
|
-
const expectedUrl = getUpstreamUrl(variant, useSsh);
|
|
1541
|
-
return {
|
|
1542
|
-
success: false,
|
|
1543
|
-
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>`
|
|
1544
|
-
};
|
|
1545
|
-
}
|
|
1546
|
-
await execaCommand4("git fetch upstream");
|
|
1547
|
-
try {
|
|
1548
|
-
const { stdout } = await execaCommand4(
|
|
1549
|
-
"git merge upstream/main --no-edit"
|
|
1550
|
-
);
|
|
1551
|
-
const alreadyUpToDate = stdout.includes("Already up to date");
|
|
1552
|
-
return {
|
|
1553
|
-
success: true,
|
|
1554
|
-
variant,
|
|
1555
|
-
upstreamUrl: currentUrl,
|
|
1556
|
-
alreadyUpToDate,
|
|
1557
|
-
message: alreadyUpToDate ? "Already up to date." : "Successfully merged upstream changes."
|
|
1558
|
-
};
|
|
1559
|
-
} catch (mergeError) {
|
|
1560
|
-
const output = getErrorOutput(mergeError);
|
|
1561
|
-
const isConflict = output.includes("CONFLICT") || output.includes("Automatic merge failed");
|
|
1562
|
-
if (!isConflict) {
|
|
1563
|
-
throw new Error(`Merge failed: ${output}`);
|
|
1564
|
-
}
|
|
1565
|
-
const { stdout: statusOutput } = await execaCommand4(
|
|
1566
|
-
"git diff --name-only --diff-filter=U"
|
|
1567
|
-
);
|
|
1568
|
-
const conflictPaths = statusOutput.trim().split("\n").filter(Boolean);
|
|
1569
|
-
const cwd = process.cwd();
|
|
1570
|
-
const conflicts = await Promise.all(
|
|
1571
|
-
conflictPaths.map(async (filePath) => {
|
|
1572
|
-
let conflicted;
|
|
1573
|
-
try {
|
|
1574
|
-
conflicted = await fs12.readFile(join12(cwd, filePath), "utf-8");
|
|
1575
|
-
} catch {
|
|
1576
|
-
conflicted = void 0;
|
|
1577
|
-
}
|
|
1578
|
-
let base;
|
|
1579
|
-
let ours;
|
|
1580
|
-
let theirs;
|
|
1581
|
-
try {
|
|
1582
|
-
const { stdout: b } = await execa3("git", [
|
|
1583
|
-
"show",
|
|
1584
|
-
`:1:${filePath}`
|
|
1585
|
-
]);
|
|
1586
|
-
base = b;
|
|
1587
|
-
} catch {
|
|
1588
|
-
base = void 0;
|
|
1589
|
-
}
|
|
1590
|
-
try {
|
|
1591
|
-
const { stdout: o } = await execa3("git", [
|
|
1592
|
-
"show",
|
|
1593
|
-
`:2:${filePath}`
|
|
1594
|
-
]);
|
|
1595
|
-
ours = o;
|
|
1596
|
-
} catch {
|
|
1597
|
-
ours = void 0;
|
|
1598
|
-
}
|
|
1599
|
-
try {
|
|
1600
|
-
const { stdout: t } = await execa3("git", [
|
|
1601
|
-
"show",
|
|
1602
|
-
`:3:${filePath}`
|
|
1603
|
-
]);
|
|
1604
|
-
theirs = t;
|
|
1605
|
-
} catch {
|
|
1606
|
-
theirs = void 0;
|
|
1607
|
-
}
|
|
1608
|
-
return { path: filePath, conflicted, base, ours, theirs };
|
|
1609
|
-
})
|
|
1610
|
-
);
|
|
1611
|
-
return {
|
|
1612
|
-
success: false,
|
|
1613
|
-
variant,
|
|
1614
|
-
upstreamUrl: currentUrl,
|
|
1615
|
-
hasConflicts: true,
|
|
1616
|
-
conflictCount: conflicts.length,
|
|
1617
|
-
conflicts,
|
|
1618
|
-
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."
|
|
1619
|
-
};
|
|
1620
|
-
}
|
|
1621
|
-
}
|
|
1622
|
-
|
|
1623
|
-
// src/commands/project/update/update.command.ts
|
|
1624
|
-
import chalk8 from "chalk";
|
|
1625
|
-
import ora6 from "ora";
|
|
1626
|
-
function createProjectUpdateCommand(parentCommand) {
|
|
1627
|
-
return parentCommand.command("update").description(
|
|
1628
|
-
"Pull the latest changes from the upstream MakerKit repository."
|
|
1629
|
-
).action(async () => {
|
|
1630
|
-
try {
|
|
1631
|
-
const spinner = ora6("Pulling latest changes from upstream...").start();
|
|
1632
|
-
const result = await projectPull({ projectPath: process.cwd() });
|
|
1633
|
-
if (result.success) {
|
|
1634
|
-
const displayName = VARIANT_CATALOG.find((v) => v.id === result.variant)?.name ?? result.variant;
|
|
1635
|
-
if (result.alreadyUpToDate) {
|
|
1636
|
-
spinner.succeed(
|
|
1637
|
-
`Already up to date. (${chalk8.cyan(displayName)})`
|
|
1638
|
-
);
|
|
1639
|
-
} else {
|
|
1640
|
-
spinner.succeed(
|
|
1641
|
-
`Successfully pulled latest changes from upstream. (${chalk8.cyan(displayName)})`
|
|
1642
|
-
);
|
|
1643
|
-
}
|
|
1644
|
-
} else if ("hasConflicts" in result) {
|
|
1645
|
-
spinner.fail("Merge conflicts detected.");
|
|
1646
|
-
console.log(
|
|
1647
|
-
chalk8.yellow(
|
|
1648
|
-
`
|
|
1649
|
-
${result.conflictCount} conflicting file(s):`
|
|
1650
|
-
)
|
|
1651
|
-
);
|
|
1652
|
-
for (const conflict of result.conflicts) {
|
|
1653
|
-
console.log(` ${chalk8.gray("-")} ${conflict.path}`);
|
|
1654
|
-
}
|
|
1655
|
-
console.log(
|
|
1656
|
-
chalk8.yellow("\nPlease resolve them manually:")
|
|
1657
|
-
);
|
|
1658
|
-
console.log(chalk8.gray(" 1. Fix the conflicting files"));
|
|
1659
|
-
console.log(chalk8.gray(" 2. Run: git add ."));
|
|
1660
|
-
console.log(chalk8.gray(" 3. Run: git commit"));
|
|
1661
|
-
process.exit(1);
|
|
1662
|
-
} else {
|
|
1663
|
-
spinner.fail("Failed to pull from upstream.");
|
|
1664
|
-
console.error(chalk8.red(`
|
|
1665
|
-
${result.reason}`));
|
|
1666
|
-
process.exit(1);
|
|
1667
|
-
}
|
|
1668
|
-
} catch (error) {
|
|
1669
|
-
const message = error instanceof Error ? error.message : "Unknown error";
|
|
1670
|
-
console.error(chalk8.red(`Error: ${message}`));
|
|
1671
|
-
process.exit(1);
|
|
1672
|
-
}
|
|
1673
|
-
});
|
|
1674
|
-
}
|
|
1675
|
-
|
|
1676
|
-
// src/commands/project/project.command.ts
|
|
1677
|
-
import { Command as Command3 } from "commander";
|
|
1678
|
-
var projectCommand = new Command3().name("project").description("Manage your MakerKit project.");
|
|
1679
|
-
createProjectUpdateCommand(projectCommand);
|
|
1680
|
-
|
|
1681
|
-
// src/index.ts
|
|
1682
|
-
import { Command as Command4 } from "commander";
|
|
1683
|
-
import { config } from "dotenv";
|
|
1684
|
-
config({
|
|
1685
|
-
path: ".env.local",
|
|
1686
|
-
quiet: true
|
|
1687
|
-
});
|
|
1688
|
-
process.on("SIGINT", () => process.exit(0));
|
|
1689
|
-
process.on("SIGTERM", () => process.exit(0));
|
|
1690
|
-
async function main() {
|
|
1691
|
-
const program = new Command4().name("makerkit").description(
|
|
1692
|
-
"Your SaaS Kit companion. Add plugins, manage migrations, and more."
|
|
1693
|
-
).version(CLI_VERSION, "-v, --version", "display the version number");
|
|
1694
|
-
program.addCommand(newCommand).addCommand(pluginsCommand).addCommand(projectCommand);
|
|
1695
|
-
program.parse();
|
|
1696
|
-
}
|
|
1697
|
-
void main();
|
|
1698
|
-
//# sourceMappingURL=index.js.map
|