@cspell/cspell-tools 7.2.0 → 7.3.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.
- package/dist/app.js +2 -2
- package/dist/compiler/SourceReader.js +13 -1
- package/dist/gzip/compressFiles.d.ts +13 -1
- package/dist/gzip/compressFiles.js +26 -4
- package/dist/gzip/gzip.d.ts +2 -1
- package/dist/gzip/gzip.js +2 -2
- package/dist/gzip/index.d.ts +1 -1
- package/dist/gzip/index.js +1 -1
- package/dist/test/TestHelper.d.ts +9 -0
- package/dist/test/TestHelper.js +4 -0
- package/package.json +9 -9
- /package/{bin.js → bin.mjs} +0 -0
package/dist/app.js
CHANGED
|
@@ -5,7 +5,7 @@ import { build } from './build.js';
|
|
|
5
5
|
import { processCompileAction } from './compile.js';
|
|
6
6
|
import * as compiler from './compiler/index.js';
|
|
7
7
|
import { logWithTimestamp } from './compiler/logWithTimestamp.js';
|
|
8
|
-
import { gzip } from './gzip/index.js';
|
|
8
|
+
import { gzip, OSFlags } from './gzip/index.js';
|
|
9
9
|
import { reportCheckChecksumFile, reportChecksumForFiles, updateChecksumForFiles } from './shasum/shasum.js';
|
|
10
10
|
import { toError } from './util/errors.js';
|
|
11
11
|
const npmPackageRaw = readFileSync(new URL('../package.json', import.meta.url), 'utf8');
|
|
@@ -34,7 +34,7 @@ function addCompileOptions(compileCommand) {
|
|
|
34
34
|
export async function run(program, argv, flags) {
|
|
35
35
|
async function handleGzip(files) {
|
|
36
36
|
try {
|
|
37
|
-
await gzip(files);
|
|
37
|
+
await gzip(files, OSFlags.Unix);
|
|
38
38
|
}
|
|
39
39
|
catch (error) {
|
|
40
40
|
const err = toError(error);
|
|
@@ -4,7 +4,7 @@ export async function createSourceReader(filename, options) {
|
|
|
4
4
|
const reader = await createReader(filename, options);
|
|
5
5
|
if (reader.type !== 'TextFile') {
|
|
6
6
|
return {
|
|
7
|
-
words: reader.lines,
|
|
7
|
+
words: splitLines(reader.lines, options),
|
|
8
8
|
get size() {
|
|
9
9
|
return reader.size;
|
|
10
10
|
},
|
|
@@ -12,6 +12,18 @@ export async function createSourceReader(filename, options) {
|
|
|
12
12
|
}
|
|
13
13
|
return textFileReader(reader, options);
|
|
14
14
|
}
|
|
15
|
+
function splitLines(lines, options) {
|
|
16
|
+
if (!options.splitWords)
|
|
17
|
+
return lines;
|
|
18
|
+
function* split() {
|
|
19
|
+
const regNonWordOrDigit = /[^\p{L}\p{M}'\w-]+/giu;
|
|
20
|
+
for (const line of lines) {
|
|
21
|
+
const words = line.split(regNonWordOrDigit);
|
|
22
|
+
yield* words;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return split();
|
|
26
|
+
}
|
|
15
27
|
async function textFileReader(reader, options) {
|
|
16
28
|
const { legacy, splitWords: split, allowedSplitWords } = options;
|
|
17
29
|
const words = [...parseFileLines(reader, { legacy, split, allowedSplitWords })];
|
|
@@ -1,2 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
+
export declare enum OSFlags {
|
|
3
|
+
FAT = 0,
|
|
4
|
+
Unix = 3,
|
|
5
|
+
HPFS = 6,
|
|
6
|
+
MACOS = 7,
|
|
7
|
+
NTFS = 11
|
|
8
|
+
}
|
|
9
|
+
export declare function compressFile(file: string, os?: OSFlags): Promise<string>;
|
|
10
|
+
export declare function compress(buf: string | Uint8Array | Buffer, os?: OSFlags): Promise<Uint8Array>;
|
|
11
|
+
export declare function decompress(buf: Uint8Array | Buffer, encoding?: undefined): Promise<Uint8Array>;
|
|
12
|
+
export declare function decompress(buf: Uint8Array | Buffer, encoding: 'utf8'): Promise<string>;
|
|
13
|
+
export declare function decompress(buf: Uint8Array | Buffer, encoding: 'utf8' | undefined): Promise<string | Uint8Array>;
|
|
2
14
|
//# sourceMappingURL=compressFiles.d.ts.map
|
|
@@ -1,14 +1,36 @@
|
|
|
1
1
|
import { readFile, writeFile } from 'node:fs/promises';
|
|
2
2
|
import { promisify } from 'node:util';
|
|
3
|
-
import { gzip as gz } from 'node:zlib';
|
|
3
|
+
import { gunzip as gunzipCB, gzip as gz } from 'node:zlib';
|
|
4
4
|
const gzip = promisify(gz);
|
|
5
|
-
|
|
5
|
+
const gunzip = promisify(gunzipCB);
|
|
6
|
+
export var OSFlags;
|
|
7
|
+
(function (OSFlags) {
|
|
8
|
+
OSFlags[OSFlags["FAT"] = 0] = "FAT";
|
|
9
|
+
OSFlags[OSFlags["Unix"] = 3] = "Unix";
|
|
10
|
+
OSFlags[OSFlags["HPFS"] = 6] = "HPFS";
|
|
11
|
+
OSFlags[OSFlags["MACOS"] = 7] = "MACOS";
|
|
12
|
+
OSFlags[OSFlags["NTFS"] = 11] = "NTFS";
|
|
13
|
+
})(OSFlags || (OSFlags = {}));
|
|
14
|
+
// https://docs.fileformat.com/compression/gz/#:~:text=A%20GZ%20file%20is%20a,compression%20formats%20on%20UNIX%20systems.
|
|
15
|
+
const OSSystemIDOffset = 9;
|
|
16
|
+
export async function compressFile(file, os) {
|
|
6
17
|
if (file.endsWith('.gz'))
|
|
7
18
|
return file;
|
|
8
19
|
const targetFile = file + '.gz';
|
|
9
|
-
const
|
|
10
|
-
const zBuf = await gzip(buf);
|
|
20
|
+
const zBuf = await compress(await readFile(file), os);
|
|
11
21
|
await writeFile(targetFile, zBuf);
|
|
12
22
|
return targetFile;
|
|
13
23
|
}
|
|
24
|
+
export async function compress(buf, os) {
|
|
25
|
+
const zBuf = await gzip(buf);
|
|
26
|
+
const osFlag = os ?? zBuf[OSSystemIDOffset];
|
|
27
|
+
zBuf[OSSystemIDOffset] = osFlag;
|
|
28
|
+
return zBuf;
|
|
29
|
+
}
|
|
30
|
+
export async function decompress(buf, encoding) {
|
|
31
|
+
const dBuf = gunzip(buf);
|
|
32
|
+
if (!encoding)
|
|
33
|
+
return dBuf;
|
|
34
|
+
return (await dBuf).toString(encoding);
|
|
35
|
+
}
|
|
14
36
|
//# sourceMappingURL=compressFiles.js.map
|
package/dist/gzip/gzip.d.ts
CHANGED
package/dist/gzip/gzip.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { globP } from '../util/globP.js';
|
|
2
2
|
import { compressFile } from './compressFiles.js';
|
|
3
3
|
// cspell:ignore nodir
|
|
4
|
-
export async function gzip(globs) {
|
|
4
|
+
export async function gzip(globs, os) {
|
|
5
5
|
const files = await globP(globs, { nodir: true });
|
|
6
6
|
for (const fileName of files) {
|
|
7
|
-
await compressFile(fileName);
|
|
7
|
+
await compressFile(fileName, os);
|
|
8
8
|
}
|
|
9
9
|
}
|
|
10
10
|
//# sourceMappingURL=gzip.js.map
|
package/dist/gzip/index.d.ts
CHANGED
package/dist/gzip/index.js
CHANGED
|
@@ -13,7 +13,16 @@ export interface TestHelper {
|
|
|
13
13
|
*/
|
|
14
14
|
resolveTemp(...parts: string[]): string;
|
|
15
15
|
createTempDir(...parts: string[]): void;
|
|
16
|
+
/**
|
|
17
|
+
* Resolves a fixture path to an absolute path
|
|
18
|
+
* @param parts - relative path to fixture
|
|
19
|
+
*/
|
|
16
20
|
resolveFixture(...parts: string[]): string;
|
|
21
|
+
/**
|
|
22
|
+
* Resolves a path to an absolute path in Samples
|
|
23
|
+
* @param parts - relative path to sample
|
|
24
|
+
*/
|
|
25
|
+
resolveSample(...parts: string[]): string;
|
|
17
26
|
/**
|
|
18
27
|
* Make the temp directory
|
|
19
28
|
* @param parts
|
package/dist/test/TestHelper.js
CHANGED
|
@@ -8,6 +8,7 @@ const _dirname = test_dirname(import.meta.url);
|
|
|
8
8
|
const packageRoot = path.join(_dirname, '../..');
|
|
9
9
|
const repoRoot = path.join(packageRoot, '../..');
|
|
10
10
|
const tempDirBase = path.join(packageRoot, 'temp');
|
|
11
|
+
const repoSamples = path.join(repoRoot, 'packages/Samples');
|
|
11
12
|
export function createTestHelper(testFilenameUrl) {
|
|
12
13
|
testFilenameUrl && assert(testFilenameUrl.startsWith('file:'));
|
|
13
14
|
const testFilename = testFilenameUrl && test_filename(testFilenameUrl);
|
|
@@ -76,6 +77,9 @@ class TestHelperImpl {
|
|
|
76
77
|
resolveFixture(...parts) {
|
|
77
78
|
return path.resolve(this.fixtureDir, ...parts);
|
|
78
79
|
}
|
|
80
|
+
resolveSample(...parts) {
|
|
81
|
+
return path.resolve(repoSamples, ...parts);
|
|
82
|
+
}
|
|
79
83
|
/**
|
|
80
84
|
* calc a path relative to the package temp directory.
|
|
81
85
|
* @param parts - optional path segments
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cspell/cspell-tools",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.3.1",
|
|
4
4
|
"description": "Tools to assist with the development of cSpell",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
8
8
|
"type": "module",
|
|
9
9
|
"bin": {
|
|
10
|
-
"cspell-tools-cli": "bin.
|
|
10
|
+
"cspell-tools-cli": "bin.mjs"
|
|
11
11
|
},
|
|
12
12
|
"scripts": {
|
|
13
13
|
"build": "pnpm run build-schema && pnpm run compile",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"Compiler"
|
|
33
33
|
],
|
|
34
34
|
"files": [
|
|
35
|
-
"bin.
|
|
35
|
+
"bin.mjs",
|
|
36
36
|
"dist",
|
|
37
37
|
"cspell-tools.config.schema.json",
|
|
38
38
|
"!**/*.tsbuildInfo",
|
|
@@ -48,13 +48,13 @@
|
|
|
48
48
|
},
|
|
49
49
|
"homepage": "https://github.com/streetsidesoftware/cspell#readme",
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@cspell/cspell-pipe": "7.
|
|
51
|
+
"@cspell/cspell-pipe": "7.3.1",
|
|
52
52
|
"commander": "^11.0.0",
|
|
53
53
|
"cosmiconfig": "8.0.0",
|
|
54
|
-
"cspell-trie-lib": "7.
|
|
54
|
+
"cspell-trie-lib": "7.3.1",
|
|
55
55
|
"gensequence": "^5.0.2",
|
|
56
|
-
"glob": "^10.3.
|
|
57
|
-
"hunspell-reader": "7.
|
|
56
|
+
"glob": "^10.3.4",
|
|
57
|
+
"hunspell-reader": "7.3.1",
|
|
58
58
|
"yaml": "^2.3.2"
|
|
59
59
|
},
|
|
60
60
|
"engines": {
|
|
@@ -67,6 +67,6 @@
|
|
|
67
67
|
"shelljs": "^0.8.5",
|
|
68
68
|
"ts-json-schema-generator": "^1.3.0"
|
|
69
69
|
},
|
|
70
|
-
"
|
|
71
|
-
"gitHead": "
|
|
70
|
+
"module": "bin.mjs",
|
|
71
|
+
"gitHead": "999b382d928e8288ebb8be5b056d04116213f4ee"
|
|
72
72
|
}
|
/package/{bin.js → bin.mjs}
RENAMED
|
File without changes
|