linguist-js 2.5.3 → 2.5.5
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/cli.d.ts +1 -1
- package/dist/cli.js +107 -107
- package/dist/helpers/convert-pcre.js +38 -37
- package/dist/helpers/load-data.js +30 -30
- package/dist/helpers/read-file.js +23 -23
- package/dist/helpers/walk-tree.js +64 -64
- package/dist/index.d.ts +4 -4
- package/dist/index.js +375 -375
- package/dist/schema.d.ts +37 -37
- package/dist/schema.js +2 -2
- package/dist/types.d.ts +47 -47
- package/dist/types.js +2 -2
- package/ext/documentation.yml +5 -1
- package/ext/generated.rb +64 -16
- package/ext/heuristics.yml +128 -70
- package/ext/languages.yml +481 -28
- package/ext/vendor.yml +6 -3
- package/package.json +11 -11
- package/readme.md +3 -2
package/dist/schema.d.ts
CHANGED
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
import { Category, Language } from './types';
|
|
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
|
|
37
|
-
export {};
|
|
1
|
+
import { Category, Language } from './types';
|
|
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 {};
|
package/dist/schema.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
package/dist/types.d.ts
CHANGED
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
export
|
|
7
|
-
export interface Options {
|
|
8
|
-
fileContent?: string | string[];
|
|
9
|
-
ignoredFiles?: string[];
|
|
10
|
-
ignoredLanguages?: Language[];
|
|
11
|
-
categories?: Category[];
|
|
12
|
-
keepVendored?: boolean;
|
|
13
|
-
keepBinary?: boolean;
|
|
14
|
-
relativePaths?: boolean;
|
|
15
|
-
childLanguages?: boolean;
|
|
16
|
-
quick?: boolean;
|
|
17
|
-
offline?: boolean;
|
|
18
|
-
checkIgnored?: boolean;
|
|
19
|
-
checkAttributes?: boolean;
|
|
20
|
-
checkHeuristics?: boolean;
|
|
21
|
-
checkShebang?: boolean;
|
|
22
|
-
checkModeline?: boolean;
|
|
23
|
-
}
|
|
24
|
-
export interface Results {
|
|
25
|
-
files: {
|
|
26
|
-
count: Integer;
|
|
27
|
-
bytes: Bytes;
|
|
28
|
-
/** Note: Results use slashes as delimiters even on Windows. */
|
|
29
|
-
results: Record<FilePath, LanguageResult>;
|
|
30
|
-
};
|
|
31
|
-
languages: {
|
|
32
|
-
count: Integer;
|
|
33
|
-
bytes: Bytes;
|
|
34
|
-
results: Record<Language, {
|
|
35
|
-
bytes: Bytes;
|
|
36
|
-
type: Category;
|
|
37
|
-
parent?: Language;
|
|
38
|
-
color?: `#${string}`;
|
|
39
|
-
}>;
|
|
40
|
-
};
|
|
41
|
-
unknown: {
|
|
42
|
-
count: Integer;
|
|
43
|
-
bytes: Bytes;
|
|
44
|
-
extensions: Record<string, Bytes>;
|
|
45
|
-
filenames: Record<string, Bytes>;
|
|
46
|
-
};
|
|
47
|
-
}
|
|
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 interface Options {
|
|
8
|
+
fileContent?: string | string[];
|
|
9
|
+
ignoredFiles?: string[];
|
|
10
|
+
ignoredLanguages?: Language[];
|
|
11
|
+
categories?: Category[];
|
|
12
|
+
keepVendored?: boolean;
|
|
13
|
+
keepBinary?: boolean;
|
|
14
|
+
relativePaths?: boolean;
|
|
15
|
+
childLanguages?: boolean;
|
|
16
|
+
quick?: boolean;
|
|
17
|
+
offline?: boolean;
|
|
18
|
+
checkIgnored?: boolean;
|
|
19
|
+
checkAttributes?: boolean;
|
|
20
|
+
checkHeuristics?: boolean;
|
|
21
|
+
checkShebang?: boolean;
|
|
22
|
+
checkModeline?: boolean;
|
|
23
|
+
}
|
|
24
|
+
export interface Results {
|
|
25
|
+
files: {
|
|
26
|
+
count: Integer;
|
|
27
|
+
bytes: Bytes;
|
|
28
|
+
/** Note: Results use slashes as delimiters even on Windows. */
|
|
29
|
+
results: Record<FilePath, LanguageResult>;
|
|
30
|
+
};
|
|
31
|
+
languages: {
|
|
32
|
+
count: Integer;
|
|
33
|
+
bytes: Bytes;
|
|
34
|
+
results: Record<Language, {
|
|
35
|
+
bytes: Bytes;
|
|
36
|
+
type: Category;
|
|
37
|
+
parent?: Language;
|
|
38
|
+
color?: `#${string}`;
|
|
39
|
+
}>;
|
|
40
|
+
};
|
|
41
|
+
unknown: {
|
|
42
|
+
count: Integer;
|
|
43
|
+
bytes: Bytes;
|
|
44
|
+
extensions: Record<string, Bytes>;
|
|
45
|
+
filenames: Record<string, Bytes>;
|
|
46
|
+
};
|
|
47
|
+
}
|
package/dist/types.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
package/ext/documentation.yml
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
1
3
|
- ^[Dd]ocs?/
|
|
2
4
|
- (^|/)[Dd]ocumentation/
|
|
3
5
|
- (^|/)[Gg]roovydoc/
|
|
@@ -5,7 +7,9 @@
|
|
|
5
7
|
- ^[Mm]an/
|
|
6
8
|
- ^[Ee]xamples/
|
|
7
9
|
- ^[Dd]emos?/
|
|
8
|
-
- (^|/)inst/doc
|
|
10
|
+
- (^|/)inst/doc/
|
|
11
|
+
|
|
12
|
+
- (^|/)CITATION(\.cff|(S)?(\.(bib|md))?)$
|
|
9
13
|
- (^|/)CHANGE(S|LOG)?(\.|$)
|
|
10
14
|
- (^|/)CONTRIBUTING(\.|$)
|
|
11
15
|
- (^|/)COPYING(\.|$)
|
package/ext/generated.rb
CHANGED
|
@@ -7,7 +7,9 @@ module Linguist
|
|
|
7
7
|
@name = name
|
|
8
8
|
@extname = File.extname(name)
|
|
9
9
|
@_data = data
|
|
10
|
-
end
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
attr_reader :name, :extname
|
|
11
13
|
def data
|
|
12
14
|
@data ||= @_data.respond_to?(:call) ? @_data.call() : @_data
|
|
13
15
|
end
|
|
@@ -24,10 +26,12 @@ module Linguist
|
|
|
24
26
|
generated_net_specflow_feature_file? ||
|
|
25
27
|
composer_lock? ||
|
|
26
28
|
cargo_lock? ||
|
|
29
|
+
flake_lock? ||
|
|
27
30
|
node_modules? ||
|
|
28
31
|
go_vendor? ||
|
|
29
32
|
go_lock? ||
|
|
30
33
|
poetry_lock? ||
|
|
34
|
+
pdm_lock? ||
|
|
31
35
|
esy_lock? ||
|
|
32
36
|
npm_shrinkwrap_or_package_lock? ||
|
|
33
37
|
terraform_lock? ||
|
|
@@ -67,7 +71,8 @@ module Linguist
|
|
|
67
71
|
generated_visualstudio6? ||
|
|
68
72
|
generated_haxe? ||
|
|
69
73
|
generated_jooq? ||
|
|
70
|
-
generated_pascal_tlb?
|
|
74
|
+
generated_pascal_tlb? ||
|
|
75
|
+
generated_sorbet_rbi?
|
|
71
76
|
end
|
|
72
77
|
def xcode_file?
|
|
73
78
|
['.nib', '.xcworkspacedata', '.xcuserstate'].include?(extname)
|
|
@@ -96,7 +101,9 @@ module Linguist
|
|
|
96
101
|
lines.last(2).any? { |l| l.match(/^\/[*\/][\#@] source(?:Mapping)?URL|sourceURL=/) }
|
|
97
102
|
end
|
|
98
103
|
def source_map?
|
|
99
|
-
return false unless extname.downcase == '.map'
|
|
104
|
+
return false unless extname.downcase == '.map'
|
|
105
|
+
|
|
106
|
+
name =~ /(\.css|\.js)\.map$/i ||
|
|
100
107
|
lines[0] =~ /^{"version":\d+,/ ||
|
|
101
108
|
lines[0] =~ /^\/\*\* Begin line maps\. \*\*\/{/
|
|
102
109
|
end
|
|
@@ -104,9 +111,15 @@ module Linguist
|
|
|
104
111
|
return false unless extname == '.js'
|
|
105
112
|
if lines[0] =~ /^\/\/ Generated by /
|
|
106
113
|
return true
|
|
107
|
-
end
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
if lines[0] == '(function() {' &&
|
|
108
117
|
lines[-2] == '}).call(this);' &&
|
|
109
|
-
lines[-1] == ''
|
|
118
|
+
lines[-1] == ''
|
|
119
|
+
|
|
120
|
+
score = 0
|
|
121
|
+
|
|
122
|
+
lines.each do |line|
|
|
110
123
|
if line =~ /var /
|
|
111
124
|
score += 1 * line.gsub(/(_fn|_i|_len|_ref|_results)/).count
|
|
112
125
|
score += 3 * line.gsub(/(__bind|__extends|__hasProp|__indexOf|__slice)/).count
|
|
@@ -134,7 +147,9 @@ module Linguist
|
|
|
134
147
|
return false unless extname == '.js'
|
|
135
148
|
if lines[0..4].join('') =~ /^(?:[^\/]|\/[^\*])*\/\*(?:[^\*]|\*[^\/])*Generated by PEG.js/
|
|
136
149
|
return true
|
|
137
|
-
end
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
false
|
|
138
153
|
end
|
|
139
154
|
def generated_postscript?
|
|
140
155
|
return false unless ['.ps', '.eps', '.pfa'].include? extname
|
|
@@ -144,29 +159,45 @@ module Linguist
|
|
|
144
159
|
return true if creator =~ /[0-9]|draw|mpage|ImageMagick|inkscape|MATLAB/ ||
|
|
145
160
|
creator =~ /PCBNEW|pnmtops|\(Unknown\)|Serif Affinity|Filterimage -tops/
|
|
146
161
|
!!creator.include?("EAGLE") and lines[0..4].find {|line| line =~ /^%%Title: EAGLE Drawing /}
|
|
147
|
-
end
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
def generated_go?
|
|
148
165
|
return false unless extname == '.go'
|
|
149
|
-
return false unless lines.count > 1
|
|
166
|
+
return false unless lines.count > 1
|
|
167
|
+
|
|
168
|
+
return lines.first(40).any? { |l| l =~ %r{^// Code generated .*} }
|
|
150
169
|
end
|
|
151
170
|
def generated_protocol_buffer_from_go?
|
|
152
171
|
return false unless extname == '.proto'
|
|
153
|
-
return false unless lines.count > 1
|
|
154
|
-
|
|
172
|
+
return false unless lines.count > 1
|
|
173
|
+
|
|
174
|
+
return lines.first(20).any? { |l| l.include? "This file was autogenerated by go-to-protobuf" }
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
PROTOBUF_EXTENSIONS = ['.py', '.java', '.h', '.cc', '.cpp', '.m', '.rb', '.php']
|
|
155
178
|
def generated_protocol_buffer?
|
|
156
179
|
return false unless PROTOBUF_EXTENSIONS.include?(extname)
|
|
157
|
-
return false unless lines.count > 1
|
|
180
|
+
return false unless lines.count > 1
|
|
181
|
+
|
|
182
|
+
return lines.first(3).any? { |l| l.include?("Generated by the protocol buffer compiler. DO NOT EDIT!") }
|
|
158
183
|
end
|
|
159
184
|
def generated_javascript_protocol_buffer?
|
|
160
185
|
return false unless extname == ".js"
|
|
161
|
-
return false unless lines.count > 6
|
|
162
|
-
|
|
186
|
+
return false unless lines.count > 6
|
|
187
|
+
|
|
188
|
+
return lines[5].include?("GENERATED CODE -- DO NOT EDIT!")
|
|
189
|
+
end
|
|
190
|
+
|
|
191
|
+
APACHE_THRIFT_EXTENSIONS = ['.rb', '.py', '.go', '.js', '.m', '.java', '.h', '.cc', '.cpp', '.php']
|
|
163
192
|
def generated_apache_thrift?
|
|
164
193
|
return false unless APACHE_THRIFT_EXTENSIONS.include?(extname)
|
|
165
194
|
return lines.first(6).any? { |l| l.include?("Autogenerated by Thrift Compiler") }
|
|
166
195
|
end
|
|
167
196
|
def generated_jni_header?
|
|
168
197
|
return false unless extname == '.h'
|
|
169
|
-
return false unless lines.count > 2
|
|
198
|
+
return false unless lines.count > 2
|
|
199
|
+
|
|
200
|
+
return lines[0].include?("/* DO NOT EDIT THIS FILE - it is machine generated */") &&
|
|
170
201
|
lines[1].include?("#include <jni.h>")
|
|
171
202
|
end
|
|
172
203
|
def node_modules?
|
|
@@ -181,6 +212,9 @@ module Linguist
|
|
|
181
212
|
def poetry_lock?
|
|
182
213
|
!!name.match(/poetry\.lock/)
|
|
183
214
|
end
|
|
215
|
+
def pdm_lock?
|
|
216
|
+
!!name.match(/pdm\.lock/)
|
|
217
|
+
end
|
|
184
218
|
def esy_lock?
|
|
185
219
|
!!name.match(/(^|\/)(\w+\.)?esy.lock$/)
|
|
186
220
|
end
|
|
@@ -202,6 +236,9 @@ module Linguist
|
|
|
202
236
|
def cargo_lock?
|
|
203
237
|
!!name.match(/Cargo\.lock/)
|
|
204
238
|
end
|
|
239
|
+
def flake_lock?
|
|
240
|
+
!!name.match(/(^|\/)flake\.lock$/)
|
|
241
|
+
end
|
|
205
242
|
def vcr_cassette?
|
|
206
243
|
return false unless extname == '.yml'
|
|
207
244
|
return false unless lines.count > 2
|
|
@@ -251,7 +288,9 @@ module Linguist
|
|
|
251
288
|
end
|
|
252
289
|
def generated_roxygen2?
|
|
253
290
|
return false unless extname == '.Rd'
|
|
254
|
-
return false unless lines.count > 1
|
|
291
|
+
return false unless lines.count > 1
|
|
292
|
+
|
|
293
|
+
return lines[0].include?("% Generated by roxygen2: do not edit by hand")
|
|
255
294
|
end
|
|
256
295
|
def generated_jison?
|
|
257
296
|
return false unless extname == '.js'
|
|
@@ -292,7 +331,9 @@ module Linguist
|
|
|
292
331
|
def generated_visualstudio6?
|
|
293
332
|
return false unless extname.downcase == '.dsp'
|
|
294
333
|
lines.first(3).any? { |l| l.include? '# Microsoft Developer Studio Generated Build File' }
|
|
295
|
-
end
|
|
334
|
+
end
|
|
335
|
+
|
|
336
|
+
HAXE_EXTENSIONS = ['.js', '.py', '.lua', '.cpp', '.h', '.java', '.cs', '.php']
|
|
296
337
|
def generated_haxe?
|
|
297
338
|
return false unless HAXE_EXTENSIONS.include?(extname)
|
|
298
339
|
return lines.first(3).any? { |l| l.include?("Generated by Haxe") }
|
|
@@ -332,6 +373,13 @@ module Linguist
|
|
|
332
373
|
def generated_pascal_tlb?
|
|
333
374
|
!!name.match(/_tlb\.pas$/i)
|
|
334
375
|
end
|
|
376
|
+
def generated_sorbet_rbi?
|
|
377
|
+
return false unless extname.downcase == '.rbi'
|
|
378
|
+
return false unless lines.count >= 5
|
|
379
|
+
lines[0].match?(/^# typed:/) &&
|
|
380
|
+
lines[2].include?("DO NOT EDIT MANUALLY") &&
|
|
381
|
+
lines[4].match?(/^# Please.*run.*`.*tapioca/)
|
|
382
|
+
end
|
|
335
383
|
def extract_html_meta(match)
|
|
336
384
|
(match.last.sub(/\/\Z/, "").strip.scan(/
|
|
337
385
|
(?<=^|\s)
|