publish.js•3.51 kB
#!/usr/bin/env node
/**
* Publish script for Atlassian MCP Server
* This script helps publish the server to npm and prepare it for the MCP marketplace
*/
import fs from 'fs';
import path from 'path';
import { fileURLToPath } from 'url';
import { execSync } from 'child_process';
import readline from 'readline';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
// Check if package.json exists
const packageJsonPath = path.join(__dirname, 'package.json');
if (!fs.existsSync(packageJsonPath)) {
console.error('Error: package.json not found');
process.exit(1);
}
// Check if mcp-metadata.json exists
const metadataPath = path.join(__dirname, 'mcp-metadata.json');
if (!fs.existsSync(metadataPath)) {
console.error('Error: mcp-metadata.json not found');
process.exit(1);
}
// Load package.json and metadata
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
const metadata = JSON.parse(fs.readFileSync(metadataPath, 'utf8'));
console.log('Atlassian MCP Server Publisher');
console.log('==============================');
console.log(`Current version: ${packageJson.version}`);
console.log(`Name: ${metadata.name}`);
console.log(`Description: ${metadata.description}`);
console.log('');
// Ensure versions match
if (packageJson.version !== metadata.version) {
console.log(`Warning: Version mismatch between package.json (${packageJson.version}) and mcp-metadata.json (${metadata.version})`);
rl.question('Do you want to update mcp-metadata.json to match package.json? (y/n): ', (answer) => {
if (answer.toLowerCase() === 'y') {
metadata.version = packageJson.version;
fs.writeFileSync(metadataPath, JSON.stringify(metadata, null, 2));
console.log('Updated mcp-metadata.json version');
}
continuePublish();
});
} else {
continuePublish();
}
function continuePublish() {
rl.question('Do you want to publish to npm? (y/n): ', (answer) => {
if (answer.toLowerCase() === 'y') {
try {
console.log('Building project...');
execSync('npm run build', { stdio: 'inherit' });
console.log('Publishing to npm...');
execSync('npm publish', { stdio: 'inherit' });
console.log('\nSuccessfully published to npm!');
} catch (error) {
console.error('Error publishing to npm:', error);
}
}
rl.question('Do you want to prepare a package for manual distribution? (y/n): ', (answer) => {
if (answer.toLowerCase() === 'y') {
try {
console.log('Creating tarball...');
execSync('npm pack', { stdio: 'inherit' });
console.log('\nTarball created successfully!');
console.log(`File: ${packageJson.name}-${packageJson.version}.tgz`);
} catch (error) {
console.error('Error creating tarball:', error);
}
}
console.log('\nTo submit to the Cline MCP Marketplace:');
console.log('1. Ensure your code is in a public GitHub repository');
console.log('2. Update the repository URL in mcp-metadata.json');
console.log('3. Add an icon.png file in the assets directory');
console.log('4. Submit your repository URL to the Cline MCP Marketplace team');
rl.close();
});
});
}
// Handle exit
rl.on('close', () => {
console.log('\nPublish process complete!');
process.exit(0);
});