Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
39 changes: 36 additions & 3 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@ name: Deploy Script

on:
workflow_dispatch:
push:
# Gate on the Plugin checks workflow instead of triggering on the same push
# directly: a plain `push:` trigger here would race the Plugin workflow and
# could reach `clasp push` while checks are still running or have failed.
workflow_run:
workflows: ["Plugin"]
types: [completed]
branches: [main, develop]
release:
types: [published]
Expand All @@ -13,6 +18,21 @@ concurrency:

jobs:
setup:
# For workflow_run, only proceed for a same-repo push that actually passed
# checks. workflow_run runs in the base repo's privileged context (full
# secrets) regardless of what triggered the upstream Plugin run, and the
# branches: filter above matches on head_branch — a fork can name its own
# branch "main" or "develop" to satisfy it. Without the event/repo checks
# below, a pull_request-triggered Plugin run from such a fork branch would
# pass this gate and let deploy check out + `clasp deploy` attacker
# -controlled code using this repo's CLASP secrets ("pwn request"; see
# https://securitylab.github.com/resources/github-actions-preventing-pwn-requests/).
# workflow_dispatch and release runs have no upstream check run to gate on.
if: |
github.event_name != 'workflow_run' ||
(github.event.workflow_run.conclusion == 'success' &&
github.event.workflow_run.event == 'push' &&
github.event.workflow_run.head_repository.full_name == github.repository)
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
Expand Down Expand Up @@ -57,6 +77,11 @@ jobs:
steps:
- name: Checkout repo
uses: actions/checkout@v4
with:
# workflow_run doesn't default to the commit that triggered the
# upstream Plugin run — pin explicitly so we deploy the exact
# commit that passed checks, not whatever HEAD happens to be.
ref: ${{ github.event.workflow_run.head_sha || github.sha }}

- name: Install clasp
run: sudo npm install @google/clasp@2.4.2 -g
Expand Down Expand Up @@ -120,6 +145,14 @@ jobs:
clasp push -f

- name: Deploy Script
# github.ref resolves to the default branch (not the triggering branch) on
# workflow_run events, so a develop-branch Plugin run would otherwise satisfy
# `github.ref == 'refs/heads/main'` here too. Check head_branch for that event
# type instead; github.ref stays reliable for workflow_dispatch and release.
if: |
(github.ref == 'refs/heads/main' || github.event_name == 'release')
run: clasp deploy -d "${GITHUB_REF_NAME}"
(github.event_name == 'workflow_run' && github.event.workflow_run.head_branch == 'main') ||
(github.event_name != 'workflow_run' && github.ref == 'refs/heads/main') ||
github.event_name == 'release'
env:
DEPLOY_REF_NAME: ${{ github.event.workflow_run.head_branch || github.ref_name }}
run: clasp deploy -d "$DEPLOY_REF_NAME"
53 changes: 53 additions & 0 deletions .github/workflows/plugin.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Plugin

on:
pull_request:
paths:
- ".github/workflows/plugin.yml"
- "appsscript.json"
- "biome.json"
- "bun.lockb"
- "index.ts"
- "package.json"
- "src/**"
- "tsconfig.json"
push:
branches: [main, develop]
paths:
- ".github/workflows/plugin.yml"
- "appsscript.json"
- "biome.json"
- "bun.lockb"
- "index.ts"
- "package.json"
- "src/**"
- "tsconfig.json"
workflow_dispatch:

permissions:
contents: read

jobs:
check:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6

- name: Set up Bun
uses: oven-sh/setup-bun@v2

- name: Install dependencies
run: bun install --frozen-lockfile

- name: TypeScript
run: bunx tsc --noEmit

- name: Biome
run: bunx biome lint .

- name: GAS boot probe
run: bun run test:gas-boot

- name: Lint parity tests
run: bun run test:lint-parity
6 changes: 3 additions & 3 deletions context/historical/html-fix-summary.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Users were experiencing "Malformed HTML content" errors during config generation

## Complete Solution

### 1. Enhanced HTML Validation (`src/lint.ts`)
### 1. Enhanced HTML Validation (`src/lint/htmlValidation.ts`)

**Added comprehensive validation checks:**

Expand Down Expand Up @@ -106,7 +106,7 @@ input.value = code; // Safe - no HTML injection possible
- Cleaner, more maintainable code
- Faster rendering

### 5. Comprehensive Test Suite (`src/lint.ts`)
### 5. Comprehensive Test Suite (`src/lint/htmlValidation.ts`)

**Three levels of testing:**

Expand Down Expand Up @@ -294,7 +294,7 @@ const message = validateAndSanitizeMessage(messages);
## References

- **HTML Validation Strategy**: `../reference/html-validation.md`
- **Validation Functions**: `src/lint.ts:1129-1450`
- **Validation Functions**: `src/lint/htmlValidation.ts`
- **Safe Dialog Wrapper**: `src/dialog.ts:13-48`
- **Client-Side Rendering Example**: `src/dialog.ts:497-764`

Expand Down
4 changes: 2 additions & 2 deletions context/implementation/performance-improvements.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ For every improvement initiative:

---

- [x] **Batch Spreadsheet Writes in Linting (`src/lint.ts`)**
- [x] **Batch Spreadsheet Writes in Linting (`src/lint/`)**
*Gain:* Dramatically reduces per-cell `setBackground/setValue` calls during `lintAllSheets`, cutting spreadsheet round-trips for large sheets.
*Risk:* Medium — batching needs to preserve all current highlighting/notes, so comprehensive before/after sheet comparisons are required.
*Tested:* `npm run lint`

- [x] **Cache Detail Slugs During Category Validation (`src/lint.ts`)**
- [x] **Cache Detail Slugs During Category Validation (`src/lint/categories.ts`)**
*Gain:* Eliminates repeated reads of the entire Details sheet while validating each category row.
*Risk:* Low — ensure cache invalidation within the lint pass so edits within the same run are respected.
*Tested:* `npm run lint`
Expand Down
2 changes: 1 addition & 1 deletion context/issues/high.md
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ class Logger {

### HIGH-018: Optimize validateTranslationSheets

**File**: `src/lint.ts`
**File**: `src/lint/translations.ts`
**Effort**: 2 hours

**Problem**: Reads entire data range multiple times
Expand Down
2 changes: 1 addition & 1 deletion context/issues/low.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Remove: `console.log(configData);`
Remove debug console.log statement.

### LOW-004: Extract Color Constants
**File**: `src/lint.ts` | **Effort**: 30min
**File**: `src/lint-colors.ts` | **Effort**: 30min

```typescript
const COLORS = {
Expand Down
2 changes: 1 addition & 1 deletion context/issues/medium.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ Prevent API quota exhaustion.
Reduce to single-pass operation.

### MED-011: Add Performance Safeguards for Large Sheets
**File**: `src/lint.ts` | **Effort**: 2h
**File**: `src/lint/` | **Effort**: 2h

Handle sheets with >10K rows gracefully.

Expand Down
4 changes: 2 additions & 2 deletions context/process/review-checklists.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,11 @@ Fetch and process icons from external API.

---

### Validation & Cleanup (3 modules)
### Validation & Cleanup (3 areas)
Lint spreadsheet data and cleanup temporary resources.

**Files**:
- `src/lint.ts` - ✅ Comprehensive validation, ⚠️ Large file (1164 lines)
- `src/lint/` - ✅ Comprehensive validation split by sheet/domain
- `src/cleanup.ts` - ✅ Excellent error handling
- `src/preflightValidation.ts` - ✅ Good coverage

Expand Down
2 changes: 1 addition & 1 deletion context/reference/cat-generation.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ For schema details, see `src/builders/payloadBuilder.ts` and `src/types.ts`.
- `src/generateCoMapeoConfig.ts` (orchestrator)
- `src/builders/payloadBuilder.ts` (payload construction)
- `src/apiService.ts` (API request/response handling)
- `src/lint.ts` (validation)
- `src/lint/` (spreadsheet validation modules)
- `src/translation.ts` (language management)
- `src/spreadsheetData.ts` (data extraction)
- `context/reference/comapeocat-format.md` (archive structure)
4 changes: 2 additions & 2 deletions context/reference/html-validation.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ The error "Malformed HTML content" occurs when Google Apps Script attempts to re

## Solution Architecture

### 1. HTML Validation Function (`src/lint.ts`)
### 1. HTML Validation Function (`src/lint/htmlValidation.ts`)

```typescript
validateHtmlContent(html: string): { isValid: boolean; errors: string[] }
Expand All @@ -40,7 +40,7 @@ validateHtmlContent(html: string): { isValid: boolean; errors: string[] }
- `isValid`: Boolean indicating if HTML is valid
- `errors`: Array of error messages describing issues

### 2. Dialog Validation Function (`src/lint.ts`)
### 2. Dialog Validation Function (`src/lint/htmlValidation.ts`)

```typescript
validateDialogHtml(html: string, context?: string): void
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
"dev": "npm run version:update && clasp push --watch",
"push": "npm run version:update && clasp push",
"lint": "bunx biome lint --write --unsafe .",
"test:gas-boot": "node src/scripts/check-gas-boot.cjs",
"test:lint-parity": "node src/scripts/check-lint-parity.cjs",
"push:all": "npm run version:update && bash src/scripts/push-all.sh",
"push:one": "npm run version:update && bash src/scripts/push-one.sh",
"fixture": "bun run scripts/generate-fixture.ts"
Expand Down
8 changes: 6 additions & 2 deletions src/data/languagesFallback.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@
*/

/// <reference path="../types.ts" />
/// <reference path="../languageLookup.ts" />

/**
* Enhanced fallback language data with dual-name support
Expand Down Expand Up @@ -207,4 +206,9 @@ const LANGUAGES_FALLBACK_ENHANCED: LanguageMapEnhanced = {
* Legacy fallback for backward compatibility
* @deprecated Use LANGUAGES_FALLBACK_ENHANCED instead
*/
const LANGUAGES_FALLBACK: LanguageMap = toLegacyLanguageMap(LANGUAGES_FALLBACK_ENHANCED);
const LANGUAGES_FALLBACK: LanguageMap = Object.entries(
LANGUAGES_FALLBACK_ENHANCED,
).reduce<LanguageMap>((legacy, [code, data]) => {
legacy[code] = data.englishName;
return legacy;
}, {});
2 changes: 1 addition & 1 deletion src/dialog.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/// <reference path="./lint.ts" />
/// <reference path="./lint/htmlValidation.ts" />

/**
* CoMapeo logo as embedded SVG data URI
Expand Down
9 changes: 7 additions & 2 deletions src/importCategory/validateConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,13 @@ const MAX_VALIDATION_ERRORS = 20;
/** Valid document types per CoMapeo spec */
const VALID_DOCUMENT_TYPES = ["observation", "track"];

// Reuse VALID_FIELD_TYPES from validation.ts (GAS global scope)
const VALID_IMPORT_FIELD_TYPES: readonly string[] = VALID_FIELD_TYPES;
// Keep load-order safe: this file can run before validation.ts in Apps Script.
const VALID_IMPORT_FIELD_TYPES = [
"text",
"number",
"selectOne",
"selectMultiple",
] as const;

/**
* Validates the structure of imported configuration data before applying to spreadsheet.
Expand Down
2 changes: 1 addition & 1 deletion src/lint-colors.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* Shared lint color constants.
*
* Used by `src/lint.ts` (production) and `src/test/testLint.ts` (mock framework).
* Used by `src/lint/` modules (production) and `src/test/testLint.ts` (mock framework).
* Keeping them in one place prevents silent test drift when the palette changes.
*/

Expand Down
Loading