@docusaurus/utils 3.7.0-canary-6267 → 3.7.0-canary-6268
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/globUtils.d.ts +1 -0
- package/lib/globUtils.d.ts.map +1 -1
- package/lib/globUtils.js +15 -5
- package/lib/globUtils.js.map +1 -1
- package/package.json +5 -5
- package/src/globUtils.ts +18 -8
package/lib/globUtils.d.ts
CHANGED
|
@@ -39,5 +39,6 @@ export declare function createMatcher(patterns: string[]): Matcher;
|
|
|
39
39
|
*/
|
|
40
40
|
export declare function createAbsoluteFilePathMatcher(patterns: string[], rootFolders: string[]): Matcher;
|
|
41
41
|
export declare function safeGlobby(patterns: string[], options?: Globby.GlobbyOptions): Promise<string[]>;
|
|
42
|
+
export declare const isTranslatableSourceFile: (filePath: string) => boolean;
|
|
42
43
|
export declare function globTranslatableSourceFiles(patterns: string[]): Promise<string[]>;
|
|
43
44
|
//# sourceMappingURL=globUtils.d.ts.map
|
package/lib/globUtils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"globUtils.d.ts","sourceRoot":"","sources":["../src/globUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAOH,OAAO,MAAM,MAAM,QAAQ,CAAC;AAG5B,0CAA0C;AAC1C,OAAO,EAAC,MAAM,EAAC,CAAC;AAEhB;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,UAK9B,CAAC;AAEF,KAAK,OAAO,GAAG,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC;AAExC;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CASzD;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,6BAA6B,CAC3C,QAAQ,EAAE,MAAM,EAAE,EAClB,WAAW,EAAE,MAAM,EAAE,GACpB,OAAO,CAqBT;AAID,wBAAsB,UAAU,CAC9B,QAAQ,EAAE,MAAM,EAAE,EAClB,OAAO,CAAC,EAAE,MAAM,CAAC,aAAa,GAC7B,OAAO,CAAC,MAAM,EAAE,CAAC,CAQnB;
|
|
1
|
+
{"version":3,"file":"globUtils.d.ts","sourceRoot":"","sources":["../src/globUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAOH,OAAO,MAAM,MAAM,QAAQ,CAAC;AAG5B,0CAA0C;AAC1C,OAAO,EAAC,MAAM,EAAC,CAAC;AAEhB;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,UAK9B,CAAC;AAEF,KAAK,OAAO,GAAG,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC;AAExC;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CASzD;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,6BAA6B,CAC3C,QAAQ,EAAE,MAAM,EAAE,EAClB,WAAW,EAAE,MAAM,EAAE,GACpB,OAAO,CAqBT;AAID,wBAAsB,UAAU,CAC9B,QAAQ,EAAE,MAAM,EAAE,EAClB,OAAO,CAAC,EAAE,MAAM,CAAC,aAAa,GAC7B,OAAO,CAAC,MAAM,EAAE,CAAC,CAQnB;AAED,eAAO,MAAM,wBAAwB,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAsBzD,CAAC;AAGL,wBAAsB,2BAA2B,CAC/C,QAAQ,EAAE,MAAM,EAAE,GACjB,OAAO,CAAC,MAAM,EAAE,CAAC,CAGnB"}
|
package/lib/globUtils.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.GlobExcludeDefault = exports.Globby = void 0;
|
|
9
|
+
exports.isTranslatableSourceFile = exports.GlobExcludeDefault = exports.Globby = void 0;
|
|
10
10
|
exports.createMatcher = createMatcher;
|
|
11
11
|
exports.createAbsoluteFilePathMatcher = createAbsoluteFilePathMatcher;
|
|
12
12
|
exports.safeGlobby = safeGlobby;
|
|
@@ -79,9 +79,8 @@ async function safeGlobby(patterns, options) {
|
|
|
79
79
|
const globPaths = patterns.map((dirPath) => (0, pathUtils_1.posixPath)(path_1.default.relative(process.cwd(), dirPath)));
|
|
80
80
|
return (0, globby_1.default)(globPaths, options);
|
|
81
81
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
// We only support extracting source code translations from these kind of files
|
|
82
|
+
exports.isTranslatableSourceFile = (() => {
|
|
83
|
+
// We only support extracting source code translations from these extensions
|
|
85
84
|
const extensionsAllowed = new Set([
|
|
86
85
|
'.js',
|
|
87
86
|
'.jsx',
|
|
@@ -92,7 +91,18 @@ async function globTranslatableSourceFiles(patterns) {
|
|
|
92
91
|
// '.md',
|
|
93
92
|
// '.mdx',
|
|
94
93
|
]);
|
|
94
|
+
const isBlacklistedFilePath = (filePath) => {
|
|
95
|
+
// We usually extract from ts files, unless they are .d.ts files
|
|
96
|
+
return filePath.endsWith('.d.ts');
|
|
97
|
+
};
|
|
98
|
+
return (filePath) => {
|
|
99
|
+
const ext = path_1.default.extname(filePath);
|
|
100
|
+
return extensionsAllowed.has(ext) && !isBlacklistedFilePath(filePath);
|
|
101
|
+
};
|
|
102
|
+
})();
|
|
103
|
+
// A bit weird to put this here, but it's used by core + theme-translations
|
|
104
|
+
async function globTranslatableSourceFiles(patterns) {
|
|
95
105
|
const filePaths = await safeGlobby(patterns);
|
|
96
|
-
return filePaths.filter(
|
|
106
|
+
return filePaths.filter(exports.isTranslatableSourceFile);
|
|
97
107
|
}
|
|
98
108
|
//# sourceMappingURL=globUtils.js.map
|
package/lib/globUtils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"globUtils.js","sourceRoot":"","sources":["../src/globUtils.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAoCH,sCASC;AAeD,sEAwBC;AAID,gCAW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O,CAAC,QAAQ,CAAC,CAAC;QACnC,OAAO,iBAAiB,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,qBAAqB,CAAC,QAAQ,CAAC,CAAC;IACxE,CAAC,CAAC;AACJ,CAAC,CAAC,EAAE,CAAC;AAEL,2EAA2E;AACpE,KAAK,UAAU,2BAA2B,CAC/C,QAAkB;IAElB,MAAM,SAAS,GAAG,MAAM,UAAU,CAAC,QAAQ,CAAC,CAAC;IAC7C,OAAO,SAAS,CAAC,MAAM,CAAC,gCAAwB,CAAC,CAAC;AACpD,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docusaurus/utils",
|
|
3
|
-
"version": "3.7.0-canary-
|
|
3
|
+
"version": "3.7.0-canary-6268",
|
|
4
4
|
"description": "Node utility functions for Docusaurus packages.",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"types": "./lib/index.d.ts",
|
|
@@ -18,9 +18,9 @@
|
|
|
18
18
|
},
|
|
19
19
|
"license": "MIT",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@docusaurus/logger": "3.7.0-canary-
|
|
22
|
-
"@docusaurus/types": "3.7.0-canary-
|
|
23
|
-
"@docusaurus/utils-common": "3.7.0-canary-
|
|
21
|
+
"@docusaurus/logger": "3.7.0-canary-6268",
|
|
22
|
+
"@docusaurus/types": "3.7.0-canary-6268",
|
|
23
|
+
"@docusaurus/utils-common": "3.7.0-canary-6268",
|
|
24
24
|
"escape-string-regexp": "^4.0.0",
|
|
25
25
|
"execa": "5.1.1",
|
|
26
26
|
"file-loader": "^6.2.0",
|
|
@@ -50,5 +50,5 @@
|
|
|
50
50
|
"dedent": "^0.7.0",
|
|
51
51
|
"tmp-promise": "^3.0.3"
|
|
52
52
|
},
|
|
53
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "c89bf6ccb376f002475ce694c433fa7b5c7c1b89"
|
|
54
54
|
}
|
package/src/globUtils.ts
CHANGED
|
@@ -104,11 +104,8 @@ export async function safeGlobby(
|
|
|
104
104
|
return Globby(globPaths, options);
|
|
105
105
|
}
|
|
106
106
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
patterns: string[],
|
|
110
|
-
): Promise<string[]> {
|
|
111
|
-
// We only support extracting source code translations from these kind of files
|
|
107
|
+
export const isTranslatableSourceFile: (filePath: string) => boolean = (() => {
|
|
108
|
+
// We only support extracting source code translations from these extensions
|
|
112
109
|
const extensionsAllowed = new Set([
|
|
113
110
|
'.js',
|
|
114
111
|
'.jsx',
|
|
@@ -120,8 +117,21 @@ export async function globTranslatableSourceFiles(
|
|
|
120
117
|
// '.mdx',
|
|
121
118
|
]);
|
|
122
119
|
|
|
120
|
+
const isBlacklistedFilePath = (filePath: string) => {
|
|
121
|
+
// We usually extract from ts files, unless they are .d.ts files
|
|
122
|
+
return filePath.endsWith('.d.ts');
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
return (filePath): boolean => {
|
|
126
|
+
const ext = path.extname(filePath);
|
|
127
|
+
return extensionsAllowed.has(ext) && !isBlacklistedFilePath(filePath);
|
|
128
|
+
};
|
|
129
|
+
})();
|
|
130
|
+
|
|
131
|
+
// A bit weird to put this here, but it's used by core + theme-translations
|
|
132
|
+
export async function globTranslatableSourceFiles(
|
|
133
|
+
patterns: string[],
|
|
134
|
+
): Promise<string[]> {
|
|
123
135
|
const filePaths = await safeGlobby(patterns);
|
|
124
|
-
return filePaths.filter(
|
|
125
|
-
extensionsAllowed.has(path.extname(filePath)),
|
|
126
|
-
);
|
|
136
|
+
return filePaths.filter(isTranslatableSourceFile);
|
|
127
137
|
}
|