generated from NodeBB/nodebb-plugin-quickstart
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
81 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
{ | ||
"extends": "nodebb" | ||
"extends": "nodebb", | ||
"parserOptions": { | ||
"ecmaVersion": 2020 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
'use strict'; | ||
|
||
const { scan, setObjectBulk, getObjects } = require.main.require('./src/database'); | ||
async function useSpan() { | ||
const migrationRegex = /^(?!<span class="dice-event-text">).+/; | ||
const keys = await scan({ match: 'topicEvent:*' }); | ||
const events = await getObjects(keys); | ||
const modifiedEvents = events | ||
.map((event, index) => [keys[index], event]) | ||
.filter(event => event[1].type === 'dice' && migrationRegex.test(event[1].text)) | ||
.map( | ||
(event) => { | ||
event[1].text = `<span class="dice-event-text">${event[1].text}</span>`; | ||
return event; | ||
}, | ||
); | ||
await setObjectBulk(modifiedEvents); | ||
} | ||
|
||
module.exports = useSpan; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
'use strict'; | ||
|
||
const fs = require('node:fs/promises'); | ||
const semver = require('semver'); | ||
|
||
const { settings } = require.main.require('./src/meta'); | ||
|
||
async function runMigrations(settings_key) { | ||
const plugin_settings = await settings.get(settings_key); | ||
let { version } = plugin_settings ?? {}; | ||
if (!semver.valid(version)) { | ||
version = '0.0.0'; | ||
} | ||
const files = await fs.readdir(__dirname); | ||
const migrations = files | ||
.map(filename => semver.clean(filename.replace('.js', ''))) | ||
.filter(filename => semver.valid(filename) && semver.gt(filename, version)); | ||
for (const migration of migrations) { | ||
// eslint-disable-next-line no-await-in-loop | ||
await require(`./${migration}`)(); | ||
version = semver.gt(migration, version) ? migration : version; | ||
} | ||
await settings.set(settings_key, { version }); | ||
} | ||
module.exports = runMigrations; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "nodebb-plugin-ws-dice", | ||
"version": "2.2.3", | ||
"version": "2.3.0", | ||
"description": "A dice plugin integrated with topic events", | ||
"main": "library.js", | ||
"scripts": { | ||
|
@@ -53,7 +53,8 @@ | |
}, | ||
"dependencies": { | ||
"@dice-roller/rpg-dice-roller": "^5.1.0", | ||
"expressionparser": "^1.1.5" | ||
"expressionparser": "^1.1.5", | ||
"semver": "^7.3.7" | ||
}, | ||
"packageManager": "[email protected]" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.