@timeax/scaffold 0.0.13 → 0.1.0

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/cli.cjs CHANGED
@@ -651,7 +651,7 @@ function stripInlineComment(content) {
651
651
  }
652
652
  return content.slice(0, cutIndex).trimEnd();
653
653
  }
654
- function parseLine(line, lineNo) {
654
+ function parseLine(line, lineNo, fileName) {
655
655
  const match = line.match(/^(\s*)(.*)$/);
656
656
  if (!match) return null;
657
657
  const indentSpaces = match[1].length;
@@ -669,7 +669,7 @@ function parseLine(line, lineNo) {
669
669
  const pathToken = parts[0];
670
670
  if (pathToken.includes(":")) {
671
671
  throw new Error(
672
- `structure.txt: ":" is reserved for annotations (@stub:, @include:, etc). Invalid path "${pathToken}" on line ${lineNo}.`
672
+ `${fileName}: ":" is reserved for annotations (@stub:, @include:, etc). Invalid path "${pathToken}" on line ${lineNo}.`
673
673
  );
674
674
  }
675
675
  let stub;
@@ -703,12 +703,12 @@ function parseLine(line, lineNo) {
703
703
  exclude: exclude.length ? exclude : void 0
704
704
  };
705
705
  }
706
- function parseStructureText(text, indentStep = 2) {
706
+ function parseStructureText(fileName, text, indentStep = 2) {
707
707
  const lines = text.split(/\r?\n/);
708
708
  const parsed = [];
709
709
  for (let i = 0; i < lines.length; i++) {
710
710
  const lineNo = i + 1;
711
- const p = parseLine(lines[i], lineNo);
711
+ const p = parseLine(lines[i], lineNo, fileName);
712
712
  if (p) parsed.push(p);
713
713
  }
714
714
  const rootEntries = [];
@@ -717,14 +717,14 @@ function parseStructureText(text, indentStep = 2) {
717
717
  const { indentSpaces, lineNo } = p;
718
718
  if (indentSpaces % indentStep !== 0) {
719
719
  throw new Error(
720
- `structure.txt: Invalid indent on line ${lineNo}. Indent must be multiples of ${indentStep} spaces.`
720
+ `${fileName}: Invalid indent on line ${lineNo}. Indent must be multiples of ${indentStep} spaces.`
721
721
  );
722
722
  }
723
723
  const level = indentSpaces / indentStep;
724
724
  if (level > stack.length) {
725
725
  if (level !== stack.length + 1) {
726
726
  throw new Error(
727
- `structure.txt: Invalid indentation on line ${lineNo}. You cannot jump more than one level at a time. Previous depth: ${stack.length}, this line depth: ${level}.`
727
+ `${fileName}: Invalid indentation on line ${lineNo}. You cannot jump more than one level at a time. Previous depth: ${stack.length}, this line depth: ${level}.`
728
728
  );
729
729
  }
730
730
  }
@@ -732,12 +732,12 @@ function parseStructureText(text, indentStep = 2) {
732
732
  const parent2 = stack[level - 1];
733
733
  if (!parent2) {
734
734
  throw new Error(
735
- `structure.txt: Indented entry without a parent on line ${lineNo}.`
735
+ `${fileName}: Indented entry without a parent on line ${lineNo}.`
736
736
  );
737
737
  }
738
738
  if (!parent2.isDir) {
739
739
  throw new Error(
740
- `structure.txt: Cannot indent under a file on line ${lineNo}. Files cannot have children. Parent: "${parent2.entry.path}".`
740
+ `${fileName}: Cannot indent under a file on line ${lineNo}. Files cannot have children. Parent: "${parent2.entry.path}".`
741
741
  );
742
742
  }
743
743
  }
@@ -788,7 +788,7 @@ function parseStructureText(text, indentStep = 2) {
788
788
 
789
789
  // src/core/resolve-structure.ts
790
790
  var logger2 = defaultLogger.child("[structure]");
791
- function resolveGroupStructure(scaffoldDir, group) {
791
+ function resolveGroupStructure(scaffoldDir, group, config) {
792
792
  if (group.structure && group.structure.length) {
793
793
  logger2.debug(`Using inline structure for group "${group.name}"`);
794
794
  return group.structure;
@@ -802,7 +802,7 @@ function resolveGroupStructure(scaffoldDir, group) {
802
802
  }
803
803
  logger2.debug(`Reading structure for group "${group.name}" from ${filePath}`);
804
804
  const raw = fs8__default.default.readFileSync(filePath, "utf8");
805
- return parseStructureText(raw);
805
+ return parseStructureText(fileName, raw, config.indentStep);
806
806
  }
807
807
  function resolveSingleStructure(scaffoldDir, config) {
808
808
  if (config.structure && config.structure.length) {
@@ -818,7 +818,7 @@ function resolveSingleStructure(scaffoldDir, config) {
818
818
  }
819
819
  logger2.debug(`Reading single structure from ${filePath}`);
820
820
  const raw = fs8__default.default.readFileSync(filePath, "utf8");
821
- return parseStructureText(raw);
821
+ return parseStructureText(fileName, raw, config.indentStep);
822
822
  }
823
823
  var logger3 = defaultLogger.child("[cache]");
824
824
  var DEFAULT_CACHE = {
@@ -1287,7 +1287,7 @@ async function runOnce(cwd, options = {}) {
1287
1287
  if (config.groups && config.groups.length > 0) {
1288
1288
  for (const group of config.groups) {
1289
1289
  const groupRootAbs = path2__default.default.resolve(projectRoot, group.root);
1290
- const structure = resolveGroupStructure(scaffoldDir, group);
1290
+ const structure = resolveGroupStructure(scaffoldDir, group, config);
1291
1291
  const groupLogger = logger6.child(`[group:${group.name}]`);
1292
1292
  await applyStructure({
1293
1293
  config,