first commit

This commit is contained in:
2025-04-24 13:11:28 +08:00
commit ff9c54d5e4
5960 changed files with 834111 additions and 0 deletions

View File

@@ -0,0 +1,30 @@
/* subscription.freeTrialExpiresAt
* Example script for a migration:
*
* This script demonstrates how to write a script that is runnable either via
* the CLI, or via a migration. The related migration is `script_example`
* in the migrations directory.
*/
import { User } from '../../app/src/models/User.js'
import { fileURLToPath } from 'node:url'
// const somePackage = require('some-package')
const runScript = async () => {
const user = await User.findOne({}, { first_name: 1 }).exec()
const name = user ? user.first_name : 'World'
console.log(`Hello ${name}!`)
}
if (fileURLToPath(import.meta.url) === process.argv[1]) {
try {
await runScript()
process.exit()
} catch (error) {
console.error(error)
process.exit(1)
}
}
export default runScript

View File

@@ -0,0 +1,31 @@
// Import the script runner utility (adjust the path as needed)
import { scriptRunner } from '../lib/ScriptRunner.mjs'
const subJobs = 30
/**
* Your script's main work goes here.
* It must be an async function and accept `trackProgress`.
* @param {(message: string) => Promise<void>} trackProgress - Call this to log progress.
*/
async function main(trackProgress) {
for (let i = 0; i < subJobs; i++) {
await new Promise(resolve => setTimeout(() => resolve(), 1000))
await trackProgress(`Job in progress ${i + 1}/${subJobs}`)
}
await trackProgress('Job finished')
}
// Define any variables your script needs (optional)
const scriptVariables = {
subJobs,
}
// --- Execute the script using the runner with async/await ---
try {
await scriptRunner(main, scriptVariables)
process.exit()
} catch (error) {
console.error(error)
process.exit(1)
}