| 1234567891011121314151617181920212223 |
- #!/usr/bin/env node
- // Patch the actual online baseline, never deploy unrelated local gateway edits.
- import {readFileSync} from 'node:fs';
- import {resolve} from 'node:path';
- import {pathToFileURL} from 'node:url';
- const helper=readFileSync(new URL('./cloud/support-requests.js',import.meta.url),'utf8').trim();
- const dispatch=" if(operation==='ops/support-requests/list') return response.json({success:true,data:await supportRequestsPage(context,input)});";
- const anchor=" if(operation==='ops/live/versions')";
- export function patchSupportRequests(code){
- if(code.includes('ops/support-requests/list')||code.includes('async function supportRequestsPage(')){
- if(code.includes(dispatch)&&code.includes(helper))return code;
- throw Error('线上已有不同版本的反馈入口,请先人工核对');
- }
- if(code.split(anchor).length!==2)throw Error('线上网关分发入口与预期不一致,停止发布');
- const next=code.replace(anchor,dispatch+'\n'+anchor)+'\n'+helper+'\n';
- if(new Function(next+'\nreturn typeof handler;')()!=='function')throw Error('网关语法校验失败');
- return next;
- }
- // The read-only board now depends on the reply ledger: deploy the complete scoped workflow.
- if(process.argv[1]&&import.meta.url===pathToFileURL(resolve(process.argv[1])).href) {
- const {deployWorkflow}=await import('./deploy-support-workflow.mjs');
- await deployWorkflow(process.argv.includes('--commit')).catch(e=>{console.error(e.message);process.exitCode=1;});
- }
|