@williamthorsen/toolbelt.git 0.0.0 → 0.3.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/CHANGELOG.md ADDED
@@ -0,0 +1,29 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ ## 0.3.0 — 2026-08-30
6
+
7
+ ### Features
8
+
9
+ - Add a tb-git CLI for branch-number and ticket-ref (#250)
10
+
11
+ Adds a `tb-git` command to `@williamthorsen/toolbelt.git`, enabling the use of `deriveBranchNumber` and `findBranchTicketRef` on the command line. `tb-git branch-number` prints the number derived from a branch name; `tb-git ticket-ref` prints the ID of the ticket encoded by the name, or the whole ref when the `--json` option is used. Both take an optional branch name and otherwise use the checked-out branch.
12
+
13
+ ## 0.2.0 — 2026-08-28
14
+
15
+ ### Features
16
+
17
+ - Add findBranchTicketRef and deriveBranchNumber to toolbelt.git (#239)
18
+
19
+ Adds `findBranchTicketRef` and `deriveBranchNumber` to `@williamthorsen/toolbelt.git` at the candidate tier.
20
+
21
+ `findBranchTicketRef` extracts the ticket ID encoded in a branch name. `deriveBranchNumber` relies on it to give every branch a stable number: the ticket's if the branch name includes one, and otherwise a `hashString` digest of the name. The number is bounded by the caller-specified range.
22
+
23
+ ### Internal
24
+
25
+ - Scaffold toolbelt.git for git utilities (#235)
26
+
27
+ Adds `packages/git`, an empty `@williamthorsen/toolbelt.git` at version `0.1.0` with its four maturity tiers in place.
28
+
29
+ <!-- Generated by release-kit. Do not edit this file. Use .meta/changelog-overrides.json to override entries. -->
package/LICENSE ADDED
@@ -0,0 +1,7 @@
1
+ ISC License
2
+
3
+ Copyright (c) 2026 William Thorsen
4
+
5
+ Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
6
+
7
+ The software is provided "as is" and the author disclaims all warranties with regard to this software including all implied warranties of merchantability and fitness. In no event shall the author be liable for any special, direct, indirect, or consequential damages or any damages whatsoever resulting from loss of use, data or profits, whether in an action of contract, negligence or other tortious action, arising out of or in connection with the use or performance of this software.
package/README.md CHANGED
@@ -1 +1,165 @@
1
- Placeholder for `@williamthorsen/toolbelt.git` — awaiting first release.
1
+ # @williamthorsen/toolbelt.git
2
+
3
+ Utilities for working with git.
4
+
5
+ <!-- section:release-notes -->
6
+ ## Release notes — v0.3.0 (2026-08-30)
7
+
8
+ ### Features
9
+
10
+ - Add a tb-git CLI for branch-number and ticket-ref (#250)
11
+
12
+ Adds a `tb-git` command to `@williamthorsen/toolbelt.git`, enabling the use of `deriveBranchNumber` and `findBranchTicketRef` on the command line. `tb-git branch-number` prints the number derived from a branch name; `tb-git ticket-ref` prints the ID of the ticket encoded by the name, or the whole ref when the `--json` option is used. Both take an optional branch name and otherwise use the checked-out branch.
13
+ <!-- /section:release-notes -->
14
+
15
+ ## Installation
16
+
17
+ ```sh
18
+ pnpm add @williamthorsen/toolbelt.git
19
+ ```
20
+
21
+ Requires Node.js 24 or later.
22
+
23
+ ## CLI
24
+
25
+ The package ships a `tb-git` command exposing the same functions to a shell caller.
26
+
27
+ ```sh
28
+ pnpm add --global @williamthorsen/toolbelt.git # puts tb-git on PATH
29
+ npx @williamthorsen/toolbelt.git branch-number # or run it without installing
30
+ ```
31
+
32
+ The short `npx` form works because the package declares exactly one bin, which npm falls back to whatever its name. Were a second bin added, the invocation would become `npx --package @williamthorsen/toolbelt.git tb-git ...`.
33
+
34
+ `tb-git --help`, each subcommand's `--help`, and `tb-git --version` report the surface and the installed version.
35
+
36
+ ### `tb-git branch-number [<branch>] [options]`
37
+
38
+ Prints [`deriveBranchNumber`](#derivebranchnumber)'s result.
39
+
40
+ | Option | Effect |
41
+ | ------------ | ----------------------------------------------- |
42
+ | `--key K` | The project's ticket key, matched in any casing |
43
+ | `--max N` | Upper bound, inclusive (default 4294967295) |
44
+ | `--min N` | Lower bound, inclusive (default 0) |
45
+ | `--offset N` | Rotate the result within the bounds |
46
+
47
+ ```sh
48
+ tb-git branch-number 232_add-widget --min 3000 --max 3999
49
+ # 3232
50
+ ```
51
+
52
+ A negative offset takes the `=` form, `--offset=-3`: a bare `-3` reads as an option rather than as the value.
53
+
54
+ ### `tb-git ticket-ref [<branch>] [options]`
55
+
56
+ Prints [`findBranchTicketRef`](#findbranchticketref)'s `id`.
57
+
58
+ | Option | Effect |
59
+ | --------- | ----------------------------------------------- |
60
+ | `--json` | Print the whole ref on one line as JSON |
61
+ | `--key K` | The project's ticket key, matched in any casing |
62
+
63
+ ```sh
64
+ tb-git ticket-ref wt/MAC-22.1-add-widget
65
+ # MAC-22
66
+
67
+ tb-git ticket-ref wt/MAC-22.1-add-widget --json
68
+ # {"id":"MAC-22","key":"MAC","number":22,"revisit":1}
69
+ ```
70
+
71
+ ### The branch argument
72
+
73
+ With no `<branch>`, both subcommands resolve the checked-out branch with `git branch --show-current`, which reports a worktree's own branch. A directory that is not a repository, an absent git, and a detached HEAD each fail rather than falling back to a derived value. An empty argument is an error too, so `tb-git ticket-ref "$BRANCH"` with `BRANCH` unset fails instead of quietly using the current branch.
74
+
75
+ ### Exit codes
76
+
77
+ | Code | Meaning |
78
+ | ---- | ----------------------------------------------------------------------- |
79
+ | `0` | A result was printed |
80
+ | `1` | `ticket-ref` found no ticket in the branch name; both streams are empty |
81
+ | `2` | Usage or validation error, with the message on stderr |
82
+
83
+ A bound, offset, or key rejected by the library exits `2` carrying the message it raises. So does an empty option value, so `--min "$PORT_MIN"` with `PORT_MIN` unset fails instead of bounding at `0`.
84
+
85
+ ```sh
86
+ if ref=$(tb-git ticket-ref); then
87
+ echo "on ticket $ref"
88
+ fi
89
+ ```
90
+
91
+ ## `findBranchTicketRef`
92
+
93
+ ```ts
94
+ findBranchTicketRef(branch: string, options?: { key?: string }): BranchTicketRef | undefined;
95
+
96
+ interface BranchTicketRef {
97
+ readonly id: string;
98
+ readonly key?: string | undefined;
99
+ readonly number: number;
100
+ readonly revisit?: number | undefined;
101
+ }
102
+ ```
103
+
104
+ Finds the ticket encoded by a branch name, or `undefined` when it encodes none.
105
+
106
+ ```ts
107
+ import { findBranchTicketRef } from '@williamthorsen/toolbelt.git/candidate';
108
+
109
+ findBranchTicketRef('wt/MAC-22.1-add-widget');
110
+ // { id: 'MAC-22', key: 'MAC', number: 22, revisit: 1 }
111
+
112
+ findBranchTicketRef('232_add-widget');
113
+ // { id: '232', number: 232 }
114
+ ```
115
+
116
+ A ref must begin a segment. `/` and `_` both delimit one, so an author prefix and a worktree-safe spelling parse alike, and the leftmost segment carrying a ref wins. Anchoring to a segment is what keeps a kebab-case description from reading as a ticket: `feat/add-widget-2` encodes none, because `widget` follows a hyphen rather than a separator.
117
+
118
+ Two forms are recognized, each taking an optional `.N` revisit suffix. A **keyed** ref is a Jira-style key and number, the key matching Jira's own rule of a letter followed by letters and digits. A **bare-numeric** ref is the number alone. `id` and `key` are emitted uppercased, since a branch name may be lowercase but the ticket it names is `MAC-22`.
119
+
120
+ By default a key must be uppercase, which is what Jira permits and the only property separating a real key from an ordinary word: without it, `feat-2` would read as ticket `FEAT-2`. Declaring the project's own key through `key` is both more permissive and more precise, since it then matches in any casing and is the only key that matches at all.
121
+
122
+ ```ts
123
+ findBranchTicketRef('mac-22/add-widget');
124
+ // undefined -- a lowercase key with none declared
125
+
126
+ findBranchTicketRef('mac-22/add-widget', { key: 'mac' });
127
+ // { id: 'MAC-22', key: 'MAC', number: 22 }
128
+
129
+ findBranchTicketRef('feat-2', { key: 'mac' });
130
+ // undefined -- `feat` is not the declared key
131
+ ```
132
+
133
+ The bare-numeric form stays active whether or not a key is declared. A `RangeError` names the fault when `key` is not a well-formed key, which would otherwise match nothing at all.
134
+
135
+ A trailing `-N` is not read as a sub-ID, being indistinguishable from a description: `232-3-column-layout` carries no revisit. Neither suffix affects `number`.
136
+
137
+ ## `deriveBranchNumber`
138
+
139
+ ```ts
140
+ deriveBranchNumber(branch: string, options?: { key?: string; max?: number; min?: number; offset?: number }): number;
141
+ ```
142
+
143
+ Derives a number from a branch name, for a port offset, a bucket, or any slot that must stay stable across checkouts of the same branch.
144
+
145
+ ```ts
146
+ import { deriveBranchNumber } from '@williamthorsen/toolbelt.git/candidate';
147
+
148
+ deriveBranchNumber('232_add-widget');
149
+ // 232
150
+
151
+ deriveBranchNumber('main');
152
+ // 663286764
153
+ ```
154
+
155
+ The number is the ticket's when the branch names one, and a [`hashString`](https://github.com/williamthorsen/toolbelt/tree/main/packages/strings#hashstring) digest of the whole name when it does not, so every branch yields something. `min`, `max`, and `offset` are `hashString`'s, and apply to both paths alike: the two land in one range, and `offset` stays a pure rotation.
156
+
157
+ ```ts
158
+ deriveBranchNumber('232_add-widget', { min: 3000, max: 3999 });
159
+ // 3232
160
+
161
+ deriveBranchNumber('refactor/tidy-imports', { min: 3000, max: 3999 });
162
+ // 3508
163
+ ```
164
+
165
+ A number that overruns the range wraps into it, so `deriveBranchNumber('1232', { max: 999 })` is `232`. `key` is passed through to `findBranchTicketRef`, and a bad `key`, bound, or offset raises the same `RangeError` whether or not the branch names a ticket.
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,7 @@
1
+ import { type BranchTicketRefOptions } from './findBranchTicketRef.js';
2
+ export declare function deriveBranchNumber(branch: string, options?: DeriveBranchNumberOptions): number;
3
+ export interface DeriveBranchNumberOptions extends BranchTicketRefOptions {
4
+ readonly max?: number | undefined;
5
+ readonly min?: number | undefined;
6
+ readonly offset?: number | undefined;
7
+ }
@@ -0,0 +1,14 @@
1
+ import { hashString } from '@williamthorsen/toolbelt.strings/candidate';
2
+ import { findBranchTicketRef } from "./findBranchTicketRef.js";
3
+ const MAX_UINT32 = 0xffff_ffff;
4
+ export function deriveBranchNumber(branch, options = {}) {
5
+ const digest = hashString(branch, options);
6
+ const ref = findBranchTicketRef(branch, options);
7
+ return ref === undefined ? digest : wrapIntoRange(ref.number, options);
8
+ }
9
+ function wrapIntoRange(value, options) {
10
+ const { max = MAX_UINT32, min = 0, offset = 0 } = options;
11
+ const size = max - min + 1;
12
+ const shift = ((offset % size) + size) % size;
13
+ return min + ((value + shift) % size);
14
+ }
@@ -0,0 +1,10 @@
1
+ export declare function findBranchTicketRef(branch: string, options?: BranchTicketRefOptions): BranchTicketRef | undefined;
2
+ export interface BranchTicketRef {
3
+ readonly id: string;
4
+ readonly key?: string | undefined;
5
+ readonly number: number;
6
+ readonly revisit?: number | undefined;
7
+ }
8
+ export interface BranchTicketRefOptions {
9
+ readonly key?: string | undefined;
10
+ }
@@ -0,0 +1,39 @@
1
+ const SEGMENT_SEPARATOR = /[/_]/;
2
+ const REF_PATTERN = /^(?:(?<key>[A-Za-z][A-Za-z0-9]+)-)?(?<number>[0-9]+)(?:\.(?<revisit>[0-9]+))?/;
3
+ const KEY_PATTERN = /^[A-Za-z][A-Za-z0-9]+$/;
4
+ export function findBranchTicketRef(branch, options = {}) {
5
+ const { key: declaredKey } = options;
6
+ if (declaredKey !== undefined && !KEY_PATTERN.test(declaredKey)) {
7
+ const received = `Received ${JSON.stringify(declaredKey)}.`;
8
+ throw new RangeError(`Invalid key: a key must be a letter followed by letters or digits. ${received}`);
9
+ }
10
+ for (const segment of branch.split(SEGMENT_SEPARATOR)) {
11
+ const groups = REF_PATTERN.exec(segment)?.groups;
12
+ if (groups === undefined) {
13
+ continue;
14
+ }
15
+ const { key, number, revisit } = groups;
16
+ if (number !== undefined && isAcceptableKey(key, declaredKey)) {
17
+ return composeRef(key, number, revisit);
18
+ }
19
+ }
20
+ return undefined;
21
+ }
22
+ function composeRef(key, number, revisit) {
23
+ const canonicalKey = key?.toUpperCase();
24
+ return {
25
+ id: canonicalKey === undefined ? number : `${canonicalKey}-${number}`,
26
+ ...(canonicalKey !== undefined && { key: canonicalKey }),
27
+ number: Number(number),
28
+ ...(revisit !== undefined && { revisit: Number(revisit) }),
29
+ };
30
+ }
31
+ function isAcceptableKey(key, declaredKey) {
32
+ if (key === undefined) {
33
+ return true;
34
+ }
35
+ if (declaredKey !== undefined) {
36
+ return key.toLowerCase() === declaredKey.toLowerCase();
37
+ }
38
+ return key === key.toUpperCase();
39
+ }
@@ -0,0 +1,2 @@
1
+ export { deriveBranchNumber, type DeriveBranchNumberOptions } from './deriveBranchNumber.js';
2
+ export { type BranchTicketRef, type BranchTicketRefOptions, findBranchTicketRef } from './findBranchTicketRef.js';
@@ -0,0 +1,2 @@
1
+ export { deriveBranchNumber } from "./deriveBranchNumber.js";
2
+ export { findBranchTicketRef } from "./findBranchTicketRef.js";
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,7 @@
1
+ export declare function findOwningManifest(startDir: string): OwningManifest;
2
+ export interface OwningManifest {
3
+ readonly manifest: {
4
+ readonly version?: unknown;
5
+ };
6
+ readonly manifestPath: string;
7
+ }
@@ -0,0 +1,24 @@
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
+ export function findOwningManifest(startDir) {
4
+ let dir = startDir;
5
+ for (;;) {
6
+ const manifestPath = path.join(dir, 'package.json');
7
+ if (fs.existsSync(manifestPath)) {
8
+ const manifest = JSON.parse(fs.readFileSync(manifestPath, 'utf8'));
9
+ if (isNamedManifest(manifest))
10
+ return { manifest, manifestPath };
11
+ }
12
+ const parent = path.dirname(dir);
13
+ if (parent === dir)
14
+ throw new Error(`No package manifest declaring a name at or above ${startDir}.`);
15
+ dir = parent;
16
+ }
17
+ }
18
+ function isNamedManifest(value) {
19
+ return (typeof value === 'object' &&
20
+ value !== null &&
21
+ !Array.isArray(value) &&
22
+ 'name' in value &&
23
+ typeof value.name === 'string');
24
+ }
@@ -0,0 +1 @@
1
+ export declare function resolveCheckedOutBranch(): string;
@@ -0,0 +1,17 @@
1
+ import { spawnSync } from 'node:child_process';
2
+ const FAILURE_PREFIX = 'Could not resolve the checked-out branch with `git branch --show-current`:';
3
+ const FAILURE_SUFFIX = 'Pass a branch name explicitly.';
4
+ export function resolveCheckedOutBranch() {
5
+ const { error, status, stderr, stdout } = spawnSync('git', ['branch', '--show-current'], { encoding: 'utf8' });
6
+ if (error !== undefined)
7
+ throw failToResolve(error.message);
8
+ if (status !== 0)
9
+ throw failToResolve(stderr.trim());
10
+ const branch = stdout.trim();
11
+ if (branch === '')
12
+ throw failToResolve('HEAD names no branch.');
13
+ return branch;
14
+ }
15
+ function failToResolve(cause) {
16
+ return new Error(`${FAILURE_PREFIX} ${cause}\n${FAILURE_SUFFIX}`);
17
+ }
@@ -0,0 +1 @@
1
+ export declare function resolveSelfVersion(fromDir?: string): string;
@@ -0,0 +1,8 @@
1
+ import { findOwningManifest } from "./findOwningManifest.js";
2
+ export function resolveSelfVersion(fromDir = import.meta.dirname) {
3
+ const { manifest, manifestPath } = findOwningManifest(fromDir);
4
+ if (typeof manifest.version !== 'string') {
5
+ throw new TypeError(`No version declared in the package manifest at ${manifestPath}.`);
6
+ }
7
+ return manifest.version;
8
+ }
@@ -0,0 +1,10 @@
1
+ export declare function runTbGit(args: string[], effects: TbGitEffects): TbGitResult;
2
+ export interface TbGitEffects {
3
+ readonly resolveBranch: () => string;
4
+ readonly resolveVersion: () => string;
5
+ }
6
+ export interface TbGitResult {
7
+ readonly exitCode: number;
8
+ readonly stderr: string;
9
+ readonly stdout: string;
10
+ }
@@ -0,0 +1,135 @@
1
+ import { parseArgs } from 'node:util';
2
+ import { deriveBranchNumber } from "../3-candidate/deriveBranchNumber.js";
3
+ import { findBranchTicketRef } from "../3-candidate/findBranchTicketRef.js";
4
+ const EXIT_OK = 0;
5
+ const EXIT_NO_RESULT = 1;
6
+ const EXIT_USAGE = 2;
7
+ const SUBCOMMANDS = new Set(['branch-number', 'ticket-ref']);
8
+ const HELP_OPTION = { help: { type: 'boolean', short: 'h' } };
9
+ const ROOT_HELP = `Usage: tb-git <subcommand> [<branch>] [options]
10
+
11
+ Utilities for working with git branch names.
12
+
13
+ Subcommands:
14
+ branch-number Print a stable number derived from a branch name
15
+ ticket-ref Print the ID of the ticket encoded by a branch name
16
+
17
+ Options:
18
+ -h, --help Print this help; each subcommand takes its own --help
19
+ --version Print the installed version
20
+
21
+ With no <branch>, the checked-out branch is used.
22
+
23
+ Exit codes:
24
+ 0 A result was printed
25
+ 1 ticket-ref found no ticket in the branch name
26
+ 2 Usage or validation error`;
27
+ const BRANCH_NUMBER_HELP = `Usage: tb-git branch-number [<branch>] [options]
28
+
29
+ Print the number of the ticket encoded by the branch name, or a hash of the name when it encodes none.
30
+
31
+ Options:
32
+ -h, --help Print this help
33
+ --key K The project's ticket key, matched in any casing
34
+ --max N Upper bound, inclusive (default 4294967295)
35
+ --min N Lower bound, inclusive (default 0)
36
+ --offset N Rotate the result within the bounds; write a negative one as --offset=-3
37
+
38
+ With no <branch>, the checked-out branch is used.`;
39
+ const TICKET_REF_HELP = `Usage: tb-git ticket-ref [<branch>] [options]
40
+
41
+ Print the ID of the ticket encoded by the branch name, exiting 1 when it encodes none.
42
+
43
+ Options:
44
+ -h, --help Print this help
45
+ --json Print the whole ref on one line as JSON
46
+ --key K The project's ticket key, matched in any casing
47
+
48
+ With no <branch>, the checked-out branch is used.`;
49
+ export function runTbGit(args, effects) {
50
+ try {
51
+ return dispatch(args, effects);
52
+ }
53
+ catch (error) {
54
+ return fail(describeError(error), args[0]);
55
+ }
56
+ }
57
+ function describeError(error) {
58
+ return error instanceof Error ? error.message : String(error);
59
+ }
60
+ function dispatch(args, effects) {
61
+ const [command, ...rest] = args;
62
+ if (command === 'branch-number')
63
+ return runBranchNumber(rest, effects);
64
+ if (command === 'ticket-ref')
65
+ return runTicketRef(rest, effects);
66
+ if (command === '--help' || command === '-h')
67
+ return succeed(ROOT_HELP);
68
+ if (command === '--version')
69
+ return succeed(effects.resolveVersion());
70
+ if (command === undefined)
71
+ return fail('A subcommand is required.', command);
72
+ return fail(`Unknown ${command.startsWith('-') ? 'option' : 'subcommand'}: ${command}`, command);
73
+ }
74
+ function fail(message, command) {
75
+ const scope = command !== undefined && SUBCOMMANDS.has(command) ? `tb-git ${command}` : 'tb-git';
76
+ return { exitCode: EXIT_USAGE, stderr: `${message}\nTry \`${scope} --help\`.\n`, stdout: '' };
77
+ }
78
+ function runBranchNumber(args, effects) {
79
+ const { positionals, values } = parseArgs({
80
+ allowPositionals: true,
81
+ args,
82
+ options: {
83
+ ...HELP_OPTION,
84
+ key: { type: 'string' },
85
+ max: { type: 'string' },
86
+ min: { type: 'string' },
87
+ offset: { type: 'string' },
88
+ },
89
+ strict: true,
90
+ });
91
+ if (values.help)
92
+ return succeed(BRANCH_NUMBER_HELP);
93
+ const number = deriveBranchNumber(selectBranch(positionals, effects), {
94
+ key: values.key,
95
+ max: toNumber('max', values.max),
96
+ min: toNumber('min', values.min),
97
+ offset: toNumber('offset', values.offset),
98
+ });
99
+ return succeed(String(number));
100
+ }
101
+ function runTicketRef(args, effects) {
102
+ const { positionals, values } = parseArgs({
103
+ allowPositionals: true,
104
+ args,
105
+ options: { ...HELP_OPTION, json: { type: 'boolean' }, key: { type: 'string' } },
106
+ strict: true,
107
+ });
108
+ if (values.help)
109
+ return succeed(TICKET_REF_HELP);
110
+ const ref = findBranchTicketRef(selectBranch(positionals, effects), { key: values.key });
111
+ if (ref === undefined)
112
+ return { exitCode: EXIT_NO_RESULT, stderr: '', stdout: '' };
113
+ return succeed(values.json === true ? JSON.stringify(ref) : ref.id);
114
+ }
115
+ function selectBranch(positionals, effects) {
116
+ if (positionals.length > 1) {
117
+ throw new Error(`Expected at most one branch name. Received ${positionals.length}.`);
118
+ }
119
+ const [branch] = positionals;
120
+ if (branch === undefined)
121
+ return effects.resolveBranch();
122
+ if (branch === '')
123
+ throw new Error('The branch name is empty. Omit it to use the checked-out branch.');
124
+ return branch;
125
+ }
126
+ function succeed(output) {
127
+ return { exitCode: EXIT_OK, stderr: '', stdout: `${output}\n` };
128
+ }
129
+ function toNumber(flag, value) {
130
+ if (value === undefined)
131
+ return undefined;
132
+ if (value.trim() === '')
133
+ throw new Error(`The value of --${flag} is empty.`);
134
+ return Number(value);
135
+ }
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/env node
2
+ import { resolveCheckedOutBranch } from "./resolveCheckedOutBranch.js";
3
+ import { resolveSelfVersion } from "./resolveSelfVersion.js";
4
+ import { runTbGit } from "./runTbGit.js";
5
+ const { exitCode, stderr, stdout } = runTbGit(process.argv.slice(2), {
6
+ resolveBranch: resolveCheckedOutBranch,
7
+ resolveVersion: resolveSelfVersion,
8
+ });
9
+ if (stdout !== '')
10
+ process.stdout.write(stdout);
11
+ if (stderr !== '')
12
+ process.stderr.write(stderr);
13
+ process.exitCode = exitCode;
package/package.json CHANGED
@@ -1,4 +1,60 @@
1
1
  {
2
2
  "name": "@williamthorsen/toolbelt.git",
3
- "version": "0.0.0"
4
- }
3
+ "version": "0.3.0",
4
+ "description": "Utilities for working with git",
5
+ "keywords": [
6
+ "esm",
7
+ "git",
8
+ "toolbelt",
9
+ "typescript",
10
+ "utilities"
11
+ ],
12
+ "homepage": "https://github.com/williamthorsen/toolbelt/tree/main/packages/git#readme",
13
+ "bugs": {
14
+ "url": "https://github.com/williamthorsen/toolbelt/issues"
15
+ },
16
+ "repository": {
17
+ "type": "git",
18
+ "url": "git+https://github.com/williamthorsen/toolbelt.git",
19
+ "directory": "packages/git"
20
+ },
21
+ "license": "ISC",
22
+ "author": "William Thorsen <william@thorsen.dev> (https://github.com/williamthorsen)",
23
+ "sideEffects": false,
24
+ "type": "module",
25
+ "exports": {
26
+ ".": {
27
+ "import": "./dist/esm/4-release/index.js"
28
+ },
29
+ "./candidate": {
30
+ "import": "./dist/esm/3-candidate/index.js"
31
+ },
32
+ "./draft": {
33
+ "import": "./dist/esm/2-draft/index.js"
34
+ },
35
+ "./proposed": {
36
+ "import": "./dist/esm/1-proposed/index.js"
37
+ }
38
+ },
39
+ "bin": {
40
+ "tb-git": "./dist/esm/bin/tb-git.js"
41
+ },
42
+ "files": [
43
+ "dist/*",
44
+ "CHANGELOG.md"
45
+ ],
46
+ "dependencies": {
47
+ "@williamthorsen/toolbelt.strings": "7.1.0"
48
+ },
49
+ "devDependencies": {
50
+ "@williamthorsen/toolbelt.filesystem": "0.8.2"
51
+ },
52
+ "engines": {
53
+ "node": ">=24.0.0"
54
+ },
55
+ "publishConfig": {
56
+ "access": "public",
57
+ "registry": "https://registry.npmjs.org"
58
+ },
59
+ "scripts": {}
60
+ }