@wp-blocks/make-pot 0.2.2 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. package/.github/workflows/node.js.yml +33 -0
  2. package/.github/workflows/tsDoc.yml +52 -0
  3. package/README.md +53 -34
  4. package/lib/assets/package-i18n.json +13 -0
  5. package/lib/assets/wp-plugin-i18n.json +14 -0
  6. package/lib/assets/wp-theme-i18n.json +13 -0
  7. package/lib/cli/index.d.ts +1 -0
  8. package/lib/cli/index.js +114 -0
  9. package/lib/cli/index.js.map +1 -0
  10. package/lib/cli/parseCli.d.ts +3 -0
  11. package/lib/cli/parseCli.js +111 -0
  12. package/lib/cli/parseCli.js.map +1 -0
  13. package/lib/cliArgs.js +36 -4
  14. package/lib/cliArgs.js.map +1 -1
  15. package/lib/const.d.ts +114 -0
  16. package/lib/const.js +40 -3
  17. package/lib/const.js.map +1 -1
  18. package/lib/extractors/css.js +13 -2
  19. package/lib/extractors/css.js.map +1 -1
  20. package/lib/extractors/headers.d.ts +3 -5
  21. package/lib/extractors/headers.js +19 -13
  22. package/lib/extractors/headers.js.map +1 -1
  23. package/lib/extractors/index.d.ts +1 -2
  24. package/lib/extractors/index.js +9 -44
  25. package/lib/extractors/index.js.map +1 -1
  26. package/lib/extractors/json.d.ts +5 -3
  27. package/lib/extractors/json.js +48 -4
  28. package/lib/extractors/json.js.map +1 -1
  29. package/lib/extractors/php.js +8 -15
  30. package/lib/extractors/php.js.map +1 -1
  31. package/lib/extractors/schema.js +5 -1
  32. package/lib/extractors/schema.js.map +1 -1
  33. package/lib/extractors/text.js +2 -6
  34. package/lib/extractors/text.js.map +1 -1
  35. package/lib/extractors/utils.d.ts +3 -3
  36. package/lib/extractors/utils.js +34 -25
  37. package/lib/extractors/utils.js.map +1 -1
  38. package/lib/fs/glob.d.ts +13 -0
  39. package/lib/fs/glob.js +95 -0
  40. package/lib/fs/glob.js.map +1 -0
  41. package/lib/fs/index.d.ts +2 -0
  42. package/lib/fs/index.js +69 -0
  43. package/lib/fs/index.js.map +1 -0
  44. package/lib/fs.d.ts +2 -1
  45. package/lib/fs.js +15 -8
  46. package/lib/fs.js.map +1 -1
  47. package/lib/index.js +5 -5
  48. package/lib/index.js.map +1 -1
  49. package/lib/makePot.d.ts +1 -1
  50. package/lib/makePot.js +20 -13
  51. package/lib/makePot.js.map +1 -1
  52. package/lib/maps.d.ts +1 -3
  53. package/lib/maps.js +12 -3
  54. package/lib/maps.js.map +1 -1
  55. package/lib/parser/consolidate.d.ts +2 -0
  56. package/lib/parser/consolidate.js +37 -0
  57. package/lib/parser/consolidate.js.map +1 -0
  58. package/lib/parser/exec.d.ts +3 -0
  59. package/lib/parser/exec.js +71 -0
  60. package/lib/parser/exec.js.map +1 -0
  61. package/lib/parser/index.d.ts +2 -0
  62. package/lib/parser/index.js +24 -0
  63. package/lib/parser/index.js.map +1 -0
  64. package/lib/parser/makePot.d.ts +2 -0
  65. package/lib/parser/makePot.js +33 -0
  66. package/lib/parser/makePot.js.map +1 -0
  67. package/lib/parser/patterns.d.ts +2 -0
  68. package/lib/parser/patterns.js +34 -0
  69. package/lib/parser/patterns.js.map +1 -0
  70. package/lib/parser/process.d.ts +5 -0
  71. package/lib/parser/process.js +70 -0
  72. package/lib/parser/process.js.map +1 -0
  73. package/lib/parser/tree.d.ts +2 -0
  74. package/lib/parser/tree.js +87 -0
  75. package/lib/parser/tree.js.map +1 -0
  76. package/lib/parser.d.ts +2 -2
  77. package/lib/parser.js +58 -57
  78. package/lib/parser.js.map +1 -1
  79. package/lib/types.d.ts +4 -3
  80. package/lib/utils/index.d.ts +8 -0
  81. package/lib/utils/index.js +78 -0
  82. package/lib/utils/index.js.map +1 -0
  83. package/lib/utils.d.ts +1 -1
  84. package/lib/utils.js +1 -1
  85. package/lib/utils.js.map +1 -1
  86. package/package.json +1 -1
  87. package/tests/consolidate.test.ts +1 -1
  88. package/tests/extract-2.test.ts +1 -1
  89. package/tests/{extract.old.ts → extract.test.ts} +20 -18
  90. package/tests/getFiles.old.ts +1 -1
  91. package/tests/getStrings.old.ts +1 -1
@@ -1,5 +1,5 @@
1
1
  import { describe, expect } from '@jest/globals'
2
- import { doTree } from '../src/tree'
2
+ import { doTree } from '../src/parser/tree'
3
3
 
4
4
  describe('getStrings', () => {
5
5
  it('should extract translations from js', () => {
@@ -15,7 +15,7 @@ describe('getStrings', () => {
15
15
  reference: 'filename.js:1',
16
16
  },
17
17
  msgid: 'Hello World',
18
- msgstr: [],
18
+ msgstr: [''],
19
19
  },
20
20
  },
21
21
  })
@@ -33,7 +33,7 @@ describe('getStrings', () => {
33
33
  reference: 'filename.ts:1',
34
34
  },
35
35
  msgid: 'Hello World',
36
- msgstr: [],
36
+ msgstr: [''],
37
37
  },
38
38
  },
39
39
  })
@@ -52,7 +52,7 @@ describe('getStrings', () => {
52
52
  reference: 'filename.tsx:1',
53
53
  },
54
54
  msgid: 'Hello World',
55
- msgstr: [],
55
+ msgstr: [''],
56
56
  },
57
57
  },
58
58
  })
@@ -73,7 +73,7 @@ describe('getStrings', () => {
73
73
  msgctxt: '',
74
74
  msgid: 'Hello World',
75
75
  msgid_plural: '',
76
- msgstr: [],
76
+ msgstr: [''],
77
77
  },
78
78
  },
79
79
  })
@@ -89,7 +89,7 @@ describe('getStrings', () => {
89
89
  },
90
90
  msgctxt: '',
91
91
  msgid: 'Hello World',
92
- msgstr: [],
92
+ msgstr: [''],
93
93
  msgid_plural: '',
94
94
  },
95
95
  },
@@ -106,16 +106,16 @@ describe('getStrings', () => {
106
106
  const content = `
107
107
  <?php /** translators: ciao! */ echo _x('Hello World', 'greeting'); ?>`
108
108
  const expected = {
109
- '': {
109
+ greeting: {
110
110
  'Hello World': {
111
111
  comments: {
112
112
  reference: 'filename.php:2',
113
113
  translator: 'ciao!',
114
114
  },
115
+ msgctxt: 'greeting',
115
116
  msgid: 'Hello World',
116
- msgctxt: '',
117
- msgid_plural: 'greeting',
118
- msgstr: [],
117
+ msgid_plural: '',
118
+ msgstr: [''],
119
119
  },
120
120
  },
121
121
  }
@@ -138,15 +138,16 @@ describe('getStrings', () => {
138
138
 
139
139
  <?php echo _x('Hello World', 'greeting'); ?>`
140
140
  const expected = {
141
- '': {
141
+ greeting: {
142
142
  'Hello World': {
143
+ msgctxt: 'greeting',
144
+ msgid: 'Hello World',
145
+ msgid_plural: '',
146
+ msgstr: [''],
143
147
  comments: {
148
+ translator: '',
144
149
  reference: 'filename.php:10',
145
150
  },
146
- msgid: 'Hello World',
147
- msgctxt: '',
148
- msgid_plural: '',
149
- msgstr: [],
150
151
  },
151
152
  },
152
153
  }
@@ -170,7 +171,7 @@ echo $link;`
170
171
  reference: 'filename.php:3',
171
172
  },
172
173
  msgid: 'Check out this link to my <a href="%s">website</a> made with WordPress.',
173
- msgstr: [],
174
+ msgstr: [''],
174
175
  },
175
176
  },
176
177
  }
@@ -214,8 +215,9 @@ describe('getStrings wp cli', () => {
214
215
  },
215
216
  msgctxt: '',
216
217
  msgid: '%1$d error found: %2$s when re-migrating order. Please review the error above.',
217
- msgid_plural: '',
218
- msgstr: [],
218
+ msgid_plural:
219
+ '%1$d errors found: %2$s when re-migrating orders. Please review the errors above.',
220
+ msgstr: ['', ''],
219
221
  },
220
222
  },
221
223
  }
@@ -1,8 +1,8 @@
1
1
  import { describe, expect } from '@jest/globals'
2
2
  import { getFiles } from '../src/glob'
3
3
  import { Args, DomainType } from '../src/types'
4
- import { parseCliArgs } from '../src/cliArgs'
5
4
  import path from 'path'
5
+ import { parseCliArgs } from '../src/cli/parseCli'
6
6
 
7
7
  describe('getFiles', () => {
8
8
  const DEFAULTS = parseCliArgs({
@@ -1,7 +1,7 @@
1
1
  import { describe, expect } from '@jest/globals'
2
- import { getStrings } from '../src/parser'
3
2
  import { Args, DomainType } from '../src/types'
4
3
  import { getFiles } from '../src/glob'
4
+ import { getStrings } from '../src/parser/process'
5
5
 
6
6
  const args: Args = {
7
7
  slug: 'plugin-slug',