@wp-blocks/make-pot 1.5.1 → 1.6.2

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.
Files changed (65) hide show
  1. package/README.md +2 -1
  2. package/lib/assets/block-i18n.js.map +1 -7
  3. package/lib/assets/package-i18n.js.map +1 -7
  4. package/lib/assets/theme-i18n.js.map +1 -7
  5. package/lib/assets/wp-plugin-i18n.js.map +1 -7
  6. package/lib/assets/wp-theme-i18n.js.map +1 -7
  7. package/lib/cli/getArgs.js +1 -1
  8. package/lib/cli/getArgs.js.map +1 -7
  9. package/lib/cli/getJsonArgs.js +1 -1
  10. package/lib/cli/getJsonArgs.js.map +1 -7
  11. package/lib/cli/parseCli.js +1 -1
  12. package/lib/cli/parseCli.js.map +1 -7
  13. package/lib/cli.js.map +1 -7
  14. package/lib/const.js +1 -1
  15. package/lib/const.js.map +1 -7
  16. package/lib/extractors/auditStrings.js +5 -0
  17. package/lib/extractors/auditStrings.js.map +1 -0
  18. package/lib/extractors/css.js +1 -1
  19. package/lib/extractors/css.js.map +1 -7
  20. package/lib/extractors/headers.js +12 -4
  21. package/lib/extractors/headers.js.map +1 -7
  22. package/lib/extractors/json.js.map +1 -7
  23. package/lib/extractors/packageJson.js.map +1 -7
  24. package/lib/extractors/php.js.map +1 -7
  25. package/lib/extractors/schema.js.map +1 -7
  26. package/lib/extractors/text.js.map +1 -7
  27. package/lib/fs/fs.js +2 -2
  28. package/lib/fs/fs.js.map +1 -7
  29. package/lib/fs/glob.js +1 -1
  30. package/lib/fs/glob.js.map +1 -7
  31. package/lib/index.js +1 -1
  32. package/lib/index.js.map +1 -7
  33. package/lib/jsonCommand.js +1 -1
  34. package/lib/jsonCommand.js.map +1 -7
  35. package/lib/makeJson.js.map +1 -7
  36. package/lib/makePot.js.map +1 -7
  37. package/lib/parser/exec.js +3 -7
  38. package/lib/parser/exec.js.map +1 -7
  39. package/lib/parser/makeJson.js +1 -1
  40. package/lib/parser/makeJson.js.map +1 -7
  41. package/lib/parser/makePot.js +1 -1
  42. package/lib/parser/makePot.js.map +1 -7
  43. package/lib/parser/patterns.js +1 -1
  44. package/lib/parser/patterns.js.map +1 -7
  45. package/lib/parser/process.js +1 -1
  46. package/lib/parser/process.js.map +1 -7
  47. package/lib/parser/progress.js.map +1 -7
  48. package/lib/parser/taskRunner.js.map +1 -7
  49. package/lib/parser/tree.js +1 -1
  50. package/lib/parser/tree.js.map +1 -7
  51. package/lib/potCommand.js +1 -1
  52. package/lib/potCommand.js.map +1 -7
  53. package/lib/types.js +1 -1
  54. package/lib/types.js.map +1 -7
  55. package/lib/utils/common.js +8 -4
  56. package/lib/utils/common.js.map +1 -7
  57. package/lib/utils/extractors.js.map +1 -7
  58. package/lib/utils/output.js +1 -0
  59. package/lib/utils/output.js.map +1 -0
  60. package/package.json +9 -7
  61. package/tests/audit.test.js +50 -0
  62. package/tests/compare-json.test.js +81 -0
  63. package/tests/extract.test.js +38 -0
  64. package/tests/parse-headers.test.js +7 -6
  65. package/tests/tree.test.js +21 -0
package/lib/fs/fs.js CHANGED
@@ -1,2 +1,2 @@
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});
1
+ "use strict";var l=Object.create;var i=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames;var F=Object.getPrototypeOf,x=Object.prototype.hasOwnProperty;var y=(e,t)=>{for(var n in t)i(e,n,{get:t[n],enumerable:!0})},u=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of m(t))!x.call(e,r)&&r!==n&&i(e,r,{get:()=>t[r],enumerable:!(o=p(t,r))||o.enumerable});return e};var f=(e,t,n)=>(n=e!=null?l(F(e)):{},u(t||!e||!e.__esModule?i(n,"default",{value:e,enumerable:!0}):n,e)),w=e=>u(i({},"__esModule",{value:!0}),e);var j={};y(j,{getCharset:()=>d,getEncodingCharset:()=>$,readFileAsync:()=>S,writeFile:()=>C});module.exports=w(j);var s=f(require("node:fs")),a=require("node:fs/promises"),c=f(require("node:path"));function E(e){if(e===void 0)return".";try{s.default.accessSync(c.default.resolve(e),s.default.constants.R_OK|s.default.constants.W_OK)}catch(t){if(t.code==="ENOENT")return s.default.mkdirSync(e,{recursive:!0}),console.log(`Folder created: ${e}`),e}return e}function d(e){if(!e)return"latin1";switch(e.toLowerCase()){case"utf-8":case"utf8":return"utf-8";default:return"latin1"}}function $(e){if(!e)return"iso-8859-1";switch(e.toLowerCase()){case"utf-8":case"utf8":return"utf-8";default:return"iso-8859-1"}}function h(e){const{out:t,headers:n,options:o}=e.paths;let r=t??n?.domainPath??"languages";r=r.replace(/^\/+|\/+$/g,"");const g=o?.json?"json":"pot";return c.default.join(process.cwd(),r,`${e.slug}.${g}`)}function C(e,t){const n=h(t);if(E(c.default.dirname(n))){const o=d(t.options?.charset);console.log(`
2
+ Pot File created at ${n}`);const r=Buffer.from(e);(0,s.writeFileSync)(n,r.toString(o),{encoding:o})}else console.log(`Folder ${n} does not exist and cannot be created`)}async function S(e){return(0,a.readFile)(e,"utf-8")}0&&(module.exports={getCharset,getEncodingCharset,readFileAsync,writeFile});
package/lib/fs/fs.js.map CHANGED
@@ -1,7 +1 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/fs/fs.ts"],
4
- "sourcesContent": ["import fs, { writeFileSync } from \"node:fs\";\nimport { readFile } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport type { Args } from \"../types.js\";\n\n/**\n * Ensures that a folder exists at the specified path.\n *\n * @param {string | undefined} folderPath - The path of the folder to ensure existence for.\n * @return {string} - The path of the folder, or '.' if folderPath is undefined.\n */\nfunction ensureFolderExists(folderPath: string | undefined): string {\n\tif (folderPath === undefined) {\n\t\treturn \".\";\n\t}\n\ttry {\n\t\t// Check if the folder exists\n\t\tfs.accessSync(\n\t\t\tpath.resolve(folderPath),\n\t\t\tfs.constants.R_OK | fs.constants.W_OK,\n\t\t);\n\t} catch (error) {\n\t\tif ((error as NodeJS.ErrnoException).code === \"ENOENT\") {\n\t\t\t// The Folder does not exist, so create it\n\t\t\tfs.mkdirSync(folderPath, { recursive: true });\n\t\t\tconsole.log(`Folder created: ${folderPath}`);\n\t\t\treturn folderPath;\n\t\t}\n\t}\n\treturn folderPath;\n}\n\n/**\n * Gets the charset of the .pot file\n *\n * @param charset the charset of the .pot file\n * @return the charset of the .pot file\n */\nexport function getCharset(charset: string | undefined): BufferEncoding {\n\tif (!charset) {\n\t\treturn \"latin1\";\n\t}\n\t// we need to check if the charset is valid otherwise we return latin1 that is a common alias for ISO-8859-1 and the default charset for pot files\n\tswitch (charset.toLowerCase()) {\n\t\tcase \"utf-8\":\n\t\tcase \"utf8\":\n\t\t\treturn \"utf-8\";\n\t\tdefault:\n\t\t\treturn \"latin1\";\n\t}\n}\n\nexport function getEncodingCharset(charset: string | undefined): string {\n\tif (!charset) {\n\t\treturn \"iso-8859-1\";\n\t}\n\t// we need to check if the charset is valid otherwise we return utf-8 that is a common alias for ISO-8859-1 and the default charset for pot files\n\tswitch (charset.toLowerCase()) {\n\t\tcase \"utf-8\":\n\t\tcase \"utf8\":\n\t\t\treturn \"utf-8\";\n\t\tdefault:\n\t\t\treturn \"iso-8859-1\";\n\t}\n}\n\n/**\n * The output path for the pot file.\n * @param outpath - the output path for the pot/json files\n * @return {string} - the output path\n */\nexport function getOutputPath(outpath?: string): string {\n\treturn path.join(process.cwd(), outpath ?? \"languages\");\n}\n\n/**\n * The output path for the pot file.\n * @param args - the command line arguments\n */\nfunction getOutputFilePath(args: Args): string {\n\tconst { out, headers, options } = args.paths;\n\tlet i18nFolder = out ?? headers?.domainPath ?? \"languages\";\n\n\t// Remove leading and trailing slashes\n\ti18nFolder = i18nFolder.replace(/^\\/+|\\/+$/g, \"\");\n\n\tconst extension = options?.json ? \"json\" : \"pot\";\n\n\treturn path.join(process.cwd(), i18nFolder, `${args.slug}.${extension}`);\n}\n\n/**\n * Writes the .pot file to disk\n *\n * @param fileContent the content of the .pot file\n * @param args the command line arguments passed to the program\n */\nexport function writeFile(fileContent: string, args: Args): void {\n\tconst dest = getOutputFilePath(args);\n\n\tif (ensureFolderExists(path.dirname(dest))) {\n\t\t// get the encoding charset\n\t\tconst encodingCharset = getCharset(args.options?.charset);\n\t\tconsole.log(`\\nFile created at ${dest}`);\n\n\t\t// write the file\n\t\tconst potBuffer = Buffer.from(fileContent);\n\t\twriteFileSync(dest, potBuffer.toString(encodingCharset), {\n\t\t\tencoding: encodingCharset,\n\t\t});\n\t} else {\n\t\tconsole.log(`Folder ${dest} does not exist and cannot be created`);\n\t}\n}\n\n/**\n * The async version of fs.readFile method\n * @param path the path of the file to read\n * @return the content of the file as a string\n */\nexport async function readFileAsync(path: string): Promise<string> {\n\treturn readFile(path, \"utf-8\");\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAAkC;AAClC,sBAAyB;AACzB,uBAAiB;AASjB,SAAS,mBAAmB,YAAwC;AACnE,MAAI,eAAe,QAAW;AAC7B,WAAO;AAAA,EACR;AACA,MAAI;AAEH,mBAAAA,QAAG;AAAA,MACF,iBAAAC,QAAK,QAAQ,UAAU;AAAA,MACvB,eAAAD,QAAG,UAAU,OAAO,eAAAA,QAAG,UAAU;AAAA,IAClC;AAAA,EACD,SAAS,OAAO;AACf,QAAK,MAAgC,SAAS,UAAU;AAEvD,qBAAAA,QAAG,UAAU,YAAY,EAAE,WAAW,KAAK,CAAC;AAC5C,cAAQ,IAAI,mBAAmB,UAAU,EAAE;AAC3C,aAAO;AAAA,IACR;AAAA,EACD;AACA,SAAO;AACR;AAQO,SAAS,WAAW,SAA6C;AACvE,MAAI,CAAC,SAAS;AACb,WAAO;AAAA,EACR;AAEA,UAAQ,QAAQ,YAAY,GAAG;AAAA,IAC9B,KAAK;AAAA,IACL,KAAK;AACJ,aAAO;AAAA,IACR;AACC,aAAO;AAAA,EACT;AACD;AAEO,SAAS,mBAAmB,SAAqC;AACvE,MAAI,CAAC,SAAS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AC;AAED;;;;GAIG;AACI,KAAK,UAAU,aAAa,CAAC,IAAY;IAC/C,OAAO,IAAA,mBAAQ,EAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AAChC,CAAC"}
package/lib/fs/glob.js CHANGED
@@ -1 +1 @@
1
- "use strict";var d=Object.create;var o=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var h=Object.getOwnPropertyNames;var y=Object.getPrototypeOf,w=Object.prototype.hasOwnProperty;var x=(t,r)=>{for(var e in r)o(t,e,{get:r[e],enumerable:!0})},i=(t,r,e,a)=>{if(r&&typeof r=="object"||typeof r=="function")for(let s of h(r))!w.call(t,s)&&s!==e&&o(t,s,{get:()=>r[s],enumerable:!(a=g(r,s))||a.enumerable});return t};var n=(t,r,e)=>(e=t!=null?d(y(t)):{},i(r||!t||!t.__esModule?o(e,"default",{value:t,enumerable:!0}):e,t)),j=t=>i(o({},"__esModule",{value:!0}),t);var F={};x(F,{getFiles:()=>A,getParser:()=>b,ignoreFunc:()=>f});module.exports=j(F);var c=n(require("node:path")),u=require("glob"),m=require("minimatch"),P=n(require("tree-sitter-javascript")),v=n(require("tree-sitter-php")),p=n(require("tree-sitter-typescript")),l=require("../utils/common.js");function b(t){switch(t.split(".").pop()){case"ts":return p.typescript;case"tsx":return p.tsx;case"js":case"jsx":case"mjs":case"cjs":return P.default;case"php":return v.default;default:return null}}const f=(t,r)=>r.some(e=>{switch((0,l.detectPatternType)(e)){case"file":return t.isNamed(e);case"directory":return t.relative().includes(e);default:return(0,m.minimatch)(t.relative(),e)}});function A(t,r){return new u.Glob(r.include,{ignore:{ignored:e=>f(e,r.exclude)},nodir:!0,cwd:t.paths.cwd,root:t.paths.root?c.default.resolve(t.paths.root):void 0})}0&&(module.exports={getFiles,getParser,ignoreFunc});
1
+ "use strict";var f=Object.create;var s=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var x=Object.getPrototypeOf,j=Object.prototype.hasOwnProperty;var w=(t,e)=>{for(var r in e)s(t,r,{get:e[r],enumerable:!0})},p=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of y(e))!j.call(t,n)&&n!==r&&s(t,n,{get:()=>e[n],enumerable:!(i=g(e,n))||i.enumerable});return t};var o=(t,e,r)=>(r=t!=null?f(x(t)):{},p(e||!t||!t.__esModule?s(r,"default",{value:t,enumerable:!0}):r,t)),P=t=>p(s({},"__esModule",{value:!0}),t);var A={};w(A,{getFiles:()=>F,getParser:()=>v,ignoreFunc:()=>d});module.exports=P(A);var u=o(require("node:path")),l=require("glob"),h=require("minimatch"),b=o(require("tree-sitter-javascript")),c=o(require("tree-sitter-php")),m=o(require("tree-sitter-typescript")),a=require("../utils/common.js");function v(t){switch((0,a.getFileExtension)(t)){case"ts":return m.typescript;case"tsx":return m.tsx;case"js":case"jsx":case"mjs":case"cjs":return b;case"php":return c.php;case"blade.php":return c.php_only;default:return null}}const d=(t,e)=>e.some(r=>{switch((0,a.detectPatternType)(r)){case"file":return t.isNamed(r);case"directory":return t.relative().includes(r);default:return(0,h.minimatch)(t.relative(),r)}});function F(t,e){return new l.Glob(e.include,{ignore:{ignored:r=>d(r,e.exclude)},nodir:!0,cwd:t.paths.cwd,root:t.paths.root?u.default.resolve(t.paths.root):void 0})}0&&(module.exports={getFiles,getParser,ignoreFunc});
@@ -1,7 +1 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/fs/glob.ts"],
4
- "sourcesContent": ["import path from \"node:path\";\nimport { Glob, type Path } from \"glob\";\nimport { minimatch } from \"minimatch\";\n// @ts-ignore\nimport * as Javascript from \"tree-sitter-javascript\";\n// @ts-ignore\nimport * as php from \"tree-sitter-php\";\n// @ts-ignore\nimport * as ts from \"tree-sitter-typescript\";\nimport type { Args, Patterns } from \"../types.js\";\nimport { detectPatternType } from \"../utils/common.js\";\n\n/**\n * Return the parser based on the file extension\n *\n * @param file - Path to the file\n * @return {Parser|null} - the parser to be used with the file or null if no parser is found\n */\nexport function getParser(\n\tfile: string,\n): string | { name: string; language: unknown } | null {\n\tconst ext = file.split(\".\").pop();\n\tswitch (ext) {\n\t\tcase \"ts\":\n\t\t\treturn ts.typescript;\n\t\tcase \"tsx\":\n\t\t\treturn ts.tsx;\n\t\tcase \"js\":\n\t\tcase \"jsx\":\n\t\tcase \"mjs\":\n\t\tcase \"cjs\":\n\t\t\treturn Javascript.default;\n\t\tcase \"php\":\n\t\t\treturn php.default;\n\t\tdefault:\n\t\t\treturn null;\n\t}\n}\n\n// Build the ignore function for Glob\nexport const ignoreFunc = (\n\tfilePath: Path,\n\texcludedPatterns: string[],\n): boolean => {\n\treturn excludedPatterns.some((exclude) => {\n\t\tconst type = detectPatternType(exclude);\n\t\t// return true to ignore\n\t\tswitch (type) {\n\t\t\tcase \"file\":\n\t\t\t\treturn filePath.isNamed(exclude);\n\t\t\tcase \"directory\":\n\t\t\t\treturn filePath.relative().includes(exclude);\n\t\t\tdefault:\n\t\t\t\t// Handle glob patterns using minimatch\n\t\t\t\treturn minimatch(filePath.relative(), exclude);\n\t\t}\n\t}) as boolean;\n};\n\n/**\n * Retrieves a list of files based on the provided arguments and patterns.\n *\n * @param {Args} args - The argument object containing the source directory and other options.\n * @param {Patterns} pattern - The pattern object containing the included and excluded file patterns.\n * @return A promise that resolves to an array of file paths.\n */\nexport function getFiles(args: Args, pattern: Patterns) {\n\t// Execute the glob search with the built patterns\n\treturn new Glob(pattern.include, {\n\t\tignore: {\n\t\t\tignored: (p: Path) => ignoreFunc(p, pattern.exclude),\n\t\t},\n\t\tnodir: true,\n\t\tcwd: args.paths.cwd,\n\t\troot: args.paths.root ? path.resolve(args.paths.root) : undefined,\n\t});\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAAiB;AACjB,kBAAgC;AAChC,uBAA0B;AAE1B,iBAA4B;AAE5B,UAAqB;AAErB,SAAoB;AAEpB,oBAAkC;AAQ3B,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AAC,OAAO,CAAC,OAAO,EAAE;QAChC,MAAM,EAAE;YACP,OAAO,EAAE,CAAC,CAAO,EAAE,EAAE,CAAC,IAAA,kBAAU,EAAC,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC;SACpD;QACD,KAAK,EAAE,IAAI;QACX,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG;QACnB,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,mBAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS;KACjE,CAAC,CAAC;AACJ,CAAC"}
package/lib/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";var k=Object.create;var m=Object.defineProperty;var l=Object.getOwnPropertyDescriptor;var s=Object.getOwnPropertyNames;var F=Object.getPrototypeOf,c=Object.prototype.hasOwnProperty;var u=(e,r)=>{for(var o in r)m(e,o,{get:r[o],enumerable:!0})},i=(e,r,o,x)=>{if(r&&typeof r=="object"||typeof r=="function")for(let a of s(r))!c.call(e,a)&&a!==o&&m(e,a,{get:()=>r[a],enumerable:!(x=l(r,a))||x.enumerable});return e};var n=(e,r,o)=>(o=e!=null?k(F(e)):{},i(r||!e||!e.__esModule?m(o,"default",{value:e,enumerable:!0}):o,e)),J=e=>i(m({},"__esModule",{value:!0}),e);var h={};u(h,{default:()=>P,doTree:()=>d.doTree,extractMainFileData:()=>t.extractMainFileData,generateHeader:()=>t.generateHeader,getAuthorFromPackage:()=>t.getAuthorFromPackage,makeJson:()=>p.default,makePot:()=>f.default,parseJsonFile:()=>g.parseJsonFile});module.exports=J(h);var p=n(require("./jsonCommand.js")),f=n(require("./potCommand.js")),d=require("./parser/tree.js"),g=require("./extractors/json.js"),t=require("./extractors/headers.js"),P={makeJson:p.default,makePot:f.default};0&&(module.exports={doTree,extractMainFileData,generateHeader,getAuthorFromPackage,makeJson,makePot,parseJsonFile});
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/index.js.map CHANGED
@@ -1,7 +1 @@
1
- {
2
- "version": 3,
3
- "sources": ["../src/index.ts"],
4
- "sourcesContent": ["import makeJson from \"./jsonCommand.js\";\nimport makePot from \"./potCommand.js\";\n\nexport { doTree } from \"./parser/tree.js\";\nexport { parseJsonFile } from \"./extractors/json.js\";\nexport {\n\textractMainFileData,\n\tgenerateHeader,\n\tgetAuthorFromPackage,\n} from \"./extractors/headers.js\";\n\nexport { makeJson, makePot };\nexport default { makeJson, makePot };\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qCAAAA;AAAA,EAAA,iCAAAC;AAAA,EAAA;AAAA;AAAA;AAAA,yBAAqB;AACrB,wBAAoB;AAEpB,kBAAuB;AACvB,kBAA8B;AAC9B,qBAIO;AAGP,IAAO,gBAAQ,EAAE,6BAAAD,SAAU,2BAAAC,QAAQ;",
6
- "names": ["makeJson", "makePot"]
7
- }
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AAAA,mFAAyD;AAc7B,wBAdrB,yBAAa,CAcqB;AAbzC,sEAAwC;AAa/B,mBAbF,wBAAQ,CAaE;AAZjB,oEAAsC;AAYnB,kBAZZ,uBAAO,CAYY;AAV1B,8CAAoD;AAA3C,2GAAA,eAAe,OAAA;AACxB,kDAAgE;AAAvD,4GAAA,OAAO,OAAkB;AAClC,4CAA0C;AAAjC,iGAAA,MAAM,OAAA;AACf,gDAAqD;AAA5C,wGAAA,aAAa,OAAA;AACtB,sDAIiC;AAHhC,iHAAA,mBAAmB,OAAA;AACnB,4GAAA,cAAc,OAAA;AACd,kHAAA,oBAAoB,OAAA"}
@@ -1 +1 @@
1
- "use strict";var k=Object.create;var r=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var d=Object.getPrototypeOf,l=Object.prototype.hasOwnProperty;var J=(o,e)=>{for(var n in e)r(o,n,{get:e[n],enumerable:!0})},a=(o,e,n,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let m of f(e))!l.call(o,m)&&m!==n&&r(o,m,{get:()=>e[m],enumerable:!(t=p(e,m))||t.enumerable});return o};var M=(o,e,n)=>(n=o!=null?k(d(o)):{},a(e||!o||!o.__esModule?r(n,"default",{value:o,enumerable:!0}):n,o)),u=o=>a(r({},"__esModule",{value:!0}),o);var g={};J(g,{default:()=>c});module.exports=u(g);var i=M(require("./parser/makeJson.js")),s=require("./utils/common.js");function c(o){const e=new i.default(o);if(Object.keys(o).length>0){(0,s.printMakePotModuleInfo)();const n=new Date;e.exec().then(t=>{o.debug&&console.log(t),(0,s.printTimeElapsed)("Make-Json",n)}).catch(t=>{console.error(`\u{1FAE4} make-json - Error: ${t}`)})}}
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}`)})}}
@@ -1,7 +1 @@
1
- {
2
- "version": 3,
3
- "sources": ["../src/jsonCommand.ts"],
4
- "sourcesContent": ["import MakeJsonCommand from \"./parser/makeJson.js\";\nimport type { MakeJsonArgs } from \"./types.js\";\nimport { printMakePotModuleInfo, printTimeElapsed } from \"./utils/common.js\";\n\nexport default function makeJsonCommand(args: MakeJsonArgs) {\n\tconst makeJsonCommand = new MakeJsonCommand(args);\n\n\tif (Object.keys(args).length > 0) {\n\t\tprintMakePotModuleInfo();\n\t\t/* capture the start time */\n\t\tconst timeStart = new Date();\n\t\tmakeJsonCommand\n\t\t\t.exec()\n\t\t\t.then((result) => {\n\t\t\t\tif (args.debug) {\n\t\t\t\t\tconsole.log(result);\n\t\t\t\t}\n\t\t\t\t/* output the end time */\n\t\t\t\tprintTimeElapsed(\"Make-Json\", timeStart);\n\t\t\t})\n\t\t\t.catch((error) => {\n\t\t\t\tconsole.error(`\uD83E\uDEE4 make-json - Error: ${error}`);\n\t\t\t});\n\t}\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAA4B;AAE5B,oBAAyD;AAE1C,SAAR,gBAAiC,MAAoB;AAC3D,QAAMA,mBAAkB,IAAI,gBAAAC,QAAgB,IAAI;AAEhD,MAAI,OAAO,KAAK,IAAI,EAAE,SAAS,GAAG;AACjC,8CAAuB;AAEvB,UAAM,YAAY,oBAAI,KAAK;AAC3B,IAAAD,iBACE,KAAK,EACL,KAAK,CAAC,WAAW;AACjB,UAAI,KAAK,OAAO;AACf,gBAAQ,IAAI,MAAM;AAAA,MACnB;AAEA,0CAAiB,aAAa,SAAS;AAAA,IACxC,CAAC,EACA,MAAM,CAAC,UAAU;AACjB,cAAQ,MAAM,gCAAyB,KAAK,EAAE;AAAA,IAC/C,CAAC;AAAA,EACH;AACD;",
6
- "names": ["makeJsonCommand", "MakeJsonCommand"]
7
- }
1
+ {"version":3,"file":"jsonCommand.js","sourceRoot":"","sources":["../src/jsonCommand.ts"],"names":[],"mappings":";;;;;AAIA,kCAoBC;AAxBD,uEAAmD;AAEnD,iDAAsE;AAEtE,SAAwB,eAAe,CAAC,IAAkB;IACzD,MAAM,QAAQ,GAAG,IAAI,qBAAe,CAAC,IAAI,CAAC,CAAC;IAE3C,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAClC,IAAA,2BAAe,GAAE,CAAC;QAClB,4BAA4B;QAC5B,MAAM,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC;QAC7B,QAAQ;aACN,IAAI,EAAE;aACN,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE;YAChB,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;gBAChB,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;YACrB,CAAC;YACD,yBAAyB;YACzB,IAAA,4BAAgB,EAAC,WAAW,EAAE,SAAS,CAAC,CAAC;QAC1C,CAAC,CAAC;aACD,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;YAChB,OAAO,CAAC,KAAK,CAAC,yBAAyB,KAAK,EAAE,CAAC,CAAC;QACjD,CAAC,CAAC,CAAC;IACL,CAAC;AACF,CAAC"}
@@ -1,7 +1 @@
1
- {
2
- "version": 3,
3
- "sources": ["../src/makeJson.ts"],
4
- "sourcesContent": ["#!/usr/bin/env node\n\nimport { getJsonArgs } from \"./cli/getJsonArgs.js\";\nimport makeJson from \"./jsonCommand.js\";\n\nconst args = getJsonArgs();\n\nmakeJson(args);\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAEA,yBAA4B;AAC5B,yBAAqB;AAErB,MAAM,WAAO,gCAAY;AAAA,IAEzB,mBAAAA,SAAS,IAAI;",
6
- "names": ["makeJson"]
7
- }
1
+ {"version":3,"file":"makeJson.js","sourceRoot":"","sources":["../src/makeJson.ts"],"names":[],"mappings":";;;;;;AAEA,yDAAmD;AACnD,sEAAwC;AAExC,MAAM,IAAI,GAAG,IAAA,4BAAW,GAAE,CAAC;AAE3B,IAAA,wBAAQ,EAAC,IAAI,CAAC,CAAC"}
@@ -1,7 +1 @@
1
- {
2
- "version": 3,
3
- "sources": ["../src/makePot.ts"],
4
- "sourcesContent": ["#!/usr/bin/env node\n\nimport { getArgs } from \"./cli/getArgs.js\";\nimport makepotCommand from \"./potCommand.js\";\nimport type { Args } from \"./types.js\";\n\n/** Main execution */\nmakepotCommand(getArgs() as Args);\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAEA,qBAAwB;AACxB,wBAA2B;AAAA,IAI3B,kBAAAA,aAAe,wBAAQ,CAAS;",
6
- "names": ["makepotCommand"]
7
- }
1
+ {"version":3,"file":"makePot.js","sourceRoot":"","sources":["../src/makePot.ts"],"names":[],"mappings":";;;;;;AAEA,iDAA2C;AAC3C,oEAA6C;AAG7C,qBAAqB;AACrB,IAAA,uBAAc,EAAC,IAAA,oBAAO,GAAU,CAAC,CAAC"}
@@ -1,7 +1,3 @@
1
- "use strict";var w=Object.create;var s=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var C=Object.getOwnPropertyNames;var j=Object.getPrototypeOf,v=Object.prototype.hasOwnProperty;var k=(t,n)=>{for(var o in n)s(t,o,{get:n[o],enumerable:!0})},c=(t,n,o,i)=>{if(n&&typeof n=="object"||typeof n=="function")for(let e of C(n))!v.call(t,e)&&e!==o&&s(t,e,{get:()=>n[e],enumerable:!(i=x(n,e))||i.enumerable});return t};var g=(t,n,o)=>(o=t!=null?w(j(t)):{},c(n||!t||!t.__esModule?s(o,"default",{value:t,enumerable:!0}):o,t)),A=t=>c(s({},"__esModule",{value:!0}),t);var G={};k(G,{exec:()=>D});module.exports=A(G);var l=g(require("node:path")),f=require("gettext-parser"),u=g(require("tannin")),r=require("../extractors/headers.js"),p=require("../fs/fs"),a=require("../utils/common.js"),h=require("./patterns.js"),d=require("./process.js"),P=require("./progress.js"),T=require("./taskRunner.js");function B(t,n){return`
2
- Script Path: ${t}
3
- for ${n.include.join()}
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});
@@ -1,7 +1 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/parser/exec.ts"],
4
- "sourcesContent": ["import path from \"node:path\";\nimport type { SingleBar } from \"cli-progress\";\nimport { type GetTextTranslations, po } from \"gettext-parser\";\nimport Tannin from \"tannin\";\nimport { generateHeader, translationsHeaders } from \"../extractors/headers.js\";\nimport { getCharset, getEncodingCharset } from \"../fs/fs\";\nimport type { Args, Patterns } from \"../types.js\";\nimport { getCopyright, printStats } from \"../utils/common.js\";\nimport { getPatterns } from \"./patterns.js\";\nimport { processFiles } from \"./process.js\";\nimport { initProgress } from \"./progress.js\";\nimport { taskRunner } from \"./taskRunner.js\";\n\n/**\n * Returns the output path recap\n *\n * @param {string} cwd - The current working directory\n * @param {Patterns} patterns - The patterns to be used for the extraction process\n * @return {string} - The output path recap\n */\nfunction outputPathRecap(cwd: string, patterns: Patterns): string {\n\treturn `\\nScript Path: ${cwd}\\nfor ${patterns.include.join()}\\nignoring patterns: ${patterns.exclude.join()}\\n`;\n}\n\n/**\n * Runs the parser and generates the pot file or the json file based on the command line arguments\n *\n * @param {Args} args - The command line arguments\n * @return {Promise<string>} - A promise that resolves with the generated pot file\n */\nexport async function exec(args: Args): Promise<string> {\n\tif (!args.options?.silent) {\n\t\tconsole.log(\"\uD83D\uDCDD Starting makePot for\", args?.slug);\n\t\tprintStats();\n\t}\n\n\t// audit\n\tif (args.options?.skip.audit) {\n\t\tconsole.log(\"\\nAudit strings...\");\n\t\tconsole.log(\"TODO\");\n\t\t/**\n\t\t * TODO audit strings\n\t\t *\n\t\t * Skips string audit where it tries to find possible mistakes in translatable strings. Useful when running in an automated environment.\n\t\t *\n\t\t **/\n\t\tconsole.log(\"\u2705 Done\");\n\t}\n\n\t/** The pot file header contains the data about the plugin or theme */\n\tconst potHeader = await generateHeader(args);\n\n\t/** We need to find the main file data so that the definitions are extracted from the plugin or theme files */\n\tlet translationsUnion = translationsHeaders(args);\n\n\tif (!args.options?.silent)\n\t\toutputPathRecap(path.resolve(args.paths.cwd), args.patterns);\n\n\t/**\n\t * The progress bar that is used to show the progress of the extraction process.\n\t */\n\tconst progressBar: SingleBar = initProgress(args, 0);\n\n\tprogressBar.start(3, 1, {\n\t\tfilename: `Resolving files in ${path.resolve(args.paths.cwd)}`,\n\t});\n\n\t/**\n\t * Extract the strings from the files\n\t */\n\tconst patterns = getPatterns(args);\n\tconst files = await processFiles(patterns, args);\n\n\tprogressBar.update(2, {\n\t\tfilename: `Found ${files.length} files`,\n\t});\n\n\ttranslationsUnion = await taskRunner(\n\t\tfiles,\n\t\ttranslationsUnion,\n\t\targs,\n\t\tprogressBar,\n\t);\n\n\tif (args.options?.json) {\n\t\t// generate the json file\n\t\tconst jedData: {\n\t\t\t[p: string]: { [p: string]: [string, string] };\n\t\t} = {\n\t\t\t[args.slug]: {\n\t\t\t\t\"\": potHeader,\n\t\t\t\t...(translationsUnion.toJson() as { [p: string]: [string, string] }),\n\t\t\t},\n\t\t};\n\t\tconst i18n = new Tannin(jedData);\n\n\t\treturn i18n.toString();\n\t}\n\n\t// generate the pot file json\n\tconst getTextTranslations: GetTextTranslations = {\n\t\tcharset: getEncodingCharset(args.options?.charset),\n\t\theaders: potHeader as { [headerName: string]: string },\n\t\ttranslations: translationsUnion.toJson(),\n\t};\n\n\t// And then compile the pot file to a string\n\tconst pluginTranslations = po\n\t\t.compile(getTextTranslations)\n\t\t.toString(getCharset(args.options?.charset));\n\n\t// return the pot file as a string, prefixed with the header\n\tconst copyrightComment =\n\t\targs.options?.fileComment ||\n\t\tgetCopyright(\n\t\t\targs.slug,\n\t\t\t(args.headers?.license as string) ?? \"GPL v2 or later\",\n\t\t);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CAAC;IAED,iCAAiC;IACjC,MAAM,mBAAmB,GAAwB;QAChD,OAAO,EAAE,IAAA,0BAAkB,EAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC;QAClD,OAAO,EAAE,SAA6C;QACtD,YAAY,EAAE,iBAAiB,CAAC,MAAM,EAAE;KACxC,CAAC;IAEF,gDAAgD;IAChD,MAAM,kBAAkB,GAAG,mBAAE;SAC3B,OAAO,CAAC,mBAAmB,CAAC;SAC5B,QAAQ,CAAC,IAAA,kBAAU,EAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;IAE9C,gEAAgE;IAChE,MAAM,gBAAgB,GACrB,IAAI,CAAC,OAAO,EAAE,WAAW;QACzB,IAAA,wBAAY,EACX,IAAI,CAAC,OAAO,EAAE,IAAI,IAAI,IAAI,CAAC,IAAI,EAC9B,IAAI,CAAC,OAAO,EAAE,OAAkB,IAAI,iBAAiB,CACtD,CAAC;IACH,OAAO,GAAG,gBAAgB,KAAK,kBAAkB,EAAE,CAAC;AACrD,CAAC"}
@@ -1 +1 @@
1
- "use strict";var N=Object.create;var g=Object.defineProperty;var S=Object.getOwnPropertyDescriptor;var F=Object.getOwnPropertyNames;var w=Object.getPrototypeOf,D=Object.prototype.hasOwnProperty;var T=(i,t)=>{for(var e in t)g(i,e,{get:t[e],enumerable:!0})},v=(i,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of F(t))!D.call(i,s)&&s!==e&&g(i,s,{get:()=>t[s],enumerable:!(n=S(t,s))||n.enumerable});return i};var m=(i,t,e)=>(e=i!=null?N(w(i)):{},v(t||!i||!i.__esModule?g(e,"default",{value:i,enumerable:!0}):e,i)),M=i=>v(g({},"__esModule",{value:!0}),i);var O={};T(O,{MakeJsonCommand:()=>x,default:()=>$});module.exports=M(O);var J=m(require("node:crypto")),d=m(require("node:fs")),r=m(require("node:path")),j=require("gettext-parser"),h=require("glob"),u=require("../const.js"),k=require("../utils/common.js");class x{source;destination;allowedFormats;purge;prettyPrint;debug;scriptName;paths;sourceDir;constructor(t){if(this.sourceDir=r.default.relative(t.paths.cwd,t.source??""),!d.existsSync(this.sourceDir))throw console.error("Source directory not found",t),new Error(`Source directory ${this.sourceDir} not found`);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 n 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 s=this.addPot(n,this.scriptName);e[s.filename]=s.data}else if(Array.isArray(this.scriptName))for(const s of this.scriptName){const o=this.addPot(n,s);e[o.filename]=o.data}for(const[n,s]of Object.entries(e)){let o;if(this.purge)d.existsSync(r.default.join(this.destination,n))&&(console.log(`Removing ${r.default.join(this.destination,n)} as the purge option is enabled`),d.unlinkSync(r.default.join(this.destination,n))),o=JSON.stringify(s,null,this?.prettyPrint?2:0);else{const c=d.readFileSync(r.default.join(this.source,n),"utf8");o=JSON.stringify({...s,...JSON.parse(c)},null,this?.prettyPrint?2:0)}const a=r.default.join(this.destination,n);d.writeFileSync(a,o),console.log(`JSON file written to ${a}`)}return e}processFile(t,e,n="utf8"){const s=r.default.join(this.destination,t),o=d.readFileSync(s,n),a=this.extractIsoCode(s),c=this.parsePoFile(o);return this.convertToJed(c.headers,c.translations,e,a)}parsePoFile(t){return j.po.parse(t)}convertToJed(t,e,n,s){const o=(0,k.getPkgJsonData)(u.modulePath,"name","version"),a="messages",c=`${o.name}/${o.version}`,f={[a]:{"":{domain:a,lang:s||t.Language||"en",plural_forms:t["Plural-Forms"]||"nplurals=2; plural=(n != 1);"}}};for(const l of Object.keys(e)){const y=e[l];for(const p of Object.keys(y)){const P=y[p];if(p==="")continue;const b=l&&l!==""?`${l}${p}`:p;f[a][b]=P.msgstr}}return{"translation-revision-date":new Date().toISOString(),generator:c,source:r.default.join(this.sourceDir,n).replace(/\\/g,"/"),domain:a,locale_data:f}}extractIsoCode(t){const e=t.match(u.IsoCodeRegex);return e?e[1]:void 0}md5(t){return J.default.createHash("md5").update(t).digest("hex")}generateFilename(t,e){const n=this.md5(t);return e.replace(".po",`-${n}.json`)}addPot(t,e){return{filename:this.generateFilename(r.default.join(this.source,e).replace(/\\/g,"/"),t),data:this.processFile(t,e)}}}var $=x;0&&(module.exports={MakeJsonCommand});
1
+ "use strict";var P=Object.create;var g=Object.defineProperty;var w=Object.getOwnPropertyDescriptor;var N=Object.getOwnPropertyNames;var M=Object.getPrototypeOf,$=Object.prototype.hasOwnProperty;var D=(o,t)=>{for(var e in t)g(o,e,{get:t[e],enumerable:!0})},v=(o,t,e,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of N(t))!$.call(o,i)&&i!==e&&g(o,i,{get:()=>t[i],enumerable:!(s=w(t,i))||s.enumerable});return o};var m=(o,t,e)=>(e=o!=null?P(M(o)):{},v(t||!o||!o.__esModule?g(e,"default",{value:o,enumerable:!0}):e,o)),C=o=>v(g({},"__esModule",{value:!0}),o);var G={};D(G,{MakeJsonCommand:()=>F,default:()=>I});module.exports=C(G);var S=m(require("node:crypto")),c=m(require("node:fs")),a=m(require("node:path")),x=require("@babel/core"),k=require("gettext-parser"),h=require("glob"),d=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){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"&&(this.scriptName=[this.scriptName]);for(const i of this.scriptName){const n=this.addPot(s,i);n.data?e[n.filename]=n.data:console.log(`\u274C Translation strings not found in Script ${i} in ${s} po file`)}}for(const[s,i]of Object.entries(e)){let n;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))),n=JSON.stringify(i,null,this?.prettyPrint?2:0);else{const l=c.readFileSync(a.default.join(this.source,s),"utf8");n=JSON.stringify({...i,...JSON.parse(l)},null,this?.prettyPrint?2:0)}const r=a.default.join(this.destination,s);c.writeFileSync(r,n),console.log(`\u2705 JSON file written to ${r} with ${s}`)}return e}processFile(t,e,s="utf8"){const i=a.default.join(this.destination,t),n=c.readFileSync(i,s),r=this.parsePoFile(n);if(this.stripUnused){const l=this.parseScript(e);if(!l)return null;const p=this.compareStrings(l.blocks,r);if(!p)return null;r.translations=p.translations}return this.convertToJed(r.headers,r.translations,e,this.extractIsoCode(i))}parsePoFile(t){return k.po.parse(t)}convertToJed(t,e,s,i){const n=(0,J.getPkgJsonData)(d.modulePath,"name","version"),r="messages",l=`${n.name}/${n.version}`,p={[r]:{"":{domain:r,lang:i||t.Language||"en",plural_forms:t["Plural-Forms"]||"nplurals=2; plural=(n != 1);"}}};for(const u of Object.keys(e)){const y=e[u];for(const f of Object.keys(y)){const b=y[f];if(f==="")continue;const j=u&&u!==""?`${u}${f}`:f;p[r][j]=b.msgstr}}return{"translation-revision-date":new Date().toISOString(),generator:l,source:a.default.join(this.sourceDir,s).replace(/\\/g,"/"),domain:r,locale_data:p}}extractIsoCode(t){const e=t.match(d.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 i=new Set(t.map(n=>n.msgid));for(const n in e.translations)if(n==="")for(const r in e.translations[n])r!==""&&i.has(r)&&(s.translations[n]||(s.translations[n]={}),s.translations[n][r]={...e.translations[n][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:i})=>({visitor:{CallExpression(n){const r=n.node.callee;if(i.isSequenceExpression(r)&&i.isMemberExpression(r.expressions[1])){const l=r.expressions[1].property;i.isIdentifier(l)&&d.allowedFunctions.has(l.name)&&(n.node.callee=i.identifier(l.name))}}}})]}).code;return(0,T.doTree)(s,t,this.debug)}}var I=F;0&&(module.exports={MakeJsonCommand});
@@ -1,7 +1 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/parser/makeJson.ts"],
4
- "sourcesContent": ["import crypto from \"node:crypto\";\nimport * as fs from \"node:fs\";\nimport path from \"node:path\";\nimport {\n\ttype GetTextTranslation,\n\ttype GetTextTranslations,\n\tpo,\n} from \"gettext-parser\";\nimport { glob } from \"glob\";\nimport { IsoCodeRegex, modulePath } from \"../const.js\";\nimport type { JedData, MakeJson, MakeJsonArgs } from \"../types.js\";\nimport { getPkgJsonData } from \"../utils/common.js\";\n\nexport class MakeJsonCommand {\n\t/**\n\t * The source file path.\n\t * Should be the \"build\" directory containing .js files\n\t * @private\n\t */\n\tprivate readonly source: string;\n\t/**\n\t * The destination file path.\n\t * Should be the \"languages\" directory containing .po files\n\t * @private\n\t */\n\tprivate readonly destination: string;\n\t/**\n\t * The allowed file extensions.\n\t * @private\n\t */\n\tprivate readonly allowedFormats: string[];\n\t/**\n\t * Remove old POT files.\n\t * @private\n\t */\n\tprivate readonly purge: boolean;\n\t/**\n\t * Pretty print JSON.\n\t * @private\n\t */\n\tprivate readonly prettyPrint: boolean;\n\t/**\n\t * Enable debug mode.\n\t * @private\n\t */\n\tprivate debug: boolean;\n\t/**\n\t * The script to be translated.\n\t * @private\n\t */\n\tprivate scriptName: string | string[] | undefined;\n\t/**\n\t * The paths to be translated.\n\t * @private\n\t */\n\tprivate paths: object | undefined;\n\t/**\n\t * The source directory.\n\t * @private\n\t */\n\tprivate readonly sourceDir: string;\n\n\t/**\n\t * The constructor.\n\t * @param args - The arguments to the command.\n\t */\n\tpublic constructor(args: MakeJsonArgs) {\n\t\tthis.sourceDir = path.relative(args.paths.cwd, args.source ?? \"\");\n\t\tif (!fs.existsSync(this.sourceDir)) {\n\t\t\tconsole.error(\"Source directory not found\", args);\n\t\t\tthrow new Error(`Source directory ${this.sourceDir} not found`);\n\t\t}\n\n\t\tthis.scriptName = args.scriptName;\n\t\tthis.source = args.source;\n\t\tthis.destination = args.destination;\n\t\tthis.allowedFormats = args.allowedFormats ?? [\n\t\t\t\".ts\",\n\t\t\t\".tsx\",\n\t\t\t\".js\",\n\t\t\t\".jsx\",\n\t\t\t\".mjs\",\n\t\t\t\".cjs\",\n\t\t];\n\t\tthis.purge = args.purge;\n\t\tthis.prettyPrint = args.prettyPrint;\n\t\tthis.debug = args.debug;\n\t\tthis.paths = args.paths;\n\t}\n\n\t/**\n\t * The main function. Parses the PO files and generates the JSON files.\n\t */\n\tpublic async exec(): Promise<Record<string, MakeJson>> {\n\t\t// get all the files in the source directory\n\t\tconst files = await glob(\"**/*.po\", { cwd: this.destination, nodir: true });\n\n\t\tconsole.log(\"Found po files\", files, \"in\", this.destination, \"folder\");\n\n\t\t// get all the po files\n\t\tconst output: Record<string, MakeJson> = {};\n\t\tfor (const file of files) {\n\t\t\tif (!this.scriptName) {\n\t\t\t\tthis.scriptName = await glob(\"*.js\", {\n\t\t\t\t\tcwd: this.source,\n\t\t\t\t\tnodir: true,\n\t\t\t\t});\n\t\t\t\tconsole.log(\n\t\t\t\t\t`Found script: ${this.scriptName} in ${this.source} folder`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// TODO: tree the script to get the translations used in there, then use reduce to filter the translations\n\n\t\t\tif (typeof this.scriptName === \"string\") {\n\t\t\t\tconst pot = this.addPot(file, this.scriptName);\n\t\t\t\toutput[pot.filename] = pot.data;\n\t\t\t} else if (Array.isArray(this.scriptName)) {\n\t\t\t\tfor (const script of this.scriptName) {\n\t\t\t\t\tconst pot = this.addPot(file, script);\n\t\t\t\t\toutput[pot.filename] = pot.data;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// write the json files\n\t\tfor (const [filename, content] of Object.entries(output)) {\n\t\t\tlet contentString: string;\n\t\t\tif (this.purge) {\n\t\t\t\tif (fs.existsSync(path.join(this.destination, filename))) {\n\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t`Removing ${path.join(this.destination, filename)} as the purge option is enabled`,\n\t\t\t\t\t);\n\t\t\t\t\tfs.unlinkSync(path.join(this.destination, filename));\n\t\t\t\t}\n\t\t\t\tcontentString = JSON.stringify(\n\t\t\t\t\tcontent,\n\t\t\t\t\tnull,\n\t\t\t\t\tthis?.prettyPrint ? 2 : 0,\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tconst oldJedContent = fs.readFileSync(\n\t\t\t\t\tpath.join(this.source, filename),\n\t\t\t\t\t\"utf8\",\n\t\t\t\t);\n\n\t\t\t\tcontentString = JSON.stringify(\n\t\t\t\t\t{ ...content, ...JSON.parse(oldJedContent) },\n\t\t\t\t\tnull,\n\t\t\t\t\tthis?.prettyPrint ? 2 : 0,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst destinationPath = path.join(this.destination, filename);\n\t\t\tfs.writeFileSync(destinationPath, contentString);\n\t\t\tconsole.log(`JSON file written to ${destinationPath}`);\n\t\t}\n\n\t\t// return the output\n\t\treturn output;\n\t}\n\n\t/**\n\t * Process a PO file and return the JSON data.\n\t * @param file - The path to the PO file.\n\t * @param script - The script to be translated.\n\t * @param encoding - The encoding of the PO file.\n\t */\n\tpublic processFile(\n\t\tfile: string,\n\t\tscript: string,\n\t\tencoding: BufferEncoding = \"utf8\",\n\t): MakeJson {\n\t\t// Get the file path\n\t\tconst filePath = path.join(this.destination, file);\n\n\t\t// Read the source file\n\t\tconst content = fs.readFileSync(filePath, encoding) as string;\n\n\t\t// Extract the ISO code\n\t\tconst languageIsoCode = this.extractIsoCode(filePath);\n\n\t\t// Parse the source file\n\t\tconst poContent = this.parsePoFile(content);\n\n\t\t// Convert to Jed json dataset\n\t\treturn this.convertToJed(\n\t\t\tpoContent.headers,\n\t\t\tpoContent.translations,\n\t\t\tscript,\n\t\t\tlanguageIsoCode,\n\t\t);\n\t}\n\n\t/**\n\t * Takes a PO file and returns the header and translations.\n\t * @param content - The content of the PO file.\n\t * @private\n\t *\n\t * @returns An object containing the header and translations.\n\t */\n\tprivate parsePoFile(content: string): GetTextTranslations {\n\t\treturn po.parse(content);\n\t}\n\n\t/**\n\t * Converts PO data to Jed data.\n\t * @param header - The header of the PO file.\n\t * @param translations - The translations of the PO file.\n\t * @param source - The source of the PO file.\n\t * @param languageIsoCode - The ISO code of the language.\n\t * @private\n\t *\n\t * @return An object containing the Jed data.\n\t */\n\tprivate convertToJed(\n\t\theader: Record<string, string>,\n\t\ttranslations: {\n\t\t\t[msgctxt: string]: { [msgId: string]: GetTextTranslation };\n\t\t},\n\t\tsource: string,\n\t\tlanguageIsoCode?: string,\n\t): MakeJson {\n\t\tconst packageJson = getPkgJsonData(modulePath, \"name\", \"version\") as {\n\t\t\tname: string;\n\t\t\tversion: string;\n\t\t};\n\n\t\t// Domain name to use for the Jed format\n\t\tconst domain = \"messages\";\n\n\t\tconst generator = `${packageJson.name}/${packageJson.version}`;\n\n\t\t// Initialize the Jed-compatible structure\n\t\tconst jedData: JedData = {\n\t\t\t[domain]: {\n\t\t\t\t\"\": {\n\t\t\t\t\tdomain: domain,\n\t\t\t\t\tlang: languageIsoCode || header.Language || \"en\",\n\t\t\t\t\tplural_forms:\n\t\t\t\t\t\theader[\"Plural-Forms\"] || \"nplurals=2; plural=(n != 1);\",\n\t\t\t\t},\n\t\t\t},\n\t\t};\n\n\t\t// Process all translations\n\t\tfor (const msgctxt of Object.keys(translations)) {\n\t\t\tconst contextTranslations = translations[msgctxt];\n\n\t\t\tfor (const msgid of Object.keys(contextTranslations)) {\n\t\t\t\tconst translation = contextTranslations[msgid];\n\n\t\t\t\t// Skip empty msgid (header) as we've already handled it\n\t\t\t\tif (msgid === \"\") continue;\n\n\t\t\t\t// Construct the key using context if available\n\t\t\t\tconst key =\n\t\t\t\t\tmsgctxt && msgctxt !== \"\" ? `${msgctxt}\\u0004${msgid}` : msgid;\n\n\t\t\t\t// Add the translation to the Jed data structure\n\t\t\t\tjedData[domain][key] = translation.msgstr;\n\t\t\t}\n\t\t}\n\n\t\tconst makeJson: {\n\t\t\tdomain: string;\n\t\t\tgenerator: string;\n\t\t\t\"translation-revision-date\": string;\n\t\t\tsource: string;\n\t\t\tlocale_data: JedData;\n\t\t} = {\n\t\t\t\"translation-revision-date\": new Date().toISOString(),\n\t\t\tgenerator: generator,\n\t\t\tsource: path.join(this.sourceDir, source).replace(/\\\\/g, \"/\"),\n\t\t\tdomain,\n\t\t\tlocale_data: jedData,\n\t\t};\n\n\t\treturn makeJson as MakeJson;\n\t}\n\n\t/**\n\t * Gets the ISO code from the filename.\n\t * @param filename The filename to extract the ISO code from.\n\t * @private\n\t *\n\t * @returns The ISO code if found, otherwise null.\n\t */\n\tprivate extractIsoCode(filename: string): string | undefined {\n\t\tconst match = filename.match(IsoCodeRegex);\n\t\treturn match ? match[1] : undefined;\n\t}\n\n\tprivate md5(text: string): string {\n\t\treturn crypto.createHash(\"md5\").update(text).digest(\"hex\");\n\t}\n\n\tprivate generateFilename(script: string, file: string): string {\n\t\tconst scriptName = this.md5(script);\n\t\t//build the filename for the json file using the po files\n\t\treturn file.replace(\".po\", `-${scriptName}.json`);\n\t}\n\n\t/**\n\t * Adds a script to the output object.\n\t * @private\n\t *\n\t * @param potFile - The pot file to parse.\n\t * @param script - The script to add.\n\t * @return {Record<string, JedData>} - The output object.\n\t * */\n\tprivate addPot(\n\t\tpotFile: string,\n\t\tscript: string,\n\t): { filename: string; data: MakeJson } {\n\t\tconst filename = this.generateFilename(\n\t\t\tpath.join(this.source, script).replace(/\\\\/g, \"/\"),\n\t\t\tpotFile,\n\t\t);\n\t\t// build the output object\n\t\treturn {\n\t\t\tfilename,\n\t\t\tdata: this.processFile(potFile, script),\n\t\t};\n\t}\n}\n\nexport default MakeJsonCommand;\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yBAAmB;AACnB,SAAoB;AACpB,uBAAiB;AACjB,4BAIO;AACP,kBAAqB;AACrB,mBAAyC;AAEzC,oBAA+B;AAExB,MAAM,gBAAgB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMX;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA;AAAA;AAAA;AAAA;AAAA;AAAA,EAKA;AAAA;AAAA;AAAA;AAAA;AAAA,EAKA;AAAA;AAAA;AAAA;AAAA;AAAA,EAKA;AAAA;AAAA;AAAA;AAAA;AAAA,EAKT;AAAA;AAAA;AAAA;AAAA;AAAA,EAKA;AAAA;AAAA;AAAA;AAAA;AAAA,EAKA;AAAA;AAAA;AAAA;AAAA;AAAA,EAKS;AAAA;AAAA;AAAA;AAAA;AAAA,EAMV,YAAY,MAAoB;AACtC,SAAK,YAAY,iBAAAA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AAsB;AACjC,WAAO,mBAAAC,QAAO,WAAW,KAAK,EAAE,OAAO,IAAI,EAAE,OAAO,KAAK;AAAA,EAC1D;AAAA,EAEQ,iBAAiB,QAAgB,MAAsB;AAC9D,UAAM,aAAa,KAAK,IAAI,MAAM;AAElC,WAAO,KAAK,QAAQ,OAAO,IAAI,UAAU,OAAO;AAAA,EACjD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUQ,OACP,SACA,QACuC;AACvC,UAAM,WAAW,KAAK;AAAA,MACrB,iBAAAD,QAAK,KAAK,KAAK,QAAQ,MAAM,EAAE,QAAQ,OAAO,GAAG;AAAA,MACjD;AAAA,IACD;AAEA,WAAO;AAAA,MACN;AAAA,MACA,MAAM,KAAK,YAAY,SAAS,MAAM;AAAA,IACvC;AAAA,EACD;AACD;AAEA,IAAO,mBAAQ;",
6
- "names": ["path", "crypto"]
7
- }
1
+ {"version":3,"file":"makeJson.js","sourceRoot":"","sources":["../../src/parser/makeJson.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8DAAiC;AACjC,4CAA8B;AAC9B,0DAA6B;AAC7B,sCAA4C;AAE5C,mDAIwB;AACxB,+BAA4B;AAC5B,0CAAyE;AAEzE,kDAAoD;AACpD,iCAAgC;AAEhC,MAAa,eAAe;IAC3B;;;;OAIG;IACc,MAAM,CAAS;IAChC;;;;OAIG;IACc,WAAW,CAAS;IACrC;;;OAGG;IACc,cAAc,CAAW;IAC1C;;;OAGG;IACc,KAAK,CAAU;IAChC;;;OAGG;IACc,WAAW,CAAU;IACtC;;;OAGG;IACK,KAAK,CAAU;IACvB;;;OAGG;IACK,UAAU,CAAgC;IAClD;;;OAGG;IACK,KAAK,CAAqB;IAClC;;;OAGG;IACc,SAAS,CAAS;IACnC;;;OAGG;IACK,WAAW,CAAU;IAE7B;;;OAGG;IACH,YAAmB,IAAkB;QACpC,IAAI,CAAC,SAAS,GAAG,mB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s=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var h=Object.prototype.hasOwnProperty;var d=(t,e)=>{for(var o in e)m(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&&m(t,a,{get:()=>e[a],enumerable:!(r=s(e,a))||r.enumerable});return t};var x=t=>u(m({},"__esModule",{value:!0}),t);var y={};d(y,{makePot:()=>k});module.exports=x(y);var i=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,i.extractMainFileData)(t);return t.headers={...t.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});
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});
@@ -1,7 +1 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/parser/makePot.ts"],
4
- "sourcesContent": ["import { extractMainFileData } from \"../extractors/headers.js\";\nimport { extractPackageJson } from \"../extractors/packageJson.js\";\nimport { writeFile } from \"../fs/fs.js\";\nimport type { Args } from \"../types.js\";\nimport { exec } from \"./exec.js\";\n\n/**\n * Generates a pot file for localization.\n *\n * @param args - the command line arguments\n * @return {string} - a promise that resolves when the pot file is generated\n */\nexport async function makePot(args: Args): Promise<string> {\n\t/** Collect metadata from the get package json */\n\tconst pkgData = extractPackageJson(args);\n\n\t/** Get metadata from the main file (theme and plugin) */\n\tconst metadata = extractMainFileData(args);\n\n\t/** Merge the metadata to get a single object with all the headers */\n\targs.headers = {\n\t\t...args.headers,\n\t\t...pkgData,\n\t\t...metadata,\n\t} as Args[\"headers\"];\n\n\t/** Generate the pot file */\n\treturn await exec(args)\n\t\t.then((jsonTranslations) => {\n\t\t\twriteFile(jsonTranslations, args);\n\n\t\t\treturn jsonTranslations;\n\t\t})\n\t\t.catch((error) => {\n\t\t\tconsole.error(error);\n\n\t\t\treturn \"\";\n\t\t});\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAAoC;AACpC,yBAAmC;AACnC,gBAA0B;AAE1B,kBAAqB;AAQrB,eAAsB,QAAQ,MAA6B;AAE1D,QAAM,cAAU,uCAAmB,IAAI;AAGvC,QAAM,eAAW,oCAAoB,IAAI;AAGzC,OAAK,UAAU;AAAA,IACd,GAAG,KAAK;AAAA,IACR,GAAG;AAAA,IACH,GAAG;AAAA,EACJ;AAGA,SAAO,UAAM,kBAAK,IAAI,EACpB,KAAK,CAAC,qBAAqB;AAC3B,6BAAU,kBAAkB,IAAI;AAEhC,WAAO;AAAA,EACR,CAAC,EACA,MAAM,CAAC,UAAU;AACjB,YAAQ,MAAM,KAAK;AAEnB,WAAO;AAAA,EACR,CAAC;AACH;",
6
- "names": []
7
- }
1
+ {"version":3,"file":"makePot.js","sourceRoot":"","sources":["../../src/parser/makePot.ts"],"names":[],"mappings":";;AAYA,0BA0BC;AAtCD,yDAA+D;AAC/D,iEAAkE;AAClE,uCAAwC;AAExC,uCAAiC;AAEjC;;;;;GAKG;AACI,KAAK,UAAU,OAAO,CAAC,IAAU;IACvC,iDAAiD;IACjD,MAAM,OAAO,GAAG,IAAA,mCAAkB,EAAC,IAAI,CAAC,CAAC;IAEzC,yDAAyD;IACzD,MAAM,QAAQ,GAAG,IAAA,gCAAmB,EAAC,IAAI,CAAC,CAAC;IAE3C,qEAAqE;IACrE,IAAI,CAAC,OAAO,GAAG;QACd,GAAG,IAAI,EAAE,OAAO,EAAE,OAAO;QACzB,GAAG,OAAO;QACV,GAAG,QAAQ;KACQ,CAAC;IAErB,4BAA4B;IAC5B,OAAO,MAAM,IAAA,cAAI,EAAC,IAAI,CAAC;SACrB,IAAI,CAAC,CAAC,gBAAgB,EAAE,EAAE;QAC1B,IAAA,iBAAS,EAAC,gBAAgB,EAAE,IAAI,CAAC,CAAC;QAElC,OAAO,gBAAgB,CAAC;IACzB,CAAC,CAAC;SACD,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;QAChB,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAErB,OAAO,EAAE,CAAC;IACX,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -1 +1 @@
1
- "use strict";var n=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var u=Object.getOwnPropertyNames;var c=Object.prototype.hasOwnProperty;var h=(t,e)=>{for(var p in e)n(t,p,{get:e[p],enumerable:!0})},l=(t,e,p,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of u(e))!c.call(t,s)&&s!==p&&n(t,s,{get:()=>e[s],enumerable:!(o=i(e,s))||o.enumerable});return t};var d=t=>l(n({},"__esModule",{value:!0}),t);var a={};h(a,{getPatterns:()=>r});module.exports=d(a);function r(t){const e={include:t.patterns.include||[],exclude:t.patterns.exclude||[],mergePaths:t.patterns.mergePaths,subtractPaths:t.patterns.subtractPaths,subtractAndMerge:t.patterns.subtractAndMerge};return t.options&&(t.options.skip.blade?e.exclude.push("**/blade.php"):t.options.skip.php&&e.exclude.push("**/*.php","**/*.blade.php"),t.options.skip.js&&e.exclude.push("**/*.{js,jsx,ts,tsx,mjs,cjs}"),t.options.skip.blockJson&&e.exclude.push("block.json"),t.options.skip.themeJson&&e.exclude.push("theme.json")),e}0&&(module.exports={getPatterns});
1
+ "use strict";var n=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var u=Object.getOwnPropertyNames;var c=Object.prototype.hasOwnProperty;var h=(t,e)=>{for(var p in e)n(t,p,{get:e[p],enumerable:!0})},l=(t,e,p,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of u(e))!c.call(t,s)&&s!==p&&n(t,s,{get:()=>e[s],enumerable:!(o=i(e,s))||o.enumerable});return t};var d=t=>l(n({},"__esModule",{value:!0}),t);var a={};h(a,{getPatterns:()=>r});module.exports=d(a);function r(t){const e={include:t.patterns.include||[],exclude:t.patterns.exclude||[],mergePaths:t.patterns.mergePaths,subtractPaths:t.patterns.subtractPaths,subtractAndMerge:t.patterns.subtractAndMerge};return t.options&&(t.options.skip.blade?e.exclude.push("**/*.blade.php"):t.options.skip.php&&e.exclude.push("**/*.php","**/*.blade.php"),t.options.skip.js&&e.exclude.push("**/*.{js,jsx,ts,tsx,mjs,cjs}"),t.options.skip.blockJson&&e.exclude.push("block.json"),t.options.skip.themeJson&&e.exclude.push("theme.json")),e}0&&(module.exports={getPatterns});
@@ -1,7 +1 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/parser/patterns.ts"],
4
- "sourcesContent": ["import type { Args, Patterns } from \"../types.js\";\n\n/**\n * Returns the patterns based on the given arguments.\n *\n * @param args - The arguments for the extract process.\n */\nexport function getPatterns(args: Args) {\n\tconst pattern = {\n\t\tinclude: args.patterns.include || [],\n\t\texclude: args.patterns.exclude || [],\n\t\tmergePaths: args.patterns.mergePaths,\n\t\tsubtractPaths: args.patterns.subtractPaths,\n\t\tsubtractAndMerge: args.patterns.subtractAndMerge,\n\t} as Patterns;\n\n\t// Additional logic to handle different file types and formats\n\tif (args.options) {\n\t\t// js typescript mjs cjs etc\n\t\tif (args.options.skip.blade) {\n\t\t\tpattern.exclude.push(\"**/blade.php\");\n\t\t} else if (args.options.skip.php) {\n\t\t\tpattern.exclude.push(\"**/*.php\", \"**/*.blade.php\");\n\t\t}\n\n\t\t// js typescript mjs cjs etc\n\t\tif (args.options.skip.js) {\n\t\t\tpattern.exclude.push(\"**/*.{js,jsx,ts,tsx,mjs,cjs}\");\n\t\t}\n\n\t\tif (args.options.skip.blockJson) {\n\t\t\tpattern.exclude.push(\"block.json\");\n\t\t}\n\n\t\tif (args.options.skip.themeJson) {\n\t\t\tpattern.exclude.push(\"theme.json\");\n\t\t}\n\t}\n\n\treturn pattern;\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAOO,SAAS,YAAY,MAAY;AACvC,QAAM,UAAU;AAAA,IACf,SAAS,KAAK,SAAS,WAAW,CAAC;AAAA,IACnC,SAAS,KAAK,SAAS,WAAW,CAAC;AAAA,IACnC,YAAY,KAAK,SAAS;AAAA,IAC1B,eAAe,KAAK,SAAS;AAAA,IAC7B,kBAAkB,KAAK,SAAS;AAAA,EACjC;AAGA,MAAI,KAAK,SAAS;AAEjB,QAAI,KAAK,QAAQ,KAAK,OAAO;AAC5B,cAAQ,QAAQ,KAAK,cAAc;AAAA,IACpC,WAAW,KAAK,QAAQ,KAAK,KAAK;AACjC,cAAQ,QAAQ,KAAK,YAAY,gBAAgB;AAAA,IAClD;AAGA,QAAI,KAAK,QAAQ,KAAK,IAAI;AACzB,cAAQ,QAAQ,KAAK,8BAA8B;AAAA,IACpD;AAEA,QAAI,KAAK,QAAQ,KAAK,WAAW;AAChC,cAAQ,QAAQ,KAAK,YAAY;AAAA,IAClC;AAEA,QAAI,KAAK,QAAQ,KAAK,WAAW;AAChC,cAAQ,QAAQ,KAAK,YAAY;AAAA,IAClC;AAAA,EACD;AAEA,SAAO;AACR;",
6
- "names": []
7
- }
1
+ {"version":3,"file":"patterns.js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IAED,OAAO,OAAO,CAAC;AAChB,CAAC"}
@@ -1 +1 @@
1
- "use strict";var S=Object.create;var m=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var g=Object.getOwnPropertyNames;var j=Object.getPrototypeOf,w=Object.prototype.hasOwnProperty;var x=(e,t)=>{for(var o in t)m(e,o,{get:t[o],enumerable:!0})},h=(e,t,o,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of g(t))!w.call(e,s)&&s!==o&&m(e,s,{get:()=>t[s],enumerable:!(r=b(t,s))||r.enumerable});return e};var F=(e,t,o)=>(o=e!=null?S(j(e)):{},h(t||!e||!e.__esModule?m(o,"default",{value:e,enumerable:!0}):o,e)),O=e=>h(m({},"__esModule",{value:!0}),e);var v={};x(v,{processFiles:()=>A});module.exports=O(v);var n=F(require("node:path")),d=require("../const.js"),u=require("../extractors/json.js"),a=require("../fs/fs.js"),k=require("../fs/glob.js"),y=require("./tree.js");async function A(e,t,o){const r=[];let s=0;const c=(0,k.getFiles)(t,e);for await(const i of c){s++;const l=n.default.basename(i),P=n.default.extname(i).replace(/^./,""),p=n.default.resolve(t.paths.cwd,i);l==="theme.json"||l==="block.json"?r.push((0,a.readFileAsync)(p).then(f=>(0,u.parseJsonCallback)(f,t.paths.cwd,l))):d.allowedFormats.includes(P)&&r.push((0,a.readFileAsync)(p).then(f=>(0,y.doTree)(f,i))),o&&(o.update(s,{filename:l}),o.setTotal(Object.values(c).length),o.render())}return r}0&&(module.exports={processFiles});
1
+ "use strict";var F=Object.create;var f=Object.defineProperty;var O=Object.getOwnPropertyDescriptor;var S=Object.getOwnPropertyNames;var j=Object.getPrototypeOf,w=Object.prototype.hasOwnProperty;var x=(e,t)=>{for(var o in t)f(e,o,{get:t[o],enumerable:!0})},d=(e,t,o,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of S(t))!w.call(e,s)&&s!==o&&f(e,s,{get:()=>t[s],enumerable:!(i=O(t,s))||i.enumerable});return e};var g=(e,t,o)=>(o=e!=null?F(j(e)):{},d(t||!e||!e.__esModule?f(o,"default",{value:e,enumerable:!0}):o,e)),v=e=>d(f({},"__esModule",{value:!0}),e);var T={};x(T,{processFiles:()=>A});module.exports=v(T);var r=g(require("node:path")),u=require("../const.js"),h=require("../extractors/json.js"),a=require("../fs/fs.js"),k=require("../fs/glob.js"),P=require("./tree.js");async function A(e,t,o){const i=[];let s=0;const c=(0,k.getFiles)(t,e);o&&(o.setTotal(Object.values(c).length),o.update(0,{filename:`Found ${Object.values(c).length} files`}));for await(const l of c){s++;const n=r.default.basename(l),b=r.default.extname(l).replace(/^./,""),p=r.default.resolve(t.paths.cwd,l);if(n==="theme.json"||n==="block.json")i.push((0,a.readFileAsync)(p).then(m=>(0,h.parseJsonCallback)(m,t.paths.cwd,n)));else if(u.allowedFormats.includes(b)){const m=(0,a.readFileAsync)(p).then(y=>(0,P.doTree)(y,l,t.debug));m&&i.push(m)}o&&(o.update(s,{filename:n}),o.render())}return i}0&&(module.exports={processFiles});
@@ -1,7 +1 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/parser/process.ts"],
4
- "sourcesContent": ["import path from \"node:path\";\nimport type { SingleBar } from \"cli-progress\";\nimport type { SetOfBlocks } from \"gettext-merger\";\nimport { allowedFormats } from \"../const.js\";\nimport { parseJsonCallback } from \"../extractors/json.js\";\nimport { readFileAsync } from \"../fs/fs.js\";\nimport { getFiles } from \"../fs/glob.js\";\nimport type { Args, Patterns } from \"../types.js\";\nimport { doTree } from \"./tree.js\";\n\n/**\n * Processes the given files and returns an array of promises that resolve to TranslationStrings.\n *\n * @param patterns\n * @param {Args} args - The arguments for processing the files.\n * @param progressBar - The progress bar element.\n * @return {Promise<SetOfBlocks[]>} - An array of promises that resolve to TranslationStrings.\n */\nexport async function processFiles(\n\tpatterns: Patterns,\n\targs: Args,\n\tprogressBar?: SingleBar,\n): Promise<Promise<SetOfBlocks>[]> {\n\tconst tasks: Promise<SetOfBlocks>[] = [];\n\tlet filesCount = 0;\n\n\tconst files = getFiles(args, patterns);\n\n\t// loop through the files and parse them\n\tfor await (const file of files) {\n\t\tfilesCount++;\n\t\tconst filename = path.basename(file);\n\t\tconst ext = path.extname(file).replace(/^./, \"\");\n\t\tconst fileRealPath = path.resolve(args.paths.cwd, file);\n\n\t\tif (filename === \"theme.json\" || filename === \"block.json\") {\n\t\t\ttasks.push(\n\t\t\t\treadFileAsync(fileRealPath).then((sourceCode) =>\n\t\t\t\t\tparseJsonCallback(sourceCode, args.paths.cwd, filename),\n\t\t\t\t),\n\t\t\t);\n\t\t} else if (allowedFormats.includes(ext)) {\n\t\t\ttasks.push(\n\t\t\t\treadFileAsync(fileRealPath).then((content) => doTree(content, file)),\n\t\t\t);\n\t\t}\n\n\t\tif (progressBar) {\n\t\t\tprogressBar.update(filesCount, { filename: filename });\n\t\t\tprogressBar.setTotal(Object.values(files).length);\n\t\t\tprogressBar.render();\n\t\t}\n\t}\n\n\treturn tasks;\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAAiB;AAGjB,mBAA+B;AAC/B,kBAAkC;AAClC,gBAA8B;AAC9B,kBAAyB;AAEzB,kBAAuB;AAUvB,eAAsB,aACrB,UACA,MACA,aACkC;AAClC,QAAM,QAAgC,CAAC;AACvC,MAAI,aAAa;AAEjB,QAAM,YAAQ,sBAAS,MAAM,QAAQ;AAGrC,mBAAiB,QAAQ,OAAO;AAC/B;AACA,UAAM,WAAW,iBAAAA,QAAK,SAAS,IAAI;AACnC,UAAM,MAAM,iBAAAA,QAAK,QAAQ,IAAI,EAAE,QAAQ,MAAM,EAAE;AAC/C,UAAM,eAAe,iBAAAA,QAAK,QAAQ,KAAK,MAAM,KAAK,IAAI;AAEtD,QAAI,aAAa,gBAAgB,aAAa,cAAc;AAC3D,YAAM;AAAA,YACL,yBAAc,YAAY,EAAE;AAAA,UAAK,CAAC,mBACjC,+BAAkB,YAAY,KAAK,MAAM,KAAK,QA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QACrC,MAAM,GAAG,GAAG,mBAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QACjD,MAAM,YAAY,GAAG,mBAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QAExD,IAAI,QAAQ,KAAK,YAAY,IAAI,QAAQ,KAAK,YAAY,EAAE,CAAC;YAC5D,KAAK,CAAC,IAAI,CACT,IAAA,qBAAa,EAAC,YAAY,CAAC,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,EAAE,CAC/C,IAAA,2BAAiB,EAAC,UAAU,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,QAAQ,CAAC,CACvD,CACD,CAAC;QACH,CAAC;aAAM,IAAI,yBAAc,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;YACzC,MAAM,QAAQ,GAAG,IAAA,qBAAa,EAAC,YAAY,CAAC,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAC7D,IAAA,gBAAM,EAAC,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,CACjC,CAAC;YACF,IAAI,QAAQ,EAAE,CAAC;gBACd,KAAK,CAAC,IAAI,CAAC,QAAgC,CAAC,CAAC;YAC9C,CAAC;QACF,CAAC;QAED,IAAI,WAAW,EAAE,CAAC;YACjB,WAAW,CAAC,MAAM,CAAC,mBAAmB,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC,CAAC;YAChE,WAAW,CAAC,MAAM,EAAE,CAAC;QACtB,CAAC;IACF,CAAC;IAED,OAAO,KAAK,CAAC;AACd,CAAC"}
@@ -1,7 +1 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/parser/progress.ts"],
4
- "sourcesContent": ["import cliProgress, { type SingleBar } from \"cli-progress\";\nimport type { Args } from \"../types.js\";\n\n/**\n * Initializes a progress bar and returns the progress bar element.\n *\n * @param {Args} args - The argument object containing the source directory and other options.\n * @param {number} filesCount - An array of file names.\n * @return {cliProgress.SingleBar} The progress bar element.\n */\nexport function initProgress(args: Args, filesCount: number): SingleBar {\n\t// Set up the progress bar\n\treturn new cliProgress.SingleBar(\n\t\t{\n\t\t\tclearOnComplete: true,\n\t\t\tetaBuffer: 1000,\n\t\t\thideCursor: true,\n\t\t\tformat:\n\t\t\t\t\" {bar} {percentage}% | ETA: {eta}s | {filename} | {value}/{total}\",\n\t\t},\n\t\tcliProgress.Presets.shades_classic,\n\t);\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAA4C;AAUrC,SAAS,aAAa,MAAY,YAA+B;AAEvE,SAAO,IAAI,oBAAAA,QAAY;AAAA,IACtB;AAAA,MACC,iBAAiB;AAAA,MACjB,WAAW;AAAA,MACX,YAAY;AAAA,MACZ,QACC;AAAA,IACF;AAAA,IACA,oBAAAA,QAAY,QAAQ;AAAA,EACrB;AACD;",
6
- "names": ["cliProgress"]
7
- }
1
+ {"version":3,"file":"progress.js","sourceRoot":"","sources":["../../src/parser/progress.ts"],"names":[],"mappings":";;;;;AAUA,oCAYC;AAtBD,gEAA2D;AAG3D;;;;;;GAMG;AACH,SAAgB,YAAY,CAAC,IAAU,EAAE,UAAkB;IAC1D,0BAA0B;IAC1B,OAAO,IAAI,sBAAW,CAAC,SAAS,CAC/B;QACC,eAAe,EAAE,IAAI;QACrB,SAAS,EAAE,IAAI;QACf,UAAU,EAAE,IAAI;QAChB,MAAM,EACL,mEAAmE;KACpE,EACD,sBAAW,CAAC,OAAO,CAAC,cAAc,CAClC,CAAC;AACH,CAAC"}
@@ -1,7 +1 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/parser/taskRunner.ts"],
4
- "sourcesContent": ["import * as os from \"node:os\";\nimport path from \"node:path\";\nimport type { SingleBar } from \"cli-progress\";\nimport type { SetOfBlocks } from \"gettext-merger\";\nimport type { Args } from \"../types.js\";\n\n/**\n * Task runner for the extraction process.\n *\n * @param tasks - The tasks to run\n * @param destination - The destination\n * @param args - The command line arguments\n * @param progressBar\n */\nexport async function taskRunner(\n\ttasks: Promise<SetOfBlocks>[],\n\tdestination: SetOfBlocks,\n\targs: Args,\n\tprogressBar: SingleBar,\n) {\n\tconst messages = [];\n\tawait Promise.allSettled(tasks)\n\t\t.then((strings) => {\n\t\t\t/**\n\t\t\t * Return the strings that are not rejected (they are fulfilled)\n\t\t\t */\n\t\t\treturn strings\n\t\t\t\t.map((block) => block.status === \"fulfilled\" && block.value)\n\t\t\t\t.filter(Boolean) as SetOfBlocks[]; // remove nullish\n\t\t})\n\t\t.then((consolidated) => {\n\t\t\t/** Log the results */\n\t\t\tif (args.options?.silent !== true) {\n\t\t\t\tfor (const result of consolidated) {\n\t\t\t\t\tif (result.blocks.length > 0) {\n\t\t\t\t\t\t/**\n\t\t\t\t\t\t * Add the strings to the destination set\n\t\t\t\t\t\t */\n\t\t\t\t\t\tdestination.addArray(result.blocks);\n\t\t\t\t\t\t/* Log the results */\n\t\t\t\t\t\tmessages.push(\n\t\t\t\t\t\t\t`\u2705 ${result.path} [${result.blocks.map((b) => b.msgid).join(\", \")}]`,\n\t\t\t\t\t\t);\n\t\t\t\t\t} else messages.push(`\u274C ${result.path} has no strings`);\n\t\t\t\t}\n\t\t\t}\n\t\t})\n\t\t.catch((err) => {\n\t\t\treturn new Error(err);\n\t\t});\n\n\tprogressBar.stop();\n\n\tconsole.log(\"\\n\uD83C\uDF89 Done!\");\n\tconsole.log(\n\t\t`\uD83D\uDCDD Found ${Object.values(destination.blocks).length} translation strings in ${path.resolve(args.paths.cwd)}.`,\n\t);\n\n\tconsole.log(messages.join(os.EOL));\n\n\treturn destination;\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,SAAoB;AACpB,uBAAiB;AAajB,eAAsB,WACr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CAAC,CAAC,MAAM,2BAA2B,mBAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAC9G,CAAC;IAEF,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAEnC,OAAO,WAAW,CAAC;AACpB,CAAC"}
@@ -1 +1 @@
1
- "use strict";var O=Object.create;var m=Object.defineProperty;var P=Object.getOwnPropertyDescriptor;var K=Object.getOwnPropertyNames;var L=Object.getPrototypeOf,F=Object.prototype.hasOwnProperty;var M=(t,e)=>{for(var n in e)m(t,n,{get:e[n],enumerable:!0})},b=(t,e,n,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of K(e))!F.call(t,s)&&s!==n&&m(t,s,{get:()=>e[s],enumerable:!(o=P(e,s))||o.enumerable});return t};var j=(t,e,n)=>(n=t!=null?O(L(t)):{},b(e||!t||!t.__esModule?m(n,"default",{value:t,enumerable:!0}):n,t)),E=t=>b(m({},"__esModule",{value:!0}),t);var V={};M(V,{doTree:()=>U});module.exports=E(V);var k=j(require("tree-sitter")),y=require("../const.js"),a=require("gettext-merger"),w=require("../fs/glob.js"),g=require("../utils/common.js");function I(t){let e=t,n=0;for(;e&&n<6;){if(e?.previousSibling?.type==="comment"&&e?.previousSibling?.text.toLowerCase().includes("translators"))return e?.previousSibling?.text?(0,g.stripTranslationMarkup)(e.previousSibling.text):void 0;n++,e=e.parent}}function U(t,e){const n=new k.default,o=(0,w.getParser)(e);if(!o)return new a.SetOfBlocks([],e);n.setLanguage(o);const s=n.parse(t),x=new a.SetOfBlocks([],e),v=e.split(".").pop()?.toLowerCase()!=="php"?"call_expression":"function_call_expression",N=["name","string","string_value","variable_name","binary_expression","member_expression","subscript_expression","shell_command_expression","function_call_expression","encapsed_string"];function _(r){if(r?.children.length)for(const l of r.children)_(l);if(r?.type===v){const l=r.firstChild?.text??null;if(l===null||!Object.keys(y.i18nFunctions).includes(l))return;const p=r.lastChild;if(p===null||p.childCount===0||p.type!=="arguments")return;const[q,C]=r.children,c={},h=y.i18nFunctions[l],$=C.children.slice(1,-1);let f=0;for(const u of $){let i=u,d=i.text;if(u.type==="argument"){if(u.children.length===0)continue;i=u.children[0]}if(i?.type===",")continue;if(i?.type&&N.includes(i.type))d=d.slice(1,-1);else{console.warn(`Unexpected node type: ${i?.type} is ${h[f]} for ${d} in ${e}`);continue}const T=h[f];c[T]=d,f+=1}const S=I(p),B=new a.Block({msgctxt:c.msgctxt,msgid:c.msgid??"",msgid_plural:c.msgid_plural,msgstr:c.msgid_plural?["",""]:[""],comments:{translator:S?[S]:void 0,reference:[`${(0,g.reverseSlashes)(e)}:${r.startPosition.row+1}`]}});x.add(B)}}return _(s.rootNode),x}0&&(module.exports={doTree});
1
+ "use strict";var C=Object.create;var f=Object.defineProperty;var F=Object.getOwnPropertyDescriptor;var L=Object.getOwnPropertyNames;var O=Object.getPrototypeOf,z=Object.prototype.hasOwnProperty;var K=(t,e)=>{for(var n in e)f(t,n,{get:e[n],enumerable:!0})},S=(t,e,n,c)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of L(e))!z.call(t,i)&&i!==n&&f(t,i,{get:()=>e[i],enumerable:!(c=F(e,i))||c.enumerable});return t};var M=(t,e,n)=>(n=t!=null?C(O(t)):{},S(e||!t||!t.__esModule?f(n,"default",{value:t,enumerable:!0}):n,t)),j=t=>S(f({},"__esModule",{value:!0}),t);var U={};K(U,{doTree:()=>I});module.exports=j(U);var b=M(require("tree-sitter")),y=require("../const.js"),u=require("gettext-merger"),$=require("../fs/glob.js"),g=require("../utils/common.js");function E(t){let e=t,n=0;for(;e&&n<6;){if(e?.previousSibling?.type==="comment"&&e?.previousSibling?.text.toLowerCase().includes("translators"))return e?.previousSibling?.text?(0,g.stripTranslationMarkup)(e.previousSibling.text):void 0;n++,e=e.parent}}function I(t,e,n){const c=new b.default,i=(0,$.getParser)(e);if(!i)return new u.SetOfBlocks([],e);c.setLanguage(i);const x=new u.SetOfBlocks([],e),k=e.split(".").pop()?.toLowerCase()!=="php"?"call_expression":"function_call_expression",v=["name","string","string_value","variable_name","binary_expression","member_expression","subscript_expression","shell_command_expression","function_call_expression","encapsed_string"];function _(s){if(s?.children.length)for(const r of s.children)_(r);if(s?.type===k){const r=s.firstChild?.text??null;if(r===null||!Object.keys(y.i18nFunctions).includes(r))return;const l=s.lastChild;if(l===null||l.childCount===0||l.type!=="arguments")return;const[V,N]=s.children,a={},h=y.i18nFunctions[r],B=N.children.slice(1,-1);let m=0;for(const d of B){let o=d,p=o.text;if(d.type==="argument"){if(d.children.length===0)continue;o=d.children[0]}if(o?.type===",")continue;if(o?.type&&v.includes(o.type))p=p.slice(1,-1);else{n&&console.warn(`Unexpected node type ${o?.type} identified as ${h[m]} with value ${p} in ${e} at ${o.startPosition.row+1} pos ${o.startPosition.column+1}`);continue}const T=h[m];a[T]=p,m+=1}const w=E(l),P=new u.Block({msgctxt:a.msgctxt,msgid:a.msgid??"",msgid_plural:a.msgid_plural,msgstr:a.msgid_plural?["",""]:[""],comments:{translator:w?[w]:void 0,reference:[`${(0,g.reverseSlashes)(e)}:${s.startPosition.row+1}`]}});x.add(P)}}try{if(t){const s=Buffer.byteLength(t,"utf8");let r=1024*32;s>=r&&(r=s+32),s>=1024*1024*2&&console.warn(`File size warning: ${e} exceeds 2 MB.`);const l=c.parse(t,void 0,{bufferSize:r});l&&_(l.rootNode)}}catch(s){console.error(`Failed to parse ${e}: ${s}`)}return x}0&&(module.exports={doTree});
@@ -1,7 +1 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/parser/tree.ts"],
4
- "sourcesContent": ["import Parser, { type SyntaxNode } from \"tree-sitter\";\nimport { i18nFunctions } from \"../const.js\";\n\nimport { Block, SetOfBlocks } from \"gettext-merger\";\nimport { getParser } from \"../fs/glob.js\";\nimport { reverseSlashes, stripTranslationMarkup } from \"../utils/common.js\";\n\n/**\n * Collect comments from the AST node and its preceding siblings.\n *\n * @param {SyntaxNode} node - The AST node.\n * @return {string[]} An array of collected comments.\n */\nfunction collectComments(node: SyntaxNode): string | undefined {\n\tlet currentNode = node;\n\tlet depth = 0;\n\n\t// Check the node's preceding siblings for comments\n\twhile (currentNode && depth < 6) {\n\t\tif (\n\t\t\tcurrentNode?.previousSibling?.type === \"comment\" &&\n\t\t\tcurrentNode?.previousSibling?.text.toLowerCase().includes(\"translators\")\n\t\t) {\n\t\t\treturn currentNode?.previousSibling?.text\n\t\t\t\t? stripTranslationMarkup(currentNode.previousSibling.text)\n\t\t\t\t: undefined;\n\t\t}\n\t\tdepth++;\n\t\tcurrentNode = currentNode.parent as SyntaxNode;\n\t}\n}\n\n/**\n * Parses the source code using the specified language parser and extracts the strings from the file.\n *\n * @param {string} sourceCode - The source code to be parsed.\n * @param {string} filepath - The path to the file being parsed.\n * @return {SetOfBlocks} An array of translation strings.\n */\nexport function doTree(sourceCode: string, filepath: string): SetOfBlocks {\n\t// set up the parser\n\tconst parser = new Parser();\n\tconst parserExt = getParser(filepath);\n\t// if no parser is found return empty\n\tif (!parserExt) return new SetOfBlocks([], filepath);\n\t// set the parser language\n\tparser.setLanguage(parserExt);\n\n\t// parse the file\n\tconst tree = parser.parse(sourceCode);\n\n\t// set up the translation object\n\tconst gettextTranslations: SetOfBlocks = new SetOfBlocks([], filepath);\n\n\tconst typeToMatch =\n\t\tfilepath.split(\".\").pop()?.toLowerCase() !== \"php\"\n\t\t\t? \"call_expression\"\n\t\t\t: \"function_call_expression\";\n\n\tconst stringType = [\n\t\t\"name\",\n\t\t\"string\",\n\t\t\"string_value\",\n\t\t\"variable_name\",\n\t\t\"binary_expression\",\n\t\t\"member_expression\",\n\t\t\"subscript_expression\",\n\t\t\"shell_command_expression\",\n\t\t\"function_call_expression\",\n\t\t\"encapsed_string\",\n\t];\n\n\t/**\n\t * Traverse the tree \uD83C\uDF33\n\t *\n\t * @param {SyntaxNode} node The node to traverse through\n\t */\n\tfunction traverse(node: SyntaxNode): void {\n\t\t// Walk the tree\n\t\tif (node?.children.length)\n\t\t\tfor (const child of node.children) {\n\t\t\t\ttraverse(child);\n\t\t\t}\n\n\t\t// Check if the node matches\n\t\tif (node?.type === typeToMatch) {\n\t\t\t// The function name is the first child\n\t\t\tconst functionName = node.firstChild?.text ?? null;\n\t\t\tif (\n\t\t\t\tfunctionName === null ||\n\t\t\t\t!Object.keys(i18nFunctions).includes(functionName)\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// The arguments are the last child\n\t\t\tconst argsNode = node.lastChild;\n\t\t\tif (\n\t\t\t\targsNode === null ||\n\t\t\t\targsNode.childCount === 0 ||\n\t\t\t\targsNode.type !== \"arguments\"\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Get the whole gettext translation string\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unused-vars\n\t\t\tconst [_fn, raw] = node.children;\n\t\t\tconst translation: Partial<{\n\t\t\t\tmsgctxt: string;\n\t\t\t\tmsgid: string;\n\t\t\t\tmsgid_plural: string;\n\t\t\t\tmsgstr: string;\n\t\t\t}> = {};\n\n\t\t\tconst translationKeys =\n\t\t\t\ti18nFunctions[functionName as keyof typeof i18nFunctions];\n\n\t\t\tconst children = raw.children.slice(1, -1);\n\t\t\tlet translationKeyIndex = 0;\n\n\t\t\t// Get the translation from the arguments (the quoted strings)\n\t\t\tfor (const child of children) {\n\t\t\t\tlet node = child;\n\t\t\t\tlet nodeValue: string | string[] = node.text;\n\n\t\t\t\t// unwrap the argument node, which is used in PHP.\n\t\t\t\tif (child.type === \"argument\") {\n\t\t\t\t\tif (child.children.length === 0) continue;\n\t\t\t\t\tnode = child.children[0];\n\t\t\t\t}\n\n\t\t\t\tif (node?.type === \",\") {\n\t\t\t\t\t// skip the comma between arguments\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tif (node?.type && stringType.includes(node.type)) {\n\t\t\t\t\t// unquote the strings\n\t\t\t\t\tnodeValue = nodeValue.slice(1, -1);\n\t\t\t\t} else {\n\t\t\t\t\t// unexpected node type this string is not translatable and should be skipped\n\t\t\t\t\tconsole.warn(\n\t\t\t\t\t\t`Unexpected node type: ${node?.type} is ${translationKeys[translationKeyIndex]} for ${nodeValue} in ${filepath}`,\n\t\t\t\t\t);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\t// the translation key (eg. msgid)\n\t\t\t\tconst currentKey = translationKeys[\n\t\t\t\t\ttranslationKeyIndex\n\t\t\t\t] as keyof typeof translation;\n\n\t\t\t\t// the value of that key\n\t\t\t\ttranslation[currentKey] = nodeValue;\n\n\t\t\t\t// increment the index of the translation key\n\t\t\t\ttranslationKeyIndex += 1;\n\t\t\t}\n\n\t\t\t// TODO: Alert about wrong translation domain?\n\t\t\tconst comments = collectComments(argsNode);\n\n\t\t\t// Get the translation data\n\t\t\tconst block = new Block({\n\t\t\t\tmsgctxt: translation.msgctxt,\n\t\t\t\tmsgid: translation.msgid ?? \"\",\n\t\t\t\tmsgid_plural: translation.msgid_plural,\n\t\t\t\tmsgstr: translation.msgid_plural ? [\"\", \"\"] : [\"\"],\n\t\t\t\tcomments: {\n\t\t\t\t\ttranslator: comments ? [comments] : undefined,\n\t\t\t\t\treference: [\n\t\t\t\t\t\t`${reverseSlashes(filepath)}:${node.startPosition.row + 1}`,\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t} as Block);\n\n\t\t\tgettextTranslations.add(block);\n\t\t}\n\t}\n\n\ttraverse(tree.rootNode);\n\n\t// Return both matches and entries\n\treturn gettextTranslations;\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yBAAwC;AACxC,mBAA8B;AAE9B,4BAAmC;AACnC,kBAA0B;AAC1B,oBAAuD;AAQvD,SAAS,gBAAgB,MAAsC;AAC9D,MAAI,cAAc;AAClB,MAAI,QAAQ;AAGZ,SAAO,eAAe,QAAQ,GAAG;AA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Property;var k=(e,t)=>{for(var o in t)n(e,o,{get:t[o],enumerable:!0})},l=(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 d=e=>l(n({},"__esModule",{value:!0}),e);var M={};k(M,{default:()=>i});module.exports=d(M);var a=require("./parser/makePot.js"),m=require("./utils/common.js");function i(e){if(Object.keys(e).length>0){(0,m.printMakePotModuleInfo)();const t=new Date;(0,a.makePot)(e).then(()=>{(0,m.printTimeElapsed)("Make-Pot",t)}).catch(o=>{console.error(`\u{1FAE4} Make-pot - ${o}`)})}}
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}`)})}}
@@ -1,7 +1 @@
1
- {
2
- "version": 3,
3
- "sources": ["../src/potCommand.ts"],
4
- "sourcesContent": ["import { makePot } from \"./parser/makePot.js\";\n\nimport type { Args } from \"./types.js\";\nimport { printMakePotModuleInfo, printTimeElapsed } from \"./utils/common.js\";\n\nexport default function potCommand(args: Args) {\n\tif (Object.keys(args).length > 0) {\n\t\tprintMakePotModuleInfo();\n\t\t/* capture the start time */\n\t\tconst timeStart = new Date();\n\t\t/** make the pot file */\n\t\tmakePot(args)\n\t\t\t.then(() => {\n\t\t\t\t/* output the end time */\n\t\t\t\tprintTimeElapsed(\"Make-Pot\", timeStart);\n\t\t\t})\n\t\t\t.catch((error) => {\n\t\t\t\tconsole.error(`\uD83E\uDEE4 Make-pot - ${error}`);\n\t\t\t});\n\t}\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAAwB;AAGxB,oBAAyD;AAE1C,SAAR,WAA4B,MAAY;AAC9C,MAAI,OAAO,KAAK,IAAI,EAAE,SAAS,GAAG;AACjC,8CAAuB;AAEvB,UAAM,YAAY,oBAAI,KAAK;AAE3B,gCAAQ,IAAI,EACV,KAAK,MAAM;AAEX,0CAAiB,YAAY,SAAS;AAAA,IACvC,CAAC,EACA,MAAM,CAAC,UAAU;AACjB,cAAQ,MAAM,wBAAiB,KAAK,EAAE;AAAA,IACvC,CAAC;AAAA,EACH;AACD;",
6
- "names": []
7
- }
1
+ {"version":3,"file":"potCommand.js","sourceRoot":"","sources":["../src/potCommand.ts"],"names":[],"mappings":";;AAKA,6BAeC;AApBD,oDAA8C;AAG9C,iDAAsE;AAEtE,SAAwB,UAAU,CAAC,IAAU;IAC5C,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAClC,IAAA,2BAAe,GAAE,CAAC;QAClB,4BAA4B;QAC5B,MAAM,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC;QAC7B,wBAAwB;QACxB,IAAA,oBAAO,EAAC,IAAI,CAAC;aACX,IAAI,CAAC,GAAG,EAAE;YACV,yBAAyB;YACzB,IAAA,4BAAgB,EAAC,UAAU,EAAE,SAAS,CAAC,CAAC;QACzC,CAAC,CAAC;aACD,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;YAChB,OAAO,CAAC,KAAK,CAAC,iBAAiB,KAAK,EAAE,CAAC,CAAC;QACzC,CAAC,CAAC,CAAC;IACL,CAAC;AACF,CAAC"}
package/lib/types.js CHANGED
@@ -1 +1 @@
1
- "use strict";var s=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var i=Object.getOwnPropertyNames;var g=Object.prototype.hasOwnProperty;var p=(t,e,o,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of i(e))!g.call(t,n)&&n!==o&&s(t,n,{get:()=>e[n],enumerable:!(r=a(e,n))||r.enumerable});return t};var l=t=>p(s({},"__esModule",{value:!0}),t);var d={};module.exports=l(d);
1
+ "use strict";var s=Object.defineProperty;var o=Object.getOwnPropertyDescriptor;var i=Object.getOwnPropertyNames;var g=Object.prototype.hasOwnProperty;var p=(t,e,a,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of i(e))!g.call(t,n)&&n!==a&&s(t,n,{get:()=>e[n],enumerable:!(r=o(e,n))||r.enumerable});return t};var l=t=>p(s({},"__esModule",{value:!0}),t);var d={};module.exports=l(d);
package/lib/types.js.map CHANGED
@@ -1,7 +1 @@
1
- {
2
- "version": 3,
3
- "sources": ["../src/types.ts"],
4
- "sourcesContent": ["import type { GetTextTranslation } from \"gettext-parser\";\nimport type { pkgJsonHeaders, pluginHeaders, themeHeaders } from \"./const.js\";\n\nexport type ThemeHeadersType = typeof themeHeaders;\nexport type PluginHeadersType = typeof pluginHeaders;\nexport type PkgHeadersType = typeof pkgJsonHeaders;\n\n/**\n * The args headers Object types\n */\nexport type PotHeaders =\n\t| keyof PkgHeadersType\n\t| keyof PluginHeadersType\n\t| keyof ThemeHeadersType\n\t| \"license\"\n\t| \"email\"\n\t| \"language\"\n\t| \"domain\"\n\t| \"bugs\";\n\n// type is the value of the themeHeader Object\nexport type DomainType =\n\t| \"plugin\"\n\t| \"theme\"\n\t| \"block\"\n\t| \"theme-block\"\n\t| \"generic\";\n\n/**\n * The patterns to use when extracting strings from files.\n *\n * @param {string} mergePaths - Comma-separated list of POT files whose contents should be merged with the extracted strings.\n * If left empty, defaults to the destination POT file. POT file headers will be ignored.\n * @param {string} subtractPaths - Comma-separated list of POT files whose contents should act as some sort of denylist\n * for string extraction. Any string which is found on that denylist will not be extracted. This can be useful when\n * you want to create multiple POT files from the same source directory with slightly different content and no duplicate\n * strings between them.\n * @param {boolean} subtractAndMerge - Whether source code references and comments from the generated POT file should be\n * instead added to the POT file used for subtraction. Warning: this modifies the files passed to `subtractPaths`!\n * @param {string} include - Comma-separated list of files and paths that should be used for string extraction.\n * If provided, only these files and folders will be taken into account for string extraction.\n * For example, `--include=\"src,my-file.php` will ignore anything besides `my-file.php` and files in the `src`\n * directory. Simple glob patterns can be used, i.e. `--include=foo-*.php` includes any PHP file with the `foo-`\n * prefix. Leading and trailing slashes are ignored, i.e. `/my/directory/` is the same as `my/directory`.\n * @param {string} exclude - Comma-separated list of files and paths that should be skipped for string extraction.\n * For example, `--exclude=.github,myfile.php` would ignore any strings found within `myfile.php` or the `.github`\n * folder. Simple glob patterns can be used, i.e. `--exclude=foo-*.php` excludes any PHP file with the `foo-`\n * prefix. Leading and trailing slashes are ignored, i.e. `/my/directory/` is the same as `my/directory`.\n * The following files and folders are always excluded: node_modules, .git, .svn, .CVS, .hg, vendor, *.min.js.\n */\nexport interface Patterns {\n\tmergePaths?: string[];\n\tsubtractPaths?: string[];\n\tsubtractAndMerge?: boolean;\n\tinclude: string[];\n\texclude: string[];\n}\n\n/**\n * Create a POT file for a WordPress project.\n *\n * Scans PHP, Blade-PHP, and JavaScript files for translatable strings, as well as theme stylesheets and plugin files\n * if the source directory is detected as either a plugin or theme.\n *\n * @param {string} sourceDirectory - Directory to scan for string extraction.\n * @param {string} destination - Name of the resulting POT file.\n * @param {string | undefined} slug - Plugin or theme slug. Defaults to the source directory's basename.\n * @param {'plugin' | 'theme' | 'block' | 'theme-block' | 'generic'} domain - Text domain to look for in the source code,\n * unless the `ignoreDomain` option is used. By default, the \"Text Domain\" header of the plugin or theme is used.\n * If none is provided, it falls back to the project slug.\n * @param {boolean} ignoreDomain - Ignore the text domain completely and extract strings with any text domain.\n * @param {{}} headers - Array in JSON format of custom headers which will be added to the POT file. Defaults to empty array.\n * @param {boolean} location - Whether to write `#: filename:line` lines. Defaults to true, use `--no-location`\n * to skip the removal. Note that disabling this option makes it harder for technically skilled translators\n * to understand each message\u2019s context.\n * @param {boolean} skipJs - Skips JavaScript string extraction. Useful when this is done in another build step, e.g. through Babel.\n * @param {boolean} skipPhp - Skips PHP string extraction.\n * @param {boolean} skipBlade - Skips Blade-PHP string extraction.\n * @param {boolean} skipBlockJson - Skips string extraction from block.json files.\n * @param {boolean} skipThemeJson - Skips string extraction from theme.json files.\n * @param {boolean} skipAudit - Skips string audit where it tries to find possible mistakes in translatable strings.\n * Useful when running in an automated environment.\n * @param {string} fileComment - String that should be added as a comment to the top of the resulting POT file.\n * By default, a copyright comment is added for WordPress plugins and themes.\n * @param {string} packageName - Name to use for the package name in the resulting POT file's `Project-Id-Version` header.\n * Overrides the plugin or theme name, if applicable.\n * @param {boolean} silent - Whether to hide progress information.\n */\nexport interface Args {\n\tslug: string;\n\tdomain: DomainType;\n\tpaths: {\n\t\tcwd: string;\n\t\tout: string;\n\t\troot?: string;\n\t};\n\toptions?: {\n\t\tignoreDomain?: boolean;\n\t\tsilent?: boolean;\n\t\tjson?: boolean;\n\t\tlocation?: boolean;\n\t\tpackageName?: string;\n\t\toutput?: boolean;\n\t\tfileComment?: string;\n\t\tcharset?: string;\n\t\tskip: {\n\t\t\tjs?: boolean;\n\t\t\tphp?: boolean;\n\t\t\tblade?: boolean;\n\t\t\tblockJson?: boolean;\n\t\t\tthemeJson?: boolean;\n\t\t\taudit?: boolean;\n\t\t};\n\t};\n\theaders?: { [key in PotHeaders]: string };\n\tpatterns: Patterns;\n}\n\n/**\n * The arguments for the `makeJson` command.\n * \t@param {string} source the source directory\n * \t@param {string | null} destination the destination directory (defaults to source)\n * \t@param {string[] | null} allowedFormats the allowed files\n * \t@param {boolean} purge remove old json files (otherwise the content will be merged)\n * \t@param {boolean} prettyPrint?: pretty print json\n * \t@param {boolean} debug: enable debug mode\n */\nexport interface MakeJsonArgs {\n\ttimeStart: number;\n\tprettyPrint: boolean;\n\tdebug: boolean;\n\tdestination: string;\n\tscriptName?: string;\n\tpurge: boolean;\n\tsource: string;\n\tslug: string;\n\tallowedFormats?: string[];\n\tpaths: {\n\t\tcwd: string;\n\t\tout?: string;\n\t\troot?: string;\n\t};\n}\n\nexport interface I18nSchema {\n\t[key: string]: string | string[] | I18nSchema | I18nSchema[];\n}\n\n/**\n * Translation string metadata.\n * Gettext format: https://www.gnu.org/savannah-checkouts/gnu/gettext/FAQ.html\n *\n * @property {string} msgctxt - context for this translation, if not present the default context applies\n * @property {string} msgid - string to be translated\n * @property {string} msgid_plural the plural form of the original string (might not be present)\n * @property {string[]} msgstr an array of translations\n * @property {{}} comments an object with the following properties: translator, reference, extracted, flag, previous.\n */\nexport interface TranslationStrings {\n\t[msgctxt: string]: { [msgId: string]: GetTextTranslation };\n}\n\n/**\n * The JSON data returned by the `makeJson` command.\n * @param {string} domain\n * @param {Record<string, unknown>} locale_data\n */\nexport interface JedData {\n\t[domain: string]: {\n\t\t[key: string]: string | string[];\n\t};\n}\n\nexport interface MakeJson {\n\tdomain: string;\n\tgenerator: string;\n\t\"translation-revision-date\": string;\n\tsource: string;\n\tlocale_data: JedData;\n}\n\n/**\n * The header data of the current plugin / theme as returned by the `extractHeaders` command.\n */\nexport interface I18nHeaders {\n\tauthorString: string;\n\tbugs: string;\n\tlicense: string;\n\tauthor?: string;\n\txDomain: string;\n\tlanguage: string;\n\tversion: string;\n\tslug: string;\n\temail: string | undefined;\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;AAAA;AAAA;",
6
- "names": []
7
- }
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
@@ -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,t)=>{for(var n in t)s(e,n,{get:t[n],enumerable:!0})},a=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of x(t))!k.call(e,r)&&r!==n&&s(e,r,{get:()=>t[r],enumerable:!(o=d(t,r))||o.enumerable});return e};var g=(e,t,n)=>(n=e!=null?f(h(e)):{},a(t||!e||!e.__esModule?s(n,"default",{value:e,enumerable:!0}):n,e)),$=e=>a(s({},"__esModule",{value:!0}),e);var J={};y(J,{detectPatternType:()=>S,getCommentBlock:()=>M,getCopyright:()=>v,getPkgJsonData:()=>m,printMakePotModuleInfo:()=>D,printStats:()=>b,printTimeElapsed:()=>T,removeCommentMarkup:()=>P,reverseSlashes:()=>w,stringstring:()=>F,stripTranslationMarkup:()=>C});module.exports=$(J);var l=g(require("node:fs")),i=require("node:os"),u=g(require("node:path")),p=require("../const.js");function M(e){const t=e.match(/\/\*\*?[\s\S]*?\*\//);return t!==null?t[0]:e}function P(e){return e.match(/[a-zA-Z].*/gm)}function C(e){const t=/\/\*\*?\s*(?:translators:)\s*([\s\S]*?)\s*\*\/|\/\/\s*(?:translators:)\s*(.*)$/i,n=e.match(t);return n?n[1]:e}function F(e){return typeof e=="string"?e.includes(",")?e.split(","):[e]:[]}function S(e){const t=e.includes("."),n=e.includes(u.default.sep);return e.includes("*")?"glob":!t&&!n?"directory":t&&!n?"file":"glob"}function v(e,t="GPL v2 or later"){return`# Copyright (C) ${new Date().getFullYear()} ${e}
2
- # This file is distributed under the ${t} license.`}function w(e){return e.replace(/\\/g,"/")}function m(e,...t){const n={},o=u.default.join(e||process.cwd(),"package.json"),r=l.default.existsSync(o)?require(o):{};for(const c of t)r[c]&&(n[c]=r[c]);return n}function D(){const{version:e,name:t}=m(p.modulePath,"name","version");console.log(`${t} version: ${e}`)}function T(e,t,n=new Date){console.log(`
3
- \u{1F680} ${e}: Job completed! ${e.split("-")[1]} file created in ${n.getTime()-t.getTime()}ms`)}function b(){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")}0&&(module.exports={detectPatternType,getCommentBlock,getCopyright,getPkgJsonData,printMakePotModuleInfo,printStats,printTimeElapsed,removeCommentMarkup,reverseSlashes,stringstring,stripTranslationMarkup});
1
+ "use strict";var m=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})},p=(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 a=(t,e,n)=>(n=t!=null?m(h(t)):{},p(e||!t||!t.__esModule?s(n,"default",{value:t,enumerable:!0}):n,t)),$=t=>p(s({},"__esModule",{value:!0}),t);var B={};y(B,{detectPatternType:()=>M,getCommentBlock:()=>P,getCopyright:()=>b,getFileExtension:()=>T,getPkgJsonData:()=>f,outputPathRecap:()=>U,printModuleInfo:()=>w,printStats:()=>j,printTimeElapsed:()=>D,removeCommentMarkup:()=>F,reverseSlashes:()=>v,stringstring:()=>C,stripTranslationMarkup:()=>S});module.exports=$(B);var g=a(require("node:fs")),i=require("node:os"),u=a(require("node:path")),l=require("../const.js");function P(t){const e=t.match(/\/\*\*?[\s\S]*?\*\//);return e!==null?e[0]:t}function F(t){return t.match(/[a-zA-Z].*/gm)}function S(t){const e=/\/\*\*?\s*(?:translators:)\s*([\s\S]*?)\s*\*\/|\/\/\s*(?:translators:)\s*(.*)$/i,n=t.match(e);return n?n[1]:t}function C(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){return t.endsWith(".blade.php")?"blade.php":t.split(".").pop()||""}function b(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 f(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}=f(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,getFileExtension,getPkgJsonData,outputPathRecap,printModuleInfo,printStats,printTimeElapsed,removeCommentMarkup,reverseSlashes,stringstring,stripTranslationMarkup});