Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,5 @@ private
dist.zip

.clasp.json

*~
Comment thread
coderabbitai[bot] marked this conversation as resolved.
8 changes: 8 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,10 @@
approvedGitRepositories:
- "**"

Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated
enableGlobalCache: true

enableScripts: true

nodeLinker: node-modules

npmMinimalAgeGate: 0
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
"name": "empower-poster",
"private": true,
"license": "MIT",
"packageManager": "yarn@4.11.0",
"packageManager": "yarn@4.17.0",
"workspaces": [
"packages/*"
],
"scripts": {
"ci": "yarn workspaces foreach -A run ci"
"ci": "yarn workspaces foreach -A install && yarn workspaces foreach -A run ci"
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated
}
}
6 changes: 3 additions & 3 deletions packages/apps-script-sample/clasp-redeploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ clasp push -f
# Find the single non-HEAD deployment
deployments_output=$(clasp list-deployments)
deployment_id=$(echo "$deployments_output" |
grep -e '^-' |
grep -e '^-' |
awk '$3 != "@HEAD" {print $2}')
[[ $(echo "$deployment_id" | wc -w) -eq 1 ]] || {
[[ $(echo "$deployment_id" | wc -w) -eq 1 ]] || {
echo "FAILED. Script only works with exactly 1 non-HEAD deployment:
$deployments_output";
exit 1;
exit 1;
}

version_output=$(clasp create-version 'Untitled')
Expand Down
5 changes: 2 additions & 3 deletions packages/apps-script-sample/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "apps-script-samples",
"name": "apps-script-sample",
"private": true,
"version": "0.2.9",
"description": "Sample Apps Script Web App for use with Empower Poster extension",
Expand All @@ -15,7 +15,7 @@
"build:redeploy": "yarn build:check && yarn redeploy",
"redeploy": "./clasp-redeploy.sh",
"typecheck": "tsc --noEmit",
"lint": "eslint '{src,tests}/**/*.{js,ts}'",
"lint": "eslint './*.{js,ts}' '{src,tests}/**/*.{js,ts}'",
"lint:fix": "yarn lint --fix",
"format:check": "prettier './*.{js,ts}' '{src,tests}/**/*.{js,ts}' --check",
"format": "prettier './*.{js,ts}' '{src,tests}/**/*.{js,ts}' --write",
Expand All @@ -32,7 +32,6 @@
"eslint": "^10.1.0",
"prettier": "^3.8.1",
"rollup": "^4.61.1",
"tslib": "^2.8.1",
"typescript": "^6.0.2",
"typescript-eslint": "^8.57.2",
"vitest": "^4.1.8"
Expand Down
8 changes: 4 additions & 4 deletions packages/apps-script-sample/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,18 +116,18 @@ export function doPost(e: GoogleAppsScript.Events.DoPost) {
classifications,
accounts,
} = JSON.parse(e.postData.contents) as PostPayload;
console.log(`API version: ${major}.${minor}`);
Logger.log(`API version: ${major}.${minor}`);
const supported = { major: 0, minor: 6 };
if (major !== supported.major || minor < supported.minor) {
throw new Error(
`data version ${major}.${minor} not supported, expected at least ${supported.major}.${supported.minor}`,
);
}
console.log(`Received ${holdings.length} holdings`);
console.log(
Logger.log(`Received ${holdings.length} holdings`);
Logger.log(
`Classifications for ${Object.keys(classifications).length} tickers`,
);
console.log(`${accounts.length} accounts`);
Logger.log(`${accounts.length} accounts`);
// Write data to sheets
const spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
const classificationsSheet = spreadsheet.getSheetByName("classifications");
Expand Down
2 changes: 1 addition & 1 deletion packages/extension/cli/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ async function main() {
const holdingsIn = getHoldings(spData.holdings);
const holdings = getHoldings(holdingsIn);
const classifications = getClassifications(classificationsIn);
console.log(JSON.stringify({ holdings, classifications }));
Logger.log(JSON.stringify({ holdings, classifications }));
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated
}
await main();
2 changes: 1 addition & 1 deletion packages/extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"dist": "rm -f dist.zip && yarn build && cd dist && zip -r ../dist.zip *",
"clean": "rm -rf dist",
"typecheck": "tsc --noEmit",
"lint": "eslint '{.,src,tests}/**/*.{js,ts}'",
"lint": "eslint './*.{js,ts}' '{src,tests}/**/*.{js,ts}'",
"lint:fix": "yarn lint --fix",
"format:check": "prettier --no-error-on-unmatched-pattern './*.{js,ts}' '{src,tests}/**/*.{js,ts}' --check",
"format": "prettier --no-error-on-unmatched-pattern './*.{js,ts}' '{src,tests}/**/*.{js,ts}' --write",
Expand Down
8 changes: 4 additions & 4 deletions packages/extension/src/background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import type {
} from "./types";
import { getPostUrls } from "./util";

console.log(`Background script started at ${new Date()}`);
Logger.log(`Background script started at ${new Date()}`);

chrome.runtime.onInstalled.addListener(async (details) => {
console.log(`Extension installed at ${new Date()}`, details);
Logger.log(`Extension installed at ${new Date()}`, details);
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated
if ((await getPostUrls()).length === 0) {
chrome.tabs.create({ url: "src/onboarding.html" });
}
Expand All @@ -25,7 +25,7 @@ chrome.webRequest.onBeforeRequest.addListener(
const csrfVal = details?.requestBody?.formData?.["csrf"]?.[0];
if (csrfVal && csrfVal !== csrf) {
csrf = csrfVal as string;
console.log("Saved token");
Logger.log("Saved token");
// Send CSRF token to all tabs with content script
const message: TokenUpdate = {
type: "TOKEN_UPDATE",
Expand Down Expand Up @@ -92,7 +92,7 @@ async function postData(
throw new Error("No POST URLs configured, can't post data");
}
if (!data.holdings || !data.classifications || !data.accounts) {
console.log(`data=${JSON.stringify(data)}`);
Logger.log(`data=${JSON.stringify(data)}`);
throw new Error(
"holdings, classifications, or accounts missing from processed data",
);
Expand Down
2 changes: 1 addition & 1 deletion packages/extension/src/config-form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export function initConfigForm({ prefill, savedMessage }: ConfigFormOptions) {
} catch (e) {
const msg = `Failed: ${e instanceof Error ? e.message : e}`;
showStatus(msg, "error");
console.log(msg);
Logger.log(msg);
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated
}
});
}
6 changes: 2 additions & 4 deletions packages/extension/src/content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ button.onclick = async () => {
if (classificationsErrors.length > 0) {
if (classificationsErrors.length > 20) {
statusLine.innerHTML = `${classificationsErrors.length} negative categorizations found, see console for details`;
console.log("Negative categorizations:", classificationsErrors);
Logger.log("Negative categorizations:", classificationsErrors);
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated
} else {
const errorList = classificationsErrors
.map((error) => {
Expand Down Expand Up @@ -220,9 +220,7 @@ setTimeout(async () => {
csrf = response.csrf;
}
} catch (e) {
console.log(
`token request failed: ${e instanceof Error ? e.message : e}`,
);
Logger.log(`token request failed: ${e instanceof Error ? e.message : e}`);
}
}
}, 5000);
Expand Down
2 changes: 1 addition & 1 deletion packages/extension/tests/processing.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ describe("getClassifications", () => {
) as ClassificationIn[];
// const smallFile = inputFile.replace('-input','-small');
// writeFileSync(smallFile, JSON.stringify(input.map(c => smallifyClassification(c)), null, 2));
// console.log(`wrote ${smallFile}`);
// Logger.log(`wrote ${smallFile}`);
const actual = getClassifications(input);
// const actualFile = inputFile.replace("-input", "-actual");
// writeFileSync(actualFile, JSON.stringify(actual, null, 2));
Expand Down
9 changes: 4 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Manual changes might be lost - proceed with caution!

__metadata:
version: 8
version: 10
cacheKey: 10c0

"@emnapi/core@npm:1.10.0":
Expand Down Expand Up @@ -950,17 +950,16 @@ __metadata:
languageName: node
linkType: hard

"apps-script-samples@workspace:packages/apps-script-sample":
"apps-script-sample@workspace:packages/apps-script-sample":
version: 0.0.0-use.local
resolution: "apps-script-samples@workspace:packages/apps-script-sample"
resolution: "apps-script-sample@workspace:packages/apps-script-sample"
dependencies:
"@rollup/plugin-node-resolve": "npm:^16.0.3"
"@rollup/plugin-typescript": "npm:^12.3.0"
"@types/google-apps-script": "npm:^2.0.11"
eslint: "npm:^10.1.0"
prettier: "npm:^3.8.1"
rollup: "npm:^4.61.1"
tslib: "npm:^2.8.1"
typescript: "npm:^6.0.2"
typescript-eslint: "npm:^8.57.2"
vitest: "npm:^4.1.8"
Expand Down Expand Up @@ -2333,7 +2332,7 @@ __metadata:
languageName: node
linkType: hard

"tslib@npm:^2.4.0, tslib@npm:^2.8.1":
"tslib@npm:^2.4.0":
version: 2.8.1
resolution: "tslib@npm:2.8.1"
checksum: 10c0/9c4759110a19c53f992d9aae23aac5ced636e99887b51b9e61def52611732872ff7668757d4e4c61f19691e36f4da981cd9485e869b4a7408d689f6bf1f14e62
Expand Down
Loading