From a79ea12f4d87af6c9a48de64ac2cf91bc323ab60 Mon Sep 17 00:00:00 2001 From: Ted Romer Date: Fri, 3 Jul 2026 20:48:30 -0700 Subject: [PATCH 1/4] Various minor changes. - Add install step to top-level yarn ci script. - ... --- .gitignore | 2 ++ .yarnrc.yml | 8 ++++++++ package.json | 4 ++-- packages/apps-script-sample/clasp-redeploy.sh | 6 +++--- packages/apps-script-sample/package.json | 5 ++--- packages/apps-script-sample/src/app.ts | 8 ++++---- packages/extension/cli/cli.ts | 2 +- packages/extension/package.json | 2 +- packages/extension/src/background.ts | 8 ++++---- packages/extension/src/config-form.ts | 2 +- packages/extension/src/content.ts | 6 ++---- packages/extension/tests/processing.test.ts | 2 +- yarn.lock | 9 ++++----- 13 files changed, 35 insertions(+), 29 deletions(-) diff --git a/.gitignore b/.gitignore index 65eea0a..c6f674f 100644 --- a/.gitignore +++ b/.gitignore @@ -27,3 +27,5 @@ private dist.zip .clasp.json + +*~ diff --git a/.yarnrc.yml b/.yarnrc.yml index 5399eb5..1d25ed8 100644 --- a/.yarnrc.yml +++ b/.yarnrc.yml @@ -1,2 +1,10 @@ +approvedGitRepositories: + - "**" + enableGlobalCache: true + +enableScripts: true + nodeLinker: node-modules + +npmMinimalAgeGate: 0 diff --git a/package.json b/package.json index 3e30158..15127ec 100644 --- a/package.json +++ b/package.json @@ -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" } } diff --git a/packages/apps-script-sample/clasp-redeploy.sh b/packages/apps-script-sample/clasp-redeploy.sh index 8ad7367..2184d84 100755 --- a/packages/apps-script-sample/clasp-redeploy.sh +++ b/packages/apps-script-sample/clasp-redeploy.sh @@ -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') diff --git a/packages/apps-script-sample/package.json b/packages/apps-script-sample/package.json index 72e6bae..438403a 100644 --- a/packages/apps-script-sample/package.json +++ b/packages/apps-script-sample/package.json @@ -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", @@ -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", @@ -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" diff --git a/packages/apps-script-sample/src/app.ts b/packages/apps-script-sample/src/app.ts index 820688f..aa70f6e 100644 --- a/packages/apps-script-sample/src/app.ts +++ b/packages/apps-script-sample/src/app.ts @@ -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"); diff --git a/packages/extension/cli/cli.ts b/packages/extension/cli/cli.ts index d85a1b2..8a375a1 100644 --- a/packages/extension/cli/cli.ts +++ b/packages/extension/cli/cli.ts @@ -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 })); } await main(); diff --git a/packages/extension/package.json b/packages/extension/package.json index 2bdd1ef..450654e 100644 --- a/packages/extension/package.json +++ b/packages/extension/package.json @@ -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", diff --git a/packages/extension/src/background.ts b/packages/extension/src/background.ts index 23b0dc2..9162cbe 100644 --- a/packages/extension/src/background.ts +++ b/packages/extension/src/background.ts @@ -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); if ((await getPostUrls()).length === 0) { chrome.tabs.create({ url: "src/onboarding.html" }); } @@ -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", @@ -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", ); diff --git a/packages/extension/src/config-form.ts b/packages/extension/src/config-form.ts index d695293..a3fe2e8 100644 --- a/packages/extension/src/config-form.ts +++ b/packages/extension/src/config-form.ts @@ -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); } }); } diff --git a/packages/extension/src/content.ts b/packages/extension/src/content.ts index 77ce9eb..87cc3fb 100644 --- a/packages/extension/src/content.ts +++ b/packages/extension/src/content.ts @@ -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); } else { const errorList = classificationsErrors .map((error) => { @@ -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); diff --git a/packages/extension/tests/processing.test.ts b/packages/extension/tests/processing.test.ts index 6ff156d..16c7ec1 100644 --- a/packages/extension/tests/processing.test.ts +++ b/packages/extension/tests/processing.test.ts @@ -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)); diff --git a/yarn.lock b/yarn.lock index 33fbb0d..f6fcbd9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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": @@ -950,9 +950,9 @@ __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" @@ -960,7 +960,6 @@ __metadata: 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" @@ -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 From f9201921984bb48cea3692cc39771156acebb886 Mon Sep 17 00:00:00 2001 From: Ted Romer Date: Fri, 3 Jul 2026 21:21:13 -0700 Subject: [PATCH 2/4] add tslib dependency back to apps-script-sample --- packages/apps-script-sample/package.json | 1 + yarn.lock | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/apps-script-sample/package.json b/packages/apps-script-sample/package.json index 438403a..58804e3 100644 --- a/packages/apps-script-sample/package.json +++ b/packages/apps-script-sample/package.json @@ -32,6 +32,7 @@ "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" diff --git a/yarn.lock b/yarn.lock index f6fcbd9..19ed1a9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -960,6 +960,7 @@ __metadata: 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" @@ -2332,7 +2333,7 @@ __metadata: languageName: node linkType: hard -"tslib@npm:^2.4.0": +"tslib@npm:^2.4.0, tslib@npm:^2.8.1": version: 2.8.1 resolution: "tslib@npm:2.8.1" checksum: 10c0/9c4759110a19c53f992d9aae23aac5ced636e99887b51b9e61def52611732872ff7668757d4e4c61f19691e36f4da981cd9485e869b4a7408d689f6bf1f14e62 From 839b83b1328cd30104afd56c5a7c8487ba7b7c76 Mon Sep 17 00:00:00 2001 From: Ted Romer Date: Fri, 3 Jul 2026 21:35:28 -0700 Subject: [PATCH 3/4] cr --- .yarnrc.yml | 7 ++----- package.json | 2 +- packages/extension/src/background.ts | 8 ++++---- packages/extension/src/config-form.ts | 2 +- packages/extension/src/content.ts | 6 ++++-- 5 files changed, 12 insertions(+), 13 deletions(-) diff --git a/.yarnrc.yml b/.yarnrc.yml index 1d25ed8..54cf43c 100644 --- a/.yarnrc.yml +++ b/.yarnrc.yml @@ -1,10 +1,7 @@ -approvedGitRepositories: - - "**" - enableGlobalCache: true -enableScripts: true +enableScripts: false nodeLinker: node-modules -npmMinimalAgeGate: 0 +npmMinimalAgeGate: 1w diff --git a/package.json b/package.json index 15127ec..287a16c 100644 --- a/package.json +++ b/package.json @@ -7,6 +7,6 @@ "packages/*" ], "scripts": { - "ci": "yarn workspaces foreach -A install && yarn workspaces foreach -A run ci" + "ci": "yarn workspaces foreach -A run ci" } } diff --git a/packages/extension/src/background.ts b/packages/extension/src/background.ts index 9162cbe..23b0dc2 100644 --- a/packages/extension/src/background.ts +++ b/packages/extension/src/background.ts @@ -9,10 +9,10 @@ import type { } from "./types"; import { getPostUrls } from "./util"; -Logger.log(`Background script started at ${new Date()}`); +console.log(`Background script started at ${new Date()}`); chrome.runtime.onInstalled.addListener(async (details) => { - Logger.log(`Extension installed at ${new Date()}`, details); + console.log(`Extension installed at ${new Date()}`, details); if ((await getPostUrls()).length === 0) { chrome.tabs.create({ url: "src/onboarding.html" }); } @@ -25,7 +25,7 @@ chrome.webRequest.onBeforeRequest.addListener( const csrfVal = details?.requestBody?.formData?.["csrf"]?.[0]; if (csrfVal && csrfVal !== csrf) { csrf = csrfVal as string; - Logger.log("Saved token"); + console.log("Saved token"); // Send CSRF token to all tabs with content script const message: TokenUpdate = { type: "TOKEN_UPDATE", @@ -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) { - Logger.log(`data=${JSON.stringify(data)}`); + console.log(`data=${JSON.stringify(data)}`); throw new Error( "holdings, classifications, or accounts missing from processed data", ); diff --git a/packages/extension/src/config-form.ts b/packages/extension/src/config-form.ts index a3fe2e8..d695293 100644 --- a/packages/extension/src/config-form.ts +++ b/packages/extension/src/config-form.ts @@ -91,7 +91,7 @@ export function initConfigForm({ prefill, savedMessage }: ConfigFormOptions) { } catch (e) { const msg = `Failed: ${e instanceof Error ? e.message : e}`; showStatus(msg, "error"); - Logger.log(msg); + console.log(msg); } }); } diff --git a/packages/extension/src/content.ts b/packages/extension/src/content.ts index 87cc3fb..77ce9eb 100644 --- a/packages/extension/src/content.ts +++ b/packages/extension/src/content.ts @@ -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`; - Logger.log("Negative categorizations:", classificationsErrors); + console.log("Negative categorizations:", classificationsErrors); } else { const errorList = classificationsErrors .map((error) => { @@ -220,7 +220,9 @@ setTimeout(async () => { csrf = response.csrf; } } catch (e) { - Logger.log(`token request failed: ${e instanceof Error ? e.message : e}`); + console.log( + `token request failed: ${e instanceof Error ? e.message : e}`, + ); } } }, 5000); From 207114eda9661a31f7912f97604be058df8ac659 Mon Sep 17 00:00:00 2001 From: Ted Romer Date: Fri, 3 Jul 2026 21:37:44 -0700 Subject: [PATCH 4/4] oops --- packages/extension/cli/cli.ts | 2 +- packages/extension/tests/processing.test.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/extension/cli/cli.ts b/packages/extension/cli/cli.ts index 8a375a1..d85a1b2 100644 --- a/packages/extension/cli/cli.ts +++ b/packages/extension/cli/cli.ts @@ -19,6 +19,6 @@ async function main() { const holdingsIn = getHoldings(spData.holdings); const holdings = getHoldings(holdingsIn); const classifications = getClassifications(classificationsIn); - Logger.log(JSON.stringify({ holdings, classifications })); + console.log(JSON.stringify({ holdings, classifications })); } await main(); diff --git a/packages/extension/tests/processing.test.ts b/packages/extension/tests/processing.test.ts index 16c7ec1..6ff156d 100644 --- a/packages/extension/tests/processing.test.ts +++ b/packages/extension/tests/processing.test.ts @@ -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)); - // Logger.log(`wrote ${smallFile}`); + // console.log(`wrote ${smallFile}`); const actual = getClassifications(input); // const actualFile = inputFile.replace("-input", "-actual"); // writeFileSync(actualFile, JSON.stringify(actual, null, 2));