tkeron 4.0.0-beta.17 → 4.0.0-beta.18

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 CHANGED
@@ -1,3 +1,28 @@
1
+ # v4.0.0-beta.18
2
+
3
+ ## Code Quality & Architecture
4
+
5
+ ### Bug Fixes
6
+
7
+ - **Fixed**: Removed `process.exit()` from library code (`build.ts`, `develop.ts`, `init.ts`) — errors now propagate via `throw`, letting wrappers handle exit
8
+ - **Fixed**: Moved `reloadClients` Set inside `develop()` to prevent shared state across multiple server instances
9
+ - **Fixed**: Removed `await` on synchronous `path.resolve()` calls in `build.ts` and `develop.ts`
10
+ - **Fixed**: `log.error()` called without arguments in `processPre.ts` — now passes empty string
11
+
12
+ ### Code Style
13
+
14
+ - **Changed**: Converted all `function` declarations to arrow functions (`initWrapper`, `processComponents`, `processComponentsTs`)
15
+ - **Removed**: Comments in source code (`processCom.ts`, `processComTs.ts`)
16
+ - **Removed**: Dead re-export of `setupSigintHandler` from `develop.ts`
17
+
18
+ ### Tests
19
+
20
+ - **Fixed**: TS2532 errors in `getBuildResult.test.ts` (proper handling of possibly undefined values)
21
+ - **Updated**: Tests adapted to new error propagation (no more `process.exit` mocking in library tests)
22
+ - **Removed**: Redundant/dead test cases for removed behavior
23
+
24
+ ---
25
+
1
26
  # v4.0.0-beta.17
2
27
 
3
28
  ## MCP Server Updates
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tkeron",
3
- "version": "4.0.0-beta.17",
3
+ "version": "4.0.0-beta.18",
4
4
  "description": "CLI tool for backend-driven frontend development with TypeScript.",
5
5
  "type": "module",
6
6
  "main": "./src/index.ts",
package/src/build.ts CHANGED
@@ -24,10 +24,10 @@ export const build = async (options: BuildOptions) => {
24
24
  return;
25
25
  }
26
26
 
27
- const source = await resolve(options.sourceDir || "websrc");
27
+ const source = resolve(options.sourceDir || "websrc");
28
28
  const target = options.targetDir
29
- ? await resolve(options.targetDir)
30
- : await resolve(dirname(source), "web");
29
+ ? resolve(options.targetDir)
30
+ : resolve(dirname(source), "web");
31
31
 
32
32
  const sourceParent = dirname(source);
33
33
  const tempDir = join(
@@ -67,14 +67,6 @@ export const build = async (options: BuildOptions) => {
67
67
  `\n💡 Tip: Create the directory first, check the path, or run 'tk init' to create a new project.`,
68
68
  );
69
69
  log.error(` Expected: ${source}\n`);
70
- process.exit(1);
71
- }
72
-
73
- if (
74
- error.message &&
75
- error.message.includes("must contain at least one hyphen")
76
- ) {
77
- process.exit(1);
78
70
  }
79
71
 
80
72
  throw error;
package/src/develop.ts CHANGED
@@ -13,8 +13,6 @@ export interface TkeronDevOptions {
13
13
  logger?: Logger;
14
14
  }
15
15
 
16
- const reloadClients = new Set<ReadableStreamDefaultController>();
17
-
18
16
  export interface DevelopServer {
19
17
  stop: () => Promise<void>;
20
18
  port: number;
@@ -28,6 +26,8 @@ export const develop = async (
28
26
  throw new Error("Invalid options provided for develop");
29
27
  }
30
28
 
29
+ const reloadClients = new Set<ReadableStreamDefaultController>();
30
+
31
31
  const {
32
32
  port = 3000,
33
33
  host = "localhost",
@@ -36,28 +36,13 @@ export const develop = async (
36
36
  logger: log = defaultLogger,
37
37
  } = options;
38
38
 
39
- const source = await resolve(sourceDir || "websrc");
39
+ const source = resolve(sourceDir || "websrc");
40
40
  const target = outputDir
41
- ? await resolve(outputDir)
42
- : await resolve(dirname(source), "web");
41
+ ? resolve(outputDir)
42
+ : resolve(dirname(source), "web");
43
43
 
44
44
  log.log("🔨 Building project...");
45
- try {
46
- await build({ sourceDir: source, targetDir: target, logger: log });
47
- } catch (error: any) {
48
- if (error.code === "ENOENT") {
49
- const actualSourceDir = sourceDir || "websrc";
50
- log.error(
51
- `\n❌ Error: Source directory "${actualSourceDir}" does not exist.`,
52
- );
53
- log.error(
54
- `\n💡 Tip: Create the directory first, check the path, or run 'tk init' to create a new project.`,
55
- );
56
- log.error(` Expected: ${source}\n`);
57
- process.exit(1);
58
- }
59
- throw error;
60
- }
45
+ await build({ sourceDir: source, targetDir: target, logger: log });
61
46
  log.log("✅ Build complete!");
62
47
 
63
48
  const server = Bun.serve({
@@ -182,5 +167,3 @@ export const develop = async (
182
167
  host: server.hostname ?? host,
183
168
  };
184
169
  };
185
-
186
- export { setupSigintHandler } from "./setupSigintHandler";
package/src/init.ts CHANGED
@@ -57,7 +57,7 @@ export const init = async (options: InitOptions) => {
57
57
 
58
58
  if (!shouldContinue) {
59
59
  log.log("\n❌ Operation cancelled.");
60
- process.exit(0);
60
+ return;
61
61
  }
62
62
  }
63
63
 
@@ -9,7 +9,7 @@ export interface InitWrapperOptions {
9
9
  [key: string]: any;
10
10
  }
11
11
 
12
- export async function initWrapper(options: InitWrapperOptions) {
12
+ export const initWrapper = async (options: InitWrapperOptions) => {
13
13
  const log = options?.logger || defaultLogger;
14
14
 
15
15
  if (!options || typeof options !== "object") {
@@ -60,4 +60,4 @@ export async function initWrapper(options: InitWrapperOptions) {
60
60
  }
61
61
  process.exit(1);
62
62
  }
63
- }
63
+ };
package/src/processCom.ts CHANGED
@@ -60,14 +60,14 @@ export const processCom = async (
60
60
  return hasChanges;
61
61
  };
62
62
 
63
- async function processComponents(
63
+ const processComponents = async (
64
64
  element: any,
65
65
  currentDir: string,
66
66
  rootDir: string,
67
67
  componentStack: string[],
68
68
  depth: number = 0,
69
69
  log: Logger = silentLogger,
70
- ): Promise<boolean> {
70
+ ): Promise<boolean> => {
71
71
  let hasChanges = false;
72
72
  const MAX_DEPTH = 50;
73
73
  if (depth > MAX_DEPTH) {
@@ -183,7 +183,6 @@ async function processComponents(
183
183
  }
184
184
  }
185
185
 
186
- // Recursively process child elements
187
186
  const childChanged = await processComponents(
188
187
  child,
189
188
  currentDir,
@@ -196,4 +195,4 @@ async function processComponents(
196
195
  }
197
196
 
198
197
  return hasChanges;
199
- }
198
+ };
@@ -61,7 +61,7 @@ export const processComTs = async (
61
61
  return hasChanges;
62
62
  };
63
63
 
64
- async function processComponentsTs(
64
+ const processComponentsTs = async (
65
65
  element: any,
66
66
  currentDir: string,
67
67
  rootDir: string,
@@ -69,7 +69,7 @@ async function processComponentsTs(
69
69
  depth: number = 0,
70
70
  log: Logger = silentLogger,
71
71
  options: ProcessComTsOptions = {},
72
- ): Promise<boolean> {
72
+ ): Promise<boolean> => {
73
73
  let hasChanges = false;
74
74
  const MAX_DEPTH = 50;
75
75
  if (depth > MAX_DEPTH) {
@@ -251,7 +251,6 @@ ${codeWithoutImports}
251
251
  }
252
252
  }
253
253
 
254
- // Recursively process child elements
255
254
  const childChanged = await processComponentsTs(
256
255
  child,
257
256
  currentDir,
@@ -265,4 +264,4 @@ ${codeWithoutImports}
265
264
  }
266
265
 
267
266
  return hasChanges;
268
- }
267
+ };
package/src/processPre.ts CHANGED
@@ -89,7 +89,7 @@ export const processPre = async (
89
89
  if (stdout) {
90
90
  log.error(`\nOutput:\n${stdout}`);
91
91
  }
92
- log.error();
92
+ log.error("");
93
93
  throw new Error(`Pre-rendering failed for ${preFile}`);
94
94
  }
95
95
  }
@@ -11,7 +11,7 @@ const hashString = (str: string): number => {
11
11
  for (let i = 0; i < str.length; i++) {
12
12
  const char = str.charCodeAt(i);
13
13
  hash = (hash << 5) - hash + char;
14
- hash = hash & hash; // Convert to 32bit integer
14
+ hash = hash & hash;
15
15
  }
16
16
  return Math.abs(hash);
17
17
  };
@@ -22,7 +22,7 @@ export const getTestResources = (
22
22
  testName: string,
23
23
  ): { port: number; dir: string } => {
24
24
  const hash = hashString(testName);
25
- const port = 9000 + (hash % 10000); // Port range: 9000-18999
25
+ const port = 9000 + (hash % 10000);
26
26
  const uniqueId = `${hash}-${resourceCounter++}`;
27
27
  const dir = join(tmpdir(), `tkeron-test-${uniqueId}`);
28
28