@massif/lancer-data 3.1.7 → 3.1.8

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/scripts/rename.js CHANGED
@@ -1,74 +1,74 @@
1
- #!/usr/bin/node
2
-
3
- const fs = require('fs');
4
-
5
- const path = require('path');
6
-
7
- const folderPath = './lib';
8
- const ignore = ['manufacturers.json', 'weapons.json', 'systems.json', 'mods.json'];
9
-
10
- const ignoreWords = ['{VAL}', '({VAL})', '{VAL}+', 'HP', 'GRIT', 'SP', 'AP', '(AP)'];
11
-
12
- function decap(string) {
13
- const words = string.split(' ');
14
- const capitalizedWords = words.map((word) => {
15
- if (ignoreWords.some((x) => x === word)) return word;
16
- else if (word === word.toUpperCase()) {
17
- return word.toLowerCase().replace(/\b\w/g, (l) => l.toUpperCase());
18
- } else {
19
- return word;
20
- }
21
- });
22
- const capitalizedString = capitalizedWords.join(' ');
23
- return capitalizedString;
24
- }
25
-
26
- fs.readdir(folderPath, (err, files) => {
27
- if (err) {
28
- console.error('Error reading folder:', err);
29
- return;
30
- }
31
-
32
- files.forEach((file) => {
33
- if (ignore.some((x) => x === file)) return;
34
- const filePath = path.join(folderPath, file);
35
- console.log(filePath);
36
-
37
- fs.readFile(filePath, 'utf8', (err, data) => {
38
- if (err) {
39
- console.error('Error reading file:', file, err);
40
- return;
41
- }
42
-
43
- try {
44
- let fixed = 0;
45
- const jsonObject = JSON.parse(data);
46
- if (Array.isArray(jsonObject)) {
47
- jsonObject.forEach((e) => {
48
- if (e.name) {
49
- if (e.name.includes('ERR:')) return;
50
- if (e.name === e.name.toUpperCase()) {
51
- const decapped = decap(e.name);
52
- if (e.name !== decapped) {
53
- // console.log('decapped:', e.name, decapped);
54
- e.name = decapped;
55
- fixed++;
56
- }
57
- }
58
- }
59
- });
60
- fs.writeFile(filePath, JSON.stringify(jsonObject, null, 2), (err) => {
61
- if (err) {
62
- console.error('Error writing file:', file, err);
63
- return;
64
- }
65
- });
66
-
67
- console.log(`fixed: ${fixed} in file: ${file}`);
68
- }
69
- } catch (err) {
70
- console.error('Error parsing JSON in file:', file, err);
71
- }
72
- });
73
- });
74
- });
1
+ #!/usr/bin/node
2
+
3
+ const fs = require('fs');
4
+
5
+ const path = require('path');
6
+
7
+ const folderPath = './lib';
8
+ const ignore = ['manufacturers.json', 'weapons.json', 'systems.json', 'mods.json'];
9
+
10
+ const ignoreWords = ['{VAL}', '({VAL})', '{VAL}+', 'HP', 'GRIT', 'SP', 'AP', '(AP)'];
11
+
12
+ function decap(string) {
13
+ const words = string.split(' ');
14
+ const capitalizedWords = words.map((word) => {
15
+ if (ignoreWords.some((x) => x === word)) return word;
16
+ else if (word === word.toUpperCase()) {
17
+ return word.toLowerCase().replace(/\b\w/g, (l) => l.toUpperCase());
18
+ } else {
19
+ return word;
20
+ }
21
+ });
22
+ const capitalizedString = capitalizedWords.join(' ');
23
+ return capitalizedString;
24
+ }
25
+
26
+ fs.readdir(folderPath, (err, files) => {
27
+ if (err) {
28
+ console.error('Error reading folder:', err);
29
+ return;
30
+ }
31
+
32
+ files.forEach((file) => {
33
+ if (ignore.some((x) => x === file)) return;
34
+ const filePath = path.join(folderPath, file);
35
+ console.log(filePath);
36
+
37
+ fs.readFile(filePath, 'utf8', (err, data) => {
38
+ if (err) {
39
+ console.error('Error reading file:', file, err);
40
+ return;
41
+ }
42
+
43
+ try {
44
+ let fixed = 0;
45
+ const jsonObject = JSON.parse(data);
46
+ if (Array.isArray(jsonObject)) {
47
+ jsonObject.forEach((e) => {
48
+ if (e.name) {
49
+ if (e.name.includes('ERR:')) return;
50
+ if (e.name === e.name.toUpperCase()) {
51
+ const decapped = decap(e.name);
52
+ if (e.name !== decapped) {
53
+ // console.log('decapped:', e.name, decapped);
54
+ e.name = decapped;
55
+ fixed++;
56
+ }
57
+ }
58
+ }
59
+ });
60
+ fs.writeFile(filePath, JSON.stringify(jsonObject, null, 2), (err) => {
61
+ if (err) {
62
+ console.error('Error writing file:', file, err);
63
+ return;
64
+ }
65
+ });
66
+
67
+ console.log(`fixed: ${fixed} in file: ${file}`);
68
+ }
69
+ } catch (err) {
70
+ console.error('Error parsing JSON in file:', file, err);
71
+ }
72
+ });
73
+ });
74
+ });
package/scripts/test.js CHANGED
@@ -1,19 +1,19 @@
1
- const fs = require('fs');
2
- var currentDir = process.cwd();
3
- var files = fs.readdirSync('./lib');
4
- let contents = ""
5
- let valid = true
6
-
7
- files.forEach(filename => {
8
- contents = fs.readFileSync(`./lib/${filename}`, 'utf-8')
9
- try {
10
- JSON.parse(contents)
11
- } catch (e) {
12
- console.error(`invalid JSON in ${filename}`);
13
- valid = false;
14
- }
15
- });
16
-
17
- if (!valid) {
18
- throw "One or more JSON files are invalid."
19
- }
1
+ const fs = require('fs');
2
+ var currentDir = process.cwd();
3
+ var files = fs.readdirSync('./lib');
4
+ let contents = ""
5
+ let valid = true
6
+
7
+ files.forEach(filename => {
8
+ contents = fs.readFileSync(`./lib/${filename}`, 'utf-8')
9
+ try {
10
+ JSON.parse(contents)
11
+ } catch (e) {
12
+ console.error(`invalid JSON in ${filename}`);
13
+ valid = false;
14
+ }
15
+ });
16
+
17
+ if (!valid) {
18
+ throw "One or more JSON files are invalid."
19
+ }