@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
JavaScript
/**
* š¦ 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;