mirror of
https://github.com/mifi/lossless-cut.git
synced 2024-11-25 11:43:17 +01:00
34 lines
9.7 KiB
JavaScript
34 lines
9.7 KiB
JavaScript
/* eslint-disable */
|
|
//prettier-ignore
|
|
module.exports = {
|
|
name: "@yarnpkg/plugin-licenses",
|
|
factory: function (require) {
|
|
var plugin=(()=>{var ae=Object.create,U=Object.defineProperty;var ce=Object.getOwnPropertyDescriptor;var le=Object.getOwnPropertyNames,B=Object.getOwnPropertySymbols,de=Object.getPrototypeOf,V=Object.prototype.hasOwnProperty,pe=Object.prototype.propertyIsEnumerable;var z=(e,t,n)=>t in e?U(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,j=(e,t)=>{for(var n in t||(t={}))V.call(t,n)&&z(e,n,t[n]);if(B)for(var n of B(t))pe.call(t,n)&&z(e,n,t[n]);return e};var fe=e=>U(e,"__esModule",{value:!0});var d=e=>{if(typeof require!="undefined")return require(e);throw new Error('Dynamic require of "'+e+'" is not supported')};var R=(e,t)=>{for(var n in t)U(e,n,{get:t[n],enumerable:!0})},ue=(e,t,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of le(t))!V.call(e,i)&&i!=="default"&&U(e,i,{get:()=>t[i],enumerable:!(n=ce(t,i))||n.enumerable});return e},p=e=>ue(fe(U(e!=null?ae(de(e)):{},"default",e&&e.__esModule&&"default"in e?{get:()=>e.default,enumerable:!0}:{value:e,enumerable:!0})),e);var Le={};R(Le,{default:()=>xe});var ne=p(d("@yarnpkg/cli")),L=p(d("@yarnpkg/core")),w=p(d("clipanion"));var a=p(d("@yarnpkg/core")),u=p(d("@yarnpkg/fslib"));var W={};R(W,{fs:()=>he,getPackagePath:()=>me});var K=p(d("@yarnpkg/plugin-pnp")),$=p(d("@yarnpkg/core")),F=p(d("@yarnpkg/fslib")),q=p(d("@yarnpkg/libzip")),me=async(e,t)=>{ge(e);let n=$.structUtils.convertPackageToLocator(t),i={name:$.structUtils.stringifyIdent(n),reference:n.reference},r=A.getPackageInformation(i);if(!r)return null;let{packageLocation:o}=r;return o},A,ge=e=>{A||(A=module.require((0,K.getPnpPath)(e).cjs))},he=new F.VirtualFS({baseFs:new F.ZipOpenFS({libzip:(0,q.getLibzipSync)(),readOnlyArchives:!0})});var H={};R(H,{_getYarnStateAliases:()=>G,fs:()=>ke,getPackagePath:()=>Pe});var x=p(d("@yarnpkg/core")),J=p(d("@yarnpkg/parsers")),k=p(d("@yarnpkg/fslib")),Pe=async(e,t)=>{await ye(e);let n=x.structUtils.convertPackageToLocator(t),i=x.structUtils.stringifyLocator(n),r=E[i]||Z[i];if(!r)return null;let o=r.locations[0];return o?k.ppath.join(e.cwd,o):e.cwd},E,Z,ye=async e=>{if(!E){let t=k.ppath.join(e.configuration.projectCwd,k.Filename.nodeModules,".yarn-state.yml");E=(0,J.parseSyml)(await k.xfs.readFilePromise(t,"utf8")),Z=G(E)}},ke=k.xfs,G=e=>Object.entries(e).reduce((t,[n,i])=>{if(!i.aliases)return t;let r=x.structUtils.parseLocator(n);for(let o of i.aliases){let l=x.structUtils.makeLocator(r,o),s=x.structUtils.stringifyLocator(l);t[s]=i}return t},{});var Y=e=>{switch(e){case"pnp":return W;case"node-modules":return H;default:throw new Error("Unsupported linker")}};var Ae=u.npath.basename(__dirname)==="@yarnpkg"?u.ppath.join(u.npath.toPortablePath(__dirname),"../.."):u.ppath.join(u.npath.toPortablePath(__dirname),".."),Q=async(e,t,n,i,r)=>{let o={},l={children:o},s=await X(e,n,i),c=Y(e.configuration.get("nodeLinker"));for(let[f,g]of s.entries()){let h=await c.getPackagePath(e,g);if(h===null)continue;let v=JSON.parse(await c.fs.readFilePromise(u.ppath.join(h,u.Filename.manifest),"utf8")),{license:m,url:N,vendorName:T,vendorUrl:I}=ve(v);o[m]||(o[m]={value:a.formatUtils.tuple(a.formatUtils.Type.NO_HINT,m),children:{}});let M=a.structUtils.convertPackageToLocator(g),P=a.formatUtils.tuple(a.formatUtils.Type.DEPENDENT,{locator:M,descriptor:f}),y=r?{}:j(j(j({},N?{url:{value:a.formatUtils.tuple(a.formatUtils.Type.NO_HINT,_("URL",N,t))}}:{}),T?{vendorName:{value:a.formatUtils.tuple(a.formatUtils.Type.NO_HINT,_("VendorName",T,t))}}:{}),I?{vendorUrl:{value:a.formatUtils.tuple(a.formatUtils.Type.NO_HINT,_("VendorUrl",I,t))}}:{}),re={value:P,children:y},se=a.structUtils.stringifyLocator(M),oe=o[m].children;oe[se]=re}return l},X=async(e,t,n)=>{let i=new Map,r;if(t){if(n){for(let c of e.workspaces)c.manifest.devDependencies.clear();let s=await a.Cache.find(e.configuration);await e.resolveEverything({report:new a.ThrowReport,cache:s})}r=e.storedDescriptors.values()}else r=e.workspaces.flatMap(s=>{let c=[s.anchoredDescriptor];for(let[f,g]of s.dependencies.entries())n&&s.manifest.devDependencies.has(f)||c.push(g);return c});let o=a.miscUtils.sortMap(r,[s=>a.structUtils.stringifyIdent(s),s=>a.structUtils.isVirtualDescriptor(s)?"0":"1",s=>s.range]),l=new Set;for(let s of o.values()){let c=e.storedResolutions.get(s.descriptorHash);if(!c)continue;let f=e.storedPackages.get(c);if(!f)continue;let{descriptorHash:g}=a.structUtils.isVirtualDescriptor(s)?a.structUtils.devirtualizeDescriptor(s):s;l.has(g)||(l.add(g),i.set(s,f))}return i};function we(e){let t={},n=e.match(/^([^(<]+)/);if(n){let o=n[0].trim();o&&(t.name=o)}let i=e.match(/<([^>]+)>/);i&&(t.email=i[1]);let r=e.match(/\(([^)]+)\)/);return r&&(t.url=r[1]),t}var ve=e=>{let{license:t,licenses:n,repository:i,homepage:r,author:o}=e,l=typeof o=="string"?we(o):o;return{license:(()=>{if(t)return C(t);if(n){if(!Array.isArray(n))return C(n);if(n.length===1)return C(n[0]);if(n.length>1)return`(${n.map(C).join(" OR ")})`}return ee})(),url:(i==null?void 0:i.url)||r,vendorName:l==null?void 0:l.name,vendorUrl:r||(l==null?void 0:l.url)}},ee="UNKNOWN",C=e=>(typeof e!="string"?e.type:e)||ee,_=(e,t,n)=>n?t:`${e}: ${t}`,te=async(e,t,n)=>{let i=await X(e,t,n),r=Y(e.configuration.get("nodeLinker")),o=new Map;for(let s of i.values()){let c=await r.getPackagePath(e,s);if(c===null)continue;let f=JSON.parse(await r.fs.readFilePromise(u.ppath.join(c,u.Filename.manifest),"utf8")),h=(await r.fs.readdirPromise(c,{withFileTypes:!0})).filter(P=>P.isFile()).map(({name:P})=>P),v=h.find(P=>{let y=P.toLowerCase();return y==="license"||y.startsWith("license.")||y==="unlicense"||y.startsWith("unlicense.")});if(!v)continue;let m=await r.fs.readFilePromise(u.ppath.join(c,v),"utf8"),N=h.find(P=>{let y=P.toLowerCase();return y==="notice"||y.startsWith("notice.")}),T;N&&(T=await r.fs.readFilePromise(u.ppath.join(c,N),"utf8"));let I=T?`${m}
|
|
|
|
NOTICE
|
|
|
|
${T}`:m,M=o.get(I);M?M.set(f.name,f):o.set(I,new Map([[f.name,f]]))}let l=`THE FOLLOWING SETS FORTH ATTRIBUTION NOTICES FOR THIRD PARTY SOFTWARE THAT MAY BE CONTAINED IN PORTIONS OF THE ${String(e.topLevelWorkspace.manifest.raw.name).toUpperCase().replace(/-/g," ")} PRODUCT.
|
|
|
|
`;for(let[s,c]of o.entries()){l+=`-----
|
|
|
|
`;let f=[],g=[];for(let{name:v,repository:m}of c.values())f.push(v),(m==null?void 0:m.url)&&g.push(c.size===1?m.url:`${m.url} (${v})`);let h=[];h.push(`The following software may be included in this product: ${f.join(", ")}.`),g.length>0&&h.push(`A copy of the source code may be downloaded from ${g.join(", ")}.`),h.push("This software contains the following license and notice below:"),l+=`${h.join(" ")}
|
|
|
|
`,l+=`${s.trim()}
|
|
|
|
`}return l};var S=class extends w.Command{constructor(){super(...arguments);this.recursive=w.Option.Boolean("-R,--recursive",!1,{description:"Include transitive dependencies (dependencies of direct dependencies)"});this.production=w.Option.Boolean("--production",!1,{description:"Exclude development dependencies"});this.json=w.Option.Boolean("--json",!1,{description:"Format output as JSON"});this.excludeMetadata=w.Option.Boolean("--exclude-metadata",!1,{description:"Exclude dependency metadata from output"})}async execute(){let t=await L.Configuration.find(this.context.cwd,this.context.plugins),{project:n,workspace:i}=await L.Project.find(t,this.context.cwd);if(!i)throw new ne.WorkspaceRequiredError(n.cwd,this.context.cwd);await n.restoreInstallState();let r=await Q(n,this.json,this.recursive,this.production,this.excludeMetadata);L.treeUtils.emitTree(r,{configuration:t,stdout:this.context.stdout,json:this.json,separators:1})}};S.paths=[["licenses","list"]],S.usage=w.Command.Usage({description:"display the licenses for all packages in the project",details:`
|
|
This command prints the license information for packages in the project. By default, only direct dependencies are listed.
|
|
|
|
If \`-R,--recursive\` is set, the listing will include transitive dependencies (dependencies of direct dependencies).
|
|
|
|
If \`--production\` is set, the listing will exclude development dependencies.
|
|
`,examples:[["List all licenses of direct dependencies","$0 licenses list"],["List all licenses of direct and transitive dependencies","$0 licenses list --recursive"],["List all licenses of production dependencies only","$0 licenses list --production"]]});var ie=p(d("@yarnpkg/cli")),D=p(d("@yarnpkg/core")),b=p(d("clipanion"));var O=class extends b.Command{constructor(){super(...arguments);this.recursive=b.Option.Boolean("-R,--recursive",!1,{description:"Include transitive dependencies (dependencies of direct dependencies)"});this.production=b.Option.Boolean("--production",!1,{description:"Exclude development dependencies"})}async execute(){let t=await D.Configuration.find(this.context.cwd,this.context.plugins),{project:n,workspace:i}=await D.Project.find(t,this.context.cwd);if(!i)throw new ie.WorkspaceRequiredError(n.cwd,this.context.cwd);await n.restoreInstallState();let r=await te(n,this.recursive,this.production);this.context.stdout.write(r)}};O.paths=[["licenses","generate-disclaimer"]],O.usage=b.Command.Usage({description:"display the license disclaimer including all packages in the project",details:`
|
|
This command prints the license disclaimer for packages in the project. By default, only direct dependencies are listed.
|
|
|
|
If \`-R,--recursive\` is set, the disclaimer will include transitive dependencies (dependencies of direct dependencies).
|
|
|
|
If \`--production\` is set, the disclaimer will exclude development dependencies.
|
|
`,examples:[["Include licenses of direct dependencies","$0 licenses generate-disclaimer"],["Include licenses of direct and transitive dependencies","$0 licenses generate-disclaimer --recursive"],["Include licenses of production dependencies only","$0 licenses list --production"]]});var Te={commands:[S,O]},xe=Te;return Le;})();
|
|
return plugin;
|
|
}
|
|
};
|