@doki-land/nifty 0.1.0 → 0.1.2

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/cli/upload.ts CHANGED
@@ -29,11 +29,11 @@ type GithubRelease = {
29
29
  id: number;
30
30
  };
31
31
 
32
- export async function runUpload(argv: string[]): Promise<void> {
32
+ export async function runUpload(argv: string[]): Promise < void> {
33
33
  await uploadFromOptions(parseUploadArgs(argv));
34
34
  }
35
35
 
36
- export async function uploadFromOptions(options: UploadOptions): Promise<void> {
36
+ export async function uploadFromOptions(options: UploadOptions): Promise < void> {
37
37
  if (options.githubAction) {
38
38
  applyGithubActionDefaults(options);
39
39
  }
@@ -83,52 +83,52 @@ function parseUploadArgs(argv: string[]): UploadOptions {
83
83
 
84
84
  for (let i = 0; i < argv.length; i += 1) {
85
85
  const arg = argv[i];
86
- if (arg === "--release") options.release = true;
87
- else if (arg === "--pages") options.pages = true;
88
- else if (arg === "--both") options.both = true;
89
- else if (arg === "-d" || arg === "--dir") options.dir = argv[++i];
86
+ if (arg === "--release")options.release = true;
87
+ else if (arg === "--pages")options.pages = true;
88
+ else if (arg === "--both")options.both = true;
89
+ else if (arg === "-d" || arg === "--dir")options.dir = argv[++i];
90
90
  else if (arg === "-h" || arg === "--help") {
91
91
  printUploadHelp();
92
92
  process.exit(0);
93
93
  }
94
- else if (arg === "-t" || arg === "--tag") options.tag = argv[++i];
95
- else if (arg === "--repo") options.repo = argv[++i];
96
- else if (arg === "--token") options.token = argv[++i];
97
- else if (arg === "--name") options.name = argv[++i];
98
- else if (arg === "--notes") options.notes = argv[++i];
99
- else if (arg === "--notes-file") options.notesFile = argv[++i];
100
- else if (arg === "--draft") options.draft = true;
101
- else if (arg === "--no-generate-notes") options.generateNotes = false;
102
- else if (arg === "--github-action") options.githubAction = true;
103
- else if (arg === "-C" || arg === "--cwd") options.cwd = argv[++i];
94
+ else if (arg === "-t" || arg === "--tag")options.tag = argv[++i];
95
+ else if (arg === "--repo")options.repo = argv[++i];
96
+ else if (arg === "--token")options.token = argv[++i];
97
+ else if (arg === "--name")options.name = argv[++i];
98
+ else if (arg === "--notes")options.notes = argv[++i];
99
+ else if (arg === "--notes-file")options.notesFile = argv[++i];
100
+ else if (arg === "--draft")options.draft = true;
101
+ else if (arg === "--no-generate-notes")options.generateNotes = false;
102
+ else if (arg === "--github-action")options.githubAction = true;
103
+ else if (arg === "-C" || arg === "--cwd")options.cwd = argv[++i];
104
104
  }
105
105
 
106
106
  return options;
107
107
  }
108
108
 
109
109
  function parseTarget(options: UploadOptions): "release" | "pages" | "both" {
110
- if (options.both) return "both";
111
- if (options.pages) return "pages";
112
- if (options.release) return "release";
110
+ if (options.both)return "both";
111
+ if (options.pages)return "pages";
112
+ if (options.release)return "release";
113
113
  throw new Error("specify --release, --pages, or --both");
114
114
  }
115
115
 
116
116
  function applyGithubActionDefaults(options: UploadOptions): void {
117
- options.token ??= process.env.GITHUB_TOKEN;
118
- options.repo ??= process.env.GITHUB_REPOSITORY;
119
- options.tag ??= process.env.GITHUB_REF_NAME;
120
- options.cwd ??= process.env.GITHUB_WORKSPACE;
117
+ options.token??= process.env.GITHUB_TOKEN;
118
+ options.repo??= process.env.GITHUB_REPOSITORY;
119
+ options.tag??= process.env.GITHUB_REF_NAME;
120
+ options.cwd??= process.env.GITHUB_WORKSPACE;
121
121
  }
122
122
 
123
123
  async function resolveNotes(
124
124
  options: UploadOptions,
125
125
  repoRoot: string,
126
126
  tag: string,
127
- native: ReturnType<typeof loadNiftyNative>,
128
- ): Promise<string> {
129
- if (options.notes) return options.notes;
130
- if (options.notesFile) return readFileSync(options.notesFile, "utf8");
131
- if (!options.generateNotes) return "";
127
+ native: ReturnType < typeof loadNiftyNative > ,
128
+ ): Promise < string> {
129
+ if (options.notes)return options.notes;
130
+ if (options.notesFile)return readFileSync(options.notesFile, "utf8");
131
+ if (!options.generateNotes)return "";
132
132
  try {
133
133
  const range = native.git["resolve-range"](repoRoot, tag.replace(/^v/, ""), undefined, tag);
134
134
  const commits = native.git["collect-commits"](repoRoot, range["from-ref"], range["to-ref"]);
@@ -144,8 +144,8 @@ async function uploadReleaseAssets(
144
144
  tag: string,
145
145
  options: UploadOptions,
146
146
  notes: string,
147
- ): Promise<void> {
148
- const [owner, name] = splitRepo(repo);
147
+ ): Promise < void> {
148
+ const[owner, name] = splitRepo(repo);
149
149
  let release = await apiReleaseByTag(owner, name, tag, token);
150
150
  if (!release) {
151
151
  release = await apiCreateRelease(owner, name, tag, options.name ?? tag, notes, options.draft, token);
@@ -178,8 +178,8 @@ Options:
178
178
  `);
179
179
  }
180
180
 
181
- async function deployGithubPages(repo: string, token: string, dir: string): Promise<void> {
182
- const [owner, name] = splitRepo(repo);
181
+ async function deployGithubPages(repo: string, token: string, dir: string): Promise < void> {
182
+ const[owner, name] = splitRepo(repo);
183
183
  const source = resolve(dir);
184
184
  const work = mkdtempSync(join(tmpdir(), "nifty-pages-"));
185
185
  cpSync(source, work, { recursive: true });
@@ -226,7 +226,7 @@ function splitRepo(repo: string): [string, string] {
226
226
  if (parts.length !== 2 || !parts[0] || !parts[1]) {
227
227
  throw new Error(`invalid repo ${repo}, expected owner/name`);
228
228
  }
229
- return [parts[0], parts[1]];
229
+ return[parts[0], parts[1]];
230
230
  }
231
231
 
232
232
  async function apiReleaseByTag(
@@ -234,16 +234,16 @@ async function apiReleaseByTag(
234
234
  name: string,
235
235
  tag: string,
236
236
  token: string,
237
- ): Promise<GithubRelease | null> {
237
+ ): Promise < GithubRelease | null > {
238
238
  const response = await fetch(
239
239
  `https://api.github.com/repos/${owner}/${name}/releases/tags/${encodeURIComponent(tag)}`,
240
240
  { headers: githubHeaders(token) },
241
241
  );
242
- if (response.status === 404) return null;
242
+ if (response.status === 404)return null;
243
243
  if (!response.ok) {
244
244
  throw new Error(`GitHub API ${response.status}: ${await response.text()}`);
245
245
  }
246
- return (await response.json()) as GithubRelease;
246
+ return(await response.json())as GithubRelease;
247
247
  }
248
248
 
249
249
  async function apiCreateRelease(
@@ -254,7 +254,7 @@ async function apiCreateRelease(
254
254
  body: string,
255
255
  draft: boolean,
256
256
  token: string,
257
- ): Promise<GithubRelease> {
257
+ ): Promise < GithubRelease> {
258
258
  const response = await fetch(`https://api.github.com/repos/${owner}/${name}/releases`, {
259
259
  method: "POST",
260
260
  headers: { ...githubHeaders(token), "Content-Type": "application/json" },
@@ -263,7 +263,7 @@ async function apiCreateRelease(
263
263
  if (!response.ok) {
264
264
  throw new Error(`GitHub API ${response.status}: ${await response.text()}`);
265
265
  }
266
- return (await response.json()) as GithubRelease;
266
+ return(await response.json())as GithubRelease;
267
267
  }
268
268
 
269
269
  async function apiUploadAsset(
@@ -273,7 +273,7 @@ async function apiUploadAsset(
273
273
  assetName: string,
274
274
  filePath: string,
275
275
  token: string,
276
- ): Promise<void> {
276
+ ): Promise < void> {
277
277
  const url = `https://uploads.github.com/repos/${owner}/${name}/releases/${releaseId}/assets?name=${encodeURIComponent(assetName)}`;
278
278
  const body = readFileSync(filePath);
279
279
  const response = await fetch(url, {
@@ -296,7 +296,7 @@ async function apiUploadAsset(
296
296
  throw new Error(`GitHub upload ${response.status}: ${text}`);
297
297
  }
298
298
 
299
- function githubHeaders(token: string): Record<string, string> {
299
+ function githubHeaders(token: string): Record < string, string > {
300
300
  return {
301
301
  Accept: "application/vnd.github+json",
302
302
  Authorization: `Bearer ${token}`,
@@ -16,10 +16,10 @@ export type PackageManifest = {
16
16
  name: string;
17
17
  version: string;
18
18
  private?: boolean;
19
- dependencies?: Record<string, string>;
20
- devDependencies?: Record<string, string>;
21
- optionalDependencies?: Record<string, string>;
22
- peerDependencies?: Record<string, string>;
19
+ dependencies?: Record < string, string > ;
20
+ devDependencies?: Record < string, string > ;
21
+ optionalDependencies?: Record < string, string > ;
22
+ peerDependencies?: Record < string, string > ;
23
23
  };
24
24
 
25
25
  const DEPENDENCY_FIELDS = [
@@ -27,7 +27,7 @@ const DEPENDENCY_FIELDS = [
27
27
  "devDependencies",
28
28
  "optionalDependencies",
29
29
  "peerDependencies",
30
- ] as const;
30
+ ]as const;
31
31
 
32
32
  export function findWorkspaceRoot(cwd: string): string {
33
33
  const layout = detectProjectLayout(cwd);
@@ -45,7 +45,7 @@ export function findWorkspaceRoot(cwd: string): string {
45
45
  export function listWorkspacePackages(root: string): WorkspacePackage[] {
46
46
  const packagesDir = join(root, "projects", "packages");
47
47
  if (!existsSync(packagesDir)) {
48
- return [];
48
+ return[];
49
49
  }
50
50
 
51
51
  const packages: WorkspacePackage[] = [];
@@ -57,7 +57,7 @@ export function listWorkspacePackages(root: string): WorkspacePackage[] {
57
57
  if (!existsSync(manifestPath)) {
58
58
  continue;
59
59
  }
60
- const manifest = JSON.parse(readFileSync(manifestPath, "utf8")) as PackageManifest;
60
+ const manifest = JSON.parse(readFileSync(manifestPath, "utf8"))as PackageManifest;
61
61
  if (!manifest.name || !manifest.version) {
62
62
  throw new Error(`package.json missing name or version: ${manifestPath}`);
63
63
  }
@@ -76,15 +76,15 @@ export function listWorkspacePackages(root: string): WorkspacePackage[] {
76
76
 
77
77
  export function collectInternalDependencyNames(
78
78
  pkg: WorkspacePackage,
79
- byName: Map<string, WorkspacePackage>,
80
- ): Set<string> {
81
- const deps = new Set<string>();
79
+ byName: Map < string, WorkspacePackage > ,
80
+ ): Set < string> {
81
+ const deps = new Set < string> ();
82
82
  for (const field of DEPENDENCY_FIELDS) {
83
83
  const entries = pkg.manifest[field];
84
84
  if (!entries) {
85
85
  continue;
86
86
  }
87
- for (const [depName, spec] of Object.entries(entries)) {
87
+ for (const[depName, spec]of Object.entries(entries)) {
88
88
  if (byName.has(depName)) {
89
89
  deps.add(depName);
90
90
  continue;
@@ -101,7 +101,7 @@ export function collectInternalDependencyNames(
101
101
  function resolveWorkspaceDependencyName(
102
102
  spec: string,
103
103
  packageDir: string,
104
- byName: Map<string, WorkspacePackage>,
104
+ byName: Map < string, WorkspacePackage > ,
105
105
  ): string | undefined {
106
106
  if (spec.startsWith("workspace:")) {
107
107
  return undefined;
@@ -119,6 +119,6 @@ function resolveWorkspaceDependencyName(
119
119
  if (!existsSync(manifestPath)) {
120
120
  return undefined;
121
121
  }
122
- const manifest = JSON.parse(readFileSync(manifestPath, "utf8")) as PackageManifest;
122
+ const manifest = JSON.parse(readFileSync(manifestPath, "utf8"))as PackageManifest;
123
123
  return manifest.name;
124
124
  }
@@ -13,12 +13,8 @@ export function resolveAuthorMapPath(config: NiftyConfig, repoRoot: string): str
13
13
  }
14
14
 
15
15
  /** Load author map file contents for native helpers expecting JSON text. */
16
- export function loadAuthorMapJson(repoRoot: string, authorMapPath?: string): string {
17
- const abs = authorMapPath
18
- ? isAbsolute(authorMapPath)
19
- ? authorMapPath
20
- : join(repoRoot, authorMapPath)
21
- : resolveAuthorMapPath({}, repoRoot);
16
+ export function loadAuthorMapJson(repoRoot: string, authorMapPath?: string) : string {
17
+ const abs = authorMapPath ? isAbsolute(authorMapPath) ? authorMapPath : join(repoRoot, authorMapPath) : resolveAuthorMapPath({ }, repoRoot);
22
18
  if (!existsSync(abs)) {
23
19
  return "{}";
24
20
  }
@@ -3,10 +3,10 @@ import type { NiftyConfig, NiftyConfigEnv } from "./types.js";
3
3
  /** Type-safe helper for `nifty.config.ts` / `nifty.config.js`. */
4
4
  export function defineConfig(config: NiftyConfig): NiftyConfig;
5
5
  export function defineConfig(
6
- config: (env: NiftyConfigEnv) => NiftyConfig | Promise<NiftyConfig>,
7
- ): (env: NiftyConfigEnv) => NiftyConfig | Promise<NiftyConfig>;
6
+ config: (env: NiftyConfigEnv) => NiftyConfig | Promise < NiftyConfig> ,
7
+ ): (env: NiftyConfigEnv) => NiftyConfig | Promise < NiftyConfig> ;
8
8
  export function defineConfig(
9
- config: NiftyConfig | ((env: NiftyConfigEnv) => NiftyConfig | Promise<NiftyConfig>),
10
- ): NiftyConfig | ((env: NiftyConfigEnv) => NiftyConfig | Promise<NiftyConfig>) {
9
+ config: NiftyConfig | ((env: NiftyConfigEnv) => NiftyConfig | Promise < NiftyConfig> ),
10
+ ): NiftyConfig | ((env: NiftyConfigEnv) => NiftyConfig | Promise < NiftyConfig> ) {
11
11
  return config;
12
12
  }
@@ -162,7 +162,7 @@ export function detectProjectLayout(cwd = process.cwd()): ProjectLayout {
162
162
 
163
163
  /** Discover npm package directories for hybrid monorepos. */
164
164
  export function discoverPackageDirs(layout: ProjectLayout): string[] {
165
- const roots = new Set<string>();
165
+ const roots = new Set < string> ();
166
166
 
167
167
  if (layout.npmWorkspaceRoot) {
168
168
  roots.add(layout.npmWorkspaceRoot);
@@ -185,5 +185,5 @@ export function discoverPackageDirs(layout: ProjectLayout): string[] {
185
185
  }
186
186
  }
187
187
 
188
- return [...roots];
188
+ return[...roots];
189
189
  }
@@ -23,7 +23,7 @@ const NIFTY_PRESET_INCLUDES = [
23
23
  "projects/dashboard/**",
24
24
  "package.json",
25
25
  "nifty.config.ts",
26
- ] as const;
26
+ ]as const;
27
27
 
28
28
  /** VMZ hybrid monorepo — JS/TS surfaces only, never whole-repo walk. */
29
29
  const VMZ_INCLUDES = [
@@ -37,9 +37,9 @@ const VMZ_INCLUDES = [
37
37
  "packages/homepage/**",
38
38
  "package.json",
39
39
  "nifty.config.ts",
40
- ] as const;
40
+ ]as const;
41
41
 
42
- const PRESET_INCLUDES: Record<NiftyFormatPreset, readonly string[] | undefined> = {
42
+ const PRESET_INCLUDES: Record < NiftyFormatPreset, readonly string[] | undefined > = {
43
43
  default: undefined,
44
44
  nifty: NIFTY_PRESET_INCLUDES,
45
45
  "npm-tools": NIFTY_PRESET_INCLUDES,
@@ -12,7 +12,7 @@ export type LoadConfigOptions = {
12
12
  /** When set, skip searching and load this file directly. */
13
13
  configFile?: string;
14
14
  /** Passed to functional configs: `export default defineConfig(({ mode }) => ...)`. */
15
- env?: Partial<NiftyConfigEnv>;
15
+ env?: Partial < NiftyConfigEnv> ;
16
16
  /**
17
17
  * When true (default), write `nifty.config.ts` at the detected project root if missing.
18
18
  * Set false for `--dry-run` so commands only report what would happen.
@@ -63,7 +63,7 @@ export function defaultConfigPath(cwd = process.cwd()): string {
63
63
  }
64
64
 
65
65
  /** Warn and optionally create a default config when none exists. */
66
- export function ensureConfigFile(options: { cwd?: string; create?: boolean } = {}): string | undefined {
66
+ export function ensureConfigFile(options: { cwd?: string; create?: boolean } = { }): string | undefined {
67
67
  const cwd = options.cwd ?? process.cwd();
68
68
  const existing = findConfigFile(cwd);
69
69
  if (existing) {
@@ -83,12 +83,12 @@ export function ensureConfigFile(options: { cwd?: string; create?: boolean } = {
83
83
 
84
84
  function normalizeExport(raw: unknown): NiftyConfigExport {
85
85
  if (raw && typeof raw === "object" && "default" in raw) {
86
- return (raw as { default: NiftyConfigExport }).default;
86
+ return(raw as { default: NiftyConfigExport }).default;
87
87
  }
88
88
  return raw as NiftyConfigExport;
89
89
  }
90
90
 
91
- async function resolveExport(exported: NiftyConfigExport, env: NiftyConfigEnv): Promise<NiftyConfig> {
91
+ async function resolveExport(exported: NiftyConfigExport, env: NiftyConfigEnv): Promise < NiftyConfig> {
92
92
  if (typeof exported === "function") {
93
93
  return await exported(env);
94
94
  }
@@ -96,7 +96,7 @@ async function resolveExport(exported: NiftyConfigExport, env: NiftyConfigEnv):
96
96
  }
97
97
 
98
98
  /** Load `nifty.config.ts/js`, creating a default file at the project root when missing. */
99
- export async function loadConfig(options: LoadConfigOptions = {}): Promise<LoadedNiftyConfig> {
99
+ export async function loadConfig(options: LoadConfigOptions = { }): Promise < LoadedNiftyConfig> {
100
100
  const cwd = options.cwd ?? process.cwd();
101
101
  let configFile = options.configFile ?? findConfigFile(cwd);
102
102
  let created = false;
@@ -106,11 +106,11 @@ export async function loadConfig(options: LoadConfigOptions = {}): Promise<Loade
106
106
  created = Boolean(configFile);
107
107
  } else if (!configFile) {
108
108
  ensureConfigFile({ cwd, create: false });
109
- return { config: {} };
109
+ return { config: { } };
110
110
  }
111
111
 
112
112
  if (!configFile) {
113
- return { config: {} };
113
+ return { config: { } };
114
114
  }
115
115
 
116
116
  const env: NiftyConfigEnv = { ...DEFAULT_ENV(cwd), ...options.env };
@@ -4,11 +4,11 @@ import type { NiftyConfig } from "./types.js";
4
4
  export function trustPayloadFromConfig(config: NiftyConfig) {
5
5
  const npm = config.trust?.npm;
6
6
  if (!npm) {
7
- return {};
7
+ return { };
8
8
  }
9
9
  return {
10
- ...(npm.repo ? { trustRepo: npm.repo } : {}),
11
- ...(npm.file ? { trustFile: npm.file } : {}),
12
- ...(npm.environment ? { trustEnvironment: npm.environment } : {}),
10
+ ...(npm.repo ? { trustRepo: npm.repo } : { }),
11
+ ...(npm.file ? { trustFile: npm.file } : { }),
12
+ ...(npm.environment ? { trustEnvironment: npm.environment } : { }),
13
13
  };
14
14
  }
@@ -84,7 +84,7 @@ export type NiftyConfig = {
84
84
  };
85
85
  /** Rule-based lint configuration. */
86
86
  lint?: {
87
- rules?: Array<{
87
+ rules?: Array < {
88
88
  id: string;
89
89
  enabled?: boolean;
90
90
  severity?: "error" | "warning" | "info";
@@ -94,7 +94,7 @@ export type NiftyConfig = {
94
94
  format?: NiftyFormatConfig;
95
95
  };
96
96
 
97
- export type NiftyConfigExport = NiftyConfig | ((env: NiftyConfigEnv) => NiftyConfig | Promise<NiftyConfig>);
97
+ export type NiftyConfigExport = NiftyConfig | ((env: NiftyConfigEnv) => NiftyConfig | Promise < NiftyConfig> );
98
98
 
99
99
  export type NiftyConfigEnv = {
100
100
  mode: string;
@@ -108,4 +108,4 @@ export const CONFIG_FILE_NAMES = [
108
108
  "nifty.config.js",
109
109
  "nifty.config.mjs",
110
110
  "nifty.config.cjs",
111
- ] as const;
111
+ ]as const;
package/src/git.ts CHANGED
@@ -11,7 +11,7 @@ export type ResolveRangeOptions = {
11
11
  * Read-only git repository helpers (gix via Node-API, no `git` subprocess).
12
12
  */
13
13
  export class Git {
14
- constructor(private readonly wasm: GitExports) {}
14
+ constructor(private readonly wasm: GitExports) { }
15
15
 
16
16
  static open(): Git {
17
17
  const native = loadNiftyNative();
@@ -36,7 +36,7 @@ export class Git {
36
36
  return this.wasm["format-tag-list"](repoRoot);
37
37
  }
38
38
 
39
- resolveRange(repoRoot: string, options: ResolveRangeOptions = {}): RangeInfo {
39
+ resolveRange(repoRoot: string, options: ResolveRangeOptions = { }): RangeInfo {
40
40
  return mapRangeInfo(
41
41
  this.wasm["resolve-range"](repoRoot, options.version, options.fromRef, options.toRef),
42
42
  );
package/src/github.ts CHANGED
@@ -3,7 +3,7 @@ import type { GithubAuthor } from "./types.js";
3
3
  const USER_AGENT = "nifty-github";
4
4
  const ACCEPT = "application/vnd.github+json";
5
5
 
6
- function parseUserJson(body: Record<string, unknown>, fallbackLogin?: string): GithubAuthor {
6
+ function parseUserJson(body: Record < string, unknown > , fallbackLogin?: string) : GithubAuthor {
7
7
  const id = typeof body.id === "number" ? BigInt(body.id) : undefined;
8
8
  const login = typeof body.login === "string" ? body.login : fallbackLogin;
9
9
  if (id === undefined && login === undefined) {
@@ -12,8 +12,8 @@ function parseUserJson(body: Record<string, unknown>, fallbackLogin?: string): G
12
12
  return { id, login };
13
13
  }
14
14
 
15
- async function getJson(url: string, token?: string): Promise<Record<string, unknown>> {
16
- const headers: Record<string, string> = {
15
+ async function getJson(url: string, token?: string) : Promise < Record < string, unknown>> {
16
+ const headers: Record < string, string > = {
17
17
  Accept: ACCEPT,
18
18
  "User-Agent": USER_AGENT,
19
19
  };
@@ -27,7 +27,7 @@ async function getJson(url: string, token?: string): Promise<Record<string, unkn
27
27
  if (!response.ok) {
28
28
  throw new Error(`GitHub API error: ${response.status} ${response.statusText}`);
29
29
  }
30
- return (await response.json()) as Record<string, unknown>;
30
+ return(await response.json())as Record < string, unknown > ;
31
31
  }
32
32
 
33
33
  function parseNoreplyEmail(email: string): GithubAuthor | undefined {
@@ -37,7 +37,7 @@ function parseNoreplyEmail(email: string): GithubAuthor | undefined {
37
37
  if (!lower.endsWith(suffix)) {
38
38
  return undefined;
39
39
  }
40
- const local = trimmed.slice(0, -suffix.length);
40
+ const local = trimmed.slice(0, - suffix.length);
41
41
  const plus = local.indexOf("+");
42
42
  if (plus >= 0) {
43
43
  const idPart = local.slice(0, plus);
@@ -53,14 +53,14 @@ function parseNoreplyEmail(email: string): GithubAuthor | undefined {
53
53
  return { login: local };
54
54
  }
55
55
 
56
- function loadAuthorMap(json: string): Map<string, GithubAuthor> {
57
- const map = new Map<string, GithubAuthor>();
56
+ function loadAuthorMap(json: string): Map < string, GithubAuthor > {
57
+ const map = new Map < string, GithubAuthor > ();
58
58
  if (!json.trim()) {
59
59
  return map;
60
60
  }
61
- const parsed = JSON.parse(json) as Record<string, { id?: number; login?: string }>;
62
- for (const [email, entry] of Object.entries(parsed)) {
63
- const author: GithubAuthor = {};
61
+ const parsed = JSON.parse(json)as Record < string, { id?: number; login?: string }>;
62
+ for (const[email, entry]of Object.entries(parsed)) {
63
+ const author: GithubAuthor = { };
64
64
  if (typeof entry.id === "number") {
65
65
  author.id = BigInt(entry.id);
66
66
  }
@@ -81,7 +81,7 @@ function mergeAuthors(existing: GithubAuthor, incoming: GithubAuthor): GithubAut
81
81
  };
82
82
  }
83
83
 
84
- async function enrichAuthor(author: GithubAuthor, token?: string, fetch = false): Promise<GithubAuthor> {
84
+ async function enrichAuthor(author: GithubAuthor, token?: string, fetch = false) : Promise < GithubAuthor> {
85
85
  if (!fetch && author.id !== undefined && author.login !== undefined) {
86
86
  return author;
87
87
  }
@@ -95,7 +95,7 @@ async function enrichAuthor(author: GithubAuthor, token?: string, fetch = false)
95
95
  return author;
96
96
  }
97
97
 
98
- async function userByLoginFetch(login: string, token?: string): Promise<GithubAuthor> {
98
+ async function userByLoginFetch(login: string, token?: string) : Promise < GithubAuthor> {
99
99
  const trimmed = login.trim();
100
100
  if (!trimmed) {
101
101
  throw new Error("login must not be empty");
@@ -104,7 +104,7 @@ async function userByLoginFetch(login: string, token?: string): Promise<GithubAu
104
104
  return parseUserJson(body, trimmed);
105
105
  }
106
106
 
107
- async function searchUserByEmailFetch(email: string, token: string): Promise<GithubAuthor | undefined> {
107
+ async function searchUserByEmailFetch(email: string, token: string): Promise < GithubAuthor | undefined > {
108
108
  const trimmed = email.trim();
109
109
  const auth = token.trim();
110
110
  if (!trimmed) {
@@ -119,7 +119,7 @@ async function searchUserByEmailFetch(email: string, token: string): Promise<Git
119
119
  if (!Array.isArray(items) || items.length === 0) {
120
120
  return undefined;
121
121
  }
122
- const first = items[0] as Record<string, unknown>;
122
+ const first = items[0]as Record < string, unknown > ;
123
123
  return parseUserJson(first);
124
124
  }
125
125
 
@@ -134,17 +134,17 @@ export type LookupUserOptions = {
134
134
  * Rust equivalent: `nifty-github` crate.
135
135
  */
136
136
  export class Github {
137
- constructor(private readonly token?: string) {}
137
+ constructor(private readonly token?: string) { }
138
138
 
139
- static open(token?: string): Github {
139
+ static open(token?: string) : Github {
140
140
  return new Github(token);
141
141
  }
142
142
 
143
- async userByLogin(login: string, token?: string): Promise<GithubAuthor> {
143
+ async userByLogin(login: string, token?: string) : Promise < GithubAuthor> {
144
144
  return userByLoginFetch(login, token ?? this.token);
145
145
  }
146
146
 
147
- async searchUserByEmail(email: string, token?: string): Promise<GithubAuthor | undefined> {
147
+ async searchUserByEmail(email: string, token?: string) : Promise < GithubAuthor | undefined > {
148
148
  const auth = token ?? this.token;
149
149
  if (!auth) {
150
150
  throw new Error("GitHub token is required for email search");
@@ -152,7 +152,7 @@ export class Github {
152
152
  return searchUserByEmailFetch(email, auth);
153
153
  }
154
154
 
155
- async lookupUserByEmail(email: string, options: LookupUserOptions = {}): Promise<GithubAuthor | undefined> {
155
+ async lookupUserByEmail(email: string, options: LookupUserOptions = { }): Promise < GithubAuthor | undefined > {
156
156
  const token = options.token ?? this.token;
157
157
  const fetch = options.fetch ?? false;
158
158
  const mapJson = options.authorMapJson ?? "{}";
@@ -179,6 +179,6 @@ export class Github {
179
179
  }
180
180
  }
181
181
 
182
- export function createGithub(token?: string): Github {
182
+ export function createGithub(token?: string) : Github {
183
183
  return Github.open(token);
184
184
  }
package/src/gitmoji.ts CHANGED
@@ -8,7 +8,7 @@ export class Gitmoji {
8
8
  constructor(
9
9
  private readonly wasm: GitmojiExports,
10
10
  private readonly defaultAuthorMapJson = "{}",
11
- ) {}
11
+ ) { }
12
12
 
13
13
  static open(authorMapJson = "{}"): Gitmoji {
14
14
  const native = loadNiftyNative();
@@ -39,7 +39,7 @@ export class Gitmoji {
39
39
  return this.wasm["leading-gitmoji"](subject);
40
40
  }
41
41
 
42
- sectionForGitmoji(gitmoji?: string): ReleaseSection {
42
+ sectionForGitmoji(gitmoji?: string) : ReleaseSection {
43
43
  return this.wasm["section-for-gitmoji"](gitmoji);
44
44
  }
45
45