Skip to content

Conversation

@Tobbe
Copy link
Member

@Tobbe Tobbe commented Dec 29, 2025

All scripts should be listed in the manifest, or the yarn cedar upgrade command won't be able to find them. And it's all too easy to forget to add it if there are no tests

@netlify
Copy link

netlify bot commented Dec 29, 2025

Deploy Preview for cedarjs canceled.

Name Link
🔨 Latest commit f39ef99
🔍 Latest deploy log https://app.netlify.com/projects/cedarjs/deploys/6952f10e1311c0000708c0d4

@github-actions github-actions bot added this to the chore milestone Dec 29, 2025
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Dec 29, 2025

Greptile Summary

This PR adds automated validation to ensure manifest.json stays synchronized with the actual upgrade scripts in the upgrade-scripts/ directory. The test compares the manifest contents against the directory listing (excluding non-script files) and will fail if they don't match.

Key Changes:

  • Added upgrade-scripts to root workspace configuration for test execution via nx
  • Created manifest.test.ts using Node's built-in test runner to validate manifest completeness
  • Added test script and repository metadata to upgrade-scripts/package.json

Notes:

  • Test relies on relative paths and assumes execution from upgrade-scripts/ directory, which works correctly with nx workspace test runner
  • Per the README, upgrade scripts can be either .ts files or directories with index.ts - the test handles both by using readdirSync() which returns all filesystem entries

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The changes are well-contained and add valuable testing infrastructure without modifying any production code. The test is straightforward, uses Node's built-in test runner (no new dependencies), and the workspace configuration change is minimal and correct. All changes work together cohesively to prevent future maintenance issues.
  • No files require special attention

Important Files Changed

Filename Overview
package.json Added upgrade-scripts to workspaces array to enable yarn workspace management and test execution
upgrade-scripts/manifest.test.ts New test validates that all upgrade script files are listed in manifest.json by comparing directory contents (excluding non-script files) with manifest entries
upgrade-scripts/package.json Added repository metadata and test script to run the new manifest validation test using Node's built-in test runner

Sequence Diagram

sequenceDiagram
    participant Test as manifest.test.ts
    participant FS as File System
    participant Manifest as manifest.json
    participant Dir as upgrade-scripts/
    
    Test->>Manifest: Read manifest.json
    Manifest-->>Test: ["canary.ts", "2.3.x.ts", "3.x.ts"]
    Test->>Test: Sort manifest array
    
    Test->>Dir: readdirSync('./')
    Dir-->>Test: All files & directories
    Test->>Test: Filter out non-script files<br/>(manifest.json, package.json,<br/>README.md, manifest.test.ts)
    Test->>Test: Sort filtered scripts
    
    Test->>Test: Compare manifest vs scripts<br/>using deepStrictEqual
    
    alt Arrays match
        Test-->>Test: Test passes ✓
    else Arrays don't match
        Test-->>Test: Test fails ✗<br/>manifest.json out of sync
    end
Loading

@nx-cloud
Copy link

nx-cloud bot commented Dec 29, 2025

🤖 Nx Cloud AI Fix

Ensure the fix-ci command is configured to always run in your CI pipeline to get automatic fixes in future runs. For more information, please see https://nx.dev/ci/features/self-healing-ci


View your CI Pipeline Execution ↗ for commit f39ef99

Command Status Duration Result
nx run-many -t build:pack --exclude create-ceda... ✅ Succeeded 11s View ↗
nx run-many -t build ✅ Succeeded 4s View ↗
nx run-many -t test --minWorkers=1 --maxWorkers=4 ✅ Succeeded 7s View ↗
nx run-many -t test:types ✅ Succeeded 10s View ↗

☁️ Nx Cloud last updated this comment at 2025-12-29 21:40:27 UTC

@Tobbe Tobbe merged commit 7b2786f into main Dec 30, 2025
42 checks passed
@Tobbe Tobbe deleted the tobbe-upgrade-scripts-tests branch December 30, 2025 06:04
@Tobbe Tobbe modified the milestones: chore, v2.3.0 Jan 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants