sandstone-cli 2.1.0 → 2.1.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sandstone-cli",
3
- "version": "2.1.0",
3
+ "version": "2.1.2",
4
4
  "description": "The CLI for Sandstone - the minecraft pack creation library.",
5
5
  "type": "module",
6
6
  "exports": "./lib/index.js",
@@ -9,8 +9,8 @@
9
9
  "create-sandstone": "./lib/create.js"
10
10
  },
11
11
  "scripts": {
12
- "build": "bun scripts/version.ts && bun build src/index.ts --outfile=lib/index.js --target=node --external=@parcel/watcher --external=figlet && bun build src/create.ts --outfile=lib/create.js --target=node --external=@parcel/watcher --external=figlet",
13
- "dev:build": "tsc && bun run build"
12
+ "bundle": "bun scripts/version.ts && bun build src/index.ts --outfile=lib/index.js --target=bun --external=@parcel/watcher --external=figlet --external=@inquirer/prompts && bun build src/create.ts --outfile=lib/create.js --target=bun --external=@parcel/watcher --external=figlet --external=@inquirer/prompts",
13
+ "dev:build": "tsc && bun bundle"
14
14
  },
15
15
  "repository": {
16
16
  "type": "git",
@@ -65,7 +65,6 @@ export type BuildOptions = {
65
65
  dry?: boolean
66
66
  verbose?: boolean
67
67
  root?: boolean
68
- fullTrace?: boolean
69
68
  strictErrors?: boolean
70
69
  production?: boolean
71
70
 
@@ -385,11 +384,12 @@ async function _buildProject(
385
384
  }
386
385
  }
387
386
  } catch (e: any) {
388
- const errorMsg = `While loading "${entrypointPath}":\n${cliOptions.fullTrace ? e : (e.message || e)}`
389
- if (!silent) {
387
+ const errorMsg = `While loading "${entrypointPath}":\n${e.stack || e.message || e}`
388
+ if (silent) {
389
+ log('BuildError:', errorMsg)
390
+ } else {
390
391
  console.error(chalk.bgRed.white('BuildError') + chalk.gray(':'), errorMsg)
391
392
  }
392
- log('BuildError:', errorMsg)
393
393
  throw e // Re-throw for buildCommand to handle
394
394
  }
395
395
 
@@ -438,6 +438,22 @@ async function _buildProject(
438
438
  // Run beforeSave script
439
439
  await scripts?.beforeSave?.()
440
440
 
441
+ // Auto-register pack types if existing resources are present
442
+ // This ensures handleResources() is called even when no resources are created programmatically
443
+ const resourcesFolder = path.join(folder, 'resources')
444
+ if (await fs.pathExists(path.join(resourcesFolder, 'resourcepack'))) {
445
+ const files = await fs.readdir(path.join(resourcesFolder, 'resourcepack'))
446
+ if (files.length > 0) {
447
+ sandstonePack.resourcePack()
448
+ }
449
+ }
450
+ if (await fs.pathExists(path.join(resourcesFolder, 'datapack'))) {
451
+ const files = await fs.readdir(path.join(resourcesFolder, 'datapack'))
452
+ if (files.length > 0) {
453
+ sandstonePack.dataPack()
454
+ }
455
+ }
456
+
441
457
  // File exclusion setup
442
458
  const excludeOption = resources?.exclude
443
459
  const fileExclusions = excludeOption
@@ -839,19 +855,15 @@ export async function buildCommand(opts: BuildOptions, _folder?: string, silent
839
855
  } catch (err: any) {
840
856
  const errorMessage = err.message || String(err)
841
857
  if (!silent) {
842
- console.error(chalk.red('Build failed:'), errorMessage)
843
- if (opts.fullTrace) {
844
- console.error(err)
845
- }
858
+ // Error already logged by _buildProject with highlighting
859
+ process.exit(1)
846
860
  }
847
861
  log('Build failed:', errorMessage)
848
- if (silent) {
849
- return {
850
- success: false,
851
- error: opts.fullTrace ? String(err) : errorMessage,
852
- resourceCounts: { functions: 0, other: 0 },
853
- timestamp: Date.now(),
854
- }
862
+ return {
863
+ success: false,
864
+ error: err.stack || errorMessage,
865
+ resourceCounts: { functions: 0, other: 0 },
866
+ timestamp: Date.now(),
855
867
  }
856
868
  }
857
869
  }
@@ -56,7 +56,7 @@ export async function watchCommand(opts: WatchOptions) {
56
56
  // Since this isn't SIGINT, its fine that we don't await this
57
57
  exit: () => exit(subscription, unmountInk)
58
58
  }),
59
- { patchConsole: false }
59
+ { patchConsole: false, exitOnCtrlC: false }
60
60
  )
61
61
  unmountInk = unmount
62
62
 
package/src/index.ts CHANGED
@@ -20,7 +20,6 @@ CLI
20
20
  .addOption(BuildOptions.get('dry'))
21
21
  .addOption(BuildOptions.get('verbose'))
22
22
  .addOption(BuildOptions.get('root'))
23
- .addOption(BuildOptions.get('fullTrace'))
24
23
  .addOption(BuildOptions.get('strictErrors'))
25
24
  .addOption(BuildOptions.get('production'))
26
25
  .addOption(BuildOptions.get('path'))
@@ -37,7 +36,6 @@ CLI
37
36
  .addOption(BuildOptions.get('dry'))
38
37
  .addOption(BuildOptions.get('verbose'))
39
38
  .addOption(BuildOptions.get('root'))
40
- .addOption(BuildOptions.get('fullTrace'))
41
39
  .addOption(BuildOptions.get('strictErrors'))
42
40
  .addOption(BuildOptions.get('path'))
43
41
  .addOption(BuildOptions.get('name'))
package/src/shared.ts CHANGED
@@ -28,7 +28,6 @@ const options = {
28
28
  dry: opt('-d, --dry', 'Do not save the pack. Mostly useful with `verbose`.'),
29
29
  verbose: opt('-f, --verbose', 'Fully log all resulting resources: functions, advancements...'),
30
30
  root: opt('-r, --root', 'Save the pack & resource pack in the .minecraft/datapacks & .minecraft/resource_packs folders. Override the value specified in the configuration file.'),
31
- fullTrace: opt('-t, --full-trace', 'Show the full stack trace on errors.'),
32
31
  strictErrors: opt('-e, --strict-errors', 'Stop pack compilation on type errors.'),
33
32
  production: opt('-p, --production', 'Runs Sandstone in production mode. This sets process.env.SANDSTONE_ENV to "production".'),
34
33
 
@@ -176,7 +176,7 @@ export function WatchUI({ manual, onManualRebuild, exit }: WatchUIProps) {
176
176
  }, [isError, isManualPending, buildResult?.error, logLines.length])
177
177
 
178
178
  useInput((input, key) => {
179
- if (input === 'q') {
179
+ if (input === 'q' || (key.ctrl && input === 'c')) {
180
180
  exit!()
181
181
  }
182
182
 
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const CLI_VERSION = '2.1.0'
1
+ export const CLI_VERSION = '2.1.2'