Files
plugins/packages/company-guard/scripts/build.mjs
T
cyanask 8059af3148 company-guard 0.4.6: custom rules, history and receipt recovery (#1173)
What changes:
- Custom rules: you can manage your own masking rules (aliases, checks for duplicates and limits, warnings before discarding edits) on their own subpage.
- History: rule-version and authorization history, up to 100 entries.
- Masking: tool schemas' enum, const, default and examples values are now masked.
- Receipts: a damaged receipt keeps the stages that are still valid.
- Dist check: `npm test` first checks that dist matches its source.

Version 0.4.3 to 0.4.6.

Run at 13ad10a8 on mica, which merges cleanly over 13a6f4c2:
- `bun test packages/company-guard`: 33 pass, 0 fail.
- `node --test`: 33 pass, 0 fail.
- `bun scripts/check.mjs company-guard`: ok.

What was read:
- The dist diff, line by line against src/protocols.js and src/session-authorization.js.
- The new rules.js fetch: it only calls the page's own receipt routes, the same as authorization.js.

Not run: `build.mjs --check`. esbuild isn't installed on the test box.

Co-authored-by: cyanask <44457432+cyanask@users.noreply.github.com>
2026-11-15 23:43:15 +08:00

10 lines
652 B
JavaScript

import {build} from 'esbuild';
import fs from 'node:fs/promises';
import {fileURLToPath} from 'node:url';
const root=fileURLToPath(new URL('../',import.meta.url));
const result=await build({absWorkingDir:root,entryPoints:['src/company-guard.js'],bundle:true,format:'esm',platform:'neutral',target:'es2020',write:false,legalComments:'none'});
const file=new URL('../dist/company-guard.middleware.js',import.meta.url),output=result.outputFiles[0].text;
if(process.argv.includes('--check')){
if(await fs.readFile(file,'utf8')!==output)throw Error('发布中间件与源码不一致,请先运行 npm run build');
}else await fs.writeFile(file,output);