@wp-blocks/make-pot 1.5.0 → 1.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/README.md +3 -3
  2. package/lib/assets/block-i18n.js.map +7 -0
  3. package/lib/assets/package-i18n.js.map +7 -0
  4. package/lib/assets/theme-i18n.js.map +7 -0
  5. package/lib/assets/wp-plugin-i18n.js.map +7 -0
  6. package/lib/assets/wp-theme-i18n.js.map +7 -0
  7. package/lib/cli/getArgs.js.map +7 -0
  8. package/lib/cli/getJsonArgs.js +1 -1
  9. package/lib/cli/getJsonArgs.js.map +7 -0
  10. package/lib/cli/parseCli.js.map +7 -0
  11. package/lib/cli.js +1 -1
  12. package/lib/cli.js.map +7 -0
  13. package/lib/const.js +1 -1
  14. package/lib/const.js.map +7 -0
  15. package/lib/extractors/css.js +1 -1
  16. package/lib/extractors/css.js.map +7 -0
  17. package/lib/extractors/headers.js +3 -3
  18. package/lib/extractors/headers.js.map +7 -0
  19. package/lib/extractors/json.js +1 -1
  20. package/lib/extractors/json.js.map +7 -0
  21. package/lib/extractors/packageJson.js +1 -0
  22. package/lib/extractors/packageJson.js.map +7 -0
  23. package/lib/extractors/php.js +2 -2
  24. package/lib/extractors/php.js.map +7 -0
  25. package/lib/extractors/schema.js +4 -4
  26. package/lib/extractors/schema.js.map +7 -0
  27. package/lib/extractors/text.js +1 -1
  28. package/lib/extractors/text.js.map +7 -0
  29. package/lib/fs/fs.js +2 -1
  30. package/lib/fs/fs.js.map +7 -0
  31. package/lib/fs/glob.js.map +7 -0
  32. package/lib/index.js +1 -1
  33. package/lib/index.js.map +7 -0
  34. package/lib/jsonCommand.js +1 -1
  35. package/lib/jsonCommand.js.map +7 -0
  36. package/lib/makeJson.js +1 -1
  37. package/lib/makeJson.js.map +7 -0
  38. package/lib/makePot.js +1 -1
  39. package/lib/makePot.js.map +7 -0
  40. package/lib/parser/exec.js +3 -3
  41. package/lib/parser/exec.js.map +7 -0
  42. package/lib/parser/makeJson.js +1 -1
  43. package/lib/parser/makeJson.js.map +7 -0
  44. package/lib/parser/makePot.js +1 -1
  45. package/lib/parser/makePot.js.map +7 -0
  46. package/lib/parser/patterns.js.map +7 -0
  47. package/lib/parser/process.js.map +7 -0
  48. package/lib/parser/progress.js +1 -1
  49. package/lib/parser/progress.js.map +7 -0
  50. package/lib/parser/taskRunner.js +2 -1
  51. package/lib/parser/taskRunner.js.map +7 -0
  52. package/lib/parser/tree.js +1 -1
  53. package/lib/parser/tree.js.map +7 -0
  54. package/lib/potCommand.js +1 -1
  55. package/lib/potCommand.js.map +7 -0
  56. package/lib/types.js.map +7 -0
  57. package/lib/utils/common.js +3 -2
  58. package/lib/utils/common.js.map +7 -0
  59. package/lib/utils/extractors.js +1 -0
  60. package/lib/utils/extractors.js.map +7 -0
  61. package/package.json +13 -12
  62. package/tests/extract-headers.test.js +54 -0
  63. package/tests/extract.test.js +1 -1
  64. package/tests/jsonParse.test.js +167 -0
  65. package/tests/parse-headers.test.js +74 -0
  66. package/lib/extractors/utils.js +0 -1
  67. package/tests/getFiles.test.no.js +0 -85
  68. package/tests/jsonParse.no.js +0 -49
  69. package/tests/wpcliCompare.no.js +0 -32
package/README.md CHANGED
@@ -32,7 +32,7 @@ npm install -g @wp-blocks/make-pot
32
32
  ```bash
33
33
  # without installation
34
34
  npx @wp-blocks/make-pot [sourceDirectory] [destination] [options]
35
- npx @wp-blocks/make-pot --makejson [sourceDirectory] [destination] [options]
35
+ npx -p @wp-blocks/make-pot makejson [sourceDirectory] [destination] [options]
36
36
 
37
37
  # installed
38
38
  npx makepot [sourceDirectory] [destination] [options]
@@ -170,8 +170,8 @@ translate the pot file into your language and then run `makejson`:
170
170
 
171
171
  ```bash
172
172
  npx makejson
173
- # OR
174
- npx @wp-blocks/make-pot --makejson,
173
+ # OR if you don't want to install the module
174
+ npx -p @wp-blocks/make-pot makejson,
175
175
  ```
176
176
  It Will create a file for each po file in the `languages` directory with the md5 hash with the name of the file.
177
177
  In this case, the file will be named my-frontend-script-en_US-79431f0eb8deb8221f24df5112e15095.json because the md5 hash of "build/frontend.js" is 79431f0eb8deb8221f24df5112e15095.
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/assets/block-i18n.ts"],
4
+ "sourcesContent": ["export default {\n\ttitle: \"block title\",\n\tdescription: \"block description\",\n\tkeywords: [\"block keyword\"],\n\tstyles: [\n\t\t{\n\t\t\tlabel: \"block style label\",\n\t\t},\n\t],\n\tvariations: [\n\t\t{\n\t\t\ttitle: \"block variation title\",\n\t\t\tdescription: \"block variation description\",\n\t\t\tkeywords: [\"block variation keyword\"],\n\t\t},\n\t],\n};\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAO,qBAAQ;AAAA,EACd,OAAO;AAAA,EACP,aAAa;AAAA,EACb,UAAU,CAAC,eAAe;AAAA,EAC1B,QAAQ;AAAA,IACP;AAAA,MACC,OAAO;AAAA,IACR;AAAA,EACD;AAAA,EACA,YAAY;AAAA,IACX;AAAA,MACC,OAAO;AAAA,MACP,aAAa;AAAA,MACb,UAAU,CAAC,yBAAyB;AAAA,IACrC;AAAA,EACD;AACD;",
6
+ "names": []
7
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/assets/package-i18n.ts"],
4
+ "sourcesContent": ["export default {\n\tname: \"name\",\n\turl: \"url\",\n\tdescription: \"description\",\n\tauthor: \"author\",\n\tauthors: \"authors\",\n\tauthorEmail: \"authorEmail\",\n\tversion: \"version\",\n\tbugs: \"bugs\",\n\t\"bugs.url\": \"bugsUrl\",\n\t\"bugs.email\": \"bugsEmail\",\n\tlicense: \"license\",\n\trepository: \"repository\",\n};\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAO,uBAAQ;AAAA,EACd,MAAM;AAAA,EACN,KAAK;AAAA,EACL,aAAa;AAAA,EACb,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,aAAa;AAAA,EACb,SAAS;AAAA,EACT,MAAM;AAAA,EACN,YAAY;AAAA,EACZ,cAAc;AAAA,EACd,SAAS;AAAA,EACT,YAAY;AACb;",
6
+ "names": []
7
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/assets/theme-i18n.ts"],
4
+ "sourcesContent": ["export default {\n\ttitle: \"Style variation name\",\n\tsettings: {\n\t\ttypography: {\n\t\t\tfontSizes: [\n\t\t\t\t{\n\t\t\t\t\tname: \"Font size name\",\n\t\t\t\t},\n\t\t\t],\n\t\t\tfontFamilies: [\n\t\t\t\t{\n\t\t\t\t\tname: \"Font family name\",\n\t\t\t\t},\n\t\t\t],\n\t\t},\n\t\tcolor: {\n\t\t\tpalette: [\n\t\t\t\t{\n\t\t\t\t\tname: \"Color name\",\n\t\t\t\t},\n\t\t\t],\n\t\t\tgradients: [\n\t\t\t\t{\n\t\t\t\t\tname: \"Gradient name\",\n\t\t\t\t},\n\t\t\t],\n\t\t\tduotone: [\n\t\t\t\t{\n\t\t\t\t\tname: \"Duotone name\",\n\t\t\t\t},\n\t\t\t],\n\t\t},\n\t\tspacing: {\n\t\t\tspacingSizes: [\n\t\t\t\t{\n\t\t\t\t\tname: \"Space size name\",\n\t\t\t\t},\n\t\t\t],\n\t\t},\n\t\tblocks: {\n\t\t\t\"*\": {\n\t\t\t\ttypography: {\n\t\t\t\t\tfontSizes: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tname: \"Font size name\",\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t\tfontFamilies: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tname: \"Font family name\",\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t\tcolor: {\n\t\t\t\t\tpalette: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tname: \"Color name\",\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t\tgradients: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tname: \"Gradient name\",\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t\tspacing: {\n\t\t\t\t\tspacingSizes: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tname: \"Space size name\",\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t},\n\tcustomTemplates: [\n\t\t{\n\t\t\ttitle: \"Custom template name\",\n\t\t},\n\t],\n\ttemplateParts: [\n\t\t{\n\t\t\ttitle: \"Template part name\",\n\t\t},\n\t],\n};\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAO,qBAAQ;AAAA,EACd,OAAO;AAAA,EACP,UAAU;AAAA,IACT,YAAY;AAAA,MACX,WAAW;AAAA,QACV;AAAA,UACC,MAAM;AAAA,QACP;AAAA,MACD;AAAA,MACA,cAAc;AAAA,QACb;AAAA,UACC,MAAM;AAAA,QACP;AAAA,MACD;AAAA,IACD;AAAA,IACA,OAAO;AAAA,MACN,SAAS;AAAA,QACR;AAAA,UACC,MAAM;AAAA,QACP;AAAA,MACD;AAAA,MACA,WAAW;AAAA,QACV;AAAA,UACC,MAAM;AAAA,QACP;AAAA,MACD;AAAA,MACA,SAAS;AAAA,QACR;AAAA,UACC,MAAM;AAAA,QACP;AAAA,MACD;AAAA,IACD;AAAA,IACA,SAAS;AAAA,MACR,cAAc;AAAA,QACb;AAAA,UACC,MAAM;AAAA,QACP;AAAA,MACD;AAAA,IACD;AAAA,IACA,QAAQ;AAAA,MACP,KAAK;AAAA,QACJ,YAAY;AAAA,UACX,WAAW;AAAA,YACV;AAAA,cACC,MAAM;AAAA,YACP;AAAA,UACD;AAAA,UACA,cAAc;AAAA,YACb;AAAA,cACC,MAAM;AAAA,YACP;AAAA,UACD;AAAA,QACD;AAAA,QACA,OAAO;AAAA,UACN,SAAS;AAAA,YACR;AAAA,cACC,MAAM;AAAA,YACP;AAAA,UACD;AAAA,UACA,WAAW;AAAA,YACV;AAAA,cACC,MAAM;AAAA,YACP;AAAA,UACD;AAAA,QACD;AAAA,QACA,SAAS;AAAA,UACR,cAAc;AAAA,YACb;AAAA,cACC,MAAM;AAAA,YACP;AAAA,UACD;AAAA,QACD;AAAA,MACD;AAAA,IACD;AAAA,EACD;AAAA,EACA,iBAAiB;AAAA,IAChB;AAAA,MACC,OAAO;AAAA,IACR;AAAA,EACD;AAAA,EACA,eAAe;AAAA,IACd;AAAA,MACC,OAAO;AAAA,IACR;AAAA,EACD;AACD;",
6
+ "names": []
7
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/assets/wp-plugin-i18n.ts"],
4
+ "sourcesContent": ["export default {\n\tname: \"Plugin Name\",\n\tslug: \"Plugin Slug\",\n\turl: \"Plugin URI\",\n\tdescription: \"Description\",\n\tversion: \"Version\",\n\tauthor: \"Author\",\n\tauthorUri: \"Author URI\",\n\ttags: \"Tags\",\n\tlicense: \"License\",\n\tlicenseUri: \"License URI\",\n\tupdateUri: \"Update URI\",\n\tdomainPath: \"Domain Path\",\n\ttextDomain: \"Text Domain\",\n};\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAO,yBAAQ;AAAA,EACd,MAAM;AAAA,EACN,MAAM;AAAA,EACN,KAAK;AAAA,EACL,aAAa;AAAA,EACb,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,WAAW;AAAA,EACX,MAAM;AAAA,EACN,SAAS;AAAA,EACT,YAAY;AAAA,EACZ,WAAW;AAAA,EACX,YAAY;AAAA,EACZ,YAAY;AACb;",
6
+ "names": []
7
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/assets/wp-theme-i18n.ts"],
4
+ "sourcesContent": ["export default {\n\tname: \"Theme Name\",\n\tauthor: \"Author\",\n\tauthorUri: \"Author URI\",\n\tdescription: \"Description\",\n\turl: \"Theme URI\",\n\ttags: \"Tags\",\n\tversion: \"Version\",\n\tlicense: \"License\",\n\tlicenseUri: \"License URI\",\n\tdomainPath: \"Domain Path\",\n\ttextDomain: \"Text Domain\",\n};\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAO,wBAAQ;AAAA,EACd,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,WAAW;AAAA,EACX,aAAa;AAAA,EACb,KAAK;AAAA,EACL,MAAM;AAAA,EACN,SAAS;AAAA,EACT,SAAS;AAAA,EACT,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,YAAY;AACb;",
6
+ "names": []
7
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/cli/getArgs.ts"],
4
+ "sourcesContent": ["import process from \"node:process\";\nimport * as yargs from \"yargs\";\nimport { hideBin } from \"yargs/helpers\";\nimport type { Args, MakeJsonArgs } from \"../types.js\";\nimport { parseCliArgs } from \"./parseCli.js\";\n\n/**\n * Retrieves and returns the command line arguments and options.\n *\n * @return The parsed command line arguments and options.\n */\nexport function getArgs(userArgs = {}): Args | MakeJsonArgs {\n\tconst args = yargs\n\t\t.default(hideBin(process.argv))\n\t\t.help(\"h\")\n\t\t.alias(\"help\", \"help\")\n\t\t.usage(\"Usage: $0 <source> [destination] [options]\")\n\t\t.positional(\"sourceDirectory\", {\n\t\t\tdescribe: \"Source directory\",\n\t\t\ttype: \"string\",\n\t\t})\n\t\t.positional(\"destination\", {\n\t\t\tdescribe: \"Destination directory\",\n\t\t\ttype: \"string\",\n\t\t})\n\t\t.options({\n\t\t\tslug: {\n\t\t\t\tdescribe: \"Plugin or theme slug\",\n\t\t\t\ttype: \"string\",\n\t\t\t},\n\t\t\tdomain: {\n\t\t\t\tdescribe: \"Text domain to look for in the source code\",\n\t\t\t\ttype: \"string\",\n\t\t\t},\n\t\t\t\"skip-js\": {\n\t\t\t\tdescribe: \"Skip JavaScript files\",\n\t\t\t\ttype: \"boolean\",\n\t\t\t},\n\t\t\t\"skip-php\": {\n\t\t\t\tdescribe: \"Skip PHP files\",\n\t\t\t\ttype: \"boolean\",\n\t\t\t},\n\t\t\t\"skip-blade\": {\n\t\t\t\tdescribe: \"Skip Blade files\",\n\t\t\t\ttype: \"boolean\",\n\t\t\t},\n\t\t\t\"skip-block-json\": {\n\t\t\t\tdescribe: \"Skip block.json files\",\n\t\t\t\ttype: \"boolean\",\n\t\t\t},\n\t\t\t\"skip-theme-json\": {\n\t\t\t\tdescribe: \"Skip theme.json files\",\n\t\t\t\ttype: \"boolean\",\n\t\t\t},\n\t\t\t\"skip-audit\": {\n\t\t\t\tdescribe: \"Skip auditing of strings\",\n\t\t\t\ttype: \"boolean\",\n\t\t\t},\n\t\t\theaders: {\n\t\t\t\tdescribe: \"Headers\",\n\t\t\t\ttype: \"string\",\n\t\t\t},\n\t\t\t\"file-comment\": {\n\t\t\t\tdescribe: \"File comment\",\n\t\t\t\ttype: \"string\",\n\t\t\t},\n\t\t\t\"package-name\": {\n\t\t\t\tdescribe: \"Package name\",\n\t\t\t\ttype: \"string\",\n\t\t\t},\n\t\t\tlocation: {\n\t\t\t\tdescribe: \"Include location information\",\n\t\t\t\ttype: \"boolean\",\n\t\t\t},\n\t\t\t\"ignore-domain\": {\n\t\t\t\tdescribe: \"Ignore text domain\",\n\t\t\t\ttype: \"boolean\",\n\t\t\t},\n\t\t\tmergePaths: {\n\t\t\t\tdescribe: \"Merge with existing POT file(s)\",\n\t\t\t\ttype: \"string\",\n\t\t\t},\n\t\t\tsubtractPaths: {\n\t\t\t\tdescribe: \"Subtract strings from existing POT file(s)\",\n\t\t\t\ttype: \"string\",\n\t\t\t},\n\t\t\tsubtractAndMerge: {\n\t\t\t\tdescribe: \"Subtract and merge strings from existing POT file(s)\",\n\t\t\t\ttype: \"boolean\",\n\t\t\t},\n\t\t\tinclude: {\n\t\t\t\tdescribe: \"Include specific files\",\n\t\t\t\ttype: \"string\",\n\t\t\t\tdefault: \"**\",\n\t\t\t},\n\t\t\texclude: {\n\t\t\t\tdescribe: \"Exclude specific files\",\n\t\t\t\ttype: \"string\",\n\t\t\t},\n\t\t\tsilent: {\n\t\t\t\tdescribe: \"No output to stdout\",\n\t\t\t\ttype: \"boolean\",\n\t\t\t\tdefault: false,\n\t\t\t},\n\t\t\tjson: {\n\t\t\t\tdescribe: \"Output the json gettext data\",\n\t\t\t\ttype: \"boolean\",\n\t\t\t},\n\t\t\toutput: {\n\t\t\t\tdescribe: \"Output the gettext data\",\n\t\t\t\ttype: \"boolean\",\n\t\t\t},\n\t\t\tcharset: {\n\t\t\t\tdescribe: \"Charset\",\n\t\t\t\ttype: \"string\",\n\t\t\t\tdefault: \"latin1\",\n\t\t\t},\n\t\t})\n\t\t.parseSync();\n\treturn parseCliArgs({ ...userArgs, ...args });\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAAoB;AACpB,YAAuB;AACvB,qBAAwB;AAExB,sBAA6B;AAOtB,SAAS,QAAQ,WAAW,CAAC,GAAwB;AAC3D,QAAM,OAAO,MACX,YAAQ,wBAAQ,oBAAAA,QAAQ,IAAI,CAAC,EAC7B,KAAK,GAAG,EACR,MAAM,QAAQ,MAAM,EACpB,MAAM,4CAA4C,EAClD,WAAW,mBAAmB;AAAA,IAC9B,UAAU;AAAA,IACV,MAAM;AAAA,EACP,CAAC,EACA,WAAW,eAAe;AAAA,IAC1B,UAAU;AAAA,IACV,MAAM;AAAA,EACP,CAAC,EACA,QAAQ;AAAA,IACR,MAAM;AAAA,MACL,UAAU;AAAA,MACV,MAAM;AAAA,IACP;AAAA,IACA,QAAQ;AAAA,MACP,UAAU;AAAA,MACV,MAAM;AAAA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,IACA,SAAS;AAAA,MACR,UAAU;AAAA,MACV,MAAM;AAAA,MACN,SAAS;AAAA,IACV;AAAA,EACD,CAAC,EACA,UAAU;AACZ,aAAO,8BAAa,EAAE,GAAG,UAAU,GAAG,KAAK,CAAC;AAC7C;",
6
+ "names": ["process"]
7
+ }
@@ -1 +1 @@
1
- "use strict";var c=Object.create;var s=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var g=Object.getOwnPropertyNames;var u=Object.getPrototypeOf,y=Object.prototype.hasOwnProperty;var m=(e,t)=>{for(var r in t)s(e,r,{get:t[r],enumerable:!0})},a=(e,t,r,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of g(t))!y.call(e,o)&&o!==r&&s(e,o,{get:()=>t[o],enumerable:!(i=f(t,o))||i.enumerable});return e};var n=(e,t,r)=>(r=e!=null?c(u(e)):{},a(t||!e||!e.__esModule?s(r,"default",{value:e,enumerable:!0}):r,e)),b=e=>a(s({},"__esModule",{value:!0}),e);var A={};m(A,{getJsonArgs:()=>J});module.exports=b(A);var p=n(require("node:process")),h=n(require("yargs")),d=require("yargs/helpers"),l=require("./parseCli");function J(e={}){const t=h.default((0,d.hideBin)(p.default.argv)).help("h").alias("help","help").usage("Usage: $0 <source> [destination] [options]").positional("source",{describe:"Source directory",type:"string"}).positional("destination",{describe:"Destination directory",type:"string"}).options({scriptName:{describe:"The name of the script to be translated",type:"string"},allowedFormats:{describe:"which extensions to use for translation",type:"array",default:["js"]},purge:{describe:"Remove old JSON files",type:"boolean",default:!0},prettyPrint:{describe:"Pretty print JSON",type:"boolean",default:!1},debug:{describe:"Debug mode",type:"boolean",default:!1}}).parseSync();return(0,l.parseJsonArgs)({...e,...t})}0&&(module.exports={getJsonArgs});
1
+ "use strict";var c=Object.create;var o=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var g=Object.getOwnPropertyNames;var u=Object.getPrototypeOf,y=Object.prototype.hasOwnProperty;var m=(e,t)=>{for(var r in t)o(e,r,{get:t[r],enumerable:!0})},a=(e,t,r,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of g(t))!y.call(e,s)&&s!==r&&o(e,s,{get:()=>t[s],enumerable:!(i=f(t,s))||i.enumerable});return e};var n=(e,t,r)=>(r=e!=null?c(u(e)):{},a(t||!e||!e.__esModule?o(r,"default",{value:e,enumerable:!0}):r,e)),b=e=>a(o({},"__esModule",{value:!0}),e);var A={};m(A,{getJsonArgs:()=>J});module.exports=b(A);var p=n(require("node:process")),h=n(require("yargs")),d=require("yargs/helpers"),l=require("./parseCli.js");function J(e={}){const t=h.default((0,d.hideBin)(p.default.argv)).help("h").alias("help","help").usage("Usage: $0 <source> [destination] [options]").positional("source",{describe:"Source directory",type:"string"}).positional("destination",{describe:"Destination directory",type:"string"}).options({scriptName:{describe:"The name of the script to be translated",type:"string"},allowedFormats:{describe:"which extensions to use for translation",type:"array",default:["js"]},purge:{describe:"Remove old JSON files",type:"boolean",default:!0},prettyPrint:{describe:"Pretty print JSON",type:"boolean",default:!1},debug:{describe:"Debug mode",type:"boolean",default:!1}}).parseSync();return(0,l.parseJsonArgs)({...e,...t})}0&&(module.exports={getJsonArgs});
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/cli/getJsonArgs.ts"],
4
+ "sourcesContent": ["import process from \"node:process\";\nimport * as yargs from \"yargs\";\nimport { hideBin } from \"yargs/helpers\";\nimport type { MakeJsonArgs } from \"../types.js\";\nimport { parseJsonArgs } from \"./parseCli.js\";\n\n/**\n * Parses the command line arguments for the JSON command.\n *\n * @param additionalArgs - Additional arguments to be parsed.\n * @returns The parsed command line arguments.\n */\nexport function getJsonArgs(additionalArgs = {}): MakeJsonArgs {\n\tconst args = yargs\n\t\t.default(hideBin(process.argv))\n\t\t.help(\"h\")\n\t\t.alias(\"help\", \"help\")\n\t\t.usage(\"Usage: $0 <source> [destination] [options]\")\n\t\t.positional(\"source\", {\n\t\t\tdescribe: \"Source directory\",\n\t\t\ttype: \"string\",\n\t\t})\n\t\t.positional(\"destination\", {\n\t\t\tdescribe: \"Destination directory\",\n\t\t\ttype: \"string\",\n\t\t})\n\t\t.options({\n\t\t\tscriptName: {\n\t\t\t\tdescribe: \"The name of the script to be translated\",\n\t\t\t\ttype: \"string\",\n\t\t\t},\n\t\t\tallowedFormats: {\n\t\t\t\tdescribe: \"which extensions to use for translation\",\n\t\t\t\ttype: \"array\",\n\t\t\t\tdefault: [\"js\"],\n\t\t\t},\n\t\t\tpurge: {\n\t\t\t\tdescribe: \"Remove old JSON files\",\n\t\t\t\ttype: \"boolean\",\n\t\t\t\tdefault: true,\n\t\t\t},\n\t\t\tprettyPrint: {\n\t\t\t\tdescribe: \"Pretty print JSON\",\n\t\t\t\ttype: \"boolean\",\n\t\t\t\tdefault: false,\n\t\t\t},\n\t\t\tdebug: {\n\t\t\t\tdescribe: \"Debug mode\",\n\t\t\t\ttype: \"boolean\",\n\t\t\t\tdefault: false,\n\t\t\t},\n\t\t})\n\t\t.parseSync();\n\treturn parseJsonArgs({ ...additionalArgs, ...args });\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAAoB;AACpB,YAAuB;AACvB,qBAAwB;AAExB,sBAA8B;AAQvB,SAAS,YAAY,iBAAiB,CAAC,GAAiB;AAC9D,QAAM,OAAO,MACX,YAAQ,wBAAQ,oBAAAA,QAAQ,IAAI,CAAC,EAC7B,KAAK,GAAG,EACR,MAAM,QAAQ,MAAM,EACpB,MAAM,4CAA4C,EAClD,WAAW,UAAU;AAAA,IACrB,UAAU;AAAA,IACV,MAAM;AAAA,EACP,CAAC,EACA,WAAW,eAAe;AAAA,IAC1B,UAAU;AAAA,IACV,MAAM;AAAA,EACP,CAAC,EACA,QAAQ;AAAA,IACR,YAAY;AAAA,MACX,UAAU;AAAA,MACV,MAAM;AAAA,IACP;AAAA,IACA,gBAAgB;AAAA,MACf,UAAU;AAAA,MACV,MAAM;AAAA,MACN,SAAS,CAAC,IAAI;AAAA,IACf;AAAA,IACA,OAAO;AAAA,MACN,UAAU;AAAA,MACV,MAAM;AAAA,MACN,SAAS;AAAA,IACV;AAAA,IACA,aAAa;AAAA,MACZ,UAAU;AAAA,MACV,MAAM;AAAA,MACN,SAAS;AAAA,IACV;AAAA,IACA,OAAO;AAAA,MACN,UAAU;AAAA,MACV,MAAM;AAAA,MACN,SAAS;AAAA,IACV;AAAA,EACD,CAAC,EACA,UAAU;AACZ,aAAO,+BAAc,EAAE,GAAG,gBAAgB,GAAG,KAAK,CAAC;AACpD;",
6
+ "names": ["process"]
7
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/cli/parseCli.ts"],
4
+ "sourcesContent": ["import fs, { accessSync } from \"node:fs\";\nimport * as path from \"node:path\";\nimport * as process from \"node:process\";\nimport type * as yargs from \"yargs\";\nimport { DEFAULT_EXCLUDED_PATH } from \"../const.js\";\nimport { getEncodingCharset } from \"../fs/fs\";\nimport type { Args, DomainType, MakeJsonArgs } from \"../types.js\";\nimport { stringstring } from \"../utils/common.js\";\n\n/**\n * This function checks if the current working directory is a theme or plugin\n * @param currentPath The current working directory\n * @param slug The slug of the theme or plugin\n */\nfunction isThemeOrPlugin(currentPath = \"/\", slug = \"default\"): DomainType {\n\tconst currentWorkingDirectory = currentPath;\n\n\t/**\n\t * Checks if the current working directory contains a plugin file\n\t */\n\ttry {\n\t\taccessSync(\n\t\t\tpath.join(currentWorkingDirectory, `${slug}.php`),\n\t\t\tfs.constants.R_OK,\n\t\t);\n\t\treturn \"plugin\";\n\t} catch (err) {\n\t\t// do nothing\n\t\tconsole.log(\n\t\t\t`the current working directory ${currentWorkingDirectory} does not contain a ${slug}.php file`,\n\t\t);\n\t}\n\n\t/**\n\t * Checks if the current working directory contains a style.css file and is a theme\n\t */\n\ttry {\n\t\taccessSync(\n\t\t\tpath.join(currentWorkingDirectory, \"style.css\"),\n\t\t\tfs.constants.R_OK,\n\t\t);\n\t\treturn \"theme\";\n\t} catch (err) {\n\t\t// do nothing\n\t\tconsole.log(\n\t\t\t`the current working directory ${currentWorkingDirectory} does not contain a style.css file`,\n\t\t);\n\t}\n\n\t// If none of the above conditions are met, return \"generic\"\n\treturn \"generic\";\n}\n\n/**\n * Parses the command line arguments and returns an object with the parsed values.\n *\n * @param {{_: string[]}} args - The command line arguments to be parsed.\n * @return {object} - An object with the parsed values from the command line arguments.\n */\nexport function parseCliArgs(\n\targs: yargs.PositionalOptions & yargs.Options & yargs.Arguments,\n): Args {\n\t// Get the input and output paths\n\tconst pos1: string | undefined = args._[0]?.toString();\n\tconst pos2: string = args._[1]?.toString() || \"languages\";\n\n\tconst inputPath: string | undefined = pos1 ?? \".\";\n\t// remove \"/\" if the output path starts with it\n\tconst outputPath: string = pos2.startsWith(\"/\") ? pos2.slice(1) : pos2;\n\n\t// Store the current working directory\n\tconst currentWorkingDirectory = process.cwd();\n\n\t// Get the slug or use the basename of the current working directory\n\t// the slug is the plugin or theme slug. Defaults to the source directory\u2019s basename\n\tconst slug =\n\t\targs.slug && typeof args.slug === \"string\"\n\t\t\t? args.slug\n\t\t\t: path.basename(path.resolve(currentWorkingDirectory, inputPath));\n\n\t// Get the relative paths\n\tconst cwd = path.relative(currentWorkingDirectory, inputPath);\n\tconst out = path.relative(currentWorkingDirectory, outputPath);\n\n\t/** get the domain to look for (plugin, theme, etc) */\n\tif (!(args?.domain as DomainType)) {\n\t\targs.domain = isThemeOrPlugin(path.resolve(cwd), slug);\n\t} else {\n\t\tswitch (args.domain) {\n\t\t\tcase \"plugin\":\n\t\t\tcase \"theme\":\n\t\t\tcase \"block\":\n\t\t\tcase \"theme-block\":\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tconsole.error(\n\t\t\t\t\t`Invalid domain: ${args.domain}. Valid domains are: plugin, theme, block, theme-block, generic`,\n\t\t\t\t);\n\t\t\t\t// fallback to generic if the domain is invalid\n\t\t\t\targs.domain = \"generic\";\n\t\t}\n\t}\n\n\tconst parsedArgs: Args = {\n\t\tslug: slug,\n\t\tdomain: args.domain as DomainType,\n\t\tpaths: { cwd: cwd, out: out },\n\t\toptions: {\n\t\t\tignoreDomain: !!args?.ignoreDomain,\n\t\t\tpackageName: String(args.packageName),\n\t\t\tsilent: args.silent === true, // default is false\n\t\t\tjson: !!args.json,\n\t\t\tlocation: !!args?.location,\n\t\t\toutput: !!args?.output,\n\t\t\tfileComment: args.fileComment ? String(args.fileComment) : undefined,\n\t\t\tcharset: getEncodingCharset(args?.charset as string | undefined),\n\t\t\tskip: {\n\t\t\t\tjs: !!args.skipJs,\n\t\t\t\tphp: !!args.skipPhp,\n\t\t\t\tblade: !!args.skipBlade,\n\t\t\t\tblockJson: !!args.skipBlockJson,\n\t\t\t\tthemeJson: !!args.skipThemeJson,\n\t\t\t\taudit: !!args.skipAudit,\n\t\t\t},\n\t\t},\n\t\t// Patterns\n\t\tpatterns: {\n\t\t\tmergePaths: stringstring(args.mergePaths as string),\n\t\t\tsubtractPaths: stringstring(args.subtractPaths as string),\n\t\t\tsubtractAndMerge: !!args.subtractAndMerge,\n\t\t\tinclude: stringstring(args.include as string),\n\t\t\texclude: [\n\t\t\t\t...stringstring(args.exclude as string),\n\t\t\t\t...DEFAULT_EXCLUDED_PATH,\n\t\t\t],\n\t\t},\n\t};\n\n\tparsedArgs.paths.root = args.root ? String(args.root) : undefined;\n\n\treturn parsedArgs;\n}\n\n/**\n * Parses the command line arguments for the JSON command.\n * @param args - The command line arguments to be parsed.\n */\nexport function parseJsonArgs(\n\targs: yargs.PositionalOptions & yargs.Options & yargs.Arguments,\n): MakeJsonArgs {\n\t// Get the input and output paths\n\tconst inputPath: string = (args._[0] as string) || \"build\";\n\tconst outputPath: string = (args._[1] as string) || \"languages\";\n\tconst currentWorkingDirectory = process.cwd();\n\tconst slug = path.basename(path.resolve(currentWorkingDirectory));\n\n\tlet scriptName = undefined;\n\tif (args.scriptName) {\n\t\tscriptName = args.scriptName.split(\",\").map((s) => s.trim());\n\t\tif (scriptName.length === 1) {\n\t\t\tscriptName = scriptName[0];\n\t\t}\n\t}\n\n\treturn {\n\t\ttimeStart: Date.now(),\n\t\tslug,\n\t\tsource: inputPath,\n\t\tdestination: outputPath,\n\t\tscriptName,\n\t\tallowedFormats: args.allowedFormats as string[],\n\t\tpurge: !!args.purge,\n\t\tprettyPrint: !!args.prettyPrint,\n\t\tdebug: !!args.debug,\n\t\tpaths: {\n\t\t\tcwd: currentWorkingDirectory,\n\t\t\tout: path.join(currentWorkingDirectory, outputPath),\n\t\t},\n\t};\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAA+B;AAC/B,WAAsB;AACtB,cAAyB;AAEzB,mBAAsC;AACtC,gBAAmC;AAEnC,oBAA6B;AAO7B,SAAS,gBAAgB,cAAc,KAAK,OAAO,WAAuB;AACzE,QAAM,0BAA0B;AAKhC,MAAI;AACH;AAAA,MACC,KAAK,KAAK,yBAAyB,GAAG,IAAI,MAAM;AAAA,MAChD,eAAAA,QAAG,UAAU;AAAA,IACd;AACA,WAAO;AAAA,EACR,SAAS,KAAK;AAEb,YAAQ;AAAA,MACP,iCAAiC,uBAAuB,uBAAuB,IAAI;AAAA,IACpF;AAAA,EACD;AAKA,MAAI;AACH;AAAA,MACC,KAAK,KAAK,yBAAyB,WAAW;AAAA,MAC9C,eAAAA,QAAG,UAAU;AAAA,IACd;AACA,WAAO;AAAA,EACR,SAAS,KAAK;AAEb,YAAQ;AAAA,MACP,iCAAiC,uBAAuB;AAAA,IACzD;AAAA,EACD;AAGA,SAAO;AACR;AAQO,SAAS,aACf,MACO;AAEP,QAAM,OAA2B,KAAK,EAAE,CAAC,GAAG,SAAS;AACrD,QAAM,OAAe,KAAK,EAAE,CAAC,GAAG,SAAS,KAAK;AAE9C,QAAM,YAAgC,QAAQ;AAE9C,QAAM,aAAqB,KAAK,WAAW,GAAG,IA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=Object.create;var n=Object.defineProperty;var l=Object.getOwnPropertyDescriptor;var A=Object.getOwnPropertyNames;var y=Object.getPrototypeOf,J=Object.prototype.hasOwnProperty;var b=(o,r,e,a)=>{if(r&&typeof r=="object"||typeof r=="function")for(let s of A(r))!J.call(o,s)&&s!==e&&n(o,s,{get:()=>r[s],enumerable:!(a=l(r,s))||a.enumerable});return o};var m=(o,r,e)=>(e=o!=null?d(y(o)):{},b(r||!o||!o.__esModule?n(e,"default",{value:o,enumerable:!0}):e,o));var t=m(require("node:process")),c=m(require("yargs")),i=require("yargs/helpers"),p=require("./cli/getArgs.js"),f=require("./cli/getJsonArgs"),g=m(require("./jsonCommand")),k=m(require("./potCommand"));const j=c.default((0,i.hideBin)(t.default.argv)).options({makejson:{describe:"Make JSON file",type:"boolean",default:!1}}).parseSync();j.makejson?(0,g.default)((0,f.getJsonArgs)()):(0,k.default)((0,p.getArgs)());
2
+ "use strict";var d=Object.create;var n=Object.defineProperty;var l=Object.getOwnPropertyDescriptor;var A=Object.getOwnPropertyNames;var y=Object.getPrototypeOf,J=Object.prototype.hasOwnProperty;var b=(o,r,s,a)=>{if(r&&typeof r=="object"||typeof r=="function")for(let e of A(r))!J.call(o,e)&&e!==s&&n(o,e,{get:()=>r[e],enumerable:!(a=l(r,e))||a.enumerable});return o};var m=(o,r,s)=>(s=o!=null?d(y(o)):{},b(r||!o||!o.__esModule?n(s,"default",{value:o,enumerable:!0}):s,o));var t=m(require("node:process")),c=m(require("yargs")),i=require("yargs/helpers"),p=require("./cli/getArgs.js"),f=require("./cli/getJsonArgs.js"),g=m(require("./jsonCommand.js")),k=m(require("./potCommand.js"));const j=c.default((0,i.hideBin)(t.default.argv)).options({makejson:{describe:"Make JSON file",type:"boolean",default:!1}}).parseSync();j.makejson?(0,g.default)((0,f.getJsonArgs)()):(0,k.default)((0,p.getArgs)());
package/lib/cli.js.map ADDED
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/cli.ts"],
4
+ "sourcesContent": ["#!/usr/bin/env node\n\nimport process from \"node:process\";\nimport * as yargs from \"yargs\";\nimport { hideBin } from \"yargs/helpers\";\nimport { getArgs } from \"./cli/getArgs.js\";\nimport { getJsonArgs } from \"./cli/getJsonArgs.js\";\nimport makeJsonCommand from \"./jsonCommand.js\";\nimport makepotCommand from \"./potCommand.js\";\nimport type { Args, MakeJsonArgs } from \"./types.js\";\n\n/** Main execution */\n// Get the selected command\nconst r = yargs\n\t.default(hideBin(process.argv))\n\t.options({\n\t\tmakejson: {\n\t\t\tdescribe: \"Make JSON file\",\n\t\t\ttype: \"boolean\",\n\t\t\tdefault: false,\n\t\t},\n\t})\n\t.parseSync() as { makejson: boolean };\n\n// Execute the command\nif (!r.makejson) {\n\tmakepotCommand(getArgs() as Args);\n} else {\n\tmakeJsonCommand(getJsonArgs() as MakeJsonArgs);\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAEA,0BAAoB;AACpB,YAAuB;AACvB,qBAAwB;AACxB,qBAAwB;AACxB,yBAA4B;AAC5B,yBAA4B;AAC5B,wBAA2B;AAK3B,MAAM,IAAI,MACR,YAAQ,wBAAQ,oBAAAA,QAAQ,IAAI,CAAC,EAC7B,QAAQ;AAAA,EACR,UAAU;AAAA,IACT,UAAU;AAAA,IACV,MAAM;AAAA,IACN,SAAS;AAAA,EACV;AACD,CAAC,EACA,UAAU;AAGZ,IAAI,CAAC,EAAE,UAAU;AAChB,wBAAAC,aAAe,wBAAQ,CAAS;AACjC,OAAO;AACN,yBAAAC,aAAgB,gCAAY,CAAiB;AAC9C;",
6
+ "names": ["process", "makepotCommand", "makeJsonCommand"]
7
+ }
package/lib/const.js CHANGED
@@ -1 +1 @@
1
- "use strict";var c=Object.create;var _=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var u=Object.getPrototypeOf,f=Object.prototype.hasOwnProperty;var b=(t,e)=>{for(var m in e)_(t,m,{get:e[m],enumerable:!0})},n=(t,e,m,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of l(e))!f.call(t,s)&&s!==m&&_(t,s,{get:()=>e[s],enumerable:!(i=p(e,s))||i.enumerable});return t};var o=(t,e,m)=>(m=t!=null?c(u(t)):{},n(e||!t||!t.__esModule?_(m,"default",{value:t,enumerable:!0}):m,t)),h=t=>n(_({},"__esModule",{value:!0}),t);var U={};b(U,{DEFAULT_EXCLUDED_PATH:()=>D,IsoCodeRegex:()=>E,allowedFormats:()=>L,blockJson:()=>k,defaultLocale:()=>J,fileRegex:()=>F,i18nFunctions:()=>T,pkgJsonHeaders:()=>w,pluginHeaders:()=>H,themeHeaders:()=>A,themeJson:()=>j});module.exports=h(U);var d=o(require("./assets/block-i18n.js")),x=o(require("./assets/package-i18n.js")),g=o(require("./assets/theme-i18n.js")),a=o(require("./assets/wp-plugin-i18n.js")),r=o(require("./assets/wp-theme-i18n.js"));const j=g.default,k=d.default,w=x.default,H=a.default,A=r.default,D=[".git","node_modules","vendor","build","dist","uploads","Gruntfile.js","webpack.config.js","**/*.min.js","tsconfig.js","**.test.**","tests"],E=/-([a-z]{2}_[A-Z]{2})\.po$/,F=/#:\s*(.*?)(?::\d+)?$/,J="en_US",L=["php","js","jsx","ts","tsx","mjs","cjs"],T={__:["msgid","text_domain"],esc_attr__:["msgid","text_domain"],esc_html__:["msgid","text_domain"],esc_xml__:["msgid","text_domain"],_e:["msgid","text_domain"],esc_attr_e:["msgid","text_domain"],esc_html_e:["msgid","text_domain"],esc_xml_e:["msgid","text_domain"],_x:["msgid","msgctxt","text_domain"],_ex:["msgid","msgctxt","text_domain"],esc_attr_x:["msgid","msgctxt","text_domain"],esc_html_x:["msgid","msgctxt","text_domain"],esc_xml_x:["msgid","msgctxt","text_domain"],_n:["msgid","msgid_plural","number","text_domain"],_nx:["msgid","msgid_plural","number","msgctxt","text_domain"],_n_noop:["msgid","msgid_plural","text_domain"],_nx_noop:["msgid","msgid_plural","msgctxt","text_domain"],_:["msgid","text_domain"],_c:["msgid","text_domain"],_nc:["msgid","msgid_plural","number","text_domain"],__ngettext:["msgid","msgid_plural","number","text_domain"],__ngettext_noop:["msgid","msgid_plural","text_domain"]};0&&(module.exports={DEFAULT_EXCLUDED_PATH,IsoCodeRegex,allowedFormats,blockJson,defaultLocale,fileRegex,i18nFunctions,pkgJsonHeaders,pluginHeaders,themeHeaders,themeJson});
1
+ "use strict";var r=Object.create;var _=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var l=Object.getPrototypeOf,u=Object.prototype.hasOwnProperty;var f=(t,e)=>{for(var m in e)_(t,m,{get:e[m],enumerable:!0})},d=(t,e,m,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of p(e))!u.call(t,s)&&s!==m&&_(t,s,{get:()=>e[s],enumerable:!(i=c(e,s))||i.enumerable});return t};var o=(t,e,m)=>(m=t!=null?r(l(t)):{},d(e||!t||!t.__esModule?_(m,"default",{value:t,enumerable:!0}):m,t)),h=t=>d(_({},"__esModule",{value:!0}),t);var P={};f(P,{DEFAULT_EXCLUDED_PATH:()=>H,IsoCodeRegex:()=>k,allowedFormats:()=>E,defaultLocale:()=>D,fileRegex:()=>A,i18nFunctions:()=>F,modulePath:()=>L,pkgJsonHeaders:()=>j,pluginHeaders:()=>b,themeHeaders:()=>w});module.exports=h(P);var n=o(require("node:path")),x=o(require("./assets/package-i18n.js")),a=o(require("./assets/wp-plugin-i18n.js")),g=o(require("./assets/wp-theme-i18n.js"));const j=x.default,b=a.default,w=g.default,H=[".git","node_modules","vendor","build","dist","uploads","Gruntfile.js","webpack.config.js","**/*.min.js","tsconfig.js","**.test.**","tests"],k=/-([a-z]{2}_[A-Z]{2})\.po$/,A=/#:\s*(.*?)(?::\d+)?$/,D="en_US",E=["php","js","jsx","ts","tsx","mjs","cjs"],F={__:["msgid","text_domain"],esc_attr__:["msgid","text_domain"],esc_html__:["msgid","text_domain"],esc_xml__:["msgid","text_domain"],_e:["msgid","text_domain"],esc_attr_e:["msgid","text_domain"],esc_html_e:["msgid","text_domain"],esc_xml_e:["msgid","text_domain"],_x:["msgid","msgctxt","text_domain"],_ex:["msgid","msgctxt","text_domain"],esc_attr_x:["msgid","msgctxt","text_domain"],esc_html_x:["msgid","msgctxt","text_domain"],esc_xml_x:["msgid","msgctxt","text_domain"],_n:["msgid","msgid_plural","number","text_domain"],_nx:["msgid","msgid_plural","number","msgctxt","text_domain"],_n_noop:["msgid","msgid_plural","text_domain"],_nx_noop:["msgid","msgid_plural","msgctxt","text_domain"],_:["msgid","text_domain"],_c:["msgid","text_domain"],_nc:["msgid","msgid_plural","number","text_domain"],__ngettext:["msgid","msgid_plural","number","text_domain"],__ngettext_noop:["msgid","msgid_plural","text_domain"]},L=n.default.resolve(__dirname,"..");0&&(module.exports={DEFAULT_EXCLUDED_PATH,IsoCodeRegex,allowedFormats,defaultLocale,fileRegex,i18nFunctions,modulePath,pkgJsonHeaders,pluginHeaders,themeHeaders});
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/const.ts"],
4
+ "sourcesContent": ["import path from \"node:path\";\nimport packagei18n from \"./assets/package-i18n.js\";\nimport wpPlugini18n from \"./assets/wp-plugin-i18n.js\";\nimport wpThemei18n from \"./assets/wp-theme-i18n.js\";\n\n/**\n * Theme Json metadata headers\n *\n */\nexport const pkgJsonHeaders = packagei18n;\n/**\n * The Plugin metadata headers\n * @link https://codex.wordpress.org/File_Header\n */\nexport const pluginHeaders = wpPlugini18n;\n/**\n * The Theme metadata headers\n * @link https://developer.wordpress.org/plugins/plugin-basics/header-requirements/\n */\nexport const themeHeaders = wpThemei18n;\n\n/**\n * The default list of paths to exclude from the pot file.\n * @link https://www.npmjs.com/package/glob#glob-primer\n */\nexport const DEFAULT_EXCLUDED_PATH = [\n\t\".git\",\n\t\"node_modules\",\n\t\"vendor\",\n\t\"build\",\n\t\"dist\",\n\t\"uploads\",\n\t\"Gruntfile.js\",\n\t\"webpack.config.js\",\n\t\"**/*.min.js\",\n\t\"tsconfig.js\",\n\t\"**.test.**\",\n\t\"tests\",\n];\n\n/**\n * The regex used to find the locale in the source code\n */\nexport const IsoCodeRegex = /-([a-z]{2}_[A-Z]{2})\\.po$/;\n\n/**\n * The regex used to find the filename in the source code\n */\nexport const fileRegex = /#:\\s*(.*?)(?::\\d+)?$/;\n\nexport const defaultLocale = \"en_US\";\n\n/**\n * The files that are allowed to be parsed using tree sitter\n *\n * Json and text files are parsed in a different way\n */\nexport const allowedFormats = [\"php\", \"js\", \"jsx\", \"ts\", \"tsx\", \"mjs\", \"cjs\"];\n\n/**\n * The default functions to use for i18n.\n */\nexport const i18nFunctions = {\n\t__: [\"msgid\", \"text_domain\"],\n\tesc_attr__: [\"msgid\", \"text_domain\"],\n\tesc_html__: [\"msgid\", \"text_domain\"],\n\tesc_xml__: [\"msgid\", \"text_domain\"],\n\t_e: [\"msgid\", \"text_domain\"],\n\tesc_attr_e: [\"msgid\", \"text_domain\"],\n\tesc_html_e: [\"msgid\", \"text_domain\"],\n\tesc_xml_e: [\"msgid\", \"text_domain\"],\n\t_x: [\"msgid\", \"msgctxt\", \"text_domain\"],\n\t_ex: [\"msgid\", \"msgctxt\", \"text_domain\"],\n\tesc_attr_x: [\"msgid\", \"msgctxt\", \"text_domain\"],\n\tesc_html_x: [\"msgid\", \"msgctxt\", \"text_domain\"],\n\tesc_xml_x: [\"msgid\", \"msgctxt\", \"text_domain\"],\n\t_n: [\"msgid\", \"msgid_plural\", \"number\", \"text_domain\"],\n\t_nx: [\"msgid\", \"msgid_plural\", \"number\", \"msgctxt\", \"text_domain\"],\n\t_n_noop: [\"msgid\", \"msgid_plural\", \"text_domain\"],\n\t_nx_noop: [\"msgid\", \"msgid_plural\", \"msgctxt\", \"text_domain\"],\n\n\t// Compat.\n\t_: [\"msgid\", \"text_domain\"],\n\n\t// Deprecated.\n\t_c: [\"msgid\", \"text_domain\"],\n\t_nc: [\"msgid\", \"msgid_plural\", \"number\", \"text_domain\"],\n\t__ngettext: [\"msgid\", \"msgid_plural\", \"number\", \"text_domain\"],\n\t__ngettext_noop: [\"msgid\", \"msgid_plural\", \"text_domain\"],\n};\n\n/**\n * @var modulePath The path to the module folder containing this file\n */\nexport const modulePath = path.resolve(__dirname, \"..\");\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAAiB;AACjB,0BAAwB;AACxB,4BAAyB;AACzB,2BAAwB;AAMjB,MAAM,iBAAiB,oBAAAA;AAKvB,MAAM,gBAAgB,sBAAAC;AAKtB,MAAM,eAAe,qBAAAC;AAMrB,MAAM,wBAAwB;AAAA,EACpC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD;AAKO,MAAM,eAAe;AAKrB,MAAM,YAAY;AAElB,MAAM,gBAAgB;AAOtB,MAAM,iBAAiB,CAAC,OAAO,MAAM,OAAO,MAAM,OAAO,OAAO,KAAK;AAKrE,MAAM,gBAAgB;AAAA,EAC5B,IAAI,CAAC,SAAS,aAAa;AAAA,EAC3B,YAAY,CAAC,SAAS,aAAa;AAAA,EACnC,YAAY,CAAC,SAAS,aAAa;AAAA,EACnC,WAAW,CAAC,SAAS,aAAa;AAAA,EAClC,IAAI,CAAC,SAAS,aAAa;AAAA,EAC3B,YAAY,CAAC,SAAS,aAAa;AAAA,EACnC,YAAY,CAAC,SAAS,aAAa;AAAA,EACnC,WAAW,CAAC,SAAS,aAAa;AAAA,EAClC,IAAI,CAAC,SAAS,WAAW,aAAa;AAAA,EACtC,KAAK,CAAC,SAAS,WAAW,aAAa;AAAA,EACvC,YAAY,CAAC,SAAS,WAAW,aAAa;AAAA,EAC9C,YAAY,CAAC,SAAS,WAAW,aAAa;AAAA,EAC9C,WAAW,CAAC,SAAS,WAAW,aAAa;AAAA,EAC7C,IAAI,CAAC,SAAS,gBAAgB,UAAU,aAAa;AAAA,EACrD,KAAK,CAAC,SAAS,gBAAgB,UAAU,WAAW,aAAa;AAAA,EACjE,SAAS,CAAC,SAAS,gBAAgB,aAAa;AAAA,EAChD,UAAU,CAAC,SAAS,gBAAgB,WAAW,aAAa;AAAA;AAAA,EAG5D,GAAG,CAAC,SAAS,aAAa;AAAA;AAAA,EAG1B,IAAI,CAAC,SAAS,aAAa;AAAA,EAC3B,KAAK,CAAC,SAAS,gBAAgB,UAAU,aAAa;AAAA,EACtD,YAAY,CAAC,SAAS,gBAAgB,UAAU,aAAa;AAAA,EAC7D,iBAAiB,CAAC,SAAS,gBAAgB,aAAa;AACzD;AAKO,MAAM,aAAa,iBAAAC,QAAK,QAAQ,WAAW,IAAI;",
6
+ "names": ["packagei18n", "wpPlugini18n", "wpThemei18n", "path"]
7
+ }
@@ -1 +1 @@
1
- "use strict";var u=Object.create;var i=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var C=Object.getOwnPropertyNames;var T=Object.getPrototypeOf,j=Object.prototype.hasOwnProperty;var k=(e,t)=>{for(var o in t)i(e,o,{get:t[o],enumerable:!0})},l=(e,t,o,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of C(t))!j.call(e,r)&&r!==o&&i(e,r,{get:()=>t[r],enumerable:!(n=x(t,r))||n.enumerable});return e};var a=(e,t,o)=>(o=e!=null?u(T(e)):{},l(t||!e||!e.__esModule?i(o,"default",{value:e,enumerable:!0}):o,e)),B=e=>l(i({},"__esModule",{value:!0}),e);var F={};k(F,{extractCssThemeData:()=>D});module.exports=B(F);var m=a(require("node:fs")),h=a(require("node:path")),d=require("../const.js"),p=require("../utils/common.js"),y=require("./text.js"),g=require("./utils.js");function D(e){let t={};const o=h.default.join(e.paths.cwd,"style.css");if(m.default.existsSync(o)){const n=m.default.readFileSync(o,"utf8"),r=(0,p.getCommentBlock)(n);if(t=(0,y.extractFileData)(r),"Theme Name"in t){console.log(`\u{1F535} Theme stylesheet detected. ${o}`),e.domain="theme";const c={};for(const s of Object.entries(t))if(s?.[0]&&s[1]){const f=(0,g.getKeyByValue)(d.themeHeaders,s[0].trim());if(f===void 0)continue;c[f]=s[1].trim()}return c}}else console.log(`Theme stylesheet not found in ${o}`);return{}}0&&(module.exports={extractCssThemeData});
1
+ "use strict";var x=Object.create;var i=Object.defineProperty;var C=Object.getOwnPropertyDescriptor;var T=Object.getOwnPropertyNames;var j=Object.getPrototypeOf,k=Object.prototype.hasOwnProperty;var B=(e,t)=>{for(var o in t)i(e,o,{get:t[o],enumerable:!0})},l=(e,t,o,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of T(t))!k.call(e,n)&&n!==o&&i(e,n,{get:()=>t[n],enumerable:!(r=C(t,n))||r.enumerable});return e};var a=(e,t,o)=>(o=e!=null?x(j(e)):{},l(t||!e||!e.__esModule?i(o,"default",{value:e,enumerable:!0}):o,e)),D=e=>l(i({},"__esModule",{value:!0}),e);var R={};B(R,{extractCssThemeData:()=>F});module.exports=D(R);var m=a(require("node:fs")),d=a(require("node:path")),h=require("../const.js"),p=require("../utils/common.js"),g=require("../utils/extractors.js"),y=require("./text.js");function F(e,t="style.css"){let o={};const r=d.default.join(e.paths.cwd,t);if(m.default.existsSync(r)){const n=m.default.readFileSync(r,"utf8"),u=(0,p.getCommentBlock)(n);if(o=(0,y.extractFileData)(u),"Theme Name"in o){console.log(`\u{1F535} Theme stylesheet detected. ${r}`),e.domain="theme";const c={};for(const s of Object.entries(o))if(s?.[0]&&s[1]){const f=(0,g.getKeyByValue)(h.themeHeaders,s[0].trim());if(f===void 0)continue;c[f]=s[1].trim()}return c}}else console.log(`Theme stylesheet not found in ${r}`);return{}}0&&(module.exports={extractCssThemeData});
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/extractors/css.ts"],
4
+ "sourcesContent": ["import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { themeHeaders } from \"../const.js\";\nimport type { Args } from \"../types.js\";\nimport { getCommentBlock } from \"../utils/common.js\";\nimport { getKeyByValue } from \"../utils/extractors.js\";\nimport { extractFileData } from \"./text.js\";\n\n/**\n * Extracts the theme data from the style.css file.\n * @param args - The command line arguments.\n * @param filename - The name of the style.css file.\n */\nexport function extractCssThemeData(\n\targs: Args,\n\tfilename = \"style.css\",\n): Record<string, string> {\n\tlet fileData: Record<string, string> = {};\n\tconst styleCssFile = path.join(args.paths.cwd, filename);\n\n\tif (fs.existsSync(styleCssFile)) {\n\t\tconst fileContent = fs.readFileSync(styleCssFile, \"utf8\");\n\t\tconst commentBlock = getCommentBlock(fileContent);\n\t\tfileData = extractFileData(commentBlock);\n\n\t\tif (\"Theme Name\" in fileData) {\n\t\t\tconsole.log(`\uD83D\uDD35 Theme stylesheet detected. ${styleCssFile}`);\n\t\t\targs.domain = \"theme\";\n\n\t\t\tconst themeInfo: Record<string, string> = {};\n\n\t\t\t// Loop through the theme headers and extract the values with the required format\n\t\t\tfor (const keyValueMatch of Object.entries(fileData)) {\n\t\t\t\t// Check if the line matches the expected format\n\t\t\t\tif (keyValueMatch?.[0] && keyValueMatch[1]) {\n\t\t\t\t\t// filter the retrieved headers\n\t\t\t\t\tconst header = getKeyByValue(themeHeaders, keyValueMatch[0].trim());\n\t\t\t\t\tif (header === undefined) continue;\n\t\t\t\t\tthemeInfo[header] = keyValueMatch[1].trim();\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn themeInfo;\n\t\t}\n\t} else {\n\t\tconsole.log(`Theme stylesheet not found in ${styleCssFile}`);\n\t}\n\treturn {};\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAAe;AACf,uBAAiB;AACjB,mBAA6B;AAE7B,oBAAgC;AAChC,wBAA8B;AAC9B,kBAAgC;AAOzB,SAAS,oBACf,MACA,WAAW,aACc;AACzB,MAAI,WAAmC,CAAC;AACxC,QAAM,eAAe,iBAAAA,QAAK,KAAK,KAAK,MAAM,KAAK,QAAQ;AAEvD,MAAI,eAAAC,QAAG,WAAW,YAAY,GAAG;AAChC,UAAM,cAAc,eAAAA,QAAG,aAAa,cAAc,MAAM;AACxD,UAAM,mBAAe,+BAAgB,WAAW;AAChD,mBAAW,6BAAgB,YAAY;AAEvC,QAAI,gBAAgB,UAAU;AAC7B,cAAQ,IAAI,wCAAiC,YAAY,EAAE;AAC3D,WAAK,SAAS;AAEd,YAAM,YAAoC,CAAC;AAG3C,iBAAW,iBAAiB,OAAO,QAAQ,QAAQ,GAAG;AAErD,YAAI,gBAAgB,CAAC,KAAK,cAAc,CAAC,GAAG;AAE3C,gBAAM,aAAS,iCAAc,2BAAc,cAAc,CAAC,EAAE,KAAK,CAAC;AAClE,cAAI,WAAW,OAAW;AAC1B,oBAAU,MAAM,IAAI,cAAc,CAAC,EAAE,KAAK;AAAA,QAC3C;AAAA,MACD;AAEA,aAAO;AAAA,IACR;AAAA,EACD,OAAO;AACN,YAAQ,IAAI,iCAAiC,YAAY,EAAE;AAAA,EAC5D;AACA,SAAO,CAAC;AACT;",
6
+ "names": ["path", "fs"]
7
+ }
@@ -1,6 +1,6 @@
1
- "use strict";var m=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var b=Object.getOwnPropertyNames;var y=Object.prototype.hasOwnProperty;var I=(e,t)=>{for(var o in t)m(e,o,{get:t[o],enumerable:!0})},P=(e,t,o,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of b(t))!y.call(e,r)&&r!==o&&m(e,r,{get:()=>t[r],enumerable:!(n=T(t,r))||n.enumerable});return e};var H=e=>P(m({},"__esModule",{value:!0}),e);var R={};I(R,{extractMainFileData:()=>x,generateHeader:()=>U,translationsHeaders:()=>E});module.exports=H(R);var d=require("gettext-merger"),f=require("../fs/fs"),u=require("../utils/common"),g=require("./css.js"),p=require("./php.js"),l=require("./utils.js");function M(e){const o=[{key:"slug",name:"Plugin/Theme slug",placeholder:"PLUGIN NAME"},{key:"author",name:"Author name",placeholder:"AUTHOR"},{key:"version",name:"Version",placeholder:""},{key:"email",name:"Author email",placeholder:"AUTHOR EMAIL"},{key:"domain",name:"Text domain",placeholder:"PLUGIN TEXTDOMAIN"}].filter(n=>!e[n.key]||e[n.key]===n.placeholder||n.key==="version"&&e[n.key]==="0.0.1");if(o.length>0){console.error(`
1
+ "use strict";var P=Object.create;var c=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var I=Object.getOwnPropertyNames;var H=Object.getPrototypeOf,M=Object.prototype.hasOwnProperty;var O=(e,t)=>{for(var n in t)c(e,n,{get:t[n],enumerable:!0})},h=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of I(t))!M.call(e,r)&&r!==n&&c(e,r,{get:()=>t[r],enumerable:!(o=T(t,r))||o.enumerable});return e};var $=(e,t,n)=>(n=e!=null?P(H(e)):{},h(t||!e||!e.__esModule?c(n,"default",{value:e,enumerable:!0}):n,e)),w=e=>h(c({},"__esModule",{value:!0}),e);var L={};O(L,{extractMainFileData:()=>E,generateHeader:()=>U,getAuthorFromPackage:()=>y,translationsHeaders:()=>v});module.exports=w(L);var f=$(require("node:path")),g=require("gettext-merger"),p=require("../const.js"),A=require("../fs/fs.js"),u=require("../utils/common.js"),l=require("../utils/extractors.js"),k=require("./css.js"),b=require("./php.js");function x(e){const n=[{key:"slug",name:"Plugin/Theme slug",placeholder:"PLUGIN NAME"},{key:"author",name:"Author name",placeholder:"AUTHOR"},{key:"version",name:"Version",placeholder:""},{key:"email",name:"Author email",placeholder:"AUTHOR EMAIL"},{key:"xDomain",name:"Text domain",placeholder:"PLUGIN TEXTDOMAIN"}].filter(o=>!e[o.key]||e[o.key]===o.placeholder||o.key==="version"&&e[o.key]==="0.0.1");if(n.length>0){console.error(`
2
2
  ! Missing required information for POT file header:
3
- `);for(const n of o)console.error(` - ${n.name} is missing or has a default value (eg. version: 0.0.1, author: AUTHOR EMAIL)`);return console.error(`
3
+ `);for(const o of n)console.error(` - ${o.name} is missing or has a default value (eg. version: 0.0.1, author: "AUTHOR <EMAIL>")`);return console.error(`
4
4
  Please provide this information adding the missing fields inside the headers object of the plugin/theme declaration or to the package.json file.`,`
5
5
  For more information check the documentation at https://github.com/wp-blocks/makePot`),console.error(`
6
- `),!1}return!0}function h(e){const t={name:"AUTHOR",email:"AUTHOR EMAIL"};if(!e)return t;if(typeof e=="string"){const o=e.match(/<([^>]+)>/),n=o?o[1].trim():void 0,r=e.match(/\(([^)]+)\)/),a=r?r[1].trim():void 0;let i=e.trim();return o&&(i=i.replace(o[0],"").trim()),r&&(i=i.replace(r[0],"").trim()),{name:i,email:n,website:a}}if(typeof e=="object")return{name:e.name,email:e.email,website:e.website}}function O(e){const t=["author","authors","contributors","maintainers"];for(const o of t)if(e[o]){let n;if(typeof e[o]=="string")n=h(e[o]);else if(typeof e[o]=="object"){for(const r of e[o])if(r&&(n=h(r),n))break}if(n?.name!=="AUTHOR"||n?.email!=="AUTHOR EMAIL")return n}return{name:"AUTHOR",email:"AUTHOR EMAIL"}}function $(e){const{author:t,textDomain:o}=e.headers,n=(0,u.getPkgJsonData)("name","version","author","authors","contributors","maintainers"),r=`https://wordpress.org/support/${e.domain==="theme"?"themes":"plugins"}/${e.slug}`,a=O(n),i=e.headers?.author||a?.name,c=a?.email,s=`${t} <${c}>`,A=process.cwd().split("/").pop()?.toLowerCase().replace(" ","-"),k=e.slug||A||(e.domain==="theme"?"THEME NAME":"PLUGIN NAME");return{...e.headers,author:i,authorString:s,slug:k,email:c,bugs:r,license:e.headers?.license||"gpl-2.0 or later",version:e.headers?.version||n.version||"0.0.1",language:"en",domain:e.headers?.textDomain||e.headers?.slug||"PLUGIN TEXTDOMAIN",xDomain:o}}async function U(e){const t=$(e),{name:o,version:n}=(0,u.getPkgJsonData)("name","version");if(!M(t))return process.exit(1),null;const r={"Project-Id-Version":`${t.slug} ${t.version}`,"Report-Msgid-Bugs-To":t.authorString,"MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","content-type":`text/plain; charset=${(0,f.getEncodingCharset)(e.options?.charset)}`,"plural-forms":"nplurals=2; plural=(n!=1);","POT-Creation-Date":`${new Date().toISOString()}`,"PO-Revision-Date":`${new Date().getFullYear()}-MO-DA HO:MI+ZONE`,"Last-Translator":t.authorString,"Language-Team":t.authorString,"X-Generator":`${o} ${n}`,Language:`${t.language}`};return t.xDomain&&(r["X-Domain"]=t.xDomain),r}function x(e){let t={};return["plugin","block","generic"].includes(e.domain)?t=(0,p.extractPhpPluginData)(e):["theme","theme-block"].includes(e.domain)?t=(0,g.extractCssThemeData)(e):console.log("No main file detected."),t}function E(e){const{domain:t,headers:o}=e,{name:n,description:r,author:a,authorUri:i,url:c}=o,s=t==="plugin"?`${e.slug}.php`:"style.css";return new d.SetOfBlocks([(0,l.gentranslation)(`Name of the ${t}`,n,s),(0,l.gentranslation)(`Url of the ${t}`,c,s),(0,l.gentranslation)(`Description of the ${t}`,r,s),(0,l.gentranslation)(`Author of the ${t}`,a,s),(0,l.gentranslation)(`Author URI of the ${t}`,i,s)])}0&&(module.exports={extractMainFileData,generateHeader,translationsHeaders});
6
+ `),!1}return!0}function d(e){const t={name:"AUTHOR",email:"AUTHOR EMAIL"};if(!e)return t;if(typeof e=="string"){const n=e.match(/<([^>]+)>/),o=n?n[1].trim():void 0,r=e.match(/\(([^)]+)\)/),a=r?r[1].trim():void 0;let i=e.trim();return n&&(i=i.replace(n[0],"").trim()),r&&(i=i.replace(r[0],"").trim()),{name:i,email:o,website:a}}if(typeof e=="object")return{name:e.name,email:e.email,website:e.website}}function y(e){const t=["author","authors","contributors","maintainers"];for(const n of t)if(e[n]){let o;if(typeof e[n]=="string")o=d(e[n]);else if(typeof e[n]=="object"){for(const r of e[n])if(r&&(o=d(r),o))break}if(o?.name!=="AUTHOR"||o?.email!=="AUTHOR EMAIL")return o}return{name:"AUTHOR",email:"AUTHOR EMAIL"}}function R(e){const t=(0,u.getPkgJsonData)(e.paths?.cwd,"name","version","author","authors","contributors","maintainers"),n=`https://wordpress.org/support/${e.domain==="theme"?"themes":"plugins"}/${e.slug}`,o=y(t),r=e?.headers?.author||o?.name,a=o?.email,i=`${r} <${a}>`,m=f.default.basename(e.paths?.cwd||process.cwd())?.toLowerCase().replace(" ","-"),s=e.slug||m||(e.domain==="theme"?"THEME NAME":"PLUGIN NAME");return{...e.headers,author:r,authorString:i,slug:s,email:a,bugs:n,license:e.headers?.license||"gpl-2.0 or later",version:e.headers?.version||t.version||"0.0.1",language:"en",xDomain:e.headers?.textDomain||s}}async function U(e){const t=R(e),{name:n,version:o}=(0,u.getPkgJsonData)(p.modulePath,"name","version");return x(t)?{"Project-Id-Version":`${t.slug} ${t.version}`,"Report-Msgid-Bugs-To":t.authorString,"MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","content-type":`text/plain; charset=${(0,A.getEncodingCharset)(e.options?.charset)}`,"plural-forms":"nplurals=2; plural=(n!=1);","POT-Creation-Date":`${new Date().toISOString()}`,"PO-Revision-Date":`${new Date().getFullYear()}-MO-DA HO:MI+ZONE`,"Last-Translator":t.authorString,"Language-Team":t.authorString,"X-Generator":`${n} ${o}`,Language:`${t.language}`,"X-Domain":t.xDomain}:(process.exit(1),null)}function E(e){let t={};return["plugin","block","generic"].includes(e.domain)?t=(0,b.extractPhpPluginData)(e):["theme","theme-block"].includes(e.domain)?t=(0,k.extractCssThemeData)(e):console.log("No main file detected."),t}function v(e){const{domain:t,headers:n}=e,{name:o,description:r,author:a,authorUri:i,url:m}=n,s=t==="plugin"?`${e.slug}.php`:"style.css";return new g.SetOfBlocks([(0,l.buildBlock)(`Name of the ${t}`,o,[s]),(0,l.buildBlock)(`Url of the ${t}`,m,[s]),(0,l.buildBlock)(`Description of the ${t}`,r,[s]),(0,l.buildBlock)(`Author of the ${t}`,a,[s]),(0,l.buildBlock)(`Author URI of the ${t}`,i,[s])])}0&&(module.exports={extractMainFileData,generateHeader,getAuthorFromPackage,translationsHeaders});
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/extractors/headers.ts"],
4
+ "sourcesContent": ["import path from \"node:path\";\nimport { SetOfBlocks } from \"gettext-merger\";\nimport { boolean } from \"yargs\";\nimport type PackageI18n from \"../assets/package-i18n.js\";\nimport { modulePath } from \"../const.js\";\nimport { getEncodingCharset } from \"../fs/fs.js\";\nimport type { Args, I18nHeaders, PotHeaders } from \"../types.js\";\nimport { getPkgJsonData } from \"../utils/common.js\";\nimport { buildBlock } from \"../utils/extractors.js\";\nimport { extractCssThemeData } from \"./css.js\";\nimport { extractPhpPluginData } from \"./php.js\";\n\n/**\n * Checks if required fields are missing and logs a clear error message\n * @param {object} headerData - The header data to validate\n * @returns {boolean} - true if all required fields are present, false otherwise\n */\nfunction validateRequiredFields(headerData: I18nHeaders): boolean {\n\tconst requiredFields = [\n\t\t{ key: \"slug\", name: \"Plugin/Theme slug\", placeholder: \"PLUGIN NAME\" },\n\t\t{ key: \"author\", name: \"Author name\", placeholder: \"AUTHOR\" },\n\t\t{ key: \"version\", name: \"Version\", placeholder: \"\" },\n\t\t{ key: \"email\", name: \"Author email\", placeholder: \"AUTHOR EMAIL\" },\n\t\t{ key: \"xDomain\", name: \"Text domain\", placeholder: \"PLUGIN TEXTDOMAIN\" },\n\t];\n\n\tconst missingFields = requiredFields.filter(\n\t\t(field) =>\n\t\t\t!headerData[field.key] ||\n\t\t\theaderData[field.key] === field.placeholder ||\n\t\t\t(field.key === \"version\" && headerData[field.key] === \"0.0.1\"),\n\t);\n\n\tif (missingFields.length > 0) {\n\t\tconsole.error(\"\\n! Missing required information for POT file header:\\n\");\n\n\t\tfor (const field of missingFields) {\n\t\t\tconsole.error(\n\t\t\t\t` - ${field.name} is missing or has a default value (eg. version: 0.0.1, author: \"AUTHOR <EMAIL>\")`,\n\t\t\t);\n\t\t}\n\n\t\tconsole.error(\n\t\t\t\"\\nPlease provide this information adding the missing fields inside the headers object of the plugin/theme declaration or to the package.json file.\",\n\t\t\t\"\\nFor more information check the documentation at https://github.com/wp-blocks/makePot\",\n\t\t);\n\n\t\tconsole.error(\"\\n\");\n\n\t\treturn false;\n\t}\n\n\treturn true;\n}\n\n/**\n * Extract author data from package.json author field and return an array of strings\n * the original field is a string and it's longer form is \"Your Name <email@example.com> (https://example.com)\"\n *\n * @returns an object with name, email, and website\n * @param authorData\n */\nfunction extractAuthorData(authorData: string | object): {\n\tname: string;\n\temail?: string;\n\twebsite?: string;\n} {\n\t// Default result with placeholder values\n\tconst defaultResult = { name: \"AUTHOR\", email: \"AUTHOR EMAIL\" };\n\n\t// Return default if no author data\n\tif (!authorData) {\n\t\treturn defaultResult;\n\t}\n\n\t// Handle string format: \"Barney Rubble <barney@npmjs.com> (http://barnyrubble.npmjs.com/)\"\n\tif (typeof authorData === \"string\") {\n\t\t// Try to extract email with regex\n\t\tconst emailMatch = authorData.match(/<([^>]+)>/);\n\t\tconst email = emailMatch ? emailMatch[1].trim() : undefined;\n\n\t\t// Try to extract website with regex\n\t\tconst websiteMatch = authorData.match(/\\(([^)]+)\\)/);\n\t\tconst website = websiteMatch ? websiteMatch[1].trim() : undefined;\n\n\t\t// Extract name by removing email and website parts if present\n\t\tlet name = authorData.trim();\n\t\tif (emailMatch) name = name.replace(emailMatch[0], \"\").trim();\n\t\tif (websiteMatch) name = name.replace(websiteMatch[0], \"\").trim();\n\n\t\treturn { name, email, website };\n\t}\n\tif (typeof authorData === \"object\") {\n\t\t// Handle object format: { name: \"Barney Rubble\", email: \"barney@npmjs.com\", website: \"http://barnyrubble.npmjs.com/\" }\n\t\treturn {\n\t\t\tname: authorData.name,\n\t\t\temail: authorData.email,\n\t\t\twebsite: authorData.website,\n\t\t};\n\t}\n}\n\n/**\n * Gets author data by checking multiple possible locations in package.json\n *\n * @param pkgJsonData The package.json data object\n * @returns Author data with name, email and website\n */\nexport function getAuthorFromPackage(pkgJsonData: PackageI18n): {\n\tname: string;\n\temail?: string;\n\twebsite?: string;\n} {\n\t// Check multiple possible locations for author information\n\tconst locations = [\n\t\t\"author\", // Standard author field\n\t\t\"authors\", // Some packages use authors (plural)\n\t\t\"contributors\", // Try contributors if no author\n\t\t\"maintainers\", // Try maintainers as last resort\n\t];\n\n\t// Try each location in order\n\tfor (const location of locations) {\n\t\tif (pkgJsonData[location]) {\n\t\t\tlet authorData: {\n\t\t\t\tname: string;\n\t\t\t\temail?: string;\n\t\t\t\twebsite?: string;\n\t\t\t};\n\t\t\tif (typeof pkgJsonData[location] === \"string\") {\n\t\t\t\tauthorData = extractAuthorData(pkgJsonData[location]);\n\t\t\t} else if (typeof pkgJsonData[location] === \"object\") {\n\t\t\t\tfor (const author of pkgJsonData[location]) {\n\t\t\t\t\tif (!author) continue;\n\t\t\t\t\tauthorData = extractAuthorData(author);\n\t\t\t\t\tif (authorData) break;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (\n\t\t\t\tauthorData?.name !== \"AUTHOR\" ||\n\t\t\t\tauthorData?.email !== \"AUTHOR EMAIL\"\n\t\t\t) {\n\t\t\t\treturn authorData;\n\t\t\t}\n\t\t}\n\t}\n\n\t// If no valid author data found in any location\n\treturn { name: \"AUTHOR\", email: \"AUTHOR EMAIL\" };\n}\n\n/**\n * This function consolidates the user headers data into a single object\n *\n * @param args the command line arguments\n * @return {Record<string, string>} the consolidated headers data object\n */\nfunction consolidateUserHeaderData(args: Args): I18nHeaders {\n\tconst pkgJsonData = getPkgJsonData(\n\t\targs.paths?.cwd,\n\t\t\"name\",\n\t\t\"version\",\n\t\t\"author\",\n\t\t\"authors\",\n\t\t\"contributors\",\n\t\t\"maintainers\",\n\t) as Record<[keyof PackageI18n], string>;\n\n\tconst bugs = `https://wordpress.org/support/${args.domain === \"theme\" ? \"themes\" : \"plugins\"}/${args.slug}`;\n\n\t// get author data from package.json\n\tconst pkgAuthor = getAuthorFromPackage(pkgJsonData);\n\t// Use command line author name if provided, fallback to package.json\n\tconst authorName = args?.headers?.author || pkgAuthor?.name;\n\tconst email = pkgAuthor?.email;\n\t// this is the author with email address in this format: author <email>\n\tconst authorString = `${authorName} <${email}>`;\n\t// get the current directory name as slug\n\tconst currentDir = path\n\t\t.basename(args.paths?.cwd || process.cwd())\n\t\t?.toLowerCase()\n\t\t.replace(\" \", \"-\");\n\tconst slug =\n\t\targs.slug ||\n\t\tcurrentDir ||\n\t\t(args.domain === \"theme\" ? \"THEME NAME\" : \"PLUGIN NAME\");\n\n\treturn {\n\t\t...args.headers,\n\t\tauthor: authorName,\n\t\tauthorString: authorString, // this is the author with email address in this format: author <email>\n\t\tslug,\n\t\temail,\n\t\tbugs,\n\t\tlicense: args.headers?.license || \"gpl-2.0 or later\",\n\t\tversion: args.headers?.version || pkgJsonData.version || \"0.0.1\",\n\t\tlanguage: \"en\",\n\t\txDomain: args.headers?.textDomain || slug,\n\t};\n}\n\n/**\n * Generates a POT header for a given set of arguments.\n * https://developer.wordpress.org/cli/commands/i18n/make-pot/\n * 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 in the following manner:\n * `\n * Copyright (C) 2018 Example Plugin Author\n * This file is distributed under the same license as the Example Plugin package.\n * `\n * If a plugin or theme specifies a license in their main plugin file or stylesheet,\n * the comment looks like this: Copyright (C) 2018 Example Plugin Author This file is distributed under the GPLv2.\n *\n * @param args - The argument object containing the headers and their values.\n * @return The generated POT header.\n */\nexport async function generateHeader(args: Args) {\n\t// Consolidate the user headers data into a single object\n\tconst headerData = consolidateUserHeaderData(args);\n\n\t// the makepot module name and version\n\tconst { name, version } = getPkgJsonData(modulePath, \"name\", \"version\");\n\n\t// Validate required fields - exit early if validation fails\n\tif (!validateRequiredFields(headerData)) {\n\t\tprocess.exit(1); // Exit with error code\n\t\treturn null; // This is never reached but helps with TypeScript\n\t}\n\n\tconst header = {\n\t\t\"Project-Id-Version\": `${headerData.slug} ${headerData.version}`,\n\t\t\"Report-Msgid-Bugs-To\": headerData.authorString,\n\t\t\"MIME-Version\": \"1.0\",\n\t\t\"Content-Transfer-Encoding\": \"8bit\",\n\t\t\"content-type\": `text/plain; charset=${getEncodingCharset(args.options?.charset)}`,\n\t\t\"plural-forms\": \"nplurals=2; plural=(n!=1);\",\n\t\t\"POT-Creation-Date\": `${new Date().toISOString()}`,\n\t\t\"PO-Revision-Date\": `${new Date().getFullYear()}-MO-DA HO:MI+ZONE`,\n\t\t\"Last-Translator\": headerData.authorString,\n\t\t\"Language-Team\": headerData.authorString,\n\t\t\"X-Generator\": `${name} ${version}`,\n\t\tLanguage: `${headerData.language}`,\n\t\t\"X-Domain\": headerData.xDomain,\n\t};\n\n\treturn header;\n}\n\n/**\n * Extracts main file data based on the given arguments.\n *\n * @param {Args} args - The arguments for extracting the main file data.\n * @return {Record<string, string>} The extracted main file data.\n */\nexport function extractMainFileData(args: Args): Record<string, string> {\n\tlet extractedData = {};\n\tif ([\"plugin\", \"block\", \"generic\"].includes(args.domain)) {\n\t\textractedData = extractPhpPluginData(args);\n\t} else if ([\"theme\", \"theme-block\"].includes(args.domain)) {\n\t\textractedData = extractCssThemeData(args);\n\t} else {\n\t\tconsole.log(\"No main file detected.\");\n\t}\n\n\treturn extractedData;\n}\n\n/**\n * Generate translation strings based on the given type and headers.\n *\n * @return {Record<string, string>} the generated translation strings\n * @param args\n */\nexport function translationsHeaders(args: Args): SetOfBlocks {\n\tconst { domain, headers } = args as Args;\n\tconst { name, description, author, authorUri, url } = headers as {\n\t\t[key in PotHeaders]: string;\n\t};\n\n\t// the main file is the plugin main php file or the css file\n\tconst fakePath = domain === \"plugin\" ? `${args.slug}.php` : \"style.css\";\n\n\treturn new SetOfBlocks([\n\t\tbuildBlock(`Name of the ${domain}`, name, [fakePath]),\n\t\tbuildBlock(`Url of the ${domain}`, url, [fakePath]),\n\t\tbuildBlock(`Description of the ${domain}`, description, [fakePath]),\n\t\tbuildBlock(`Author of the ${domain}`, author, [fakePath]),\n\t\tbuildBlock(`Author URI of the ${domain}`, authorUri, [fakePath]),\n\t]);\n}\n"],
5
+ "mapp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AA,IAC5B,eAAe,GAAG,IAAI,IAAI,OAAO;AAAA,IACjC,UAAU,GAAG,WAAW,QAAQ;AAAA,IAChC,YAAY,WAAW;AAAA,EACxB;AAEA,SAAO;AACR;AAQO,SAAS,oBAAoB,MAAoC;AACvE,MAAI,gBAAgB,CAAC;AACrB,MAAI,CAAC,UAAU,SAAS,SAAS,EAAE,SAAS,KAAK,MAAM,GAAG;AACzD,wBAAgB,iCAAqB,IAAI;AAAA,EAC1C,WAAW,CAAC,SAAS,aAAa,EAAE,SAAS,KAAK,MAAM,GAAG;AAC1D,wBAAgB,gCAAoB,IAAI;AAAA,EACzC,OAAO;AACN,YAAQ,IAAI,wBAAwB;AAAA,EACrC;AAEA,SAAO;AACR;AAQO,SAAS,oBAAoB,MAAyB;AAC5D,QAAM,EAAE,QAAQ,QAAQ,IAAI;AAC5B,QAAM,EAAE,MAAM,aAAa,QAAQ,WAAW,IAAI,IAAI;AAKtD,QAAM,WAAW,WAAW,WAAW,GAAG,KAAK,IAAI,SAAS;AAE5D,SAAO,IAAI,kCAAY;AAAA,QACtB,8BAAW,eAAe,MAAM,IAAI,MAAM,CAAC,QAAQ,CAAC;AAAA,QACpD,8BAAW,cAAc,MAAM,IAAI,KAAK,CAAC,QAAQ,CAAC;AAAA,QAClD,8BAAW,sBAAsB,MAAM,IAAI,aAAa,CAAC,QAAQ,CAAC;AAAA,QAClE,8BAAW,iBAAiB,MAAM,IAAI,QAAQ,CAAC,QAAQ,CAAC;AAAA,QACxD,8BAAW,qBAAqB,MAAM,IAAI,WAAW,CAAC,QAAQ,CAAC;AAAA,EAChE,CAAC;AACF;",
6
+ "names": ["path"]
7
+ }
@@ -1 +1 @@
1
- "use strict";var k=Object.create;var c=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var j=Object.getOwnPropertyNames;var J=Object.getPrototypeOf,d=Object.prototype.hasOwnProperty;var b=(e,n)=>{for(var t in n)c(e,t,{get:n[t],enumerable:!0})},l=(e,n,t,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let s of j(n))!d.call(e,s)&&s!==t&&c(e,s,{get:()=>n[s],enumerable:!(o=u(n,s))||o.enumerable});return e};var g=(e,n,t)=>(t=e!=null?k(J(e)):{},l(n||!e||!e.__esModule?c(t,"default",{value:e,enumerable:!0}):t,e)),S=e=>l(c({},"__esModule",{value:!0}),e);var C={};b(C,{extractPackageJson:()=>F,getJsonComment:()=>x,parseJsonCallback:()=>w,parseJsonFile:()=>h});module.exports=S(C);var m=g(require("node:fs")),f=g(require("node:path")),a=require("../const.js"),r=require("./schema.js"),p=require("./utils.js");async function h(e){return await r.JsonSchemaExtractor.fromString(e.fileContent,{file:e.filename,schema:e.filename==="theme.json"?r.JsonSchemaExtractor.themeJsonSource:r.JsonSchemaExtractor.blockJsonSource,schemaFallback:e.filename==="theme.json"?r.JsonSchemaExtractor.themeJsonFallback:r.JsonSchemaExtractor.blockJsonFallback,addReferences:!0})??{}}function y(e){switch(e){case"block.json":return a.blockJson;case"theme.json":return a.themeJson;default:return{}}}function x(e,n){const t=y(n);return e in Object.values(t)?t[e]:e}function F(e){const n=a.pkgJsonHeaders,t={},o=e.paths.cwd?f.default.join(e.paths.cwd,"package.json"):"package.json";if(m.default.existsSync(o)){const s=JSON.parse(m.default.readFileSync(o,"utf8"));for(const i of Object.keys(n))i in s&&(t[i]=s[i])}return t}async function w(e,n,t){const o=await h({fileContent:e,filename:t,filepath:n});return(0,p.yieldParsedData)(o,t,f.default.join(n,t))}0&&(module.exports={extractPackageJson,getJsonComment,parseJsonCallback,parseJsonFile});
1
+ "use strict";var f=Object.create;var s=Object.defineProperty;var k=Object.getOwnPropertyDescriptor;var h=Object.getOwnPropertyNames;var p=Object.getPrototypeOf,b=Object.prototype.hasOwnProperty;var u=(e,o)=>{for(var n in o)s(e,n,{get:o[n],enumerable:!0})},l=(e,o,n,a)=>{if(o&&typeof o=="object"||typeof o=="function")for(let r of h(o))!b.call(e,r)&&r!==n&&s(e,r,{get:()=>o[r],enumerable:!(a=k(o,r))||a.enumerable});return e};var S=(e,o,n)=>(n=e!=null?f(p(e)):{},l(o||!e||!e.__esModule?s(n,"default",{value:e,enumerable:!0}):n,e)),j=e=>l(s({},"__esModule",{value:!0}),e);var J={};u(J,{parseJsonCallback:()=>d,parseJsonFile:()=>m});module.exports=j(J);var c=S(require("node:path")),i=require("../utils/extractors.js"),t=require("./schema.js");async function m(e){const o=e.filename==="theme.json",n={url:o?t.JsonSchemaExtractor.themeJsonSource:t.JsonSchemaExtractor.blockJsonSource,fallback:o?t.JsonSchemaExtractor.themeJsonFallback:t.JsonSchemaExtractor.blockJsonFallback};if(!n.url||!n.fallback){console.error("Schema URL or fallback not provided");return}return await t.JsonSchemaExtractor.parse(e.fileContent,n,{file:e.filename,addReferences:!0})??[]}async function d(e,o,n){const a=await m({fileContent:e,filename:n});return(0,i.yieldParsedData)(a,n,c.default.join(o,n))}0&&(module.exports={parseJsonCallback,parseJsonFile});
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/extractors/json.ts"],
4
+ "sourcesContent": ["import path from \"node:path\";\nimport type { Block, SetOfBlocks } from \"gettext-merger\";\nimport type { I18nSchema } from \"../types.js\";\nimport { yieldParsedData } from \"../utils/extractors.js\";\nimport { JsonSchemaExtractor } from \"./schema.js\";\n\n/**\n * Parses a JSON file and returns an array of parsed data.\n *\n * @param {Object} opts - The arguments for parsing the JSON file.\n * @param {string} opts.filepath - The filepath of the JSON file to parse.\n * @param {Object} [opts.stats] - Optional statistics object.\n * @param {number} opts.stats.index - The index of the progress bar.\n * @return {Promise<TranslationStrings>} A promise that resolves to an object containing the parsed data.\n */\nexport async function parseJsonFile(opts: {\n\tfileContent: string;\n\tfilename: \"block.json\" | \"theme.json\";\n}): Promise<Block[]> {\n\tconst isTheme = opts.filename === \"theme.json\";\n\tconst schema: { url: string; fallback: I18nSchema } = {\n\t\turl: isTheme\n\t\t\t? JsonSchemaExtractor.themeJsonSource\n\t\t\t: JsonSchemaExtractor.blockJsonSource,\n\t\tfallback: isTheme\n\t\t\t? (JsonSchemaExtractor.themeJsonFallback as I18nSchema)\n\t\t\t: (JsonSchemaExtractor.blockJsonFallback as I18nSchema),\n\t};\n\n\tif (!schema.url || !schema.fallback) {\n\t\tconsole.error(\"Schema URL or fallback not provided\");\n\t\treturn;\n\t}\n\n\t// Get the JSON translations from the schema\n\tconst jsonTranslations = await JsonSchemaExtractor.parse(\n\t\topts.fileContent,\n\t\tschema,\n\t\t{\n\t\t\tfile: opts.filename,\n\t\t\taddReferences: true,\n\t\t},\n\t);\n\n\treturn jsonTranslations ?? [];\n}\n\n/**\n * Parses the JSON content of a file based on the filename and file content.\n *\n * @param {string} fileContent - The content of the file to parse.\n * @param {string} filePath - The path of the file being parsed.\n * @param {'block.json' | 'theme.json'} filename - The type of JSON file being parsed.\n * @return {Promise<TranslationStrings>} The parsed translation strings.\n */\nexport async function parseJsonCallback(\n\tfileContent: string,\n\tfilePath: string,\n\tfilename: \"block.json\" | \"theme.json\",\n): Promise<SetOfBlocks> {\n\tconst data = await parseJsonFile({\n\t\tfileContent: fileContent,\n\t\tfilename: filename,\n\t});\n\n\treturn yieldParsedData(data, filename, path.join(filePath, filename));\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAAiB;AAGjB,wBAAgC;AAChC,oBAAoC;AAWpC,eAAsB,cAAc,MAGf;AACpB,QAAM,UAAU,KAAK,aAAa;AAClC,QAAM,SAAgD;AAAA,IACrD,KAAK,UACF,kCAAoB,kBACpB,kCAAoB;AAAA,IACvB,UAAU,UACN,kCAAoB,oBACpB,kCAAoB;AAAA,EACzB;AAEA,MAAI,CAAC,OAAO,OAAO,CAAC,OAAO,UAAU;AACpC,YAAQ,MAAM,qCAAqC;AACnD;AAAA,EACD;AAGA,QAAM,mBAAmB,MAAM,kCAAoB;AAAA,IAClD,KAAK;AAAA,IACL;AAAA,IACA;AAAA,MACC,MAAM,KAAK;AAAA,MACX,eAAe;AAAA,IAChB;AAAA,EACD;AAEA,SAAO,oBAAoB,CAAC;AAC7B;AAUA,eAAsB,kBACrB,aACA,UACA,UACuB;AACvB,QAAM,OAAO,MAAM,cAAc;AAAA,IAChC;AAAA,IACA;AAAA,EACD,CAAC;AAED,aAAO,mCAAgB,MAAM,UAAU,iBAAAA,QAAK,KAAK,UAAU,QAAQ,CAAC;AACrE;",
6
+ "names": ["path"]
7
+ }
@@ -0,0 +1 @@
1
+ "use strict";var d=Object.create;var e=Object.defineProperty;var k=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames;var J=Object.getPrototypeOf,j=Object.prototype.hasOwnProperty;var y=(s,t)=>{for(var o in t)e(s,o,{get:t[o],enumerable:!0})},i=(s,t,o,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of m(t))!j.call(s,n)&&n!==o&&e(s,n,{get:()=>t[n],enumerable:!(r=k(t,n))||r.enumerable});return s};var p=(s,t,o)=>(o=s!=null?d(J(s)):{},i(t||!s||!s.__esModule?e(o,"default",{value:s,enumerable:!0}):o,s)),h=s=>i(e({},"__esModule",{value:!0}),s);var u={};y(u,{extractPackageJson:()=>l});module.exports=h(u);var c=p(require("node:fs")),f=p(require("node:path")),g=require("../const.js");function l(s){const t=g.pkgJsonHeaders,o={},r=s.paths.cwd?f.default.join(s.paths.cwd,"package.json"):"package.json";if(c.default.existsSync(r)){const n=JSON.parse(c.default.readFileSync(r,"utf8"));for(const a of Object.keys(t))a in n&&(o[a]=`${n[a]}`)}return o}0&&(module.exports={extractPackageJson});
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/extractors/packageJson.ts"],
4
+ "sourcesContent": ["import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { pkgJsonHeaders } from \"../const.js\";\nimport type { Args } from \"../types.js\";\n\n/**\n * Extracts package data from the given arguments and returns a record\n * containing the specified fields from the package.json file.\n *\n * @param {Args} args - The arguments for extracting package data.\n *\n * @return {Record<string, string>} - A record containing the extracted package data.\n */\nexport function extractPackageJson(args: Args): Record<string, string> {\n\tconst fields = pkgJsonHeaders;\n\tconst pkgJsonMeta: Record<string, string> = {};\n\t// read the package.json file\n\tconst packageJsonPath = args.paths.cwd\n\t\t? path.join(args.paths.cwd, \"package.json\")\n\t\t: \"package.json\";\n\n\t/**\n\t * check if the package.json extract the fields from the package.json file\n\t */\n\tif (fs.existsSync(packageJsonPath)) {\n\t\tconst packageJson = JSON.parse(fs.readFileSync(packageJsonPath, \"utf8\"));\n\t\tfor (const field of Object.keys(fields)) {\n\t\t\t// if the field exists in the package.json\n\t\t\tif (field in packageJson) {\n\t\t\t\tpkgJsonMeta[field] = `${packageJson[field]}` as string;\n\t\t\t}\n\t\t}\n\t}\n\treturn pkgJsonMeta;\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAAe;AACf,uBAAiB;AACjB,mBAA+B;AAWxB,SAAS,mBAAmB,MAAoC;AACtE,QAAM,SAAS;AACf,QAAM,cAAsC,CAAC;AAE7C,QAAM,kBAAkB,KAAK,MAAM,MAChC,iBAAAA,QAAK,KAAK,KAAK,MAAM,KAAK,cAAc,IACxC;AAKH,MAAI,eAAAC,QAAG,WAAW,eAAe,GAAG;AACnC,UAAM,cAAc,KAAK,MAAM,eAAAA,QAAG,aAAa,iBAAiB,MAAM,CAAC;AACvE,eAAW,SAAS,OAAO,KAAK,MAAM,GAAG;AAExC,UAAI,SAAS,aAAa;AACzB,oBAAY,KAAK,IAAI,GAAG,YAAY,KAAK,CAAC;AAAA,MAC3C;AAAA,IACD;AAAA,EACD;AACA,SAAO;AACR;",
6
+ "names": ["path", "fs"]
7
+ }
@@ -1,2 +1,2 @@
1
- "use strict";var h=Object.create;var s=Object.defineProperty;var P=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var x=Object.getPrototypeOf,R=Object.prototype.hasOwnProperty;var k=(t,n)=>{for(var e in n)s(t,e,{get:n[e],enumerable:!0})},f=(t,n,e,i)=>{if(n&&typeof n=="object"||typeof n=="function")for(let o of y(n))!R.call(t,o)&&o!==e&&s(t,o,{get:()=>n[o],enumerable:!(i=P(n,o))||i.enumerable});return t};var g=(t,n,e)=>(e=t!=null?h(x(t)):{},f(n||!t||!t.__esModule?s(e,"default",{value:t,enumerable:!0}):e,t)),B=t=>f(s({},"__esModule",{value:!0}),t);var S={};k(S,{extractPhpPluginData:()=>F,parsePHPFile:()=>a});module.exports=B(S);var c=g(require("node:fs")),m=g(require("node:path")),p=require("../const.js"),u=require("./utils.js");function F(t){let n={};const e=m.default.join(t.paths.cwd,`${t.slug}.php`);if(c.default.existsSync(e)){const i=c.default.readFileSync(e,"utf8");return n=a(i),console.log(`\u{1F535} Plugin file detected. (${e})`),t.domain="plugin",n}return console.log("Plugin file not found."),console.log(`Missing Plugin filename: ${e}`),{}}function a(t){const n=t.match(/\/\*\*([\s\S]*?)\*\//);if(n?.[1]){const i=n[1].split(`
2
- `),o={};for(const d of i){const r=d.match(/^\s*\*\s*([^:]+):\s*(.*)/);if(r?.[1]&&r[2]){const l=(0,u.getKeyByValue)(p.pluginHeaders,r[1].trim());if(l===void 0)continue;o[l]=r[2].trim()}}return o}return{}}0&&(module.exports={extractPhpPluginData,parsePHPFile});
1
+ "use strict";var h=Object.create;var s=Object.defineProperty;var P=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var x=Object.getPrototypeOf,R=Object.prototype.hasOwnProperty;var k=(t,n)=>{for(var e in n)s(t,e,{get:n[e],enumerable:!0})},f=(t,n,e,i)=>{if(n&&typeof n=="object"||typeof n=="function")for(let o of y(n))!R.call(t,o)&&o!==e&&s(t,o,{get:()=>n[o],enumerable:!(i=P(n,o))||i.enumerable});return t};var g=(t,n,e)=>(e=t!=null?h(x(t)):{},f(n||!t||!t.__esModule?s(e,"default",{value:t,enumerable:!0}):e,t)),B=t=>f(s({},"__esModule",{value:!0}),t);var S={};k(S,{extractPhpPluginData:()=>F,parsePHPFile:()=>a});module.exports=B(S);var c=g(require("node:fs")),m=g(require("node:path")),u=require("../const.js"),p=require("../utils/extractors.js");function F(t){let n={};const e=m.default.join(t.paths.cwd,`${t.slug}.php`);if(c.default.existsSync(e)){const i=c.default.readFileSync(e,"utf8");return n=a(i),console.log(`\u{1F535} Plugin file detected. (${e})`),t.domain="plugin",n}return console.log("Plugin file not found."),console.log(`Missing Plugin filename: ${e}`),{}}function a(t){const n=t.match(/\/\*\*([\s\S]*?)\*\//);if(n?.[1]&&n){const i=n[1].split(`
2
+ `),o={};for(const d of i){const r=d.match(/^\s*\*\s*([^:]+):\s*(.*)/);if(r&&r?.[1]&&r[2]){const l=(0,p.getKeyByValue)(u.pluginHeaders,r[1].trim());if(l===void 0)continue;o[l]=r[2].trim()}}return o}return{}}0&&(module.exports={extractPhpPluginData,parsePHPFile});
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/extractors/php.ts"],
4
+ "sourcesContent": ["import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { pluginHeaders } from \"../const.js\";\nimport type { Args } from \"../types.js\";\nimport { getKeyByValue } from \"../utils/extractors.js\";\n\nexport function extractPhpPluginData(args: Args): Record<string, string> {\n\tlet fileData: Record<string, string> = {};\n\tconst folderPhpFile = path.join(args.paths.cwd, `${args.slug}.php`);\n\n\tif (fs.existsSync(folderPhpFile)) {\n\t\tconst fileContent = fs.readFileSync(folderPhpFile, \"utf8\");\n\t\tfileData = parsePHPFile(fileContent);\n\n\t\tconsole.log(`\uD83D\uDD35 Plugin file detected. (${folderPhpFile})`);\n\n\t\t// Set the domain\n\t\targs.domain = \"plugin\";\n\n\t\treturn fileData;\n\t}\n\n\tconsole.log(\"Plugin file not found.\");\n\tconsole.log(`Missing Plugin filename: ${folderPhpFile}`);\n\n\treturn {};\n}\n\n/**\n * Parses a PHP file and extracts the plugin information from the comment block.\n *\n * @param {string} phpContent - The content of the PHP file.\n * @return {Record<string, string>} - A record containing the plugin information.\n */\nexport function parsePHPFile(phpContent: string): Record<string, string> {\n\tconst match = phpContent.match(/\\/\\*\\*([\\s\\S]*?)\\*\\//);\n\n\tif (match?.[1] && match) {\n\t\tconst commentBlock = match[1];\n\t\tconst lines = commentBlock.split(\"\\n\");\n\n\t\tconst pluginInfo: Record<string, string> = {};\n\n\t\tfor (const line of lines) {\n\t\t\tconst keyValueMatch = line.match(/^\\s*\\*\\s*([^:]+):\\s*(.*)/);\n\n\t\t\tif (!keyValueMatch) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// Check if the line matches the expected format\n\t\t\tif (keyValueMatch?.[1] && keyValueMatch[2]) {\n\t\t\t\t// filter the retrieved headers\n\t\t\t\tconst header = getKeyByValue(pluginHeaders, keyValueMatch[1].trim());\n\t\t\t\tif (header === undefined) continue;\n\t\t\t\tpluginInfo[header] = keyValueMatch[2].trim();\n\t\t\t}\n\t\t}\n\n\t\treturn pluginInfo;\n\t}\n\treturn {};\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAAe;AACf,uBAAiB;AACjB,mBAA8B;AAE9B,wBAA8B;AAEvB,SAAS,qBAAqB,MAAoC;AACxE,MAAI,WAAmC,CAAC;AACxC,QAAM,gBAAgB,iBAAAA,QAAK,KAAK,KAAK,MAAM,KAAK,GAAG,KAAK,IAAI,MAAM;AAElE,MAAI,eAAAC,QAAG,WAAW,aAAa,GAAG;AACjC,UAAM,cAAc,eAAAA,QAAG,aAAa,eAAe,MAAM;AACzD,eAAW,aAAa,WAAW;AAEnC,YAAQ,IAAI,oCAA6B,aAAa,GAAG;AAGzD,SAAK,SAAS;AAEd,WAAO;AAAA,EACR;AAEA,UAAQ,IAAI,wBAAwB;AACpC,UAAQ,IAAI,4BAA4B,aAAa,EAAE;AAEvD,SAAO,CAAC;AACT;AAQO,SAAS,aAAa,YAA4C;AACxE,QAAM,QAAQ,WAAW,MAAM,sBAAsB;AAErD,MAAI,QAAQ,CAAC,KAAK,OAAO;AACxB,UAAM,eAAe,MAAM,CAAC;AAC5B,UAAM,QAAQ,aAAa,MAAM,IAAI;AAErC,UAAM,aAAqC,CAAC;AAE5C,eAAW,QAAQ,OAAO;AACzB,YAAM,gBAAgB,KAAK,MAAM,0BAA0B;AAE3D,UAAI,CAAC,eAAe;AACnB;AAAA,MACD;AAGA,UAAI,gBAAgB,CAAC,KAAK,cAAc,CAAC,GAAG;AAE3C,cAAM,aAAS,iCAAc,4BAAe,cAAc,CAAC,EAAE,KAAK,CAAC;AACnE,YAAI,WAAW,OAAW;AAC1B,mBAAW,MAAM,IAAI,cAAc,CAAC,EAAE,KAAK;AAAA,MAC5C;AAAA,IACD;AAEA,WAAO;AAAA,EACR;AACA,SAAO,CAAC;AACT;",
6
+ "names": ["path", "fs"]
7
+ }
@@ -1,4 +1,4 @@
1
- "use strict";var p=Object.create;var i=Object.defineProperty;var d=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var g=Object.getPrototypeOf,u=Object.prototype.hasOwnProperty;var y=(t,e)=>{for(var r in e)i(t,r,{get:e[r],enumerable:!0})},h=(t,e,r,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of f(e))!u.call(t,s)&&s!==r&&i(t,s,{get:()=>e[s],enumerable:!(a=d(e,s))||a.enumerable});return t};var m=(t,e,r)=>(r=t!=null?p(g(t)):{},h(e||!t||!t.__esModule?i(r,"default",{value:t,enumerable:!0}):r,t)),b=t=>h(i({},"__esModule",{value:!0}),t);var j={};y(j,{JsonSchemaExtractor:()=>c});module.exports=b(j);var I=m(require("../assets/block-i18n.js")),S=m(require("../assets/theme-i18n.js"));class c{static schemaCache={};static themeJsonSource="http://develop.svn.wordpress.org/trunk/src/wp-includes/theme-i18n.json";static themeJsonFallback=S;static blockJsonSource="http://develop.svn.wordpress.org/trunk/src/wp-includes/block-i18n.json";static blockJsonFallback=I;static async loadSchema(e,r){if(c.schemaCache[e])return c.schemaCache[e];try{console.log(`
2
- [i] Loading schema from ${e}`);const a=await fetch(e,{responseType:"json",accept:"application/json",headers:{"Content-Type":"application/json","Access-Control-Allow-Origin":"*"}}).then(s=>s.json()).catch(s=>{throw new Error(`
3
- Failed to load schema from ${e}. Error: ${s.message}`)});return!a||!a?.data?r:(console.log("Schema loaded successfully"),c.schemaCache[e]=a.data,a.data)}catch(a){return console.error(`
4
- Failed to load schema from ${e}. Using fallback. Error: ${a.message}`),c.schemaCache[e]=r,r}}static async fromString(e,r){const a=r.schema,s=r.schemaFallback;if(!a||!s){console.error("Schema URL or fallback not provided");return}const n=await c.loadSchema(a,s);try{const o=JSON.parse(e);if(o===null){console.error("Could not parse JSON.");return}return c.extractStringsUsingI18nSchema(n,o)}catch(o){console.error(`Error parsing JSON: ${o.message}`);return}}static extractStringsUsingI18nSchema(e,r){if(!e||!r)return{};if(Array.isArray(e)&&typeof r=="object"){const a={};for(const s in r){const n=c.extractStringsUsingI18nSchema(e[s],s);Object.assign(a,n)}return a}if(typeof e=="object"&&typeof r=="object"){const a="*",s={};for(const[n,o]of Object.entries(r))if(e[n])s[n]=e[n];else if(Object.prototype.hasOwnProperty.call(e,a)){const l=c.extractStringsUsingI18nSchema(e[a],o);l&&Object.assign(s,l)}return s}return{}}}0&&(module.exports={JsonSchemaExtractor});
1
+ "use strict";var A=Object.create;var y=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var v=Object.getOwnPropertyNames;var C=Object.getPrototypeOf,B=Object.prototype.hasOwnProperty;var F=(n,e)=>{for(var s in e)y(n,s,{get:e[s],enumerable:!0})},j=(n,e,s,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of v(e))!B.call(n,r)&&r!==s&&y(n,r,{get:()=>e[r],enumerable:!(i=u(e,r))||i.enumerable});return n};var w=(n,e,s)=>(s=n!=null?A(C(n)):{},j(e||!n||!n.__esModule?y(s,"default",{value:n,enumerable:!0}):s,n)),O=n=>j(y({},"__esModule",{value:!0}),n);var T={};F(T,{JsonSchemaExtractor:()=>c});module.exports=O(T);var $=w(require("../assets/block-i18n.js")),R=w(require("../assets/theme-i18n.js"));class c{static schemaCache={};static themeJsonSource="http://develop.svn.wordpress.org/trunk/src/wp-includes/theme-i18n.json";static themeJsonFallback=R;static blockJsonSource="http://develop.svn.wordpress.org/trunk/src/wp-includes/block-i18n.json";static blockJsonFallback=$;static async loadSchema(e,s){if(c.schemaCache[e])return c.schemaCache[e];try{console.log(`
2
+ [i] Loading schema from ${e}`);const i=await fetch(e,{responseType:"json",accept:"application/json",headers:{"Access-Control-Allow-Origin":"*"}}).then(r=>r.json()).catch(r=>{throw new Error(`
3
+ Failed to load schema from ${e}. Error: ${r.message}`)});return i?(console.log("Schema loaded successfully"),c.schemaCache[e]=i,i):s}catch(i){return console.error(`
4
+ Failed to load schema from ${e}. Using fallback. Error: ${i.message}`),c.schemaCache[e]=s,s}}static async parse(e,s,i){const r=await c.loadSchema(s.url,s.fallback);try{const l=JSON.parse(e);if(!l){console.error("Could not parse JSON.");return}return c.extractFromJsonSchema(l,r,i)}catch(l){console.error(`Error parsing JSON: ${l.message}`);return}}static extractFromJsonSchema(e,s,i={filename:void 0,addReferences:!1}){const{filename:r="block.json",addReferences:l=!1}=i,g=[];function h(t,a,p=[]){if(!(!t||!a)&&typeof t=="object"&&!Array.isArray(t)&&typeof a=="object"&&!Array.isArray(a))for(const o of Object.keys(a))o in t&&(typeof t[o]=="string"?k(t[o],a[o],r,l):Array.isArray(t[o])&&Array.isArray(a[o])?I(t[o],a[o],[...p,o],r,l):typeof t[o]=="object"&&typeof a[o]=="object"&&h(t[o],a[o],[...p,o]))}function I(t,a,p,o,m){if(a.length>0){const d=a[0];for(const f of t)if(typeof f=="string")k(f,d,o,m);else if(typeof f=="object")if(typeof d=="object")h(f,d,p);else for(const b of Object.keys(f))typeof f[b]=="string"&&k(f[b],d,o,m)}}function k(t,a,p,o){if(!t)return;const m={msgid:a,msgctxt:t};o&&(m.comments={reference:[p]}),g.push(m)}return h(e,s),g}}0&&(module.exports={JsonSchemaExtractor});
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/extractors/schema.ts"],
4
+ "sourcesContent": ["import type { Block } from \"gettext-merger\";\nimport * as blocki18n from \"../assets/block-i18n.js\";\nimport type BlockI18n from \"../assets/block-i18n.js\";\nimport * as themei18n from \"../assets/theme-i18n.js\";\nimport type ThemeI18n from \"../assets/theme-i18n.js\";\nimport type { I18nSchema } from \"../types.js\";\n\n/**\n * Extracts strings from JSON files using the I18n schema.\n */\n\n// biome-ignore lint/complexity/noStaticOnlyClass: <explanation>\nexport class JsonSchemaExtractor {\n\tprivate static schemaCache: { [url: string]: I18nSchema } = {};\n\n\t/** Theme */\n\tstatic themeJsonSource =\n\t\t\"http://develop.svn.wordpress.org/trunk/src/wp-includes/theme-i18n.json\";\n\tstatic themeJsonFallback = themei18n as ThemeI18n;\n\t/** Block */\n\tstatic blockJsonSource =\n\t\t\"http://develop.svn.wordpress.org/trunk/src/wp-includes/block-i18n.json\";\n\tstatic blockJsonFallback = blocki18n as BlockI18n;\n\n\t/**\n\t * Load the schema from the specified URL, with a fallback URL if needed.\n\t *\n\t * @param {string} url - The URL to load the schema from.\n\t * @param {I18nSchema} fallback - The fallback schema to use if the main URL fails.\n\t * @return {Promise<I18nSchema>} The loaded schema.\n\t */\n\tprivate static async loadSchema(\n\t\turl: string,\n\t\tfallback: I18nSchema,\n\t): Promise<I18nSchema> {\n\t\tif (JsonSchemaExtractor.schemaCache[url]) {\n\t\t\treturn JsonSchemaExtractor.schemaCache[url];\n\t\t}\n\n\t\ttry {\n\t\t\tconsole.log(`\\n[i] Loading schema from ${url}`);\n\t\t\tconst response = await fetch(url, {\n\t\t\t\tresponseType: \"json\",\n\t\t\t\taccept: \"application/json\",\n\t\t\t\theaders: {\n\t\t\t\t\t\"Access-Control-Allow-Origin\": \"*\",\n\t\t\t\t},\n\t\t\t})\n\t\t\t\t.then((response) => response.json())\n\t\t\t\t.catch((error: Error) => {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`\\nFailed to load schema from ${url}. Error: ${error.message}`,\n\t\t\t\t\t);\n\t\t\t\t});\n\n\t\t\t// Verify if the response is valid\n\t\t\tif (!response) {\n\t\t\t\treturn fallback;\n\t\t\t}\n\n\t\t\tconsole.log(\"Schema loaded successfully\");\n\t\t\tJsonSchemaExtractor.schemaCache[url] = response;\n\t\t\treturn response;\n\t\t} catch (error) {\n\t\t\tconsole.error(\n\t\t\t\t`\\nFailed to load schema from ${url}. Using fallback. Error: ${error.message}`,\n\t\t\t);\n\t\t\tJsonSchemaExtractor.schemaCache[url] = fallback;\n\t\t\treturn fallback;\n\t\t}\n\t}\n\n\t/**\n\t * Parses a string and extracts translations using the specified schema.\n\t *\n\t * @param {string} text - the input string to be parsed\n\t * @param {object} schema - the schema to use for parsing the input string\n\t * @param {string} schema.url - the URL of the schema to use for parsing the input string\n\t * @param {object} schema.schemaFallback - the fallback schema to use if the main schema fails\n\t * @param {object} options - the options for parsing the input string\n\t * @param {string} options.file - the name of the file being parsed\n\t * @param {boolean} options.addReferences - whether to add references to the extracted strings\n\t *\n\t * @return {Promise<I18nSchema | undefined>} a promise that resolves with the extracted schema\n\t */\n\tpublic static async parse(\n\t\ttext: string,\n\t\tschema: {\n\t\t\turl: string;\n\t\t\tfallback: I18nSchema;\n\t\t},\n\t\toptions: {\n\t\t\tfile: \"block.json\" | \"theme.json\";\n\t\t\taddReferences: boolean;\n\t\t},\n\t): Promise<Block[] | undefined> {\n\t\tconst parsedSchema = await JsonSchemaExtractor.loadSchema(\n\t\t\tschema.url,\n\t\t\tschema.fallback,\n\t\t);\n\n\t\ttry {\n\t\t\tconst json = JSON.parse(text) as Record<string, unknown>;\n\t\t\tif (!json) {\n\t\t\t\tconsole.error(\"Could not parse JSON.\");\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\treturn JsonSchemaExtractor.extractFromJsonSchema(\n\t\t\t\tjson,\n\t\t\t\tparsedSchema,\n\t\t\t\toptions,\n\t\t\t);\n\t\t} catch (error) {\n\t\t\tconsole.error(`Error parsing JSON: ${error.message}`);\n\t\t\treturn;\n\t\t}\n\t}\n\n\t/**\n\t * Extracts translatable strings from a JSON file by comparing it with a schema\n\t *\n\t * @param {Object} json - The JSON object to extract strings from\n\t * @param {Object} schema - The schema that defines which fields contain translatable strings\n\t * @param {Object} options - Options for extraction\n\t * @param {string} options.filename - The name of the file being extracted (for references)\n\t * @param {boolean} options.addReferences - Whether to add file references in comments\n\t * @return {Array} - An array of objects with translatable strings in gettext format\n\t */\n\tprivate static extractFromJsonSchema(\n\t\tjson: Record<string, unknown>,\n\t\tschema: I18nSchema,\n\t\toptions: { filename?: string; addReferences?: boolean } = {\n\t\t\tfilename: undefined,\n\t\t\taddReferences: false,\n\t\t},\n\t): Block[] | undefined {\n\t\tconst { filename = \"block.json\", addReferences = false } = options;\n\t\tconst translations = [];\n\n\t\t/**\n\t\t * Recursive function to extract translatable strings\n\t\t * @param {*} currentJson - The current node in the JSON\n\t\t * @param {*} currentSchema - The current node in the schema\n\t\t * @param {Array} path - The current path in the JSON\n\t\t */\n\t\tfunction extract(currentJson, currentSchema, path = []) {\n\t\t\t// If either is null or undefined, there's nothing to do\n\t\t\tif (!currentJson || !currentSchema) return;\n\n\t\t\t// Handles the case where both are objects\n\t\t\tif (\n\t\t\t\ttypeof currentJson === \"object\" &&\n\t\t\t\t!Array.isArray(currentJson) &&\n\t\t\t\ttypeof currentSchema === \"object\" &&\n\t\t\t\t!Array.isArray(currentSchema)\n\t\t\t) {\n\t\t\t\t// Iterate over the schema keys\n\t\t\t\tfor (const key of Object.keys(currentSchema)) {\n\t\t\t\t\tif (key in currentJson) {\n\t\t\t\t\t\t// If the key exists in the JSON, check the type\n\t\t\t\t\t\tif (typeof currentJson[key] === \"string\") {\n\t\t\t\t\t\t\t// It's a string - add it to translations\n\t\t\t\t\t\t\taddTranslation(\n\t\t\t\t\t\t\t\tcurrentJson[key],\n\t\t\t\t\t\t\t\tcurrentSchema[key],\n\t\t\t\t\t\t\t\tfilename,\n\t\t\t\t\t\t\t\taddReferences,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t} else if (\n\t\t\t\t\t\t\tArray.isArray(currentJson[key]) &&\n\t\t\t\t\t\t\tArray.isArray(currentSchema[key])\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t// It's an array - handle each element\n\t\t\t\t\t\t\thandleArrays(\n\t\t\t\t\t\t\t\tcurrentJson[key],\n\t\t\t\t\t\t\t\tcurrentSchema[key],\n\t\t\t\t\t\t\t\t[...path, key],\n\t\t\t\t\t\t\t\tfilename,\n\t\t\t\t\t\t\t\taddReferences,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t} else if (\n\t\t\t\t\t\t\ttypeof currentJson[key] === \"object\" &&\n\t\t\t\t\t\t\ttypeof currentSchema[key] === \"object\"\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t// It's an object - recurse\n\t\t\t\t\t\t\textract(currentJson[key], currentSchema[key], [...path, key]);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t/**\n\t\t * Handles arrays in JSON and schema\n\t\t * @param {Array} jsonArray - The JSON array\n\t\t * @param {Array} schemaArray - The schema array\n\t\t * @param {Array} path - The current path\n\t\t * @param {string} filename - The name of the file\n\t\t * @param {boolean} addReferences - whenever to add references\n\t\t */\n\t\tfunction handleArrays(\n\t\t\tjsonArray,\n\t\t\tschemaArray,\n\t\t\tpath,\n\t\t\tfilename,\n\t\t\taddReferences,\n\t\t) {\n\t\t\t// If the schema has at least one element, use it as a template\n\t\t\tif (schemaArray.length > 0) {\n\t\t\t\tconst schemaTemplate = schemaArray[0];\n\n\t\t\t\t// For each element in the JSON array\n\t\t\t\tfor (const jsonItem of jsonArray) {\n\t\t\t\t\tif (typeof jsonItem === \"string\") {\n\t\t\t\t\t\t// If the JSON element is a string, add it directly\n\t\t\t\t\t\taddTranslation(jsonItem, schemaTemplate, filename, addReferences);\n\t\t\t\t\t} else if (typeof jsonItem === \"object\") {\n\t\t\t\t\t\t// If it's an object, recurse\n\t\t\t\t\t\tif (typeof schemaTemplate === \"object\") {\n\t\t\t\t\t\t\textract(jsonItem, schemaTemplate, path);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t// Edge case: handles cases like keywords: [\"string1\", \"string2\"]\n\t\t\t\t\t\t\t// when the schema has keywords: [\"keyword context\"]\n\t\t\t\t\t\t\tfor (const key of Object.keys(jsonItem)) {\n\t\t\t\t\t\t\t\tif (typeof jsonItem[key] === \"string\") {\n\t\t\t\t\t\t\t\t\taddTranslation(\n\t\t\t\t\t\t\t\t\t\tjsonItem[key],\n\t\t\t\t\t\t\t\t\t\tschemaTemplate,\n\t\t\t\t\t\t\t\t\t\tfilename,\n\t\t\t\t\t\t\t\t\t\taddReferences,\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t/**\n\t\t * Adds a translation to the translations array\n\t\t * @param {string} msgctxt - The context of the text to be translated\n\t\t * @param {string} msgid - The text to be translated\n\t\t * @param {string} filename - The name of the file for references\n\t\t * @param {boolean} addReferences - Whether to add references\n\t\t */\n\t\tfunction addTranslation(msgctxt, msgid, filename, addReferences) {\n\t\t\tif (!msgctxt) return; // Do not add empty strings\n\n\t\t\tconst translation = {\n\t\t\t\tmsgid,\n\t\t\t\tmsgctxt,\n\t\t\t} as Block;\n\n\t\t\tif (addReferences) {\n\t\t\t\ttranslation.comments = {\n\t\t\t\t\treference: [filename],\n\t\t\t\t};\n\t\t\t}\n\n\t\t\ttranslations.push(translation);\n\t\t}\n\n\t\t// Start extraction from the root\n\t\textract(json, schema);\n\n\t\treturn translations;\n\t}\n}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,OAAO,cAAc,GAAG,MAAM,UAC7B;AAED,sBAAQ,YAAY,GAAG,GAAG,cAAc,GAAG,GAAG,CAAC,GAAG,MAAM,GAAG,CAAC;AAAA,YAC7D;AAAA,UACD;AAAA,QACD;AAAA,MACD;AAAA,IACD;AAUA,aAAS,aACR,WACA,aACA,MACAC,WACAC,gBACC;AAED,UAAI,YAAY,SAAS,GAAG;AAC3B,cAAM,iBAAiB,YAAY,CAAC;AAGpC,mBAAW,YAAY,WAAW;AACjC,cAAI,OAAO,aAAa,UAAU;AAEjC,2BAAe,UAAU,gBAAgBD,WAAUC,cAAa;AAAA,UACjE,WAAW,OAAO,aAAa,UAAU;AAExC,gBAAI,OAAO,mBAAmB,UAAU;AACvC,sBAAQ,UAAU,gBAAgB,IAAI;AAAA,YACvC,OAAO;AAGN,yBAAW,OAAO,OAAO,KAAK,QAAQ,GAAG;AACxC,oBAAI,OAAO,SAAS,GAAG,MAAM,UAAU;AACtC;AAAA,oBACC,SAAS,GAAG;AAAA,oBACZ;AAAA,oBACAD;AAAA,oBACAC;AAAA,kBACD;AAAA,gBACD;AAAA,cACD;AAAA,YACD;AAAA,UACD;AAAA,QACD;AAAA,MACD;AAAA,IACD;AASA,aAAS,eAAe,SAAS,OAAOD,WAAUC,gBAAe;AAChE,UAAI,CAAC,QAAS;AAEd,YAAM,cAAc;AAAA,QACnB;AAAA,QACA;AAAA,MACD;AAEA,UAAIA,gBAAe;AAClB,oBAAY,WAAW;AAAA,UACtB,WAAW,CAACD,SAAQ;AAAA,QACrB;AAAA,MACD;AAEA,mBAAa,KAAK,WAAW;AAAA,IAC9B;AAGA,YAAQ,MAAM,MAAM;AAEpB,WAAO;AAAA,EACR;AACD;",
6
+ "names": ["response", "filename", "addReferences"]
7
+ }
@@ -1 +1 @@
1
- "use strict";var o=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var g=Object.prototype.hasOwnProperty;var m=(r,t)=>{for(var n in t)o(r,n,{get:t[n],enumerable:!0})},l=(r,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let e of c(t))!g.call(r,e)&&e!==n&&o(r,e,{get:()=>t[e],enumerable:!(i=a(t,e))||i.enumerable});return r};var p=r=>l(o({},"__esModule",{value:!0}),r);var f={};m(f,{extractFileData:()=>u});module.exports=p(f);var s=require("../utils/common.js");function u(r,t=":"){const n={};return(0,s.removeCommentMarkup)(r)?.forEach(i=>{const e=i.split(t);e.length!==2&&Object.values(n).length>0||(n[e[0]?.trim()]=e[1]?.trim())}),n}0&&(module.exports={extractFileData});
1
+ "use strict";var s=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var g=Object.getOwnPropertyNames;var m=Object.prototype.hasOwnProperty;var l=(r,t)=>{for(var n in t)s(r,n,{get:t[n],enumerable:!0})},f=(r,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let e of g(t))!m.call(r,e)&&e!==n&&s(r,e,{get:()=>t[e],enumerable:!(o=a(t,e))||o.enumerable});return r};var p=r=>f(s({},"__esModule",{value:!0}),r);var d={};l(d,{extractFileData:()=>u});module.exports=p(d);var c=require("../utils/common.js");function u(r,t=":"){const n={},o=(0,c.removeCommentMarkup)(r)??[];for(const e of o){const i=e.split(t);i.length!==2&&Object.values(n).length>0&&i[1]||(n[i[0]?.trim()]=i[1].trim())}return n}0&&(module.exports={extractFileData});
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/extractors/text.ts"],
4
+ "sourcesContent": ["import { removeCommentMarkup } from \"../utils/common.js\";\n\n/**\n * Extracts file data from the given file content.\n *\n * @param {string} fileContent - The content of the file.\n * @param {string} separator - The separator used in the file.\n * @return {Record<string, string>} An object containing the extracted file data.\n */\nexport function extractFileData(\n\tfileContent: string,\n\tseparator = \":\",\n): Record<string, string> {\n\tconst data: Record<string, string> = {};\n\n\t// split by lines and trim every line\n\tconst text = removeCommentMarkup(fileContent) ?? [];\n\t// split each line by break line and trim each part and add to data\n\tfor (const line of text) {\n\t\tconst parts = line.split(separator);\n\t\t/* Check if the parser has already collected the data from the previous line\n\t\t\t and the current line is empty.\n\t\t\t If so, skip this line */\n\t\tif (parts.length !== 2 && Object.values(data).length > 0 && parts[1]) {\n\t\t\tcontinue;\n\t\t}\n\t\tdata[parts[0]?.trim()] = parts[1].trim();\n\t}\n\n\treturn data;\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAoC;AAS7B,SAAS,gBACf,aACA,YAAY,KACa;AACzB,QAAM,OAA+B,CAAC;AAGtC,QAAM,WAAO,mCAAoB,WAAW,KAAK,CAAC;AAElD,aAAW,QAAQ,MAAM;AACxB,UAAM,QAAQ,KAAK,MAAM,SAAS;AAIlC,QAAI,MAAM,WAAW,KAAK,OAAO,OAAO,IAAI,EAAE,SAAS,KAAK,MAAM,CAAC,GAAG;AACrE;AAAA,IACD;AACA,SAAK,MAAM,CAAC,GAAG,KAAK,CAAC,IAAI,MAAM,CAAC,EAAE,KAAK;AAAA,EACxC;AAEA,SAAO;AACR;",
6
+ "names": []
7
+ }
package/lib/fs/fs.js CHANGED
@@ -1 +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 j={};w(j,{getCharset:()=>d,getEncodingCharset:()=>h,getOutputPath:()=>$,readFileAsync:()=>S,writeFile:()=>O});module.exports=y(j);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 C(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 O(t,e){const n=C(e);if(E(i.default.dirname(n))){const o=d(e.options?.charset);console.log(`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 S(t){return(0,f.readFile)(t,"utf-8")}0&&(module.exports={getCharset,getEncodingCharset,getOutputPath,readFileAsync,writeFile});
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});
@@ -0,0 +1,7 @@
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;AACb,WAAO;AAAA,EACR;AAEA,UAAQ,QAAQ,YAAY,GAAG;AAAA,IAC9B,KAAK;AAAA,IACL,KAAK;AACJ,aAAO;AAAA,IACR;AACC,aAAO;AAAA,EACT;AACD;AAOO,SAAS,cAAc,SAA0B;AACvD,SAAO,iBAAAC,QAAK,KAAK,QAAQ,IAAI,GAAG,WAAW,WAAW;AACvD;AAMA,SAAS,kBAAkB,MAAoB;AAC9C,QAAM,EAAE,KAAK,SAAS,QAAQ,IAAI,KAAK;AACvC,MAAI,aAAa,OAAO,SAAS,cAAc;AAG/C,eAAa,WAAW,QAAQ,cAAc,EAAE;AAEhD,QAAM,YAAY,SAAS,OAAO,SAAS;AAE3C,SAAO,iBAAAA,QAAK,KAAK,QAAQ,IAAI,GAAG,YAAY,GAAG,KAAK,IAAI,IAAI,SAAS,EAAE;AACxE;AAQO,SAAS,UAAU,aAAqB,MAAkB;AAChE,QAAM,OAAO,kBAAkB,IAAI;AAEnC,MAAI,mBAAmB,iBAAAA,QAAK,QAAQ,IAAI,CAAC,GAAG;AAE3C,UAAM,kBAAkB,WAAW,KAAK,SAAS,OAAO;AACxD,YAAQ,IAAI;AAAA,kBAAqB,IAAI,EAAE;AAGvC,UAAM,YAAY,OAAO,KAAK,WAAW;AACzC,sCAAc,MAAM,UAAU,SAAS,eAAe,GAAG;AAAA,MACxD,UAAU;AAAA,IACX,CAAC;AAAA,EACF,OAAO;AACN,YAAQ,IAAI,UAAU,IAAI,uCAAuC;AAAA,EAClE;AACD;AAOA,eAAsB,cAAcA,OAA+B;AAClE,aAAO,0BAASA,OAAM,OAAO;AAC9B;",
6
+ "names": ["fs", "path"]
7
+ }
@@ -0,0 +1,7 @@
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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AACF;",
6
+ "names": ["path"]
7
+ }
package/lib/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";var k=Object.create;var t=Object.defineProperty;var l=Object.getOwnPropertyDescriptor;var n=Object.getOwnPropertyNames;var s=Object.getPrototypeOf,u=Object.prototype.hasOwnProperty;var J=(o,r)=>{for(var e in r)t(o,e,{get:r[e],enumerable:!0})},x=(o,r,e,a)=>{if(r&&typeof r=="object"||typeof r=="function")for(let m of n(r))!u.call(o,m)&&m!==e&&t(o,m,{get:()=>r[m],enumerable:!(a=l(r,m))||a.enumerable});return o};var d=(o,r,e)=>(e=o!=null?k(s(o)):{},x(r||!o||!o.__esModule?t(e,"default",{value:o,enumerable:!0}):e,o)),P=o=>x(t({},"__esModule",{value:!0}),o);var b={};J(b,{default:()=>T,doTree:()=>i.doTree,makeJson:()=>p.default,makePot:()=>f.default});module.exports=P(b);var p=d(require("./jsonCommand")),f=d(require("./potCommand")),i=require("./parser/tree.js"),T={makeJson:p.default,makePot:f.default};0&&(module.exports={doTree,makeJson,makePot});
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});
@@ -0,0 +1,7 @@
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 +1 @@
1
- "use strict";var p=Object.create;var r=Object.defineProperty;var c=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})},s=(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=c(e,m))||t.enumerable});return o};var M=(o,e,n)=>(n=o!=null?p(d(o)):{},s(e||!o||!o.__esModule?r(n,"default",{value:o,enumerable:!0}):n,o)),u=o=>s(r({},"__esModule",{value:!0}),o);var g={};J(g,{default:()=>k});module.exports=u(g);var i=M(require("./parser/makeJson")),a=require("./utils/common");function k(o){const e=new i.default(o);if(Object.keys(o).length>0){(0,a.printMakePotModuleInfo)();const n=new Date;e.invoke().then(t=>{o.debug&&console.log(t),(0,a.printTimeElapsed)(n)}).catch(t=>{console.error(`\u{1FAE4} make-json - Error: ${t}`)})}}
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}`)})}}