metascope 0.2.3 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/cli.js +4 -4
- package/dist/lib/_virtual/_rolldown/runtime.js +0 -1
- package/dist/lib/index.d.ts +2 -1
- package/dist/lib/package.js +1 -1
- package/dist/lib/sources/dependency-updates.js +9 -4
- package/dist/lib/sources/processing-library-properties.d.ts +1 -1
- package/dist/lib/sources/python-pypi-registry.js +1 -1
- package/dist/lib/templates/codemeta-json.d.ts +109 -0
- package/dist/lib/templates/codemeta-json.js +20 -0
- package/dist/lib/templates/frontmatter.js +23 -25
- package/dist/lib/templates/index.d.ts +96 -0
- package/dist/lib/templates/index.js +2 -0
- package/dist/lib/templates/metadata.js +5 -7
- package/dist/lib/templates/project.js +13 -15
- package/package.json +1 -1
- package/readme.md +12 -2
package/dist/lib/index.d.ts
CHANGED
|
@@ -2,10 +2,11 @@ import { setLogger } from "./log.js";
|
|
|
2
2
|
import { OneOrMany, SourceRecord } from "./source.js";
|
|
3
3
|
import { Credentials, DEFAULT_GET_METADATA_OPTIONS, GetMetadataOptions, GetMetadataTemplateOptions, MetadataContext, SourceName, Template, TemplateData, defineTemplate } from "./metadata-types.js";
|
|
4
4
|
import { TemplateDataCodemeta } from "./templates/codemeta.js";
|
|
5
|
+
import { TemplateDataCodemetaJson } from "./templates/codemeta-json.js";
|
|
5
6
|
import { TemplateDataFrontmatter } from "./templates/frontmatter.js";
|
|
6
7
|
import { TemplateDataMetadata } from "./templates/metadata.js";
|
|
7
8
|
import { TemplateDataProject } from "./templates/project.js";
|
|
8
9
|
import { templates } from "./templates/index.js";
|
|
9
10
|
import { getMetadata, sourceNames } from "./metadata.js";
|
|
10
11
|
import { template_helpers_d_exports } from "./utilities/template-helpers.js";
|
|
11
|
-
export { type Credentials, DEFAULT_GET_METADATA_OPTIONS, type GetMetadataOptions, type GetMetadataTemplateOptions, type MetadataContext, type OneOrMany, type SourceName, type SourceRecord, type Template, type TemplateData, type TemplateDataCodemeta, type TemplateDataFrontmatter, type TemplateDataMetadata, type TemplateDataProject, defineTemplate, getMetadata, template_helpers_d_exports as helpers, setLogger, sourceNames, templates };
|
|
12
|
+
export { type Credentials, DEFAULT_GET_METADATA_OPTIONS, type GetMetadataOptions, type GetMetadataTemplateOptions, type MetadataContext, type OneOrMany, type SourceName, type SourceRecord, type Template, type TemplateData, type TemplateDataCodemeta, type TemplateDataCodemetaJson, type TemplateDataFrontmatter, type TemplateDataMetadata, type TemplateDataProject, defineTemplate, getMetadata, template_helpers_d_exports as helpers, setLogger, sourceNames, templates };
|
package/dist/lib/package.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { log } from "../log.js";
|
|
2
2
|
import { defineSource } from "../source.js";
|
|
3
|
-
import { createRequire } from "node:module";
|
|
4
3
|
import { dirname, join } from "node:path";
|
|
4
|
+
import { readFileSync } from "node:fs";
|
|
5
5
|
import { exec } from "tinyexec";
|
|
6
6
|
import { z } from "zod";
|
|
7
|
+
import { fileURLToPath } from "node:url";
|
|
7
8
|
import { coerce, diff } from "semver";
|
|
8
9
|
//#region src/lib/sources/dependency-updates.ts
|
|
9
10
|
const depSchema = z.object({
|
|
@@ -15,11 +16,15 @@ const depSchema = z.object({
|
|
|
15
16
|
const updatesOutputSchema = z.object({ results: z.record(z.string(), z.record(z.string(), z.record(z.string(), depSchema))) });
|
|
16
17
|
/**
|
|
17
18
|
* Resolve the path to the `updates` CLI binary from its installed package.
|
|
19
|
+
*
|
|
20
|
+
* Uses `import.meta.resolve` instead of `createRequire` so that resolution
|
|
21
|
+
* works even when metascope's code is re-bundled by a downstream consumer
|
|
22
|
+
* (where `import.meta.url` would point to the consumer's output, not to
|
|
23
|
+
* metascope's node_modules).
|
|
18
24
|
*/
|
|
19
25
|
function resolveUpdatesBinary() {
|
|
20
|
-
const
|
|
21
|
-
const
|
|
22
|
-
const packageJson = require(packageJsonPath);
|
|
26
|
+
const packageJsonPath = fileURLToPath(import.meta.resolve("updates/package.json"));
|
|
27
|
+
const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf8"));
|
|
23
28
|
const bin = typeof packageJson === "object" && packageJson !== null && "bin" in packageJson && typeof packageJson.bin === "string" ? packageJson.bin : void 0;
|
|
24
29
|
if (!bin) throw new Error("Could not resolve updates binary path");
|
|
25
30
|
return join(dirname(packageJsonPath), bin);
|
|
@@ -8,13 +8,13 @@ declare const processingLibraryPropertiesSchema: z.ZodObject<{
|
|
|
8
8
|
url: z.ZodOptional<z.ZodString>;
|
|
9
9
|
}, z.core.$strip>>;
|
|
10
10
|
categories: z.ZodArray<z.ZodEnum<{
|
|
11
|
-
GUI: "GUI";
|
|
12
11
|
"3D": "3D";
|
|
13
12
|
Animation: "Animation";
|
|
14
13
|
Compilations: "Compilations";
|
|
15
14
|
Data: "Data";
|
|
16
15
|
Fabrication: "Fabrication";
|
|
17
16
|
Geometry: "Geometry";
|
|
17
|
+
GUI: "GUI";
|
|
18
18
|
Hardware: "Hardware";
|
|
19
19
|
"I/O": "I/O";
|
|
20
20
|
Language: "Language";
|
|
@@ -47,7 +47,7 @@ const pythonPypiRegistrySource = defineSource({
|
|
|
47
47
|
"pythonSetupPy",
|
|
48
48
|
"pythonPkgInfo"
|
|
49
49
|
].some((key) => context.completedSources?.has(key))) {
|
|
50
|
-
log.
|
|
50
|
+
log.debug(`Missing python package names in source context metadata for ${context.options.path}, extracting them now...`);
|
|
51
51
|
packageNames = ensureArray(await pythonPyprojectTomlSource.extract(context)).filter((value) => !hasPrivateClassifier(value.data.project?.classifiers, value.data.project?.name, context.options.path)).map((value) => value.data.project?.name).filter((value) => value !== void 0);
|
|
52
52
|
if (packageNames.length === 0) packageNames = ensureArray(await pythonSetupCfgSource.extract(context)).filter((value) => !hasPrivateClassifier(value.data.classifiers, value.data.name, context.options.path)).map((value) => value.data.name).filter((value) => value !== void 0);
|
|
53
53
|
if (packageNames.length === 0) packageNames = ensureArray(await pythonSetupPySource.extract(context)).filter((value) => !hasPrivateClassifier(value.data.classifiers, value.data.name, context.options.path)).map((value) => value.data.name).filter((value) => value !== void 0);
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { Template } from "../metadata-types.js";
|
|
2
|
+
//#region src/lib/templates/codemeta-json.d.ts
|
|
3
|
+
type TemplateDataCodemetaJson = ReturnType<typeof codemetaJson>;
|
|
4
|
+
/**
|
|
5
|
+
* A JSON-friendly derivation of the `codemeta` template.
|
|
6
|
+
* Produces the same aggregated metadata but parses it through a strict
|
|
7
|
+
* schema,stripping JSON-LD artifacts (like `@context` and `@type`) to yield
|
|
8
|
+
* plain JSON suitable for consumption by tools that don't care to understand
|
|
9
|
+
* JSON-LD.
|
|
10
|
+
*
|
|
11
|
+
* This template also provides a handy baseline normalization abstraction for
|
|
12
|
+
* the other templates.
|
|
13
|
+
*/
|
|
14
|
+
declare const codemetaJson: Template<{
|
|
15
|
+
applicationCategory?: string | undefined;
|
|
16
|
+
applicationSubCategory?: string | undefined;
|
|
17
|
+
author?: {
|
|
18
|
+
affiliation?: string | undefined;
|
|
19
|
+
email?: string | undefined;
|
|
20
|
+
familyName?: string | undefined;
|
|
21
|
+
givenName?: string | undefined;
|
|
22
|
+
id?: string | undefined;
|
|
23
|
+
name?: string | undefined;
|
|
24
|
+
type?: "Organization" | "Person" | undefined;
|
|
25
|
+
url?: string | undefined;
|
|
26
|
+
}[] | undefined;
|
|
27
|
+
buildInstructions?: string | undefined;
|
|
28
|
+
codeRepository?: string | undefined;
|
|
29
|
+
continuousIntegration?: string | undefined;
|
|
30
|
+
contributor?: {
|
|
31
|
+
affiliation?: string | undefined;
|
|
32
|
+
email?: string | undefined;
|
|
33
|
+
familyName?: string | undefined;
|
|
34
|
+
givenName?: string | undefined;
|
|
35
|
+
id?: string | undefined;
|
|
36
|
+
name?: string | undefined;
|
|
37
|
+
type?: "Organization" | "Person" | undefined;
|
|
38
|
+
url?: string | undefined;
|
|
39
|
+
}[] | undefined;
|
|
40
|
+
copyrightHolder?: {
|
|
41
|
+
affiliation?: string | undefined;
|
|
42
|
+
email?: string | undefined;
|
|
43
|
+
familyName?: string | undefined;
|
|
44
|
+
givenName?: string | undefined;
|
|
45
|
+
id?: string | undefined;
|
|
46
|
+
name?: string | undefined;
|
|
47
|
+
type?: "Organization" | "Person" | undefined;
|
|
48
|
+
url?: string | undefined;
|
|
49
|
+
}[] | undefined;
|
|
50
|
+
copyrightYear?: number | undefined;
|
|
51
|
+
dateCreated?: string | undefined;
|
|
52
|
+
dateModified?: string | undefined;
|
|
53
|
+
datePublished?: string | undefined;
|
|
54
|
+
description?: string | undefined;
|
|
55
|
+
developmentStatus?: string | undefined;
|
|
56
|
+
downloadUrl?: string | undefined;
|
|
57
|
+
funder?: {
|
|
58
|
+
affiliation?: string | undefined;
|
|
59
|
+
email?: string | undefined;
|
|
60
|
+
familyName?: string | undefined;
|
|
61
|
+
givenName?: string | undefined;
|
|
62
|
+
id?: string | undefined;
|
|
63
|
+
name?: string | undefined;
|
|
64
|
+
type?: "Organization" | "Person" | undefined;
|
|
65
|
+
url?: string | undefined;
|
|
66
|
+
}[] | undefined;
|
|
67
|
+
funding?: string | undefined;
|
|
68
|
+
identifier?: string | undefined;
|
|
69
|
+
installUrl?: string | undefined;
|
|
70
|
+
isAccessibleForFree?: boolean | undefined;
|
|
71
|
+
issueTracker?: string | undefined;
|
|
72
|
+
keywords?: string[] | undefined;
|
|
73
|
+
license?: string | string[] | undefined;
|
|
74
|
+
maintainer?: {
|
|
75
|
+
affiliation?: string | undefined;
|
|
76
|
+
email?: string | undefined;
|
|
77
|
+
familyName?: string | undefined;
|
|
78
|
+
givenName?: string | undefined;
|
|
79
|
+
id?: string | undefined;
|
|
80
|
+
name?: string | undefined;
|
|
81
|
+
type?: "Organization" | "Person" | undefined;
|
|
82
|
+
url?: string | undefined;
|
|
83
|
+
}[] | undefined;
|
|
84
|
+
name?: string | undefined;
|
|
85
|
+
operatingSystem?: string[] | undefined;
|
|
86
|
+
programmingLanguage?: string[] | undefined;
|
|
87
|
+
readme?: string | undefined;
|
|
88
|
+
relatedLink?: string | string[] | undefined;
|
|
89
|
+
releaseNotes?: string | undefined;
|
|
90
|
+
runtimePlatform?: string[] | undefined;
|
|
91
|
+
softwareHelp?: string | undefined;
|
|
92
|
+
softwareRequirements?: {
|
|
93
|
+
identifier?: string | undefined;
|
|
94
|
+
name?: string | undefined;
|
|
95
|
+
runtimePlatform?: string | undefined;
|
|
96
|
+
version?: string | undefined;
|
|
97
|
+
}[] | undefined;
|
|
98
|
+
softwareSuggestions?: {
|
|
99
|
+
identifier?: string | undefined;
|
|
100
|
+
name?: string | undefined;
|
|
101
|
+
runtimePlatform?: string | undefined;
|
|
102
|
+
version?: string | undefined;
|
|
103
|
+
}[] | undefined;
|
|
104
|
+
softwareVersion?: string | undefined;
|
|
105
|
+
url?: string | undefined;
|
|
106
|
+
version?: string | undefined;
|
|
107
|
+
}>;
|
|
108
|
+
//#endregion
|
|
109
|
+
export { TemplateDataCodemetaJson };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { defineTemplate } from "../metadata-types.js";
|
|
2
|
+
import { codeMetaJsonDataSchema } from "../sources/codemeta-json.js";
|
|
3
|
+
import { codemeta } from "./codemeta.js";
|
|
4
|
+
//#region src/lib/templates/codemeta-json.ts
|
|
5
|
+
/**
|
|
6
|
+
* A JSON-friendly derivation of the `codemeta` template.
|
|
7
|
+
* Produces the same aggregated metadata but parses it through a strict
|
|
8
|
+
* schema,stripping JSON-LD artifacts (like `@context` and `@type`) to yield
|
|
9
|
+
* plain JSON suitable for consumption by tools that don't care to understand
|
|
10
|
+
* JSON-LD.
|
|
11
|
+
*
|
|
12
|
+
* This template also provides a handy baseline normalization abstraction for
|
|
13
|
+
* the other templates.
|
|
14
|
+
*/
|
|
15
|
+
const codemetaJson = defineTemplate((context, templateData) => {
|
|
16
|
+
const codemetaTemplateOutput = codemeta(context, templateData);
|
|
17
|
+
return codeMetaJsonDataSchema.parse(codemetaTemplateOutput);
|
|
18
|
+
});
|
|
19
|
+
//#endregion
|
|
20
|
+
export { codemetaJson };
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { defineTemplate } from "../metadata-types.js";
|
|
2
2
|
import { REPLACEMENTS, dependencyNames, firstOf, isValidUrl, mixedStringsToArray, nonEmpty, toAlias, toBasicLicenses, toBasicNames, toLocalUrl, toMb, toStatus } from "../utilities/template-helpers.js";
|
|
3
|
-
import {
|
|
4
|
-
import { codemeta } from "./codemeta.js";
|
|
3
|
+
import { codemetaJson } from "./codemeta-json.js";
|
|
5
4
|
import is from "@sindresorhus/is";
|
|
6
5
|
//#region src/lib/templates/frontmatter.ts
|
|
7
6
|
/**
|
|
@@ -10,8 +9,7 @@ import is from "@sindresorhus/is";
|
|
|
10
9
|
* blending all available sources into a single trackable snapshot.
|
|
11
10
|
*/
|
|
12
11
|
const frontmatter = defineTemplate((context, templateData) => {
|
|
13
|
-
const
|
|
14
|
-
const codemeta$1 = codeMetaJsonDataSchema.parse(codemetaTemplateOutput);
|
|
12
|
+
const codemeta = codemetaJson(context, templateData);
|
|
15
13
|
const codeStats = firstOf(context.codeStats)?.data;
|
|
16
14
|
const dependencyUpdates = firstOf(context.dependencyUpdates);
|
|
17
15
|
const fileStats = firstOf(context.fileStats)?.data;
|
|
@@ -23,39 +21,39 @@ const frontmatter = defineTemplate((context, templateData) => {
|
|
|
23
21
|
const obsidianPluginManifestJson = firstOf(context.obsidianPluginManifestJson)?.data;
|
|
24
22
|
const obsidianPluginRegistry = firstOf(context.obsidianPluginRegistry)?.data;
|
|
25
23
|
const pythonPypiRegistry = firstOf(context.pythonPypiRegistry)?.data;
|
|
26
|
-
const primaryLanguages = mixedStringsToArray(codemeta
|
|
24
|
+
const primaryLanguages = mixedStringsToArray(codemeta.programmingLanguage ?? github?.primaryLanguage, REPLACEMENTS) ?? null;
|
|
27
25
|
const secondaryLanguages = mixedStringsToArray(codeStats?.total?.languages, REPLACEMENTS)?.filter((value) => !primaryLanguages?.includes(value)) ?? null;
|
|
28
|
-
const rawName = codemeta
|
|
29
|
-
const id = codemeta
|
|
26
|
+
const rawName = codemeta.name === "undefined" ? null : cinderCinderblockXml === void 0 ? codemeta.name : `Cinder ${codemeta.name}`;
|
|
27
|
+
const id = codemeta.identifier ?? rawName;
|
|
30
28
|
const name = is.nonEmptyString(rawName) ? toAlias(rawName) : void 0;
|
|
31
29
|
const aliases = id === name ? void 0 : id;
|
|
32
30
|
return {
|
|
33
31
|
Name: name ?? null,
|
|
34
32
|
ID: id ?? null,
|
|
35
|
-
Description: codemeta
|
|
36
|
-
Author: mixedStringsToArray(toBasicNames(codemeta
|
|
37
|
-
Contributor: mixedStringsToArray(toBasicNames(codemeta
|
|
38
|
-
Maintainer: mixedStringsToArray(toBasicNames(codemeta
|
|
39
|
-
Version: codemeta
|
|
33
|
+
Description: codemeta.description ?? null,
|
|
34
|
+
Author: mixedStringsToArray(toBasicNames(codemeta.author)) ?? null,
|
|
35
|
+
Contributor: mixedStringsToArray(toBasicNames(codemeta.contributor)) ?? null,
|
|
36
|
+
Maintainer: mixedStringsToArray(toBasicNames(codemeta.maintainer)) ?? null,
|
|
37
|
+
Version: codemeta.version ?? null,
|
|
40
38
|
Account: github?.ownerLogin ?? null,
|
|
41
39
|
Public: !(github?.isPrivate ?? false),
|
|
42
40
|
Fork: github?.isFork ?? false,
|
|
43
41
|
Published: Boolean(obsidianPluginRegistry?.url ?? nodeNpmRegistry?.url ?? pythonPypiRegistry?.url),
|
|
44
|
-
Status: toStatus(codemeta
|
|
45
|
-
Tags: codemeta
|
|
42
|
+
Status: toStatus(codemeta.codeRepository, codemeta.author, [...codemeta.contributor ?? [], ...codemeta.maintainer ?? []], github?.isFork ?? false, templateData.authorName, templateData.githubAccount),
|
|
43
|
+
Tags: codemeta.keywords ?? null,
|
|
46
44
|
Aliases: nonEmpty([aliases]) ?? null,
|
|
47
|
-
License: toBasicLicenses(codemeta
|
|
45
|
+
License: toBasicLicenses(codemeta.license) ?? null,
|
|
48
46
|
Language: primaryLanguages,
|
|
49
47
|
"Secondary Language": secondaryLanguages,
|
|
50
48
|
"Repo Path": metascope?.options.path === void 0 ? null : `file://${metascope.options.path}`,
|
|
51
49
|
"VS Code Path": metascope?.options.path === void 0 ? null : `vscode://file/${metascope.options.path}`,
|
|
52
|
-
"Readme Path": toLocalUrl(codemeta
|
|
53
|
-
"Homepage URL": codemeta
|
|
54
|
-
"Repo URL": codemeta
|
|
55
|
-
"Issues URL": codemeta
|
|
56
|
-
"Readme URL": codemeta
|
|
50
|
+
"Readme Path": toLocalUrl(codemeta.readme, metascope?.options.path) ?? null,
|
|
51
|
+
"Homepage URL": codemeta.url !== void 0 && !codemeta.url.startsWith("https://github.com/") ? codemeta.url : null,
|
|
52
|
+
"Repo URL": codemeta.codeRepository ?? github?.url ?? null,
|
|
53
|
+
"Issues URL": codemeta.issueTracker ?? null,
|
|
54
|
+
"Readme URL": codemeta.readme !== void 0 && isValidUrl(codemeta.readme) ? codemeta.readme : null,
|
|
57
55
|
"Package URL": obsidianPluginRegistry?.url ?? nodeNpmRegistry?.url ?? pythonPypiRegistry?.url ?? null,
|
|
58
|
-
Created: codemeta
|
|
56
|
+
Created: codemeta.dateCreated ?? null,
|
|
59
57
|
"First Commit Date": gitStats?.commitDateFirst ?? null,
|
|
60
58
|
"Latest Commit Date": gitStats?.commitDateLast ?? null,
|
|
61
59
|
"Latest Push Date": github?.pushedAt ?? null,
|
|
@@ -80,15 +78,15 @@ const frontmatter = defineTemplate((context, templateData) => {
|
|
|
80
78
|
"Tracked Files": gitStats?.trackedFileCount ?? null,
|
|
81
79
|
"Tracked Size MB": toMb(gitStats?.trackedSizeBytes) ?? null,
|
|
82
80
|
"GitHub Size MB": toMb(github?.diskUsageBytes) ?? null,
|
|
83
|
-
Dependencies: dependencyNames(codemeta
|
|
84
|
-
"Dev Dependencies": dependencyNames(codemeta
|
|
81
|
+
Dependencies: dependencyNames(codemeta, "prod") ?? null,
|
|
82
|
+
"Dev Dependencies": dependencyNames(codemeta, "dev") ?? null,
|
|
85
83
|
"Major Updates": dependencyUpdates?.data.major?.length ?? 0,
|
|
86
84
|
"Minor Updates": dependencyUpdates?.data.minor?.length ?? 0,
|
|
87
85
|
"Patch Updates": dependencyUpdates?.data.patch?.length ?? 0,
|
|
88
86
|
"Total Updates": dependencyUpdates?.extra?.total ?? 0,
|
|
89
87
|
Libyears: dependencyUpdates?.extra?.libyears ?? 0,
|
|
90
|
-
Runtime: codemeta
|
|
91
|
-
"Operating System": codemeta
|
|
88
|
+
Runtime: codemeta.runtimePlatform ?? null,
|
|
89
|
+
"Operating System": codemeta.operatingSystem ?? null,
|
|
92
90
|
"Forked From": github?.forkedFrom ?? null,
|
|
93
91
|
"Fork Ahead": github?.commitsAheadUpstream ?? null,
|
|
94
92
|
"Fork Behind": github?.commitsBehindUpstream ?? null,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Template } from "../metadata-types.js";
|
|
2
2
|
import { CodemetaDependencyLd, CodemetaPersonOrOrgLd } from "../utilities/codemeta-helpers.js";
|
|
3
3
|
import { TemplateDataCodemeta } from "./codemeta.js";
|
|
4
|
+
import { TemplateDataCodemetaJson } from "./codemeta-json.js";
|
|
4
5
|
import { TemplateDataFrontmatter } from "./frontmatter.js";
|
|
5
6
|
import { TemplateDataMetadata } from "./metadata.js";
|
|
6
7
|
import { TemplateDataProject } from "./project.js";
|
|
@@ -50,6 +51,100 @@ declare const templates: {
|
|
|
50
51
|
url: string | undefined;
|
|
51
52
|
version: string | undefined;
|
|
52
53
|
}>;
|
|
54
|
+
codemetaJson: Template<{
|
|
55
|
+
applicationCategory?: string | undefined;
|
|
56
|
+
applicationSubCategory?: string | undefined;
|
|
57
|
+
author?: {
|
|
58
|
+
affiliation?: string | undefined;
|
|
59
|
+
email?: string | undefined;
|
|
60
|
+
familyName?: string | undefined;
|
|
61
|
+
givenName?: string | undefined;
|
|
62
|
+
id?: string | undefined;
|
|
63
|
+
name?: string | undefined;
|
|
64
|
+
type?: "Organization" | "Person" | undefined;
|
|
65
|
+
url?: string | undefined;
|
|
66
|
+
}[] | undefined;
|
|
67
|
+
buildInstructions?: string | undefined;
|
|
68
|
+
codeRepository?: string | undefined;
|
|
69
|
+
continuousIntegration?: string | undefined;
|
|
70
|
+
contributor?: {
|
|
71
|
+
affiliation?: string | undefined;
|
|
72
|
+
email?: string | undefined;
|
|
73
|
+
familyName?: string | undefined;
|
|
74
|
+
givenName?: string | undefined;
|
|
75
|
+
id?: string | undefined;
|
|
76
|
+
name?: string | undefined;
|
|
77
|
+
type?: "Organization" | "Person" | undefined;
|
|
78
|
+
url?: string | undefined;
|
|
79
|
+
}[] | undefined;
|
|
80
|
+
copyrightHolder?: {
|
|
81
|
+
affiliation?: string | undefined;
|
|
82
|
+
email?: string | undefined;
|
|
83
|
+
familyName?: string | undefined;
|
|
84
|
+
givenName?: string | undefined;
|
|
85
|
+
id?: string | undefined;
|
|
86
|
+
name?: string | undefined;
|
|
87
|
+
type?: "Organization" | "Person" | undefined;
|
|
88
|
+
url?: string | undefined;
|
|
89
|
+
}[] | undefined;
|
|
90
|
+
copyrightYear?: number | undefined;
|
|
91
|
+
dateCreated?: string | undefined;
|
|
92
|
+
dateModified?: string | undefined;
|
|
93
|
+
datePublished?: string | undefined;
|
|
94
|
+
description?: string | undefined;
|
|
95
|
+
developmentStatus?: string | undefined;
|
|
96
|
+
downloadUrl?: string | undefined;
|
|
97
|
+
funder?: {
|
|
98
|
+
affiliation?: string | undefined;
|
|
99
|
+
email?: string | undefined;
|
|
100
|
+
familyName?: string | undefined;
|
|
101
|
+
givenName?: string | undefined;
|
|
102
|
+
id?: string | undefined;
|
|
103
|
+
name?: string | undefined;
|
|
104
|
+
type?: "Organization" | "Person" | undefined;
|
|
105
|
+
url?: string | undefined;
|
|
106
|
+
}[] | undefined;
|
|
107
|
+
funding?: string | undefined;
|
|
108
|
+
identifier?: string | undefined;
|
|
109
|
+
installUrl?: string | undefined;
|
|
110
|
+
isAccessibleForFree?: boolean | undefined;
|
|
111
|
+
issueTracker?: string | undefined;
|
|
112
|
+
keywords?: string[] | undefined;
|
|
113
|
+
license?: string | string[] | undefined;
|
|
114
|
+
maintainer?: {
|
|
115
|
+
affiliation?: string | undefined;
|
|
116
|
+
email?: string | undefined;
|
|
117
|
+
familyName?: string | undefined;
|
|
118
|
+
givenName?: string | undefined;
|
|
119
|
+
id?: string | undefined;
|
|
120
|
+
name?: string | undefined;
|
|
121
|
+
type?: "Organization" | "Person" | undefined;
|
|
122
|
+
url?: string | undefined;
|
|
123
|
+
}[] | undefined;
|
|
124
|
+
name?: string | undefined;
|
|
125
|
+
operatingSystem?: string[] | undefined;
|
|
126
|
+
programmingLanguage?: string[] | undefined;
|
|
127
|
+
readme?: string | undefined;
|
|
128
|
+
relatedLink?: string | string[] | undefined;
|
|
129
|
+
releaseNotes?: string | undefined;
|
|
130
|
+
runtimePlatform?: string[] | undefined;
|
|
131
|
+
softwareHelp?: string | undefined;
|
|
132
|
+
softwareRequirements?: {
|
|
133
|
+
identifier?: string | undefined;
|
|
134
|
+
name?: string | undefined;
|
|
135
|
+
runtimePlatform?: string | undefined;
|
|
136
|
+
version?: string | undefined;
|
|
137
|
+
}[] | undefined;
|
|
138
|
+
softwareSuggestions?: {
|
|
139
|
+
identifier?: string | undefined;
|
|
140
|
+
name?: string | undefined;
|
|
141
|
+
runtimePlatform?: string | undefined;
|
|
142
|
+
version?: string | undefined;
|
|
143
|
+
}[] | undefined;
|
|
144
|
+
softwareVersion?: string | undefined;
|
|
145
|
+
url?: string | undefined;
|
|
146
|
+
version?: string | undefined;
|
|
147
|
+
}>;
|
|
53
148
|
frontmatter: Template<{
|
|
54
149
|
Name: string | null;
|
|
55
150
|
ID: string | null;
|
|
@@ -169,6 +264,7 @@ declare const templates: {
|
|
|
169
264
|
*/
|
|
170
265
|
type TemplateMap = {
|
|
171
266
|
codemeta: TemplateDataCodemeta;
|
|
267
|
+
codemetaJson: TemplateDataCodemetaJson;
|
|
172
268
|
frontmatter: TemplateDataFrontmatter;
|
|
173
269
|
metadata: TemplateDataMetadata;
|
|
174
270
|
project: TemplateDataProject;
|
|
@@ -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 {
|
|
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
|
|
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
|
|
25
|
+
const homepage = metadataFile?.homepage ?? codemeta.url ?? codemeta.codeRepository;
|
|
28
26
|
return {
|
|
29
|
-
description: metadataFile?.description ?? codemeta
|
|
27
|
+
description: metadataFile?.description ?? codemeta.description,
|
|
30
28
|
homepage: normalizeGitUrl(homepage),
|
|
31
|
-
topics: metadataFile?.keywords ?? codemeta
|
|
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 {
|
|
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
|
|
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
|
|
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
|
|
27
|
-
isAuthoredByMe: isAuthoredBy(codemeta
|
|
28
|
-
isOnMyGitHub: isOnGithubAccountOf(codemeta
|
|
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
|
|
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
|
|
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
|
|
43
|
-
title: codemeta
|
|
44
|
-
type: toStatusLegacy(codemeta
|
|
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
|
|
47
|
-
version: codemeta
|
|
44
|
+
usesSharedConfig: hasDependencyWithId("@kitschpatrol/shared-config", codemeta),
|
|
45
|
+
version: codemeta.version
|
|
48
46
|
};
|
|
49
47
|
});
|
|
50
48
|
//#endregion
|
package/package.json
CHANGED
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
|
|
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
|
-
|
|
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.
|