-
-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added utilities for validating service urls
- Loading branch information
Showing
10 changed files
with
210 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
v12.16.1 |
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,3 @@ | ||
*node_modules* | ||
.git/ | ||
package.json |
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,10 @@ | ||
{ | ||
"printWidth": 100, | ||
"singleQuote": true, | ||
"trailingComma": "es5", | ||
"bracketSpacing": false, | ||
"jsxBracketSameLine": false, | ||
"semi": true, | ||
"requirePragma": false, | ||
"arrowParens": "avoid" | ||
} |
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 @@ | ||
This is used for testing URLs that are opened in the browser after using the `OPEN_ALL` command. This is useful for validating if the URLs redirect or error after opening. | ||
|
||
The `lz4jsoncat` was build on macOS 10.15.7 on a 2013 Macbook Pro. If it doesn't work, rebuild it from [its repo](https://github.com/andikleen/lz4json). | ||
|
||
This requires: | ||
|
||
- Firefox | ||
- macOS 10.15.7 (or later?) | ||
- nvm |
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,29 @@ | ||
#!/usr/bin/env node | ||
const fs = require('fs'); | ||
const assert = require('assert-diff'); | ||
|
||
function main() { | ||
const stdinBuffer = fs.readFileSync(0); | ||
const rawSession = stdinBuffer.toString(); | ||
const session = JSON.parse(rawSession); | ||
const activeAwsUrls = []; | ||
session.windows.forEach(window => { | ||
window.tabs.forEach(tab => { | ||
const currentEntry = tab.entries[tab.entries.length - 1]; | ||
if (currentEntry.url.includes('console.aws.amazon.com')) { | ||
activeAwsUrls.push(currentEntry.url); | ||
} | ||
}); | ||
}); | ||
|
||
const lastOpenedUrlsBuffer = fs.readFileSync( | ||
// TODO this will break with Alfred 4 | ||
`${process.env.HOME}/Library/Caches/com.runningwithcrayons.Alfred-3/Workflow Data/com.ryankoval.awsconsoleservices/last-opened-urls.json` | ||
); | ||
const lastOpenedUrls = JSON.parse(lastOpenedUrlsBuffer); | ||
|
||
assert.deepStrictEqual(activeAwsUrls, lastOpenedUrls); | ||
console.log('✅ urls matches successfully!'); | ||
} | ||
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// this is a helper to paste in the browser to pull out urls from aws side nav | ||
function getAwsUrlsFromPage(className) { | ||
return $$(`.${className} a`) | ||
.map(element => { | ||
let url; | ||
try { | ||
url = new URL(element.href); | ||
url.searchParams.delete('region'); | ||
url = url.pathname + url.search + url.hash; | ||
} catch { | ||
url = element.href; | ||
} | ||
return { | ||
id: element.innerText.replaceAll(' ', '').replaceAll('-', '').toLowerCase(), | ||
name: element.innerText, | ||
url, | ||
}; | ||
}) | ||
.filter(entry => !!entry.id); | ||
} |
Binary file not shown.
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,6 @@ | ||
#!/usr/bin/env bash | ||
cd "$(dirname "$0")" | ||
|
||
# this holds session info in firefox like the currently opened tabs | ||
./lz4jsoncat $HOME/Library/Application\ Support/Firefox/Profiles/*default*/sessionstore-backups/recovery.jsonlz4 \ | ||
| ./diff-urls-with-last-opened-urls-json.js |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 @@ | ||
{ | ||
"dependencies": { | ||
"assert-diff": "^3.0.2", | ||
"chalk": "^4.1.2", | ||
"diff": "^5.0.0", | ||
"prettier": "^2.3.2" | ||
}, | ||
"devDependencies": {} | ||
} |