efficient-shell 14.4.0 → 14.5.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.
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- import{createRequire as e}from"module";import{join as n}from"path";import{existsSync as t,readFileSync as i,readdirSync as r}from"fs";function o(t){return function(t,i){for(const r of[n(process.cwd(),"package.json"),i])try{return e(r)(t)}catch{}throw new Error(`${t} is not installed; add it to this repository's devDependencies`)}("typescript",t)}var s=/[.+^$()|[\]\\]/g;function a(e){let n="",t=0;for(let i=0;i<e.length;i++){const r=e[i];"*"===r?"*"===e[i+1]?"/"===e[i+2]?(n+="(?:[^/]+/)*",i+=2):(n+=".*",i+=1):n+="[^/]*":"?"===r?n+="[^/]":"{"===r?(n+="(?:",t+=1):"}"===r&&t>0?(n+=")",t-=1):n+=","===r&&t>0?"|":r.replace(s,"\\$&")}if(0!==t)throw new Error(`unbalanced { in glob "${e}"`);return new RegExp(`^${n}$`)}function g(e){const n=e.map(a);return e=>n.some(n=>n.test(e))}var c=new Set(["node_modules",".git"]),l=new Set(["dist","coverage",".next",".turbo"]);function d(e){const n=e.search(/[*?{]/),t=-1===n?e:e.slice(0,n),i=t.lastIndexOf("/");return-1===i?"":t.slice(0,i)}function h(e,t){const i=g(t),o=[...new Set(t.map(d))].sort(),s=o.filter(e=>!o.some(n=>n!==e&&(""===n||e.startsWith(`${n}/`)))),a=new Set,h=t=>{let o;try{o=r(n(e,t),{withFileTypes:!0})}catch{return}for(const e of o){const n=t?`${t}/${e.name}`:e.name;e.isDirectory()?c.has(e.name)||""===t&&l.has(e.name)||h(n):e.isFile()&&i(n)&&a.add(n)}};for(const e of s)h(e);return[...a].sort(u)}var u=(e,n)=>e<n?-1:e>n?1:0;Object.keys({fast:120,base:160}).map(e=>`--motion-${e}`).join(", "),Object.keys({body:400,control:500,heading:600,figure:700}).map(e=>`--weight-${e}`).join(", "),Object.keys({hairline:1,strong:2,accent:4}).map(e=>`--border-${e}`).join(", "),[2,4,8,12,16,20,24,32,40,48].join("/");var p=(...e)=>["origin",...e].join("-");new RegExp(["(?:transformOrigin|transform-origin)\\s*[:=]\\s*[\"'`]?\\s*(?:top left|left top|0 0|0% 0%|0px 0px)(?![\\w%-])",`(?<![\\w-])!?${p("top","left")}(?![\\w-])`,`(?<![\\w-])!?${p("\\[0_0\\]")}`].join("|"));var f=(...e)=>e.join(""),m="3xs|2xs|xs|sm|base|lg|xl|[2-9]xl";new RegExp(`(?<![\\w-])!?(?:${f("te","xt-")}(?:(?:${m})(?:\\/[\\w.()-]+)?|\\[(?:length:)?[\\d.]+(?:px|rem|em)\\])|${f("fo","nt-")}(?:thin|extralight|light|normal|medium|semibold|bold|extrabold|black|\\[\\d+\\]))(?![\\w-])`),new RegExp(`(?<![\\w-])${f("round","ed")}(?:-(?:full|sm|md|lg|xl|[23]xl|[trblse]|tl|tr|br|bl|\\([^)]*\\)|\\[[^\\]]*\\]))*(?![\\w-])`);new RegExp(`(?<![\\w-])${f("b","g-")}(?!(?:none|transparent|current|inherit|cover|contain|auto|fixed|local|scroll|center|top|bottom|left|right|repeat|no-repeat|clip|origin|blend|linear|radial|conic|gradient|position|size|image)(?![\\w]))[\\w\\[(#][^\\s'"\`]*`);var w=`${m}|left|center|right|justify|start|end|wrap|nowrap|balance|pretty|ellipsis|clip|transparent|current|inherit|shadow`;new RegExp(`(?<![\\w-])${f("te","xt-")}(?!(?:${w})(?![\\w]))(?!\\[[\\d.]+(?:px|rem|em)\\])(?!\\[length:)[\\w\\[(#][^\\s'"\`]*`),new RegExp(`(?<![\\w-])${f("p","[xs]?-")}(?:\\d|\\[|\\()`),new RegExp(`(?<![\\w-])${f("p","y-")}(?:0|px|0\\.5|\\[[0-3](?:\\.\\d+)?px\\])(?![\\w.-])`),new RegExp(`(?<![\\w-])${f("round","ed-full")}(?![\\w-])`),new RegExp(`(?<![\\w-])${f("te","xt-")}(?:xs|2xs|3xs|\\[(?:9|10|11|12)px\\])(?![\\w-])`),new RegExp(`(?<![\\w-])${f("p","y-")}`),new RegExp(`(?<![\\w-])!?(?:${f("dura","tion-")}|${f("del","ay-")})(?:\\d+|\\[[^\\]]+\\])(?![\\w-])|(?<![\\w-])!?${f("fo","nt-")}\\[\\d+\\](?![\\w-])|(?<![\\w-])!?${f("bor","der")}(?:-[xytrblse])?-\\[[\\d.]+px\\](?![\\w-])`,"g");var $={busy:{words:["Accepting","Adding","Applying","Approving","Arranging","Asking","Assigning","Booking","Building","Calculating","Cancelling","Capturing","Changing","Checking","Choosing","Closing","Combining","Comparing","Completing","Confirming","Connecting","Converting","Copying","Correcting","Counting","Creating","Deleting","Detaching","Downloading","Drawing","Duplicating","Emailing","Ending","Exporting","Fetching","Filing","Finding","Flushing","Generating","Grouping","Importing","Linking","Loading","Locating","Looking","Making","Marking","Matching","Measuring","Merging","Moving","Opening","Ordering","Paying","Pending","Posting","Preparing","Previewing","Pricing","Processing","Provisioning","Publishing","Purging","Pushing","Queued","Queuing","Quoting","Re-booking","Re-importing","Re-opening","Reading","Rebooting","Rebuilding","Receiving","Reconciling","Reconnecting","Recording","Refreshing","Refunding","Regenerating","Registering","Reinstating","Rejecting","Removing","Reopening","Requesting","Resending","Resetting","Resolving","Restarting","Restoring","Resuming","Retrying","Reversing","Reverting","Running","Saving","Searching","Sending","Setting","Settling","Sharing","Signing","Splitting","Starting","Submitting","Suggesting","Switching","Syncing","Taking","Testing","Transferring","Typing","Updating","Uploading","Verifying","Waiting","Withdrawing","Working"]}};new Set(($.busy?.words??[]).map(e=>e.toLowerCase()));var x=(...e)=>e.join("-");x("p[xytrblse]?",""),x("max","[wh]",""),x("h",""),x("w",""),x("[wh]",""),x("min","h","");var y=class extends Error{},b=new Set(["$schema","schema","include","exclude","allow"]),R=e=>"object"==typeof e&&null!==e&&!Array.isArray(e),S=e=>"string"==typeof e&&""!==e.trim();var v="d3as2htf4hwbtr.cloudfront.net",k={dealer:{bucket:"inovit-dealer-portal-assets",hosts:["d201q0i87q901p.cloudfront.net"],key_pattern:"^marketing/"},media:{bucket:"regis-media-production",hosts:["media.regis.design","d21nnr9ivf9hcc.cloudfront.net"],key_pattern:"^[a-z0-9_]+/storefront/(?!uploads/thumbs/)"},site:{bucket:"inovit-ecommerce-media",hosts:["cdn.inovit.com","dhxlibd8r3td0.cloudfront.net"],key_pattern:"^images/"}},j=Object.values(k),C=Object.freeze([...new Set([...j.flatMap(e=>e.hosts),v,...j.map(e=>e.bucket)])].sort()),A=new RegExp([...C.map(e=>{return`(?<![\\w-])${n=e,n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}(?![\\w-])`;var n}),"(?<![\\w-])[a-z0-9]+\\.cloudfront\\.net(?![\\w-])","(?<![\\w-])(?:[a-z0-9-]+\\.)*s3(?:[.-][a-z0-9-]+)*\\.amazonaws\\.com(?![\\w-])","s3://"].join("|"),"gi");function E(e,n,t){const i=e.createSourceFile(n,t,e.ScriptTarget.Latest,!0,function(e,n){return n.endsWith(".tsx")?e.ScriptKind.TSX:n.endsWith(".jsx")?e.ScriptKind.JSX:/\.[cm]?js$/.test(n)?e.ScriptKind.JS:e.ScriptKind.TS}(e,n)),r=[],o=(e,n)=>{const t=i.getLineAndCharacterOfPosition(e.getStart(i)).line+1;for(const e of function(e){return[...e.matchAll(A)].map(e=>({match:e[0],index:e.index??0}))}(n)){const i=n.slice(0,e.index);r.push({line:t+(i.match(/\n/g)?.length??0),match:e.match})}},s=n=>{e.isStringLiteral(n)||e.isNoSubstitutionTemplateLiteral(n)||e.isTemplateHead(n)||e.isTemplateMiddle(n)||e.isTemplateTail(n)?o(n,n.text):e.isRegularExpressionLiteral(n)&&o(n,n.text.replace(/\\(.)/g,"$1")),e.forEachChild(n,s)};return s(i),r}var O="media-host-check.config.json",T="efficient-shell-media-host-check",P=`${T}: no code writes a media origin; files are reached through the storage backend, the API's URL, media() or imageCopyUrl() (harness API-15, SSOT-2).\n\n ${T} check this repository; exits 1 on a finding\n ${T} --json print the result as JSON\n\nRefused in any string, template or regular expression: every host and bucket in\nthe image-copies contract, any *.cloudfront.net host, any S3 endpoint, and s3://.\nReads ${O} in the current directory.`;function L(e,t,r){const o=[],s=g(r.exclude);for(const e of r.include)0===h(t,[e]).length&&o.push(`include "${e}" matches no file; delete it`);const a=h(t,r.include).filter(e=>(e=>/\.(?:[cm]?[jt]s|[jt]sx)$/.test(e)&&!e.endsWith(".d.ts"))(e)&&!s(e)),c=[];for(const r of a)for(const o of E(e,r,i(n(t,r),"utf8")))c.push({file:r,...o});const l=(e,n)=>e.toLowerCase()===n.toLowerCase();for(const e of r.allow)c.some(n=>n.file===e.file&&l(e.match,n.match))||o.push(`allow ${e.file} "${e.match}" matches nothing any more; delete it`);return{files:a.length,findings:c.filter(e=>!(e=>r.allow.some(n=>n.file===e.file&&l(n.match,e.match)))(e)),problems:o}}process.exitCode=function(e,r){let o=!1;for(const n of e){if("--help"===n||"-h"===n)return r.out(P),0;if("--version"===n||"-v"===n)return r.out(r.version),0;if("--json"!==n)return r.err(`${T}: unknown argument "${n}"\n\n${P}`),2;o=!0}const s=n(r.cwd,O);if(!t(s))return r.err(`${T}: no ${O} in ${r.cwd}. Run it from the repository root.`),2;let a;try{const e=function(e,n="media-host-check.config.json"){const t=[];if(!R(e))throw new y(`${n}: expected an object`);for(const n of Object.keys(e))b.has(n)||t.push(`unknown key "${n}"`);1!==e.schema&&t.push('"schema" must be 1');const i=(n,i)=>{const r=e[n];return void 0!==r||i?!Array.isArray(r)||!r.every(S)||i&&0===r.length?(t.push(`"${n}" must be ${i?"a non-empty":"an"} array of globs`),[]):r:[]},r=i("include",!0),o=i("exclude",!1),s=[];void 0===e.allow||Array.isArray(e.allow)||t.push('"allow" must be an array');for(const[n,i]of(Array.isArray(e.allow)?e.allow:[]).entries()){if(!(R(i)&&S(i.file)&&S(i.match)&&S(i.reason))){t.push(`allow[${n}] needs "file", "match" and "reason", each a non-empty string`);continue}const e=Object.keys(i).filter(e=>!["file","match","reason"].includes(e));e.length&&t.push(`allow[${n}] has unknown keys: ${e.join(", ")}`),s.push({file:i.file,match:i.match,reason:i.reason})}if(t.length)throw new y(`${n}:\n ${t.join("\n ")}`);return{schema:1,include:r,exclude:o,allow:s}}(JSON.parse(i(s,"utf8")),O);a=L(r.loadTypeScript(),r.cwd,e)}catch(e){return r.err(`${T}: ${e instanceof y||e instanceof SyntaxError?e.message:String(e)}`),2}const g=a.findings.length>0||a.problems.length>0;if(o)return r.out(JSON.stringify({ok:!g,...a},null,2)),g?1:0;if(!g)return r.out(`${T}: ${a.files} files, no media origin written in code (harness API-15, SSOT-2).`),0;for(const e of a.findings)r.err(`${e.file}:${e.line} "${e.match}" is a media origin written in code.`);for(const e of a.problems)r.err(`${O}: ${e}`);return a.findings.length&&r.err(`\nReach the file through the storage backend, the URL the API returns, media() or imageCopyUrl() (harness API-15, SSOT-2). An origin that must stay goes in "allow" in ${O}, with its reason.`),1}(process.argv.slice(2),{cwd:process.cwd(),out:e=>console.log(e),err:e=>console.error(e),loadTypeScript:()=>o(import.meta.url),version:"14.4.0"});
2
+ import{createRequire as e}from"module";import{join as n}from"path";import{existsSync as t,readFileSync as i,readdirSync as r}from"fs";function o(t){return function(t,i){for(const r of[n(process.cwd(),"package.json"),i])try{return e(r)(t)}catch{}throw new Error(`${t} is not installed; add it to this repository's devDependencies`)}("typescript",t)}var s=/[.+^$()|[\]\\]/g;function a(e){let n="",t=0;for(let i=0;i<e.length;i++){const r=e[i];"*"===r?"*"===e[i+1]?"/"===e[i+2]?(n+="(?:[^/]+/)*",i+=2):(n+=".*",i+=1):n+="[^/]*":"?"===r?n+="[^/]":"{"===r?(n+="(?:",t+=1):"}"===r&&t>0?(n+=")",t-=1):n+=","===r&&t>0?"|":r.replace(s,"\\$&")}if(0!==t)throw new Error(`unbalanced { in glob "${e}"`);return new RegExp(`^${n}$`)}function g(e){const n=e.map(a);return e=>n.some(n=>n.test(e))}var c=new Set(["node_modules",".git"]),l=new Set(["dist","coverage",".next",".turbo"]);function d(e){const n=e.search(/[*?{]/),t=-1===n?e:e.slice(0,n),i=t.lastIndexOf("/");return-1===i?"":t.slice(0,i)}function h(e,t){const i=g(t),o=[...new Set(t.map(d))].sort(),s=o.filter(e=>!o.some(n=>n!==e&&(""===n||e.startsWith(`${n}/`)))),a=new Set,h=t=>{let o;try{o=r(n(e,t),{withFileTypes:!0})}catch{return}for(const e of o){const n=t?`${t}/${e.name}`:e.name;e.isDirectory()?c.has(e.name)||""===t&&l.has(e.name)||h(n):e.isFile()&&i(n)&&a.add(n)}};for(const e of s)h(e);return[...a].sort(u)}var u=(e,n)=>e<n?-1:e>n?1:0;Object.keys({fast:120,base:160}).map(e=>`--motion-${e}`).join(", "),Object.keys({body:400,control:500,heading:600,figure:700}).map(e=>`--weight-${e}`).join(", "),Object.keys({hairline:1,strong:2,accent:4}).map(e=>`--border-${e}`).join(", "),[2,4,8,12,16,20,24,32,40,48].join("/");var p=(...e)=>["origin",...e].join("-");new RegExp(["(?:transformOrigin|transform-origin)\\s*[:=]\\s*[\"'`]?\\s*(?:top left|left top|0 0|0% 0%|0px 0px)(?![\\w%-])",`(?<![\\w-])!?${p("top","left")}(?![\\w-])`,`(?<![\\w-])!?${p("\\[0_0\\]")}`].join("|"));var f=(...e)=>e.join(""),m="3xs|2xs|xs|sm|base|lg|xl|[2-9]xl";new RegExp(`(?<![\\w-])!?(?:${f("te","xt-")}(?:(?:${m})(?:\\/[\\w.()-]+)?|\\[(?:length:)?[\\d.]+(?:px|rem|em)\\])|${f("fo","nt-")}(?:thin|extralight|light|normal|medium|semibold|bold|extrabold|black|\\[\\d+\\]))(?![\\w-])`),new RegExp(`(?<![\\w-])${f("round","ed")}(?:-(?:full|sm|md|lg|xl|[23]xl|[trblse]|tl|tr|br|bl|\\([^)]*\\)|\\[[^\\]]*\\]))*(?![\\w-])`);new RegExp(`(?<![\\w-])${f("b","g-")}(?!(?:none|transparent|current|inherit|cover|contain|auto|fixed|local|scroll|center|top|bottom|left|right|repeat|no-repeat|clip|origin|blend|linear|radial|conic|gradient|position|size|image)(?![\\w]))[\\w\\[(#][^\\s'"\`]*`);var w=`${m}|left|center|right|justify|start|end|wrap|nowrap|balance|pretty|ellipsis|clip|transparent|current|inherit|shadow`;new RegExp(`(?<![\\w-])${f("te","xt-")}(?!(?:${w})(?![\\w]))(?!\\[[\\d.]+(?:px|rem|em)\\])(?!\\[length:)[\\w\\[(#][^\\s'"\`]*`),new RegExp(`(?<![\\w-])${f("p","[xs]?-")}(?:\\d|\\[|\\()`),new RegExp(`(?<![\\w-])${f("p","y-")}(?:0|px|0\\.5|\\[[0-3](?:\\.\\d+)?px\\])(?![\\w.-])`),new RegExp(`(?<![\\w-])${f("round","ed-full")}(?![\\w-])`),new RegExp(`(?<![\\w-])${f("te","xt-")}(?:xs|2xs|3xs|\\[(?:9|10|11|12)px\\])(?![\\w-])`),new RegExp(`(?<![\\w-])${f("p","y-")}`),new RegExp(`(?<![\\w-])!?(?:${f("dura","tion-")}|${f("del","ay-")})(?:\\d+|\\[[^\\]]+\\])(?![\\w-])|(?<![\\w-])!?${f("fo","nt-")}\\[\\d+\\](?![\\w-])|(?<![\\w-])!?${f("bor","der")}(?:-[xytrblse])?-\\[[\\d.]+px\\](?![\\w-])`,"g");var $={busy:{words:["Accepting","Adding","Applying","Approving","Arranging","Asking","Assigning","Booking","Building","Calculating","Cancelling","Capturing","Changing","Checking","Choosing","Closing","Combining","Comparing","Completing","Confirming","Connecting","Converting","Copying","Correcting","Counting","Creating","Deleting","Detaching","Downloading","Drawing","Duplicating","Emailing","Ending","Exporting","Fetching","Filing","Finding","Flushing","Generating","Grouping","Importing","Linking","Loading","Locating","Looking","Making","Marking","Matching","Measuring","Merging","Moving","Opening","Ordering","Paying","Pending","Posting","Preparing","Previewing","Pricing","Processing","Provisioning","Publishing","Purging","Pushing","Queued","Queuing","Quoting","Re-booking","Re-importing","Re-opening","Reading","Rebooting","Rebuilding","Receiving","Reconciling","Reconnecting","Recording","Refreshing","Refunding","Regenerating","Registering","Reinstating","Rejecting","Removing","Reopening","Requesting","Resending","Resetting","Resolving","Restarting","Restoring","Resuming","Retrying","Reversing","Reverting","Running","Saving","Searching","Sending","Setting","Settling","Sharing","Signing","Splitting","Starting","Submitting","Suggesting","Switching","Syncing","Taking","Testing","Transferring","Typing","Updating","Uploading","Verifying","Waiting","Withdrawing","Working"]}};new Set(($.busy?.words??[]).map(e=>e.toLowerCase()));var x=(...e)=>e.join("-");x("p[xytrblse]?",""),x("max","[wh]",""),x("h",""),x("w",""),x("[wh]",""),x("min","h","");var y=class extends Error{},b=new Set(["$schema","schema","include","exclude","allow"]),R=e=>"object"==typeof e&&null!==e&&!Array.isArray(e),S=e=>"string"==typeof e&&""!==e.trim();var v="d3as2htf4hwbtr.cloudfront.net",k={dealer:{bucket:"inovit-dealer-portal-assets",hosts:["d201q0i87q901p.cloudfront.net"],key_pattern:"^marketing/"},media:{bucket:"regis-media-production",hosts:["media.regis.design","d21nnr9ivf9hcc.cloudfront.net"],key_pattern:"^[a-z0-9_]+/storefront/(?!uploads/thumbs/)"},site:{bucket:"inovit-ecommerce-media",hosts:["cdn.inovit.com","dhxlibd8r3td0.cloudfront.net"],key_pattern:"^images/"}},j=Object.values(k),C=Object.freeze([...new Set([...j.flatMap(e=>e.hosts),v,...j.map(e=>e.bucket)])].sort()),A=new RegExp([...C.map(e=>{return`(?<![\\w-])${n=e,n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}(?![\\w-])`;var n}),"(?<![\\w-])[a-z0-9]+\\.cloudfront\\.net(?![\\w-])","(?<![\\w-])(?:[a-z0-9-]+\\.)*s3(?:[.-][a-z0-9-]+)*\\.amazonaws\\.com(?![\\w-])","s3://"].join("|"),"gi");function E(e,n,t){const i=e.createSourceFile(n,t,e.ScriptTarget.Latest,!0,function(e,n){return n.endsWith(".tsx")?e.ScriptKind.TSX:n.endsWith(".jsx")?e.ScriptKind.JSX:/\.[cm]?js$/.test(n)?e.ScriptKind.JS:e.ScriptKind.TS}(e,n)),r=[],o=(e,n)=>{const t=i.getLineAndCharacterOfPosition(e.getStart(i)).line+1;for(const e of function(e){return[...e.matchAll(A)].map(e=>({match:e[0],index:e.index??0}))}(n)){const i=n.slice(0,e.index);r.push({line:t+(i.match(/\n/g)?.length??0),match:e.match})}},s=n=>{e.isStringLiteral(n)||e.isNoSubstitutionTemplateLiteral(n)||e.isTemplateHead(n)||e.isTemplateMiddle(n)||e.isTemplateTail(n)?o(n,n.text):e.isRegularExpressionLiteral(n)&&o(n,n.text.replace(/\\(.)/g,"$1")),e.forEachChild(n,s)};return s(i),r}var O="media-host-check.config.json",T="efficient-shell-media-host-check",P=`${T}: no code writes a media origin; files are reached through the storage backend, the API's URL, media() or imageCopyUrl() (harness API-15, SSOT-2).\n\n ${T} check this repository; exits 1 on a finding\n ${T} --json print the result as JSON\n\nRefused in any string, template or regular expression: every host and bucket in\nthe image-copies contract, any *.cloudfront.net host, any S3 endpoint, and s3://.\nReads ${O} in the current directory.`;function L(e,t,r){const o=[],s=g(r.exclude);for(const e of r.include)0===h(t,[e]).length&&o.push(`include "${e}" matches no file; delete it`);const a=h(t,r.include).filter(e=>(e=>/\.(?:[cm]?[jt]s|[jt]sx)$/.test(e)&&!e.endsWith(".d.ts"))(e)&&!s(e)),c=[];for(const r of a)for(const o of E(e,r,i(n(t,r),"utf8")))c.push({file:r,...o});const l=(e,n)=>e.toLowerCase()===n.toLowerCase();for(const e of r.allow)c.some(n=>n.file===e.file&&l(e.match,n.match))||o.push(`allow ${e.file} "${e.match}" matches nothing any more; delete it`);return{files:a.length,findings:c.filter(e=>!(e=>r.allow.some(n=>n.file===e.file&&l(n.match,e.match)))(e)),problems:o}}process.exitCode=function(e,r){let o=!1;for(const n of e){if("--help"===n||"-h"===n)return r.out(P),0;if("--version"===n||"-v"===n)return r.out(r.version),0;if("--json"!==n)return r.err(`${T}: unknown argument "${n}"\n\n${P}`),2;o=!0}const s=n(r.cwd,O);if(!t(s))return r.err(`${T}: no ${O} in ${r.cwd}. Run it from the repository root.`),2;let a;try{const e=function(e,n="media-host-check.config.json"){const t=[];if(!R(e))throw new y(`${n}: expected an object`);for(const n of Object.keys(e))b.has(n)||t.push(`unknown key "${n}"`);1!==e.schema&&t.push('"schema" must be 1');const i=(n,i)=>{const r=e[n];return void 0!==r||i?!Array.isArray(r)||!r.every(S)||i&&0===r.length?(t.push(`"${n}" must be ${i?"a non-empty":"an"} array of globs`),[]):r:[]},r=i("include",!0),o=i("exclude",!1),s=[];void 0===e.allow||Array.isArray(e.allow)||t.push('"allow" must be an array');for(const[n,i]of(Array.isArray(e.allow)?e.allow:[]).entries()){if(!(R(i)&&S(i.file)&&S(i.match)&&S(i.reason))){t.push(`allow[${n}] needs "file", "match" and "reason", each a non-empty string`);continue}const e=Object.keys(i).filter(e=>!["file","match","reason"].includes(e));e.length&&t.push(`allow[${n}] has unknown keys: ${e.join(", ")}`),s.push({file:i.file,match:i.match,reason:i.reason})}if(t.length)throw new y(`${n}:\n ${t.join("\n ")}`);return{schema:1,include:r,exclude:o,allow:s}}(JSON.parse(i(s,"utf8")),O);a=L(r.loadTypeScript(),r.cwd,e)}catch(e){return r.err(`${T}: ${e instanceof y||e instanceof SyntaxError?e.message:String(e)}`),2}const g=a.findings.length>0||a.problems.length>0;if(o)return r.out(JSON.stringify({ok:!g,...a},null,2)),g?1:0;if(!g)return r.out(`${T}: ${a.files} files, no media origin written in code (harness API-15, SSOT-2).`),0;for(const e of a.findings)r.err(`${e.file}:${e.line} "${e.match}" is a media origin written in code.`);for(const e of a.problems)r.err(`${O}: ${e}`);return a.findings.length&&r.err(`\nReach the file through the storage backend, the URL the API returns, media() or imageCopyUrl() (harness API-15, SSOT-2). An origin that must stay goes in "allow" in ${O}, with its reason.`),1}(process.argv.slice(2),{cwd:process.cwd(),out:e=>console.log(e),err:e=>console.error(e),loadTypeScript:()=>o(import.meta.url),version:"14.5.1"});