Merge pull request #24790 from overleaf/ls-use-script-runner

Update some scripts to use Script Runner

GitOrigin-RevId: aaa11f94dcfd328c158bb02d1b9fb2adfb1bb146
This commit is contained in:
Liangjun Song
2025-05-23 08:05:23 +00:00
committed by Copybot
parent d0010217cd
commit 2f87db9c0d
62 changed files with 225 additions and 112 deletions
+15 -10
View File
@@ -1,23 +1,28 @@
import { ScriptLog } from '../../app/src/models/ScriptLog.mjs'
import Settings from '@overleaf/settings'
const UNKNOWN = 'unknown'
async function beforeScriptExecution(canonicalName, vars, scriptPath) {
let log = new ScriptLog({
canonicalName,
filePathAtVersion: scriptPath,
podName: process.env.OL_POD_NAME,
username: process.env.OL_USERNAME,
imageVersion: process.env.OL_IMAGE_VERSION,
podName: process.env.OL_POD_NAME ?? UNKNOWN,
username: process.env.OL_USERNAME ?? UNKNOWN,
imageVersion: process.env.OL_IMAGE_VERSION ?? UNKNOWN,
vars,
})
log = await log.save()
console.log(
'\n==================================' +
'\n✨ Your script is running!' +
'\n📊 Track progress at:' +
`\n${Settings.adminUrl}/admin/script-log/${log._id}` +
'\n==================================\n'
)
// Print Script Log link if ran by a user
if (process.env.OL_USERNAME) {
console.log(
'\n==================================' +
'\n✨ Your script is running!' +
'\n📊 Track progress at:' +
`\n${Settings.adminUrl}/admin/script-log/${log._id}` +
'\n==================================\n'
)
}
return log._id
}