@timeax/scaffold 0.0.10 → 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/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(baseDir, relFromBase);
948
+ const absDir = path2.resolve(baseDirAbs, relFromBase);
946
949
  const relFromRoot = toPosixPath(
947
- toProjectRelativePath(projectRoot, absDir)
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(baseDir, relFromBase);
963
+ const absFile = path2.resolve(baseDirAbs, relFromBase);
961
964
  const relFromRoot = toPosixPath(
962
- toProjectRelativePath(projectRoot, absFile)
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
- if (desiredPaths.has(cachedPath)) continue;
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,