commitscape 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/LICENSE-APACHE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/LICENSE-MIT ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Dev Talan
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,248 @@
1
+ <div align="center">
2
+ <img src="./.github/logo.svg" alt="commitscape" width="64" height="64" />
3
+ <h1>commitscape</h1>
4
+ <p>Reads a git repository's history and shows what changes what you do next.</p>
5
+ </div>
6
+
7
+ <p align="center">
8
+ <a href="https://github.com/pixelactstudio/commitscape/actions/workflows/ci.yml">
9
+ <img src="https://github.com/pixelactstudio/commitscape/actions/workflows/ci.yml/badge.svg" alt="CI" />
10
+ </a>
11
+ <a href="https://github.com/pixelactstudio/commitscape/actions/workflows/docker.yml">
12
+ <img src="https://github.com/pixelactstudio/commitscape/actions/workflows/docker.yml/badge.svg" alt="Docker images" />
13
+ </a>
14
+ <a href="#license">
15
+ <img src="https://img.shields.io/badge/license-MIT%20or%20Apache--2.0-blue" alt="MIT or Apache-2.0 license" />
16
+ </a>
17
+ </p>
18
+
19
+ commitscape reads a git repository and answers the questions its history
20
+ can answer: who knows which part of the code, which files are risky to
21
+ change, what you probably forgot to change, and how the project got here.
22
+ It reads the whole history of a large repository in seconds, on your
23
+ machine, from git's own data.
24
+
25
+ ![commitscape's own story, drawn by commitscape](.github/commitscape-card.svg)
26
+
27
+ There are three ways to use it:
28
+
29
+ 1. **In your terminal.** Run `npx commitscape` in any git repository.
30
+ Nothing leaves your machine.
31
+ 2. **Shared from a terminal.** `commitscape share` builds the Report on
32
+ your machine, encrypts it, uploads it and prints a link. The link opens
33
+ in any browser for 4 hours, and the Site cannot read what it stores.
34
+ 3. **On the Site.** Paste any public GitHub link to see its Report, sign in
35
+ with GitHub to open your private repositories, or browse the
36
+ Leaderboards.
37
+
38
+ The project is in early development. The CLI and the Site work end to end;
39
+ the first release is next.
40
+
41
+ ## Getting started
42
+
43
+ ```sh
44
+ npx commitscape
45
+ ```
46
+
47
+ The first run reads the whole history (about 25 seconds for a repository
48
+ the size of rust-lang/rust). After that it opens in well under a second.
49
+
50
+ ![The terminal interface on ripgrep](docs/media/terminal.gif)
51
+
52
+ ## Install
53
+
54
+ | How | Command |
55
+ |---|---|
56
+ | npm | `npx commitscape`, `pnpm dlx commitscape`, or `npm install -g commitscape` |
57
+ | Homebrew | `brew install pixelactstudio/commitscape/commitscape` |
58
+ | winget | `winget install DevTalan.Commitscape` |
59
+ | Scoop | `scoop bucket add pixelactstudio https://github.com/pixelactstudio/scoop-bucket`, then `scoop install commitscape` |
60
+ | Arch (AUR) | `yay -S commitscape-bin` |
61
+ | Debian, Ubuntu | the `.deb` from the [latest release](https://github.com/pixelactstudio/commitscape/releases/latest): `sudo apt install ./commitscape_*_amd64.deb` |
62
+ | Fedora, RHEL | the `.rpm` from the latest release: `sudo dnf install ./commitscape-*.x86_64.rpm` |
63
+ | Cargo | `cargo install commitscape` |
64
+ | Nix | `nix run github:pixelactstudio/commitscape` |
65
+ | A binary | the archive for your platform from the latest release |
66
+
67
+ Prebuilt binaries cover Linux on x64 and ARM (glibc or musl), macOS on
68
+ Intel and Apple silicon, and Windows on x64. The npm package installs only
69
+ your platform's binary, runs nothing at install time, and needs no Node
70
+ once it runs.
71
+
72
+ ## Commands
73
+
74
+ | Command | What it does |
75
+ |---|---|
76
+ | `commitscape [path]` | The terminal interface: five screens over any Window of history |
77
+ | `commitscape check` | The files that nearly always change with the ones you staged, and did not |
78
+ | `commitscape who <path>` | Who to ask about a file or folder, and whether they still commit |
79
+ | `commitscape health <owner/name>` | Whether a GitHub project is alive and whether it depends on one person |
80
+ | `commitscape wrapped [folder]` | Your year across every repository under a folder, as a card |
81
+ | `commitscape card [path]` | The repository's story as an SVG card, like the one above |
82
+ | `commitscape share` | An encrypted link to this repository's Report, for any browser |
83
+ | `commitscape report [path]` | The Report as gzipped JSON, as the Site stores it |
84
+ | `commitscape github [path]` | Fetch pull requests, issues and releases through the `gh` CLI |
85
+
86
+ `commitscape --summary` prints a plain-text summary, `--json` every metric
87
+ as one document, `--window 30d|90d|1y|all` picks the Window, and `--help`
88
+ lists every option.
89
+
90
+ ## What it shows
91
+
92
+ | Screen | Shows |
93
+ |---|---|
94
+ | Overview | The project's story on a line (its first commit, releases, people joining and leaving, the busiest day, quiet stretches), commits over time, who writes the code, and what is worth a look |
95
+ | Activity | Commits over time by person with releases marked, pull requests and issues a week, the hours of the week, and what kind of work it was |
96
+ | People | A column per measure and no single score: commits, active days, lines added and removed, folders that depend on them, pull requests and reviews, with a profile for each person |
97
+ | Map | The code as nested blocks sized by lines, coloured by how often, when last, or who changes it. Open a file to see what changes with it |
98
+ | Risk | Hotspots (files changed often and deeply nested), files that change together, and folders one person holds, with who could take each over |
99
+ | Commits | Every commit, searched in your browser as you type (on the Site) |
100
+
101
+ Every number is explained on screen. Press `?` for what each screen means
102
+ and every key.
103
+
104
+ ## Questions it answers
105
+
106
+ **What did I forget?** Before you commit, `commitscape check` names the
107
+ files that nearly always change with the ones you staged, with the
108
+ evidence, and says nothing when the evidence is weak:
109
+
110
+ ```text
111
+ $ commitscape check
112
+ Probably forgotten:
113
+ You changed src/schema.ts. 9 of the last 10 commits that did also changed a file in migrations/.
114
+ ```
115
+
116
+ `--branch main` checks a branch, `--pr 123` a pull request, and `--strict`
117
+ exits with 1 when something looks forgotten. The
118
+ [`actions/check`](actions/check/README.md) GitHub Action comments the same
119
+ on pull requests.
120
+
121
+ **Who do I ask?** `commitscape who src/api` lists who worked on a file or
122
+ folder most and most recently, flags anyone who has stopped committing,
123
+ and names who to ask instead.
124
+
125
+ **Can I rely on this project?** `commitscape health owner/name` says
126
+ whether a GitHub project is alive: its maintainers in the last 90 days,
127
+ its bus factor, how often it releases, how fast issues get a first answer,
128
+ and whether it is getting busier or quieter.
129
+
130
+ **What did I do this year?** `commitscape wrapped ~/code` keeps only your
131
+ commits across every repository under a folder, under every address you
132
+ commit with, and draws your year as a card. Private repositories are
133
+ included, and nothing is uploaded.
134
+
135
+ ## On the Site
136
+
137
+ - **Any public GitHub repository.** Go to `/gh/<owner>/<name>`. GitHub's
138
+ facts show at once, and the Report follows when its history is read:
139
+ seconds for most repositories.
140
+ - **Your own repositories.** Sign in with GitHub and choose repositories
141
+ through commitscape's GitHub App, which can only read. A private
142
+ repository's Report is shown only to people GitHub says can see it.
143
+ - **Leaderboards.** Popular repositories ranked by what commitscape
144
+ measures: resting on one person, most maintainers, most active, fastest
145
+ to answer issues, and oldest code still running. Repositories only,
146
+ never people.
147
+ - **For AI agents.** An MCP server at `/mcp` lets an agent look up a
148
+ repository and read its Report.
149
+
150
+ `/privacy` on the Site says what it keeps, where, for how long, and who can
151
+ read it.
152
+
153
+ ## Privacy
154
+
155
+ On your machine, commitscape sends nothing anywhere unless you ask:
156
+
157
+ - With the [GitHub CLI](https://cli.github.com) signed in, it asks GitHub
158
+ about pull requests, issues, reviews and releases. `--offline` never
159
+ asks.
160
+ - `share` uploads the Report encrypted with AES-256-GCM. The key is only in
161
+ the link, after the `#`, which browsers never send, so the Site stores
162
+ what it cannot read. No email address is ever included.
163
+ - No analytics, no update checks, and nothing runs at install time.
164
+
165
+ ## Self-hosting
166
+
167
+ The Site is a TanStack Start app and the Builder a small Node worker, both
168
+ published as Docker images on every merge. [DEPLOY.md](./DEPLOY.md) runs
169
+ them in Dokploy with Postgres and a Cloudflare R2 bucket.
170
+
171
+ ## Development
172
+
173
+ Requirements: Rust (stable), Node.js 24, pnpm 12 and Docker.
174
+
175
+ ```sh
176
+ git clone git@github.com:pixelactstudio/commitscape.git
177
+ cd commitscape
178
+ pnpm install
179
+ pnpm services
180
+ cargo xtask fixtures --force
181
+ cp apps/site/.env.example apps/site/.env
182
+ cp apps/builder/.env.example apps/builder/.env
183
+ pnpm dev:builder
184
+ pnpm dev:site
185
+ ```
186
+
187
+ `pnpm services` starts Postgres and an S3 stand-in in Docker. Set
188
+ `BETTER_AUTH_SECRET` in `apps/site/.env` (`openssl rand -hex 32`). The Site
189
+ runs at [http://localhost:3100](http://localhost:3100). GitHub sign-in,
190
+ Sentry and PostHog stay off while their keys are empty.
191
+
192
+ | Command | Purpose |
193
+ |---|---|
194
+ | `cargo run -p commitscape -- <path>` | Run the CLI on a repository |
195
+ | `cargo test --workspace` | Every Rust test |
196
+ | `cargo clippy --workspace --all-targets -- -D warnings` | Rust lints |
197
+ | `cargo xtask check-layering` | Check that the crates depend on each other only as designed |
198
+ | `pnpm check` | Typecheck, lint, test and build every TypeScript package |
199
+ | `pnpm e2e` | The Site and the Builder end to end in Chromium, with accessibility checks |
200
+ | `pnpm db:generate` | Write the migration for a schema change |
201
+ | `cargo xtask bench` | Timings on large repositories |
202
+
203
+ ## Architecture
204
+
205
+ | Folder | What |
206
+ |---|---|
207
+ | `crates/` | Rust: the engine that reads git, the metrics, the terminal interface, the Report and the CLI |
208
+ | `apps/site/` | The Site: TanStack Start on Node, server-rendered, with Better Auth |
209
+ | `apps/builder/` | The Builder: takes Builds from a Postgres queue, runs `commitscape report`, stores the Report in R2 |
210
+ | `packages/server/` | The database schema and migrations, R2 storage, the queue and stored Reports |
211
+ | `packages/ui/` | Every screen and chart the Site shows |
212
+ | `packages/data/` | The Report's types, generated from Rust |
213
+
214
+ - [Domain language](./CONTEXT.md)
215
+ - [Architecture decisions](./docs/adr)
216
+ - [Deploying](./DEPLOY.md)
217
+ - [Releasing](./RELEASING.md)
218
+ - [Agent guide](./CLAUDE.md)
219
+
220
+ ## Stack
221
+
222
+ - Rust, gix, ratatui
223
+ - TanStack Start, React 19, TypeScript and Vite
224
+ - Astryx and Tailwind CSS
225
+ - PostgreSQL, Drizzle ORM, pg-boss and Cloudflare R2
226
+ - Better Auth, PostHog and Sentry
227
+ - Turborepo, oxlint, Vitest and Playwright
228
+
229
+ ## Commit workflow
230
+
231
+ Commits and pull request titles use
232
+ [Conventional Commits](https://www.conventionalcommits.org/). Releases,
233
+ version numbers and the changelog are generated from them
234
+ ([RELEASING.md](./RELEASING.md)):
235
+
236
+ ```text
237
+ feat: count lines changed per person
238
+ fix: keep the Window when opening a file
239
+ chore: update dependencies
240
+ ```
241
+
242
+ ## License
243
+
244
+ commitscape is open-source software, licensed under either the
245
+ [MIT License](./LICENSE-MIT) or the [Apache License 2.0](./LICENSE-APACHE),
246
+ at your option.
247
+
248
+ An open-source project by [Pixelact Studio](https://pixelactstudio.com).
@@ -0,0 +1,69 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+
4
+ const fs = require("node:fs");
5
+ const { spawnSync } = require("node:child_process");
6
+
7
+ function candidates() {
8
+ const { platform, arch } = process;
9
+ if (platform === "linux" && arch === "x64") {
10
+ const musl = fs.existsSync("/lib/ld-musl-x86_64.so.1");
11
+ const gnu = "@commitscape/linux-x64-gnu";
12
+ const alpine = "@commitscape/linux-x64-musl";
13
+ return musl ? [alpine, gnu] : [gnu, alpine];
14
+ }
15
+ if (platform === "linux" && arch === "arm64") return ["@commitscape/linux-arm64"];
16
+ if (platform === "darwin" && (arch === "x64" || arch === "arm64")) return [`@commitscape/darwin-${arch}`];
17
+ if (platform === "win32" && arch === "x64") return ["@commitscape/win32-x64"];
18
+ return [];
19
+ }
20
+
21
+ const exe = process.platform === "win32" ? "commitscape.exe" : "commitscape";
22
+ const packages = candidates();
23
+ let binary = null;
24
+ for (const pkg of packages) {
25
+ try {
26
+ binary = require.resolve(`${pkg}/bin/${exe}`);
27
+ break;
28
+ } catch {
29
+ }
30
+ }
31
+ if (!binary) {
32
+ const where = `${process.platform}-${process.arch}`;
33
+ process.stderr.write(
34
+ packages.length > 0
35
+ ? `commitscape: the package with its binary for ${where}, ${packages[0]}, was not installed.\n` +
36
+ "npm installs it as an optional dependency: reinstall without --no-optional (or --omit=optional),\n" +
37
+ `or install it yourself: npm install ${packages[0]}\n`
38
+ : `commitscape: there is no build for ${where} yet; the README says how to build it from source.\n`,
39
+ );
40
+ process.exit(1);
41
+ }
42
+
43
+ const args = process.argv.slice(2);
44
+
45
+ let runnable = true;
46
+ try {
47
+ fs.accessSync(binary, fs.constants.X_OK);
48
+ } catch {
49
+ runnable = false;
50
+ }
51
+ if (runnable && typeof process.execve === "function") {
52
+ process.emitWarning = () => {};
53
+ process.execve(binary, [binary, ...args], process.env);
54
+ }
55
+
56
+ const signals = ["SIGINT", "SIGTERM", "SIGHUP"];
57
+ const ignore = () => {};
58
+ for (const signal of signals) process.on(signal, ignore);
59
+ const result = spawnSync(binary, args, { stdio: "inherit" });
60
+ if (result.error) {
61
+ process.stderr.write(`commitscape: could not start ${binary}: ${result.error.message}\n`);
62
+ process.exit(1);
63
+ }
64
+ if (result.signal) {
65
+ for (const signal of signals) process.removeListener(signal, ignore);
66
+ process.kill(process.pid, result.signal);
67
+ } else {
68
+ process.exit(result.status ?? 1);
69
+ }
package/package.json ADDED
@@ -0,0 +1,39 @@
1
+ {
2
+ "bin": {
3
+ "commitscape": "bin/commitscape.js"
4
+ },
5
+ "description": "Reads a git repository and shows what changes what you do next: who knows the code, what is risky, what you forgot.",
6
+ "engines": {
7
+ "node": ">=18"
8
+ },
9
+ "files": [
10
+ "bin/commitscape.js",
11
+ "README.md",
12
+ "LICENSE-MIT",
13
+ "LICENSE-APACHE"
14
+ ],
15
+ "keywords": [
16
+ "git",
17
+ "repository",
18
+ "analytics",
19
+ "code-ownership",
20
+ "hotspots",
21
+ "cli",
22
+ "tui"
23
+ ],
24
+ "license": "MIT OR Apache-2.0",
25
+ "name": "commitscape",
26
+ "optionalDependencies": {
27
+ "@commitscape/darwin-arm64": "0.1.0",
28
+ "@commitscape/darwin-x64": "0.1.0",
29
+ "@commitscape/linux-arm64": "0.1.0",
30
+ "@commitscape/linux-x64-gnu": "0.1.0",
31
+ "@commitscape/linux-x64-musl": "0.1.0",
32
+ "@commitscape/win32-x64": "0.1.0"
33
+ },
34
+ "repository": {
35
+ "type": "git",
36
+ "url": "git+https://github.com/pixelactstudio/commitscape.git"
37
+ },
38
+ "version": "0.1.0"
39
+ }