@timmy6942025/cli-timer 1.0.0 → 1.0.1

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/README.md CHANGED
@@ -96,6 +96,14 @@ Open interactive settings UI:
96
96
  timer settings
97
97
  ```
98
98
 
99
+ `timer settings` ships with prebuilt Bubble Tea binaries for:
100
+
101
+ - Linux x64 / arm64
102
+ - macOS x64 / arm64
103
+ - Windows x64 / arm64
104
+
105
+ If your platform is unsupported, it falls back to running the Go source (`go run`) when Go is installed.
106
+
99
107
  This launches a Bubble Tea based screen where you can change:
100
108
 
101
109
  - Font
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@timmy6942025/cli-timer",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Simple customizable terminal timer and stopwatch",
5
5
  "main": "src/index.js",
6
6
  "bin": {
package/src/index.js CHANGED
@@ -5,6 +5,7 @@ const { spawnSync } = require("child_process");
5
5
  const figlet = require("figlet");
6
6
 
7
7
  const PROJECT_ROOT = path.join(__dirname, "..");
8
+ const PREBUILT_SETTINGS_UI_DIR = path.join(PROJECT_ROOT, "settings-ui", "prebuilt");
8
9
  const CONFIG_DIR = path.join(os.homedir(), ".cli-timer");
9
10
  const CONFIG_PATH = path.join(CONFIG_DIR, "config.json");
10
11
  const SETTINGS_STATE_PATH = path.join(CONFIG_DIR, "settings-state.json");
@@ -645,11 +646,52 @@ function runSettingsUI() {
645
646
 
646
647
  ensureConfigDir();
647
648
 
648
- const goVersion = spawnSync("go", ["version"], { stdio: "ignore" });
649
- if (goVersion.error || goVersion.status !== 0) {
650
- process.stderr.write("Go is required for `timer settings` (Bubble Tea UI).\n");
651
- process.exitCode = 1;
652
- return;
649
+ const platformMap = {
650
+ linux: "linux",
651
+ darwin: "darwin",
652
+ win32: "windows"
653
+ };
654
+ const archMap = {
655
+ x64: "x64",
656
+ arm64: "arm64"
657
+ };
658
+
659
+ function getSettingsBinaryTarget() {
660
+ const platform = platformMap[process.platform];
661
+ const arch = archMap[process.arch];
662
+ if (!platform || !arch) {
663
+ return null;
664
+ }
665
+ return `${platform}-${arch}`;
666
+ }
667
+
668
+ function getPrebuiltSettingsBinaryPath() {
669
+ const target = getSettingsBinaryTarget();
670
+ if (!target) {
671
+ return null;
672
+ }
673
+ const binaryName = process.platform === "win32" ? "cli-timer-settings-ui.exe" : "cli-timer-settings-ui";
674
+ const fullPath = path.join(PREBUILT_SETTINGS_UI_DIR, target, binaryName);
675
+ if (!fs.existsSync(fullPath)) {
676
+ return null;
677
+ }
678
+ return fullPath;
679
+ }
680
+
681
+ function hasGoToolchain() {
682
+ const goVersion = spawnSync("go", ["version"], { stdio: "ignore" });
683
+ return !(goVersion.error || goVersion.status !== 0);
684
+ }
685
+
686
+ function runPrebuiltSettingsUI(binaryPath) {
687
+ return spawnSync(binaryPath, ["--state", SETTINGS_STATE_PATH], { stdio: "inherit" });
688
+ }
689
+
690
+ function runGoSettingsUI() {
691
+ return spawnSync("go", ["run", ".", "--state", SETTINGS_STATE_PATH], {
692
+ cwd: path.join(PROJECT_ROOT, "settings-ui"),
693
+ stdio: "inherit"
694
+ });
653
695
  }
654
696
 
655
697
  const state = {
@@ -660,16 +702,39 @@ function runSettingsUI() {
660
702
 
661
703
  fs.writeFileSync(SETTINGS_STATE_PATH, JSON.stringify(state), "utf8");
662
704
 
663
- const result = spawnSync("go", ["run", ".", "--state", SETTINGS_STATE_PATH], {
664
- cwd: path.join(PROJECT_ROOT, "settings-ui"),
665
- stdio: "inherit"
666
- });
705
+ let result;
706
+ const prebuiltPath = getPrebuiltSettingsBinaryPath();
707
+ const canRunGo = hasGoToolchain();
708
+
709
+ if (prebuiltPath) {
710
+ result = runPrebuiltSettingsUI(prebuiltPath);
711
+ if (result.error && canRunGo) {
712
+ result = runGoSettingsUI();
713
+ }
714
+ } else if (canRunGo) {
715
+ result = runGoSettingsUI();
716
+ } else {
717
+ const target = getSettingsBinaryTarget();
718
+ if (target) {
719
+ process.stderr.write(`No prebuilt settings UI binary for ${target}, and Go is not installed.\n`);
720
+ } else {
721
+ process.stderr.write(
722
+ `No prebuilt settings UI binary for ${process.platform}/${process.arch}, and Go is not installed.\n`
723
+ );
724
+ }
725
+ process.stderr.write("Install Go or use a supported platform for `timer settings`.\n");
726
+ process.exitCode = 1;
727
+ }
667
728
 
668
729
  try {
669
730
  fs.unlinkSync(SETTINGS_STATE_PATH);
670
731
  } catch (_error) {
671
732
  }
672
733
 
734
+ if (!result) {
735
+ return;
736
+ }
737
+
673
738
  if (result.error) {
674
739
  process.stderr.write(`Failed to run settings UI: ${result.error.message}\n`);
675
740
  process.exitCode = 1;