@wp-blocks/make-pot 1.2.0 → 1.3.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.
Files changed (96) hide show
  1. package/biome.json +12 -0
  2. package/lib/assets/block-i18n.js +1 -0
  3. package/lib/assets/package-i18n.js +1 -0
  4. package/lib/assets/theme-i18n.js +1 -0
  5. package/lib/assets/wp-plugin-i18n.js +1 -0
  6. package/lib/assets/wp-theme-i18n.js +1 -0
  7. package/lib/cli/getArgs.js +1 -0
  8. package/lib/cli/parseCli.js +1 -110
  9. package/lib/const.js +1 -82
  10. package/lib/extractors/css.js +1 -42
  11. package/lib/extractors/headers.js +1 -73
  12. package/lib/extractors/json.js +1 -69
  13. package/lib/extractors/php.js +2 -49
  14. package/lib/extractors/schema.js +1 -100
  15. package/lib/extractors/text.js +1 -18
  16. package/lib/extractors/utils.js +1 -55
  17. package/lib/fs/fs.js +1 -0
  18. package/lib/fs/glob.js +3 -83
  19. package/lib/index.js +1 -26
  20. package/lib/parser/exec.js +3 -49
  21. package/lib/parser/makePot.js +1 -0
  22. package/lib/parser/patterns.js +1 -33
  23. package/lib/parser/process.js +1 -38
  24. package/lib/parser/progress.js +1 -21
  25. package/lib/parser/taskRunner.js +1 -33
  26. package/lib/parser/tree.js +1 -104
  27. package/lib/run.js +1 -0
  28. package/lib/types.js +1 -3
  29. package/lib/utils/common.js +2 -0
  30. package/package.json +68 -75
  31. package/tsconfig.json +4 -20
  32. package/ .prettierignore +0 -3
  33. package/.editorconfig +0 -15
  34. package/.eslintrc.json +0 -12
  35. package/jest.config.json +0 -18
  36. package/lib/assets/block-i18n.json +0 -17
  37. package/lib/assets/package-i18n.json +0 -13
  38. package/lib/assets/theme-i18n.json +0 -86
  39. package/lib/assets/wp-plugin-i18n.json +0 -14
  40. package/lib/assets/wp-theme-i18n.json +0 -13
  41. package/lib/cli/index.d.ts +0 -1
  42. package/lib/cli/index.js +0 -114
  43. package/lib/cli/index.js.map +0 -1
  44. package/lib/cli/parseCli.d.ts +0 -3
  45. package/lib/cli/parseCli.js.map +0 -1
  46. package/lib/const.d.ts +0 -140
  47. package/lib/const.js.map +0 -1
  48. package/lib/extractors/css.d.ts +0 -2
  49. package/lib/extractors/css.js.map +0 -1
  50. package/lib/extractors/headers.d.ts +0 -5
  51. package/lib/extractors/headers.js.map +0 -1
  52. package/lib/extractors/index.d.ts +0 -2
  53. package/lib/extractors/index.js +0 -50
  54. package/lib/extractors/index.js.map +0 -1
  55. package/lib/extractors/json.d.ts +0 -10
  56. package/lib/extractors/json.js.map +0 -1
  57. package/lib/extractors/php.d.ts +0 -3
  58. package/lib/extractors/php.js.map +0 -1
  59. package/lib/extractors/schema.d.ts +0 -84
  60. package/lib/extractors/schema.js.map +0 -1
  61. package/lib/extractors/text.d.ts +0 -1
  62. package/lib/extractors/text.js.map +0 -1
  63. package/lib/extractors/utils.d.ts +0 -5
  64. package/lib/extractors/utils.js.map +0 -1
  65. package/lib/fs/glob.d.ts +0 -13
  66. package/lib/fs/glob.js.map +0 -1
  67. package/lib/fs/index.d.ts +0 -2
  68. package/lib/fs/index.js +0 -58
  69. package/lib/fs/index.js.map +0 -1
  70. package/lib/index.d.ts +0 -2
  71. package/lib/index.js.map +0 -1
  72. package/lib/parser/exec.d.ts +0 -2
  73. package/lib/parser/exec.js.map +0 -1
  74. package/lib/parser/index.d.ts +0 -2
  75. package/lib/parser/index.js +0 -30
  76. package/lib/parser/index.js.map +0 -1
  77. package/lib/parser/patterns.d.ts +0 -2
  78. package/lib/parser/patterns.js.map +0 -1
  79. package/lib/parser/process.d.ts +0 -4
  80. package/lib/parser/process.js.map +0 -1
  81. package/lib/parser/progress.d.ts +0 -3
  82. package/lib/parser/progress.js.map +0 -1
  83. package/lib/parser/taskRunner.d.ts +0 -4
  84. package/lib/parser/taskRunner.js.map +0 -1
  85. package/lib/parser/tree.d.ts +0 -2
  86. package/lib/parser/tree.js.map +0 -1
  87. package/lib/types.d.ts +0 -50
  88. package/lib/types.js.map +0 -1
  89. package/lib/utils/index.d.ts +0 -9
  90. package/lib/utils/index.js +0 -83
  91. package/lib/utils/index.js.map +0 -1
  92. package/tests/extract.test.ts +0 -382
  93. package/tests/getFiles.test.ts +0 -114
  94. package/tests/ignoreFunction.test.ts +0 -102
  95. package/tests/jsonParse.ts +0 -51
  96. package/tests/tree.test.ts +0 -151
@@ -1,151 +0,0 @@
1
- import { describe, expect } from '@jest/globals'
2
- import { doTree } from '../src/parser/tree'
3
- import fs from 'fs'
4
-
5
- import path from 'path'
6
-
7
- describe('doTree js', () => {
8
- const filepath = 'tests/fixtures/block/javascript.js'
9
- let filePath: string
10
- let fileContent: string
11
- beforeAll(() => {
12
- filePath = path.join(process.cwd(), filepath)
13
- console.log('My file path is: ' + filePath)
14
- fileContent = fs.readFileSync(filePath, 'utf8')
15
- })
16
- test('Should parse TSX file and extract strings', () => {
17
- const fileParsed = doTree(fileContent, filepath)
18
- expect(fileParsed).toMatchSnapshot()
19
- })
20
- })
21
-
22
- describe('doTree php', () => {
23
- const filepath = 'tests/fixtures/sourcedir/file.php'
24
- let filePath: string
25
- let fileContent: string
26
- beforeAll(() => {
27
- filePath = path.join(process.cwd(), filepath)
28
- console.log('My file path is: ' + filePath)
29
- fileContent = fs.readFileSync(filePath, 'utf8')
30
- })
31
- test('Should parse TSX file and extract strings', () => {
32
- const fileParsed = doTree(fileContent, filepath)
33
- expect(fileParsed).toMatchSnapshot()
34
- })
35
- })
36
-
37
- describe('doTree tsx file', () => {
38
- const filepath = 'tests/fixtures/block/SvgControls.tsx'
39
- let filePath: string
40
- let fileContent: string
41
- beforeAll(() => {
42
- filePath = path.join(process.cwd(), filepath)
43
- console.log('My file path is: ' + filePath)
44
- fileContent = fs.readFileSync(filePath, 'utf8')
45
- })
46
- test('Should parse TSX file and extract strings', () => {
47
- const fileParsed = doTree(fileContent, filepath)
48
- expect(fileParsed).toMatchSnapshot()
49
- })
50
- })
51
-
52
- describe('doTree php test file', () => {
53
- /** see wp cli tests */
54
- it('should extract translations and comments from code content', () => {
55
- const content = `<?php
56
-
57
- // translators: Foo Bar Comment
58
- __( 'Foo Bar', 'foo-plugin' );
59
-
60
- // TrANslAtORs: Bar Baz Comment
61
- __( 'Bar Baz', 'foo-plugin' );
62
-
63
- // translators: Software name
64
- const string = __( 'WordPress', 'foo-plugin' );
65
-
66
- // translators: So much space
67
-
68
- __( 'Spacey text', 'foo-plugin' );
69
-
70
- /* translators: Long comment
71
- spanning multiple
72
- lines */
73
- const string = __( 'Short text', 'foo-plugin' );
74
-
75
- ReactDOM.render(
76
- <h1>{__( 'Hello JSX', 'foo-plugin' )}</h1>,
77
- document.getElementById('root')
78
- );
79
-
80
- wp.i18n.__( 'wp.i18n.__', 'foo-plugin' );
81
- wp.i18n._n( 'wp.i18n._n_single', 'wp.i18n._n_plural', number, 'foo-plugin' );
82
-
83
- const translate = wp.i18n;
84
- translate.__( 'translate.__', 'foo-plugin' );
85
-
86
- Object(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_7__["__"])( 'webpack.__', 'foo-plugin' );
87
- Object(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_7__[/* __ */ "a"])( 'webpack.mangle.__', 'foo-plugin' );
88
-
89
- Object(u.__)( 'minified.__', 'foo-plugin' );
90
- Object(j._x)( 'minified._x', 'minified._x_context', 'foo-plugin' );
91
-
92
- /* translators: babel */
93
- (0, __)( 'babel.__', 'foo-plugin' );
94
- (0, _i18n.__)( 'babel-i18n.__', 'foo-plugin' );
95
- (0, _i18n._x)( 'babel-i18n._x', 'babel-i18n._x_context', 'foo-plugin' );
96
-
97
- eval( "__( 'Hello Eval World', 'foo-plugin' );" );
98
-
99
- __( \`This is a \${bug}\`, 'foo-plugin' );
100
-
101
- /**
102
- * Plugin Name: Plugin name
103
- */
104
-
105
- /* translators: Translators 1! */
106
- _e( 'hello world', 'foo-plugin' );
107
-
108
- /* Translators: Translators 2! */
109
- $foo = __( 'foo', 'foo-plugin' );
110
-
111
- /* translators: localized date and time format, see https://secure.php.net/date */
112
- __( 'F j, Y g:i a', 'foo-plugin' );
113
-
114
- // translators: let your ears fly!
115
- __( 'on', 'foo-plugin' );
116
-
117
- /*
118
- * Translators: If there are characters in your language that are not supported
119
- * by Lato, translate this to 'off'. Do not translate into your own language.
120
- */
121
- __( 'off', 'foo-plugin' );
122
-
123
- /* translators: this should get extracted. */ $foo = __( 'baba', 'foo-plugin' );
124
-
125
- /* translators: boo */ /* translators: this should get extracted too. */ /* some other comment */ $bar = g( __( 'bubu', 'foo-plugin' ) );
126
-
127
- {TAB}/*
128
- {TAB} * translators: this comment block is indented with a tab and should get extracted too.
129
- {TAB} */
130
- {TAB}__( 'yolo', 'foo-plugin' );
131
-
132
- /* translators: This is a comment */
133
- __( 'Plugin name', 'foo-plugin' );
134
-
135
- /* Translators: This is another comment! */
136
- __( 'https://example.com', 'foo-plugin' );
137
- `
138
-
139
- const filename = 'filename.php'
140
-
141
- const r = doTree(content, filename).blocks
142
- const res = Object.values(r)[0]
143
-
144
- /** TODO: fix this test - btw i counted 19 blocks and 8 comments in the test file */
145
- expect(r.map((block) => block).length).toBeGreaterThanOrEqual(19)
146
- expect(
147
- r.filter((block) => block.comments).length
148
- ).toBeGreaterThanOrEqual(8)
149
- expect(res).toMatchSnapshot()
150
- })
151
- })