ai-forge-cli 0.4.9 → 0.4.11
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/add-shared-query-YLAKKIJH.js +66 -0
- package/dist/index.js +1 -0
- package/dist/templates/layout/auth/_layout.tsx.hbs +1 -1
- package/dist/templates/layout/base/_layout.tsx.hbs +1 -1
- package/dist/templates/layout/dashboard/_layout.tsx.hbs +1 -1
- package/dist/templates/layout/marketing/_layout.tsx.hbs +1 -1
- package/dist/templates/shared-query/query.ts.hbs +39 -0
- package/package.json +1 -1
- package/templates/layout/auth/_layout.tsx.hbs +1 -1
- package/templates/layout/base/_layout.tsx.hbs +1 -1
- package/templates/layout/dashboard/_layout.tsx.hbs +1 -1
- package/templates/layout/marketing/_layout.tsx.hbs +1 -1
- package/templates/shared-query/query.ts.hbs +39 -0
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
camelCase,
|
|
4
|
+
kebabCase,
|
|
5
|
+
renderTemplate
|
|
6
|
+
} from "./chunk-MBF6K2AC.js";
|
|
7
|
+
import {
|
|
8
|
+
fileExists,
|
|
9
|
+
logger,
|
|
10
|
+
writeFile
|
|
11
|
+
} from "./chunk-HL4K5AHI.js";
|
|
12
|
+
|
|
13
|
+
// src/commands/add-shared-query.ts
|
|
14
|
+
import { defineCommand } from "citty";
|
|
15
|
+
import { join } from "path";
|
|
16
|
+
var add_shared_query_default = defineCommand({
|
|
17
|
+
meta: {
|
|
18
|
+
name: "add:shared-query",
|
|
19
|
+
description: "Create a shared Convex query file. Creates: convex/<name>.ts with query/mutation boilerplate. Use for global backend logic not tied to a feature."
|
|
20
|
+
},
|
|
21
|
+
args: {
|
|
22
|
+
name: {
|
|
23
|
+
type: "positional",
|
|
24
|
+
description: "Query file name (e.g., notifications, emails, analytics)",
|
|
25
|
+
required: true
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
async run({ args }) {
|
|
29
|
+
const cwd = process.cwd();
|
|
30
|
+
const rawName = args.name;
|
|
31
|
+
const fileName = kebabCase(rawName);
|
|
32
|
+
const queryName = camelCase(rawName);
|
|
33
|
+
const queryPath = join(cwd, "convex", `${fileName}.ts`);
|
|
34
|
+
if (await fileExists(queryPath)) {
|
|
35
|
+
logger.error(`Shared query "${fileName}" already exists at convex/${fileName}.ts`);
|
|
36
|
+
process.exit(1);
|
|
37
|
+
}
|
|
38
|
+
const convexDir = join(cwd, "convex");
|
|
39
|
+
if (!await fileExists(convexDir)) {
|
|
40
|
+
logger.error("convex/ directory not found. Is this a Convex project?");
|
|
41
|
+
process.exit(1);
|
|
42
|
+
}
|
|
43
|
+
logger.blank();
|
|
44
|
+
const templateData = {
|
|
45
|
+
fileName,
|
|
46
|
+
queryName
|
|
47
|
+
};
|
|
48
|
+
const content = renderTemplate("shared-query/query.ts.hbs", templateData);
|
|
49
|
+
await writeFile(queryPath, content);
|
|
50
|
+
logger.success(`Created convex/${fileName}.ts`);
|
|
51
|
+
logger.blank();
|
|
52
|
+
logger.log(` Shared query "${fileName}" created!`);
|
|
53
|
+
logger.blank();
|
|
54
|
+
logger.log(" Location:");
|
|
55
|
+
logger.log(` convex/${fileName}.ts`);
|
|
56
|
+
logger.blank();
|
|
57
|
+
logger.log(" Usage:");
|
|
58
|
+
logger.log(` import { api } from "convex/_generated/api";`);
|
|
59
|
+
logger.log(` const data = useQuery(api.${fileName}.list);`);
|
|
60
|
+
logger.log(` const create = useMutation(api.${fileName}.create);`);
|
|
61
|
+
logger.blank();
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
export {
|
|
65
|
+
add_shared_query_default as default
|
|
66
|
+
};
|
package/dist/index.js
CHANGED
|
@@ -27,6 +27,7 @@ var main = defineCommand({
|
|
|
27
27
|
"add:component": () => import("./add-component-B3O3RZWD.js").then((m) => m.default),
|
|
28
28
|
"add:hook": () => import("./add-hook-VJC6P6AP.js").then((m) => m.default),
|
|
29
29
|
"add:util": () => import("./add-util-V5SQRVJC.js").then((m) => m.default),
|
|
30
|
+
"add:shared-query": () => import("./add-shared-query-YLAKKIJH.js").then((m) => m.default),
|
|
30
31
|
check: () => import("./check-SD5NBZ26.js").then((m) => m.default),
|
|
31
32
|
version: () => import("./version-VO3LHLDO.js").then((m) => m.default)
|
|
32
33
|
},
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Outlet, createFileRoute } from "@tanstack/react-router";
|
|
2
2
|
import { Sidebar, Header } from "~/components/layout";
|
|
3
3
|
|
|
4
|
-
export const Route = createFileRoute("/dashboard")({
|
|
4
|
+
export const Route = createFileRoute("/dashboard/_layout")({
|
|
5
5
|
component: DashboardLayout,
|
|
6
6
|
});
|
|
7
7
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Outlet, createFileRoute, Link } from "@tanstack/react-router";
|
|
2
2
|
import { Button } from "~/components/ui/button";
|
|
3
3
|
|
|
4
|
-
export const Route = createFileRoute("/{{name}}")({
|
|
4
|
+
export const Route = createFileRoute("/{{name}}/_layout")({
|
|
5
5
|
component: MarketingLayout,
|
|
6
6
|
});
|
|
7
7
|
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { query, mutation } from "./_generated/server";
|
|
2
|
+
import { v } from "convex/values";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Shared queries and mutations for {{fileName}}
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
export const list = query({
|
|
9
|
+
args: {},
|
|
10
|
+
handler: async (ctx) => {
|
|
11
|
+
// TODO: Implement list query
|
|
12
|
+
return [];
|
|
13
|
+
},
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
export const getById = query({
|
|
17
|
+
args: { id: v.id("{{fileName}}") },
|
|
18
|
+
handler: async (ctx, args) => {
|
|
19
|
+
return await ctx.db.get(args.id);
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
export const create = mutation({
|
|
24
|
+
args: {
|
|
25
|
+
// TODO: Define your fields
|
|
26
|
+
// name: v.string(),
|
|
27
|
+
},
|
|
28
|
+
handler: async (ctx, args) => {
|
|
29
|
+
// TODO: Implement create mutation
|
|
30
|
+
// return await ctx.db.insert("{{fileName}}", { ...args });
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
export const remove = mutation({
|
|
35
|
+
args: { id: v.id("{{fileName}}") },
|
|
36
|
+
handler: async (ctx, args) => {
|
|
37
|
+
await ctx.db.delete(args.id);
|
|
38
|
+
},
|
|
39
|
+
});
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Outlet, createFileRoute } from "@tanstack/react-router";
|
|
2
2
|
import { Sidebar, Header } from "~/components/layout";
|
|
3
3
|
|
|
4
|
-
export const Route = createFileRoute("/dashboard")({
|
|
4
|
+
export const Route = createFileRoute("/dashboard/_layout")({
|
|
5
5
|
component: DashboardLayout,
|
|
6
6
|
});
|
|
7
7
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Outlet, createFileRoute, Link } from "@tanstack/react-router";
|
|
2
2
|
import { Button } from "~/components/ui/button";
|
|
3
3
|
|
|
4
|
-
export const Route = createFileRoute("/{{name}}")({
|
|
4
|
+
export const Route = createFileRoute("/{{name}}/_layout")({
|
|
5
5
|
component: MarketingLayout,
|
|
6
6
|
});
|
|
7
7
|
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { query, mutation } from "./_generated/server";
|
|
2
|
+
import { v } from "convex/values";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Shared queries and mutations for {{fileName}}
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
export const list = query({
|
|
9
|
+
args: {},
|
|
10
|
+
handler: async (ctx) => {
|
|
11
|
+
// TODO: Implement list query
|
|
12
|
+
return [];
|
|
13
|
+
},
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
export const getById = query({
|
|
17
|
+
args: { id: v.id("{{fileName}}") },
|
|
18
|
+
handler: async (ctx, args) => {
|
|
19
|
+
return await ctx.db.get(args.id);
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
export const create = mutation({
|
|
24
|
+
args: {
|
|
25
|
+
// TODO: Define your fields
|
|
26
|
+
// name: v.string(),
|
|
27
|
+
},
|
|
28
|
+
handler: async (ctx, args) => {
|
|
29
|
+
// TODO: Implement create mutation
|
|
30
|
+
// return await ctx.db.insert("{{fileName}}", { ...args });
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
export const remove = mutation({
|
|
35
|
+
args: { id: v.id("{{fileName}}") },
|
|
36
|
+
handler: async (ctx, args) => {
|
|
37
|
+
await ctx.db.delete(args.id);
|
|
38
|
+
},
|
|
39
|
+
});
|