keryx 0.20.0 → 0.20.1
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/package.json +1 -1
- package/templates/generate/plugin.ts.mustache +15 -0
- package/util/cli.ts +1 -0
- package/util/generate.ts +4 -0
package/package.json
CHANGED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { KeryxPlugin } from "keryx";
|
|
2
|
+
|
|
3
|
+
export const {{className}}: KeryxPlugin = {
|
|
4
|
+
name: "{{name}}",
|
|
5
|
+
version: "0.1.0",
|
|
6
|
+
|
|
7
|
+
// initializers: [],
|
|
8
|
+
// actions: [],
|
|
9
|
+
// channels: [],
|
|
10
|
+
// servers: [],
|
|
11
|
+
|
|
12
|
+
// configDefaults: {},
|
|
13
|
+
|
|
14
|
+
// generators: [],
|
|
15
|
+
};
|
package/util/cli.ts
CHANGED
|
@@ -107,6 +107,7 @@ export async function buildProgram(opts: {
|
|
|
107
107
|
" keryx generate middleware auth\n" +
|
|
108
108
|
" keryx generate channel notifications\n" +
|
|
109
109
|
" keryx generate ops UserOps\n" +
|
|
110
|
+
" keryx generate plugin analytics\n" +
|
|
110
111
|
" keryx g action hello",
|
|
111
112
|
)
|
|
112
113
|
.option("--dry-run", "Show what would be generated without writing files")
|
package/util/generate.ts
CHANGED
|
@@ -10,6 +10,7 @@ const VALID_TYPES = [
|
|
|
10
10
|
"middleware",
|
|
11
11
|
"channel",
|
|
12
12
|
"ops",
|
|
13
|
+
"plugin",
|
|
13
14
|
] as const;
|
|
14
15
|
type GeneratorType = (typeof VALID_TYPES)[number];
|
|
15
16
|
|
|
@@ -77,6 +78,7 @@ function resolveFilePath(type: GeneratorType, name: string): string {
|
|
|
77
78
|
middleware: "middleware",
|
|
78
79
|
channel: "channels",
|
|
79
80
|
ops: "ops",
|
|
81
|
+
plugin: "plugins",
|
|
80
82
|
};
|
|
81
83
|
|
|
82
84
|
const baseDir = dirMap[type];
|
|
@@ -173,6 +175,7 @@ export async function generateComponent(
|
|
|
173
175
|
let className = toClassName(name);
|
|
174
176
|
if (type === "middleware") className += "Middleware";
|
|
175
177
|
if (type === "channel") className += "Channel";
|
|
178
|
+
if (type === "plugin") className += "Plugin";
|
|
176
179
|
|
|
177
180
|
const view: Record<string, string> = { name, className };
|
|
178
181
|
if (type === "action") {
|
|
@@ -191,6 +194,7 @@ export async function generateComponent(
|
|
|
191
194
|
middleware: "action-middleware.ts.mustache",
|
|
192
195
|
channel: "channel.ts.mustache",
|
|
193
196
|
ops: "ops.ts.mustache",
|
|
197
|
+
plugin: "plugin.ts.mustache",
|
|
194
198
|
};
|
|
195
199
|
const template = await loadTemplate(templateMap[type as GeneratorType]);
|
|
196
200
|
content = Mustache.render(template, view);
|