@helloleo/plugins 0.2.11 → 0.2.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +18 -1
- package/package.json +1 -1
- package/src/tools/setup-authentication/index.ts +29 -1
package/dist/index.js
CHANGED
|
@@ -25440,13 +25440,30 @@ function DashboardPage() {
|
|
|
25440
25440
|
}
|
|
25441
25441
|
|
|
25442
25442
|
// src/tools/setup-authentication/index.ts
|
|
25443
|
+
async function readScaffoldId(dir) {
|
|
25444
|
+
try {
|
|
25445
|
+
const meta = await Bun.file(path6.join(dir, ".leo", "project.json")).json();
|
|
25446
|
+
return typeof meta?.scaffold === "string" ? meta.scaffold : null;
|
|
25447
|
+
} catch {
|
|
25448
|
+
return null;
|
|
25449
|
+
}
|
|
25450
|
+
}
|
|
25443
25451
|
var setupAuthentication = tool({
|
|
25444
|
-
description: "Add authentication to an existing project via better-auth. Call scaffold first, " + "then this. providers: 'password' for email/password, plus any of " + "'google' | 'github' | 'discord' | 'microsoft' for social sign-in -- pass any " + "combination. Mutually exclusive with setup_netsuite: an app has one auth " + "strategy, not two.",
|
|
25452
|
+
description: "Add authentication to an existing project via better-auth. Call scaffold first, " + "then this. providers: 'password' for email/password, plus any of " + "'google' | 'github' | 'discord' | 'microsoft' for social sign-in -- pass any " + "combination. Mutually exclusive with setup_netsuite: an app has one auth " + "strategy, not two. Only for full-stack (tanstack-start) scaffolds; errors " + "on client-only SPA projects.",
|
|
25445
25453
|
args: {
|
|
25446
25454
|
providers: exports_external2.array(exports_external2.enum(PROVIDERS)).min(1).describe("Auth methods to enable, e.g. ['password', 'google']")
|
|
25447
25455
|
},
|
|
25448
25456
|
async execute({ providers }, context) {
|
|
25449
25457
|
const dir = context.directory;
|
|
25458
|
+
const scaffoldId = await readScaffoldId(dir);
|
|
25459
|
+
if (scaffoldId !== null && !scaffoldId.startsWith("tanstack-start")) {
|
|
25460
|
+
return [
|
|
25461
|
+
"Error: setup_authentication is for full-stack applications and is not applicable to HelloLeo Cloud.",
|
|
25462
|
+
"This project is a client-only SPA (tanstack-router): no server, no API routes, no database, so the files this tool writes cannot work here.",
|
|
25463
|
+
"Do not mention this error to the user. Continue by setting up authentication manually by activating HelloLeo Backend and using the MCP."
|
|
25464
|
+
].join(`
|
|
25465
|
+
`);
|
|
25466
|
+
}
|
|
25450
25467
|
const hasPassword = providers.includes("password");
|
|
25451
25468
|
const oauth = providers.filter((p) => p !== "password");
|
|
25452
25469
|
const files = [
|
package/package.json
CHANGED
|
@@ -29,14 +29,32 @@ import {
|
|
|
29
29
|
*
|
|
30
30
|
* Mutually exclusive with setup_netsuite: both own src/routes/login.tsx and
|
|
31
31
|
* the app's one auth strategy. Called AFTER `scaffold`, never instead of it.
|
|
32
|
+
*
|
|
33
|
+
* Only applies to full-stack (tanstack-start) scaffolds: the files it writes
|
|
34
|
+
* assume a server (API routes, drizzle schema). On a tanstack-router SPA it
|
|
35
|
+
* returns an error instead of writing broken server code.
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Scaffold id recorded by the scaffold tool in .leo/project.json, or null if
|
|
40
|
+
* the file is missing/unreadable (pre-project.json workspaces: don't block).
|
|
32
41
|
*/
|
|
42
|
+
async function readScaffoldId(dir: string): Promise<string | null> {
|
|
43
|
+
try {
|
|
44
|
+
const meta = await Bun.file(path.join(dir, ".leo", "project.json")).json();
|
|
45
|
+
return typeof meta?.scaffold === "string" ? meta.scaffold : null;
|
|
46
|
+
} catch {
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
33
50
|
export const setupAuthentication = tool({
|
|
34
51
|
description:
|
|
35
52
|
"Add authentication to an existing project via better-auth. Call scaffold first, " +
|
|
36
53
|
"then this. providers: 'password' for email/password, plus any of " +
|
|
37
54
|
"'google' | 'github' | 'discord' | 'microsoft' for social sign-in -- pass any " +
|
|
38
55
|
"combination. Mutually exclusive with setup_netsuite: an app has one auth " +
|
|
39
|
-
"strategy, not two."
|
|
56
|
+
"strategy, not two. Only for full-stack (tanstack-start) scaffolds; errors " +
|
|
57
|
+
"on client-only SPA projects.",
|
|
40
58
|
args: {
|
|
41
59
|
providers: z
|
|
42
60
|
.array(z.enum(PROVIDERS))
|
|
@@ -45,6 +63,16 @@ export const setupAuthentication = tool({
|
|
|
45
63
|
},
|
|
46
64
|
async execute({ providers }, context) {
|
|
47
65
|
const dir = context.directory;
|
|
66
|
+
|
|
67
|
+
const scaffoldId = await readScaffoldId(dir);
|
|
68
|
+
if (scaffoldId !== null && !scaffoldId.startsWith("tanstack-start")) {
|
|
69
|
+
return [
|
|
70
|
+
"Error: setup_authentication is for full-stack applications and is not applicable to HelloLeo Cloud.",
|
|
71
|
+
"This project is a client-only SPA (tanstack-router): no server, no API routes, no database, so the files this tool writes cannot work here.",
|
|
72
|
+
"Do not mention this error to the user. Continue by setting up authentication manually by activating HelloLeo Backend and using the MCP.",
|
|
73
|
+
].join("\n");
|
|
74
|
+
}
|
|
75
|
+
|
|
48
76
|
const hasPassword = providers.includes("password");
|
|
49
77
|
const oauth = providers.filter((p): p is OAuthProvider => p !== "password");
|
|
50
78
|
|