@chiendt/ack-cli 0.0.0-dev.5

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/ack.js ADDED
@@ -0,0 +1,56 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * CLI entry point for npm-installed ACK CLI.
5
+ * Runs the packaged Node-targeted bundle without requiring Bun on user machines.
6
+ */
7
+
8
+ import { existsSync } from "node:fs";
9
+ import { dirname, join } from "node:path";
10
+ import { fileURLToPath, pathToFileURL } from "node:url";
11
+
12
+ const MIN_NODE_VERSION = [18, 0];
13
+ const __dirname = dirname(fileURLToPath(import.meta.url));
14
+
15
+ const getErrorMessage = (err) => {
16
+ return err instanceof Error ? err.message : String(err);
17
+ };
18
+
19
+ const checkNodeVersion = () => {
20
+ const [major, minor] = process.versions.node.split(".").map(Number);
21
+ const [minMajor, minMinor] = MIN_NODE_VERSION;
22
+
23
+ if (major < minMajor || (major === minMajor && minor < minMinor)) {
24
+ console.error(
25
+ `[X] Node.js ${MIN_NODE_VERSION.join(".")}+ is required. Current version: ${process.versions.node}`,
26
+ );
27
+ console.error(" Please upgrade Node.js: https://nodejs.org/");
28
+ process.exit(1);
29
+ }
30
+ };
31
+
32
+ const runWithNode = async () => {
33
+ const distPath = join(__dirname, "..", "dist", "index.js");
34
+ if (!existsSync(distPath)) {
35
+ throw new Error(
36
+ "Compiled distribution not found. Reinstall ACK CLI or report a packaging issue.",
37
+ );
38
+ }
39
+
40
+ const distUrl = pathToFileURL(distPath).href;
41
+ await import(distUrl);
42
+ };
43
+
44
+ const main = async () => {
45
+ checkNodeVersion();
46
+
47
+ try {
48
+ await runWithNode();
49
+ } catch (err) {
50
+ console.error(`[X] Failed to run CLI: ${getErrorMessage(err)}`);
51
+ console.error("Please report this issue at: https://github.com/chiendt1108/ack-cli/issues");
52
+ process.exit(1);
53
+ }
54
+ };
55
+
56
+ main();