@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.
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="PrettierConfiguration">
4
+ <option name="myConfigurationMode" value="AUTOMATIC" />
5
+ </component>
6
+ </project>
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(baseDir, relFromBase);
959
+ const absDir = path2__default.default.resolve(baseDirAbs, relFromBase);
957
960
  const relFromRoot = toPosixPath(
958
- toProjectRelativePath(projectRoot, absDir)
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(baseDir, relFromBase);
974
+ const absFile = path2__default.default.resolve(baseDirAbs, relFromBase);
972
975
  const relFromRoot = toPosixPath(
973
- toProjectRelativePath(projectRoot, absFile)
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
- if (desiredPaths.has(cachedPath)) continue;
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,
@@ -1327,7 +1341,7 @@ function watchScaffold(cwd, options = {}) {
1327
1341
  // we already resolved scaffoldDir for watcher; pass it down
1328
1342
  scaffoldDir
1329
1343
  });
1330
- logger6.info("Scaffold run completed.");
1344
+ logger6.info("Scaffold run completed");
1331
1345
  } catch (err) {
1332
1346
  logger6.error("Scaffold run failed:", err);
1333
1347
  } finally {
@@ -1342,27 +1356,21 @@ function watchScaffold(cwd, options = {}) {
1342
1356
  if (timer) clearTimeout(timer);
1343
1357
  timer = setTimeout(run, debounceMs);
1344
1358
  }
1345
- const watcher = chokidar__default.default.watch(
1346
- [
1347
- // config files (ts/js/etc.)
1348
- path2__default.default.join(scaffoldDir, "config.*"),
1349
- // structure files: plain txt + our custom extensions
1350
- path2__default.default.join(scaffoldDir, "*.txt"),
1351
- path2__default.default.join(scaffoldDir, "*.tss"),
1352
- path2__default.default.join(scaffoldDir, "*.stx")
1353
- ],
1354
- {
1355
- ignoreInitial: false
1356
- }
1357
- );
1358
- watcher.on("add", (filePath) => {
1359
- logger6.debug(`File added: ${filePath}`);
1360
- scheduleRun();
1361
- }).on("change", (filePath) => {
1362
- logger6.debug(`File changed: ${filePath}`);
1363
- scheduleRun();
1364
- }).on("unlink", (filePath) => {
1365
- logger6.debug(`File removed: ${filePath}`);
1359
+ function isInteresting(filePath) {
1360
+ const rel = path2__default.default.relative(scaffoldDir, filePath);
1361
+ if (rel.startsWith("..")) return false;
1362
+ const base = path2__default.default.basename(filePath).toLowerCase();
1363
+ if (base.startsWith("config.")) return true;
1364
+ const ext = path2__default.default.extname(base);
1365
+ return ext === ".txt" || ext === ".tss" || ext === ".stx";
1366
+ }
1367
+ const watcher = chokidar__default.default.watch(scaffoldDir, {
1368
+ ignoreInitial: false,
1369
+ persistent: true
1370
+ });
1371
+ watcher.on("all", (event, filePath) => {
1372
+ if (!isInteresting(filePath)) return;
1373
+ logger6.debug(`Event ${event} on ${filePath}`);
1366
1374
  scheduleRun();
1367
1375
  }).on("error", (error) => {
1368
1376
  logger6.error("Watcher error:", error);