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:
69
README.MD
69
README.MD
@@ -1,39 +1,68 @@
|
|||||||
# Gregs Memory Palace
|
# Gregs Memory Palace
|
||||||
|
|
||||||
|
This project contains several files that perform various tasks. Here's a brief overview of each file:
|
||||||
|
|
||||||
|
# File Summary
|
||||||
|
|
||||||
This project contains several files that perform various tasks. Here's a brief overview of each file:
|
## [dag.js](src\utils\bookmarklets\dag.js)
|
||||||
|
|
||||||
## [DAG](src/utils/bookmarklets/dag.js)
|
|
||||||
Opens the DAG Task details page(s) based on user input.
|
Opens the DAG Task details page(s) based on user input.
|
||||||
This JavaScript file contains a bookmarklet function that prompts the user for a list of DAG Task numbers, separated by commas. For each provided number, it opens a new browser tab with the corresponding DAG Task details page. If the user doesn't provide any input, it opens the default DAG Tasks page in a new tab. This can be useful for quickly accessing multiple DAG Task details pages based on user input.
|
If user provides a comma-separated list of DAG Task numbers, it opens each task's details page in a new tab.
|
||||||
If user does not provide any input, it opens the default DAG Tasks page in a new tab.
|
If user does not provide any input, it opens the default DAG Tasks page in a new tab.
|
||||||
## [hashid](src/utils/bookmarklets/hashid.js)
|
|
||||||
## [hashid.js](src\utils\bookmarklets\hashid.js)
|
## [hashid.js](src\utils\bookmarklets\hashid.js)
|
||||||
This JavaScript file contains a bookmarklet function that takes a string, decodes it using decodeURIComponent, alerts the decoded string, and copies the result to the clipboard.
|
|
||||||
|
|
||||||
## [jira.js](src/utils/bookmarklets/jira.js)
|
This JavaScript function takes a string, decodes it using decodeURIComponent,
|
||||||
alerts the decoded string, and copies the result to the clipboard.
|
alerts the decoded string, and copies the result to the clipboard.
|
||||||
This JavaScript file contains a bookmarklet function that prompts the user for a JIRA ticket number and then opens a new browser tab with the corresponding JIRA page for that ticket.
|
|
||||||
The function works as follows:
|
The function works as follows:
|
||||||
## [moids.js](src/utils/bookmarklets/moids.js)
|
1. Takes a string as input.
|
||||||
2. Decodes the string using decodeURIComponent.
|
2. Decodes the string using decodeURIComponent.
|
||||||
This JavaScript file contains a bookmarklet function that prompts the user for multiple MOID (Markit On Demand) numbers and then opens a new browser tab for each corresponding Jira page for those MOIDs.
|
3. Alerts the decoded string.
|
||||||
4. Copies the decoded string to the clipboard.
|
4. Copies the decoded string to the clipboard.
|
||||||
## [rbc-di-featureflag.js](src/utils/bookmarklets/rbc-di-featureflags.js)
|
|
||||||
Note: This function uses the Clipboard API which might not be fully supported in all browsers.
|
Note: This function uses the Clipboard API which might not be fully supported in all browsers.
|
||||||
This JavaScript file contains a bookmarklet function that checks the feature flags set in the session storage and displays themm as checkboxes that the user can set then save
|
|
||||||
## [jira.js](src\utils\bookmarklets\jira.js)
|
## [jira.js](src\utils\bookmarklets\jira.js)
|
||||||
## [Workspace - WIP](src/utils/bookmarklets/workspace.js)
|
|
||||||
|
|
||||||
This is just so i can get up and running on a new window with all the pages i care about
|
This JavaScript function is a bookmarklet that prompts the user for a JIRA ticket number
|
||||||
and then opens a new browser tab with the corresponding JIRA page for that ticket.
|
and then opens a new browser tab with the corresponding JIRA page for that ticket.
|
||||||
## [jsToMsDate.js](src/utils/others/jsToMsDate.js)
|
|
||||||
The function works as follows:
|
The function works as follows:
|
||||||
This JavaScript file contains a function that converts a JavaScript Date object to a Microsoft Date string format. It can be useful when working with APIs or databases that require dates to be in the Microsoft Date format.
|
1. Prompts the user to enter a JIRA ticket number. The entered value is stored in the `answer` variable.
|
||||||
2. Sets a default URL to the JIRA dashboard.
|
2. Sets a default URL to the JIRA dashboard.
|
||||||
## [msToJsDate.js](src/utils/others/msToJsDate.js)
|
3. Checks if the user entered a value in the prompt.
|
||||||
|
4. If the user entered a value, changes the URL to point to the specific JIRA page for the entered ticket number.
|
||||||
|
5. Opens the URL in a new browser tab and brings focus to it.
|
||||||
|
|
||||||
|
Note: This function is wrapped in a self-invoking function `(function() {...})();` which means it will automatically execute as soon as it is defined.
|
||||||
|
|
||||||
|
## [moids.js](src\utils\bookmarklets\moids.js)
|
||||||
|
|
||||||
|
|
||||||
This JavaScript file contains a function that converts a Microsoft Date string format to a JavaScript Date object. It can be useful when working with APIs or databases that provide dates in the Microsoft Date format.
|
This JavaScript function is a bookmarklet that prompts the user for multiple MOID (Markit On Demand) numbers
|
||||||
and then opens a new browser tab for each corresponding Jira page for those MOIDs.
|
and then opens a new browser tab for each corresponding Jira page for those MOIDs.
|
||||||
## [showDebugInfo.js](src/utils/others/showDebugInfo.js)
|
|
||||||
The function works as follows:
|
The function works as follows:
|
||||||
This JavaScript file contains a bookmarklet function that displays debug information about the current page. It can be useful for troubleshooting and understanding the state of the page during development.
|
1. Prompts the user to enter MOID numbers separated by commas. The entered values are stored in the `answers` array.
|
||||||
|
2. Sets a default URL to the Jira dashboard.
|
||||||
|
3. Checks if the user entered any values in the prompt.
|
||||||
|
4. If the user entered values, changes the URL to point to the specific Jira page for each entered MOID number.
|
||||||
|
5. Opens each URL in a new browser tab and brings focus to the last opened tab.
|
||||||
|
|
||||||
|
Note: This function is wrapped in a self-invoking function `(function() {...})();` which means it will automatically execute as soon as it is defined.
|
||||||
|
|
||||||
|
## [rbc-di-featureflags.js](src\utils\bookmarklets\rbc-di-featureflags.js)
|
||||||
|
|
||||||
|
|
||||||
|
This function creates a modal dialog that allows the user to toggle feature flags.
|
||||||
|
It retrieves the feature flags from the session storage, creates checkboxes for each flag,
|
||||||
|
and saves the updated flags back to the session storage when the user clicks the save button.
|
||||||
|
The modal dialog is appended to the document body and can be closed by clicking the save button.
|
||||||
|
|
||||||
|
## [rbcSessionStorage.js](src\utils\bookmarklets\rbcSessionStorage.js)
|
||||||
|
|
||||||
|
|
||||||
@@ -7,7 +7,8 @@
|
|||||||
"test": "echo \"Error: no test specified\" && exit 1",
|
"test": "echo \"Error: no test specified\" && exit 1",
|
||||||
"lint": "eslint src --ext .js",
|
"lint": "eslint src --ext .js",
|
||||||
"lint:fix": "eslint src --ext .js --fix",
|
"lint:fix": "eslint src --ext .js --fix",
|
||||||
"format": "prettier src --write --ignore-unknown"
|
"format": "prettier src --write --ignore-unknown",
|
||||||
|
"readme": "node updateReadme.js"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
|||||||
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