@wp-blocks/make-pot 1.0.2 → 1.2.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 (95) hide show
  1. package/README.md +18 -1
  2. package/lib/cli/parseCli.js +11 -12
  3. package/lib/cli/parseCli.js.map +1 -1
  4. package/lib/const.js +1 -12
  5. package/lib/const.js.map +1 -1
  6. package/lib/extractors/headers.d.ts +2 -3
  7. package/lib/extractors/headers.js +23 -13
  8. package/lib/extractors/headers.js.map +1 -1
  9. package/lib/extractors/index.d.ts +2 -2
  10. package/lib/extractors/index.js +15 -25
  11. package/lib/extractors/index.js.map +1 -1
  12. package/lib/extractors/json.d.ts +3 -2
  13. package/lib/extractors/json.js +17 -30
  14. package/lib/extractors/json.js.map +1 -1
  15. package/lib/extractors/schema.d.ts +73 -2
  16. package/lib/extractors/schema.js +31 -52
  17. package/lib/extractors/schema.js.map +1 -1
  18. package/lib/extractors/text.js +3 -4
  19. package/lib/extractors/text.js.map +1 -1
  20. package/lib/extractors/utils.d.ts +4 -4
  21. package/lib/extractors/utils.js +17 -16
  22. package/lib/extractors/utils.js.map +1 -1
  23. package/lib/fs/glob.d.ts +2 -2
  24. package/lib/fs/glob.js +9 -21
  25. package/lib/fs/glob.js.map +1 -1
  26. package/lib/fs/index.js +2 -13
  27. package/lib/fs/index.js.map +1 -1
  28. package/lib/index.js +2 -2
  29. package/lib/index.js.map +1 -1
  30. package/lib/parser/exec.d.ts +0 -1
  31. package/lib/parser/exec.js +38 -60
  32. package/lib/parser/exec.js.map +1 -1
  33. package/lib/parser/index.d.ts +2 -2
  34. package/lib/parser/index.js +25 -19
  35. package/lib/parser/index.js.map +1 -1
  36. package/lib/parser/patterns.js +6 -7
  37. package/lib/parser/patterns.js.map +1 -1
  38. package/lib/parser/process.d.ts +4 -5
  39. package/lib/parser/process.js +25 -57
  40. package/lib/parser/process.js.map +1 -1
  41. package/lib/parser/progress.d.ts +3 -0
  42. package/lib/parser/progress.js +21 -0
  43. package/lib/parser/progress.js.map +1 -0
  44. package/lib/parser/taskRunner.d.ts +4 -0
  45. package/lib/parser/taskRunner.js +33 -0
  46. package/lib/parser/taskRunner.js.map +1 -0
  47. package/lib/parser/tree.d.ts +2 -2
  48. package/lib/parser/tree.js +40 -23
  49. package/lib/parser/tree.js.map +1 -1
  50. package/lib/utils/index.d.ts +1 -0
  51. package/lib/utils/index.js +7 -2
  52. package/lib/utils/index.js.map +1 -1
  53. package/package.json +16 -3
  54. package/tests/extract.test.ts +95 -104
  55. package/tests/getFiles.test.ts +114 -114
  56. package/tests/ignoreFunction.test.ts +102 -126
  57. package/tests/tree.test.ts +6 -7
  58. package/tsconfig.json +3 -3
  59. package/lib/cliArgs.d.ts +0 -4
  60. package/lib/cliArgs.js +0 -216
  61. package/lib/cliArgs.js.map +0 -1
  62. package/lib/consolidate.d.ts +0 -2
  63. package/lib/consolidate.js +0 -37
  64. package/lib/consolidate.js.map +0 -1
  65. package/lib/fs.d.ts +0 -2
  66. package/lib/fs.js +0 -69
  67. package/lib/fs.js.map +0 -1
  68. package/lib/glob.d.ts +0 -13
  69. package/lib/glob.js +0 -95
  70. package/lib/glob.js.map +0 -1
  71. package/lib/makePot.d.ts +0 -2
  72. package/lib/makePot.js +0 -83
  73. package/lib/makePot.js.map +0 -1
  74. package/lib/maps.d.ts +0 -122
  75. package/lib/maps.js +0 -73
  76. package/lib/maps.js.map +0 -1
  77. package/lib/parser/consolidate.d.ts +0 -2
  78. package/lib/parser/consolidate.js +0 -37
  79. package/lib/parser/consolidate.js.map +0 -1
  80. package/lib/parser/makePot.d.ts +0 -2
  81. package/lib/parser/makePot.js +0 -35
  82. package/lib/parser/makePot.js.map +0 -1
  83. package/lib/parser.d.ts +0 -6
  84. package/lib/parser.js +0 -110
  85. package/lib/parser.js.map +0 -1
  86. package/lib/tree.d.ts +0 -2
  87. package/lib/tree.js +0 -78
  88. package/lib/tree.js.map +0 -1
  89. package/lib/utils.d.ts +0 -8
  90. package/lib/utils.js +0 -78
  91. package/lib/utils.js.map +0 -1
  92. package/tests/consolidate.test.ts +0 -77
  93. package/tests/getStrings.test.ts +0 -85
  94. /package/{LICENSE.md → LICENSE} +0 -0
  95. /package/tests/{jsonParse.test.ts → jsonParse.ts} +0 -0
@@ -1,77 +0,0 @@
1
- import { describe, expect } from '@jest/globals'
2
- import { consolidate } from '../src/parser/consolidate'
3
- import { GetTextComment } from 'gettext-parser'
4
-
5
- describe('consolidate', () => {
6
- it('should consolidate strings with translator comments', () => {
7
- const translationStrings = {
8
- '': {
9
- '': {
10
- msgid: '',
11
- msgstr: [
12
- 'Content-Type: text/plain; charset=iso-8859-1\n...',
13
- ],
14
- },
15
- },
16
- '': {
17
- a: {
18
- msgid: '',
19
- msgstr: ['a'],
20
- },
21
- },
22
- 'another context': {
23
- '%s example': {
24
- msgctxt: 'another context',
25
- msgid: '%s example',
26
- msgid_plural: '%s examples',
27
- msgstr: ['% näide', '%s näidet'],
28
- comments: {
29
- translator: 'This is a regular comment',
30
- reference: '/path/to/file:123',
31
- } as GetTextComment,
32
- },
33
- },
34
- }
35
- const translationStrings2 = {
36
- '': {
37
- '': {
38
- msgid: '',
39
- msgstr: [
40
- 'Content-Type: text/plain; charset=iso-8859-1\n...',
41
- ],
42
- },
43
- },
44
- }
45
- // eslint-disable-next-line
46
- const expected = {
47
- '': {
48
- '': {
49
- msgid: '',
50
- msgstr: [
51
- 'Content-Type: text/plain; charset=iso-8859-1\n...',
52
- ],
53
- },
54
- a: {
55
- msgid: 'a',
56
- msgstr: ['a'],
57
- },
58
- },
59
- 'another context': {
60
- '%s example': {
61
- comments: {
62
- reference: '/path/to/file:123',
63
- translator: 'This is a regular comment',
64
- },
65
- msgctxt: 'another context',
66
- msgid: '%s example',
67
- msgid_plural: '%s examples',
68
- msgstr: ['% näide', '%s näidet'],
69
- },
70
- },
71
- }
72
-
73
- const result = consolidate([translationStrings, translationStrings2])
74
-
75
- expect(result).toMatchObject(expected)
76
- })
77
- })
@@ -1,85 +0,0 @@
1
- import { describe, expect } from '@jest/globals'
2
- import { Args, DomainType } from '../src/types'
3
- import { getFiles } from '../src/fs/glob'
4
- import { getStrings } from '../src/parser/process'
5
-
6
- const args: Args = {
7
- slug: 'plugin-slug',
8
- paths: { cwd: 'tests/fixtures/sourcedir/', out: 'tests/fixtures/' },
9
- domain: 'plugin' as DomainType,
10
- patterns: {
11
- include: ['**'],
12
- exclude: [
13
- 'node_modules',
14
- 'vendor',
15
- 'dist',
16
- 'tests',
17
- 'package-lock.json',
18
- ],
19
- },
20
- }
21
-
22
- describe('getStrings', () => {
23
- it('Should build pot file', async () => {
24
- const files = await getFiles(args as Args, {
25
- include: ['file.php'],
26
- exclude: ['node_modules', 'dist'],
27
- })
28
- const dataExtracted = await getStrings({ ...args } as Args, files)
29
-
30
- expect(dataExtracted).toMatchSnapshot()
31
- })
32
- })
33
-
34
- describe('getFiles', () => {
35
- it('Should build pot file from fixtures block.json', async () => {
36
- const currentArgs = {
37
- ...args,
38
- paths: { cwd: 'tests/fixtures/block/', out: 'tests/fixtures/' },
39
- patterns: {
40
- include: ['block.json'],
41
- exclude: ['node_modules'],
42
- },
43
- } as Args
44
- const files = await getFiles(currentArgs as Args, currentArgs.patterns)
45
- const dataExtracted = await getStrings(currentArgs as Args, files)
46
-
47
- const expected = [
48
- {
49
- '': {
50
- description: {
51
- comments: {
52
- extracted: 'description',
53
- reference: 'tests\\fixtures\\block\\block.json',
54
- },
55
- msgctxt: undefined,
56
- msgid: 'description',
57
- msgid_plural: '',
58
- msgstr: [],
59
- },
60
- keywords: {
61
- comments: {
62
- extracted: 'keywords',
63
- reference: 'tests\\fixtures\\block\\block.json',
64
- },
65
- msgctxt: undefined,
66
- msgid: 'keywords',
67
- msgid_plural: '',
68
- msgstr: [],
69
- },
70
- title: {
71
- comments: {
72
- extracted: 'title',
73
- reference: 'tests\\fixtures\\block\\block.json',
74
- },
75
- msgctxt: undefined,
76
- msgid: 'title',
77
- msgid_plural: '',
78
- msgstr: [],
79
- },
80
- },
81
- },
82
- ]
83
- expect(dataExtracted).toMatchObject(expected)
84
- })
85
- })
File without changes
File without changes