deploy-support-requests.mjs 1.5 KB

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