Skip to content

Commit c89e5d0

Browse files
committed
Remove auto-update of config file
1 parent a46fd10 commit c89e5d0

4 files changed

Lines changed: 16 additions & 104 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ All notable changes to this project will be documented in this file.
44

55

66
## [1.55.0] (25/02/2026)
7-
In this update we have introduced a new feature that allows you to move text parts into subdirectories. The config file will be updated to reflect the new location of the text parts.
7+
In this update we have introduced a new feature that allows you to move text parts into subdirectories.
88

99
## [1.54.0] (17/02/2026)
1010
Added `create-test` command support for account templates (fetches template data, period data, and custom data).

lib/templates/accountTemplate.js

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,6 @@ class AccountTemplate {
9191

9292
if (!this.#validateFolderName(name, templateConfig)) return false;
9393

94-
// Scan disk for text parts and update config paths
95-
templateConfig = this.#syncTextPartsFromDisk(name, templateConfig);
96-
9794
const template = this.#filterConfigItems(templateConfig);
9895

9996
// Liquid tests
@@ -214,27 +211,6 @@ class AccountTemplate {
214211
}
215212
}
216213

217-
/**
218-
* For text parts already listed in the config, scan the disk to find their actual location.
219-
* This allows parts to be moved into subdirectories without manually editing the config.
220-
* Only parts that are already in the config are updated — new files on disk are not added.
221-
*/
222-
static #syncTextPartsFromDisk(name, templateConfig) {
223-
if (!templateConfig.text_parts || Object.keys(templateConfig.text_parts).length === 0) {
224-
return templateConfig;
225-
}
226-
227-
const diskParts = fsUtils.scanTextParts(this.TEMPLATE_TYPE, name);
228-
229-
for (const partName of Object.keys(templateConfig.text_parts)) {
230-
if (diskParts[partName]) {
231-
templateConfig.text_parts[partName] = diskParts[partName];
232-
}
233-
}
234-
235-
return templateConfig;
236-
}
237-
238214
static #createLiquidTest(name, templateConfig) {
239215
const testContent = "# Add your Liquid Tests here";
240216
fsUtils.createLiquidTestFiles(this.TEMPLATE_TYPE, name, testContent);

lib/templates/reconciliationText.js

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,6 @@ class ReconciliationText {
100100
const originalConfig = JSON.parse(JSON.stringify(templateConfig));
101101
templateConfig = this.#checkHandleAndNameInConfig(templateConfig, handle);
102102

103-
// Scan disk for text parts and update config paths
104-
templateConfig = this.#syncTextPartsFromDisk(handle, templateConfig);
105-
106103
let template = this.#filterConfigItems(templateConfig);
107104
template = this.#checkReconciliationType(template);
108105
// Liquid Tests
@@ -224,27 +221,6 @@ class ReconciliationText {
224221
return templateConfig;
225222
}
226223

227-
/**
228-
* For text parts already listed in the config, scan the disk to find their actual location.
229-
* This allows parts to be moved into subdirectories without manually editing the config.
230-
* Only parts that are already in the config are updated — new files on disk are not added.
231-
*/
232-
static #syncTextPartsFromDisk(handle, templateConfig) {
233-
if (!templateConfig.text_parts || Object.keys(templateConfig.text_parts).length === 0) {
234-
return templateConfig;
235-
}
236-
237-
const diskParts = fsUtils.scanTextParts(this.TEMPLATE_TYPE, handle);
238-
239-
for (const partName of Object.keys(templateConfig.text_parts)) {
240-
if (diskParts[partName]) {
241-
templateConfig.text_parts[partName] = diskParts[partName];
242-
}
243-
}
244-
245-
return templateConfig;
246-
}
247-
248224
static #createLiquidTest(handle, templateConfig) {
249225
// Liquid Test YAML
250226
const testContent = "# Add your Liquid Tests here";

tests/lib/templates/reconciliationTexts.test.js

Lines changed: 15 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -570,87 +570,47 @@ describe("ReconciliationText", () => {
570570
expect(result.name_nl).toBe(handle);
571571
});
572572

573-
it("should find a text part that was moved into a subdirectory", () => {
574-
// Move part_1.liquid into a subfolder
573+
it("should read a text part from a subdirectory when config path is set manually", () => {
574+
// User manually set config to point to a subfolder; file lives there
575575
const subDir = path.join(templateDir, "text_parts", "tables");
576576
fs.mkdirSync(subDir, { recursive: true });
577577
fs.renameSync(part1LiquidPath, path.join(subDir, "part_1.liquid"));
578578

579+
const configWithSubfolderPath = { ...configContent, text_parts: { part_1: "text_parts/tables/part_1.liquid" } };
580+
fs.writeFileSync(configPath, JSON.stringify(configWithSubfolderPath));
581+
579582
const result = ReconciliationText.read(handle);
580583

581584
expect(result.text_parts).toEqual([{ name: "part_1", content: "Part 1 content" }]);
582585
});
583586

584-
it("should update config.json when a text part is moved to a subdirectory", () => {
585-
// Move part_1.liquid into a subfolder
586-
const subDir = path.join(templateDir, "text_parts", "tables");
587-
fs.mkdirSync(subDir, { recursive: true });
588-
fs.renameSync(part1LiquidPath, path.join(subDir, "part_1.liquid"));
589-
590-
ReconciliationText.read(handle);
591-
592-
const updatedConfig = JSON.parse(fs.readFileSync(configPath, "utf-8"));
593-
expect(updatedConfig.text_parts.part_1).toBe("text_parts/tables/part_1.liquid");
594-
});
595-
596-
it("should find a text part nested multiple levels deep", () => {
597-
// Move part_1.liquid into a deeply nested subfolder
598-
// First, ensure no leftover from other tests by recreating the file at original location
599-
if (!fs.existsSync(part1LiquidPath)) {
600-
fs.writeFileSync(part1LiquidPath, "Part 1 content");
601-
}
602-
// Remove any subdirectories left from previous tests
603-
const textPartsDir = path.join(templateDir, "text_parts");
604-
for (const entry of fs.readdirSync(textPartsDir)) {
605-
const fullPath = path.join(textPartsDir, entry);
606-
if (fs.statSync(fullPath).isDirectory()) {
607-
fs.rmSync(fullPath, { recursive: true, force: true });
608-
}
609-
}
587+
it("should read a text part nested multiple levels deep when config path is set manually", () => {
610588
const deepDir = path.join(templateDir, "text_parts", "section", "subsection");
611589
fs.mkdirSync(deepDir, { recursive: true });
612-
fs.renameSync(part1LiquidPath, path.join(deepDir, "part_1.liquid"));
590+
fs.writeFileSync(path.join(deepDir, "part_1.liquid"), "Part 1 content");
591+
fs.unlinkSync(part1LiquidPath);
592+
593+
const configWithDeepPath = { ...configContent, text_parts: { part_1: "text_parts/section/subsection/part_1.liquid" } };
594+
fs.writeFileSync(configPath, JSON.stringify(configWithDeepPath));
613595

614596
const result = ReconciliationText.read(handle);
615597

616598
expect(result.text_parts).toEqual([{ name: "part_1", content: "Part 1 content" }]);
617-
618-
const updatedConfig = JSON.parse(fs.readFileSync(configPath, "utf-8"));
619-
expect(updatedConfig.text_parts.part_1).toBe("text_parts/section/subsection/part_1.liquid");
620599
});
621600

622-
it("should not add new files on disk that are not in the config", () => {
623-
// Add a new liquid file that is NOT listed in config
601+
it("should only include parts listed in the config", () => {
602+
// Extra file on disk not in config is ignored
624603
fs.writeFileSync(path.join(templateDir, "text_parts", "extra_part.liquid"), "Extra content");
625604

626605
const result = ReconciliationText.read(handle);
627606

628-
// Should only contain part_1, not extra_part
629607
expect(result.text_parts).toEqual([{ name: "part_1", content: "Part 1 content" }]);
630-
631-
const updatedConfig = JSON.parse(fs.readFileSync(configPath, "utf-8"));
632-
expect(updatedConfig.text_parts).not.toHaveProperty("extra_part");
633608
});
634609

635-
it("should keep config entry unchanged when a text part file is missing from disk", () => {
636-
// Delete part_1.liquid from disk but keep it in the config
610+
it("should throw when a text part in config is missing from disk", () => {
637611
fs.unlinkSync(part1LiquidPath);
638612

639-
// The config should still have the original path (not removed by syncTextPartsFromDisk)
640-
// We can't call read() fully because it will fail when trying to read the missing file,
641-
// so we just verify the config is not modified by writing it and checking it
642-
const configBefore = JSON.parse(fs.readFileSync(configPath, "utf-8"));
643-
expect(configBefore.text_parts.part_1).toBe("text_parts/part_1.liquid");
644-
645-
// read() will fail at readPartsLiquid, but the config should not have been altered
646-
try {
647-
ReconciliationText.read(handle);
648-
} catch (e) {
649-
// Expected to fail when reading the missing file
650-
}
651-
652-
const configAfter = JSON.parse(fs.readFileSync(configPath, "utf-8"));
653-
expect(configAfter.text_parts.part_1).toBe("text_parts/part_1.liquid");
613+
expect(() => ReconciliationText.read(handle)).toThrow();
654614
});
655615
});
656616
});

0 commit comments

Comments
 (0)