@kitschpatrol/mdat-config 7.6.2 → 7.6.4
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 +1 -1
- package/package.json +2 -2
- package/readme.md +13 -0
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 from"node:fs";import a from"node:path";import{PassThrough as o,Transform as s}from"node:stream";import{fileURLToPath as c}from"node:url";import{packageUp as l,packageUpSync as u}from"package-up";import d from"picocolors";import f from"yargs";import{hideBin as p}from"yargs/helpers";import m from"@pinojs/json-colorizer";import h from"decircular";import g from"deepmerge";import _ from"json-stringify-pretty-compact";import{findWorkspaces as v,findWorkspacesRoot as y}from"find-workspaces";import b from"node:fs/promises";import{stripVTControlCharacters as x}from"node:util";import{loadConfig as S}from"mdat";var C=`7.6.
|
|
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 from"node:fs";import a from"node:path";import{PassThrough as o,Transform as s}from"node:stream";import{fileURLToPath as c}from"node:url";import{packageUp as l,packageUpSync as u}from"package-up";import d from"picocolors";import f from"yargs";import{hideBin as p}from"yargs/helpers";import m from"@pinojs/json-colorizer";import h from"decircular";import g from"deepmerge";import _ from"json-stringify-pretty-compact";import{findWorkspaces as v,findWorkspacesRoot as y}from"find-workspaces";import b from"node:fs/promises";import{stripVTControlCharacters as x}from"node:util";import{loadConfig as S}from"mdat";var C=`7.6.4`;function w(e){return e instanceof Error&&`exitCode`in e&&typeof e.exitCode==`number`}function T(e){return m(_(h(e),{indent:2,replacer(e,t){return typeof t==`function`?t.name:t}}),{colors:{BRACKET:`gray`}})}const E=(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]=D(e[i],a,n):e.includes(a)||r.push(a);return r};function D(e,t,n={arrayMerge:E}){return g(e,t,n)}function O(e,t){return e.startsWith(t+a.sep)}function k(){let e=A(),t=new Set([e]),n=v();if(n!==null)for(let r of n){let n=a.resolve(r.location);O(n,e)&&t.add(n)}return[...t]}function A(){let e=u();if(e===void 0)throw Error(`No package.json found.`);return a.dirname(e)}function j(){let e=y();return e===null?A():a.resolve(e.location)}function M(e){if(e===`workspace-root`)return j();if(e===`package-dir`)return A();if(typeof e==`string`){if(!r.pathExistsSync(e))throw Error(`Custom cwd directory does not exist: ${e}`);return e}return process.cwd()}async function ee(e,t){try{let{default:n}=await import(`prettier`),r=await n.resolveConfig(e),i=await n.format(t,{filepath:e,...r});await b.writeFile(e,i,`utf8`)}catch{console.warn(`Skipped formatting ${e} since Prettier is not installed.`)}}async function N(e){try{await ee(e,await b.readFile(e,`utf8`))}catch{}}const P=/\r?\n/;function F(e){return new s({transform(t,n,r){let i=t.toString().split(P).filter(t=>t.trim()!==``&&!e(x(t))).join(`
|
|
3
3
|
`);this.push(i+`
|
|
4
4
|
`),r()}})}function I(e,t){return new s({transform(n,r,i){let a=n.toString().split(P).filter(e=>e.trim().length>0).map(n=>`${e?t===void 0?e:d[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(d.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(e,t,r,i,a){let s=1,c;if(i.logPrefix===void 0)c=e;else{let t=I(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=M(i.cwdOverride);a&&c.write(`Running: "${i.name} ${f.join(` `)}"`);let m=i.prettyJsonOutput?new o: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=F(i.outputFilter),n=F(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 L(m),t=T(JSON.parse(e)).split(`
|
|
5
5
|
`);for(let e of t)c.write(`${e}\n`)}s=e.exitCode??1}catch(e){console.error(`${i.name} failed with error:`),console.error(e),w(e)&&(s=typeof e.exitCode==`number`?e.exitCode:1)}return s}function V(e){return`execute`in e}const H=/^ksc-/;function U(e){return e.replace(H,``)}function W(e){return e===void 0||e.length===0?[]:e.flatMap(e=>e.split(`,`)).map(e=>U(e.trim()))}function G(e){return e.option(`skip`,{array:!0,describe:`Tool names to skip (with or without "ksc-" prefix).`,type:`string`})}async function K(e,t,n,r,i,a,o){let s=o??[],c=[],l=[];for(let e of r)s.length>0&&s.includes(U(e.name))?l.push(e):c.push(e);if(s.length>0){let t=new Set(l.map(e=>U(e.name))),n=s.filter(e=>!t.has(e));if(n.length>0){let t=r.map(e=>U(e.name)).join(`, `);e.write(`⚠️ ${d.yellow(`Unrecognized --skip ${R(`value`,n.length)}: ${n.join(`, `)}. Available: ${t}`)}\n`)}}let u=[];for(let r of c){let a=await(V(r)?z(e,t,n,r,i):B(e,t,n,r,i));u.push({exitCode:a,name:r.name})}let f=r.length;if(l.length>0){let t=l.map(({name:e})=>e);e.write(`⏭️ ${d.dim(d.bold(`${t.length} / ${f} ${R(`Command`,t.length)} Skipped:`))} ${d.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(`✅ ${d.green(d.bold(`${t.length} / ${f} ${R(`Command`,t.length)} Succeeded:`))} ${d.green(t.join(`, `))}\n`),n.length>0&&e.write(`❌ ${d.red(d.bold(`${n.length} / ${f} ${R(`Command`,n.length)} Failed:`))} ${d.red(n.join(`, `))}\n`)}return+!u.every(({exitCode:e})=>e===0)}async function q(e,t,n,o){let s=await l();if(s===void 0)throw Error("The `init` command must be used in a directory with a package.json file");let u=await l({cwd:c(import.meta.url)});if(u===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/mdat-config",
|
|
3
|
-
"version": "7.6.
|
|
3
|
+
"version": "7.6.4",
|
|
4
4
|
"description": "MDAT configuration for @kitschpatrol/shared-config.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"shared-config",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"find-workspaces": "^0.3.1",
|
|
54
54
|
"fs-extra": "^11.3.5",
|
|
55
55
|
"json-stringify-pretty-compact": "^4.0.0",
|
|
56
|
-
"mdat": "^2.3.
|
|
56
|
+
"mdat": "^2.3.6",
|
|
57
57
|
"package-up": "^5.0.0",
|
|
58
58
|
"picocolors": "^1.1.1",
|
|
59
59
|
"prettier": "^3.8.3",
|
package/readme.md
CHANGED
|
@@ -211,6 +211,19 @@ Config is merged in priority order: shared defaults < per-call overrides (via md
|
|
|
211
211
|
|
|
212
212
|
The Mdat module is cached internally for performance across multiple calls. Use `clearCache()` to force re-initialization.
|
|
213
213
|
|
|
214
|
+
## Troubleshooting
|
|
215
|
+
|
|
216
|
+
### `No readme found` errors
|
|
217
|
+
|
|
218
|
+
Running `ksc-mdat fix` can sometimes throw this error in complex repos that have additional `package.json` files that are not actually defining additional packages in the monorepo, e.g. a `package.json` that's part of a test fixture or demo project.
|
|
219
|
+
|
|
220
|
+
In these cases, make sure your workspace is explicitly defined in your `pnpm-workspace.yaml`, even if there's just one package in the repo:
|
|
221
|
+
|
|
222
|
+
```yml
|
|
223
|
+
packages:
|
|
224
|
+
- '.'
|
|
225
|
+
```
|
|
226
|
+
|
|
214
227
|
<!-- license -->
|
|
215
228
|
|
|
216
229
|
## License
|