@docusaurus/utils 2.0.0-beta.fc64c12e4 → 2.0.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.
- package/lib/constants.d.ts +73 -0
- package/lib/constants.d.ts.map +1 -0
- package/lib/constants.js +78 -0
- package/lib/constants.js.map +1 -0
- package/lib/dataFileUtils.d.ts +60 -0
- package/lib/dataFileUtils.d.ts.map +1 -0
- package/lib/dataFileUtils.js +91 -0
- package/lib/dataFileUtils.js.map +1 -0
- package/lib/emitUtils.d.ts +32 -0
- package/lib/emitUtils.d.ts.map +1 -0
- package/lib/emitUtils.js +80 -0
- package/lib/emitUtils.js.map +1 -0
- package/lib/gitUtils.d.ts +66 -0
- package/lib/gitUtils.d.ts.map +1 -0
- package/lib/gitUtils.js +63 -0
- package/lib/gitUtils.js.map +1 -0
- package/lib/globUtils.d.ts +29 -0
- package/lib/globUtils.d.ts.map +1 -0
- package/lib/globUtils.js +36 -12
- package/lib/globUtils.js.map +1 -0
- package/lib/hashUtils.d.ts +6 -4
- package/lib/hashUtils.d.ts.map +1 -0
- package/lib/hashUtils.js +13 -10
- package/lib/hashUtils.js.map +1 -0
- package/lib/i18nUtils.d.ts +53 -0
- package/lib/i18nUtils.d.ts.map +1 -0
- package/lib/i18nUtils.js +70 -0
- package/lib/i18nUtils.js.map +1 -0
- package/lib/index.d.ts +15 -75
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +86 -395
- package/lib/index.js.map +1 -0
- package/lib/jsUtils.d.ts +28 -0
- package/lib/jsUtils.d.ts.map +1 -0
- package/lib/jsUtils.js +57 -0
- package/lib/jsUtils.js.map +1 -0
- package/lib/markdownLinks.d.ts +49 -5
- package/lib/markdownLinks.d.ts.map +1 -0
- package/lib/markdownLinks.js +57 -13
- package/lib/markdownLinks.js.map +1 -0
- package/lib/markdownUtils.d.ts +112 -0
- package/lib/markdownUtils.d.ts.map +1 -0
- package/lib/markdownUtils.js +271 -0
- package/lib/markdownUtils.js.map +1 -0
- package/lib/pathUtils.d.ts +45 -1
- package/lib/pathUtils.d.ts.map +1 -0
- package/lib/pathUtils.js +92 -12
- package/lib/pathUtils.js.map +1 -0
- package/lib/shellUtils.d.ts +8 -0
- package/lib/shellUtils.d.ts.map +1 -0
- package/lib/shellUtils.js +21 -0
- package/lib/shellUtils.js.map +1 -0
- package/lib/slugger.d.ts +24 -0
- package/lib/slugger.d.ts.map +1 -0
- package/lib/slugger.js +23 -0
- package/lib/slugger.js.map +1 -0
- package/lib/tags.d.ts +59 -0
- package/lib/tags.d.ts.map +1 -0
- package/lib/tags.js +91 -0
- package/lib/tags.js.map +1 -0
- package/lib/urlUtils.d.ts +66 -0
- package/lib/urlUtils.d.ts.map +1 -0
- package/lib/urlUtils.js +207 -0
- package/lib/urlUtils.js.map +1 -0
- package/lib/webpackUtils.d.ts +35 -0
- package/lib/webpackUtils.d.ts.map +1 -0
- package/lib/webpackUtils.js +115 -0
- package/lib/webpackUtils.js.map +1 -0
- package/package.json +27 -12
- package/src/constants.ts +98 -0
- package/src/dataFileUtils.ts +122 -0
- package/src/deps.d.ts +10 -0
- package/src/emitUtils.ts +99 -0
- package/src/gitUtils.ts +146 -0
- package/src/globUtils.ts +37 -15
- package/src/hashUtils.ts +9 -8
- package/src/i18nUtils.ts +114 -0
- package/src/index.ts +91 -502
- package/src/jsUtils.ts +59 -0
- package/src/markdownLinks.ts +101 -30
- package/src/markdownUtils.ts +357 -0
- package/src/pathUtils.ts +93 -12
- package/src/shellUtils.ts +18 -0
- package/src/slugger.ts +36 -0
- package/src/tags.ts +130 -0
- package/src/urlUtils.ts +234 -0
- package/src/webpackUtils.ts +153 -0
- package/lib/.tsbuildinfo +0 -1
- package/lib/codeTranslationsUtils.d.ts +0 -11
- package/lib/codeTranslationsUtils.js +0 -50
- package/lib/escapePath.d.ts +0 -17
- package/lib/escapePath.js +0 -25
- package/lib/markdownParser.d.ts +0 -30
- package/lib/markdownParser.js +0 -140
- package/lib/posixPath.d.ts +0 -14
- package/lib/posixPath.js +0 -28
- package/src/__tests__/__fixtures__/defaultCodeTranslations/en.json +0 -4
- package/src/__tests__/__fixtures__/defaultCodeTranslations/fr-FR.json +0 -5
- package/src/__tests__/__fixtures__/defaultCodeTranslations/fr.json +0 -4
- package/src/__tests__/__snapshots__/index.test.ts.snap +0 -8
- package/src/__tests__/codeTranslationsUtils.test.ts +0 -112
- package/src/__tests__/escapePath.test.ts +0 -25
- package/src/__tests__/globUtils.test.ts +0 -109
- package/src/__tests__/hashUtils.test.ts +0 -51
- package/src/__tests__/index.test.ts +0 -631
- package/src/__tests__/markdownParser.test.ts +0 -817
- package/src/__tests__/pathUtils.test.ts +0 -63
- package/src/__tests__/posixPath.test.ts +0 -25
- package/src/codeTranslationsUtils.ts +0 -56
- package/src/escapePath.ts +0 -23
- package/src/markdownParser.ts +0 -182
- package/src/posixPath.ts +0 -27
- package/tsconfig.json +0 -9
|
@@ -1,25 +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
|
-
|
|
8
|
-
import {escapePath} from '../escapePath';
|
|
9
|
-
|
|
10
|
-
describe('escapePath', () => {
|
|
11
|
-
test('escapePath works', () => {
|
|
12
|
-
const asserts: Record<string, string> = {
|
|
13
|
-
'c:/aaaa\\bbbb': 'c:/aaaa\\\\bbbb',
|
|
14
|
-
'c:\\aaaa\\bbbb\\★': 'c:\\\\aaaa\\\\bbbb\\\\★',
|
|
15
|
-
'\\\\?\\c:\\aaaa\\bbbb': '\\\\\\\\?\\\\c:\\\\aaaa\\\\bbbb',
|
|
16
|
-
'c:\\aaaa\\bbbb': 'c:\\\\aaaa\\\\bbbb',
|
|
17
|
-
'foo\\bar': 'foo\\\\bar',
|
|
18
|
-
'foo\\bar/lol': 'foo\\\\bar/lol',
|
|
19
|
-
'website\\docs/**/*.{md,mdx}': 'website\\\\docs/**/*.{md,mdx}',
|
|
20
|
-
};
|
|
21
|
-
Object.keys(asserts).forEach((file) => {
|
|
22
|
-
expect(escapePath(file)).toBe(asserts[file]);
|
|
23
|
-
});
|
|
24
|
-
});
|
|
25
|
-
});
|
|
@@ -1,109 +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
|
-
|
|
8
|
-
import {
|
|
9
|
-
GlobExcludeDefault,
|
|
10
|
-
createMatcher,
|
|
11
|
-
createAbsoluteFilePathMatcher,
|
|
12
|
-
} from '../globUtils';
|
|
13
|
-
|
|
14
|
-
describe('createMatcher', () => {
|
|
15
|
-
const matcher = createMatcher(GlobExcludeDefault);
|
|
16
|
-
|
|
17
|
-
test('match default exclude MD/MDX partials correctly', () => {
|
|
18
|
-
expect(matcher('doc.md')).toEqual(false);
|
|
19
|
-
expect(matcher('category/doc.md')).toEqual(false);
|
|
20
|
-
expect(matcher('category/subcategory/doc.md')).toEqual(false);
|
|
21
|
-
//
|
|
22
|
-
expect(matcher('doc.mdx')).toEqual(false);
|
|
23
|
-
expect(matcher('category/doc.mdx')).toEqual(false);
|
|
24
|
-
expect(matcher('category/subcategory/doc.mdx')).toEqual(false);
|
|
25
|
-
//
|
|
26
|
-
expect(matcher('_doc.md')).toEqual(true);
|
|
27
|
-
expect(matcher('category/_doc.md')).toEqual(true);
|
|
28
|
-
expect(matcher('category/subcategory/_doc.md')).toEqual(true);
|
|
29
|
-
expect(matcher('_category/doc.md')).toEqual(true);
|
|
30
|
-
expect(matcher('_category/subcategory/doc.md')).toEqual(true);
|
|
31
|
-
expect(matcher('category/_subcategory/doc.md')).toEqual(true);
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
test('match default exclude tests correctly', () => {
|
|
35
|
-
expect(matcher('xyz.js')).toEqual(false);
|
|
36
|
-
expect(matcher('xyz.ts')).toEqual(false);
|
|
37
|
-
expect(matcher('xyz.jsx')).toEqual(false);
|
|
38
|
-
expect(matcher('xyz.tsx')).toEqual(false);
|
|
39
|
-
expect(matcher('folder/xyz.js')).toEqual(false);
|
|
40
|
-
expect(matcher('folder/xyz.ts')).toEqual(false);
|
|
41
|
-
expect(matcher('folder/xyz.jsx')).toEqual(false);
|
|
42
|
-
expect(matcher('folder/xyz.tsx')).toEqual(false);
|
|
43
|
-
//
|
|
44
|
-
expect(matcher('xyz.test.js')).toEqual(true);
|
|
45
|
-
expect(matcher('xyz.test.ts')).toEqual(true);
|
|
46
|
-
expect(matcher('xyz.test.jsx')).toEqual(true);
|
|
47
|
-
expect(matcher('xyz.test.tsx')).toEqual(true);
|
|
48
|
-
expect(matcher('folder/xyz.test.js')).toEqual(true);
|
|
49
|
-
expect(matcher('folder/xyz.test.ts')).toEqual(true);
|
|
50
|
-
expect(matcher('folder/xyz.test.jsx')).toEqual(true);
|
|
51
|
-
expect(matcher('folder/xyz.test.tsx')).toEqual(true);
|
|
52
|
-
expect(matcher('folder/subfolder/xyz.test.js')).toEqual(true);
|
|
53
|
-
expect(matcher('folder/subfolder/xyz.test.ts')).toEqual(true);
|
|
54
|
-
expect(matcher('folder/subfolder/xyz.test.jsx')).toEqual(true);
|
|
55
|
-
expect(matcher('folder/subfolder/xyz.test.tsx')).toEqual(true);
|
|
56
|
-
//
|
|
57
|
-
expect(matcher('__tests__/subfolder/xyz.js')).toEqual(true);
|
|
58
|
-
expect(matcher('__tests__/subfolder/xyz.ts')).toEqual(true);
|
|
59
|
-
expect(matcher('__tests__/subfolder/xyz.jsx')).toEqual(true);
|
|
60
|
-
expect(matcher('__tests__/subfolder/xyz.tsx')).toEqual(true);
|
|
61
|
-
expect(matcher('folder/__tests__/xyz.js')).toEqual(true);
|
|
62
|
-
expect(matcher('folder/__tests__/xyz.ts')).toEqual(true);
|
|
63
|
-
expect(matcher('folder/__tests__/xyz.jsx')).toEqual(true);
|
|
64
|
-
expect(matcher('folder/__tests__/xyz.tsx')).toEqual(true);
|
|
65
|
-
});
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
describe('createAbsoluteFilePathMatcher', () => {
|
|
69
|
-
const rootFolders = ['/_root/docs', '/root/_docs/', '/__test__/website/src'];
|
|
70
|
-
|
|
71
|
-
const matcher = createAbsoluteFilePathMatcher(
|
|
72
|
-
GlobExcludeDefault,
|
|
73
|
-
rootFolders,
|
|
74
|
-
);
|
|
75
|
-
|
|
76
|
-
test('match default exclude MD/MDX partials correctly', () => {
|
|
77
|
-
expect(matcher('/_root/docs/myDoc.md')).toEqual(false);
|
|
78
|
-
expect(matcher('/_root/docs/myDoc.mdx')).toEqual(false);
|
|
79
|
-
expect(matcher('/root/_docs/myDoc.md')).toEqual(false);
|
|
80
|
-
expect(matcher('/root/_docs/myDoc.mdx')).toEqual(false);
|
|
81
|
-
expect(matcher('/_root/docs/category/myDoc.md')).toEqual(false);
|
|
82
|
-
expect(matcher('/_root/docs/category/myDoc.mdx')).toEqual(false);
|
|
83
|
-
expect(matcher('/root/_docs/category/myDoc.md')).toEqual(false);
|
|
84
|
-
expect(matcher('/root/_docs/category/myDoc.mdx')).toEqual(false);
|
|
85
|
-
//
|
|
86
|
-
expect(matcher('/_root/docs/_myDoc.md')).toEqual(true);
|
|
87
|
-
expect(matcher('/_root/docs/_myDoc.mdx')).toEqual(true);
|
|
88
|
-
expect(matcher('/root/_docs/_myDoc.md')).toEqual(true);
|
|
89
|
-
expect(matcher('/root/_docs/_myDoc.mdx')).toEqual(true);
|
|
90
|
-
expect(matcher('/_root/docs/_category/myDoc.md')).toEqual(true);
|
|
91
|
-
expect(matcher('/_root/docs/_category/myDoc.mdx')).toEqual(true);
|
|
92
|
-
expect(matcher('/root/_docs/_category/myDoc.md')).toEqual(true);
|
|
93
|
-
expect(matcher('/root/_docs/_category/myDoc.mdx')).toEqual(true);
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
test('match default exclude tests correctly', () => {
|
|
97
|
-
expect(matcher('/__test__/website/src/xyz.js')).toEqual(false);
|
|
98
|
-
expect(matcher('/__test__/website/src/__test__/xyz.js')).toEqual(true);
|
|
99
|
-
expect(matcher('/__test__/website/src/xyz.test.js')).toEqual(true);
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
test('throw if file is not contained in any root doc', () => {
|
|
103
|
-
expect(() =>
|
|
104
|
-
matcher('/bad/path/myDoc.md'),
|
|
105
|
-
).toThrowErrorMatchingInlineSnapshot(
|
|
106
|
-
`"createAbsoluteFilePathMatcher unexpected error, absoluteFilePath=/bad/path/myDoc.md was not contained in any of the root folders [\\"/_root/docs\\",\\"/root/_docs/\\",\\"/__test__/website/src\\"]"`,
|
|
107
|
-
);
|
|
108
|
-
});
|
|
109
|
-
});
|
|
@@ -1,51 +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
|
-
|
|
8
|
-
import {simpleHash, docuHash} from '../hashUtils';
|
|
9
|
-
|
|
10
|
-
describe('hashUtils', () => {
|
|
11
|
-
test('simpleHash', () => {
|
|
12
|
-
const asserts: Record<string, string> = {
|
|
13
|
-
'': 'd41',
|
|
14
|
-
'/foo-bar': '096',
|
|
15
|
-
'/foo/bar': '1df',
|
|
16
|
-
'/endi/lie': '9fa',
|
|
17
|
-
'/endi-lie': 'fd3',
|
|
18
|
-
'/yangshun/tay': '48d',
|
|
19
|
-
'/yangshun-tay': 'f3b',
|
|
20
|
-
'/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar':
|
|
21
|
-
'd46',
|
|
22
|
-
'/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/test1-test2':
|
|
23
|
-
'787',
|
|
24
|
-
};
|
|
25
|
-
Object.keys(asserts).forEach((str) => {
|
|
26
|
-
expect(simpleHash(str, 3)).toBe(asserts[str]);
|
|
27
|
-
});
|
|
28
|
-
});
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
describe('docuHash', () => {
|
|
32
|
-
test('docuHash works', () => {
|
|
33
|
-
const asserts: Record<string, string> = {
|
|
34
|
-
'': '-d41',
|
|
35
|
-
'/': 'index',
|
|
36
|
-
'/foo-bar': 'foo-bar-096',
|
|
37
|
-
'/foo/bar': 'foo-bar-1df',
|
|
38
|
-
'/endi/lie': 'endi-lie-9fa',
|
|
39
|
-
'/endi-lie': 'endi-lie-fd3',
|
|
40
|
-
'/yangshun/tay': 'yangshun-tay-48d',
|
|
41
|
-
'/yangshun-tay': 'yangshun-tay-f3b',
|
|
42
|
-
'/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar':
|
|
43
|
-
'foo-bar-foo-bar-foo-bar-foo-bar-foo-bar-foo-bar-foo-bar-foo-bar-foo-bar-foo-bar-foo-bar-foo-bar-foo-bar-foo-bar-foo-bar-foo-bar-foo-bar-foo-bar-foo-bar-foo-bar-foo-bar-foo-bar-foo-bar-foo-bar-foo-bar-foo-bar-foo-bar-foo-bar-foo-bar-foo-bar-foo--d46',
|
|
44
|
-
'/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/foo/bar/test1-test2':
|
|
45
|
-
'foo-bar-foo-bar-foo-bar-foo-bar-foo-bar-foo-bar-foo-bar-foo-bar-foo-bar-foo-bar-foo-bar-foo-bar-foo-bar-foo-bar-foo-bar-foo-bar-foo-bar-foo-bar-foo-bar-foo-bar-foo-bar-foo-bar-foo-bar-foo-bar-foo-bar-foo-bar-foo-bar-foo-bar-foo-bar-test-1-test--787',
|
|
46
|
-
};
|
|
47
|
-
Object.keys(asserts).forEach((file) => {
|
|
48
|
-
expect(docuHash(file)).toBe(asserts[file]);
|
|
49
|
-
});
|
|
50
|
-
});
|
|
51
|
-
});
|