-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.js
More file actions
64 lines (51 loc) · 2.26 KB
/
deploy.js
File metadata and controls
64 lines (51 loc) · 2.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
const { execSync } = require("child_process");
const fs = require("fs");
const versionType = process.argv[2]; // 'patch', 'minor', 'major', or undefined
console.log("🚀 Deploying @return-0/mcp-server to npm...\n");
// Get current version
const packageJson = JSON.parse(fs.readFileSync("package.json", "utf8"));
const currentVersion = packageJson.version;
console.log(`Current version: ${currentVersion}\n`);
try {
// Step 1: Run tests
console.log("🧪 Step 1: Running tests...");
execSync("npm test", { stdio: "inherit" });
console.log("✓ Tests passed\n");
// Step 2: Clean dist folder
console.log("🧹 Step 2: Cleaning dist folder...");
if (fs.existsSync("dist")) {
fs.rmSync("dist", { recursive: true, force: true });
console.log("✓ Dist folder removed\n");
}
// Step 3: Build
console.log("📦 Step 3: Building package...");
execSync("npm run build", { stdio: "inherit" });
console.log("✓ Build complete\n");
// Step 4: Update version
if (versionType) {
console.log(`📝 Step 4: Bumping ${versionType} version...`);
execSync(`npm version ${versionType} --no-git-tag-version`, { stdio: "inherit" });
// Read updated version
const updatedPackageJson = JSON.parse(fs.readFileSync("package.json", "utf8"));
const newVersion = updatedPackageJson.version;
console.log(`✓ Version updated: ${currentVersion} → ${newVersion}\n`);
} else {
console.log("⚠️ No version type specified. Publishing current version.\n");
console.log(" Usage: npm run deploy -- [patch|minor|major]");
console.log(" Example: npm run deploy -- patch\n");
}
// Step 5: Publish
console.log("📤 Step 5: Publishing to npm...");
execSync("npm publish --access public", { stdio: "inherit" });
console.log("✓ Published successfully\n");
// Get final version
const finalPackageJson = JSON.parse(fs.readFileSync("package.json", "utf8"));
const finalVersion = finalPackageJson.version;
console.log("\n✅ Deployment complete!");
console.log(`📦 Package: @return-0/mcp-server@${finalVersion}`);
console.log(`🌐 Homepage: https://getreturn0.com`);
console.log(`📥 Install: npm install -g @return-0/mcp-server\n`);
} catch (error) {
console.error("\n❌ Deployment failed:", error.message);
process.exit(1);
}