@wp-blocks/make-pot 1.6.5 → 1.6.6

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 (50) hide show
  1. package/README.md +2 -2
  2. package/lib/assets/block-i18n.js +41 -1
  3. package/lib/assets/package-i18n.js +38 -1
  4. package/lib/assets/theme-i18n.js +110 -1
  5. package/lib/assets/wp-plugin-i18n.js +39 -1
  6. package/lib/assets/wp-theme-i18n.js +37 -1
  7. package/lib/cli/getArgs.js +156 -1
  8. package/lib/cli/getArgs.js.map +2 -2
  9. package/lib/cli/getJsonArgs.js +82 -1
  10. package/lib/cli/parseCli.js +179 -1
  11. package/lib/cli.js +43 -1
  12. package/lib/const.js +111 -1
  13. package/lib/extractors/auditStrings.js +177 -6
  14. package/lib/extractors/auditStrings.js.map +2 -2
  15. package/lib/extractors/css.js +69 -1
  16. package/lib/extractors/headers.js +253 -15
  17. package/lib/extractors/headers.js.map +2 -2
  18. package/lib/extractors/json.js +70 -1
  19. package/lib/extractors/packageJson.js +55 -1
  20. package/lib/extractors/php.js +79 -2
  21. package/lib/extractors/php.js.map +2 -2
  22. package/lib/extractors/schema.js +217 -3
  23. package/lib/extractors/text.js +41 -1
  24. package/lib/fs/fs.js +114 -2
  25. package/lib/fs/glob.js +103 -1
  26. package/lib/index.js +64 -1
  27. package/lib/jsonCommand.js +51 -1
  28. package/lib/makeJson.js +28 -1
  29. package/lib/makePot.js +27 -1
  30. package/lib/parser/exec.js +94 -3
  31. package/lib/parser/exec.js.map +2 -2
  32. package/lib/parser/makeJson.js +393 -1
  33. package/lib/parser/makePot.js +48 -1
  34. package/lib/parser/patterns.js +54 -1
  35. package/lib/parser/process.js +85 -1
  36. package/lib/parser/progress.js +57 -1
  37. package/lib/parser/taskRunner.js +65 -2
  38. package/lib/parser/taskRunner.js.map +2 -2
  39. package/lib/parser/tree.js +228 -2
  40. package/lib/potCommand.js +36 -1
  41. package/lib/potCommand.js.map +2 -2
  42. package/lib/types.js +17 -1
  43. package/lib/types.js.map +1 -1
  44. package/lib/utils/common.js +161 -8
  45. package/lib/utils/common.js.map +2 -2
  46. package/lib/utils/extractors.js +69 -1
  47. package/lib/utils/output.js +59 -1
  48. package/lib/utils/output.js.map +3 -3
  49. package/package.json +1 -2
  50. package/tests/parse-php.test.js +47 -0
package/lib/types.js.map CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/types.ts"],
4
- "sourcesContent": ["import type { GetTextTranslation } from \"gettext-parser\";\r\nimport type { pkgJsonHeaders, pluginHeaders, themeHeaders } from \"./const.js\";\r\n\r\nexport type ThemeHeadersType = typeof themeHeaders;\r\nexport type PluginHeadersType = typeof pluginHeaders;\r\nexport type PkgHeadersType = typeof pkgJsonHeaders;\r\n\r\n/**\r\n * The args headers Object types\r\n */\r\nexport type PotHeaders =\r\n\t| keyof PkgHeadersType\r\n\t| keyof PluginHeadersType\r\n\t| keyof ThemeHeadersType\r\n\t| \"license\"\r\n\t| \"email\"\r\n\t| \"language\"\r\n\t| \"domain\"\r\n\t| \"bugs\";\r\n\r\n// type is the value of the themeHeader Object\r\nexport type DomainType =\r\n\t| \"plugin\"\r\n\t| \"theme\"\r\n\t| \"block\"\r\n\t| \"theme-block\"\r\n\t| \"generic\";\r\n\r\n/**\r\n * The patterns to use when extracting strings from files.\r\n *\r\n * @param {string} mergePaths - Comma-separated list of POT files whose contents should be merged with the extracted strings.\r\n * If left empty, defaults to the destination POT file. POT file headers will be ignored.\r\n * @param {string} subtractPaths - Comma-separated list of POT files whose contents should act as some sort of denylist\r\n * for string extraction. Any string which is found on that denylist will not be extracted. This can be useful when\r\n * you want to create multiple POT files from the same source directory with slightly different content and no duplicate\r\n * strings between them.\r\n * @param {boolean} subtractAndMerge - Whether source code references and comments from the generated POT file should be\r\n * instead added to the POT file used for subtraction. Warning: this modifies the files passed to `subtractPaths`!\r\n * @param {string} include - Comma-separated list of files and paths that should be used for string extraction.\r\n * If provided, only these files and folders will be taken into account for string extraction.\r\n * For example, `--include=\"src,my-file.php` will ignore anything besides `my-file.php` and files in the `src`\r\n * directory. Simple glob patterns can be used, i.e. `--include=foo-*.php` includes any PHP file with the `foo-`\r\n * prefix. Leading and trailing slashes are ignored, i.e. `/my/directory/` is the same as `my/directory`.\r\n * @param {string} exclude - Comma-separated list of files and paths that should be skipped for string extraction.\r\n * For example, `--exclude=.github,myfile.php` would ignore any strings found within `myfile.php` or the `.github`\r\n * folder. Simple glob patterns can be used, i.e. `--exclude=foo-*.php` excludes any PHP file with the `foo-`\r\n * prefix. Leading and trailing slashes are ignored, i.e. `/my/directory/` is the same as `my/directory`.\r\n * The following files and folders are always excluded: node_modules, .git, .svn, .CVS, .hg, vendor, *.min.js.\r\n */\r\nexport interface Patterns {\r\n\tmergePaths?: string[];\r\n\tsubtractPaths?: string[];\r\n\tsubtractAndMerge?: boolean;\r\n\tinclude: string[];\r\n\texclude: string[];\r\n}\r\n\r\n/**\r\n * Create a POT file for a WordPress project.\r\n *\r\n * Scans PHP, Blade-PHP, and JavaScript files for translatable strings, as well as theme stylesheets and plugin files\r\n * if the source directory is detected as either a plugin or theme.\r\n *\r\n * @param {string} sourceDirectory - Directory to scan for string extraction.\r\n * @param {string} destination - Name of the resulting POT file.\r\n * @param {string | undefined} slug - Plugin or theme slug. Defaults to the source directory's basename.\r\n * @param {'plugin' | 'theme' | 'block' | 'theme-block' | 'generic'} domain - Text domain to look for in the source code,\r\n * unless the `ignoreDomain` option is used. By default, the \"Text Domain\" header of the plugin or theme is used.\r\n * If none is provided, it falls back to the project slug.\r\n * @param {boolean} ignoreDomain - Ignore the text domain completely and extract strings with any text domain.\r\n * @param {{}} headers - Array in JSON format of custom headers which will be added to the POT file. Defaults to empty array.\r\n * @param {boolean} location - Whether to write `#: filename:line` lines. Defaults to true, use `--no-location`\r\n * to skip the removal. Note that disabling this option makes it harder for technically skilled translators\r\n * to understand each message\u2019s context.\r\n * @param {boolean} skipJs - Skips JavaScript string extraction. Useful when this is done in another build step, e.g. through Babel.\r\n * @param {boolean} skipPhp - Skips PHP string extraction.\r\n * @param {boolean} skipBlade - Skips Blade-PHP string extraction.\r\n * @param {boolean} skipBlockJson - Skips string extraction from block.json files.\r\n * @param {boolean} skipThemeJson - Skips string extraction from theme.json files.\r\n * @param {boolean} skipAudit - Skips string audit where it tries to find possible mistakes in translatable strings.\r\n * Useful when running in an automated environment.\r\n * @param {string} fileComment - String that should be added as a comment to the top of the resulting POT file.\r\n * By default, a copyright comment is added for WordPress plugins and themes.\r\n * @param {string} packageName - Name to use for the package name in the resulting POT file's `Project-Id-Version` header.\r\n * Overrides the plugin or theme name, if applicable.\r\n * @param {boolean} silent - Whether to hide progress information.\r\n */\r\nexport interface Args {\r\n\tslug: string;\r\n\tdebug: boolean;\r\n\tdomain: DomainType;\r\n\tpaths: {\r\n\t\tcwd: string;\r\n\t\tout: string;\r\n\t\troot?: string;\r\n\t};\r\n\toptions?: {\r\n\t\tignoreDomain?: boolean;\r\n\t\tsilent?: boolean;\r\n\t\tjson?: boolean;\r\n\t\tlocation?: boolean;\r\n\t\tpackageName?: string;\r\n\t\theaders: { [key in PotHeaders]: string };\r\n\t\toutput?: boolean;\r\n\t\ttheme?: boolean;\r\n\t\tfileComment?: string;\r\n\t\tcharset?: string;\r\n\t\tskip: {\r\n\t\t\tjs?: boolean;\r\n\t\t\tphp?: boolean;\r\n\t\t\tblade?: boolean;\r\n\t\t\tblockJson?: boolean;\r\n\t\t\tthemeJson?: boolean;\r\n\t\t\taudit?: boolean;\r\n\t\t};\r\n\t\ttranslationDomains?: string[];\r\n\t};\r\n\theaders?: { [key in PotHeaders]: string };\r\n\tpatterns: Patterns;\r\n}\r\n\r\n/**\r\n * The arguments for the `makeJson` command.\r\n * \t@param {string} source the source directory\r\n * \t@param {string | null} destination the destination directory (defaults to source)\r\n * \t@param {string[] | null} allowedFormats the allowed files\r\n * \t@param {boolean} purge remove old json files (otherwise the content will be merged)\r\n * \t@param {boolean} prettyPrint?: pretty print json\r\n * \t@param {boolean} debug: enable debug mode\r\n */\r\nexport interface MakeJsonArgs {\r\n\ttimeStart: number;\r\n\tprettyPrint: boolean;\r\n\tdebug: boolean;\r\n\tdestination: string;\r\n\tscriptName?: string;\r\n\tpurge: boolean;\r\n\tstripUnused: boolean;\r\n\tsource: string;\r\n\tslug: string;\r\n\tallowedFormats?: string[];\r\n\tpaths: {\r\n\t\tcwd: string;\r\n\t\tout?: string;\r\n\t\troot?: string;\r\n\t};\r\n}\r\n\r\nexport interface I18nSchema {\r\n\t[key: string]: string | string[] | I18nSchema | I18nSchema[];\r\n}\r\n\r\n/**\r\n * Translation string metadata.\r\n * Gettext format: https://www.gnu.org/savannah-checkouts/gnu/gettext/FAQ.html\r\n *\r\n * @property {string} msgctxt - context for this translation, if not present the default context applies\r\n * @property {string} msgid - string to be translated\r\n * @property {string} msgid_plural the plural form of the original string (might not be present)\r\n * @property {string[]} msgstr an array of translations\r\n * @property {{}} comments an object with the following properties: translator, reference, extracted, flag, previous.\r\n */\r\nexport interface TranslationStrings {\r\n\t[msgctxt: string]: { [msgId: string]: GetTextTranslation };\r\n}\r\n\r\n/** The header of the JED file. */\r\nexport interface JedHeader {\r\n\tdomain: string;\r\n\tlang: string;\r\n\tplural_forms: string;\r\n\t[key: string]: string;\r\n}\r\n\r\n/**\r\n * The JSON data returned by the `makeJson` command.\r\n * @param {string} domain\r\n * @param {Record<string, string | string[] | JedHeader>} locale_data\r\n */\r\nexport interface JedData {\r\n\t[domain: string]: {\r\n\t\t[key: string]: string | string[] | JedHeader;\r\n\t};\r\n}\r\n\r\nexport interface MakeJson {\r\n\tdomain: string;\r\n\tgenerator: string;\r\n\t\"translation-revision-date\": string;\r\n\tsource: string;\r\n\tlocale_data: JedData;\r\n}\r\n\r\n/**\r\n * The header data of the current plugin / theme as returned by the `extractHeaders` command.\r\n */\r\nexport interface I18nHeaders {\r\n\tname: string;\r\n\tauthorString: string;\r\n\tbugs: string;\r\n\tlicense: string;\r\n\tauthor?: string;\r\n\txDomain: string;\r\n\tlanguage: string;\r\n\tversion: string;\r\n\tslug: string;\r\n\temail: string | undefined;\r\n}\r\n\r\nexport interface AuthorData {\r\n\tname: string;\r\n\temail?: string;\r\n\twebsite?: string;\r\n}\r\n"],
4
+ "sourcesContent": ["import type { GetTextTranslation } from \"gettext-parser\";\r\nimport type { pkgJsonHeaders, pluginHeaders, themeHeaders } from \"./const.js\";\r\n\r\nexport type ThemeHeadersType = typeof themeHeaders;\r\nexport type PluginHeadersType = typeof pluginHeaders;\r\nexport type PkgHeadersType = typeof pkgJsonHeaders;\r\n\r\n/**\r\n * The args headers Object types\r\n */\r\nexport type PotHeaders =\r\n\t| keyof PkgHeadersType\r\n\t| keyof PluginHeadersType\r\n\t| keyof ThemeHeadersType\r\n\t| \"license\"\r\n\t| \"email\"\r\n\t| \"language\"\r\n\t| \"domain\"\r\n\t| \"bugs\";\r\n\r\n// type is the value of the themeHeader Object\r\nexport type DomainType =\r\n\t| \"plugin\"\r\n\t| \"theme\"\r\n\t| \"block\"\r\n\t| \"theme-block\"\r\n\t| \"generic\";\r\n\r\n/**\r\n * The patterns to use when extracting strings from files.\r\n *\r\n * @param {string} mergePaths - Comma-separated list of POT files whose contents should be merged with the extracted strings.\r\n * If left empty, defaults to the destination POT file. POT file headers will be ignored.\r\n * @param {string} subtractPaths - Comma-separated list of POT files whose contents should act as some sort of denylist\r\n * for string extraction. Any string which is found on that denylist will not be extracted. This can be useful when\r\n * you want to create multiple POT files from the same source directory with slightly different content and no duplicate\r\n * strings between them.\r\n * @param {boolean} subtractAndMerge - Whether source code references and comments from the generated POT file should be\r\n * instead added to the POT file used for subtraction. Warning: this modifies the files passed to `subtractPaths`!\r\n * @param {string} include - Comma-separated list of files and paths that should be used for string extraction.\r\n * If provided, only these files and folders will be taken into account for string extraction.\r\n * For example, `--include=\"src,my-file.php` will ignore anything besides `my-file.php` and files in the `src`\r\n * directory. Simple glob patterns can be used, i.e. `--include=foo-*.php` includes any PHP file with the `foo-`\r\n * prefix. Leading and trailing slashes are ignored, i.e. `/my/directory/` is the same as `my/directory`.\r\n * @param {string} exclude - Comma-separated list of files and paths that should be skipped for string extraction.\r\n * For example, `--exclude=.github,myfile.php` would ignore any strings found within `myfile.php` or the `.github`\r\n * folder. Simple glob patterns can be used, i.e. `--exclude=foo-*.php` excludes any PHP file with the `foo-`\r\n * prefix. Leading and trailing slashes are ignored, i.e. `/my/directory/` is the same as `my/directory`.\r\n * The following files and folders are always excluded: node_modules, .git, .svn, .CVS, .hg, vendor, *.min.js.\r\n */\r\nexport interface Patterns {\r\n\tmergePaths?: string[];\r\n\tsubtractPaths?: string[];\r\n\tsubtractAndMerge?: boolean;\r\n\tinclude: string[];\r\n\texclude: string[];\r\n}\r\n\r\n/**\r\n * Create a POT file for a WordPress project.\r\n *\r\n * Scans PHP, Blade-PHP, and JavaScript files for translatable strings, as well as theme stylesheets and plugin files\r\n * if the source directory is detected as either a plugin or theme.\r\n *\r\n * @param {string} sourceDirectory - Directory to scan for string extraction.\r\n * @param {string} destination - Name of the resulting POT file.\r\n * @param {string | undefined} slug - Plugin or theme slug. Defaults to the source directory's basename.\r\n * @param {'plugin' | 'theme' | 'block' | 'theme-block' | 'generic'} domain - Text domain to look for in the source code,\r\n * unless the `ignoreDomain` option is used. By default, the \"Text Domain\" header of the plugin or theme is used.\r\n * If none is provided, it falls back to the project slug.\r\n * @param {boolean} ignoreDomain - Ignore the text domain completely and extract strings with any text domain.\r\n * @param {{}} headers - Array in JSON format of custom headers which will be added to the POT file. Defaults to empty array.\r\n * @param {boolean} location - Whether to write `#: filename:line` lines. Defaults to true, use `--no-location`\r\n * to skip the removal. Note that disabling this option makes it harder for technically skilled translators\r\n * to understand each message\u2019s context.\r\n * @param {boolean} skipJs - Skips JavaScript string extraction. Useful when this is done in another build step, e.g. through Babel.\r\n * @param {boolean} skipPhp - Skips PHP string extraction.\r\n * @param {boolean} skipBlade - Skips Blade-PHP string extraction.\r\n * @param {boolean} skipBlockJson - Skips string extraction from block.json files.\r\n * @param {boolean} skipThemeJson - Skips string extraction from theme.json files.\r\n * @param {boolean} skipAudit - Skips string audit where it tries to find possible mistakes in translatable strings.\r\n * Useful when running in an automated environment.\r\n * @param {string} fileComment - String that should be added as a comment to the top of the resulting POT file.\r\n * By default, a copyright comment is added for WordPress plugins and themes.\r\n * @param {string} packageName - Name to use for the package name in the resulting POT file's `Project-Id-Version` header.\r\n * Overrides the plugin or theme name, if applicable.\r\n * @param {boolean} silent - Whether to hide progress information.\r\n */\r\nexport interface Args {\r\n\tslug: string;\r\n\tdebug: boolean;\r\n\tdomain: DomainType;\r\n\tpaths: {\r\n\t\tcwd: string;\r\n\t\tout: string;\r\n\t\troot?: string;\r\n\t};\r\n\toptions?: {\r\n\t\tignoreDomain?: boolean;\r\n\t\tsilent?: boolean;\r\n\t\tjson?: boolean;\r\n\t\tlocation?: boolean;\r\n\t\tpackageName?: string;\r\n\t\theaders: { [key in PotHeaders]: string };\r\n\t\toutput?: boolean;\r\n\t\ttheme?: boolean;\r\n\t\tfileComment?: string;\r\n\t\tcharset?: string;\r\n\t\tskip: {\r\n\t\t\tjs?: boolean;\r\n\t\t\tphp?: boolean;\r\n\t\t\tblade?: boolean;\r\n\t\t\tblockJson?: boolean;\r\n\t\t\tthemeJson?: boolean;\r\n\t\t\taudit?: boolean;\r\n\t\t};\r\n\t\ttranslationDomains?: string[];\r\n\t};\r\n\theaders?: { [key in PotHeaders]: string };\r\n\tpatterns: Patterns;\r\n\ttimeStart?: Date;\r\n}\r\n\r\n/**\r\n * The arguments for the `makeJson` command.\r\n * \t@param {string} source the source directory\r\n * \t@param {string | null} destination the destination directory (defaults to source)\r\n * \t@param {string[] | null} allowedFormats the allowed files\r\n * \t@param {boolean} purge remove old json files (otherwise the content will be merged)\r\n * \t@param {boolean} prettyPrint?: pretty print json\r\n * \t@param {boolean} debug: enable debug mode\r\n */\r\nexport interface MakeJsonArgs {\r\n\ttimeStart: number;\r\n\tprettyPrint: boolean;\r\n\tdebug: boolean;\r\n\tdestination: string;\r\n\tscriptName?: string;\r\n\tpurge: boolean;\r\n\tstripUnused: boolean;\r\n\tsource: string;\r\n\tslug: string;\r\n\tallowedFormats?: string[];\r\n\tpaths: {\r\n\t\tcwd: string;\r\n\t\tout?: string;\r\n\t\troot?: string;\r\n\t};\r\n}\r\n\r\nexport interface I18nSchema {\r\n\t[key: string]: string | string[] | I18nSchema | I18nSchema[];\r\n}\r\n\r\n/**\r\n * Translation string metadata.\r\n * Gettext format: https://www.gnu.org/savannah-checkouts/gnu/gettext/FAQ.html\r\n *\r\n * @property {string} msgctxt - context for this translation, if not present the default context applies\r\n * @property {string} msgid - string to be translated\r\n * @property {string} msgid_plural the plural form of the original string (might not be present)\r\n * @property {string[]} msgstr an array of translations\r\n * @property {{}} comments an object with the following properties: translator, reference, extracted, flag, previous.\r\n */\r\nexport interface TranslationStrings {\r\n\t[msgctxt: string]: { [msgId: string]: GetTextTranslation };\r\n}\r\n\r\n/** The header of the JED file. */\r\nexport interface JedHeader {\r\n\tdomain: string;\r\n\tlang: string;\r\n\tplural_forms: string;\r\n\t[key: string]: string;\r\n}\r\n\r\n/**\r\n * The JSON data returned by the `makeJson` command.\r\n * @param {string} domain\r\n * @param {Record<string, string | string[] | JedHeader>} locale_data\r\n */\r\nexport interface JedData {\r\n\t[domain: string]: {\r\n\t\t[key: string]: string | string[] | JedHeader;\r\n\t};\r\n}\r\n\r\nexport interface MakeJson {\r\n\tdomain: string;\r\n\tgenerator: string;\r\n\t\"translation-revision-date\": string;\r\n\tsource: string;\r\n\tlocale_data: JedData;\r\n}\r\n\r\n/**\r\n * The header data of the current plugin / theme as returned by the `extractHeaders` command.\r\n */\r\nexport interface I18nHeaders {\r\n\tname: string;\r\n\tauthorString: string;\r\n\tbugs: string;\r\n\tlicense: string;\r\n\tauthor?: string;\r\n\txDomain: string;\r\n\tlanguage: string;\r\n\tversion: string;\r\n\tslug: string;\r\n\temail: string | undefined;\r\n}\r\n\r\nexport interface AuthorData {\r\n\tname: string;\r\n\temail?: string;\r\n\twebsite?: string;\r\n}\r\n"],
5
5
  "mappings": ";;;;;;;;;;;;;;AAAA;AAAA;",
6
6
  "names": []
7
7
  }
@@ -1,8 +1,161 @@
1
- "use strict";var m=Object.create;var s=Object.defineProperty;var d=Object.getOwnPropertyDescriptor;var x=Object.getOwnPropertyNames;var h=Object.getPrototypeOf,k=Object.prototype.hasOwnProperty;var y=(t,e)=>{for(var n in e)s(t,n,{get:e[n],enumerable:!0})},u=(t,e,n,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of x(e))!k.call(t,r)&&r!==n&&s(t,r,{get:()=>e[r],enumerable:!(o=d(e,r))||o.enumerable});return t};var p=(t,e,n)=>(n=t!=null?m(h(t)):{},u(e||!t||!t.__esModule?s(n,"default",{value:t,enumerable:!0}):n,t)),$=t=>u(s({},"__esModule",{value:!0}),t);var B={};y(B,{detectPatternType:()=>M,getCommentBlock:()=>P,getCopyright:()=>b,getFileExtension:()=>T,getPkgJsonData:()=>f,outputPathRecap:()=>U,printModuleInfo:()=>w,printStats:()=>j,printTimeElapsed:()=>D,removeCommentMarkup:()=>F,reverseSlashes:()=>v,stringstring:()=>C,stripTranslationMarkup:()=>S});module.exports=$(B);var a=p(require("node:fs")),i=require("node:os"),g=p(require("node:path")),l=require("../const.js");function P(t){const e=t.match(/\/\*\*?[\s\S]*?\*\//);return e!==null?e[0]:t}function F(t){return t.match(/[a-zA-Z].*/gm)}function S(t){const e=/\/\*\*?\s*(?:translators:)\s*([\s\S]*?)\s*\*\/|\/\/\s*(?:translators:)\s*(.*)$/i,n=t.match(e);return n?n[1]:t}function C(t){return typeof t=="string"?t.includes(",")?t.split(","):[t]:[]}function M(t){const e=t.includes("."),n=t.includes("/");return t.includes("*")?"glob":!e&&!n?"directory":e&&!n?"file":"glob"}function T(t){return t.endsWith(".blade.php")?"blade.php":t.split(".").pop()||""}function b(t,e="GPL v2 or later"){return`# Copyright (C) ${new Date().getFullYear()} ${t}
2
- # This file is distributed under the ${e} license.`}function v(t){return t.replace(/\\/g,"/")}function f(t,...e){const n={},o=g.default.join(t||process.cwd(),"package.json"),r=a.default.existsSync(o)?require(o):{};for(const c of e)r[c]&&(n[c]=r[c]);return n}function w(){const{version:t,name:e}=f(l.modulePath,"name","version");console.log(`${e} version: ${t}`)}function D(t,e,n=new Date){console.log(`
3
- \u{1F680} ${t}: Task completed! ${t.split("-")[1]} file created in ${n.getTime()-e.getTime()}ms`)}function j(){console.log("Memory usage:",(process.memoryUsage().heapUsed/1024/1024).toFixed(2),"MB (Free:",((0,i.totalmem)()/1024/1024/1024).toFixed(2),`GB)
4
- Cpu User:`,(process.cpuUsage().user/1e6).toFixed(2),"ms Cpu System:",(process.cpuUsage().system/1e6).toFixed(2),"ms of",(0,i.cpus)().length,"cores")}function U(t,e){return`
5
- Script Path: ${t}
6
- for ${e.include.join()}
7
- ignoring patterns: ${e.exclude.join()}
8
- `}0&&(module.exports={detectPatternType,getCommentBlock,getCopyright,getFileExtension,getPkgJsonData,outputPathRecap,printModuleInfo,printStats,printTimeElapsed,removeCommentMarkup,reverseSlashes,stringstring,stripTranslationMarkup});
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var common_exports = {};
30
+ __export(common_exports, {
31
+ detectPatternType: () => detectPatternType,
32
+ getCommentBlock: () => getCommentBlock,
33
+ getCopyright: () => getCopyright,
34
+ getFileExtension: () => getFileExtension,
35
+ getPkgJsonData: () => getPkgJsonData,
36
+ outputPathRecap: () => outputPathRecap,
37
+ printModuleInfo: () => printModuleInfo,
38
+ printStats: () => printStats,
39
+ printTimeElapsed: () => printTimeElapsed,
40
+ removeCommentMarkup: () => removeCommentMarkup,
41
+ reverseSlashes: () => reverseSlashes,
42
+ stringstring: () => stringstring,
43
+ stripTranslationMarkup: () => stripTranslationMarkup
44
+ });
45
+ module.exports = __toCommonJS(common_exports);
46
+ var import_node_fs = __toESM(require("node:fs"));
47
+ var import_node_os = require("node:os");
48
+ var import_node_path = __toESM(require("node:path"));
49
+ var import_const = require("../const.js");
50
+ function getCommentBlock(input) {
51
+ const commentBlock = input.match(/\/\*\*?[\s\S]*?\*\//);
52
+ return commentBlock !== null ? commentBlock[0] : input;
53
+ }
54
+ function removeCommentMarkup(input) {
55
+ return input.match(/[a-zA-Z].*/gm);
56
+ }
57
+ function stripTranslationMarkup(comment) {
58
+ const commentPattern = /\/\*\*?\s*(?:translators:)\s*([\s\S]*?)\s*\*\/|\/\/\s*(?:translators:)\s*(.*)$/i;
59
+ const matches = comment.match(commentPattern);
60
+ return matches ? matches[1] : comment;
61
+ }
62
+ function stringstring(string) {
63
+ if (typeof string === "string") {
64
+ if (string.includes(",")) {
65
+ return string.split(",");
66
+ }
67
+ return [string];
68
+ }
69
+ return [];
70
+ }
71
+ function detectPatternType(pattern) {
72
+ const containsFileExtension = pattern.includes(".");
73
+ const containsDirectorySeparator = pattern.includes("/");
74
+ if (pattern.includes("*")) {
75
+ return "glob";
76
+ }
77
+ if (!containsFileExtension && !containsDirectorySeparator) {
78
+ return "directory";
79
+ }
80
+ if (containsFileExtension && !containsDirectorySeparator) {
81
+ return "file";
82
+ }
83
+ return "glob";
84
+ }
85
+ function getFileExtension(filename) {
86
+ if (filename.endsWith(".blade.php")) {
87
+ return "blade.php";
88
+ }
89
+ return filename.split(".").pop() || "";
90
+ }
91
+ function getCopyright(slug, license = "GPL v2 or later") {
92
+ return `# Copyright (C) ${(/* @__PURE__ */ new Date()).getFullYear()} ${slug}
93
+ # This file is distributed under the ${license} license.`;
94
+ }
95
+ function reverseSlashes(filePath) {
96
+ return filePath.replace(/\\/g, "/");
97
+ }
98
+ function getPkgJsonData(location, ...fields) {
99
+ const requested = {};
100
+ const pkgJsonPath = import_node_path.default.join(location || process.cwd(), "package.json");
101
+ const pkgJson = import_node_fs.default.existsSync(pkgJsonPath) ? require(pkgJsonPath) : {};
102
+ for (const field of fields) {
103
+ if (pkgJson[field]) {
104
+ requested[field] = pkgJson[field];
105
+ }
106
+ }
107
+ return requested;
108
+ }
109
+ function printModuleInfo() {
110
+ const { version, name } = getPkgJsonData(import_const.modulePath, "name", "version");
111
+ console.log(`
112
+ ${name} version: ${version}`);
113
+ }
114
+ function printTimeElapsed(scriptName, timeStart, timeEnd = /* @__PURE__ */ new Date()) {
115
+ if (!timeStart) {
116
+ return;
117
+ }
118
+ console.log(
119
+ `
120
+ \u{1F680} ${scriptName}: Task completed! ${scriptName.split("-")[1]} file created in ${timeEnd.getTime() - timeStart.getTime()}ms`
121
+ );
122
+ }
123
+ function printStats() {
124
+ console.log(
125
+ "Memory usage:",
126
+ (process.memoryUsage().heapUsed / 1024 / 1024).toFixed(2),
127
+ "MB (Free:",
128
+ ((0, import_node_os.totalmem)() / 1024 / 1024 / 1024).toFixed(2),
129
+ "GB)\nCpu User:",
130
+ (process.cpuUsage().user / 1e6).toFixed(2),
131
+ "ms Cpu System:",
132
+ (process.cpuUsage().system / 1e6).toFixed(2),
133
+ "ms of",
134
+ (0, import_node_os.cpus)().length,
135
+ "cores"
136
+ );
137
+ }
138
+ function outputPathRecap(cwd, patterns) {
139
+ return `
140
+ Script Path: ${cwd}
141
+ for ${patterns.include.join()}
142
+ ignoring patterns: ${patterns.exclude.join()}
143
+ `;
144
+ }
145
+ // Annotate the CommonJS export names for ESM import in node:
146
+ 0 && (module.exports = {
147
+ detectPatternType,
148
+ getCommentBlock,
149
+ getCopyright,
150
+ getFileExtension,
151
+ getPkgJsonData,
152
+ outputPathRecap,
153
+ printModuleInfo,
154
+ printStats,
155
+ printTimeElapsed,
156
+ removeCommentMarkup,
157
+ reverseSlashes,
158
+ stringstring,
159
+ stripTranslationMarkup
160
+ });
161
+ //# sourceMappingURL=common.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/utils/common.ts"],
4
- "sourcesContent": ["import fs from \"node:fs\";\r\nimport { cpus, totalmem } from \"node:os\";\r\nimport path from \"node:path\";\r\nimport { modulePath } from \"../const.js\";\r\nimport type { Patterns } from \"../types.js\";\r\n\r\n/**\r\n * A function that removes comment markup from a given string.\r\n *\r\n * @param {string} input - The input string with comment markup.\r\n * @return {string} - The input string without comment markup.\r\n */\r\nexport function getCommentBlock(input: string): string {\r\n\tconst commentBlock = input.match(/\\/\\*\\*?[\\s\\S]*?\\*\\//);\r\n\treturn commentBlock !== null ? commentBlock[0] : input;\r\n}\r\n\r\n/**\r\n * A function that starts to capture the text after the first letter.\r\n *\r\n * @param {string} input - The input string with comment markup.\r\n * @return {string} - The input string without comment markup.\r\n */\r\nexport function removeCommentMarkup(input: string): string[] | null {\r\n\treturn input.match(/[a-zA-Z].*/gm);\r\n}\r\n\r\n/**\r\n * Removes the markup from a comment string.\r\n *\r\n * @param {string} comment - The comment string to remove markup from.\r\n * @return {string} The comment text without the markers.\r\n */\r\nexport function stripTranslationMarkup(comment: string): string {\r\n\tconst commentPattern =\r\n\t\t/\\/\\*\\*?\\s*(?:translators:)\\s*([\\s\\S]*?)\\s*\\*\\/|\\/\\/\\s*(?:translators:)\\s*(.*)$/i;\r\n\tconst matches = comment.match(commentPattern);\r\n\treturn matches ? matches[1] : comment;\r\n}\r\n\r\n/**\r\n * Splits a string into an array of strings based on the presence of a comma.\r\n *\r\n * @param {string} string - The string to be split.\r\n * @return {string[]} An array of strings after splitting the input string.\r\n */\r\nexport function stringstring(string: string | string[] | undefined): string[] {\r\n\tif (typeof string === \"string\") {\r\n\t\tif (string.includes(\",\")) {\r\n\t\t\treturn string.split(\",\");\r\n\t\t}\r\n\t\treturn [string];\r\n\t}\r\n\treturn [];\r\n}\r\n\r\n/**\r\n * Determines if a pattern represents a file, a directory, or a glob pattern.\r\n * @param pattern - The pattern string to evaluate.\r\n * @returns 'file', 'directory', or 'glob'.\r\n */\r\nexport function detectPatternType(\r\n\tpattern: string,\r\n): \"file\" | \"directory\" | \"glob\" {\r\n\tconst containsFileExtension = pattern.includes(\".\");\r\n\tconst containsDirectorySeparator = pattern.includes(\"/\");\r\n\r\n\tif (pattern.includes(\"*\")) {\r\n\t\treturn \"glob\";\r\n\t}\r\n\tif (!containsFileExtension && !containsDirectorySeparator) {\r\n\t\treturn \"directory\";\r\n\t}\r\n\tif (containsFileExtension && !containsDirectorySeparator) {\r\n\t\treturn \"file\";\r\n\t}\r\n\treturn \"glob\";\r\n}\r\n\r\n/**\r\n * Gets the file extension from a filename.\r\n * @param filename - The name of the file to extract the extension from.\r\n * @returns The file extension, or 'blade.php' for Blade templates.\r\n */\r\nexport function getFileExtension(filename: string): string {\r\n\tif (filename.endsWith(\".blade.php\")) {\r\n\t\treturn \"blade.php\";\r\n\t}\r\n\treturn filename.split(\".\").pop() || \"\";\r\n}\r\n\r\n/**\r\n * Generates a copyright comment for the specified slug and license.\r\n *\r\n * @param slug - The slug to include in the copyright comment\r\n * @param [license='GPL v2 or later'] - The license to use in the copyright comment\r\n * @return The generated copyright comment\r\n */\r\nexport function getCopyright(\r\n\tslug: string,\r\n\tlicense = \"GPL v2 or later\",\r\n): string {\r\n\treturn (\r\n\t\t`# Copyright (C) ${new Date().getFullYear()} ${slug}\\n` +\r\n\t\t`# This file is distributed under the ${license} license.`\r\n\t);\r\n}\r\n\r\n/**\r\n * Reverse slashes in a path, and replace backward slashes with forward slashes\r\n *\r\n * @param filePath - The path to be reversed.\r\n * @return {string} The reversed path.\r\n */\r\nexport function reverseSlashes(filePath: string): string {\r\n\t// Replace backward slashes with forward slashes\r\n\treturn filePath.replace(/\\\\/g, \"/\");\r\n}\r\n\r\n/**\r\n * The makepot package.json file data\r\n * @arguments {string[]} fields - The fields to extract\r\n * @return {Record<string, unknown>} - The package.json data\r\n */\r\nexport function getPkgJsonData(\r\n\tlocation?: string,\r\n\t...fields: string[]\r\n): Record<string, unknown> {\r\n\tconst requested: Record<string, unknown> = {};\r\n\t// read the package.json file the is in the root directory\r\n\tconst pkgJsonPath = path.join(location || process.cwd(), \"package.json\");\r\n\t// read the package.json file or return an empty object\r\n\tconst pkgJson: Record<string, unknown> = fs.existsSync(pkgJsonPath)\r\n\t\t? require(pkgJsonPath)\r\n\t\t: {};\r\n\t// extract the requested fields from the package.json\r\n\tfor (const field of fields) {\r\n\t\tif (pkgJson[field]) {\r\n\t\t\trequested[field] = pkgJson[field];\r\n\t\t}\r\n\t}\r\n\treturn requested;\r\n}\r\n\r\n/**\r\n * Print the module header with the current version and name\r\n */\r\nexport function printModuleInfo() {\r\n\tconst { version, name } = getPkgJsonData(modulePath, \"name\", \"version\");\r\n\t/* print the version */\r\n\tconsole.log(`${name} version: ${version}`);\r\n}\r\n\r\n/**\r\n * Output to the console the time elapsed in milliseconds between two dates\r\n * @param scriptName the name of the script\r\n * @param timeStart the start time\r\n * @param timeEnd the end time\r\n */\r\nexport function printTimeElapsed(\r\n\tscriptName: \"Make-Pot\" | \"Make-Json\",\r\n\ttimeStart: Date,\r\n\ttimeEnd: Date = new Date(),\r\n) {\r\n\tconsole.log(\r\n\t\t`\\n\uD83D\uDE80 ${scriptName}: Task completed! ${scriptName.split(\"-\")[1]} file created in ${timeEnd.getTime() - timeStart.getTime()\r\n\t\t}ms`,\r\n\t);\r\n}\r\n\r\n/**\r\n/**\r\n* Prints the memory usage and cpu usage of the system\r\n */\r\nexport function printStats() {\r\n\tconsole.log(\r\n\t\t\"Memory usage:\",\r\n\t\t(process.memoryUsage().heapUsed / 1024 / 1024).toFixed(2),\r\n\t\t\"MB (Free:\",\r\n\t\t(totalmem() / 1024 / 1024 / 1024).toFixed(2),\r\n\t\t\"GB)\\nCpu User:\",\r\n\t\t(process.cpuUsage().user / 1000000).toFixed(2),\r\n\t\t\"ms Cpu System:\",\r\n\t\t(process.cpuUsage().system / 1000000).toFixed(2),\r\n\t\t\"ms of\",\r\n\t\tcpus().length,\r\n\t\t\"cores\",\r\n\t);\r\n}\r\n\r\n/**\r\n * Returns the output path recap\r\n *\r\n * @param {string} cwd - The current working directory\r\n * @param {Patterns} patterns - The patterns to be used for the extraction process\r\n * @return {string} - The output path recap\r\n */\r\nexport function outputPathRecap(cwd: string, patterns: Patterns): string {\r\n\treturn `\\nScript Path: ${cwd}\\nfor ${patterns.include.join()}\\nignoring patterns: ${patterns.exclude.join()}\\n`;\r\n}\r\n"],
5
- "mappings": "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",
4
+ "sourcesContent": ["import fs from \"node:fs\";\r\nimport { cpus, totalmem } from \"node:os\";\r\nimport path from \"node:path\";\r\nimport { modulePath } from \"../const.js\";\r\nimport type { Patterns } from \"../types.js\";\r\n\r\n/**\r\n * A function that removes comment markup from a given string.\r\n *\r\n * @param {string} input - The input string with comment markup.\r\n * @return {string} - The input string without comment markup.\r\n */\r\nexport function getCommentBlock(input: string): string {\r\n\tconst commentBlock = input.match(/\\/\\*\\*?[\\s\\S]*?\\*\\//);\r\n\treturn commentBlock !== null ? commentBlock[0] : input;\r\n}\r\n\r\n/**\r\n * A function that starts to capture the text after the first letter.\r\n *\r\n * @param {string} input - The input string with comment markup.\r\n * @return {string} - The input string without comment markup.\r\n */\r\nexport function removeCommentMarkup(input: string): string[] | null {\r\n\treturn input.match(/[a-zA-Z].*/gm);\r\n}\r\n\r\n/**\r\n * Removes the markup from a comment string.\r\n *\r\n * @param {string} comment - The comment string to remove markup from.\r\n * @return {string} The comment text without the markers.\r\n */\r\nexport function stripTranslationMarkup(comment: string): string {\r\n\tconst commentPattern =\r\n\t\t/\\/\\*\\*?\\s*(?:translators:)\\s*([\\s\\S]*?)\\s*\\*\\/|\\/\\/\\s*(?:translators:)\\s*(.*)$/i;\r\n\tconst matches = comment.match(commentPattern);\r\n\treturn matches ? matches[1] : comment;\r\n}\r\n\r\n/**\r\n * Splits a string into an array of strings based on the presence of a comma.\r\n *\r\n * @param {string} string - The string to be split.\r\n * @return {string[]} An array of strings after splitting the input string.\r\n */\r\nexport function stringstring(string: string | string[] | undefined): string[] {\r\n\tif (typeof string === \"string\") {\r\n\t\tif (string.includes(\",\")) {\r\n\t\t\treturn string.split(\",\");\r\n\t\t}\r\n\t\treturn [string];\r\n\t}\r\n\treturn [];\r\n}\r\n\r\n/**\r\n * Determines if a pattern represents a file, a directory, or a glob pattern.\r\n * @param pattern - The pattern string to evaluate.\r\n * @returns 'file', 'directory', or 'glob'.\r\n */\r\nexport function detectPatternType(\r\n\tpattern: string,\r\n): \"file\" | \"directory\" | \"glob\" {\r\n\tconst containsFileExtension = pattern.includes(\".\");\r\n\tconst containsDirectorySeparator = pattern.includes(\"/\");\r\n\r\n\tif (pattern.includes(\"*\")) {\r\n\t\treturn \"glob\";\r\n\t}\r\n\tif (!containsFileExtension && !containsDirectorySeparator) {\r\n\t\treturn \"directory\";\r\n\t}\r\n\tif (containsFileExtension && !containsDirectorySeparator) {\r\n\t\treturn \"file\";\r\n\t}\r\n\treturn \"glob\";\r\n}\r\n\r\n/**\r\n * Gets the file extension from a filename.\r\n * @param filename - The name of the file to extract the extension from.\r\n * @returns The file extension, or 'blade.php' for Blade templates.\r\n */\r\nexport function getFileExtension(filename: string): string {\r\n\tif (filename.endsWith(\".blade.php\")) {\r\n\t\treturn \"blade.php\";\r\n\t}\r\n\treturn filename.split(\".\").pop() || \"\";\r\n}\r\n\r\n/**\r\n * Generates a copyright comment for the specified slug and license.\r\n *\r\n * @param slug - The slug to include in the copyright comment\r\n * @param [license='GPL v2 or later'] - The license to use in the copyright comment\r\n * @return The generated copyright comment\r\n */\r\nexport function getCopyright(\r\n\tslug: string,\r\n\tlicense = \"GPL v2 or later\",\r\n): string {\r\n\treturn (\r\n\t\t`# Copyright (C) ${new Date().getFullYear()} ${slug}\\n` +\r\n\t\t`# This file is distributed under the ${license} license.`\r\n\t);\r\n}\r\n\r\n/**\r\n * Reverse slashes in a path, and replace backward slashes with forward slashes\r\n *\r\n * @param filePath - The path to be reversed.\r\n * @return {string} The reversed path.\r\n */\r\nexport function reverseSlashes(filePath: string): string {\r\n\t// Replace backward slashes with forward slashes\r\n\treturn filePath.replace(/\\\\/g, \"/\");\r\n}\r\n\r\n/**\r\n * The makepot package.json file data\r\n * @arguments {string[]} fields - The fields to extract\r\n * @return {Record<string, unknown>} - The package.json data\r\n */\r\nexport function getPkgJsonData(\r\n\tlocation?: string,\r\n\t...fields: string[]\r\n): Record<string, unknown> {\r\n\tconst requested: Record<string, unknown> = {};\r\n\t// read the package.json file the is in the root directory\r\n\tconst pkgJsonPath = path.join(location || process.cwd(), \"package.json\");\r\n\t// read the package.json file or return an empty object\r\n\tconst pkgJson: Record<string, unknown> = fs.existsSync(pkgJsonPath)\r\n\t\t? require(pkgJsonPath)\r\n\t\t: {};\r\n\t// extract the requested fields from the package.json\r\n\tfor (const field of fields) {\r\n\t\tif (pkgJson[field]) {\r\n\t\t\trequested[field] = pkgJson[field];\r\n\t\t}\r\n\t}\r\n\treturn requested;\r\n}\r\n\r\n/**\r\n * Print the module header with the current version and name\r\n */\r\nexport function printModuleInfo() {\r\n\tconst { version, name } = getPkgJsonData(modulePath, \"name\", \"version\");\r\n\t/* print the version */\r\n\tconsole.log(`\\n${name} version: ${version}`);\r\n}\r\n\r\n/**\r\n * Output to the console the time elapsed in milliseconds between two dates\r\n * @param scriptName the name of the script\r\n * @param timeStart the start time\r\n * @param timeEnd the end time\r\n */\r\nexport function printTimeElapsed(\r\n\tscriptName: \"Make-Pot\" | \"Make-Json\",\r\n\ttimeStart?: Date,\r\n\ttimeEnd: Date = new Date(),\r\n) {\r\n\tif (!timeStart) {\r\n\t\treturn;\r\n\t}\r\n\tconsole.log(\r\n\t\t`\\n\uD83D\uDE80 ${scriptName}: Task completed! ${scriptName.split(\"-\")[1]} file created in ${timeEnd.getTime() - timeStart.getTime()\r\n\t\t}ms`,\r\n\t);\r\n}\r\n\r\n/**\r\n/**\r\n* Prints the memory usage and cpu usage of the system\r\n */\r\nexport function printStats() {\r\n\tconsole.log(\r\n\t\t\"Memory usage:\",\r\n\t\t(process.memoryUsage().heapUsed / 1024 / 1024).toFixed(2),\r\n\t\t\"MB (Free:\",\r\n\t\t(totalmem() / 1024 / 1024 / 1024).toFixed(2),\r\n\t\t\"GB)\\nCpu User:\",\r\n\t\t(process.cpuUsage().user / 1000000).toFixed(2),\r\n\t\t\"ms Cpu System:\",\r\n\t\t(process.cpuUsage().system / 1000000).toFixed(2),\r\n\t\t\"ms of\",\r\n\t\tcpus().length,\r\n\t\t\"cores\",\r\n\t);\r\n}\r\n\r\n/**\r\n * Returns the output path recap\r\n *\r\n * @param {string} cwd - The current working directory\r\n * @param {Patterns} patterns - The patterns to be used for the extraction process\r\n * @return {string} - The output path recap\r\n */\r\nexport function outputPathRecap(cwd: string, patterns: Patterns): string {\r\n\treturn `\\nScript Path: ${cwd}\\nfor ${patterns.include.join()}\\nignoring patterns: ${patterns.exclude.join()}\\n`;\r\n}\r\n"],
5
+ "mappings": "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",
6
6
  "names": ["path", "fs"]
7
7
  }
@@ -1 +1,69 @@
1
- "use strict";var c=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames;var g=Object.prototype.hasOwnProperty;var u=(n,t)=>{for(var s in t)c(n,s,{get:t[s],enumerable:!0})},l=(n,t,s,e)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of m(t))!g.call(n,o)&&o!==s&&c(n,o,{get:()=>t[o],enumerable:!(e=f(t,o))||e.enumerable});return n};var k=n=>l(c({},"__esModule",{value:!0}),n);var x={};u(x,{buildBlock:()=>d,getKeyByValue:()=>B,yieldParsedData:()=>a});module.exports=k(x);var r=require("gettext-merger");function B(n,t){return Object.keys(n).find(s=>n[s]===t)??void 0}const d=(n,t,s=void 0)=>{const e=new r.Block([]);return e.msgctxt=void 0,e.msgid=t,e.msgid_plural="",e.msgstr=[],e.comments={},n&&(e.comments.extracted=[n]),s?.length&&(e.comments.reference=s),e};function a(n,t,s){const e=new r.SetOfBlocks([],s);if(!n)return e;e.path=s;for(const o of n){const i=d(o.msgid,o.msgctxt,o.comments?.reference);i&&e.blocks.push(i)}return e}0&&(module.exports={buildBlock,getKeyByValue,yieldParsedData});
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var extractors_exports = {};
20
+ __export(extractors_exports, {
21
+ buildBlock: () => buildBlock,
22
+ getKeyByValue: () => getKeyByValue,
23
+ yieldParsedData: () => yieldParsedData
24
+ });
25
+ module.exports = __toCommonJS(extractors_exports);
26
+ var import_gettext_merger = require("gettext-merger");
27
+ function getKeyByValue(object, value) {
28
+ return Object.keys(object).find((key) => object[key] === value) ?? void 0;
29
+ }
30
+ const buildBlock = (label, string, filePath = void 0) => {
31
+ const block = new import_gettext_merger.Block([]);
32
+ block.msgctxt = void 0;
33
+ block.msgid = string;
34
+ block.msgid_plural = "";
35
+ block.msgstr = [];
36
+ block.comments = {};
37
+ if (label) {
38
+ block.comments.extracted = [label];
39
+ }
40
+ if (filePath?.length) {
41
+ block.comments.reference = filePath;
42
+ }
43
+ return block;
44
+ };
45
+ function yieldParsedData(parsed, _filename, filepath) {
46
+ const gettextTranslations = new import_gettext_merger.SetOfBlocks([], filepath);
47
+ if (!parsed) {
48
+ return gettextTranslations;
49
+ }
50
+ gettextTranslations.path = filepath;
51
+ for (const item of parsed) {
52
+ const block = buildBlock(
53
+ item.msgid,
54
+ item.msgctxt,
55
+ item.comments?.reference
56
+ );
57
+ if (block) {
58
+ gettextTranslations.blocks.push(block);
59
+ }
60
+ }
61
+ return gettextTranslations;
62
+ }
63
+ // Annotate the CommonJS export names for ESM import in node:
64
+ 0 && (module.exports = {
65
+ buildBlock,
66
+ getKeyByValue,
67
+ yieldParsedData
68
+ });
69
+ //# sourceMappingURL=extractors.js.map
@@ -1 +1,59 @@
1
- "use strict";var p=Object.create;var s=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames;var f=Object.getPrototypeOf,l=Object.prototype.hasOwnProperty;var c=(t,r)=>{for(var e in r)s(t,e,{get:r[e],enumerable:!0})},i=(t,r,e,o)=>{if(r&&typeof r=="object"||typeof r=="function")for(let n of m(r))!l.call(t,n)&&n!==e&&s(t,n,{get:()=>r[n],enumerable:!(o=a(r,n))||o.enumerable});return t};var u=(t,r,e)=>(e=t!=null?p(f(t)):{},i(r||!t||!t.__esModule?s(e,"default",{value:t,enumerable:!0}):e,t)),y=t=>i(s({},"__esModule",{value:!0}),t);var T={};c(T,{outputJson:()=>x});module.exports=y(T);var g=u(require("tannin"));function x(t,r,e){const o={[t.slug]:{"":r??{},...e.toJson()}};return new g.default(o).toString()}0&&(module.exports={outputJson});
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var output_exports = {};
20
+ __export(output_exports, {
21
+ outputJson: () => outputJson
22
+ });
23
+ module.exports = __toCommonJS(output_exports);
24
+ function outputJson(args, potHeader, translationsUnion) {
25
+ const domain = args.slug;
26
+ const gettextTranslations = translationsUnion.toJson();
27
+ const jedData = {
28
+ [domain]: {
29
+ "": {
30
+ domain,
31
+ lang: potHeader?.Language || "en",
32
+ plural_forms: potHeader?.["Plural-Forms"] || "nplurals=2; plural=(n != 1);",
33
+ ...potHeader
34
+ }
35
+ }
36
+ };
37
+ for (const msgctxt of Object.keys(gettextTranslations)) {
38
+ const contextTranslations = gettextTranslations[msgctxt];
39
+ for (const msgid of Object.keys(contextTranslations)) {
40
+ const translation = contextTranslations[msgid];
41
+ if (msgid === "") continue;
42
+ const key = msgctxt && msgctxt !== "" ? `${msgctxt}${msgid}` : msgid;
43
+ jedData[domain][key] = translation.msgstr;
44
+ }
45
+ }
46
+ const makeJson = {
47
+ domain,
48
+ "translation-revision-date": (/* @__PURE__ */ new Date()).toISOString(),
49
+ generator: "makePot",
50
+ source: "",
51
+ locale_data: jedData
52
+ };
53
+ return JSON.stringify(makeJson, null, 2);
54
+ }
55
+ // Annotate the CommonJS export names for ESM import in node:
56
+ 0 && (module.exports = {
57
+ outputJson
58
+ });
59
+ //# sourceMappingURL=output.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/utils/output.ts"],
4
- "sourcesContent": ["import type { SetOfBlocks } from \"gettext-merger\";\r\nimport Tannin from \"tannin\";\r\nimport type { Args } from \"../types.js\";\r\nimport type { GetTextTranslation } from 'gettext-parser'\r\n\r\n/**\r\n * Outputs the pot file in json format based on the command line arguments --json option\r\n *\r\n * @param {Args} args - The command line arguments\r\n * @param {Record<string, string>} potHeader - The pot file header\r\n * @param {SetOfBlocks} translationsUnion - The translations union\r\n * @return {string} - The output pot file\r\n */\r\nexport function outputJson(\r\n\targs: Args,\r\n\tpotHeader: Record<string, string> | null,\r\n\ttranslationsUnion: SetOfBlocks,\r\n): string {\r\n\tconst jedData = {\r\n\t\t[args.slug]: {\r\n\t\t\t\"\": potHeader ?? {},\r\n\t\t\t...(translationsUnion.toJson() as{\r\n\t\t\t\t[key: string]: {\r\n\t\t\t\t\t[key: string]: GetTextTranslation;\r\n\t\t\t\t};\r\n\t\t\t}),\r\n\t\t},\r\n\t};\r\n\tconst i18n = new Tannin(jedData);\r\n\r\n\treturn i18n.toString();\r\n}\r\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,oBAAmB;AAYZ,SAAS,WACf,MACA,WACA,mBACS;AACT,QAAM,UAAU;AAAA,IACf,CAAC,KAAK,IAAI,GAAG;AAAA,MACZ,IAAI,aAAa,CAAC;AAAA,MAClB,GAAI,kBAAkB,OAAO;AAAA,IAK9B;AAAA,EACD;AACA,QAAM,OAAO,IAAI,cAAAA,QAAO,OAAO;AAE/B,SAAO,KAAK,SAAS;AACtB;",
6
- "names": ["Tannin"]
4
+ "sourcesContent": ["import type { SetOfBlocks } from \"gettext-merger\";\r\nimport type { Args, JedData, MakeJson } from \"../types.js\";\r\nimport type { GetTextTranslation } from 'gettext-parser'\r\n\r\n/**\r\n * Outputs the pot file in json format based on the command line arguments --json option\r\n *\r\n * @param {Args} args - The command line arguments\r\n * @param {Record<string, string>} potHeader - The pot file header\r\n * @param {SetOfBlocks} translationsUnion - The translations union\r\n * @return {string} - The output pot file\r\n */\r\nexport function outputJson(\r\n\targs: Args,\r\n\tpotHeader: Record<string, string> | null,\r\n\ttranslationsUnion: SetOfBlocks,\r\n): string {\r\n\tconst domain = args.slug;\r\n\tconst gettextTranslations = translationsUnion.toJson() as {\r\n\t\t[key: string]: {\r\n\t\t\t[key: string]: GetTextTranslation;\r\n\t\t};\r\n\t};\r\n\r\n\tconst jedData: JedData = {\r\n\t\t[domain]: {\r\n\t\t\t\"\": {\r\n\t\t\t\tdomain,\r\n\t\t\t\tlang: potHeader?.Language || \"en\",\r\n\t\t\t\tplural_forms:\r\n\t\t\t\t\tpotHeader?.[\"Plural-Forms\"] || \"nplurals=2; plural=(n != 1);\",\r\n\t\t\t\t...potHeader,\r\n\t\t\t},\r\n\t\t},\r\n\t};\r\n\r\n\t// Process all translations\r\n\tfor (const msgctxt of Object.keys(gettextTranslations)) {\r\n\t\tconst contextTranslations = gettextTranslations[msgctxt];\r\n\r\n\t\tfor (const msgid of Object.keys(contextTranslations)) {\r\n\t\t\tconst translation = contextTranslations[msgid];\r\n\r\n\t\t\t// Skip empty msgid (header) as we've already handled it\r\n\t\t\tif (msgid === \"\") continue;\r\n\r\n\t\t\t// Construct the key using context if available\r\n\t\t\tconst key =\r\n\t\t\t\tmsgctxt && msgctxt !== \"\" ? `${msgctxt}\\u0004${msgid}` : msgid;\r\n\r\n\t\t\t// Add the translation to the Jed data structure\r\n\t\t\tjedData[domain][key] = translation.msgstr;\r\n\t\t}\r\n\t}\r\n\r\n\tconst makeJson: MakeJson = {\r\n\t\tdomain,\r\n\t\t\"translation-revision-date\": new Date().toISOString(),\r\n\t\tgenerator: \"makePot\",\r\n\t\tsource: \"\",\r\n\t\tlocale_data: jedData,\r\n\t};\r\n\r\n\treturn JSON.stringify(makeJson, null, 2);\r\n}\r\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAYO,SAAS,WACf,MACA,WACA,mBACS;AACT,QAAM,SAAS,KAAK;AACpB,QAAM,sBAAsB,kBAAkB,OAAO;AAMrD,QAAM,UAAmB;AAAA,IACxB,CAAC,MAAM,GAAG;AAAA,MACT,IAAI;AAAA,QACH;AAAA,QACA,MAAM,WAAW,YAAY;AAAA,QAC7B,cACC,YAAY,cAAc,KAAK;AAAA,QAChC,GAAG;AAAA,MACJ;AAAA,IACD;AAAA,EACD;AAGA,aAAW,WAAW,OAAO,KAAK,mBAAmB,GAAG;AACvD,UAAM,sBAAsB,oBAAoB,OAAO;AAEvD,eAAW,SAAS,OAAO,KAAK,mBAAmB,GAAG;AACrD,YAAM,cAAc,oBAAoB,KAAK;AAG7C,UAAI,UAAU,GAAI;AAGlB,YAAM,MACL,WAAW,YAAY,KAAK,GAAG,OAAO,IAAS,KAAK,KAAK;AAG1D,cAAQ,MAAM,EAAE,GAAG,IAAI,YAAY;AAAA,IACpC;AAAA,EACD;AAEA,QAAM,WAAqB;AAAA,IAC1B;AAAA,IACA,8BAA6B,oBAAI,KAAK,GAAE,YAAY;AAAA,IACpD,WAAW;AAAA,IACX,QAAQ;AAAA,IACR,aAAa;AAAA,EACd;AAEA,SAAO,KAAK,UAAU,UAAU,MAAM,CAAC;AACxC;",
6
+ "names": []
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wp-blocks/make-pot",
3
- "version": "1.6.5",
3
+ "version": "1.6.6",
4
4
  "license": "GPL-3.0-or-later",
5
5
  "homepage": "https://wp-blocks.github.io/make-pot/",
6
6
  "description": "A Node.js script for generating a POT file from source code",
@@ -68,7 +68,6 @@
68
68
  "gettext-merger": "^1.2.1",
69
69
  "gettext-parser": "^4.2.0",
70
70
  "glob": "^11.1.0",
71
- "tannin": "^1.2.0",
72
71
  "tree-sitter": "^0.21.1",
73
72
  "tree-sitter-javascript": "^0.23.1",
74
73
  "tree-sitter-php": "^0.23.12",
@@ -0,0 +1,47 @@
1
+ const { describe, it } = require("node:test");
2
+ const assert = require("node:assert");
3
+ const { parsePHPFile } = require("../lib/extractors/php.js");
4
+
5
+ describe("parsePHPFile", () => {
6
+ it("correctly extracts headers from standard docblock (/** ... */)", () => {
7
+ const phpContent = `<?php
8
+ /**
9
+ * Plugin Name: My Plugin
10
+ * Description: A basic WordPress plugin template with translation support.
11
+ * Version: 1.0
12
+ * Author: Your Name
13
+ * Text Domain: my-plugin
14
+ * Domain Path: /languages
15
+ */`;
16
+ const result = parsePHPFile(phpContent);
17
+ assert.deepStrictEqual(result, {
18
+ name: "My Plugin",
19
+ description: "A basic WordPress plugin template with translation support.",
20
+ version: "1.0",
21
+ author: "Your Name",
22
+ textDomain: "my-plugin",
23
+ domainPath: "/languages",
24
+ });
25
+ });
26
+
27
+ it("correctly extracts headers from simple comment block (/* ... */)", () => {
28
+ const phpContent = `<?php
29
+ /*
30
+ Plugin Name: My Plugin
31
+ Description: A basic WordPress plugin template with translation support.
32
+ Version: 1.0
33
+ Author: Your Name
34
+ Text Domain: my-plugin
35
+ Domain Path: /languages
36
+ */`;
37
+ const result = parsePHPFile(phpContent);
38
+ assert.deepStrictEqual(result, {
39
+ name: "My Plugin",
40
+ description: "A basic WordPress plugin template with translation support.",
41
+ version: "1.0",
42
+ author: "Your Name",
43
+ textDomain: "my-plugin",
44
+ domainPath: "/languages",
45
+ });
46
+ });
47
+ });