@kitschpatrol/cspell-config 5.0.0 → 5.0.2
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/bin/cli.js +81 -18
- package/package.json +4 -2
package/bin/cli.js
CHANGED
|
@@ -627,7 +627,7 @@ var source_default = chalk;
|
|
|
627
627
|
import { cosmiconfig } from "cosmiconfig";
|
|
628
628
|
import { execa } from "execa";
|
|
629
629
|
import fse2 from "fs-extra";
|
|
630
|
-
import
|
|
630
|
+
import fs3 from "node:fs";
|
|
631
631
|
import path3 from "node:path";
|
|
632
632
|
import { PassThrough } from "node:stream";
|
|
633
633
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
@@ -5541,7 +5541,7 @@ var Yargs = YargsFactory(esm_default);
|
|
|
5541
5541
|
var yargs_default = Yargs;
|
|
5542
5542
|
|
|
5543
5543
|
// ../../package.json
|
|
5544
|
-
var version = "5.0.
|
|
5544
|
+
var version = "5.0.2";
|
|
5545
5545
|
|
|
5546
5546
|
// ../../src/execa-utils.ts
|
|
5547
5547
|
function isErrorExecaError(error) {
|
|
@@ -5726,6 +5726,29 @@ function getCwdOverride(option) {
|
|
|
5726
5726
|
return process.cwd();
|
|
5727
5727
|
}
|
|
5728
5728
|
|
|
5729
|
+
// ../../src/prettier-utils.ts
|
|
5730
|
+
import fs2 from "node:fs/promises";
|
|
5731
|
+
async function formatTextAndSaveFile(filePath, content) {
|
|
5732
|
+
try {
|
|
5733
|
+
const { default: prettier } = await import("prettier");
|
|
5734
|
+
const prettierConfig = await prettier.resolveConfig(filePath);
|
|
5735
|
+
const formattedContent = await prettier.format(content, {
|
|
5736
|
+
filepath: filePath,
|
|
5737
|
+
...prettierConfig
|
|
5738
|
+
});
|
|
5739
|
+
await fs2.writeFile(filePath, formattedContent, "utf8");
|
|
5740
|
+
} catch {
|
|
5741
|
+
console.warn(`Skipped formatting ${filePath} since Prettier is not installed.`);
|
|
5742
|
+
}
|
|
5743
|
+
}
|
|
5744
|
+
async function formatFileInPlace(filePath) {
|
|
5745
|
+
try {
|
|
5746
|
+
const content = await fs2.readFile(filePath, "utf8");
|
|
5747
|
+
await formatTextAndSaveFile(filePath, content);
|
|
5748
|
+
} catch {
|
|
5749
|
+
}
|
|
5750
|
+
}
|
|
5751
|
+
|
|
5729
5752
|
// ../../src/stream-utils.ts
|
|
5730
5753
|
import { Transform } from "node:stream";
|
|
5731
5754
|
function createStreamFilter(matcher) {
|
|
@@ -5780,7 +5803,11 @@ async function executeFunctionCommand(logStream, positionalArguments, optionFlag
|
|
|
5780
5803
|
targetStream = subStream;
|
|
5781
5804
|
}
|
|
5782
5805
|
if (verbose) {
|
|
5783
|
-
targetStream.write(
|
|
5806
|
+
targetStream.write(
|
|
5807
|
+
source_default.bold(
|
|
5808
|
+
`Running: "${command2.name}() with Positional arguments: ${String(positionalArguments)} and Option flags: ${String(optionFlags)}"`
|
|
5809
|
+
)
|
|
5810
|
+
);
|
|
5784
5811
|
}
|
|
5785
5812
|
try {
|
|
5786
5813
|
exitCode = await command2.execute(targetStream, positionalArguments, optionFlags);
|
|
@@ -5898,9 +5925,6 @@ async function copyAndMergeInitFiles(logStream, location, configFile, configPack
|
|
|
5898
5925
|
const source = path3.join(path3.dirname(sourcePackage), "init");
|
|
5899
5926
|
const destination = path3.dirname(destinationPackage);
|
|
5900
5927
|
const hasConfigLocationOption = (location === "file" || location === "package") && configFile !== void 0 && configPackageJson !== void 0;
|
|
5901
|
-
logStream.write(`Adding initial configuration files from:
|
|
5902
|
-
"${source}" \u2192 "${destination}"
|
|
5903
|
-
`);
|
|
5904
5928
|
try {
|
|
5905
5929
|
if (hasConfigLocationOption) {
|
|
5906
5930
|
const configKey = Object.keys(configPackageJson)[0];
|
|
@@ -5912,7 +5936,8 @@ Package config key "${configKey}" \u2192 "${destination}" (Because --location is
|
|
|
5912
5936
|
`
|
|
5913
5937
|
);
|
|
5914
5938
|
const mergedPackageJson = merge(destinationPackageJson, configPackageJson);
|
|
5915
|
-
fse2.writeJSONSync(destinationPackage, mergedPackageJson, { spaces:
|
|
5939
|
+
fse2.writeJSONSync(destinationPackage, mergedPackageJson, { spaces: " " });
|
|
5940
|
+
await formatFileInPlace(destinationPackage);
|
|
5916
5941
|
} else {
|
|
5917
5942
|
const destinationPackageJson = fse2.readJsonSync(destinationPackage);
|
|
5918
5943
|
if (Object.keys(destinationPackageJson).includes(configKey)) {
|
|
@@ -5922,14 +5947,28 @@ Package config key "${configKey}" in "${destination}" (Because --location is set
|
|
|
5922
5947
|
`
|
|
5923
5948
|
);
|
|
5924
5949
|
delete destinationPackageJson[configKey];
|
|
5925
|
-
fse2.writeJSONSync(destinationPackage, destinationPackageJson, { spaces:
|
|
5950
|
+
fse2.writeJSONSync(destinationPackage, destinationPackageJson, { spaces: " " });
|
|
5951
|
+
await formatFileInPlace(destinationPackage);
|
|
5926
5952
|
}
|
|
5927
5953
|
}
|
|
5928
5954
|
}
|
|
5955
|
+
const sourceExists = await fse2.pathExists(source);
|
|
5956
|
+
if (!sourceExists) {
|
|
5957
|
+
return 0;
|
|
5958
|
+
}
|
|
5959
|
+
const sourceFiles = await fse2.readdir(source);
|
|
5960
|
+
if (sourceFiles.length === 0) {
|
|
5961
|
+
logStream.write(`Source directory "${source}" is empty.
|
|
5962
|
+
`);
|
|
5963
|
+
return 0;
|
|
5964
|
+
}
|
|
5965
|
+
logStream.write(`Adding initial configuration files from:
|
|
5966
|
+
"${source}" \u2192 "${destination}"
|
|
5967
|
+
`);
|
|
5929
5968
|
await fse2.copy(source, destination, {
|
|
5930
|
-
filter(source2, destination2) {
|
|
5931
|
-
const isFile =
|
|
5932
|
-
const destinationExists =
|
|
5969
|
+
async filter(source2, destination2) {
|
|
5970
|
+
const isFile = fs3.statSync(source2).isFile();
|
|
5971
|
+
const destinationExists = fs3.existsSync(destination2);
|
|
5933
5972
|
if (isFile) {
|
|
5934
5973
|
if (hasConfigLocationOption && location === "package" && source2.includes(configFile)) {
|
|
5935
5974
|
if (destinationExists) {
|
|
@@ -5948,25 +5987,28 @@ Package config key "${configKey}" in "${destination}" (Because --location is set
|
|
|
5948
5987
|
}
|
|
5949
5988
|
return false;
|
|
5950
5989
|
}
|
|
5951
|
-
if (destinationExists && destination2.includes(".vscode/") && path3.extname(destination2) === ".json") {
|
|
5990
|
+
if (destinationExists && (destination2.includes(".vscode/") || destination2.includes("package.json")) && path3.extname(destination2) === ".json") {
|
|
5952
5991
|
logStream.write(`Merging:
|
|
5953
5992
|
"${source2}" \u2192 "${destination2}"
|
|
5954
5993
|
`);
|
|
5955
5994
|
const sourceJson = fse2.readJSONSync(source2);
|
|
5956
5995
|
const destinationJson = fse2.readJSONSync(destination2);
|
|
5957
5996
|
const mergedJson = merge(destinationJson, sourceJson);
|
|
5958
|
-
fse2.writeJSONSync(destination2, mergedJson, { spaces:
|
|
5997
|
+
fse2.writeJSONSync(destination2, mergedJson, { spaces: " " });
|
|
5998
|
+
await formatFileInPlace(destination2);
|
|
5959
5999
|
return false;
|
|
5960
6000
|
}
|
|
5961
6001
|
if (destinationExists) {
|
|
5962
6002
|
logStream.write(`Overwriting:
|
|
5963
6003
|
"${source2}" \u2192 "${destination2}"
|
|
5964
6004
|
`);
|
|
6005
|
+
await formatFileInPlace(destination2);
|
|
5965
6006
|
return true;
|
|
5966
6007
|
}
|
|
5967
6008
|
logStream.write(`Copying:
|
|
5968
6009
|
"${source2}" \u2192 "${destination2}"
|
|
5969
6010
|
`);
|
|
6011
|
+
await formatFileInPlace(destination2);
|
|
5970
6012
|
return true;
|
|
5971
6013
|
}
|
|
5972
6014
|
return true;
|
|
@@ -6006,11 +6048,12 @@ async function buildCommands(commandDefinition2) {
|
|
|
6006
6048
|
// Command: init.locationOptionFlag ? 'init [--location]' : 'init',
|
|
6007
6049
|
describe: init.description ?? `Initialize by copying starter config files to your project root${init.locationOptionFlag ? " or to your package.json file." : "."}`,
|
|
6008
6050
|
async handler(argv) {
|
|
6051
|
+
const location = init.locationOptionFlag ? argv.location : void 0;
|
|
6009
6052
|
const copyAndMergeInitFilesCommand = {
|
|
6010
|
-
async execute(logStream2) {
|
|
6053
|
+
async execute(logStream2, _, optionFlags) {
|
|
6011
6054
|
return copyAndMergeInitFiles(
|
|
6012
6055
|
logStream2,
|
|
6013
|
-
|
|
6056
|
+
optionFlags.at(1),
|
|
6014
6057
|
init.configFile,
|
|
6015
6058
|
init.configPackageJson
|
|
6016
6059
|
);
|
|
@@ -6020,7 +6063,7 @@ async function buildCommands(commandDefinition2) {
|
|
|
6020
6063
|
const exitCode = await executeCommands(
|
|
6021
6064
|
logStream,
|
|
6022
6065
|
[],
|
|
6023
|
-
[],
|
|
6066
|
+
location === void 0 ? [] : ["--location", location],
|
|
6024
6067
|
[copyAndMergeInitFilesCommand, ...init.commands ?? []]
|
|
6025
6068
|
);
|
|
6026
6069
|
process.exit(exitCode);
|
|
@@ -6158,6 +6201,21 @@ async function checkForUnusedWords(fileGlobs = ["."]) {
|
|
|
6158
6201
|
}
|
|
6159
6202
|
|
|
6160
6203
|
// src/command.ts
|
|
6204
|
+
async function getCspellIgnorePaths() {
|
|
6205
|
+
const config = await getDefaultConfigLoader2().searchForConfigFile(void 0);
|
|
6206
|
+
if (config === void 0) {
|
|
6207
|
+
throw new Error("No CSpell configuration found.");
|
|
6208
|
+
}
|
|
6209
|
+
const resolvedConfig = await resolveConfigFileImports(config);
|
|
6210
|
+
if (resolvedConfig.ignorePaths === void 0) {
|
|
6211
|
+
return "";
|
|
6212
|
+
}
|
|
6213
|
+
const globStrings = [];
|
|
6214
|
+
for (const globDefOrString of resolvedConfig.ignorePaths) {
|
|
6215
|
+
globStrings.push(typeof globDefOrString === "string" ? globDefOrString : globDefOrString.glob);
|
|
6216
|
+
}
|
|
6217
|
+
return globStrings.join(",");
|
|
6218
|
+
}
|
|
6161
6219
|
async function checkForUnusedWordsCommand(logStream, positionalArguments) {
|
|
6162
6220
|
const unusedWords = await checkForUnusedWords(positionalArguments);
|
|
6163
6221
|
if (unusedWords.length > 0) {
|
|
@@ -6202,7 +6260,12 @@ async function casePoliceCommand(logStream, positionalArguments) {
|
|
|
6202
6260
|
logColor: "cyanBright",
|
|
6203
6261
|
logPrefix,
|
|
6204
6262
|
name: "case-police",
|
|
6205
|
-
optionFlags: [
|
|
6263
|
+
optionFlags: [
|
|
6264
|
+
"--dict",
|
|
6265
|
+
await getCasePoliceDictionaryPath(),
|
|
6266
|
+
"--ignore",
|
|
6267
|
+
await getCspellIgnorePaths()
|
|
6268
|
+
],
|
|
6206
6269
|
receivePositionalArguments: true
|
|
6207
6270
|
}
|
|
6208
6271
|
]
|
|
@@ -6227,7 +6290,7 @@ async function printCspellConfigCommand(logStream) {
|
|
|
6227
6290
|
var commandDefinition = {
|
|
6228
6291
|
commands: {
|
|
6229
6292
|
init: {
|
|
6230
|
-
configFile: "cspell.config.
|
|
6293
|
+
configFile: "cspell.config.js",
|
|
6231
6294
|
configPackageJson: {
|
|
6232
6295
|
cspell: {
|
|
6233
6296
|
import: "@kitschpatrol/cspell-config"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kitschpatrol/cspell-config",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.2",
|
|
4
4
|
"description": "CSpell configuration for @kitschpatrol/shared-config.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"shared-config",
|
|
@@ -48,7 +48,9 @@
|
|
|
48
48
|
"cspell": "^8.17.3",
|
|
49
49
|
"cspell-lib": "^8.17.3",
|
|
50
50
|
"execa": "^9.5.2",
|
|
51
|
-
"
|
|
51
|
+
"find-workspaces": "^0.3.1",
|
|
52
|
+
"fs-extra": "^11.3.0",
|
|
53
|
+
"prettier": "^3.4.2"
|
|
52
54
|
},
|
|
53
55
|
"engines": {
|
|
54
56
|
"node": ">=22.0.0",
|