@kithinji/pod 1.0.20 → 1.0.22

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.
Files changed (40) hide show
  1. package/README.md +439 -0
  2. package/dist/main.js +109 -2
  3. package/dist/main.js.map +2 -2
  4. package/dist/types/docker/docker.d.ts.map +1 -1
  5. package/package.json +31 -8
  6. package/build.js +0 -22
  7. package/src/add/component/component.ts +0 -496
  8. package/src/add/component/index.ts +0 -1
  9. package/src/add/index.ts +0 -3
  10. package/src/add/module/index.ts +0 -1
  11. package/src/add/module/module.ts +0 -545
  12. package/src/add/new/index.ts +0 -198
  13. package/src/config/config.ts +0 -141
  14. package/src/config/index.ts +0 -1
  15. package/src/deploy/deploy.ts +0 -592
  16. package/src/deploy/index.ts +0 -1
  17. package/src/dev/index.ts +0 -1
  18. package/src/dev/project.ts +0 -45
  19. package/src/dev/server.ts +0 -191
  20. package/src/docker/docker.ts +0 -592
  21. package/src/docker/index.ts +0 -1
  22. package/src/macros/expand_macros.ts +0 -791
  23. package/src/macros/index.ts +0 -2
  24. package/src/macros/macro_executer.ts +0 -189
  25. package/src/main.ts +0 -106
  26. package/src/plugins/analyzers/graph.ts +0 -279
  27. package/src/plugins/css/index.ts +0 -25
  28. package/src/plugins/generators/generate_controller.ts +0 -308
  29. package/src/plugins/generators/generate_rsc.ts +0 -274
  30. package/src/plugins/generators/generate_server_component.ts +0 -455
  31. package/src/plugins/generators/tsx_server_stub.ts +0 -315
  32. package/src/plugins/index.ts +0 -3
  33. package/src/plugins/my.ts +0 -282
  34. package/src/plugins/transformers/j2d.ts +0 -1080
  35. package/src/store/index.ts +0 -1
  36. package/src/store/store.ts +0 -44
  37. package/src/utils/cases.ts +0 -15
  38. package/src/utils/create.ts +0 -26
  39. package/src/utils/index.ts +0 -2
  40. package/tsconfig.json +0 -27
package/src/dev/server.ts DELETED
@@ -1,191 +0,0 @@
1
- import * as esbuild from "esbuild";
2
- import { spawn, ChildProcess } from "child_process";
3
- import * as fs from "fs/promises";
4
- import { loadConfig, mergeConfig, getDefaultConfig } from "../config/config";
5
- import { buildGraph, useMyPlugin } from "@/plugins";
6
- import { Store } from "@/store";
7
-
8
- async function copyFile(): Promise<void> {
9
- try {
10
- await fs.mkdir("public", { recursive: true });
11
- await fs.copyFile("./src/client/index.html", "./public/index.html");
12
- } catch (error) {
13
- console.error("❌ Failed to copy index.html:", error);
14
- throw error;
15
- }
16
- }
17
-
18
- async function cleanDirectories(): Promise<void> {
19
- await Promise.all([
20
- fs.rm("dist", { recursive: true, force: true }),
21
- fs.rm("public", { recursive: true, force: true }),
22
- ]);
23
- }
24
-
25
- function createRestartServerPlugin(
26
- serverProcess: { current: ChildProcess | null },
27
- onServerBuildComplete: () => void
28
- ): esbuild.Plugin {
29
- return {
30
- name: "restart-server",
31
- setup(build) {
32
- build.onEnd((result) => {
33
- if (result.errors.length > 0) {
34
- console.error(
35
- `❌ Server build failed with ${result.errors.length} error(s)`
36
- );
37
- return;
38
- }
39
-
40
- if (serverProcess.current) {
41
- serverProcess.current.kill("SIGTERM");
42
- }
43
-
44
- serverProcess.current = spawn("node", ["dist/main.js"], {
45
- stdio: "inherit",
46
- });
47
-
48
- serverProcess.current.on("error", (err) => {
49
- console.error("❌ Server process error:", err);
50
- });
51
-
52
- onServerBuildComplete();
53
- });
54
- },
55
- };
56
- }
57
-
58
- export async function startDevServer(): Promise<void> {
59
- const store = Store.getInstance();
60
- const userConfig = await loadConfig();
61
- const config = mergeConfig(getDefaultConfig(), userConfig);
62
-
63
- await cleanDirectories();
64
- await copyFile();
65
-
66
- const entryPoints = ["src/main.ts"];
67
- const clientFiles = new Set<string>(["src/client/client.tsx"]);
68
- const serverProcessRef = { current: null as ChildProcess | null };
69
- let clientCtx: esbuild.BuildContext | null = null;
70
- let isShuttingDown = false;
71
-
72
- let pendingClientFiles = new Set<string>();
73
- let needsClientRebuild = false;
74
-
75
- async function rebuildClient(): Promise<void> {
76
- if (isShuttingDown) return;
77
-
78
- try {
79
- if (clientCtx) {
80
- await clientCtx.dispose();
81
- clientCtx = null;
82
- }
83
-
84
- if (clientFiles.size === 0) return;
85
-
86
- const entryPoints = Array.from(clientFiles);
87
-
88
- const graph = buildGraph(entryPoints);
89
-
90
- clientCtx = await esbuild.context({
91
- entryPoints,
92
- bundle: true,
93
- outdir: "public",
94
- outbase: ".",
95
- platform: "browser",
96
- format: "esm",
97
- sourcemap: config.build?.sourcemap ?? true,
98
- splitting: true,
99
- minify: config.build?.minify ?? true,
100
- plugins: [
101
- ...(config.plugins?.map((cb) => cb(store)) || []),
102
- ...(config.client_plugins?.map((cb) => cb(store)) || []),
103
- useMyPlugin({
104
- graph,
105
- isServerBuild: false,
106
- onClientFound: () => {},
107
- }),
108
- {
109
- name: "client-build-logger",
110
- setup(build: any) {
111
- build.onEnd((result: any) => {
112
- if (result.errors.length > 0) {
113
- console.error(
114
- `❌ Client build failed with ${result.errors.length} error(s)`
115
- );
116
- }
117
- });
118
- },
119
- },
120
- ],
121
- write: true,
122
- });
123
-
124
- await clientCtx.watch();
125
- pendingClientFiles.clear();
126
- needsClientRebuild = false;
127
- } catch (error) {
128
- console.error("❌ Failed to rebuild client:", error);
129
- throw error;
130
- }
131
- }
132
-
133
- async function onServerBuildComplete(): Promise<void> {
134
- if (needsClientRebuild && pendingClientFiles.size > 0) {
135
- await rebuildClient();
136
- }
137
- }
138
-
139
- const serverCtx = await esbuild.context({
140
- entryPoints,
141
- bundle: true,
142
- outdir: config.build?.outDir || "dist",
143
- platform: "node",
144
- format: "esm",
145
- packages: "external",
146
- sourcemap: config.build?.sourcemap ?? true,
147
- minify: config.build?.minify ?? false,
148
- plugins: [
149
- ...(config.plugins?.map((cb) => cb(store)) || []),
150
- useMyPlugin({
151
- isServerBuild: true,
152
- onClientFound: async (filePath) => {
153
- const isNewFile = !clientFiles.has(filePath);
154
-
155
- if (isNewFile) {
156
- clientFiles.add(filePath);
157
- pendingClientFiles.add(filePath);
158
- needsClientRebuild = true;
159
- }
160
- },
161
- }),
162
- createRestartServerPlugin(serverProcessRef, onServerBuildComplete),
163
- ],
164
- write: true,
165
- });
166
-
167
- async function shutdown(): Promise<void> {
168
- if (isShuttingDown) return;
169
- isShuttingDown = true;
170
-
171
- try {
172
- if (serverProcessRef.current) {
173
- serverProcessRef.current.kill("SIGTERM");
174
- await new Promise((resolve) => setTimeout(resolve, 1000));
175
- }
176
-
177
- await serverCtx.dispose();
178
- if (clientCtx) await clientCtx.dispose();
179
-
180
- process.exit(0);
181
- } catch (error) {
182
- console.error("❌ Error during shutdown:", error);
183
- process.exit(1);
184
- }
185
- }
186
-
187
- process.on("SIGINT", shutdown);
188
- process.on("SIGTERM", shutdown);
189
-
190
- await serverCtx.watch();
191
- }