@jrtilak-recall/plugin-creator 0.0.1 → 0.0.2-alpha.0
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/CHANGELOG.md +18 -0
- package/README.md +11 -3
- package/dist/cli.js +15 -0
- package/package.json +30 -25
- package/dist/build-plugin.js +0 -131
- package/src/scripts/build-plugin.ts +0 -89
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bun
|
|
2
|
-
|
|
3
|
-
import { rm } from "node:fs/promises";
|
|
4
|
-
import { join } from "node:path";
|
|
5
|
-
import { log } from "@jrtilak-recall/logger";
|
|
6
|
-
import { PluginConfigSchema, ThemeSchema } from "@jrtilak-recall/plugin-schema";
|
|
7
|
-
import z from "zod";
|
|
8
|
-
|
|
9
|
-
const __DIST_THEME_PATH = "theme.json";
|
|
10
|
-
|
|
11
|
-
const root = process.cwd();
|
|
12
|
-
const distDir = join(root, "dist");
|
|
13
|
-
|
|
14
|
-
log.info(`Building plugin from dir ${root} ...`);
|
|
15
|
-
|
|
16
|
-
log.info("Cleaning dist directory...");
|
|
17
|
-
|
|
18
|
-
await rm(distDir, { recursive: true, force: true });
|
|
19
|
-
|
|
20
|
-
const pkg = await Bun.file(join(root, "package.json")).json();
|
|
21
|
-
|
|
22
|
-
if (!pkg) {
|
|
23
|
-
log.error("No package.json found in plugin root");
|
|
24
|
-
process.exit(1);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const result = PluginConfigSchema.safeParse(pkg);
|
|
28
|
-
|
|
29
|
-
if (!result.success) {
|
|
30
|
-
log.error(
|
|
31
|
-
"Invalid plugin config: package.json does not conform to PluginConfigSchema",
|
|
32
|
-
);
|
|
33
|
-
log.error(z.treeifyError(result.error));
|
|
34
|
-
process.exit(1);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
const pkgJson = result.data;
|
|
38
|
-
|
|
39
|
-
const newManifst = {
|
|
40
|
-
...pkgJson,
|
|
41
|
-
recall: {
|
|
42
|
-
...pkgJson.recall,
|
|
43
|
-
theme: __DIST_THEME_PATH,
|
|
44
|
-
},
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
await Bun.write(join(distDir, "manifest.json"), JSON.stringify(newManifst));
|
|
48
|
-
|
|
49
|
-
log.info("Plugin manifest generated");
|
|
50
|
-
|
|
51
|
-
const theme = pkgJson.recall.theme;
|
|
52
|
-
|
|
53
|
-
if (theme) {
|
|
54
|
-
log.info("Plugin has theme, copying theme files...");
|
|
55
|
-
const themeJson = await Bun.file(join(root, theme)).json();
|
|
56
|
-
|
|
57
|
-
if (!themeJson) {
|
|
58
|
-
log.error(`Theme file ${theme} not found or invalid JSON`);
|
|
59
|
-
process.exit(1);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
const result = ThemeSchema.safeParse(themeJson);
|
|
63
|
-
|
|
64
|
-
if (!result.success) {
|
|
65
|
-
log.error(
|
|
66
|
-
"Invalid plugin theme: theme file does not conform to ThemeSchema",
|
|
67
|
-
);
|
|
68
|
-
log.error(z.treeifyError(result.error));
|
|
69
|
-
process.exit(1);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
Bun.write(join(distDir, __DIST_THEME_PATH), JSON.stringify(result.data));
|
|
73
|
-
log.info("Plugin theme generated");
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
const main = pkgJson.recall.main;
|
|
77
|
-
|
|
78
|
-
// TODO: support main file
|
|
79
|
-
if (main) {
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
if (!main && !theme) {
|
|
83
|
-
log.error("Plugin must have either a main file or a theme");
|
|
84
|
-
process.exit(1);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
log.info("Plugin build complete");
|
|
88
|
-
|
|
89
|
-
// TODO: also zip the plguin using `zip` if available
|