2024-10-24 08:18:37 -04:00
|
|
|
import fs from 'fs'
|
|
|
|
import Path from 'path'
|
|
|
|
import { fileURLToPath } from 'url'
|
|
|
|
const __dirname = fileURLToPath(new URL('.', import.meta.url))
|
|
|
|
const ONESKY_SETTING_PATH = Path.join(__dirname, '../../data/onesky.json')
|
2020-09-28 06:51:39 -04:00
|
|
|
let userOptions
|
|
|
|
try {
|
2024-10-24 08:18:37 -04:00
|
|
|
userOptions = JSON.parse(fs.readFileSync(ONESKY_SETTING_PATH))
|
2020-09-28 06:51:39 -04:00
|
|
|
} catch (err) {
|
2024-10-24 08:18:37 -04:00
|
|
|
if (err.code !== 'ENOENT') throw err
|
2020-09-28 06:51:39 -04:00
|
|
|
if (!process.env.ONE_SKY_PUBLIC_KEY) {
|
|
|
|
console.error(
|
|
|
|
'Cannot detect onesky credentials.\n\tDevelopers: see the docs at',
|
|
|
|
'https://github.com/overleaf/developer-manual/blob/master/code/translations.md#testing-translations-scripts',
|
|
|
|
'\n\tOps: environment variable ONE_SKY_PUBLIC_KEY is not set'
|
|
|
|
)
|
|
|
|
process.exit(1)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function withAuth(options) {
|
|
|
|
return Object.assign(
|
|
|
|
options,
|
|
|
|
{
|
|
|
|
apiKey: process.env.ONE_SKY_PUBLIC_KEY,
|
|
|
|
secret: process.env.ONE_SKY_PRIVATE_KEY,
|
2021-04-27 03:52:58 -04:00
|
|
|
projectId: '25049',
|
2020-09-28 06:51:39 -04:00
|
|
|
},
|
|
|
|
userOptions
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2024-10-24 08:18:37 -04:00
|
|
|
export default {
|
2021-04-27 03:52:58 -04:00
|
|
|
withAuth,
|
2020-09-28 06:51:39 -04:00
|
|
|
}
|