@vdhewei/xlsx-template-lib 1.6.4 → 1.6.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/bin.js CHANGED
@@ -4419,6 +4419,7 @@ async function parseRulesFromFile(filePath) {
4419
4419
  const lines = fileContent.split("\n");
4420
4420
  const rules = [];
4421
4421
  const validTypes = ["cell", "alias", "rowCell", "mergeCell"];
4422
+ const validRulesSet = /* @__PURE__ */ new Set();
4422
4423
  for (let i = 0; i < lines.length; i++) {
4423
4424
  const line = lines[i].trim();
4424
4425
  if (!line || line.startsWith("#")) {
@@ -4430,16 +4431,28 @@ async function parseRulesFromFile(filePath) {
4430
4431
  continue;
4431
4432
  }
4432
4433
  const type = line.substring(0, spaceIndex).trim();
4433
- const rule = line.substring(spaceIndex + 1).trim();
4434
- if (!type || !rule) {
4434
+ const items = line.substring(spaceIndex + 1).trim().split(" ");
4435
+ if (!type) {
4435
4436
  console.log(import_chalk.default.yellow(`\u26A0 Line ${i + 1}: Invalid format. Expected "<type> ruleExpr"`));
4436
4437
  continue;
4437
4438
  }
4439
+ if (!items || items.length === 0) {
4440
+ continue;
4441
+ }
4438
4442
  if (!validTypes.includes(type)) {
4439
4443
  console.log(import_chalk.default.yellow(`\u26A0 Line ${i + 1}: Invalid rule type "${type}". Must be one of: ${validTypes.join(", ")}`));
4440
4444
  continue;
4441
4445
  }
4442
- rules.push({ type, rule });
4446
+ for (const rule of items) {
4447
+ let str = rule.trim();
4448
+ let key = `${type}:${str}`;
4449
+ if (validRulesSet.has(key)) {
4450
+ console.log(import_chalk.default.yellow(`\u26A0 Line ${i + 1}: Duplicate rule "${str}"`));
4451
+ continue;
4452
+ }
4453
+ validRulesSet.add(key);
4454
+ rules.push({ type, rule: str });
4455
+ }
4443
4456
  }
4444
4457
  if (rules.length === 0) {
4445
4458
  throw new Error("No valid rules found in file");
@@ -4499,7 +4512,7 @@ async function main() {
4499
4512
  opts.remove = options.remove || false;
4500
4513
  const compiledBuffer = await compileAll(buffer, opts);
4501
4514
  console.log(import_chalk2.default.green("\u2713 Compilation completed"));
4502
- const outputFile = options.save || path3.join(process.cwd(), generateOutputFilename(xlsxFile));
4515
+ const outputFile = path3.join(options.save || process.cwd(), generateOutputFilename(xlsxFile));
4503
4516
  console.log(import_chalk2.default.gray(`Saving to: ${outputFile}`));
4504
4517
  await fs4.writeFile(outputFile, compiledBuffer);
4505
4518
  console.log(import_chalk2.default.green("\u2713 Excel file compiled successfully!"));
@@ -4546,7 +4559,7 @@ async function main() {
4546
4559
  level: 9
4547
4560
  }
4548
4561
  });
4549
- const outputFile = options.save || path3.join(process.cwd(), generateOutputFilename(xlsxFile));
4562
+ const outputFile = path3.join(options.save || process.cwd(), generateOutputFilename(xlsxFile));
4550
4563
  console.log(import_chalk2.default.gray(`Saving to: ${outputFile}`));
4551
4564
  await fs4.writeFile(outputFile, outputBuffer);
4552
4565
  console.log(import_chalk2.default.green("\u2713 Excel template rendered successfully!"));
@@ -4593,7 +4606,7 @@ async function main() {
4593
4606
  console.log(import_chalk2.default.gray(`Loading file: ${filePath}`));
4594
4607
  const buffer = await fs4.readFile(filePath);
4595
4608
  const updatedBuffer = await addMultipleRulesToSheet(buffer, rules);
4596
- const outputFile = options.save || path3.join(process.cwd(), generateOutputFilename(xlsxFile));
4609
+ const outputFile = path3.join(options.save || process.cwd(), generateOutputFilename(xlsxFile));
4597
4610
  console.log(import_chalk2.default.gray(`Saving to: ${outputFile}`));
4598
4611
  await fs4.writeFile(outputFile, updatedBuffer);
4599
4612
  console.log(import_chalk2.default.green("\u2713 All rules added successfully!"));