Skip to content

Issue 97 drop mdapi support - #366

Merged
pwrightcertinia merged 12 commits into
mainfrom
issue-97-drop-mdapi-support
Sep 5, 2025
Merged

pwrightcertinia merged 12 commits into
mainfrom
issue-97-drop-mdapi-support

Conversation

@nawforce

@nawforce nawforce commented Aug 15, 2025 •

Copy link
Copy Markdown
Contributor

Summary

Removes MDAPI format support and enforces SFDX-only project structure, improving code consistency and reducing maintenance complexity. Includes comprehensive test fixes to ensure compatibility with the new SFDX-only requirement.

Core Changes

SFDX-Only Requirement:

  • Workspace.scala: Added mandatory sfdx-project.json validation - projects without this file now return clear error message
  • FileSystemHelper: Enhanced test infrastructure to auto-create sfdx-project.json files for backward compatibility
  • SFDX Format Enforcement: All projects must now use SFDX format structure with proper packageDirectories configuration

Case Sensitivity Validation:

  • MetadataDocument.scala: Enhanced directory detection logic for flexible case handling in child directories
  • MetadataValidator.scala: Added case sensitivity warnings for incorrect metadata folder naming (e.g., "Fields" vs "fields")
  • SFDX.md Documentation: Updated with comprehensive case sensitivity requirements and cross-platform compatibility guidance

Test Infrastructure Improvements

FileSystemHelper Enhancements:

  • Auto-creation of sfdx-project.json with "path": "." for test compatibility
  • Automatic generation of missing .cls-meta.xml and .trigger-meta.xml files for legacy tests
  • Maintained backward compatibility while enforcing new SFDX requirements

Comprehensive Test Fixes (122 tests across 4 classes):

  • DirectoryTreeTest: Added filtering for auto-created sfdx-project.json in file tracking assertions
  • ProjectTest: Enhanced missing file test to properly handle auto-creation scenario
  • PackageAPITest: Added explicit sfdx-project.json for subdirectory-based test scenarios
  • CachedTest: Provided sfdx-project.json files for separate pkg1/pkg2 test environments
  • FileSystemHelperEnhancementTest: Updated assertions to expect current directory path reference

Sample Directory Updates

  • samples/mdapi-test/: Added sfdx-project.json to maintain compatibility with existing sample workflows
  • Documentation: Updated .claude/SFDX.md with detailed case sensitivity requirements and platform-specific behavior

Benefits

  • Simplified Maintenance: Single format support reduces code complexity and testing overhead
  • Improved Validation: Consistent metadata folder name validation with helpful error messages
  • Cross-Platform Compatibility: Enhanced case sensitivity handling prevents deployment failures
  • Clear Error Messages: Descriptive feedback when sfdx-project.json is missing or incorrectly configured

Migration Impact

  • Breaking Change: MDAPI format projects will no longer load and will receive clear error messages
  • Test Compatibility: All existing tests continue to work with auto-generated SFDX structure
  • Documentation: Comprehensive guidance provided for case sensitivity requirements

- Remove MDAPIWorkspaceConfig class and WorkspaceConfig trait
- Simplify workspace creation to use SFDXProject directly
- Require sfdx-project.json for all projects
- Remove unused imports from Org.scala
- Projects without sfdx-project.json now fail with clear error message

This is the core implementation for issue #97 to drop MDAPI format support.
Tests that rely on MDAPI format will need to be updated to use SFDX format.
- Refactor WorkspaceTest.scala for better maintainability:
  * Replace chained .join() calls with helper methods
  * Add comprehensive SFDX path building helpers
  * Extract common XML patterns into reusable constants
  * Simplify repetitive path assertion patterns
  * All 42 tests still passing (100% success rate maintained)

- Add new WorkspaceTypeLookupTest.scala for missing coverage:
  * Test Workspace.get(typeName) method functionality
  * Multi-package directory type lookup behavior
  * Custom Object lookup with Schema namespace
  * Complex metadata hierarchy scenarios
  * Event/get() consistency validation
  * 8 comprehensive tests, all passing

Key insight: Custom Objects require Schema namespace for type lookup:
TypeName(Name("ObjectName__c"), Nil, Some(TypeName.Schema))

Coverage improvement: ~75% → ~85% for Workspace functionality
- Add ensureSFDXProject() method to automatically create sfdx-project.json when missing
- Remove redundant withSFDXProject() helper method from WorkspaceTest
- Update 39 tests to use FileSystemHelper auto-creation directly
- Fix 3 Master/Detail tests to use withMultiPackageSFDXProject() for multi-package scenarios
- Add comprehensive FileSystemHelperEnhancementTest covering auto-creation behavior
- Simplify test authoring by eliminating boilerplate SFDX project setup
…tories

- Update MetadataDocument to use case-insensitive matching for child directories (fields, fieldSets, sharingReasons)
- Keep strict case enforcement for objects directory (SFDX requirement)
- Add MetadataValidator warnings for incorrect case usage with helpful suggestions
- Add comprehensive test coverage for case sensitivity scenarios in MetadataDocumentTest and MetadataValidatorTest
- Improve user experience by recognizing files with incorrect case while guiding users to correct conventions
- Ensure cross-platform compatibility and SFDX CLI compliance

This resolves issues where metadata files in directories like "Fields" vs "fields" were not being recognized,
while maintaining proper validation and user guidance for consistent project structure.
- Add ensureSFDXProject method to automatically create sfdx-project.json when missing on both JVM and JS platforms
- Update WorkspaceTest to remove redundant withSFDXProject helper and fix multi-package tests
- Add comprehensive FileSystemHelperEnhancementTest covering auto-creation scenarios
- Apply scalafmt formatting across modified files for consistent code style
- Update Workspace error message formatting
- Enhance ParsedCache tests with better formatting

This completes the FileSystemHelper enhancement work that enables tests to work with raw metadata files
without requiring manual SFDX project setup, while maintaining proper validation for edge cases.
- Fix FileSystemHelperEnhancementTest assertion to expect "." path instead of "force-app"
- Add sfdx-project.json to samples/mdapi-test directory for compatibility
- Update PackageAPITest to include explicit sfdx-project.json in test subdirectory
- Update CachedTest to include sfdx-project.json files for pkg1/pkg2 test scenarios
- Fix DirectoryTreeTest to filter out auto-created sfdx-project.json from assertions
- Fix ProjectTest to delete auto-created sfdx-project.json when testing missing file scenario

All fixes address the transition from MDAPI support to SFDX-only format requirement.
Total of 122 tests across 4 test classes now pass successfully.
Automatically create temporary sfdx-project.json files for samples that lack them.
This allows sample tests to run successfully after dropping MDAPI support without
modifying the actual sample repositories.

Changes:
- Enhanced findProjectDir() to detect existing sfdx-project.json files and create
  temporary ones when needed
- Consolidated all sfdx-project.json handling logic into a single function
- Added proper cleanup of temporary files after each test
- Updated test snapshots to reflect new path formats
Comment thread .claude/MODULES.md
@@ -0,0 +1,355 @@
# Apex-LS Modularization Plan

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is something I had Claude draw up, was just wondering what 'better' might look like. It's not done a great job at understanding how the code splits between cross compiled and jvm only, but its maybe a start now this kind of reorg would be much cheaper for us to do.

@nawforce
nawforce marked this pull request as ready for review August 17, 2025 15:19
- Expose defaultSFDXProject from FileSystemHelper test utilities
- Replace toLowerCase comparisons with equalsIgnoreCase() for consistency
- Add explanatory comment for SFDXProject error logging consistency
- Consolidate documentation files into .claude directories
- Update test files to use shared defaultSFDXProject constant

This addresses all feedback from PR #366 review comments.
Comment thread .claude/CLAUDE.md
@@ -0,0 +1,155 @@
# CLAUDE.md

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I messed these up on an earlier PR so just resetting

Resolved conflict in test snapshot file by accepting main branch changes
which include new test modifier validation rules.
The snapshot now correctly reflects both the branch changes (removing
MDAPI-only samples) and the new test modifier validation rules from main.
The snapshots now correctly include the new test modifier validation
errors from main branch for samples that have test methods without
proper @istest class annotations.
@pwrightcertinia
pwrightcertinia merged commit e36d96c into main Sep 5, 2025
@pwrightcertinia
pwrightcertinia deleted the issue-97-drop-mdapi-support branch September 5, 2025 09:29
kjonescertinia added a commit that referenced this pull request Sep 20, 2025
- Add test modifier validation (#333)
- Add break/continue statement validation (#378)
- Add ForceIgnore version configuration (#371)
- Add ForceIgnoreV2 improvements (#369)
- Add interface method overload validation (#368)
- Document MDAPI workspace support removal (#366)
- Include library project enhancements and fixes
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