@nightkatana/kronosys-app 1.0.0-beta.1 → 1.0.0-beta.11

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,40 @@
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";
28
+ const psBin = process.platform === "win32" ? "powershell.exe" : null;
17
29
 
18
30
  const [, , command = "start", ...rest] = process.argv;
19
31
 
20
32
  const commands = {
21
- start: ["npx", "next", "start", "-p", "5555", ...rest],
22
- dev: ["npx", "next", "dev", "--webpack", "-H", "kronosys", "-p", "5555", ...rest],
33
+ start: [npxBin, "next", "start", "-p", "5555", ...rest],
34
+ dev: [
35
+ npxBin,
36
+ "next",
37
+ "dev",
38
+ "--webpack",
39
+ "-H",
40
+ "kronosys",
41
+ "-p",
42
+ "5555",
43
+ ...rest,
44
+ ],
23
45
  };
24
46
 
25
47
  if (!commands[command]) {
@@ -28,14 +50,34 @@ if (!commands[command]) {
28
50
  process.exit(1);
29
51
  }
30
52
 
31
- function runCommand(bin, args, env) {
53
+ function runCommand(bin, args, env, cwd) {
32
54
  return new Promise((resolvePromise, rejectPromise) => {
33
- const child = spawn(bin, args, {
34
- cwd: projectRoot,
35
- stdio: "inherit",
36
- shell: false,
37
- env,
38
- });
55
+ const windowsArg = (arg) => `'${String(arg).replaceAll("'", "''")}'`;
56
+
57
+ const child = isWindows
58
+ ? spawn(
59
+ psBin,
60
+ [
61
+ "-NoLogo",
62
+ "-NoProfile",
63
+ "-ExecutionPolicy",
64
+ "Bypass",
65
+ "-Command",
66
+ "& " + [bin, ...args].map(windowsArg).join(" "),
67
+ ],
68
+ {
69
+ cwd,
70
+ stdio: "inherit",
71
+ shell: false,
72
+ env,
73
+ },
74
+ )
75
+ : spawn(bin, args, {
76
+ cwd,
77
+ stdio: "inherit",
78
+ shell: false,
79
+ env,
80
+ });
39
81
 
40
82
  child.on("error", (err) => {
41
83
  rejectPromise(err);
@@ -47,23 +89,100 @@ function runCommand(bin, args, env) {
47
89
  });
48
90
  }
49
91
 
92
+ function prepareRuntimeRoot() {
93
+ const runtimeRoot = resolve(
94
+ homedir(),
95
+ ".kronosys",
96
+ "runtime",
97
+ String(packageVersion),
98
+ );
99
+ const runtimePackageJson = resolve(runtimeRoot, "package.json");
100
+
101
+ if (!existsSync(runtimePackageJson)) {
102
+ mkdirSync(runtimeRoot, { recursive: true });
103
+ cpSync(projectRoot, runtimeRoot, {
104
+ recursive: true,
105
+ force: true,
106
+ filter: (src) => {
107
+ const normalized = src.replaceAll("\\", "/");
108
+ const rel = normalized
109
+ .replace(projectRoot.replaceAll("\\", "/"), "")
110
+ .replace(/^\/+/, "");
111
+ if (!rel) return true;
112
+ if (rel === ".next" || rel.startsWith(".next/")) return false;
113
+ if (rel === "node_modules" || rel.startsWith("node_modules/"))
114
+ return false;
115
+ return true;
116
+ },
117
+ });
118
+ }
119
+
120
+ return runtimeRoot;
121
+ }
122
+
50
123
  async function main() {
124
+ const runRoot = inNodeModules ? prepareRuntimeRoot() : projectRoot;
51
125
  const env = {
52
126
  ...process.env,
53
127
  NODE_ENV: command === "dev" ? "development" : "production",
54
128
  };
55
129
 
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);
130
+ // Global installs live under node_modules; install runtime deps in copied runtime dir.
131
+ if (inNodeModules && !existsSync(resolve(runRoot, "node_modules"))) {
132
+ console.log("[kronosys] Installing runtime dependencies...");
133
+ const installCode = await runCommand(
134
+ npmBin,
135
+ ["install", "--omit=dev", "--no-audit", "--no-fund"],
136
+ {
137
+ ...env,
138
+ HUSKY: "0",
139
+ npm_config_cache:
140
+ process.env.npm_config_cache ?? resolve(homedir(), ".npm"),
141
+ },
142
+ runRoot,
143
+ );
144
+ if (installCode !== 0) {
145
+ process.exit(installCode);
146
+ }
147
+
148
+ // Ensure native bindings are present for the current OS/ABI.
149
+ const rebuildCode = await runCommand(
150
+ npmBin,
151
+ ["rebuild", "better-sqlite3", "--no-audit", "--no-fund"],
152
+ {
153
+ ...env,
154
+ HUSKY: "0",
155
+ npm_config_cache:
156
+ process.env.npm_config_cache ?? resolve(homedir(), ".npm"),
157
+ },
158
+ runRoot,
159
+ );
160
+ if (rebuildCode !== 0) {
161
+ process.exit(rebuildCode);
162
+ }
163
+ }
164
+
165
+ // Production mode requires a Next build. Build once on first run.
166
+ if (
167
+ command === "start" &&
168
+ !existsSync(resolve(runRoot, ".next", "BUILD_ID"))
169
+ ) {
170
+ console.log(
171
+ "[kronosys] No production build found. Running `next build`...",
172
+ );
173
+ const buildCode = await runCommand(
174
+ npxBin,
175
+ ["next", "build", "--webpack"],
176
+ env,
177
+ runRoot,
178
+ );
60
179
  if (buildCode !== 0) {
61
180
  process.exit(buildCode);
62
181
  }
63
182
  }
64
183
 
65
184
  const [bin, ...args] = commands[command];
66
- const code = await runCommand(bin, args, env);
185
+ const code = await runCommand(bin, args, env, runRoot);
67
186
  process.exit(code);
68
187
  }
69
188
 
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.11",
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
+ }