@wp-blocks/make-pot 0.0.1 → 0.0.3
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/LICENSE.md +674 -0
- package/README.md +7 -0
- package/lib/cliArgs.js +10 -9
- package/lib/cliArgs.js.map +1 -1
- package/lib/consolidate.js +1 -1
- package/lib/consolidate.js.map +1 -1
- package/lib/extractors-php.js +2 -1
- package/lib/extractors-php.js.map +1 -1
- package/lib/extractors-text.js +2 -1
- package/lib/extractors-text.js.map +1 -1
- package/lib/extractors.js +30 -21
- package/lib/extractors.js.map +1 -1
- package/lib/fs.js +15 -4
- package/lib/fs.js.map +1 -1
- package/lib/glob.js +22 -10
- package/lib/glob.js.map +1 -1
- package/lib/makePot.js +55 -40
- package/lib/makePot.js.map +1 -1
- package/lib/parser.js +73 -57
- package/lib/parser.js.map +1 -1
- package/lib/tree.js +10 -10
- package/lib/tree.js.map +1 -1
- package/lib/utils.js +4 -3
- package/lib/utils.js.map +1 -1
- package/package.json +4 -4
- package/tests/extract.test.ts +23 -0
- package/tests/getStrings.test.ts +2 -75
- package/tests/ingnoreFunction.test.ts +18 -67
- package/tests/utils.test.ts +3 -3
- package/tsconfig.json +3 -6
- package/.github/workflows/node.js.yml +0 -33
package/lib/parser.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parser.js","sourceRoot":"","sources":["../src/parser.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"parser.js","sourceRoot":"","sources":["../src/parser.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,gEAA0D;AAC1D,6CAAwC;AACxC,mCAAsC;AAEtC,iCAAiC;AACjC,+CAA2C;AAU3C,SAAS,YAAY,CAAC,IAAU,EAAE,UAAkB;;IACnD,IAAI,MAAA,IAAI,CAAC,OAAO,0CAAE,MAAM;QAAE,OAAO,IAAI,CAAA;IAErC,MAAM,WAAW,GAAG,IAAI,sBAAW,CAAC,SAA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b,IACC,CAAA,MAAA,IAAI,CAAC,OAAO,0CAAE,IAAI,CAAC,GAAG,MAAK,SAAS;YACpC,CAAA,MAAA,IAAI,CAAC,OAAO,0CAAE,IAAI,CAAC,KAAK,MAAK,SAAS,EACrC,CAAC;YACF,IAAI,CAAA,MAAA,IAAI,CAAC,OAAO,0CAAE,IAAI,CAAC,KAAK,MAAK,SAAS,EAAE,CAAC;gBAE5C,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;YACjC,CAAC;iBAAM,CAAC;gBACP,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,EAAE,eAAe,CAAC,CAAA;YAClD,CAAC;QACF,CAAC;QAGD,IAAI,CAAA,MAAA,IAAI,CAAC,OAAO,0CAAE,IAAI,CAAC,EAAE,MAAK,SAAS,EAAE,CAAC;YACzC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAA;QACrD,CAAC;QAED,IAAI,CAAA,MAAA,IAAI,CAAC,OAAO,0CAAE,IAAI,CAAC,SAAS,MAAK,SAAS,EAAE,CAAC;YAChD,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC,CAAA;QACnC,CAAC;QAED,IAAI,CAAA,MAAA,IAAI,CAAC,OAAO,0CAAE,IAAI,CAAC,SAAS,MAAK,SAAS,EAAE,CAAC;YAChD,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC,CAAA;QACnC,CAAC;QAED,MAAM,KAAK,GAAG,MAAM,IAAA,eAAQ,EAAC,IAAI,EAAE,OAAO,CAAC,CAAA;QAC3C,OAAO,MAAM,UAAU,CAAC,IAAI,EAAE,KAAK,CAAC,CAAA;;CACpC;AAtCD,gCAsCC"}
|
package/lib/tree.js
CHANGED
|
@@ -9,31 +9,34 @@ const const_1 = require("./const");
|
|
|
9
9
|
const utils_1 = require("./utils");
|
|
10
10
|
const glob_1 = require("./glob");
|
|
11
11
|
function collectComments(node, typeToMatch) {
|
|
12
|
+
var _a;
|
|
12
13
|
let currentNode = node;
|
|
13
14
|
let depth = 0;
|
|
14
15
|
while (currentNode && depth < 10) {
|
|
15
|
-
if (currentNode
|
|
16
|
-
return (0, utils_1.stripTranslationMarkup)(currentNode
|
|
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);
|
|
17
18
|
}
|
|
18
19
|
depth++;
|
|
19
20
|
currentNode = currentNode.parent;
|
|
20
21
|
}
|
|
21
22
|
}
|
|
22
23
|
function doTree(sourceCode, filepath) {
|
|
24
|
+
var _a;
|
|
23
25
|
const parser = new tree_sitter_1.default();
|
|
24
26
|
parser.setLanguage((0, glob_1.getParser)(filepath));
|
|
25
27
|
const tree = parser.parse(sourceCode);
|
|
26
28
|
const gettextTranslations = {};
|
|
27
|
-
const typeToMatch = filepath.split('.').pop()
|
|
29
|
+
const typeToMatch = ((_a = filepath.split('.').pop()) === null || _a === void 0 ? void 0 : _a.toLowerCase()) !== 'php'
|
|
28
30
|
? 'call_expression'
|
|
29
31
|
: 'function_call_expression';
|
|
30
32
|
function traverse(node) {
|
|
31
|
-
|
|
33
|
+
var _a, _b, _c, _d;
|
|
34
|
+
if (node === null || node === void 0 ? void 0 : node.children.length)
|
|
32
35
|
for (const child of node.children) {
|
|
33
36
|
traverse(child);
|
|
34
37
|
}
|
|
35
|
-
if (node
|
|
36
|
-
const functionName = node.firstChild
|
|
38
|
+
if ((node === null || node === void 0 ? void 0 : node.type) === typeToMatch) {
|
|
39
|
+
const functionName = (_b = (_a = node.firstChild) === null || _a === void 0 ? void 0 : _a.text) !== null && _b !== void 0 ? _b : null;
|
|
37
40
|
if (functionName === null ||
|
|
38
41
|
!Object.keys(const_1.i18nFunctions).includes(functionName)) {
|
|
39
42
|
return;
|
|
@@ -64,10 +67,7 @@ function doTree(sourceCode, filepath) {
|
|
|
64
67
|
flag: '',
|
|
65
68
|
},
|
|
66
69
|
};
|
|
67
|
-
gettextTranslations[gettext.msgctxt
|
|
68
|
-
...(gettextTranslations[gettext.msgctxt ?? ''] || {}),
|
|
69
|
-
[gettext.msgid]: gettext,
|
|
70
|
-
};
|
|
70
|
+
gettextTranslations[(_c = gettext.msgctxt) !== null && _c !== void 0 ? _c : ''] = Object.assign(Object.assign({}, (gettextTranslations[(_d = gettext.msgctxt) !== null && _d !== void 0 ? _d : ''] || {})), { [gettext.msgid]: gettext });
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
73
|
traverse(tree.rootNode);
|
package/lib/tree.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tree.js","sourceRoot":"","sources":["../src/tree.ts"],"names":[],"mappings":";;;;;;AAAA,8DAAqD;AAErD,mCAAuC;AAEvC,mCAAgD;AAEhD,iCAAkC;AASlC,SAAS,eAAe,CACvB,IAAgB,EAChB,WAAmB
|
|
1
|
+
{"version":3,"file":"tree.js","sourceRoot":"","sources":["../src/tree.ts"],"names":[],"mappings":";;;;;;AAAA,8DAAqD;AAErD,mCAAuC;AAEvC,mCAAgD;AAEhD,iCAAkC;AASlC,SAAS,eAAe,CACvB,IAAgB,EAChB,WAAmB;;IAEnB,IAAI,WAAW,GAAG,IAAI,CAAA;IACtB,IAAI,KAAK,GAAG,CAAC,CAAA;IAGb,OAAO,WAAW,IAAI,KAAK,GAAG,EAAE,EAAE,CAAC;QAClC,IAAI,CAAA,MAAA,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,eAAe,0CAAE,IAAI,MAAK,SAAS,EAAE,CAAC;YACtD,OAAO,IAAA,8BAAsB,EAAC,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,eAAe,CAAC,IAAI,CAAC,CAAA;QACjE,CAAC;QACD,KAAK,EAAE,CAAA;QACP,WAAW,GAAG,WAAW,CAAC,MAA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AvFD,wBAuFC"}
|
package/lib/utils.js
CHANGED
|
@@ -6,10 +6,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.includeFunction = exports.detectPatternType = exports.stringstring = exports.stripTranslationMarkup = exports.removeCommentMarkup = exports.getCommentBlock = exports.generateHeaderComments = void 0;
|
|
7
7
|
const path_1 = __importDefault(require("path"));
|
|
8
8
|
function generateHeaderComments(args) {
|
|
9
|
+
var _a, _b, _c, _d, _e, _f;
|
|
9
10
|
const { author, email, license } = {
|
|
10
|
-
author: args.headers
|
|
11
|
-
email: args.headers
|
|
12
|
-
license: args.headers
|
|
11
|
+
author: (_b = (_a = args.headers) === null || _a === void 0 ? void 0 : _a.author) !== null && _b !== void 0 ? _b : 'AUTHOR',
|
|
12
|
+
email: (_d = (_c = args.headers) === null || _c === void 0 ? void 0 : _c.email) !== null && _d !== void 0 ? _d : 'EMAIL',
|
|
13
|
+
license: (_f = (_e = args.headers) === null || _e === void 0 ? void 0 : _e.license) !== null && _f !== void 0 ? _f : 'gpl-2.0 or later',
|
|
13
14
|
};
|
|
14
15
|
return `# Copyright (C) ${new Date().getFullYear()} ${author} (${email})
|
|
15
16
|
# This file is distributed under the ${license}.`;
|
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
|
|
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,O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CAAC,QAAQ,CAAC,GAAG,CAAC,CAAA;IACnD,MAAM,0BAA0B,GAC/B,OAAO,CAAC,QAAQ,CAAC,cAAI,CAAC,GAAG,CAAC,IAAI,OAAO,CAAC,QAAQ,CAAC,cAAI,CAAC,GAAG,CAAC,CAAA;IAEzD,IAAI,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;QAC3B,OAAO,MAAM,CAAA;IACd,CAAC;SAAM,IAAI,CAAC,qBAAqB,IAAI,CAAC,0BAA0B,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.
|
|
3
|
+
"version": "0.0.3",
|
|
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
|
"scripts": {
|
|
@@ -8,12 +8,12 @@
|
|
|
8
8
|
"watch": "tsc --watch",
|
|
9
9
|
"clean": "tsc --build --clean",
|
|
10
10
|
"lint": "eslint ./src ./tests --fix",
|
|
11
|
-
"test": "jest
|
|
12
|
-
"update-
|
|
11
|
+
"test": "jest",
|
|
12
|
+
"update-snapshots": "jest -u",
|
|
13
13
|
"run": "node ./lib/index.js"
|
|
14
14
|
},
|
|
15
15
|
"bin": {
|
|
16
|
-
"make-pot": "lib/index.js
|
|
16
|
+
"make-pot": "lib/index.js"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"cli-progress": "^3.12.0",
|
package/tests/extract.test.ts
CHANGED
|
@@ -12,6 +12,10 @@ describe('getStrings', () => {
|
|
|
12
12
|
'': {
|
|
13
13
|
'Hello World': {
|
|
14
14
|
comments: {
|
|
15
|
+
comment: '',
|
|
16
|
+
extracted: '',
|
|
17
|
+
flag: '',
|
|
18
|
+
previous: '',
|
|
15
19
|
reference: 'filename.php:1',
|
|
16
20
|
},
|
|
17
21
|
msgid: 'Hello World',
|
|
@@ -26,6 +30,10 @@ describe('getStrings', () => {
|
|
|
26
30
|
'': {
|
|
27
31
|
'Hello World': {
|
|
28
32
|
comments: {
|
|
33
|
+
comment: '',
|
|
34
|
+
extracted: '',
|
|
35
|
+
flag: '',
|
|
36
|
+
previous: '',
|
|
29
37
|
reference: 'filename.php:1',
|
|
30
38
|
},
|
|
31
39
|
msgid: 'Hello World',
|
|
@@ -48,10 +56,15 @@ describe('getStrings', () => {
|
|
|
48
56
|
'': {
|
|
49
57
|
'Hello World': {
|
|
50
58
|
comments: {
|
|
59
|
+
comment: '',
|
|
60
|
+
extracted: '',
|
|
61
|
+
flag: '',
|
|
62
|
+
previous: '',
|
|
51
63
|
reference: 'filename.php:2',
|
|
52
64
|
translator: 'ciao!',
|
|
53
65
|
},
|
|
54
66
|
msgid: 'Hello World',
|
|
67
|
+
msgid_plural: 'greeting',
|
|
55
68
|
msgstr: [],
|
|
56
69
|
},
|
|
57
70
|
},
|
|
@@ -78,9 +91,14 @@ describe('getStrings', () => {
|
|
|
78
91
|
'': {
|
|
79
92
|
'Hello World': {
|
|
80
93
|
comments: {
|
|
94
|
+
comment: '',
|
|
95
|
+
extracted: '',
|
|
96
|
+
flag: '',
|
|
97
|
+
previous: '',
|
|
81
98
|
reference: 'filename.php:10',
|
|
82
99
|
},
|
|
83
100
|
msgid: 'Hello World',
|
|
101
|
+
msgid_plural: 'greeting',
|
|
84
102
|
msgstr: [],
|
|
85
103
|
},
|
|
86
104
|
},
|
|
@@ -102,9 +120,14 @@ echo $link;`
|
|
|
102
120
|
'Check out this link to my <a href="%s">website</a> made with WordPress.':
|
|
103
121
|
{
|
|
104
122
|
comments: {
|
|
123
|
+
comment: '',
|
|
124
|
+
extracted: '',
|
|
125
|
+
flag: '',
|
|
126
|
+
previous: '',
|
|
105
127
|
reference: 'filename.php:3',
|
|
106
128
|
},
|
|
107
129
|
msgid: 'Check out this link to my <a href="%s">website</a> made with WordPress.',
|
|
130
|
+
msgid_plural: 'my-text-domain',
|
|
108
131
|
msgstr: [],
|
|
109
132
|
},
|
|
110
133
|
},
|
package/tests/getStrings.test.ts
CHANGED
|
@@ -26,81 +26,8 @@ describe('getStrings', () => {
|
|
|
26
26
|
exclude: ['node_modules', 'dist'],
|
|
27
27
|
})
|
|
28
28
|
const dataExtracted = await getStrings({ ...args } as Args, files)
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
sdasdasdasd: {
|
|
32
|
-
msgid: 'sdasdasdasd',
|
|
33
|
-
msgid_plural: undefined,
|
|
34
|
-
msgstr: [],
|
|
35
|
-
},
|
|
36
|
-
'strong magenta': {
|
|
37
|
-
msgid: 'strong magenta',
|
|
38
|
-
msgid_plural: undefined,
|
|
39
|
-
msgstr: [],
|
|
40
|
-
},
|
|
41
|
-
'light grayish magenta': {
|
|
42
|
-
msgid: 'light grayish magenta',
|
|
43
|
-
msgid_plural: undefined,
|
|
44
|
-
msgstr: [],
|
|
45
|
-
},
|
|
46
|
-
'very light gray': {
|
|
47
|
-
msgid: 'very light gray',
|
|
48
|
-
msgid_plural: undefined,
|
|
49
|
-
msgstr: [],
|
|
50
|
-
},
|
|
51
|
-
'very dark gray': {
|
|
52
|
-
msgid: 'very dark gray',
|
|
53
|
-
msgid_plural: undefined,
|
|
54
|
-
msgstr: [],
|
|
55
|
-
},
|
|
56
|
-
'Vivid cyan blue to vivid purple': {
|
|
57
|
-
msgid: 'Vivid cyan blue to vivid purple',
|
|
58
|
-
msgid_plural: undefined,
|
|
59
|
-
msgstr: [],
|
|
60
|
-
},
|
|
61
|
-
'Vivid green cyan to vivid cyan blue': {
|
|
62
|
-
msgid: 'Vivid green cyan to vivid cyan blue',
|
|
63
|
-
msgid_plural: undefined,
|
|
64
|
-
msgstr: [],
|
|
65
|
-
},
|
|
66
|
-
'Light green cyan to vivid green cyan': {
|
|
67
|
-
msgid: 'Light green cyan to vivid green cyan',
|
|
68
|
-
msgid_plural: undefined,
|
|
69
|
-
msgstr: [],
|
|
70
|
-
},
|
|
71
|
-
'Luminous vivid amber to luminous vivid orange': {
|
|
72
|
-
msgid: 'Luminous vivid amber to luminous vivid orange',
|
|
73
|
-
msgid_plural: undefined,
|
|
74
|
-
msgstr: [],
|
|
75
|
-
},
|
|
76
|
-
'Luminous vivid orange to vivid red': {
|
|
77
|
-
msgid: 'Luminous vivid orange to vivid red',
|
|
78
|
-
msgid_plural: undefined,
|
|
79
|
-
msgstr: [],
|
|
80
|
-
},
|
|
81
|
-
Small: {
|
|
82
|
-
msgid: 'Small',
|
|
83
|
-
msgid_plural: undefined,
|
|
84
|
-
msgstr: [],
|
|
85
|
-
},
|
|
86
|
-
Regular: {
|
|
87
|
-
msgid: 'Regular',
|
|
88
|
-
msgid_plural: undefined,
|
|
89
|
-
msgstr: [],
|
|
90
|
-
},
|
|
91
|
-
Large: {
|
|
92
|
-
msgid: 'Large',
|
|
93
|
-
msgid_plural: undefined,
|
|
94
|
-
msgstr: [],
|
|
95
|
-
},
|
|
96
|
-
Huge: {
|
|
97
|
-
msgid: 'Huge',
|
|
98
|
-
msgid_plural: undefined,
|
|
99
|
-
msgstr: [],
|
|
100
|
-
},
|
|
101
|
-
},
|
|
102
|
-
}
|
|
103
|
-
expect(dataExtracted).toMatchObject(expected)
|
|
29
|
+
|
|
30
|
+
expect(dataExtracted).toMatchSnapshot()
|
|
104
31
|
})
|
|
105
32
|
it('Should build pot file from fixtures block.json', async () => {
|
|
106
33
|
const currentArgs = {
|
|
@@ -7,15 +7,7 @@ import { minimatch } from 'minimatch'
|
|
|
7
7
|
const sep = path.sep
|
|
8
8
|
|
|
9
9
|
describe('includes or not', () => {
|
|
10
|
-
it('
|
|
11
|
-
expect(
|
|
12
|
-
path.normalize(
|
|
13
|
-
path.relative(
|
|
14
|
-
'D:\\vvv-local\\www\\phpeighttwo\\public_html\\wp-content\\plugins\\makePot\\tests\\fixtures',
|
|
15
|
-
'fixtures'
|
|
16
|
-
)
|
|
17
|
-
)
|
|
18
|
-
).toBe(path.normalize('..\\..\\fixtures'))
|
|
10
|
+
it('paths includes', () => {
|
|
19
11
|
expect(
|
|
20
12
|
path
|
|
21
13
|
.normalize(
|
|
@@ -24,7 +16,15 @@ describe('includes or not', () => {
|
|
|
24
16
|
.includes('tests')
|
|
25
17
|
).toBe(true)
|
|
26
18
|
expect(
|
|
27
|
-
|
|
19
|
+
path.normalize(
|
|
20
|
+
path.relative(
|
|
21
|
+
'D:\\vvv-local\\www\\phpeighttwo\\public_html\\wp-content\\plugins\\makePot\\tests\\fixtures',
|
|
22
|
+
'tests'
|
|
23
|
+
)
|
|
24
|
+
)
|
|
25
|
+
).toBe('../tests')
|
|
26
|
+
expect(
|
|
27
|
+
minimatch(path.normalize('block/SvgControls.tsx'), 'block/**')
|
|
28
28
|
).toBe(true)
|
|
29
29
|
})
|
|
30
30
|
})
|
|
@@ -52,42 +52,7 @@ const tests = [
|
|
|
52
52
|
'**/lib/c**.d.ts',
|
|
53
53
|
'**/**tt**',
|
|
54
54
|
],
|
|
55
|
-
result:
|
|
56
|
-
'tsconfig.json',
|
|
57
|
-
'package.json',
|
|
58
|
-
'package-lock.json',
|
|
59
|
-
'jest.config.json',
|
|
60
|
-
'src\\utils.ts',
|
|
61
|
-
'src\\types.ts',
|
|
62
|
-
'src\\tree.ts',
|
|
63
|
-
'src\\parser.ts',
|
|
64
|
-
'src\\makePot.ts',
|
|
65
|
-
'src\\index.ts',
|
|
66
|
-
'src\\glob.ts',
|
|
67
|
-
'src\\fs.ts',
|
|
68
|
-
'src\\const.ts',
|
|
69
|
-
'src\\consolidate.ts',
|
|
70
|
-
'src\\cliArgs.ts',
|
|
71
|
-
'lib\\utils.js',
|
|
72
|
-
'lib\\utils.d.ts',
|
|
73
|
-
'lib\\types.js',
|
|
74
|
-
'lib\\types.d.ts',
|
|
75
|
-
'lib\\tree.js',
|
|
76
|
-
'lib\\tree.d.ts',
|
|
77
|
-
'lib\\parser.js',
|
|
78
|
-
'lib\\parser.d.ts',
|
|
79
|
-
'lib\\makePot.js',
|
|
80
|
-
'lib\\makePot.d.ts',
|
|
81
|
-
'lib\\index.js',
|
|
82
|
-
'lib\\index.d.ts',
|
|
83
|
-
'lib\\glob.js',
|
|
84
|
-
'lib\\glob.d.ts',
|
|
85
|
-
'lib\\fs.js',
|
|
86
|
-
'lib\\fs.d.ts',
|
|
87
|
-
'lib\\const.js',
|
|
88
|
-
'lib\\consolidate.js',
|
|
89
|
-
'lib\\cliArgs.js',
|
|
90
|
-
],
|
|
55
|
+
result: 20,
|
|
91
56
|
},
|
|
92
57
|
{
|
|
93
58
|
title: 'exclude file.php',
|
|
@@ -100,7 +65,7 @@ const tests = [
|
|
|
100
65
|
'package.json',
|
|
101
66
|
'file2.txt',
|
|
102
67
|
'vendor' + path.sep + 'index.php',
|
|
103
|
-
'node_modules
|
|
68
|
+
'node_modules' + path.sep + 'module' + path.sep + 'block.json',
|
|
104
69
|
],
|
|
105
70
|
},
|
|
106
71
|
{
|
|
@@ -120,25 +85,7 @@ const tests = [
|
|
|
120
85
|
title: 'globstar path',
|
|
121
86
|
src: 'tests/fixtures',
|
|
122
87
|
exclude: ['**/*.php', '**/*.json', 'block/**'],
|
|
123
|
-
result:
|
|
124
|
-
'file1.txt',
|
|
125
|
-
'theme\\style.css',
|
|
126
|
-
'sourcedir\\svgTools.ts',
|
|
127
|
-
'sourcedir\\file2.txt',
|
|
128
|
-
'fse\\style.css',
|
|
129
|
-
'child-theme\\style.css',
|
|
130
|
-
'Block Patterns\\README.md',
|
|
131
|
-
'Block Patterns\\mother.jpg',
|
|
132
|
-
'Block Patterns\\flora.png',
|
|
133
|
-
'Block Patterns\\clothes.jpg',
|
|
134
|
-
'fse\\templates\\single.html',
|
|
135
|
-
'fse\\templates\\search.html',
|
|
136
|
-
'fse\\templates\\page.html',
|
|
137
|
-
'fse\\templates\\index.html',
|
|
138
|
-
'fse\\templates\\archive.html',
|
|
139
|
-
'fse\\parts\\header.html',
|
|
140
|
-
'fse\\parts\\footer.html',
|
|
141
|
-
],
|
|
88
|
+
result: 15,
|
|
142
89
|
},
|
|
143
90
|
{
|
|
144
91
|
title: 'should exclude globstar',
|
|
@@ -171,7 +118,11 @@ describe('testing the ignoreFunc used to ignore files', () => {
|
|
|
171
118
|
foundDirs.push(dir)
|
|
172
119
|
}
|
|
173
120
|
|
|
174
|
-
|
|
121
|
+
if (typeof test.result === 'number') {
|
|
122
|
+
expect(foundDirs.length).toBeGreaterThanOrEqual(test.result)
|
|
123
|
+
} else {
|
|
124
|
+
expect(foundDirs).toStrictEqual(test.result)
|
|
125
|
+
}
|
|
175
126
|
})
|
|
176
127
|
})
|
|
177
128
|
})
|
package/tests/utils.test.ts
CHANGED
|
@@ -10,8 +10,8 @@ describe('detectPatternType', () => {
|
|
|
10
10
|
expect(detectPatternType('example')).toBe('directory')
|
|
11
11
|
})
|
|
12
12
|
|
|
13
|
-
test('should return "
|
|
14
|
-
expect(detectPatternType('example/')).toBe('
|
|
13
|
+
test('should return "glob" when pattern ends with a directory separator', () => {
|
|
14
|
+
expect(detectPatternType('example/')).toBe('glob')
|
|
15
15
|
})
|
|
16
16
|
|
|
17
17
|
test('should return "glob" when pattern contains an asterisk', () => {
|
|
@@ -19,7 +19,7 @@ describe('detectPatternType', () => {
|
|
|
19
19
|
})
|
|
20
20
|
|
|
21
21
|
test('should return "file" when pattern has directory separator and extension', () => {
|
|
22
|
-
expect(detectPatternType('folder/example.txt')).toBe('
|
|
22
|
+
expect(detectPatternType('folder/example.txt')).toBe('glob')
|
|
23
23
|
})
|
|
24
24
|
|
|
25
25
|
test('should return "glob" when pattern is a complex glob pattern', () => {
|
package/tsconfig.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"compilerOptions": {
|
|
3
|
-
"module": "
|
|
4
|
-
"target": "
|
|
5
|
-
"lib": [ "
|
|
3
|
+
"module": "commonjs",
|
|
4
|
+
"target": "ES2015",
|
|
5
|
+
"lib": [ "Es6" ],
|
|
6
6
|
"noImplicitAny": true,
|
|
7
7
|
"removeComments": true,
|
|
8
8
|
"preserveConstEnums": true,
|
|
@@ -28,8 +28,5 @@
|
|
|
28
28
|
},
|
|
29
29
|
"include": [
|
|
30
30
|
"./src/**/*"
|
|
31
|
-
],
|
|
32
|
-
"exclude": [
|
|
33
|
-
"lib",
|
|
34
31
|
]
|
|
35
32
|
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
|
|
2
|
-
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs
|
|
3
|
-
|
|
4
|
-
name: Node.js CI
|
|
5
|
-
|
|
6
|
-
on:
|
|
7
|
-
push:
|
|
8
|
-
branches: [ "master" ]
|
|
9
|
-
pull_request:
|
|
10
|
-
branches: [ "master" ]
|
|
11
|
-
|
|
12
|
-
jobs:
|
|
13
|
-
build:
|
|
14
|
-
|
|
15
|
-
runs-on: ${{ matrix.os }}
|
|
16
|
-
|
|
17
|
-
strategy:
|
|
18
|
-
matrix:
|
|
19
|
-
node-version: [lts/*, latest]
|
|
20
|
-
os: [ubuntu-latest, macos-latest, windows-latest]
|
|
21
|
-
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
|
|
22
|
-
|
|
23
|
-
steps:
|
|
24
|
-
- uses: actions/checkout@v3
|
|
25
|
-
- name: Use Node.js ${{ matrix.node-version }}
|
|
26
|
-
uses: actions/setup-node@v3
|
|
27
|
-
with:
|
|
28
|
-
node-version: ${{ matrix.node-version }}
|
|
29
|
-
cache: 'npm'
|
|
30
|
-
- run: npm install
|
|
31
|
-
- run: npm run build --if-present
|
|
32
|
-
- run: npm test
|
|
33
|
-
|