sandstone-cli 2.3.0 → 2.3.1

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/bun.lock CHANGED
@@ -31,7 +31,7 @@
31
31
  "@types/semver": "^7.5.3",
32
32
  "bun-types": "^1.3.9",
33
33
  "node-pty": "^1.1.0",
34
- "sandstone": "^1.0.0-beta.2",
34
+ "sandstone": "^1.0.0-beta.3",
35
35
  "typescript": "^5.2.2",
36
36
  },
37
37
  },
@@ -370,7 +370,7 @@
370
370
 
371
371
  "safer-buffer": ["safer-buffer@2.1.2", "", {}, "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg=="],
372
372
 
373
- "sandstone": ["sandstone@1.0.0-beta.2", "", { "dependencies": { "@sinclair/typebox": "^0.31.21", "@smithed-mc/data-types": "^0.1.2", "@types/nearley": "^2.11.5", "@types/node": "24", "@typescript/analyze-trace": "^0.4.0", "adm-zip": "^0.5.10", "fs-extra": "^11.1.1", "lodash": "^4.17.21", "nanoid": "^3.3.6", "nearley": "^2.20.1", "node-fetch": "^3.3.2", "prismarine-nbt": "^2.2.1", "semver": "^7.5.4" } }, "sha512-8VBne5JcvcfPGP/LZRsd5G4ViGo6aWblgfr6xdWZP0k73k2nvZpgbCimT4EVBDyBAEuFCkMHTq5z9aoo/W4uYA=="],
373
+ "sandstone": ["sandstone@1.0.0-beta.3", "", { "dependencies": { "@sinclair/typebox": "^0.31.21", "@smithed-mc/data-types": "^0.1.2", "@types/nearley": "^2.11.5", "@types/node": "24", "@typescript/analyze-trace": "^0.4.0", "adm-zip": "^0.5.10", "fs-extra": "^11.1.1", "lodash": "^4.17.21", "nanoid": "^3.3.6", "nearley": "^2.20.1", "node-fetch": "^3.3.2", "prismarine-nbt": "^2.2.1", "semver": "^7.5.4" } }, "sha512-aQNz7uxBQW+B5mQshFiFnTt81ecc77KIih7jDvryM0kdhqtOuF5hwxR7vi3RXvTWkrLVGpnW/D3qClj3ufD0FQ=="],
374
374
 
375
375
  "scheduler": ["scheduler@0.27.0", "", {}, "sha512-eNv+WrVbKu1f3vbYJT/xtiF5syA5HPIMtf9IgY/nKg0sWqzAUEvqY/xm7OcZc/qafLx/iO9FgOmeSAp4v5ti/Q=="],
376
376
 
package/lib/create.js CHANGED
@@ -5680,7 +5680,7 @@ var {
5680
5680
  import figlet from "figlet";
5681
5681
 
5682
5682
  // src/version.ts
5683
- var CLI_VERSION = "2.3.0";
5683
+ var CLI_VERSION = "2.3.1";
5684
5684
 
5685
5685
  // src/commands/create.ts
5686
5686
  var import_semver = __toESM(require_semver2(), 1);
package/lib/index.js CHANGED
@@ -22574,7 +22574,7 @@ var {
22574
22574
  import figlet from "figlet";
22575
22575
 
22576
22576
  // src/version.ts
22577
- var CLI_VERSION = "2.3.0";
22577
+ var CLI_VERSION = "2.3.1";
22578
22578
 
22579
22579
  // src/commands/build/index.ts
22580
22580
  var import_fs_extra4 = __toESM(require_lib(), 1);
@@ -23816,14 +23816,34 @@ ${e.message || e}`;
23816
23816
  }
23817
23817
  }
23818
23818
  if (cliOptions.dry !== true) {
23819
+ const deletedDirs = new Set;
23819
23820
  for (const file of Object.keys(oldCache.files)) {
23820
23821
  if (!(file in newCache.files)) {
23821
- await import_fs_extra4.default.rm(path5.join(outputFolder, file));
23822
+ const fileDir = path5.dirname(file);
23823
+ if (deletedDirs.has(fileDir))
23824
+ continue;
23825
+ let skipFile = false;
23826
+ for (const deletedDir of deletedDirs) {
23827
+ if (fileDir.startsWith(deletedDir + path5.sep)) {
23828
+ skipFile = true;
23829
+ break;
23830
+ }
23831
+ }
23832
+ if (skipFile)
23833
+ continue;
23834
+ try {
23835
+ await import_fs_extra4.default.rm(path5.join(outputFolder, file));
23836
+ } catch (e) {
23837
+ if (e.code !== "ENOENT")
23838
+ throw e;
23839
+ log(source_default.yellow("Warning:"), `Cached file not found during cleanup: ${file}`);
23840
+ }
23822
23841
  let dir = undefined;
23823
- for (const segment of $split(new RegExp(RegExp.escape(path5.sep)), path5.dirname(file))) {
23842
+ for (const segment of $split(new RegExp(RegExp.escape(path5.sep)), fileDir)) {
23824
23843
  dir = dir === undefined ? segment : path5.join(dir, segment);
23825
23844
  if (!newDirs.has(dir)) {
23826
23845
  await import_fs_extra4.default.rm(path5.join(outputFolder, dir), { force: true, recursive: true });
23846
+ deletedDirs.add(dir);
23827
23847
  break;
23828
23848
  }
23829
23849
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sandstone-cli",
3
- "version": "2.3.0",
3
+ "version": "2.3.1",
4
4
  "description": "The CLI for Sandstone - the minecraft pack creation library.",
5
5
  "type": "module",
6
6
  "exports": "./lib/index.js",
@@ -69,7 +69,7 @@
69
69
  "@types/semver": "^7.5.3",
70
70
  "bun-types": "^1.3.9",
71
71
  "node-pty": "^1.1.0",
72
- "sandstone": "^1.0.0-beta.2",
72
+ "sandstone": "^1.0.0-beta.3",
73
73
  "typescript": "^5.2.2"
74
74
  },
75
75
  "trustedDependencies": [
@@ -320,7 +320,7 @@ async function _buildProject(
320
320
  dry: cliOptions.dry ?? false,
321
321
  verbose: cliOptions.verbose ?? false,
322
322
 
323
- // TODO !: Remove this type cast after beta 2
323
+ // TODO: Implement `contentSummary` and remove this typecast
324
324
  fileHandler: (saveOptions.customFileHandler as ((relativePath: string, content: any) => Promise<void>) | undefined) ??
325
325
  (async (relativePath: string, content: any) => {
326
326
  let pathPass = true
@@ -426,16 +426,36 @@ async function _buildProject(
426
426
 
427
427
  // Clean up old files and directories
428
428
  if (cliOptions.dry !== true) {
429
+ const deletedDirs = new Set<string>()
430
+
429
431
  for (const file of Object.keys(oldCache.files)) {
430
432
  if (!(file in newCache.files)) {
431
- await fs.rm(path.join(outputFolder, file))
433
+ // Skip files whose parent directory was already deleted
434
+ const fileDir = path.dirname(file)
435
+ if (deletedDirs.has(fileDir)) continue
436
+ let skipFile = false
437
+ for (const deletedDir of deletedDirs) {
438
+ if (fileDir.startsWith(deletedDir + path.sep)) {
439
+ skipFile = true
440
+ break
441
+ }
442
+ }
443
+ if (skipFile) continue
444
+
445
+ try {
446
+ await fs.rm(path.join(outputFolder, file))
447
+ } catch (e: any) {
448
+ if (e.code !== 'ENOENT') throw e
449
+ log(chalk.yellow('Warning:'), `Cached file not found during cleanup: ${file}`)
450
+ }
432
451
 
433
452
  let dir: string | undefined = undefined
434
- for (const segment of split(new RegExp(RegExp.escape(path.sep)), path.dirname(file))) {
453
+ for (const segment of split(new RegExp(RegExp.escape(path.sep)), fileDir)) {
435
454
  dir = dir === undefined ? segment : path.join(dir, segment)
436
455
 
437
456
  if (!newDirs.has(dir)) {
438
457
  await fs.rm(path.join(outputFolder, dir), { force: true, recursive: true })
458
+ deletedDirs.add(dir)
439
459
  break
440
460
  }
441
461
  }
@@ -130,7 +130,7 @@ export async function createCommand(_project: string, opts: CreateOptions) {
130
130
 
131
131
  const sv = (v: string) => new SemVer(v)
132
132
 
133
- const versions = [[sv('1.0.0-beta.2'), sv(CLI_VERSION)]] as const
133
+ const versions = [[sv('1.0.0-beta.3'), sv(CLI_VERSION)]] as const
134
134
 
135
135
  const version = await select({
136
136
  message: 'Which version of Sandstone do you want to use? These are the only supported versions for new projects.',
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const CLI_VERSION = '2.3.0'
1
+ export const CLI_VERSION = '2.3.1'