Rename seed.js to setup; add npm script for it

This commit is contained in:
Cadence Ember 2024-09-26 09:47:21 +12:00
parent b0a0e62a86
commit 8743910c35
3 changed files with 6 additions and 5 deletions

View file

@ -61,6 +61,7 @@
}, },
"scripts": { "scripts": {
"start": "node start.js", "start": "node start.js",
"setup": "node scripts/setup.js",
"addbot": "node addbot.js", "addbot": "node addbot.js",
"test": "cross-env FORCE_COLOR=true supertape --no-check-assertions-count --format tap test/test.js | tap-dot", "test": "cross-env FORCE_COLOR=true supertape --no-check-assertions-count --format tap test/test.js | tap-dot",
"test-slow": "cross-env FORCE_COLOR=true supertape --no-check-assertions-count --format tap --no-worker test/test.js -- --slow | tap-dot", "test-slow": "cross-env FORCE_COLOR=true supertape --no-check-assertions-count --format tap --no-worker test/test.js -- --slow | tap-dot",

View file

@ -81,9 +81,9 @@ Follow these steps:
1. Install dependencies: `npm install` 1. Install dependencies: `npm install`
1. Run `node scripts/seed.js` to check your setup and set the bot's initial state. It will prompt you for information. You only need to run this once ever. 1. Run `npm run setup` to check your setup and set the bot's initial state. It will prompt you for information. You only need to run this once ever.
1. Start the bridge: `npm start` 1. Start the bridge: `npm run start`
1. Add the bot to a server - use any *one* of the following commands for an invite link: 1. Add the bot to a server - use any *one* of the following commands for an invite link:
* (in the REPL) `addbot` * (in the REPL) `addbot`
@ -152,8 +152,8 @@ To get into the rooms on your Matrix account, use the `/invite [your mxid here]`
│   └── *.js │   └── *.js
* Various files you can run once if you need them. * Various files you can run once if you need them.
└── scripts └── scripts
* First time running a new bridge? Run this file to plant a seed, which will flourish into state for the bridge: * First time running a new bridge? Run this file to set up prerequisites on the Matrix server:
├── seed.js ├── setup.js
* Hopefully you won't need the rest of these. Code quality varies wildly. * Hopefully you won't need the rest of these. Code quality varies wildly.
└── *.js └── *.js

2
scripts/seed.js → scripts/setup.js Executable file → Normal file
View file

@ -305,7 +305,7 @@ async function validateHomeserverOrigin(serverUrlPrompt, url) {
} }
// Otherwise, it's the user's problem // Otherwise, it's the user's problem
if (!guild) { if (!guild) {
return die(`Error: The bot needs to upload some emojis. Please say where to upload them to. Run seed.js again with --emoji-guild=GUILD_ID`) return die(`Error: The bot needs to upload some emojis. Please say where to upload them to. Run setup again with --emoji-guild=GUILD_ID`)
} }
// Upload those emojis to the chosen location // Upload those emojis to the chosen location
db.prepare("REPLACE INTO auto_emoji (name, emoji_id, guild_id) VALUES ('_', '_', ?)").run(guild.id) db.prepare("REPLACE INTO auto_emoji (name, emoji_id, guild_id) VALUES ('_', '_', ?)").run(guild.id)