cspell 8.14.3 → 8.15.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.
@@ -1,6 +1,6 @@
1
1
  export { pkgDir } from './dirname.js';
2
2
  export declare const name = "cspell";
3
- export declare const version = "8.14.3";
3
+ export declare const version = "8.15.0";
4
4
  export declare const engines: {
5
5
  node: string;
6
6
  };
@@ -1,7 +1,7 @@
1
1
  // This file is generated by tools/patch-version.mjs
2
2
  export { pkgDir } from './dirname.js';
3
3
  export const name = 'cspell';
4
- export const version = '8.14.3';
4
+ export const version = '8.15.0';
5
5
  export const engines = { node: '>=18' };
6
6
  export const npmPackage = { name, version, engines };
7
7
  //# sourceMappingURL=pkgInfo.js.map
@@ -1,5 +1,6 @@
1
1
  export declare const UTF8: "utf8";
2
2
  export declare const STDIN: "stdin";
3
- export declare const STDINProtocol: "stdin://";
4
- export declare const FileProtocol: "file://";
3
+ export declare const STDINProtocol: "stdin:";
4
+ export declare const STDINUrlPrefix: "stdin://";
5
+ export declare const FileUrlPrefix: "file://";
5
6
  //# sourceMappingURL=constants.d.ts.map
@@ -1,5 +1,6 @@
1
1
  export const UTF8 = 'utf8';
2
2
  export const STDIN = 'stdin';
3
- export const STDINProtocol = 'stdin://';
4
- export const FileProtocol = 'file://';
3
+ export const STDINProtocol = 'stdin:';
4
+ export const STDINUrlPrefix = 'stdin://';
5
+ export const FileUrlPrefix = 'file://';
5
6
  //# sourceMappingURL=constants.js.map
@@ -30,7 +30,7 @@ export interface FileResult {
30
30
  cached?: boolean;
31
31
  }
32
32
  export declare function fileInfoToDocument(fileInfo: FileInfo, languageId: string | undefined, locale: string | undefined): Document;
33
- export declare function filenameToUrlString(filename: string, cwd?: string): URL;
33
+ export declare function filenameToUrl(filename: string, cwd?: string): URL;
34
34
  export declare function filenameToUri(filename: string, cwd?: string): URL;
35
35
  export declare function isBinaryFile(filename: string, cwd?: string): boolean;
36
36
  export interface ReadFileInfoResult extends FileInfo {
@@ -7,10 +7,11 @@ import * as cspell from 'cspell-lib';
7
7
  import { fileToDocument, isBinaryFile as isUriBinaryFile } from 'cspell-lib';
8
8
  import getStdin from 'get-stdin';
9
9
  import { asyncAwait, asyncFlatten, asyncMap, asyncPipe, mergeAsyncIterables } from './async.js';
10
- import { FileProtocol, STDIN, STDINProtocol, UTF8 } from './constants.js';
10
+ import { FileUrlPrefix, STDIN, STDINProtocol, STDINUrlPrefix, UTF8 } from './constants.js';
11
11
  import { IOError, toApplicationError, toError } from './errors.js';
12
12
  import { globP } from './glob.js';
13
13
  import { readStdin } from './stdin.js';
14
+ import { isStdinUrl, resolveStdinUrl } from './stdinUrl.js';
14
15
  import { clean } from './util.js';
15
16
  export async function readConfig(configFile, root) {
16
17
  if (configFile) {
@@ -24,7 +25,7 @@ export function fileInfoToDocument(fileInfo, languageId, locale) {
24
25
  const { filename, text } = fileInfo;
25
26
  languageId = languageId || undefined;
26
27
  locale = locale || undefined;
27
- const uri = filenameToUrlString(filename);
28
+ const uri = filenameToUrl(filename);
28
29
  if (uri.href.startsWith(STDINProtocol)) {
29
30
  return clean({
30
31
  uri: uri.href,
@@ -35,18 +36,17 @@ export function fileInfoToDocument(fileInfo, languageId, locale) {
35
36
  }
36
37
  return fileToDocument(uri.href, text, languageId, locale);
37
38
  }
38
- export function filenameToUrlString(filename, cwd = '.') {
39
+ export function filenameToUrl(filename, cwd = '.') {
39
40
  const cwdURL = toFileDirURL(cwd);
40
41
  if (filename === STDIN)
41
42
  return new URL('stdin:///');
42
- if (filename.startsWith(STDINProtocol)) {
43
- const filePath = filename.slice(STDINProtocol.length);
44
- return toFileURL(filePath, cwdURL);
43
+ if (isStdinUrl(filename)) {
44
+ return new URL(resolveStdinUrl(filename, cwd));
45
45
  }
46
46
  return toFileURL(filename, cwdURL);
47
47
  }
48
48
  export function filenameToUri(filename, cwd) {
49
- return toURL(filenameToUrlString(filename, cwd));
49
+ return toURL(filenameToUrl(filename, cwd));
50
50
  }
51
51
  export function isBinaryFile(filename, cwd) {
52
52
  const uri = filenameToUri(filename, cwd);
@@ -57,14 +57,15 @@ export function isBinaryFile(filename, cwd) {
57
57
  export function resolveFilename(filename, cwd) {
58
58
  cwd = cwd || process.cwd();
59
59
  if (filename === STDIN)
60
- return STDINProtocol;
61
- if (filename.startsWith(FileProtocol)) {
62
- const url = new URL(filename.slice(FileProtocol.length), pathToFileURL(cwd + path.sep));
60
+ return STDINUrlPrefix;
61
+ if (filename.startsWith(FileUrlPrefix)) {
62
+ const url = new URL(filename.slice(FileUrlPrefix.length), pathToFileURL(cwd + path.sep));
63
63
  return fileURLToPath(url);
64
64
  }
65
- const scheme = filename.startsWith(STDINProtocol) ? STDINProtocol : '';
66
- const pathname = filename.slice(scheme.length);
67
- return scheme + path.resolve(cwd, pathname);
65
+ if (isStdinUrl(filename)) {
66
+ return resolveStdinUrl(filename, cwd);
67
+ }
68
+ return path.resolve(cwd, filename);
68
69
  }
69
70
  export function readFileInfo(filename, encoding = UTF8, handleNotFound = false) {
70
71
  filename = resolveFilename(filename);
@@ -87,9 +88,7 @@ export function readFile(filename, encoding = UTF8) {
87
88
  */
88
89
  export async function findFiles(globPatterns, options) {
89
90
  const stdin = [];
90
- const globPats = globPatterns.filter((filename) => filename !== STDIN && !filename.startsWith(STDINProtocol) && !filename.startsWith(FileProtocol)
91
- ? true
92
- : (stdin.push(filename), false));
91
+ const globPats = globPatterns.filter((filename) => !isStdin(filename) && !filename.startsWith(FileUrlPrefix) ? true : (stdin.push(filename), false));
93
92
  const globResults = globPats.length ? await globP(globPats, options) : [];
94
93
  const cwd = options.cwd || process.cwd();
95
94
  return [...stdin, ...globResults].map((filename) => resolveFilename(filename, cwd));
@@ -134,7 +133,12 @@ export async function readFileListFile(listFile) {
134
133
  throw toApplicationError(err, `Error reading file list from: "${listFile}"`);
135
134
  }
136
135
  }
136
+ function isStdin(filename) {
137
+ return filename === STDIN || isStdinUrl(filename);
138
+ }
137
139
  export async function isFile(filename) {
140
+ if (isStdin(filename))
141
+ return true;
138
142
  try {
139
143
  const stat = await fsp.stat(filename);
140
144
  return stat.isFile();
@@ -2,7 +2,7 @@ import { promises as fs } from 'node:fs';
2
2
  import * as path from 'node:path';
3
3
  import { posix } from 'node:path';
4
4
  import { fileOrGlobToGlob, GlobMatcher } from 'cspell-glob';
5
- import glob from 'fast-glob';
5
+ import { glob } from 'tinyglobby';
6
6
  import { clean } from './util.js';
7
7
  const defaultExcludeGlobs = ['node_modules/**'];
8
8
  /**
@@ -23,6 +23,7 @@ export async function globP(pattern, options) {
23
23
  ignore,
24
24
  absolute: true,
25
25
  followSymbolicLinks: false,
26
+ expandDirectories: false,
26
27
  });
27
28
  const compare = new Intl.Collator('en').compare;
28
29
  const absolutePaths = (await glob(patterns, useOptions)).sort(compare);
@@ -1,4 +1,4 @@
1
- import strip from 'strip-ansi';
1
+ import { stripVTControlCharacters } from 'node:util';
2
2
  export function pad(s, w) {
3
3
  const p = padWidth(s, w);
4
4
  if (!p)
@@ -23,6 +23,6 @@ export function width(s) {
23
23
  .replaceAll(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g, '.').length);
24
24
  }
25
25
  export function ansiWidth(s) {
26
- return width(strip(s));
26
+ return width(stripVTControlCharacters(s));
27
27
  }
28
28
  //# sourceMappingURL=pad.js.map
@@ -0,0 +1,9 @@
1
+ export declare function isStdinUrl(url: string | URL): boolean;
2
+ /**
3
+ * Normalize and resolve a stdin url.
4
+ * @param url - stdin url to resolve.
5
+ * @param cwd - file path to resolve relative paths against.
6
+ * @returns
7
+ */
8
+ export declare function resolveStdinUrl(url: string, cwd: string): string;
9
+ //# sourceMappingURL=stdinUrl.d.ts.map
@@ -0,0 +1,26 @@
1
+ import assert from 'node:assert';
2
+ import Path from 'node:path';
3
+ import { pathToFileURL } from 'node:url';
4
+ import { STDINProtocol } from './constants.js';
5
+ export function isStdinUrl(url) {
6
+ if (url instanceof URL) {
7
+ return url.protocol === STDINProtocol;
8
+ }
9
+ return url.startsWith(STDINProtocol);
10
+ }
11
+ /**
12
+ * Normalize and resolve a stdin url.
13
+ * @param url - stdin url to resolve.
14
+ * @param cwd - file path to resolve relative paths against.
15
+ * @returns
16
+ */
17
+ export function resolveStdinUrl(url, cwd) {
18
+ assert(url.startsWith(STDINProtocol), `Expected url to start with ${STDINProtocol}`);
19
+ const path = url
20
+ .slice(STDINProtocol.length)
21
+ .replace(/^\/\//, '')
22
+ .replace(/^\/([a-z]:)/i, '$1');
23
+ const fileUrl = pathToFileURL(Path.resolve(cwd, path));
24
+ return fileUrl.toString().replace(/^file:/, STDINProtocol) + (path ? '' : '/');
25
+ }
26
+ //# sourceMappingURL=stdinUrl.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cspell",
3
- "version": "8.14.3",
3
+ "version": "8.15.0",
4
4
  "description": "A Spelling Checker for Code!",
5
5
  "funding": "https://github.com/streetsidesoftware/cspell?sponsor=1",
6
6
  "bin": {
@@ -43,7 +43,6 @@
43
43
  "build": "tsc -p . && pnpm run build:api",
44
44
  "build:api": "rollup -c rollup.config.mjs",
45
45
  "build:esm": "tsc -p .",
46
- "build:lib": "tsc -b src/lib/tsconfig.json -f",
47
46
  "build:readme": "pnpm build:readme:help",
48
47
  "build:readme:help": "pnpm build:readme:help:lint && pnpm build:readme:help:trace && inject-markdown README.md && prettier -w README.md",
49
48
  "build:readme:help:lint": "./bin.mjs lint --help > static/help-lint.txt",
@@ -52,8 +51,8 @@
52
51
  "coverage": "vitest run --coverage",
53
52
  "test:watch": "vitest",
54
53
  "test": "vitest run",
55
- "watch": "tsc -b . -w -f",
56
- "compile": "tsc -b . -f",
54
+ "watch": "tsc -p . -w",
55
+ "compile": "tsc -p .",
57
56
  "test-watch": "vitest",
58
57
  "version": "node ./tools/patch-version.mjs && git add .",
59
58
  "prepublishOnly": "pnpm run clean-build",
@@ -82,25 +81,24 @@
82
81
  },
83
82
  "homepage": "https://cspell.org/",
84
83
  "dependencies": {
85
- "@cspell/cspell-json-reporter": "8.14.3",
86
- "@cspell/cspell-pipe": "8.14.3",
87
- "@cspell/cspell-types": "8.14.3",
88
- "@cspell/dynamic-import": "8.14.3",
89
- "@cspell/url": "8.14.3",
84
+ "@cspell/cspell-json-reporter": "8.15.0",
85
+ "@cspell/cspell-pipe": "8.15.0",
86
+ "@cspell/cspell-types": "8.15.0",
87
+ "@cspell/dynamic-import": "8.15.0",
88
+ "@cspell/url": "8.15.0",
90
89
  "chalk": "^5.3.0",
91
90
  "chalk-template": "^1.1.0",
92
91
  "commander": "^12.1.0",
93
- "cspell-dictionary": "8.14.3",
94
- "cspell-gitignore": "8.14.3",
95
- "cspell-glob": "8.14.3",
96
- "cspell-io": "8.14.3",
97
- "cspell-lib": "8.14.3",
98
- "fast-glob": "^3.3.2",
92
+ "cspell-dictionary": "8.15.0",
93
+ "cspell-gitignore": "8.15.0",
94
+ "cspell-glob": "8.15.0",
95
+ "cspell-io": "8.15.0",
96
+ "cspell-lib": "8.15.0",
99
97
  "fast-json-stable-stringify": "^2.1.0",
100
98
  "file-entry-cache": "^9.1.0",
101
99
  "get-stdin": "^9.0.0",
102
100
  "semver": "^7.6.3",
103
- "strip-ansi": "^7.1.0"
101
+ "tinyglobby": "^0.2.9"
104
102
  },
105
103
  "engines": {
106
104
  "node": ">=18"
@@ -113,5 +111,5 @@
113
111
  "micromatch": "^4.0.8",
114
112
  "minimatch": "^9.0.5"
115
113
  },
116
- "gitHead": "ce996377857f5d7c3e70f27fc512afbe605562f8"
114
+ "gitHead": "60b04562dfa023eede01929d86fa944163c07256"
117
115
  }