@docusaurus/utils 4.0.0-canary-6834 → 4.0.0-canary-6836
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/index.d.ts +0 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -8
- package/lib/index.js.map +1 -1
- package/package.json +5 -8
- package/src/index.ts +0 -8
- package/lib/globUtils.d.ts +0 -46
- package/lib/globUtils.d.ts.map +0 -1
- package/lib/globUtils.js +0 -113
- package/lib/globUtils.js.map +0 -1
- package/src/globUtils.ts +0 -143
package/lib/index.d.ts
CHANGED
|
@@ -17,7 +17,6 @@ export { type ContentPaths, type SourceToPermalink, resolveMarkdownLinkPathname,
|
|
|
17
17
|
export { type SluggerOptions, type Slugger, createSlugger } from './slugger';
|
|
18
18
|
export { isNameTooLong, shortName, posixPath, toMessageRelativeFilePath, aliasedSitePath, aliasedSitePathToRelativePath, escapePath, addTrailingPathSeparator, } from './pathUtils';
|
|
19
19
|
export { md5Hash, simpleHash, docuHash } from './hashUtils';
|
|
20
|
-
export { Globby, GlobExcludeDefault, safeGlobby, globTranslatableSourceFiles, createMatcher, createAbsoluteFilePathMatcher, } from './globUtils';
|
|
21
20
|
export { getFileLoaderUtils, getWebpackLoaderCompilerName, type WebpackCompilerName, } from './webpackUtils';
|
|
22
21
|
export { loadFreshModule } from './moduleUtils';
|
|
23
22
|
export { getDataFilePath, readDataFile, getContentPathList, findFolderContainingFile, getFolderContainingFile, } from './dataFileUtils';
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,sBAAsB,EACtB,wBAAwB,EACxB,sBAAsB,EACtB,wBAAwB,EACxB,YAAY,EACZ,uBAAuB,EACvB,6BAA6B,EAC7B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T,SAAS,EACT,yBAAyB,EACzB,eAAe,EACf,6BAA6B,EAC7B,UAAU,EACV,wBAAwB,GACzB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAC,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAC,MAAM,aAAa,CAAC;AAC1D,OAAO,EACL,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,sBAAsB,EACtB,wBAAwB,EACxB,sBAAsB,EACtB,wBAAwB,EACxB,YAAY,EACZ,uBAAuB,EACvB,6BAA6B,EAC7B,UAAU,EACV,qBAAqB,EACrB,2BAA2B,EAC3B,YAAY,EACZ,iBAAiB,EACjB,wBAAwB,GACzB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAC,QAAQ,EAAE,kBAAkB,EAAC,MAAM,aAAa,CAAC;AACzD,OAAO,EACL,iBAAiB,EACjB,6BAA6B,EAC7B,iBAAiB,EACjB,eAAe,GAChB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAC,kBAAkB,EAAE,mBAAmB,EAAC,MAAM,WAAW,CAAC;AAClE,OAAO,EACL,YAAY,EACZ,UAAU,EACV,UAAU,EACV,UAAU,EACV,eAAe,EACf,eAAe,EACf,YAAY,EACZ,iBAAiB,EACjB,cAAc,EACd,SAAS,EACT,gBAAgB,EAChB,cAAc,EACd,aAAa,EACb,WAAW,GACZ,MAAM,YAAY,CAAC;AACpB,YAAY,EAAC,OAAO,EAAC,MAAM,YAAY,CAAC;AACxC,OAAO,EACL,KAAK,GAAG,EACR,KAAK,QAAQ,EACb,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,SAAS,EACd,KAAK,cAAc,EACnB,KAAK,iBAAiB,EACtB,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,QAAQ,CAAC;AAChB,OAAO,EACL,m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,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.resolveMarkdownLinkPathname = exports.writeMarkdownHeadingId = exports.escapeMarkdownHeadingIds = exports.parseMarkdownHeadingId = exports.parseMarkdownFile = exports.parseMarkdownContentTitle = exports.DEFAULT_PARSE_FRONT_MATTER = exports.createExcerpt = exports.admonitionTitleToDirectiveLabel = exports.unwrapMdxCodeBlocks = exports.getTagVisibility = exports.groupTaggedItems = exports.buildSshUrl = exports.buildHttpsUrl = exports.hasSSHProtocol = exports.serializeURLPath = exports.toURLPath = exports.parseURLOrPath = exports.parseLocalURLPath = exports.parseURLPath = exports.resolvePathname = exports.isValidPathname = exports.encodePath = exports.fileToPath = exports.getEditUrl = exports.normalizeUrl = exports.findAsyncSequential = exports.mapAsyncSequential = exports.getLocaleConfig = exports.getPluginI18nPath = exports.updateTranslationFileMessages = exports.mergeTranslations = exports.readOutputHTMLFile = exports.generate = exports.WEBPACK_URL_LOADER_LIMIT = exports.DEFAULT_PLUGIN_ID = exports.DEFAULT_PORT = exports.CODE_TRANSLATIONS_FILE_NAME = exports.DEFAULT_I18N_DIR_NAME = exports.THEME_PATH = exports.OUTPUT_STATIC_ASSETS_DIR_NAME = exports.DEFAULT_STATIC_DIR_NAME = exports.SRC_DIR_NAME = exports.GENERATED_FILES_DIR_NAME = exports.BABEL_CONFIG_FILE_NAME = exports.DEFAULT_CONFIG_FILE_NAME = exports.DEFAULT_BUILD_DIR_NAME = exports.DOCUSAURUS_VERSION = exports.NODE_MINOR_VERSION = exports.NODE_MAJOR_VERSION = void 0;
|
|
10
|
-
exports.reportInlineTags = exports.normalizeTags = exports.TEST_VCS = exports.getVcsPreset = exports.VcsPresetNames = exports.readLastUpdateData = exports.flattenRoutes = exports.isUnlisted = exports.isDraft = exports.getFolderContainingFile = exports.findFolderContainingFile = exports.getContentPathList = exports.readDataFile = exports.getDataFilePath = exports.loadFreshModule = exports.getWebpackLoaderCompilerName = exports.getFileLoaderUtils = exports.
|
|
10
|
+
exports.reportInlineTags = exports.normalizeTags = exports.TEST_VCS = exports.getVcsPreset = exports.VcsPresetNames = exports.readLastUpdateData = exports.flattenRoutes = exports.isUnlisted = exports.isDraft = exports.getFolderContainingFile = exports.findFolderContainingFile = exports.getContentPathList = exports.readDataFile = exports.getDataFilePath = exports.loadFreshModule = exports.getWebpackLoaderCompilerName = exports.getFileLoaderUtils = exports.docuHash = exports.simpleHash = exports.md5Hash = exports.addTrailingPathSeparator = exports.escapePath = exports.aliasedSitePathToRelativePath = exports.aliasedSitePath = exports.toMessageRelativeFilePath = exports.posixPath = exports.shortName = exports.isNameTooLong = exports.createSlugger = void 0;
|
|
11
11
|
var constants_1 = require("./constants");
|
|
12
12
|
Object.defineProperty(exports, "NODE_MAJOR_VERSION", { enumerable: true, get: function () { return constants_1.NODE_MAJOR_VERSION; } });
|
|
13
13
|
Object.defineProperty(exports, "NODE_MINOR_VERSION", { enumerable: true, get: function () { return constants_1.NODE_MINOR_VERSION; } });
|
|
@@ -82,13 +82,6 @@ var hashUtils_1 = require("./hashUtils");
|
|
|
82
82
|
Object.defineProperty(exports, "md5Hash", { enumerable: true, get: function () { return hashUtils_1.md5Hash; } });
|
|
83
83
|
Object.defineProperty(exports, "simpleHash", { enumerable: true, get: function () { return hashUtils_1.simpleHash; } });
|
|
84
84
|
Object.defineProperty(exports, "docuHash", { enumerable: true, get: function () { return hashUtils_1.docuHash; } });
|
|
85
|
-
var globUtils_1 = require("./globUtils");
|
|
86
|
-
Object.defineProperty(exports, "Globby", { enumerable: true, get: function () { return globUtils_1.Globby; } });
|
|
87
|
-
Object.defineProperty(exports, "GlobExcludeDefault", { enumerable: true, get: function () { return globUtils_1.GlobExcludeDefault; } });
|
|
88
|
-
Object.defineProperty(exports, "safeGlobby", { enumerable: true, get: function () { return globUtils_1.safeGlobby; } });
|
|
89
|
-
Object.defineProperty(exports, "globTranslatableSourceFiles", { enumerable: true, get: function () { return globUtils_1.globTranslatableSourceFiles; } });
|
|
90
|
-
Object.defineProperty(exports, "createMatcher", { enumerable: true, get: function () { return globUtils_1.createMatcher; } });
|
|
91
|
-
Object.defineProperty(exports, "createAbsoluteFilePathMatcher", { enumerable: true, get: function () { return globUtils_1.createAbsoluteFilePathMatcher; } });
|
|
92
85
|
var webpackUtils_1 = require("./webpackUtils");
|
|
93
86
|
Object.defineProperty(exports, "getFileLoaderUtils", { enumerable: true, get: function () { return webpackUtils_1.getFileLoaderUtils; } });
|
|
94
87
|
Object.defineProperty(exports, "getWebpackLoaderCompilerName", { enumerable: true, get: function () { return webpackUtils_1.getWebpackLoaderCompilerName; } });
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;AAEH,yCAiBqB;AAhBnB,+GAAA,kBAAkB,OAAA;AAClB,+GAAA,kBAAkB,OAAA;AAClB,+GAAA,kBAAkB,OAAA;AAClB,mHAAA,sBAAsB,OAAA;AACtB,qHAAA,wBAAwB,OAAA;AACxB,mHAAA,sBAAsB,OAAA;AACtB,qHAAA,wBAAwB,OAAA;AACxB,yGAAA,YAAY,OAAA;AACZ,oHAAA,uBAAuB,OAAA;AACvB,0HAAA,6BAA6B,OAAA;AAC7B,uGAAA,UAAU,OAAA;AACV,kHAAA,qBAAqB,OAAA;AACrB,wHAAA,2BAA2B,OAAA;AAC3B,yGAAA,YAAY,OAAA;AACZ,8GAAA,iBAAiB,OAAA;AACjB,qHAAA,wBAAwB,OAAA;AAE1B,yCAAyD;AAAjD,qGAAA,QAAQ,OAAA;AAAE,+GAAA,kBAAkB,OAAA;AACpC,yCAKqB;AAJnB,8GAAA,iBAAiB,OAAA;AACjB,0HAAA,6BAA6B,OAAA;AAC7B,8GAAA,iBAAiB,OAAA;AACjB,4GAAA,eAAe,OAAA;AAEjB,qCAAkE;AAA1D,6GAAA,kBAAkB,OAAA;AAA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|
2
2
|
"name": "@docusaurus/utils",
|
|
3
|
-
"version": "4.0.0-canary-
|
|
3
|
+
"version": "4.0.0-canary-6836",
|
|
4
4
|
"description": "Node utility functions for Docusaurus packages.",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"types": "./lib/index.d.ts",
|
|
@@ -19,9 +19,9 @@
|
|
|
19
19
|
"license": "MIT",
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"@11ty/gray-matter": "^3.0.0",
|
|
22
|
-
"@docusaurus/logger": "4.0.0-canary-
|
|
23
|
-
"@docusaurus/types": "4.0.0-canary-
|
|
24
|
-
"@docusaurus/utils-common": "4.0.0-canary-
|
|
22
|
+
"@docusaurus/logger": "4.0.0-canary-6836",
|
|
23
|
+
"@docusaurus/types": "4.0.0-canary-6836",
|
|
24
|
+
"@docusaurus/utils-common": "4.0.0-canary-6836",
|
|
25
25
|
"execa": "^10.0.1",
|
|
26
26
|
"file-loader": "^6.2.0",
|
|
27
27
|
"fs-extra": "^11.4.0",
|
|
@@ -29,11 +29,9 @@
|
|
|
29
29
|
"jiti": "^2.7.0",
|
|
30
30
|
"js-yaml": "^5.4.1",
|
|
31
31
|
"lodash": "^4.18.1",
|
|
32
|
-
"micromatch": "^4.0.8",
|
|
33
32
|
"p-queue": "^6.6.2",
|
|
34
33
|
"prompts": "^2.4.2",
|
|
35
34
|
"resolve-pathname": "^3.0.0",
|
|
36
|
-
"tinyglobby": "^0.2.17",
|
|
37
35
|
"tslib": "^2.8.1",
|
|
38
36
|
"url-loader": "^4.1.1",
|
|
39
37
|
"utility-types": "^3.11.0",
|
|
@@ -44,9 +42,8 @@
|
|
|
44
42
|
},
|
|
45
43
|
"devDependencies": {
|
|
46
44
|
"@types/dedent": "^0.7.2",
|
|
47
|
-
"@types/micromatch": "^4.0.10",
|
|
48
45
|
"@types/react-dom": "^19.3.0",
|
|
49
46
|
"dedent": "^1.7.2"
|
|
50
47
|
},
|
|
51
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "f64b0fa249027f680c607bc543a8b30a89ab208e"
|
|
52
49
|
}
|
package/src/index.ts
CHANGED
|
@@ -92,14 +92,6 @@ export {
|
|
|
92
92
|
addTrailingPathSeparator,
|
|
93
93
|
} from './pathUtils';
|
|
94
94
|
export {md5Hash, simpleHash, docuHash} from './hashUtils';
|
|
95
|
-
export {
|
|
96
|
-
Globby,
|
|
97
|
-
GlobExcludeDefault,
|
|
98
|
-
safeGlobby,
|
|
99
|
-
globTranslatableSourceFiles,
|
|
100
|
-
createMatcher,
|
|
101
|
-
createAbsoluteFilePathMatcher,
|
|
102
|
-
} from './globUtils';
|
|
103
95
|
export {
|
|
104
96
|
getFileLoaderUtils,
|
|
105
97
|
getWebpackLoaderCompilerName,
|
package/lib/globUtils.d.ts
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/
|
|
7
|
-
import * as Tinyglobby from 'tinyglobby';
|
|
8
|
-
type GlobOptions = Tinyglobby.GlobOptions;
|
|
9
|
-
/** A re-export of the globby instance. */
|
|
10
|
-
export declare const Globby: typeof Tinyglobby.glob;
|
|
11
|
-
/**
|
|
12
|
-
* The default glob patterns we ignore when sourcing content.
|
|
13
|
-
* - Ignore files and folders starting with `_` recursively
|
|
14
|
-
* - Ignore tests
|
|
15
|
-
*/
|
|
16
|
-
export declare const GlobExcludeDefault: string[];
|
|
17
|
-
type Matcher = (str: string) => boolean;
|
|
18
|
-
/**
|
|
19
|
-
* A very thin wrapper around `Micromatch.makeRe`.
|
|
20
|
-
*
|
|
21
|
-
* @see {@link createAbsoluteFilePathMatcher}
|
|
22
|
-
* @param patterns A list of glob patterns. If the list is empty, it defaults to
|
|
23
|
-
* matching none.
|
|
24
|
-
* @returns A matcher handle that tells if a file path is matched by any of the
|
|
25
|
-
* patterns.
|
|
26
|
-
*/
|
|
27
|
-
export declare function createMatcher(patterns: string[]): Matcher;
|
|
28
|
-
/**
|
|
29
|
-
* We use match patterns like `"** /_* /**"` (ignore the spaces), where `"_*"`
|
|
30
|
-
* should only be matched within a subfolder. This function would:
|
|
31
|
-
* - Match `/user/sebastien/website/docs/_partials/xyz.md`
|
|
32
|
-
* - Ignore `/user/_sebastien/website/docs/partials/xyz.md`
|
|
33
|
-
*
|
|
34
|
-
* @param patterns A list of glob patterns.
|
|
35
|
-
* @param rootFolders A list of root folders to resolve the glob from.
|
|
36
|
-
* @returns A matcher handle that tells if a file path is matched by any of the
|
|
37
|
-
* patterns, resolved from the first root folder that contains the path.
|
|
38
|
-
* @throws Throws when the returned matcher receives a path that doesn't belong
|
|
39
|
-
* to any of the `rootFolders`.
|
|
40
|
-
*/
|
|
41
|
-
export declare function createAbsoluteFilePathMatcher(patterns: string[], rootFolders: string[]): Matcher;
|
|
42
|
-
export declare function safeGlobby(patterns: string[], options?: GlobOptions): Promise<string[]>;
|
|
43
|
-
export declare const isTranslatableSourceFile: (filePath: string) => boolean;
|
|
44
|
-
export declare function globTranslatableSourceFiles(patterns: string[]): Promise<string[]>;
|
|
45
|
-
export {};
|
|
46
|
-
//# sourceMappingURL=globUtils.d.ts.map
|
package/lib/globUtils.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"globUtils.d.ts","sourceRoot":"","sources":["../src/globUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAOH,OAAO,KAAK,UAAU,MAAM,YAAY,CAAC;AAGzC,KAAK,WAAW,GAAG,UAAU,CAAC,WAAW,CAAC;AAI1C,0CAA0C;AAC1C,eAAO,MAAM,MAAM,wBAAkB,CAAC;AAEtC;;;;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,WAAW,GACpB,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,CAKnB"}
|
package/lib/globUtils.js
DELETED
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
4
|
-
*
|
|
5
|
-
* This source code is licensed under the MIT license found in the
|
|
6
|
-
* LICENSE file in the root directory of this source tree.
|
|
7
|
-
*/
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.isTranslatableSourceFile = exports.GlobExcludeDefault = exports.Globby = void 0;
|
|
10
|
-
exports.createMatcher = createMatcher;
|
|
11
|
-
exports.createAbsoluteFilePathMatcher = createAbsoluteFilePathMatcher;
|
|
12
|
-
exports.safeGlobby = safeGlobby;
|
|
13
|
-
exports.globTranslatableSourceFiles = globTranslatableSourceFiles;
|
|
14
|
-
const tslib_1 = require("tslib");
|
|
15
|
-
// Globby/Micromatch are the 2 libs we use in Docusaurus consistently
|
|
16
|
-
const path_1 = tslib_1.__importDefault(require("path"));
|
|
17
|
-
const micromatch_1 = tslib_1.__importDefault(require("micromatch")); // Note: Micromatch is used by Globby
|
|
18
|
-
const utils_common_1 = require("@docusaurus/utils-common");
|
|
19
|
-
const Tinyglobby = tslib_1.__importStar(require("tinyglobby"));
|
|
20
|
-
const pathUtils_1 = require("./pathUtils");
|
|
21
|
-
// TODO Docusaurus v4 refactor, hide lib behind home-made abstraction
|
|
22
|
-
// See https://github.com/facebook/docusaurus/pull/11042
|
|
23
|
-
/** A re-export of the globby instance. */
|
|
24
|
-
exports.Globby = Tinyglobby.glob;
|
|
25
|
-
/**
|
|
26
|
-
* The default glob patterns we ignore when sourcing content.
|
|
27
|
-
* - Ignore files and folders starting with `_` recursively
|
|
28
|
-
* - Ignore tests
|
|
29
|
-
*/
|
|
30
|
-
exports.GlobExcludeDefault = [
|
|
31
|
-
'**/_*.{js,jsx,ts,tsx,md,mdx}',
|
|
32
|
-
'**/_*/**',
|
|
33
|
-
'**/*.test.{js,jsx,ts,tsx}',
|
|
34
|
-
'**/__tests__/**',
|
|
35
|
-
];
|
|
36
|
-
/**
|
|
37
|
-
* A very thin wrapper around `Micromatch.makeRe`.
|
|
38
|
-
*
|
|
39
|
-
* @see {@link createAbsoluteFilePathMatcher}
|
|
40
|
-
* @param patterns A list of glob patterns. If the list is empty, it defaults to
|
|
41
|
-
* matching none.
|
|
42
|
-
* @returns A matcher handle that tells if a file path is matched by any of the
|
|
43
|
-
* patterns.
|
|
44
|
-
*/
|
|
45
|
-
function createMatcher(patterns) {
|
|
46
|
-
if (patterns.length === 0) {
|
|
47
|
-
// `/(?:)/.test("foo")` is `true`
|
|
48
|
-
return () => false;
|
|
49
|
-
}
|
|
50
|
-
const regexp = new RegExp(patterns.map((pattern) => micromatch_1.default.makeRe(pattern).source).join('|'));
|
|
51
|
-
return (str) => regexp.test(str);
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* We use match patterns like `"** /_* /**"` (ignore the spaces), where `"_*"`
|
|
55
|
-
* should only be matched within a subfolder. This function would:
|
|
56
|
-
* - Match `/user/sebastien/website/docs/_partials/xyz.md`
|
|
57
|
-
* - Ignore `/user/_sebastien/website/docs/partials/xyz.md`
|
|
58
|
-
*
|
|
59
|
-
* @param patterns A list of glob patterns.
|
|
60
|
-
* @param rootFolders A list of root folders to resolve the glob from.
|
|
61
|
-
* @returns A matcher handle that tells if a file path is matched by any of the
|
|
62
|
-
* patterns, resolved from the first root folder that contains the path.
|
|
63
|
-
* @throws Throws when the returned matcher receives a path that doesn't belong
|
|
64
|
-
* to any of the `rootFolders`.
|
|
65
|
-
*/
|
|
66
|
-
function createAbsoluteFilePathMatcher(patterns, rootFolders) {
|
|
67
|
-
const matcher = createMatcher(patterns);
|
|
68
|
-
function getRelativeFilePath(absoluteFilePath) {
|
|
69
|
-
const rootFolder = rootFolders.find((folderPath) => [(0, utils_common_1.addSuffix)(folderPath, '/'), (0, utils_common_1.addSuffix)(folderPath, '\\')].some((p) => absoluteFilePath.startsWith(p)));
|
|
70
|
-
if (!rootFolder) {
|
|
71
|
-
throw new Error(`createAbsoluteFilePathMatcher unexpected error, absoluteFilePath=${absoluteFilePath} was not contained in any of the root folders: ${rootFolders.join(', ')}`);
|
|
72
|
-
}
|
|
73
|
-
return path_1.default.relative(rootFolder, absoluteFilePath);
|
|
74
|
-
}
|
|
75
|
-
return (absoluteFilePath) => matcher(getRelativeFilePath(absoluteFilePath));
|
|
76
|
-
}
|
|
77
|
-
// Globby that fix Windows path patterns
|
|
78
|
-
// See https://github.com/facebook/docusaurus/pull/4222#issuecomment-795517329
|
|
79
|
-
async function safeGlobby(patterns, options) {
|
|
80
|
-
// Required for Windows support, as paths using \ should not be used by globby
|
|
81
|
-
// (also using the windows hard drive prefix like c: is not a good idea)
|
|
82
|
-
const globPaths = patterns.map((dirPath) => (0, pathUtils_1.posixPath)(path_1.default.relative(process.cwd(), dirPath)));
|
|
83
|
-
return (0, exports.Globby)(globPaths, options);
|
|
84
|
-
}
|
|
85
|
-
exports.isTranslatableSourceFile = (() => {
|
|
86
|
-
// We only support extracting source code translations from these extensions
|
|
87
|
-
const extensionsAllowed = new Set([
|
|
88
|
-
'.js',
|
|
89
|
-
'.jsx',
|
|
90
|
-
'.ts',
|
|
91
|
-
'.tsx',
|
|
92
|
-
// TODO support md/mdx too? (may be overkill)
|
|
93
|
-
// need to compile the MDX to JSX first and remove front matter
|
|
94
|
-
// '.md',
|
|
95
|
-
// '.mdx',
|
|
96
|
-
]);
|
|
97
|
-
const isBlacklistedFilePath = (filePath) => {
|
|
98
|
-
// We usually extract from ts files, unless they are .d.ts files
|
|
99
|
-
return filePath.endsWith('.d.ts');
|
|
100
|
-
};
|
|
101
|
-
return (filePath) => {
|
|
102
|
-
const ext = path_1.default.extname(filePath);
|
|
103
|
-
return extensionsAllowed.has(ext) && !isBlacklistedFilePath(filePath);
|
|
104
|
-
};
|
|
105
|
-
})();
|
|
106
|
-
// A bit weird to put this here, but it's used by core + theme-translations
|
|
107
|
-
async function globTranslatableSourceFiles(patterns) {
|
|
108
|
-
const filePaths = await safeGlobby(patterns, {
|
|
109
|
-
absolute: true,
|
|
110
|
-
});
|
|
111
|
-
return filePaths.filter(exports.isTranslatableSourceFile);
|
|
112
|
-
}
|
|
113
|
-
//# sourceMappingURL=globUtils.js.map
|
package/lib/globUtils.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"globUtils.js","sourceRoot":"","sources":["../src/globUtils.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;;;AAEH,qEAAqE;AAErE,wDAAwB;AACxB,oEAAoC,CAAC,qCAAqC;AAC1E,2DAAmD;AACnD,MAAY,UAAU,+CAAmB;AACzC,2CAAsC;AAItC,qEAAqE;AACrE,wDAAwD;AACxD,0CAA0C;AAC7B,QAAA,MAAM,GAAG,UAAU,CAAC,IAAI,CAAC;AAEtC;;;;GAIG;AACU,QAAA,kBAAkB,GAAG;IAChC,8BAA8B;IAC9B,UAAU;IACV,2BAA2B;IAC3B,iBAAiB;CAClB,CAAC;AAIF;;;;;;;;GAQG;AACH,uBAA8B,QAAkB;IAC9C,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,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licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
// Globby/Micromatch are the 2 libs we use in Docusaurus consistently
|
|
9
|
-
|
|
10
|
-
import path from 'path';
|
|
11
|
-
import Micromatch from 'micromatch'; // Note: Micromatch is used by Globby
|
|
12
|
-
import {addSuffix} from '@docusaurus/utils-common';
|
|
13
|
-
import * as Tinyglobby from 'tinyglobby';
|
|
14
|
-
import {posixPath} from './pathUtils';
|
|
15
|
-
|
|
16
|
-
type GlobOptions = Tinyglobby.GlobOptions;
|
|
17
|
-
|
|
18
|
-
// TODO Docusaurus v4 refactor, hide lib behind home-made abstraction
|
|
19
|
-
// See https://github.com/facebook/docusaurus/pull/11042
|
|
20
|
-
/** A re-export of the globby instance. */
|
|
21
|
-
export const Globby = Tinyglobby.glob;
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* The default glob patterns we ignore when sourcing content.
|
|
25
|
-
* - Ignore files and folders starting with `_` recursively
|
|
26
|
-
* - Ignore tests
|
|
27
|
-
*/
|
|
28
|
-
export const GlobExcludeDefault = [
|
|
29
|
-
'**/_*.{js,jsx,ts,tsx,md,mdx}',
|
|
30
|
-
'**/_*/**',
|
|
31
|
-
'**/*.test.{js,jsx,ts,tsx}',
|
|
32
|
-
'**/__tests__/**',
|
|
33
|
-
];
|
|
34
|
-
|
|
35
|
-
type Matcher = (str: string) => boolean;
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* A very thin wrapper around `Micromatch.makeRe`.
|
|
39
|
-
*
|
|
40
|
-
* @see {@link createAbsoluteFilePathMatcher}
|
|
41
|
-
* @param patterns A list of glob patterns. If the list is empty, it defaults to
|
|
42
|
-
* matching none.
|
|
43
|
-
* @returns A matcher handle that tells if a file path is matched by any of the
|
|
44
|
-
* patterns.
|
|
45
|
-
*/
|
|
46
|
-
export function createMatcher(patterns: string[]): Matcher {
|
|
47
|
-
if (patterns.length === 0) {
|
|
48
|
-
// `/(?:)/.test("foo")` is `true`
|
|
49
|
-
return () => false;
|
|
50
|
-
}
|
|
51
|
-
const regexp = new RegExp(
|
|
52
|
-
patterns.map((pattern) => Micromatch.makeRe(pattern).source).join('|'),
|
|
53
|
-
);
|
|
54
|
-
return (str) => regexp.test(str);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* We use match patterns like `"** /_* /**"` (ignore the spaces), where `"_*"`
|
|
59
|
-
* should only be matched within a subfolder. This function would:
|
|
60
|
-
* - Match `/user/sebastien/website/docs/_partials/xyz.md`
|
|
61
|
-
* - Ignore `/user/_sebastien/website/docs/partials/xyz.md`
|
|
62
|
-
*
|
|
63
|
-
* @param patterns A list of glob patterns.
|
|
64
|
-
* @param rootFolders A list of root folders to resolve the glob from.
|
|
65
|
-
* @returns A matcher handle that tells if a file path is matched by any of the
|
|
66
|
-
* patterns, resolved from the first root folder that contains the path.
|
|
67
|
-
* @throws Throws when the returned matcher receives a path that doesn't belong
|
|
68
|
-
* to any of the `rootFolders`.
|
|
69
|
-
*/
|
|
70
|
-
export function createAbsoluteFilePathMatcher(
|
|
71
|
-
patterns: string[],
|
|
72
|
-
rootFolders: string[],
|
|
73
|
-
): Matcher {
|
|
74
|
-
const matcher = createMatcher(patterns);
|
|
75
|
-
|
|
76
|
-
function getRelativeFilePath(absoluteFilePath: string) {
|
|
77
|
-
const rootFolder = rootFolders.find((folderPath) =>
|
|
78
|
-
[addSuffix(folderPath, '/'), addSuffix(folderPath, '\\')].some((p) =>
|
|
79
|
-
absoluteFilePath.startsWith(p),
|
|
80
|
-
),
|
|
81
|
-
);
|
|
82
|
-
if (!rootFolder) {
|
|
83
|
-
throw new Error(
|
|
84
|
-
`createAbsoluteFilePathMatcher unexpected error, absoluteFilePath=${absoluteFilePath} was not contained in any of the root folders: ${rootFolders.join(
|
|
85
|
-
', ',
|
|
86
|
-
)}`,
|
|
87
|
-
);
|
|
88
|
-
}
|
|
89
|
-
return path.relative(rootFolder, absoluteFilePath);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
return (absoluteFilePath: string) =>
|
|
93
|
-
matcher(getRelativeFilePath(absoluteFilePath));
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
// Globby that fix Windows path patterns
|
|
97
|
-
// See https://github.com/facebook/docusaurus/pull/4222#issuecomment-795517329
|
|
98
|
-
export async function safeGlobby(
|
|
99
|
-
patterns: string[],
|
|
100
|
-
options?: GlobOptions,
|
|
101
|
-
): Promise<string[]> {
|
|
102
|
-
// Required for Windows support, as paths using \ should not be used by globby
|
|
103
|
-
// (also using the windows hard drive prefix like c: is not a good idea)
|
|
104
|
-
const globPaths = patterns.map((dirPath) =>
|
|
105
|
-
posixPath(path.relative(process.cwd(), dirPath)),
|
|
106
|
-
);
|
|
107
|
-
|
|
108
|
-
return Globby(globPaths, options);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
export const isTranslatableSourceFile: (filePath: string) => boolean = (() => {
|
|
112
|
-
// We only support extracting source code translations from these extensions
|
|
113
|
-
const extensionsAllowed = new Set([
|
|
114
|
-
'.js',
|
|
115
|
-
'.jsx',
|
|
116
|
-
'.ts',
|
|
117
|
-
'.tsx',
|
|
118
|
-
// TODO support md/mdx too? (may be overkill)
|
|
119
|
-
// need to compile the MDX to JSX first and remove front matter
|
|
120
|
-
// '.md',
|
|
121
|
-
// '.mdx',
|
|
122
|
-
]);
|
|
123
|
-
|
|
124
|
-
const isBlacklistedFilePath = (filePath: string) => {
|
|
125
|
-
// We usually extract from ts files, unless they are .d.ts files
|
|
126
|
-
return filePath.endsWith('.d.ts');
|
|
127
|
-
};
|
|
128
|
-
|
|
129
|
-
return (filePath): boolean => {
|
|
130
|
-
const ext = path.extname(filePath);
|
|
131
|
-
return extensionsAllowed.has(ext) && !isBlacklistedFilePath(filePath);
|
|
132
|
-
};
|
|
133
|
-
})();
|
|
134
|
-
|
|
135
|
-
// A bit weird to put this here, but it's used by core + theme-translations
|
|
136
|
-
export async function globTranslatableSourceFiles(
|
|
137
|
-
patterns: string[],
|
|
138
|
-
): Promise<string[]> {
|
|
139
|
-
const filePaths = await safeGlobby(patterns, {
|
|
140
|
-
absolute: true,
|
|
141
|
-
});
|
|
142
|
-
return filePaths.filter(isTranslatableSourceFile);
|
|
143
|
-
}
|