Update README.md to provide a comprehensive overview of the ScriptShare platform, including features, tech stack, setup instructions, admin capabilities, and contribution guidelines.

This commit is contained in:
2025-08-12 22:31:26 +01:00
parent 978b9b26bc
commit aa10ea0b26
64 changed files with 12998 additions and 2 deletions

126
scripts/create-superuser.js Normal file
View File

@ -0,0 +1,126 @@
#!/usr/bin/env node
/**
* Script to create the first superuser account
* Run this script to set up the initial admin user for ScriptShare
*
* Usage: node scripts/create-superuser.js
*/
import readline from 'readline';
import crypto from 'crypto';
import fs from 'fs';
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
function question(prompt) {
return new Promise((resolve) => {
rl.question(prompt, resolve);
});
}
function generateId() {
return crypto.randomBytes(16).toString('hex');
}
function createSuperUser(userData) {
const now = new Date().toISOString();
return {
id: generateId(),
email: userData.email,
username: userData.username,
displayName: userData.displayName,
avatarUrl: userData.avatarUrl,
bio: userData.bio,
isAdmin: true,
isModerator: true,
isSuperUser: true,
permissions: [
'user:create',
'user:read',
'user:update',
'user:delete',
'user:promote',
'script:approve',
'script:reject',
'script:delete',
'comment:moderate',
'system:configure',
'analytics:view',
'backup:manage'
],
createdAt: now,
updatedAt: now,
// In a real app, this would be hashed
passwordHash: crypto.createHash('sha256').update(userData.password).digest('hex')
};
}
async function main() {
console.log('🚀 ScriptShare Super User Creation Tool');
console.log('=====================================\n');
try {
const email = await question('Email address: ');
const username = await question('Username: ');
const displayName = await question('Display Name: ');
const password = await question('Password: ');
const bio = await question('Bio (optional): ') || '';
const avatarUrl = await question('Avatar URL (optional): ') || '';
if (!email || !username || !displayName || !password) {
console.error('❌ All required fields must be provided');
process.exit(1);
}
const superUser = createSuperUser({
email,
username,
displayName,
password,
bio,
avatarUrl
});
console.log('\n✅ Super User Created Successfully!');
console.log('=====================================');
console.log(`ID: ${superUser.id}`);
console.log(`Email: ${superUser.email}`);
console.log(`Username: @${superUser.username}`);
console.log(`Display Name: ${superUser.displayName}`);
console.log(`Super User: ${superUser.isSuperUser ? 'Yes' : 'No'}`);
console.log(`Admin: ${superUser.isAdmin ? 'Yes' : 'No'}`);
console.log(`Moderator: ${superUser.isModerator ? 'Yes' : 'No'}`);
console.log(`Permissions: ${superUser.permissions.length} total`);
console.log(`Created: ${superUser.createdAt}`);
console.log('\n📋 Next Steps:');
console.log('1. Save this user data to your database');
console.log('2. Use these credentials to log into the admin panel');
console.log('3. Create additional admin users through the web interface');
// Save to a JSON file for reference
const outputPath = './superuser-account.json';
fs.writeFileSync(outputPath, JSON.stringify(superUser, null, 2));
console.log(`\n💾 User data saved to: ${outputPath}`);
} catch (error) {
console.error('❌ Error creating super user:', error.message);
process.exit(1);
} finally {
rl.close();
}
}
// Handle Ctrl+C gracefully
process.on('SIGINT', () => {
console.log('\n\n❌ Operation cancelled by user');
process.exit(0);
});
// Run the main function
main();