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.
Files changed (111) hide show
  1. package/dist/.DS_Store +0 -0
  2. package/dist/bin/cli.js +14 -14
  3. package/dist/lib/{chunk-DrSxFLj_.js → _virtual/_rolldown/runtime.js} +1 -1
  4. package/dist/lib/file-matching.js +152 -0
  5. package/dist/lib/index.d.ts +11 -1496
  6. package/dist/lib/index.js +6 -6215
  7. package/dist/lib/log.d.ts +11 -0
  8. package/dist/lib/log.js +20 -0
  9. package/dist/lib/metadata-types.d.ts +151 -0
  10. package/dist/lib/metadata-types.js +30 -0
  11. package/dist/lib/metadata.d.ts +16 -0
  12. package/dist/lib/metadata.js +235 -0
  13. package/dist/lib/package.js +5 -0
  14. package/dist/lib/parsers/configparser-parser.js +43 -0
  15. package/dist/lib/parsers/gemspec-parser.js +256 -0
  16. package/dist/lib/parsers/go-mod-parser.js +153 -0
  17. package/dist/lib/parsers/makefile-config-parser.js +102 -0
  18. package/dist/lib/parsers/properties-parser.js +31 -0
  19. package/dist/lib/parsers/rfc822-header-parser.js +48 -0
  20. package/dist/lib/parsers/setup-py-parser.js +173 -0
  21. package/dist/lib/source.d.ts +17 -0
  22. package/dist/lib/source.js +34 -0
  23. package/dist/lib/sources/arduino-library-properties.d.ts +45 -0
  24. package/dist/lib/sources/arduino-library-properties.js +208 -0
  25. package/dist/lib/sources/cinder-cinderblock-xml.d.ts +21 -0
  26. package/dist/lib/sources/cinder-cinderblock-xml.js +134 -0
  27. package/dist/lib/sources/code-stats.d.ts +14 -0
  28. package/dist/lib/sources/code-stats.js +40 -0
  29. package/dist/lib/sources/codemeta-json.d.ts +117 -0
  30. package/dist/lib/sources/codemeta-json.js +226 -0
  31. package/dist/lib/sources/dependency-updates.d.ts +22 -0
  32. package/dist/lib/sources/dependency-updates.js +132 -0
  33. package/dist/lib/sources/file-stats.d.ts +12 -0
  34. package/dist/lib/sources/file-stats.js +48 -0
  35. package/dist/lib/sources/git-config.d.ts +8 -0
  36. package/dist/lib/sources/git-config.js +21 -0
  37. package/dist/lib/sources/git-stats.d.ts +35 -0
  38. package/dist/lib/sources/git-stats.js +130 -0
  39. package/dist/lib/sources/github.d.ts +94 -0
  40. package/dist/lib/sources/github.js +399 -0
  41. package/dist/lib/sources/go-go-mod.d.ts +19 -0
  42. package/dist/lib/sources/go-go-mod.js +38 -0
  43. package/dist/lib/sources/go-goreleaser-yaml.d.ts +19 -0
  44. package/dist/lib/sources/go-goreleaser-yaml.js +152 -0
  45. package/dist/lib/sources/java-pom-xml.d.ts +52 -0
  46. package/dist/lib/sources/java-pom-xml.js +248 -0
  47. package/dist/lib/sources/license-file.d.ts +10 -0
  48. package/dist/lib/sources/license-file.js +26 -0
  49. package/dist/lib/sources/metadata-file.d.ts +14 -0
  50. package/dist/lib/sources/metadata-file.js +109 -0
  51. package/dist/lib/sources/metascope.d.ts +14 -0
  52. package/dist/lib/sources/metascope.js +35 -0
  53. package/dist/lib/sources/node-npm-registry.d.ts +19 -0
  54. package/dist/lib/sources/node-npm-registry.js +74 -0
  55. package/dist/lib/sources/node-package-json.d.ts +7 -0
  56. package/dist/lib/sources/node-package-json.js +27 -0
  57. package/dist/lib/sources/obsidian-plugin-manifest-json.d.ts +17 -0
  58. package/dist/lib/sources/obsidian-plugin-manifest-json.js +34 -0
  59. package/dist/lib/sources/obsidian-plugin-registry.d.ts +10 -0
  60. package/dist/lib/sources/obsidian-plugin-registry.js +44 -0
  61. package/dist/lib/sources/openframeworks-addon-config-mk.d.ts +17 -0
  62. package/dist/lib/sources/openframeworks-addon-config-mk.js +39 -0
  63. package/dist/lib/sources/openframeworks-install-xml.d.ts +20 -0
  64. package/dist/lib/sources/openframeworks-install-xml.js +153 -0
  65. package/dist/lib/sources/processing-library-properties.d.ts +44 -0
  66. package/dist/lib/sources/processing-library-properties.js +219 -0
  67. package/dist/lib/sources/processing-sketch-properties.d.ts +38 -0
  68. package/dist/lib/sources/processing-sketch-properties.js +185 -0
  69. package/dist/lib/sources/publiccode-yaml.d.ts +73 -0
  70. package/dist/lib/sources/publiccode-yaml.js +256 -0
  71. package/dist/lib/sources/python-pkg-info.d.ts +31 -0
  72. package/dist/lib/sources/python-pkg-info.js +115 -0
  73. package/dist/lib/sources/python-pypi-registry.d.ts +19 -0
  74. package/dist/lib/sources/python-pypi-registry.js +101 -0
  75. package/dist/lib/sources/python-pyproject-toml.d.ts +7 -0
  76. package/dist/lib/sources/python-pyproject-toml.js +30 -0
  77. package/dist/lib/sources/python-setup-cfg.d.ts +28 -0
  78. package/dist/lib/sources/python-setup-cfg.js +106 -0
  79. package/dist/lib/sources/python-setup-py.d.ts +28 -0
  80. package/dist/lib/sources/python-setup-py.js +48 -0
  81. package/dist/lib/sources/readme-file.d.ts +11 -0
  82. package/dist/lib/sources/readme-file.js +55 -0
  83. package/dist/lib/sources/ruby-gemspec.d.ts +44 -0
  84. package/dist/lib/sources/ruby-gemspec.js +62 -0
  85. package/dist/lib/sources/rust-cargo-toml.d.ts +40 -0
  86. package/dist/lib/sources/rust-cargo-toml.js +159 -0
  87. package/dist/lib/sources/xcode-info-plist.d.ts +22 -0
  88. package/dist/lib/sources/xcode-info-plist.js +199 -0
  89. package/dist/lib/sources/xcode-project-pbxproj.d.ts +21 -0
  90. package/dist/lib/sources/xcode-project-pbxproj.js +222 -0
  91. package/dist/lib/templates/codemeta.d.ts +47 -0
  92. package/dist/lib/templates/codemeta.js +494 -0
  93. package/dist/lib/templates/frontmatter.d.ts +87 -0
  94. package/dist/lib/templates/frontmatter.js +111 -0
  95. package/dist/lib/templates/index.d.ts +181 -0
  96. package/dist/lib/templates/index.js +22 -0
  97. package/dist/lib/templates/metadata.d.ts +17 -0
  98. package/dist/lib/templates/metadata.js +35 -0
  99. package/dist/lib/templates/project.d.ts +39 -0
  100. package/dist/lib/templates/project.js +51 -0
  101. package/dist/lib/utilities/codemeta-helpers.d.ts +39 -0
  102. package/dist/lib/utilities/codemeta-helpers.js +83 -0
  103. package/dist/lib/utilities/fetch.js +43 -0
  104. package/dist/lib/utilities/formatting.js +28 -0
  105. package/dist/lib/utilities/license-identification.js +141 -0
  106. package/dist/lib/utilities/schema-primitives.js +47 -0
  107. package/dist/lib/utilities/template-helpers.d.ts +135 -0
  108. package/dist/lib/utilities/template-helpers.js +310 -0
  109. package/dist/lib/utilities/tree-sitter-wasm.js +30 -0
  110. package/package.json +6 -6
  111. package/readme.md +62 -15
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "metascope",
3
- "version": "0.1.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.1",
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.0",
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.1",
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/lib/grammars/tree-sitter-ruby.wasm && cp node_modules/tree-sitter-python/tree-sitter-python.wasm src/lib/grammars/tree-sitter-python.wasm",
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 | Default |
113
- | ---------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------- | ------- |
114
- | `--template`<br>`-t` | Built-in template name (`codemeta`, `frontmatter`, `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
- | `--no-ignore` | Include files ignored by .gitignore in the file tree | `boolean` | `false` |
121
- | `--recursive`<br>`-r` | Search for metadata files recursively in subdirectories | `boolean` | `false` |
122
- | `--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` |
123
- | `--verbose` | Run with verbose logging | `boolean` | `false` |
124
- | `--help`<br>`-h` | Show help | `boolean` | |
125
- | `--version`<br>`-v` | Show version number | `boolean` | |
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
- Three built-in templates are available by name. Pass the name as the `template` option on the CLI or in the API.
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.