@doki-land/nifty 0.0.0 → 0.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/src/native.ts CHANGED
@@ -1,277 +1,284 @@
1
- import { createRequire } from "node:module";
2
- import type {
3
- CommitRecord,
4
- GithubAuthor,
5
- ParsedSubject,
6
- RangeInfo,
7
- ReleaseSection,
8
- TagInfo,
9
- } from "./types.js";
10
-
11
- export type GitmojiExports = {
12
- "known-gitmojis": () => string[];
13
- "validate-subject": (subject: string) => boolean;
14
- "parse-subject": (subject: string) => ParsedSubject;
15
- "format-subject": (gitmoji: string, body: string) => string;
16
- "strip-gitmoji": (subject: string) => string;
17
- "leading-gitmoji": (subject: string) => string | undefined;
18
- "section-for-gitmoji": (gitmoji: string | undefined) => ReleaseSection;
19
- "parse-noreply-email": (email: string) => GithubAuthor | undefined;
20
- "resolve-github-author": (email: string, authorMapJson: string) => GithubAuthor | undefined;
21
- "display-login": (author: GithubAuthor) => string;
22
- "profile-url": (author: GithubAuthor) => string;
23
- "avatar-url": (author: GithubAuthor) => string;
24
- "author-mention": (email: string, authorName: string, authorMapJson: string) => string;
25
- "commit-bullet": (body: string, email: string, authorName: string, authorMapJson: string) => string;
26
- };
27
-
28
- export type GitExports = {
29
- "discover-root": (startPath: string) => string;
30
- "list-version-tags": (repoRoot: string) => string[];
31
- "list-tag-infos": (repoRoot: string) => Array<{ name: string; "short-hash": string }>;
32
- "format-tag-list": (repoRoot: string) => string;
33
- "resolve-range": (
34
- repoRoot: string,
35
- version: string | undefined,
36
- fromRef: string | undefined,
37
- toRef: string | undefined,
38
- ) => { version: string; "from-ref"?: string; "to-ref": string };
39
- "collect-commits": (
40
- repoRoot: string,
41
- fromRef: string | undefined,
42
- toRef: string,
43
- ) => Array<{
44
- hash: string;
45
- email: string;
46
- author: string;
47
- subject: string;
48
- body: string;
49
- gitmoji?: string;
50
- section: string;
51
- }>;
52
- "detect-github-repo": (repoRoot: string) => string | undefined;
53
- "parse-github-remote": (url: string) => string | undefined;
54
- };
55
-
56
- export type PublishReport = {
57
- root: string;
58
- order: string[];
59
- published: string[];
60
- skipped: string[];
61
- };
62
-
63
- export type TrustReport = {
64
- root: string;
65
- configured: string[];
66
- skipped: string[];
67
- failed: string[];
68
- };
69
-
70
- export type PublisherExports = {
71
- "publish-workspace": (options: {
72
- cwd?: string;
73
- dryRun?: boolean;
74
- tag?: string;
75
- access?: string;
76
- npm?: string;
77
- otp?: string;
78
- totpSecret?: string;
79
- token?: string;
80
- }) => PublishReport;
81
- "trust-workspace": (options: {
82
- cwd?: string;
83
- dryRun?: boolean;
84
- only?: string;
85
- npm?: string;
86
- otp?: string;
87
- totpSecret?: string;
88
- token?: string;
89
- }) => TrustReport;
90
- };
91
-
92
- export type NiftyNative = {
93
- gitmoji: GitmojiExports;
94
- git: GitExports;
95
- publisher: PublisherExports;
96
- };
97
-
98
- type NativeBinding = {
99
- gitmojiKnownGitmojis: () => string[];
100
- gitmojiValidateSubject: (subject: string) => boolean;
101
- gitmojiParseSubject: (subject: string) => ParsedSubject;
102
- gitmojiFormatSubject: (gitmoji: string, body: string) => string;
103
- gitmojiStripGitmoji: (subject: string) => string;
104
- gitmojiLeadingGitmoji: (subject: string) => string | null;
105
- gitmojiSectionForGitmoji: (gitmoji?: string | null) => string;
106
- gitmojiParseNoreplyEmail: (email: string) => GithubAuthor | null;
107
- gitmojiResolveGithubAuthor: (email: string, authorMapJson: string) => GithubAuthor | null;
108
- gitmojiDisplayLogin: (author: GithubAuthor) => string;
109
- gitmojiProfileUrl: (author: GithubAuthor) => string;
110
- gitmojiAvatarUrl: (author: GithubAuthor) => string;
111
- gitmojiAuthorMention: (email: string, authorName: string, authorMapJson: string) => string;
112
- gitmojiCommitBullet: (body: string, email: string, authorName: string, authorMapJson: string) => string;
113
- gitDiscoverRoot: (startPath: string) => string;
114
- gitListVersionTags: (repoRoot: string) => string[];
115
- gitListTagInfos: (repoRoot: string) => Array<{ name: string; shortHash: string }>;
116
- gitFormatTagList: (repoRoot: string) => string;
117
- gitResolveRange: (
118
- repoRoot: string,
119
- version?: string | null,
120
- fromRef?: string | null,
121
- toRef?: string | null,
122
- ) => { version: string; fromRef?: string; toRef: string };
123
- gitCollectCommits: (
124
- repoRoot: string,
125
- fromRef: string | null | undefined,
126
- toRef: string,
127
- ) => CommitRecord[];
128
- gitDetectGithubRepo: (repoRoot: string) => string | null;
129
- gitParseGithubRemote: (url: string) => string | null;
130
- publisherPublishWorkspace: (options: {
131
- cwd?: string | null;
132
- dryRun?: boolean | null;
133
- tag?: string | null;
134
- access?: string | null;
135
- npm?: string | null;
136
- otp?: string | null;
137
- totpSecret?: string | null;
138
- token?: string | null;
139
- }) => PublishReport;
140
- publisherTrustWorkspace: (options: {
141
- cwd?: string | null;
142
- dryRun?: boolean | null;
143
- only?: string | null;
144
- npm?: string | null;
145
- otp?: string | null;
146
- totpSecret?: string | null;
147
- token?: string | null;
148
- }) => TrustReport;
149
- };
150
-
151
- const PLATFORM_PACKAGES: Record<string, string> = {
152
- "win32-x64": "@doki-land/nifty-win32-x64",
153
- "linux-x64": "@doki-land/nifty-linux-x64",
154
- "linux-arm64": "@doki-land/nifty-linux-arm64",
155
- "darwin-x64": "@doki-land/nifty-darwin-x64",
156
- "darwin-arm64": "@doki-land/nifty-darwin-arm64",
157
- };
158
-
159
- function mapAuthor(raw: GithubAuthor | null | undefined): GithubAuthor | undefined {
160
- if (!raw) {
161
- return undefined;
162
- }
163
- return {
164
- id: raw.id !== undefined && raw.id !== null ? BigInt(raw.id) : undefined,
165
- login: raw.login ?? undefined,
166
- };
167
- }
168
-
169
- function wrapBinding(binding: NativeBinding): NiftyNative {
170
- return {
171
- gitmoji: {
172
- "known-gitmojis": () => binding.gitmojiKnownGitmojis(),
173
- "validate-subject": (subject) => binding.gitmojiValidateSubject(subject),
174
- "parse-subject": (subject) => binding.gitmojiParseSubject(subject),
175
- "format-subject": (gitmoji, body) => binding.gitmojiFormatSubject(gitmoji, body),
176
- "strip-gitmoji": (subject) => binding.gitmojiStripGitmoji(subject),
177
- "leading-gitmoji": (subject) => binding.gitmojiLeadingGitmoji(subject) ?? undefined,
178
- "section-for-gitmoji": (gitmoji) => binding.gitmojiSectionForGitmoji(gitmoji) as ReleaseSection,
179
- "parse-noreply-email": (email) => mapAuthor(binding.gitmojiParseNoreplyEmail(email)),
180
- "resolve-github-author": (email, authorMapJson) =>
181
- mapAuthor(binding.gitmojiResolveGithubAuthor(email, authorMapJson)),
182
- "display-login": (author) => binding.gitmojiDisplayLogin(author),
183
- "profile-url": (author) => binding.gitmojiProfileUrl(author),
184
- "avatar-url": (author) => binding.gitmojiAvatarUrl(author),
185
- "author-mention": (email, authorName, authorMapJson) =>
186
- binding.gitmojiAuthorMention(email, authorName, authorMapJson),
187
- "commit-bullet": (body, email, authorName, authorMapJson) =>
188
- binding.gitmojiCommitBullet(body, email, authorName, authorMapJson),
189
- },
190
- git: {
191
- "discover-root": (startPath) => binding.gitDiscoverRoot(startPath),
192
- "list-version-tags": (repoRoot) => binding.gitListVersionTags(repoRoot),
193
- "list-tag-infos": (repoRoot) =>
194
- binding.gitListTagInfos(repoRoot).map((tag) => ({
195
- name: tag.name,
196
- "short-hash": tag.shortHash,
197
- })),
198
- "format-tag-list": (repoRoot) => binding.gitFormatTagList(repoRoot),
199
- "resolve-range": (repoRoot, version, fromRef, toRef) => {
200
- const range = binding.gitResolveRange(repoRoot, version, fromRef, toRef);
201
- return {
202
- version: range.version,
203
- "from-ref": range.fromRef,
204
- "to-ref": range.toRef,
205
- };
206
- },
207
- "collect-commits": (repoRoot, fromRef, toRef) => binding.gitCollectCommits(repoRoot, fromRef, toRef),
208
- "detect-github-repo": (repoRoot) => binding.gitDetectGithubRepo(repoRoot) ?? undefined,
209
- "parse-github-remote": (url) => binding.gitParseGithubRemote(url) ?? undefined,
210
- },
211
- publisher: {
212
- "publish-workspace": (options) =>
213
- binding.publisherPublishWorkspace({
214
- ...(options.cwd !== undefined ? { cwd: options.cwd } : {}),
215
- ...(options.dryRun !== undefined ? { dryRun: options.dryRun } : {}),
216
- ...(options.tag !== undefined ? { tag: options.tag } : {}),
217
- ...(options.access !== undefined ? { access: options.access } : {}),
218
- ...(options.npm !== undefined ? { npm: options.npm } : {}),
219
- ...(options.otp !== undefined ? { otp: options.otp } : {}),
220
- ...(options.totpSecret !== undefined ? { totpSecret: options.totpSecret } : {}),
221
- ...(options.token !== undefined ? { token: options.token } : {}),
222
- }),
223
- "trust-workspace": (options) =>
224
- binding.publisherTrustWorkspace({
225
- ...(options.cwd !== undefined ? { cwd: options.cwd } : {}),
226
- ...(options.dryRun !== undefined ? { dryRun: options.dryRun } : {}),
227
- ...(options.only !== undefined ? { only: options.only } : {}),
228
- ...(options.npm !== undefined ? { npm: options.npm } : {}),
229
- ...(options.otp !== undefined ? { otp: options.otp } : {}),
230
- ...(options.totpSecret !== undefined ? { totpSecret: options.totpSecret } : {}),
231
- ...(options.token !== undefined ? { token: options.token } : {}),
232
- }),
233
- },
234
- };
235
- }
236
-
237
- let cached: NiftyNative | undefined;
238
-
239
- /** Load the platform-specific Node-API binary from `@doki-land/nifty-<platform>`. */
240
- export function loadNiftyNative(): NiftyNative {
241
- if (cached) {
242
- return cached;
243
- }
244
- const key = `${process.platform}-${process.arch}`;
245
- const pkg = PLATFORM_PACKAGES[key];
246
- if (!pkg) {
247
- throw new Error(`Unsupported platform for Nifty native bindings: ${key}`);
248
- }
249
- const require = createRequire(import.meta.url);
250
- const binding = require(pkg).default as NativeBinding;
251
- cached = wrapBinding(binding);
252
- return cached;
253
- }
254
-
255
- export function mapTagInfo(raw: { name: string; "short-hash": string }): TagInfo {
256
- return { name: raw.name, shortHash: raw["short-hash"] };
257
- }
258
-
259
- export function mapRangeInfo(raw: { version: string; "from-ref"?: string; "to-ref": string }): RangeInfo {
260
- return {
261
- version: raw.version,
262
- fromRef: raw["from-ref"],
263
- toRef: raw["to-ref"],
264
- };
265
- }
266
-
267
- export function mapCommitRecord(raw: CommitRecord): CommitRecord {
268
- return {
269
- hash: raw.hash,
270
- email: raw.email,
271
- author: raw.author,
272
- subject: raw.subject,
273
- body: raw.body,
274
- gitmoji: raw.gitmoji,
275
- section: raw.section as ReleaseSection,
276
- };
277
- }
1
+ import { createRequire } from "node:module";
2
+ import type {
3
+ CommitRecord,
4
+ GithubAuthor,
5
+ ParsedSubject,
6
+ RangeInfo,
7
+ ReleaseSection,
8
+ TagInfo,
9
+ } from "./types.js";
10
+
11
+ export type GitmojiExports = {
12
+ "known-gitmojis": () => string[];
13
+ "validate-subject": (subject: string) => boolean;
14
+ "parse-subject": (subject: string) => ParsedSubject;
15
+ "format-subject": (gitmoji: string, body: string) => string;
16
+ "strip-gitmoji": (subject: string) => string;
17
+ "leading-gitmoji": (subject: string) => string | undefined;
18
+ "section-for-gitmoji": (gitmoji: string | undefined) => ReleaseSection;
19
+ "parse-noreply-email": (email: string) => GithubAuthor | undefined;
20
+ "resolve-github-author": (email: string, authorMapJson: string) => GithubAuthor | undefined;
21
+ "display-login": (author: GithubAuthor) => string;
22
+ "profile-url": (author: GithubAuthor) => string;
23
+ "avatar-url": (author: GithubAuthor) => string;
24
+ "author-mention": (email: string, authorName: string, authorMapJson: string) => string;
25
+ "commit-bullet": (body: string, email: string, authorName: string, authorMapJson: string) => string;
26
+ };
27
+
28
+ export type GitExports = {
29
+ "discover-root": (startPath: string) => string;
30
+ "list-version-tags": (repoRoot: string) => string[];
31
+ "list-tag-infos": (repoRoot: string) => Array<{ name: string; "short-hash": string }>;
32
+ "format-tag-list": (repoRoot: string) => string;
33
+ "resolve-range": (
34
+ repoRoot: string,
35
+ version: string | undefined,
36
+ fromRef: string | undefined,
37
+ toRef: string | undefined,
38
+ ) => { version: string; "from-ref"?: string; "to-ref": string };
39
+ "collect-commits": (
40
+ repoRoot: string,
41
+ fromRef: string | undefined,
42
+ toRef: string,
43
+ ) => Array<{
44
+ hash: string;
45
+ email: string;
46
+ author: string;
47
+ subject: string;
48
+ body: string;
49
+ gitmoji?: string;
50
+ section: string;
51
+ }>;
52
+ "detect-github-repo": (repoRoot: string) => string | undefined;
53
+ "parse-github-remote": (url: string) => string | undefined;
54
+ };
55
+
56
+ export type PublishReport = {
57
+ root: string;
58
+ order: string[];
59
+ published: string[];
60
+ skipped: string[];
61
+ skippedVersions: string[];
62
+ };
63
+
64
+ export type TrustReport = {
65
+ root: string;
66
+ configured: string[];
67
+ skipped: string[];
68
+ failed: string[];
69
+ };
70
+
71
+ export type PublisherExports = {
72
+ "publish-workspace": (options: {
73
+ cwd?: string;
74
+ dryRun?: boolean;
75
+ refresh?: boolean;
76
+ tag?: string;
77
+ access?: string;
78
+ npm?: string;
79
+ otp?: string;
80
+ totpSecret?: string;
81
+ token?: string;
82
+ }) => PublishReport;
83
+ "trust-workspace": (options: {
84
+ cwd?: string;
85
+ dryRun?: boolean;
86
+ refresh?: boolean;
87
+ only?: string;
88
+ npm?: string;
89
+ otp?: string;
90
+ totpSecret?: string;
91
+ token?: string;
92
+ }) => TrustReport;
93
+ };
94
+
95
+ export type NiftyNative = {
96
+ gitmoji: GitmojiExports;
97
+ git: GitExports;
98
+ publisher: PublisherExports;
99
+ };
100
+
101
+ type NativeBinding = {
102
+ gitmojiKnownGitmojis: () => string[];
103
+ gitmojiValidateSubject: (subject: string) => boolean;
104
+ gitmojiParseSubject: (subject: string) => ParsedSubject;
105
+ gitmojiFormatSubject: (gitmoji: string, body: string) => string;
106
+ gitmojiStripGitmoji: (subject: string) => string;
107
+ gitmojiLeadingGitmoji: (subject: string) => string | null;
108
+ gitmojiSectionForGitmoji: (gitmoji?: string | null) => string;
109
+ gitmojiParseNoreplyEmail: (email: string) => GithubAuthor | null;
110
+ gitmojiResolveGithubAuthor: (email: string, authorMapJson: string) => GithubAuthor | null;
111
+ gitmojiDisplayLogin: (author: GithubAuthor) => string;
112
+ gitmojiProfileUrl: (author: GithubAuthor) => string;
113
+ gitmojiAvatarUrl: (author: GithubAuthor) => string;
114
+ gitmojiAuthorMention: (email: string, authorName: string, authorMapJson: string) => string;
115
+ gitmojiCommitBullet: (body: string, email: string, authorName: string, authorMapJson: string) => string;
116
+ gitDiscoverRoot: (startPath: string) => string;
117
+ gitListVersionTags: (repoRoot: string) => string[];
118
+ gitListTagInfos: (repoRoot: string) => Array<{ name: string; shortHash: string }>;
119
+ gitFormatTagList: (repoRoot: string) => string;
120
+ gitResolveRange: (
121
+ repoRoot: string,
122
+ version?: string | null,
123
+ fromRef?: string | null,
124
+ toRef?: string | null,
125
+ ) => { version: string; fromRef?: string; toRef: string };
126
+ gitCollectCommits: (
127
+ repoRoot: string,
128
+ fromRef: string | null | undefined,
129
+ toRef: string,
130
+ ) => CommitRecord[];
131
+ gitDetectGithubRepo: (repoRoot: string) => string | null;
132
+ gitParseGithubRemote: (url: string) => string | null;
133
+ publisherPublishWorkspace: (options: {
134
+ cwd?: string | null;
135
+ dryRun?: boolean | null;
136
+ refresh?: boolean | null;
137
+ tag?: string | null;
138
+ access?: string | null;
139
+ npm?: string | null;
140
+ otp?: string | null;
141
+ totpSecret?: string | null;
142
+ token?: string | null;
143
+ }) => PublishReport;
144
+ publisherTrustWorkspace: (options: {
145
+ cwd?: string | null;
146
+ dryRun?: boolean | null;
147
+ refresh?: boolean | null;
148
+ only?: string | null;
149
+ npm?: string | null;
150
+ otp?: string | null;
151
+ totpSecret?: string | null;
152
+ token?: string | null;
153
+ }) => TrustReport;
154
+ };
155
+
156
+ const PLATFORM_PACKAGES: Record<string, string> = {
157
+ "win32-x64": "@doki-land/nifty-win32-x64",
158
+ "linux-x64": "@doki-land/nifty-linux-x64",
159
+ "linux-arm64": "@doki-land/nifty-linux-arm64",
160
+ "darwin-x64": "@doki-land/nifty-darwin-x64",
161
+ "darwin-arm64": "@doki-land/nifty-darwin-arm64",
162
+ };
163
+
164
+ function mapAuthor(raw: GithubAuthor | null | undefined): GithubAuthor | undefined {
165
+ if (!raw) {
166
+ return undefined;
167
+ }
168
+ return {
169
+ id: raw.id !== undefined && raw.id !== null ? BigInt(raw.id) : undefined,
170
+ login: raw.login ?? undefined,
171
+ };
172
+ }
173
+
174
+ function wrapBinding(binding: NativeBinding): NiftyNative {
175
+ return {
176
+ gitmoji: {
177
+ "known-gitmojis": () => binding.gitmojiKnownGitmojis(),
178
+ "validate-subject": (subject) => binding.gitmojiValidateSubject(subject),
179
+ "parse-subject": (subject) => binding.gitmojiParseSubject(subject),
180
+ "format-subject": (gitmoji, body) => binding.gitmojiFormatSubject(gitmoji, body),
181
+ "strip-gitmoji": (subject) => binding.gitmojiStripGitmoji(subject),
182
+ "leading-gitmoji": (subject) => binding.gitmojiLeadingGitmoji(subject) ?? undefined,
183
+ "section-for-gitmoji": (gitmoji) => binding.gitmojiSectionForGitmoji(gitmoji) as ReleaseSection,
184
+ "parse-noreply-email": (email) => mapAuthor(binding.gitmojiParseNoreplyEmail(email)),
185
+ "resolve-github-author": (email, authorMapJson) =>
186
+ mapAuthor(binding.gitmojiResolveGithubAuthor(email, authorMapJson)),
187
+ "display-login": (author) => binding.gitmojiDisplayLogin(author),
188
+ "profile-url": (author) => binding.gitmojiProfileUrl(author),
189
+ "avatar-url": (author) => binding.gitmojiAvatarUrl(author),
190
+ "author-mention": (email, authorName, authorMapJson) =>
191
+ binding.gitmojiAuthorMention(email, authorName, authorMapJson),
192
+ "commit-bullet": (body, email, authorName, authorMapJson) =>
193
+ binding.gitmojiCommitBullet(body, email, authorName, authorMapJson),
194
+ },
195
+ git: {
196
+ "discover-root": (startPath) => binding.gitDiscoverRoot(startPath),
197
+ "list-version-tags": (repoRoot) => binding.gitListVersionTags(repoRoot),
198
+ "list-tag-infos": (repoRoot) =>
199
+ binding.gitListTagInfos(repoRoot).map((tag) => ({
200
+ name: tag.name,
201
+ "short-hash": tag.shortHash,
202
+ })),
203
+ "format-tag-list": (repoRoot) => binding.gitFormatTagList(repoRoot),
204
+ "resolve-range": (repoRoot, version, fromRef, toRef) => {
205
+ const range = binding.gitResolveRange(repoRoot, version, fromRef, toRef);
206
+ return {
207
+ version: range.version,
208
+ "from-ref": range.fromRef,
209
+ "to-ref": range.toRef,
210
+ };
211
+ },
212
+ "collect-commits": (repoRoot, fromRef, toRef) => binding.gitCollectCommits(repoRoot, fromRef, toRef),
213
+ "detect-github-repo": (repoRoot) => binding.gitDetectGithubRepo(repoRoot) ?? undefined,
214
+ "parse-github-remote": (url) => binding.gitParseGithubRemote(url) ?? undefined,
215
+ },
216
+ publisher: {
217
+ "publish-workspace": (options) =>
218
+ binding.publisherPublishWorkspace({
219
+ ...(options.cwd !== undefined ? { cwd: options.cwd } : {}),
220
+ ...(options.dryRun !== undefined ? { dryRun: options.dryRun } : {}),
221
+ ...(options.refresh !== undefined ? { refresh: options.refresh } : {}),
222
+ ...(options.tag !== undefined ? { tag: options.tag } : {}),
223
+ ...(options.access !== undefined ? { access: options.access } : {}),
224
+ ...(options.npm !== undefined ? { npm: options.npm } : {}),
225
+ ...(options.otp !== undefined ? { otp: options.otp } : {}),
226
+ ...(options.totpSecret !== undefined ? { totpSecret: options.totpSecret } : {}),
227
+ ...(options.token !== undefined ? { token: options.token } : {}),
228
+ }),
229
+ "trust-workspace": (options) =>
230
+ binding.publisherTrustWorkspace({
231
+ ...(options.cwd !== undefined ? { cwd: options.cwd } : {}),
232
+ ...(options.dryRun !== undefined ? { dryRun: options.dryRun } : {}),
233
+ ...(options.refresh !== undefined ? { refresh: options.refresh } : {}),
234
+ ...(options.only !== undefined ? { only: options.only } : {}),
235
+ ...(options.npm !== undefined ? { npm: options.npm } : {}),
236
+ ...(options.otp !== undefined ? { otp: options.otp } : {}),
237
+ ...(options.totpSecret !== undefined ? { totpSecret: options.totpSecret } : {}),
238
+ ...(options.token !== undefined ? { token: options.token } : {}),
239
+ }),
240
+ },
241
+ };
242
+ }
243
+
244
+ let cached: NiftyNative | undefined;
245
+
246
+ /** Load the platform-specific Node-API binary from `@doki-land/nifty-<platform>`. */
247
+ export function loadNiftyNative(): NiftyNative {
248
+ if (cached) {
249
+ return cached;
250
+ }
251
+ const key = `${process.platform}-${process.arch}`;
252
+ const pkg = PLATFORM_PACKAGES[key];
253
+ if (!pkg) {
254
+ throw new Error(`Unsupported platform for Nifty native bindings: ${key}`);
255
+ }
256
+ const require = createRequire(import.meta.url);
257
+ const binding = require(pkg).default as NativeBinding;
258
+ cached = wrapBinding(binding);
259
+ return cached;
260
+ }
261
+
262
+ export function mapTagInfo(raw: { name: string; "short-hash": string }): TagInfo {
263
+ return { name: raw.name, shortHash: raw["short-hash"] };
264
+ }
265
+
266
+ export function mapRangeInfo(raw: { version: string; "from-ref"?: string; "to-ref": string }): RangeInfo {
267
+ return {
268
+ version: raw.version,
269
+ fromRef: raw["from-ref"],
270
+ toRef: raw["to-ref"],
271
+ };
272
+ }
273
+
274
+ export function mapCommitRecord(raw: CommitRecord): CommitRecord {
275
+ return {
276
+ hash: raw.hash,
277
+ email: raw.email,
278
+ author: raw.author,
279
+ subject: raw.subject,
280
+ body: raw.body,
281
+ gitmoji: raw.gitmoji,
282
+ section: raw.section as ReleaseSection,
283
+ };
284
+ }