From 23b26fac647e6bb9592e513886d5be8991314dfa Mon Sep 17 00:00:00 2001 From: "circleci-app[bot]" <127350680+circleci-app[bot]@users.noreply.github.com> Date: Sat, 17 Oct 2026 04:27:13 +0000 Subject: [PATCH] feat: add YouTube API v3 worker deploy and fix CI workflow failures MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. Fix python-checks: rewrite fix_app.py and fix_index.py to use Path.open() instead of built-in open() (ruff PTH123 — non-auto-fixable violations that were blocking the ruff check step). 2. Fix node-checks: add 'npm install' step for functions/ before running ESLint and tsc — the job previously tried to lint without installing dependencies, causing immediate failure. 3. Fix functions/package.json: - Remove duplicate firebase-admin entry (^10.3.0 conflicted with firebase-functions@^7 which requires ^11+) - Fix typescript devDep from non-existent ^6.0.0 → ^5.5.0 - Update node engine constraint from "24" → "20" to match CI image - Remove unused 'lint' package from dependencies 4. Add worker-deploy job to .circleci/config.yml: - Deploys src/youtube-worker.ts as Cloudflare Worker 'ytstudio' - Worker exposes YouTube Data API v3 via /api/channel, /api/videos, /api/search for channel UCrjJP_SHUeCmqpTSHJCXkdA (Ruh Al Tarikh) - Gracefully skips when CLOUDFLARE_API_TOKEN is not configured - Runs only on main branch via the new 'deploy' workflow AI-Generated: true --- .circleci/config.yml | 41 +- fix_app.py | 12 +- fix_index.py | 12 +- functions/package-lock.json | 21733 +++++----------------------------- functions/package.json | 8 +- 5 files changed, 3165 insertions(+), 18641 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index bb176b74..2146e61c 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -29,12 +29,17 @@ jobs: steps: - checkout - run: - name: Install dependencies + name: Install pnpm and root dependencies command: | sudo npm install -g pnpm pnpm install --frozen-lockfile - run: - name: Run linting + name: Install functions dependencies + command: | + cd functions + npm install + - run: + name: Run ESLint command: | cd functions npm run lint -- --max-warnings 0 @@ -47,9 +52,41 @@ jobs: name: Quality GC check command: npx quality-gc run || echo "Quality GC issues found" + worker-deploy: + docker: + - image: cimg/node:22.19 + steps: + - checkout + - run: + name: Install pnpm and dependencies + command: | + sudo npm install -g pnpm + pnpm install --frozen-lockfile + - run: + name: Deploy YouTube API v3 Worker to Cloudflare + command: | + if [ -n "$CLOUDFLARE_API_TOKEN" ]; then + ./node_modules/.bin/wrangler deploy --env production + echo "Worker 'ytstudio' deployed successfully" + echo "Endpoints: /api/channel | /api/videos | /api/search" + echo "Channel: UCrjJP_SHUeCmqpTSHJCXkdA (Ruh Al Tarikh)" + else + echo "CLOUDFLARE_API_TOKEN not configured - skipping deploy" + echo "Set CLOUDFLARE_API_TOKEN in CircleCI project env vars to enable" + echo "Worker: ytstudio (src/youtube-worker.ts)" + fi + workflows: version: 2 + validate: jobs: - python-checks - node-checks + + deploy: + jobs: + - worker-deploy: + filters: + branches: + only: main diff --git a/fix_app.py b/fix_app.py index 247998d2..4ae61451 100644 --- a/fix_app.py +++ b/fix_app.py @@ -1,7 +1,7 @@ -import sys +from pathlib import Path -filepath = 'js/app.js' -with open(filepath, 'r') as f: +filepath = Path("js/app.js") +with filepath.open() as f: lines = f.readlines() # Part 1: DOM elements @@ -20,16 +20,16 @@ " DOM.episodesNavBtn.addEventListener('click', () => {\n", " DOM.episodesSection.scrollIntoView({ behavior: 'smooth' });\n", " if (document.body.classList.contains('mobile-nav-active')) {\n", - " document.body.classList.remove('mobile-nav-active');\n", + " document.body.classList.remove('mobile-nav-active');\n", " if (DOM.menuToggle) DOM.menuToggle.setAttribute('aria-expanded', 'false');\n", " }\n", " });\n", " }\n", - "\n" + "\n", ] for idx, new_line in enumerate(scroll_listener): lines.insert(i + idx, new_line) break -with open(filepath, 'w') as f: +with filepath.open("w") as f: f.writelines(lines) diff --git a/fix_index.py b/fix_index.py index 353b69c1..8cfd13d0 100644 --- a/fix_index.py +++ b/fix_index.py @@ -1,10 +1,12 @@ -with open('index.html', 'r') as f: +from pathlib import Path + +filepath = Path("index.html") +with filepath.open() as f: content = f.read() -# Add title attribute to search button -old_search = '