@n-seiji/nuthatch 0.1.5 → 0.2.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.
@@ -0,0 +1,25 @@
1
+ // src/domain/posix-path.ts
2
+ var withoutTrailingSlash = (path) => path.length > 1 && path.endsWith("/") ? path.slice(0, -1) : path;
3
+ var shortenHome = (path, home) => {
4
+ if (home === "" || home === "/") {
5
+ return path;
6
+ }
7
+ if (path === home) {
8
+ return "~";
9
+ }
10
+ return path.startsWith(`${home}/`) ? `~${path.slice(home.length)}` : path;
11
+ };
12
+ var parentDir = (path) => {
13
+ const trimmed = withoutTrailingSlash(path);
14
+ const index = trimmed.lastIndexOf("/");
15
+ if (index === -1) {
16
+ return ".";
17
+ }
18
+ return index === 0 ? "/" : trimmed.slice(0, index);
19
+ };
20
+ var absoluteCandidates = (dirs, name) => [
21
+ ...new Set(dirs.map((entry) => entry.trim()).filter((entry) => entry.startsWith("/")).map((dir) => `${dir.endsWith("/") ? dir.slice(0, -1) : dir}/${name}`))
22
+ ];
23
+ var splitPathEnv = (pathEnv) => (pathEnv ?? "").split(":");
24
+
25
+ export { shortenHome, parentDir, absoluteCandidates, splitPathEnv };
@@ -0,0 +1,87 @@
1
+ import {
2
+ describeFatalError
3
+ } from "./cli-ph0gp56k.js";
4
+ import {
5
+ reportResult
6
+ } from "./cli-dbzx9nzg.js";
7
+ import {
8
+ fail
9
+ } from "./cli-77yanq37.js";
10
+
11
+ // src/cli-dispatch.ts
12
+ var normalizeCliArgs = (rawArgs, argv0, isCompiledBinary) => isCompiledBinary && rawArgs.length === 1 && rawArgs[0] === argv0 ? [] : rawArgs;
13
+ var isRunningAsCompiledBinary = () => typeof Bun !== "undefined" && Bun.main.startsWith("/$bunfs/");
14
+ var isUpdateRequest = (rawArgs) => rawArgs[0] === "--update";
15
+ var HELP_FLAGS = new Set(["--help", "-h", "help"]);
16
+ var UPDATE_HELP_FLAGS = new Set(["--help", "-h"]);
17
+ var isHelpRequest = (rawArgs) => rawArgs.length > 0 && (HELP_FLAGS.has(rawArgs[0] ?? "") || isUpdateRequest(rawArgs) && rawArgs.slice(1).some((token) => UPDATE_HELP_FLAGS.has(token)));
18
+ var isVersionRequest = (rawArgs) => rawArgs[0] === "--version";
19
+ var dispatchCliArgs = (rawArgs, reservedNames) => {
20
+ const [first, ...rest] = rawArgs;
21
+ if (first === "--") {
22
+ return { kind: "jump", args: rest };
23
+ }
24
+ if (first !== undefined && reservedNames.includes(first)) {
25
+ return { kind: "reserved", name: first, args: rest };
26
+ }
27
+ return { kind: "jump", args: rawArgs };
28
+ };
29
+
30
+ // src/cli-fatal.ts
31
+ var wantsJson = (args) => args.some((arg) => arg === "--json" || arg.startsWith("--json="));
32
+ var reportFatalError = (command, json, error) => {
33
+ const fatal = describeFatalError(error);
34
+ const result = fail(fatal.exitCode, `hop: ${fatal.message}`);
35
+ reportResult(command, result, json);
36
+ };
37
+ // package.json
38
+ var package_default = {
39
+ name: "@n-seiji/nuthatch",
40
+ version: "0.2.1",
41
+ description: "git worktree manager (hop)",
42
+ homepage: "https://github.com/n-seiji/nuthatch#readme",
43
+ bugs: {
44
+ url: "https://github.com/n-seiji/nuthatch/issues"
45
+ },
46
+ license: "GPL-3.0-only",
47
+ repository: {
48
+ type: "git",
49
+ url: "git+https://github.com/n-seiji/nuthatch.git"
50
+ },
51
+ bin: {
52
+ hop: "dist/cli.js"
53
+ },
54
+ files: [
55
+ "dist"
56
+ ],
57
+ type: "module",
58
+ publishConfig: {
59
+ access: "public"
60
+ },
61
+ scripts: {
62
+ build: "bun build ./src/cli.ts --outdir dist --target node --format esm --splitting",
63
+ typecheck: "tsc --noEmit",
64
+ lint: "oxlint .",
65
+ "lint:fix": "oxlint . --fix",
66
+ format: "oxfmt --write .",
67
+ "format:check": "oxfmt --check .",
68
+ test: "bun test"
69
+ },
70
+ dependencies: {
71
+ valibot: "^1.4.2"
72
+ },
73
+ devDependencies: {
74
+ "@types/bun": "latest",
75
+ oxfmt: "^0.72.0",
76
+ oxlint: "^1.81.0",
77
+ typescript: "^5.6.0"
78
+ },
79
+ engines: {
80
+ node: ">=22"
81
+ }
82
+ };
83
+
84
+ // src/version.ts
85
+ var VERSION = package_default.version;
86
+
87
+ export { normalizeCliArgs, isRunningAsCompiledBinary, isUpdateRequest, isHelpRequest, isVersionRequest, dispatchCliArgs, wantsJson, reportFatalError, VERSION };