mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 22:28:48 +02:00
fixed undefined errors
This commit is contained in:
parent
22065ad611
commit
6cb4901bae
4 changed files with 710 additions and 50 deletions
|
@ -1,18 +1,20 @@
|
||||||
var fs = require('fs');
|
var fs = require('fs');
|
||||||
var path = require('path');
|
var path = require('path');
|
||||||
var request = require('request');
|
var request = require('request');
|
||||||
|
var axios = require('axios');
|
||||||
|
|
||||||
var badLinks = [];
|
var badLinks = [];
|
||||||
var baseLink = `http://localhost:8000/api-reference/`;
|
// var baseLink = `http://localhost:8000/api-reference/`;
|
||||||
|
var baseLink = `https://docs.highfidelity.com`;
|
||||||
var linkList = fs.readFileSync(__dirname + '/Links-Untouched','utf8').split('\n');
|
var linkList = fs.readFileSync(__dirname + '/Links-Untouched','utf8').split('\n');
|
||||||
console.log("link list", linkList);
|
// console.log("link list", linkList);
|
||||||
// console.log("filtered List", JSON.stringify(filteredList));
|
// console.log("filtered List", JSON.stringify(filteredList));
|
||||||
var linkHash = {};
|
var linkHash = {};
|
||||||
|
|
||||||
var currentGroup;
|
var currentGroup;
|
||||||
linkList.forEach( link => {
|
linkList.forEach( link => {
|
||||||
link = link.trim()
|
link = link.trim()
|
||||||
console.log("link", link)
|
// console.log("link", link)
|
||||||
if (link.slice(-1) === ':'){
|
if (link.slice(-1) === ':'){
|
||||||
currentGroup = link.slice(0, link.length-1);
|
currentGroup = link.slice(0, link.length-1);
|
||||||
// console.log("current Group: ", currentGroup);
|
// console.log("current Group: ", currentGroup);
|
||||||
|
@ -35,37 +37,39 @@ var keys = Object.keys(linkHash);
|
||||||
keys.forEach( key => {
|
keys.forEach( key => {
|
||||||
for (var linkKey in linkHash[key]){
|
for (var linkKey in linkHash[key]){
|
||||||
var link = linkHash[key][linkKey];
|
var link = linkHash[key][linkKey];
|
||||||
console.log("link", link);
|
// console.log("link", link);
|
||||||
var extractLink = link.split(`"`)[1];
|
var extractLink = link.split(`"`)[1];
|
||||||
console.log("extractLink", extractLink)
|
|
||||||
if (!extractLink.indexOf('http') > -1){
|
|
||||||
extractLink = baseLink + extractLink;
|
|
||||||
}
|
|
||||||
console.log("about to make a request for", extractLink)
|
|
||||||
setTimeout(function(){
|
|
||||||
request.get(extractLink)
|
|
||||||
.on('response', response => {
|
|
||||||
if (response.statusCode(404)){
|
|
||||||
console.log("found bad link")
|
|
||||||
console.log(JSON.stringify({file: key, link: extractLink}))
|
|
||||||
|
|
||||||
// badLinks.push({file: key, link: link})
|
|
||||||
stream.write(JSON.stringify({file: key, link: extractLink}));
|
|
||||||
}
|
|
||||||
}, 4000)
|
|
||||||
})
|
|
||||||
|
|
||||||
}
|
if (!(extractLink.indexOf(':') > -1)){
|
||||||
|
console.log(" adding link")
|
||||||
|
extractLink = baseLink + extractLink;
|
||||||
|
} else {
|
||||||
|
// console.log("found https")
|
||||||
|
}
|
||||||
|
console.log("extractLink", extractLink)
|
||||||
|
|
||||||
})
|
// console.log("about to make a request for", extractLink)
|
||||||
|
axios.get(extractLink)
|
||||||
|
.then( response => {
|
||||||
|
console.log("response")
|
||||||
|
if (response.status === 404){
|
||||||
|
console.log("found bad link")
|
||||||
|
// console.log(JSON.stringify({file: key, link: extractLink}))
|
||||||
|
// stream.write(JSON.stringify({file: key, link: extractLink}));
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch( error => {
|
||||||
|
console.log("error")
|
||||||
|
// console.log(error);
|
||||||
|
// if (error.response.status === 404){
|
||||||
|
// console.log("found bad link")
|
||||||
|
// console.log(JSON.stringify({file: key, link: extractLink}))
|
||||||
|
// stream.write(JSON.stringify({file: key, link: extractLink}));
|
||||||
|
// }
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
stream.end();
|
stream.end();
|
||||||
// */
|
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function endsWith(path, exts) {
|
function endsWith(path, exts) {
|
||||||
var result = false;
|
var result = false;
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -115,10 +115,14 @@
|
||||||
function modifyClassLinks(match, p1,p2,p3,p4){
|
function modifyClassLinks(match, p1,p2,p3,p4){
|
||||||
let matchedp = [p2,p3].join("");
|
let matchedp = [p2,p3].join("");
|
||||||
if(!isMultipleDots(matchedp)){
|
if(!isMultipleDots(matchedp)){
|
||||||
return;
|
console.log("not multiple");
|
||||||
|
console.log("matchedp:", matchedp)
|
||||||
|
return match;
|
||||||
}
|
}
|
||||||
p2 = p2.split('.')[1].toLowerCase();
|
p2 = p2.split('.')[1].toLowerCase();
|
||||||
return [p1,p2,p3,p4].join("");
|
let newString = [p1,p2,p3,p4].join("");
|
||||||
|
// console.log("new String:", newString);
|
||||||
|
return newString;
|
||||||
}
|
}
|
||||||
|
|
||||||
function lowerCaseGeneralLinks(match, p1, p2, p3, p4){
|
function lowerCaseGeneralLinks(match, p1, p2, p3, p4){
|
||||||
|
@ -136,7 +140,7 @@
|
||||||
}
|
}
|
||||||
if (!linksNoHashes){
|
if (!linksNoHashes){
|
||||||
return content;
|
return content;
|
||||||
}
|
}
|
||||||
for(var i = linksNoHashes.length-1; i > -1; i--){
|
for(var i = linksNoHashes.length-1; i > -1; i--){
|
||||||
if (linksNoHashes[i][0].indexOf("http") > -1){
|
if (linksNoHashes[i][0].indexOf("http") > -1){
|
||||||
continue;
|
continue;
|
||||||
|
@ -149,7 +153,8 @@
|
||||||
}
|
}
|
||||||
let group3 = linksNoHashes[i][3];
|
let group3 = linksNoHashes[i][3];
|
||||||
let index = linksNoHashes[i][4];
|
let index = linksNoHashes[i][4];
|
||||||
let newString = `${group1}/api-reference/${returnRightGroup(group2)}/${group2.toLowerCase()}${group3}`;
|
let newString = `${group1}/api-reference/${returnRightGroup(group2)}/${group2.toLowerCase()}${group3}`;
|
||||||
|
// console.log("newString", newString);
|
||||||
content = [content.slice(0,index), newString, content.slice(index+linkLength)].join("");
|
content = [content.slice(0,index), newString, content.slice(index+linkLength)].join("");
|
||||||
}
|
}
|
||||||
return content;
|
return content;
|
||||||
|
@ -161,6 +166,8 @@
|
||||||
for (i = 0; i < groupNameMemberMap[key].length; i++ ){
|
for (i = 0; i < groupNameMemberMap[key].length; i++ ){
|
||||||
if (methodToCheck.toLowerCase() === groupNameMemberMap[key][i].toLowerCase()){
|
if (methodToCheck.toLowerCase() === groupNameMemberMap[key][i].toLowerCase()){
|
||||||
return key.toLowerCase();
|
return key.toLowerCase();
|
||||||
|
} else {
|
||||||
|
// console.log("Couldn't find group: ", methodToCheck);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "hifiJSDoc",
|
"name": "hifiJSDoc",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"axios": "^0.18.0",
|
||||||
"cheerio": "^1.0.0-rc.2",
|
"cheerio": "^1.0.0-rc.2",
|
||||||
"dedent-js": "^1.0.1",
|
"dedent-js": "^1.0.1",
|
||||||
"htmlclean": "^3.0.8",
|
"htmlclean": "^3.0.8",
|
||||||
|
|
Loading…
Reference in a new issue