mirror of
https://github.com/whyour/qinglong.git
synced 2026-08-06 00:34:33 +08:00
Compare commits
15 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| a743aa8115 | |||
| fe4516df00 | |||
| be2da98674 | |||
| 0da8155bac | |||
| eddd258614 | |||
| 2ad6437672 | |||
| 162bd9d8cc | |||
| e694570f1a | |||
| eb5cc3943d | |||
| 1b39d3ab48 | |||
| f47a788184 | |||
| 738fe04ce4 | |||
| a2812d9c03 | |||
| 5c53ae4993 | |||
| e191aca41f |
@@ -7,7 +7,6 @@ on:
|
||||
branches:
|
||||
- "master"
|
||||
- "develop"
|
||||
- "test-cli"
|
||||
tags:
|
||||
- "v*"
|
||||
schedule:
|
||||
|
||||
+4
-1
@@ -22,4 +22,7 @@
|
||||
.env
|
||||
.history
|
||||
.version.ts
|
||||
/.tmp
|
||||
/.tmp
|
||||
__pycache__
|
||||
/shell/preload/env.*
|
||||
/shell/preload/notify.*
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
**/*.svg
|
||||
**/*.ejs
|
||||
**/*.html
|
||||
package.json
|
||||
.umi
|
||||
.umi-production
|
||||
.umi-test
|
||||
|
||||
@@ -26,6 +26,7 @@ if (process.env.QL_DATA_DIR) {
|
||||
}
|
||||
|
||||
const shellPath = path.join(rootPath, 'shell/');
|
||||
const preloadPath = path.join(shellPath, 'preload/');
|
||||
const tmpPath = path.join(rootPath, '.tmp/');
|
||||
const samplePath = path.join(rootPath, 'sample/');
|
||||
const configPath = path.join(dataPath, 'config/');
|
||||
@@ -37,9 +38,11 @@ const uploadPath = path.join(dataPath, 'upload/');
|
||||
const sshdPath = path.join(dataPath, 'ssh.d/');
|
||||
const systemLogPath = path.join(dataPath, 'syslog/');
|
||||
|
||||
const envFile = path.join(configPath, 'env.sh');
|
||||
const jsEnvFile = path.join(configPath, 'env.js');
|
||||
const pyEnvFile = path.join(configPath, 'env.py');
|
||||
const envFile = path.join(preloadPath, 'env.sh');
|
||||
const jsEnvFile = path.join(preloadPath, 'env.js');
|
||||
const pyEnvFile = path.join(preloadPath, 'env.py');
|
||||
const jsNotifyFile = path.join(preloadPath, 'notify.js');
|
||||
const pyNotifyFile = path.join(preloadPath, 'notify.py');
|
||||
const confFile = path.join(configPath, 'config.sh');
|
||||
const crontabFile = path.join(configPath, 'crontab.list');
|
||||
const authConfigFile = path.join(configPath, 'auth.json');
|
||||
@@ -91,6 +94,8 @@ export default {
|
||||
envFile,
|
||||
jsEnvFile,
|
||||
pyEnvFile,
|
||||
jsNotifyFile,
|
||||
pyNotifyFile,
|
||||
dbPath,
|
||||
uploadPath,
|
||||
configPath,
|
||||
|
||||
+7
-16
@@ -19,35 +19,26 @@ async function linkToNodeModule(src: string, dst?: string) {
|
||||
async function linkCommand() {
|
||||
const commandPath = await promiseExec('which node');
|
||||
const commandDir = path.dirname(commandPath);
|
||||
const oldLinkShell = [
|
||||
const linkShell = [
|
||||
{
|
||||
src: 'update.sh',
|
||||
dest: 'ql',
|
||||
tmp: 'ql_tmp',
|
||||
},
|
||||
{
|
||||
src: 'task.sh',
|
||||
dest: 'task',
|
||||
tmp: 'task_tmp',
|
||||
},
|
||||
];
|
||||
// const newLinkShell = [
|
||||
// {
|
||||
// src: 'task.mjs',
|
||||
// dest: 'task',
|
||||
// tmp: 'task_tmp',
|
||||
// },
|
||||
// ];
|
||||
|
||||
for (const link of oldLinkShell) {
|
||||
for (const link of linkShell) {
|
||||
const source = path.join(config.rootPath, 'shell', link.src);
|
||||
const target = path.join(commandDir, link.dest);
|
||||
const tmpTarget = path.join(commandDir, link.tmp);
|
||||
await fs.symlink(source, tmpTarget);
|
||||
await fs.rename(tmpTarget, target);
|
||||
}
|
||||
// for (const link of newLinkShell) {
|
||||
// const source = path.join(config.rootPath, 'cli', link.src);
|
||||
// const target = path.join(commandDir, link.dest);
|
||||
// const tmpTarget = path.join(commandDir, link.tmp);
|
||||
// await fs.symlink(source, tmpTarget);
|
||||
// await fs.rename(tmpTarget, target);
|
||||
// }
|
||||
}
|
||||
|
||||
export default async (src: string = 'deps') => {
|
||||
|
||||
@@ -11,6 +11,7 @@ if (process.env.QL_DATA_DIR) {
|
||||
dataPath = process.env.QL_DATA_DIR.replace(/\/$/g, '');
|
||||
}
|
||||
|
||||
const preloadPath = path.join(rootPath, 'shell/preload/');
|
||||
const configPath = path.join(dataPath, 'config/');
|
||||
const scriptPath = path.join(dataPath, 'scripts/');
|
||||
const logPath = path.join(dataPath, 'log/');
|
||||
@@ -27,7 +28,11 @@ const sampleNotifyJsFile = path.join(samplePath, 'notify.js');
|
||||
const sampleNotifyPyFile = path.join(samplePath, 'notify.py');
|
||||
const scriptNotifyJsFile = path.join(scriptPath, 'sendNotify.js');
|
||||
const scriptNotifyPyFile = path.join(scriptPath, 'notify.py');
|
||||
const jsNotifyFile = path.join(preloadPath, 'notify.js');
|
||||
const pyNotifyFile = path.join(preloadPath, 'notify.py');
|
||||
const TaskBeforeFile = path.join(configPath, 'task_before.sh');
|
||||
const TaskBeforeJsFile = path.join(configPath, 'task_before.js');
|
||||
const TaskBeforePyFile = path.join(configPath, 'task_before.py');
|
||||
const TaskAfterFile = path.join(configPath, 'task_after.sh');
|
||||
const homedir = os.homedir();
|
||||
const sshPath = path.resolve(homedir, '.ssh');
|
||||
@@ -38,6 +43,7 @@ export default async () => {
|
||||
const authFileExist = await fileExist(authConfigFile);
|
||||
const confFileExist = await fileExist(confFile);
|
||||
const scriptDirExist = await fileExist(scriptPath);
|
||||
const preloadDirExist = await fileExist(preloadPath);
|
||||
const logDirExist = await fileExist(logPath);
|
||||
const configDirExist = await fileExist(configPath);
|
||||
const uploadDirExist = await fileExist(uploadPath);
|
||||
@@ -49,6 +55,8 @@ export default async () => {
|
||||
const scriptNotifyJsFileExist = await fileExist(scriptNotifyJsFile);
|
||||
const scriptNotifyPyFileExist = await fileExist(scriptNotifyPyFile);
|
||||
const TaskBeforeFileExist = await fileExist(TaskBeforeFile);
|
||||
const TaskBeforeJsFileExist = await fileExist(TaskBeforeJsFile);
|
||||
const TaskBeforePyFileExist = await fileExist(TaskBeforePyFile);
|
||||
const TaskAfterFileExist = await fileExist(TaskAfterFile);
|
||||
|
||||
if (!configDirExist) {
|
||||
@@ -59,6 +67,10 @@ export default async () => {
|
||||
await fs.mkdir(scriptPath);
|
||||
}
|
||||
|
||||
if (!preloadDirExist) {
|
||||
await fs.mkdir(preloadPath);
|
||||
}
|
||||
|
||||
if (!logDirExist) {
|
||||
await fs.mkdir(logPath);
|
||||
}
|
||||
@@ -96,6 +108,9 @@ export default async () => {
|
||||
await fs.writeFile(confFile, await fs.readFile(sampleConfigFile));
|
||||
}
|
||||
|
||||
await fs.writeFile(jsNotifyFile, await fs.readFile(sampleNotifyJsFile));
|
||||
await fs.writeFile(pyNotifyFile, await fs.readFile(sampleNotifyPyFile));
|
||||
|
||||
if (!scriptNotifyJsFileExist) {
|
||||
await fs.writeFile(
|
||||
scriptNotifyJsFile,
|
||||
@@ -114,6 +129,20 @@ export default async () => {
|
||||
await fs.writeFile(TaskBeforeFile, await fs.readFile(sampleTaskShellFile));
|
||||
}
|
||||
|
||||
if (!TaskBeforeJsFileExist) {
|
||||
await fs.writeFile(
|
||||
TaskBeforeJsFile,
|
||||
'// The JavaScript code that executes before the JavaScript task execution will execute.',
|
||||
);
|
||||
}
|
||||
|
||||
if (!TaskBeforePyFileExist) {
|
||||
await fs.writeFile(
|
||||
TaskBeforePyFile,
|
||||
'# The Python code that executes before the Python task execution will execute.',
|
||||
);
|
||||
}
|
||||
|
||||
if (!TaskAfterFileExist) {
|
||||
await fs.writeFile(TaskAfterFile, await fs.readFile(sampleTaskShellFile));
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ export default async () => {
|
||||
const subscriptionService = Container.get(SubscriptionService);
|
||||
|
||||
// 生成内置token
|
||||
let tokenCommand = `tsx ${join(config.rootPath, 'back/token.ts')}`;
|
||||
let tokenCommand = `ts-node-transpile-only ${join(config.rootPath, 'back/token.ts')}`;
|
||||
const tokenFile = join(config.rootPath, 'static/build/token.js');
|
||||
|
||||
if (await fileExist(tokenFile)) {
|
||||
|
||||
+10
-5
@@ -210,13 +210,18 @@ export default class EnvService {
|
||||
.replace(/'/g, "'\\''")
|
||||
.trim();
|
||||
env_string += `export ${key}='${value}'\n`;
|
||||
const _env_value = `'${group
|
||||
const _env_value = `${group
|
||||
.map((x) => x.value)
|
||||
.join('&')
|
||||
.replace(/\\/g, '\\\\')
|
||||
.replace(/'/g, "\\'")}'`;
|
||||
js_env_string += `process.env.${key}=${_env_value};\n`;
|
||||
py_env_string += `os.environ['${key}']=${_env_value}\n`;
|
||||
.replace(/\\/g, '\\\\')}`;
|
||||
js_env_string += `process.env.${key}=\`${_env_value.replace(
|
||||
/\`/g,
|
||||
'\\`',
|
||||
)}\`;\n`;
|
||||
py_env_string += `os.environ['${key}']='''${_env_value.replace(
|
||||
/\'/g,
|
||||
"\\'",
|
||||
)}'''\n`;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ import taskLimit from '../shared/pLimit';
|
||||
import NotificationService from './notify';
|
||||
import ScheduleService, { TaskCallbacks } from './schedule';
|
||||
import SockService from './sock';
|
||||
import os from 'os';
|
||||
|
||||
@Service()
|
||||
export default class SystemService {
|
||||
@@ -205,6 +206,9 @@ export default class SystemService {
|
||||
});
|
||||
let defaultDomain = 'https://dl-cdn.alpinelinux.org';
|
||||
let targetDomain = 'https://dl-cdn.alpinelinux.org';
|
||||
if (os.platform() !== 'linux') {
|
||||
return;
|
||||
}
|
||||
const content = await fs.promises.readFile('/etc/apk/repositories', {
|
||||
encoding: 'utf-8',
|
||||
});
|
||||
|
||||
-274
@@ -1,274 +0,0 @@
|
||||
#!/usr/bin/env zx
|
||||
import path from 'path';
|
||||
|
||||
const dir_root = process.env.QL_DIR;
|
||||
const file_auth_token = path.join(dir_root, 'static/auth.json');
|
||||
const token_file = path.join(dir_root, 'static/build/token.js');
|
||||
|
||||
let token;
|
||||
|
||||
const createToken = async () => {
|
||||
let tokenCommand = `tsx ${dir_root}/back/token.ts`;
|
||||
if (await fs.exists(token_file)) {
|
||||
tokenCommand = `node ${token_file}`;
|
||||
}
|
||||
token = (await $([tokenCommand])).stdout.trim();
|
||||
};
|
||||
|
||||
const getToken = async () => {
|
||||
if (fs.existsSync(file_auth_token)) {
|
||||
const authTokenData = JSON.parse(fs.readFileSync(file_auth_token, 'utf8'));
|
||||
token = authTokenData.value;
|
||||
const expiration = authTokenData.expiration;
|
||||
const currentTimeStamp = Math.floor(Date.now() / 1000);
|
||||
if (currentTimeStamp >= expiration) {
|
||||
await createToken();
|
||||
}
|
||||
} else {
|
||||
await createToken();
|
||||
}
|
||||
};
|
||||
|
||||
export const addCronApi = async (schedule, command, name, subId = null) => {
|
||||
const currentTimeStamp = Math.floor(Date.now() / 1000);
|
||||
const data = {
|
||||
name,
|
||||
command,
|
||||
schedule,
|
||||
sub_id: subId,
|
||||
};
|
||||
|
||||
try {
|
||||
const response = await fetch(
|
||||
`http://0.0.0.0:5600/open/crons?t=${currentTimeStamp}`,
|
||||
{
|
||||
method: 'POST',
|
||||
headers: {
|
||||
Accept: 'application/json',
|
||||
Authorization: `Bearer ${token}`,
|
||||
'User-Agent': 'Mozilla/5.0',
|
||||
'Content-Type': 'application/json;charset=UTF-8',
|
||||
},
|
||||
body: JSON.stringify(data),
|
||||
},
|
||||
);
|
||||
|
||||
const responseData = await response.json();
|
||||
const { code, message } = responseData;
|
||||
if (code === 200) {
|
||||
console.log(`${name} -> 添加成功`);
|
||||
} else {
|
||||
console.log(`${name} -> 添加失败(${message})`);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(`${name} -> 添加失败(${error.message})`);
|
||||
}
|
||||
};
|
||||
|
||||
export const updateCronApi = async (schedule, command, name, id) => {
|
||||
const currentTimeStamp = Math.floor(Date.now() / 1000);
|
||||
const data = {
|
||||
name,
|
||||
command,
|
||||
schedule,
|
||||
id,
|
||||
};
|
||||
|
||||
try {
|
||||
const response = await fetch(
|
||||
`http://0.0.0.0:5600/open/crons?t=${currentTimeStamp}`,
|
||||
{
|
||||
method: 'PUT',
|
||||
headers: {
|
||||
Accept: 'application/json',
|
||||
Authorization: `Bearer ${token}`,
|
||||
'User-Agent': 'Mozilla/5.0',
|
||||
'Content-Type': 'application/json;charset=UTF-8',
|
||||
},
|
||||
body: JSON.stringify(data),
|
||||
},
|
||||
);
|
||||
|
||||
const responseData = await response.json();
|
||||
const { code, message } = responseData;
|
||||
if (code === 200) {
|
||||
console.log(`${name} -> 更新成功`);
|
||||
} else {
|
||||
console.log(`${name} -> 更新失败(${message})`);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(`${name} -> 更新失败(${error.message})`);
|
||||
}
|
||||
};
|
||||
|
||||
export const updateCronCommandApi = async (command, id) => {
|
||||
const currentTimeStamp = Math.floor(Date.now() / 1000);
|
||||
const data = {
|
||||
command,
|
||||
id,
|
||||
};
|
||||
|
||||
try {
|
||||
const response = await fetch(
|
||||
`http://0.0.0.0:5600/open/crons?t=${currentTimeStamp}`,
|
||||
{
|
||||
method: 'PUT',
|
||||
headers: {
|
||||
Accept: 'application/json',
|
||||
Authorization: `Bearer ${token}`,
|
||||
'User-Agent': 'Mozilla/5.0',
|
||||
'Content-Type': 'application/json;charset=UTF-8',
|
||||
},
|
||||
body: JSON.stringify(data),
|
||||
},
|
||||
);
|
||||
|
||||
const responseData = await response.json();
|
||||
const { code, message } = responseData;
|
||||
if (code === 200) {
|
||||
console.log(`${command} -> 更新成功`);
|
||||
} else {
|
||||
console.log(`${command} -> 更新失败(${message})`);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(`${command} -> 更新失败(${error.message})`);
|
||||
}
|
||||
};
|
||||
|
||||
export const delCronApi = async (ids) => {
|
||||
const currentTimeStamp = Math.floor(Date.now() / 1000);
|
||||
|
||||
try {
|
||||
const response = await fetch(
|
||||
`http://0.0.0.0:5600/open/crons?t=${currentTimeStamp}`,
|
||||
{
|
||||
method: 'DELETE',
|
||||
headers: {
|
||||
Accept: 'application/json',
|
||||
Authorization: `Bearer ${token}`,
|
||||
'User-Agent': 'Mozilla/5.0',
|
||||
'Content-Type': 'application/json;charset=UTF-8',
|
||||
},
|
||||
body: JSON.stringify(ids),
|
||||
},
|
||||
);
|
||||
|
||||
const responseData = await response.json();
|
||||
const { code, message } = responseData;
|
||||
if (code === 200) {
|
||||
console.log('成功');
|
||||
} else {
|
||||
console.log(`失败(${message})`);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(`删除失败(${error.message})`);
|
||||
}
|
||||
};
|
||||
|
||||
export const updateCron = async (
|
||||
ids,
|
||||
status,
|
||||
pid,
|
||||
logPath,
|
||||
lastExecutingTime = 0,
|
||||
runningTime = 0,
|
||||
) => {
|
||||
const currentTimeStamp = Math.floor(Date.now() / 1000);
|
||||
const data = {
|
||||
ids,
|
||||
status,
|
||||
pid,
|
||||
log_path: logPath,
|
||||
last_execution_time: lastExecutingTime,
|
||||
last_running_time: runningTime,
|
||||
};
|
||||
|
||||
try {
|
||||
const response = await fetch(
|
||||
`http://0.0.0.0:5600/open/crons/status?t=${currentTimeStamp}`,
|
||||
{
|
||||
method: 'PUT',
|
||||
headers: {
|
||||
Accept: 'application/json',
|
||||
Authorization: `Bearer ${token}`,
|
||||
'User-Agent': 'Mozilla/5.0',
|
||||
'Content-Type': 'application/json;charset=UTF-8',
|
||||
},
|
||||
body: JSON.stringify(data),
|
||||
},
|
||||
);
|
||||
|
||||
const responseData = await response.json();
|
||||
const { code, message } = responseData;
|
||||
if (code !== 200) {
|
||||
console.log(`更新任务状态失败(${message})`);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(`更新任务状态失败(${error.message})`);
|
||||
}
|
||||
};
|
||||
|
||||
export const notifyApi = async (title, content) => {
|
||||
const currentTimeStamp = Math.floor(Date.now() / 1000);
|
||||
const data = {
|
||||
title,
|
||||
content,
|
||||
};
|
||||
|
||||
try {
|
||||
const response = await fetch(
|
||||
`http://0.0.0.0:5600/open/system/notify?t=${currentTimeStamp}`,
|
||||
{
|
||||
method: 'PUT',
|
||||
headers: {
|
||||
Accept: 'application/json',
|
||||
Authorization: `Bearer ${token}`,
|
||||
'User-Agent': 'Mozilla/5.0',
|
||||
'Content-Type': 'application/json;charset=UTF-8',
|
||||
},
|
||||
body: JSON.stringify(data),
|
||||
},
|
||||
);
|
||||
|
||||
const responseData = await response.json();
|
||||
const { code, message } = responseData;
|
||||
if (code === 200) {
|
||||
console.log('通知发送成功🎉');
|
||||
} else {
|
||||
console.log(`通知失败(${message})`);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(`通知失败(${error.message})`);
|
||||
}
|
||||
};
|
||||
|
||||
export const findCronApi = async (params) => {
|
||||
const currentTimeStamp = Math.floor(Date.now() / 1000);
|
||||
|
||||
try {
|
||||
const response = await fetch(
|
||||
`http://0.0.0.0:5600/open/crons/detail?${params}&t=${currentTimeStamp}`,
|
||||
{
|
||||
headers: {
|
||||
Accept: 'application/json',
|
||||
Authorization: `Bearer ${token}`,
|
||||
'User-Agent': 'Mozilla/5.0',
|
||||
'Content-Type': 'application/json;charset=UTF-8',
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
const responseData = await response.json();
|
||||
const { data } = responseData;
|
||||
if (data === 'null') {
|
||||
console.log('');
|
||||
} else {
|
||||
const { name } = data;
|
||||
console.log(name);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(`查找失败(${error.message})`);
|
||||
}
|
||||
};
|
||||
|
||||
await getToken();
|
||||
@@ -0,0 +1,13 @@
|
||||
import { CommandModule } from 'yargs';
|
||||
export const updateCommand: CommandModule = {
|
||||
command: 'update',
|
||||
describe: 'Update and restart qinglong',
|
||||
builder: (yargs) => {
|
||||
return yargs.option('repositority', {
|
||||
type: 'string',
|
||||
alias: 'r',
|
||||
describe: `Specify the release warehouse address of the package`,
|
||||
});
|
||||
},
|
||||
handler: async (argv) => {},
|
||||
};
|
||||
-22
@@ -1,22 +0,0 @@
|
||||
#!/usr/bin/env zx
|
||||
|
||||
import 'zx/globals';
|
||||
let initialVars = [];
|
||||
|
||||
export const storeEnvVars = async () => {
|
||||
const stdout = (await $`env`).lines();
|
||||
initialVars = stdout.map((line) => line.split('=')[0]);
|
||||
};
|
||||
|
||||
export const restoreEnvVars = async () => {
|
||||
const stdout = (await $`env`).lines();
|
||||
const currentVars = stdout.map((line) => line.split('=')[0]);
|
||||
|
||||
for (const key of currentVars) {
|
||||
if (!initialVars.includes(key)) {
|
||||
await $`unset ${key}`;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
await storeEnvVars();
|
||||
@@ -0,0 +1,13 @@
|
||||
import * as yargs from 'yargs';
|
||||
import { green, red } from 'chalk';
|
||||
import { updateCommand } from './commands/update';
|
||||
|
||||
yargs
|
||||
.usage('Usage: ql [command] <options>')
|
||||
.command(updateCommand)
|
||||
.fail((err) => {
|
||||
console.error(`${red(err)}`);
|
||||
})
|
||||
.alias('h', 'help')
|
||||
.showHelp()
|
||||
.recommendCommands().argv;
|
||||
-302
@@ -1,302 +0,0 @@
|
||||
#!/usr/bin/env zx
|
||||
|
||||
import {
|
||||
dirScripts,
|
||||
dirLog,
|
||||
handleTaskStart,
|
||||
runTaskBefore,
|
||||
runTaskAfter,
|
||||
handleTaskEnd,
|
||||
globalState,
|
||||
formatLogTime,
|
||||
} from './share.mjs';
|
||||
import { basename, dirname } from 'path';
|
||||
|
||||
function defineProgram(fileParam) {
|
||||
if (fileParam.endsWith('.js') || fileParam.endsWith('.mjs')) {
|
||||
return 'node';
|
||||
} else if (fileParam.endsWith('.py') || fileParam.endsWith('.pyc')) {
|
||||
return 'python3';
|
||||
} else if (fileParam.endsWith('.sh')) {
|
||||
return 'bash';
|
||||
} else if (fileParam.endsWith('.ts')) {
|
||||
return $`command -v tsx`
|
||||
.then(() => 'tsx')
|
||||
.catch(() => 'ts-node-transpile-only');
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
async function randomDelay(fileParam) {
|
||||
const randomDelayMax = process.env.RandomDelay;
|
||||
if (randomDelayMax && randomDelayMax > 0) {
|
||||
const fileExtensions = process.env.RandomDelayFileExtensions || 'js';
|
||||
const ignoredMinutes = process.env.RandomDelayIgnoredMinutes || '0 30';
|
||||
const currentMin = new Date().getMinutes();
|
||||
|
||||
if (
|
||||
fileExtensions.split(' ').some((ext) => fileParam.endsWith(`.${ext}`))
|
||||
) {
|
||||
if (
|
||||
ignoredMinutes.split(' ').some((min) => parseInt(min) === currentMin)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
const delaySecond = Math.floor(Math.random() * randomDelayMax) + 1;
|
||||
console.log(
|
||||
`任务随机延迟 ${delaySecond} 秒,配置文件参数 RandomDelay 置空可取消延迟`,
|
||||
);
|
||||
await sleep(delaySecond * 1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function genArrayScripts() {
|
||||
const arrayScripts = [];
|
||||
const arrayScriptsName = [];
|
||||
const files = await fs.readdir(dirScripts);
|
||||
|
||||
for (const file of files) {
|
||||
if (file.endsWith('.js') && file !== 'sendNotify.js') {
|
||||
arrayScripts.push(file);
|
||||
const content = await fs.readFile(`${dirScripts}/${file}`, 'utf8');
|
||||
const match = content.match(/new Env\(['"]([^'"]+)['"]\)/);
|
||||
arrayScriptsName.push(match ? match[1] : '<未识别出活动名称>');
|
||||
}
|
||||
}
|
||||
|
||||
return { arrayScripts, arrayScriptsName };
|
||||
}
|
||||
|
||||
async function usage() {
|
||||
const { arrayScripts, arrayScriptsName } = await genArrayScripts();
|
||||
console.log(
|
||||
`task命令运行本程序自动添加进crontab的脚本,需要输入脚本的绝对路径或去掉 “${dirScripts}/” 目录后的相对路径(定时任务中请写作相对路径),用法为:`,
|
||||
);
|
||||
console.log(
|
||||
`1.$cmdTask <fileName> # 依次执行,如果设置了随机延迟,将随机延迟一定秒数`,
|
||||
);
|
||||
console.log(
|
||||
`2.$cmdTask <fileName> now # 依次执行,无论是否设置了随机延迟,均立即运行,前台会输出日志,同时记录在日志文件中`,
|
||||
);
|
||||
console.log(
|
||||
`3.$cmdTask <fileName> conc <环境变量名称> <账号编号,空格分隔>(可选的) # 并发执行,无论是否设置了随机延迟,均立即运行,前台不产生日志,直接记录在日志文件中,且可指定账号执行`,
|
||||
);
|
||||
console.log(
|
||||
`4.$cmdTask <fileName> desi <环境变量名称> <账号编号,空格分隔> # 指定账号执行,无论是否设置了随机延迟,均立即运行`,
|
||||
);
|
||||
if (arrayScripts.length > 0) {
|
||||
console.log(`\n当前有以下脚本可以运行:`);
|
||||
arrayScripts.forEach((script, i) =>
|
||||
console.log(`${i + 1}. ${arrayScriptsName[i]}:${script}`),
|
||||
);
|
||||
} else {
|
||||
console.log(`\n暂无脚本可以执行`);
|
||||
}
|
||||
}
|
||||
|
||||
export function parseDuration(d) {
|
||||
if (typeof d == 'number') {
|
||||
if (isNaN(d) || d < 0) throw new Error(`Invalid duration: "${d}".`);
|
||||
return d;
|
||||
} else if (/\d+s/.test(d)) {
|
||||
return +d.slice(0, -1) * 1000;
|
||||
} else if (/\d+ms/.test(d)) {
|
||||
return +d.slice(0, -2);
|
||||
} else if (/\d+m/.test(d)) {
|
||||
return +d.slice(0, -1) * 1000 * 60;
|
||||
} else if (/\d+h/.test(d)) {
|
||||
return +d.slice(0, -1) * 1000 * 60 * 60;
|
||||
} else if (/\d+d/.test(d)) {
|
||||
return +d.slice(0, -1) * 1000 * 60 * 60 * 24;
|
||||
}
|
||||
throw new Error(`Unknown duration: "${d}".`);
|
||||
}
|
||||
|
||||
async function runWithTimeout(command) {
|
||||
if (globalState.commandTimeoutTime) {
|
||||
const timeoutNumber = parseDuration(globalState.commandTimeoutTime);
|
||||
await $([command]).timeout(timeoutNumber).nothrow().pipe(process.stdout);
|
||||
} else {
|
||||
await $([command]).nothrow().pipe(process.stdout);
|
||||
}
|
||||
}
|
||||
|
||||
async function runNormal(fileParam, scriptParams) {
|
||||
if (
|
||||
!scriptParams.includes('now') &&
|
||||
process.env.realTime !== 'true' &&
|
||||
process.env.noDelay !== 'true'
|
||||
) {
|
||||
await randomDelay(fileParam);
|
||||
}
|
||||
cd(dirScripts);
|
||||
const relativePath = dirname(fileParam);
|
||||
if (!fileParam.startsWith('/') && relativePath) {
|
||||
cd(relativePath);
|
||||
fileParam = fileParam.replace(`${relativePath}/`, '');
|
||||
}
|
||||
await runWithTimeout(
|
||||
`${globalState.whichProgram} ${fileParam} ${scriptParams}`,
|
||||
);
|
||||
}
|
||||
|
||||
async function runConcurrent(fileParam, envParam, numParam, scriptParams) {
|
||||
if (!envParam || !numParam) {
|
||||
console.log(`缺少并发运行的环境变量参数 task xxx.js conc Test 1 3`);
|
||||
return;
|
||||
}
|
||||
|
||||
const array = (process.env[envParam] || '').split('&');
|
||||
const runArr = expandRange(numParam, array.length);
|
||||
const arrayRun = runArr.map((i) => array[i - 1]).filter(Boolean);
|
||||
|
||||
const singleLogTime = formatLogTime(new Date());
|
||||
|
||||
cd(dirScripts);
|
||||
const relativePath = dirname(fileParam);
|
||||
if (relativePath && fileParam.includes('/')) {
|
||||
cd(relativePath);
|
||||
fileParam = fileParam.replace(`${relativePath}/`, '');
|
||||
}
|
||||
|
||||
await Promise.all(
|
||||
arrayRun.map(async (env, i) => {
|
||||
const singleLogPath = `${dirLog}/${globalState.logDir}/${singleLogTime}_${
|
||||
i + 1
|
||||
}.log`;
|
||||
await runWithTimeout(
|
||||
`${envParam}="${env.replace('"', '\\"')}" ${
|
||||
globalState.whichProgram
|
||||
} ${fileParam} ${scriptParams} &>${singleLogPath}`,
|
||||
);
|
||||
}),
|
||||
);
|
||||
|
||||
for (let i = 0; i < arrayRun.length; i++) {
|
||||
const singleLogPath = `${dirLog}/${globalState.logDir}/${singleLogTime}_${
|
||||
i + 1
|
||||
}.log`;
|
||||
const log = await fs.readFile(singleLogPath, 'utf8');
|
||||
console.log(log);
|
||||
await fs.unlink(singleLogPath);
|
||||
}
|
||||
}
|
||||
|
||||
async function runDesignated(fileParam, envParam, numParam, scriptParams) {
|
||||
if (!envParam || !numParam) {
|
||||
console.log(`缺少单独运行的参数 task xxx.js desi Test 1 3`);
|
||||
return;
|
||||
}
|
||||
|
||||
const array = (process.env[envParam] || '').split('&');
|
||||
const runArr = expandRange(numParam, array.length);
|
||||
const arrayRun = runArr.map((i) => array[i - 1]).filter(Boolean);
|
||||
const cookieStr = arrayRun.join('&');
|
||||
cd(dirScripts);
|
||||
const relativePath = dirname(fileParam);
|
||||
if (relativePath && fileParam.includes('/')) {
|
||||
cd(relativePath);
|
||||
fileParam = fileParam.replace(`${relativePath}/`, '');
|
||||
}
|
||||
|
||||
console.log('cookieStr', cookieStr.length, arrayRun.length);
|
||||
// ${envParam}="${cookieStr.replace('"', '\\"')}"
|
||||
await runWithTimeout(
|
||||
`${globalState.whichProgram} ${fileParam} ${scriptParams}`,
|
||||
);
|
||||
}
|
||||
|
||||
async function runElse(fileParam, scriptParams) {
|
||||
cd(dirScripts);
|
||||
const relativePath = dirname(fileParam);
|
||||
if (relativePath && fileParam.includes('/')) {
|
||||
cd(relativePath);
|
||||
fileParam = fileParam.replace(`${relativePath}/`, './');
|
||||
}
|
||||
|
||||
await runWithTimeout(
|
||||
`${globalState.whichProgram} ${fileParam} ${scriptParams}`,
|
||||
);
|
||||
}
|
||||
|
||||
function expandRange(rangeStr, max) {
|
||||
const tempRangeStr = rangeStr
|
||||
.replace(/-max/g, `-${max}`)
|
||||
.replace(/max-/g, `${max}-`);
|
||||
|
||||
return tempRangeStr.split(' ').flatMap((part) => {
|
||||
const rangeMatch = part.match(/^(\d+)([-~_])(\d+)$/);
|
||||
if (rangeMatch) {
|
||||
const [, start, , end] = rangeMatch.map(Number);
|
||||
return Array.from({ length: end - start + 1 }, (_, i) => start + i);
|
||||
}
|
||||
return Number(part);
|
||||
});
|
||||
}
|
||||
|
||||
async function main(taskShellParams, scriptParams) {
|
||||
const [fileParam, action, envParam, ...others] = taskShellParams;
|
||||
if (taskShellParams.length === 0) {
|
||||
return await usage();
|
||||
}
|
||||
if (fileParam && /\.(js|py|pyc|sh|ts)$/.test(fileParam)) {
|
||||
const filePath = fileParam.startsWith('/')
|
||||
? fileParam
|
||||
: path.join(dirScripts, fileParam);
|
||||
if (!(await fs.exists(filePath))) {
|
||||
console.log(`文件不存在 ${fileParam}`);
|
||||
return;
|
||||
}
|
||||
switch (action) {
|
||||
case undefined:
|
||||
return await runNormal(fileParam, scriptParams);
|
||||
case 'now':
|
||||
return await runNormal(fileParam, scriptParams);
|
||||
case 'conc':
|
||||
return await runConcurrent(
|
||||
fileParam,
|
||||
envParam,
|
||||
others.join(' '),
|
||||
scriptParams,
|
||||
);
|
||||
case 'desi':
|
||||
return await runDesignated(
|
||||
fileParam,
|
||||
envParam,
|
||||
others.join(' '),
|
||||
scriptParams,
|
||||
);
|
||||
}
|
||||
}
|
||||
await runElse(fileParam, taskShellParams.slice(1).concat(scriptParams));
|
||||
}
|
||||
|
||||
async function run() {
|
||||
const taskArgv = minimist(process.argv.slice(3), {
|
||||
'--': true,
|
||||
});
|
||||
const { _: taskShellParams, m, '--': scriptParams, GlobalState } = taskArgv;
|
||||
const cacheState = JSON.parse(GlobalState || '{}');
|
||||
for (const key in cacheState) {
|
||||
globalState[key] = cacheState[key];
|
||||
}
|
||||
if (m) {
|
||||
globalState.commandTimeoutTime = m;
|
||||
}
|
||||
globalState.whichProgram = await defineProgram(taskShellParams[0]);
|
||||
|
||||
await handleTaskStart();
|
||||
await runTaskBefore();
|
||||
await main(taskShellParams, scriptParams);
|
||||
await runTaskAfter();
|
||||
await handleTaskEnd();
|
||||
}
|
||||
|
||||
async function singleHandle() {}
|
||||
|
||||
const signals = ['SIGINT', 'SIGTERM', 'SIGHUP', 'SIGQUIT', 'SIGTSTP'];
|
||||
signals.forEach((sig) => process.on(sig, singleHandle));
|
||||
|
||||
await run();
|
||||
-500
@@ -1,500 +0,0 @@
|
||||
#!/usr/bin/env zx
|
||||
import 'zx/globals';
|
||||
// $.verbose = true;
|
||||
|
||||
import { updateCron, notifyApi } from './api.mjs';
|
||||
import { restoreEnvVars } from './env.mjs';
|
||||
|
||||
export const dirRoot = process.env.QL_DIR;
|
||||
export const dirTmp = path.join(dirRoot, '.tmp');
|
||||
export const dirData = process.env.QL_DATA_DIR
|
||||
? process.env.QL_DATA_DIR.endsWith('/')
|
||||
? process.env.QL_DATA_DIR.slice(-1)
|
||||
: process.env.QL_DATA_DIR
|
||||
: path.join(dirRoot, 'data');
|
||||
export const dirShell = path.join(dirRoot, 'shell');
|
||||
export const dirCli = path.join(dirRoot, 'cli');
|
||||
export const dirSample = path.join(dirRoot, 'sample');
|
||||
export const dirStatic = path.join(dirRoot, 'static');
|
||||
export const dirConfig = path.join(dirData, 'config');
|
||||
export const dirScripts = path.join(dirData, 'scripts');
|
||||
export const dirRepo = path.join(dirData, 'repo');
|
||||
export const dirRaw = path.join(dirData, 'raw');
|
||||
export const dirLog = path.join(dirData, 'log');
|
||||
export const dirDb = path.join(dirData, 'db');
|
||||
export const dirDep = path.join(dirData, 'deps');
|
||||
export const dirListTmp = path.join(dirLog, '.tmp');
|
||||
export const dirUpdateLog = path.join(dirLog, 'update');
|
||||
export const qlStaticRepo = path.join(dirRepo, 'static');
|
||||
|
||||
export const fileConfigSample = path.join(dirSample, 'config.sample.sh');
|
||||
export const fileEnv = path.join(dirConfig, 'env.sh');
|
||||
export const jsFileEnv = path.join(dirConfig, 'env.js');
|
||||
export const fileConfigUser = path.join(dirConfig, 'config.sh');
|
||||
export const fileAuthSample = path.join(dirSample, 'auth.sample.json');
|
||||
export const fileAuthUser = path.join(dirConfig, 'auth.json');
|
||||
export const fileAuthToken = path.join(dirConfig, 'token.json');
|
||||
export const fileExtraShell = path.join(dirConfig, 'extra.sh');
|
||||
export const fileTaskBefore = path.join(dirConfig, 'task_before.sh');
|
||||
export const fileTaskAfter = path.join(dirConfig, 'task_after.sh');
|
||||
export const fileTaskSample = path.join(dirSample, 'task.sample.sh');
|
||||
export const fileExtraSample = path.join(dirSample, 'extra.sample.sh');
|
||||
export const fileNotifyJsSample = path.join(dirSample, 'notify.js');
|
||||
export const fileNotifyPySample = path.join(dirSample, 'notify.py');
|
||||
export const fileTestJsSample = path.join(dirSample, 'ql_sample.js');
|
||||
export const fileTestPySample = path.join(dirSample, 'ql_sample.py');
|
||||
export const fileNotifyPy = path.join(dirScripts, 'notify.py');
|
||||
export const fileNotifyJs = path.join(dirScripts, 'sendNotify.js');
|
||||
export const fileTestJs = path.join(dirScripts, 'ql_sample.js');
|
||||
export const fileTestPy = path.join(dirScripts, 'ql_sample.py');
|
||||
export const nginxAppConf = path.join(dirRoot, 'docker/front.conf');
|
||||
export const nginxConf = path.join(dirRoot, 'docker/nginx.conf');
|
||||
export const depNotifyPy = path.join(dirDep, 'notify.py');
|
||||
export const depNotifyJs = path.join(dirDep, 'sendNotify.js');
|
||||
|
||||
export const listCrontabUser = path.join(dirConfig, 'crontab.list');
|
||||
export const listCrontabSample = path.join(dirSample, 'crontab.sample.list');
|
||||
export const listOwnScripts = path.join(dirListTmp, 'own_scripts.list');
|
||||
export const listOwnUser = path.join(dirListTmp, 'own_user.list');
|
||||
export const listOwnAdd = path.join(dirListTmp, 'own_add.list');
|
||||
export const listOwnDrop = path.join(dirListTmp, 'own_drop.list');
|
||||
|
||||
export const globalState = {};
|
||||
|
||||
export const initEnv = () => {
|
||||
$.prefix +=
|
||||
'export NODE_PATH=/usr/local/bin:/usr/local/pnpm-global/5/node_modules:/usr/local/lib/node_modules:/root/.local/share/pnpm/global/5/node_modules;';
|
||||
$.prefix += 'export PYTHONUNBUFFERED=1;';
|
||||
$.prefix += 'export TERM=xterm-color;';
|
||||
};
|
||||
|
||||
export const importConfig = async () => {
|
||||
if (await fs.exists(fileConfigUser)) {
|
||||
$.prefix += (await fs.readFile(fileConfigUser, 'utf8'));
|
||||
}
|
||||
// if (process.env.LOAD_ENV !== 'false' && (await fs.exists(fileEnv))) {
|
||||
// $.prefix += (await fs.readFile(fileEnv, 'utf8'));
|
||||
// }
|
||||
require(jsFileEnv)
|
||||
|
||||
globalState.qlBaseUrl = process.env.QlBaseUrl || '/';
|
||||
globalState.qlPort = process.env.QlPort || '5700';
|
||||
globalState.commandTimeoutTime = process.env.CommandTimeoutTime;
|
||||
globalState.fileExtensions = process.env.RepoFileExtensions || 'js py';
|
||||
globalState.proxyUrl = process.env.ProxyUrl || '';
|
||||
globalState.currentBranch = process.env.QL_BRANCH;
|
||||
|
||||
if (process.env.DefaultCronRule) {
|
||||
globalState.defaultCron = process.env.DefaultCronRule;
|
||||
} else {
|
||||
globalState.defaultCron = `${Math.floor(Math.random() * 60)} ${Math.floor(
|
||||
Math.random() * 24,
|
||||
)} * * *`;
|
||||
}
|
||||
|
||||
globalState.cpuWarn = process.env.CpuWarn;
|
||||
globalState.memWarn = process.env.MemoryWarn;
|
||||
globalState.diskWarn = process.env.DiskWarn;
|
||||
};
|
||||
|
||||
export const setProxy = (proxy) => {
|
||||
if (proxy) {
|
||||
globalState.proxyUrl = proxy;
|
||||
}
|
||||
if (globalState.proxyUrl) {
|
||||
$`export http_proxy=${globalState.proxyUrl}`;
|
||||
$`export https_proxy=${globalState.proxyUrl}`;
|
||||
}
|
||||
};
|
||||
|
||||
export const unsetProxy = () => {
|
||||
$`unset http_proxy`;
|
||||
$`unset https_proxy`;
|
||||
};
|
||||
|
||||
export const makeDir = async (dir) => {
|
||||
if (!(await fs.exists(dir))) {
|
||||
await fs.mkdir(dir, { recursive: true });
|
||||
}
|
||||
};
|
||||
|
||||
export const detectTermux = () => {
|
||||
globalState.isTermux = process.env.PATH?.includes('com.termux') ? 1 : 0;
|
||||
};
|
||||
|
||||
export const detectMacos = () => {
|
||||
globalState.isMacos = os.type() === 'Darwin' ? 1 : 0;
|
||||
};
|
||||
|
||||
export const genRandomNum = (number) => {
|
||||
return Math.floor(Math.random() * number);
|
||||
};
|
||||
|
||||
export const fixConfig = async () => {
|
||||
await makeDir(dirTmp);
|
||||
await makeDir(dirStatic);
|
||||
await makeDir(dirData);
|
||||
await makeDir(dirConfig);
|
||||
await makeDir(dirLog);
|
||||
await makeDir(dirDb);
|
||||
await makeDir(dirScripts);
|
||||
await makeDir(dirListTmp);
|
||||
await makeDir(dirRepo);
|
||||
await makeDir(dirRaw);
|
||||
await makeDir(dirUpdateLog);
|
||||
await makeDir(dirDep);
|
||||
|
||||
if (!(await fs.exists(fileConfigUser))) {
|
||||
console.log(
|
||||
`复制一份 ${fileConfigSample} 为 ${fileConfigUser},随后请按注释编辑你的配置文件:${fileConfigUser}`,
|
||||
);
|
||||
await fs.copyFile(fileConfigSample, fileConfigUser);
|
||||
}
|
||||
|
||||
if (!(await fs.exists(fileEnv))) {
|
||||
console.log(
|
||||
'检测到config配置目录下不存在env.sh,创建一个空文件用于初始化...',
|
||||
);
|
||||
await fs.writeFile(fileEnv, '');
|
||||
}
|
||||
|
||||
if (!(await fs.exists(fileTaskBefore))) {
|
||||
console.log(`复制一份 ${fileTaskSample} 为 ${fileTaskBefore}`);
|
||||
await fs.copyFile(fileTaskSample, fileTaskBefore);
|
||||
}
|
||||
|
||||
if (!(await fs.exists(fileTaskAfter))) {
|
||||
console.log(`复制一份 ${fileTaskSample} 为 ${fileTaskAfter}`);
|
||||
await fs.copyFile(fileTaskSample, fileTaskAfter);
|
||||
}
|
||||
|
||||
if (!(await fs.exists(fileExtraShell))) {
|
||||
console.log(`复制一份 ${fileExtraSample} 为 ${fileExtraShell}`);
|
||||
await fs.copyFile(fileExtraSample, fileExtraShell);
|
||||
}
|
||||
|
||||
if (!(await fs.exists(fileAuthUser))) {
|
||||
console.log(`复制一份 ${fileAuthSample} 为 ${fileAuthUser}`);
|
||||
await fs.copyFile(fileAuthSample, fileAuthUser);
|
||||
}
|
||||
|
||||
if (!(await fs.exists(fileNotifyPy))) {
|
||||
console.log(`复制一份 ${fileNotifyPySample} 为 ${fileNotifyPy}`);
|
||||
await fs.copyFile(fileNotifyPySample, fileNotifyPy);
|
||||
}
|
||||
|
||||
if (!(await fs.exists(fileNotifyJs))) {
|
||||
console.log(`复制一份 ${fileNotifyJsSample} 为 ${fileNotifyJs}`);
|
||||
await fs.copyFile(fileNotifyJsSample, fileNotifyJs);
|
||||
}
|
||||
|
||||
if (!(await fs.exists(fileTestJs))) {
|
||||
await fs.copyFile(fileTestJsSample, fileTestJs);
|
||||
}
|
||||
|
||||
if (!(await fs.exists(fileTestPy))) {
|
||||
await fs.copyFile(fileTestPySample, fileTestPy);
|
||||
}
|
||||
|
||||
if (await fs.exists('/etc/nginx/conf.d/default.conf')) {
|
||||
console.log('检测到你可能未修改过默认nginx配置,将帮你删除');
|
||||
await fs.unlink('/etc/nginx/conf.d/default.conf');
|
||||
}
|
||||
if (!(await fs.exists(depNotifyJs))) {
|
||||
console.log(`复制一份 ${fileNotifyJsSample} 为 ${depNotifyJs}`);
|
||||
await fs.copyFile(fileNotifyJsSample, depNotifyJs);
|
||||
}
|
||||
|
||||
if (!(await fs.exists(depNotifyPy))) {
|
||||
console.log(`复制一份 ${fileNotifyPySample} 为 ${depNotifyPy}`);
|
||||
await fs.copyFile(fileNotifyPySample, depNotifyPy);
|
||||
}
|
||||
};
|
||||
|
||||
export const npmInstallSub = async () => {
|
||||
if (globalState.isTermux === 1) {
|
||||
await $`npm install --production --no-bin-links`;
|
||||
} else if (!(await $`command -v pnpm`)) {
|
||||
await $`npm install --production`;
|
||||
} else {
|
||||
await $`pnpm install --loglevel error --production`;
|
||||
}
|
||||
};
|
||||
|
||||
export const npmInstall = async (dirWork) => {
|
||||
const dirCurrent = process.cwd();
|
||||
|
||||
await $`cd ${dirWork}`;
|
||||
console.log(`安装 ${dirWork} 依赖包...`);
|
||||
await npmInstallSub();
|
||||
await $`cd ${dirCurrent}`;
|
||||
};
|
||||
|
||||
export const diffAndCopy = async (copySource, copyTo) => {
|
||||
if (
|
||||
!(await fs.exists(copyTo)) ||
|
||||
(await $`diff ${copySource} ${copyTo}`).exitCode !== 0
|
||||
) {
|
||||
await fs.copyFile(copySource, copyTo);
|
||||
}
|
||||
};
|
||||
|
||||
export const gitCloneScripts = async (url, dir, branch, proxy) => {
|
||||
const partCmd = branch ? `-b ${branch}` : '';
|
||||
console.log(`开始拉取仓库 ${globalState.uniqPath} 到 ${dir}`);
|
||||
|
||||
setProxy(proxy);
|
||||
|
||||
const res = await $`git clone -q --depth=1 ${partCmd} ${url} ${dir}`;
|
||||
globalState.exitStatus = res.exitCode;
|
||||
|
||||
unsetProxy();
|
||||
};
|
||||
|
||||
export const randomRange = (begin, end) => {
|
||||
return Math.floor(Math.random() * (end - begin) + begin);
|
||||
};
|
||||
|
||||
export const deletePm2 = async () => {
|
||||
await $`cd ${dirRoot}`;
|
||||
await $`pm2 delete ecosystem.config.js`;
|
||||
};
|
||||
|
||||
export const reloadPm2 = async () => {
|
||||
await $`cd ${dirRoot}`;
|
||||
restoreEnvVars();
|
||||
await $`pm2 flush &>/dev/null`;
|
||||
await $`pm2 startOrGracefulReload ecosystem.config.js`;
|
||||
};
|
||||
|
||||
export const reloadUpdate = async () => {
|
||||
await $`cd ${dirRoot}`;
|
||||
restoreEnvVars();
|
||||
await $`pm2 flush &>/dev/null`;
|
||||
await $`pm2 startOrGracefulReload other.config.js`;
|
||||
};
|
||||
|
||||
export const diffTime = (beginTime, endTime) => {
|
||||
let diffTime;
|
||||
if (globalState.isMacos === 1) {
|
||||
diffTime = (+new Date(endTime) - +new Date(beginTime)) / 1000;
|
||||
} else {
|
||||
diffTime =
|
||||
(new Date(endTime).getTime() - new Date(beginTime).getTime()) / 1000;
|
||||
}
|
||||
return diffTime;
|
||||
};
|
||||
|
||||
export const formatTime = (time) => {
|
||||
// 秒
|
||||
return new Date(time).toLocaleString();
|
||||
};
|
||||
|
||||
function pad(n, min = 10) {
|
||||
return n < min ? '0' + n : n;
|
||||
}
|
||||
|
||||
export function formatDate(date) {
|
||||
const year = date.getFullYear();
|
||||
const month = pad(date.getMonth() + 1);
|
||||
const day = pad(date.getDate());
|
||||
const hour = pad(date.getHours());
|
||||
const minute = pad(date.getMinutes());
|
||||
const second = pad(date.getSeconds());
|
||||
|
||||
return `${year}-${month}-${day} ${hour}:${minute}:${second}`;
|
||||
}
|
||||
|
||||
export const formatLogTime = (date) => {
|
||||
const year = date.getFullYear();
|
||||
const month = pad(date.getMonth() + 1);
|
||||
const day = pad(date.getDate());
|
||||
const hour = pad(date.getHours());
|
||||
const minute = pad(date.getMinutes());
|
||||
const second = pad(date.getSeconds());
|
||||
const milliSecond = pad(date.getMilliseconds(), 100);
|
||||
|
||||
return `${year}-${month}-${day}-${hour}-${minute}-${second}-${milliSecond}`;
|
||||
};
|
||||
|
||||
export const formatTimestamp = (date) => {
|
||||
return Math.floor(date.getTime() / 1000);
|
||||
};
|
||||
|
||||
export const patchVersion = async () => {
|
||||
await $`git config --global pull.rebase false`;
|
||||
|
||||
if (await fs.exists(path.join(dirRoot, 'db/cookie.db'))) {
|
||||
console.log('检测到旧的db文件,拷贝为新db...');
|
||||
await $`mv ${path.join(dirRoot, 'db/cookie.db')} ${path.join(
|
||||
dirRoot,
|
||||
'db/env.db',
|
||||
)}`;
|
||||
await $`rm -rf ${path.join(dirRoot, 'db/cookie.db')}`;
|
||||
}
|
||||
|
||||
if (await fs.exists(path.join(dirRoot, 'db'))) {
|
||||
console.log('检测到旧的db目录,拷贝到data目录...');
|
||||
await $`cp -rf ${path.join(dirRoot, 'config')} ${dirData}`;
|
||||
}
|
||||
|
||||
if (await fs.exists(path.join(dirRoot, 'scripts'))) {
|
||||
console.log('检测到旧的scripts目录,拷贝到data目录...');
|
||||
await $`cp -rf ${path.join(dirRoot, 'scripts')} ${dirData}`;
|
||||
}
|
||||
|
||||
if (await fs.exists(path.join(dirRoot, 'log'))) {
|
||||
console.log('检测到旧的log目录,拷贝到data目录...');
|
||||
await $`cp -rf ${path.join(dirRoot, 'log')} ${dirData}`;
|
||||
}
|
||||
|
||||
if (await fs.exists(path.join(dirRoot, 'config'))) {
|
||||
console.log('检测到旧的config目录,拷贝到data目录...');
|
||||
await $`cp -rf ${path.join(dirRoot, 'config')} ${dirData}`;
|
||||
}
|
||||
};
|
||||
|
||||
export const initNginx = async () => {
|
||||
await fs.copyFile(nginxConf, '/etc/nginx/nginx.conf');
|
||||
await fs.copyFile(nginxAppConf, '/etc/nginx/conf.d/front.conf');
|
||||
let locationUrl = '/';
|
||||
let aliasStr = '';
|
||||
let rootStr = '';
|
||||
let qlBaseUrl = globalState.qlBaseUrl;
|
||||
let qlPort = globalState.qlPort;
|
||||
if (qlBaseUrl !== '/') {
|
||||
if (!qlBaseUrl.startsWith('/')) {
|
||||
qlBaseUrl = `/${qlBaseUrl}`;
|
||||
}
|
||||
if (!qlBaseUrl.endsWith('/')) {
|
||||
qlBaseUrl = `${qlBaseUrl}/`;
|
||||
}
|
||||
locationUrl = `^~${qlBaseUrl.slice(0, -1)}`;
|
||||
aliasStr = `alias ${path.join(dirStatic, 'dist')};`;
|
||||
const file = await fs.readFile(
|
||||
path.join(dirStatic, 'dist/index.html'),
|
||||
'utf8',
|
||||
);
|
||||
if (!file.includes(`<base href="${qlBaseUrl}">`)) {
|
||||
await fs.writeFile(
|
||||
path.join(dirStatic, 'dist/index.html'),
|
||||
`<base href="${qlBaseUrl}">\n${file}`,
|
||||
);
|
||||
}
|
||||
} else {
|
||||
rootStr = `root ${path.join(dirStatic, 'dist')};`;
|
||||
}
|
||||
await $`sed -i "s,QL_ALIAS_CONFIG,${aliasStr},g" /etc/nginx/conf.d/front.conf`;
|
||||
await $`sed -i "s,QL_ROOT_CONFIG,${rootStr},g" /etc/nginx/conf.d/front.conf`;
|
||||
await $`sed -i "s,QL_BASE_URL_LOCATION,${locationUrl},g" /etc/nginx/conf.d/front.conf`;
|
||||
let ipv6Str = '';
|
||||
const ipv6 = await $`ip a | grep inet6`;
|
||||
if (ipv6.stdout.trim()) {
|
||||
ipv6Str = 'listen [::]:${qlPort} ipv6only=on;';
|
||||
}
|
||||
const ipv4Str = `listen ${qlPort};`;
|
||||
await $`sed -i "s,IPV6_CONFIG,${ipv6Str},g" /etc/nginx/conf.d/front.conf`;
|
||||
await $`sed -i "s,IPV4_CONFIG,${ipv4Str},g" /etc/nginx/conf.d/front.conf`;
|
||||
};
|
||||
|
||||
async function checkServer() {
|
||||
const cpuWarn = parseInt(process.env.cpuWarn || '0');
|
||||
const memWarn = parseInt(process.env.memWarn || '0');
|
||||
const diskWarn = parseInt(process.env.diskWarn || '0');
|
||||
|
||||
if (cpuWarn && memWarn && diskWarn) {
|
||||
const topResult = await $`top -b -n 1`;
|
||||
const cpuUse = parseInt(
|
||||
topResult.stdout.match(/CPU\s+(\d+)\%/)?.[1] || '0',
|
||||
);
|
||||
const memFree = parseInt(
|
||||
(await $`free -m`).stdout.match(/Mem:\s+(\d+)/)?.[1] || '0',
|
||||
);
|
||||
const memTotal = parseInt(
|
||||
(await $`free -m`).stdout.match(/Mem:\s+\d+\s+(\d+)/)?.[1] || '0',
|
||||
);
|
||||
const diskUse = parseInt(
|
||||
(await $`df -P`).stdout.match(/\/dev.*\s+(\d+)\%/)?.[1] || '0',
|
||||
);
|
||||
if (memFree && memTotal && diskUse && cpuUse) {
|
||||
const memUse = Math.floor((memFree * 100) / memTotal);
|
||||
|
||||
if (cpuUse > cpuWarn || memFree < memWarn || diskUse > diskWarn) {
|
||||
const resource = topResult.stdout
|
||||
.split('\n')
|
||||
.slice(7, 17)
|
||||
.map((line) => line.replace(/\s+/g, ' '))
|
||||
.join('\\n');
|
||||
await notifyApi(
|
||||
'服务器资源异常警告',
|
||||
`当前CPU占用 ${cpuUse}% 内存占用 ${memUse}% 磁盘占用 ${diskUse}% \n资源占用详情 \n\n ${resource}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export const handleTaskStart = async () => {
|
||||
if (globalState.ID) {
|
||||
await updateCron(
|
||||
[globalState.ID],
|
||||
'0',
|
||||
String(process.pid),
|
||||
globalState.logPath,
|
||||
globalState.beginTimestamp,
|
||||
);
|
||||
}
|
||||
console.log(`## 开始执行... ${globalState.beginTime}\n`);
|
||||
};
|
||||
|
||||
export const runTaskBefore = async () => {
|
||||
if (globalState.isMacos === 0) {
|
||||
await checkServer();
|
||||
}
|
||||
await $`. ${fileTaskBefore} "$@"`;
|
||||
|
||||
if (globalState.taskBefore) {
|
||||
console.log('执行前置命令');
|
||||
await $`eval ${globalState.taskBefore}`;
|
||||
console.log('执行前置命令结束');
|
||||
}
|
||||
};
|
||||
|
||||
export const runTaskAfter = async () => {
|
||||
await $`. ${fileTaskAfter} "$@"`;
|
||||
|
||||
if (globalState.taskAfter) {
|
||||
console.log('执行后置命令');
|
||||
await $`eval "${globalState.taskAfter}"`;
|
||||
console.log('执行后置命令结束');
|
||||
}
|
||||
};
|
||||
|
||||
export const handleTaskEnd = async () => {
|
||||
const etime = new Date();
|
||||
const endTime = formatDate(etime);
|
||||
const endTimestamp = formatTimestamp(etime);
|
||||
let diffTime = endTimestamp - globalState.beginTimestamp;
|
||||
|
||||
if (diffTime === 0) {
|
||||
diffTime = 1;
|
||||
}
|
||||
|
||||
if (globalState.ID) {
|
||||
await updateCron(
|
||||
[globalState.ID],
|
||||
'1',
|
||||
`${process.pid}`,
|
||||
globalState.logPath,
|
||||
globalState.beginTimestamp,
|
||||
diffTime,
|
||||
);
|
||||
}
|
||||
|
||||
console.log(`\n## 执行结束... ${endTime} 耗时 ${diffTime} 秒`);
|
||||
};
|
||||
|
||||
initEnv();
|
||||
detectTermux();
|
||||
detectMacos();
|
||||
await importConfig();
|
||||
@@ -1,94 +0,0 @@
|
||||
#!/usr/bin/env zx
|
||||
import 'zx/globals';
|
||||
|
||||
import { PassThrough } from 'node:stream';
|
||||
import {
|
||||
listCrontabUser,
|
||||
formatLogTime,
|
||||
formatTimestamp,
|
||||
formatDate,
|
||||
dirLog,
|
||||
dirCli,
|
||||
globalState,
|
||||
handleTaskEnd,
|
||||
} from './share.mjs';
|
||||
import './api.mjs';
|
||||
|
||||
// $.verbose = true;
|
||||
|
||||
async function singleHandle() {}
|
||||
|
||||
const signals = ['SIGINT', 'SIGTERM', 'SIGHUP', 'SIGQUIT', 'SIGTSTP'];
|
||||
signals.forEach((sig) => process.on(sig, singleHandle));
|
||||
|
||||
export async function handleLogPath(fileParam) {
|
||||
let ID = $.env.ID;
|
||||
if (!ID) {
|
||||
const grepResult =
|
||||
await $`grep -E "task.* ${fileParam}" ${listCrontabUser}`.nothrow();
|
||||
ID = grepResult.stdout.match(/ID=(\d+)/)?.[1];
|
||||
}
|
||||
globalState.ID = ID;
|
||||
|
||||
const suffix = ID && parseInt(ID, 10) > 0 ? `_${ID}` : '';
|
||||
globalState.time = new Date();
|
||||
const logTime = formatLogTime(globalState.time);
|
||||
let logDirTmp = path.basename(fileParam);
|
||||
let logDirTmpPath = '';
|
||||
|
||||
if (fileParam.includes('/')) {
|
||||
logDirTmpPath = path.isAbsolute(fileParam)
|
||||
? fileParam.substring(1)
|
||||
: fileParam;
|
||||
logDirTmpPath = path.basename(path.dirname(logDirTmpPath));
|
||||
}
|
||||
|
||||
if (logDirTmpPath) {
|
||||
logDirTmp = `${logDirTmpPath}_${logDirTmp}`;
|
||||
}
|
||||
|
||||
const logDir = `${logDirTmp.replace(/\.[^/.]+$/, '')}${suffix}`;
|
||||
globalState.logDir = logDir;
|
||||
globalState.logPath = `${logDir}/${logTime}.log`;
|
||||
if ($.env.real_log_path) {
|
||||
globalState.logPath = realLogPath;
|
||||
}
|
||||
|
||||
await $`mkdir -p ${dirLog}/${logDir}`;
|
||||
}
|
||||
|
||||
export function initBeginTime() {
|
||||
globalState.beginTime = formatDate(globalState.time);
|
||||
globalState.beginTimestamp = formatTimestamp(globalState.time);
|
||||
}
|
||||
|
||||
async function main() {
|
||||
const taskArgv = minimist(process.argv.slice(3), {
|
||||
'--': true,
|
||||
});
|
||||
const {
|
||||
_: [scriptFile],
|
||||
} = taskArgv;
|
||||
|
||||
await handleLogPath(scriptFile);
|
||||
initBeginTime();
|
||||
|
||||
cd(`${dirCli}`);
|
||||
const logStream = fs.createWriteStream(`${dirLog}/${globalState.logPath}`);
|
||||
const passThrough = new PassThrough();
|
||||
passThrough.pipe(logStream);
|
||||
const p = $`./otask.mjs ${process.argv.slice(
|
||||
3,
|
||||
)} --GlobalState=${JSON.stringify(globalState)} 2>&1`.nothrow();
|
||||
p.stdout.pipe(passThrough).pipe(process.stdout);
|
||||
await p;
|
||||
}
|
||||
|
||||
main()
|
||||
.then(() => {
|
||||
process.exit(0);
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error(err);
|
||||
process.exit(1);
|
||||
});
|
||||
@@ -3,7 +3,7 @@ COPY package.json .npmrc pnpm-lock.yaml /tmp/build/
|
||||
RUN set -x \
|
||||
&& apk update \
|
||||
&& apk add nodejs npm git \
|
||||
&& npm i -g pnpm@8.3.1 pm2 tsx \
|
||||
&& npm i -g pnpm@8.3.1 pm2 ts-node \
|
||||
&& cd /tmp/build \
|
||||
&& pnpm install --prod
|
||||
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@ COPY package.json .npmrc pnpm-lock.yaml /tmp/build/
|
||||
RUN set -x \
|
||||
&& apk update \
|
||||
&& apk add nodejs npm git \
|
||||
&& npm i -g pnpm@8.3.1 pm2 tsx \
|
||||
&& npm i -g pnpm@8.3.1 pm2 ts-node \
|
||||
&& cd /tmp/build \
|
||||
&& pnpm install --prod
|
||||
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
#!/bin/bash
|
||||
|
||||
dir_shell=/ql/shell
|
||||
. $dir_shell/env.sh
|
||||
. $dir_shell/share.sh
|
||||
. $dir_shell/env.sh
|
||||
|
||||
echo -e "======================1. 检测配置文件========================\n"
|
||||
import_config "$@"
|
||||
make_dir /etc/nginx/conf.d
|
||||
make_dir /run/nginx
|
||||
init_nginx
|
||||
|
||||
+2
-6
@@ -19,9 +19,6 @@
|
||||
"test": "umi-test",
|
||||
"test:coverage": "umi-test --coverage"
|
||||
},
|
||||
"bin": {
|
||||
"task": "./cli/task.mjs"
|
||||
},
|
||||
"gitHooks": {
|
||||
"pre-commit": "lint-staged"
|
||||
},
|
||||
@@ -100,7 +97,7 @@
|
||||
"uuid": "^8.3.2",
|
||||
"winston": "^3.6.0",
|
||||
"winston-daily-rotate-file": "^4.7.1",
|
||||
"zx": "^8.1.4",
|
||||
"yargs": "^17.3.1",
|
||||
"tough-cookie": "^4.0.0",
|
||||
"request-ip": "3.3.0",
|
||||
"ip2region": "2.3.0"
|
||||
@@ -166,10 +163,9 @@
|
||||
"react-intl-universal": "^2.6.21",
|
||||
"react-split-pane": "^0.1.92",
|
||||
"sockjs-client": "^1.6.0",
|
||||
"ts-node": "^10.6.0",
|
||||
"ts-node": "^10.9.2",
|
||||
"ts-proto": "^1.146.0",
|
||||
"tslib": "^2.4.0",
|
||||
"tsx": "^4.7.3",
|
||||
"typescript": "5.2.2",
|
||||
"vh-check": "^2.0.5",
|
||||
"virtualizedtableforantd4": "1.3.0",
|
||||
|
||||
Generated
+7
-299
@@ -134,9 +134,9 @@ dependencies:
|
||||
winston-daily-rotate-file:
|
||||
specifier: ^4.7.1
|
||||
version: 4.7.1(winston@3.9.0)
|
||||
zx:
|
||||
specifier: ^8.1.4
|
||||
version: 8.1.4
|
||||
yargs:
|
||||
specifier: ^17.3.1
|
||||
version: 17.7.2
|
||||
|
||||
devDependencies:
|
||||
'@ant-design/icons':
|
||||
@@ -320,17 +320,14 @@ devDependencies:
|
||||
specifier: ^1.6.0
|
||||
version: 1.6.1
|
||||
ts-node:
|
||||
specifier: ^10.6.0
|
||||
version: 10.9.1(@types/node@17.0.45)(typescript@5.2.2)
|
||||
specifier: ^10.9.2
|
||||
version: 10.9.2(@types/node@17.0.45)(typescript@5.2.2)
|
||||
ts-proto:
|
||||
specifier: ^1.146.0
|
||||
version: 1.148.2
|
||||
tslib:
|
||||
specifier: ^2.4.0
|
||||
version: 2.5.3
|
||||
tsx:
|
||||
specifier: ^4.7.3
|
||||
version: 4.7.3
|
||||
typescript:
|
||||
specifier: 5.2.2
|
||||
version: 5.2.2
|
||||
@@ -3399,15 +3396,6 @@ packages:
|
||||
get-tsconfig: 4.7.3
|
||||
dev: true
|
||||
|
||||
/@esbuild/aix-ppc64@0.19.12:
|
||||
resolution: {integrity: sha512-bmoCYyWdEL3wDQIVbcyzRyeKLgk2WtWLTWz1ZIAZF/EGbNOwSA6ew3PftJ1PqMiOOGu0OyFMzG53L0zqIpPeNA==}
|
||||
engines: {node: '>=12'}
|
||||
cpu: [ppc64]
|
||||
os: [aix]
|
||||
requiresBuild: true
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/android-arm64@0.17.19:
|
||||
resolution: {integrity: sha512-KBMWvEZooR7+kzY0BtbTQn0OAYY7CsiydT63pVEaPtVYF0hXbUaOyZog37DKxK7NF3XacBJOpYT4adIJh+avxA==}
|
||||
engines: {node: '>=12'}
|
||||
@@ -3417,15 +3405,6 @@ packages:
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/android-arm64@0.19.12:
|
||||
resolution: {integrity: sha512-P0UVNGIienjZv3f5zq0DP3Nt2IE/3plFzuaS96vihvD0Hd6H/q4WXUGpCxD/E8YrSXfNyRPbpTq+T8ZQioSuPA==}
|
||||
engines: {node: '>=12'}
|
||||
cpu: [arm64]
|
||||
os: [android]
|
||||
requiresBuild: true
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/android-arm@0.17.19:
|
||||
resolution: {integrity: sha512-rIKddzqhmav7MSmoFCmDIb6e2W57geRsM94gV2l38fzhXMwq7hZoClug9USI2pFRGL06f4IOPHHpFNOkWieR8A==}
|
||||
engines: {node: '>=12'}
|
||||
@@ -3435,15 +3414,6 @@ packages:
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/android-arm@0.19.12:
|
||||
resolution: {integrity: sha512-qg/Lj1mu3CdQlDEEiWrlC4eaPZ1KztwGJ9B6J+/6G+/4ewxJg7gqj8eVYWvao1bXrqGiW2rsBZFSX3q2lcW05w==}
|
||||
engines: {node: '>=12'}
|
||||
cpu: [arm]
|
||||
os: [android]
|
||||
requiresBuild: true
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/android-x64@0.17.19:
|
||||
resolution: {integrity: sha512-uUTTc4xGNDT7YSArp/zbtmbhO0uEEK9/ETW29Wk1thYUJBz3IVnvgEiEwEa9IeLyvnpKrWK64Utw2bgUmDveww==}
|
||||
engines: {node: '>=12'}
|
||||
@@ -3453,15 +3423,6 @@ packages:
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/android-x64@0.19.12:
|
||||
resolution: {integrity: sha512-3k7ZoUW6Q6YqhdhIaq/WZ7HwBpnFBlW905Fa4s4qWJyiNOgT1dOqDiVAQFwBH7gBRZr17gLrlFCRzF6jFh7Kew==}
|
||||
engines: {node: '>=12'}
|
||||
cpu: [x64]
|
||||
os: [android]
|
||||
requiresBuild: true
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/darwin-arm64@0.17.19:
|
||||
resolution: {integrity: sha512-80wEoCfF/hFKM6WE1FyBHc9SfUblloAWx6FJkFWTWiCoht9Mc0ARGEM47e67W9rI09YoUxJL68WHfDRYEAvOhg==}
|
||||
engines: {node: '>=12'}
|
||||
@@ -3471,15 +3432,6 @@ packages:
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/darwin-arm64@0.19.12:
|
||||
resolution: {integrity: sha512-B6IeSgZgtEzGC42jsI+YYu9Z3HKRxp8ZT3cqhvliEHovq8HSX2YX8lNocDn79gCKJXOSaEot9MVYky7AKjCs8g==}
|
||||
engines: {node: '>=12'}
|
||||
cpu: [arm64]
|
||||
os: [darwin]
|
||||
requiresBuild: true
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/darwin-x64@0.17.19:
|
||||
resolution: {integrity: sha512-IJM4JJsLhRYr9xdtLytPLSH9k/oxR3boaUIYiHkAawtwNOXKE8KoU8tMvryogdcT8AU+Bflmh81Xn6Q0vTZbQw==}
|
||||
engines: {node: '>=12'}
|
||||
@@ -3489,15 +3441,6 @@ packages:
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/darwin-x64@0.19.12:
|
||||
resolution: {integrity: sha512-hKoVkKzFiToTgn+41qGhsUJXFlIjxI/jSYeZf3ugemDYZldIXIxhvwN6erJGlX4t5h417iFuheZ7l+YVn05N3A==}
|
||||
engines: {node: '>=12'}
|
||||
cpu: [x64]
|
||||
os: [darwin]
|
||||
requiresBuild: true
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/freebsd-arm64@0.17.19:
|
||||
resolution: {integrity: sha512-pBwbc7DufluUeGdjSU5Si+P3SoMF5DQ/F/UmTSb8HXO80ZEAJmrykPyzo1IfNbAoaqw48YRpv8shwd1NoI0jcQ==}
|
||||
engines: {node: '>=12'}
|
||||
@@ -3507,15 +3450,6 @@ packages:
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/freebsd-arm64@0.19.12:
|
||||
resolution: {integrity: sha512-4aRvFIXmwAcDBw9AueDQ2YnGmz5L6obe5kmPT8Vd+/+x/JMVKCgdcRwH6APrbpNXsPz+K653Qg8HB/oXvXVukA==}
|
||||
engines: {node: '>=12'}
|
||||
cpu: [arm64]
|
||||
os: [freebsd]
|
||||
requiresBuild: true
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/freebsd-x64@0.17.19:
|
||||
resolution: {integrity: sha512-4lu+n8Wk0XlajEhbEffdy2xy53dpR06SlzvhGByyg36qJw6Kpfk7cp45DR/62aPH9mtJRmIyrXAS5UWBrJT6TQ==}
|
||||
engines: {node: '>=12'}
|
||||
@@ -3525,15 +3459,6 @@ packages:
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/freebsd-x64@0.19.12:
|
||||
resolution: {integrity: sha512-EYoXZ4d8xtBoVN7CEwWY2IN4ho76xjYXqSXMNccFSx2lgqOG/1TBPW0yPx1bJZk94qu3tX0fycJeeQsKovA8gg==}
|
||||
engines: {node: '>=12'}
|
||||
cpu: [x64]
|
||||
os: [freebsd]
|
||||
requiresBuild: true
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/linux-arm64@0.17.19:
|
||||
resolution: {integrity: sha512-ct1Tg3WGwd3P+oZYqic+YZF4snNl2bsnMKRkb3ozHmnM0dGWuxcPTTntAF6bOP0Sp4x0PjSF+4uHQ1xvxfRKqg==}
|
||||
engines: {node: '>=12'}
|
||||
@@ -3543,15 +3468,6 @@ packages:
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/linux-arm64@0.19.12:
|
||||
resolution: {integrity: sha512-EoTjyYyLuVPfdPLsGVVVC8a0p1BFFvtpQDB/YLEhaXyf/5bczaGeN15QkR+O4S5LeJ92Tqotve7i1jn35qwvdA==}
|
||||
engines: {node: '>=12'}
|
||||
cpu: [arm64]
|
||||
os: [linux]
|
||||
requiresBuild: true
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/linux-arm@0.17.19:
|
||||
resolution: {integrity: sha512-cdmT3KxjlOQ/gZ2cjfrQOtmhG4HJs6hhvm3mWSRDPtZ/lP5oe8FWceS10JaSJC13GBd4eH/haHnqf7hhGNLerA==}
|
||||
engines: {node: '>=12'}
|
||||
@@ -3561,15 +3477,6 @@ packages:
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/linux-arm@0.19.12:
|
||||
resolution: {integrity: sha512-J5jPms//KhSNv+LO1S1TX1UWp1ucM6N6XuL6ITdKWElCu8wXP72l9MM0zDTzzeikVyqFE6U8YAV9/tFyj0ti+w==}
|
||||
engines: {node: '>=12'}
|
||||
cpu: [arm]
|
||||
os: [linux]
|
||||
requiresBuild: true
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/linux-ia32@0.17.19:
|
||||
resolution: {integrity: sha512-w4IRhSy1VbsNxHRQpeGCHEmibqdTUx61Vc38APcsRbuVgK0OPEnQ0YD39Brymn96mOx48Y2laBQGqgZ0j9w6SQ==}
|
||||
engines: {node: '>=12'}
|
||||
@@ -3579,15 +3486,6 @@ packages:
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/linux-ia32@0.19.12:
|
||||
resolution: {integrity: sha512-Thsa42rrP1+UIGaWz47uydHSBOgTUnwBwNq59khgIwktK6x60Hivfbux9iNR0eHCHzOLjLMLfUMLCypBkZXMHA==}
|
||||
engines: {node: '>=12'}
|
||||
cpu: [ia32]
|
||||
os: [linux]
|
||||
requiresBuild: true
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/linux-loong64@0.17.19:
|
||||
resolution: {integrity: sha512-2iAngUbBPMq439a+z//gE+9WBldoMp1s5GWsUSgqHLzLJ9WoZLZhpwWuym0u0u/4XmZ3gpHmzV84PonE+9IIdQ==}
|
||||
engines: {node: '>=12'}
|
||||
@@ -3597,15 +3495,6 @@ packages:
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/linux-loong64@0.19.12:
|
||||
resolution: {integrity: sha512-LiXdXA0s3IqRRjm6rV6XaWATScKAXjI4R4LoDlvO7+yQqFdlr1Bax62sRwkVvRIrwXxvtYEHHI4dm50jAXkuAA==}
|
||||
engines: {node: '>=12'}
|
||||
cpu: [loong64]
|
||||
os: [linux]
|
||||
requiresBuild: true
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/linux-mips64el@0.17.19:
|
||||
resolution: {integrity: sha512-LKJltc4LVdMKHsrFe4MGNPp0hqDFA1Wpt3jE1gEyM3nKUvOiO//9PheZZHfYRfYl6AwdTH4aTcXSqBerX0ml4A==}
|
||||
engines: {node: '>=12'}
|
||||
@@ -3615,15 +3504,6 @@ packages:
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/linux-mips64el@0.19.12:
|
||||
resolution: {integrity: sha512-fEnAuj5VGTanfJ07ff0gOA6IPsvrVHLVb6Lyd1g2/ed67oU1eFzL0r9WL7ZzscD+/N6i3dWumGE1Un4f7Amf+w==}
|
||||
engines: {node: '>=12'}
|
||||
cpu: [mips64el]
|
||||
os: [linux]
|
||||
requiresBuild: true
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/linux-ppc64@0.17.19:
|
||||
resolution: {integrity: sha512-/c/DGybs95WXNS8y3Ti/ytqETiW7EU44MEKuCAcpPto3YjQbyK3IQVKfF6nbghD7EcLUGl0NbiL5Rt5DMhn5tg==}
|
||||
engines: {node: '>=12'}
|
||||
@@ -3633,15 +3513,6 @@ packages:
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/linux-ppc64@0.19.12:
|
||||
resolution: {integrity: sha512-nYJA2/QPimDQOh1rKWedNOe3Gfc8PabU7HT3iXWtNUbRzXS9+vgB0Fjaqr//XNbd82mCxHzik2qotuI89cfixg==}
|
||||
engines: {node: '>=12'}
|
||||
cpu: [ppc64]
|
||||
os: [linux]
|
||||
requiresBuild: true
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/linux-riscv64@0.17.19:
|
||||
resolution: {integrity: sha512-FC3nUAWhvFoutlhAkgHf8f5HwFWUL6bYdvLc/TTuxKlvLi3+pPzdZiFKSWz/PF30TB1K19SuCxDTI5KcqASJqA==}
|
||||
engines: {node: '>=12'}
|
||||
@@ -3651,15 +3522,6 @@ packages:
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/linux-riscv64@0.19.12:
|
||||
resolution: {integrity: sha512-2MueBrlPQCw5dVJJpQdUYgeqIzDQgw3QtiAHUC4RBz9FXPrskyyU3VI1hw7C0BSKB9OduwSJ79FTCqtGMWqJHg==}
|
||||
engines: {node: '>=12'}
|
||||
cpu: [riscv64]
|
||||
os: [linux]
|
||||
requiresBuild: true
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/linux-s390x@0.17.19:
|
||||
resolution: {integrity: sha512-IbFsFbxMWLuKEbH+7sTkKzL6NJmG2vRyy6K7JJo55w+8xDk7RElYn6xvXtDW8HCfoKBFK69f3pgBJSUSQPr+4Q==}
|
||||
engines: {node: '>=12'}
|
||||
@@ -3669,15 +3531,6 @@ packages:
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/linux-s390x@0.19.12:
|
||||
resolution: {integrity: sha512-+Pil1Nv3Umes4m3AZKqA2anfhJiVmNCYkPchwFJNEJN5QxmTs1uzyy4TvmDrCRNT2ApwSari7ZIgrPeUx4UZDg==}
|
||||
engines: {node: '>=12'}
|
||||
cpu: [s390x]
|
||||
os: [linux]
|
||||
requiresBuild: true
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/linux-x64@0.17.19:
|
||||
resolution: {integrity: sha512-68ngA9lg2H6zkZcyp22tsVt38mlhWde8l3eJLWkyLrp4HwMUr3c1s/M2t7+kHIhvMjglIBrFpncX1SzMckomGw==}
|
||||
engines: {node: '>=12'}
|
||||
@@ -3687,15 +3540,6 @@ packages:
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/linux-x64@0.19.12:
|
||||
resolution: {integrity: sha512-B71g1QpxfwBvNrfyJdVDexenDIt1CiDN1TIXLbhOw0KhJzE78KIFGX6OJ9MrtC0oOqMWf+0xop4qEU8JrJTwCg==}
|
||||
engines: {node: '>=12'}
|
||||
cpu: [x64]
|
||||
os: [linux]
|
||||
requiresBuild: true
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/netbsd-x64@0.17.19:
|
||||
resolution: {integrity: sha512-CwFq42rXCR8TYIjIfpXCbRX0rp1jo6cPIUPSaWwzbVI4aOfX96OXY8M6KNmtPcg7QjYeDmN+DD0Wp3LaBOLf4Q==}
|
||||
engines: {node: '>=12'}
|
||||
@@ -3705,15 +3549,6 @@ packages:
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/netbsd-x64@0.19.12:
|
||||
resolution: {integrity: sha512-3ltjQ7n1owJgFbuC61Oj++XhtzmymoCihNFgT84UAmJnxJfm4sYCiSLTXZtE00VWYpPMYc+ZQmB6xbSdVh0JWA==}
|
||||
engines: {node: '>=12'}
|
||||
cpu: [x64]
|
||||
os: [netbsd]
|
||||
requiresBuild: true
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/openbsd-x64@0.17.19:
|
||||
resolution: {integrity: sha512-cnq5brJYrSZ2CF6c35eCmviIN3k3RczmHz8eYaVlNasVqsNY+JKohZU5MKmaOI+KkllCdzOKKdPs762VCPC20g==}
|
||||
engines: {node: '>=12'}
|
||||
@@ -3723,15 +3558,6 @@ packages:
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/openbsd-x64@0.19.12:
|
||||
resolution: {integrity: sha512-RbrfTB9SWsr0kWmb9srfF+L933uMDdu9BIzdA7os2t0TXhCRjrQyCeOt6wVxr79CKD4c+p+YhCj31HBkYcXebw==}
|
||||
engines: {node: '>=12'}
|
||||
cpu: [x64]
|
||||
os: [openbsd]
|
||||
requiresBuild: true
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/sunos-x64@0.17.19:
|
||||
resolution: {integrity: sha512-vCRT7yP3zX+bKWFeP/zdS6SqdWB8OIpaRq/mbXQxTGHnIxspRtigpkUcDMlSCOejlHowLqII7K2JKevwyRP2rg==}
|
||||
engines: {node: '>=12'}
|
||||
@@ -3741,15 +3567,6 @@ packages:
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/sunos-x64@0.19.12:
|
||||
resolution: {integrity: sha512-HKjJwRrW8uWtCQnQOz9qcU3mUZhTUQvi56Q8DPTLLB+DawoiQdjsYq+j+D3s9I8VFtDr+F9CjgXKKC4ss89IeA==}
|
||||
engines: {node: '>=12'}
|
||||
cpu: [x64]
|
||||
os: [sunos]
|
||||
requiresBuild: true
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/win32-arm64@0.17.19:
|
||||
resolution: {integrity: sha512-yYx+8jwowUstVdorcMdNlzklLYhPxjniHWFKgRqH7IFlUEa0Umu3KuYplf1HUZZ422e3NU9F4LGb+4O0Kdcaag==}
|
||||
engines: {node: '>=12'}
|
||||
@@ -3759,15 +3576,6 @@ packages:
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/win32-arm64@0.19.12:
|
||||
resolution: {integrity: sha512-URgtR1dJnmGvX864pn1B2YUYNzjmXkuJOIqG2HdU62MVS4EHpU2946OZoTMnRUHklGtJdJZ33QfzdjGACXhn1A==}
|
||||
engines: {node: '>=12'}
|
||||
cpu: [arm64]
|
||||
os: [win32]
|
||||
requiresBuild: true
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/win32-ia32@0.17.19:
|
||||
resolution: {integrity: sha512-eggDKanJszUtCdlVs0RB+h35wNlb5v4TWEkq4vZcmVt5u/HiDZrTXe2bWFQUez3RgNHwx/x4sk5++4NSSicKkw==}
|
||||
engines: {node: '>=12'}
|
||||
@@ -3777,15 +3585,6 @@ packages:
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/win32-ia32@0.19.12:
|
||||
resolution: {integrity: sha512-+ZOE6pUkMOJfmxmBZElNOx72NKpIa/HFOMGzu8fqzQJ5kgf6aTGrcJaFsNiVMH4JKpMipyK+7k0n2UXN7a8YKQ==}
|
||||
engines: {node: '>=12'}
|
||||
cpu: [ia32]
|
||||
os: [win32]
|
||||
requiresBuild: true
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/win32-x64@0.17.19:
|
||||
resolution: {integrity: sha512-lAhycmKnVOuRYNtRtatQR1LPQf2oYCkRGkSFnseDAKPl8lu5SOsK/e1sXe5a0Pc5kHIHe6P2I/ilntNv2xf3cA==}
|
||||
engines: {node: '>=12'}
|
||||
@@ -3795,15 +3594,6 @@ packages:
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@esbuild/win32-x64@0.19.12:
|
||||
resolution: {integrity: sha512-T1QyPSDCyMXaO3pzBkF96E8xMkiRYbUEZADd29SyPGabqxMViNoii+NcK7eWJAEoU6RZyEm5lVSIjTmcdoB9HA==}
|
||||
engines: {node: '>=12'}
|
||||
cpu: [x64]
|
||||
os: [win32]
|
||||
requiresBuild: true
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@eslint-community/eslint-utils@4.4.0(eslint@8.35.0):
|
||||
resolution: {integrity: sha512-1/sA4dwrzBAyeUoQ6oxahHKmrZvsnLCg4RfxW3ZFGGmQkSNQPFNLV9CUEFQP1x9EYXHTo5p6xdhZM1Ne9p/AfA==}
|
||||
engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
|
||||
@@ -5114,15 +4904,6 @@ packages:
|
||||
resolution: {integrity: sha512-xbqnZmGrCEqi/KUzOkeUSe77p7APvLuyellGaAoeww3CHJ1AbjQWjPSCFtKIzZn8L7LpEax4NXnC+gfa6nM7IA==}
|
||||
dev: true
|
||||
|
||||
/@types/fs-extra@11.0.4:
|
||||
resolution: {integrity: sha512-yTbItCNreRooED33qjunPthRcSjERP1r4MqCZc7wv0u2sUkzTFp45tgUfS5+r7FrZPdmCCNflLhVSP/o+SemsQ==}
|
||||
requiresBuild: true
|
||||
dependencies:
|
||||
'@types/jsonfile': 6.1.4
|
||||
'@types/node': 17.0.45
|
||||
dev: false
|
||||
optional: true
|
||||
|
||||
/@types/graceful-fs@4.1.6:
|
||||
resolution: {integrity: sha512-Sig0SNORX9fdW+bQuTEovKj3uHcUL6LQKbCrrqb1X7J6/ReAbhCXRAhc+SMejhLELFj2QcyuxmUooZ4bt5ReSw==}
|
||||
dependencies:
|
||||
@@ -5186,14 +4967,6 @@ packages:
|
||||
resolution: {integrity: sha512-Hr5Jfhc9eYOQNPYO5WLDq/n4jqijdHNlDXjuAQkkt+mWdQR+XJToOHrsD4cPaMXpn6KO7y2+wM8AZEs8VpBLVA==}
|
||||
dev: true
|
||||
|
||||
/@types/jsonfile@6.1.4:
|
||||
resolution: {integrity: sha512-D5qGUYwjvnNNextdU59/+fI+spnwtTFmyQP0h+PfIOSkNfpU6AOICUOkm4i0OnSk+NyjdPJrxCDro0sJsWlRpQ==}
|
||||
requiresBuild: true
|
||||
dependencies:
|
||||
'@types/node': 17.0.45
|
||||
dev: false
|
||||
optional: true
|
||||
|
||||
/@types/jsonwebtoken@8.5.9:
|
||||
resolution: {integrity: sha512-272FMnFGzAVMGtu9tkr29hRL6bZj4Zs1KZNeHLnKqAvp06tAIcarTMwOh8/8bz4FmKRcMxZhZNeUAQsNLoiPhg==}
|
||||
dependencies:
|
||||
@@ -5248,14 +5021,6 @@ packages:
|
||||
/@types/node@17.0.45:
|
||||
resolution: {integrity: sha512-w+tIMs3rq2afQdsPJlODhoUEKzFP1ayaoyl1CcnwtIlsVe7K7bA1NGm4s3PraqTLlXnbIN84zuBlxBWo1u9BLw==}
|
||||
|
||||
/@types/node@20.14.9:
|
||||
resolution: {integrity: sha512-06OCtnTXtWOZBJlRApleWndH4JsRVs1pDCc8dLSQp+7PpUpX3ePdHyeNSFTeSe7FtKyQkrlPvHwJOW3SLd8Oyg==}
|
||||
requiresBuild: true
|
||||
dependencies:
|
||||
undici-types: 5.26.5
|
||||
dev: false
|
||||
optional: true
|
||||
|
||||
/@types/nodemailer@6.4.8:
|
||||
resolution: {integrity: sha512-oVsJSCkqViCn8/pEu2hfjwVO+Gb3e+eTWjg3PcjeFKRItfKpKwHphQqbYmPQrlMk+op7pNNWPbsJIEthpFN/OQ==}
|
||||
dependencies:
|
||||
@@ -8675,37 +8440,6 @@ packages:
|
||||
'@esbuild/win32-x64': 0.17.19
|
||||
dev: true
|
||||
|
||||
/esbuild@0.19.12:
|
||||
resolution: {integrity: sha512-aARqgq8roFBj054KvQr5f1sFu0D65G+miZRCuJyJ0G13Zwx7vRar5Zhn2tkQNzIXcBrNVsv/8stehpj+GAjgbg==}
|
||||
engines: {node: '>=12'}
|
||||
hasBin: true
|
||||
requiresBuild: true
|
||||
optionalDependencies:
|
||||
'@esbuild/aix-ppc64': 0.19.12
|
||||
'@esbuild/android-arm': 0.19.12
|
||||
'@esbuild/android-arm64': 0.19.12
|
||||
'@esbuild/android-x64': 0.19.12
|
||||
'@esbuild/darwin-arm64': 0.19.12
|
||||
'@esbuild/darwin-x64': 0.19.12
|
||||
'@esbuild/freebsd-arm64': 0.19.12
|
||||
'@esbuild/freebsd-x64': 0.19.12
|
||||
'@esbuild/linux-arm': 0.19.12
|
||||
'@esbuild/linux-arm64': 0.19.12
|
||||
'@esbuild/linux-ia32': 0.19.12
|
||||
'@esbuild/linux-loong64': 0.19.12
|
||||
'@esbuild/linux-mips64el': 0.19.12
|
||||
'@esbuild/linux-ppc64': 0.19.12
|
||||
'@esbuild/linux-riscv64': 0.19.12
|
||||
'@esbuild/linux-s390x': 0.19.12
|
||||
'@esbuild/linux-x64': 0.19.12
|
||||
'@esbuild/netbsd-x64': 0.19.12
|
||||
'@esbuild/openbsd-x64': 0.19.12
|
||||
'@esbuild/sunos-x64': 0.19.12
|
||||
'@esbuild/win32-arm64': 0.19.12
|
||||
'@esbuild/win32-ia32': 0.19.12
|
||||
'@esbuild/win32-x64': 0.19.12
|
||||
dev: true
|
||||
|
||||
/escalade@3.1.1:
|
||||
resolution: {integrity: sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==}
|
||||
engines: {node: '>=6'}
|
||||
@@ -15742,8 +15476,8 @@ packages:
|
||||
resolution: {integrity: sha512-XrHUvV5HpdLmIj4uVMxHggLbFSZYIn7HEWsqePZcI50pco+MPqJ50wMGY794X7AOOhxOBAjbkqfAbEe/QMp2Lw==}
|
||||
dev: false
|
||||
|
||||
/ts-node@10.9.1(@types/node@17.0.45)(typescript@5.2.2):
|
||||
resolution: {integrity: sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw==}
|
||||
/ts-node@10.9.2(@types/node@17.0.45)(typescript@5.2.2):
|
||||
resolution: {integrity: sha512-f0FFpIdcHgn8zcPSbf1dRevwt047YMnaiJM3u2w2RewrB+fob/zePZcrOyQoLMMO7aBIddLcQIEK5dYjkLnGrQ==}
|
||||
hasBin: true
|
||||
peerDependencies:
|
||||
'@swc/core': '>=1.2.50'
|
||||
@@ -15831,17 +15565,6 @@ packages:
|
||||
fsevents: 2.3.3
|
||||
dev: true
|
||||
|
||||
/tsx@4.7.3:
|
||||
resolution: {integrity: sha512-+fQnMqIp/jxZEXLcj6WzYy9FhcS5/Dfk8y4AtzJ6ejKcKqmfTF8Gso/jtrzDggCF2zTU20gJa6n8XqPYwDAUYQ==}
|
||||
engines: {node: '>=18.0.0'}
|
||||
hasBin: true
|
||||
dependencies:
|
||||
esbuild: 0.19.12
|
||||
get-tsconfig: 4.7.3
|
||||
optionalDependencies:
|
||||
fsevents: 2.3.3
|
||||
dev: true
|
||||
|
||||
/tty-browserify@0.0.0:
|
||||
resolution: {integrity: sha512-JVa5ijo+j/sOoHGjw0sxw734b1LhBkQ3bvUGNdxnVXDCX81Yx7TFgnZygxrIIWn23hbfTaMYLwRmAxFyDuFmIw==}
|
||||
dev: true
|
||||
@@ -16013,12 +15736,6 @@ packages:
|
||||
resolution: {integrity: sha512-ZqGrAgaqqZM7LGRzNjLnw5elevWb5M8LEoDMadxIW3OWbcv72wMMgKdwOKpd5Fqxe8choLD8HN3iSj3TUh/giQ==}
|
||||
dev: false
|
||||
|
||||
/undici-types@5.26.5:
|
||||
resolution: {integrity: sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==}
|
||||
requiresBuild: true
|
||||
dev: false
|
||||
optional: true
|
||||
|
||||
/unescape@1.0.1:
|
||||
resolution: {integrity: sha512-O0+af1Gs50lyH1nUu3ZyYS1cRh01Q/kUKatTOkSs7jukXE6/NebucDVxyiDsA9AQ4JC1V1jUH9EO8JX2nMDgGQ==}
|
||||
engines: {node: '>=0.10.0'}
|
||||
@@ -16681,15 +16398,6 @@ packages:
|
||||
strip-indent: 2.0.0
|
||||
dev: true
|
||||
|
||||
/zx@8.1.4:
|
||||
resolution: {integrity: sha512-QFDYYpnzdpRiJ3dL2102Cw26FpXpWshW4QLTGxiYfIcwdAqg084jRCkK/kuP/NOSkxOjydRwNFG81qzA5r1a6w==}
|
||||
engines: {node: '>= 12.17.0'}
|
||||
hasBin: true
|
||||
optionalDependencies:
|
||||
'@types/fs-extra': 11.0.4
|
||||
'@types/node': 20.14.9
|
||||
dev: false
|
||||
|
||||
github.com/whyour/node-sqlite3/3a00af0b5d7603b7f1b290032507320b18a6b741:
|
||||
resolution: {tarball: https://codeload.github.com/whyour/node-sqlite3/tar.gz/3a00af0b5d7603b7f1b290032507320b18a6b741}
|
||||
name: '@whyour/sqlite3'
|
||||
|
||||
@@ -8,7 +8,7 @@ AutoAddCron="true"
|
||||
DefaultCronRule=""
|
||||
|
||||
## ql repo命令拉取脚本时需要拉取的文件后缀,直接写文件后缀名即可
|
||||
RepoFileExtensions="js py"
|
||||
RepoFileExtensions="js mjs py pyc"
|
||||
|
||||
## 代理地址,支持HTTP/SOCK5,例如 http://127.0.0.1:7890
|
||||
ProxyUrl=""
|
||||
@@ -43,7 +43,7 @@ BotRepoUrl=""
|
||||
|
||||
## 通知环境变量
|
||||
## 1. Server酱
|
||||
## https://sct.ftqq.com
|
||||
## https://sct.ftqq.com/r/13363
|
||||
## 下方填写 SCHKEY 值或 SendKey 值
|
||||
export PUSH_KEY=""
|
||||
|
||||
|
||||
+2
-4
@@ -4,8 +4,6 @@
|
||||
* 定时规则
|
||||
* cron: 1 9 * * *
|
||||
*/
|
||||
const { sendNotify } = require('./sendNotify.js'); // commonjs
|
||||
// import { sendNotify } from './sendNotify'; // es6
|
||||
|
||||
console.log('test scripts');
|
||||
sendNotify('test scripts', 'test desc');
|
||||
QLAPI.notify('test scripts', 'test desc');
|
||||
console.log('test desc');
|
||||
|
||||
+2
-3
@@ -4,7 +4,6 @@ name: script name
|
||||
定时规则
|
||||
cron: 1 9 * * *
|
||||
"""
|
||||
import notify
|
||||
|
||||
print("test script")
|
||||
notify.send('test script', 'test desc')
|
||||
QLAPI.notify('test script', 'test desc')
|
||||
print("test desc")
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
create_token() {
|
||||
local token_command="tsx ${dir_root}/back/token.ts"
|
||||
local token_command="ts-node-transpile-only ${dir_root}/back/token.ts"
|
||||
local token_file="${dir_root}/static/build/token.js"
|
||||
if [[ -f $token_file ]]; then
|
||||
token_command="node ${token_file}"
|
||||
|
||||
+1
-1
@@ -73,7 +73,7 @@ check_pm2() {
|
||||
|
||||
main() {
|
||||
echo -e "=====> 开始检测"
|
||||
npm i -g pnpm@8.3.1 pm2 tsx
|
||||
npm i -g pnpm@8.3.1 pm2 ts-node
|
||||
patch_version
|
||||
|
||||
reset_env
|
||||
|
||||
+94
-63
@@ -69,26 +69,18 @@ run_nohup() {
|
||||
nohup node $file_name &>$log_path &
|
||||
}
|
||||
|
||||
check_server() {
|
||||
if [[ $cpu_warn ]] && [[ $mem_warn ]] && [[ $disk_warn ]]; then
|
||||
local top_result=$(top -b -n 1)
|
||||
cpu_use=$(echo "$top_result" | grep CPU | grep -v -E 'grep|PID' | awk '{print $2}' | cut -f 1 -d "%" | head -n 1)
|
||||
|
||||
mem_free=$(free -m | grep "Mem" | awk '{print $3}' | head -n 1)
|
||||
mem_total=$(free -m | grep "Mem" | awk '{print $2}' | head -n 1)
|
||||
mem_use=$(printf "%d%%" $((mem_free * 100 / mem_total)) | cut -f 1 -d "%" | head -n 1)
|
||||
|
||||
disk_use=$(df -P | grep /dev | grep -v -E '(tmp|boot|shm)' | awk '{print $5}' | cut -f 1 -d "%" | head -n 1)
|
||||
if [[ $cpu_use -gt $cpu_warn ]] && [[ $cpu_warn ]] || [[ $mem_free -lt $mem_warn ]] || [[ $disk_use -gt $disk_warn ]]; then
|
||||
local resource=$(echo "$top_result" | grep -v -E 'grep|Mem|idle|Load|tr' | awk '{$2="";$3="";$4="";$5="";$7="";print $0}' | head -n 10 | tr '\n' '|' | sed s/\|/\\\\n/g)
|
||||
notify_api "服务器资源异常警告" "当前CPU占用 $cpu_use% 内存占用 $mem_use% 磁盘占用 $disk_use% \n资源占用详情 \n\n $resource"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
env_str_to_array() {
|
||||
. $file_env
|
||||
local IFS="&"
|
||||
read -ra array <<<"${!env_param}"
|
||||
array_length=${#array[@]}
|
||||
clear_env
|
||||
}
|
||||
|
||||
clear_non_sh_env() {
|
||||
if [[ $file_param != *.sh ]]; then
|
||||
clear_env
|
||||
fi
|
||||
}
|
||||
|
||||
## 正常运行单个脚本,$1:传入参数
|
||||
@@ -105,37 +97,34 @@ run_normal() {
|
||||
file_param=${file_param/$relative_path\//}
|
||||
fi
|
||||
|
||||
if [[ $isJsOrPythonFile == 'false' ]]; then
|
||||
clear_non_sh_env
|
||||
fi
|
||||
$timeoutCmd $which_program $file_param "${script_params[@]}"
|
||||
}
|
||||
|
||||
handle_env_split() {
|
||||
if [[ ! $num_param ]]; then
|
||||
num_param="1-max"
|
||||
fi
|
||||
|
||||
env_str_to_array
|
||||
local tempArr=$(echo $num_param | sed "s/-max/-${array_length}/g" | sed "s/max-/${array_length}-/g" | perl -pe "s|(\d+)(-\|~\|_)(\d+)|{\1..\3}|g")
|
||||
local runArr=($(eval echo $tempArr))
|
||||
array_run=($(awk -v RS=' ' '!a[$1]++' <<<${runArr[@]}))
|
||||
}
|
||||
|
||||
## 并发执行时,设定的 RandomDelay 不会生效,即所有任务立即执行
|
||||
run_concurrent() {
|
||||
local file_param="$1"
|
||||
local env_param="$2"
|
||||
local num_param=$(echo "$3" | perl -pe "s|.*$2(.*)|\1|")
|
||||
local num_param=$(echo "$3" | perl -pe "s|.*$2(.*)|\1|" | awk '{$1=$1};1')
|
||||
if [[ ! $env_param ]]; then
|
||||
echo -e "\n 缺少并发运行的环境变量参数"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
env_str_to_array
|
||||
local tempArr=$(echo $num_param | sed "s/-max/-${#array[@]}/g" | sed "s/max-/${#array[@]}-/g" | perl -pe "s|(\d+)(-\|~\|_)(\d+)|{\1..\3}|g")
|
||||
local runArr=($(eval echo $tempArr))
|
||||
runArr=($(awk -v RS=' ' '!a[$1]++' <<<${runArr[@]}))
|
||||
|
||||
local n=0
|
||||
for i in ${runArr[@]}; do
|
||||
array_run[n]=${array[$i - 1]}
|
||||
let n++
|
||||
done
|
||||
|
||||
local cookieStr=$(
|
||||
IFS="&"
|
||||
echo "${array_run[*]}"
|
||||
)
|
||||
[[ ! -z $cookieStr ]] && export "${env_param}=${cookieStr}"
|
||||
|
||||
env_str_to_array
|
||||
handle_env_split
|
||||
single_log_time=$(date "+%Y-%m-%d-%H-%M-%S.%3N")
|
||||
|
||||
cd $dir_scripts
|
||||
@@ -144,15 +133,24 @@ run_concurrent() {
|
||||
cd ${relative_path}
|
||||
file_param=${file_param/$relative_path\//}
|
||||
fi
|
||||
for i in "${!array[@]}"; do
|
||||
export "${env_param}=${array[i]}"
|
||||
single_log_path="$dir_log/$log_dir/${single_log_time}_$((i + 1)).log"
|
||||
eval $timeoutCmd $which_program $file_param "${script_params[@]}" &>$single_log_path &
|
||||
|
||||
local j=0
|
||||
for i in ${array_run[@]}; do
|
||||
single_log_path="$dir_log/$log_dir/${single_log_time}_$((j + 1)).log"
|
||||
let j++
|
||||
|
||||
if [[ $isJsOrPythonFile == 'false' ]]; then
|
||||
export "${env_param}=${array[$i - 1]}"
|
||||
clear_non_sh_env
|
||||
fi
|
||||
eval envParam="${env_param}" numParam="${i}" $timeoutCmd $which_program $file_param "${script_params[@]}" &>$single_log_path &
|
||||
done
|
||||
|
||||
wait
|
||||
for i in "${!array[@]}"; do
|
||||
single_log_path="$dir_log/$log_dir/${single_log_time}_$((i + 1)).log"
|
||||
local k=0
|
||||
for i in ${array_run[@]}; do
|
||||
single_log_path="$dir_log/$log_dir/${single_log_time}_$((k + 1)).log"
|
||||
let k++
|
||||
cat $single_log_path
|
||||
[[ -f $single_log_path ]] && rm -f $single_log_path
|
||||
done
|
||||
@@ -161,28 +159,27 @@ run_concurrent() {
|
||||
run_designated() {
|
||||
local file_param="$1"
|
||||
local env_param="$2"
|
||||
local num_param=$(echo "$3" | perl -pe "s|.*$2(.*)|\1|")
|
||||
if [[ ! $env_param ]] || [[ ! $num_param ]]; then
|
||||
echo -e "\n 缺少单独运行的参数 task xxx.js desi Test 1 3"
|
||||
local num_param=$(echo "$3" | perl -pe "s|.*$2(.*)|\1|" | awk '{$1=$1};1')
|
||||
if [[ ! $env_param ]]; then
|
||||
echo -e "\n 缺少单独运行的参数 task xxx.js desi Test"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
env_str_to_array
|
||||
local tempArr=$(echo $num_param | sed "s/-max/-${#array[@]}/g" | sed "s/max-/${#array[@]}-/g" | perl -pe "s|(\d+)(-\|~\|_)(\d+)|{\1..\3}|g")
|
||||
local runArr=($(eval echo $tempArr))
|
||||
runArr=($(awk -v RS=' ' '!a[$1]++' <<<${runArr[@]}))
|
||||
handle_env_split
|
||||
|
||||
local n=0
|
||||
for i in ${runArr[@]}; do
|
||||
array_run[n]=${array[$i - 1]}
|
||||
let n++
|
||||
done
|
||||
|
||||
local cookieStr=$(
|
||||
IFS="&"
|
||||
echo "${array_run[*]}"
|
||||
)
|
||||
[[ ! -z $cookieStr ]] && export "${env_param}=${cookieStr}"
|
||||
if [[ $isJsOrPythonFile == 'false' ]]; then
|
||||
local n=0
|
||||
for i in ${array_run[@]}; do
|
||||
array_str[n]=${array[$i - 1]}
|
||||
let n++
|
||||
done
|
||||
local envStr=$(
|
||||
IFS="&"
|
||||
echo "${array_str[*]}"
|
||||
)
|
||||
[[ ! -z $envStr ]] && export "${env_param}=${envStr}"
|
||||
clear_non_sh_env
|
||||
fi
|
||||
|
||||
cd $dir_scripts
|
||||
local relative_path="${file_param%/*}"
|
||||
@@ -190,7 +187,8 @@ run_designated() {
|
||||
cd ${relative_path}
|
||||
file_param=${file_param/$relative_path\//}
|
||||
fi
|
||||
$timeoutCmd $which_program $file_param "${script_params[@]}"
|
||||
|
||||
envParam="${env_param}" numParam="${num_param}" $timeoutCmd $which_program $file_param "${script_params[@]}"
|
||||
}
|
||||
|
||||
## 运行其他命令
|
||||
@@ -206,12 +204,37 @@ run_else() {
|
||||
|
||||
shift
|
||||
|
||||
clear_non_sh_env
|
||||
$timeoutCmd $which_program $file_param "$@"
|
||||
}
|
||||
|
||||
## 命令检测
|
||||
check_file() {
|
||||
isJsOrPythonFile="false"
|
||||
if [[ $1 == *.js ]] || [[ $1 == *.py ]] || [[ $1 == *.pyc ]] || [[ $1 == *.ts ]]; then
|
||||
isJsOrPythonFile="true"
|
||||
fi
|
||||
if [[ -f $file_env ]]; then
|
||||
get_env_array
|
||||
if [[ $isJsOrPythonFile == 'true' ]]; then
|
||||
PREV_NODE_OPTIONS="${NODE_OPTIONS}"
|
||||
PREV_PYTHONPATH="${PYTHONPATH}"
|
||||
if [[ $1 == *.js ]] || [[ $1 == *.ts ]]; then
|
||||
export NODE_OPTIONS="${NODE_OPTIONS} -r ${file_preload_js}"
|
||||
else
|
||||
export PYTHONPATH="${PYTHONPATH}:${dir_preload}:${dir_config}"
|
||||
fi
|
||||
else
|
||||
. $file_env
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
main() {
|
||||
if [[ $1 == *.js ]] || [[ $1 == *.py ]] || [[ $1 == *.pyc ]] || [[ $1 == *.sh ]] || [[ $1 == *.ts ]]; then
|
||||
if [[ $1 == *.sh ]]; then
|
||||
timeoutCmd=""
|
||||
fi
|
||||
|
||||
case $# in
|
||||
1)
|
||||
run_normal "$1"
|
||||
@@ -242,7 +265,15 @@ main() {
|
||||
}
|
||||
|
||||
handle_task_start "${task_shell_params[@]}"
|
||||
run_task_before "${task_shell_params[@]}"
|
||||
check_file "${task_shell_params[@]}"
|
||||
if [[ $isJsOrPythonFile == 'false' ]]; then
|
||||
run_task_before "${task_shell_params[@]}"
|
||||
fi
|
||||
main "${task_shell_params[@]}"
|
||||
if [[ $isJsOrPythonFile == 'true' ]]; then
|
||||
export NODE_OPTIONS="${PREV_NODE_OPTIONS}"
|
||||
export PYTHONPATH="${PREV_PYTHONPATH}"
|
||||
fi
|
||||
run_task_after "${task_shell_params[@]}"
|
||||
clear_env
|
||||
handle_task_end "${task_shell_params[@]}"
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
const { execSync } = require('child_process');
|
||||
require(`./env.js`);
|
||||
function expandRange(rangeStr, max) {
|
||||
const tempRangeStr = rangeStr
|
||||
.trim()
|
||||
.replace(/-max/g, `-${max}`)
|
||||
.replace(/max-/g, `${max}-`);
|
||||
|
||||
return tempRangeStr.split(' ').flatMap((part) => {
|
||||
const rangeMatch = part.match(/^(\d+)([-~_])(\d+)$/);
|
||||
if (rangeMatch) {
|
||||
const [, start, , end] = rangeMatch.map(Number);
|
||||
const step = start < end ? 1 : -1;
|
||||
return Array.from(
|
||||
{ length: Math.abs(end - start) + 1 },
|
||||
(_, i) => start + i * step,
|
||||
);
|
||||
}
|
||||
return Number(part);
|
||||
});
|
||||
}
|
||||
|
||||
function run() {
|
||||
const {
|
||||
envParam,
|
||||
numParam,
|
||||
file_task_before,
|
||||
file_task_before_js,
|
||||
dir_scripts,
|
||||
task_before,
|
||||
} = process.env;
|
||||
|
||||
require(file_task_before_js);
|
||||
|
||||
try {
|
||||
const splitStr = '__sitecustomize__';
|
||||
const fileName = process.argv[1].replace(`${dir_scripts}/`, '');
|
||||
let command = `bash -c "source ${file_task_before} ${fileName}`;
|
||||
if (task_before) {
|
||||
const escapeTaskBefore = task_before.replace(/"/g, '\\"');
|
||||
command = `${command} && echo -e '执行前置命令\n' && eval '${escapeTaskBefore}' && echo -e '\n执行前置命令结束\n'`;
|
||||
}
|
||||
const res = execSync(
|
||||
`${command} && echo -e '${splitStr}' && NODE_OPTIONS= node -p 'JSON.stringify(process.env)'"`,
|
||||
{
|
||||
encoding: 'utf-8',
|
||||
},
|
||||
);
|
||||
const [output, envStr] = res.split(splitStr);
|
||||
const newEnvObject = JSON.parse(envStr.trim());
|
||||
for (const key in newEnvObject) {
|
||||
process.env[key] = newEnvObject[key];
|
||||
}
|
||||
console.log(output);
|
||||
} catch (error) {
|
||||
if (!error.message.includes('spawnSync /bin/sh E2BIG')) {
|
||||
console.log(`run task before error: `, error);
|
||||
}
|
||||
}
|
||||
|
||||
if (envParam && numParam) {
|
||||
const array = (process.env[envParam] || '').split('&');
|
||||
const runArr = expandRange(numParam, array.length);
|
||||
const arrayRun = runArr.map((i) => array[i - 1]);
|
||||
const envStr = arrayRun.join('&');
|
||||
process.env[envParam] = envStr;
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
run();
|
||||
|
||||
const { sendNotify } = require('./notify.js');
|
||||
global.QLAPI = {
|
||||
notify: sendNotify,
|
||||
};
|
||||
} catch (error) {
|
||||
console.log(`run builtin code error: `, error, '\n');
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
import os
|
||||
import re
|
||||
import subprocess
|
||||
import json
|
||||
import builtins
|
||||
import sys
|
||||
import env
|
||||
|
||||
|
||||
def try_parse_int(value):
|
||||
try:
|
||||
return int(value)
|
||||
except ValueError:
|
||||
return None
|
||||
|
||||
|
||||
def expand_range(range_str, max_value):
|
||||
temp_range_str = (
|
||||
range_str.strip()
|
||||
.replace("-max", f"-{max_value}")
|
||||
.replace("max-", f"{max_value}-")
|
||||
)
|
||||
|
||||
result = []
|
||||
for part in temp_range_str.split(" "):
|
||||
range_match = re.match(r"^(\d+)([-~_])(\d+)$", part)
|
||||
if range_match:
|
||||
start, _, end = map(try_parse_int, range_match.groups())
|
||||
step = 1 if start < end else -1
|
||||
result.extend(range(start, end + step, step))
|
||||
else:
|
||||
result.append(int(part))
|
||||
|
||||
return result
|
||||
|
||||
|
||||
def run():
|
||||
import task_before
|
||||
|
||||
try:
|
||||
split_str = "__sitecustomize__"
|
||||
file_name = sys.argv[0].replace(f"{os.getenv('dir_scripts')}/", "")
|
||||
command = f'bash -c "source {os.getenv("file_task_before")} {file_name}'
|
||||
task_before = os.getenv("task_before")
|
||||
|
||||
if task_before:
|
||||
escape_task_before = task_before.replace('"', '\\"')
|
||||
command += f" && echo -e '执行前置命令\n' && eval '{escape_task_before}' && echo -e '\n执行前置命令结束\n'"
|
||||
|
||||
python_command = "PYTHONPATH= python3 -c 'import os, json; print(json.dumps(dict(os.environ)))'"
|
||||
command += f" && echo -e '{split_str}' && {python_command}\""
|
||||
|
||||
res = subprocess.check_output(command, shell=True, encoding="utf-8")
|
||||
output, env_str = res.split(split_str)
|
||||
|
||||
env_json = json.loads(env_str.strip())
|
||||
|
||||
for key, value in env_json.items():
|
||||
os.environ[key] = value
|
||||
|
||||
print(output)
|
||||
|
||||
except subprocess.CalledProcessError as error:
|
||||
print(f"run task before error: {error}")
|
||||
except OSError as error:
|
||||
error_message = str(error)
|
||||
if "Argument list too long" not in error_message:
|
||||
print(f"run task before error: {error}")
|
||||
except Exception as error:
|
||||
print(f"run task before error: {error}")
|
||||
|
||||
env_param = os.getenv("envParam")
|
||||
num_param = os.getenv("numParam")
|
||||
|
||||
if env_param and num_param:
|
||||
array = (os.getenv(env_param) or "").split("&")
|
||||
run_arr = expand_range(num_param, len(array))
|
||||
array_run = [array[i - 1] for i in run_arr if i - 1 < len(array) and i > 0]
|
||||
env_str = "&".join(array_run)
|
||||
os.environ[env_param] = env_str
|
||||
|
||||
|
||||
try:
|
||||
run()
|
||||
|
||||
from notify import send
|
||||
|
||||
class BaseApi:
|
||||
def notify(self, *args, **kwargs):
|
||||
return send(*args, **kwargs)
|
||||
|
||||
QLAPI = BaseApi()
|
||||
builtins.QLAPI = QLAPI
|
||||
except Exception as error:
|
||||
print(f"run builtin code error: {error}\n")
|
||||
+1
-1
@@ -11,7 +11,7 @@ echo -e "提交master代码"
|
||||
git push
|
||||
|
||||
echo -e "更新cdn文件"
|
||||
tsx sample/tool.ts
|
||||
ts-node-transpile-only sample/tool.ts
|
||||
|
||||
string=$(cat version.yaml | grep "version" | egrep "[^ ]*" -o | egrep "\d\.*")
|
||||
version="v$string"
|
||||
|
||||
+85
-62
@@ -1,53 +1,57 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
## 目录
|
||||
dir_root=$QL_DIR
|
||||
dir_tmp=$dir_root/.tmp
|
||||
dir_data=$dir_root/data
|
||||
export dir_root=$QL_DIR
|
||||
export dir_tmp=$dir_root/.tmp
|
||||
export dir_data=$dir_root/data
|
||||
|
||||
if [[ $QL_DATA_DIR ]]; then
|
||||
dir_data="${QL_DATA_DIR%/}"
|
||||
export dir_data="${QL_DATA_DIR%/}"
|
||||
fi
|
||||
|
||||
dir_shell=$dir_root/shell
|
||||
dir_sample=$dir_root/sample
|
||||
dir_static=$dir_root/static
|
||||
dir_config=$dir_data/config
|
||||
dir_scripts=$dir_data/scripts
|
||||
dir_repo=$dir_data/repo
|
||||
dir_raw=$dir_data/raw
|
||||
dir_log=$dir_data/log
|
||||
dir_db=$dir_data/db
|
||||
dir_dep=$dir_data/deps
|
||||
dir_list_tmp=$dir_log/.tmp
|
||||
dir_update_log=$dir_log/update
|
||||
ql_static_repo=$dir_repo/static
|
||||
export dir_shell=$dir_root/shell
|
||||
export dir_preload=$dir_shell/preload
|
||||
export dir_sample=$dir_root/sample
|
||||
export dir_static=$dir_root/static
|
||||
export dir_config=$dir_data/config
|
||||
export dir_scripts=$dir_data/scripts
|
||||
export dir_repo=$dir_data/repo
|
||||
export dir_raw=$dir_data/raw
|
||||
export dir_log=$dir_data/log
|
||||
export dir_db=$dir_data/db
|
||||
export dir_dep=$dir_data/deps
|
||||
export dir_list_tmp=$dir_log/.tmp
|
||||
export dir_update_log=$dir_log/update
|
||||
export ql_static_repo=$dir_repo/static
|
||||
|
||||
## 文件
|
||||
file_config_sample=$dir_sample/config.sample.sh
|
||||
file_env=$dir_config/env.sh
|
||||
file_sharecode=$dir_config/sharecode.sh
|
||||
file_config_user=$dir_config/config.sh
|
||||
file_auth_sample=$dir_sample/auth.sample.json
|
||||
file_auth_user=$dir_config/auth.json
|
||||
file_auth_token=$dir_config/token.json
|
||||
file_extra_shell=$dir_config/extra.sh
|
||||
file_task_before=$dir_config/task_before.sh
|
||||
file_task_after=$dir_config/task_after.sh
|
||||
file_task_sample=$dir_sample/task.sample.sh
|
||||
file_extra_sample=$dir_sample/extra.sample.sh
|
||||
file_notify_js_sample=$dir_sample/notify.js
|
||||
file_notify_py_sample=$dir_sample/notify.py
|
||||
file_test_js_sample=$dir_sample/ql_sample.js
|
||||
file_test_py_sample=$dir_sample/ql_sample.py
|
||||
file_notify_py=$dir_scripts/notify.py
|
||||
file_notify_js=$dir_scripts/sendNotify.js
|
||||
file_test_js=$dir_scripts/ql_sample.js
|
||||
file_test_py=$dir_scripts/ql_sample.py
|
||||
nginx_app_conf=$dir_root/docker/front.conf
|
||||
nginx_conf=$dir_root/docker/nginx.conf
|
||||
dep_notify_py=$dir_dep/notify.py
|
||||
dep_notify_js=$dir_dep/sendNotify.js
|
||||
export file_config_sample=$dir_sample/config.sample.sh
|
||||
export file_env=$dir_preload/env.sh
|
||||
export file_preload_js=$dir_preload/sitecustomize.js
|
||||
export file_sharecode=$dir_config/sharecode.sh
|
||||
export file_config_user=$dir_config/config.sh
|
||||
export file_auth_sample=$dir_sample/auth.sample.json
|
||||
export file_auth_user=$dir_config/auth.json
|
||||
export file_auth_token=$dir_config/token.json
|
||||
export file_extra_shell=$dir_config/extra.sh
|
||||
export file_task_before=$dir_config/task_before.sh
|
||||
export file_task_before_js=$dir_config/task_before.js
|
||||
export file_task_before_py=$dir_config/task_before.py
|
||||
export file_task_after=$dir_config/task_after.sh
|
||||
export file_task_sample=$dir_sample/task.sample.sh
|
||||
export file_extra_sample=$dir_sample/extra.sample.sh
|
||||
export file_notify_js_sample=$dir_sample/notify.js
|
||||
export file_notify_py_sample=$dir_sample/notify.py
|
||||
export file_test_js_sample=$dir_sample/ql_sample.js
|
||||
export file_test_py_sample=$dir_sample/ql_sample.py
|
||||
export file_notify_py=$dir_scripts/notify.py
|
||||
export file_notify_js=$dir_scripts/sendNotify.js
|
||||
export file_test_js=$dir_scripts/ql_sample.js
|
||||
export file_test_py=$dir_scripts/ql_sample.py
|
||||
export nginx_app_conf=$dir_root/docker/front.conf
|
||||
export nginx_conf=$dir_root/docker/nginx.conf
|
||||
export dep_notify_py=$dir_dep/notify.py
|
||||
export dep_notify_js=$dir_dep/sendNotify.js
|
||||
|
||||
## 清单文件
|
||||
list_crontab_user=$dir_config/crontab.list
|
||||
@@ -59,11 +63,11 @@ list_own_drop=$dir_list_tmp/own_drop.list
|
||||
|
||||
## 软连接及其原始文件对应关系
|
||||
link_name=(
|
||||
# task
|
||||
task
|
||||
ql
|
||||
)
|
||||
original_name=(
|
||||
# task.sh
|
||||
task.sh
|
||||
update.sh
|
||||
)
|
||||
|
||||
@@ -74,9 +78,6 @@ init_env() {
|
||||
|
||||
import_config() {
|
||||
[[ -f $file_config_user ]] && . $file_config_user
|
||||
if [[ $LOAD_ENV != 'false' ]] && [[ -f $file_env ]]; then
|
||||
. $file_env
|
||||
fi
|
||||
|
||||
ql_base_url=${QlBaseUrl:-"/"}
|
||||
ql_port=${QlPort:-"5700"}
|
||||
@@ -90,10 +91,6 @@ import_config() {
|
||||
else
|
||||
default_cron="$(random_range 0 59) $(random_range 0 23) * * *"
|
||||
fi
|
||||
|
||||
cpu_warn=${CpuWarn}
|
||||
mem_warn=${MemoryWarn}
|
||||
disk_warn=${DiskWarn}
|
||||
}
|
||||
|
||||
set_proxy() {
|
||||
@@ -136,6 +133,28 @@ gen_random_num() {
|
||||
echo $((${RANDOM} % $divi))
|
||||
}
|
||||
|
||||
define_cmd() {
|
||||
local cmd_prefix cmd_suffix
|
||||
if type task &>/dev/null; then
|
||||
cmd_suffix=""
|
||||
if [[ -f "$dir_shell/task.sh" ]]; then
|
||||
cmd_prefix=""
|
||||
else
|
||||
cmd_prefix="bash "
|
||||
fi
|
||||
else
|
||||
cmd_suffix=".sh"
|
||||
if [[ -f "$dir_shell/task.sh" ]]; then
|
||||
cmd_prefix="$dir_shell/"
|
||||
else
|
||||
cmd_prefix="bash $dir_shell/"
|
||||
fi
|
||||
fi
|
||||
for ((i = 0; i < ${#link_name[*]}; i++)); do
|
||||
export cmd_${link_name[i]}="${cmd_prefix}${link_name[i]}${cmd_suffix}"
|
||||
done
|
||||
}
|
||||
|
||||
fix_config() {
|
||||
make_dir $dir_tmp
|
||||
make_dir $dir_static
|
||||
@@ -156,12 +175,6 @@ fix_config() {
|
||||
echo
|
||||
fi
|
||||
|
||||
if [[ ! -f $file_env ]]; then
|
||||
echo -e "检测到config配置目录下不存在env.sh,创建一个空文件用于初始化...\n"
|
||||
touch $file_env
|
||||
echo
|
||||
fi
|
||||
|
||||
if [[ ! -f $file_task_before ]]; then
|
||||
echo -e "复制一份 $file_task_sample 为 $file_task_before\n"
|
||||
cp -fv $file_task_sample $file_task_before
|
||||
@@ -417,19 +430,30 @@ init_nginx() {
|
||||
sed -i "s,IPV4_CONFIG,${ipv4Str},g" /etc/nginx/conf.d/front.conf
|
||||
}
|
||||
|
||||
get_env_array() {
|
||||
exported_variables=()
|
||||
while IFS= read -r line; do
|
||||
exported_variables+=("$line")
|
||||
done < <(grep '^export ' $file_env | awk '{print $2}' | cut -d= -f1)
|
||||
}
|
||||
|
||||
clear_env() {
|
||||
for var in "${exported_variables[@]}"; do
|
||||
unset "$var"
|
||||
done
|
||||
}
|
||||
|
||||
handle_task_start() {
|
||||
[[ $ID ]] && update_cron "\"$ID\"" "0" "$$" "$log_path" "$begin_timestamp"
|
||||
echo -e "## 开始执行... $begin_time\n"
|
||||
}
|
||||
|
||||
run_task_before() {
|
||||
[[ $is_macos -eq 0 ]] && check_server
|
||||
|
||||
. $file_task_before "$@"
|
||||
|
||||
if [[ $task_before ]]; then
|
||||
echo -e "执行前置命令\n"
|
||||
eval "$task_before"
|
||||
eval "$task_before" "$@"
|
||||
echo -e "\n执行前置命令结束\n"
|
||||
fi
|
||||
}
|
||||
@@ -439,7 +463,7 @@ run_task_after() {
|
||||
|
||||
if [[ $task_after ]]; then
|
||||
echo -e "\n执行后置命令\n"
|
||||
eval "$task_after"
|
||||
eval "$task_after" "$@"
|
||||
echo -e "\n执行后置命令结束"
|
||||
fi
|
||||
}
|
||||
@@ -459,5 +483,4 @@ handle_task_end() {
|
||||
init_env
|
||||
detect_termux
|
||||
detect_macos
|
||||
|
||||
import_config $1
|
||||
define_cmd
|
||||
|
||||
+3
-6
@@ -19,13 +19,9 @@ define_program() {
|
||||
elif [[ $file_param == *.py ]] || [[ $file_param == *.pyc ]]; then
|
||||
which_program="python3"
|
||||
elif [[ $file_param == *.sh ]]; then
|
||||
which_program="bash"
|
||||
which_program="."
|
||||
elif [[ $file_param == *.ts ]]; then
|
||||
if ! type tsx &>/dev/null; then
|
||||
which_program="ts-node-transpile-only"
|
||||
else
|
||||
which_program="tsx"
|
||||
fi
|
||||
which_program="ts-node-transpile-only"
|
||||
else
|
||||
which_program=""
|
||||
fi
|
||||
@@ -117,6 +113,7 @@ init_begin_time() {
|
||||
begin_timestamp=$(format_timestamp "$time_format" "$time")
|
||||
}
|
||||
|
||||
import_config "$@"
|
||||
while getopts ":lm:" opt; do
|
||||
case $opt in
|
||||
l)
|
||||
|
||||
+2
-1
@@ -1,9 +1,9 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
dir_shell=$QL_DIR/shell
|
||||
. $dir_shell/env.sh
|
||||
. $dir_shell/share.sh
|
||||
. $dir_shell/api.sh
|
||||
. $dir_shell/env.sh
|
||||
|
||||
send_mark=$dir_shell/send_mark
|
||||
|
||||
@@ -563,6 +563,7 @@ main() {
|
||||
fi
|
||||
}
|
||||
|
||||
import_config "$@"
|
||||
main "$@"
|
||||
|
||||
exit 0
|
||||
|
||||
@@ -349,7 +349,7 @@
|
||||
"推送到个人QQ: http://127.0.0.1/send_private_msg,群:http://127.0.0.1/send_group_msg": "Push to personal QQ: http://127.0.0.1/send_private_msg, group: http://127.0.0.1/send_group_msg",
|
||||
"访问密钥": "Access Key",
|
||||
"如果GOBOT_URL设置 /send_private_msg 则需要填入 user_id=个人QQ 相反如果是 /send_group_msg 则需要填入 group_id=QQ群": "If GOBOT_URL is set to /send_private_msg, enter user_id=personal QQ; if set to /send_group_msg, enter group_id=QQ group",
|
||||
"Server酱SENDKEY": "ServerChan SENDKEY",
|
||||
"Server酱SENDKEY": "ServerChan SENDKEY, https://sct.ftqq.com/r/13363",
|
||||
"PushDeer的Key,https://github.com/easychen/pushdeer": "PushDeer Key, https://github.com/easychen/pushdeer",
|
||||
"PushDeer的自架API endpoint,默认是 https://api2.pushdeer.com/message/push": "PushDeer's self-hosted API endpoint, default is https://api2.pushdeer.com/message/push",
|
||||
"Bark的信息IP/设备码,例如:https://api.day.app/XXXXXXXX": "Bark information IP/device code, e.g., https://api.day.app/XXXXXXXX",
|
||||
|
||||
@@ -349,7 +349,7 @@
|
||||
"推送到个人QQ: http://127.0.0.1/send_private_msg,群:http://127.0.0.1/send_group_msg": "推送到个人QQ: http://127.0.0.1/send_private_msg,群:http://127.0.0.1/send_group_msg",
|
||||
"访问密钥": "访问密钥",
|
||||
"如果GOBOT_URL设置 /send_private_msg 则需要填入 user_id=个人QQ 相反如果是 /send_group_msg 则需要填入 group_id=QQ群": "如果GOBOT_URL设置 /send_private_msg 则需要填入 user_id=个人QQ 相反如果是 /send_group_msg 则需要填入 group_id=QQ群",
|
||||
"Server酱SENDKEY": "Server酱SENDKEY",
|
||||
"Server酱SENDKEY": "Server 酱 SENDKEY,https://sct.ftqq.com/r/13363",
|
||||
"PushDeer的Key,https://github.com/easychen/pushdeer": "PushDeer的Key,https://github.com/easychen/pushdeer",
|
||||
"PushDeer的自架API endpoint,默认是 https://api2.pushdeer.com/message/push": "PushDeer的自架API endpoint,默认是 https://api2.pushdeer.com/message/push",
|
||||
"Bark的信息IP/设备码,例如:https://api.day.app/XXXXXXXX": "Bark的信息IP/设备码,例如:https://api.day.app/XXXXXXXX",
|
||||
|
||||
+7
-7
@@ -1,8 +1,8 @@
|
||||
version: 2.17.7
|
||||
changeLogLink: https://t.me/jiao_long/408
|
||||
publishTime: 2024-06-30 16:00
|
||||
version: 2.17.9
|
||||
changeLogLink: https://t.me/jiao_long/420
|
||||
publishTime: 2024-07-23 23:00
|
||||
changeLog: |
|
||||
1. 修复更新任务状态错误
|
||||
2. 修复查询系统 health 状态错误
|
||||
3. 修复更新 linux 镜像源错误
|
||||
4. npm 包支持 alpine 和 debian、ubuntu,修复 linux 依赖安装命令
|
||||
1. Javascript 和 Python 增加内置API QLAPI.notify
|
||||
2. 配置管理增加 task_before.js 和 task_before.py 文件,在执行任务前执行,避免环境变量过大报错
|
||||
3. 修复执行任务 JavaScript 和 Python 任务前未执行 task_before.sh
|
||||
|
||||
Reference in New Issue
Block a user