linguist-js 2.9.0 → 2.9.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.
Files changed (38) hide show
  1. package/dist/cli.js +7 -0
  2. package/dist/helpers/convert-pcre.js +1 -1
  3. package/dist/helpers/load-data.js +2 -3
  4. package/dist/helpers/parse-gitattributes.js +1 -1
  5. package/dist/helpers/parse-gitignore.js +1 -1
  6. package/dist/helpers/read-file.js +1 -1
  7. package/dist/helpers/walk-tree.js +1 -1
  8. package/dist/index.js +1 -1
  9. package/ext/generated.rb +1 -1
  10. package/ext/heuristics.yml +45 -14
  11. package/ext/languages.yml +42 -3
  12. package/license.md +1 -1
  13. package/package.json +2 -2
  14. package/dist/package.json +0 -56
  15. package/dist/src/cli.d.ts +0 -1
  16. package/dist/src/cli.js +0 -146
  17. package/dist/src/helpers/convert-pcre.d.ts +0 -2
  18. package/dist/src/helpers/convert-pcre.js +0 -38
  19. package/dist/src/helpers/load-data.d.ts +0 -4
  20. package/dist/src/helpers/load-data.js +0 -37
  21. package/dist/src/helpers/norm-path.d.ts +0 -2
  22. package/dist/src/helpers/norm-path.js +0 -15
  23. package/dist/src/helpers/parse-gitattributes.d.ts +0 -17
  24. package/dist/src/helpers/parse-gitattributes.js +0 -37
  25. package/dist/src/helpers/parse-gitignore.d.ts +0 -1
  26. package/dist/src/helpers/parse-gitignore.js +0 -12
  27. package/dist/src/helpers/read-file.d.ts +0 -5
  28. package/dist/src/helpers/read-file.js +0 -23
  29. package/dist/src/helpers/walk-tree.d.ts +0 -20
  30. package/dist/src/helpers/walk-tree.js +0 -85
  31. package/dist/src/index.d.ts +0 -4
  32. package/dist/src/index.js +0 -485
  33. package/dist/src/schema.d.ts +0 -37
  34. package/dist/src/schema.js +0 -2
  35. package/dist/src/types.d.ts +0 -74
  36. package/dist/src/types.js +0 -2
  37. package/dist/version.d.ts +0 -2
  38. package/dist/version.js +0 -4
package/dist/cli.js CHANGED
@@ -57,6 +57,13 @@ for (const arg in args) {
57
57
  // Run Linguist
58
58
  if (args.analyze)
59
59
  (async () => {
60
+ var _a;
61
+ // Check arguments
62
+ const validCategories = ['data', 'programming', 'prose', 'markup'];
63
+ if ((_a = args.categories) === null || _a === void 0 ? void 0 : _a.some((category) => !validCategories.includes(category))) {
64
+ console.log(`Error: '${args.categories.join(', ')}' contains an invalid category. Valid options: ${validCategories.join(', ')}.`);
65
+ return;
66
+ }
60
67
  // Fetch language data
61
68
  const root = args.analyze === true ? '.' : args.analyze;
62
69
  const data = await (0, index_1.default)(root, args);
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = pcre;
3
4
  /** Convert a PCRE regex into JS. */
4
5
  function pcre(regex) {
5
6
  let finalRegex = regex;
@@ -35,4 +36,3 @@ function pcre(regex) {
35
36
  // Return final regex
36
37
  return RegExp(finalRegex, [...finalFlags].join(''));
37
38
  }
38
- exports.default = pcre;
@@ -3,7 +3,8 @@ 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
- exports.parseGeneratedDataFile = void 0;
6
+ exports.parseGeneratedDataFile = parseGeneratedDataFile;
7
+ exports.default = loadFile;
7
8
  const fs_1 = __importDefault(require("fs"));
8
9
  const path_1 = __importDefault(require("path"));
9
10
  const cross_fetch_1 = __importDefault(require("cross-fetch"));
@@ -30,9 +31,7 @@ function parseGeneratedDataFile(fileContent) {
30
31
  var _a;
31
32
  return [...(_a = fileContent.match(/(?<=name\.match\(\/).+?(?=(?<!\\)\/)/gm)) !== null && _a !== void 0 ? _a : []];
32
33
  }
33
- exports.parseGeneratedDataFile = parseGeneratedDataFile;
34
34
  /** Load a data file from github-linguist. */
35
35
  function loadFile(file, offline = false) {
36
36
  return offline ? loadLocalFile(file) : loadWebFile(file);
37
37
  }
38
- exports.default = loadFile;
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = parseAttributes;
3
4
  const norm_path_1 = require("./norm-path");
4
5
  /**
5
6
  * Parses a gitattributes file.
@@ -34,4 +35,3 @@ function parseAttributes(content, folderRoot = '.') {
34
35
  }
35
36
  return output;
36
37
  }
37
- exports.default = parseAttributes;
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = parseGitignore;
3
4
  function parseGitignore(content) {
4
5
  const readableData = content
5
6
  // Remove comments unless escaped
@@ -9,4 +10,3 @@ function parseGitignore(content) {
9
10
  const arrayData = readableData.split(/\r?\n/).filter(data => data);
10
11
  return arrayData;
11
12
  }
12
- exports.default = parseGitignore;
@@ -3,6 +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
+ exports.default = readFileChunk;
6
7
  const fs_1 = __importDefault(require("fs"));
7
8
  /**
8
9
  * Read part of a file on disc.
@@ -20,4 +21,3 @@ async function readFileChunk(filename, onlyFirstLine = false) {
20
21
  }
21
22
  return content;
22
23
  }
23
- exports.default = readFileChunk;
@@ -3,6 +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
+ exports.default = walk;
6
7
  const fs_1 = __importDefault(require("fs"));
7
8
  const path_1 = __importDefault(require("path"));
8
9
  const parse_gitignore_1 = __importDefault(require("./parse-gitignore"));
@@ -87,4 +88,3 @@ function walk(data) {
87
88
  folders: [...allFolders],
88
89
  };
89
90
  }
90
- exports.default = walk;
package/dist/index.js CHANGED
@@ -46,7 +46,7 @@ async function analyse(rawPaths, opts = {}) {
46
46
  const manualFileContent = [(_a = opts.fileContent) !== null && _a !== void 0 ? _a : []].flat();
47
47
  // Normalise input option arguments
48
48
  opts = {
49
- calculateLines: (_b = opts.calculateLines) !== null && _b !== void 0 ? _b : true,
49
+ calculateLines: (_b = opts.calculateLines) !== null && _b !== void 0 ? _b : true, // default to true if unset
50
50
  checkIgnored: !opts.quick,
51
51
  checkDetected: !opts.quick,
52
52
  checkAttributes: !opts.quick,
package/ext/generated.rb CHANGED
@@ -29,4 +29,4 @@
29
29
  - __generated__\/
30
30
  - _tlb\.pas$
31
31
  - (?:^|\/)htmlcov\/
32
- - (?:^|.*\/)\.sqlx\/query-.+\.json$
32
+ - (?:^|\/)\.sqlx\/query-[a-f\d]{64}\.json$
@@ -38,7 +38,7 @@ disambiguations:
38
38
  - extensions: ['.as']
39
39
  rules:
40
40
  - language: ActionScript
41
- pattern: '^\s*(?:package(?:\s+[\w.]+)?\s+(?:\{|$)|import\s+[\w.*]+\s*;|(?=.*?(?:intrinsic|extends))(intrinsic\s+)?class\s+[\w<>.]+(?:\s+extends\s+[\w<>.]+)?|(?:(?:public|protected|private|static)\s+)*(?:(?:var|const|local)\s+\w+\s*:\s*[\w<>.]+(?:\s*=.*)?\s*;|function\s+\w+\s*\((?:\s*\w+\s*:\s*[\w<>.]+\s*(,\s*\w+\s*:\s*[\w<>.]+\s*)*)?\)))'
41
+ pattern: '^\s*(?:package(?:\s+[\w.]+)?\s+(?:\{|$)|import\s+[\w.*]+\s*;|(?:intrinsic\s+)class\s+[\w<>.]+|\s+class\s+extends\s+[\w<>.]+|(?:(?:public|protected|private|static)\s+)*(?:(?:var|const|local)\s+\w+\s*:\s*[\w<>.]+(?:\s*=.*)?\s*;|function\s+\w+\s*\((?:\s*\w+\s*:\s*[\w<>.]+\s*(,\s*\w+\s*:\s*[\w<>.]+\s*)*)?\)))'
42
42
  - extensions: ['.asc']
43
43
  rules:
44
44
  - language: Public Key
@@ -49,6 +49,8 @@ disambiguations:
49
49
  pattern: '^(\/\/.+|((import|export)\s+)?(function|int|float|char)\s+((room|repeatedly|on|game)_)?([A-Za-z]+[A-Za-z_0-9]+)\s*[;\(])'
50
50
  - extensions: ['.asm']
51
51
  rules:
52
+ - language: Assembly
53
+ pattern: '(?i)mov\s+[^\s]{2,},'
52
54
  - language: Motorola 68K Assembly
53
55
  named_pattern: m68k
54
56
  - extensions: ['.asy']
@@ -103,12 +105,12 @@ disambiguations:
103
105
  - extensions: ['.bs']
104
106
  rules:
105
107
  - language: Bikeshed
106
- pattern: '^(?i:<pre\s+class)\s*=\s*(''|\"|\b)metadata\b\1[^>\r\n]*>'
108
+ pattern: '^(?i:<pre\s+class)\s*=\s*(''|\"|\b)metadata\b(''|\"|\b)[^>\r\n]*>'
107
109
  - language: BrighterScript
108
110
  pattern:
109
- - (?i:^\s*(?=^sub\s)(?:sub\s*\w+\(.*?\))|(?::\s*sub\(.*?\))$)
111
+ - (?i:^\s*(?:sub\s*\w+\(.*?\))|(?::\s*sub\(.*?\))$)
110
112
  - (?i:^\s*(end\ssub)$)
111
- - (?i:^\s*(?=^function\s)(?:function\s*\w+\(.*?\)\s*as\s*\w*)|(?::\s*function\(.*?\)\s*as\s*\w*)$)
113
+ - (?i:^\s*(?:function\s*\w+\(.*?\)\s*as\s*\w*)|(?::\s*function\(.*?\)\s*as\s*\w*)$)
112
114
  - (?i:^\s*(end\sfunction)$)
113
115
  - language: Bluespec BH
114
116
  pattern: '^package\s+[A-Za-z_][A-Za-z0-9_'']*(?:\s*\(|\s+where)'
@@ -258,7 +260,7 @@ disambiguations:
258
260
  - extensions: ['.ftl']
259
261
  rules:
260
262
  - language: FreeMarker
261
- pattern: '^(?:<|[a-zA-Z-][a-zA-Z0-9_-]+[ \t]+\w)|\$\{\w+[^\r\n]*?\}|^[ \t]*(?:<#--.*?-->|<#([a-z]+)(?=\s|>)[^>]*>.*?</#\1>|\[#--.*?--\]|\[#([a-z]+)(?=\s|\])[^\]]*\].*?\[#\2\])'
263
+ pattern: '^(?:<|[a-zA-Z-][a-zA-Z0-9_-]+[ \t]+\w)|\$\{\w+[^\r\n]*?\}|^[ \t]*(?:<#--.*?-->|<#(?:[a-z]+)\s[^>]*>.*?</#(?:[a-z]+)>|\[#--.*?--\]|\[#(?:[a-z]+)\s[^\]]*\].*?\[#(?:[a-z]+)\])'
262
264
  - language: Fluent
263
265
  pattern: '^-?[a-zA-Z][a-zA-Z0-9_-]* *=|\{\$-?[a-zA-Z][-\w]*(?:\.[a-zA-Z][-\w]*)?\}'
264
266
  - extensions: ['.g']
@@ -326,6 +328,10 @@ disambiguations:
326
328
  named_pattern: m68k
327
329
  - language: SWIG
328
330
  pattern: '^[ \t]*%[a-z_]+\b|^%[{}]$'
331
+ - language: Assembly
332
+ pattern:
333
+ - '(?i)mov\s+[^\s]+,'
334
+ - '^\s+(i?)db\s+[a-z\d]'
329
335
  - extensions: ['.ice']
330
336
  rules:
331
337
  - language: JSON
@@ -345,7 +351,7 @@ disambiguations:
345
351
  - language: NASL
346
352
  pattern:
347
353
  - '^\s*include\s*\(\s*(?:"|'')[\\/\w\-\.:\s]+\.(?:nasl|inc)\s*(?:"|'')\s*\)\s*;'
348
- - '^\s*(?:global|local)_var\s+(?:\w+(?:\s*=\s*[\w\-"'']+)?\s*)(?:,\s*\w+(?:\s*=\s*[\w\-"'']+)?\s*)*+\s*;'
354
+ - '^\s*(?:global|local)_var\s+(?:\w+(?:\s*=\s*[\w\-"'']+)?\s*)(?:,\s*\w+(?:\s*=\s*[\w\-"'']+)?\s*)*\s*;'
349
355
  - '^\s*namespace\s+\w+\s*\{'
350
356
  - '^\s*object\s+\w+\s*(?:extends\s+\w+(?:::\w+)?)?\s*\{'
351
357
  - '^\s*(?:public\s+|private\s+|\s*)function\s+\w+\s*\([\w\s,]*\)\s*\{'
@@ -357,6 +363,10 @@ disambiguations:
357
363
  - '^\s*end[.;]\s*$'
358
364
  - language: BitBake
359
365
  pattern: '^inherit(\s+[\w.-]+)+\s*$'
366
+ - language: Assembly
367
+ pattern:
368
+ - '^(?i)[^"m]*mov\s+[^\s]+,'
369
+ - '^\s+(?i)db\s+[a-z\d]'
360
370
  - extensions: ['.json']
361
371
  rules:
362
372
  - language: OASv2-json
@@ -428,7 +438,7 @@ disambiguations:
428
438
  - extensions: ['.mc']
429
439
  rules:
430
440
  - language: Win32 Message File
431
- pattern: '(?i)^[ \t]*(?>\/\*\s*)?MessageId=|^\.$'
441
+ pattern: '(?i)^[ \t]*(\/\*\s*)?MessageId=|^\.$'
432
442
  - language: M4
433
443
  pattern: '^dnl|^divert\((?:-?\d+)?\)|^\w+\(`[^\r\n]*?''[),]'
434
444
  - language: Monkey C
@@ -644,7 +654,7 @@ disambiguations:
644
654
  - extensions: ['.rno']
645
655
  rules:
646
656
  - language: RUNOFF
647
- pattern: '(?i:^\.!|^\f|\f$|^\.end lit(?:eral)?\b|^\.[a-zA-Z].*?;\.[a-zA-Z](?:[; \t])|\^\*[^\s*][^*]*\\\*(?=$|\s)|^\.c;[ \t]*\w+)'
657
+ pattern: '(?i:^\.!|^\f|\f$|^\.end lit(?:eral)?\b|^\.[a-zA-Z].*?;\.[a-zA-Z](?:[; \t])|\^\*[^\s*][^*]*\\\*(?:$|\s)|^\.c;[ \t]*\w+)'
648
658
  - language: Roff
649
659
  pattern: '^\.\\" '
650
660
  - extensions: ['.rpy']
@@ -662,6 +672,10 @@ disambiguations:
662
672
  pattern: '^\s*<\?xml'
663
673
  - extensions: ['.s']
664
674
  rules:
675
+ - language: Unix Assembly
676
+ pattern: '(?i:mov[lq]?)\s+[%\$]'
677
+ - language: Assembly
678
+ pattern: '(?i:mov)\s+[^\s%]{2,},'
665
679
  - language: Motorola 68K Assembly
666
680
  named_pattern: m68k
667
681
  - extensions: ['.sc']
@@ -676,10 +690,27 @@ disambiguations:
676
690
  pattern: '(?i:\^(this|super)\.|^\s*(~\w+\s*=\.|SynthDef\b))'
677
691
  - language: Markdown
678
692
  pattern: '^#+\s+(NAME|SYNOPSIS|DESCRIPTION)'
693
+ - extensions: ['.scm']
694
+ rules:
695
+ - language: Scheme
696
+ pattern:
697
+ - '(?:''[\(\*#]|\w->\w|\.\.\.[\s\)]|\([+\-:<>\/=~\)]|~>|[#`]\(|#:\w)'
698
+ - '^\s*\((?:define\*?|import|library|lambda)'
699
+ negative_pattern:
700
+ - '\(#[\w-]+[!\?]'
701
+ - '[\)\]"_]\s*(?:[\*\+\?]|@\w)'
702
+ - language: Tree-sitter Query
703
+ pattern:
704
+ - '\(#[\w-]+[!\?]'
705
+ - '[\)\]"_]\s*(?:[\*\+\?]|@\w)'
706
+ - '(?:^\s*\w+:\s*[\(\[\"])'
707
+ - '\(#(?:set!|(?:not-)?(?:any-of|match)\?)'
708
+ negative_pattern:
709
+ - '\([+\-:<>\/=~\)]'
679
710
  - extensions: ['.sol']
680
711
  rules:
681
712
  - language: Solidity
682
- pattern: '\bpragma\s+solidity\b|\b(?:abstract\s+)?contract\s+(?!\d)[a-zA-Z0-9$_]+(?:\s+is\s+(?:[a-zA-Z0-9$_][^\{]*?)?)?\s*\{'
713
+ pattern: '\bpragma\s+solidity\b|\b(?:abstract\s+)?contract\s+[a-zA-Z$_][a-zA-Z0-9$_]*(?:\s+is\s+(?:[a-zA-Z0-9$_][^\{]*?)?)?\s*\{'
683
714
  - language: Gerber Image
684
715
  pattern: '^[DGMT][0-9]{2}\*(?:\r?\n|\r)'
685
716
  - extensions: ['.sql']
@@ -700,7 +731,7 @@ disambiguations:
700
731
  - extensions: ['.st']
701
732
  rules:
702
733
  - language: StringTemplate
703
- pattern: '\$\w+[($]|(.)!\s*.+?\s*!\1|<!\s*.+?\s*!>|\[!\s*.+?\s*!\]|\{!\s*.+?\s*!\}'
734
+ pattern: '\$\w+[($]|.!\s*.+?\s*!.|<!\s*.+?\s*!>|\[!\s*.+?\s*!\]|\{!\s*.+?\s*!\}'
704
735
  - language: Smalltalk
705
736
  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*\['
706
737
  - extensions: ['.star']
@@ -778,7 +809,7 @@ disambiguations:
778
809
  - language: Vim Help File
779
810
  pattern: '(?:(?:^|[ \t])(?:vi|Vi(?=m))(?:m[<=>]?[0-9]+|m)?|[ \t]ex)(?=:(?=[ \t]*set?[ \t][^\r\n:]+:)|:(?![ \t]*set?[ \t]))(?:(?:[ \t]*:[ \t]*|[ \t])\w*(?:[ \t]*=(?:[^\\\s]|\\.)*)?)*[ \t:](?:filetype|ft|syntax)[ \t]*=(help)(?=$|\s|:)'
780
811
  - language: Hosts File
781
- pattern: '(?xi) ^(?<ipv4>(?!\.)(?:\.?(?: 25[0-5]| 2[0-4]\d| 1\d\d| [1-9]?\d)\b){4})(?<cidr>/(3[0-2]|[12]?\d)\b)?(?<domains>[ \t]+\w[-\w]* (?:\.\w[-\w]*)*(?<!-)\b)*+(?=$|\s)'
812
+ pattern: '(?xi) ^(?<ipv4>(?!\.)(?:\.?(?: 25[0-5]| 2[0-4]\d| 1\d\d| [1-9]?\d)\b){4})(?<cidr>/(3[0-2]|[12]?\d)\b)?(?<domains>[ \t]+\w[-\w]* (?:\.\w[-\w]*)*(?<!-)\b)*+(?:$|\s)'
782
813
  - language: Adblock Filter List
783
814
  pattern: '\A\[(?<version>(?:[Aa]d[Bb]lock(?:[ \t][Pp]lus)?|u[Bb]lock(?:[ \t][Oo]rigin)?|[Aa]d[Gg]uard)(?:[ \t] \d+(?:\.\d+)*+)?)(?:[ \t]?;[ \t]?\g<version>)*+\]'
784
815
  - language: Text
@@ -790,7 +821,7 @@ disambiguations:
790
821
  - extensions: ['.url']
791
822
  rules:
792
823
  - language: INI
793
- pattern: '^\[InternetShortcut\](?:\r?\n|\r)(?>[^\s\[][^\r\n]*(?:\r?\n|\r))*URL='
824
+ pattern: '^\[InternetShortcut\](?:\r?\n|\r)([^\s\[][^\r\n]*(?:\r?\n|\r)){0,20}URL='
794
825
  - extensions: ['.v']
795
826
  rules:
796
827
  - language: Coq
@@ -861,8 +892,8 @@ named_patterns:
861
892
  - '(?i)^[ \t]*dim( shared)? [a-z_][a-z0-9_]* as [a-z_][a-z0-9_]* ptr'
862
893
  gsc:
863
894
  - '^\s*#\s*(?:using|insert|include|define|namespace)[ \t]+\w'
864
- - '^\s*(?>(?:autoexec|private)\s+){0,2}function\s+(?>(?:autoexec|private)\s+){0,2}\w+\s*\('
865
- - '\b(?:level|self)[ \t]+thread[ \t]+(?:\[\[[ \t]*(?>\w+\.)*\w+[ \t]*\]\]|\w+)[ \t]*\([^\r\n\)]*\)[ \t]*;'
895
+ - '^\s*((?:autoexec|private)\s+){0,2}function\s+((?:autoexec|private)\s+){0,2}\w+\s*\('
896
+ - '\b(?:level|self)[ \t]+thread[ \t]+(?:\[\[[ \t]*(\w+\.)+[ \t]*\]\]|\w+)[ \t]*\([^\r\n\)]*\)[ \t]*;'
866
897
  - '^[ \t]*#[ \t]*(?:precache|using_animtree)[ \t]*\('
867
898
  json: '\A\s*[{\[]'
868
899
  key_equals_value: '^[^#!;][^=]*='
package/ext/languages.yml CHANGED
@@ -392,6 +392,7 @@ Assembly:
392
392
  - ".inc"
393
393
  - ".nas"
394
394
  - ".nasm"
395
+ - ".s"
395
396
  tm_scope: source.assembly
396
397
  ace_mode: assembly_x86
397
398
  language_id: 24
@@ -563,6 +564,13 @@ BibTeX:
563
564
  codemirror_mode: stex
564
565
  codemirror_mime_type: text/x-stex
565
566
  language_id: 982188347
567
+ BibTeX Style:
568
+ type: programming
569
+ extensions:
570
+ - ".bst"
571
+ tm_scope: source.bst
572
+ ace_mode: text
573
+ language_id: 909569041
566
574
  Bicep:
567
575
  type: programming
568
576
  color: "#519aba"
@@ -3072,6 +3080,16 @@ IRC log:
3072
3080
  codemirror_mode: mirc
3073
3081
  codemirror_mime_type: text/mirc
3074
3082
  language_id: 164
3083
+ ISPC:
3084
+ type: programming
3085
+ color: "#2D68B1"
3086
+ extensions:
3087
+ - ".ispc"
3088
+ tm_scope: source.ispc
3089
+ ace_mode: c_cpp
3090
+ codemirror_mode: clike
3091
+ codemirror_mime_type: text/x-csrc
3092
+ language_id: 327071
3075
3093
  Idris:
3076
3094
  type: programming
3077
3095
  color: "#b30000"
@@ -3282,7 +3300,9 @@ JSON:
3282
3300
  - ".tern-project"
3283
3301
  - ".watchmanconfig"
3284
3302
  - MODULE.bazel.lock
3303
+ - Package.resolved
3285
3304
  - Pipfile.lock
3305
+ - bun.lock
3286
3306
  - composer.lock
3287
3307
  - deno.lock
3288
3308
  - flake.lock
@@ -3292,7 +3312,7 @@ JSON with Comments:
3292
3312
  type: data
3293
3313
  color: "#292929"
3294
3314
  group: JSON
3295
- tm_scope: source.js
3315
+ tm_scope: source.json.comments
3296
3316
  ace_mode: javascript
3297
3317
  codemirror_mode: javascript
3298
3318
  codemirror_mime_type: text/javascript
@@ -3917,14 +3937,14 @@ Linear Programming:
3917
3937
  ace_mode: text
3918
3938
  language_id: 377204539
3919
3939
  Linker Script:
3920
- type: data
3940
+ type: programming
3921
3941
  extensions:
3922
3942
  - ".ld"
3923
3943
  - ".lds"
3924
3944
  - ".x"
3925
3945
  filenames:
3926
3946
  - ld.script
3927
- tm_scope: none
3947
+ tm_scope: source.c.linker
3928
3948
  ace_mode: text
3929
3949
  language_id: 202
3930
3950
  Linux Kernel Module:
@@ -6917,6 +6937,14 @@ Singularity:
6917
6937
  - Singularity
6918
6938
  ace_mode: text
6919
6939
  language_id: 987024632
6940
+ Slang:
6941
+ type: programming
6942
+ color: "#1fbec9"
6943
+ extensions:
6944
+ - ".slang"
6945
+ tm_scope: source.slang
6946
+ ace_mode: text
6947
+ language_id: 239357863
6920
6948
  Slash:
6921
6949
  type: programming
6922
6950
  color: "#007eff"
@@ -7525,6 +7553,16 @@ Toit:
7525
7553
  tm_scope: source.toit
7526
7554
  ace_mode: text
7527
7555
  language_id: 356554395
7556
+ Tree-sitter Query:
7557
+ type: programming
7558
+ color: "#8ea64c"
7559
+ aliases:
7560
+ - tsq
7561
+ extensions:
7562
+ - ".scm"
7563
+ tm_scope: source.scm
7564
+ ace_mode: text
7565
+ language_id: 436081647
7528
7566
  Turing:
7529
7567
  type: programming
7530
7568
  color: "#cf142b"
@@ -7568,6 +7606,7 @@ TypeScript:
7568
7606
  aliases:
7569
7607
  - ts
7570
7608
  interpreters:
7609
+ - bun
7571
7610
  - deno
7572
7611
  - ts-node
7573
7612
  - tsx
package/license.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # ISC License
2
2
 
3
- Copyright &copy; Nixinova 2021&ndash;2024
3
+ Copyright &copy; Nixinova 2021&ndash;2025
4
4
 
5
5
  Permission to use, copy, modify, and/or distribute this software for any
6
6
  purpose with or without fee is hereby granted, provided that the above
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "linguist-js",
3
- "version": "2.9.0",
3
+ "version": "2.9.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": {
@@ -9,7 +9,7 @@
9
9
  },
10
10
  "engines": {
11
11
  "node": ">=12",
12
- "npm": "<9"
12
+ "npm": ">=8"
13
13
  },
14
14
  "scripts": {
15
15
  "download-files": "npx tsx@3 build/download-files",
package/dist/package.json DELETED
@@ -1,56 +0,0 @@
1
- {
2
- "name": "linguist-js",
3
- "version": "2.8.0",
4
- "description": "Analyse languages used in a folder. Powered by GitHub Linguist, although it doesn't need to be installed.",
5
- "main": "dist/index.js",
6
- "bin": {
7
- "linguist-js": "bin/index.js",
8
- "linguist": "bin/index.js"
9
- },
10
- "engines": {
11
- "node": ">=12"
12
- },
13
- "scripts": {
14
- "download-files": "npx tsx@3 build/download-files",
15
- "pre-publish": "npm run download-files && npm test && npm run perf",
16
- "perf": "tsc && node test/perf",
17
- "test": "tsc && node test/folder && node test/unit"
18
- },
19
- "files": [
20
- "bin/",
21
- "dist/",
22
- "ext/"
23
- ],
24
- "repository": {
25
- "type": "git",
26
- "url": "git+https://github.com/Nixinova/Linguist.git"
27
- },
28
- "keywords": [
29
- "linguist",
30
- "languages",
31
- "language-analysis",
32
- "language-analyzer"
33
- ],
34
- "author": "Nixinova (https://nixinova.com)",
35
- "license": "ISC",
36
- "bugs": {
37
- "url": "https://github.com/Nixinova/Linguist/issues"
38
- },
39
- "homepage": "https://github.com/Nixinova/Linguist#readme",
40
- "dependencies": {
41
- "binary-extensions": "^2.3.0 <3",
42
- "commander": "^9.5.0 <10",
43
- "common-path-prefix": "^3.0.0",
44
- "cross-fetch": "^3.1.8 <4",
45
- "ignore": "^5.3.2",
46
- "isbinaryfile": "^4.0.10 <5",
47
- "js-yaml": "^4.1.0",
48
- "node-cache": "^5.1.2"
49
- },
50
- "devDependencies": {
51
- "@types/js-yaml": "^4.0.9",
52
- "@types/node": "ts5.0",
53
- "deep-object-diff": "^1.1.9",
54
- "typescript": "~5.0.4 <5.1"
55
- }
56
- }
package/dist/src/cli.d.ts DELETED
@@ -1 +0,0 @@
1
- export {};
package/dist/src/cli.js DELETED
@@ -1,146 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const package_json_1 = __importDefault(require("../package.json"));
7
- ;
8
- const node_fs_1 = __importDefault(require("node:fs"));
9
- const node_path_1 = __importDefault(require("node:path"));
10
- const commander_1 = require("commander");
11
- const index_1 = __importDefault(require("./index"));
12
- const norm_path_1 = require("./helpers/norm-path");
13
- const colouredMsg = ([r, g, b], msg) => `\u001B[${38};2;${r};${g};${b}m${msg}${'\u001b[0m'}`;
14
- const hexToRgb = (hex) => [parseInt(hex.slice(1, 3), 16), parseInt(hex.slice(3, 5), 16), parseInt(hex.slice(5, 7), 16)];
15
- commander_1.program
16
- .name('linguist')
17
- .usage('--analyze [<folders...>] [<options...>]')
18
- .option('-a|--analyze|--analyse [folders...]', 'Analyse the languages of all files in a folder')
19
- .option('-i|--ignoredFiles <files...>', `A list of file path globs to ignore`)
20
- .option('-l|--ignoredLanguages <languages...>', `A list of languages to ignore`)
21
- .option('-c|--categories <categories...>', 'Language categories to include in output')
22
- .option('-C|--childLanguages [bool]', 'Display child languages instead of their parents', false)
23
- .option('-j|--json [bool]', 'Display the output as JSON', false)
24
- .option('-t|--tree <traversal>', 'Which part of the output JSON to display (dot-delimited)')
25
- .option('-F|--listFiles [bool]', 'Whether to list every matching file under the language results', false)
26
- .option('-q|--quick [bool]', 'Skip complex language analysis (alias for -{A|I|H|S}=false)', false)
27
- .option('-o|--offline [bool]', 'Use packaged data files instead of fetching latest from GitHub', false)
28
- .option('-L|--calculateLines [bool]', 'Calculate lines of code totals', true)
29
- .option('-V|--keepVendored [bool]', 'Prevent skipping over vendored/generated files', false)
30
- .option('-B|--keepBinary [bool]', 'Prevent skipping over binary files', false)
31
- .option('-r|--relativePaths [bool]', 'Convert absolute file paths to relative', false)
32
- .option('-A|--checkAttributes [bool]', 'Force the checking of gitattributes files', true)
33
- .option('-I|--checkIgnored [bool]', 'Force the checking of gitignore files', true)
34
- .option('-D|--checkDetected [bool]', 'Force files marked with linguist-detectable to always appear in output', true)
35
- .option('-H|--checkHeuristics [bool]', 'Apply heuristics to ambiguous languages', true)
36
- .option('-S|--checkShebang [bool]', 'Check shebang lines for explicit classification', true)
37
- .option('-M|--checkModeline [bool]', 'Check modelines for explicit classification', true)
38
- .helpOption(`-h|--help`, 'Display this help message')
39
- .version(package_json_1.default.version, '-v|--version', 'Display the installed version of linguist-js');
40
- commander_1.program.parse(process.argv);
41
- const args = commander_1.program.opts();
42
- // Normalise arguments
43
- for (const arg in args) {
44
- const normalise = (val) => {
45
- if (typeof val !== 'string')
46
- return val;
47
- val = val.replace(/^=/, '');
48
- if (val.match(/true$|false$/))
49
- val = val === 'true';
50
- return val;
51
- };
52
- if (Array.isArray(args[arg]))
53
- args[arg] = args[arg].map(normalise);
54
- else
55
- args[arg] = normalise(args[arg]);
56
- }
57
- // Run Linguist
58
- if (args.analyze)
59
- (async () => {
60
- // Fetch language data
61
- const root = args.analyze === true ? '.' : args.analyze;
62
- const data = await (0, index_1.default)(root, args);
63
- const { files, languages, unknown } = data;
64
- // Print output
65
- if (!args.json) {
66
- const sortedEntries = Object.entries(languages.results).sort((a, b) => a[1].bytes < b[1].bytes ? +1 : -1);
67
- const totalBytes = languages.bytes;
68
- console.log(`\n Analysed ${files.bytes.toLocaleString()} B from ${files.count} files with linguist-js`);
69
- console.log(`\n Language analysis results: \n`);
70
- let count = 0;
71
- if (sortedEntries.length === 0)
72
- console.log(` None`);
73
- // Collate files per language
74
- const filesPerLanguage = {};
75
- if (args.listFiles) {
76
- for (const language of Object.keys(languages.results)) {
77
- filesPerLanguage[language] = [];
78
- }
79
- for (const [file, lang] of Object.entries(files.results)) {
80
- if (lang)
81
- filesPerLanguage[lang].push(file);
82
- }
83
- }
84
- // List parsed results
85
- for (const [lang, { bytes, lines, color }] of sortedEntries) {
86
- const percent = (bytes) => bytes / (totalBytes || 1) * 100;
87
- const fmtd = {
88
- index: (++count).toString().padStart(2, ' '),
89
- lang: lang.padEnd(24, ' '),
90
- percent: percent(bytes).toFixed(2).padStart(5, ' '),
91
- bytes: bytes.toLocaleString().padStart(10, ' '),
92
- loc: lines.code.toLocaleString().padStart(10, ' '),
93
- icon: colouredMsg(hexToRgb(color !== null && color !== void 0 ? color : '#ededed'), '\u2588'),
94
- };
95
- console.log(` ${fmtd.index}. ${fmtd.icon} ${fmtd.lang} ${fmtd.percent}% ${fmtd.bytes} B ${fmtd.loc} LOC`);
96
- // If using `listFiles` option, list all files tagged as this language
97
- if (args.listFiles) {
98
- console.log(); // padding
99
- for (const file of filesPerLanguage[lang]) {
100
- let relFile = (0, norm_path_1.normPath)(node_path_1.default.relative(node_path_1.default.resolve('.'), file));
101
- if (!relFile.startsWith('../'))
102
- relFile = './' + relFile;
103
- const bytes = (await node_fs_1.default.promises.stat(file)).size;
104
- const fmtd2 = {
105
- file: relFile.padEnd(42, ' '),
106
- percent: percent(bytes).toFixed(2).padStart(5, ' '),
107
- bytes: bytes.toLocaleString().padStart(10, ' '),
108
- };
109
- console.log(` ${fmtd.icon} ${fmtd2.file} ${fmtd2.percent}% ${fmtd2.bytes} B`);
110
- }
111
- console.log(); // padding
112
- }
113
- }
114
- if (!args.listFiles)
115
- console.log(); // padding
116
- console.log(` Total: ${totalBytes.toLocaleString()} B`);
117
- // List unknown files/extensions
118
- if (unknown.bytes > 0) {
119
- console.log(`\n Unknown files and extensions:`);
120
- for (const [name, bytes] of Object.entries(unknown.filenames)) {
121
- console.log(` '${name}': ${bytes.toLocaleString()} B`);
122
- }
123
- for (const [ext, bytes] of Object.entries(unknown.extensions)) {
124
- console.log(` '*${ext}': ${bytes.toLocaleString()} B`);
125
- }
126
- console.log(` Total: ${unknown.bytes.toLocaleString()} B`);
127
- }
128
- }
129
- else if (args.tree) {
130
- const treeParts = args.tree.split('.');
131
- let nestedData = data;
132
- for (const part of treeParts) {
133
- if (!nestedData[part])
134
- throw Error(`TraversalError: Key '${part}' cannot be found on output object.`);
135
- nestedData = nestedData[part];
136
- }
137
- console.log(nestedData);
138
- }
139
- else {
140
- console.dir(data, { depth: null });
141
- }
142
- })();
143
- else {
144
- console.log(`Welcome to linguist-js, a JavaScript port of GitHub's language analyzer.`);
145
- console.log(`Type 'linguist --help' for a list of commands.`);
146
- }
@@ -1,2 +0,0 @@
1
- /** Convert a PCRE regex into JS. */
2
- export default function pcre(regex: string): RegExp;