Skip to content

Comments

Allow folder structure in config text parts#248

Open
Benjvandam wants to merge 7 commits intomainfrom
allow-folder-structure-in-config-text-parts
Open

Allow folder structure in config text parts#248
Benjvandam wants to merge 7 commits intomainfrom
allow-folder-structure-in-config-text-parts

Conversation

@Benjvandam
Copy link

@Benjvandam Benjvandam commented Feb 16, 2026

Fixes # #240

Description

This feature allows you to create a folder structure within the text_parts of a reconciliation and account template. First it builds a map of the actual folder structure. Then based on the map, the text parts in the config are updated to to reflect the correct path. If a file was not mentioned in the config file, it will not be suddenly be included.

Testing Instructions

Steps:

  1. Update the folder structure in your files. Add folders and subfolders and shift your files text_parts around
  2. Update/ push your files to the platform or run tests
  3. The config file will automatically be updated to reflect the correct path and everything else keeps working

Keep into account that you may have to disable the extension for testing. Because it seems that when you move files around in subfolders, the Extension automatically removes them from the config when you save. In order for it to work properly, we may need to update the Extension as well still.

Author Checklist

  • Skip bumping the CLI version

Reviewer Checklist

  • PR has a clear title and description
  • Manually tested the changes that the PR introduces
  • Changes introduced are covered by tests of acceptable quality

@Benjvandam Benjvandam self-assigned this Feb 16, 2026
@Benjvandam Benjvandam added the feature request New feature or request label Feb 16, 2026
@coderabbitai
Copy link

coderabbitai bot commented Feb 16, 2026

Walkthrough

Adds disk-based synchronization for template text_parts: a new fsUtils scanner maps on-disk text parts, templates refresh their in-memory configs from disk during reads/creates, changed configs are persisted back to disk, and tests cover moved, nested, missing, and unlisted text parts.

Changes

Cohort / File(s) Summary
Text Parts Scan Utility
lib/utils/fsUtils.js
Adds scanTextParts(templateType, handle) to recursively scan text_parts on disk, return name→relative-path map, detect/log duplicates, and export the function.
Template sync & persistence
lib/templates/accountTemplate.js, lib/templates/reconciliationText.js
Adds private static helpers #syncTextPartsFromDisk and #updateConfigIfChanged, switches to deep-cloning configs, integrates disk-sync into read/create flows, and persists config when differences are detected.
Tests for reconciliation texts
tests/lib/templates/reconciliationTexts.test.js
Adds tests for moved parts (including nested directories), missing files, and ensuring on-disk-only parts are not injected; updates cleanup to fs.rmSync(..., { force: true }).
Package metadata & changelog
package.json, CHANGELOG.md
Version bump to 1.54.0 and changelog entry describing support for moving text parts into subdirectories and config updates.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 3 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main feature: allowing folder structures in config text parts, which is the core change across all modified files.
Merge Conflict Detection ✅ Passed ✅ No merge conflicts detected when merging into main
Description check ✅ Passed PR description includes all required sections: issue link, detailed description of changes, testing instructions with steps, and both checklists.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch allow-folder-structure-in-config-text-parts

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
tests/lib/templates/reconciliationTexts.test.js (1)

635-654: Test relies on exception handling for incomplete verification.

The test correctly verifies that the config entry remains unchanged when a file is missing from disk. However, the test catches and ignores the exception from ReconciliationText.read(handle) without verifying it was thrown for the expected reason.

Consider adding an assertion to verify the exception was thrown:

💡 Suggested improvement
      // read() will fail at readPartsLiquid, but the config should not have been altered
+     let errorThrown = false;
      try {
        ReconciliationText.read(handle);
      } catch (e) {
        // Expected to fail when reading the missing file
+       errorThrown = true;
+       expect(e.code).toBe('ENOENT');
      }
+     expect(errorThrown).toBe(true);

      const configAfter = JSON.parse(fs.readFileSync(configPath, "utf-8"));
      expect(configAfter.text_parts.part_1).toBe("text_parts/part_1.liquid");
lib/templates/accountTemplate.js (1)

211-236: Consider extracting duplicated methods to a shared utility.

The #updateConfigIfChanged and #syncTextPartsFromDisk methods are nearly identical to those in ReconciliationText. This duplication increases maintenance burden.

Since both classes already use fsUtils, consider moving these helper functions there:

// In fsUtils.js
function syncTextPartsInConfig(templateType, handle, templateConfig) { ... }
function updateConfigIfChanged(templateType, handle, originalConfig, currentConfig) { ... }

This would allow both ReconciliationText and AccountTemplate to share the same implementation.

@Benjvandam Benjvandam force-pushed the allow-folder-structure-in-config-text-parts branch from 54bf138 to 4f4d617 Compare February 16, 2026 14:52
@Benjvandam Benjvandam force-pushed the allow-folder-structure-in-config-text-parts branch from 4f4d617 to 5726497 Compare February 16, 2026 14:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature request New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants