@timeax/scaffold 0.0.9 → 0.0.11
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/.idea/prettier.xml +6 -0
- package/dist/cli.cjs +38 -22
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.mjs +38 -22
- package/dist/cli.mjs.map +1 -1
- package/dist/index.cjs +21 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +21 -7
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -1
- package/src/cli/main.ts +285 -286
- package/src/core/apply-structure.ts +306 -255
package/dist/cli.cjs
CHANGED
|
@@ -941,6 +941,9 @@ async function applyStructure(opts) {
|
|
|
941
941
|
interactiveDelete
|
|
942
942
|
} = opts;
|
|
943
943
|
const logger6 = opts.logger ?? defaultLogger.child(groupName ? `[apply:${groupName}]` : "[apply]");
|
|
944
|
+
const projectRootAbs = path2__default.default.resolve(projectRoot);
|
|
945
|
+
const baseDirAbs = path2__default.default.resolve(baseDir);
|
|
946
|
+
baseDirAbs.endsWith(path2__default.default.sep) ? baseDirAbs : baseDirAbs + path2__default.default.sep;
|
|
944
947
|
const desiredPaths = /* @__PURE__ */ new Set();
|
|
945
948
|
const threshold = sizePromptThreshold ?? config.sizePromptThreshold ?? 128 * 1024;
|
|
946
949
|
async function walk(entry, inheritedStub) {
|
|
@@ -953,9 +956,9 @@ async function applyStructure(opts) {
|
|
|
953
956
|
}
|
|
954
957
|
async function handleDir(entry, inheritedStub) {
|
|
955
958
|
const relFromBase = entry.path.replace(/^[./]+/, "");
|
|
956
|
-
const absDir = path2__default.default.resolve(
|
|
959
|
+
const absDir = path2__default.default.resolve(baseDirAbs, relFromBase);
|
|
957
960
|
const relFromRoot = toPosixPath(
|
|
958
|
-
toProjectRelativePath(
|
|
961
|
+
toProjectRelativePath(projectRootAbs, absDir)
|
|
959
962
|
);
|
|
960
963
|
desiredPaths.add(relFromRoot);
|
|
961
964
|
ensureDirSync(absDir);
|
|
@@ -968,14 +971,14 @@ async function applyStructure(opts) {
|
|
|
968
971
|
}
|
|
969
972
|
async function handleFile(entry, inheritedStub) {
|
|
970
973
|
const relFromBase = entry.path.replace(/^[./]+/, "");
|
|
971
|
-
const absFile = path2__default.default.resolve(
|
|
974
|
+
const absFile = path2__default.default.resolve(baseDirAbs, relFromBase);
|
|
972
975
|
const relFromRoot = toPosixPath(
|
|
973
|
-
toProjectRelativePath(
|
|
976
|
+
toProjectRelativePath(projectRootAbs, absFile)
|
|
974
977
|
);
|
|
975
978
|
desiredPaths.add(relFromRoot);
|
|
976
979
|
const stubName = entry.stub ?? inheritedStub;
|
|
977
980
|
const ctx = {
|
|
978
|
-
projectRoot,
|
|
981
|
+
projectRoot: projectRootAbs,
|
|
979
982
|
targetPath: relFromRoot,
|
|
980
983
|
absolutePath: absFile,
|
|
981
984
|
isDirectory: false,
|
|
@@ -1015,7 +1018,19 @@ async function applyStructure(opts) {
|
|
|
1015
1018
|
await walk(entry);
|
|
1016
1019
|
}
|
|
1017
1020
|
for (const cachedPath of cache.allPaths()) {
|
|
1018
|
-
|
|
1021
|
+
const entry = cache.get(cachedPath);
|
|
1022
|
+
if (groupName) {
|
|
1023
|
+
if (!entry || entry.groupName !== groupName) {
|
|
1024
|
+
continue;
|
|
1025
|
+
}
|
|
1026
|
+
} else {
|
|
1027
|
+
if (entry && entry.groupName) {
|
|
1028
|
+
continue;
|
|
1029
|
+
}
|
|
1030
|
+
}
|
|
1031
|
+
if (desiredPaths.has(cachedPath)) {
|
|
1032
|
+
continue;
|
|
1033
|
+
}
|
|
1019
1034
|
const abs = path2__default.default.resolve(projectRoot, cachedPath);
|
|
1020
1035
|
const stats = statSafeSync(abs);
|
|
1021
1036
|
if (!stats) {
|
|
@@ -1026,7 +1041,6 @@ async function applyStructure(opts) {
|
|
|
1026
1041
|
cache.delete(cachedPath);
|
|
1027
1042
|
continue;
|
|
1028
1043
|
}
|
|
1029
|
-
const entry = cache.get(cachedPath);
|
|
1030
1044
|
const ctx = {
|
|
1031
1045
|
projectRoot,
|
|
1032
1046
|
targetPath: cachedPath,
|
|
@@ -1541,8 +1555,9 @@ async function handleRunCommand(cwd, baseOpts) {
|
|
|
1541
1555
|
const logger6 = createCliLogger(baseOpts);
|
|
1542
1556
|
const configPath = baseOpts.config ? path2__default.default.resolve(cwd, baseOpts.config) : void 0;
|
|
1543
1557
|
const scaffoldDir = baseOpts.dir ? path2__default.default.resolve(cwd, baseOpts.dir) : void 0;
|
|
1558
|
+
const resolvedScaffoldDir = scaffoldDir ?? path2__default.default.resolve(cwd, SCAFFOLD_ROOT_DIR);
|
|
1544
1559
|
logger6.debug(
|
|
1545
|
-
`Starting scaffold (cwd=${cwd}, config=${configPath ?? "auto"}, dir=${
|
|
1560
|
+
`Starting scaffold (cwd=${cwd}, config=${configPath ?? "auto"}, dir=${resolvedScaffoldDir}, watch=${baseOpts.watch ? "yes" : "no"})`
|
|
1546
1561
|
);
|
|
1547
1562
|
const runnerOptions = {
|
|
1548
1563
|
configPath,
|
|
@@ -1574,7 +1589,9 @@ async function handleScanCommand(cwd, scanOpts, baseOpts) {
|
|
|
1574
1589
|
logger6.info("Scanning project using scaffold config/groups...");
|
|
1575
1590
|
await writeScannedStructuresFromConfig(cwd, {
|
|
1576
1591
|
ignore: scanOpts.ignore,
|
|
1577
|
-
groups: scanOpts.groups
|
|
1592
|
+
groups: scanOpts.groups,
|
|
1593
|
+
scaffoldDir: baseOpts.dir,
|
|
1594
|
+
maxDepth: scanOpts.maxDepth
|
|
1578
1595
|
});
|
|
1579
1596
|
return;
|
|
1580
1597
|
}
|
|
@@ -1624,19 +1641,16 @@ async function handleStructuresCommand(cwd, baseOpts) {
|
|
|
1624
1641
|
async function main() {
|
|
1625
1642
|
const cwd = process.cwd();
|
|
1626
1643
|
const program = new commander.Command();
|
|
1627
|
-
program.name("scaffold").description("@timeax/scaffold \u2013 structure-based project scaffolding").option("-c, --config <path>", "Path to scaffold config file").option(
|
|
1644
|
+
program.name("scaffold").description("@timeax/scaffold \u2013 structure-based project scaffolding").option("-c, --config <path>", "Path to scaffold config file").option(
|
|
1645
|
+
"-d, --dir <path>",
|
|
1646
|
+
`Path to scaffold directory (default: ./${SCAFFOLD_ROOT_DIR})`
|
|
1647
|
+
).option("-w, --watch", "Watch scaffold directory for changes").option("--quiet", "Silence logs").option("--debug", "Enable debug logging");
|
|
1628
1648
|
program.command("scan").description(
|
|
1629
1649
|
"Generate structure.txt-style output (config-aware by default, or manual root/out)"
|
|
1630
1650
|
).option(
|
|
1631
1651
|
"--from-config",
|
|
1632
|
-
|
|
1633
|
-
).option(
|
|
1634
|
-
"-r, --root <path>",
|
|
1635
|
-
"Root directory to scan (manual mode)"
|
|
1636
|
-
).option(
|
|
1637
|
-
"-o, --out <path>",
|
|
1638
|
-
"Output file path (manual mode)"
|
|
1639
|
-
).option(
|
|
1652
|
+
`Scan based on scaffold config/groups and write structure files into ${SCAFFOLD_ROOT_DIR}/ (default if no root/out specified)`
|
|
1653
|
+
).option("-r, --root <path>", "Root directory to scan (manual mode)").option("-o, --out <path>", "Output file path (manual mode)").option("-d, --depth <number>", "Max directory depth to scan (default: infinity, 0 = only scan root dir").option(
|
|
1640
1654
|
"--ignore <patterns...>",
|
|
1641
1655
|
"Additional glob patterns to ignore (relative to root)"
|
|
1642
1656
|
).option(
|
|
@@ -1646,22 +1660,24 @@ async function main() {
|
|
|
1646
1660
|
const baseOpts = cmd.parent?.opts() ?? {};
|
|
1647
1661
|
await handleScanCommand(cwd, scanOpts, baseOpts);
|
|
1648
1662
|
});
|
|
1649
|
-
program.command("init").description(
|
|
1663
|
+
program.command("init").description(
|
|
1664
|
+
`Initialize ${SCAFFOLD_ROOT_DIR} folder and config/structure files`
|
|
1665
|
+
).option(
|
|
1650
1666
|
"--force",
|
|
1651
1667
|
"Overwrite existing config/structure files if they already exist"
|
|
1652
1668
|
).action(async (initOpts, cmd) => {
|
|
1653
1669
|
const baseOpts = cmd.parent?.opts() ?? {};
|
|
1654
1670
|
await handleInitCommand(cwd, initOpts, baseOpts);
|
|
1655
1671
|
});
|
|
1656
|
-
program.action(async (opts) => {
|
|
1657
|
-
await handleRunCommand(cwd, opts);
|
|
1658
|
-
});
|
|
1659
1672
|
program.command("structures").description(
|
|
1660
1673
|
"Create missing structure files specified in the config (does not overwrite existing files)"
|
|
1661
1674
|
).action(async (_opts, cmd) => {
|
|
1662
1675
|
const baseOpts = cmd.parent?.opts() ?? {};
|
|
1663
1676
|
await handleStructuresCommand(cwd, baseOpts);
|
|
1664
1677
|
});
|
|
1678
|
+
program.action(async (opts) => {
|
|
1679
|
+
await handleRunCommand(cwd, opts);
|
|
1680
|
+
});
|
|
1665
1681
|
await program.parseAsync(process.argv);
|
|
1666
1682
|
}
|
|
1667
1683
|
main().catch((err) => {
|