-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: broken links & improve link checker (#147)
* fix: broken links --------- Co-authored-by: Call Delegation <106365423+calldelegation@users.noreply.github.com>
- Loading branch information
1 parent
8a94cbd
commit c686cbc
Showing
12 changed files
with
296 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import { readFileSync, writeFileSync } from 'fs'; | ||
import { EOL } from 'os'; | ||
import { join } from 'path'; | ||
|
||
const constantsPath = join( | ||
process.cwd(), | ||
'docs/fuels-wallet/packages/docs/src/constants.ts' | ||
); | ||
const nightlyConstantsPath = | ||
'docs/nightly/fuels-wallet/packages/docs/src/constants.ts'; | ||
|
||
const downloadVarName = 'DOWNLOAD_LINK'; | ||
|
||
function getWalletVersion(isNightly) { | ||
const file = readFileSync( | ||
join( | ||
process.cwd(), | ||
`docs/${ | ||
isNightly ? 'nightly/' : '' | ||
}fuels-wallet/packages/app/package.json` | ||
), | ||
'utf-8' | ||
); | ||
const json = JSON.parse(file); | ||
return json.version; | ||
} | ||
|
||
function handleConstantsFile(filePath, isNightly) { | ||
const file = readFileSync(filePath, 'utf8'); | ||
|
||
let lines = file.split(EOL); | ||
let start; | ||
let end; | ||
|
||
for (let i = 0; i < lines.length; i++) { | ||
if (!start) { | ||
if (lines[i].includes(downloadVarName)) { | ||
start = i; | ||
} | ||
} else if (!end) { | ||
if (lines[i].endsWith(';')) { | ||
end = i; | ||
} | ||
} | ||
} | ||
|
||
const walletVersion = getWalletVersion(isNightly); | ||
|
||
if (start !== undefined && end !== undefined && walletVersion) { | ||
let modifiedContent = `export const DOWNLOAD_LINK = 'https://next-wallet.fuel.network/app/fuel-wallet-${walletVersion}.zip';`; | ||
lines.splice(start, end - start + 1, modifiedContent); | ||
const newFileContent = lines.join(EOL); | ||
writeFileSync(filePath, newFileContent, 'utf8'); | ||
|
||
console.log('File modified successfully'); | ||
} else { | ||
console.log('Variable definition not found or incomplete.'); | ||
} | ||
} | ||
|
||
export default function patchFixWalletDownloadLink() { | ||
handleConstantsFile(constantsPath, false); | ||
handleConstantsFile(nightlyConstantsPath, true); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import patchFixWalletDownloadLink from './download-link.mjs'; | ||
import patchFixWalletExamples from './wallet-examples.mjs'; | ||
|
||
function main() { | ||
patchFixWalletExamples(); | ||
patchFixWalletDownloadLink(); | ||
} | ||
|
||
main(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.