@wp-blocks/make-pot 1.5.1 → 1.6.0
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/README.md +2 -1
- package/lib/cli/getArgs.js +1 -1
- package/lib/cli/getJsonArgs.js +1 -1
- package/lib/cli/parseCli.js +1 -1
- package/lib/const.js +1 -1
- package/lib/extractors/auditStrings.js +5 -0
- package/lib/extractors/css.js +1 -1
- package/lib/extractors/headers.js +12 -4
- package/lib/fs/fs.js +1 -1
- package/lib/index.js +1 -1
- package/lib/jsonCommand.js +1 -1
- package/lib/parser/exec.js +3 -7
- package/lib/parser/makeJson.js +1 -1
- package/lib/parser/makePot.js +1 -1
- package/lib/parser/process.js +1 -1
- package/lib/potCommand.js +1 -1
- package/lib/utils/common.js +8 -4
- package/lib/utils/output.js +1 -0
- package/package.json +4 -2
- package/tests/audit.test.js +50 -0
- package/tests/compare-json.test.js +81 -0
- package/tests/parse-headers.test.js +7 -6
- package/lib/assets/block-i18n.js.map +0 -7
- package/lib/assets/package-i18n.js.map +0 -7
- package/lib/assets/theme-i18n.js.map +0 -7
- package/lib/assets/wp-plugin-i18n.js.map +0 -7
- package/lib/assets/wp-theme-i18n.js.map +0 -7
- package/lib/cli/getArgs.js.map +0 -7
- package/lib/cli/getJsonArgs.js.map +0 -7
- package/lib/cli/parseCli.js.map +0 -7
- package/lib/cli.js.map +0 -7
- package/lib/const.js.map +0 -7
- package/lib/extractors/css.js.map +0 -7
- package/lib/extractors/headers.js.map +0 -7
- package/lib/extractors/json.js.map +0 -7
- package/lib/extractors/packageJson.js.map +0 -7
- package/lib/extractors/php.js.map +0 -7
- package/lib/extractors/schema.js.map +0 -7
- package/lib/extractors/text.js.map +0 -7
- package/lib/fs/fs.js.map +0 -7
- package/lib/fs/glob.js.map +0 -7
- package/lib/index.js.map +0 -7
- package/lib/jsonCommand.js.map +0 -7
- package/lib/makeJson.js.map +0 -7
- package/lib/makePot.js.map +0 -7
- package/lib/parser/exec.js.map +0 -7
- package/lib/parser/makeJson.js.map +0 -7
- package/lib/parser/makePot.js.map +0 -7
- package/lib/parser/patterns.js.map +0 -7
- package/lib/parser/process.js.map +0 -7
- package/lib/parser/progress.js.map +0 -7
- package/lib/parser/taskRunner.js.map +0 -7
- package/lib/parser/tree.js.map +0 -7
- package/lib/potCommand.js.map +0 -7
- package/lib/types.js.map +0 -7
- package/lib/utils/common.js.map +0 -7
- package/lib/utils/extractors.js.map +0 -7
package/README.md
CHANGED
|
@@ -65,7 +65,7 @@ npx @wp-blocks/make-pot src languages --charset='utf-8' --include="src/**/*.{ts,
|
|
|
65
65
|
- `--skip-block-json`: Skips block.json files during processing.
|
|
66
66
|
- `--skip-theme-json`: Skips theme.json files during processing.
|
|
67
67
|
- `--skip-audit`: Skips auditing of strings.
|
|
68
|
-
- `--headers <headers>`: Specifies additional headers for the `.pot` file.
|
|
68
|
+
- `--headers <headers>`: Specifies additional headers for the `.pot` file. Accepts an array of strings (--headers=email:erik@ck.it,domain:my-block) or multiple values (--headers=email:erik@ck.it --headers=domain:my-block)
|
|
69
69
|
- `--file-comment <comment>`: Specifies the file comment for the `.pot` file.
|
|
70
70
|
- `--package-name <name>`: Specifies the package name.
|
|
71
71
|
- `--location`: Includes location information in the `.pot` file.
|
|
@@ -158,6 +158,7 @@ Unlike traditional PO/MO files, JavaScript translations use JSON. This format is
|
|
|
158
158
|
- `--allowedFormats`: The allowed formats of the translation file (e.g. `js` or `tsx`).
|
|
159
159
|
- `--purge`: if enabled, removes the existing translation file. Otherwise, the old translation file will be merged with the new.
|
|
160
160
|
- `--prettyPrint`: Pretty prints the translation file.
|
|
161
|
+
- `--stripUnused`: strips unused translations from the translation file (default: true).
|
|
161
162
|
- `--debug`: Enables debug mode.
|
|
162
163
|
|
|
163
164
|
## How to Generate Json translations
|
package/lib/cli/getArgs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var l=Object.create;var o=Object.defineProperty;var
|
|
1
|
+
"use strict";var l=Object.create;var o=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var g=Object.getOwnPropertyNames;var u=Object.getPrototypeOf,f=Object.prototype.hasOwnProperty;var y=(e,t)=>{for(var i in t)o(e,i,{get:t[i],enumerable:!0})},n=(e,t,i,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of g(t))!f.call(e,s)&&s!==i&&o(e,s,{get:()=>t[s],enumerable:!(r=b(t,s))||r.enumerable});return e};var a=(e,t,i)=>(i=e!=null?l(u(e)):{},n(t||!e||!e.__esModule?o(i,"default",{value:e,enumerable:!0}):i,e)),m=e=>n(o({},"__esModule",{value:!0}),e);var S={};y(S,{getArgs:()=>h});module.exports=m(S);var p=a(require("node:process")),k=a(require("yargs")),d=require("yargs/helpers"),c=require("./parseCli.js");function h(e={}){const t=k.default((0,d.hideBin)(p.default.argv)).help("h").alias("help","help").usage("Usage: $0 <source> [destination] [options]").positional("sourceDirectory",{describe:"Source directory",type:"string"}).positional("destination",{describe:"Destination directory",type:"string"}).options({slug:{describe:"Plugin or theme slug",type:"string"},domain:{describe:"Text domain to look for in the source code",type:"string"},"skip-js":{describe:"Skip JavaScript files",type:"boolean"},"skip-php":{describe:"Skip PHP files",type:"boolean"},"skip-blade":{describe:"Skip Blade files",type:"boolean"},"skip-block-json":{describe:"Skip block.json files",type:"boolean"},"skip-theme-json":{describe:"Skip theme.json files",type:"boolean"},"skip-audit":{describe:"Skip auditing of strings",type:"boolean",default:!1},headers:{describe:"Additional Headers",type:"array",default:[]},"file-comment":{describe:"File comment",type:"string"},"package-name":{describe:"Package name",type:"string"},location:{describe:"Include location information",type:"boolean"},"ignore-domain":{describe:"Ignore text domain",type:"boolean"},mergePaths:{describe:"Merge with existing POT file(s)",type:"string"},subtractPaths:{describe:"Subtract strings from existing POT file(s)",type:"string"},subtractAndMerge:{describe:"Subtract and merge strings from existing POT file(s)",type:"boolean"},include:{describe:"Include specific files",type:"string",default:"**"},exclude:{describe:"Exclude specific files",type:"string"},silent:{describe:"No output to stdout",type:"boolean",default:!1},json:{describe:"Output the json gettext data",type:"boolean"},output:{describe:"Output the gettext data",type:"boolean"},charset:{describe:"Charset",type:"string",default:"latin1"},debug:{describe:"Debug mode",type:"boolean",default:!1}}).parseSync();return(0,c.parseCliArgs)({...e,...t})}0&&(module.exports={getArgs});
|
package/lib/cli/getJsonArgs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var u=Object.create;var o=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var y=Object.getPrototypeOf,g=Object.prototype.hasOwnProperty;var b=(e,t)=>{for(var s in t)o(e,s,{get:t[s],enumerable:!0})},a=(e,t,s,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of f(t))!g.call(e,r)&&r!==s&&o(e,r,{get:()=>t[r],enumerable:!(i=c(t,r))||i.enumerable});return e};var n=(e,t,s)=>(s=e!=null?u(y(e)):{},a(t||!e||!e.__esModule?o(s,"default",{value:e,enumerable:!0}):s,e)),m=e=>a(o({},"__esModule",{value:!0}),e);var S={};b(S,{getJsonArgs:()=>J});module.exports=m(S);var p=n(require("node:process")),h=n(require("yargs")),d=require("yargs/helpers"),l=require("./parseCli.js");function J(e={}){const t=h.default((0,d.hideBin)(p.default.argv)).help("h").alias("help","help").usage("Usage: $0 <source> [destination] [options]").positional("source",{describe:"Source directory",type:"string"}).positional("destination",{describe:"Destination directory",type:"string"}).options({scriptName:{describe:"The name of the script to be translated",type:"string"},allowedFormats:{describe:"which extensions to use for translation",type:"array",default:["js"]},purge:{describe:"Remove old JSON files",type:"boolean",default:!0},prettyPrint:{describe:"Pretty print JSON",type:"boolean",default:!1},debug:{describe:"Debug mode",type:"boolean",default:!1},stripUnused:{describe:"Strip unused translations in js files",type:"boolean",default:!0}}).parseSync();return(0,l.parseJsonArgs)({...e,...t})}0&&(module.exports={getJsonArgs});
|
package/lib/cli/parseCli.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var w=Object.create;var u=Object.defineProperty;var J=Object.getOwnPropertyDescriptor;var T=Object.getOwnPropertyNames;var _=Object.getPrototypeOf,j=Object.prototype.hasOwnProperty;var v=(t,n)=>{for(var e in n)u(t,e,{get:n[e],enumerable:!0})},g=(t,n,e,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let s of T(n))!j.call(t,s)&&s!==e&&u(t,s,{get:()=>n[s],enumerable:!(o=J(n,s))||o.enumerable});return t};var d=(t,n,e)=>(e=t!=null?w(_(t)):{},g(n||!t||!t.__esModule?u(e,"default",{value:t,enumerable:!0}):e,t)),O=t=>g(u({},"__esModule",{value:!0}),t);var $={};v($,{parseCliArgs:()=>C,parseJsonArgs:()=>N});module.exports=O($);var c=d(require("node:fs")),i=d(require("node:path")),f=d(require("node:process")),y=require("../const.js"),k=require("../fs/fs"),a=require("../utils/common.js");function S(t="/",n="default"){const e=t;try{return(0,c.accessSync)(i.join(e,`${n}.php`),c.default.constants.R_OK),"plugin"}catch{console.log(`the current working directory ${e} does not contain a ${n}.php file`)}try{return(0,c.accessSync)(i.join(e,"style.css"),c.default.constants.R_OK),"theme"}catch{console.log(`the current working directory ${e} does not contain a style.css file`)}return"generic"}function C(t){const n=t._[0]?.toString(),e=t._[1]?.toString()||"languages",o=n??".",s=e.startsWith("/")?e.slice(1):e,r=f.cwd(),p=t.slug&&typeof t.slug=="string"?t.slug:i.basename(i.resolve(r,o)),m=i.relative(r,o),b=i.relative(r,s);if(!t?.domain)t.domain=S(i.resolve(m),p);else switch(t.domain){case"plugin":case"theme":case"block":case"theme-block":break;default:console.error(`Invalid domain: ${t.domain}. Valid domains are: plugin, theme, block, theme-block, generic`),t.domain="generic"}const l={};for(const P of t.headers){const[A,D]=P.split(":");l[A.trim()]=D.trim()}const h={slug:p,debug:!!t.debug,domain:t.domain,paths:{cwd:m,out:b},options:{ignoreDomain:!!t?.ignoreDomain,packageName:String(t.packageName),silent:t.silent===!0,json:!!t.json,location:!!t?.location,headers:l,theme:!!t?.theme,output:!!t?.output,fileComment:t.fileComment?String(t.fileComment):void 0,charset:(0,k.getEncodingCharset)(t?.charset),skip:{js:!!t.skipJs,php:!!t.skipPhp,blade:!!t.skipBlade,blockJson:!!t.skipBlockJson,themeJson:!!t.skipThemeJson,audit:!!t.skipAudit}},patterns:{mergePaths:(0,a.stringstring)(t.mergePaths),subtractPaths:(0,a.stringstring)(t.subtractPaths),subtractAndMerge:!!t.subtractAndMerge,include:(0,a.stringstring)(t.include),exclude:[...(0,a.stringstring)(t.exclude),...y.DEFAULT_EXCLUDED_PATH]}};return h.paths.root=t.root?String(t.root):void 0,h}function N(t){const n=t._[0]||"build",e=t._[1]||"languages",o=f.cwd(),s=i.basename(i.resolve(o));let r;return t.scriptName&&(r=t.scriptName.split(",").map(p=>p.trim()),r.length===1&&(r=r[0])),{timeStart:Date.now(),slug:s,source:n,destination:e,scriptName:r,allowedFormats:t.allowedFormats,purge:!!t.purge,stripUnused:!!t.stripUnused,prettyPrint:!!t.prettyPrint,debug:!!t.debug,paths:{cwd:o,out:i.join(o,e)}}}0&&(module.exports={parseCliArgs,parseJsonArgs});
|
package/lib/const.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var r=Object.create;var _=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var l=Object.getPrototypeOf,u=Object.prototype.hasOwnProperty;var f=(t,e)=>{for(var m in e)_(t,m,{get:e[m],enumerable:!0})},
|
|
1
|
+
"use strict";var r=Object.create;var _=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var l=Object.getPrototypeOf,u=Object.prototype.hasOwnProperty;var f=(t,e)=>{for(var m in e)_(t,m,{get:e[m],enumerable:!0})},n=(t,e,m,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of p(e))!u.call(t,s)&&s!==m&&_(t,s,{get:()=>e[s],enumerable:!(i=c(e,s))||i.enumerable});return t};var o=(t,e,m)=>(m=t!=null?r(l(t)):{},n(e||!t||!t.__esModule?_(m,"default",{value:t,enumerable:!0}):m,t)),h=t=>n(_({},"__esModule",{value:!0}),t);var T={};f(T,{DEFAULT_EXCLUDED_PATH:()=>F,IsoCodeRegex:()=>H,allowedFormats:()=>D,allowedFunctions:()=>E,defaultLocale:()=>A,fileRegex:()=>k,i18nFunctions:()=>L,modulePath:()=>P,pkgJsonHeaders:()=>j,pluginHeaders:()=>b,themeHeaders:()=>w});module.exports=h(T);var d=o(require("node:path")),x=o(require("./assets/package-i18n.js")),a=o(require("./assets/wp-plugin-i18n.js")),g=o(require("./assets/wp-theme-i18n.js"));const j=x.default,b=a.default,w=g.default,F=[".git","node_modules","vendor","build","dist","uploads","Gruntfile.js","webpack.config.js","**/*.min.js","tsconfig.js","**.test.**","tests"],H=/-([a-z]{2}_[A-Z]{2})\.po$/,k=/#:\s*(.*?)(?::\d+)?$/,A="en_US",D=["php","js","jsx","ts","tsx","mjs","cjs"],E=new Set(["__","_x","_n","_nx"]),L={__:["msgid","text_domain"],esc_attr__:["msgid","text_domain"],esc_html__:["msgid","text_domain"],esc_xml__:["msgid","text_domain"],_e:["msgid","text_domain"],esc_attr_e:["msgid","text_domain"],esc_html_e:["msgid","text_domain"],esc_xml_e:["msgid","text_domain"],_x:["msgid","msgctxt","text_domain"],_ex:["msgid","msgctxt","text_domain"],esc_attr_x:["msgid","msgctxt","text_domain"],esc_html_x:["msgid","msgctxt","text_domain"],esc_xml_x:["msgid","msgctxt","text_domain"],_n:["msgid","msgid_plural","number","text_domain"],_nx:["msgid","msgid_plural","number","msgctxt","text_domain"],_n_noop:["msgid","msgid_plural","text_domain"],_nx_noop:["msgid","msgid_plural","msgctxt","text_domain"],_:["msgid","text_domain"],_c:["msgid","text_domain"],_nc:["msgid","msgid_plural","number","text_domain"],__ngettext:["msgid","msgid_plural","number","text_domain"],__ngettext_noop:["msgid","msgid_plural","text_domain"]},P=d.default.resolve(__dirname,"..");0&&(module.exports={DEFAULT_EXCLUDED_PATH,IsoCodeRegex,allowedFormats,allowedFunctions,defaultLocale,fileRegex,i18nFunctions,modulePath,pkgJsonHeaders,pluginHeaders,themeHeaders});
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";var p=Object.create;var c=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var R=Object.getOwnPropertyNames;var E=Object.getPrototypeOf,P=Object.prototype.hasOwnProperty;var S=(t,s)=>{for(var e in s)c(t,e,{get:s[e],enumerable:!0})},g=(t,s,e,o)=>{if(s&&typeof s=="object"||typeof s=="function")for(let r of R(s))!P.call(t,r)&&r!==e&&c(t,r,{get:()=>s[r],enumerable:!(o=f(s,r))||o.enumerable});return t};var _=(t,s,e)=>(e=t!=null?p(E(t)):{},g(s||!t||!t.__esModule?c(e,"default",{value:t,enumerable:!0}):e,t)),D=t=>g(c({},"__esModule",{value:!0}),t);var $={};S($,{audit:()=>T,default:()=>L});module.exports=D($);var u=require("node:fs"),d=_(require("node:path"));function T(t,s){const e=new m(t.domain);if(e.auditStrings(s.blocks),console.log(`
|
|
2
|
+
Audit Complete!`),e.getResults().length===0){console.log("No issues found! \u{1F389}");try{(0,u.unlinkSync)(d.default.join(t.paths.cwd,"audit.log"))}catch{}}else{console.log(`Found ${e.getResults().length} issues!`);const o=e.getResults().join(`
|
|
3
|
+
`);console.log(o),(0,u.writeFileSync)(d.default.join(t.paths.cwd,"audit.log"),o)}}class m{SPRINTF_PLACEHOLDER_REGEX=/%(?:\d+\$)?[+-]?(?:[ 0]|\'.)?-?\d*(?:\.\d+)?[bcdeEfFgGhHosuxX]/g;UNORDERED_SPRINTF_PLACEHOLDER_REGEX=/%(?!(\d+)\$)[+-]?(?:[ 0]|\'.)?-?\d*(?:\.\d+)?[bcdeEfFgGhHosuxX]/g;projectType;results=[];constructor(s){this.projectType=s}getFileHeaders(s){return{plugin:["Plugin Name:","Plugin URI:","Description:","Author:","Author URI:","Version:","Text Domain:","Domain Path:","Network:","Requires at least:","Requires PHP:"],theme:["Theme Name:","Theme URI:","Author:","Author URI:","Description:","Version:","License:","License URI:","Text Domain:","Domain Path:","Tags:","Requires at least:","Requires PHP:"]}[s]||[]}auditStrings(s){for(const e of s){const o=e.comments?.reference||[],r=o.length>0?`(${o[0]})`:"";if(!e.msgid)continue;if((!e.comments?.extracted||e.comments.extracted.length===0)&&(e.msgid.match(this.SPRINTF_PLACEHOLDER_REGEX)||[]).length>=1){const n=`The string "${e.msgid}" contains placeholders but has no "translators:" comment to clarify their meaning. ${r}`;this.results.push(n)}if(e.comments?.extracted&&e.comments.extracted.length>0){let n=e.comments.extracted;n=n.filter(i=>{for(const h of this.getFileHeaders(this.projectType))if(i.startsWith(h))return!1;return!0});const a=[];n=n.filter(i=>a.includes(i)?!1:(a.push(i),!0));const l=n.length;if(l>1){const i=`The string "${e.msgid}" has ${l} different translator comments. ${r}
|
|
4
|
+
${n.join(`
|
|
5
|
+
`)}`;this.results.push(i)}}if(e.msgid.trim().replace(/^(['"])(.*)\1$/s,"$2").replace(this.SPRINTF_PLACEHOLDER_REGEX,"")===""){const n=`Found string without translatable content. ${r}`;this.results.push(n)}if((e.msgid.match(this.UNORDERED_SPRINTF_PLACEHOLDER_REGEX)||[]).length>=2){const n=`Multiple placeholders should be ordered. ${r}`;this.results.push(n)}if(e.msgid_plural){const n=e.msgid.match(this.SPRINTF_PLACEHOLDER_REGEX)||[],a=e.msgid_plural.match(this.SPRINTF_PLACEHOLDER_REGEX)||[];if(n.length<a.length){const l=`Missing singular placeholder, needed for some languages. See https://developer.wordpress.org/plugins/internationalization/how-to-internationalize-your-plugin/#plurals ${r}`;this.results.push(l)}else{const l=[...n].sort(),i=[...a].sort();if(JSON.stringify(l)!==JSON.stringify(i)){const h=`Mismatched placeholders for singular and plural string. ${r}`;this.results.push(h)}}}}}getResults(){return this.results}}var L=m;0&&(module.exports={audit});
|
package/lib/extractors/css.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var x=Object.create;var i=Object.defineProperty;var C=Object.getOwnPropertyDescriptor;var T=Object.getOwnPropertyNames;var j=Object.getPrototypeOf,k=Object.prototype.hasOwnProperty;var B=(e,t)=>{for(var o in t)i(e,o,{get:t[o],enumerable:!0})},l=(e,t,o,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of T(t))!k.call(e,n)&&n!==o&&i(e,n,{get:()=>t[n],enumerable:!(r=C(t,n))||r.enumerable});return e};var a=(e,t,o)=>(o=e!=null?x(j(e)):{},l(t||!e||!e.__esModule?i(o,"default",{value:e,enumerable:!0}):o,e)),D=e=>l(i({},"__esModule",{value:!0}),e);var R={};B(R,{extractCssThemeData:()=>F});module.exports=D(R);var m=a(require("node:fs")),d=a(require("node:path")),h=require("../const.js"),p=require("../utils/common.js"),g=require("../utils/extractors.js"),y=require("./text.js");function F(e,t="style.css"){let o={};const r=d.default.join(e.paths.cwd,t);if(m.default.existsSync(r)){const n=m.default.readFileSync(r,"utf8"),u=(0,p.getCommentBlock)(n);if(o=(0,y.extractFileData)(u),"Theme Name"in o){console.log(`\u{1F535} Theme stylesheet detected. ${r}`),e.domain="theme";const c={};for(const s of Object.entries(o))if(s?.[0]&&s[1]){const f=(0,g.getKeyByValue)(h.themeHeaders,s[0].trim());if(f===void 0)continue;c[f]=s[1].trim()}return c}}else console.log(`Theme stylesheet not found in ${r}`);return{}}0&&(module.exports={extractCssThemeData});
|
|
1
|
+
"use strict";var x=Object.create;var i=Object.defineProperty;var C=Object.getOwnPropertyDescriptor;var T=Object.getOwnPropertyNames;var j=Object.getPrototypeOf,k=Object.prototype.hasOwnProperty;var B=(e,t)=>{for(var o in t)i(e,o,{get:t[o],enumerable:!0})},l=(e,t,o,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of T(t))!k.call(e,n)&&n!==o&&i(e,n,{get:()=>t[n],enumerable:!(r=C(t,n))||r.enumerable});return e};var a=(e,t,o)=>(o=e!=null?x(j(e)):{},l(t||!e||!e.__esModule?i(o,"default",{value:e,enumerable:!0}):o,e)),D=e=>l(i({},"__esModule",{value:!0}),e);var R={};B(R,{extractCssThemeData:()=>F});module.exports=D(R);var m=a(require("node:fs")),d=a(require("node:path")),h=require("../const.js"),p=require("../utils/common.js"),g=require("../utils/extractors.js"),y=require("./text.js");function F(e,t="style.css"){let o={};const r=d.default.join(e.paths.cwd,t);if(m.default.existsSync(r)){const n=m.default.readFileSync(r,"utf8"),u=(0,p.getCommentBlock)(n);if(o=(0,y.extractFileData)(u),"Theme Name"in o){console.log(`\u{1F535} Theme stylesheet detected. (${r})`),e.domain="theme";const c={};for(const s of Object.entries(o))if(s?.[0]&&s[1]){const f=(0,g.getKeyByValue)(h.themeHeaders,s[0].trim());if(f===void 0)continue;c[f]=s[1].trim()}return c}}else console.log(`Theme stylesheet not found in ${r}`);return{}}0&&(module.exports={extractCssThemeData});
|
|
@@ -1,6 +1,14 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var y=Object.create;var c=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var H=Object.getOwnPropertyNames;var I=Object.getPrototypeOf,M=Object.prototype.hasOwnProperty;var O=(e,t)=>{for(var o in t)c(e,o,{get:t[o],enumerable:!0})},d=(e,t,o,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of H(t))!M.call(e,n)&&n!==o&&c(e,n,{get:()=>t[n],enumerable:!(r=T(t,n))||r.enumerable});return e};var $=(e,t,o)=>(o=e!=null?y(I(e)):{},d(t||!e||!e.__esModule?c(o,"default",{value:e,enumerable:!0}):o,e)),w=e=>d(c({},"__esModule",{value:!0}),e);var L={};O(L,{extractMainFileData:()=>v,generateHeader:()=>U,getAuthorFromPackage:()=>P,translationsHeaders:()=>E});module.exports=w(L);var f=$(require("node:path")),g=require("gettext-merger"),p=require("../const.js"),k=require("../fs/fs.js"),u=require("../utils/common.js"),m=require("../utils/extractors.js"),b=require("./css.js"),A=require("./php.js");function R(e,t){const r=[{key:"slug",name:"Plugin/Theme slug",placeholder:"PLUGIN NAME"},{key:"author",name:"Author name",placeholder:"AUTHOR"},{key:"version",name:"Version",placeholder:""},{key:"email",name:"Author email",placeholder:"AUTHOR EMAIL"},{key:"xDomain",name:"Text domain",placeholder:"PLUGIN TEXTDOMAIN"}].filter(n=>!e[n.key]||e[n.key]===n.placeholder||n.key==="version"&&e[n.key]==="0.0.1");if(r.length>0){console.error(`
|
|
2
2
|
! Missing required information for POT file header:
|
|
3
|
-
`);for(const
|
|
3
|
+
`);for(const n of r)console.error(` - ${n.name} is missing or has a default value (eg. version: 0.0.1")`);return console.error(`
|
|
4
4
|
Please provide this information adding the missing fields inside the headers object of the plugin/theme declaration or to the package.json file.`,`
|
|
5
|
-
For more information check the documentation at https://github.com/wp-blocks/makePot`),console.error(`
|
|
6
|
-
|
|
5
|
+
For more information check the documentation at https://github.com/wp-blocks/makePot`),r.some(n=>n.key==="email")&&console.error(`
|
|
6
|
+
|
|
7
|
+
Wordpress didn't require an email field in the headers object but it's required in order to generate a valid pot file.`,`
|
|
8
|
+
Please add the email field to the package.json file (author field eg. author: "AUTHOR <EMAIL>")`,`
|
|
9
|
+
or inject those information using the --headers flag to the "makePot" command (eg. --headers=email:erik@ck.it).`,`
|
|
10
|
+
For more information check the documentation at https://github.com/wp-blocks/makePot`),r&&t&&console.error(`
|
|
11
|
+
Debug information:`,`
|
|
12
|
+
Missing fields:`,r,`
|
|
13
|
+
Header data:`,e),console.error(`
|
|
14
|
+
`),!1}return!0}function h(e){const t={name:"AUTHOR",email:"AUTHOR EMAIL"};if(!e)return t;if(typeof e=="string"){const o=e.match(/<([^>]+)>/),r=o?o[1].trim():void 0,n=e.match(/\(([^)]+)\)/),s=n?n[1].trim():void 0;let i=e.trim();return o&&(i=i.replace(o[0],"").trim()),n&&(i=i.replace(n[0],"").trim()),{name:i,email:r,website:s}}if(typeof e=="object")return{name:e.name,email:e.email,website:e.website}}function P(e){const t=["author","authors","contributors","maintainers"];for(const o of t)if(e[o]){let r;if(typeof e[o]=="string")r=h(e[o]);else if(typeof e[o]=="object"){for(const n of e[o])if(n&&(r=h(n),r))break}if(r?.name!=="AUTHOR"||r?.email!=="AUTHOR EMAIL")return r}return{name:"AUTHOR",email:"AUTHOR EMAIL"}}function x(e){const t=(0,u.getPkgJsonData)(e.paths?.cwd,"name","version","author","authors","contributors","maintainers"),o=P(t),r=f.default.basename(e.paths?.cwd||process.cwd())?.toLowerCase().replace(" ","-"),n=e?.headers?.author||o?.name,s=e?.headers?.email||o?.email,i=`${n} <${s}>`,l=e.slug||r||e.headers?.name?.toString().replace(/ /g,"-")||(e.domain==="theme"?"THEME NAME":"PLUGIN NAME"),a=`https://wordpress.org/support/${e.domain==="theme"?"themes":"plugins"}/${l}`;return{...e.headers,name:e.headers?.name||l,author:n,authorString:i,slug:l,email:s,bugs:a,license:e.headers?.license||"gpl-2.0 or later",version:e.headers?.version||t.version||"0.0.1",language:"en",xDomain:e.headers?.textDomain||l}}async function U(e){const t=x(e),{name:o,version:r}=(0,u.getPkgJsonData)(p.modulePath,"name","version");return R(t,e.debug)?{"Project-Id-Version":`${t.name} ${t.version}`,"Report-Msgid-Bugs-To":t.bugs,"MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","content-type":`text/plain; charset=${(0,k.getEncodingCharset)(e.options?.charset)}`,"plural-forms":"nplurals=2; plural=(n!=1);","POT-Creation-Date":`${new Date().toISOString()}`,"PO-Revision-Date":`${new Date().getFullYear()}-MO-DA HO:MI+ZONE`,"Last-Translator":t.authorString,"Language-Team":t.authorString,"X-Generator":`${o} ${r}`,Language:`${t.language}`,"X-Domain":t.xDomain}:(process.exit(1),null)}function v(e){let t={};return["plugin","block","generic"].includes(e.domain)?t=(0,A.extractPhpPluginData)(e):["theme","theme-block"].includes(e.domain)?t=(0,b.extractCssThemeData)(e):console.log("No main file detected."),t}function E(e){const{domain:t,headers:o}=e,{name:r,description:n,author:s,authorUri:i,url:l}=o,a=t==="plugin"?`${e.slug}.php`:"style.css";return new g.SetOfBlocks([(0,m.buildBlock)(`Name of the ${t}`,r,[a]),(0,m.buildBlock)(`Url of the ${t}`,l,[a]),(0,m.buildBlock)(`Description of the ${t}`,n,[a]),(0,m.buildBlock)(`Author of the ${t}`,s,[a]),(0,m.buildBlock)(`Author URI of the ${t}`,i,[a])])}0&&(module.exports={extractMainFileData,generateHeader,getAuthorFromPackage,translationsHeaders});
|
package/lib/fs/fs.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use strict";var p=Object.create;var c=Object.defineProperty;var l=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames;var F=Object.getPrototypeOf,x=Object.prototype.hasOwnProperty;var w=(t,e)=>{for(var n in e)c(t,n,{get:e[n],enumerable:!0})},u=(t,e,n,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of m(e))!x.call(t,r)&&r!==n&&c(t,r,{get:()=>e[r],enumerable:!(o=l(e,r))||o.enumerable});return t};var a=(t,e,n)=>(n=t!=null?p(F(t)):{},u(e||!t||!t.__esModule?c(n,"default",{value:t,enumerable:!0}):n,t)),y=t=>u(c({},"__esModule",{value:!0}),t);var S={};w(S,{getCharset:()=>d,getEncodingCharset:()=>h,getOutputPath:()=>$,readFileAsync:()=>O,writeFile:()=>C});module.exports=y(S);var s=a(require("node:fs")),f=require("node:fs/promises"),i=a(require("node:path"));function E(t){if(t===void 0)return".";try{s.default.accessSync(i.default.resolve(t),s.default.constants.R_OK|s.default.constants.W_OK)}catch(e){if(e.code==="ENOENT")return s.default.mkdirSync(t,{recursive:!0}),console.log(`Folder created: ${t}`),t}return t}function d(t){if(!t)return"latin1";switch(t.toLowerCase()){case"utf-8":case"utf8":return"utf-8";default:return"latin1"}}function h(t){if(!t)return"iso-8859-1";switch(t.toLowerCase()){case"utf-8":case"utf8":return"utf-8";default:return"iso-8859-1"}}function $(t){return i.default.join(process.cwd(),t??"languages")}function j(t){const{out:e,headers:n,options:o}=t.paths;let r=e??n?.domainPath??"languages";r=r.replace(/^\/+|\/+$/g,"");const g=o?.json?"json":"pot";return i.default.join(process.cwd(),r,`${t.slug}.${g}`)}function C(t,e){const n=j(e);if(E(i.default.dirname(n))){const o=d(e.options?.charset);console.log(`
|
|
2
|
-
File created at ${n}`);const r=Buffer.from(t);(0,s.writeFileSync)(n,r.toString(o),{encoding:o})}else console.log(`Folder ${n} does not exist and cannot be created`)}async function O(t){return(0,f.readFile)(t,"utf-8")}0&&(module.exports={getCharset,getEncodingCharset,getOutputPath,readFileAsync,writeFile});
|
|
2
|
+
Pot File created at ${n}`);const r=Buffer.from(t);(0,s.writeFileSync)(n,r.toString(o),{encoding:o})}else console.log(`Folder ${n} does not exist and cannot be created`)}async function O(t){return(0,f.readFile)(t,"utf-8")}0&&(module.exports={getCharset,getEncodingCharset,getOutputPath,readFileAsync,writeFile});
|
package/lib/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var F=Object.create;var a=Object.defineProperty;var J=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var l=Object.getPrototypeOf,u=Object.prototype.hasOwnProperty;var A=(o,r)=>{for(var e in r)a(o,e,{get:r[e],enumerable:!0})},k=(o,r,e,x)=>{if(r&&typeof r=="object"||typeof r=="function")for(let t of c(r))!u.call(o,t)&&t!==e&&a(o,t,{get:()=>r[t],enumerable:!(x=J(r,t))||x.enumerable});return o};var p=(o,r,e)=>(e=o!=null?F(l(o)):{},k(r||!o||!o.__esModule?a(e,"default",{value:o,enumerable:!0}):e,o)),C=o=>k(a({},"__esModule",{value:!0}),o);var M={};A(M,{MakeJsonCommand:()=>d.MakeJsonCommand,StringAuditor:()=>f.default,doTree:()=>g.doTree,extractMainFileData:()=>m.extractMainFileData,generateHeader:()=>m.generateHeader,getAuthorFromPackage:()=>m.getAuthorFromPackage,makeJson:()=>i.default,makePot:()=>n.default,makePotCommand:()=>s.makePot,parseJsonFile:()=>P.parseJsonFile});module.exports=C(M);var f=p(require("./extractors/auditStrings.js")),i=p(require("./jsonCommand.js")),n=p(require("./potCommand.js")),d=require("./parser/makeJson"),s=require("./parser/makePot.js"),g=require("./parser/tree.js"),P=require("./extractors/json.js"),m=require("./extractors/headers.js");0&&(module.exports={MakeJsonCommand,StringAuditor,doTree,extractMainFileData,generateHeader,getAuthorFromPackage,makeJson,makePot,makePotCommand,parseJsonFile});
|
package/lib/jsonCommand.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var p=Object.create;var m=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var k=Object.getOwnPropertyNames;var l=Object.getPrototypeOf,d=Object.prototype.hasOwnProperty;var J=(e,o)=>{for(var n in o)m(e,n,{get:o[n],enumerable:!0})},a=(e,o,n,t)=>{if(o&&typeof o=="object"||typeof o=="function")for(let r of k(o))!d.call(e,r)&&r!==n&&m(e,r,{get:()=>o[r],enumerable:!(t=f(o,r))||t.enumerable});return e};var M=(e,o,n)=>(n=e!=null?p(l(e)):{},a(o||!e||!e.__esModule?m(n,"default",{value:e,enumerable:!0}):n,e)),u=e=>a(m({},"__esModule",{value:!0}),e);var g={};J(g,{default:()=>c});module.exports=u(g);var i=M(require("./parser/makeJson.js")),s=require("./utils/common.js");function c(e){const o=new i.default(e);if(Object.keys(e).length>0){(0,s.printModuleInfo)();const n=new Date;o.exec().then(t=>{e.debug&&console.log(t),(0,s.printTimeElapsed)("Make-Json",n)}).catch(t=>{console.error(`\u{1FAE4} make-json - Error: ${t}`)})}}
|
package/lib/parser/exec.js
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
"use strict";var w=Object.create;var s=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
ignoring patterns: ${n.exclude.join()}
|
|
5
|
-
`}async function D(t){t.options?.silent||(console.log("\u{1F4DD} Starting makePot for",t?.slug),(0,a.printStats)()),t.options?.skip.audit&&(console.log(`
|
|
6
|
-
Audit strings...`),console.log("TODO"),console.log("\u2705 Done"));const n=await(0,r.generateHeader)(t);let o=(0,r.translationsHeaders)(t);t.options?.silent||B(l.default.resolve(t.paths.cwd),t.patterns);const i=(0,P.initProgress)(t,0);i.start(3,1,{filename:`Resolving files in ${l.default.resolve(t.paths.cwd)}`});const e=(0,h.getPatterns)(t),m=await(0,d.processFiles)(e,t);if(i.update(2,{filename:`Found ${m.length} files`}),o=await(0,T.taskRunner)(m,o,t,i),t.options?.json){const $={[t.slug]:{"":n,...o.toJson()}};return new u.default($).toString()}const y={charset:(0,p.getEncodingCharset)(t.options?.charset),headers:n,translations:o.toJson()},S=f.po.compile(y).toString((0,p.getCharset)(t.options?.charset));return`${t.options?.fileComment||(0,a.getCopyright)(t.slug,t.headers?.license??"GPL v2 or later")}
|
|
7
|
-
${S}`}0&&(module.exports={exec});
|
|
1
|
+
"use strict";var w=Object.create;var s=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var S=Object.getOwnPropertyNames;var v=Object.getPrototypeOf,$=Object.prototype.hasOwnProperty;var k=(t,o)=>{for(var e in o)s(t,e,{get:o[e],enumerable:!0})},c=(t,o,e,i)=>{if(o&&typeof o=="object"||typeof o=="function")for(let n of S(o))!$.call(t,n)&&n!==e&&s(t,n,{get:()=>o[n],enumerable:!(i=x(o,n))||i.enumerable});return t};var A=(t,o,e)=>(e=t!=null?w(v(t)):{},c(o||!t||!t.__esModule?s(e,"default",{value:t,enumerable:!0}):e,t)),B=t=>c(s({},"__esModule",{value:!0}),t);var H={};k(H,{exec:()=>G});module.exports=B(H);var m=A(require("node:path")),f=require("gettext-parser"),h=require("../extractors/auditStrings.js"),p=require("../extractors/headers.js"),a=require("../fs/fs.js"),r=require("../utils/common.js"),u=require("../utils/output"),d=require("./patterns.js"),g=require("./process.js"),y=require("./progress.js"),T=require("./taskRunner.js");async function G(t){t.options?.silent||(console.log("\u{1F4DD} Starting makePot for",t?.slug),(0,r.printStats)());const o=await(0,p.generateHeader)(t);let e=(0,p.translationsHeaders)(t);t.options?.silent||(0,r.outputPathRecap)(m.default.resolve(t.paths.cwd),t.patterns);const i=(0,y.initProgress)(t,0);i.start(3,1,{filename:`Resolving files in ${m.default.resolve(t.paths.cwd)}`});const n=(0,d.getPatterns)(t),l=await(0,g.processFiles)(n,t);if(i.update(2,{filename:`Found ${l.length} files... `}),e=await(0,T.taskRunner)(l,e,t,i),t.options?.skip.audit||(console.log(`
|
|
2
|
+
Audit strings...`),(0,h.audit)(t,e)),t.options?.json)return(0,u.outputJson)(t,o,e);const C={charset:(0,a.getEncodingCharset)(t.options?.charset),headers:o,translations:e.toJson()},P=f.po.compile(C).toString((0,a.getCharset)(t.options?.charset));return`${t.options?.fileComment||(0,r.getCopyright)(t.headers?.name||t.slug,t.headers?.license??"GPL v2 or later")}
|
|
3
|
+
${P}`}0&&(module.exports={exec});
|
package/lib/parser/makeJson.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var N=Object.create;var
|
|
1
|
+
"use strict";var N=Object.create;var m=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var w=Object.getOwnPropertyNames;var $=Object.getPrototypeOf,M=Object.prototype.hasOwnProperty;var D=(o,t)=>{for(var e in t)m(o,e,{get:t[e],enumerable:!0})},v=(o,t,e,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of w(t))!M.call(o,n)&&n!==e&&m(o,n,{get:()=>t[n],enumerable:!(s=b(t,n))||s.enumerable});return o};var g=(o,t,e)=>(e=o!=null?N($(o)):{},v(t||!o||!o.__esModule?m(e,"default",{value:o,enumerable:!0}):e,o)),C=o=>v(m({},"__esModule",{value:!0}),o);var G={};D(G,{MakeJsonCommand:()=>F,default:()=>I});module.exports=C(G);var S=g(require("node:crypto")),c=g(require("node:fs")),a=g(require("node:path")),x=require("@babel/core"),k=require("gettext-parser"),h=require("glob"),p=require("../const.js"),J=require("../utils/common.js"),T=require("./tree");class F{source;destination;allowedFormats;purge;prettyPrint;debug;scriptName;paths;sourceDir;stripUnused;constructor(t){if(this.sourceDir=a.default.relative(t.paths.cwd,t.source??""),!c.existsSync(this.sourceDir))throw console.error("Source directory not found",t),new Error(`Source directory ${this.sourceDir} not found`);this.stripUnused=t.stripUnused,this.scriptName=t.scriptName,this.source=t.source,this.destination=t.destination,this.allowedFormats=t.allowedFormats??[".ts",".tsx",".js",".jsx",".mjs",".cjs"],this.purge=t.purge,this.prettyPrint=t.prettyPrint,this.debug=t.debug,this.paths=t.paths}async exec(){const t=await(0,h.glob)("**/*.po",{cwd:this.destination,nodir:!0});console.log("Found po files",t,"in",this.destination,"folder");const e={};for(const s of t)if(this.scriptName||(this.scriptName=await(0,h.glob)("**/*.js",{cwd:this.source,nodir:!0}),console.log(`Found script: ${this.scriptName} in ${this.source} folder`)),typeof this.scriptName=="string"){const n=this.addPot(s,this.scriptName);n.data?e[n.filename]=n.data:console.log(`\u274C Translation strings not found in Script ${this.scriptName} in ${s} po file`)}else if(Array.isArray(this.scriptName))for(const n of this.scriptName){const i=this.addPot(s,n);i.data?e[i.filename]=i.data:console.log(`\u274C Translation strings not found in Script ${n} in ${s} po file`)}for(const[s,n]of Object.entries(e)){let i;if(this.purge)c.existsSync(a.default.join(this.destination,s))&&(console.log(`Removing ${a.default.join(this.destination,s)} as the purge option is enabled`),c.unlinkSync(a.default.join(this.destination,s))),i=JSON.stringify(n,null,this?.prettyPrint?2:0);else{const l=c.readFileSync(a.default.join(this.source,s),"utf8");i=JSON.stringify({...n,...JSON.parse(l)},null,this?.prettyPrint?2:0)}const r=a.default.join(this.destination,s);c.writeFileSync(r,i),console.log(`\u2705 JSON file written to ${r} with ${s}`)}return e}processFile(t,e,s="utf8"){const n=a.default.join(this.destination,t),i=c.readFileSync(n,s),r=this.parsePoFile(i);if(this.stripUnused){const l=this.parseScript(e),d=this.compareStrings(l.blocks,r);if(!d)return null;r.translations=d.translations}return this.convertToJed(r.headers,r.translations,e,this.extractIsoCode(n))}parsePoFile(t){return k.po.parse(t)}convertToJed(t,e,s,n){const i=(0,J.getPkgJsonData)(p.modulePath,"name","version"),r="messages",l=`${i.name}/${i.version}`,d={[r]:{"":{domain:r,lang:n||t.Language||"en",plural_forms:t["Plural-Forms"]||"nplurals=2; plural=(n != 1);"}}};for(const f of Object.keys(e)){const y=e[f];for(const u of Object.keys(y)){const P=y[u];if(u==="")continue;const j=f&&f!==""?`${f}${u}`:u;d[r][j]=P.msgstr}}return{"translation-revision-date":new Date().toISOString(),generator:l,source:a.default.join(this.sourceDir,s).replace(/\\/g,"/"),domain:r,locale_data:d}}extractIsoCode(t){const e=t.match(p.IsoCodeRegex);return e?e[1]:void 0}md5(t){return S.default.createHash("md5").update(t).digest("hex")}generateFilename(t,e){const s=this.md5(t);return e.replace(".po",`-${s}.json`)}addPot(t,e){return{filename:this.generateFilename(a.default.join(this.source,e).replace(/\\/g,"/"),t),data:this.processFile(t,e)}}compareStrings(t,e){const s={charset:e.charset,headers:{...e.headers},translations:{"":{}}};e.translations[""][""]&&(s.translations[""][""]={...e.translations[""][""]});const n=new Set(t.map(i=>i.msgid));for(const i in e.translations)if(i==="")for(const r in e.translations[i])r!==""&&n.has(r)&&(s.translations[i]||(s.translations[i]={}),s.translations[i][r]={...e.translations[i][r]});return Object.keys(s.translations[""]).length<=1?null:s}parseScript(t){const e=c.readFileSync(a.default.join(this.source,t),"utf8"),s=(0,x.transformSync)(e,{configFile:!1,presets:["@babel/preset-env"],compact:!1,comments:!0,sourceMaps:!1,plugins:[({types:n})=>({visitor:{CallExpression(i){const r=i.node.callee;if(n.isSequenceExpression(r)&&n.isMemberExpression(r.expressions[1])){const l=r.expressions[1].property;n.isIdentifier(l)&&p.allowedFunctions.has(l.name)&&(i.node.callee=n.identifier(l.name))}}}})]}).code;return(0,T.doTree)(s,t)}}var I=F;0&&(module.exports={MakeJsonCommand});
|
package/lib/parser/makePot.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var i=Object.defineProperty;var s=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var h=Object.prototype.hasOwnProperty;var d=(t,e)=>{for(var o in e)i(t,o,{get:e[o],enumerable:!0})},u=(t,e,o,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of f(e))!h.call(t,a)&&a!==o&&i(t,a,{get:()=>e[a],enumerable:!(r=s(e,a))||r.enumerable});return t};var x=t=>u(i({},"__esModule",{value:!0}),t);var y={};d(y,{makePot:()=>k});module.exports=x(y);var m=require("../extractors/headers.js"),c=require("../extractors/packageJson.js"),n=require("../fs/fs.js"),p=require("./exec.js");async function k(t){const e=(0,c.extractPackageJson)(t),o=(0,m.extractMainFileData)(t);return t.headers={...t?.options?.headers,...e,...o},await(0,p.exec)(t).then(r=>((0,n.writeFile)(r,t),r)).catch(r=>(console.error(r),""))}0&&(module.exports={makePot});
|
package/lib/parser/process.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var P=Object.create;var m=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var j=Object.getOwnPropertyNames;var O=Object.getPrototypeOf,S=Object.prototype.hasOwnProperty;var w=(e,t)=>{for(var o in t)m(e,o,{get:t[o],enumerable:!0})},d=(e,t,o,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of j(t))!S.call(e,s)&&s!==o&&m(e,s,{get:()=>t[s],enumerable:!(i=b(t,s))||i.enumerable});return e};var x=(e,t,o)=>(o=e!=null?P(O(e)):{},d(t||!e||!e.__esModule?m(o,"default",{value:e,enumerable:!0}):o,e)),g=e=>d(m({},"__esModule",{value:!0}),e);var A={};w(A,{processFiles:()=>v});module.exports=g(A);var r=x(require("node:path")),h=require("../const.js"),u=require("../extractors/json.js"),c=require("../fs/fs.js"),k=require("../fs/glob.js"),y=require("./tree.js");async function v(e,t,o){const i=[];let s=0;const f=(0,k.getFiles)(t,e);o&&(o.setTotal(Object.values(f).length),o.update(0,{filename:`Found ${Object.values(f).length} files`}));for await(const l of f){s++;const n=r.default.basename(l),F=r.default.extname(l).replace(/^./,""),p=r.default.resolve(t.paths.cwd,l);n==="theme.json"||n==="block.json"?i.push((0,c.readFileAsync)(p).then(a=>(0,u.parseJsonCallback)(a,t.paths.cwd,n))):h.allowedFormats.includes(F)&&i.push((0,c.readFileAsync)(p).then(a=>(0,y.doTree)(a,l))),o&&(o.update(s,{filename:n}),o.render())}return i}0&&(module.exports={processFiles});
|
package/lib/potCommand.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var n=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var s=Object.getOwnPropertyNames;var c=Object.prototype.hasOwnProperty;var
|
|
1
|
+
"use strict";var n=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var s=Object.getOwnPropertyNames;var c=Object.prototype.hasOwnProperty;var l=(e,t)=>{for(var o in t)n(e,o,{get:t[o],enumerable:!0})},d=(e,t,o,p)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of s(t))!c.call(e,r)&&r!==o&&n(e,r,{get:()=>t[r],enumerable:!(p=f(t,r))||p.enumerable});return e};var k=e=>d(n({},"__esModule",{value:!0}),e);var h={};l(h,{default:()=>a});module.exports=k(h);var i=require("./parser/makePot.js"),m=require("./utils/common.js");function a(e){if(Object.keys(e).length>0){(0,m.printModuleInfo)();const t=new Date;(0,i.makePot)(e).then(()=>{(0,m.printTimeElapsed)("Make-Pot",t)}).catch(o=>{console.error(`\u{1FAE4} Make-pot - ${o}`)})}}
|
package/lib/utils/common.js
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
"use strict";var f=Object.create;var s=Object.defineProperty;var d=Object.getOwnPropertyDescriptor;var x=Object.getOwnPropertyNames;var h=Object.getPrototypeOf,k=Object.prototype.hasOwnProperty;var y=(e
|
|
2
|
-
# This file is distributed under the ${
|
|
3
|
-
\u{1F680} ${
|
|
4
|
-
Cpu User:`,(process.cpuUsage().user/1e6).toFixed(2),"ms Cpu System:",(process.cpuUsage().system/1e6).toFixed(2),"ms of",(0,i.cpus)().length,"cores")}
|
|
1
|
+
"use strict";var f=Object.create;var s=Object.defineProperty;var d=Object.getOwnPropertyDescriptor;var x=Object.getOwnPropertyNames;var h=Object.getPrototypeOf,k=Object.prototype.hasOwnProperty;var y=(t,e)=>{for(var n in e)s(t,n,{get:e[n],enumerable:!0})},a=(t,e,n,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of x(e))!k.call(t,r)&&r!==n&&s(t,r,{get:()=>e[r],enumerable:!(o=d(e,r))||o.enumerable});return t};var p=(t,e,n)=>(n=t!=null?f(h(t)):{},a(e||!t||!t.__esModule?s(n,"default",{value:t,enumerable:!0}):n,t)),$=t=>a(s({},"__esModule",{value:!0}),t);var b={};y(b,{detectPatternType:()=>M,getCommentBlock:()=>P,getCopyright:()=>T,getPkgJsonData:()=>m,outputPathRecap:()=>U,printModuleInfo:()=>w,printStats:()=>j,printTimeElapsed:()=>D,removeCommentMarkup:()=>S,reverseSlashes:()=>v,stringstring:()=>F,stripTranslationMarkup:()=>C});module.exports=$(b);var g=p(require("node:fs")),i=require("node:os"),u=p(require("node:path")),l=require("../const.js");function P(t){const e=t.match(/\/\*\*?[\s\S]*?\*\//);return e!==null?e[0]:t}function S(t){return t.match(/[a-zA-Z].*/gm)}function C(t){const e=/\/\*\*?\s*(?:translators:)\s*([\s\S]*?)\s*\*\/|\/\/\s*(?:translators:)\s*(.*)$/i,n=t.match(e);return n?n[1]:t}function F(t){return typeof t=="string"?t.includes(",")?t.split(","):[t]:[]}function M(t){const e=t.includes("."),n=t.includes(u.default.sep);return t.includes("*")?"glob":!e&&!n?"directory":e&&!n?"file":"glob"}function T(t,e="GPL v2 or later"){return`# Copyright (C) ${new Date().getFullYear()} ${t}
|
|
2
|
+
# This file is distributed under the ${e} license.`}function v(t){return t.replace(/\\/g,"/")}function m(t,...e){const n={},o=u.default.join(t||process.cwd(),"package.json"),r=g.default.existsSync(o)?require(o):{};for(const c of e)r[c]&&(n[c]=r[c]);return n}function w(){const{version:t,name:e}=m(l.modulePath,"name","version");console.log(`${e} version: ${t}`)}function D(t,e,n=new Date){console.log(`
|
|
3
|
+
\u{1F680} ${t}: Task completed! ${t.split("-")[1]} file created in ${n.getTime()-e.getTime()}ms`)}function j(){console.log("Memory usage:",(process.memoryUsage().heapUsed/1024/1024).toFixed(2),"MB (Free:",((0,i.totalmem)()/1024/1024/1024).toFixed(2),`GB)
|
|
4
|
+
Cpu User:`,(process.cpuUsage().user/1e6).toFixed(2),"ms Cpu System:",(process.cpuUsage().system/1e6).toFixed(2),"ms of",(0,i.cpus)().length,"cores")}function U(t,e){return`
|
|
5
|
+
Script Path: ${t}
|
|
6
|
+
for ${e.include.join()}
|
|
7
|
+
ignoring patterns: ${e.exclude.join()}
|
|
8
|
+
`}0&&(module.exports={detectPatternType,getCommentBlock,getCopyright,getPkgJsonData,outputPathRecap,printModuleInfo,printStats,printTimeElapsed,removeCommentMarkup,reverseSlashes,stringstring,stripTranslationMarkup});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var p=Object.create;var i=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var f=Object.getPrototypeOf,u=Object.prototype.hasOwnProperty;var l=(t,n)=>{for(var r in n)i(t,r,{get:n[r],enumerable:!0})},g=(t,n,r,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let s of c(n))!u.call(t,s)&&s!==r&&i(t,s,{get:()=>n[s],enumerable:!(o=m(n,s))||o.enumerable});return t};var a=(t,n,r)=>(r=t!=null?p(f(t)):{},g(n||!t||!t.__esModule?i(r,"default",{value:t,enumerable:!0}):r,t)),y=t=>g(i({},"__esModule",{value:!0}),t);var d={};l(d,{outputJson:()=>S});module.exports=y(d);var e=a(require("tannin"));function S(t,n,r){const o={[t.slug]:{"":n??{},...r.toJson()}};return new e.default(o).toString()}0&&(module.exports={outputJson});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wp-blocks/make-pot",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0",
|
|
4
4
|
"license": "GPL-3.0-or-later",
|
|
5
5
|
"homepage": "https://wp-blocks.github.io/make-pot/",
|
|
6
6
|
"description": "A Node.js script for generating a POT file from source code",
|
|
@@ -53,12 +53,14 @@
|
|
|
53
53
|
"rm": "rmdir /s /q lib",
|
|
54
54
|
"test:build": "npx esbuild ./src/**/* --format=cjs --sourcemap --outdir=lib --platform=node",
|
|
55
55
|
"test": "npm run test:build && node --test",
|
|
56
|
-
"build:build-ci": "npx esbuild ./src/index.ts --format=cjs --outdir=lib --bundle --external:tree-sitter --external:tree-sitter-typescript --external:tree-sitter-php --external:tree-sitter-javascript --platform=node",
|
|
56
|
+
"build:build-ci": "npx esbuild ./src/index.ts --format=cjs --outdir=lib --bundle --external:tree-sitter --external:tree-sitter-typescript --external:tree-sitter-php --external:tree-sitter-javascript --external:@babel/preset-typescript --platform=node",
|
|
57
57
|
"test:ci": "npm run build:build-ci && npm run test",
|
|
58
58
|
"test:watch": "node --test --watch",
|
|
59
59
|
"test:coverage": "node --test --experimental-test-coverage"
|
|
60
60
|
},
|
|
61
61
|
"dependencies": {
|
|
62
|
+
"@babel/core": "^7.27.1",
|
|
63
|
+
"@babel/preset-env": "^7.27.2",
|
|
62
64
|
"cli-progress": "^3.12.0",
|
|
63
65
|
"gettext-merger": "^1.2.1",
|
|
64
66
|
"gettext-parser": "^4.0.4",
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
const { describe, it, beforeEach, before } = require("node:test");
|
|
2
|
+
const assert = require("node:assert");
|
|
3
|
+
const { StringAuditor } = require("../lib");
|
|
4
|
+
|
|
5
|
+
describe("Audit", () => {
|
|
6
|
+
it("should not find any errors", () => {
|
|
7
|
+
/** @type {Block[]} */
|
|
8
|
+
const translations = [
|
|
9
|
+
{
|
|
10
|
+
comments: {
|
|
11
|
+
reference: ["tests/fixtures/block/javascript.js:7"],
|
|
12
|
+
translator: undefined,
|
|
13
|
+
},
|
|
14
|
+
msgctxt: undefined,
|
|
15
|
+
msgid: "Simple Block",
|
|
16
|
+
msgid_plural: undefined,
|
|
17
|
+
msgstr: [""],
|
|
18
|
+
},
|
|
19
|
+
];
|
|
20
|
+
|
|
21
|
+
const SA = new StringAuditor("plugin");
|
|
22
|
+
SA.auditStrings(translations);
|
|
23
|
+
|
|
24
|
+
assert.deepStrictEqual(SA.results, []);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it("should find an error", () => {
|
|
28
|
+
/** @type {Block[]} */
|
|
29
|
+
const translations = [
|
|
30
|
+
{
|
|
31
|
+
comments: {
|
|
32
|
+
reference: ["tests/fixtures/block/javascript.js:7"],
|
|
33
|
+
translator: undefined,
|
|
34
|
+
},
|
|
35
|
+
msgctxt: undefined,
|
|
36
|
+
msgid: "translation with multiple %s %S %s %s %d and no comments",
|
|
37
|
+
msgid_plural: undefined,
|
|
38
|
+
msgstr: [""],
|
|
39
|
+
},
|
|
40
|
+
];
|
|
41
|
+
|
|
42
|
+
const SA = new StringAuditor("plugin");
|
|
43
|
+
SA.auditStrings(translations);
|
|
44
|
+
|
|
45
|
+
assert.deepStrictEqual(SA.results, [
|
|
46
|
+
'The string "translation with multiple %s %S %s %s %d and no comments" contains placeholders but has no "translators:" comment to clarify their meaning. (tests/fixtures/block/javascript.js:7)',
|
|
47
|
+
"Multiple placeholders should be ordered. (tests/fixtures/block/javascript.js:7)",
|
|
48
|
+
]);
|
|
49
|
+
});
|
|
50
|
+
});
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
const fs = require("node:fs");
|
|
2
|
+
const { describe, it } = require("node:test");
|
|
3
|
+
const assert = require("node:assert");
|
|
4
|
+
const { join, resolve } = require("node:path");
|
|
5
|
+
|
|
6
|
+
describe("MakeJson", () => {
|
|
7
|
+
describe("should return the used translations", () => {
|
|
8
|
+
it("compare js translations with pot file", async () => {
|
|
9
|
+
const { MakeJsonCommand } = await require("../lib");
|
|
10
|
+
// the current working directory
|
|
11
|
+
const path = "tests/fixtures/makejson";
|
|
12
|
+
const cwd = join(process.cwd(), path);
|
|
13
|
+
const makeJson = new MakeJsonCommand({
|
|
14
|
+
source: "",
|
|
15
|
+
destination: "",
|
|
16
|
+
paths: {
|
|
17
|
+
cwd: cwd,
|
|
18
|
+
source: cwd,
|
|
19
|
+
destination: cwd,
|
|
20
|
+
},
|
|
21
|
+
stripUnused: true,
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
const result = await makeJson.processFile(
|
|
25
|
+
"tests/fixtures/makejson/live-search-block-it_IT.po",
|
|
26
|
+
"tests/fixtures/makejson/script.js",
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
result["translation-revision-date"] = undefined;
|
|
30
|
+
|
|
31
|
+
assert.deepStrictEqual(result.locale_data.messages, {
|
|
32
|
+
"": {
|
|
33
|
+
domain: "messages",
|
|
34
|
+
lang: "it_IT",
|
|
35
|
+
plural_forms: "nplurals=2; plural=(n != 1);",
|
|
36
|
+
},
|
|
37
|
+
Search: ["Cerca"],
|
|
38
|
+
"Type to search…": ["Digita per cercare…"],
|
|
39
|
+
"Please add %s more characters": [
|
|
40
|
+
"Aggiungere %s altri caratteri",
|
|
41
|
+
"Aggiungere %s caratteri in più",
|
|
42
|
+
],
|
|
43
|
+
"Sorry, no results found": ["Spiacente, nessun risultato trovato"],
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it("compare js translations with pot file", async () => {
|
|
48
|
+
const { MakeJsonCommand } = await require("../lib");
|
|
49
|
+
// the current working directory
|
|
50
|
+
const path = "tests/fixtures/makejson-2";
|
|
51
|
+
const cwd = join(process.cwd(), path);
|
|
52
|
+
const makeJson = new MakeJsonCommand({
|
|
53
|
+
source: "",
|
|
54
|
+
destination: "",
|
|
55
|
+
paths: {
|
|
56
|
+
cwd: cwd,
|
|
57
|
+
source: cwd,
|
|
58
|
+
destination: cwd,
|
|
59
|
+
},
|
|
60
|
+
stripUnused: true,
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
const result = await makeJson.processFile(
|
|
64
|
+
"tests/fixtures/makejson-2/plugin2-it_IT.po",
|
|
65
|
+
"tests/fixtures/makejson-2/unminified.js",
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
result["translation-revision-date"] = undefined;
|
|
69
|
+
|
|
70
|
+
assert.deepStrictEqual(result.locale_data.messages, {
|
|
71
|
+
"": {
|
|
72
|
+
domain: "messages",
|
|
73
|
+
lang: "it_IT",
|
|
74
|
+
plural_forms: "nplurals=2; plural=(n != 1);",
|
|
75
|
+
},
|
|
76
|
+
"Grid view": ["Vista a griglia"],
|
|
77
|
+
"List view": ["Visualizzazione elenco"],
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
});
|
|
@@ -34,24 +34,24 @@ describe("Header generation", () => {
|
|
|
34
34
|
|
|
35
35
|
it("from package.json data", async () => {
|
|
36
36
|
const expected = {
|
|
37
|
-
"Project-Id-Version": "
|
|
38
|
-
"Report-Msgid-Bugs-To": "
|
|
37
|
+
"Project-Id-Version": "My Plugin Name 1.0.0",
|
|
38
|
+
"Report-Msgid-Bugs-To": "https://wordpress.org/support/plugins/plugin",
|
|
39
39
|
"MIME-Version": "1.0",
|
|
40
40
|
"Content-Transfer-Encoding": "8bit",
|
|
41
41
|
"content-type": "text/plain; charset=iso-8859-1",
|
|
42
42
|
"plural-forms": "nplurals=2; plural=(n!=1);",
|
|
43
|
-
"POT-Creation-Date": undefined,
|
|
44
|
-
"PO-Revision-Date": undefined,
|
|
43
|
+
"POT-Creation-Date": undefined, // because the date is going to change every test
|
|
44
|
+
"PO-Revision-Date": undefined, // because the date is going to change every test
|
|
45
45
|
"Last-Translator": "John Doe <bbb@ccc.ddd>",
|
|
46
46
|
"Language-Team": "John Doe <bbb@ccc.ddd>",
|
|
47
|
-
"X-Generator":
|
|
47
|
+
"X-Generator": undefined, // because the version changes
|
|
48
48
|
Language: "en",
|
|
49
49
|
"X-Domain": "plugin",
|
|
50
50
|
};
|
|
51
51
|
|
|
52
52
|
const result = await generateHeader({
|
|
53
53
|
headers: {
|
|
54
|
-
name: "
|
|
54
|
+
name: "My Plugin Name",
|
|
55
55
|
author: "John Doe",
|
|
56
56
|
version: "1.0.0",
|
|
57
57
|
license: "MIT",
|
|
@@ -67,6 +67,7 @@ describe("Header generation", () => {
|
|
|
67
67
|
// remove the date "POT-Creation-Date"
|
|
68
68
|
result["POT-Creation-Date"] = undefined;
|
|
69
69
|
result["PO-Revision-Date"] = undefined;
|
|
70
|
+
result["X-Generator"] = undefined;
|
|
70
71
|
|
|
71
72
|
assert.deepStrictEqual(result, expected);
|
|
72
73
|
});
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/assets/block-i18n.ts"],
|
|
4
|
-
"sourcesContent": ["export default {\n\ttitle: \"block title\",\n\tdescription: \"block description\",\n\tkeywords: [\"block keyword\"],\n\tstyles: [\n\t\t{\n\t\t\tlabel: \"block style label\",\n\t\t},\n\t],\n\tvariations: [\n\t\t{\n\t\t\ttitle: \"block variation title\",\n\t\t\tdescription: \"block variation description\",\n\t\t\tkeywords: [\"block variation keyword\"],\n\t\t},\n\t],\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAO,qBAAQ;AAAA,EACd,OAAO;AAAA,EACP,aAAa;AAAA,EACb,UAAU,CAAC,eAAe;AAAA,EAC1B,QAAQ;AAAA,IACP;AAAA,MACC,OAAO;AAAA,IACR;AAAA,EACD;AAAA,EACA,YAAY;AAAA,IACX;AAAA,MACC,OAAO;AAAA,MACP,aAAa;AAAA,MACb,UAAU,CAAC,yBAAyB;AAAA,IACrC;AAAA,EACD;AACD;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/assets/package-i18n.ts"],
|
|
4
|
-
"sourcesContent": ["export default {\n\tname: \"name\",\n\turl: \"url\",\n\tdescription: \"description\",\n\tauthor: \"author\",\n\tauthors: \"authors\",\n\tauthorEmail: \"authorEmail\",\n\tversion: \"version\",\n\tbugs: \"bugs\",\n\t\"bugs.url\": \"bugsUrl\",\n\t\"bugs.email\": \"bugsEmail\",\n\tlicense: \"license\",\n\trepository: \"repository\",\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAO,uBAAQ;AAAA,EACd,MAAM;AAAA,EACN,KAAK;AAAA,EACL,aAAa;AAAA,EACb,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,aAAa;AAAA,EACb,SAAS;AAAA,EACT,MAAM;AAAA,EACN,YAAY;AAAA,EACZ,cAAc;AAAA,EACd,SAAS;AAAA,EACT,YAAY;AACb;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/assets/theme-i18n.ts"],
|
|
4
|
-
"sourcesContent": ["export default {\n\ttitle: \"Style variation name\",\n\tsettings: {\n\t\ttypography: {\n\t\t\tfontSizes: [\n\t\t\t\t{\n\t\t\t\t\tname: \"Font size name\",\n\t\t\t\t},\n\t\t\t],\n\t\t\tfontFamilies: [\n\t\t\t\t{\n\t\t\t\t\tname: \"Font family name\",\n\t\t\t\t},\n\t\t\t],\n\t\t},\n\t\tcolor: {\n\t\t\tpalette: [\n\t\t\t\t{\n\t\t\t\t\tname: \"Color name\",\n\t\t\t\t},\n\t\t\t],\n\t\t\tgradients: [\n\t\t\t\t{\n\t\t\t\t\tname: \"Gradient name\",\n\t\t\t\t},\n\t\t\t],\n\t\t\tduotone: [\n\t\t\t\t{\n\t\t\t\t\tname: \"Duotone name\",\n\t\t\t\t},\n\t\t\t],\n\t\t},\n\t\tspacing: {\n\t\t\tspacingSizes: [\n\t\t\t\t{\n\t\t\t\t\tname: \"Space size name\",\n\t\t\t\t},\n\t\t\t],\n\t\t},\n\t\tblocks: {\n\t\t\t\"*\": {\n\t\t\t\ttypography: {\n\t\t\t\t\tfontSizes: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tname: \"Font size name\",\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t\tfontFamilies: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tname: \"Font family name\",\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t\tcolor: {\n\t\t\t\t\tpalette: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tname: \"Color name\",\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t\tgradients: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tname: \"Gradient name\",\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t\tspacing: {\n\t\t\t\t\tspacingSizes: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tname: \"Space size name\",\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t},\n\tcustomTemplates: [\n\t\t{\n\t\t\ttitle: \"Custom template name\",\n\t\t},\n\t],\n\ttemplateParts: [\n\t\t{\n\t\t\ttitle: \"Template part name\",\n\t\t},\n\t],\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAO,qBAAQ;AAAA,EACd,OAAO;AAAA,EACP,UAAU;AAAA,IACT,YAAY;AAAA,MACX,WAAW;AAAA,QACV;AAAA,UACC,MAAM;AAAA,QACP;AAAA,MACD;AAAA,MACA,cAAc;AAAA,QACb;AAAA,UACC,MAAM;AAAA,QACP;AAAA,MACD;AAAA,IACD;AAAA,IACA,OAAO;AAAA,MACN,SAAS;AAAA,QACR;AAAA,UACC,MAAM;AAAA,QACP;AAAA,MACD;AAAA,MACA,WAAW;AAAA,QACV;AAAA,UACC,MAAM;AAAA,QACP;AAAA,MACD;AAAA,MACA,SAAS;AAAA,QACR;AAAA,UACC,MAAM;AAAA,QACP;AAAA,MACD;AAAA,IACD;AAAA,IACA,SAAS;AAAA,MACR,cAAc;AAAA,QACb;AAAA,UACC,MAAM;AAAA,QACP;AAAA,MACD;AAAA,IACD;AAAA,IACA,QAAQ;AAAA,MACP,KAAK;AAAA,QACJ,YAAY;AAAA,UACX,WAAW;AAAA,YACV;AAAA,cACC,MAAM;AAAA,YACP;AAAA,UACD;AAAA,UACA,cAAc;AAAA,YACb;AAAA,cACC,MAAM;AAAA,YACP;AAAA,UACD;AAAA,QACD;AAAA,QACA,OAAO;AAAA,UACN,SAAS;AAAA,YACR;AAAA,cACC,MAAM;AAAA,YACP;AAAA,UACD;AAAA,UACA,WAAW;AAAA,YACV;AAAA,cACC,MAAM;AAAA,YACP;AAAA,UACD;AAAA,QACD;AAAA,QACA,SAAS;AAAA,UACR,cAAc;AAAA,YACb;AAAA,cACC,MAAM;AAAA,YACP;AAAA,UACD;AAAA,QACD;AAAA,MACD;AAAA,IACD;AAAA,EACD;AAAA,EACA,iBAAiB;AAAA,IAChB;AAAA,MACC,OAAO;AAAA,IACR;AAAA,EACD;AAAA,EACA,eAAe;AAAA,IACd;AAAA,MACC,OAAO;AAAA,IACR;AAAA,EACD;AACD;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/assets/wp-plugin-i18n.ts"],
|
|
4
|
-
"sourcesContent": ["export default {\n\tname: \"Plugin Name\",\n\tslug: \"Plugin Slug\",\n\turl: \"Plugin URI\",\n\tdescription: \"Description\",\n\tversion: \"Version\",\n\tauthor: \"Author\",\n\tauthorUri: \"Author URI\",\n\ttags: \"Tags\",\n\tlicense: \"License\",\n\tlicenseUri: \"License URI\",\n\tupdateUri: \"Update URI\",\n\tdomainPath: \"Domain Path\",\n\ttextDomain: \"Text Domain\",\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAO,yBAAQ;AAAA,EACd,MAAM;AAAA,EACN,MAAM;AAAA,EACN,KAAK;AAAA,EACL,aAAa;AAAA,EACb,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,WAAW;AAAA,EACX,MAAM;AAAA,EACN,SAAS;AAAA,EACT,YAAY;AAAA,EACZ,WAAW;AAAA,EACX,YAAY;AAAA,EACZ,YAAY;AACb;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/assets/wp-theme-i18n.ts"],
|
|
4
|
-
"sourcesContent": ["export default {\n\tname: \"Theme Name\",\n\tauthor: \"Author\",\n\tauthorUri: \"Author URI\",\n\tdescription: \"Description\",\n\turl: \"Theme URI\",\n\ttags: \"Tags\",\n\tversion: \"Version\",\n\tlicense: \"License\",\n\tlicenseUri: \"License URI\",\n\tdomainPath: \"Domain Path\",\n\ttextDomain: \"Text Domain\",\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAO,wBAAQ;AAAA,EACd,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,WAAW;AAAA,EACX,aAAa;AAAA,EACb,KAAK;AAAA,EACL,MAAM;AAAA,EACN,SAAS;AAAA,EACT,SAAS;AAAA,EACT,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,YAAY;AACb;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
package/lib/cli/getArgs.js.map
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/cli/getArgs.ts"],
|
|
4
|
-
"sourcesContent": ["import process from \"node:process\";\nimport * as yargs from \"yargs\";\nimport { hideBin } from \"yargs/helpers\";\nimport type { Args, MakeJsonArgs } from \"../types.js\";\nimport { parseCliArgs } from \"./parseCli.js\";\n\n/**\n * Retrieves and returns the command line arguments and options.\n *\n * @return The parsed command line arguments and options.\n */\nexport function getArgs(userArgs = {}): Args | MakeJsonArgs {\n\tconst args = yargs\n\t\t.default(hideBin(process.argv))\n\t\t.help(\"h\")\n\t\t.alias(\"help\", \"help\")\n\t\t.usage(\"Usage: $0 <source> [destination] [options]\")\n\t\t.positional(\"sourceDirectory\", {\n\t\t\tdescribe: \"Source directory\",\n\t\t\ttype: \"string\",\n\t\t})\n\t\t.positional(\"destination\", {\n\t\t\tdescribe: \"Destination directory\",\n\t\t\ttype: \"string\",\n\t\t})\n\t\t.options({\n\t\t\tslug: {\n\t\t\t\tdescribe: \"Plugin or theme slug\",\n\t\t\t\ttype: \"string\",\n\t\t\t},\n\t\t\tdomain: {\n\t\t\t\tdescribe: \"Text domain to look for in the source code\",\n\t\t\t\ttype: \"string\",\n\t\t\t},\n\t\t\t\"skip-js\": {\n\t\t\t\tdescribe: \"Skip JavaScript files\",\n\t\t\t\ttype: \"boolean\",\n\t\t\t},\n\t\t\t\"skip-php\": {\n\t\t\t\tdescribe: \"Skip PHP files\",\n\t\t\t\ttype: \"boolean\",\n\t\t\t},\n\t\t\t\"skip-blade\": {\n\t\t\t\tdescribe: \"Skip Blade files\",\n\t\t\t\ttype: \"boolean\",\n\t\t\t},\n\t\t\t\"skip-block-json\": {\n\t\t\t\tdescribe: \"Skip block.json files\",\n\t\t\t\ttype: \"boolean\",\n\t\t\t},\n\t\t\t\"skip-theme-json\": {\n\t\t\t\tdescribe: \"Skip theme.json files\",\n\t\t\t\ttype: \"boolean\",\n\t\t\t},\n\t\t\t\"skip-audit\": {\n\t\t\t\tdescribe: \"Skip auditing of strings\",\n\t\t\t\ttype: \"boolean\",\n\t\t\t},\n\t\t\theaders: {\n\t\t\t\tdescribe: \"Headers\",\n\t\t\t\ttype: \"string\",\n\t\t\t},\n\t\t\t\"file-comment\": {\n\t\t\t\tdescribe: \"File comment\",\n\t\t\t\ttype: \"string\",\n\t\t\t},\n\t\t\t\"package-name\": {\n\t\t\t\tdescribe: \"Package name\",\n\t\t\t\ttype: \"string\",\n\t\t\t},\n\t\t\tlocation: {\n\t\t\t\tdescribe: \"Include location information\",\n\t\t\t\ttype: \"boolean\",\n\t\t\t},\n\t\t\t\"ignore-domain\": {\n\t\t\t\tdescribe: \"Ignore text domain\",\n\t\t\t\ttype: \"boolean\",\n\t\t\t},\n\t\t\tmergePaths: {\n\t\t\t\tdescribe: \"Merge with existing POT file(s)\",\n\t\t\t\ttype: \"string\",\n\t\t\t},\n\t\t\tsubtractPaths: {\n\t\t\t\tdescribe: \"Subtract strings from existing POT file(s)\",\n\t\t\t\ttype: \"string\",\n\t\t\t},\n\t\t\tsubtractAndMerge: {\n\t\t\t\tdescribe: \"Subtract and merge strings from existing POT file(s)\",\n\t\t\t\ttype: \"boolean\",\n\t\t\t},\n\t\t\tinclude: {\n\t\t\t\tdescribe: \"Include specific files\",\n\t\t\t\ttype: \"string\",\n\t\t\t\tdefault: \"**\",\n\t\t\t},\n\t\t\texclude: {\n\t\t\t\tdescribe: \"Exclude specific files\",\n\t\t\t\ttype: \"string\",\n\t\t\t},\n\t\t\tsilent: {\n\t\t\t\tdescribe: \"No output to stdout\",\n\t\t\t\ttype: \"boolean\",\n\t\t\t\tdefault: false,\n\t\t\t},\n\t\t\tjson: {\n\t\t\t\tdescribe: \"Output the json gettext data\",\n\t\t\t\ttype: \"boolean\",\n\t\t\t},\n\t\t\toutput: {\n\t\t\t\tdescribe: \"Output the gettext data\",\n\t\t\t\ttype: \"boolean\",\n\t\t\t},\n\t\t\tcharset: {\n\t\t\t\tdescribe: \"Charset\",\n\t\t\t\ttype: \"string\",\n\t\t\t\tdefault: \"latin1\",\n\t\t\t},\n\t\t})\n\t\t.parseSync();\n\treturn parseCliArgs({ ...userArgs, ...args });\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAAoB;AACpB,YAAuB;AACvB,qBAAwB;AAExB,sBAA6B;AAOtB,SAAS,QAAQ,WAAW,CAAC,GAAwB;AAC3D,QAAM,OAAO,MACX,YAAQ,wBAAQ,oBAAAA,QAAQ,IAAI,CAAC,EAC7B,KAAK,GAAG,EACR,MAAM,QAAQ,MAAM,EACpB,MAAM,4CAA4C,EAClD,WAAW,mBAAmB;AAAA,IAC9B,UAAU;AAAA,IACV,MAAM;AAAA,EACP,CAAC,EACA,WAAW,eAAe;AAAA,IAC1B,UAAU;AAAA,IACV,MAAM;AAAA,EACP,CAAC,EACA,QAAQ;AAAA,IACR,MAAM;AAAA,MACL,UAAU;AAAA,MACV,MAAM;AAAA,IACP;AAAA,IACA,QAAQ;AAAA,MACP,UAAU;AAAA,MACV,MAAM;AAAA,IACP;AAAA,IACA,WAAW;AAAA,MACV,UAAU;AAAA,MACV,MAAM;AAAA,IACP;AAAA,IACA,YAAY;AAAA,MACX,UAAU;AAAA,MACV,MAAM;AAAA,IACP;AAAA,IACA,cAAc;AAAA,MACb,UAAU;AAAA,MACV,MAAM;AAAA,IACP;AAAA,IACA,mBAAmB;AAAA,MAClB,UAAU;AAAA,MACV,MAAM;AAAA,IACP;AAAA,IACA,mBAAmB;AAAA,MAClB,UAAU;AAAA,MACV,MAAM;AAAA,IACP;AAAA,IACA,cAAc;AAAA,MACb,UAAU;AAAA,MACV,MAAM;AAAA,IACP;AAAA,IACA,SAAS;AAAA,MACR,UAAU;AAAA,MACV,MAAM;AAAA,IACP;AAAA,IACA,gBAAgB;AAAA,MACf,UAAU;AAAA,MACV,MAAM;AAAA,IACP;AAAA,IACA,gBAAgB;AAAA,MACf,UAAU;AAAA,MACV,MAAM;AAAA,IACP;AAAA,IACA,UAAU;AAAA,MACT,UAAU;AAAA,MACV,MAAM;AAAA,IACP;AAAA,IACA,iBAAiB;AAAA,MAChB,UAAU;AAAA,MACV,MAAM;AAAA,IACP;AAAA,IACA,YAAY;AAAA,MACX,UAAU;AAAA,MACV,MAAM;AAAA,IACP;AAAA,IACA,eAAe;AAAA,MACd,UAAU;AAAA,MACV,MAAM;AAAA,IACP;AAAA,IACA,kBAAkB;AAAA,MACjB,UAAU;AAAA,MACV,MAAM;AAAA,IACP;AAAA,IACA,SAAS;AAAA,MACR,UAAU;AAAA,MACV,MAAM;AAAA,MACN,SAAS;AAAA,IACV;AAAA,IACA,SAAS;AAAA,MACR,UAAU;AAAA,MACV,MAAM;AAAA,IACP;AAAA,IACA,QAAQ;AAAA,MACP,UAAU;AAAA,MACV,MAAM;AAAA,MACN,SAAS;AAAA,IACV;AAAA,IACA,MAAM;AAAA,MACL,UAAU;AAAA,MACV,MAAM;AAAA,IACP;AAAA,IACA,QAAQ;AAAA,MACP,UAAU;AAAA,MACV,MAAM;AAAA,IACP;AAAA,IACA,SAAS;AAAA,MACR,UAAU;AAAA,MACV,MAAM;AAAA,MACN,SAAS;AAAA,IACV;AAAA,EACD,CAAC,EACA,UAAU;AACZ,aAAO,8BAAa,EAAE,GAAG,UAAU,GAAG,KAAK,CAAC;AAC7C;",
|
|
6
|
-
"names": ["process"]
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/cli/getJsonArgs.ts"],
|
|
4
|
-
"sourcesContent": ["import process from \"node:process\";\nimport * as yargs from \"yargs\";\nimport { hideBin } from \"yargs/helpers\";\nimport type { MakeJsonArgs } from \"../types.js\";\nimport { parseJsonArgs } from \"./parseCli.js\";\n\n/**\n * Parses the command line arguments for the JSON command.\n *\n * @param additionalArgs - Additional arguments to be parsed.\n * @returns The parsed command line arguments.\n */\nexport function getJsonArgs(additionalArgs = {}): MakeJsonArgs {\n\tconst args = yargs\n\t\t.default(hideBin(process.argv))\n\t\t.help(\"h\")\n\t\t.alias(\"help\", \"help\")\n\t\t.usage(\"Usage: $0 <source> [destination] [options]\")\n\t\t.positional(\"source\", {\n\t\t\tdescribe: \"Source directory\",\n\t\t\ttype: \"string\",\n\t\t})\n\t\t.positional(\"destination\", {\n\t\t\tdescribe: \"Destination directory\",\n\t\t\ttype: \"string\",\n\t\t})\n\t\t.options({\n\t\t\tscriptName: {\n\t\t\t\tdescribe: \"The name of the script to be translated\",\n\t\t\t\ttype: \"string\",\n\t\t\t},\n\t\t\tallowedFormats: {\n\t\t\t\tdescribe: \"which extensions to use for translation\",\n\t\t\t\ttype: \"array\",\n\t\t\t\tdefault: [\"js\"],\n\t\t\t},\n\t\t\tpurge: {\n\t\t\t\tdescribe: \"Remove old JSON files\",\n\t\t\t\ttype: \"boolean\",\n\t\t\t\tdefault: true,\n\t\t\t},\n\t\t\tprettyPrint: {\n\t\t\t\tdescribe: \"Pretty print JSON\",\n\t\t\t\ttype: \"boolean\",\n\t\t\t\tdefault: false,\n\t\t\t},\n\t\t\tdebug: {\n\t\t\t\tdescribe: \"Debug mode\",\n\t\t\t\ttype: \"boolean\",\n\t\t\t\tdefault: false,\n\t\t\t},\n\t\t})\n\t\t.parseSync();\n\treturn parseJsonArgs({ ...additionalArgs, ...args });\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAAoB;AACpB,YAAuB;AACvB,qBAAwB;AAExB,sBAA8B;AAQvB,SAAS,YAAY,iBAAiB,CAAC,GAAiB;AAC9D,QAAM,OAAO,MACX,YAAQ,wBAAQ,oBAAAA,QAAQ,IAAI,CAAC,EAC7B,KAAK,GAAG,EACR,MAAM,QAAQ,MAAM,EACpB,MAAM,4CAA4C,EAClD,WAAW,UAAU;AAAA,IACrB,UAAU;AAAA,IACV,MAAM;AAAA,EACP,CAAC,EACA,WAAW,eAAe;AAAA,IAC1B,UAAU;AAAA,IACV,MAAM;AAAA,EACP,CAAC,EACA,QAAQ;AAAA,IACR,YAAY;AAAA,MACX,UAAU;AAAA,MACV,MAAM;AAAA,IACP;AAAA,IACA,gBAAgB;AAAA,MACf,UAAU;AAAA,MACV,MAAM;AAAA,MACN,SAAS,CAAC,IAAI;AAAA,IACf;AAAA,IACA,OAAO;AAAA,MACN,UAAU;AAAA,MACV,MAAM;AAAA,MACN,SAAS;AAAA,IACV;AAAA,IACA,aAAa;AAAA,MACZ,UAAU;AAAA,MACV,MAAM;AAAA,MACN,SAAS;AAAA,IACV;AAAA,IACA,OAAO;AAAA,MACN,UAAU;AAAA,MACV,MAAM;AAAA,MACN,SAAS;AAAA,IACV;AAAA,EACD,CAAC,EACA,UAAU;AACZ,aAAO,+BAAc,EAAE,GAAG,gBAAgB,GAAG,KAAK,CAAC;AACpD;",
|
|
6
|
-
"names": ["process"]
|
|
7
|
-
}
|