@nightkatana/kronosys-app 1.0.0-beta.1 → 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
@@ -8,18 +8,39 @@
8
8
  */
9
9
 
10
10
  import { spawn } from "node:child_process";
11
- import { existsSync } from "node:fs";
11
+ import { cpSync, existsSync, mkdirSync, readFileSync } from "node:fs";
12
+ import { homedir } from "node:os";
12
13
  import { dirname, resolve } from "node:path";
13
14
  import { fileURLToPath } from "node:url";
14
15
 
15
16
  const __dirname = dirname(fileURLToPath(import.meta.url));
16
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";
17
28
 
18
29
  const [, , command = "start", ...rest] = process.argv;
19
30
 
20
31
  const commands = {
21
- start: ["npx", "next", "start", "-p", "5555", ...rest],
22
- 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
+ ],
23
44
  };
24
45
 
25
46
  if (!commands[command]) {
@@ -28,14 +49,32 @@ if (!commands[command]) {
28
49
  process.exit(1);
29
50
  }
30
51
 
31
- function runCommand(bin, args, env) {
52
+ function runCommand(bin, args, env, cwd) {
32
53
  return new Promise((resolvePromise, rejectPromise) => {
33
- const child = spawn(bin, args, {
34
- cwd: projectRoot,
35
- stdio: "inherit",
36
- shell: false,
37
- env,
38
- });
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
+ });
39
78
 
40
79
  child.on("error", (err) => {
41
80
  rejectPromise(err);
@@ -47,23 +86,83 @@ function runCommand(bin, args, env) {
47
86
  });
48
87
  }
49
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
+ }
119
+
50
120
  async function main() {
121
+ const runRoot = inNodeModules ? prepareRuntimeRoot() : projectRoot;
51
122
  const env = {
52
123
  ...process.env,
53
124
  NODE_ENV: command === "dev" ? "development" : "production",
54
125
  };
55
126
 
56
- // Production mode requires a Next build. For global installs, build once automatically.
57
- if (command === "start" && !existsSync(resolve(projectRoot, ".next", "BUILD_ID"))) {
58
- console.log("[kronosys] No production build found. Running `next build`...");
59
- const buildCode = await runCommand("npx", ["next", "build", "--webpack"], env);
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
+ );
60
159
  if (buildCode !== 0) {
61
160
  process.exit(buildCode);
62
161
  }
63
162
  }
64
163
 
65
164
  const [bin, ...args] = commands[command];
66
- const code = await runCommand(bin, args, env);
165
+ const code = await runCommand(bin, args, env, runRoot);
67
166
  process.exit(code);
68
167
  }
69
168
 
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.1",
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
+ }