Skip to content

Commit 018d79a

Browse files
committed
documented config better, add-game-entry has option to call build-config.js (resolves #295 on github)
1 parent 55125b4 commit 018d79a

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,15 +81,20 @@ This is why the script `add-game-entry.js` was created, an easy way to add a new
8181
# For this demonstration bun will be used as dependencies are automatically installed
8282
bun add-game-script.js
8383
# Answer the prompts that follow and the configuration will be updated
84+
85+
# If you said 'N(o)' to rebuilding the config, then you need to run the following command before the site can find the game
86+
bun build-config.js
8487
```
88+
As `add-game-script.js` is built to work with alphanumerically-ordered lists, expect unintended behavior if the games list is not alphanumerically sorted.
89+
Additionally, **do not** manually edit the `js/config.js` file. That is generated by the `build-config.js` script based off of `config.jsonc`. **Any changes to `js/config.js` will be overwritten.**
8590

8691
#### Themes
8792

8893
Theme standard not implemented yet (TODO)
8994

9095
#### Proxy
9196

92-
Proxy configuration options are under the **"config"** key.
97+
Proxy configuration options are under the **"config"** key.
9398
The value for key `"proxy"` is a boolean value that enables or disables the proxy function. If `"proxy"` is set to false, then the user will be greeted with an error dialog when attempting to access the proxy.
9499
The value for key `"proxyPath"` is the path to the proxy. It can be an absolute path or a relative path, but the proxy must support **CORS** as the proxy page will be displayed as an iframe on the site.
95100

add-game-entry.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { exit } from 'process';
2+
import { fork } from 'child_process'
23
import { readFileSync, existsSync, writeFileSync } from 'fs';
3-
import { input } from '@inquirer/prompts';
4+
import { input, confirm } from '@inquirer/prompts';
45

56
if (!existsSync('config.jsonc')) {
67
console.log('config.jsonc not found! Are you in the right directory?');
@@ -102,5 +103,17 @@ if (!existsSync('config.jsonc')) {
102103

103104
writeFileSync('config.jsonc', jsonc);
104105
console.log('Saved to config.jsonc!');
106+
107+
108+
const shouldRebuildConfig = await confirm({ message: 'Do you want to rebuild the config now? (the site will not see the game until you do this)' });
109+
110+
if (shouldRebuildConfig) {
111+
if (!existsSync('build-config.js')) {
112+
console.log("`build-config.js` not found! Are you in the right directory?");
113+
114+
} else {
115+
fork("build-config.js");
116+
};
117+
}
105118
exit(0);
106119
})();

0 commit comments

Comments
 (0)