fxrjson 15.0.0 → 20.0.0

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.
Files changed (2) hide show
  1. package/fxrjson.js +29 -26
  2. package/package.json +3 -3
package/fxrjson.js CHANGED
@@ -3,7 +3,7 @@
3
3
  import fs from 'node:fs/promises'
4
4
  import path from 'node:path'
5
5
  import { FXR, Game } from '@cccode/fxr'
6
- import beautify from 'json-beautify'
6
+ import stringify from 'fabulous-json'
7
7
  import { fileURLToPath } from 'node:url'
8
8
 
9
9
  const CTX_MENU_NAME = 'FXR ⇄ JSON'
@@ -79,38 +79,41 @@ await (async () => {
79
79
  }
80
80
  }
81
81
 
82
- if (game === null) try {
83
- const cliSelect = (await import('cli-select')).default
84
- console.log('What game is this for?')
85
- const result = await cliSelect({
86
- values: [
87
- 'Dark Souls III',
88
- 'Sekiro: Shadows Die Twice',
89
- 'Elden Ring',
90
- 'Armored Core VI Fires of Rubicon',
91
- ],
92
- defaultValue: 2,
93
- indentation: 2,
94
- unselected: '[ ]',
95
- selected: '[✓]',
96
- })
97
- game = games[Game[result.id].toLowerCase()]
98
- console.log(`Selected: ${result.value}`)
99
- } catch {
100
- console.log('Canceled.')
101
- return
102
- }
103
-
104
82
  const filePath = process.argv[2]
105
83
  const content = await fs.readFile(filePath)
106
84
 
107
85
  if (content.subarray(0, 4).equals(Buffer.from('FXR\0'))) {
108
- const fxr = FXR.read(content, game, { round: true })
109
- await fs.writeFile(filePath + '.json', beautify({
86
+ const fxr = FXR.read(content, Game.Heuristic, { round: true })
87
+ await fs.writeFile(filePath + '.json', stringify({
110
88
  version: `${name}@${version}`,
111
89
  fxr
112
- }, null, 2, 80))
90
+ }, {
91
+ allowInline(key, value) {
92
+ return Array.isArray(value) || !('type' in value) || Object.keys(value).length === 1
93
+ },
94
+ }))
113
95
  } else {
96
+ if (game === null) try {
97
+ const cliSelect = (await import('cli-select')).default
98
+ console.log('What game is this for?')
99
+ const result = await cliSelect({
100
+ values: [
101
+ 'Dark Souls III',
102
+ 'Sekiro: Shadows Die Twice',
103
+ 'Elden Ring',
104
+ 'Armored Core VI Fires of Rubicon',
105
+ ],
106
+ defaultValue: 2,
107
+ indentation: 2,
108
+ unselected: '[ ]',
109
+ selected: '[✓]',
110
+ })
111
+ game = games[Game[result.id].toLowerCase()]
112
+ console.log(`Selected: ${result.value}`)
113
+ } catch {
114
+ console.log('Canceled.')
115
+ return
116
+ }
114
117
  const json = JSON.parse(await fs.readFile(filePath, 'utf-8'))
115
118
  if (json.version !== `${name}@${version}`) {
116
119
  console.warn(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fxrjson",
3
- "version": "15.0.0",
3
+ "version": "20.0.0",
4
4
  "description": "Convert FXR files from Dark Souls 3, Sekiro, Elden Ring, and Armored Core 6 to and from JSON.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -21,9 +21,9 @@
21
21
  "url": "https://github.com/EvenTorset/fxrjson/issues"
22
22
  },
23
23
  "dependencies": {
24
- "@cccode/fxr": "^15.0.0",
24
+ "@cccode/fxr": "^20.0.1",
25
25
  "cli-select": "^1.1.2",
26
- "json-beautify": "^1.1.1",
26
+ "fabulous-json": "^1.0.0",
27
27
  "rage-edit": "^1.2.0"
28
28
  }
29
29
  }