@repometry/cli 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/README.md
CHANGED
|
@@ -22,7 +22,7 @@ Git can serve as a project’s single source of truth for code, tests, docs, and
|
|
|
22
22
|
|
|
23
23
|
Node.js >=24
|
|
24
24
|
|
|
25
|
-
Repometry analyses JavaScript, TypeScript, Go, Python, Java and PHP with no extra tools. Ruby, Kotlin
|
|
25
|
+
Repometry analyses JavaScript, TypeScript, Go, Python, Java and PHP with no extra tools. Ruby, Kotlin, HCL (Terraform), Lua, Scala, Elixir and Rust come with `@repometry/all` or as plugins. C#, C, C++ and Swift are separate plugins. See [Languages](docs/native-languages.md). Generating coverage uses your project's own test tools.
|
|
26
26
|
|
|
27
27
|
## Install
|
|
28
28
|
|
|
@@ -40,7 +40,7 @@ npm install --global repometry
|
|
|
40
40
|
| --- | --- | --- | --- |
|
|
41
41
|
| `@repometry/cli` | `repometry-cli` | JavaScript, TypeScript | about 8 MB |
|
|
42
42
|
| `repometry` | `repometry` | The above, Go, Python, Java, PHP | about 15 MB |
|
|
43
|
-
| `@repometry/all` | `repometry-all` | The above, Ruby, Kotlin, HCL | about
|
|
43
|
+
| `@repometry/all` | `repometry-all` | The above, Ruby, Kotlin, HCL, Lua, Scala, Elixir, Rust | about 28 MB |
|
|
44
44
|
|
|
45
45
|
To add a language to `@repometry/cli`, install its `@repometry/language-*` package with your package manager and list it in `plugins`. Repometry never installs a plugin. See [Packages](docs/cli.md#packages).
|
|
46
46
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@repometry/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Track repository metrics without SaaS",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
"dependencies": {
|
|
68
68
|
"@babel/parser": "7.29.15",
|
|
69
69
|
"@babel/types": "7.29.15",
|
|
70
|
-
"@repometry/core": "0.
|
|
70
|
+
"@repometry/core": "0.5.0",
|
|
71
71
|
"ajv": "8.20.0",
|
|
72
72
|
"semver": "7.8.6"
|
|
73
73
|
},
|
|
@@ -1,4 +1,27 @@
|
|
|
1
1
|
[
|
|
2
|
+
{
|
|
3
|
+
"language": "c",
|
|
4
|
+
"label": "C",
|
|
5
|
+
"package": "@repometry/language-c",
|
|
6
|
+
"experimental": true,
|
|
7
|
+
"extensions": [
|
|
8
|
+
".c",
|
|
9
|
+
".h"
|
|
10
|
+
]
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
"language": "cpp",
|
|
14
|
+
"label": "C++",
|
|
15
|
+
"package": "@repometry/language-cpp",
|
|
16
|
+
"experimental": true,
|
|
17
|
+
"extensions": [
|
|
18
|
+
".cc",
|
|
19
|
+
".cpp",
|
|
20
|
+
".cxx",
|
|
21
|
+
".hpp",
|
|
22
|
+
".hh"
|
|
23
|
+
]
|
|
24
|
+
},
|
|
2
25
|
{
|
|
3
26
|
"language": "csharp",
|
|
4
27
|
"label": "C#",
|
|
@@ -7,6 +30,15 @@
|
|
|
7
30
|
".cs"
|
|
8
31
|
]
|
|
9
32
|
},
|
|
33
|
+
{
|
|
34
|
+
"language": "elixir",
|
|
35
|
+
"label": "Elixir",
|
|
36
|
+
"package": "@repometry/language-elixir",
|
|
37
|
+
"extensions": [
|
|
38
|
+
".ex",
|
|
39
|
+
".exs"
|
|
40
|
+
]
|
|
41
|
+
},
|
|
10
42
|
{
|
|
11
43
|
"language": "go",
|
|
12
44
|
"label": "Go",
|
|
@@ -73,5 +105,30 @@
|
|
|
73
105
|
"extensions": [
|
|
74
106
|
".rb"
|
|
75
107
|
]
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
"language": "rust",
|
|
111
|
+
"label": "Rust",
|
|
112
|
+
"package": "@repometry/language-rust",
|
|
113
|
+
"extensions": [
|
|
114
|
+
".rs"
|
|
115
|
+
]
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
"language": "scala",
|
|
119
|
+
"label": "Scala",
|
|
120
|
+
"package": "@repometry/language-scala",
|
|
121
|
+
"extensions": [
|
|
122
|
+
".scala"
|
|
123
|
+
]
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
"language": "swift",
|
|
127
|
+
"label": "Swift",
|
|
128
|
+
"package": "@repometry/language-swift",
|
|
129
|
+
"experimental": true,
|
|
130
|
+
"extensions": [
|
|
131
|
+
".swift"
|
|
132
|
+
]
|
|
76
133
|
}
|
|
77
134
|
]
|
|
@@ -6,6 +6,7 @@ import { languageFileSelection } from './file-selection.js';
|
|
|
6
6
|
const fileTypesByExtension = new Map(fileTypes.flatMap(type => (type.extensions ?? []).map(extension => [extension, type.id])));
|
|
7
7
|
const officialByExtension = new Map();
|
|
8
8
|
const packagesByLanguage = new Map();
|
|
9
|
+
const experimentalPackages = new Set(catalog.filter(entry => entry.experimental).map(entry => entry.package));
|
|
9
10
|
const labels = new Map(catalog.map(({ language, label }) => [language, label]));
|
|
10
11
|
for (const entry of catalog) {
|
|
11
12
|
const packages = packagesByLanguage.get(entry.language) ?? new Set();
|
|
@@ -43,7 +44,7 @@ export function detectMissingLanguages(plugins) {
|
|
|
43
44
|
}
|
|
44
45
|
export function missingLanguageNotice({ language, files, packages }) {
|
|
45
46
|
const label = labels.get(language) ?? language;
|
|
46
|
-
const choices = packages.join(' or ');
|
|
47
|
+
const choices = packages.map(name => experimentalPackages.has(name) ? name + ' (experimental)' : name).join(' or ');
|
|
47
48
|
const install = packages.map(name => 'npm install -D ' + name).join(' or ');
|
|
48
49
|
const noun = files === 1 ? 'file has' : 'files have';
|
|
49
50
|
return `${label}: ${files} ${noun} no configured parser. Install ${choices} next to Repometry (${install}) and add it to plugins in repometry.config.json.`;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { extname } from 'node:path';
|
|
1
2
|
import { plan } from '@repometry/core/internal/engine/plan.js';
|
|
2
3
|
import { fileTypeId, fileTypes } from '@repometry/core/internal/model/file-types.js';
|
|
3
4
|
import { codeStructure, codeStructures } from '@repometry/core/internal/model/code-structure.js';
|
|
@@ -7,6 +8,7 @@ import { languageMeasures, restrictStructureMeasures, structureImplementation }
|
|
|
7
8
|
import { builtInPluginIds, builtInPlugins, registeredPlugins } from './built-ins.js';
|
|
8
9
|
import { pluginRegistration } from './registered-plugin.js';
|
|
9
10
|
import { languageFileSelection } from './file-selection.js';
|
|
11
|
+
import { pluginScope } from './plugin-scope.js';
|
|
10
12
|
export { claimMatcher } from './file-selection.js';
|
|
11
13
|
const fileTypeSyntax = new Map(fileTypes.flatMap(({ id, syntax }) => syntax === undefined ? [] : [[id, syntax]]));
|
|
12
14
|
export const defaultLanguages = languageRegistry([]);
|
|
@@ -20,6 +22,8 @@ export function languageRegistry(plugins, parsers, label = 'parsers') {
|
|
|
20
22
|
byProvider.set(plugin.id, [...byProvider.get(plugin.id) ?? [], language]);
|
|
21
23
|
const bindings = new Map();
|
|
22
24
|
const entries = registered.filter(plugin => plugin.kinds.includes('language')).flatMap(plugin => languageEntry(plugin, byProvider.get(plugin.id) ?? [], bindings));
|
|
25
|
+
// The official C++ package accepts .h only through a configured include.
|
|
26
|
+
const cpp = entries.find(entry => entry.id === 'language-cpp' && entry.requiresSource && entry.explicitInclude);
|
|
23
27
|
const active = entries.flatMap(({ provider }) => provider ?? []);
|
|
24
28
|
const { extensions, globs, catalog } = languageSelection(entries);
|
|
25
29
|
const syntaxById = selectedSyntax(selection);
|
|
@@ -36,7 +40,10 @@ export function languageRegistry(plugins, parsers, label = 'parsers') {
|
|
|
36
40
|
}
|
|
37
41
|
function match(path) {
|
|
38
42
|
let matched;
|
|
43
|
+
const cppHeader = cpp !== undefined && extname(path) === '.h' && cpp.matches(path);
|
|
39
44
|
for (const entry of entries) {
|
|
45
|
+
if (cppHeader && entry.id === 'language-c' && entry.requiresSource)
|
|
46
|
+
continue;
|
|
40
47
|
if (!entry.matches(path))
|
|
41
48
|
continue;
|
|
42
49
|
if (matched)
|
|
@@ -68,7 +75,8 @@ function languageEntry(plugin, chosen, bindings) {
|
|
|
68
75
|
const provider = available && operation ? bindParser(plugin, operation, declared, identify) : undefined;
|
|
69
76
|
if (provider)
|
|
70
77
|
bindings.set(plugin, provider.plugin);
|
|
71
|
-
return [{ id: plugin.id, provider, declared, claims, matches, identify,
|
|
78
|
+
return [{ id: plugin.id, provider, declared, claims, matches, identify,
|
|
79
|
+
requiresSource: plugin.languageProvenanceRequiresSource, explicitInclude: pluginScope(plugin)?.include !== undefined }];
|
|
72
80
|
}
|
|
73
81
|
function languageSelection(entries) {
|
|
74
82
|
const available = entries.filter(({ provider }) => provider !== undefined);
|