mirror of
https://github.com/chatmail/core.git
synced 2026-04-05 23:22:11 +03:00
adjust scripts to new location of deltachat-core-rust adjust dc-node readme to repo change mention old repository migrate github actions, try out if they work fix path to node docs in SSH github action passing mailadm token to node tests hopefully fixing the download paths for the artifacts fixing download paths, this time for real post upload link to details fix scp command forgot to remove platform_status dict fixing paths in the github action add github action to delete node preview builds when PR is closed move environment variable to yaml remove git trash github action to release to npm use different action which also works with branches for testing we don't want to publish to NPM through the CI see what lint issues windows has
74 lines
1.9 KiB
JavaScript
Executable File
74 lines
1.9 KiB
JavaScript
Executable File
#!/usr/bin/env node
|
|
|
|
const fs = require('fs')
|
|
const path = require('path')
|
|
const split = require('split2')
|
|
|
|
const data = []
|
|
const regex = /^#define\s+(\w+)\s+(\w+)/i
|
|
const header = path.resolve(
|
|
__dirname,
|
|
'../../deltachat-ffi/deltachat.h'
|
|
)
|
|
|
|
console.log('Generating constants...')
|
|
|
|
fs.createReadStream(header)
|
|
.pipe(split())
|
|
.on('data', (line) => {
|
|
const match = regex.exec(line)
|
|
if (match) {
|
|
const key = match[1]
|
|
const value = parseInt(match[2])
|
|
if (isNaN(value)) return
|
|
|
|
data.push({ key, value })
|
|
}
|
|
})
|
|
.on('end', () => {
|
|
const constants = data
|
|
.filter(
|
|
({ key }) => key.toUpperCase()[0] === key[0] // check if define name is uppercase
|
|
)
|
|
.sort((lhs, rhs) => {
|
|
if (lhs.key < rhs.key) return -1
|
|
else if (lhs.key > rhs.key) return 1
|
|
return 0
|
|
})
|
|
.map((row) => {
|
|
return ` ${row.key}: ${row.value}`
|
|
})
|
|
.join(',\n')
|
|
|
|
const events = data
|
|
.sort((lhs, rhs) => {
|
|
if (lhs.value < rhs.value) return -1
|
|
else if (lhs.value > rhs.value) return 1
|
|
return 0
|
|
})
|
|
.filter((i) => {
|
|
return i.key.startsWith('DC_EVENT_')
|
|
})
|
|
.map((i) => {
|
|
return ` ${i.value}: '${i.key}'`
|
|
})
|
|
.join(',\n')
|
|
|
|
// backwards compat
|
|
fs.writeFileSync(
|
|
path.resolve(__dirname, '../constants.js'),
|
|
`// Generated!\n\nmodule.exports = {\n${constants}\n}\n`
|
|
)
|
|
// backwards compat
|
|
fs.writeFileSync(
|
|
path.resolve(__dirname, '../events.js'),
|
|
`/* eslint-disable quotes */\n// Generated!\n\nmodule.exports = {\n${events}\n}\n`
|
|
)
|
|
|
|
fs.writeFileSync(
|
|
path.resolve(__dirname, '../lib/constants.ts'),
|
|
`// Generated!\n\nexport enum C {\n${constants.replace(/:/g, ' =')},\n}\n
|
|
// Generated!\n\nexport const EventId2EventName: { [key: number]: string } = {\n${events},\n}\n`
|
|
)
|
|
})
|