metascope 0.1.0 → 0.2.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/.DS_Store +0 -0
- package/dist/bin/cli.js +14 -14
- package/dist/lib/{chunk-DrSxFLj_.js → _virtual/_rolldown/runtime.js} +1 -1
- package/dist/lib/file-matching.js +152 -0
- package/dist/lib/index.d.ts +11 -1496
- package/dist/lib/index.js +6 -6215
- package/dist/lib/log.d.ts +11 -0
- package/dist/lib/log.js +20 -0
- package/dist/lib/metadata-types.d.ts +151 -0
- package/dist/lib/metadata-types.js +30 -0
- package/dist/lib/metadata.d.ts +16 -0
- package/dist/lib/metadata.js +235 -0
- package/dist/lib/package.js +5 -0
- package/dist/lib/parsers/configparser-parser.js +43 -0
- package/dist/lib/parsers/gemspec-parser.js +256 -0
- package/dist/lib/parsers/go-mod-parser.js +153 -0
- package/dist/lib/parsers/makefile-config-parser.js +102 -0
- package/dist/lib/parsers/properties-parser.js +31 -0
- package/dist/lib/parsers/rfc822-header-parser.js +48 -0
- package/dist/lib/parsers/setup-py-parser.js +173 -0
- package/dist/lib/source.d.ts +17 -0
- package/dist/lib/source.js +34 -0
- package/dist/lib/sources/arduino-library-properties.d.ts +45 -0
- package/dist/lib/sources/arduino-library-properties.js +208 -0
- package/dist/lib/sources/cinder-cinderblock-xml.d.ts +21 -0
- package/dist/lib/sources/cinder-cinderblock-xml.js +134 -0
- package/dist/lib/sources/code-stats.d.ts +14 -0
- package/dist/lib/sources/code-stats.js +40 -0
- package/dist/lib/sources/codemeta-json.d.ts +117 -0
- package/dist/lib/sources/codemeta-json.js +226 -0
- package/dist/lib/sources/dependency-updates.d.ts +22 -0
- package/dist/lib/sources/dependency-updates.js +132 -0
- package/dist/lib/sources/file-stats.d.ts +12 -0
- package/dist/lib/sources/file-stats.js +48 -0
- package/dist/lib/sources/git-config.d.ts +8 -0
- package/dist/lib/sources/git-config.js +21 -0
- package/dist/lib/sources/git-stats.d.ts +35 -0
- package/dist/lib/sources/git-stats.js +130 -0
- package/dist/lib/sources/github.d.ts +94 -0
- package/dist/lib/sources/github.js +399 -0
- package/dist/lib/sources/go-go-mod.d.ts +19 -0
- package/dist/lib/sources/go-go-mod.js +38 -0
- package/dist/lib/sources/go-goreleaser-yaml.d.ts +19 -0
- package/dist/lib/sources/go-goreleaser-yaml.js +152 -0
- package/dist/lib/sources/java-pom-xml.d.ts +52 -0
- package/dist/lib/sources/java-pom-xml.js +248 -0
- package/dist/lib/sources/license-file.d.ts +10 -0
- package/dist/lib/sources/license-file.js +26 -0
- package/dist/lib/sources/metadata-file.d.ts +14 -0
- package/dist/lib/sources/metadata-file.js +109 -0
- package/dist/lib/sources/metascope.d.ts +14 -0
- package/dist/lib/sources/metascope.js +35 -0
- package/dist/lib/sources/node-npm-registry.d.ts +19 -0
- package/dist/lib/sources/node-npm-registry.js +74 -0
- package/dist/lib/sources/node-package-json.d.ts +7 -0
- package/dist/lib/sources/node-package-json.js +27 -0
- package/dist/lib/sources/obsidian-plugin-manifest-json.d.ts +17 -0
- package/dist/lib/sources/obsidian-plugin-manifest-json.js +34 -0
- package/dist/lib/sources/obsidian-plugin-registry.d.ts +10 -0
- package/dist/lib/sources/obsidian-plugin-registry.js +44 -0
- package/dist/lib/sources/openframeworks-addon-config-mk.d.ts +17 -0
- package/dist/lib/sources/openframeworks-addon-config-mk.js +39 -0
- package/dist/lib/sources/openframeworks-install-xml.d.ts +20 -0
- package/dist/lib/sources/openframeworks-install-xml.js +153 -0
- package/dist/lib/sources/processing-library-properties.d.ts +44 -0
- package/dist/lib/sources/processing-library-properties.js +219 -0
- package/dist/lib/sources/processing-sketch-properties.d.ts +38 -0
- package/dist/lib/sources/processing-sketch-properties.js +185 -0
- package/dist/lib/sources/publiccode-yaml.d.ts +73 -0
- package/dist/lib/sources/publiccode-yaml.js +256 -0
- package/dist/lib/sources/python-pkg-info.d.ts +31 -0
- package/dist/lib/sources/python-pkg-info.js +115 -0
- package/dist/lib/sources/python-pypi-registry.d.ts +19 -0
- package/dist/lib/sources/python-pypi-registry.js +101 -0
- package/dist/lib/sources/python-pyproject-toml.d.ts +7 -0
- package/dist/lib/sources/python-pyproject-toml.js +30 -0
- package/dist/lib/sources/python-setup-cfg.d.ts +28 -0
- package/dist/lib/sources/python-setup-cfg.js +106 -0
- package/dist/lib/sources/python-setup-py.d.ts +28 -0
- package/dist/lib/sources/python-setup-py.js +48 -0
- package/dist/lib/sources/readme-file.d.ts +11 -0
- package/dist/lib/sources/readme-file.js +55 -0
- package/dist/lib/sources/ruby-gemspec.d.ts +44 -0
- package/dist/lib/sources/ruby-gemspec.js +62 -0
- package/dist/lib/sources/rust-cargo-toml.d.ts +40 -0
- package/dist/lib/sources/rust-cargo-toml.js +159 -0
- package/dist/lib/sources/xcode-info-plist.d.ts +22 -0
- package/dist/lib/sources/xcode-info-plist.js +199 -0
- package/dist/lib/sources/xcode-project-pbxproj.d.ts +21 -0
- package/dist/lib/sources/xcode-project-pbxproj.js +222 -0
- package/dist/lib/templates/codemeta.d.ts +47 -0
- package/dist/lib/templates/codemeta.js +494 -0
- package/dist/lib/templates/frontmatter.d.ts +87 -0
- package/dist/lib/templates/frontmatter.js +111 -0
- package/dist/lib/templates/index.d.ts +181 -0
- package/dist/lib/templates/index.js +22 -0
- package/dist/lib/templates/metadata.d.ts +17 -0
- package/dist/lib/templates/metadata.js +35 -0
- package/dist/lib/templates/project.d.ts +39 -0
- package/dist/lib/templates/project.js +51 -0
- package/dist/lib/utilities/codemeta-helpers.d.ts +39 -0
- package/dist/lib/utilities/codemeta-helpers.js +83 -0
- package/dist/lib/utilities/fetch.js +43 -0
- package/dist/lib/utilities/formatting.js +28 -0
- package/dist/lib/utilities/license-identification.js +141 -0
- package/dist/lib/utilities/schema-primitives.js +47 -0
- package/dist/lib/utilities/template-helpers.d.ts +135 -0
- package/dist/lib/utilities/template-helpers.js +310 -0
- package/dist/lib/utilities/tree-sitter-wasm.js +30 -0
- package/package.json +6 -6
- package/readme.md +62 -15
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "metascope",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.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",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"@types/yargs": "^17.0.35",
|
|
48
48
|
"case-police": "^2.2.0",
|
|
49
49
|
"defu": "^6.1.4",
|
|
50
|
-
"fast-xml-parser": "^5.5.
|
|
50
|
+
"fast-xml-parser": "^5.5.3",
|
|
51
51
|
"find-workspaces": "^0.3.1",
|
|
52
52
|
"git-url-parse": "^16.1.0",
|
|
53
53
|
"jiti": "^2.6.1",
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
"tinyexec": "^1.0.2",
|
|
70
70
|
"tinyglobby": "^0.2.15",
|
|
71
71
|
"unified": "^11.0.5",
|
|
72
|
-
"updates": "^17.9.
|
|
72
|
+
"updates": "^17.9.1",
|
|
73
73
|
"web-tree-sitter": "^0.26.6",
|
|
74
74
|
"yaml": "^2.8.2",
|
|
75
75
|
"yargs": "^18.0.0",
|
|
@@ -88,7 +88,7 @@
|
|
|
88
88
|
"publint": "^0.3.18",
|
|
89
89
|
"tree-sitter-python": "^0.25.0",
|
|
90
90
|
"tree-sitter-ruby": "^0.23.1",
|
|
91
|
-
"tsdown": "^0.21.
|
|
91
|
+
"tsdown": "^0.21.2",
|
|
92
92
|
"tsx": "^4.21.0",
|
|
93
93
|
"typescript": "~5.9.3",
|
|
94
94
|
"vitest": "^4.0.18"
|
|
@@ -103,7 +103,7 @@
|
|
|
103
103
|
"fix": "ksc fix",
|
|
104
104
|
"lint": "ksc lint",
|
|
105
105
|
"release": "bumpp --commit 'Release: %s' && pnpm run build && NPM_AUTH_TOKEN=$(op read 'op://Personal/npm/token') && pnpm publish",
|
|
106
|
-
"pretest": "cp node_modules/tree-sitter-ruby/tree-sitter-ruby.wasm src/
|
|
107
|
-
"test": "vitest"
|
|
106
|
+
"pretest": "mkdir -p src/grammars && cp node_modules/tree-sitter-ruby/tree-sitter-ruby.wasm src/grammars/tree-sitter-ruby.wasm && cp node_modules/tree-sitter-python/tree-sitter-python.wasm src/grammars/tree-sitter-python.wasm",
|
|
107
|
+
"test": "vitest run"
|
|
108
108
|
}
|
|
109
109
|
}
|
package/readme.md
CHANGED
|
@@ -109,20 +109,21 @@ metascope [path]
|
|
|
109
109
|
| ------------------- | ---------------------- | -------- | ------- |
|
|
110
110
|
| `path` | Project directory path | `string` | `"."` |
|
|
111
111
|
|
|
112
|
-
| Option | Description | Type
|
|
113
|
-
| ---------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
114
|
-
| `--template`<br>`-t` | Built-in template name (`codemeta`, `frontmatter`, `project`) or path to a custom template file
|
|
115
|
-
| `--github-token` | GitHub API token (or set `$GITHUB_TOKEN`) | `string`
|
|
116
|
-
| `--author-name` | Optional author name(s) for ownership checks in templates | `array`
|
|
117
|
-
| `--github-account` | Optional GitHub account name(s) for ownership checks in templates | `array`
|
|
118
|
-
| `--absolute` | Output absolute paths. Use `--no-absolute` for relative paths. | `boolean`
|
|
119
|
-
| `--offline` | Skip sources requiring network requests | `boolean`
|
|
120
|
-
| `--
|
|
121
|
-
| `--
|
|
122
|
-
| `--
|
|
123
|
-
| `--
|
|
124
|
-
| `--
|
|
125
|
-
| `--
|
|
112
|
+
| Option | Description | Type | Default |
|
|
113
|
+
| ---------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- |
|
|
114
|
+
| `--template`<br>`-t` | Built-in template name (`codemeta`, `frontmatter`, `metadata`, `project`) or path to a custom template file | `string` | |
|
|
115
|
+
| `--github-token` | GitHub API token (or set `$GITHUB_TOKEN`) | `string` | |
|
|
116
|
+
| `--author-name` | Optional author name(s) for ownership checks in templates | `array` | |
|
|
117
|
+
| `--github-account` | Optional GitHub account name(s) for ownership checks in templates | `array` | |
|
|
118
|
+
| `--absolute` | Output absolute paths. Use `--no-absolute` for relative paths. | `boolean` | `true` |
|
|
119
|
+
| `--offline` | Skip sources requiring network requests | `boolean` | `false` |
|
|
120
|
+
| `--sources`<br>`-s` | Only run specific metadata sources (defaults to all) | `"arduinoLibraryProperties"` `"cinderCinderblockXml"` `"codemetaJson"` `"gitConfig"` `"goGoMod"` `"goGoreleaserYaml"` `"javaPomXml"` `"licenseFile"` `"metadataFile"` `"metascope"` `"nodePackageJson"` `"obsidianPluginManifestJson"` `"openframeworksAddonConfigMk"` `"openframeworksInstallXml"` `"processingLibraryProperties"` `"processingSketchProperties"` `"publiccodeYaml"` `"pythonPkgInfo"` `"pythonPyprojectToml"` `"pythonSetupCfg"` `"pythonSetupPy"` `"readmeFile"` `"rubyGemspec"` `"rustCargoToml"` `"xcodeInfoPlist"` `"xcodeProjectPbxproj"` `"codeStats"` `"dependencyUpdates"` `"fileStats"` `"gitStats"` `"github"` `"nodeNpmRegistry"` `"obsidianPluginRegistry"` `"pythonPypiRegistry"` | |
|
|
121
|
+
| `--no-ignore` | Include files ignored by .gitignore in the file tree | `boolean` | `false` |
|
|
122
|
+
| `--recursive`<br>`-r` | Search for metadata files recursively in subdirectories | `boolean` | `false` |
|
|
123
|
+
| `--workspaces`<br>`-w` | Include workspace-specific metadata in monorepos; pass a `boolean` to enable or disable auto-detection, or pass one or more `string`s to explicitly define workspace paths | | `true` |
|
|
124
|
+
| `--verbose` | Run with verbose logging | `boolean` | `false` |
|
|
125
|
+
| `--help`<br>`-h` | Show help | `boolean` | |
|
|
126
|
+
| `--version`<br>`-v` | Show version number | `boolean` | |
|
|
126
127
|
|
|
127
128
|
<!-- /cli-help -->
|
|
128
129
|
|
|
@@ -188,6 +189,14 @@ export default defineTemplate(({ codemetaJson, github, gitStats }) => {
|
|
|
188
189
|
})
|
|
189
190
|
```
|
|
190
191
|
|
|
192
|
+
##### Run only specific sources
|
|
193
|
+
|
|
194
|
+
Extract metadata from only the sources you need, skipping everything else for faster results:
|
|
195
|
+
|
|
196
|
+
```sh
|
|
197
|
+
metascope --sources nodePackageJson gitStats
|
|
198
|
+
```
|
|
199
|
+
|
|
191
200
|
##### Pipe compact JSON to another tool
|
|
192
201
|
|
|
193
202
|
```sh
|
|
@@ -230,6 +239,17 @@ The function accepts a project directory path, optional credentials, and an opti
|
|
|
230
239
|
|
|
231
240
|
All `undefined` values and empty source objects are deep-stripped from the output before returning.
|
|
232
241
|
|
|
242
|
+
To run only a subset of sources, pass a `sources` array with the desired source key names. When omitted, all sources run (the default). This is useful for faster extraction when you only need specific data:
|
|
243
|
+
|
|
244
|
+
```ts
|
|
245
|
+
const result = await getMetadata({
|
|
246
|
+
path: '.',
|
|
247
|
+
sources: ['nodePackageJson', 'gitStats'],
|
|
248
|
+
})
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
Templates can be combined with the `sources` option, but note that some of the built-in templates might suffer missing data if they rely on specific sources.
|
|
252
|
+
|
|
233
253
|
#### `defineTemplate`
|
|
234
254
|
|
|
235
255
|
```ts
|
|
@@ -255,6 +275,23 @@ console.log(helpers.firstOf(metadata.gitStats)?.data.commitCount)
|
|
|
255
275
|
|
|
256
276
|
_See [output sample](./docs/metascope-basic.json) for this repository._
|
|
257
277
|
|
|
278
|
+
##### Get metadata from specific sources only
|
|
279
|
+
|
|
280
|
+
```ts
|
|
281
|
+
import { getMetadata, helpers } from 'metascope'
|
|
282
|
+
|
|
283
|
+
const metadata = await getMetadata({
|
|
284
|
+
path: '.',
|
|
285
|
+
sources: ['nodePackageJson', 'licenseFile'],
|
|
286
|
+
})
|
|
287
|
+
|
|
288
|
+
// Only the requested sources are populated
|
|
289
|
+
console.log(helpers.firstOf(metadata.nodePackageJson)?.data.name)
|
|
290
|
+
console.log(helpers.firstOf(metadata.licenseFile)?.data.spdxId)
|
|
291
|
+
// Other sources are undefined
|
|
292
|
+
console.log(metadata.github) // Undefined
|
|
293
|
+
```
|
|
294
|
+
|
|
258
295
|
##### Get shaped metadata via a template
|
|
259
296
|
|
|
260
297
|
```ts
|
|
@@ -389,7 +426,7 @@ Metascope provides a basic templating / output transformation functionality to c
|
|
|
389
426
|
|
|
390
427
|
### Built-in templates
|
|
391
428
|
|
|
392
|
-
|
|
429
|
+
Four built-in templates are available by name. Pass the name as the `template` option on the CLI or in the API.
|
|
393
430
|
|
|
394
431
|
#### `codemeta`
|
|
395
432
|
|
|
@@ -419,6 +456,16 @@ metascope --template frontmatter
|
|
|
419
456
|
|
|
420
457
|
_See an [output sample](./docs/metascope-template-frontmatter.json) from the `frontmatter` template run against this repository._
|
|
421
458
|
|
|
459
|
+
#### `metadata`
|
|
460
|
+
|
|
461
|
+
A minimal template that outputs the three fields used by `metadata.json` / `metadata.yaml`: `description`, `homepage`, and `topics`. Designed for use with [github-action-repo-sync](https://github.com/kitschpatrol/github-action-repo-sync) to populate a GitHub repository's description, homepage, and topics. Values from a `metadata.json` source file override what the `codemeta` template would otherwise produce.
|
|
462
|
+
|
|
463
|
+
```sh
|
|
464
|
+
metascope --template metadata
|
|
465
|
+
```
|
|
466
|
+
|
|
467
|
+
_See an [output sample](./docs/metascope-template-metadata.json) from the `metadata` template run against this repository._
|
|
468
|
+
|
|
422
469
|
#### `project`
|
|
423
470
|
|
|
424
471
|
I needed this one for a legacy internal dashboard application. Includes ownership checks via `authorName` and `githubAccount` template data.
|