@wp-blocks/make-pot 0.0.7 → 0.1.0

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.
package/lib/fs.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"fs.js","sourceRoot":"","sources":["../src/fs.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,2CAA4B;AAC5B,uCAAwB;AAQxB,SAAS,kBAAkB,CAAC,UAA8B;IACzD,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;QAC9B,OAAO,GAAG,CAAA;IACX,CAAC;IACD,IAAI,CAAC;QAEJ,EAAE,CAAC,UAAU,CACZ,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,EACxB,EAAE,CAAC,SAAS,CAAC,IAAI,GAAG,EAAE,CAAC,SAAS,CAAC,IAAI,CACrC,CAAA;IACF,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,IAAK,KAA+B,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YAExD,EAAE,CAAC,SAAS,CAAC,UAAU,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;YAC7C,OAAO,CAAC,GAAG,CAAC,mBAAmB,UAAU,EAAE,CAAC,CAAA;YAC5C,OAAO,UAAU,CAAA;QAClB,CAAC;IACF,CAAC;IACD,OAAO,UAAU,CAAA;AAClB,CAAC;AAQD,SAAsB,SAAS,CAAC,WAAmB,EAAE,IAAY;;QAChE,IAAI,kBAAkB,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC;YAC5C,EAAE,CAAC,aAAa,CAAC,IAAI,EAAE,WAAW,CAAC,CAAA;QACpC,CAAC;IACF,CAAC;CAAA;AAJD,8BAIC"}
1
+ {"version":3,"file":"fs.js","sourceRoot":"","sources":["../src/fs.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,2CAA4B;AAC5B,uCAAwB;AAQxB,SAAS,kBAAkB,CAAC,UAA8B;IACzD,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;QAC9B,OAAO,GAAG,CAAA;IACX,CAAC;IACD,IAAI,CAAC;QAEJ,EAAE,CAAC,UAAU,CACZ,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,EACxB,EAAE,CAAC,SAAS,CAAC,IAAI,GAAG,EAAE,CAAC,SAAS,CAAC,IAAI,CACrC,CAAA;IACF,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,IAAK,KAA+B,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YAExD,EAAE,CAAC,SAAS,CAAC,UAAU,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;YAC7C,OAAO,CAAC,GAAG,CAAC,mBAAmB,UAAU,EAAE,CAAC,CAAA;YAC5C,OAAO,UAAU,CAAA;QAClB,CAAC;IACF,CAAC;IACD,OAAO,UAAU,CAAA;AAClB,CAAC;AAMD,SAAsB,SAAS,CAAC,WAAmB,EAAE,IAAY;;QAChE,IAAI,kBAAkB,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC;YAC5C,EAAE,CAAC,aAAa,CAAC,IAAI,EAAE,WAAW,CAAC,CAAA;QACpC,CAAC;IACF,CAAC;CAAA;AAJD,8BAIC"}
package/lib/tree.js CHANGED
@@ -6,15 +6,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.doTree = void 0;
7
7
  const tree_sitter_1 = __importDefault(require("tree-sitter"));
8
8
  const const_1 = require("./const");
9
- const utils_1 = require("./utils");
10
9
  const glob_1 = require("./glob");
11
- function collectComments(node, typeToMatch) {
12
- var _a;
10
+ const utils_1 = require("./utils");
11
+ function collectComments(node) {
12
+ var _a, _b;
13
13
  let currentNode = node;
14
14
  let depth = 0;
15
- while (currentNode && depth < 10) {
16
- if (((_a = currentNode === null || currentNode === void 0 ? void 0 : currentNode.previousSibling) === null || _a === void 0 ? void 0 : _a.type) === 'comment') {
17
- return (0, utils_1.stripTranslationMarkup)(currentNode === null || currentNode === void 0 ? void 0 : currentNode.previousSibling.text);
15
+ while (currentNode && depth < 6) {
16
+ if (((_a = currentNode === null || currentNode === void 0 ? void 0 : currentNode.previousSibling) === null || _a === void 0 ? void 0 : _a.type) === 'comment' &&
17
+ ((_b = currentNode === null || currentNode === void 0 ? void 0 : currentNode.previousSibling) === null || _b === void 0 ? void 0 : _b.text.toLowerCase().includes('translators'))) {
18
+ const comment = (0, utils_1.stripTranslationMarkup)(currentNode === null || currentNode === void 0 ? void 0 : currentNode.previousSibling.text);
19
+ return comment;
18
20
  }
19
21
  depth++;
20
22
  currentNode = currentNode.parent;
@@ -30,7 +32,7 @@ function doTree(sourceCode, filepath) {
30
32
  ? 'call_expression'
31
33
  : 'function_call_expression';
32
34
  function traverse(node) {
33
- var _a, _b, _c, _d, _e, _f, _g;
35
+ var _a, _b, _c, _d, _e, _f, _g, _h;
34
36
  if (node === null || node === void 0 ? void 0 : node.children.length)
35
37
  for (const child of node.children) {
36
38
  traverse(child);
@@ -63,10 +65,10 @@ function doTree(sourceCode, filepath) {
63
65
  msgstr: [],
64
66
  comments: {
65
67
  reference: `${filepath}:${node.startPosition.row + 1}`,
66
- translator: collectComments(node, typeToMatch),
68
+ translator: (_f = collectComments(node)) !== null && _f !== void 0 ? _f : '',
67
69
  },
68
70
  };
69
- gettextTranslations[(_f = gettext.msgctxt) !== null && _f !== void 0 ? _f : ''] = Object.assign(Object.assign({}, (gettextTranslations[(_g = gettext.msgctxt) !== null && _g !== void 0 ? _g : ''] || {})), { [gettext.msgid]: gettext });
71
+ gettextTranslations[(_g = gettext.msgctxt) !== null && _g !== void 0 ? _g : ''] = Object.assign(Object.assign({}, (gettextTranslations[(_h = gettext.msgctxt) !== null && _h !== void 0 ? _h : ''] || {})), { [gettext.msgid]: gettext });
70
72
  }
71
73
  }
72
74
  traverse(tree.rootNode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C,MAAA,OAAO,CAAC,OAAO,mCAAI,EAAE,CAAC,IAAI,EAAE,CAAC,KACrD,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,OAAO,GACxB,CAAA;QACF,CAAC;IACF,CAAC;IAED,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;IAGvB,OAAO,mBAAmB,CAAA;AAC3B,CAAC;AA1FD,wBA0FC"}
package/lib/utils.js CHANGED
@@ -26,7 +26,7 @@ function removeCommentMarkup(input) {
26
26
  }
27
27
  exports.removeCommentMarkup = removeCommentMarkup;
28
28
  function stripTranslationMarkup(comment) {
29
- const commentPattern = /\/\*\*?\s*translators:\s*([\s\S]*?)\s*\*\/|\/\/\s*translators:\s*(.*)$/i;
29
+ const commentPattern = /\/\*\*?\s*(?:translators:)\s*([\s\S]*?)\s*\*\/|\/\/\s*(?:translators:)\s*(.*)$/i;
30
30
  const matches = comment.match(commentPattern);
31
31
  return matches ? matches[1] : comment;
32
32
  }
package/lib/utils.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;;;;;AACA,gDAAuB;AAiBvB,SAAgB,sBAAsB,CAAC,IAAU;;IAChD,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG;QAClC,MAAM,EAAE,MAAA,MAAA,IAAI,CAAC,OAAO,0CAAE,MAAM,mCAAI,QAAQ;QACxC,KAAK,EAAE,MAAA,MAAA,IAAI,CAAC,OAAO,0CAAE,KAAK,mCAAI,OAAO;QACrC,OAAO,EAAE,MAAA,MAAA,IAAI,CAAC,OAAO,0CAAE,OAAO,mCAAI,kBAAkB;KACpD,CAAA;IAED,OAAO,mBAAmB,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,IAAI,MAAM,KAAK,KAAK;uCAChC,OAAO,GAAG,CAAA;AACjD,CAAC;AATD,wDASC;AAQD,SAAgB,eAAe,CAAC,KAAa;IAC5C,MAAM,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0B,EAAE,CAAC;QAClE,OAAO,WAAW,CAAA;IACnB,CAAC;SAAM,IAAI,qBAAqB,IAAI,CAAC,0BAA0B,EAAE,CAAC;QACjE,OAAO,MAAM,CAAA;IACd,CAAC;SAAM,CAAC;QACP,OAAO,MAAM,CAAA;IACd,CAAC;AACF,CAAC;AAhBD,8CAgBC;AAQD,SAAgB,eAAe,CAAC,WAAqB;IACpD,OAAO,WAAW,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;QAC/B,MAAM,IAAI,GAAG,iBAAiB,CAAC,IAAI,CAAC,CAAA;QACpC,QAAQ,IAAI,EAAE,CAAC;YACd,KAAK,WAAW;gBACf,OAAO,IAAI,GAAG,KAAK,CAAA;YACpB,KAAK,MAAM;gBACV,OAAO,KAAK,GAAG,IAAI,CAAA;YACpB;gBACC,OAAO,IAAI,CAAA;QACb,CAAC;IACF,CAAC,CAAC,CAAA;AACH,CAAC;AAZD,0CAYC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wp-blocks/make-pot",
3
- "version": "0.0.7",
3
+ "version": "0.1.0",
4
4
  "description": "A Node.js script for generating a POT file from source code",
5
5
  "author": "Erik Golinelli <https://github.com/erikyo>",
6
6
  "main": "lib/index.js",
@@ -33,6 +33,7 @@
33
33
  "@types/gettext-parser": "^4.0.4",
34
34
  "@types/jest": "^29.5.11",
35
35
  "@types/node": "^20.10.4",
36
+ "@types/strip-comments": "^2.0.4",
36
37
  "@types/yargs": "^17.0.32",
37
38
  "@typescript-eslint/eslint-plugin": "^6.18.1",
38
39
  "@typescript-eslint/parser": "^6.14.0",
@@ -68,8 +68,11 @@ describe('getStrings', () => {
68
68
  'Hello World': {
69
69
  comments: {
70
70
  reference: 'filename.php:1',
71
+ translator: '',
71
72
  },
73
+ msgctxt: '',
72
74
  msgid: 'Hello World',
75
+ msgid_plural: '',
73
76
  msgstr: [],
74
77
  },
75
78
  },
@@ -82,9 +85,12 @@ describe('getStrings', () => {
82
85
  'Hello World': {
83
86
  comments: {
84
87
  reference: 'filename.php:1',
88
+ translator: '',
85
89
  },
90
+ msgctxt: '',
86
91
  msgid: 'Hello World',
87
92
  msgstr: [],
93
+ msgid_plural: '',
88
94
  },
89
95
  },
90
96
  }
@@ -107,6 +113,7 @@ describe('getStrings', () => {
107
113
  translator: 'ciao!',
108
114
  },
109
115
  msgid: 'Hello World',
116
+ msgctxt: '',
110
117
  msgid_plural: 'greeting',
111
118
  msgstr: [],
112
119
  },
@@ -137,7 +144,8 @@ describe('getStrings', () => {
137
144
  reference: 'filename.php:10',
138
145
  },
139
146
  msgid: 'Hello World',
140
- msgid_plural: 'greeting',
147
+ msgctxt: '',
148
+ msgid_plural: '',
141
149
  msgstr: [],
142
150
  },
143
151
  },
@@ -145,7 +153,7 @@ describe('getStrings', () => {
145
153
 
146
154
  const result = doTree(content, filename)
147
155
 
148
- expect(result).toEqual(expected)
156
+ expect(result).toMatchObject(expected)
149
157
  })
150
158
 
151
159
  it('should extract translations inside a sprint', () => {
@@ -169,107 +177,51 @@ echo $link;`
169
177
 
170
178
  const result = doTree(content, filename)
171
179
 
172
- expect(result).toEqual(expected)
180
+ expect(result).toMatchObject(expected)
173
181
  })
174
182
  })
183
+
175
184
  describe('getStrings wp cli', () => {
176
185
  it('should extract translations with translator comments inside the formatting hell', () => {
177
186
  const filename = 'filename.php'
178
- const content = `<?php /** 1*/
179
- /** 2*/ /** translators: 1: Site URL, 2: Username, 3: User email address, 4: Lost password URL. */
180
- sprintf(__( 'Your site at %1$s is active. You may now log in to your site using your chosen username of &#8220;%2$s&#8221;. Please check your email inbox at %3$s for your password and login instructions. If you do not receive an email, please check your junk or spam folder. If you still do not receive an email within an hour, you can <a href="%4$s">reset your password</a>.' ),
181
- /** 6*/\t\t\tsprintf( '<a href="http://%1$s%2$s">%1$s%2$s</a>', $signup->domain, $blog_details->path ),
182
- /** 7*/\t\t\t$signup->user_login,
183
- /** 8*/\t\t\t$signup->user_email,
184
- /** 9*/\t\t\twp_lostpassword_url()
185
- /** 10*/\t\t);
186
-
187
- /** 11*/\t\techo __( 'aaaaaaa' );
188
- /** 12*/\t\techo __( 'aaaaaaa' );
189
- /** 13 */\t\techo __( 'aaaaaaa' );
190
- /** 14 */
191
- /** 15 */ printf(
192
- \t\t\t\t/* translators: 1: Site URL, 2: Username, 3: User email address, 4: Lost password URL. */
193
- \t\t\t__( 'aaaaaaa' ),
194
- /** 18 */\t\t\t\t);
195
- /** translators:aaaa */
196
- echo __( 'Your site at %1$s' )
197
-
198
- /** translators:aaaa */
199
- _e( 'Your site at %1$s' )`
200
- const expected = [
201
- {
202
- '': {
203
- 'Your site at %1$s is active. You may now log in to your site using your chosen username of &#8220;%2$s&#8221;. Please check your email inbox at %3$s for your password and login instructions. If you do not receive an email, please check your junk or spam folder. If you still do not receive an email within an hour, you can <a href="%4$s">reset your password</a>.':
204
- {
205
- comments: {
206
- reference: 'filename.php:3',
207
- },
208
- msgid: 'Your site at %1$s is active. You may now log in to your site using your chosen username of &#8220;%2$s&#8221;. Please check your email inbox at %3$s for your password and login instructions. If you do not receive an email, please check your junk or spam folder. If you still do not receive an email within an hour, you can <a href="%4$s">reset your password</a>.',
209
- msgstr: [],
210
- },
211
- },
212
- },
213
- {
214
- '': {
215
- aaaaaaa: {
216
- comments: {
217
- reference: 'filename.php:10',
218
- },
219
- msgid: 'aaaaaaa',
220
- msgstr: [],
221
- },
222
- },
223
- },
224
- {
225
- '': {
226
- aaaaaaa: {
227
- comments: {
228
- reference: 'filename.php:11',
229
- },
230
- msgid: 'aaaaaaa',
231
- msgstr: [],
232
- },
233
- },
234
- },
235
- {
236
- '': {
237
- aaaaaaa: {
238
- comments: {
239
- reference: 'filename.php:12',
240
- },
241
- msgid: 'aaaaaaa',
242
- msgstr: [],
243
- },
244
- },
245
- },
246
- {
247
- '': {
248
- aaaaaaa: {
249
- comments: {
250
- reference: 'filename.php:16',
251
- translator: '',
252
- },
253
- msgid: 'aaaaaaa',
254
- msgstr: [],
255
- },
256
- },
257
- },
258
- {
259
- '': {
260
- 'Your site at %1$s': {
187
+ const content = `<?php if ( count( $errors_in_remigrate_batch ) > 0 ) {
188
+ $formatted_errors = wp_json_encode( $errors_in_remigrate_batch, JSON_PRETTY_PRINT );
189
+ WP_CLI::warning(
190
+ sprintf(
191
+ /* Translators: %1$d is number of errors and %2$s is the formatted array of order IDs. */
192
+ _n(
193
+ '%1$d error found: %2$s when re-migrating order. Please review the error above.',
194
+ '%1$d errors found: %2$s when re-migrating orders. Please review the errors above.',
195
+ count( $errors_in_remigrate_batch ),
196
+ 'woocommerce'
197
+ ),
198
+ count( $errors_in_remigrate_batch ),
199
+ $formatted_errors
200
+ )
201
+ );
202
+ } else {
203
+ WP_CLI::warning( 'Re-migration successful.', 'woocommerce' );
204
+ }
205
+ `
206
+ const expected = {
207
+ '': {
208
+ '%1$d error found: %2$s when re-migrating order. Please review the error above.':
209
+ {
261
210
  comments: {
262
- reference: 'filename.php:19',
211
+ reference: 'filename.php:6',
212
+ translator:
213
+ '%1$d is number of errors and %2$s is the formatted array of order IDs.',
263
214
  },
264
- msgid: 'Your site at %1$s',
215
+ msgctxt: '',
216
+ msgid: '%1$d error found: %2$s when re-migrating order. Please review the error above.',
217
+ msgid_plural: '',
265
218
  msgstr: [],
266
219
  },
267
- },
268
220
  },
269
- ]
221
+ }
270
222
 
271
223
  const result = doTree(content, filename)
272
- expect(result).toMatchObject(result)
224
+ expect(expected).toMatchObject(result)
273
225
  })
274
226
 
275
227
  /** see https://github.com/wp-cli/i18n-command/blob/main/features/makepot.feature */
@@ -22,7 +22,7 @@ describe('includes or not', () => {
22
22
  'tests'
23
23
  )
24
24
  )
25
- ).toBe('../tests')
25
+ ).toBe('..')
26
26
  expect(
27
27
  minimatch(path.normalize('block/SvgControls.tsx'), 'block/**')
28
28
  ).toBe(true)
@@ -1,3 +1,4 @@
1
+ import { describe, expect } from '@jest/globals'
1
2
  import { doTree } from '../src/tree'
2
3
  import fs from 'fs'
3
4
 
@@ -1,3 +1,4 @@
1
+ import { describe, expect } from '@jest/globals'
1
2
  import { doTree } from '../src/tree'
2
3
  import path from 'path'
3
4
  import fs from 'fs'
@@ -1,3 +1,4 @@
1
+ import { describe, expect } from '@jest/globals'
1
2
  import { doTree } from '../src/tree'
2
3
  import path from 'path'
3
4
 
@@ -11,7 +11,7 @@ describe('detectPatternType', () => {
11
11
  })
12
12
 
13
13
  test('should return "glob" when pattern ends with a directory separator', () => {
14
- expect(detectPatternType('example/')).toBe('glob')
14
+ expect(detectPatternType('example/')).toBe('directory')
15
15
  })
16
16
 
17
17
  test('should return "glob" when pattern contains an asterisk', () => {
File without changes
File without changes
File without changes
File without changes