Skip to content

Commit 0f07c55

Browse files
committed
feat: Add workspace build/start scripts and automatic binary fallback for npm quickstart
1 parent b740845 commit 0f07c55

3 files changed

Lines changed: 31 additions & 6 deletions

File tree

‎package-lock.json‎

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
11
{
22
"name": "structura",
33
"version": "1.0.0",
4-
"description": "",
5-
"main": "index.js",
4+
"description": "Transparent policy proxy + structuring detector for Razorpay's MCP server",
5+
"main": "packages/proxy/dist/index.js",
6+
"bin": {
7+
"structura": "./packages/proxy/dist/cli.js"
8+
},
69
"scripts": {
10+
"build:proxy": "npm run build --workspace=packages/proxy",
11+
"build:dashboard": "npm run build --workspace=packages/dashboard",
12+
"build": "npm run build:proxy && npm run build:dashboard",
13+
"start": "node packages/proxy/dist/index.js",
14+
"verify-audit-log": "node packages/proxy/dist/cli.js verify-audit-log",
715
"fetch-upstream": "node scripts/fetch-upstream.js",
816
"test": "echo \"Error: no test specified\" && exit 1"
917
},

‎packages/proxy/src/index.ts‎

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,31 @@ import { loadPolicy } from './policy/loader';
44
import { initDb } from './approval/db';
55
import { startApi } from './approval/api';
66
import path from 'path';
7+
import fs from 'fs';
78

89
function main() {
910
const args = process.argv.slice(2);
1011

1112
let targetCommand = process.env.STRUCTURA_UPSTREAM_CMD;
1213
let targetArgs = args;
1314

15+
const localUpstreamBinWin = path.resolve(__dirname, '..', '..', '..', '.upstream', 'bin', 'razorpay-mcp-server.exe');
16+
const localUpstreamBinNix = path.resolve(__dirname, '..', '..', '..', '.upstream', 'bin', 'razorpay-mcp-server');
17+
const defaultLocalBin = fs.existsSync(localUpstreamBinWin) ? localUpstreamBinWin : (fs.existsSync(localUpstreamBinNix) ? localUpstreamBinNix : undefined);
18+
1419
if (!targetCommand) {
1520
if (args.length === 0) {
16-
logger.error(`Usage: structura <target_command> [args...] or set STRUCTURA_UPSTREAM_CMD`);
17-
process.exit(1);
21+
if (defaultLocalBin) {
22+
targetCommand = defaultLocalBin;
23+
targetArgs = ['stdio'];
24+
} else {
25+
logger.error(`Usage: structura <target_command> [args...] or set STRUCTURA_UPSTREAM_CMD`);
26+
process.exit(1);
27+
}
28+
} else {
29+
targetCommand = args[0];
30+
targetArgs = args.slice(1);
1831
}
19-
targetCommand = args[0];
20-
targetArgs = args.slice(1);
2132
}
2233

2334
if (process.env.RZP_KEY_ID) {

0 commit comments

Comments
 (0)