@docusaurus/utils 2.0.0-beta.15d451942 → 2.0.0-beta.16

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 (88) hide show
  1. package/README.md +1 -1
  2. package/lib/constants.d.ts +20 -0
  3. package/lib/constants.d.ts.map +1 -0
  4. package/lib/constants.js +27 -0
  5. package/lib/constants.js.map +1 -0
  6. package/lib/dataFileUtils.d.ts +24 -0
  7. package/lib/dataFileUtils.d.ts.map +1 -0
  8. package/lib/dataFileUtils.js +65 -0
  9. package/lib/dataFileUtils.js.map +1 -0
  10. package/lib/gitUtils.d.ts +17 -0
  11. package/lib/gitUtils.d.ts.map +1 -0
  12. package/lib/gitUtils.js +63 -0
  13. package/lib/gitUtils.js.map +1 -0
  14. package/lib/globUtils.d.ts +12 -0
  15. package/lib/globUtils.d.ts.map +1 -0
  16. package/lib/globUtils.js +48 -0
  17. package/lib/globUtils.js.map +1 -0
  18. package/lib/hashUtils.d.ts +16 -0
  19. package/lib/hashUtils.d.ts.map +1 -0
  20. package/lib/hashUtils.js +41 -0
  21. package/lib/hashUtils.js.map +1 -0
  22. package/lib/index.d.ts +30 -52
  23. package/lib/index.d.ts.map +1 -0
  24. package/lib/index.js +126 -247
  25. package/lib/index.js.map +1 -0
  26. package/lib/markdownLinks.d.ts +1 -0
  27. package/lib/markdownLinks.d.ts.map +1 -0
  28. package/lib/markdownLinks.js +36 -11
  29. package/lib/markdownLinks.js.map +1 -0
  30. package/lib/markdownParser.d.ts +7 -3
  31. package/lib/markdownParser.d.ts.map +1 -0
  32. package/lib/markdownParser.js +77 -48
  33. package/lib/markdownParser.js.map +1 -0
  34. package/lib/pathUtils.d.ts +51 -0
  35. package/lib/pathUtils.d.ts.map +1 -0
  36. package/lib/pathUtils.js +106 -0
  37. package/lib/pathUtils.js.map +1 -0
  38. package/lib/slugger.d.ts +14 -0
  39. package/lib/slugger.d.ts.map +1 -0
  40. package/lib/slugger.js +19 -0
  41. package/lib/slugger.js.map +1 -0
  42. package/lib/tags.d.ts +27 -0
  43. package/lib/tags.d.ts.map +1 -0
  44. package/lib/tags.js +77 -0
  45. package/lib/tags.js.map +1 -0
  46. package/lib/urlUtils.d.ts +9 -0
  47. package/lib/urlUtils.d.ts.map +1 -0
  48. package/lib/urlUtils.js +81 -0
  49. package/lib/urlUtils.js.map +1 -0
  50. package/lib/webpackUtils.d.ts +30 -0
  51. package/lib/webpackUtils.d.ts.map +1 -0
  52. package/lib/webpackUtils.js +112 -0
  53. package/lib/webpackUtils.js.map +1 -0
  54. package/package.json +20 -10
  55. package/src/constants.ts +38 -0
  56. package/src/dataFileUtils.ts +90 -0
  57. package/src/deps.d.ts +10 -0
  58. package/src/gitUtils.ts +93 -0
  59. package/src/globUtils.ts +64 -0
  60. package/src/hashUtils.ts +37 -0
  61. package/src/index.ts +135 -294
  62. package/src/markdownLinks.ts +35 -13
  63. package/src/markdownParser.ts +86 -62
  64. package/src/pathUtils.ts +115 -0
  65. package/src/slugger.ts +24 -0
  66. package/src/tags.ts +105 -0
  67. package/src/urlUtils.ts +96 -0
  68. package/src/webpackUtils.ts +146 -0
  69. package/lib/.tsbuildinfo +0 -3972
  70. package/lib/codeTranslationsUtils.d.ts +0 -11
  71. package/lib/codeTranslationsUtils.js +0 -50
  72. package/lib/escapePath.d.ts +0 -17
  73. package/lib/escapePath.js +0 -25
  74. package/lib/posixPath.d.ts +0 -14
  75. package/lib/posixPath.js +0 -28
  76. package/src/__tests__/__fixtures__/defaultCodeTranslations/en.json +0 -4
  77. package/src/__tests__/__fixtures__/defaultCodeTranslations/fr-FR.json +0 -5
  78. package/src/__tests__/__fixtures__/defaultCodeTranslations/fr.json +0 -4
  79. package/src/__tests__/__snapshots__/index.test.ts.snap +0 -8
  80. package/src/__tests__/codeTranslationsUtils.test.ts +0 -112
  81. package/src/__tests__/escapePath.test.ts +0 -25
  82. package/src/__tests__/index.test.ts +0 -681
  83. package/src/__tests__/markdownParser.test.ts +0 -772
  84. package/src/__tests__/posixPath.test.ts +0 -25
  85. package/src/codeTranslationsUtils.ts +0 -56
  86. package/src/escapePath.ts +0 -23
  87. package/src/posixPath.ts +0 -27
  88. package/tsconfig.json +0 -9
package/README.md CHANGED
@@ -1,3 +1,3 @@
1
1
  # `@docusaurus/utils`
2
2
 
3
- Node validation utility functions for Docusaurus packages.
3
+ Node utility functions for Docusaurus packages.
@@ -0,0 +1,20 @@
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
+ export declare const NODE_MAJOR_VERSION: number;
8
+ export declare const NODE_MINOR_VERSION: number;
9
+ export declare const DEFAULT_BUILD_DIR_NAME = "build";
10
+ export declare const DEFAULT_CONFIG_FILE_NAME = "docusaurus.config.js";
11
+ export declare const BABEL_CONFIG_FILE_NAME: string;
12
+ export declare const GENERATED_FILES_DIR_NAME: string;
13
+ export declare const SRC_DIR_NAME = "src";
14
+ export declare const STATIC_DIR_NAME = "static";
15
+ export declare const OUTPUT_STATIC_ASSETS_DIR_NAME = "assets";
16
+ export declare const THEME_PATH: string;
17
+ export declare const DEFAULT_PORT = 3000;
18
+ export declare const DEFAULT_PLUGIN_ID = "default";
19
+ export declare const WEBPACK_URL_LOADER_LIMIT: string | number;
20
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,kBAAkB,QAG9B,CAAC;AACF,eAAO,MAAM,kBAAkB,QAG9B,CAAC;AAGF,eAAO,MAAM,sBAAsB,UAAU,CAAC;AAG9C,eAAO,MAAM,wBAAwB,yBAAyB,CAAC;AAE/D,eAAO,MAAM,sBAAsB,QACiC,CAAC;AAErE,eAAO,MAAM,wBAAwB,QAC6B,CAAC;AAEnE,eAAO,MAAM,YAAY,QAAQ,CAAC;AAClC,eAAO,MAAM,eAAe,WAAW,CAAC;AACxC,eAAO,MAAM,6BAA6B,WAAW,CAAC;AACtD,eAAO,MAAM,UAAU,QAA0B,CAAC;AAClD,eAAO,MAAM,YAAY,OAAO,CAAC;AACjC,eAAO,MAAM,iBAAiB,YAAY,CAAC;AAG3C,eAAO,MAAM,wBAAwB,iBACU,CAAC"}
@@ -0,0 +1,27 @@
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
+ var _a;
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.WEBPACK_URL_LOADER_LIMIT = exports.DEFAULT_PLUGIN_ID = exports.DEFAULT_PORT = exports.THEME_PATH = exports.OUTPUT_STATIC_ASSETS_DIR_NAME = exports.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.NODE_MINOR_VERSION = exports.NODE_MAJOR_VERSION = void 0;
11
+ exports.NODE_MAJOR_VERSION = parseInt(process.versions.node.split('.')[0], 10);
12
+ exports.NODE_MINOR_VERSION = parseInt(process.versions.node.split('.')[1], 10);
13
+ // Can be overridden with cli option --out-dir
14
+ exports.DEFAULT_BUILD_DIR_NAME = 'build';
15
+ // Can be overridden with cli option --config
16
+ exports.DEFAULT_CONFIG_FILE_NAME = 'docusaurus.config.js';
17
+ exports.BABEL_CONFIG_FILE_NAME = process.env.DOCUSAURUS_BABEL_CONFIG_FILE_NAME || 'babel.config.js';
18
+ exports.GENERATED_FILES_DIR_NAME = process.env.DOCUSAURUS_GENERATED_FILES_DIR_NAME || '.docusaurus';
19
+ exports.SRC_DIR_NAME = 'src';
20
+ exports.STATIC_DIR_NAME = 'static';
21
+ exports.OUTPUT_STATIC_ASSETS_DIR_NAME = 'assets'; // files handled by webpack, hashed (can be cached aggressively)
22
+ exports.THEME_PATH = `${exports.SRC_DIR_NAME}/theme`;
23
+ exports.DEFAULT_PORT = 3000;
24
+ exports.DEFAULT_PLUGIN_ID = 'default';
25
+ // Temporary fix for https://github.com/facebook/docusaurus/issues/5493
26
+ exports.WEBPACK_URL_LOADER_LIMIT = (_a = process.env.WEBPACK_URL_LOADER_LIMIT) !== null && _a !== void 0 ? _a : 10000;
27
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;AAEU,QAAA,kBAAkB,GAAG,QAAQ,CACxC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EACnC,EAAE,CACH,CAAC;AACW,QAAA,kBAAkB,GAAG,QAAQ,CACxC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EACnC,EAAE,CACH,CAAC;AAEF,8CAA8C;AACjC,QAAA,sBAAsB,GAAG,OAAO,CAAC;AAE9C,6CAA6C;AAChC,QAAA,wBAAwB,GAAG,sBAAsB,CAAC;AAElD,QAAA,sBAAsB,GACjC,OAAO,CAAC,GAAG,CAAC,iCAAiC,IAAI,iBAAiB,CAAC;AAExD,QAAA,wBAAwB,GACnC,OAAO,CAAC,GAAG,CAAC,mCAAmC,IAAI,aAAa,CAAC;AAEtD,QAAA,YAAY,GAAG,KAAK,CAAC;AACrB,QAAA,eAAe,GAAG,QAAQ,CAAC;AAC3B,QAAA,6BAA6B,GAAG,QAAQ,CAAC,CAAC,gEAAgE;AAC1G,QAAA,UAAU,GAAG,GAAG,oBAAY,QAAQ,CAAC;AACrC,QAAA,YAAY,GAAG,IAAI,CAAC;AACpB,QAAA,iBAAiB,GAAG,SAAS,CAAC;AAE3C,uEAAuE;AAC1D,QAAA,wBAAwB,GACnC,MAAA,OAAO,CAAC,GAAG,CAAC,wBAAwB,mCAAI,KAAK,CAAC"}
@@ -0,0 +1,24 @@
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 type { ContentPaths } from './markdownLinks';
8
+ declare type DataFileParams = {
9
+ filePath: string;
10
+ contentPaths: ContentPaths;
11
+ };
12
+ export declare function getDataFilePath({ filePath, contentPaths, }: DataFileParams): Promise<string | undefined>;
13
+ /**
14
+ * Looks up for a data file in the content paths, returns the normalized object.
15
+ * Throws when validation fails; returns undefined when file not found
16
+ */
17
+ export declare function getDataFileData<T>(params: DataFileParams & {
18
+ fileType: string;
19
+ }, validate: (content: unknown) => T): Promise<T | undefined>;
20
+ export declare function getContentPathList(contentPaths: ContentPaths): string[];
21
+ export declare function findFolderContainingFile(folderPaths: string[], relativeFilePath: string): Promise<string | undefined>;
22
+ export declare function getFolderContainingFile(folderPaths: string[], relativeFilePath: string): Promise<string>;
23
+ export {};
24
+ //# sourceMappingURL=dataFileUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dataFileUtils.d.ts","sourceRoot":"","sources":["../src/dataFileUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,iBAAiB,CAAC;AAGlD,aAAK,cAAc,GAAG;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,YAAY,CAAC;CAC5B,CAAC;AAEF,wBAAsB,eAAe,CAAC,EACpC,QAAQ,EACR,YAAY,GACb,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAU9C;AAED;;;GAGG;AACH,wBAAsB,eAAe,CAAC,CAAC,EACrC,MAAM,EAAE,cAAc,GAAG;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAC,EAC3C,QAAQ,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,CAAC,GAChC,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC,CAcxB;AAGD,wBAAgB,kBAAkB,CAAC,YAAY,EAAE,YAAY,GAAG,MAAM,EAAE,CAEvE;AAGD,wBAAsB,wBAAwB,CAC5C,WAAW,EAAE,MAAM,EAAE,EACrB,gBAAgB,EAAE,MAAM,GACvB,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAI7B;AAED,wBAAsB,uBAAuB,CAC3C,WAAW,EAAE,MAAM,EAAE,EACrB,gBAAgB,EAAE,MAAM,GACvB,OAAO,CAAC,MAAM,CAAC,CAcjB"}
@@ -0,0 +1,65 @@
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.getFolderContainingFile = exports.findFolderContainingFile = exports.getContentPathList = exports.getDataFileData = exports.getDataFilePath = void 0;
10
+ const tslib_1 = require("tslib");
11
+ const fs_extra_1 = (0, tslib_1.__importDefault)(require("fs-extra"));
12
+ const js_yaml_1 = (0, tslib_1.__importDefault)(require("js-yaml"));
13
+ const path_1 = (0, tslib_1.__importDefault)(require("path"));
14
+ const index_1 = require("./index");
15
+ const logger_1 = (0, tslib_1.__importDefault)(require("@docusaurus/logger"));
16
+ async function getDataFilePath({ filePath, contentPaths, }) {
17
+ // Loads a localized data file in priority
18
+ const contentPath = await findFolderContainingFile(getContentPathList(contentPaths), filePath);
19
+ if (contentPath) {
20
+ return path_1.default.join(contentPath, filePath);
21
+ }
22
+ return undefined;
23
+ }
24
+ exports.getDataFilePath = getDataFilePath;
25
+ /**
26
+ * Looks up for a data file in the content paths, returns the normalized object.
27
+ * Throws when validation fails; returns undefined when file not found
28
+ */
29
+ async function getDataFileData(params, validate) {
30
+ const filePath = await getDataFilePath(params);
31
+ if (!filePath) {
32
+ return undefined;
33
+ }
34
+ try {
35
+ const contentString = await fs_extra_1.default.readFile(filePath, { encoding: 'utf8' });
36
+ const unsafeContent = js_yaml_1.default.load(contentString);
37
+ return validate(unsafeContent);
38
+ }
39
+ catch (err) {
40
+ // TODO replace later by error cause, see https://v8.dev/features/error-cause
41
+ logger_1.default.error `The ${params.fileType} file at path=${filePath} looks invalid.`;
42
+ throw err;
43
+ }
44
+ }
45
+ exports.getDataFileData = getDataFileData;
46
+ // Order matters: we look in priority in localized folder
47
+ function getContentPathList(contentPaths) {
48
+ return [contentPaths.contentPathLocalized, contentPaths.contentPath];
49
+ }
50
+ exports.getContentPathList = getContentPathList;
51
+ // return the first folder path in which the file exists in
52
+ async function findFolderContainingFile(folderPaths, relativeFilePath) {
53
+ return (0, index_1.findAsyncSequential)(folderPaths, (folderPath) => fs_extra_1.default.pathExists(path_1.default.join(folderPath, relativeFilePath)));
54
+ }
55
+ exports.findFolderContainingFile = findFolderContainingFile;
56
+ async function getFolderContainingFile(folderPaths, relativeFilePath) {
57
+ const maybeFolderPath = await findFolderContainingFile(folderPaths, relativeFilePath);
58
+ // should never happen, as the source was read from the FS anyway...
59
+ if (!maybeFolderPath) {
60
+ throw new Error(`File "${relativeFilePath}" does not exist in any of these folders:\n- ${folderPaths.join('\n- ')}]`);
61
+ }
62
+ return maybeFolderPath;
63
+ }
64
+ exports.getFolderContainingFile = getFolderContainingFile;
65
+ //# sourceMappingURL=dataFileUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dataFileUtils.js","sourceRoot":"","sources":["../src/dataFileUtils.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;AAEH,qEAA0B;AAC1B,mEAA2B;AAC3B,6DAAwB;AACxB,mCAA4C;AAE5C,6EAAwC;AAOjC,KAAK,UAAU,eAAe,CAAC,EACpC,QAAQ,EACR,YAAY,GACG;IACf,0CAA0C;IAC1C,MAAM,WAAW,GAAG,MAAM,wBAAwB,C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,UAAU,uBAAuB,CAC3C,WAAqB,EACrB,gBAAwB;IAExB,MAAM,eAAe,GAAG,MAAM,wBAAwB,CACpD,WAAW,EACX,gBAAgB,CACjB,CAAC;IACF,oEAAoE;IACpE,IAAI,CAAC,eAAe,EAAE;QACpB,MAAM,IAAI,KAAK,CACb,SAAS,gBAAgB,gDAAgD,WAAW,CAAC,IAAI,CACvF,MAAM,CACP,GAAG,CACL,CAAC;KACH;IACD,OAAO,eAAe,CAAC;AACzB,CAAC;AAjBD,0DAiBC"}
@@ -0,0 +1,17 @@
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
+ export declare class GitNotFoundError extends Error {
8
+ }
9
+ export declare const getFileCommitDate: (file: string, { age, includeAuthor, }: {
10
+ age?: "oldest" | "newest" | undefined;
11
+ includeAuthor?: boolean | undefined;
12
+ }) => {
13
+ date: Date;
14
+ timestamp: number;
15
+ author?: string | undefined;
16
+ };
17
+ //# sourceMappingURL=gitUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gitUtils.d.ts","sourceRoot":"","sources":["../src/gitUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,qBAAa,gBAAiB,SAAQ,KAAK;CAAG;AAE9C,eAAO,MAAM,iBAAiB,SACtB,MAAM;;;;UASN,IAAI;eACC,MAAM;;CAqElB,CAAC"}
@@ -0,0 +1,63 @@
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.getFileCommitDate = exports.GitNotFoundError = void 0;
10
+ const tslib_1 = require("tslib");
11
+ const path_1 = (0, tslib_1.__importDefault)(require("path"));
12
+ const shelljs_1 = (0, tslib_1.__importDefault)(require("shelljs"));
13
+ class GitNotFoundError extends Error {
14
+ }
15
+ exports.GitNotFoundError = GitNotFoundError;
16
+ const getFileCommitDate = (file, { age = 'oldest', includeAuthor = false, }) => {
17
+ if (!shelljs_1.default.which('git')) {
18
+ throw new GitNotFoundError(`Failed to retrieve git history for "${file}" because git is not installed.`);
19
+ }
20
+ if (!shelljs_1.default.test('-f', file)) {
21
+ throw new Error(`Failed to retrieve git history for "${file}" because the file does not exist.`);
22
+ }
23
+ const fileBasename = path_1.default.basename(file);
24
+ const fileDirname = path_1.default.dirname(file);
25
+ let formatArg = '--format=%ct';
26
+ if (includeAuthor) {
27
+ formatArg += ',%an';
28
+ }
29
+ let extraArgs = '--max-count=1';
30
+ if (age === 'oldest') {
31
+ // --follow is necessary to follow file renames
32
+ // --diff-filter=A ensures we only get the commit which (A)dded the file
33
+ extraArgs += ' --follow --diff-filter=A';
34
+ }
35
+ const result = shelljs_1.default.exec(`git log ${extraArgs} ${formatArg} -- "${fileBasename}"`, {
36
+ // cwd is important, see: https://github.com/facebook/docusaurus/pull/5048
37
+ cwd: fileDirname,
38
+ silent: true,
39
+ });
40
+ if (result.code !== 0) {
41
+ throw new Error(`Failed to retrieve the git history for file "${file}" with exit code ${result.code}: ${result.stderr}`);
42
+ }
43
+ let regex = /^(?<timestamp>\d+)$/;
44
+ if (includeAuthor) {
45
+ regex = /^(?<timestamp>\d+),(?<author>.+)$/;
46
+ }
47
+ const output = result.stdout.trim();
48
+ const match = output.match(regex);
49
+ if (!match ||
50
+ !match.groups ||
51
+ !match.groups.timestamp ||
52
+ (includeAuthor && !match.groups.author)) {
53
+ throw new Error(`Failed to retrieve the git history for file "${file}" with unexpected output: ${output}`);
54
+ }
55
+ const timestamp = Number(match.groups.timestamp);
56
+ const date = new Date(timestamp * 1000);
57
+ if (includeAuthor) {
58
+ return { date, timestamp, author: match.groups.author };
59
+ }
60
+ return { date, timestamp };
61
+ };
62
+ exports.getFileCommitDate = getFileCommitDate;
63
+ //# sourceMappingURL=gitUt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oB,MAAM,CAAC,IAAI,KAAK,MAAM,CAAC,MAAM,EAAE,CACxG,CAAC;KACH;IACD,IAAI,KAAK,GAAG,qBAAqB,CAAC;IAClC,IAAI,aAAa,EAAE;QACjB,KAAK,GAAG,mCAAmC,CAAC;KAC7C;IAED,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;IACpC,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAElC,IACE,CAAC,KAAK;QACN,CAAC,KAAK,CAAC,MAAM;QACb,CAAC,KAAK,CAAC,MAAM,CAAC,SAAS;QACvB,CAAC,aAAa,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,EACvC;QACA,MAAM,IAAI,KAAK,CACb,gDAAgD,IAAI,6BAA6B,MAAM,EAAE,CAC1F,CAAC;KACH;IAED,MAAM,SAAS,GAAG,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IACjD,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,CAAC;IAExC,IAAI,aAAa,EAAE;QACjB,OAAO,EAAC,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAC,CAAC;KACvD;IACD,OAAO,EAAC,IAAI,EAAE,SAAS,EAAC,CAAC;AAC3B,CAAC,CAAC;AAhFW,QAAA,iBAAiB,qBAgF5B"}
@@ -0,0 +1,12 @@
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
+ export { default as Globby } from 'globby';
8
+ export declare const GlobExcludeDefault: string[];
9
+ declare type Matcher = (str: string) => boolean;
10
+ export declare function createMatcher(patterns: string[]): Matcher;
11
+ export declare function createAbsoluteFilePathMatcher(patterns: string[], rootFolders: string[]): Matcher;
12
+ //# sourceMappingURL=globUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"globUtils.d.ts","sourceRoot":"","sources":["../src/globUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAOH,OAAO,EAAC,OAAO,IAAI,MAAM,EAAC,MAAM,QAAQ,CAAC;AAIzC,eAAO,MAAM,kBAAkB,UAU9B,CAAC;AAEF,aAAK,OAAO,GAAG,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC;AAExC,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CAKzD;AAMD,wBAAgB,6BAA6B,CAC3C,QAAQ,EAAE,MAAM,EAAE,EAClB,WAAW,EAAE,MAAM,EAAE,GACpB,OAAO,CAmBT"}
@@ -0,0 +1,48 @@
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.createAbsoluteFilePathMatcher = exports.createMatcher = exports.GlobExcludeDefault = exports.Globby = void 0;
10
+ const tslib_1 = require("tslib");
11
+ // Globby/Micromatch are the 2 libs we use in Docusaurus consistently
12
+ const micromatch_1 = (0, tslib_1.__importDefault)(require("micromatch")); // Note: Micromatch is used by Globby
13
+ const path_1 = (0, tslib_1.__importDefault)(require("path"));
14
+ var globby_1 = require("globby");
15
+ Object.defineProperty(exports, "Globby", { enumerable: true, get: function () { return (0, tslib_1.__importDefault)(globby_1).default; } });
16
+ // The default patterns we ignore when globbing
17
+ // using _ prefix for exclusion by convention
18
+ exports.GlobExcludeDefault = [
19
+ // Ignore files starting with _
20
+ '**/_*.{js,jsx,ts,tsx,md,mdx}',
21
+ // Ignore folders starting with _ (including folder content)
22
+ '**/_*/**',
23
+ // Ignore tests
24
+ '**/*.test.{js,jsx,ts,tsx}',
25
+ '**/__tests__/**',
26
+ ];
27
+ function createMatcher(patterns) {
28
+ const regexp = new RegExp(patterns.map((pattern) => micromatch_1.default.makeRe(pattern).source).join('|'));
29
+ return (str) => regexp.test(str);
30
+ }
31
+ exports.createMatcher = createMatcher;
32
+ // We use match patterns like '**/_*/**',
33
+ // This function permits to help to:
34
+ // Match /user/sebastien/website/docs/_partials/xyz.md
35
+ // Ignore /user/_sebastien/website/docs/partials/xyz.md
36
+ function createAbsoluteFilePathMatcher(patterns, rootFolders) {
37
+ const matcher = createMatcher(patterns);
38
+ function getRelativeFilePath(absoluteFilePath) {
39
+ const rootFolder = rootFolders.find((folderPath) => absoluteFilePath.startsWith(folderPath));
40
+ if (!rootFolder) {
41
+ throw new Error(`createAbsoluteFilePathMatcher unexpected error, absoluteFilePath=${absoluteFilePath} was not contained in any of the root folders ${JSON.stringify(rootFolders)}`);
42
+ }
43
+ return path_1.default.relative(rootFolder, absoluteFilePath);
44
+ }
45
+ return (absoluteFilePath) => matcher(getRelativeFilePath(absoluteFilePath));
46
+ }
47
+ exports.createAbsoluteFilePathMatcher = createAbsoluteFilePathMatcher;
48
+ //# sourceMappingURL=globUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"globUtils.js","sourceRoot":"","sources":["../src/globUtils.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;AAEH,qEAAqE;AAErE,yEAAoC,CAAC,qCAAqC;AAC1E,6DAAwB;AAExB,iCAAyC;AAAjC,8HAAA,OAAO,OAAU;AAEzB,+CAA+C;AAC/C,6CAA6C;AAChC,QAAA,kBAAkB,GAAG;IAChC,+BAA+B;IAC/B,8BAA8B;IAE9B,4DAA4D;IAC5D,UAAU;IAEV,eAAe;IACf,2BAA2B;IAC3B,iBAAiB;CAClB,CAAC;AAIF,SAAgB,aAAa,CAAC,QAAkB;IAC9C,MAAM,MAAM,GAAG,IAAI,MAAM,CACvB,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,oBAAU,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CACvE,CAAC;IACF,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACnC,CAAC;AALD,sCAKC;AAED,yCAAyC;AACzC,oCAAoC;AACpC,sDAAsD;AACtD,uDAAuD;AACvD,SAAgB,6BAA6B,CAC3C,QAAkB,EAClB,WAAqB;IAErB,MAAM,OAAO,GAAG,aAAa,CAAC,QAAQ,CAAC,CAAC;IAExC,SAAS,mBAAmB,CAAC,gBAAwB;QACnD,MAAM,UAAU,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,EAAE,CACjD,gBAAgB,CAAC,UAAU,CAAC,UAAU,CAAC,CACxC,CAAC;QACF,IAAI,CAAC,UAAU,EAAE;YACf,MAAM,IAAI,KAAK,CACb,oEAAoE,gBAAgB,iDAAiD,IAAI,CAAC,SAAS,CACjJ,WAAW,CACZ,EAAE,CACJ,CAAC;SACH;QACD,OAAO,cAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,gBAAgB,CAAC,CAAC;IACrD,CAAC;IAED,OAAO,CAAC,gBAAwB,EAAE,EAAE,CAClC,OAAO,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,CAAC,CAAC;AACnD,CAAC;AAtBD,sEAsBC"}
@@ -0,0 +1,16 @@
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
+ export declare function md5Hash(str: string): string;
8
+ export declare function simpleHash(str: string, length: number): string;
9
+ /**
10
+ * Given an input string, convert to kebab-case and append a hash.
11
+ * Avoid str collision.
12
+ * Also removes part of the string if its larger than the allowed
13
+ * filename per OS. Avoids ERRNAMETOOLONG error.
14
+ */
15
+ export declare function docuHash(str: string): string;
16
+ //# sourceMappingURL=hashUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hashUtils.d.ts","sourceRoot":"","sources":["../src/hashUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE3C;AAED,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAE9D;AAGD;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAU5C"}
@@ -0,0 +1,41 @@
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.docuHash = exports.simpleHash = exports.md5Hash = void 0;
10
+ const tslib_1 = require("tslib");
11
+ const crypto_1 = require("crypto");
12
+ const lodash_1 = (0, tslib_1.__importDefault)(require("lodash"));
13
+ const pathUtils_1 = require("./pathUtils");
14
+ function md5Hash(str) {
15
+ return (0, crypto_1.createHash)('md5').update(str).digest('hex');
16
+ }
17
+ exports.md5Hash = md5Hash;
18
+ function simpleHash(str, length) {
19
+ return md5Hash(str).substr(0, length);
20
+ }
21
+ exports.simpleHash = simpleHash;
22
+ // Based on https://github.com/gatsbyjs/gatsby/pull/21518/files
23
+ /**
24
+ * Given an input string, convert to kebab-case and append a hash.
25
+ * Avoid str collision.
26
+ * Also removes part of the string if its larger than the allowed
27
+ * filename per OS. Avoids ERRNAMETOOLONG error.
28
+ */
29
+ function docuHash(str) {
30
+ if (str === '/') {
31
+ return 'index';
32
+ }
33
+ const shortHash = simpleHash(str, 3);
34
+ const parsedPath = `${lodash_1.default.kebabCase(str)}-${shortHash}`;
35
+ if ((0, pathUtils_1.isNameTooLong)(parsedPath)) {
36
+ return `${(0, pathUtils_1.shortName)(lodash_1.default.kebabCase(str))}-${shortHash}`;
37
+ }
38
+ return parsedPath;
39
+ }
40
+ exports.docuHash = docuHash;
41
+ //# sourceMappingURL=hashUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hashUtils.js","sourceRoot":"","sources":["../src/hashUtils.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;AAEH,mCAAkC;AAClC,iEAAuB;AACvB,2CAAqD;AAErD,SAAgB,OAAO,CAAC,GAAW;IACjC,OAAO,IAAA,mBAAU,EAAC,KAAK,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AACrD,CAAC;AAFD,0BAEC;AAED,SAAgB,UAAU,CAAC,GAAW,EAAE,MAAc;IACpD,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;AACxC,CAAC;AAFD,gCAEC;AAED,+DAA+D;AAC/D;;;;;GAKG;AACH,SAAgB,QAAQ,CAAC,GAAW;IAClC,IAAI,GAAG,KAAK,GAAG,EAAE;QACf,OAAO,OAAO,CAAC;KAChB;IACD,MAAM,SAAS,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;IACrC,MAAM,UAAU,GAAG,GAAG,gBAAC,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,SAAS,EAAE,CAAC;IACtD,IAAI,IAAA,yBAAa,EAAC,UAAU,CAAC,EAAE;QAC7B,OAAO,GAAG,IAAA,qBAAS,EAAC,gBAAC,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,IAAI,SAAS,EAAE,CAAC;KACtD;IACD,OAAO,UAAU,CAAC;AACpB,CAAC;AAVD,4BAUC"}
package/lib/index.d.ts CHANGED
@@ -4,85 +4,63 @@
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
- import { ReportingSeverity, TranslationFileContent, TranslationFile } from '@docusaurus/types';
8
- import { posixPath as posixPathImport } from './posixPath';
9
- export declare const posixPath: typeof posixPathImport;
10
- export * from './codeTranslationsUtils';
11
- export * from './markdownParser';
12
- export * from './markdownLinks';
13
- export * from './escapePath';
7
+ /// <reference types="node" />
8
+ import type { ReportingSeverity, TranslationFileContent, TranslationFile } from '@docusaurus/types';
9
+ export { NODE_MAJOR_VERSION, NODE_MINOR_VERSION, DEFAULT_BUILD_DIR_NAME, DEFAULT_CONFIG_FILE_NAME, BABEL_CONFIG_FILE_NAME, GENERATED_FILES_DIR_NAME, SRC_DIR_NAME, STATIC_DIR_NAME, OUTPUT_STATIC_ASSETS_DIR_NAME, THEME_PATH, DEFAULT_PORT, DEFAULT_PLUGIN_ID, WEBPACK_URL_LOADER_LIMIT, } from './constants';
10
+ export { getFileCommitDate, GitNotFoundError } from './gitUtils';
11
+ export { normalizeUrl, getEditUrl } from './urlUtils';
12
+ export { type Tag, type FrontMatterTag, type TaggedItemGroup, normalizeFrontMatterTag, normalizeFrontMatterTags, groupTaggedItems, } from './tags';
13
+ export { parseMarkdownHeadingId, createExcerpt, parseFrontMatter, parseMarkdownContentTitle, parseMarkdownString, } from './markdownParser';
14
+ export { type ContentPaths, type BrokenMarkdownLink, type ReplaceMarkdownLinksParams, type ReplaceMarkdownLinksReturn, replaceMarkdownLinks, } from './markdownLinks';
15
+ export { type SluggerOptions, type Slugger, createSlugger } from './slugger';
16
+ export { isNameTooLong, shortName, posixPath, toMessageRelativeFilePath, aliasedSitePath, escapePath, } from './pathUtils';
17
+ export { md5Hash, simpleHash, docuHash } from './hashUtils';
18
+ export { Globby, GlobExcludeDefault, createMatcher, createAbsoluteFilePathMatcher, } from './globUtils';
19
+ export { getFileLoaderUtils } from './webpackUtils';
20
+ export { getDataFilePath, getDataFileData, getContentPathList, findFolderContainingFile, getFolderContainingFile, } from './dataFileUtils';
14
21
  export declare function generate(generatedFilesDir: string, file: string, content: string, skipCache?: boolean): Promise<void>;
15
- export declare function objectWithKeySorted<T>(obj: Record<string, T>): Record<string, T>;
16
22
  /**
17
23
  * Convert filepath to url path.
18
24
  * Example: 'index.md' -> '/', 'foo/bar.js' -> '/foo/bar',
19
25
  */
20
26
  export declare function fileToPath(file: string): string;
21
- export declare function encodePath(userpath: string): string;
22
- export declare function simpleHash(str: string, length: number): string;
23
- /**
24
- * Given an input string, convert to kebab-case and append a hash.
25
- * Avoid str collision.
26
- */
27
- export declare function docuHash(str: string): string;
28
- /**
29
- * Convert first string character to the upper case.
30
- * E.g: docusaurus -> Docusaurus
31
- */
32
- export declare function upperFirst(str: string): string;
33
- /**
34
- * Generate unique React Component Name.
35
- * E.g: /foo-bar -> FooBar096
36
- */
37
- export declare function genComponentName(pagePath: string): string;
38
- export declare function toMessageRelativeFilePath(filePath: string): string;
27
+ export declare function encodePath(userPath: string): string;
39
28
  /**
40
29
  * Generate unique chunk name given a module path.
41
30
  */
42
31
  export declare function genChunkName(modulePath: string, prefix?: string, preferredName?: string, shortId?: boolean): string;
43
- export declare function idx(target: any, keyPaths?: string | (string | number)[]): any;
44
- /**
45
- * Given a filepath and dirpath, get the first directory.
46
- */
47
- export declare function getSubFolder(file: string, refDir: string): string | null;
48
- export declare function normalizeUrl(rawUrls: string[]): string;
49
- /**
50
- * Alias filepath relative to site directory, very useful so that we
51
- * don't expose user's site structure.
52
- * Example: some/path/to/website/docs/foo.md -> @site/docs/foo.md
53
- */
54
- export declare function aliasedSitePath(filePath: string, siteDir: string): string;
55
- export declare function getEditUrl(fileRelativePath: string, editUrl?: string): string | undefined;
56
32
  export declare function isValidPathname(str: string): boolean;
57
33
  export declare function resolvePathname(to: string, from?: string): string;
58
34
  export declare function addLeadingSlash(str: string): string;
59
- export declare function addTrailingSlash(str: string): string;
60
35
  export declare function addTrailingPathSeparator(str: string): string;
36
+ export declare function addTrailingSlash(str: string): string;
61
37
  export declare function removeTrailingSlash(str: string): string;
62
38
  export declare function removeSuffix(str: string, suffix: string): string;
63
39
  export declare function removePrefix(str: string, prefix: string): string;
64
- export declare function getFilePathForRoutePath(routePath: string): string;
65
- export declare function getElementsAround<T extends unknown>(array: T[], aroundIndex: number): {
40
+ export declare function getElementsAround<T>(array: T[], aroundIndex: number): {
66
41
  next: T | undefined;
67
42
  previous: T | undefined;
68
43
  };
69
- export declare function getPluginI18nPath({ siteDir, locale, pluginName, pluginId, // TODO duplicated constant
70
- subPaths, }: {
44
+ export declare function getPluginI18nPath({ siteDir, locale, pluginName, pluginId, subPaths, }: {
71
45
  siteDir: string;
72
46
  locale: string;
73
47
  pluginName: string;
74
48
  pluginId?: string | undefined;
75
49
  subPaths?: string[];
76
50
  }): string;
77
- export declare function mapAsyncSequencial<T extends unknown, R extends unknown>(array: T[], action: (t: T) => Promise<R>): Promise<R[]>;
51
+ /**
52
+ * @param permalink The URL that the HTML file corresponds to, without base URL
53
+ * @param outDir Full path to the output directory
54
+ * @param trailingSlash The site config option. If provided, only one path will
55
+ * be read.
56
+ * @returns This returns a buffer, which you have to decode string yourself if
57
+ * needed. (Not always necessary since the output isn't for human consumption
58
+ * anyways, and most HTML manipulation libs accept buffers)
59
+ */
60
+ export declare function readOutputHTMLFile(permalink: string, outDir: string, trailingSlash: boolean | undefined): Promise<Buffer>;
61
+ export declare function mapAsyncSequential<T, R>(array: T[], action: (t: T) => Promise<R>): Promise<R[]>;
78
62
  export declare function findAsyncSequential<T>(array: T[], predicate: (t: T) => Promise<boolean>): Promise<T | undefined>;
79
- export declare function findFolderContainingFile(folderPaths: string[], relativeFilePath: string): Promise<string | undefined>;
80
- export declare function getFolderContainingFile(folderPaths: string[], relativeFilePath: string): Promise<string>;
81
63
  export declare function reportMessage(message: string, reportingSeverity: ReportingSeverity): void;
82
64
  export declare function mergeTranslations(contents: TranslationFileContent[]): TranslationFileContent;
83
- export declare function getSwizzledComponent(componentPath: string): string | undefined;
84
65
  export declare function updateTranslationFileMessages(translationFile: TranslationFile, updateMessage: (message: string) => string): TranslationFile;
85
- export declare function parseMarkdownHeadingId(heading: string): {
86
- text: string;
87
- id?: string;
88
- };
66
+ //# sourceMappingURL=index.d.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