New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

fill-pot-po

Package Overview
Dependencies
Maintainers
1
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fill-pot-po - npm Package Compare versions

Comparing version

to
2.2.2

2

dist/index.d.ts

@@ -27,2 +27,4 @@ import Vinyl from 'vinyl';

poSources?: string[] | null;
_pot_input_files?: Vinyl[];
_po_input_files?: string[][];
};

@@ -29,0 +31,0 @@ type PreparedOptions = Required<StandardizedOptions>;

8

dist/index.js

@@ -1,4 +0,4 @@

var be=Object.create;var j=Object.defineProperty;var we=Object.getOwnPropertyDescriptor;var xe=Object.getOwnPropertyNames;var Re=Object.getPrototypeOf,$e=Object.prototype.hasOwnProperty;var ve=(e,t)=>{for(var r in t)j(e,r,{get:t[r],enumerable:!0})},ne=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of xe(t))!$e.call(e,o)&&o!==r&&j(e,o,{get:()=>t[o],enumerable:!(n=we(t,o))||n.enumerable});return e};var m=(e,t,r)=>(r=e!=null?be(Re(e)):{},ne(t||!e||!e.__esModule?j(r,"default",{value:e,enumerable:!0}):r,e)),ke=e=>ne(j({},"__esModule",{value:!0}),e);var Ne={};ve(Ne,{default:()=>Ue,prepareOptions:()=>$,sync:()=>re,testOptions:()=>ye});module.exports=ke(Ne);var Ce=()=>typeof document>"u"?new URL("file:"+__filename).href:document.currentScript&&document.currentScript.src||new URL("main.js",document.baseURI).href,y=Ce();var Y=m(require("fs")),z=m(require("vinyl")),Pe=require("safe-buffer"),G=m(require("gettext-parser")),k=m(require("ansi-colors")),Se=m(require("color-support"));var se=m(require("util")),E=m(require("ansi-colors")),oe=m(require("color-support")),ae=require("fs");E.default.enabled=!!(0,oe.default)().hasBasic;var Fe=JSON.parse((0,ae.readFileSync)(new URL("../package.json",y),"utf-8")),q=class{message;category;constructor(t,r=""){this.message=t,this.category=r.slice(0,1).toUpperCase()+r.slice(1).toLowerCase()}toString(){return`${E.default.cyan(Fe.name)} ${E.default.bold.red(`${this.category}Error`)} ${this.message}`}[se.inspect.custom](){return this.toString()}},b=q;var R=require("path"),ue=m(require("vinyl"));var ie=m(require("vinyl"));var x=e=>Object.prototype.toString.call(e)==="[object Array]",le=e=>Object.prototype.toString.call(e)==="[object Object]",g=e=>Object.prototype.toString.call(e)==="[object String]",ce=e=>Object.prototype.toString.call(e)==="[object Boolean]",_=e=>x(e)?!!e.reduce((t,r)=>g(r)&&t,!0):!1,pe=e=>x(e)?!!e.reduce((t,r)=>ie.default.isVinyl(r)&&t,!0):!1,H=(e,t)=>{if(!g(e)||!g(t))throw new Error("pathLineSort: a or b not a string");let r,n;if([e,r]=e.split(":"),[t,n]=t.split(":"),e=e.replace(/(^\/|\/$)/g,""),t=t.replace(/(^\/|\/$)/g,""),e===t){if((!r||r==="")&&n&&n.length)return-1;if((!n||n==="")&&r&&r.length)return 1;if(r&&r.length&&n&&n.length)return parseInt(r)-parseInt(n)}let o=e.split("/"),s=t.split("/"),a=o.length,l=s.length,u=Math.max(a,l);for(let c=0;c<u;c++){if(c>=l||!s[c])return-1;if(c>=a||!o[c])return 1;let[f,d]=o[c].split(/\.(?=[^.]*$)/g),[O,h]=s[c].split(/\.(?=[^.]*$)/g),D=d&&d!=="",T=h&&h!=="";if(!D&&T)return-1;if(D&&!T||f.toUpperCase()>O.toUpperCase())return 1;if(f.toUpperCase()<O.toUpperCase())return-1;if(d&&h){if(d.toUpperCase()>h.toUpperCase())return 1;if(d.toUpperCase()<h.toUpperCase())return-1}}return 0};var P=class extends b{constructor(t){super(t,"options")}},W="./",De=e=>{if(le(e)){if("potSources"in e&&!g(e.potSources)&&!_(e.potSources)&&!ue.default.isVinyl(e.potSources)&&!pe(e.potSources))throw new P("Option potSources should be a string or Vinyl object, or an array of those.");if("poSources"in e&&e.poSources!==null&&!g(e.poSources)&&!_(e.poSources))throw new P("Option poSources should be a glob string or glob array.");if("wrapLength"in e&&(typeof e.wrapLength!="number"||0>=e.wrapLength))throw new P("If set, option wrapLength should be a number higher than 0.");let t=["srcDir","destDir","domain"];for(let n of t)if(n in e)if(g(e[n])){if(e[n].match(/\n/))throw new P(`Option ${n} can't contain newline characters.`)}else throw new P(`Option ${n} should be a string.`);let r=["writeFiles","returnPOT","domainFromPOTPath","domainInPOPath","defaultContextAsFallback","appendNonIncludedFromPO","includePORevisionDate","includeGenerator","logResults"];for(let n of r)if(n in e&&!ce(e[n]))throw new P(`Option ${n} should be a boolean.`)}else{if(g(e)||_(e))return{poSources:e};if(typeof e<"u")throw new P("Options should be an object of options, glob string or glob array.");return{}}return e},Te=e=>(typeof e.potSources<"u"&&(x(e.potSources)||(e.potSources=[e.potSources]),e.potSources=e.potSources.map(t=>g(t)?t.trim():t).filter(t=>!g(t)||t.length>0)),typeof e.poSources<"u"&&e.poSources!==null&&(x(e.poSources)||(e.poSources=[e.poSources]),e.poSources=e.poSources.map(t=>t.trim()).filter(t=>t.length>0)),e.srcDir&&(e.srcDir=(0,R.resolve)(e.srcDir.trim()),e.srcDir=`${(0,R.relative)(W,e.srcDir)}/`.replace(/\\/g,"/").replace(/\/+/g,"/").replace(/(?<!\.)\.\//g,"").replace(/^\//g,"")),e.destDir&&(e.destDir=(0,R.resolve)(e.destDir.trim()),e.destDir=`${(0,R.relative)(W,e.destDir)}/`.replace(/\\/g,"/").replace(/\/+/g,"/").replace(/(?<!\.)\.\//g,"").replace(/^\//g,"")),e.wrapLength&&(e.wrapLength=Math.ceil(e.wrapLength)),e),$=e=>{W=(0,R.resolve)(),e=De(e),e=Te(e);let r=Object.assign({},{potSources:["**/*.pot","!node_modules/**"],poSources:null,srcDir:"",domainInPOPath:!0,domainFromPOTPath:!0,domain:"",srcGlobOptions:{},wrapLength:77,defaultContextAsFallback:!1,appendNonIncludedFromPO:!1,includePORevisionDate:!1,includeGenerator:!0,returnPOT:!1,writeFiles:!0,destDir:"",logResults:!1},e);if(r.domainFromPOTPath===!1&&r.domainInPOPath===!0&&0>=r.domain.length)throw new P("Option domain should be a non-empty string when domainFromPOTPath is false and domainInPOPath is true.");if(r.returnPOT&&!r.writeFiles)throw new P("If option returnPOT is true, option writeFiles must be true or no PO files will be generated.");return r};var v=require("path"),me=require("safe-buffer"),X=require("matched"),F=require("fs"),de=m(require("gettext-parser")),ge=m(require("vinyl")),S=m(require("ansi-colors")),Oe=m(require("color-support"));var he=require("fs");S.default.enabled=!!(0,Oe.default)().hasBasic;var fe=JSON.parse((0,he.readFileSync)(new URL("../package.json",y),"utf-8")),L=e=>{if(x(e.potSources)&&e.potSources.length&&g(e.potSources[0])&&(e.potSources=(0,X.sync)(e.potSources)),e._potFilenames=e.potSources.map(t=>g(t)?t:t.path),0>=e.potSources.length)throw new b("No POT files found to process.");if(1<e.potSources.length&&e.poSources)throw new b(`When processing multiple POT files, leave option poSources empty.
Else, the same generated PO files will be overwritten for each POT file.`,"options");return e},I=(e,t)=>{let r=(0,v.basename)(e,".pot"),n=t.domainFromPOTPath?r:t.domain,o=t.srcDir?t.srcDir:`${(0,v.dirname)(e)}/`,s=[];if(t.poSources)s.push(...t.poSources);else{let l="[a-z][a-z]?([a-z])?(_[A-Z][A-Z]?([A-Z]))?(_formal)",u=t.domainInPOPath?`${n}-`:"";s.push(`${o}${u}${l}.po`)}return(0,X.sync)(s,t.srcGlobOptions).sort(H)},U=(e,t,r,n)=>{let o=JSON.parse(JSON.stringify(e));o=Ve(o,t,n);let s=Ae(o,n),a=(0,v.basename)(r);return n.writeFiles&&je(`${n.destDir}${a}`,s),new ge.default({contents:me.Buffer.from(s),path:a})},Ve=(e,t,r)=>{var n,o,s,a,l,u,c,f,d,O,h,D,T;for(let[i,V]of Object.entries(e.translations))for(let[p,w]of Object.entries(V))t.translations[i]&&t.translations[i][p]&&t.translations[i][p].msgstr.length===w.msgstr.length?e.translations[i][p].msgstr=[...t.translations[i][p].msgstr]:r.defaultContextAsFallback&&t.translations[""]&&t.translations[""][p]&&t.translations[""][p].msgstr.length===w.msgstr.length&&(e.translations[i][p].msgstr=[...t.translations[""][p].msgstr],e.translations[i][p].comments={...((n=e.translations[i][p])==null?void 0:n.comments)??{},flag:["fuzzy",(s=(o=e.translations[i][p])==null?void 0:o.comments)==null?void 0:s.flag].filter(Z=>Z).join(", ")},t.translations[""][p].comments={...((a=t.translations[""][p])==null?void 0:a.comments)??{},translator:[`NOTE: re-used for same message, but with context '${i}'`,(u=(l=t.translations[""][p])==null?void 0:l.comments)==null?void 0:u.translator].filter(Z=>Z).join(`
`)});if(r.appendNonIncludedFromPO)for(let[i,V]of Object.entries(t.translations)){e.translations[i]||(e.translations[i]={});for(let[p,w]of Object.entries(V))e.translations[i][p]||(e.translations[i][p]=w,e.translations[i][p].comments={...((c=e.translations[i][p])==null?void 0:c.comments)??{},...(d=(f=e.translations[i][p])==null?void 0:f.comments)!=null&&d.translator&&((O=w==null?void 0:w.comments)!=null&&O.translator.match(/^DEPRECATED$/gm))?{}:{translator:g((D=(h=e.translations[i][p])==null?void 0:h.comments)==null?void 0:D.translator)?`DEPRECATED
`+(((T=e.translations[i][p].comments)==null?void 0:T.translator)??""):"DEPRECATED"}})}if(r.includePORevisionDate){let i=new Date,V=[`${i.getUTCFullYear()}`,`-${String(i.getUTCMonth()+1).padStart(2,"0")}`,`-${String(i.getUTCDate()).padStart(2,"0")}`,` ${String(i.getUTCHours()).padStart(2,"0")}`,`:${String(i.getUTCMinutes()).padStart(2,"0")}`,"+0000"].join("");e.headers["po-revision-date"]=V}return r.includeGenerator&&(e.headers["X-Generator"]=`${fe.name}/${fe.version}`),e},Ae=(e,t)=>de.default.po.compile(e,{foldLength:t.wrapLength,sort:(r,n)=>{var a,l,u,c,f,d;let o=(l=(a=n.comments)==null?void 0:a.translator)==null?void 0:l.match(/^DEPRECATED$/gm),s=(c=(u=r.comments)==null?void 0:u.translator)==null?void 0:c.match(/^DEPRECATED$/gm);return!s&&o?-1:s&&!o?1:(f=n.comments)!=null&&f.reference?(d=r.comments)!=null&&d.reference?(r=r.comments.reference.trim().split(/\s+/)[0],n=n.comments.reference.trim().split(/\s+/)[0],H(r,n)):1:-1}}),je=(e,t)=>{let r=(0,v.dirname)(e);(0,F.existsSync)(r)||(0,F.mkdirSync)(r,{recursive:!0}),(0,F.writeFileSync)(e,t.toString())},N=(e,t,r,n)=>{e.forEach((o,s)=>{var f,d;let a=(0,v.basename)(o),l=(f=t[s])==null?void 0:f.map(O=>O),u=(d=r[s])==null?void 0:d.map(O=>O.path),c=l.reduce((O,h)=>Math.max(h.length,O),0);console.log(""),u&&u.length?(console.log(` ${S.default.bold.green("\u25A0")} ${S.default.white(a)}`),u.forEach((O,h)=>{console.log([" ",`${S.default.cyan(l[h].padEnd(c," "))}`,` ${S.default.gray("\u2014\u25BA")} `,`${S.default.yellow(n)}${S.default.yellow(O)}`].join(""))})):(console.log(` ${S.default.gray("\u25A0")} ${S.default.white(a)}`),console.log(` ${S.default.gray("No PO files found.")}`))}),console.log("")};k.default.enabled=!!(0,Se.default)().hasBasic;var J=[],B=[],Ee=(e,t,r)=>{Y.readFile(e,(n,o)=>{n&&r(n);let s=G.default.po.parse(o);t(s)})},_e=(e,t,r,n)=>{let o=z.default.isVinyl(e),s=o?e.path:e,a=I(s,t);if(a.length)if(o){t.returnPOT&&J.push(e);let l=G.default.po.parse(e.contents);r([l,a])}else Y.readFile(s,(l,u)=>{l&&n(l),t.returnPOT&&J.push(new z.default({contents:Pe.Buffer.from(u),path:s}));let c=G.default.po.parse(u);r([c,a])});else r(null)},C=(e,t)=>{if(typeof e!="function")throw new b("fillPotPo() requires a callback function as first parameter");let r;try{r=L($(t))}catch(n){e([!1,n.toString()]);return}J=[],B=[],Promise.all(r.potSources.map(n=>{let o=z.default.isVinyl(n)?n.relative:n;return new Promise((s,a)=>{_e(n,r,s,a)}).then(async s=>{if(!s)return B.push([]),[];let a=s[0],l=s[1];return B.push(l),await Promise.all(l.map(c=>new Promise((f,d)=>{Ee(c,f,d)}).then(f=>U(a,f,c,r)).catch(f=>{throw new b(`${k.default.bold(f.message)} ${k.default.gray(`(PO ${k.default.white(c)})`)}`)})))}).catch(s=>{throw new b(`${s.message} ${k.default.gray(`(POT ${k.default.white(o)})`)}`)})})).then(n=>{if(r.logResults&&N(r._potFilenames,B,n,r.destDir),r.returnPOT){e([!0,J]);return}e([!0,[].concat(...n)])}).catch(n=>{e([!1,n.toString()])})};var ee=m(require("fs")),K=m(require("vinyl")),te=m(require("gettext-parser"));var M=[],Q=[],A=[],Le=(e,t,r)=>{let n=[];for(let o of e){let s=ee.readFileSync(o).toString(),a=te.default.po.parse(s);n.push(U(t,a,o,r))}A.push(n)},Ie=(e,t)=>{let r=K.default.isVinyl(e),n=r?e.path:e,o=I(n,t);if(Q.push(o),o.length){let s="";if(r)t.returnPOT&&M.push(e),s=e.contents;else{let l=ee.readFileSync(n);s=l.toString(),t.returnPOT&&M.push(new K.default({contents:l,path:n}))}let a=te.default.po.parse(s);Le(o,a,t)}else A.push([])},re=e=>{M=[],Q=[],A=[];let t=L($(e));return t.potSources.forEach(r=>{Ie(r,t)}),t.logResults&&N(t._potFilenames,Q,A,t.destDir),t.returnPOT?M:[].concat(...A)};var ye={wrapLength:77,defaultContextAsFallback:!0,appendNonIncludedFromPO:!0,includePORevisionDate:!1,includeGenerator:!1},Ue=C;typeof module<"u"&&(C.sync=re,C.testOptions=ye,C.prepareOptions=$,module.exports=C,module.exports.default=C);0&&(module.exports={prepareOptions,sync,testOptions});
var Pe=Object.create;var A=Object.defineProperty;var Se=Object.getOwnPropertyDescriptor;var ye=Object.getOwnPropertyNames;var be=Object.getPrototypeOf,we=Object.prototype.hasOwnProperty;var _e=(e,r)=>{for(var t in r)A(e,t,{get:r[t],enumerable:!0})},ee=(e,r,t,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of ye(r))!we.call(e,o)&&o!==t&&A(e,o,{get:()=>r[o],enumerable:!(n=Se(r,o))||n.enumerable});return e};var m=(e,r,t)=>(t=e!=null?Pe(be(e)):{},ee(r||!e||!e.__esModule?A(t,"default",{value:e,enumerable:!0}):t,e)),xe=e=>ee(A({},"__esModule",{value:!0}),e);var Le={};_e(Le,{default:()=>Ee,prepareOptions:()=>R,sync:()=>Q,testOptions:()=>he});module.exports=xe(Le);var Re=()=>typeof document>"u"?new URL("file:"+__filename).href:document.currentScript&&document.currentScript.src||new URL("main.js",document.baseURI).href,y=Re();var H=m(require("fs")),B=m(require("vinyl")),ge=require("safe-buffer"),z=m(require("gettext-parser")),v=m(require("ansi-colors")),Oe=m(require("color-support"));var te=m(require("util")),j=m(require("ansi-colors")),re=m(require("color-support")),ne=require("fs");j.default.enabled=!!(0,re.default)().hasBasic;var $e=JSON.parse((0,ne.readFileSync)(new URL("../package.json",y),"utf-8")),M=class{message;category;constructor(r,t=""){this.message=r,this.category=t.slice(0,1).toUpperCase()+t.slice(1).toLowerCase()}toString(){return`${j.default.cyan($e.name)} ${j.default.bold.red(`${this.category}Error`)} ${this.message}`}[te.inspect.custom](){return this.toString()}},b=M;var x=require("path"),le=m(require("vinyl"));var se=m(require("vinyl"));var _=e=>Object.prototype.toString.call(e)==="[object Array]",oe=e=>Object.prototype.toString.call(e)==="[object Object]",g=e=>Object.prototype.toString.call(e)==="[object String]",ie=e=>Object.prototype.toString.call(e)==="[object Boolean]",E=e=>_(e)?!!e.reduce((r,t)=>g(t)&&r,!0):!1,ae=e=>_(e)?!!e.reduce((r,t)=>se.default.isVinyl(t)&&r,!0):!1,Z=(e,r)=>{if(!g(e)||!g(r))throw new Error("pathLineSort: a or b not a string");let t,n;if([e,t]=e.split(":"),[r,n]=r.split(":"),e=e.replace(/(^\/|\/$)/g,""),r=r.replace(/(^\/|\/$)/g,""),e===r){if((!t||t==="")&&n&&n.length)return-1;if((!n||n==="")&&t&&t.length)return 1;if(t&&t.length&&n&&n.length)return parseInt(t)-parseInt(n)}let o=e.split("/"),s=r.split("/"),i=o.length,l=s.length,u=Math.max(i,l);for(let c=0;c<u;c++){if(c>=l||!s[c])return-1;if(c>=i||!o[c])return 1;let[f,d]=o[c].split(/\.(?=[^.]*$)/g),[O,h]=s[c].split(/\.(?=[^.]*$)/g),F=d&&d!=="",D=h&&h!=="";if(!F&&D)return-1;if(F&&!D||f.toUpperCase()>O.toUpperCase())return 1;if(f.toUpperCase()<O.toUpperCase())return-1;if(d&&h){if(d.toUpperCase()>h.toUpperCase())return 1;if(d.toUpperCase()<h.toUpperCase())return-1}}return 0};var P=class extends b{constructor(r){super(r,"options")}},ve=e=>{if(oe(e)){if("potSources"in e&&!g(e.potSources)&&!E(e.potSources)&&!le.default.isVinyl(e.potSources)&&!ae(e.potSources))throw new P("Option potSources should be a string or Vinyl object, or an array of those.");if("poSources"in e&&e.poSources!==null&&!g(e.poSources)&&!E(e.poSources))throw new P("Option poSources should be a glob string or glob array.");if("wrapLength"in e&&(typeof e.wrapLength!="number"||0>=e.wrapLength))throw new P("If set, option wrapLength should be a number higher than 0.");let r=["srcDir","destDir","domain"];for(let n of r)if(n in e)if(g(e[n])){if(e[n].match(/\n/))throw new P(`Option ${n} can't contain newline characters.`)}else throw new P(`Option ${n} should be a string.`);let t=["writeFiles","returnPOT","domainFromPOTPath","domainInPOPath","defaultContextAsFallback","appendNonIncludedFromPO","includePORevisionDate","includeGenerator","logResults"];for(let n of t)if(n in e&&!ie(e[n]))throw new P(`Option ${n} should be a boolean.`)}else{if(g(e)||E(e))return{poSources:e};if(typeof e<"u")throw new P("Options should be an object of options, glob string or glob array.");return{}}return e},ke=e=>{let r=(0,x.resolve)();return typeof e.potSources<"u"&&(_(e.potSources)||(e.potSources=[e.potSources]),e.potSources=e.potSources.map(t=>g(t)?t.trim():t).filter(t=>!g(t)||t.length>0)),typeof e.poSources<"u"&&e.poSources!==null&&(_(e.poSources)||(e.poSources=[e.poSources]),e.poSources=e.poSources.map(t=>t.trim()).filter(t=>t.length>0)),e.srcDir&&(e.srcDir=(0,x.resolve)(e.srcDir.trim()),e.srcDir=`${(0,x.relative)(r,e.srcDir)}/`.replace(/\\/g,"/").replace(/\/+/g,"/").replace(/(?<!\.)\.\//g,"").replace(/^\//g,"")),e.destDir&&(e.destDir=(0,x.resolve)(e.destDir.trim()),e.destDir=`${(0,x.relative)(r,e.destDir)}/`.replace(/\\/g,"/").replace(/\/+/g,"/").replace(/(?<!\.)\.\//g,"").replace(/^\//g,"")),e.wrapLength&&(e.wrapLength=Math.ceil(e.wrapLength)),e},R=e=>{e=ve(e),e=ke(e);let t=Object.assign({},{potSources:["**/*.pot","!node_modules/**"],poSources:null,srcDir:"",domainInPOPath:!0,domainFromPOTPath:!0,domain:"",srcGlobOptions:{},wrapLength:77,defaultContextAsFallback:!1,appendNonIncludedFromPO:!1,includePORevisionDate:!1,includeGenerator:!0,returnPOT:!1,writeFiles:!0,destDir:"",logResults:!1,_pot_input_files:[],_po_input_files:[]},e);if(t.domainFromPOTPath===!1&&t.domainInPOPath===!0&&0>=t.domain.length)throw new P("Option domain should be a non-empty string when domainFromPOTPath is false and domainInPOPath is true.");if(t.returnPOT&&!t.writeFiles)throw new P("If option returnPOT is true, option writeFiles must be true or no PO files will be generated.");return t};var $=require("path"),pe=require("safe-buffer"),q=require("matched"),C=require("fs"),ue=m(require("gettext-parser")),fe=m(require("vinyl")),S=m(require("ansi-colors")),me=m(require("color-support"));var de=require("fs");S.default.enabled=!!(0,me.default)().hasBasic;var ce=JSON.parse((0,de.readFileSync)(new URL("../package.json",y),"utf-8")),L=e=>{if(_(e.potSources)&&e.potSources.length&&g(e.potSources[0])&&(e.potSources=(0,q.sync)(e.potSources)),e._potFilenames=e.potSources.map(r=>g(r)?r:r.path),0>=e.potSources.length)throw new b("No POT files found to process.");if(1<e.potSources.length&&e.poSources)throw new b(`When processing multiple POT files, leave option poSources empty.
Else, the same generated PO files will be overwritten for each POT file.`,"options");return e},I=(e,r)=>{let t=(0,$.basename)(e,".pot"),n=r.domainFromPOTPath?t:r.domain,o=r.srcDir?r.srcDir:`${(0,$.dirname)(e)}/`,s=[];if(r.poSources)s.push(...r.poSources);else{let l="[a-z][a-z]?([a-z])?(_[A-Z][A-Z]?([A-Z]))?(_formal)",u=r.domainInPOPath?`${n}-`:"";s.push(`${o}${u}${l}.po`)}return(0,q.sync)(s,r.srcGlobOptions).sort(Z)},U=(e,r,t,n)=>{let o=JSON.parse(JSON.stringify(e));o=Ce(o,r,n);let s=Fe(o,n),i=(0,$.basename)(t);return n.writeFiles&&De(`${n.destDir}${i}`,s),new fe.default({contents:pe.Buffer.from(s),path:i})},Ce=(e,r,t)=>{var n,o,s,i,l,u,c,f,d,O,h,F,D;for(let[a,T]of Object.entries(e.translations))for(let[p,w]of Object.entries(T))r.translations[a]&&r.translations[a][p]&&r.translations[a][p].msgstr.length===w.msgstr.length?e.translations[a][p].msgstr=[...r.translations[a][p].msgstr]:t.defaultContextAsFallback&&r.translations[""]&&r.translations[""][p]&&r.translations[""][p].msgstr.length===w.msgstr.length&&(e.translations[a][p].msgstr=[...r.translations[""][p].msgstr],e.translations[a][p].comments={...((n=e.translations[a][p])==null?void 0:n.comments)??{},flag:["fuzzy",(s=(o=e.translations[a][p])==null?void 0:o.comments)==null?void 0:s.flag].filter(J=>J).join(", ")},r.translations[""][p].comments={...((i=r.translations[""][p])==null?void 0:i.comments)??{},translator:[`NOTE: re-used for same message, but with context '${a}'`,(u=(l=r.translations[""][p])==null?void 0:l.comments)==null?void 0:u.translator].filter(J=>J).join(`
`)});if(t.appendNonIncludedFromPO)for(let[a,T]of Object.entries(r.translations)){e.translations[a]||(e.translations[a]={});for(let[p,w]of Object.entries(T))e.translations[a][p]||(e.translations[a][p]=w,e.translations[a][p].comments={...((c=e.translations[a][p])==null?void 0:c.comments)??{},...(d=(f=e.translations[a][p])==null?void 0:f.comments)!=null&&d.translator&&((O=w==null?void 0:w.comments)!=null&&O.translator.match(/^DEPRECATED$/gm))?{}:{translator:g((F=(h=e.translations[a][p])==null?void 0:h.comments)==null?void 0:F.translator)?`DEPRECATED
`+(((D=e.translations[a][p].comments)==null?void 0:D.translator)??""):"DEPRECATED"}})}if(t.includePORevisionDate){let a=new Date,T=[`${a.getUTCFullYear()}`,`-${String(a.getUTCMonth()+1).padStart(2,"0")}`,`-${String(a.getUTCDate()).padStart(2,"0")}`,` ${String(a.getUTCHours()).padStart(2,"0")}`,`:${String(a.getUTCMinutes()).padStart(2,"0")}`,"+0000"].join("");e.headers["po-revision-date"]=T}return t.includeGenerator&&(e.headers["X-Generator"]=`${ce.name}/${ce.version}`),e},Fe=(e,r)=>ue.default.po.compile(e,{foldLength:r.wrapLength,sort:(t,n)=>{var i,l,u,c,f,d;let o=(l=(i=n.comments)==null?void 0:i.translator)==null?void 0:l.match(/^DEPRECATED$/gm),s=(c=(u=t.comments)==null?void 0:u.translator)==null?void 0:c.match(/^DEPRECATED$/gm);return!s&&o?-1:s&&!o?1:(f=n.comments)!=null&&f.reference?(d=t.comments)!=null&&d.reference?(t=t.comments.reference.trim().split(/\s+/)[0],n=n.comments.reference.trim().split(/\s+/)[0],Z(t,n)):1:-1}}),De=(e,r)=>{let t=(0,$.dirname)(e);(0,C.existsSync)(t)||(0,C.mkdirSync)(t,{recursive:!0}),(0,C.writeFileSync)(e,r.toString())},N=(e,r,t,n)=>{e.forEach((o,s)=>{var f,d;let i=(0,$.basename)(o),l=(f=r[s])==null?void 0:f.map(O=>O),u=(d=t[s])==null?void 0:d.map(O=>O.path),c=l.reduce((O,h)=>Math.max(h.length,O),0);console.log(""),u&&u.length?(console.log(` ${S.default.bold.green("\u25A0")} ${S.default.white(i)}`),u.forEach((O,h)=>{console.log([" ",`${S.default.cyan(l[h].padEnd(c," "))}`,` ${S.default.gray("\u2014\u25BA")} `,`${S.default.yellow(n)}${S.default.yellow(O)}`].join(""))})):(console.log(` ${S.default.gray("\u25A0")} ${S.default.white(i)}`),console.log(` ${S.default.gray("No PO files found.")}`))}),console.log("")};v.default.enabled=!!(0,Oe.default)().hasBasic;var Te=(e,r,t)=>{H.readFile(e,(n,o)=>{n&&t(n);let s=z.default.po.parse(o);r(s)})},Ve=(e,r,t,n)=>{let o=B.default.isVinyl(e),s=o?e.path:e,i=I(s,r);if(i.length)if(o){r.returnPOT&&r._pot_input_files.push(e);let l=z.default.po.parse(e.contents);t([l,i])}else H.readFile(s,(l,u)=>{l&&n(l),r.returnPOT&&r._pot_input_files.push(new B.default({contents:ge.Buffer.from(u),path:s}));let c=z.default.po.parse(u);t([c,i])});else t(null)},k=(e,r)=>{if(typeof e!="function")throw new b("fillPotPo() requires a callback function as first parameter");let t;try{t=L(R(r))}catch(n){e([!1,n.toString()]);return}t._pot_input_files=[],t._po_input_files=[],Promise.all(t.potSources.map(n=>{let o=B.default.isVinyl(n)?n.relative:n;return new Promise((s,i)=>{Ve(n,t,s,i)}).then(async s=>{if(!s)return t._po_input_files.push([]),[];let i=s[0],l=s[1];return t._po_input_files.push(l),await Promise.all(l.map(c=>new Promise((f,d)=>{Te(c,f,d)}).then(f=>U(i,f,c,t)).catch(f=>{throw new b(`${v.default.bold(f.message)} ${v.default.gray(`(PO ${v.default.white(c)})`)}`)})))}).catch(s=>{throw new b(`${s.message} ${v.default.gray(`(POT ${v.default.white(o)})`)}`)})})).then(n=>{if(t.logResults&&N(t._potFilenames,t._po_input_files,n,t.destDir),t.returnPOT){e([!0,t._pot_input_files]);return}e([!0,[].concat(...n)])}).catch(n=>{e([!1,n.toString()])}).finally(()=>{t._pot_input_files=[],t._po_input_files=[]})};var Y=m(require("fs")),W=m(require("vinyl")),K=m(require("gettext-parser"));var G=[],X=[],V=[],Ae=(e,r,t)=>{let n=[];for(let o of e){let s=Y.readFileSync(o).toString(),i=K.default.po.parse(s);n.push(U(r,i,o,t))}V.push(n)},je=(e,r)=>{let t=W.default.isVinyl(e),n=t?e.path:e,o=I(n,r);if(X.push(o),o.length){let s="";if(t)r.returnPOT&&G.push(e),s=e.contents;else{let l=Y.readFileSync(n);s=l.toString(),r.returnPOT&&G.push(new W.default({contents:l,path:n}))}let i=K.default.po.parse(s);Ae(o,i,r)}else V.push([])},Q=e=>{G=[],X=[],V=[];let r=L(R(e));return r.potSources.forEach(t=>{je(t,r)}),r.logResults&&N(r._potFilenames,X,V,r.destDir),r.returnPOT?G:[].concat(...V)};var he={wrapLength:77,defaultContextAsFallback:!0,appendNonIncludedFromPO:!0,includePORevisionDate:!1,includeGenerator:!1},Ee=k;typeof module<"u"&&(k.sync=Q,k.testOptions=he,k.prepareOptions=R,module.exports=k,module.exports.default=k);0&&(module.exports={prepareOptions,sync,testOptions});
{
"name": "fill-pot-po",
"version": "2.2.1",
"version": "2.2.2",
"description": "Create pre-filled PO files from POT file, using previous PO files.",

@@ -62,10 +62,10 @@ "main": "./dist/index.js",

"@types/jest": "^29.5.3",
"@typescript-eslint/eslint-plugin": "^6.1.0",
"@typescript-eslint/parser": "^6.1.0",
"@typescript-eslint/eslint-plugin": "^6.2.1",
"@typescript-eslint/parser": "^6.2.1",
"babel-plugin-transform-import-meta": "^2.2.0",
"eslint": "^8.45.0",
"eslint-config-prettier": "^8.8.0",
"eslint": "^8.46.0",
"eslint-config-prettier": "^8.9.0",
"eslint-plugin-jest": "^27.2.3",
"eslint-plugin-prettier": "^5.0.0",
"jest": "^29.6.1",
"jest": "^29.6.2",
"ts-jest": "^29.1.1",

@@ -72,0 +72,0 @@ "ts-node": "^10.9.1",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet