linguist-js 2.5.0 → 2.5.1

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.
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const promises_1 = __importDefault(require("fs/promises"));
6
+ const fs_1 = __importDefault(require("fs"));
7
7
  const path_1 = __importDefault(require("path"));
8
8
  const cross_fetch_1 = __importDefault(require("cross-fetch"));
9
9
  const node_cache_1 = __importDefault(require("node-cache"));
@@ -21,7 +21,7 @@ async function loadWebFile(file) {
21
21
  }
22
22
  async function loadLocalFile(file) {
23
23
  const filePath = path_1.default.resolve(__dirname, '../../ext', file);
24
- return promises_1.default.readFile(filePath).then(buffer => buffer.toString());
24
+ return fs_1.default.promises.readFile(filePath).then(buffer => buffer.toString());
25
25
  }
26
26
  /** Load a data file from github-linguist. */
27
27
  async function loadFile(file, offline = false) {
package/dist/index.js CHANGED
@@ -14,8 +14,8 @@ const load_data_1 = __importDefault(require("./helpers/load-data"));
14
14
  const read_file_1 = __importDefault(require("./helpers/read-file"));
15
15
  const convert_pcre_1 = __importDefault(require("./helpers/convert-pcre"));
16
16
  async function analyse(input, opts = {}) {
17
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
18
- var _t, _u, _v;
17
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
18
+ var _u, _v, _w;
19
19
  const useRawContent = opts.fileContent !== undefined;
20
20
  input = [input !== null && input !== void 0 ? input : []].flat();
21
21
  opts.fileContent = [(_a = opts.fileContent) !== null && _a !== void 0 ? _a : []].flat();
@@ -269,8 +269,16 @@ async function analyse(input, opts = {}) {
269
269
  normalise(heuristic.pattern);
270
270
  if (heuristic.named_pattern)
271
271
  normalise(heuristicsData.named_patterns[heuristic.named_pattern]);
272
+ if (heuristic.and) {
273
+ for (const data of heuristic.and) {
274
+ if (data.pattern)
275
+ normalise(data.pattern);
276
+ if (data.named_pattern)
277
+ normalise(heuristicsData.named_patterns[data.named_pattern]);
278
+ }
279
+ }
272
280
  // Check file contents and apply heuristic patterns
273
- const fileContent = opts.fileContent ? opts.fileContent[files.indexOf(file)] : await (0, read_file_1.default)(file).catch(() => null);
281
+ const fileContent = ((_l = opts.fileContent) === null || _l === void 0 ? void 0 : _l.length) ? opts.fileContent[files.indexOf(file)] : await (0, read_file_1.default)(file).catch(() => null);
274
282
  if (fileContent === null)
275
283
  continue;
276
284
  if (!patterns.length || patterns.some(pattern => (0, convert_pcre_1.default)(pattern).test(fileContent))) {
@@ -280,10 +288,10 @@ async function analyse(input, opts = {}) {
280
288
  }
281
289
  }
282
290
  // If no heuristics, assign a language
283
- (_l = (_t = results.files.results)[file]) !== null && _l !== void 0 ? _l : (_t[file] = fileAssociations[file][0]);
291
+ (_m = (_u = results.files.results)[file]) !== null && _m !== void 0 ? _m : (_u[file] = fileAssociations[file][0]);
284
292
  }
285
293
  // Skip specified categories
286
- if ((_m = opts.categories) === null || _m === void 0 ? void 0 : _m.length) {
294
+ if ((_o = opts.categories) === null || _o === void 0 ? void 0 : _o.length) {
287
295
  const categories = ['data', 'markup', 'programming', 'prose'];
288
296
  const hiddenCategories = categories.filter(cat => !opts.categories.includes(cat));
289
297
  for (const [file, lang] of Object.entries(results.files.results)) {
@@ -319,21 +327,21 @@ async function analyse(input, opts = {}) {
319
327
  for (const [file, lang] of Object.entries(results.files.results)) {
320
328
  if (lang && !langData[lang])
321
329
  continue;
322
- const fileSize = (_q = (_p = (_o = opts.fileContent) === null || _o === void 0 ? void 0 : _o[files.indexOf(file)]) === null || _p === void 0 ? void 0 : _p.length) !== null && _q !== void 0 ? _q : fs_1.default.statSync(file).size;
330
+ const fileSize = (_r = (_q = (_p = opts.fileContent) === null || _p === void 0 ? void 0 : _p[files.indexOf(file)]) === null || _q === void 0 ? void 0 : _q.length) !== null && _r !== void 0 ? _r : fs_1.default.statSync(file).size;
323
331
  results.files.bytes += fileSize;
324
332
  // If no language found, add extension in other section
325
333
  if (!lang) {
326
334
  const ext = path_1.default.extname(file);
327
335
  const unknownType = ext === '' ? 'filenames' : 'extensions';
328
336
  const name = ext === '' ? path_1.default.basename(file) : ext;
329
- (_r = (_u = results.unknown[unknownType])[name]) !== null && _r !== void 0 ? _r : (_u[name] = 0);
337
+ (_s = (_v = results.unknown[unknownType])[name]) !== null && _s !== void 0 ? _s : (_v[name] = 0);
330
338
  results.unknown[unknownType][name] += fileSize;
331
339
  results.unknown.bytes += fileSize;
332
340
  continue;
333
341
  }
334
342
  // Add language and bytes data to corresponding section
335
343
  const { type } = langData[lang];
336
- (_s = (_v = results.languages.results)[lang]) !== null && _s !== void 0 ? _s : (_v[lang] = { type, bytes: 0, color: langData[lang].color });
344
+ (_t = (_w = results.languages.results)[lang]) !== null && _t !== void 0 ? _t : (_w[lang] = { type, bytes: 0, color: langData[lang].color });
337
345
  if (opts.childLanguages) {
338
346
  results.languages.results[lang].parent = langData[lang].group;
339
347
  }
@@ -65,10 +65,22 @@ disambiguations:
65
65
  pattern: '(<^\s*; |End Function)'
66
66
  - language: BitBake
67
67
  pattern: '^\s*(# |include|require)\b'
68
+ - language: Clojure
69
+ pattern: '\((def|defn|defmacro|let)\s'
68
70
  - extensions: ['.bi']
69
71
  rules:
70
72
  - language: FreeBasic
71
73
  pattern: '^[ \t]*#(?:define|endif|endmacro|ifn?def|if|include|lang|macro)\s'
74
+ - extensions: ['.bs']
75
+ rules:
76
+ - language: Bikeshed
77
+ pattern: '^(?i:<pre\s+class)\s*=\s*(''|\"|\b)metadata\b\1[^>\r\n]*>'
78
+ - language: BrighterScript
79
+ pattern:
80
+ - (?i:^\s*(?=^sub\s)(?:sub\s*\w+\(.*?\))|(?::\s*sub\(.*?\))$)
81
+ - (?i:^\s*(end\ssub)$)
82
+ - (?i:^\s*(?=^function\s)(?:function\s*\w+\(.*?\)\s*as\s*\w*)|(?::\s*function\(.*?\)\s*as\s*\w*)$)
83
+ - (?i:^\s*(end\sfunction)$)
72
84
  - extensions: ['.builds']
73
85
  rules:
74
86
  - language: XML
@@ -552,6 +564,15 @@ disambiguations:
552
564
  pattern: '\$\w+[($]|(.)!\s*.+?\s*!\1|<!\s*.+?\s*!>|\[!\s*.+?\s*!\]|\{!\s*.+?\s*!\}'
553
565
  - language: Smalltalk
554
566
  pattern: '\A\s*[\[{(^"''\w#]|[a-zA-Z_]\w*\s*:=\s*[a-zA-Z_]\w*|class\s*>>\s*[a-zA-Z_]\w*|^[a-zA-Z_]\w*\s+[a-zA-Z_]\w*:|^Class\s*{|if(?:True|False):\s*\['
567
+ - extensions: ['.star']
568
+ rules:
569
+ - language: STAR
570
+ pattern: '^loop_\s*$'
571
+ - language: Starlark
572
+ - extensions: ['.stl']
573
+ rules:
574
+ - language: STL
575
+ pattern: '\A\s*solid(?=$|\s)(?m:.*?)\Rendsolid(?:$|\s)'
555
576
  - extensions: ['.t']
556
577
  rules:
557
578
  - language: Perl
package/ext/languages.yml CHANGED
@@ -270,6 +270,16 @@ Ant Build System:
270
270
  codemirror_mode: xml
271
271
  codemirror_mime_type: application/xml
272
272
  language_id: 15
273
+ Antlers:
274
+ type: markup
275
+ color: "#ff269e"
276
+ extensions:
277
+ - ".antlers.html"
278
+ - ".antlers.php"
279
+ - ".antlers.xml"
280
+ tm_scope: text.html.statamic
281
+ ace_mode: text
282
+ language_id: 1067292663
273
283
  ApacheConf:
274
284
  type: data
275
285
  color: "#d12127"
@@ -515,6 +525,16 @@ Bicep:
515
525
  tm_scope: source.bicep
516
526
  ace_mode: text
517
527
  language_id: 321200902
528
+ Bikeshed:
529
+ type: markup
530
+ color: "#5562ac"
531
+ extensions:
532
+ - ".bs"
533
+ tm_scope: source.csswg
534
+ ace_mode: html
535
+ codemirror_mode: htmlmixed
536
+ codemirror_mime_type: text/html
537
+ language_id: 1055528081
518
538
  Bison:
519
539
  type: programming
520
540
  color: "#6A463F"
@@ -602,12 +622,20 @@ Brainfuck:
602
622
  codemirror_mode: brainfuck
603
623
  codemirror_mime_type: text/x-brainfuck
604
624
  language_id: 38
625
+ BrighterScript:
626
+ type: programming
627
+ color: "#66AABB"
628
+ extensions:
629
+ - ".bs"
630
+ tm_scope: source.brs
631
+ ace_mode: text
632
+ language_id: 943571030
605
633
  Brightscript:
606
634
  type: programming
607
635
  color: "#662D91"
608
636
  extensions:
609
637
  - ".brs"
610
- tm_scope: source.brightscript
638
+ tm_scope: source.brs
611
639
  ace_mode: text
612
640
  language_id: 39
613
641
  Browserslist:
@@ -699,6 +727,16 @@ C2hs Haskell:
699
727
  codemirror_mode: haskell
700
728
  codemirror_mime_type: text/x-haskell
701
729
  language_id: 45
730
+ CAP CDS:
731
+ type: programming
732
+ tm_scope: source.cds
733
+ color: "#0092d1"
734
+ aliases:
735
+ - cds
736
+ extensions:
737
+ - ".cds"
738
+ ace_mode: text
739
+ language_id: 390788699
702
740
  CIL:
703
741
  type: data
704
742
  tm_scope: source.cil
@@ -885,6 +923,39 @@ Charity:
885
923
  tm_scope: none
886
924
  ace_mode: text
887
925
  language_id: 56
926
+ Checksums:
927
+ type: data
928
+ tm_scope: text.checksums
929
+ aliases:
930
+ - checksum
931
+ - hash
932
+ - hashes
933
+ - sum
934
+ - sums
935
+ filenames:
936
+ - MD5SUMS
937
+ - SHA1SUMS
938
+ - SHA256SUMS
939
+ - SHA256SUMS.txt
940
+ - SHA512SUMS
941
+ - checksums.txt
942
+ - cksums
943
+ - md5sum.txt
944
+ extensions:
945
+ - ".crc32"
946
+ - ".md2"
947
+ - ".md4"
948
+ - ".md5"
949
+ - ".sha1"
950
+ - ".sha2"
951
+ - ".sha224"
952
+ - ".sha256"
953
+ - ".sha256sum"
954
+ - ".sha3"
955
+ - ".sha384"
956
+ - ".sha512"
957
+ ace_mode: text
958
+ language_id: 372063053
888
959
  ChucK:
889
960
  type: programming
890
961
  color: "#3f8000"
@@ -955,6 +1026,7 @@ Clojure:
955
1026
  color: "#db5855"
956
1027
  extensions:
957
1028
  - ".clj"
1029
+ - ".bb"
958
1030
  - ".boot"
959
1031
  - ".cl2"
960
1032
  - ".cljc"
@@ -965,6 +1037,8 @@ Clojure:
965
1037
  - ".hic"
966
1038
  filenames:
967
1039
  - riemann.config
1040
+ interpreters:
1041
+ - bb
968
1042
  language_id: 62
969
1043
  Closure Templates:
970
1044
  type: markup
@@ -1685,6 +1759,7 @@ F*:
1685
1759
  - fstar
1686
1760
  extensions:
1687
1761
  - ".fst"
1762
+ - ".fsti"
1688
1763
  tm_scope: source.fstar
1689
1764
  ace_mode: text
1690
1765
  language_id: 336943375
@@ -2158,6 +2233,16 @@ Git Config:
2158
2233
  codemirror_mime_type: text/x-properties
2159
2234
  tm_scope: source.gitconfig
2160
2235
  language_id: 807968997
2236
+ Git Revision List:
2237
+ type: data
2238
+ color: "#F44D27"
2239
+ aliases:
2240
+ - Git Blame Ignore Revs
2241
+ filenames:
2242
+ - ".git-blame-ignore-revs"
2243
+ tm_scope: source.git-revlist
2244
+ ace_mode: text
2245
+ language_id: 461881235
2161
2246
  Gleam:
2162
2247
  type: programming
2163
2248
  color: "#ffaff3"
@@ -2626,8 +2711,11 @@ INI:
2626
2711
  - ".properties"
2627
2712
  - ".url"
2628
2713
  filenames:
2714
+ - ".coveragerc"
2629
2715
  - ".flake8"
2716
+ - ".pylintrc"
2630
2717
  - buildozer.spec
2718
+ - pylintrc
2631
2719
  tm_scope: source.ini
2632
2720
  aliases:
2633
2721
  - dosini
@@ -2794,8 +2882,14 @@ JSON:
2794
2882
  ace_mode: json
2795
2883
  codemirror_mode: javascript
2796
2884
  codemirror_mime_type: application/json
2885
+ aliases:
2886
+ - geojson
2887
+ - jsonl
2888
+ - topojson
2797
2889
  extensions:
2798
2890
  - ".json"
2891
+ - ".4DForm"
2892
+ - ".4DProject"
2799
2893
  - ".avsc"
2800
2894
  - ".geojson"
2801
2895
  - ".gltf"
@@ -3020,6 +3114,20 @@ Jest Snapshot:
3020
3114
  codemirror_mode: javascript
3021
3115
  codemirror_mime_type: application/javascript
3022
3116
  language_id: 774635084
3117
+ JetBrains MPS:
3118
+ type: programming
3119
+ aliases:
3120
+ - mps
3121
+ color: "#21D789"
3122
+ extensions:
3123
+ - ".mps"
3124
+ - ".mpl"
3125
+ - ".msd"
3126
+ ace_mode: xml
3127
+ codemirror_mode: xml
3128
+ codemirror_mime_type: text/xml
3129
+ tm_scope: none
3130
+ language_id: 465165328
3023
3131
  Jinja:
3024
3132
  type: markup
3025
3133
  color: "#a52a22"
@@ -3164,6 +3272,7 @@ KiCad Schematic:
3164
3272
  aliases:
3165
3273
  - eeschema schematic
3166
3274
  extensions:
3275
+ - ".kicad_sch"
3167
3276
  - ".sch"
3168
3277
  tm_scope: source.pcb.schematic
3169
3278
  ace_mode: text
@@ -3653,6 +3762,7 @@ Markdown:
3653
3762
  wrap: true
3654
3763
  extensions:
3655
3764
  - ".md"
3765
+ - ".livemd"
3656
3766
  - ".markdown"
3657
3767
  - ".mdown"
3658
3768
  - ".mdwn"
@@ -4712,6 +4822,14 @@ Pony:
4712
4822
  tm_scope: source.pony
4713
4823
  ace_mode: text
4714
4824
  language_id: 290
4825
+ Portugol:
4826
+ type: programming
4827
+ color: "#f8bd00"
4828
+ extensions:
4829
+ - ".por"
4830
+ tm_scope: source.portugol
4831
+ ace_mode: text
4832
+ language_id: 832391833
4715
4833
  PostCSS:
4716
4834
  type: markup
4717
4835
  color: "#dc3a0c"
@@ -5667,6 +5785,24 @@ SSH Config:
5667
5785
  ace_mode: text
5668
5786
  tm_scope: source.ssh-config
5669
5787
  language_id: 554920715
5788
+ STAR:
5789
+ type: data
5790
+ extensions:
5791
+ - ".star"
5792
+ tm_scope: source.star
5793
+ ace_mode: text
5794
+ language_id: 424510560
5795
+ STL:
5796
+ type: data
5797
+ color: "#373b5e"
5798
+ aliases:
5799
+ - ascii stl
5800
+ - stla
5801
+ extensions:
5802
+ - ".stl"
5803
+ tm_scope: source.stl
5804
+ ace_mode: text
5805
+ language_id: 455361735
5670
5806
  STON:
5671
5807
  type: data
5672
5808
  group: Smalltalk
@@ -6061,6 +6197,7 @@ Starlark:
6061
6197
  color: "#76d275"
6062
6198
  extensions:
6063
6199
  - ".bzl"
6200
+ - ".star"
6064
6201
  filenames:
6065
6202
  - BUCK
6066
6203
  - BUILD
@@ -6216,7 +6353,7 @@ TSV:
6216
6353
  language_id: 1035892117
6217
6354
  TSX:
6218
6355
  type: programming
6219
- color: "#2b7489"
6356
+ color: "#3178c6"
6220
6357
  group: TypeScript
6221
6358
  extensions:
6222
6359
  - ".tsx"
@@ -6442,7 +6579,7 @@ Type Language:
6442
6579
  language_id: 632765617
6443
6580
  TypeScript:
6444
6581
  type: programming
6445
- color: "#2b7489"
6582
+ color: "#3178c6"
6446
6583
  aliases:
6447
6584
  - ts
6448
6585
  interpreters:
@@ -6450,6 +6587,8 @@ TypeScript:
6450
6587
  - ts-node
6451
6588
  extensions:
6452
6589
  - ".ts"
6590
+ - ".cts"
6591
+ - ".mts"
6453
6592
  tm_scope: source.ts
6454
6593
  ace_mode: typescript
6455
6594
  codemirror_mode: javascript
@@ -6488,6 +6627,10 @@ Unix Assembly:
6488
6627
  extensions:
6489
6628
  - ".s"
6490
6629
  - ".ms"
6630
+ aliases:
6631
+ - gas
6632
+ - gnu asm
6633
+ - unix asm
6491
6634
  tm_scope: source.x86
6492
6635
  ace_mode: assembly_x86
6493
6636
  language_id: 120
@@ -6759,9 +6902,11 @@ WebIDL:
6759
6902
  WebVTT:
6760
6903
  type: data
6761
6904
  wrap: true
6905
+ aliases:
6906
+ - vtt
6762
6907
  extensions:
6763
6908
  - ".vtt"
6764
- tm_scope: source.vtt
6909
+ tm_scope: text.vtt
6765
6910
  ace_mode: text
6766
6911
  language_id: 658679714
6767
6912
  Wget Config:
@@ -6774,6 +6919,14 @@ Wget Config:
6774
6919
  tm_scope: source.wgetrc
6775
6920
  ace_mode: text
6776
6921
  language_id: 668457123
6922
+ Whiley:
6923
+ type: programming
6924
+ color: "#d5c397"
6925
+ extensions:
6926
+ - ".whiley"
6927
+ tm_scope: source.whiley
6928
+ ace_mode: text
6929
+ language_id: 888779559
6777
6930
  Wikitext:
6778
6931
  type: prose
6779
6932
  color: "#fc5757"
package/ext/vendor.yml CHANGED
@@ -163,3 +163,4 @@
163
163
  - (^|/)\.google_apis/
164
164
  - (^|/)Jenkinsfile$
165
165
  - (^|/)\.gitpod\.Dockerfile$
166
+ - (^|/)\.github/
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "linguist-js",
3
- "version": "2.5.0",
3
+ "version": "2.5.1",
4
4
  "description": "Analyse languages used in a folder. Powered by GitHub Linguist, although it doesn't need to be installed.",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
@@ -40,7 +40,7 @@
40
40
  "homepage": "https://github.com/Nixinova/Linguist#readme",
41
41
  "dependencies": {
42
42
  "binary-extensions": "^2.2.0",
43
- "commander": "^9.2.0",
43
+ "commander": "^9.3.0",
44
44
  "common-path-prefix": "^3.0.0",
45
45
  "cross-fetch": "^3.1.5",
46
46
  "ignore": "^5.2.0",
@@ -49,10 +49,9 @@
49
49
  "node-cache": "^5.1.2"
50
50
  },
51
51
  "devDependencies": {
52
- "@types/glob-to-regexp": "ts4.6",
53
- "@types/js-yaml": "ts4.6",
54
- "@types/node": "ts4.6",
52
+ "@types/js-yaml": "^4.0.5",
53
+ "@types/node": "ts4.7",
55
54
  "deep-object-diff": "^1.1.7",
56
- "typescript": "~4.6.4"
55
+ "typescript": "~4.7.4"
57
56
  }
58
57
  }
package/readme.md CHANGED
@@ -77,7 +77,6 @@ Running LinguistJS on this folder will return the following JSON:
77
77
  ### Notes
78
78
 
79
79
  - File paths in the output use only forward slashes as delimiters, even on Windows.
80
- - This tool does not work when offline.
81
80
  - Do not rely on any language classification output from LinguistJS being unchanged between runs.
82
81
  Language data is fetched each run from the latest classifications of [`github-linguist`](https://github.com/github/linguist).
83
82
  This data is subject to change at any time and may change the results of a run even when using the same version of Linguist.