@kitschpatrol/shared-config 7.6.0 → 7.6.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.
Files changed (3) hide show
  1. package/bin/cli.js +1 -1
  2. package/package.json +14 -14
  3. package/readme.md +1 -1
package/bin/cli.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import{cosmiconfig as e}from"cosmiconfig";import{TypeScriptLoader as t}from"cosmiconfig-typescript-loader";import{execa as n}from"execa";import r from"fs-extra";import i,{constants as a}from"node:fs";import o from"node:path";import{PassThrough as s,Transform as c}from"node:stream";import{fileURLToPath as l}from"node:url";import{packageUp as u,packageUpSync as d}from"package-up";import f from"picocolors";import p from"yargs";import{hideBin as m}from"yargs/helpers";import h from"@pinojs/json-colorizer";import g from"decircular";import _ from"deepmerge";import ee from"json-stringify-pretty-compact";import{findWorkspaces as te,findWorkspacesRoot as ne}from"find-workspaces";import v,{access as re}from"node:fs/promises";import{stripVTControlCharacters as y}from"node:util";import{getDefaultConfigLoader as b,resolveConfigFileImports as x}from"cspell-lib";import{lint as ie}from"cspell";import"deepmerge-ts";import{loadConfig as S}from"mdat";import{globby as ae}from"globby";import C,{gt as w,minVersion as oe}from"semver";import{readWantedLockfile as se}from"@pnpm/lockfile.fs";import ce from"stylelint";var le=`7.6.0`;function ue(e){return e instanceof Error&&`exitCode`in e&&typeof e.exitCode==`number`}function T(e){return h(ee(g(e),{indent:2,replacer(e,t){return typeof t==`function`?t.name:t}}),{colors:{BRACKET:`gray`}})}const de=(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]=E(e[i],a,n):e.includes(a)||r.push(a);return r};function E(e,t,n={arrayMerge:de}){return _(e,t,n)}function fe(e,t){return e.startsWith(t+o.sep)}function pe(){let e=D(),t=new Set([e]),n=te();if(n!==null)for(let r of n){let n=o.resolve(r.location);fe(n,e)&&t.add(n)}return[...t]}function D(){let e=d();if(e===void 0)throw Error(`No package.json found.`);return o.dirname(e)}function me(){return ne()!==null}function O(){let e=ne();return e===null?D():o.resolve(e.location)}function k(e){let t=o.join(O(),e);if(r.existsSync(t))return t}function A(e){if(e===`workspace-root`)return O();if(e===`package-dir`)return D();if(typeof e==`string`){if(!r.pathExistsSync(e))throw Error(`Custom cwd directory does not exist: ${e}`);return e}return process.cwd()}async function he(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 j(e){try{await he(e,await v.readFile(e,`utf8`))}catch{}}const ge=/\r?\n/;function M(e){return new c({transform(t,n,r){let i=t.toString().split(ge).filter(t=>t.trim()!==``&&!e(y(t))).join(`
2
+ import{cosmiconfig as e}from"cosmiconfig";import{TypeScriptLoader as t}from"cosmiconfig-typescript-loader";import{execa as n}from"execa";import r from"fs-extra";import i,{constants as a}from"node:fs";import o from"node:path";import{PassThrough as s,Transform as c}from"node:stream";import{fileURLToPath as l}from"node:url";import{packageUp as u,packageUpSync as d}from"package-up";import f from"picocolors";import p from"yargs";import{hideBin as m}from"yargs/helpers";import h from"@pinojs/json-colorizer";import g from"decircular";import _ from"deepmerge";import ee from"json-stringify-pretty-compact";import{findWorkspaces as te,findWorkspacesRoot as ne}from"find-workspaces";import v,{access as re}from"node:fs/promises";import{stripVTControlCharacters as y}from"node:util";import{getDefaultConfigLoader as b,resolveConfigFileImports as x}from"cspell-lib";import{lint as ie}from"cspell";import"deepmerge-ts";import{loadConfig as S}from"mdat";import{globby as ae}from"globby";import C,{gt as w,minVersion as oe}from"semver";import{readWantedLockfile as se}from"@pnpm/lockfile.fs";import ce from"stylelint";var le=`7.6.2`;function ue(e){return e instanceof Error&&`exitCode`in e&&typeof e.exitCode==`number`}function T(e){return h(ee(g(e),{indent:2,replacer(e,t){return typeof t==`function`?t.name:t}}),{colors:{BRACKET:`gray`}})}const de=(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]=E(e[i],a,n):e.includes(a)||r.push(a);return r};function E(e,t,n={arrayMerge:de}){return _(e,t,n)}function fe(e,t){return e.startsWith(t+o.sep)}function pe(){let e=D(),t=new Set([e]),n=te();if(n!==null)for(let r of n){let n=o.resolve(r.location);fe(n,e)&&t.add(n)}return[...t]}function D(){let e=d();if(e===void 0)throw Error(`No package.json found.`);return o.dirname(e)}function me(){return ne()!==null}function O(){let e=ne();return e===null?D():o.resolve(e.location)}function k(e){let t=o.join(O(),e);if(r.existsSync(t))return t}function A(e){if(e===`workspace-root`)return O();if(e===`package-dir`)return D();if(typeof e==`string`){if(!r.pathExistsSync(e))throw Error(`Custom cwd directory does not exist: ${e}`);return e}return process.cwd()}async function he(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 j(e){try{await he(e,await v.readFile(e,`utf8`))}catch{}}const ge=/\r?\n/;function M(e){return new c({transform(t,n,r){let i=t.toString().split(ge).filter(t=>t.trim()!==``&&!e(y(t))).join(`
3
3
  `);this.push(i+`
4
4
  `),r()}})}function N(e,t){return new c({transform(n,r,i){let a=n.toString().split(ge).filter(e=>e.trim().length>0).map(n=>`${e?t===void 0?e:f[t](e):``} ${n}\n`).join(``);this.push(a),i()}})}async function _e(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 ve(e){return e.replaceAll(/[A-Z\u00C0-\u00D6\u00D8-\u00DE]/g,e=>`-`+e.toLowerCase())}function P(e,t){return t===1?e:e+`s`}async function ye(e,t,n,r,i){let a=1,o;if(r.logPrefix===void 0)o=e;else{let t=N(r.logPrefix,r.logColor);t.pipe(e),o=t}i&&o.write(f.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 be(e,t,r,i,a){let o=1,c;if(i.logPrefix===void 0)c=e;else{let t=N(i.logPrefix,i.logColor);t.pipe(e),c=t}let l=i.subcommands??[],u=[...i.receivePositionalArguments?t:[],...i.positionalArguments??[]],d=[...i.receiveOptionFlags?r:[],...i.optionFlags??[]],f=[...l,...d,...u],p=A(i.cwdOverride);a&&c.write(`Running: "${i.name} ${f.join(` `)}"`);let m=i.prettyJsonOutput?new s:c;try{let e=n(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 t=M(i.outputFilter),n=M(i.outputFilter);e.stdout.pipe(t).pipe(m,{end:!1}),e.stderr.pipe(n).pipe(m,{end:!1})}else e.stdout.pipe(m,{end:!1}),e.stderr.pipe(m,{end:!1});if(await e,i.prettyJsonOutput){m.end();let e=await _e(m),t=T(JSON.parse(e)).split(`
5
5
  `);for(let e of t)c.write(`${e}\n`)}o=e.exitCode??1}catch(e){console.error(`${i.name} failed with error:`),console.error(e),ue(e)&&(o=typeof e.exitCode==`number`?e.exitCode:1)}return o}function xe(e){return`execute`in e}const Se=/^ksc-/;function F(e){return e.replace(Se,``)}function I(e){return e===void 0||e.length===0?[]:e.flatMap(e=>e.split(`,`)).map(e=>F(e.trim()))}function L(e){return e.option(`skip`,{array:!0,describe:`Tool names to skip (with or without "ksc-" prefix).`,type:`string`})}async function R(e,t,n,r,i,a,o){let s=o??[],c=[],l=[];for(let e of r)s.length>0&&s.includes(F(e.name))?l.push(e):c.push(e);if(s.length>0){let t=new Set(l.map(e=>F(e.name))),n=s.filter(e=>!t.has(e));if(n.length>0){let t=r.map(e=>F(e.name)).join(`, `);e.write(`⚠️ ${f.yellow(`Unrecognized --skip ${P(`value`,n.length)}: ${n.join(`, `)}. Available: ${t}`)}\n`)}}let u=[];for(let r of c){let a=await(xe(r)?ye(e,t,n,r,i):be(e,t,n,r,i));u.push({exitCode:a,name:r.name})}let d=r.length;if(l.length>0){let t=l.map(({name:e})=>e);e.write(`⏭️ ${f.dim(f.bold(`${t.length} / ${d} ${P(`Command`,t.length)} Skipped:`))} ${f.dim(t.join(`, `))}\n`)}if(a){let t=u.filter(({exitCode:e})=>e===0).map(({name:e})=>e),n=u.filter(({exitCode:e})=>e!==0).map(({name:e})=>e);t.length>0&&e.write(`✅ ${f.green(f.bold(`${t.length} / ${d} ${P(`Command`,t.length)} Succeeded:`))} ${f.green(t.join(`, `))}\n`),n.length>0&&e.write(`❌ ${f.red(f.bold(`${n.length} / ${d} ${P(`Command`,n.length)} Failed:`))} ${f.red(n.join(`, `))}\n`)}return+!u.every(({exitCode:e})=>e===0)}async function Ce(e,t,n,a){let s=await u();if(s===void 0)throw Error("The `init` command must be used in a directory with a package.json file");let c=await u({cwd:l(import.meta.url)});if(c===void 0)return e.write(`Error: The script being called was not in a package, weird.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kitschpatrol/shared-config",
3
- "version": "7.6.0",
3
+ "version": "7.6.2",
4
4
  "description": "A collection of shared configurations, linters, and formatting tools for TypeScript projects. All managed as a single dependency, and invoked via a single CLI command.",
5
5
  "keywords": [
6
6
  "shared-config",
@@ -49,7 +49,7 @@
49
49
  ],
50
50
  "dependencies": {
51
51
  "@pinojs/json-colorizer": "^4.0.0",
52
- "@pnpm/lockfile.fs": "^1100.0.7",
52
+ "@pnpm/lockfile.fs": "^1100.0.8",
53
53
  "cosmiconfig": "^9.0.1",
54
54
  "cosmiconfig-typescript-loader": "^6.3.0",
55
55
  "cspell": "^10.0.0",
@@ -62,25 +62,25 @@
62
62
  "fs-extra": "^11.3.5",
63
63
  "globby": "^16.2.0",
64
64
  "json-stringify-pretty-compact": "^4.0.0",
65
- "mdat": "^2.3.2",
65
+ "mdat": "^2.3.5",
66
66
  "package-up": "^5.0.0",
67
67
  "picocolors": "^1.1.1",
68
68
  "prettier": "^3.8.3",
69
69
  "semver": "^7.8.0",
70
- "stylelint": "^17.11.0",
70
+ "stylelint": "^17.11.1",
71
71
  "yargs": "^18.0.0",
72
- "@kitschpatrol/cspell-config": "7.6.0",
73
- "@kitschpatrol/eslint-config": "7.6.0",
74
- "@kitschpatrol/knip-config": "7.6.0",
75
- "@kitschpatrol/remark-config": "7.6.0",
76
- "@kitschpatrol/prettier-config": "7.6.0",
77
- "@kitschpatrol/typescript-config": "7.6.0",
78
- "@kitschpatrol/repo-config": "7.6.0",
79
- "@kitschpatrol/mdat-config": "7.6.0",
80
- "@kitschpatrol/stylelint-config": "7.6.0"
72
+ "@kitschpatrol/eslint-config": "7.6.2",
73
+ "@kitschpatrol/knip-config": "7.6.2",
74
+ "@kitschpatrol/remark-config": "7.6.2",
75
+ "@kitschpatrol/prettier-config": "7.6.2",
76
+ "@kitschpatrol/repo-config": "7.6.2",
77
+ "@kitschpatrol/stylelint-config": "7.6.2",
78
+ "@kitschpatrol/cspell-config": "7.6.2",
79
+ "@kitschpatrol/typescript-config": "7.6.2",
80
+ "@kitschpatrol/mdat-config": "7.6.2"
81
81
  },
82
82
  "engines": {
83
- "node": ">=22.18.0"
83
+ "node": "^22.22.2 || >=24.0.0"
84
84
  },
85
85
  "publishConfig": {
86
86
  "access": "public"
package/readme.md CHANGED
@@ -112,7 +112,7 @@ The top-level `ksc` command also takes care of some nuances in terms of _which_
112
112
 
113
113
  ### Dependencies
114
114
 
115
- [Node](https://nodejs.org) >=22.18.0 is required, and [pnpm](https://pnpm.io) >=11 is recommended. NPM and yarn might work as well, but I haven't tested them.
115
+ [Node](https://nodejs.org) >=22.22.2 is required, and [pnpm](https://pnpm.io) >=11 is recommended. NPM and yarn might work as well, but I haven't tested them.
116
116
 
117
117
  ### Installation
118
118