metascope 0.8.5 → 0.9.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.
Files changed (103) hide show
  1. package/dist/bin/cli.js +30426 -29237
  2. package/dist/bin/{jiti-DDHyYNLW.js → jiti-B26uDQuv.js} +2 -2
  3. package/dist/bin/renovate-CEC0BhMB.js +1 -0
  4. package/dist/bin/shared-Ch5JsD6s.js +8 -0
  5. package/dist/bin/shared2-Dhjk_Okb.js +1 -0
  6. package/dist/bin/web-tree-sitter.wasm +0 -0
  7. package/dist/lib/data/license-urls.js +2904 -0
  8. package/dist/lib/file-matching.js +5 -2
  9. package/dist/lib/log.d.ts +0 -1
  10. package/dist/lib/metadata-types.d.ts +16 -9
  11. package/dist/lib/metadata.d.ts +0 -1
  12. package/dist/lib/metadata.js +5 -5
  13. package/dist/lib/package.js +1 -1
  14. package/dist/lib/parsers/configparser-parser.js +14 -12
  15. package/dist/lib/parsers/gemspec-parser.js +41 -42
  16. package/dist/lib/parsers/go-mod-parser.js +51 -45
  17. package/dist/lib/parsers/makefile-config-parser.js +7 -6
  18. package/dist/lib/parsers/properties-parser.js +1 -1
  19. package/dist/lib/parsers/rfc822-header-parser.js +8 -6
  20. package/dist/lib/parsers/setup-py-parser.js +28 -24
  21. package/dist/lib/source.d.ts +6 -2
  22. package/dist/lib/sources/arduino-library-properties.d.ts +0 -1
  23. package/dist/lib/sources/arduino-library-properties.js +6 -7
  24. package/dist/lib/sources/cinder-cinderblock-xml.d.ts +0 -1
  25. package/dist/lib/sources/cinder-cinderblock-xml.js +5 -5
  26. package/dist/lib/sources/code-stats.d.ts +3 -2
  27. package/dist/lib/sources/codemeta-json.d.ts +0 -1
  28. package/dist/lib/sources/codemeta-json.js +21 -20
  29. package/dist/lib/sources/dependency-updates.d.ts +17 -8
  30. package/dist/lib/sources/dependency-updates.js +38 -34
  31. package/dist/lib/sources/file-stats.d.ts +7 -4
  32. package/dist/lib/sources/git-config.d.ts +0 -1
  33. package/dist/lib/sources/git-stats.d.ts +47 -24
  34. package/dist/lib/sources/git-stats.js +51 -33
  35. package/dist/lib/sources/github-actions.d.ts +0 -1
  36. package/dist/lib/sources/github-actions.js +4 -3
  37. package/dist/lib/sources/github.d.ts +156 -78
  38. package/dist/lib/sources/github.js +11 -8
  39. package/dist/lib/sources/go-go-mod.d.ts +0 -1
  40. package/dist/lib/sources/go-goreleaser-yaml.d.ts +0 -1
  41. package/dist/lib/sources/go-goreleaser-yaml.js +5 -3
  42. package/dist/lib/sources/java-pom-xml.d.ts +0 -1
  43. package/dist/lib/sources/java-pom-xml.js +12 -12
  44. package/dist/lib/sources/license-file.d.ts +0 -1
  45. package/dist/lib/sources/metadata-file.d.ts +0 -1
  46. package/dist/lib/sources/metadata-file.js +9 -10
  47. package/dist/lib/sources/metascope.d.ts +9 -5
  48. package/dist/lib/sources/node-npm-registry.d.ts +21 -11
  49. package/dist/lib/sources/node-npm-registry.js +12 -6
  50. package/dist/lib/sources/node-package-json.d.ts +0 -1
  51. package/dist/lib/sources/obsidian-plugin-manifest-json.d.ts +17 -9
  52. package/dist/lib/sources/obsidian-plugin-manifest-json.js +2 -2
  53. package/dist/lib/sources/obsidian-plugin-registry.d.ts +3 -2
  54. package/dist/lib/sources/obsidian-plugin-registry.js +2 -1
  55. package/dist/lib/sources/openframeworks-addon-config-mk.d.ts +0 -1
  56. package/dist/lib/sources/openframeworks-install-xml.d.ts +0 -1
  57. package/dist/lib/sources/openframeworks-install-xml.js +3 -3
  58. package/dist/lib/sources/processing-library-properties.d.ts +0 -1
  59. package/dist/lib/sources/processing-library-properties.js +9 -10
  60. package/dist/lib/sources/processing-sketch-properties.d.ts +0 -1
  61. package/dist/lib/sources/processing-sketch-properties.js +13 -20
  62. package/dist/lib/sources/publiccode-yaml.d.ts +0 -1
  63. package/dist/lib/sources/publiccode-yaml.js +61 -58
  64. package/dist/lib/sources/python-pkg-info.d.ts +0 -1
  65. package/dist/lib/sources/python-pkg-info.js +6 -5
  66. package/dist/lib/sources/python-pypi-registry.d.ts +21 -11
  67. package/dist/lib/sources/python-pypi-registry.js +23 -16
  68. package/dist/lib/sources/python-pyproject-toml.d.ts +0 -1
  69. package/dist/lib/sources/python-setup-cfg.d.ts +2 -3
  70. package/dist/lib/sources/python-setup-cfg.js +10 -9
  71. package/dist/lib/sources/python-setup-py.d.ts +0 -1
  72. package/dist/lib/sources/readme-file.d.ts +0 -1
  73. package/dist/lib/sources/readme-file.js +4 -3
  74. package/dist/lib/sources/ruby-gemspec.d.ts +0 -1
  75. package/dist/lib/sources/rust-cargo-toml.d.ts +0 -1
  76. package/dist/lib/sources/rust-cargo-toml.js +1 -1
  77. package/dist/lib/sources/xcode-info-plist.d.ts +0 -1
  78. package/dist/lib/sources/xcode-info-plist.js +29 -31
  79. package/dist/lib/sources/xcode-project-pbxproj.d.ts +0 -1
  80. package/dist/lib/sources/xcode-project-pbxproj.js +17 -16
  81. package/dist/lib/templates/codemeta-json.d.ts +1 -0
  82. package/dist/lib/templates/codemeta.d.ts +1 -0
  83. package/dist/lib/templates/codemeta.js +98 -89
  84. package/dist/lib/templates/frontmatter.d.ts +2 -1
  85. package/dist/lib/templates/frontmatter.js +1 -1
  86. package/dist/lib/templates/index.d.ts +2 -1
  87. package/dist/lib/templates/index.js +1 -1
  88. package/dist/lib/templates/metadata.d.ts +1 -0
  89. package/dist/lib/templates/project.d.ts +1 -0
  90. package/dist/lib/utilities/codemeta-helpers.js +14 -13
  91. package/dist/lib/utilities/fetch.js +5 -3
  92. package/dist/lib/utilities/formatting.js +1 -1
  93. package/dist/lib/utilities/github.js +2 -2
  94. package/dist/lib/utilities/license-identification.d.ts +9 -4
  95. package/dist/lib/utilities/license-identification.js +37 -23
  96. package/dist/lib/utilities/template-helpers.d.ts +7 -5
  97. package/dist/lib/utilities/template-helpers.js +15 -14
  98. package/dist/lib/utilities/tree-sitter-wasm.d.ts +0 -1
  99. package/dist/lib/utilities/tree-sitter-wasm.js +1 -1
  100. package/package.json +18 -17
  101. package/readme.md +13 -11
  102. package/dist/bin/renovate-CpDMbQZd.js +0 -1
  103. package/dist/bin/shared-Dix5HPlG.js +0 -6
@@ -6,8 +6,8 @@ import { stat } from "node:fs/promises";
6
6
  import { join, resolve } from "node:path";
7
7
  import { simpleGit } from "simple-git";
8
8
  //#region src/lib/sources/git-stats.ts
9
- const VERSION_TAG_REGEX = /^v?\d+(?:\.\d+){1,2}$/;
10
- const LEADING_V_REGEX = /^v/;
9
+ const VERSION_TAG_REGEX = /^v?\d+(?:\.\d+){1,2}$/v;
10
+ const LEADING_V_REGEX = /^v/v;
11
11
  const gitStatsSource = defineSource({
12
12
  async discover(context) {
13
13
  return (await getMatches(context.options, [".git/config"])).map((value) => resolve(value, "../../"));
@@ -21,41 +21,56 @@ const gitStatsSource = defineSource({
21
21
  git.log(),
22
22
  git.branch(),
23
23
  git.tags(),
24
- git.raw([
25
- "rev-list",
26
- "--max-parents=0",
27
- "HEAD",
28
- "--format=%aI"
29
- ]).then((output) => {
30
- return output.trim().split("\n").filter((line) => !line.startsWith("commit ")).at(-1) ?? void 0;
31
- }),
32
- git.raw(["ls-files"]).then((output) => output.trim().split("\n").filter(Boolean)),
24
+ (async () => {
25
+ return (await git.raw([
26
+ "rev-list",
27
+ "--max-parents=0",
28
+ "HEAD",
29
+ "--format=%aI"
30
+ ])).trim().split("\n").filter((line) => !line.startsWith("commit ")).at(-1) ?? void 0;
31
+ })(),
32
+ (async () => {
33
+ return (await git.raw(["ls-files"])).trim().split("\n").filter(Boolean);
34
+ })(),
33
35
  git.getRemotes(),
34
- git.raw(["submodule", "status"]).then((output) => {
35
- const count = output.trim().split("\n").filter(Boolean).length;
36
- return count > 0 ? count : void 0;
37
- }).catch(() => void 0),
38
- git.raw(["lfs", "ls-files"]).then((output) => output.trim().length > 0 ? true : void 0).catch(() => void 0)
36
+ (async () => {
37
+ try {
38
+ const count = (await git.raw(["submodule", "status"])).trim().split("\n").filter(Boolean).length;
39
+ return count > 0 ? count : void 0;
40
+ } catch {
41
+ return;
42
+ }
43
+ })(),
44
+ (async () => {
45
+ try {
46
+ return (await git.raw(["lfs", "ls-files"])).trim().length > 0 ? true : void 0;
47
+ } catch {
48
+ return;
49
+ }
50
+ })()
39
51
  ]);
40
52
  const contributors = new Set(logResult.all.map((commit) => commit.author_email));
41
53
  const tagNameLatest = tagResult.latest ?? void 0;
42
54
  const [trackedSizeBytes, tagDateLatest, versionTagInfo, remoteStatusEntries] = await Promise.all([
43
- batchMap(trackedFiles, async (file) => {
44
- try {
45
- return (await stat(join(context.options.path, file))).size;
46
- } catch {
47
- return 0;
48
- }
49
- }).then((sizes) => sizes.reduce((sum, size) => sum + size, 0)),
50
55
  (async () => {
51
- if (!tagNameLatest) return;
56
+ return (await batchMap(trackedFiles, async (file) => {
57
+ try {
58
+ return (await stat(join(context.options.path, file))).size;
59
+ } catch {
60
+ return 0;
61
+ }
62
+ })).reduce((sum, size) => sum + size, 0);
63
+ })(),
64
+ (async () => {
65
+ if (tagNameLatest === void 0 || tagNameLatest === "") return;
52
66
  try {
53
- return (await git.raw([
67
+ const trimmed = (await git.raw([
54
68
  "log",
55
69
  "-1",
56
70
  "--format=%aI",
57
71
  tagNameLatest
58
- ])).trim() || void 0;
72
+ ])).trim();
73
+ return trimmed.length > 0 ? trimmed : void 0;
59
74
  } catch {
60
75
  return;
61
76
  }
@@ -65,16 +80,19 @@ const gitStatsSource = defineSource({
65
80
  const versionTags = (await git.raw(["tag", "--sort=-creatordate"])).trim().split("\n").filter(Boolean).filter((tag) => VERSION_TAG_REGEX.test(tag));
66
81
  const tagReleaseCount = versionTags.length > 0 ? versionTags.length : void 0;
67
82
  const match = versionTags[0];
68
- if (match) return {
69
- tagReleaseCount,
70
- tagVersionDateLatest: (await git.raw([
83
+ if (match !== void 0) {
84
+ const trimmedDate = (await git.raw([
71
85
  "log",
72
86
  "-1",
73
87
  "--format=%aI",
74
88
  match
75
- ])).trim() || void 0,
76
- tagVersionLatest: match.replace(LEADING_V_REGEX, "")
77
- };
89
+ ])).trim();
90
+ return {
91
+ tagReleaseCount,
92
+ tagVersionDateLatest: trimmedDate.length > 0 ? trimmedDate : void 0,
93
+ tagVersionLatest: match.replace(LEADING_V_REGEX, "")
94
+ };
95
+ }
78
96
  return {
79
97
  tagReleaseCount,
80
98
  tagVersionDateLatest: void 0,
@@ -98,7 +116,7 @@ const gitStatsSource = defineSource({
98
116
  "--count",
99
117
  `HEAD...${reference}`
100
118
  ])).trim().split(" ").map(Number);
101
- return [remote.name, {
119
+ if (ahead !== void 0 && behind !== void 0) return [remote.name, {
102
120
  ahead,
103
121
  behind
104
122
  }];
@@ -1,6 +1,5 @@
1
1
  import { OneOrMany, SourceRecord } from "../source.js";
2
2
  import { z } from "zod";
3
-
4
3
  //#region src/lib/sources/github-actions.d.ts
5
4
  declare const githubActionSchema: z.ZodObject<{
6
5
  file: z.ZodString;
@@ -83,7 +83,7 @@ async function fetchWorkflowRuns(octokit, owner, repo, defaultBranch) {
83
83
  for (const run of response.data.workflow_runs) {
84
84
  if (runsByPath.has(run.path)) continue;
85
85
  let durationMs;
86
- if (run.run_started_at) durationMs = new Date(run.updated_at).getTime() - new Date(run.run_started_at).getTime();
86
+ if (run.run_started_at !== void 0 && run.run_started_at !== "") durationMs = new Date(run.updated_at).getTime() - new Date(run.run_started_at).getTime();
87
87
  const conclusion = workflowRunConclusion.safeParse(run.conclusion);
88
88
  const status = workflowRunStatus.safeParse(run.status);
89
89
  if (!conclusion.success || !status.success) continue;
@@ -124,9 +124,10 @@ const githubActionsSource = {
124
124
  else try {
125
125
  const ownerRepo = await resolveOwnerRepo(context);
126
126
  if (ownerRepo) {
127
- const octokit = new Octokit(context.options.credentials?.githubToken ? { auth: context.options.credentials.githubToken } : void 0);
127
+ const githubToken = context.options.credentials?.githubToken;
128
+ const octokit = new Octokit(githubToken !== void 0 && githubToken !== "" ? { auth: githubToken } : void 0);
128
129
  let defaultBranch = ensureArray(context.metadata?.github)[0]?.data.defaultBranch;
129
- if (!defaultBranch) defaultBranch = (await octokit.rest.repos.get({
130
+ if (defaultBranch === void 0 || defaultBranch === "") defaultBranch = (await octokit.rest.repos.get({
130
131
  owner: ownerRepo.owner,
131
132
  repo: ownerRepo.repo
132
133
  })).data.default_branch;
@@ -1,92 +1,170 @@
1
1
  import { OneOrMany, SourceRecord } from "../source.js";
2
-
3
2
  //#region src/lib/sources/github.d.ts
4
3
  type GitHubInfo = {
5
- /** ISO 8601 date when the repo was archived, if applicable. */archivedAt?: string; /** Name of the repository's code of conduct. */
6
- codeOfConduct?: string; /** Commits the default branch is ahead of the upstream fork parent. */
7
- commitsAheadUpstream?: number; /** Commits the default branch is behind the upstream fork parent. */
8
- commitsBehindUpstream?: number; /** Number of contributors to the repository. */
9
- contributorCount?: number; /** ISO 8601 date when the repo was created. */
10
- createdAt?: string; /** GitHub's internal numeric repository ID. */
11
- databaseId?: number; /** Name of the default branch (e.g. "main"). */
12
- defaultBranch?: string; /** Repository description. */
13
- description?: string; /** Total number of discussions. */
14
- discussionCount?: number; /** Repository disk usage in bytes. */
15
- diskUsageBytes?: number; /** Number of forks. */
16
- forkCount?: number; /** URL of the upstream repository this was forked from. */
17
- forkedFrom?: string; /** Funding links configured on the repository. */
4
+ /** ISO 8601 date when the repo was archived, if applicable. */
5
+ archivedAt?: string;
6
+ /** Name of the repository's code of conduct. */
7
+ codeOfConduct?: string;
8
+ /** Commits the default branch is ahead of the upstream fork parent. */
9
+ commitsAheadUpstream?: number;
10
+ /** Commits the default branch is behind the upstream fork parent. */
11
+ commitsBehindUpstream?: number;
12
+ /** Number of contributors to the repository. */
13
+ contributorCount?: number;
14
+ /** ISO 8601 date when the repo was created. */
15
+ createdAt?: string;
16
+ /** GitHub's internal numeric repository ID. */
17
+ databaseId?: number;
18
+ /** Name of the default branch (e.g. "main"). */
19
+ defaultBranch?: string;
20
+ /** Repository description. */
21
+ description?: string;
22
+ /** Total number of discussions. */
23
+ discussionCount?: number;
24
+ /** Repository disk usage in bytes. */
25
+ diskUsageBytes?: number;
26
+ /** Number of forks. */
27
+ forkCount?: number;
28
+ /** URL of the upstream repository this was forked from. */
29
+ forkedFrom?: string;
30
+ /** Funding links configured on the repository. */
18
31
  fundingLinks?: Array<{
19
32
  platform: string;
20
33
  url: string;
21
- }>; /** Whether a CONTRIBUTING file exists. */
22
- hasContributing?: boolean; /** Whether discussions are enabled. */
23
- hasDiscussionsEnabled?: boolean; /** Whether issues are enabled. */
24
- hasIssuesEnabled?: boolean; /** Whether the repo uses Git LFS (detected via .gitattributes). */
25
- hasLfs?: boolean; /** Whether GitHub Pages is enabled. */
26
- hasPages?: boolean; /** Whether projects are enabled. */
27
- hasProjectsEnabled?: boolean; /** Whether sponsorships are enabled. */
28
- hasSponsorshipsEnabled?: boolean; /** Whether vulnerability alerts are enabled. */
29
- hasVulnerabilityAlertsEnabled?: boolean; /** Whether the wiki is enabled. */
30
- hasWikiEnabled?: boolean; /** Homepage URL set on the repository. */
31
- homepageUrl?: string; /** Whether the repository is archived. */
32
- isArchived?: boolean; /** Whether the repository is disabled. */
33
- isDisabled?: boolean; /** Whether the repository is a fork. */
34
- isFork?: boolean; /** Whether the repository belongs to an organization. */
35
- isInOrganization?: boolean; /** Whether the repository is a mirror. */
36
- isMirror?: boolean; /** Whether the repository is private. */
37
- isPrivate?: boolean; /** Whether a security policy is enabled. */
38
- isSecurityPolicyEnabled?: boolean; /** Number of closed issues. */
39
- issueCountClosed?: number; /** Number of open issues. */
40
- issueCountOpen?: number; /** Whether the repository is a template. */
41
- isTemplate?: boolean; /** Languages used in the repo, keyed by name with size in bytes. */
34
+ }>;
35
+ /** Whether a CONTRIBUTING file exists. */
36
+ hasContributing?: boolean;
37
+ /** Whether discussions are enabled. */
38
+ hasDiscussionsEnabled?: boolean;
39
+ /** Whether issues are enabled. */
40
+ hasIssuesEnabled?: boolean;
41
+ /** Whether the repo uses Git LFS (detected via .gitattributes). */
42
+ hasLfs?: boolean;
43
+ /** Whether GitHub Pages is enabled. */
44
+ hasPages?: boolean;
45
+ /** Whether projects are enabled. */
46
+ hasProjectsEnabled?: boolean;
47
+ /** Whether sponsorships are enabled. */
48
+ hasSponsorshipsEnabled?: boolean;
49
+ /** Whether vulnerability alerts are enabled. */
50
+ hasVulnerabilityAlertsEnabled?: boolean;
51
+ /** Whether the wiki is enabled. */
52
+ hasWikiEnabled?: boolean;
53
+ /** Homepage URL set on the repository. */
54
+ homepageUrl?: string;
55
+ /** Whether the repository is archived. */
56
+ isArchived?: boolean;
57
+ /** Whether the repository is disabled. */
58
+ isDisabled?: boolean;
59
+ /** Whether the repository is a fork. */
60
+ isFork?: boolean;
61
+ /** Whether the repository belongs to an organization. */
62
+ isInOrganization?: boolean;
63
+ /** Whether the repository is a mirror. */
64
+ isMirror?: boolean;
65
+ /** Whether the repository is private. */
66
+ isPrivate?: boolean;
67
+ /** Whether a security policy is enabled. */
68
+ isSecurityPolicyEnabled?: boolean;
69
+ /** Number of closed issues. */
70
+ issueCountClosed?: number;
71
+ /** Number of open issues. */
72
+ issueCountOpen?: number;
73
+ /** Whether the repository is a template. */
74
+ isTemplate?: boolean;
75
+ /** Languages used in the repo, keyed by name with size in bytes. */
42
76
  languages?: Record<string, number>;
43
77
  /** License identifier (unused; codemeta provides this). */
44
78
  /** SPDX license key (e.g. "mit"). */
45
- licenseKey?: string; /** Human-readable license name. */
46
- licenseName?: string; /** SPDX license identifier (e.g. "MIT"). */
47
- licenseSpdxId?: string; /** URL to the license text. */
48
- licenseUrl?: string; /** URL of the upstream mirror, if applicable. */
49
- mirrorUrl?: string; /** Repository name. */
50
- name?: string; /** Full "owner/repo" identifier. */
51
- nameWithOwner?: string; /** URL to the repository's Open Graph image. */
52
- openGraphImageUrl?: string; /** GitHub username of the repository owner. */
53
- ownerLogin?: string; /** Owner type, e.g. "User" or "Organization". */
54
- ownerType?: string; /** Full "owner/repo" of the parent fork source. */
55
- parentNameWithOwner?: string; /** Primary programming language of the repository. */
56
- primaryLanguage?: string; /** Number of closed pull requests. */
57
- pullRequestCountClosed?: number; /** Number of merged pull requests. */
58
- pullRequestCountMerged?: number; /** Number of open pull requests. */
59
- pullRequestCountOpen?: number; /** ISO 8601 date of the most recent push. */
60
- pushedAt?: string; /** Total number of releases. */
61
- releaseCount?: number; /** ISO 8601 date of the latest release. */
62
- releaseDateLatest?: string; /** Total download count across latest release assets. */
63
- releaseDownloadCount?: number; /** Tag name of the latest release. */
64
- releaseVersionLatest?: string; /** URL to the security policy. */
65
- securityPolicyUrl?: string; /** Repository merge and branch settings. */
79
+ licenseKey?: string;
80
+ /** Human-readable license name. */
81
+ licenseName?: string;
82
+ /** SPDX license identifier (e.g. "MIT"). */
83
+ licenseSpdxId?: string;
84
+ /** URL to the license text. */
85
+ licenseUrl?: string;
86
+ /** URL of the upstream mirror, if applicable. */
87
+ mirrorUrl?: string;
88
+ /** Repository name. */
89
+ name?: string;
90
+ /** Full "owner/repo" identifier. */
91
+ nameWithOwner?: string;
92
+ /** URL to the repository's Open Graph image. */
93
+ openGraphImageUrl?: string;
94
+ /** GitHub username of the repository owner. */
95
+ ownerLogin?: string;
96
+ /** Owner type, e.g. "User" or "Organization". */
97
+ ownerType?: string;
98
+ /** Full "owner/repo" of the parent fork source. */
99
+ parentNameWithOwner?: string;
100
+ /** Primary programming language of the repository. */
101
+ primaryLanguage?: string;
102
+ /** Number of closed pull requests. */
103
+ pullRequestCountClosed?: number;
104
+ /** Number of merged pull requests. */
105
+ pullRequestCountMerged?: number;
106
+ /** Number of open pull requests. */
107
+ pullRequestCountOpen?: number;
108
+ /** ISO 8601 date of the most recent push. */
109
+ pushedAt?: string;
110
+ /** Total number of releases. */
111
+ releaseCount?: number;
112
+ /** ISO 8601 date of the latest release. */
113
+ releaseDateLatest?: string;
114
+ /** Total download count across latest release assets. */
115
+ releaseDownloadCount?: number;
116
+ /** Tag name of the latest release. */
117
+ releaseVersionLatest?: string;
118
+ /** URL to the security policy. */
119
+ securityPolicyUrl?: string;
120
+ /** Repository merge and branch settings. */
66
121
  settings?: {
67
- /** Whether "Update branch" button is enabled. */allowUpdateBranch?: boolean; /** Whether auto-merge is allowed. */
68
- autoMergeAllowed?: boolean; /** Whether branches are deleted after merge. */
69
- deleteBranchOnMerge?: boolean; /** Whether forking is allowed. */
70
- forkingAllowed?: boolean; /** Whether merge commits are allowed. */
71
- mergeCommitAllowed?: boolean; /** Template for merge commit messages. */
72
- mergeCommitMessage?: string; /** Template for merge commit titles. */
73
- mergeCommitTitle?: string; /** Whether rebase merging is allowed. */
74
- rebaseMergeAllowed?: boolean; /** Whether squash merging is allowed. */
75
- squashMergeAllowed?: boolean; /** Template for squash merge commit messages. */
76
- squashMergeCommitMessage?: string; /** Template for squash merge commit titles. */
77
- squashMergeCommitTitle?: string; /** Whether web-based commits require sign-off. */
122
+ /** Whether "Update branch" button is enabled. */
123
+ allowUpdateBranch?: boolean;
124
+ /** Whether auto-merge is allowed. */
125
+ autoMergeAllowed?: boolean;
126
+ /** Whether branches are deleted after merge. */
127
+ deleteBranchOnMerge?: boolean;
128
+ /** Whether forking is allowed. */
129
+ forkingAllowed?: boolean;
130
+ /** Whether merge commits are allowed. */
131
+ mergeCommitAllowed?: boolean;
132
+ /** Template for merge commit messages. */
133
+ mergeCommitMessage?: string;
134
+ /** Template for merge commit titles. */
135
+ mergeCommitTitle?: string;
136
+ /** Whether rebase merging is allowed. */
137
+ rebaseMergeAllowed?: boolean;
138
+ /** Whether squash merging is allowed. */
139
+ squashMergeAllowed?: boolean;
140
+ /** Template for squash merge commit messages. */
141
+ squashMergeCommitMessage?: string;
142
+ /** Template for squash merge commit titles. */
143
+ squashMergeCommitTitle?: string;
144
+ /** Whether web-based commits require sign-off. */
78
145
  webCommitSignoffRequired?: boolean;
79
- }; /** SSH clone URL. */
80
- sshUrl?: string; /** Number of stars. */
81
- stargazerCount?: number; /** Number of git submodules (detected via .gitmodules). */
82
- submoduleCount?: number; /** URL of the template repository this was created from. */
83
- templateFrom?: string; /** Repository topics. */
84
- topics?: string[]; /** ISO 8601 date the repo was last updated. */
85
- updatedAt?: string; /** GitHub URL of the repository. */
86
- url?: string; /** Whether a custom Open Graph image is set. */
87
- usesCustomOpenGraphImage?: boolean; /** Repository visibility (e.g. "PUBLIC", "PRIVATE"). */
88
- visibility?: string; /** Number of open vulnerability alerts. */
89
- vulnerabilityAlertCount?: number; /** Number of watchers. */
146
+ };
147
+ /** SSH clone URL. */
148
+ sshUrl?: string;
149
+ /** Number of stars. */
150
+ stargazerCount?: number;
151
+ /** Number of git submodules (detected via .gitmodules). */
152
+ submoduleCount?: number;
153
+ /** URL of the template repository this was created from. */
154
+ templateFrom?: string;
155
+ /** Repository topics. */
156
+ topics?: string[];
157
+ /** ISO 8601 date the repo was last updated. */
158
+ updatedAt?: string;
159
+ /** GitHub URL of the repository. */
160
+ url?: string;
161
+ /** Whether a custom Open Graph image is set. */
162
+ usesCustomOpenGraphImage?: boolean;
163
+ /** Repository visibility (e.g. "PUBLIC", "PRIVATE"). */
164
+ visibility?: string;
165
+ /** Number of open vulnerability alerts. */
166
+ vulnerabilityAlertCount?: number;
167
+ /** Number of watchers. */
90
168
  watcherCount?: number;
91
169
  };
92
170
  type GitHubData = OneOrMany<SourceRecord<GitHubInfo>> | undefined;
@@ -218,7 +218,7 @@ async function checkHasPages(octokit, owner, repo) {
218
218
  }
219
219
  async function getUpstreamComparison(octokit, owner, repo, defaultBranch, parent) {
220
220
  const parentBranch = parent.defaultBranchRef?.name;
221
- if (!parentBranch) return;
221
+ if (parentBranch === void 0 || parentBranch === "") return;
222
222
  try {
223
223
  const response = await octokit.rest.repos.compareCommitsWithBasehead({
224
224
  basehead: `${parent.owner.login}:${parentBranch}...${owner}:${defaultBranch}`,
@@ -234,11 +234,11 @@ async function getUpstreamComparison(octokit, owner, repo, defaultBranch, parent
234
234
  }
235
235
  }
236
236
  function countSubmodules(gitmodulesText) {
237
- if (!gitmodulesText) return 0;
238
- return gitmodulesText.match(/\[submodule\s/g)?.length ?? 0;
237
+ if (gitmodulesText === void 0 || gitmodulesText === "") return 0;
238
+ return gitmodulesText.match(/\[submodule\s/gv)?.length ?? 0;
239
239
  }
240
240
  function detectLfs(gitattributesText) {
241
- if (!gitattributesText) return false;
241
+ if (gitattributesText === void 0 || gitattributesText === "") return false;
242
242
  return gitattributesText.includes("filter=lfs");
243
243
  }
244
244
  function extractLanguages(data) {
@@ -247,7 +247,8 @@ function extractLanguages(data) {
247
247
  return languages;
248
248
  }
249
249
  function mapRepoData(data, extras) {
250
- const releaseDownloadCount = (data.latestRelease?.releaseAssets.nodes.reduce((sum, asset) => sum + asset.downloadCount, 0) ?? 0) || void 0;
250
+ const totalReleaseDownloads = data.latestRelease?.releaseAssets.nodes.reduce((sum, asset) => sum + asset.downloadCount, 0) ?? 0;
251
+ const releaseDownloadCount = totalReleaseDownloads === 0 || Number.isNaN(totalReleaseDownloads) ? void 0 : totalReleaseDownloads;
251
252
  return {
252
253
  archivedAt: data.archivedAt ?? void 0,
253
254
  codeOfConduct: data.codeOfConduct?.name ?? void 0,
@@ -303,7 +304,7 @@ function mapRepoData(data, extras) {
303
304
  pullRequestCountMerged: data.mergedPullRequests.totalCount,
304
305
  pullRequestCountOpen: data.openPullRequests.totalCount,
305
306
  pushedAt: data.pushedAt ?? void 0,
306
- releaseCount: data.releases.totalCount || void 0,
307
+ releaseCount: data.releases.totalCount === 0 ? void 0 : data.releases.totalCount,
307
308
  releaseDateLatest: data.latestRelease?.createdAt ?? void 0,
308
309
  releaseDownloadCount,
309
310
  releaseVersionLatest: data.latestRelease?.tagName ?? void 0,
@@ -351,8 +352,10 @@ const githubSource = defineSource({
351
352
  key: "github",
352
353
  async parse(input, context) {
353
354
  log.debug("Extracting GitHub metadata...");
354
- const [owner, repo] = input.split("/");
355
- const octokit = new Octokit(context.options.credentials?.githubToken ? { auth: context.options.credentials.githubToken } : void 0);
355
+ const [owner, repo] = input.split("/", 2);
356
+ if (owner === void 0 || repo === void 0) throw new Error(`Invalid GitHub repo identifier "${input}", expected "owner/repo"`);
357
+ const githubToken = context.options.credentials?.githubToken;
358
+ const octokit = new Octokit(githubToken !== void 0 && githubToken !== "" ? { auth: githubToken } : void 0);
356
359
  const [graphqlResult, hasPages] = await Promise.all([octokit.graphql(graphqlQuery, {
357
360
  owner,
358
361
  repo
@@ -1,6 +1,5 @@
1
1
  import { OneOrMany, SourceRecord } from "../source.js";
2
2
  import { z } from "zod";
3
-
4
3
  //#region src/lib/sources/go-go-mod.d.ts
5
4
  declare const goModDataSchema: z.ZodObject<{
6
5
  dependencies: z.ZodArray<z.ZodObject<{
@@ -1,6 +1,5 @@
1
1
  import { OneOrMany, SourceRecord } from "../source.js";
2
2
  import { z } from "zod";
3
-
4
3
  //#region src/lib/sources/go-goreleaser-yaml.d.ts
5
4
  declare const goreleaserDataSchema: z.ZodObject<{
6
5
  description: z.ZodOptional<z.ZodPreprocess<z.ZodOptional<z.ZodString>>>;
@@ -47,7 +47,8 @@ function isNonEmptyString(value) {
47
47
  * `{{`).
48
48
  */
49
49
  function firstString(sections, field) {
50
- for (const section of sections) if (isPlainObject(section)) {
50
+ for (const section of sections) {
51
+ if (!isPlainObject(section)) continue;
51
52
  const value = section[field];
52
53
  if (isNonEmptyString(value) && !value.includes("{{")) return value.trim();
53
54
  }
@@ -126,7 +127,8 @@ function parse$1(source) {
126
127
  }
127
128
  const goosSet = /* @__PURE__ */ new Set();
128
129
  const builds = collectSections(data, "builds", "build");
129
- for (const build of builds) if (isPlainObject(build)) {
130
+ for (const build of builds) {
131
+ if (!isPlainObject(build)) continue;
130
132
  const { goos } = build;
131
133
  if (Array.isArray(goos)) {
132
134
  for (const os of goos) if (typeof os === "string") goosSet.add(os.toLowerCase());
@@ -142,7 +144,7 @@ const goGoreleaserYamlSource = defineSource({
142
144
  key: "goGoreleaserYaml",
143
145
  async parse(input, context) {
144
146
  const data = parse$1(await readFile(resolve(context.options.path, input), "utf8"));
145
- if (data !== void 0) return {
147
+ return data === void 0 ? void 0 : {
146
148
  data,
147
149
  source: input
148
150
  };
@@ -1,6 +1,5 @@
1
1
  import { OneOrMany, SourceRecord } from "../source.js";
2
2
  import { z } from "zod";
3
-
4
3
  //#region src/lib/sources/java-pom-xml.d.ts
5
4
  declare const pomXmlSchema: z.ZodObject<{
6
5
  artifactId: z.ZodOptional<z.ZodPreprocess<z.ZodOptional<z.ZodString>>>;
@@ -107,7 +107,7 @@ function parse(content) {
107
107
  devDependencies,
108
108
  developers: parsePersonEntries(project.developers, "developer"),
109
109
  groupId,
110
- identifier: groupId && artifactId ? `${groupId}.${artifactId}` : void 0,
110
+ identifier: groupId !== void 0 && artifactId !== void 0 ? `${groupId}.${artifactId}` : void 0,
111
111
  inceptionYear: getString(project.inceptionYear),
112
112
  issueManagementUrl: getNestedUrl(project.issueManagement),
113
113
  javaVersion: parseJavaVersion(project),
@@ -142,10 +142,10 @@ function getCleanString(value) {
142
142
  */
143
143
  function resolveName(project, groupId, artifactId) {
144
144
  const name = getString(project.name);
145
- if (!name) return;
145
+ if (name === void 0) return;
146
146
  let resolved = name;
147
- if (groupId) resolved = resolved.replaceAll("${project.groupId}", groupId);
148
- if (artifactId) resolved = resolved.replaceAll("${project.artifactId}", artifactId);
147
+ if (groupId !== void 0) resolved = resolved.replaceAll("${project.groupId}", () => groupId);
148
+ if (artifactId !== void 0) resolved = resolved.replaceAll("${project.artifactId}", () => artifactId);
149
149
  return resolved;
150
150
  }
151
151
  /**
@@ -167,7 +167,7 @@ function parsePersonEntries(container, childKey) {
167
167
  for (const entry of ensureArray(children)) {
168
168
  if (!is.plainObject(entry)) continue;
169
169
  const name = getString(entry.name);
170
- if (!name) continue;
170
+ if (name === void 0) continue;
171
171
  results.push({
172
172
  email: getString(entry.email),
173
173
  name,
@@ -187,7 +187,7 @@ function parseLicenses(project) {
187
187
  if (!is.plainObject(entry)) continue;
188
188
  const name = getString(entry.name);
189
189
  const url = getString(entry.url);
190
- if (name ?? url) results.push({
190
+ if (name !== void 0 || url !== void 0) results.push({
191
191
  name,
192
192
  url
193
193
  });
@@ -208,14 +208,14 @@ function parseDependencies(project) {
208
208
  if (!is.plainObject(entry)) continue;
209
209
  const groupId = getString(entry.groupId);
210
210
  const artifactId = getString(entry.artifactId);
211
- if (!groupId || !artifactId) continue;
212
- const dep = {
211
+ if (groupId === void 0 || artifactId === void 0) continue;
212
+ const dependency = {
213
213
  artifactId,
214
214
  groupId,
215
215
  version: getCleanString(entry.version)
216
216
  };
217
- if (getString(entry.scope) === "test") devDependencies.push(dep);
218
- else dependencies.push(dep);
217
+ if (getString(entry.scope) === "test") devDependencies.push(dependency);
218
+ else dependencies.push(dependency);
219
219
  }
220
220
  return {
221
221
  dependencies,
@@ -235,7 +235,7 @@ function parseScmUrl(project) {
235
235
  function parseOrganization(project) {
236
236
  if (!is.plainObject(project.organization)) return;
237
237
  const name = getString(project.organization.name);
238
- if (!name) return;
238
+ if (name === void 0) return;
239
239
  return {
240
240
  name,
241
241
  url: getString(project.organization.url)
@@ -256,7 +256,7 @@ const javaPomXmlSource = defineSource({
256
256
  key: "javaPomXml",
257
257
  async parse(input, context) {
258
258
  const data = parse(await readFile(resolve(context.options.path, input), "utf8"));
259
- if (data !== void 0) return {
259
+ return data === void 0 ? void 0 : {
260
260
  data,
261
261
  source: input
262
262
  };
@@ -1,6 +1,5 @@
1
1
  import { OneOrMany, SourceRecord } from "../source.js";
2
2
  import { LicenseMatch } from "../utilities/license-identification.js";
3
-
4
3
  //#region src/lib/sources/license-file.d.ts
5
4
  /**
6
5
  * A license file record. The `type` discriminator is always present so the
@@ -1,6 +1,5 @@
1
1
  import { OneOrMany, SourceRecord } from "../source.js";
2
2
  import { z } from "zod";
3
-
4
3
  //#region src/lib/sources/metadata-file.d.ts
5
4
  declare const metadataSchema: z.ZodObject<{
6
5
  description: z.ZodOptional<z.ZodPreprocess<z.ZodOptional<z.ZodString>>>;