@timeax/scaffold 0.0.12 → 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/.vscode/settings.json +0 -1
- package/dist/cli.cjs +12 -12
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.mjs +12 -12
- package/dist/cli.mjs.map +1 -1
- package/dist/index.cjs +12 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +12 -12
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -1
- package/scripts/postpublish.mjs +16 -6
- package/src/core/resolve-structure.ts +3 -2
- package/src/core/runner.ts +1 -1
- package/src/core/structure-txt.ts +8 -7
package/dist/index.cjs
CHANGED
|
@@ -645,7 +645,7 @@ function stripInlineComment(content) {
|
|
|
645
645
|
}
|
|
646
646
|
return content.slice(0, cutIndex).trimEnd();
|
|
647
647
|
}
|
|
648
|
-
function parseLine(line, lineNo) {
|
|
648
|
+
function parseLine(line, lineNo, fileName) {
|
|
649
649
|
const match = line.match(/^(\s*)(.*)$/);
|
|
650
650
|
if (!match) return null;
|
|
651
651
|
const indentSpaces = match[1].length;
|
|
@@ -663,7 +663,7 @@ function parseLine(line, lineNo) {
|
|
|
663
663
|
const pathToken = parts[0];
|
|
664
664
|
if (pathToken.includes(":")) {
|
|
665
665
|
throw new Error(
|
|
666
|
-
|
|
666
|
+
`${fileName}: ":" is reserved for annotations (@stub:, @include:, etc). Invalid path "${pathToken}" on line ${lineNo}.`
|
|
667
667
|
);
|
|
668
668
|
}
|
|
669
669
|
let stub;
|
|
@@ -697,12 +697,12 @@ function parseLine(line, lineNo) {
|
|
|
697
697
|
exclude: exclude.length ? exclude : void 0
|
|
698
698
|
};
|
|
699
699
|
}
|
|
700
|
-
function parseStructureText(text, indentStep = 2) {
|
|
700
|
+
function parseStructureText(fileName, text, indentStep = 2) {
|
|
701
701
|
const lines = text.split(/\r?\n/);
|
|
702
702
|
const parsed = [];
|
|
703
703
|
for (let i = 0; i < lines.length; i++) {
|
|
704
704
|
const lineNo = i + 1;
|
|
705
|
-
const p = parseLine(lines[i], lineNo);
|
|
705
|
+
const p = parseLine(lines[i], lineNo, fileName);
|
|
706
706
|
if (p) parsed.push(p);
|
|
707
707
|
}
|
|
708
708
|
const rootEntries = [];
|
|
@@ -711,14 +711,14 @@ function parseStructureText(text, indentStep = 2) {
|
|
|
711
711
|
const { indentSpaces, lineNo } = p;
|
|
712
712
|
if (indentSpaces % indentStep !== 0) {
|
|
713
713
|
throw new Error(
|
|
714
|
-
|
|
714
|
+
`${fileName}: Invalid indent on line ${lineNo}. Indent must be multiples of ${indentStep} spaces.`
|
|
715
715
|
);
|
|
716
716
|
}
|
|
717
717
|
const level = indentSpaces / indentStep;
|
|
718
718
|
if (level > stack.length) {
|
|
719
719
|
if (level !== stack.length + 1) {
|
|
720
720
|
throw new Error(
|
|
721
|
-
|
|
721
|
+
`${fileName}: Invalid indentation on line ${lineNo}. You cannot jump more than one level at a time. Previous depth: ${stack.length}, this line depth: ${level}.`
|
|
722
722
|
);
|
|
723
723
|
}
|
|
724
724
|
}
|
|
@@ -726,12 +726,12 @@ function parseStructureText(text, indentStep = 2) {
|
|
|
726
726
|
const parent2 = stack[level - 1];
|
|
727
727
|
if (!parent2) {
|
|
728
728
|
throw new Error(
|
|
729
|
-
|
|
729
|
+
`${fileName}: Indented entry without a parent on line ${lineNo}.`
|
|
730
730
|
);
|
|
731
731
|
}
|
|
732
732
|
if (!parent2.isDir) {
|
|
733
733
|
throw new Error(
|
|
734
|
-
|
|
734
|
+
`${fileName}: Cannot indent under a file on line ${lineNo}. Files cannot have children. Parent: "${parent2.entry.path}".`
|
|
735
735
|
);
|
|
736
736
|
}
|
|
737
737
|
}
|
|
@@ -782,7 +782,7 @@ function parseStructureText(text, indentStep = 2) {
|
|
|
782
782
|
|
|
783
783
|
// src/core/resolve-structure.ts
|
|
784
784
|
var logger2 = defaultLogger.child("[structure]");
|
|
785
|
-
function resolveGroupStructure(scaffoldDir, group) {
|
|
785
|
+
function resolveGroupStructure(scaffoldDir, group, config) {
|
|
786
786
|
if (group.structure && group.structure.length) {
|
|
787
787
|
logger2.debug(`Using inline structure for group "${group.name}"`);
|
|
788
788
|
return group.structure;
|
|
@@ -796,7 +796,7 @@ function resolveGroupStructure(scaffoldDir, group) {
|
|
|
796
796
|
}
|
|
797
797
|
logger2.debug(`Reading structure for group "${group.name}" from ${filePath}`);
|
|
798
798
|
const raw = fs2__default.default.readFileSync(filePath, "utf8");
|
|
799
|
-
return parseStructureText(raw);
|
|
799
|
+
return parseStructureText(fileName, raw, config.indentStep);
|
|
800
800
|
}
|
|
801
801
|
function resolveSingleStructure(scaffoldDir, config) {
|
|
802
802
|
if (config.structure && config.structure.length) {
|
|
@@ -812,7 +812,7 @@ function resolveSingleStructure(scaffoldDir, config) {
|
|
|
812
812
|
}
|
|
813
813
|
logger2.debug(`Reading single structure from ${filePath}`);
|
|
814
814
|
const raw = fs2__default.default.readFileSync(filePath, "utf8");
|
|
815
|
-
return parseStructureText(raw);
|
|
815
|
+
return parseStructureText(fileName, raw, config.indentStep);
|
|
816
816
|
}
|
|
817
817
|
var logger3 = defaultLogger.child("[cache]");
|
|
818
818
|
var DEFAULT_CACHE = {
|
|
@@ -1123,7 +1123,7 @@ async function runOnce(cwd, options = {}) {
|
|
|
1123
1123
|
if (config.groups && config.groups.length > 0) {
|
|
1124
1124
|
for (const group of config.groups) {
|
|
1125
1125
|
const groupRootAbs = path2__default.default.resolve(projectRoot, group.root);
|
|
1126
|
-
const structure = resolveGroupStructure(scaffoldDir, group);
|
|
1126
|
+
const structure = resolveGroupStructure(scaffoldDir, group, config);
|
|
1127
1127
|
const groupLogger = logger5.child(`[group:${group.name}]`);
|
|
1128
1128
|
await applyStructure({
|
|
1129
1129
|
config,
|