UNPKG

@cursedfaction3333/cursed-faction-vault-ecosystem

Version:

AI-powered NFT vault ecosystem with Magic Eden & Zora integration, cross-chain bridging, and advanced security features

199 lines (169 loc) • 6.43 kB
#!/usr/bin/env node /** * šŸ“¦ PACKAGE PUBLISHER * * Automated publishing script for Cursed Faction Vault Ecosystem * Publishes to npm profile: cursedfaction3333 */ const { execSync } = require('child_process'); const fs = require('fs'); class PackagePublisher { constructor() { this.packageName = '@cursedfaction3333/cursed-faction-vault-ecosystem'; this.version = '1.0.0'; this.author = 'cursedfaction3333'; this.npmProfile = 'https://www.npmjs.com/~cursedfaction3333'; } /** * Check if user is logged into npm */ checkNPMLogin() { try { const whoami = execSync('npm whoami', { encoding: 'utf8' }).trim(); console.log(`āœ… Logged in as: ${whoami}`); return whoami === this.author; } catch (error) { console.log('āŒ Not logged into npm'); return false; } } /** * Validate package.json */ validatePackage() { console.log("šŸ“‹ Validating package..."); if (!fs.existsSync('package.json')) { throw new Error('package.json not found'); } const packageJson = JSON.parse(fs.readFileSync('package.json', 'utf8')); if (packageJson.name !== this.packageName) { throw new Error(`Package name mismatch: expected ${this.packageName}, got ${packageJson.name}`); } if (packageJson.version !== this.version) { throw new Error(`Version mismatch: expected ${this.version}, got ${packageJson.version}`); } if (packageJson.author !== this.author) { throw new Error(`Author mismatch: expected ${this.author}, got ${packageJson.author}`); } console.log("āœ… Package validation passed"); return true; } /** * Run dry-run to check package contents */ runDryRun() { console.log("šŸ” Running dry-run..."); try { const output = execSync('npm pack --dry-run', { encoding: 'utf8' }); console.log("āœ… Dry-run successful"); console.log("šŸ“¦ Package contents validated"); return true; } catch (error) { console.error("āŒ Dry-run failed:", error.message); return false; } } /** * Publish the package */ publishPackage() { console.log("šŸš€ Publishing package to npm..."); try { const output = execSync('npm publish --access public', { encoding: 'utf8' }); console.log("āœ… Package published successfully!"); console.log(`šŸ“¦ Package: ${this.packageName}@${this.version}`); console.log(`šŸ”— NPM URL: https://www.npmjs.com/package/${this.packageName}`); console.log(`šŸ‘¤ Profile: ${this.npmProfile}`); return true; } catch (error) { console.error("āŒ Publishing failed:", error.message); return false; } } /** * Show installation instructions */ showInstallationInstructions() { console.log("\nšŸ“¦ INSTALLATION INSTRUCTIONS"); console.log("============================="); console.log("Users can install your package with:"); console.log(`npm install ${this.packageName}`); console.log(""); console.log("Or with yarn:"); console.log(`yarn add ${this.packageName}`); console.log(""); console.log("Usage:"); console.log("```javascript"); console.log(`const { CursedFactionEcosystem } = require('${this.packageName}');`); console.log(""); console.log("const ecosystem = new CursedFactionEcosystem({"); console.log(" network: 'baseSepolia',"); console.log(" privateKey: process.env.PRIVATE_KEY"); console.log("});"); console.log(""); console.log("await ecosystem.initialize();"); console.log("```"); } /** * Show success summary */ showSuccessSummary() { console.log("\nšŸŽ‰ PUBLISHING COMPLETE!"); console.log("========================"); console.log(`āœ… Package: ${this.packageName}@${this.version}`); console.log(`āœ… Author: ${this.author}`); console.log(`āœ… NPM Profile: ${this.npmProfile}`); console.log(`āœ… Package URL: https://www.npmjs.com/package/${this.packageName}`); console.log(""); console.log("šŸŽÆ Your package is now live on npm!"); console.log("šŸ“Š Check your profile for download statistics"); console.log("šŸ”— Share the package URL with the community"); } /** * Main publishing process */ async publish() { console.log("šŸ“¦ CURSED FACTION VAULT ECOSYSTEM PUBLISHER"); console.log("============================================="); console.log(`Package: ${this.packageName}@${this.version}`); console.log(`Author: ${this.author}`); console.log(`Profile: ${this.npmProfile}`); console.log(""); try { // Step 1: Check npm login if (!this.checkNPMLogin()) { console.log("šŸ” Please log in to npm first:"); console.log("npm adduser"); return false; } // Step 2: Validate package this.validatePackage(); // Step 3: Run dry-run if (!this.runDryRun()) { return false; } // Step 4: Publish package if (!this.publishPackage()) { return false; } // Step 5: Show instructions this.showInstallationInstructions(); // Step 6: Show success summary this.showSuccessSummary(); return true; } catch (error) { console.error("āŒ Publishing process failed:", error.message); return false; } } } // Main function async function main() { const publisher = new PackagePublisher(); await publisher.publish(); } // Run publishing if (require.main === module) { main().catch(console.error); } module.exports = PackagePublisher;