git hook to fix readme when i commit as well as watchlist populator to speed up setting up all cc's for a deploy
This commit is contained in:
29
src/utils/bookmarklets/rbcSiteNavigator.js
Normal file
29
src/utils/bookmarklets/rbcSiteNavigator.js
Normal file
@@ -0,0 +1,29 @@
|
||||
|
||||
/**
|
||||
* Opens a specific URL based on the provided environment and language.
|
||||
* Prompts the user to enter the environment and language in the format 'prod|ste,en|fr'.
|
||||
* If the input is valid, it opens the corresponding URL in a new tab.
|
||||
* If the input is invalid, it logs an error message to the console.
|
||||
*/
|
||||
javascript: (function () {
|
||||
const answer = prompt("Please enter the env and language in the format 'prod|ste,en|fr':");
|
||||
const [env, language] = answer.split(",");
|
||||
switch (env) {
|
||||
case "prod":
|
||||
if (language === "fr") {
|
||||
window.open("https://www1.royalbank.com/french/netaction/sgnf.html", "_blank").focus();
|
||||
} else {
|
||||
window.open("https://www1.royalbank.com/english/netaction/sgne.html", "_blank").focus();
|
||||
}
|
||||
break;
|
||||
case "ste":
|
||||
if (language === "fr") {
|
||||
window.open("https://www1.steroyalbank.com/french/netaction/sgnf.html", "_blank").focus();
|
||||
} else {
|
||||
window.open("https://www1.steroyalbank.com/english/netaction/sgne.html", "_blank").focus();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
console.log("Invalid input");
|
||||
}
|
||||
})();
|
||||
48
src/utils/bookmarklets/rbcWatchlistPopulator.js
Normal file
48
src/utils/bookmarklets/rbcWatchlistPopulator.js
Normal file
@@ -0,0 +1,48 @@
|
||||
/**
|
||||
This code is a bookmarklet that populates a watchlist on a web page.
|
||||
It defines an array of new securities and a function called populateWatchlist.
|
||||
The function finds the input field on the page, iterates over the new securities array,
|
||||
and sets the value of the input field to each security in the array.
|
||||
It then triggers events to simulate user input and key presses to add the security to the watchlist.
|
||||
The process repeats for each security in the array with a delay of 2.5 seconds between each iteration.
|
||||
The code is executed when the bookmarklet is clicked on the web page.
|
||||
*/
|
||||
javascript: (function () {
|
||||
const newSecurities = [
|
||||
'AMX',
|
||||
'VNORP',
|
||||
'AMBKP',
|
||||
'CSU.DB',
|
||||
'NFLX',
|
||||
'ICFSSUSN',
|
||||
'ICRP',
|
||||
'LDSVF',
|
||||
'AMTPQ',
|
||||
'DSHKP',
|
||||
'AITRR',
|
||||
'URW',
|
||||
'AP.UN',
|
||||
'PVF.WT'
|
||||
];
|
||||
function populateWatchlist() {
|
||||
const foundInputs = document.querySelectorAll('.rbc-typeahead-search-input');
|
||||
const input = foundInputs && foundInputs.length > 1 ? foundInputs[1] : null;
|
||||
if (input) {
|
||||
let index = 0;
|
||||
const interval = setInterval(() => {
|
||||
if (index >= newSecurities.length) {
|
||||
clearInterval(interval);
|
||||
return;
|
||||
}
|
||||
input.value = newSecurities[index];
|
||||
input.dispatchEvent(new Event('input', { bubbles: true }));
|
||||
input.dispatchEvent(new Event('change', { bubbles: true }));
|
||||
setTimeout(() => {
|
||||
input.dispatchEvent(new KeyboardEvent('keydown', { keyCode: 13 }));
|
||||
}, 1000);
|
||||
index++;
|
||||
}, 2500);
|
||||
}
|
||||
}
|
||||
populateWatchlist();
|
||||
})();
|
||||
68
src/utils/git/updateReadme.js
Normal file
68
src/utils/git/updateReadme.js
Normal file
@@ -0,0 +1,68 @@
|
||||
|
||||
/**
|
||||
* This file is responsible for updating the README file with file links and descriptions.
|
||||
* It reads the files in the specified directory, extracts their descriptions, and generates
|
||||
* markdown links for each file. Then, it updates the README file with the generated links
|
||||
* and descriptions.
|
||||
*/
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
const resolvedPath = path.resolve();
|
||||
console.log(resolvedPath);
|
||||
|
||||
const utilsDir = path.join(resolvedPath, 'src/utils');
|
||||
const readmePath = path.join(resolvedPath, 'README.md');
|
||||
|
||||
fs.readdir(utilsDir, (err, files) => {
|
||||
function readDirectory(dir) {
|
||||
const files = fs.readdirSync(dir);
|
||||
const fileLinks = [];
|
||||
|
||||
files.forEach((file) => {
|
||||
const filePath = path.join(dir, file);
|
||||
const stats = fs.statSync(filePath);
|
||||
|
||||
if (stats.isFile()) {
|
||||
const fileContent = fs.readFileSync(filePath, 'utf8');
|
||||
const description = getFileDescription(fileContent);
|
||||
fileLinks.push(`## [${file}](${path.relative(resolvedPath, filePath)})\n\n${description}`);
|
||||
} else if (stats.isDirectory()) {
|
||||
fileLinks.push(...readDirectory(filePath));
|
||||
}
|
||||
});
|
||||
|
||||
return fileLinks;
|
||||
}
|
||||
|
||||
const fileLinks = readDirectory(utilsDir);
|
||||
|
||||
const readmeContent = fs.readFileSync(readmePath, 'utf8');
|
||||
let updatedReadmeContent = updateReadmeContent(readmeContent, fileLinks);
|
||||
fs.writeFileSync(readmePath, updatedReadmeContent, 'utf8');
|
||||
|
||||
console.log('README updated successfully!');
|
||||
});
|
||||
|
||||
function getFileDescription(fileContent) {
|
||||
// Extract the description from the function comment in the file
|
||||
// You can use regular expressions or any other method to extract the description
|
||||
// Replace the following line with your implementation
|
||||
const descriptionRegex = /\/\*(.*?)\*\//s;
|
||||
const match = fileContent.match(descriptionRegex);
|
||||
const description = match ? match[1].trim().replace(/^\s*\* ?/gm, '') : 'No Description Provided';
|
||||
// const description = match ? match[1].trim().replace(/^\*/gm, '') : 'No Description Provided';
|
||||
|
||||
return description;
|
||||
}
|
||||
|
||||
function updateReadmeContent(readmeContent, fileLinks) {
|
||||
const readmeSummaryIndex = readmeContent.indexOf('# File Summary');
|
||||
if (readmeSummaryIndex !== -1) {
|
||||
// If '# File Summary' is found, keep everything before it
|
||||
readmeContent = readmeContent.slice(0, readmeSummaryIndex);
|
||||
}
|
||||
// Append the new '# File Summary' section
|
||||
readmeContent += '# File Summary\n\n' + fileLinks.join('\n\n');
|
||||
return readmeContent;
|
||||
}
|
||||
Reference in New Issue
Block a user