@timeax/scaffold 0.0.10 → 0.0.12
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 +37 -29
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.mjs +37 -29
- 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 +1 -1
- package/src/core/apply-structure.ts +306 -255
- package/src/core/watcher.ts +29 -32
package/dist/cli.mjs
CHANGED
|
@@ -930,6 +930,9 @@ async function applyStructure(opts) {
|
|
|
930
930
|
interactiveDelete
|
|
931
931
|
} = opts;
|
|
932
932
|
const logger6 = opts.logger ?? defaultLogger.child(groupName ? `[apply:${groupName}]` : "[apply]");
|
|
933
|
+
const projectRootAbs = path2.resolve(projectRoot);
|
|
934
|
+
const baseDirAbs = path2.resolve(baseDir);
|
|
935
|
+
baseDirAbs.endsWith(path2.sep) ? baseDirAbs : baseDirAbs + path2.sep;
|
|
933
936
|
const desiredPaths = /* @__PURE__ */ new Set();
|
|
934
937
|
const threshold = sizePromptThreshold ?? config.sizePromptThreshold ?? 128 * 1024;
|
|
935
938
|
async function walk(entry, inheritedStub) {
|
|
@@ -942,9 +945,9 @@ async function applyStructure(opts) {
|
|
|
942
945
|
}
|
|
943
946
|
async function handleDir(entry, inheritedStub) {
|
|
944
947
|
const relFromBase = entry.path.replace(/^[./]+/, "");
|
|
945
|
-
const absDir = path2.resolve(
|
|
948
|
+
const absDir = path2.resolve(baseDirAbs, relFromBase);
|
|
946
949
|
const relFromRoot = toPosixPath(
|
|
947
|
-
toProjectRelativePath(
|
|
950
|
+
toProjectRelativePath(projectRootAbs, absDir)
|
|
948
951
|
);
|
|
949
952
|
desiredPaths.add(relFromRoot);
|
|
950
953
|
ensureDirSync(absDir);
|
|
@@ -957,14 +960,14 @@ async function applyStructure(opts) {
|
|
|
957
960
|
}
|
|
958
961
|
async function handleFile(entry, inheritedStub) {
|
|
959
962
|
const relFromBase = entry.path.replace(/^[./]+/, "");
|
|
960
|
-
const absFile = path2.resolve(
|
|
963
|
+
const absFile = path2.resolve(baseDirAbs, relFromBase);
|
|
961
964
|
const relFromRoot = toPosixPath(
|
|
962
|
-
toProjectRelativePath(
|
|
965
|
+
toProjectRelativePath(projectRootAbs, absFile)
|
|
963
966
|
);
|
|
964
967
|
desiredPaths.add(relFromRoot);
|
|
965
968
|
const stubName = entry.stub ?? inheritedStub;
|
|
966
969
|
const ctx = {
|
|
967
|
-
projectRoot,
|
|
970
|
+
projectRoot: projectRootAbs,
|
|
968
971
|
targetPath: relFromRoot,
|
|
969
972
|
absolutePath: absFile,
|
|
970
973
|
isDirectory: false,
|
|
@@ -1004,7 +1007,19 @@ async function applyStructure(opts) {
|
|
|
1004
1007
|
await walk(entry);
|
|
1005
1008
|
}
|
|
1006
1009
|
for (const cachedPath of cache.allPaths()) {
|
|
1007
|
-
|
|
1010
|
+
const entry = cache.get(cachedPath);
|
|
1011
|
+
if (groupName) {
|
|
1012
|
+
if (!entry || entry.groupName !== groupName) {
|
|
1013
|
+
continue;
|
|
1014
|
+
}
|
|
1015
|
+
} else {
|
|
1016
|
+
if (entry && entry.groupName) {
|
|
1017
|
+
continue;
|
|
1018
|
+
}
|
|
1019
|
+
}
|
|
1020
|
+
if (desiredPaths.has(cachedPath)) {
|
|
1021
|
+
continue;
|
|
1022
|
+
}
|
|
1008
1023
|
const abs = path2.resolve(projectRoot, cachedPath);
|
|
1009
1024
|
const stats = statSafeSync(abs);
|
|
1010
1025
|
if (!stats) {
|
|
@@ -1015,7 +1030,6 @@ async function applyStructure(opts) {
|
|
|
1015
1030
|
cache.delete(cachedPath);
|
|
1016
1031
|
continue;
|
|
1017
1032
|
}
|
|
1018
|
-
const entry = cache.get(cachedPath);
|
|
1019
1033
|
const ctx = {
|
|
1020
1034
|
projectRoot,
|
|
1021
1035
|
targetPath: cachedPath,
|
|
@@ -1316,7 +1330,7 @@ function watchScaffold(cwd, options = {}) {
|
|
|
1316
1330
|
// we already resolved scaffoldDir for watcher; pass it down
|
|
1317
1331
|
scaffoldDir
|
|
1318
1332
|
});
|
|
1319
|
-
logger6.info("Scaffold run completed
|
|
1333
|
+
logger6.info("Scaffold run completed");
|
|
1320
1334
|
} catch (err) {
|
|
1321
1335
|
logger6.error("Scaffold run failed:", err);
|
|
1322
1336
|
} finally {
|
|
@@ -1331,27 +1345,21 @@ function watchScaffold(cwd, options = {}) {
|
|
|
1331
1345
|
if (timer) clearTimeout(timer);
|
|
1332
1346
|
timer = setTimeout(run, debounceMs);
|
|
1333
1347
|
}
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
)
|
|
1347
|
-
|
|
1348
|
-
logger6.debug(`
|
|
1349
|
-
scheduleRun();
|
|
1350
|
-
}).on("change", (filePath) => {
|
|
1351
|
-
logger6.debug(`File changed: ${filePath}`);
|
|
1352
|
-
scheduleRun();
|
|
1353
|
-
}).on("unlink", (filePath) => {
|
|
1354
|
-
logger6.debug(`File removed: ${filePath}`);
|
|
1348
|
+
function isInteresting(filePath) {
|
|
1349
|
+
const rel = path2.relative(scaffoldDir, filePath);
|
|
1350
|
+
if (rel.startsWith("..")) return false;
|
|
1351
|
+
const base = path2.basename(filePath).toLowerCase();
|
|
1352
|
+
if (base.startsWith("config.")) return true;
|
|
1353
|
+
const ext = path2.extname(base);
|
|
1354
|
+
return ext === ".txt" || ext === ".tss" || ext === ".stx";
|
|
1355
|
+
}
|
|
1356
|
+
const watcher = chokidar.watch(scaffoldDir, {
|
|
1357
|
+
ignoreInitial: false,
|
|
1358
|
+
persistent: true
|
|
1359
|
+
});
|
|
1360
|
+
watcher.on("all", (event, filePath) => {
|
|
1361
|
+
if (!isInteresting(filePath)) return;
|
|
1362
|
+
logger6.debug(`Event ${event} on ${filePath}`);
|
|
1355
1363
|
scheduleRun();
|
|
1356
1364
|
}).on("error", (error) => {
|
|
1357
1365
|
logger6.error("Watcher error:", error);
|