1 #!/usr/bin/env node
2
3 const fs = require("fs");
4 const path = require("path");
5
6 const [outputPath, version, product = "smb"] = process.argv.slice(2);
7
8 if (!outputPath || !version) {
9 throw new Error("Usage: render-main-package.cjs <output-path> <version> [product]");
10 }
11
12 // The platform binary packages the wrapper resolves at runtime. Kept in
13 // lockstep with the release build matrix and the `optionalDependencies` below.
14 const platformSuffixes = [
15 "darwin-arm64",
16 "darwin-x64",
17 "linux-arm64",
18 "linux-x64",
19 "windows-arm64",
20 "windows-x64",
21 ];
22
23 const products = {
24 smb: {
25 name: "@smbcloud/cli",
26 // Ownership proof for the MCP Registry: must match `name` in ../../server.json.
27 mcpName: "io.github.smbcloudXYZ/smbcloud-cli",
28 binName: "smb",
29 platformPrefix: "cli",
30 description: "A CLI for accessing the smbCloud platform.",
31 keywords: [
32 "smbcloud",
33 "cli",
34 "smb",
35 "pndk",
36 "smbcloud-cli",
37 "cloud",
38 "smbcloud",
39 "developer",
40 "tools",
41 "web3",
42 "web3js",
43 "web3.js",
44 "web3js",
45 "bitcoin",
46 "btc",
47 "ethereum",
48 "solana",
49 "eth",
50 "sol",
51 "blockchain",
52 "smart-contracts",
53 "dapps",
54 "dapp",
55 "dapp-tools",
56 "dapp-tool",
57 "dapp-toolkit",
58 "dapp-toolkit-cli",
59 ],
60 },
61 xcrs: {
62 name: "@smbcloud/xcrs",
63 // Ownership proof for the MCP Registry: must match `name` in ../../server-xcrs.json.
64 mcpName: "io.github.smbcloudXYZ/xcrs",
65 binName: "xcrs",
66 platformPrefix: "xcrs",
67 description: "Cross-platform mobile and TV app automation over MCP.",
68 keywords: [
69 "xcrs",
70 "mcp",
71 "model-context-protocol",
72 "mobile",
73 "ios",
74 "android",
75 "tv",
76 "apple-tv",
77 "android-tv",
78 "automation",
79 "app-testing",
80 "device",
81 "simulator",
82 "adb",
83 "cli",
84 ],
85 },
86 };
87
88 const selected = products[product];
89
90 if (!selected) {
91 throw new Error(
92 `Unknown product "${product}". Expected one of: ${Object.keys(products).join(", ")}.`
93 );
94 }
95
96 const optionalDependencies = {};
97 for (const suffix of platformSuffixes) {
98 optionalDependencies[`@smbcloud/${selected.platformPrefix}-${suffix}`] = version;
99 }
100
101 const packageJson = {
102 name: selected.name,
103 version,
104 mcpName: selected.mcpName,
105 keywords: selected.keywords,
106 bin: {
107 [selected.binName]: "lib/index.js",
108 },
109 files: ["lib", "README.md"],
110 description: selected.description,
111 license: "Apache-2.0",
112 repository: {
113 type: "git",
114 url: "git+https://github.com/smbcloudXYZ/smbcloud-cli.git",
115 },
116 scripts: {
117 typecheck: "tsc --noEmit",
118 lint: "eslint .",
119 "lint:fix": "eslint . --fix",
120 build: "tsc",
121 dev: "npm run build && node lib/index.js",
122 },
123 devDependencies: {
124 "@types/node": "^18.15.11",
125 "@typescript-eslint/eslint-plugin": "^5.48.0",
126 "@typescript-eslint/parser": "^5.48.0",
127 eslint: "^8.31.0",
128 typescript: "^5.0.0",
129 },
130 optionalDependencies,
131 };
132
133 fs.writeFileSync(path.resolve(outputPath), `${JSON.stringify(packageJson, null, 2)}
134 `);