@@ -28,7 +28,7 @@ GITHUB_API_TOKEN_READONLY=xxxxx
28
28
{
29
29
"type" : " module" ,
30
30
"dependencies" : {
31
- "doxdox-fetch" : " 1 .0.0"
31
+ "doxdox-fetch" : " 2 .0.0"
32
32
},
33
33
"devDependencies" : {
34
34
"dotenv" : " 16.0.0"
@@ -45,23 +45,31 @@ GITHUB_API_TOKEN_READONLY=xxxxx
45
45
``` javascript
46
46
import { downloadFile , getRepoData , parseFiles } from ' doxdox-fetch' ;
47
47
48
+ import { parseString } from ' doxdox-parser-custom' ;
49
+
50
+ import { Doc } from ' doxdox-core/dist/types' ;
51
+
48
52
(async () => {
49
- const data = await getRepoData (' neogeek ' , ' pocket-sized-facade.js ' , {
53
+ const repoData = await getRepoData (username, repo , {
50
54
GITHUB_API_TOKEN : process .env .GITHUB_API_TOKEN_READONLY
51
55
});
52
56
53
- const files = await downloadFile (
54
- ' neogeek' ,
55
- ' pocket-sized-facade.js' ,
56
- data .default_branch ,
57
- [/ . js$ / , / package. json$ / , / \. doxdoxignore$ / ]
58
- );
57
+ const currentBranch =
58
+ branch && [repoData .default_branch , ... repoData .tags ].includes (branch)
59
+ ? branch
60
+ : repoData .default_branch ;
61
+
62
+ const files = await downloadFile (username, repo, currentBranch, [
63
+ / . [jt] sx? $ / ,
64
+ / package. json$ / ,
65
+ / \. doxdoxignore$ /
66
+ ]);
59
67
60
68
const jsFiles = files .filter (
61
69
({ path }) =>
62
- path .match (/ \. js $ / ) &&
63
- ! path .match (/ \. min\. js $ / ) &&
64
- ! path .match (/ \. test\. js $ / ) &&
70
+ path .match (/ \. [jt] sx ? $ / ) &&
71
+ ! path .match (/ \. min\. [jt] sx ? $ / ) &&
72
+ ! path .match (/ \. test\. [jt] sx ? $ / ) &&
65
73
! path .match (/ ^ dist\/ / ) &&
66
74
! path .match (/ __tests__\/ / )
67
75
);
@@ -70,11 +78,11 @@ import { downloadFile, getRepoData, parseFiles } from 'doxdox-fetch';
70
78
71
79
const pkgFileContents = JSON .parse (pkgFile? .content || ' {}' );
72
80
73
- const doc = {
74
- name: pkgFileContents .name || data .name ,
75
- description: pkgFileContents .description || data .description ,
76
- homepage: pkgFileContents .homepage || data .html_url ,
77
- files: await parseFiles (jsFiles)
81
+ const doc: Doc = {
82
+ name: pkgFileContents .name || repoData .name ,
83
+ description: pkgFileContents .description || repoData .description ,
84
+ homepage: pkgFileContents .homepage || repoData .html_url ,
85
+ files: await parseFiles (jsFiles, parseString )
78
86
};
79
87
80
88
console .log (doc);
0 commit comments