@kitschpatrol/cspell-config 6.1.0 → 7.0.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.
package/bin/cli.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
- import"cosmiconfig";import"cosmiconfig-typescript-loader";import{execa as e}from"execa";import t from"fs-extra";import n,{constants as r}from"node:fs";import i from"node:path";import{PassThrough as a,Transform as o}from"node:stream";import{fileURLToPath as s}from"node:url";import{packageUp as c,packageUpSync as l}from"package-up";import u from"picocolors";import d from"yargs";import{hideBin as f}from"yargs/helpers";import p from"@pinojs/json-colorizer";import m from"decircular";import h from"deepmerge";import g from"json-stringify-pretty-compact";import{findWorkspacesRoot as _}from"find-workspaces";import v,{access as y}from"node:fs/promises";import{getDefaultConfigLoader as b,resolveConfigFileImports as x}from"cspell-lib";import{stripVTControlCharacters as S}from"node:util";import{lint as C}from"cspell";var w=`6.1.0`;function T(e){return e instanceof Error&&`exitCode`in e&&typeof e.exitCode==`number`}function E(e){return p(g(m(e),{indent:2,replacer(e,t){return typeof t==`function`?t.name:t}}),{colors:{BRACKET:`gray`}})}const D=(e,t,n)=>{let r=[...e];for(let[i,a]of t.entries())r[i]===void 0?r[i]=n.cloneUnlessOtherwiseSpecified(a,n):n.isMergeableObject(a)?r[i]=O(e[i],a,n):e.includes(a)||r.push(a);return r};function O(e,t,n={arrayMerge:D}){return h(e,t,n)}function k(){let e=l();if(e===void 0)throw Error(`No package.json found.`);return i.dirname(e)}function A(){let e=_();return e===null?k():e.location}function j(e){if(e===`workspace-root`)return A();if(e===`package-dir`)return k();if(typeof e==`string`){if(!t.pathExistsSync(e))throw Error(`Custom cwd directory does not exist: ${e}`);return e}return process.cwd()}async function M(e,t){try{let{default:n}=await import(`prettier`),r=await n.resolveConfig(e),i=await n.format(t,{filepath:e,...r});await v.writeFile(e,i,`utf8`)}catch{console.warn(`Skipped formatting ${e} since Prettier is not installed.`)}}async function N(e){try{await M(e,await v.readFile(e,`utf8`))}catch{}}function P(e){return new o({transform(t,n,r){let i=t.toString().split(/\r?\n/).filter(t=>t.trim()!==``&&!e(t)).join(`
2
+ import"cosmiconfig";import"cosmiconfig-typescript-loader";import{execa as e}from"execa";import t from"fs-extra";import n,{constants as r}from"node:fs";import i from"node:path";import{PassThrough as a,Transform as o}from"node:stream";import{fileURLToPath as s}from"node:url";import{packageUp as c,packageUpSync as l}from"package-up";import u from"picocolors";import d from"yargs";import{hideBin as f}from"yargs/helpers";import p from"@pinojs/json-colorizer";import m from"decircular";import h from"deepmerge";import g from"json-stringify-pretty-compact";import{findWorkspacesRoot as _}from"find-workspaces";import v,{access as y}from"node:fs/promises";import{stripVTControlCharacters as b}from"node:util";import{getDefaultConfigLoader as x,resolveConfigFileImports as S}from"cspell-lib";import{lint as C}from"cspell";var w=`7.0.0`;function T(e){return e instanceof Error&&`exitCode`in e&&typeof e.exitCode==`number`}function E(e){return p(g(m(e),{indent:2,replacer(e,t){return typeof t==`function`?t.name:t}}),{colors:{BRACKET:`gray`}})}const D=(e,t,n)=>{let r=[...e];for(let[i,a]of t.entries())r[i]===void 0?r[i]=n.cloneUnlessOtherwiseSpecified(a,n):n.isMergeableObject(a)?r[i]=O(e[i],a,n):e.includes(a)||r.push(a);return r};function O(e,t,n={arrayMerge:D}){return h(e,t,n)}function k(){let e=l();if(e===void 0)throw Error(`No package.json found.`);return i.dirname(e)}function A(){let e=_();return e===null?k():i.resolve(e.location)}function j(e){if(e===`workspace-root`)return A();if(e===`package-dir`)return k();if(typeof e==`string`){if(!t.pathExistsSync(e))throw Error(`Custom cwd directory does not exist: ${e}`);return e}return process.cwd()}async function M(e,t){try{let{default:n}=await import(`prettier`),r=await n.resolveConfig(e),i=await n.format(t,{filepath:e,...r});await v.writeFile(e,i,`utf8`)}catch{console.warn(`Skipped formatting ${e} since Prettier is not installed.`)}}async function N(e){try{await M(e,await v.readFile(e,`utf8`))}catch{}}const P=/\r?\n/;function F(e){return new o({transform(t,n,r){let i=t.toString().split(P).filter(t=>t.trim()!==``&&!e(b(t))).join(`
3
3
  `);this.push(i+`
4
- `),r()}})}function F(e,t){return new o({transform(n,r,i){let a=n.toString().split(/\r?\n/).filter(e=>e.trim().length>0).map(n=>`${e?t===void 0?e:u[t](e):``} ${n}\n`).join(``);this.push(a),i()}})}async function I(e){let t=[];return new Promise((n,r)=>{e.on(`data`,e=>t.push(e)),e.on(`error`,e=>{r(e)}),e.on(`end`,()=>{n(Buffer.concat(t).toString(`utf8`))})})}function L(e,t){return t===1?e:e+`s`}async function R(e,t,n,r,i){let a=1,o;if(r.logPrefix===void 0)o=e;else{let t=F(r.logPrefix,r.logColor);t.pipe(e),o=t}i&&o.write(u.bold(`Running: "${r.name}() with Positional arguments: ${String(t)} and Option flags: ${String(n)}"`));try{a=await r.execute(o,t,n)}catch(e){console.error(String(e)),a=1}return a}async function z(t,n,r,i,o){let s=1,c;if(i.logPrefix===void 0)c=t;else{let e=F(i.logPrefix,i.logColor);e.pipe(t),c=e}let l=i.subcommands??[],u=[...i.receivePositionalArguments?n:[],...i.positionalArguments??[]],d=[...i.receiveOptionFlags?r:[],...i.optionFlags??[]],f=[...l,...d,...u],p=j(i.cwdOverride);o&&c.write(`Running: "${i.name} ${f.join(` `)}"`);let m=i.prettyJsonOutput?new a:c;try{let t=e(i.name,f,{cwd:p,env:{...process.env.NO_COLOR===void 0?{FORCE_COLOR:`true`}:{}},preferLocal:!0,reject:!1,stdin:`inherit`});if(t.stdout.pipe(m,{end:!1}),t.stderr.pipe(m,{end:!1}),await t,i.prettyJsonOutput){m.end();let e=await I(m),t=E(JSON.parse(e)).split(`
5
- `);for(let e of t)c.write(`${e}\n`)}s=t.exitCode??1}catch(e){console.error(`${i.name} failed with error:`),console.error(e),T(e)&&(s=typeof e.exitCode==`number`?e.exitCode:1)}return s}function B(e){return`execute`in e}async function V(e,t,n,r,i,a){let o=[];for(let a of r){let r=await(B(a)?R(e,t,n,a,i):z(e,t,n,a,i));o.push({exitCode:r,name:a.name})}if(a){let t=o.filter(({exitCode:e})=>e===0).map(({name:e})=>e),n=o.filter(({exitCode:e})=>e!==0).map(({name:e})=>e),r=o.length;t.length>0&&e.write(`✅ ${u.green(u.bold(`${t.length} / ${r} ${L(`Command`,t.length)} Succeeded:`))} ${u.green(t.join(`, `))}\n`),n.length>0&&e.write(`❌ ${u.red(u.bold(`${n.length} / ${r} ${L(`Command`,n.length)} Failed:`))} ${u.red(n.join(`, `))}\n`)}return o.every(({exitCode:e})=>e===0)?0:1}async function H(e,r,a,o){let l=await c();if(l===void 0)throw Error("The `init` command must be used in a directory with a package.json file");let u=await c({cwd:s(import.meta.url)});if(u===void 0)return e.write(`Error: The script being called was not in a package, weird.
6
- `),1;let d=i.join(i.dirname(u),`init`),f=i.dirname(l),p=(r===`file`||r===`package`)&&a!==void 0&&o!==void 0;try{if(p){let n=Object.keys(o)[0];if(r===`package`){let r=t.readJsonSync(l);e.write(`Merging: \nPackage config key "${n}" → "${f}" (Because --location is set to "package")\n`);let i=O(r,o);t.writeJSONSync(l,i,{spaces:` `}),await N(l)}else{let r=t.readJsonSync(l);Object.keys(r).includes(n)&&(e.write(`Deleting: \nPackage config key "${n}" in "${f}" (Because --location is set to "file")\n`),delete r[n],t.writeJSONSync(l,r,{spaces:` `}),await N(l))}}if(!await t.pathExists(d))return 0;if((await t.readdir(d)).length===0)return e.write(`Source directory "${d}" is empty.\n`),0;e.write(`Adding initial configuration files from:\n"${d}" → "${f}"\n`),await t.copy(d,f,{async filter(o,s){let c=n.statSync(o).isFile(),l=n.existsSync(s);if(c){if(p&&r===`package`&&o.includes(a))return l?(e.write(`Deleting: \n"${o}" → "${s}" (Because --location is set to "package")\n`),t.removeSync(s)):e.write(`Skipping: \n"${o}" → "${s}" (Because --location is set to "package")\n`),!1;if(l&&(s.includes(`.vscode/`)||s.includes(`package.json`))&&i.extname(s)===`.json`){e.write(`Merging: \n"${o}" → "${s}"\n`);let n=t.readJSONSync(o),r=O(t.readJSONSync(s),n);return t.writeJSONSync(s,r,{spaces:` `}),await N(s),!1}return l?(e.write(`Overwriting: \n"${o}" → "${s}"\n`),await N(s),!0):(e.write(`Copying: \n"${o}" → "${s}"\n`),await N(s),!0)}return!0},overwrite:!0})}catch(e){return console.error(String(e)),1}return 0}async function U(e){let{commands:{fix:t,init:n,lint:r,printConfig:i},description:a,logColor:o,logPrefix:s,name:c,showSummary:l,verbose:u}=e,p=F(s,o);p.pipe(process.stdout);let m=d(f(process.argv)).scriptName(c).usage(`$0 <command>`,a);n!==void 0&&m.command({builder(e){return n.locationOptionFlag?e.option(`location`,{choices:[`file`,`package`],default:`file`,describe:`TK`,type:`string`}):e},command:`init`,describe:n.description??`Initialize by copying starter config files to your project root${n.locationOptionFlag?` or to your package.json file.`:`.`}`,async handler(e){let t=n.locationOptionFlag?e.location:void 0,r=await V(p,[],t===void 0?[]:[`--location`,t],[{async execute(e,t,r){return H(e,r.at(1),n.configFile,n.configPackageJson)},name:`copyAndMergeInitFiles`},...n.commands??[]]);process.exit(r)}}),r!==void 0&&m.command({builder(e){return r.positionalArgumentMode===`none`?e:e.positional(`files`,{array:!0,...r.positionalArgumentDefault===void 0?{}:{default:r.positionalArgumentDefault},describe:`Files or glob pattern to lint.`,type:`string`})},command:r.positionalArgumentMode===`none`?`lint`:r.positionalArgumentMode===`optional`?`lint [files..]`:`lint <files..>`,describe:r.description,async handler(e){let t=await V(p,e.files??[],[],r.commands,u,l);process.exit(t)}}),t!==void 0&&m.command({builder(e){return t.positionalArgumentMode===`none`?e:e.positional(`files`,{array:!0,...t.positionalArgumentDefault===void 0?{}:{default:t.positionalArgumentDefault},describe:`Files or glob pattern to fix.`,type:`string`})},command:t.positionalArgumentMode===`none`?`fix`:t.positionalArgumentMode===`optional`?`fix [files..]`:`fix <files..>`,describe:t.description,async handler(e){let n=await V(p,e.files??[],[],t.commands);process.exit(n)}}),i!==void 0&&m.command({builder(e){return i.positionalArgumentMode===`none`?e:e.positional(`file`,{...i.positionalArgumentDefault===void 0?{}:{default:i.positionalArgumentDefault},describe:`File or glob pattern to TK.`,type:`string`})},command:i.positionalArgumentMode===`none`?`print-config`:i.positionalArgumentMode===`optional`?`print-config [file]`:`print-config <file>`,describe:i.description,async handler(e){let t=e.file??void 0,n=await V(p,t===void 0?[]:[t],[],i.commands,u,l);process.exit(n)}}),m.alias(`h`,`help`),m.version(w),m.alias(`v`,`version`),m.help(),m.wrap(process.stdout.isTTY?Math.min(120,m.terminalWidth()):0),await m.parseAsync()}const W={fileRun:`Matches files below the current working directory by default.`,monorepoRun:`In a monorepo, it will also run in all packages below the current working directory.`,monorepoSearch:`Searches up to the root of a monorepo if necessary.`,multiArgumentCaveat:`Will use file arguments / globs where possible if provided, but some of the invoked tools only operate at the package-scope.`,multiOptionCaveat:`Will use option flags where possible if provided, but some of the invoked tools will ignore them.`,optionalFileRun:`Package-scoped by default, file-scoped if a file argument is provided.`,packageRun:`Package-scoped.`,packageSearch:`Package-scoped.`};async function G(e=[`.`]){let t=await b().searchForConfigFile(void 0);if(t===void 0)throw Error(`No CSpell configuration found.`);let{settings:n,url:r}=t;if(n.words===void 0||n.words.length===0)return[];let i=[...n.words];return n.words=void 0,await C(e,{config:{settings:n,url:r},progress:!1,unique:!0,wordsOnly:!0},{issue({text:e,uri:t}){i=i.filter(n=>n.toLowerCase()!==e.toLowerCase().replace(/['\u2019\u2018]s$/,``)||t===r.href)}}),i}async function K(){let e=await b().searchForConfigFile(void 0);if(e===void 0)throw Error(`No CSpell configuration found.`);let t=await x(e);if(t.ignorePaths===void 0)return``;let n=[];for(let e of t.ignorePaths)n.push(typeof e==`string`?e:e.glob);return n.join(`,`)}async function q(e,t){let n=await G(t);if(n.length>0){let t=F(`[Unused Words]`,`cyanBright`);t.pipe(e);for(let e of n)t.write(`${e}\n`);return 1}return 0}async function J(){let e=import.meta.resolve(`@kitschpatrol/cspell-config`),t=await c({cwd:i.dirname(s(e))});if(t===void 0)throw Error(`Could not find Case Police dictionary parent package.`);let n=i.join(i.dirname(t),`dictionaries`,`case-police.json`);try{await y(n,r.F_OK)}catch{throw Error(`Case Police dictionary file "${n}" does not exist.`)}return n}async function Y(e,t){let n=`[Case Police]`,r=P(e=>{let t=S(e);return!t.startsWith(n)||!t.includes(`→`)});return r.pipe(e),V(r,t,[],[{logColor:`cyanBright`,logPrefix:n,name:`case-police`,optionFlags:[`--dict`,await J(),`--ignore`,await K()],receivePositionalArguments:!0}])}async function X(e){let t=await b().searchForConfigFile(void 0);if(t===void 0)throw Error(`No CSpell configuration found.`);e.write(`Found cspell readme configuration at "${s(t.url)}"\n`);let n=E(await x(t)).split(`
7
- `);for(let t of n)e.write(`${t}\n`);return 0}await U({commands:{init:{configFile:`cspell.config.ts`,configPackageJson:{cspell:{import:`@kitschpatrol/cspell-config`}},locationOptionFlag:!0},lint:{commands:[{name:`cspell`,optionFlags:[`--quiet`],receivePositionalArguments:!0},{execute:q,name:q.name},{execute:Y,name:Y.name}],description:`Check for spelling mistakes. ${W.fileRun}`,positionalArgumentDefault:`**/*`,positionalArgumentMode:`optional`},printConfig:{commands:[{execute:X,name:X.name}],description:`Print the resolved CSpell configuration. ${W.packageSearch} ${W.monorepoSearch}`,positionalArgumentMode:`none`}},description:`Kitschpatrol's CSpell shared configuration tools. (Automated fixes are handled by ESLint.)`,logColor:`cyan`,logPrefix:`[CSpell]`,name:`ksc-cspell`,order:6});export{};
4
+ `),r()}})}function I(e,t){return new o({transform(n,r,i){let a=n.toString().split(P).filter(e=>e.trim().length>0).map(n=>`${e?t===void 0?e:u[t](e):``} ${n}\n`).join(``);this.push(a),i()}})}async function L(e){let t=[];return new Promise((n,r)=>{e.on(`data`,e=>t.push(e)),e.on(`error`,e=>{r(e)}),e.on(`end`,()=>{n(Buffer.concat(t).toString(`utf8`))})})}function R(e,t){return t===1?e:e+`s`}async function z(e,t,n,r,i){let a=1,o;if(r.logPrefix===void 0)o=e;else{let t=I(r.logPrefix,r.logColor);t.pipe(e),o=t}i&&o.write(u.bold(`Running: "${r.name}() with Positional arguments: ${String(t)} and Option flags: ${String(n)}"`));try{a=await r.execute(o,t,n)}catch(e){console.error(String(e)),a=1}return a}async function B(t,n,r,i,o){let s=1,c;if(i.logPrefix===void 0)c=t;else{let e=I(i.logPrefix,i.logColor);e.pipe(t),c=e}let l=i.subcommands??[],u=[...i.receivePositionalArguments?n:[],...i.positionalArguments??[]],d=[...i.receiveOptionFlags?r:[],...i.optionFlags??[]],f=[...l,...d,...u],p=j(i.cwdOverride);o&&c.write(`Running: "${i.name} ${f.join(` `)}"`);let m=i.prettyJsonOutput?new a:c;try{let t=e(i.name,f,{cwd:p,env:{...process.env.NO_COLOR===void 0?{FORCE_COLOR:`true`}:{}},preferLocal:!0,reject:!1,stdin:`inherit`});if(i.outputFilter){let e=F(i.outputFilter),n=F(i.outputFilter);t.stdout.pipe(e).pipe(m,{end:!1}),t.stderr.pipe(n).pipe(m,{end:!1})}else t.stdout.pipe(m,{end:!1}),t.stderr.pipe(m,{end:!1});if(await t,i.prettyJsonOutput){m.end();let e=await L(m),t=E(JSON.parse(e)).split(`
5
+ `);for(let e of t)c.write(`${e}\n`)}s=t.exitCode??1}catch(e){console.error(`${i.name} failed with error:`),console.error(e),T(e)&&(s=typeof e.exitCode==`number`?e.exitCode:1)}return s}function V(e){return`execute`in e}async function H(e,t,n,r,i,a){let o=[];for(let a of r){let r=await(V(a)?z(e,t,n,a,i):B(e,t,n,a,i));o.push({exitCode:r,name:a.name})}if(a){let t=o.filter(({exitCode:e})=>e===0).map(({name:e})=>e),n=o.filter(({exitCode:e})=>e!==0).map(({name:e})=>e),r=o.length;t.length>0&&e.write(`✅ ${u.green(u.bold(`${t.length} / ${r} ${R(`Command`,t.length)} Succeeded:`))} ${u.green(t.join(`, `))}\n`),n.length>0&&e.write(`❌ ${u.red(u.bold(`${n.length} / ${r} ${R(`Command`,n.length)} Failed:`))} ${u.red(n.join(`, `))}\n`)}return o.every(({exitCode:e})=>e===0)?0:1}async function U(e,r,a,o){let l=await c();if(l===void 0)throw Error("The `init` command must be used in a directory with a package.json file");let u=await c({cwd:s(import.meta.url)});if(u===void 0)return e.write(`Error: The script being called was not in a package, weird.
6
+ `),1;let d=i.join(i.dirname(u),`init`),f=i.dirname(l),p=(r===`file`||r===`package`)&&a!==void 0&&o!==void 0;try{if(p){let n=Object.keys(o)[0];if(r===`package`){let r=t.readJsonSync(l);e.write(`Merging: \nPackage config key "${n}" → "${f}" (Because --location is set to "package")\n`);let i=O(r,o);t.writeJSONSync(l,i,{spaces:` `}),await N(l)}else{let r=t.readJsonSync(l);Object.keys(r).includes(n)&&(e.write(`Deleting: \nPackage config key "${n}" in "${f}" (Because --location is set to "file")\n`),delete r[n],t.writeJSONSync(l,r,{spaces:` `}),await N(l))}}if(!await t.pathExists(d))return 0;if((await t.readdir(d)).length===0)return e.write(`Source directory "${d}" is empty.\n`),0;e.write(`Adding initial configuration files from:\n"${d}" → "${f}"\n`),await t.copy(d,f,{async filter(o,s){let c=n.statSync(o).isFile(),l=n.existsSync(s);if(c){if(p&&r===`package`&&o.includes(a))return l?(e.write(`Deleting: \n"${o}" → "${s}" (Because --location is set to "package")\n`),t.removeSync(s)):e.write(`Skipping: \n"${o}" → "${s}" (Because --location is set to "package")\n`),!1;if(l&&(s.includes(`.vscode/`)||s.includes(`package.json`))&&i.extname(s)===`.json`){e.write(`Merging: \n"${o}" → "${s}"\n`);let n=t.readJSONSync(o),r=O(t.readJSONSync(s),n);return t.writeJSONSync(s,r,{spaces:` `}),await N(s),!1}return l?(e.write(`Overwriting: \n"${o}" → "${s}"\n`),await N(s),!0):(e.write(`Copying: \n"${o}" → "${s}"\n`),await N(s),!0)}return!0},overwrite:!0})}catch(e){return console.error(String(e)),1}return 0}async function W(e){let{commands:{fix:t,init:n,lint:r,printConfig:i},description:a,logColor:o,logPrefix:s,name:c,showSummary:l,verbose:u}=e,p=I(s,o);p.pipe(process.stdout);let m=d(f(process.argv)).scriptName(c).usage(`$0 <command>`,a);n!==void 0&&m.command({builder(e){return n.locationOptionFlag?e.option(`location`,{choices:[`file`,`package`],default:`file`,describe:`Where to store the configuration.`,type:`string`}):e},command:`init`,describe:n.description??`Initialize by copying starter config files to your project root${n.locationOptionFlag?` or to your package.json file.`:`.`}`,async handler(e){let t=n.locationOptionFlag?e.location:void 0,r=await H(p,[],t===void 0?[]:[`--location`,t],[{async execute(e,t,r){return U(e,r.at(1),n.configFile,n.configPackageJson)},name:`copyAndMergeInitFiles`},...n.commands??[]]);process.exit(r)}}),r!==void 0&&m.command({builder(e){return r.positionalArgumentMode===`none`?e:e.positional(`files`,{array:!0,...r.positionalArgumentDefault===void 0?{}:{default:r.positionalArgumentDefault},describe:`Files or glob pattern to lint.`,type:`string`})},command:r.positionalArgumentMode===`none`?`lint`:r.positionalArgumentMode===`optional`?`lint [files..]`:`lint <files..>`,describe:r.description,async handler(e){let t=await H(p,e.files??[],[],r.commands,u,l);process.exit(t)}}),t!==void 0&&m.command({builder(e){return t.positionalArgumentMode===`none`?e:e.positional(`files`,{array:!0,...t.positionalArgumentDefault===void 0?{}:{default:t.positionalArgumentDefault},describe:`Files or glob pattern to fix.`,type:`string`})},command:t.positionalArgumentMode===`none`?`fix`:t.positionalArgumentMode===`optional`?`fix [files..]`:`fix <files..>`,describe:t.description,async handler(e){let n=await H(p,e.files??[],[],t.commands);process.exit(n)}}),i!==void 0&&m.command({builder(e){return i.positionalArgumentMode===`none`?e:e.positional(`file`,{...i.positionalArgumentDefault===void 0?{}:{default:i.positionalArgumentDefault},describe:`File or glob pattern to print configuration for.`,type:`string`})},command:i.positionalArgumentMode===`none`?`print-config`:i.positionalArgumentMode===`optional`?`print-config [file]`:`print-config <file>`,describe:i.description,async handler(e){let t=e.file??void 0,n=await H(p,t===void 0?[]:[t],[],i.commands,u,l);process.exit(n)}}),m.alias(`h`,`help`),m.version(w),m.alias(`v`,`version`),m.help(),m.wrap(process.stdout.isTTY?Math.min(120,m.terminalWidth()):0),await m.parseAsync()}const G={fileRun:`Matches files below the current working directory by default.`,monorepoRun:`In a monorepo, it will also run in all packages below the current working directory.`,monorepoSearch:`Searches up to the root of a monorepo if necessary.`,multiArgumentCaveat:`Will use file arguments / globs where possible if provided, but some of the invoked tools only operate at the package-scope.`,multiOptionCaveat:`Will use option flags where possible if provided, but some of the invoked tools will ignore them.`,optionalFileRun:`Package-scoped by default, file-scoped if a file argument is provided.`,packageRun:`Package-scoped.`,packageSearch:`Package-scoped.`},K=/['\u2019\u2018]s$/;async function q(e=[`.`]){let t=await x().searchForConfigFile(void 0);if(t===void 0)throw Error(`No CSpell configuration found.`);let{settings:n,url:r}=t;if(n.words===void 0||n.words.length===0)return[];let i=[...n.words];return n.words=void 0,await C(e,{config:{settings:n,url:r},progress:!1,unique:!0,wordsOnly:!0},{issue({text:e,uri:t}){i=i.filter(n=>n.toLowerCase()!==e.toLowerCase().replace(K,``)||t===r.href)}}),i}async function J(){let e=await x().searchForConfigFile(void 0);if(e===void 0)throw Error(`No CSpell configuration found.`);let t=await S(e);if(t.ignorePaths===void 0)return``;let n=[];for(let e of t.ignorePaths)n.push(typeof e==`string`?e:e.glob);return n.join(`,`)}async function Y(e,t){let n=await q(t);if(n.length>0){let t=I(`[Unused Words]`,`cyanBright`);t.pipe(e);for(let e of n)t.write(`${e}\n`);return 1}return 0}async function X(){let e=import.meta.resolve(`@kitschpatrol/cspell-config`),t=await c({cwd:i.dirname(s(e))});if(t===void 0)throw Error(`Could not find Case Police dictionary parent package.`);let n=i.join(i.dirname(t),`dictionaries`,`case-police.json`);try{await y(n,r.F_OK)}catch{throw Error(`Case Police dictionary file "${n}" does not exist.`)}return n}async function Z(e,t){let n=`[Case Police]`,r=F(e=>{let t=b(e);return!t.startsWith(n)||!t.includes(`→`)});return r.pipe(e),H(r,t,[],[{logColor:`cyanBright`,logPrefix:n,name:`case-police`,optionFlags:[`--dict`,await X(),`--ignore`,await J()],receivePositionalArguments:!0}])}async function Q(e){let t=await x().searchForConfigFile(void 0);if(t===void 0)throw Error(`No CSpell configuration found.`);e.write(`Found cspell readme configuration at "${s(t.url)}"\n`);let n=E(await S(t)).split(`
7
+ `);for(let t of n)e.write(`${t}\n`);return 0}await W({commands:{init:{configFile:`cspell.config.ts`,configPackageJson:{cspell:{import:`@kitschpatrol/cspell-config`}},locationOptionFlag:!0},lint:{commands:[{name:`cspell`,optionFlags:[`--quiet`],receivePositionalArguments:!0},{execute:Y,name:Y.name},{execute:Z,name:Z.name}],description:`Check for spelling mistakes. ${G.fileRun}`,positionalArgumentDefault:`**/*`,positionalArgumentMode:`optional`},printConfig:{commands:[{execute:Q,name:Q.name}],description:`Print the resolved CSpell configuration. ${G.packageSearch} ${G.monorepoSearch}`,positionalArgumentMode:`none`}},description:`Kitschpatrol's CSpell shared configuration tools. (Automated fixes are handled by ESLint.)`,logColor:`cyan`,logPrefix:`[CSpell]`,name:`ksc-cspell`,order:6});export{};
@@ -69,6 +69,7 @@ camelcase
69
69
  camerakit
70
70
  cameraring
71
71
  camerawheel
72
+ canparse
72
73
  capsizecss
73
74
  certbot
74
75
  charuco
@@ -169,6 +170,7 @@ fadecandy
169
170
  fanin
170
171
  fanout
171
172
  farbfeld
173
+ farmfe
172
174
  fassets
173
175
  faststart
174
176
  favicons
package/dist/index.d.ts CHANGED
@@ -3,17 +3,16 @@ import { CSpellUserSettings } from "@cspell/cspell-types";
3
3
  //#region src/index.d.ts
4
4
  declare const sharedCspellConfig: CSpellUserSettings;
5
5
  /**
6
- * **\@Kitschpatrol's Shared Cspell Configuration**
6
+ * **@Kitschpatrol's Shared Cspell Configuration**
7
+ *
8
+ * @example
9
+ * export default cspellConfig({
10
+ * ignorePaths: ['/test/fixtures/input'],
11
+ * })
12
+ *
7
13
  * @see [@kitschpatrol/cspell-config](https://github.com/kitschpatrol/shared-config/tree/main/packages/cspell-config)
14
+ *
8
15
  * @see [@kitschpatrol/shared-config](https://github.com/kitschpatrol/shared-config)
9
- * @example
10
- * ```js
11
- * export default cspellConfig({
12
- * ignorePaths: [
13
- * '/test/fixtures/input',
14
- * ],
15
- * })
16
- * ```
17
16
  */
18
17
  declare function cspellConfig(config?: CSpellUserSettings): CSpellUserSettings;
19
18
  //#endregion
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kitschpatrol/cspell-config",
3
- "version": "6.1.0",
3
+ "version": "7.0.0",
4
4
  "description": "CSpell configuration for @kitschpatrol/shared-config.",
5
5
  "keywords": [
6
6
  "shared-config",
@@ -62,17 +62,11 @@
62
62
  "yargs": "^18.0.0"
63
63
  },
64
64
  "devDependencies": {
65
- "globby": "^16.1.1",
65
+ "globby": "^16.2.0",
66
66
  "untildify": "^6.0.0"
67
67
  },
68
68
  "engines": {
69
- "node": ">=20.19.0"
70
- },
71
- "devEngines": {
72
- "runtime": {
73
- "name": "node",
74
- "version": ">=22.18.0"
75
- }
69
+ "node": ">=22.18.0"
76
70
  },
77
71
  "publishConfig": {
78
72
  "access": "public"
package/readme.md CHANGED
@@ -1,5 +1,3 @@
1
- <!--+ Warning: Content inside HTML comment blocks was generated by mdat and may be overwritten. +-->
2
-
3
1
  <!-- title -->
4
2
 
5
3
  # @kitschpatrol/cspell-config
@@ -223,11 +221,11 @@ Usage:
223
221
  ksc-cspell init
224
222
  ```
225
223
 
226
- | Option | Description | Type | Default |
227
- | ------------------- | ------------------- | -------------------- | -------- |
228
- | `--location` | TK | `"file"` `"package"` | `"file"` |
229
- | `--help`<br>`-h` | Show help | `boolean` | |
230
- | `--version`<br>`-v` | Show version number | `boolean` | |
224
+ | Option | Description | Type | Default |
225
+ | ------------------- | --------------------------------- | -------------------- | -------- |
226
+ | `--location` | Where to store the configuration. | `"file"` `"package"` | `"file"` |
227
+ | `--help`<br>`-h` | Show help | `boolean` | |
228
+ | `--version`<br>`-v` | Show version number | `boolean` | |
231
229
 
232
230
  #### Subcommand: `ksc-cspell lint`
233
231