ctate 0.0.0 → 0.1.0

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/Cargo.toml ADDED
@@ -0,0 +1,12 @@
1
+ [package]
2
+ name = "ctate"
3
+ version = "0.1.0"
4
+ edition = "2021"
5
+ description = "A ratatui version of ctate.dev"
6
+ license = "MIT"
7
+ publish = false
8
+
9
+ [dependencies]
10
+ crossterm = "0.28"
11
+ ratatui = { version = "0.29", default-features = false, features = ["crossterm"] }
12
+ webbrowser = "1.0"
package/README.md CHANGED
@@ -1,3 +1,28 @@
1
1
  # ctate
2
2
 
3
- Coming soon.
3
+ A ratatui version of [ctate.dev](https://ctate.dev).
4
+
5
+ ```bash
6
+ npx ctate
7
+ ```
8
+
9
+ Use the arrow keys or `j`/`k` to select a project, then press Enter to open it in your browser. Press `g` to open GitHub and `q` to quit.
10
+
11
+ ## Development
12
+
13
+ ```bash
14
+ npm run dev
15
+ npm run check
16
+ npm test
17
+ ```
18
+
19
+ ## Publishing
20
+
21
+ Build the Rust binary and prepare the npm artifact:
22
+
23
+ ```bash
24
+ npm run prepare:npm
25
+ npm publish
26
+ ```
27
+
28
+ `prepare:npm` writes the current platform binary to `dist/ctate-<platform>-<arch>`. The npm launcher uses that binary when it exists and falls back to `cargo run --release` when the source is present.
package/bin/ctate.js ADDED
@@ -0,0 +1,45 @@
1
+ #!/usr/bin/env node
2
+ import { spawnSync } from "node:child_process";
3
+ import { existsSync } from "node:fs";
4
+ import { dirname, join, resolve } from "node:path";
5
+ import { fileURLToPath } from "node:url";
6
+
7
+ const currentFile = fileURLToPath(import.meta.url);
8
+ const packageRoot = resolve(dirname(currentFile), "..");
9
+ const exe = process.platform === "win32" ? ".exe" : "";
10
+ const localBinary = join(packageRoot, "target", "release", `ctate${exe}`);
11
+ const binary = join(packageRoot, "dist", `ctate-${process.platform}-${process.arch}${exe}`);
12
+ const cargoManifest = join(packageRoot, "Cargo.toml");
13
+ const args = process.argv.slice(2);
14
+
15
+ let result;
16
+
17
+ if (existsSync(localBinary)) {
18
+ result = spawnSync(localBinary, args, { stdio: "inherit" });
19
+ } else if (existsSync(binary)) {
20
+ result = spawnSync(binary, args, { stdio: "inherit" });
21
+ } else if (existsSync(cargoManifest)) {
22
+ result = spawnSync("cargo", ["run", "--quiet", "--release", "--", ...args], {
23
+ cwd: packageRoot,
24
+ shell: process.platform === "win32",
25
+ stdio: "inherit"
26
+ });
27
+ } else {
28
+ console.error(`ctate: no binary found for ${process.platform}-${process.arch}.`);
29
+ process.exit(1);
30
+ }
31
+
32
+ if (result.error) {
33
+ if (result.error.code === "ENOENT") {
34
+ console.error(`ctate: no binary found for ${process.platform}-${process.arch}, and Cargo is not installed.`);
35
+ } else {
36
+ console.error(`ctate: ${result.error.message}`);
37
+ }
38
+ process.exit(1);
39
+ }
40
+
41
+ if (result.signal) {
42
+ process.kill(process.pid, result.signal);
43
+ }
44
+
45
+ process.exit(result.status ?? 0);
Binary file
package/package.json CHANGED
@@ -1,12 +1,37 @@
1
1
  {
2
2
  "name": "ctate",
3
- "version": "0.0.0",
4
- "description": "Coming soon",
5
- "main": "index.js",
6
- "author": "",
3
+ "version": "0.1.0",
4
+ "description": "A ratatui version of ctate.dev.",
5
+ "type": "module",
6
+ "bin": {
7
+ "ctate": "bin/ctate.js"
8
+ },
9
+ "files": [
10
+ "bin/",
11
+ "dist/",
12
+ "scripts/",
13
+ "src/",
14
+ "Cargo.toml",
15
+ "Cargo.lock",
16
+ "README.md"
17
+ ],
18
+ "scripts": {
19
+ "dev": "cargo run",
20
+ "check": "cargo check",
21
+ "test": "cargo test",
22
+ "build": "cargo build",
23
+ "build:release": "cargo build --release",
24
+ "prepare:npm": "npm run build:release && node ./scripts/copy-binary.mjs",
25
+ "prepack": "npm run prepare:npm"
26
+ },
27
+ "keywords": [
28
+ "ctate",
29
+ "tui",
30
+ "ratatui",
31
+ "terminal"
32
+ ],
7
33
  "license": "MIT",
8
- "repository": {
9
- "type": "git",
10
- "url": ""
34
+ "engines": {
35
+ "node": ">=18"
11
36
  }
12
- }
37
+ }
@@ -0,0 +1,22 @@
1
+ import { chmodSync, copyFileSync, existsSync, mkdirSync } from "node:fs";
2
+ import { dirname, join, resolve } from "node:path";
3
+ import { fileURLToPath } from "node:url";
4
+
5
+ const currentFile = fileURLToPath(import.meta.url);
6
+ const packageRoot = resolve(dirname(currentFile), "..");
7
+ const exe = process.platform === "win32" ? ".exe" : "";
8
+ const source = join(packageRoot, "target", "release", `ctate${exe}`);
9
+ const dist = join(packageRoot, "dist");
10
+ const target = join(dist, `ctate-${process.platform}-${process.arch}${exe}`);
11
+
12
+ if (!existsSync(source)) {
13
+ console.error(`Missing release binary: ${source}`);
14
+ console.error("Run `npm run build:release` before copying the npm binary.");
15
+ process.exit(1);
16
+ }
17
+
18
+ mkdirSync(dist, { recursive: true });
19
+ copyFileSync(source, target);
20
+ chmodSync(target, 0o755);
21
+
22
+ console.log(`Wrote ${target}`);