@kitschpatrol/shared-config 5.0.0 → 5.0.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/bin/cli.js +103 -23
- package/package.json +11 -10
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.1";
|
|
5545
5545
|
|
|
5546
5546
|
// ../../src/execa-utils.ts
|
|
5547
5547
|
function isErrorExecaError(error) {
|
|
@@ -5753,6 +5753,29 @@ function getCwdOverride(option) {
|
|
|
5753
5753
|
return process.cwd();
|
|
5754
5754
|
}
|
|
5755
5755
|
|
|
5756
|
+
// ../../src/prettier-utils.ts
|
|
5757
|
+
import fs2 from "node:fs/promises";
|
|
5758
|
+
async function formatTextAndSaveFile(filePath, content) {
|
|
5759
|
+
try {
|
|
5760
|
+
const { default: prettier } = await import("prettier");
|
|
5761
|
+
const prettierConfig = await prettier.resolveConfig(filePath);
|
|
5762
|
+
const formattedContent = await prettier.format(content, {
|
|
5763
|
+
filepath: filePath,
|
|
5764
|
+
...prettierConfig
|
|
5765
|
+
});
|
|
5766
|
+
await fs2.writeFile(filePath, formattedContent, "utf8");
|
|
5767
|
+
} catch {
|
|
5768
|
+
console.warn(`Skipped formatting ${filePath} since Prettier is not installed.`);
|
|
5769
|
+
}
|
|
5770
|
+
}
|
|
5771
|
+
async function formatFileInPlace(filePath) {
|
|
5772
|
+
try {
|
|
5773
|
+
const content = await fs2.readFile(filePath, "utf8");
|
|
5774
|
+
await formatTextAndSaveFile(filePath, content);
|
|
5775
|
+
} catch {
|
|
5776
|
+
}
|
|
5777
|
+
}
|
|
5778
|
+
|
|
5756
5779
|
// ../../src/stream-utils.ts
|
|
5757
5780
|
import { Transform } from "node:stream";
|
|
5758
5781
|
function createStreamFilter(matcher) {
|
|
@@ -5810,7 +5833,11 @@ async function executeFunctionCommand(logStream, positionalArguments, optionFlag
|
|
|
5810
5833
|
targetStream = subStream;
|
|
5811
5834
|
}
|
|
5812
5835
|
if (verbose) {
|
|
5813
|
-
targetStream.write(
|
|
5836
|
+
targetStream.write(
|
|
5837
|
+
source_default.bold(
|
|
5838
|
+
`Running: "${command2.name}() with Positional arguments: ${String(positionalArguments)} and Option flags: ${String(optionFlags)}"`
|
|
5839
|
+
)
|
|
5840
|
+
);
|
|
5814
5841
|
}
|
|
5815
5842
|
try {
|
|
5816
5843
|
exitCode = await command2.execute(targetStream, positionalArguments, optionFlags);
|
|
@@ -5928,9 +5955,6 @@ async function copyAndMergeInitFiles(logStream, location, configFile, configPack
|
|
|
5928
5955
|
const source = path3.join(path3.dirname(sourcePackage), "init");
|
|
5929
5956
|
const destination = path3.dirname(destinationPackage);
|
|
5930
5957
|
const hasConfigLocationOption = (location === "file" || location === "package") && configFile !== void 0 && configPackageJson !== void 0;
|
|
5931
|
-
logStream.write(`Adding initial configuration files from:
|
|
5932
|
-
"${source}" \u2192 "${destination}"
|
|
5933
|
-
`);
|
|
5934
5958
|
try {
|
|
5935
5959
|
if (hasConfigLocationOption) {
|
|
5936
5960
|
const configKey = Object.keys(configPackageJson)[0];
|
|
@@ -5942,7 +5966,8 @@ Package config key "${configKey}" \u2192 "${destination}" (Because --location is
|
|
|
5942
5966
|
`
|
|
5943
5967
|
);
|
|
5944
5968
|
const mergedPackageJson = merge(destinationPackageJson, configPackageJson);
|
|
5945
|
-
fse2.writeJSONSync(destinationPackage, mergedPackageJson, { spaces:
|
|
5969
|
+
fse2.writeJSONSync(destinationPackage, mergedPackageJson, { spaces: " " });
|
|
5970
|
+
await formatFileInPlace(destinationPackage);
|
|
5946
5971
|
} else {
|
|
5947
5972
|
const destinationPackageJson = fse2.readJsonSync(destinationPackage);
|
|
5948
5973
|
if (Object.keys(destinationPackageJson).includes(configKey)) {
|
|
@@ -5952,14 +5977,28 @@ Package config key "${configKey}" in "${destination}" (Because --location is set
|
|
|
5952
5977
|
`
|
|
5953
5978
|
);
|
|
5954
5979
|
delete destinationPackageJson[configKey];
|
|
5955
|
-
fse2.writeJSONSync(destinationPackage, destinationPackageJson, { spaces:
|
|
5980
|
+
fse2.writeJSONSync(destinationPackage, destinationPackageJson, { spaces: " " });
|
|
5981
|
+
await formatFileInPlace(destinationPackage);
|
|
5956
5982
|
}
|
|
5957
5983
|
}
|
|
5958
5984
|
}
|
|
5985
|
+
const sourceExists = await fse2.pathExists(source);
|
|
5986
|
+
if (!sourceExists) {
|
|
5987
|
+
return 0;
|
|
5988
|
+
}
|
|
5989
|
+
const sourceFiles = await fse2.readdir(source);
|
|
5990
|
+
if (sourceFiles.length === 0) {
|
|
5991
|
+
logStream.write(`Source directory "${source}" is empty.
|
|
5992
|
+
`);
|
|
5993
|
+
return 0;
|
|
5994
|
+
}
|
|
5995
|
+
logStream.write(`Adding initial configuration files from:
|
|
5996
|
+
"${source}" \u2192 "${destination}"
|
|
5997
|
+
`);
|
|
5959
5998
|
await fse2.copy(source, destination, {
|
|
5960
|
-
filter(source2, destination2) {
|
|
5961
|
-
const isFile =
|
|
5962
|
-
const destinationExists =
|
|
5999
|
+
async filter(source2, destination2) {
|
|
6000
|
+
const isFile = fs3.statSync(source2).isFile();
|
|
6001
|
+
const destinationExists = fs3.existsSync(destination2);
|
|
5963
6002
|
if (isFile) {
|
|
5964
6003
|
if (hasConfigLocationOption && location === "package" && source2.includes(configFile)) {
|
|
5965
6004
|
if (destinationExists) {
|
|
@@ -5978,25 +6017,28 @@ Package config key "${configKey}" in "${destination}" (Because --location is set
|
|
|
5978
6017
|
}
|
|
5979
6018
|
return false;
|
|
5980
6019
|
}
|
|
5981
|
-
if (destinationExists && destination2.includes(".vscode/") && path3.extname(destination2) === ".json") {
|
|
6020
|
+
if (destinationExists && (destination2.includes(".vscode/") || destination2.includes("package.json")) && path3.extname(destination2) === ".json") {
|
|
5982
6021
|
logStream.write(`Merging:
|
|
5983
6022
|
"${source2}" \u2192 "${destination2}"
|
|
5984
6023
|
`);
|
|
5985
6024
|
const sourceJson = fse2.readJSONSync(source2);
|
|
5986
6025
|
const destinationJson = fse2.readJSONSync(destination2);
|
|
5987
6026
|
const mergedJson = merge(destinationJson, sourceJson);
|
|
5988
|
-
fse2.writeJSONSync(destination2, mergedJson, { spaces:
|
|
6027
|
+
fse2.writeJSONSync(destination2, mergedJson, { spaces: " " });
|
|
6028
|
+
await formatFileInPlace(destination2);
|
|
5989
6029
|
return false;
|
|
5990
6030
|
}
|
|
5991
6031
|
if (destinationExists) {
|
|
5992
6032
|
logStream.write(`Overwriting:
|
|
5993
6033
|
"${source2}" \u2192 "${destination2}"
|
|
5994
6034
|
`);
|
|
6035
|
+
await formatFileInPlace(destination2);
|
|
5995
6036
|
return true;
|
|
5996
6037
|
}
|
|
5997
6038
|
logStream.write(`Copying:
|
|
5998
6039
|
"${source2}" \u2192 "${destination2}"
|
|
5999
6040
|
`);
|
|
6041
|
+
await formatFileInPlace(destination2);
|
|
6000
6042
|
return true;
|
|
6001
6043
|
}
|
|
6002
6044
|
return true;
|
|
@@ -6036,11 +6078,12 @@ async function buildCommands(commandDefinition11) {
|
|
|
6036
6078
|
// Command: init.locationOptionFlag ? 'init [--location]' : 'init',
|
|
6037
6079
|
describe: init.description ?? `Initialize by copying starter config files to your project root${init.locationOptionFlag ? " or to your package.json file." : "."}`,
|
|
6038
6080
|
async handler(argv) {
|
|
6081
|
+
const location = init.locationOptionFlag ? argv.location : void 0;
|
|
6039
6082
|
const copyAndMergeInitFilesCommand = {
|
|
6040
|
-
async execute(logStream2) {
|
|
6083
|
+
async execute(logStream2, _, optionFlags) {
|
|
6041
6084
|
return copyAndMergeInitFiles(
|
|
6042
6085
|
logStream2,
|
|
6043
|
-
|
|
6086
|
+
optionFlags.at(1),
|
|
6044
6087
|
init.configFile,
|
|
6045
6088
|
init.configPackageJson
|
|
6046
6089
|
);
|
|
@@ -6050,7 +6093,7 @@ async function buildCommands(commandDefinition11) {
|
|
|
6050
6093
|
const exitCode = await executeCommands(
|
|
6051
6094
|
logStream,
|
|
6052
6095
|
[],
|
|
6053
|
-
[],
|
|
6096
|
+
location === void 0 ? [] : ["--location", location],
|
|
6054
6097
|
[copyAndMergeInitFilesCommand, ...init.commands ?? []]
|
|
6055
6098
|
);
|
|
6056
6099
|
process.exit(exitCode);
|
|
@@ -6231,6 +6274,21 @@ async function checkForUnusedWords(fileGlobs = ["."]) {
|
|
|
6231
6274
|
}
|
|
6232
6275
|
|
|
6233
6276
|
// ../cspell-config/src/command.ts
|
|
6277
|
+
async function getCspellIgnorePaths() {
|
|
6278
|
+
const config = await getDefaultConfigLoader2().searchForConfigFile(void 0);
|
|
6279
|
+
if (config === void 0) {
|
|
6280
|
+
throw new Error("No CSpell configuration found.");
|
|
6281
|
+
}
|
|
6282
|
+
const resolvedConfig = await resolveConfigFileImports(config);
|
|
6283
|
+
if (resolvedConfig.ignorePaths === void 0) {
|
|
6284
|
+
return "";
|
|
6285
|
+
}
|
|
6286
|
+
const globStrings = [];
|
|
6287
|
+
for (const globDefOrString of resolvedConfig.ignorePaths) {
|
|
6288
|
+
globStrings.push(typeof globDefOrString === "string" ? globDefOrString : globDefOrString.glob);
|
|
6289
|
+
}
|
|
6290
|
+
return globStrings.join(",");
|
|
6291
|
+
}
|
|
6234
6292
|
async function checkForUnusedWordsCommand(logStream, positionalArguments) {
|
|
6235
6293
|
const unusedWords = await checkForUnusedWords(positionalArguments);
|
|
6236
6294
|
if (unusedWords.length > 0) {
|
|
@@ -6275,7 +6333,12 @@ async function casePoliceCommand(logStream, positionalArguments) {
|
|
|
6275
6333
|
logColor: "cyanBright",
|
|
6276
6334
|
logPrefix,
|
|
6277
6335
|
name: "case-police",
|
|
6278
|
-
optionFlags: [
|
|
6336
|
+
optionFlags: [
|
|
6337
|
+
"--dict",
|
|
6338
|
+
await getCasePoliceDictionaryPath(),
|
|
6339
|
+
"--ignore",
|
|
6340
|
+
await getCspellIgnorePaths()
|
|
6341
|
+
],
|
|
6279
6342
|
receivePositionalArguments: true
|
|
6280
6343
|
}
|
|
6281
6344
|
]
|
|
@@ -6300,7 +6363,7 @@ async function printCspellConfigCommand(logStream) {
|
|
|
6300
6363
|
var commandDefinition = {
|
|
6301
6364
|
commands: {
|
|
6302
6365
|
init: {
|
|
6303
|
-
configFile: "cspell.config.
|
|
6366
|
+
configFile: "cspell.config.js",
|
|
6304
6367
|
configPackageJson: {
|
|
6305
6368
|
cspell: {
|
|
6306
6369
|
import: "@kitschpatrol/cspell-config"
|
|
@@ -6426,6 +6489,10 @@ import path6 from "node:path";
|
|
|
6426
6489
|
// ../knip-config/src/index.ts
|
|
6427
6490
|
var sharedKnipConfig = {
|
|
6428
6491
|
entry: [
|
|
6492
|
+
// Default entry... not merging in from default Knip config?
|
|
6493
|
+
"{index,cli,main}.{js,mjs,cjs,jsx,ts,tsx,mts,cts}!",
|
|
6494
|
+
"src/{index,cli,main}.{js,mjs,cjs,jsx,ts,tsx,mts,cts}!",
|
|
6495
|
+
// Customized entries
|
|
6429
6496
|
"scripts/**/*.ts",
|
|
6430
6497
|
".remarkrc.js",
|
|
6431
6498
|
"cspell.config.js",
|
|
@@ -6433,6 +6500,19 @@ var sharedKnipConfig = {
|
|
|
6433
6500
|
"mdat.config.ts",
|
|
6434
6501
|
"prettier.config.js",
|
|
6435
6502
|
"stylelint.config.js"
|
|
6503
|
+
],
|
|
6504
|
+
ignoreDependencies: [
|
|
6505
|
+
"@kitschpatrol/cspell-config",
|
|
6506
|
+
"@kitschpatrol/eslint-config",
|
|
6507
|
+
"@kitschpatrol/knip-config",
|
|
6508
|
+
"@kitschpatrol/mdat-config",
|
|
6509
|
+
"@kitschpatrol/prettier-config",
|
|
6510
|
+
"@kitschpatrol/remark-config",
|
|
6511
|
+
"@kitschpatrol/repo-config",
|
|
6512
|
+
// Technically not needed?
|
|
6513
|
+
"@kitschpatrol/stylelint-config",
|
|
6514
|
+
"@kitschpatrol/typescript-config"
|
|
6515
|
+
// Technically not needed?
|
|
6436
6516
|
]
|
|
6437
6517
|
};
|
|
6438
6518
|
var src_default = sharedKnipConfig;
|
|
@@ -6658,7 +6738,7 @@ var commandDefinition6 = {
|
|
|
6658
6738
|
plugins: ["@kitschpatrol/remark-config"]
|
|
6659
6739
|
}
|
|
6660
6740
|
},
|
|
6661
|
-
locationOptionFlag:
|
|
6741
|
+
locationOptionFlag: true
|
|
6662
6742
|
},
|
|
6663
6743
|
printConfig: {
|
|
6664
6744
|
commands: [getCosmiconfigCommand("remark")],
|
|
@@ -6674,7 +6754,7 @@ var commandDefinition6 = {
|
|
|
6674
6754
|
};
|
|
6675
6755
|
|
|
6676
6756
|
// ../repo-config/src/copyright-year-updater.ts
|
|
6677
|
-
import
|
|
6757
|
+
import fs4 from "node:fs/promises";
|
|
6678
6758
|
|
|
6679
6759
|
// ../../src/node-utils.ts
|
|
6680
6760
|
import process5 from "node:process";
|
|
@@ -6735,7 +6815,7 @@ async function copyrightYear(logStream, fix = false) {
|
|
|
6735
6815
|
"!node_modules/**"
|
|
6736
6816
|
];
|
|
6737
6817
|
suppressNodeWarnings();
|
|
6738
|
-
for await (const filePath of
|
|
6818
|
+
for await (const filePath of fs4.glob(patterns, {
|
|
6739
6819
|
cwd: getPackageDirectory(),
|
|
6740
6820
|
// Will find monorepo packages
|
|
6741
6821
|
withFileTypes: false
|
|
@@ -6746,12 +6826,12 @@ async function copyrightYear(logStream, fix = false) {
|
|
|
6746
6826
|
const outdatedLicenseFiles = [];
|
|
6747
6827
|
for (const filePath of licenseFiles) {
|
|
6748
6828
|
try {
|
|
6749
|
-
const originalContent = await
|
|
6829
|
+
const originalContent = await fs4.readFile(filePath, "utf8");
|
|
6750
6830
|
const updatedContent = updateLicenseContent(originalContent, currentYear);
|
|
6751
6831
|
if (updatedContent !== originalContent) {
|
|
6752
6832
|
outdatedLicenseFiles.push(filePath);
|
|
6753
6833
|
if (fix) {
|
|
6754
|
-
await
|
|
6834
|
+
await fs4.writeFile(filePath, updatedContent, "utf8");
|
|
6755
6835
|
}
|
|
6756
6836
|
}
|
|
6757
6837
|
} catch (error) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kitschpatrol/shared-config",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.1",
|
|
4
4
|
"description": "A collection of shared configurations for various linters and formatting tools. All managed as a single dependency, and invoked via a single command.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"shared-config",
|
|
@@ -39,15 +39,16 @@
|
|
|
39
39
|
"cosmiconfig": "^9.0.0",
|
|
40
40
|
"execa": "^9.5.2",
|
|
41
41
|
"fs-extra": "^11.3.0",
|
|
42
|
-
"
|
|
43
|
-
"@kitschpatrol/
|
|
44
|
-
"@kitschpatrol/
|
|
45
|
-
"@kitschpatrol/
|
|
46
|
-
"@kitschpatrol/
|
|
47
|
-
"@kitschpatrol/
|
|
48
|
-
"@kitschpatrol/
|
|
49
|
-
"@kitschpatrol/stylelint-config": "5.0.
|
|
50
|
-
"@kitschpatrol/
|
|
42
|
+
"prettier": "^3.4.2",
|
|
43
|
+
"@kitschpatrol/cspell-config": "5.0.1",
|
|
44
|
+
"@kitschpatrol/eslint-config": "5.0.1",
|
|
45
|
+
"@kitschpatrol/mdat-config": "5.0.1",
|
|
46
|
+
"@kitschpatrol/prettier-config": "5.0.1",
|
|
47
|
+
"@kitschpatrol/knip-config": "5.0.1",
|
|
48
|
+
"@kitschpatrol/remark-config": "5.0.1",
|
|
49
|
+
"@kitschpatrol/stylelint-config": "5.0.1",
|
|
50
|
+
"@kitschpatrol/repo-config": "5.0.1",
|
|
51
|
+
"@kitschpatrol/typescript-config": "5.0.1"
|
|
51
52
|
},
|
|
52
53
|
"devDependencies": {
|
|
53
54
|
"chalk": "^5.4.1",
|