metascope 0.2.3 → 0.4.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.
@@ -1,4 +1,5 @@
1
1
  import { codemeta } from "./codemeta.js";
2
+ import { codemetaJson } from "./codemeta-json.js";
2
3
  import { frontmatter } from "./frontmatter.js";
3
4
  import { metadata } from "./metadata.js";
4
5
  import { project } from "./project.js";
@@ -8,6 +9,7 @@ import { project } from "./project.js";
8
9
  */
9
10
  const templates = {
10
11
  codemeta,
12
+ codemetaJson,
11
13
  frontmatter,
12
14
  metadata,
13
15
  project
@@ -1,7 +1,6 @@
1
1
  import { defineTemplate } from "../metadata-types.js";
2
2
  import { firstOf } from "../utilities/template-helpers.js";
3
- import { codeMetaJsonDataSchema } from "../sources/codemeta-json.js";
4
- import { codemeta } from "./codemeta.js";
3
+ import { codemetaJson } from "./codemeta-json.js";
5
4
  //#region src/lib/templates/metadata.ts
6
5
  /**
7
6
  * Strip `git+` prefix and `.git` suffix from a URL.
@@ -21,14 +20,13 @@ function normalizeGitUrl(url) {
21
20
  * metadata.json source fields override the result.
22
21
  */
23
22
  const metadata = defineTemplate((context, templateData) => {
24
- const codemetaTemplateOutput = codemeta(context, templateData);
25
- const codemeta$1 = codeMetaJsonDataSchema.parse(codemetaTemplateOutput);
23
+ const codemeta = codemetaJson(context, templateData);
26
24
  const metadataFile = firstOf(context.metadataFile)?.data;
27
- const homepage = metadataFile?.homepage ?? codemeta$1.url ?? codemeta$1.codeRepository;
25
+ const homepage = metadataFile?.homepage ?? codemeta.url ?? codemeta.codeRepository;
28
26
  return {
29
- description: metadataFile?.description ?? codemeta$1.description,
27
+ description: metadataFile?.description ?? codemeta.description,
30
28
  homepage: normalizeGitUrl(homepage),
31
- topics: metadataFile?.keywords ?? codemeta$1.keywords
29
+ topics: metadataFile?.keywords ?? codemeta.keywords
32
30
  };
33
31
  });
34
32
  //#endregion
@@ -1,14 +1,12 @@
1
1
  import { defineTemplate } from "../metadata-types.js";
2
2
  import { firstOf, hasDependencyWithId, isAuthoredBy, isOnGithubAccountOf, toBasicLicenses, toLocalUrl, toStatusLegacy, usesPnpm } from "../utilities/template-helpers.js";
3
- import { codeMetaJsonDataSchema } from "../sources/codemeta-json.js";
4
- import { codemeta } from "./codemeta.js";
3
+ import { codemetaJson } from "./codemeta-json.js";
5
4
  //#region src/lib/templates/project.ts
6
5
  /**
7
6
  * Legacy structure used in AllWork desktop app
8
7
  */
9
8
  const project = defineTemplate((context, templateData) => {
10
- const codemetaTemplateOutput = codemeta(context, templateData);
11
- const codemeta$1 = codeMetaJsonDataSchema.parse(codemetaTemplateOutput);
9
+ const codemeta = codemetaJson(context, templateData);
12
10
  const dependencyUpdates = firstOf(context.dependencyUpdates);
13
11
  const github = firstOf(context.github)?.data;
14
12
  const gitStats = firstOf(context.gitStats)?.data;
@@ -16,35 +14,35 @@ const project = defineTemplate((context, templateData) => {
16
14
  const nodeNpmRegistry = firstOf(context.nodeNpmRegistry)?.data;
17
15
  const nodePackageJson = firstOf(context.nodePackageJson);
18
16
  return {
19
- description: codemeta$1.description,
17
+ description: codemeta.description,
20
18
  firstCommitDate: gitStats?.commitDateFirst,
21
19
  gitHubLink: github?.url,
22
20
  gitHubStarCount: github?.stargazerCount,
23
21
  gitIsClean: gitStats?.isClean,
24
22
  gitIsDirty: gitStats?.isDirty,
25
23
  gitRemoteCount: gitStats?.remoteCount,
26
- homepage: github?.homepageUrl ?? codemeta$1.url ?? github?.url,
27
- isAuthoredByMe: isAuthoredBy(codemeta$1.author, templateData.authorName),
28
- isOnMyGitHub: isOnGithubAccountOf(codemeta$1.codeRepository, templateData.githubAccount),
24
+ homepage: github?.homepageUrl ?? codemeta.url ?? github?.url,
25
+ isAuthoredByMe: isAuthoredBy(codemeta.author, templateData.authorName),
26
+ isOnMyGitHub: isOnGithubAccountOf(codemeta.codeRepository, templateData.githubAccount),
29
27
  isOnNpm: nodeNpmRegistry?.url !== void 0,
30
28
  isPublic: !(github?.isPrivate ?? false),
31
29
  isRemoteAhead: gitStats?.isRemoteAhead,
32
30
  issueCount: github?.issueCountOpen,
33
31
  lastCommitDate: gitStats?.commitDateLast,
34
- license: toBasicLicenses(codemeta$1.license ?? github?.licenseSpdxId)?.at(0),
32
+ license: toBasicLicenses(codemeta.license ?? github?.licenseSpdxId)?.at(0),
35
33
  majorUpdateCount: dependencyUpdates?.data.major?.length ?? 0,
36
34
  majorUpdateList: dependencyUpdates?.data.major?.map((value) => value.name),
37
35
  npmDownloadCount: nodeNpmRegistry?.downloadsTotal,
38
- readmePath: toLocalUrl(codemeta$1.readme, metascope?.options.path),
36
+ readmePath: toLocalUrl(codemeta.readme, metascope?.options.path),
39
37
  repositoryPath: metascope?.options.path === void 0 ? void 0 : `file://${metascope.options.path}`,
40
38
  semverUpdateCount: void 0,
41
39
  semverUpdateList: void 0,
42
- tags: codemeta$1.keywords,
43
- title: codemeta$1.name,
44
- type: toStatusLegacy(codemeta$1.codeRepository, codemeta$1.author, templateData.authorName, templateData.githubAccount),
40
+ tags: codemeta.keywords,
41
+ title: codemeta.name,
42
+ type: toStatusLegacy(codemeta.codeRepository, codemeta.author, templateData.authorName, templateData.githubAccount),
45
43
  usesPnpm: usesPnpm(nodePackageJson),
46
- usesSharedConfig: hasDependencyWithId("@kitschpatrol/shared-config", codemeta$1),
47
- version: codemeta$1.version
44
+ usesSharedConfig: hasDependencyWithId("@kitschpatrol/shared-config", codemeta),
45
+ version: codemeta.version
48
46
  };
49
47
  });
50
48
  //#endregion
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "metascope",
3
- "version": "0.2.3",
3
+ "version": "0.4.0",
4
4
  "description": "A CLI tool and TypeScript library to easily extract metadata from all kinds of software repositories.",
5
5
  "keywords": [
6
6
  "metadata",
@@ -50,10 +50,11 @@
50
50
  "@types/plist": "^3.0.5",
51
51
  "@types/yargs": "^17.0.35",
52
52
  "case-police": "^2.2.0",
53
- "defu": "^6.1.4",
53
+ "defu": "^6.1.6",
54
54
  "fast-xml-parser": "^5.5.9",
55
55
  "find-workspaces": "^0.3.1",
56
56
  "git-url-parse": "^16.1.0",
57
+ "gray-matter-es": "^0.2.1",
57
58
  "jiti": "^2.6.1",
58
59
  "lognow": "^0.5.2",
59
60
  "octokit": "^5.0.5",
@@ -74,7 +75,7 @@
74
75
  "tinyglobby": "^0.2.15",
75
76
  "unified": "^11.0.5",
76
77
  "updates": "^17.13.1",
77
- "web-tree-sitter": "^0.26.7",
78
+ "web-tree-sitter": "^0.26.8",
78
79
  "yaml": "^2.8.3",
79
80
  "yargs": "^18.0.0",
80
81
  "zod": "^4.3.6"
@@ -88,7 +89,7 @@
88
89
  "@types/semver": "^7.7.1",
89
90
  "bumpp": "^11.0.1",
90
91
  "jsonld": "^9.0.0",
91
- "mdat-plugin-cli-help": "^1.0.7",
92
+ "mdat-plugin-cli-help": "^1.0.8",
92
93
  "msw": "2.12.14",
93
94
  "publint": "^0.3.18",
94
95
  "tree-sitter-python": "^0.25.0",
package/readme.md CHANGED
@@ -119,7 +119,7 @@ metascope [path]
119
119
 
120
120
  | Option | Description | Type | Default |
121
121
  | ---------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------- | ------- |
122
- | `--template`<br>`-t` | Built-in template name (`codemeta`, `frontmatter`, `metadata`, `project`) or path to a custom template file | `string` | |
122
+ | `--template`<br>`-t` | Built-in template name (`codemeta`, `codemetaJson`, `frontmatter`, `metadata`, `project`) or path to a custom template file | `string` | |
123
123
  | `--github-token` | GitHub API token (or set `$GITHUB_TOKEN`) | `string` | |
124
124
  | `--author-name` | Optional author name(s) for ownership checks in templates | `array` | |
125
125
  | `--github-account` | Optional GitHub account name(s) for ownership checks in templates | `array` | |
@@ -434,7 +434,7 @@ Metascope provides a basic templating / output transformation functionality to c
434
434
 
435
435
  ### Built-in templates
436
436
 
437
- Four built-in templates are available by name. Pass the name as the `template` option on the CLI or in the API.
437
+ Five built-in templates are available by name. Pass the name as the `template` option on the CLI or in the API.
438
438
 
439
439
  #### `codemeta`
440
440
 
@@ -454,6 +454,16 @@ metascope --template codemeta
454
454
 
455
455
  _See an [output sample](./docs/metascope-template-codemeta.json) from the `codemeta` template run against this repository._
456
456
 
457
+ #### `codemetaJson`
458
+
459
+ A JSON-friendly derivation of the `codemeta` template. Produces the same aggregated metadata but parses it through a strict schema, stripping JSON-LD artifacts (like `@context` and `@type`) to yield plain JSON suitable for consumption by tools that don't understand JSON-LD.
460
+
461
+ ```sh
462
+ metascope --template codemetaJson
463
+ ```
464
+
465
+ _See an [output sample](./docs/metascope-template-codemeta-json.json) from the `codemetaJson` template run against this repository._
466
+
457
467
  #### `frontmatter`
458
468
 
459
469
  A compact, non-nested, polyglot overview of the project. Designed for Obsidian frontmatter — flat keys with natural language names, blending all available sources into a single trackable snapshot. Uses `null` for missing values to ensure stable keys.