@nightkatana/kronosys-app 1.0.0-beta.0 → 1.0.0-beta.10

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/bin/kronosys.mjs CHANGED
@@ -3,22 +3,44 @@
3
3
  * kronosys CLI — entry point for `npx kronosys <command>`
4
4
  *
5
5
  * Supported commands:
6
- * start next start -p 5555 (production)
7
- * dev next dev --webpack -H kronosys -p 5555
6
+ * start -> next start -p 5555 (production, default; auto-build if needed)
7
+ * dev -> next dev --webpack -H kronosys -p 5555
8
8
  */
9
9
 
10
10
  import { spawn } from "node:child_process";
11
- import { fileURLToPath } from "node:url";
11
+ import { cpSync, existsSync, mkdirSync, readFileSync } from "node:fs";
12
+ import { homedir } from "node:os";
12
13
  import { dirname, resolve } from "node:path";
14
+ import { fileURLToPath } from "node:url";
13
15
 
14
16
  const __dirname = dirname(fileURLToPath(import.meta.url));
15
17
  const projectRoot = resolve(__dirname, "..");
18
+ const packageJson = JSON.parse(
19
+ readFileSync(resolve(projectRoot, "package.json"), "utf8"),
20
+ );
21
+ const packageVersion = packageJson.version;
22
+ const inNodeModules =
23
+ projectRoot.includes("/node_modules/") ||
24
+ projectRoot.includes("\\node_modules\\");
25
+ const isWindows = process.platform === "win32";
26
+ const npmBin = process.platform === "win32" ? "npm.cmd" : "npm";
27
+ const npxBin = process.platform === "win32" ? "npx.cmd" : "npx";
16
28
 
17
29
  const [, , command = "start", ...rest] = process.argv;
18
30
 
19
31
  const commands = {
20
- start: ["npx", "next", "start", "-p", "5555", ...rest],
21
- dev: ["npx", "next", "dev", "--webpack", "-H", "kronosys", "-p", "5555", ...rest],
32
+ start: [npxBin, "next", "start", "-p", "5555", ...rest],
33
+ dev: [
34
+ npxBin,
35
+ "next",
36
+ "dev",
37
+ "--webpack",
38
+ "-H",
39
+ "kronosys",
40
+ "-p",
41
+ "5555",
42
+ ...rest,
43
+ ],
22
44
  };
23
45
 
24
46
  if (!commands[command]) {
@@ -27,20 +49,127 @@ if (!commands[command]) {
27
49
  process.exit(1);
28
50
  }
29
51
 
30
- const [bin, ...args] = commands[command];
52
+ function runCommand(bin, args, env, cwd) {
53
+ return new Promise((resolvePromise, rejectPromise) => {
54
+ const child = isWindows
55
+ ? spawn(
56
+ process.env.ComSpec || "cmd.exe",
57
+ [
58
+ "/d",
59
+ "/s",
60
+ "/c",
61
+ [bin, ...args]
62
+ .map((arg) => `"${String(arg).replaceAll('"', '\\"')}"`)
63
+ .join(" "),
64
+ ],
65
+ {
66
+ cwd,
67
+ stdio: "inherit",
68
+ shell: false,
69
+ env,
70
+ },
71
+ )
72
+ : spawn(bin, args, {
73
+ cwd,
74
+ stdio: "inherit",
75
+ shell: false,
76
+ env,
77
+ });
31
78
 
32
- const child = spawn(bin, args, {
33
- cwd: projectRoot,
34
- stdio: "inherit",
35
- shell: false,
36
- env: { ...process.env, NODE_ENV: command === "dev" ? "development" : "production" },
37
- });
79
+ child.on("error", (err) => {
80
+ rejectPromise(err);
81
+ });
38
82
 
39
- child.on("error", (err) => {
40
- console.error(`[kronosys] Failed to start: ${err.message}`);
41
- process.exit(1);
42
- });
83
+ child.on("exit", (code) => {
84
+ resolvePromise(code ?? 0);
85
+ });
86
+ });
87
+ }
88
+
89
+ function prepareRuntimeRoot() {
90
+ const runtimeRoot = resolve(
91
+ homedir(),
92
+ ".kronosys",
93
+ "runtime",
94
+ String(packageVersion),
95
+ );
96
+ const runtimePackageJson = resolve(runtimeRoot, "package.json");
97
+
98
+ if (!existsSync(runtimePackageJson)) {
99
+ mkdirSync(runtimeRoot, { recursive: true });
100
+ cpSync(projectRoot, runtimeRoot, {
101
+ recursive: true,
102
+ force: true,
103
+ filter: (src) => {
104
+ const normalized = src.replaceAll("\\", "/");
105
+ const rel = normalized
106
+ .replace(projectRoot.replaceAll("\\", "/"), "")
107
+ .replace(/^\/+/, "");
108
+ if (!rel) return true;
109
+ if (rel === ".next" || rel.startsWith(".next/")) return false;
110
+ if (rel === "node_modules" || rel.startsWith("node_modules/"))
111
+ return false;
112
+ return true;
113
+ },
114
+ });
115
+ }
116
+
117
+ return runtimeRoot;
118
+ }
43
119
 
44
- child.on("exit", (code) => {
45
- process.exit(code ?? 0);
46
- });
120
+ async function main() {
121
+ const runRoot = inNodeModules ? prepareRuntimeRoot() : projectRoot;
122
+ const env = {
123
+ ...process.env,
124
+ NODE_ENV: command === "dev" ? "development" : "production",
125
+ };
126
+
127
+ // Global installs live under node_modules; install runtime deps in copied runtime dir.
128
+ if (inNodeModules && !existsSync(resolve(runRoot, "node_modules"))) {
129
+ console.log("[kronosys] Installing runtime dependencies...");
130
+ const installCode = await runCommand(
131
+ npmBin,
132
+ ["install", "--omit=dev", "--ignore-scripts", "--no-audit", "--no-fund"],
133
+ {
134
+ ...env,
135
+ npm_config_cache:
136
+ process.env.npm_config_cache ?? resolve(homedir(), ".npm"),
137
+ },
138
+ runRoot,
139
+ );
140
+ if (installCode !== 0) {
141
+ process.exit(installCode);
142
+ }
143
+ }
144
+
145
+ // Production mode requires a Next build. Build once on first run.
146
+ if (
147
+ command === "start" &&
148
+ !existsSync(resolve(runRoot, ".next", "BUILD_ID"))
149
+ ) {
150
+ console.log(
151
+ "[kronosys] No production build found. Running `next build`...",
152
+ );
153
+ const buildCode = await runCommand(
154
+ npxBin,
155
+ ["next", "build", "--webpack"],
156
+ env,
157
+ runRoot,
158
+ );
159
+ if (buildCode !== 0) {
160
+ process.exit(buildCode);
161
+ }
162
+ }
163
+
164
+ const [bin, ...args] = commands[command];
165
+ const code = await runCommand(bin, args, env, runRoot);
166
+ process.exit(code);
167
+ }
168
+
169
+ try {
170
+ await main();
171
+ } catch (err) {
172
+ const message = err instanceof Error ? err.message : String(err);
173
+ console.error(`[kronosys] Failed to start: ${message}`);
174
+ process.exit(1);
175
+ }
package/next.config.ts CHANGED
@@ -10,6 +10,13 @@ const nextConfig: NextConfig = {
10
10
  },
11
11
  serverExternalPackages: ["better-sqlite3"],
12
12
  outputFileTracingRoot: appDir,
13
+ webpack: (config) => {
14
+ config.resolve.alias = {
15
+ ...config.resolve.alias,
16
+ "@": appDir,
17
+ };
18
+ return config;
19
+ },
13
20
  };
14
21
 
15
22
  export default nextConfig;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nightkatana/kronosys-app",
3
- "version": "1.0.0-beta.0",
3
+ "version": "1.0.0-beta.10",
4
4
  "description": "Kronosys — application Next.js (UI + API + SQLite).",
5
5
  "license": "MIT",
6
6
  "author": "nightkatana",
@@ -55,6 +55,7 @@
55
55
  "@dnd-kit/core": "^6.3.1",
56
56
  "@dnd-kit/sortable": "^10.0.0",
57
57
  "@dnd-kit/utilities": "^3.2.2",
58
+ "@tailwindcss/postcss": "^4",
58
59
  "better-sqlite3": "^12.9.0",
59
60
  "date-fns": "^4.1.0",
60
61
  "fflate": "^0.8.2",
@@ -63,12 +64,13 @@
63
64
  "next": "16.2.3",
64
65
  "react": "19.2.4",
65
66
  "react-day-picker": "^9.14.0",
66
- "react-dom": "19.2.4"
67
+ "react-dom": "19.2.4",
68
+ "tailwindcss": "^4",
69
+ "typescript": "^5.9.3"
67
70
  },
68
71
  "devDependencies": {
69
72
  "@changesets/cli": "^2.31.0",
70
73
  "@playwright/test": "^1.59.1",
71
- "@tailwindcss/postcss": "^4",
72
74
  "@testing-library/react": "^16.3.0",
73
75
  "@testing-library/user-event": "^14.6.1",
74
76
  "@types/better-sqlite3": "^7.6.13",
@@ -80,8 +82,6 @@
80
82
  "eslint-config-next": "16.2.3",
81
83
  "husky": "^9.1.7",
82
84
  "jsdom": "^26.1.0",
83
- "tailwindcss": "^4",
84
- "typescript": "^5.9.3",
85
85
  "vitest": "^3.2.4"
86
86
  }
87
87
  }
package/tsconfig.json CHANGED
@@ -17,6 +17,7 @@
17
17
  "isolatedModules": true,
18
18
  "jsx": "react-jsx",
19
19
  "incremental": true,
20
+ "baseUrl": ".",
20
21
  "plugins": [
21
22
  {
22
23
  "name": "next"
@@ -38,4 +39,4 @@
38
39
  "exclude": [
39
40
  "node_modules"
40
41
  ]
41
- }
42
+ }