@wp-blocks/make-pot 1.6.4 → 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 (55) 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/const.js.map +1 -1
  14. package/lib/extractors/auditStrings.js +177 -6
  15. package/lib/extractors/auditStrings.js.map +2 -2
  16. package/lib/extractors/css.js +69 -1
  17. package/lib/extractors/headers.js +253 -15
  18. package/lib/extractors/headers.js.map +2 -2
  19. package/lib/extractors/json.js +70 -1
  20. package/lib/extractors/packageJson.js +55 -1
  21. package/lib/extractors/php.js +79 -2
  22. package/lib/extractors/php.js.map +2 -2
  23. package/lib/extractors/schema.js +217 -3
  24. package/lib/extractors/text.js +41 -1
  25. package/lib/fs/fs.js +114 -2
  26. package/lib/fs/glob.js +103 -1
  27. package/lib/fs/glob.js.map +2 -2
  28. package/lib/index.js +64 -1
  29. package/lib/jsonCommand.js +51 -1
  30. package/lib/makeJson.js +28 -1
  31. package/lib/makePot.js +27 -1
  32. package/lib/parser/exec.js +94 -3
  33. package/lib/parser/exec.js.map +2 -2
  34. package/lib/parser/makeJson.js +393 -1
  35. package/lib/parser/makePot.js +48 -1
  36. package/lib/parser/patterns.js +54 -1
  37. package/lib/parser/process.js +85 -1
  38. package/lib/parser/process.js.map +2 -2
  39. package/lib/parser/progress.js +57 -1
  40. package/lib/parser/progress.js.map +2 -2
  41. package/lib/parser/taskRunner.js +65 -2
  42. package/lib/parser/taskRunner.js.map +2 -2
  43. package/lib/parser/tree.js +228 -2
  44. package/lib/parser/tree.js.map +2 -2
  45. package/lib/potCommand.js +36 -1
  46. package/lib/potCommand.js.map +2 -2
  47. package/lib/types.js +17 -1
  48. package/lib/types.js.map +1 -1
  49. package/lib/utils/common.js +161 -8
  50. package/lib/utils/common.js.map +2 -2
  51. package/lib/utils/extractors.js +69 -1
  52. package/lib/utils/output.js +59 -1
  53. package/lib/utils/output.js.map +3 -3
  54. package/package.json +3 -3
  55. package/tests/parse-php.test.js +47 -0
package/lib/index.js CHANGED
@@ -1 +1,64 @@
1
- "use strict";var F=Object.create;var a=Object.defineProperty;var J=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var l=Object.getPrototypeOf,u=Object.prototype.hasOwnProperty;var A=(o,r)=>{for(var e in r)a(o,e,{get:r[e],enumerable:!0})},k=(o,r,e,x)=>{if(r&&typeof r=="object"||typeof r=="function")for(let t of c(r))!u.call(o,t)&&t!==e&&a(o,t,{get:()=>r[t],enumerable:!(x=J(r,t))||x.enumerable});return o};var p=(o,r,e)=>(e=o!=null?F(l(o)):{},k(r||!o||!o.__esModule?a(e,"default",{value:o,enumerable:!0}):e,o)),C=o=>k(a({},"__esModule",{value:!0}),o);var M={};A(M,{MakeJsonCommand:()=>d.MakeJsonCommand,StringAuditor:()=>f.default,doTree:()=>g.doTree,extractMainFileData:()=>m.extractMainFileData,generateHeader:()=>m.generateHeader,getAuthorFromPackage:()=>m.getAuthorFromPackage,makeJson:()=>i.default,makePot:()=>n.default,makePotCommand:()=>s.makePot,parseJsonFile:()=>P.parseJsonFile});module.exports=C(M);var f=p(require("./extractors/auditStrings.js")),i=p(require("./jsonCommand.js")),n=p(require("./potCommand.js")),d=require("./parser/makeJson"),s=require("./parser/makePot.js"),g=require("./parser/tree.js"),P=require("./extractors/json.js"),m=require("./extractors/headers.js");0&&(module.exports={MakeJsonCommand,StringAuditor,doTree,extractMainFileData,generateHeader,getAuthorFromPackage,makeJson,makePot,makePotCommand,parseJsonFile});
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 index_exports = {};
30
+ __export(index_exports, {
31
+ MakeJsonCommand: () => import_makeJson.MakeJsonCommand,
32
+ StringAuditor: () => import_auditStrings.default,
33
+ doTree: () => import_tree.doTree,
34
+ extractMainFileData: () => import_headers.extractMainFileData,
35
+ generateHeader: () => import_headers.generateHeader,
36
+ getAuthorFromPackage: () => import_headers.getAuthorFromPackage,
37
+ makeJson: () => import_jsonCommand.default,
38
+ makePot: () => import_potCommand.default,
39
+ makePotCommand: () => import_makePot.makePot,
40
+ parseJsonFile: () => import_json.parseJsonFile
41
+ });
42
+ module.exports = __toCommonJS(index_exports);
43
+ var import_auditStrings = __toESM(require("./extractors/auditStrings.js"));
44
+ var import_jsonCommand = __toESM(require("./jsonCommand.js"));
45
+ var import_potCommand = __toESM(require("./potCommand.js"));
46
+ var import_makeJson = require("./parser/makeJson");
47
+ var import_makePot = require("./parser/makePot.js");
48
+ var import_tree = require("./parser/tree.js");
49
+ var import_json = require("./extractors/json.js");
50
+ var import_headers = require("./extractors/headers.js");
51
+ // Annotate the CommonJS export names for ESM import in node:
52
+ 0 && (module.exports = {
53
+ MakeJsonCommand,
54
+ StringAuditor,
55
+ doTree,
56
+ extractMainFileData,
57
+ generateHeader,
58
+ getAuthorFromPackage,
59
+ makeJson,
60
+ makePot,
61
+ makePotCommand,
62
+ parseJsonFile
63
+ });
64
+ //# sourceMappingURL=index.js.map
@@ -1 +1,51 @@
1
- "use strict";var p=Object.create;var m=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var k=Object.getOwnPropertyNames;var l=Object.getPrototypeOf,d=Object.prototype.hasOwnProperty;var J=(e,o)=>{for(var n in o)m(e,n,{get:o[n],enumerable:!0})},a=(e,o,n,t)=>{if(o&&typeof o=="object"||typeof o=="function")for(let r of k(o))!d.call(e,r)&&r!==n&&m(e,r,{get:()=>o[r],enumerable:!(t=f(o,r))||t.enumerable});return e};var M=(e,o,n)=>(n=e!=null?p(l(e)):{},a(o||!e||!e.__esModule?m(n,"default",{value:e,enumerable:!0}):n,e)),u=e=>a(m({},"__esModule",{value:!0}),e);var g={};J(g,{default:()=>c});module.exports=u(g);var i=M(require("./parser/makeJson.js")),s=require("./utils/common.js");function c(e){const o=new i.default(e);if(Object.keys(e).length>0){(0,s.printModuleInfo)();const n=new Date;o.exec().then(t=>{e.debug&&console.log(t),(0,s.printTimeElapsed)("Make-Json",n)}).catch(t=>{console.error(`\u{1FAE4} make-json - Error: ${t}`)})}}
1
+ "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 jsonCommand_exports = {};
30
+ __export(jsonCommand_exports, {
31
+ default: () => makeJsonCommand
32
+ });
33
+ module.exports = __toCommonJS(jsonCommand_exports);
34
+ var import_makeJson = __toESM(require("./parser/makeJson.js"));
35
+ var import_common = require("./utils/common.js");
36
+ function makeJsonCommand(args) {
37
+ const makeJson = new import_makeJson.default(args);
38
+ if (Object.keys(args).length > 0) {
39
+ (0, import_common.printModuleInfo)();
40
+ const timeStart = /* @__PURE__ */ new Date();
41
+ makeJson.exec().then((result) => {
42
+ if (args.debug) {
43
+ console.log(result);
44
+ }
45
+ (0, import_common.printTimeElapsed)("Make-Json", timeStart);
46
+ }).catch((error) => {
47
+ console.error(`\u{1FAE4} make-json - Error: ${error}`);
48
+ });
49
+ }
50
+ }
51
+ //# sourceMappingURL=jsonCommand.js.map
package/lib/makeJson.js CHANGED
@@ -1,2 +1,29 @@
1
1
  #!/usr/bin/env node
2
- "use strict";var i=Object.create;var e=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var p=Object.getPrototypeOf,J=Object.prototype.hasOwnProperty;var b=(o,r,n,m)=>{if(r&&typeof r=="object"||typeof r=="function")for(let s of f(r))!J.call(o,s)&&s!==n&&e(o,s,{get:()=>r[s],enumerable:!(m=a(r,s))||m.enumerable});return o};var c=(o,r,n)=>(n=o!=null?i(p(o)):{},b(r||!o||!o.__esModule?e(n,"default",{value:o,enumerable:!0}):n,o));var t=require("./cli/getJsonArgs.js"),g=c(require("./jsonCommand.js"));const d=(0,t.getJsonArgs)();(0,g.default)(d);
2
+ "use strict";
3
+ var __create = Object.create;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
18
+ // If the importer is in node compatibility mode or this is not an ESM
19
+ // file that has been converted to a CommonJS file using a Babel-
20
+ // compatible transform (i.e. "__esModule" has not been set), then set
21
+ // "default" to the CommonJS "module.exports" for node compatibility.
22
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
23
+ mod
24
+ ));
25
+ var import_getJsonArgs = require("./cli/getJsonArgs.js");
26
+ var import_jsonCommand = __toESM(require("./jsonCommand.js"));
27
+ const args = (0, import_getJsonArgs.getJsonArgs)();
28
+ (0, import_jsonCommand.default)(args);
29
+ //# sourceMappingURL=makeJson.js.map
package/lib/makePot.js CHANGED
@@ -1,2 +1,28 @@
1
1
  #!/usr/bin/env node
2
- "use strict";var i=Object.create;var e=Object.defineProperty;var n=Object.getOwnPropertyDescriptor;var a=Object.getOwnPropertyNames;var f=Object.getPrototypeOf,A=Object.prototype.hasOwnProperty;var d=(r,m,o,t)=>{if(m&&typeof m=="object"||typeof m=="function")for(let s of a(m))!A.call(r,s)&&s!==o&&e(r,s,{get:()=>m[s],enumerable:!(t=n(m,s))||t.enumerable});return r};var y=(r,m,o)=>(o=r!=null?i(f(r)):{},d(m||!r||!r.__esModule?e(o,"default",{value:r,enumerable:!0}):o,r));var p=require("./cli/getArgs.js"),g=y(require("./potCommand.js"));(0,g.default)((0,p.getArgs)());
2
+ "use strict";
3
+ var __create = Object.create;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
18
+ // If the importer is in node compatibility mode or this is not an ESM
19
+ // file that has been converted to a CommonJS file using a Babel-
20
+ // compatible transform (i.e. "__esModule" has not been set), then set
21
+ // "default" to the CommonJS "module.exports" for node compatibility.
22
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
23
+ mod
24
+ ));
25
+ var import_getArgs = require("./cli/getArgs.js");
26
+ var import_potCommand = __toESM(require("./potCommand.js"));
27
+ (0, import_potCommand.default)((0, import_getArgs.getArgs)());
28
+ //# sourceMappingURL=makePot.js.map
@@ -1,3 +1,94 @@
1
- "use strict";var w=Object.create;var s=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var S=Object.getOwnPropertyNames;var v=Object.getPrototypeOf,$=Object.prototype.hasOwnProperty;var k=(t,o)=>{for(var e in o)s(t,e,{get:o[e],enumerable:!0})},c=(t,o,e,n)=>{if(o&&typeof o=="object"||typeof o=="function")for(let i of S(o))!$.call(t,i)&&i!==e&&s(t,i,{get:()=>o[i],enumerable:!(n=x(o,i))||n.enumerable});return t};var A=(t,o,e)=>(e=t!=null?w(v(t)):{},c(o||!t||!t.__esModule?s(e,"default",{value:t,enumerable:!0}):e,t)),B=t=>c(s({},"__esModule",{value:!0}),t);var H={};k(H,{exec:()=>G});module.exports=B(H);var l=A(require("node:path")),f=require("gettext-parser"),h=require("../extractors/auditStrings.js"),p=require("../extractors/headers.js"),a=require("../fs/fs.js"),r=require("../utils/common.js"),u=require("../utils/output"),d=require("./patterns.js"),g=require("./process.js"),y=require("./progress.js"),T=require("./taskRunner.js");async function G(t){t.options?.silent||(console.log("\u{1F4DD} Starting makePot for",t?.slug),(0,r.printStats)());const o=await(0,p.generateHeader)(t);let e=(0,p.translationsHeaders)(t);t.options?.silent||(0,r.outputPathRecap)(l.default.resolve(t.paths.cwd),t.patterns);const n=(0,y.initProgress)(t,0);n.start(3,1,{filename:`Resolving files in ${l.default.resolve(t.paths.cwd)}`});const i=(0,d.getPatterns)(t),m=await(0,g.processFiles)(i,t,n);if(n.start(m.length,0,{filename:`Found ${m.length} files... `}),e=await(0,T.taskRunner)(m,e,t,n),t.options?.skip.audit||(console.log(`
2
- Audit strings...`),(0,h.audit)(t,e)),t.options?.json)return(0,u.outputJson)(t,o,e);const C={charset:(0,a.getEncodingCharset)(t.options?.charset),headers:o,translations:e.toJson()},P=f.po.compile(C).toString((0,a.getCharset)(t.options?.charset));return`${t.options?.fileComment||(0,r.getCopyright)(t.headers?.name||t.slug,t.headers?.license??"GPL v2 or later")}
3
- ${P}`}0&&(module.exports={exec});
1
+ "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 exec_exports = {};
30
+ __export(exec_exports, {
31
+ exec: () => exec
32
+ });
33
+ module.exports = __toCommonJS(exec_exports);
34
+ var import_node_path = __toESM(require("node:path"));
35
+ var import_gettext_parser = require("gettext-parser");
36
+ var import_auditStrings = require("../extractors/auditStrings.js");
37
+ var import_headers = require("../extractors/headers.js");
38
+ var import_fs = require("../fs/fs.js");
39
+ var import_common = require("../utils/common.js");
40
+ var import_output = require("../utils/output");
41
+ var import_patterns = require("./patterns.js");
42
+ var import_process = require("./process.js");
43
+ var import_progress = require("./progress.js");
44
+ var import_taskRunner = require("./taskRunner.js");
45
+ async function exec(args) {
46
+ if (!args.options?.silent) {
47
+ console.log("\u{1F4DD} Starting makePot for", args?.slug);
48
+ (0, import_common.printStats)();
49
+ }
50
+ const potHeader = await (0, import_headers.generateHeader)(args);
51
+ args.timeStart = /* @__PURE__ */ new Date();
52
+ let translationsUnion = (0, import_headers.translationsHeaders)(args);
53
+ if (!args.options?.silent)
54
+ (0, import_common.outputPathRecap)(import_node_path.default.resolve(args.paths.cwd), args.patterns);
55
+ const progressBar = (0, import_progress.initProgress)(args, 0);
56
+ progressBar.start(3, 1, {
57
+ filename: `Resolving files in ${import_node_path.default.resolve(args.paths.cwd)}`
58
+ });
59
+ const patterns = (0, import_patterns.getPatterns)(args);
60
+ const { tasks, processedCount, skippedCount } = await (0, import_process.processFiles)(patterns, args, progressBar);
61
+ progressBar.start(tasks.length, 0, {
62
+ filename: `Processing ${processedCount} files (${skippedCount} skipped)... `
63
+ });
64
+ translationsUnion = await (0, import_taskRunner.taskRunner)(
65
+ tasks,
66
+ translationsUnion,
67
+ args,
68
+ progressBar
69
+ );
70
+ if (!args.options?.skip.audit) {
71
+ console.log("\nAudit strings...");
72
+ (0, import_auditStrings.audit)(args, translationsUnion);
73
+ }
74
+ if (args.options?.json) {
75
+ return (0, import_output.outputJson)(args, potHeader, translationsUnion);
76
+ }
77
+ const getTextTranslations = {
78
+ charset: (0, import_fs.getEncodingCharset)(args.options?.charset),
79
+ headers: potHeader,
80
+ translations: translationsUnion.toJson()
81
+ };
82
+ const pluginTranslations = import_gettext_parser.po.compile(getTextTranslations).toString((0, import_fs.getCharset)(args.options?.charset));
83
+ const copyrightComment = args.options?.fileComment || (0, import_common.getCopyright)(
84
+ args.headers?.name || args.slug,
85
+ args.headers?.license ?? "GPL v2 or later"
86
+ );
87
+ return `${copyrightComment}
88
+ ${pluginTranslations}`;
89
+ }
90
+ // Annotate the CommonJS export names for ESM import in node:
91
+ 0 && (module.exports = {
92
+ exec
93
+ });
94
+ //# sourceMappingURL=exec.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/parser/exec.ts"],
4
- "sourcesContent": ["import path from \"node:path\";\nimport type { SingleBar } from \"cli-progress\";\nimport { type GetTextTranslations, po } from \"gettext-parser\";\nimport { audit } from \"../extractors/auditStrings.js\";\nimport { generateHeader, translationsHeaders } from \"../extractors/headers.js\";\nimport { getCharset, getEncodingCharset } from \"../fs/fs.js\";\nimport type { Args } from \"../types.js\";\nimport { getCopyright, outputPathRecap, printStats } from \"../utils/common.js\";\nimport { outputJson } from \"../utils/output\";\nimport { getPatterns } from \"./patterns.js\";\nimport { processFiles } from \"./process.js\";\nimport { initProgress } from \"./progress.js\";\nimport { taskRunner } from \"./taskRunner.js\";\n\n/**\n * Runs the parser and generates the pot file or the json file based on the command line arguments\n *\n * @param {Args} args - The command line arguments\n * @return {Promise<string>} - A promise that resolves with the generated pot file\n */\nexport async function exec(args: Args): Promise<string> {\n\tif (!args.options?.silent) {\n\t\tconsole.log(\"\uD83D\uDCDD Starting makePot for\", args?.slug);\n\t\tprintStats();\n\t}\n\n\t/** The pot file header contains the data about the plugin or theme */\n\tconst potHeader = await generateHeader(args);\n\n\t/** We need to find the main file data so that the definitions are extracted from the plugin or theme files */\n\tlet translationsUnion = translationsHeaders(args);\n\n\tif (!args.options?.silent)\n\t\toutputPathRecap(path.resolve(args.paths.cwd), args.patterns);\n\n\t/**\n\t * The progress bar that is used to show the progress of the extraction process.\n\t */\n\tconst progressBar: SingleBar = initProgress(args, 0);\n\tprogressBar.start(3, 1, {\n\t\tfilename: `Resolving files in ${path.resolve(args.paths.cwd)}`,\n\t});\n\n\t/**\n\t * Extract the strings from the files\n\t */\n\tconst patterns = getPatterns(args);\n\tconst files = await processFiles(patterns, args, progressBar);\n\n\tprogressBar.start(files.length, 0, {\n\t\tfilename: `Found ${files.length} files... `,\n\t});\n\n\ttranslationsUnion = await taskRunner(\n\t\tfiles,\n\t\ttranslationsUnion,\n\t\targs,\n\t\tprogressBar,\n\t);\n\n\t/**\n\t * Audit Strings: Strings are validated and reported to the user if they are not compliant.\n\t * --skip-audit flag turns this off\n\t **/\n\tif (!args.options?.skip.audit) {\n\t\tconsole.log(\"\\nAudit strings...\");\n\t\taudit(args, translationsUnion);\n\t}\n\n\t/** generate the JSON file based on the --json flag passed */\n\tif (args.options?.json) {\n\t\treturn outputJson(args, potHeader, translationsUnion);\n\t}\n\n\t/** Generate the pot file JSON */\n\tconst getTextTranslations: GetTextTranslations = {\n\t\tcharset: getEncodingCharset(args.options?.charset),\n\t\theaders: potHeader as { [headerName: string]: string },\n\t\ttranslations: translationsUnion.toJson(),\n\t};\n\n\t/** And then compile the pot file to a string */\n\tconst pluginTranslations = po\n\t\t.compile(getTextTranslations)\n\t\t.toString(getCharset(args.options?.charset));\n\n\t/** Return the pot file as a string, prefixed with the header */\n\tconst copyrightComment =\n\t\targs.options?.fileComment ||\n\t\tgetCopyright(\n\t\t\targs.headers?.name || args.slug,\n\t\t\t(args.headers?.license as string) ?? \"GPL v2 or later\",\n\t\t);\n\treturn `${copyrightComment}\\n${pluginTranslations}`;\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAAiB;AAEjB,4BAA6C;AAC7C,0BAAsB;AACtB,qBAAoD;AACpD,gBAA+C;AAE/C,oBAA0D;AAC1D,oBAA2B;AAC3B,sBAA4B;AAC5B,qBAA6B;AAC7B,sBAA6B;AAC7B,wBAA2B;AAQ3B,eAAsB,KAAK,MAA6B;AACvD,MAAI,CAAC,KAAK,SAAS,QAAQ;AAC1B,YAAQ,IAAI,kCAA2B,MAAM,IAAI;AACjD,kCAAW;AAAA,EACZ;AAGA,QAAM,YAAY,UAAM,+BAAe,IAAI;AAG3C,MAAI,wBAAoB,oCAAoB,IAAI;AAEhD,MAAI,CAAC,KAAK,SAAS;AAClB,uCAAgB,iBAAAA,QAAK,QAAQ,KAAK,MAAM,GAAG,GAAG,KAAK,QAAQ;AAK5D,QAAM,kBAAyB,8BAAa,MAAM,CAAC;AACnD,cAAY,MAAM,GAAG,GAAG;AAAA,IACvB,UAAU,sBAAsB,iBAAAA,QAAK,QAAQ,KAAK,MAAM,GAAG,CAAC;AAAA,EAC7D,CAAC;AAKD,QAAM,eAAW,6BAAY,IAAI;AACjC,QAAM,QAAQ,UAAM,6BAAa,UAAU,MAAM,WAAW;AAE5D,cAAY,MAAM,MAAM,QAAQ,GAAG;AAAA,IAClC,UAAU,SAAS,MAAM,MAAM;AAAA,EAChC,CAAC;AAED,sBAAoB,UAAM;AAAA,IACzB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD;AAMA,MAAI,CAAC,KAAK,SAAS,KAAK,OAAO;AAC9B,YAAQ,IAAI,oBAAoB;AAChC,mCAAM,MAAM,iBAAiB;AAAA,EAC9B;AAGA,MAAI,KAAK,SAAS,MAAM;AACvB,eAAO,0BAAW,MAAM,WAAW,iBAAiB;AAAA,EACrD;AAGA,QAAM,sBAA2C;AAAA,IAChD,aAAS,8BAAmB,KAAK,SAAS,OAAO;AAAA,IACjD,SAAS;AAAA,IACT,cAAc,kBAAkB,OAAO;AAAA,EACxC;AAGA,QAAM,qBAAqB,yBACzB,QAAQ,mBAAmB,EAC3B,aAAS,sBAAW,KAAK,SAAS,OAAO,CAAC;AAG5C,QAAM,mBACL,KAAK,SAAS,mBACd;AAAA,IACC,KAAK,SAAS,QAAQ,KAAK;AAAA,IAC1B,KAAK,SAAS,WAAsB;AAAA,EACtC;AACD,SAAO,GAAG,gBAAgB;AAAA,EAAK,kBAAkB;AAClD;",
4
+ "sourcesContent": ["import path from \"node:path\";\r\nimport type { SingleBar } from \"cli-progress\";\r\nimport { type GetTextTranslations, po } from \"gettext-parser\";\r\nimport { audit } from \"../extractors/auditStrings.js\";\r\nimport { generateHeader, translationsHeaders } from \"../extractors/headers.js\";\r\nimport { getCharset, getEncodingCharset } from \"../fs/fs.js\";\r\nimport type { Args } from \"../types.js\";\r\nimport { getCopyright, outputPathRecap, printStats } from \"../utils/common.js\";\r\nimport { outputJson } from \"../utils/output\";\r\nimport { getPatterns } from \"./patterns.js\";\r\nimport { processFiles } from \"./process.js\";\r\nimport { initProgress } from \"./progress.js\";\r\nimport { taskRunner } from \"./taskRunner.js\";\r\n\r\n/**\r\n * Runs the parser and generates the pot file or the json file based on the command line arguments\r\n *\r\n * @param {Args} args - The command line arguments\r\n * @return {Promise<string>} - A promise that resolves with the generated pot file\r\n */\r\nexport async function exec(args: Args): Promise<string> {\r\n\tif (!args.options?.silent) {\r\n\t\tconsole.log(\"\uD83D\uDCDD Starting makePot for\", args?.slug);\r\n\t\tprintStats();\r\n\t}\r\n\r\n\t/** The pot file header contains the data about the plugin or theme */\r\n\tconst potHeader = await generateHeader(args);\r\n\r\n\t/** Capture the start time */\r\n\targs.timeStart = new Date();\r\n\r\n\t/** We need to find the main file data so that the definitions are extracted from the plugin or theme files */\r\n\tlet translationsUnion = translationsHeaders(args);\r\n\r\n\tif (!args.options?.silent)\r\n\t\toutputPathRecap(path.resolve(args.paths.cwd), args.patterns);\r\n\r\n\t/**\r\n\t * The progress bar that is used to show the progress of the extraction process.\r\n\t */\r\n\tconst progressBar: SingleBar = initProgress(args, 0);\r\n\tprogressBar.start(3, 1, {\r\n\t\tfilename: `Resolving files in ${path.resolve(args.paths.cwd)}`,\r\n\t});\r\n\r\n\t/**\r\n\t * Extract the strings from the files\r\n\t */\r\n\tconst patterns = getPatterns(args);\r\n\tconst { tasks, processedCount, skippedCount } = await processFiles(patterns, args, progressBar);\r\n\r\n\tprogressBar.start(tasks.length, 0, {\r\n\t\tfilename: `Processing ${processedCount} files (${skippedCount} skipped)... `,\r\n\t});\r\n\r\n\ttranslationsUnion = await taskRunner(\r\n\t\ttasks,\r\n\t\ttranslationsUnion,\r\n\t\targs,\r\n\t\tprogressBar,\r\n\t);\r\n\r\n\t/**\r\n\t * Audit Strings: Strings are validated and reported to the user if they are not compliant.\r\n\t * --skip-audit flag turns this off\r\n\t **/\r\n\tif (!args.options?.skip.audit) {\r\n\t\tconsole.log(\"\\nAudit strings...\");\r\n\t\taudit(args, translationsUnion);\r\n\t}\r\n\r\n\t/** generate the JSON file based on the --json flag passed */\r\n\tif (args.options?.json) {\r\n\t\treturn outputJson(args, potHeader, translationsUnion);\r\n\t}\r\n\r\n\t/** Generate the pot file JSON */\r\n\tconst getTextTranslations: GetTextTranslations = {\r\n\t\tcharset: getEncodingCharset(args.options?.charset),\r\n\t\theaders: potHeader as { [headerName: string]: string },\r\n\t\ttranslations: translationsUnion.toJson(),\r\n\t};\r\n\r\n\t/** And then compile the pot file to a string */\r\n\tconst pluginTranslations = po\r\n\t\t.compile(getTextTranslations)\r\n\t\t.toString(getCharset(args.options?.charset));\r\n\r\n\t/** Return the pot file as a string, prefixed with the header */\r\n\tconst copyrightComment =\r\n\t\targs.options?.fileComment ||\r\n\t\tgetCopyright(\r\n\t\t\targs.headers?.name || args.slug,\r\n\t\t\t(args.headers?.license as string) ?? \"GPL v2 or later\",\r\n\t\t);\r\n\treturn `${copyrightComment}\\n${pluginTranslations}`;\r\n}\r\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAAiB;AAEjB,4BAA6C;AAC7C,0BAAsB;AACtB,qBAAoD;AACpD,gBAA+C;AAE/C,oBAA0D;AAC1D,oBAA2B;AAC3B,sBAA4B;AAC5B,qBAA6B;AAC7B,sBAA6B;AAC7B,wBAA2B;AAQ3B,eAAsB,KAAK,MAA6B;AACvD,MAAI,CAAC,KAAK,SAAS,QAAQ;AAC1B,YAAQ,IAAI,kCAA2B,MAAM,IAAI;AACjD,kCAAW;AAAA,EACZ;AAGA,QAAM,YAAY,UAAM,+BAAe,IAAI;AAG3C,OAAK,YAAY,oBAAI,KAAK;AAG1B,MAAI,wBAAoB,oCAAoB,IAAI;AAEhD,MAAI,CAAC,KAAK,SAAS;AAClB,uCAAgB,iBAAAA,QAAK,QAAQ,KAAK,MAAM,GAAG,GAAG,KAAK,QAAQ;AAK5D,QAAM,kBAAyB,8BAAa,MAAM,CAAC;AACnD,cAAY,MAAM,GAAG,GAAG;AAAA,IACvB,UAAU,sBAAsB,iBAAAA,QAAK,QAAQ,KAAK,MAAM,GAAG,CAAC;AAAA,EAC7D,CAAC;AAKD,QAAM,eAAW,6BAAY,IAAI;AACjC,QAAM,EAAE,OAAO,gBAAgB,aAAa,IAAI,UAAM,6BAAa,UAAU,MAAM,WAAW;AAE9F,cAAY,MAAM,MAAM,QAAQ,GAAG;AAAA,IAClC,UAAU,cAAc,cAAc,WAAW,YAAY;AAAA,EAC9D,CAAC;AAED,sBAAoB,UAAM;AAAA,IACzB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD;AAMA,MAAI,CAAC,KAAK,SAAS,KAAK,OAAO;AAC9B,YAAQ,IAAI,oBAAoB;AAChC,mCAAM,MAAM,iBAAiB;AAAA,EAC9B;AAGA,MAAI,KAAK,SAAS,MAAM;AACvB,eAAO,0BAAW,MAAM,WAAW,iBAAiB;AAAA,EACrD;AAGA,QAAM,sBAA2C;AAAA,IAChD,aAAS,8BAAmB,KAAK,SAAS,OAAO;AAAA,IACjD,SAAS;AAAA,IACT,cAAc,kBAAkB,OAAO;AAAA,EACxC;AAGA,QAAM,qBAAqB,yBACzB,QAAQ,mBAAmB,EAC3B,aAAS,sBAAW,KAAK,SAAS,OAAO,CAAC;AAG5C,QAAM,mBACL,KAAK,SAAS,mBACd;AAAA,IACC,KAAK,SAAS,QAAQ,KAAK;AAAA,IAC1B,KAAK,SAAS,WAAsB;AAAA,EACtC;AACD,SAAO,GAAG,gBAAgB;AAAA,EAAK,kBAAkB;AAClD;",
6
6
  "names": ["path"]
7
7
  }