linguist-js 2.9.2 → 3.0.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/bin/index.js +1 -1
- package/dist/analyser/classifiers/byAttributes.d.ts +3 -0
- package/dist/analyser/classifiers/byAttributes.js +13 -0
- package/dist/analyser/classifiers/byExtension.d.ts +3 -0
- package/dist/analyser/classifiers/byExtension.js +31 -0
- package/dist/analyser/classifiers/byFilename.d.ts +3 -0
- package/dist/analyser/classifiers/byFilename.js +10 -0
- package/dist/analyser/classifiers/byHeuristics.d.ts +3 -0
- package/dist/analyser/classifiers/byHeuristics.js +67 -0
- package/dist/analyser/classifiers/byModeline.d.ts +3 -0
- package/dist/analyser/classifiers/byModeline.js +22 -0
- package/dist/analyser/classifiers/byShebang.d.ts +3 -0
- package/dist/analyser/classifiers/byShebang.js +27 -0
- package/dist/analyser/index.d.ts +3 -0
- package/dist/analyser/index.js +12 -0
- package/dist/analyser/pipeline/aggregate.d.ts +4 -0
- package/dist/analyser/pipeline/aggregate.js +98 -0
- package/dist/analyser/pipeline/classify.d.ts +3 -0
- package/dist/analyser/pipeline/classify.js +32 -0
- package/dist/analyser/pipeline/filter.d.ts +2 -0
- package/dist/analyser/pipeline/filter.js +14 -0
- package/dist/analyser/pipeline/heuristics.d.ts +3 -0
- package/dist/analyser/pipeline/heuristics.js +12 -0
- package/dist/analyser/pipeline/normalise.d.ts +2 -0
- package/dist/analyser/pipeline/normalise.js +9 -0
- package/dist/cli/output/default.d.ts +3 -0
- package/dist/cli/output/default.js +106 -0
- package/dist/cli/output/tree.d.ts +3 -0
- package/dist/cli/output/tree.js +11 -0
- package/dist/cli/runCliAnalysis.d.ts +2 -0
- package/dist/cli/runCliAnalysis.js +26 -0
- package/dist/cli/utils.d.ts +2 -0
- package/dist/cli/utils.js +9 -0
- package/dist/cli.js +14 -143
- package/dist/entry/analyseFs.d.ts +2 -0
- package/dist/entry/analyseFs.js +11 -0
- package/dist/entry/analyseRaw.d.ts +4 -0
- package/dist/entry/analyseRaw.js +11 -0
- package/dist/index.d.ts +19 -4
- package/dist/index.js +18 -483
- package/dist/input/fromFilesystem.d.ts +4 -0
- package/dist/input/fromFilesystem.js +115 -0
- package/dist/input/fromRawContent.d.ts +2 -0
- package/dist/input/fromRawContent.js +19 -0
- package/dist/input/normaliseOpts.d.ts +2 -0
- package/dist/input/normaliseOpts.js +13 -0
- package/dist/program/classes/attributes.d.ts +11 -0
- package/dist/program/classes/attributes.js +37 -0
- package/dist/program/data/loadDataFiles.d.ts +4 -0
- package/dist/program/data/loadDataFiles.js +32 -0
- package/dist/program/data/retrieveData.d.ts +12 -0
- package/dist/program/data/retrieveData.js +27 -0
- package/dist/program/fs/normalisedPath.d.ts +3 -0
- package/dist/program/fs/normalisedPath.js +17 -0
- package/dist/program/fs/readFile.js +17 -0
- package/dist/program/fs/walkTree.d.ts +20 -0
- package/dist/program/fs/walkTree.js +82 -0
- package/dist/program/parsing/parseGitattributes.d.ts +17 -0
- package/dist/program/parsing/parseGitattributes.js +33 -0
- package/dist/program/parsing/parseGitignore.js +9 -0
- package/dist/program/processFiles.d.ts +9 -0
- package/dist/program/processFiles.js +111 -0
- package/dist/program/utils/pcre.js +35 -0
- package/dist/src/cli/output/default.d.ts +3 -0
- package/dist/src/cli/output/default.js +106 -0
- package/dist/src/cli/output/tree.d.ts +3 -0
- package/dist/src/cli/output/tree.js +11 -0
- package/dist/src/cli/runCliAnalysis.d.ts +2 -0
- package/dist/src/cli/runCliAnalysis.js +25 -0
- package/dist/src/cli/utils.d.ts +2 -0
- package/dist/src/cli/utils.js +9 -0
- package/dist/src/cli.d.ts +1 -0
- package/dist/src/cli.js +56 -0
- package/dist/src/helpers/convert-pcre.d.ts +2 -0
- package/dist/src/helpers/parse-gitignore.d.ts +1 -0
- package/dist/src/helpers/read-file.d.ts +5 -0
- package/dist/{helpers → src/helpers}/read-file.js +1 -1
- package/dist/src/index.d.ts +5 -0
- package/dist/src/index.js +470 -0
- package/dist/src/program/data/loadData.d.ts +4 -0
- package/dist/src/program/data/loadData.js +32 -0
- package/dist/src/program/fs/normalisedPath.d.ts +2 -0
- package/dist/src/program/fs/normalisedPath.js +7 -0
- package/dist/src/program/fs/readFile.d.ts +5 -0
- package/dist/src/program/fs/readFile.js +17 -0
- package/dist/src/program/fs/walkTree.d.ts +20 -0
- package/dist/src/program/fs/walkTree.js +82 -0
- package/dist/src/program/parsing/parseGitattributes.d.ts +17 -0
- package/dist/src/program/parsing/parseGitattributes.js +33 -0
- package/dist/src/program/parsing/parseGitignore.d.ts +1 -0
- package/dist/src/program/parsing/parseGitignore.js +9 -0
- package/dist/src/program/utils/pcre.d.ts +2 -0
- package/dist/src/program/utils/pcre.js +35 -0
- package/dist/src/types/schema.d.ts +37 -0
- package/dist/src/types/schema.js +1 -0
- package/dist/src/types/types.d.ts +65 -0
- package/dist/src/types/types.js +1 -0
- package/dist/types/schema.d.ts +37 -0
- package/dist/types/schema.js +1 -0
- package/dist/types/types.d.ts +84 -0
- package/dist/types/types.js +1 -0
- package/ext/generated.rb +6 -0
- package/ext/heuristics.yml +102 -11
- package/ext/languages.yml +526 -88
- package/ext/vendor.yml +1 -0
- package/package.json +14 -13
- package/readme.md +99 -111
- /package/dist/{helpers/read-file.d.ts → program/fs/readFile.d.ts} +0 -0
- /package/dist/{helpers/parse-gitignore.d.ts → program/parsing/parseGitignore.d.ts} +0 -0
- /package/dist/{helpers/convert-pcre.d.ts → program/utils/pcre.d.ts} +0 -0
- /package/dist/{helpers → src/helpers}/convert-pcre.js +0 -0
- /package/dist/{helpers → src/helpers}/load-data.d.ts +0 -0
- /package/dist/{helpers → src/helpers}/load-data.js +0 -0
- /package/dist/{helpers → src/helpers}/norm-path.d.ts +0 -0
- /package/dist/{helpers → src/helpers}/norm-path.js +0 -0
- /package/dist/{helpers → src/helpers}/parse-gitattributes.d.ts +0 -0
- /package/dist/{helpers → src/helpers}/parse-gitattributes.js +0 -0
- /package/dist/{helpers → src/helpers}/parse-gitignore.js +0 -0
- /package/dist/{helpers → src/helpers}/walk-tree.d.ts +0 -0
- /package/dist/{helpers → src/helpers}/walk-tree.js +0 -0
- /package/dist/{schema.d.ts → src/schema.d.ts} +0 -0
- /package/dist/{schema.js → src/schema.js} +0 -0
- /package/dist/{types.d.ts → src/types.d.ts} +0 -0
- /package/dist/{types.js → src/types.js} +0 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Ignore } from 'ignore';
|
|
2
|
+
interface WalkInput {
|
|
3
|
+
/** Whether this is walking the tree from the root */
|
|
4
|
+
init: boolean;
|
|
5
|
+
/** The common root absolute path of all folders being checked */
|
|
6
|
+
commonRoot: string;
|
|
7
|
+
/** The absolute path that each folder is relative to */
|
|
8
|
+
folderRoots: string[];
|
|
9
|
+
/** The absolute path of folders being checked */
|
|
10
|
+
folders: string[];
|
|
11
|
+
/** An instantiated Ignore object listing ignored files */
|
|
12
|
+
ignored: Ignore;
|
|
13
|
+
}
|
|
14
|
+
interface WalkOutput {
|
|
15
|
+
files: string[];
|
|
16
|
+
folders: string[];
|
|
17
|
+
}
|
|
18
|
+
/** Generate list of files in a directory. */
|
|
19
|
+
export default function walkTree(data: WalkInput): WalkOutput;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import FS from 'node:fs';
|
|
2
|
+
import Path from 'node:path';
|
|
3
|
+
import parseGitignore from '../parsing/parseGitignore.js';
|
|
4
|
+
import { normAbsPath, normPath } from './normalisedPath.js';
|
|
5
|
+
let allFiles;
|
|
6
|
+
let allFolders;
|
|
7
|
+
/** Generate list of files in a directory. */
|
|
8
|
+
export default function walkTree(data) {
|
|
9
|
+
const { init, commonRoot, folderRoots, folders, ignored } = data;
|
|
10
|
+
// Initialise files and folders lists
|
|
11
|
+
if (init) {
|
|
12
|
+
allFiles = new Set();
|
|
13
|
+
allFolders = new Set();
|
|
14
|
+
}
|
|
15
|
+
// Walk tree of a folder
|
|
16
|
+
if (folders.length === 1) {
|
|
17
|
+
const folder = folders[0];
|
|
18
|
+
const localRoot = folderRoots[0].replace(commonRoot, '').replace(/^\//, '');
|
|
19
|
+
// Get list of files and folders inside this folder
|
|
20
|
+
const files = FS.readdirSync(folder).map((file) => {
|
|
21
|
+
// Create path relative to root
|
|
22
|
+
const base = normAbsPath(folder, file).replace(commonRoot, '.');
|
|
23
|
+
// Add trailing slash to mark directories
|
|
24
|
+
const isDir = FS.lstatSync(Path.resolve(commonRoot, base)).isDirectory();
|
|
25
|
+
return isDir ? `${base}/` : base;
|
|
26
|
+
});
|
|
27
|
+
// Read and apply gitignores
|
|
28
|
+
const gitignoreFilename = normPath(folder, '.gitignore');
|
|
29
|
+
if (FS.existsSync(gitignoreFilename)) {
|
|
30
|
+
const gitignoreContents = FS.readFileSync(gitignoreFilename, 'utf-8');
|
|
31
|
+
const ignoredPaths = parseGitignore(gitignoreContents);
|
|
32
|
+
const rootRelIgnoredPaths = ignoredPaths.map((ignorePath) =>
|
|
33
|
+
// get absolute path of the ignore glob
|
|
34
|
+
normPath(folder, ignorePath)
|
|
35
|
+
// convert abs ignore glob to be relative to the root folder
|
|
36
|
+
.replace(commonRoot + '/', ''));
|
|
37
|
+
ignored.add(rootRelIgnoredPaths);
|
|
38
|
+
}
|
|
39
|
+
// Add gitattributes if present
|
|
40
|
+
const gitattributesPath = normPath(folder, '.gitattributes');
|
|
41
|
+
if (FS.existsSync(gitattributesPath)) {
|
|
42
|
+
allFiles.add(gitattributesPath);
|
|
43
|
+
}
|
|
44
|
+
// Loop through files and folders
|
|
45
|
+
for (const file of files) {
|
|
46
|
+
// Create absolute path for disc operations
|
|
47
|
+
const path = normAbsPath(commonRoot, file);
|
|
48
|
+
const localPath = localRoot ? file.replace(`./${localRoot}/`, '') : file.replace('./', '');
|
|
49
|
+
// Skip if nonexistant
|
|
50
|
+
const nonExistant = !FS.existsSync(path);
|
|
51
|
+
if (nonExistant)
|
|
52
|
+
continue;
|
|
53
|
+
// Skip if marked in gitignore
|
|
54
|
+
const isIgnored = ignored.test(localPath).ignored;
|
|
55
|
+
if (isIgnored)
|
|
56
|
+
continue;
|
|
57
|
+
// Add absolute folder path to list
|
|
58
|
+
allFolders.add(normAbsPath(folder));
|
|
59
|
+
// Check if this is a folder or file
|
|
60
|
+
if (file.endsWith('/')) {
|
|
61
|
+
// Recurse into subfolders
|
|
62
|
+
allFolders.add(path);
|
|
63
|
+
walkTree({ init: false, commonRoot, folderRoots, folders: [path], ignored });
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
// Add file path to list
|
|
67
|
+
allFiles.add(path);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
// Recurse into all folders
|
|
72
|
+
else {
|
|
73
|
+
for (const i in folders) {
|
|
74
|
+
walkTree({ init: false, commonRoot, folderRoots: [folderRoots[i]], folders: [folders[i]], ignored });
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
// Return absolute files and folders lists
|
|
78
|
+
return {
|
|
79
|
+
files: [...allFiles].map((file) => file.replace(/^\./, commonRoot)),
|
|
80
|
+
folders: [...allFolders],
|
|
81
|
+
};
|
|
82
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import * as T from '../../types/types.js';
|
|
2
|
+
export type FlagAttributes = {
|
|
3
|
+
'vendored': boolean | null;
|
|
4
|
+
'generated': boolean | null;
|
|
5
|
+
'documentation': boolean | null;
|
|
6
|
+
'detectable': boolean | null;
|
|
7
|
+
'binary': boolean | null;
|
|
8
|
+
'language': T.LanguageResult;
|
|
9
|
+
};
|
|
10
|
+
export type ParsedGitattributes = Array<{
|
|
11
|
+
glob: T.FileGlob;
|
|
12
|
+
attrs: FlagAttributes;
|
|
13
|
+
}>;
|
|
14
|
+
/**
|
|
15
|
+
* Parses a gitattributes file.
|
|
16
|
+
*/
|
|
17
|
+
export default function parseGitattributes(content: string, folderRoot?: string): ParsedGitattributes;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { normPath } from '../fs/normalisedPath.js';
|
|
2
|
+
/**
|
|
3
|
+
* Parses a gitattributes file.
|
|
4
|
+
*/
|
|
5
|
+
export default function parseGitattributes(content, folderRoot = '.') {
|
|
6
|
+
const output = [];
|
|
7
|
+
for (const rawLine of content.split('\n')) {
|
|
8
|
+
const line = rawLine.replace(/#.*/, '').trim();
|
|
9
|
+
if (!line)
|
|
10
|
+
continue;
|
|
11
|
+
const parts = line.split(/\s+/g);
|
|
12
|
+
const fileGlob = parts[0];
|
|
13
|
+
const relFileGlob = normPath(folderRoot, fileGlob);
|
|
14
|
+
const attrParts = parts.slice(1);
|
|
15
|
+
const isTrue = (str) => !str.startsWith('-') && !str.endsWith('=false');
|
|
16
|
+
const isFalse = (str) => str.startsWith('-') || str.endsWith('=false');
|
|
17
|
+
const trueParts = (str) => attrParts.filter(part => part.includes(str) && isTrue(part));
|
|
18
|
+
const falseParts = (str) => attrParts.filter(part => part.includes(str) && isFalse(part));
|
|
19
|
+
const hasTrueParts = (str) => trueParts(str).length > 0;
|
|
20
|
+
const hasFalseParts = (str) => falseParts(str).length > 0;
|
|
21
|
+
const boolOrNullVal = (str) => hasTrueParts(str) ? true : hasFalseParts(str) ? false : null;
|
|
22
|
+
const attrs = {
|
|
23
|
+
'generated': boolOrNullVal('linguist-generated'),
|
|
24
|
+
'vendored': boolOrNullVal('linguist-vendored'),
|
|
25
|
+
'documentation': boolOrNullVal('linguist-documentation'),
|
|
26
|
+
'detectable': boolOrNullVal('linguist-detectable'),
|
|
27
|
+
'binary': hasTrueParts('binary') || hasFalseParts('text') ? true : hasFalseParts('binary') || hasTrueParts('text') ? false : null,
|
|
28
|
+
'language': trueParts('linguist-language').at(-1)?.split('=')[1] ?? null,
|
|
29
|
+
};
|
|
30
|
+
output.push({ glob: relFileGlob, attrs });
|
|
31
|
+
}
|
|
32
|
+
return output;
|
|
33
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function parseGitignore(content: string): string[];
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export default function parseGitignore(content) {
|
|
2
|
+
const readableData = content
|
|
3
|
+
// Remove comments unless escaped
|
|
4
|
+
.replace(/(?<!\\)#.+/g, '')
|
|
5
|
+
// Remove whitespace unless escaped
|
|
6
|
+
.replace(/(?:(?<!\\)\s)+$/g, '');
|
|
7
|
+
const arrayData = readableData.split(/\r?\n/).filter(data => data);
|
|
8
|
+
return arrayData;
|
|
9
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/** Convert a PCRE regex into JS. */
|
|
2
|
+
export default function pcre(regex) {
|
|
3
|
+
let finalRegex = regex;
|
|
4
|
+
const replace = (search, replace) => finalRegex = finalRegex.replace(search, replace);
|
|
5
|
+
const finalFlags = new Set();
|
|
6
|
+
// Convert inline flag declarations
|
|
7
|
+
const inlineMatches = regex.matchAll(/\?(-)?([a-z]):/g);
|
|
8
|
+
const startMatches = regex.matchAll(/\(\?(-)?([a-z]+)\)/g);
|
|
9
|
+
for (const [match, isNegative, flags] of [...inlineMatches, ...startMatches]) {
|
|
10
|
+
replace(match, '');
|
|
11
|
+
const func = (flag) => isNegative ? finalFlags.delete(flag) : finalFlags.add(flag);
|
|
12
|
+
[...flags].forEach(func);
|
|
13
|
+
}
|
|
14
|
+
// Remove PCRE-only syntax
|
|
15
|
+
replace(/([*+]){2}/g, '$1');
|
|
16
|
+
replace(/\(\?>/g, '(?:');
|
|
17
|
+
// Remove start/end-of-file markers
|
|
18
|
+
if (/\\[AZ]/.test(finalRegex)) {
|
|
19
|
+
replace(/\\A/g, '^');
|
|
20
|
+
replace(/\\Z/g, '$');
|
|
21
|
+
finalFlags.delete('m');
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
finalFlags.add('m');
|
|
25
|
+
}
|
|
26
|
+
// Reformat free-spacing mode
|
|
27
|
+
if (finalFlags.has('x')) {
|
|
28
|
+
finalFlags.delete('x');
|
|
29
|
+
replace(/#.+/g, '');
|
|
30
|
+
replace(/^\s+|\s+$|\n/gm, '');
|
|
31
|
+
replace(/\s+/g, ' ');
|
|
32
|
+
}
|
|
33
|
+
// Return final regex
|
|
34
|
+
return RegExp(finalRegex, [...finalFlags].join(''));
|
|
35
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Category, Language } from './types.js';
|
|
2
|
+
export interface LanguagesScema {
|
|
3
|
+
[name: string]: {
|
|
4
|
+
language_id: number;
|
|
5
|
+
fs_name?: Language;
|
|
6
|
+
type: Category;
|
|
7
|
+
group?: Language;
|
|
8
|
+
color?: `#${string}`;
|
|
9
|
+
aliases?: string[];
|
|
10
|
+
extensions?: `.${string}`[];
|
|
11
|
+
filenames?: string[];
|
|
12
|
+
interpreters?: string[];
|
|
13
|
+
tm_scope?: `${'source' | 'text'}.${string}`;
|
|
14
|
+
ace_mode?: string;
|
|
15
|
+
codemirror_mode?: string;
|
|
16
|
+
codemirror_mime_type?: `${string}/${string}`;
|
|
17
|
+
wrap?: boolean;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
interface HeuristicsRules {
|
|
21
|
+
pattern?: string;
|
|
22
|
+
named_pattern?: string;
|
|
23
|
+
named_patterns?: string[];
|
|
24
|
+
negative_pattern?: string;
|
|
25
|
+
}
|
|
26
|
+
export interface HeuristicsSchema {
|
|
27
|
+
disambiguations: Array<{
|
|
28
|
+
extensions: string[];
|
|
29
|
+
rules: Array<HeuristicsRules & {
|
|
30
|
+
language: string | string[];
|
|
31
|
+
and?: HeuristicsRules[];
|
|
32
|
+
}>;
|
|
33
|
+
}>;
|
|
34
|
+
named_patterns: Record<string, string | string[]>;
|
|
35
|
+
}
|
|
36
|
+
export type VendorSchema = string[];
|
|
37
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
export type LanguageResult = string | null;
|
|
2
|
+
export type Language = string;
|
|
3
|
+
export type Category = 'data' | 'markup' | 'programming' | 'prose';
|
|
4
|
+
export type FilePath = string;
|
|
5
|
+
export type Bytes = Integer;
|
|
6
|
+
export type Integer = number;
|
|
7
|
+
export type RelFile = string & {};
|
|
8
|
+
export type AbsFile = string & {};
|
|
9
|
+
export type AbsFolder = string & {};
|
|
10
|
+
export type FileGlob = string & {};
|
|
11
|
+
export interface Options {
|
|
12
|
+
ignoredFiles?: string[];
|
|
13
|
+
ignoredLanguages?: Language[];
|
|
14
|
+
categories?: Category[];
|
|
15
|
+
keepVendored?: boolean;
|
|
16
|
+
keepBinary?: boolean;
|
|
17
|
+
relativePaths?: boolean;
|
|
18
|
+
childLanguages?: boolean;
|
|
19
|
+
quick?: boolean;
|
|
20
|
+
offline?: boolean;
|
|
21
|
+
calculateLines?: boolean;
|
|
22
|
+
checkIgnored?: boolean;
|
|
23
|
+
checkDetected?: boolean;
|
|
24
|
+
checkAttributes?: boolean;
|
|
25
|
+
checkHeuristics?: boolean;
|
|
26
|
+
checkShebang?: boolean;
|
|
27
|
+
checkModeline?: boolean;
|
|
28
|
+
}
|
|
29
|
+
type LinesOfCode = {
|
|
30
|
+
total: Integer;
|
|
31
|
+
content: Integer;
|
|
32
|
+
};
|
|
33
|
+
export interface Results {
|
|
34
|
+
files: {
|
|
35
|
+
count: Integer;
|
|
36
|
+
bytes: Bytes;
|
|
37
|
+
lines: LinesOfCode;
|
|
38
|
+
/** Note: Results use slashes as delimiters even on Windows. */
|
|
39
|
+
results: Record<FilePath, LanguageResult>;
|
|
40
|
+
alternatives: Record<FilePath, LanguageResult[]>;
|
|
41
|
+
};
|
|
42
|
+
languages: {
|
|
43
|
+
count: Integer;
|
|
44
|
+
bytes: Bytes;
|
|
45
|
+
lines: LinesOfCode;
|
|
46
|
+
results: Record<Language, {
|
|
47
|
+
count: Integer;
|
|
48
|
+
bytes: Bytes;
|
|
49
|
+
lines: LinesOfCode;
|
|
50
|
+
}>;
|
|
51
|
+
};
|
|
52
|
+
unknown: {
|
|
53
|
+
count: Integer;
|
|
54
|
+
bytes: Bytes;
|
|
55
|
+
lines: LinesOfCode;
|
|
56
|
+
extensions: Record<string, Bytes>;
|
|
57
|
+
filenames: Record<string, Bytes>;
|
|
58
|
+
};
|
|
59
|
+
repository: Record<Language, {
|
|
60
|
+
type: Category;
|
|
61
|
+
parent?: Language;
|
|
62
|
+
color?: `#${string}`;
|
|
63
|
+
}>;
|
|
64
|
+
}
|
|
65
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Category, Language } from './types.js';
|
|
2
|
+
export interface LanguagesScema {
|
|
3
|
+
[name: string]: {
|
|
4
|
+
language_id: number;
|
|
5
|
+
fs_name?: Language;
|
|
6
|
+
type: Category;
|
|
7
|
+
group?: Language;
|
|
8
|
+
color?: `#${string}`;
|
|
9
|
+
aliases?: string[];
|
|
10
|
+
extensions?: `.${string}`[];
|
|
11
|
+
filenames?: string[];
|
|
12
|
+
interpreters?: string[];
|
|
13
|
+
tm_scope?: `${'source' | 'text'}.${string}`;
|
|
14
|
+
ace_mode?: string;
|
|
15
|
+
codemirror_mode?: string;
|
|
16
|
+
codemirror_mime_type?: `${string}/${string}`;
|
|
17
|
+
wrap?: boolean;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
interface HeuristicsRules {
|
|
21
|
+
pattern?: string;
|
|
22
|
+
named_pattern?: string;
|
|
23
|
+
named_patterns?: string[];
|
|
24
|
+
negative_pattern?: string;
|
|
25
|
+
}
|
|
26
|
+
export interface HeuristicsSchema {
|
|
27
|
+
disambiguations: Array<{
|
|
28
|
+
extensions: string[];
|
|
29
|
+
rules: Array<HeuristicsRules & {
|
|
30
|
+
language: string | string[];
|
|
31
|
+
and?: HeuristicsRules[];
|
|
32
|
+
}>;
|
|
33
|
+
}>;
|
|
34
|
+
named_patterns: Record<string, string | string[]>;
|
|
35
|
+
}
|
|
36
|
+
export type VendorSchema = string[];
|
|
37
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import type { LanguagesScema } from './schema.js';
|
|
2
|
+
export type LanguageResult = string | null;
|
|
3
|
+
export type Language = string;
|
|
4
|
+
export type Category = 'data' | 'markup' | 'programming' | 'prose';
|
|
5
|
+
export type FilePath = string;
|
|
6
|
+
export type Bytes = Integer;
|
|
7
|
+
export type Integer = number;
|
|
8
|
+
export type LanguageMetadata = LanguagesScema[string];
|
|
9
|
+
export type RelFile = string & {};
|
|
10
|
+
export type AbsFile = string & {};
|
|
11
|
+
export type AbsFolder = string & {};
|
|
12
|
+
export type FileGlob = string & {};
|
|
13
|
+
export interface Options {
|
|
14
|
+
ignoredFiles?: string[];
|
|
15
|
+
ignoredLanguages?: Language[];
|
|
16
|
+
categories?: Category[];
|
|
17
|
+
keepVendored?: boolean;
|
|
18
|
+
keepBinary?: boolean;
|
|
19
|
+
relativePaths?: boolean;
|
|
20
|
+
childLanguages?: boolean;
|
|
21
|
+
quick?: boolean;
|
|
22
|
+
offline?: boolean;
|
|
23
|
+
calculateLines?: boolean;
|
|
24
|
+
checkIgnored?: boolean;
|
|
25
|
+
checkDetected?: boolean;
|
|
26
|
+
checkAttributes?: boolean;
|
|
27
|
+
checkHeuristics?: boolean;
|
|
28
|
+
checkShebang?: boolean;
|
|
29
|
+
checkModeline?: boolean;
|
|
30
|
+
}
|
|
31
|
+
export interface VirtualFile {
|
|
32
|
+
path: string;
|
|
33
|
+
content?: string;
|
|
34
|
+
firstLine?: string;
|
|
35
|
+
size?: number;
|
|
36
|
+
extension?: string;
|
|
37
|
+
isBinary?: boolean;
|
|
38
|
+
metadata?: {
|
|
39
|
+
vendored?: boolean;
|
|
40
|
+
generated?: boolean;
|
|
41
|
+
documentation?: boolean;
|
|
42
|
+
};
|
|
43
|
+
attributes?: {
|
|
44
|
+
language?: LanguageResult;
|
|
45
|
+
binary?: boolean;
|
|
46
|
+
detectable?: boolean;
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
type LinesOfCode = {
|
|
50
|
+
total: Integer;
|
|
51
|
+
content: Integer;
|
|
52
|
+
};
|
|
53
|
+
export interface Results {
|
|
54
|
+
files: {
|
|
55
|
+
count: Integer;
|
|
56
|
+
bytes: Bytes;
|
|
57
|
+
lines: LinesOfCode;
|
|
58
|
+
/** Note: Results use slashes as delimiters even on Windows. */
|
|
59
|
+
results: Record<FilePath, LanguageResult>;
|
|
60
|
+
};
|
|
61
|
+
languages: {
|
|
62
|
+
count: Integer;
|
|
63
|
+
bytes: Bytes;
|
|
64
|
+
lines: LinesOfCode;
|
|
65
|
+
results: Record<Language, {
|
|
66
|
+
count: Integer;
|
|
67
|
+
bytes: Bytes;
|
|
68
|
+
lines: LinesOfCode;
|
|
69
|
+
}>;
|
|
70
|
+
};
|
|
71
|
+
unknown: {
|
|
72
|
+
count: Integer;
|
|
73
|
+
bytes: Bytes;
|
|
74
|
+
lines: LinesOfCode;
|
|
75
|
+
extensions: Record<string, Bytes>;
|
|
76
|
+
filenames: Record<string, Bytes>;
|
|
77
|
+
};
|
|
78
|
+
repository: Record<Language, {
|
|
79
|
+
type: Category;
|
|
80
|
+
parent?: Language;
|
|
81
|
+
color?: `#${string}`;
|
|
82
|
+
}>;
|
|
83
|
+
}
|
|
84
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/ext/generated.rb
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
- node_modules\/
|
|
7
7
|
- vendor\/((?!-)[-0-9A-Za-z]+(?<!-)\.)+(com|edu|gov|in|me|net|org|fm|io)
|
|
8
8
|
- (Gopkg|glide)\.lock
|
|
9
|
+
- Package\.resolved
|
|
9
10
|
- poetry\.lock
|
|
10
11
|
- pdm\.lock
|
|
11
12
|
- uv\.lock
|
|
@@ -15,6 +16,7 @@
|
|
|
15
16
|
- npm-shrinkwrap\.json
|
|
16
17
|
- package-lock\.json
|
|
17
18
|
- pnpm-lock\.yaml
|
|
19
|
+
- (?:^|\/)bun\.lockb?$
|
|
18
20
|
- (^|\/)\.pnp\..*$
|
|
19
21
|
- Godeps\/
|
|
20
22
|
- composer\.lock
|
|
@@ -23,6 +25,10 @@
|
|
|
23
25
|
- Cargo\.toml\.orig
|
|
24
26
|
- (^|\/)flake\.lock$
|
|
25
27
|
- (^|\/)MODULE\.bazel\.lock$
|
|
28
|
+
- (?:^|\/)gradlew(?:\.bat)?$
|
|
29
|
+
- (?:^|\/)mvnw(?:\.cmd)?$
|
|
30
|
+
- (?:^|\/)mise(?:\.[^\/]+)?\.lock$
|
|
31
|
+
- (?:^|\/)(Julia)?Manifest(-v\d+\.\d+)?\.toml$
|
|
26
32
|
- Pipfile\.lock
|
|
27
33
|
- (?:^|\/)\.terraform\.lock\.hcl$
|
|
28
34
|
- ppport\.h$
|