@wp-blocks/make-pot 0.0.8 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/CODE_OF_CONDUCT.md +45 -0
  2. package/CONTRIBUTING.md +92 -0
  3. package/README.md +34 -2
  4. package/lib/assets/block-i18n.json +17 -0
  5. package/lib/assets/theme-i18n.json +86 -0
  6. package/lib/cliArgs.js +7 -6
  7. package/lib/cliArgs.js.map +1 -1
  8. package/lib/const.js +2 -2
  9. package/lib/const.js.map +1 -1
  10. package/lib/extractors/css.d.ts +2 -0
  11. package/lib/extractors/css.js +31 -0
  12. package/lib/extractors/css.js.map +1 -0
  13. package/lib/extractors/headers.d.ts +8 -0
  14. package/lib/extractors/headers.js +57 -0
  15. package/lib/extractors/headers.js.map +1 -0
  16. package/lib/extractors/index.d.ts +3 -0
  17. package/lib/{extractors.js → extractors/index.js} +30 -72
  18. package/lib/extractors/index.js.map +1 -0
  19. package/lib/extractors/json.d.ts +7 -0
  20. package/lib/extractors/json.js +38 -0
  21. package/lib/extractors/json.js.map +1 -0
  22. package/lib/extractors/php.d.ts +3 -0
  23. package/lib/extractors/php.js +56 -0
  24. package/lib/extractors/php.js.map +1 -0
  25. package/lib/extractors/schema.d.ts +13 -0
  26. package/lib/extractors/schema.js +117 -0
  27. package/lib/extractors/schema.js.map +1 -0
  28. package/lib/extractors/text.d.ts +1 -0
  29. package/lib/{extractors-text.js → extractors/text.js} +6 -5
  30. package/lib/extractors/text.js.map +1 -0
  31. package/lib/extractors/utils.d.ts +5 -0
  32. package/lib/extractors/utils.js +45 -0
  33. package/lib/extractors/utils.js.map +1 -0
  34. package/lib/fs.js.map +1 -1
  35. package/lib/index.js +2 -0
  36. package/lib/index.js.map +1 -1
  37. package/lib/makePot.js +31 -27
  38. package/lib/makePot.js.map +1 -1
  39. package/lib/maps.d.ts +124 -0
  40. package/lib/maps.js +64 -0
  41. package/lib/maps.js.map +1 -0
  42. package/lib/parser.js +1 -1
  43. package/lib/parser.js.map +1 -1
  44. package/lib/tree.js +6 -6
  45. package/lib/tree.js.map +1 -1
  46. package/lib/types.d.ts +7 -5
  47. package/lib/utils.d.ts +2 -2
  48. package/lib/utils.js +15 -12
  49. package/lib/utils.js.map +1 -1
  50. package/package.json +19 -10
  51. package/tests/extract-2.test.ts +10 -3
  52. package/tests/{jsonParse.test.ts → jsonParse.ts} +9 -8
  53. package/lib/extractors-json.d.ts +0 -9
  54. package/lib/extractors-json.js +0 -53
  55. package/lib/extractors-json.js.map +0 -1
  56. package/lib/extractors-maps.d.ts +0 -109
  57. package/lib/extractors-maps.js +0 -139
  58. package/lib/extractors-maps.js.map +0 -1
  59. package/lib/extractors-php.d.ts +0 -1
  60. package/lib/extractors-php.js +0 -25
  61. package/lib/extractors-php.js.map +0 -1
  62. package/lib/extractors-text.d.ts +0 -1
  63. package/lib/extractors-text.js.map +0 -1
  64. package/lib/extractors.d.ts +0 -17
  65. package/lib/extractors.js.map +0 -1
  66. package/tests/index.html +0 -78
  67. /package/tests/{extract.test.ts → extract.old.ts} +0 -0
  68. /package/tests/{getFiles.test.ts → getFiles.old.ts} +0 -0
  69. /package/tests/{getStrings.test.ts → getStrings.old.ts} +0 -0
  70. /package/tests/{ingnoreFunction.test.ts → ingnoreFunction.old.ts} +0 -0
  71. /package/tests/{makePot.ts → makePot.old.ts} +0 -0
  72. /package/tests/{treeJs.test.ts → treeJs.old.ts} +0 -0
  73. /package/tests/{treePhp.test.ts → treePhp.old.ts} +0 -0
  74. /package/tests/{treeTs.test.ts → treeTs.old.ts} +0 -0
  75. /package/tests/{utils.test.ts → utils.old.ts} +0 -0
@@ -0,0 +1,45 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to make participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ ## Our Standards
8
+
9
+ Examples of behavior that contributes to creating a positive environment include:
10
+
11
+ * Using welcoming and inclusive language
12
+ * Being respectful of differing viewpoints and experiences
13
+ * Gracefully accepting constructive criticism
14
+ * Focusing on what is best for the community
15
+ * Showing empathy towards other community members
16
+
17
+ Examples of unacceptable behavior by participants include:
18
+
19
+ * The use of sexualized language or imagery and unwelcome sexual attention or advances
20
+ * Trolling, insulting/derogatory comments, and personal or political attacks
21
+ * Public or private harassment
22
+ * Publishing others' private information, such as a physical or electronic address, without explicit permission
23
+ * Other conduct which could reasonably be considered inappropriate in a professional setting
24
+
25
+ ## Our Responsibilities
26
+
27
+ Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
28
+
29
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
30
+
31
+ ## Scope
32
+
33
+ This Code of Conduct applies within all project spaces, and it also applies when an individual is representing the project or its community in public spaces. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
34
+
35
+ ## Enforcement
36
+
37
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project maintainer using any of the [private contact addresses](https://github.com/dec0dOS/amazing-github-template#support). All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
38
+
39
+ Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
40
+
41
+ ## Attribution
42
+
43
+ This Code of Conduct is adapted from the [Contributor Covenant](https://www.contributor-covenant.org), version 1.4, available at <https://www.contributor-covenant.org/version/1/4/code-of-conduct.html>
44
+
45
+ For answers to common questions about this code of conduct, see <https://www.contributor-covenant.org/faq>
@@ -0,0 +1,92 @@
1
+ # Contributing
2
+
3
+ When contributing to this repository, please first discuss the change you wish to make via issue,
4
+ email, or any other method with the owners of this repository before making a change.
5
+
6
+ Please note we have a code of conduct, please follow it in all your interactions with the project.
7
+
8
+ ## Pull Request Process
9
+
10
+ 1. Ensure any install or build dependencies are removed before the end of the layer when doing a
11
+ build.
12
+ 2. Update the README.md with details of changes to the interface, this includes new environment
13
+ variables, exposed ports, useful file locations and container parameters.
14
+ 3. Increase the version numbers in any examples files and the README.md to the new version that this
15
+ Pull Request would represent. The versioning scheme we use is [SemVer](http://semver.org/).
16
+ 4. You may merge the Pull Request in once you have the sign-off of two other developers, or if you
17
+ do not have permission to do that, you may request the second reviewer to merge it for you.
18
+
19
+ ## Code of Conduct
20
+
21
+ ### Our Pledge
22
+
23
+ In the interest of fostering an open and welcoming environment, we as
24
+ contributors and maintainers pledge to making participation in our project and
25
+ our community a harassment-free experience for everyone, regardless of age, body
26
+ size, disability, ethnicity, gender identity and expression, level of experience,
27
+ nationality, personal appearance, race, religion, or sexual identity and
28
+ orientation.
29
+
30
+ ### Our Standards
31
+
32
+ Examples of behavior that contributes to creating a positive environment
33
+ include:
34
+
35
+ * Using welcoming and inclusive language
36
+ * Being respectful of differing viewpoints and experiences
37
+ * Gracefully accepting constructive criticism
38
+ * Focusing on what is best for the community
39
+ * Showing empathy towards other community members
40
+
41
+ Examples of unacceptable behavior by participants include:
42
+
43
+ * The use of sexualized language or imagery and unwelcome sexual attention or
44
+ advances
45
+ * Trolling, insulting/derogatory comments, and personal or political attacks
46
+ * Public or private harassment
47
+ * Publishing others' private information, such as a physical or electronic
48
+ address, without explicit permission
49
+ * Other conduct which could reasonably be considered inappropriate in a
50
+ professional setting
51
+
52
+ ### Our Responsibilities
53
+
54
+ Project maintainers are responsible for clarifying the standards of acceptable
55
+ behavior and are expected to take appropriate and fair corrective action in
56
+ response to any instances of unacceptable behavior.
57
+
58
+ Project maintainers have the right and responsibility to remove, edit, or
59
+ reject comments, commits, code, wiki edits, issues, and other contributions
60
+ that are not aligned to this Code of Conduct, or to ban temporarily or
61
+ permanently any contributor for other behaviors that they deem inappropriate,
62
+ threatening, offensive, or harmful.
63
+
64
+ ### Scope
65
+
66
+ This Code of Conduct applies both within project spaces and in public spaces
67
+ when an individual is representing the project or its community. Examples of
68
+ representing a project or community include using an official project e-mail
69
+ address, posting via an official social media account, or acting as an appointed
70
+ representative at an online or offline event. Representation of a project may be
71
+ further defined and clarified by project maintainers.
72
+
73
+ ### Enforcement
74
+
75
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
76
+ reported by contacting the project team. All
77
+ complaints will be reviewed and investigated and will result in a response that
78
+ is deemed necessary and appropriate to the circumstances. The project team is
79
+ obligated to maintain confidentiality with regard to the reporter of an incident.
80
+ Further details of specific enforcement policies may be posted separately.
81
+
82
+ Project maintainers who do not follow or enforce the Code of Conduct in good
83
+ faith may face temporary or permanent repercussions as determined by other
84
+ members of the project's leadership.
85
+
86
+ ### Attribution
87
+
88
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
89
+ available at [http://contributor-covenant.org/version/1/4][version]
90
+
91
+ [homepage]: http://contributor-covenant.org
92
+ [version]: http://contributor-covenant.org/version/1/4/
package/README.md CHANGED
@@ -1,7 +1,39 @@
1
1
  # make-pot
2
2
 
3
- wip
3
+ A node.js module that generates the pot file for your WordPress plugin or theme.
4
4
 
5
5
  ```
6
- npx @wp-blocks/make-pot -h
6
+ npx @wp-blocks/make-pot -h
7
+ Usage: index.js <source> [destination] [options]
8
+
9
+ Positionals:
10
+ sourceDirectory Source directory [string]
11
+ destination Destination directory [string]
12
+
13
+ Options:
14
+ --version Show version number [boolean]
15
+ -h Show help [boolean]
16
+ --slug Plugin or theme slug [string]
17
+ --domain Text domain to look for in the source code [string]
18
+ --skip-js Skip JavaScript files [boolean]
19
+ --skip-php Skip PHP files [boolean]
20
+ --skip-blade Skip Blade files [boolean]
21
+ --skip-block-json Skip block.json files [boolean]
22
+ --skip-theme-json Skip theme.json files [boolean]
23
+ --skip-audit Skip auditing of strings [boolean]
24
+ --headers Headers [string]
25
+ --file-comment File comment [string]
26
+ --package-name Package name [string]
27
+ --location Include location information [boolean]
28
+ --ignore-domain Ignore text domain [boolean]
29
+ --mergePaths Merge with existing POT file(s) [string]
30
+ --subtractPaths Subtract strings from existing POT file(s) [string]
31
+ --subtractAndMerge Subtract and merge strings from existing POT file(s)
32
+ [boolean]
33
+ --include Include specific files [string]
34
+ --exclude Exclude specific files [string]
35
+ --silent No output to stdout [boolean]
36
+ --json Output the json gettext data [boolean]
37
+ --output Output the gettext data [boolean]
7
38
  ```
39
+
@@ -0,0 +1,17 @@
1
+ {
2
+ "title": "block title",
3
+ "description": "block description",
4
+ "keywords": ["block keyword"],
5
+ "styles": [
6
+ {
7
+ "label": "block style label"
8
+ }
9
+ ],
10
+ "variations": [
11
+ {
12
+ "title": "block variation title",
13
+ "description": "block variation description",
14
+ "keywords": ["block variation keyword"]
15
+ }
16
+ ]
17
+ }
@@ -0,0 +1,86 @@
1
+ {
2
+ "title": "Style variation name",
3
+ "settings": {
4
+ "typography": {
5
+ "fontSizes": [
6
+ {
7
+ "name": "Font size name"
8
+ }
9
+ ],
10
+ "fontFamilies": [
11
+ {
12
+ "name": "Font family name"
13
+ }
14
+ ]
15
+ },
16
+ "color": {
17
+ "palette": [
18
+ {
19
+ "name": "Color name"
20
+ }
21
+ ],
22
+ "gradients": [
23
+ {
24
+ "name": "Gradient name"
25
+ }
26
+ ],
27
+ "duotone": [
28
+ {
29
+ "name": "Duotone name"
30
+ }
31
+ ]
32
+ },
33
+ "spacing": {
34
+ "spacingSizes": [
35
+ {
36
+ "name": "Space size name"
37
+ }
38
+ ]
39
+ },
40
+ "blocks": {
41
+ "*": {
42
+ "typography": {
43
+ "fontSizes": [
44
+ {
45
+ "name": "Font size name"
46
+ }
47
+ ],
48
+ "fontFamilies": [
49
+ {
50
+ "name": "Font family name"
51
+ }
52
+ ]
53
+ },
54
+ "color": {
55
+ "palette": [
56
+ {
57
+ "name": "Color name"
58
+ }
59
+ ],
60
+ "gradients": [
61
+ {
62
+ "name": "Gradient name"
63
+ }
64
+ ]
65
+ },
66
+ "spacing": {
67
+ "spacingSizes": [
68
+ {
69
+ "name": "Space size name"
70
+ }
71
+ ]
72
+ }
73
+ }
74
+ }
75
+ },
76
+ "customTemplates": [
77
+ {
78
+ "title": "Custom template name"
79
+ }
80
+ ],
81
+ "templateParts": [
82
+ {
83
+ "title": "Template part name"
84
+ }
85
+ ]
86
+ }
package/lib/cliArgs.js CHANGED
@@ -140,15 +140,16 @@ function parseCliArgs(args) {
140
140
  var _a, _b, _c, _d, _e, _f, _g;
141
141
  const inputPath = typeof args._[0] === 'string' ? args._[0] : '.';
142
142
  const outputPath = typeof args._[1] === 'string' ? args._[1] : '.';
143
+ const currentWorkingDirectory = process.cwd();
144
+ const cwd = path.relative(currentWorkingDirectory, inputPath);
145
+ const out = path.relative(currentWorkingDirectory, outputPath);
146
+ const domain = (_a = args === null || args === void 0 ? void 0 : args.domain) !== null && _a !== void 0 ? _a : 'generic';
143
147
  const parsedArgs = {
144
148
  slug: args.slug && typeof args.slug === 'string'
145
149
  ? args.slug
146
- : path.basename(process.cwd()),
147
- domain: (_a = args === null || args === void 0 ? void 0 : args.domain) !== null && _a !== void 0 ? _a : 'generic',
148
- paths: {
149
- cwd: path.relative(process.cwd(), inputPath),
150
- out: path.relative(process.cwd(), outputPath),
151
- },
150
+ : path.basename(path.resolve(currentWorkingDirectory, inputPath)),
151
+ domain: domain,
152
+ paths: { cwd: cwd, out: out },
152
153
  options: {
153
154
  ignoreDomain: !!(args === null || args === void 0 ? void 0 : args.ignoreDomain),
154
155
  packageName: String((_b = args.packageName) !== null && _b !== void 0 ? _b : ''),
@@ -1 +1 @@
1
- {"version":3,"file":"cliArgs.js","sourceRoot":"","sources":["../src/cliArgs.ts"],"names":[],"mappings":";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MAAC,IAAI,CAAC,WAAsB,mCAAI,EAAE;SAC/C;QAED,QAAQ,EAAE;YACT,UAAU,EAAE,MAAA,IAAA,oBAAY,EAAC,IAAI,CAAC,UAAoB,CAAC,mCAAI,EAAE;YACzD,aAAa,EAAE,MAAA,IAAA,oBAAY,EAAC,IAAI,CAAC,aAAuB,CAAC,mCAAI,EAAE;YAC/D,gBAAgB,EAAE,CAAC,CAAC,IAAI,CAAC,gBAAgB;YACzC,OAAO,EAAE,MAAA,IAAA,oBAAY,EAAC,IAAI,CAAC,OAAiB,CAAC,mCAAI,CAAC,IAAI,CAAC;YACvD,OAAO,EACN,MAAA,IAAA,oBAAY,EAAC,IAAI,CAAC,OAAiB,CAAC,mCAAI,6BAAqB;SAC9D;KACD,CAAA;IAED,UAAU,CAAC,KAAK,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAA;IAEjE,OAAO,UAAU,CAAA;AAClB,CAAC;AAzDD,oCAyDC"}
package/lib/const.js CHANGED
@@ -38,8 +38,8 @@ exports.i18nFunctions = {
38
38
  esc_attr_e: ['msgid', 'text_domain'],
39
39
  esc_html_e: ['msgid', 'text_domain'],
40
40
  esc_xml_e: ['msgid', 'text_domain'],
41
- _x: ['text', 'msgctxt', 'text_domain'],
42
- _ex: ['text', 'msgctxt', 'text_domain'],
41
+ _x: ['msgid', 'msgctxt', 'text_domain'],
42
+ _ex: ['msgid', 'msgctxt', 'text_domain'],
43
43
  esc_attr_x: ['msgid', 'msgctxt', 'text_domain'],
44
44
  esc_html_x: ['msgid', 'msgctxt', 'text_domain'],
45
45
  esc_xml_x: ['msgid', 'msgctxt', 'text_domain'],
package/lib/const.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"const.js","sourceRoot":"","sources":["../src/const.ts"],"names":[],"mappings":";;;AAIa,QAAA,qBAAqB,GAAG;IACpC,MAAM;IACN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AAE,EAAE,CAAC,OAAO,EAAE,SAAS,EAAE,aAAa,CAAC;IACvC,GAAG,EAAE,CAAC,OAAO,EAAE,SAAS,EAAE,aAAa,CAAC;IACxC,UAAU,EAAE,CAAC,OAAO,EAAE,SAAS,EAAE,aAAa,CAAC;IAC/C,UAAU,EAAE,CAAC,OAAO,EAAE,SAAS,EAAE,aAAa,CAAC;IAC/C,SAAS,EAAE,CAAC,OAAO,EAAE,SAAS,EAAE,aAAa,CAAC;IAC9C,EAAE,EAAE,CAAC,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,aAAa,CAAC;IACtD,GAAG,EAAE,CAAC,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,SAAS,EAAE,aAAa,CAAC;IAClE,OAAO,EAAE,CAAC,OAAO,EAAE,cAAc,EAAE,aAAa,CAAC;IACjD,QAAQ,EAAE,CAAC,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,aAAa,CAAC;IAG7D,CAAC,EAAE,CAAC,OAAO,EAAE,aAAa,CAAC;IAG3B,EAAE,EAAE,CAAC,OAAO,EAAE,aAAa,CAAC;IAC5B,GAAG,EAAE,CAAC,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,aAAa,CAAC;IACvD,UAAU,EAAE,CAAC,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,aAAa,CAAC;IAC9D,eAAe,EAAE,CAAC,OAAO,EAAE,cAAc,EAAE,aAAa,CAAC;CACzD,CAAA"}
@@ -0,0 +1,2 @@
1
+ import type { Args } from '../types';
2
+ export declare function extractCssThemeData(args: Args): Record<string, string>;
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.extractCssThemeData = void 0;
7
+ const path_1 = __importDefault(require("path"));
8
+ const fs_1 = __importDefault(require("fs"));
9
+ const utils_1 = require("../utils");
10
+ const text_1 = require("./text");
11
+ function extractCssThemeData(args) {
12
+ let fileData = {};
13
+ const styleCssFile = path_1.default.join(args.paths.cwd, 'style.css');
14
+ if (fs_1.default.existsSync(styleCssFile)) {
15
+ const fileContent = fs_1.default.readFileSync(styleCssFile, 'utf8');
16
+ const commentBlock = (0, utils_1.getCommentBlock)(fileContent);
17
+ fileData = (0, text_1.extractFileData)(commentBlock);
18
+ if ('Name' in fileData) {
19
+ console.log('Theme stylesheet detected.');
20
+ console.log(`Theme stylesheet: ${styleCssFile}`);
21
+ args.domain = 'theme';
22
+ return fileData;
23
+ }
24
+ }
25
+ else {
26
+ console.log(`Theme stylesheet not found in ${styleCssFile}`);
27
+ }
28
+ return {};
29
+ }
30
+ exports.extractCssThemeData = extractCssThemeData;
31
+ //# sourceMappingURL=css.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"css.js","sourceRoot":"","sources":["../../src/extractors/css.ts"],"names":[],"mappings":";;;;;;AACA,gDAAuB;AACvB,4CAAmB;AACnB,oCAA0C;AAC1C,iCAAwC;AAMxC,SAAgB,mBAAmB,CAAC,IAAU;IAC7C,IAAI,QAAQ,GAA2B,EAAE,CAAA;IACzC,MAAM,YAAY,GAAG,cAAI,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,WAAW,CAAC,CAAA;IAE3D,IAAI,YAAE,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE,CAAC;QACjC,MAAM,WAAW,GAAG,YAAE,CAAC,YAAY,CAAC,YAAY,EAAE,MAAM,CAAC,CAAA;QACzD,MAAM,YAAY,GAAG,IAAA,uBAAe,EAAC,WAAW,CAAC,CAAA;QACjD,QAAQ,GAAG,IAAA,sBAAe,EAAC,YAAY,CAAC,CAAA;QAExC,IAAI,MAAM,IAAI,QAAQ,EAAE,CAAC;YACxB,OAAO,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAA;YACzC,OAAO,CAAC,GAAG,CAAC,qBAAqB,YAAY,EAAE,CAAC,CAAA;YAChD,IAAI,CAAC,MAAM,GAAG,OAAO,CAAA;YAErB,OAAO,QAAQ,CAAA;QAChB,CAAC;IACF,CAAC;SAAM,CAAC;QACP,OAAO,CAAC,GAAG,CAAC,iCAAiC,YAAY,EAAE,CAAC,CAAA;IAC7D,CAAC;IACD,OAAO,EAAE,CAAA;AACV,CAAC;AApBD,kDAoBC"}
@@ -0,0 +1,8 @@
1
+ import { Args } from '../types';
2
+ export declare function generateHeader(args: Args): Record<string, string>;
3
+ export declare function extractMainFileData(args: Args): Record<string, string>;
4
+ export declare function translationsHeaders(args: Args): {
5
+ name: import("gettext-parser").GetTextTranslation;
6
+ description: import("gettext-parser").GetTextTranslation;
7
+ author: import("gettext-parser").GetTextTranslation;
8
+ };
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.translationsHeaders = exports.extractMainFileData = exports.generateHeader = void 0;
4
+ const php_1 = require("./php");
5
+ const css_1 = require("./css");
6
+ const utils_1 = require("./utils");
7
+ const maps_1 = require("../maps");
8
+ function generateHeader(args) {
9
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
10
+ const headerData = Object.assign(Object.assign({}, args.headers), { author: ((_a = args.headers) === null || _a === void 0 ? void 0 : _a.author) || 'AUTHOR', slug: ((_b = args.headers) === null || _b === void 0 ? void 0 : _b.slug) || 'PLUGIN NAME', email: ((_c = args.headers) === null || _c === void 0 ? void 0 : _c.email) || 'EMAIL', license: ((_d = args.headers) === null || _d === void 0 ? void 0 : _d.license) || 'gpl-2.0 or later', version: ((_e = args.headers) === null || _e === void 0 ? void 0 : _e.version) || 'VERSION', language: ((_f = args.headers) === null || _f === void 0 ? void 0 : _f.language) || 'LANGUAGE', domain: ((_g = args.headers) === null || _g === void 0 ? void 0 : _g.domain) || ((_h = args.headers) === null || _h === void 0 ? void 0 : _h.slug) || undefined, bugs: {
11
+ url: ((_j = args.headers) === null || _j === void 0 ? void 0 : _j.bugs) ||
12
+ 'https://wordpress.org/support/plugin/' + args.slug,
13
+ email: ((_k = args.headers) === null || _k === void 0 ? void 0 : _k.authoremail) || 'AUTHOR EMAIL',
14
+ } });
15
+ return {
16
+ 'Project-Id-Version': `${headerData.slug} ${headerData.version}`,
17
+ 'Report-Msgid-Bugs-To': `${headerData.bugs.email} ${headerData.bugs.url}`,
18
+ 'MIME-Version': `1.0`,
19
+ 'Content-Transfer-Encoding': `8bit`,
20
+ 'content-type': 'text/plain; charset=iso-8859-1',
21
+ 'plural-forms': 'nplurals=2; plural=(n!=1);',
22
+ 'POT-Creation-Date': `${new Date().toISOString()}`,
23
+ 'PO-Revision-Date': `${new Date().getFullYear()}-MO-DA HO:MI+ZONE`,
24
+ 'Last-Translator': `${headerData.author} <${headerData.email}>`,
25
+ 'Language-Team': `${headerData.author} <${headerData.email}>`,
26
+ 'X-Generator': `${maps_1.pkgJson.name} ${maps_1.pkgJson.version}`,
27
+ Language: `${headerData.language}`,
28
+ 'X-Domain': headerData.domain ? `${headerData.domain}` : '',
29
+ };
30
+ }
31
+ exports.generateHeader = generateHeader;
32
+ function extractMainFileData(args) {
33
+ let extractedData = {};
34
+ if (['plugin', 'block', 'generic'].includes(args.domain)) {
35
+ extractedData = (0, php_1.extractPhpPluginData)(args);
36
+ }
37
+ else if (['theme', 'theme-block'].includes(args.domain)) {
38
+ extractedData = (0, css_1.extractCssThemeData)(args);
39
+ }
40
+ else {
41
+ console.log('No main file detected.');
42
+ }
43
+ return extractedData;
44
+ }
45
+ exports.extractMainFileData = extractMainFileData;
46
+ function translationsHeaders(args) {
47
+ const { domain, headers } = args;
48
+ const { name, description, author } = headers;
49
+ const fakePath = domain === 'plugin' ? args.slug + '.php' : 'style.css';
50
+ return {
51
+ name: (0, utils_1.gentranslation)('Name of the ' + domain, name, fakePath),
52
+ description: (0, utils_1.gentranslation)('Description of the ' + domain, description, fakePath),
53
+ author: (0, utils_1.gentranslation)('Author of the ' + domain, author, fakePath),
54
+ };
55
+ }
56
+ exports.translationsHeaders = translationsHeaders;
57
+ //# sourceMappingURL=headers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"headers.js","sourceRoot":"","sources":["../../src/extractors/headers.ts"],"names":[],"mappings":";;;AACA,+BAA4C;AAC5C,+BAA2C;AAC3C,mCAAwC;AACxC,kCAAiC;AAiBjC,SAAgB,cAAc,CAAC,IAAU;;IAExC,MAAM,UAAU,GAAG,gCACf,IAAI,CAAC,OAAO,KACf,MAAM,EAAE,CAAA,MAAA,IAAI,CAAC,OAAO,0CAAE,MAAM,KAAI,QAAQ,EACxC,IAAI,EAAE,CAAA,MAAA,IAAI,CAAC,OAAO,0CAAE,IAAI,KAAI,aAAa,EACzC,KAAK,EAAE,CAAA,MAAA,IAAI,CAAC,OAAO,0CAAE,KAAK,KAAI,OAAO,EACrC,OAAO,EAAE,CAAA,MAAA,IAAI,CAAC,OAAO,0CAAE,OAAO,KAAI,kBAAkB,EACpD,OAAO,EAAE,CAAA,MAAA,IAAI,CAAC,OAAO,0CAAE,OAAO,KAAI,SAAS,EAC3C,QAAQ,EAAE,CAAA,MAAA,IAAI,CAAC,OAAO,0CAAE,QAAQ,KAAI,UAAU,EAC9C,MAAM,EAAE,CAAA,MAAA,IAAI,CAAC,OAAO,0CAAE,MAAM,MAAI,MAAA,IAAI,CAAC,OAAO,0CAAE,IAAI,CAAA,IAAI,SAAS,EAC/D,IAAI,EAAE;YACL,GAAG,EACF,CAAA,MAAA,IAAI,CAAC,OAAO,0CAAE,IAAI;gBAClB,uCAAuC,GAAG,IAAI,CAAC,IAAI;YACpD,KAAK,EAAE,CAAA,MAAA,IAAI,CAAC,OAAO,0CAAE,WAAW,KAAI,cAAc;SAClD,GACQ,CAAA;IAEV,OAAO;QACN,oBAAoB,EAAE,GAAG,UAAU,CAAC,IAAI,IAAI,UAAU,CAAC,OAAO,EAAE;QAChE,sBAAsB,EAAE,GAAG,UAAU,CAAC,IAAI,CAAC,KAAK,IAAI,UAAU,CAAC,I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QD,SAAgB,mBAAmB,CAAC,IAAU;IAC7C,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,IAAY,CAAA;IACxC,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,EAAE,GAAG,OAIrC,CAAA;IAGD,MAAM,QAAQ,GAAG,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC,CAAC,CAAC,WAAW,CAAA;IAGvE,OAAO;QACN,IAAI,EAAE,IAAA,sBAAc,EAAC,cAAc,GAAG,MAAM,EAAE,IAAI,EAAE,QAAQ,CAAC;QAC7D,WAAW,EAAE,IAAA,sBAAc,EAC1B,qBAAqB,GAAG,MAAM,EAC9B,WAAW,EACX,QAAQ,CACR;QACD,MAAM,EAAE,IAAA,sBAAc,EAAC,gBAAgB,GAAG,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC;KACnE,CAAA;AACF,CAAC;AArBD,kDAqBC"}
@@ -0,0 +1,3 @@
1
+ import { type TranslationStrings } from '../types';
2
+ export declare function yieldParsedData(parsed: Record<string, string>, filename: 'block.json' | 'theme.json' | 'readme.txt', filepath: string): TranslationStrings;
3
+ export declare function parseFile(file: string, filePath?: string): Promise<TranslationStrings | null>;
@@ -32,20 +32,19 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
32
32
  });
33
33
  };
34
34
  Object.defineProperty(exports, "__esModule", { value: true });
35
- exports.extractMainFileData = exports.extractCssThemeData = exports.extractPhpPluginData = exports.extractPackageJson = exports.parseFile = exports.yieldParsedData = void 0;
35
+ exports.parseFile = exports.yieldParsedData = void 0;
36
36
  const path = __importStar(require("path"));
37
37
  const fs = __importStar(require("fs"));
38
- const utils_1 = require("./utils");
39
- const extractors_json_1 = require("./extractors-json");
40
- const extractors_php_1 = require("./extractors-php");
41
- const extractors_text_1 = require("./extractors-text");
42
- const extractors_maps_1 = require("./extractors-maps");
43
- const tree_1 = require("./tree");
38
+ const utils_1 = require("../utils");
39
+ const json_1 = require("./json");
40
+ const text_1 = require("./text");
41
+ const tree_1 = require("../tree");
42
+ const utils_2 = require("./utils");
44
43
  function yieldParsedData(parsed, filename, filepath) {
45
44
  const gettextTranslations = {};
46
- Object.entries(parsed).map(([k, v]) => {
45
+ Object.entries(parsed).forEach(([term, string]) => {
47
46
  var _a, _b;
48
- const entry = (0, extractors_json_1.jsonString)(k, v, filepath, filename);
47
+ const entry = (0, utils_2.gentranslation)((0, json_1.getJsonComment)(term, filename), string, filepath);
49
48
  gettextTranslations[(_a = entry.msgctxt) !== null && _a !== void 0 ? _a : ''] = Object.assign(Object.assign({}, (gettextTranslations[(_b = entry.msgctxt) !== null && _b !== void 0 ? _b : ''] || {})), { [entry.msgid]: entry });
50
49
  });
51
50
  return gettextTranslations;
@@ -58,11 +57,31 @@ function parseFile(file, filePath = '') {
58
57
  if (ext === 'json') {
59
58
  const filename = path.basename(file);
60
59
  if (filename === 'theme.json' || filename === 'block.json') {
61
- return (0, extractors_json_1.parseJsonFile)({
60
+ const res = yield (0, json_1.parseJsonFile)({
62
61
  sourceCode: fs.readFileSync(fileRealPath, 'utf8'),
63
62
  filename: filename,
64
63
  filepath: filePath,
65
64
  });
65
+ if (res) {
66
+ return yieldParsedData(res, filename, path.join(filePath, filename));
67
+ }
68
+ else {
69
+ return {};
70
+ }
71
+ }
72
+ }
73
+ if (ext === 'txt') {
74
+ const filename = path.basename(file);
75
+ if (filename === 'readme.txt') {
76
+ const fileContent = fs.readFileSync(file, 'utf8');
77
+ const commentBlock = (0, utils_1.getCommentBlock)(fileContent);
78
+ const parsed = (0, text_1.extractFileData)(commentBlock);
79
+ if (parsed) {
80
+ return yieldParsedData(parsed, filename, filePath);
81
+ }
82
+ else {
83
+ return {};
84
+ }
66
85
  }
67
86
  }
68
87
  if (['ts', 'tsx', 'js', 'jsx', 'mjs', 'cjs', 'php'].includes(ext)) {
@@ -73,65 +92,4 @@ function parseFile(file, filePath = '') {
73
92
  });
74
93
  }
75
94
  exports.parseFile = parseFile;
76
- function extractPackageJson(args, fields = extractors_maps_1.pkgJsonHeaders) {
77
- const pkgJsonMeta = {};
78
- const packageJsonPath = args.paths.cwd
79
- ? path.join(args.paths.cwd, 'package.json')
80
- : 'package.json';
81
- if (fs.existsSync(packageJsonPath)) {
82
- const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
83
- for (const field of Object.keys(fields)) {
84
- if (packageJson[field] !== undefined) {
85
- pkgJsonMeta[field] = packageJson[field];
86
- }
87
- }
88
- }
89
- return pkgJsonMeta;
90
- }
91
- exports.extractPackageJson = extractPackageJson;
92
- function extractPhpPluginData(args) {
93
- let fileData = {};
94
- const folderPhpFile = path.join(args.paths.cwd, `${args.slug}.php`);
95
- if (fs.existsSync(folderPhpFile)) {
96
- const fileContent = fs.readFileSync(folderPhpFile, 'utf8');
97
- fileData = (0, extractors_php_1.parsePHPFile)(fileContent);
98
- if ('Plugin Name' in fileData) {
99
- console.log('Plugin file detected.');
100
- console.log(`Plugin file: ${folderPhpFile}`);
101
- args.domain = 'plugin';
102
- }
103
- }
104
- else {
105
- console.log('Plugin file not found.');
106
- console.log(`Missing Plugin filename: ${folderPhpFile}`);
107
- }
108
- }
109
- exports.extractPhpPluginData = extractPhpPluginData;
110
- function extractCssThemeData(args) {
111
- let fileData = {};
112
- const styleCssFile = path.join(args.paths.cwd, 'style.css');
113
- if (fs.existsSync(styleCssFile)) {
114
- const fileContent = fs.readFileSync(styleCssFile, 'utf8');
115
- const commentBlock = (0, utils_1.getCommentBlock)(fileContent);
116
- fileData = (0, extractors_text_1.extractFileData)(commentBlock);
117
- console.log('Theme stylesheet detected.');
118
- console.log(`Theme stylesheet: ${styleCssFile}`);
119
- args.domain = 'theme';
120
- return fileData;
121
- }
122
- else {
123
- console.log(`Theme stylesheet not found in ${styleCssFile}`);
124
- }
125
- }
126
- exports.extractCssThemeData = extractCssThemeData;
127
- function extractMainFileData(args) {
128
- if (['plugin', 'block', 'generic'].includes(args.domain)) {
129
- return extractPhpPluginData(args);
130
- }
131
- else if (['theme', 'theme-block'].includes(args.domain)) {
132
- return extractCssThemeData(args);
133
- }
134
- return console.log('No main file detected.');
135
- }
136
- exports.extractMainFileData = extractMainFileData;
137
- //# sourceMappingURL=extractors.js.map
95
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/extractors/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA4B;AAC5B,uCAAwB;AAExB,oCAA0C;AAE1C,iCAAsD;AACtD,iCAAwC;AACxC,kCAAgC;AAChC,mCAAwC;AAUxC,SAAgB,eAAe,CAC9B,MAA8B,EAC9B,QAAoD,EACpD,QAAgB;IAEhB,MAAM,mBAAmB,GAAuB,EAAE,CAAA;IAElD,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,EAAE,MAAM,CAAC,EAAE,EAAE;;QACjD,MAAM,KAAK,GAAG,IAAA,sBAAc,EAC3B,IAAA,qBAAc,EAAC,IAAI,EAAE,QAAQ,CAAC,EAC9B,MAAM,EACN,QAAQ,CACR,CAAA;QAED,mBAAmB,CAAC,MAAA,KAAK,CAAC,OAAO,mCAAI,EAAE,CAAC,mCACpC,CAAC,mBAAmB,CAAC,MAAA,KAAK,CAAC,OAAO,mCAAI,EAAE,CAAC,IAAI,EAAE,CAAC,KACnD,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,KAAK,GACpB,CAAA;IACF,CAAC,CAAC,CAAA;IAEF,OAAO,mBAAmB,CAAA;AAC3B,CAAC;AArBD,0CAqBC;AAOD,SAAsB,SAAS,CAC9B,IAAY,EACZ,WAAmB,EAAE;;QAErB,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAA;QAChD,MAAM,YAAY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,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;YAEnE,MAAM,UAAU,GAAG,EAAE,CAAC,YAAY,CAAC,YAAY,EAAE,MAAM,CAAC,CAAA;YAExD,OAAO,IAAA,aAAM,EAAC,UAAU,EAAE,IAAI,CAAC,CAAA;QAChC,CAAC;QAED,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAA;IAC/C,CAAC;CAAA;AA9DD,8BA8DC"}
@@ -0,0 +1,7 @@
1
+ import type { I18nSchema } from '../types';
2
+ export declare function parseJsonFile(opts: {
3
+ sourceCode: string;
4
+ filename: 'block.json' | 'theme.json';
5
+ filepath: string;
6
+ }): Promise<I18nSchema>;
7
+ export declare function getJsonComment(key: string, type?: 'block.json' | 'theme.json' | 'readme.txt'): string;