"use strict"; /** * AeThex CLI - Main Entry Point * Command-line interface for AeThex compiler */ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || (function () { var ownKeys = function(o) { ownKeys = Object.getOwnPropertyNames || function (o) { var ar = []; for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; return ar; }; return ownKeys(o); }; return function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); __setModuleDefault(result, mod); return result; }; })(); var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const commander_1 = require("commander"); const fs = __importStar(require("fs")); const path = __importStar(require("path")); const chalk_1 = __importDefault(require("chalk")); const chokidar_1 = require("chokidar"); const Compiler_1 = require("./compiler/Compiler"); const program = new commander_1.Command(); program .name('aethex') .description('AeThex Language CLI - Write once, deploy everywhere') .version('1.0.0'); // Compile command program .command('compile ') .description('Compile an AeThex file') .option('-t, --target ', 'Target platform: javascript, roblox, uefn, unity', 'javascript') .option('-o, --output ', 'Output file path') .option('-w, --watch', 'Watch for file changes') .action((file, options) => { compileFile(file, options); if (options.watch) { console.log(chalk_1.default.blue('šŸ‘€ Watching for changes...')); const watcher = (0, chokidar_1.watch)(file, { persistent: true }); watcher.on('change', () => { console.log(chalk_1.default.yellow('\nšŸ”„ File changed, recompiling...')); compileFile(file, options); }); } }); // New project command program .command('new ') .description('Create a new AeThex project') .option('--template ', 'Project template: basic, passport, game', 'basic') .action((name, options) => { createProject(name, options.template); }); // Init command program .command('init') .description('Initialize AeThex in current directory') .action(() => { initProject(); }); program.parse(); // Helper functions function compileFile(file, options) { if (!fs.existsSync(file)) { console.error(chalk_1.default.red(`āŒ File not found: ${file}`)); process.exit(1); } const sourceCode = fs.readFileSync(file, 'utf-8'); const compiler = new Compiler_1.AeThexCompiler({ target: options.target, sourceFile: file }); console.log(chalk_1.default.blue(`šŸ”Ø Compiling ${path.basename(file)} to ${options.target}...`)); const result = compiler.compile(sourceCode); // Display errors/warnings console.log('\n' + Compiler_1.AeThexCompiler.formatErrors(result)); if (result.success && result.code) { if (options.output) { fs.writeFileSync(options.output, result.code); console.log(chalk_1.default.green(`\nāœ… Compiled to: ${options.output}`)); } else { // Auto-generate output filename const ext = Compiler_1.AeThexCompiler.getExtension(options.target); const outputFile = file.replace(/\.aethex$/, `.${ext}`); fs.writeFileSync(outputFile, result.code); console.log(chalk_1.default.green(`\nāœ… Compiled to: ${outputFile}`)); } } else { process.exit(1); } } function createProject(name, template) { const projectDir = path.join(process.cwd(), name); if (fs.existsSync(projectDir)) { console.error(chalk_1.default.red(`āŒ Directory already exists: ${name}`)); process.exit(1); } console.log(chalk_1.default.blue(`šŸ“¦ Creating new AeThex project: ${name}`)); // Create directory structure fs.mkdirSync(projectDir, { recursive: true }); fs.mkdirSync(path.join(projectDir, 'src'), { recursive: true }); fs.mkdirSync(path.join(projectDir, 'build'), { recursive: true }); // Create package.json const packageJson = { name, version: '1.0.0', description: 'AeThex Project', scripts: { build: 'aethex compile src/main.aethex', 'build:roblox': 'aethex compile src/main.aethex -t roblox', watch: 'aethex compile src/main.aethex --watch' }, dependencies: { '@aethex.os/core': '^1.0.0' }, devDependencies: { '@aethex.os/cli': '^1.0.0' } }; fs.writeFileSync(path.join(projectDir, 'package.json'), JSON.stringify(packageJson, null, 2)); // Create aethex.config.json const config = { targets: ['javascript', 'roblox'], srcDir: 'src', outDir: 'build', stdlib: true, compliance: { coppa: true, ferpa: true, piiDetection: true } }; fs.writeFileSync(path.join(projectDir, 'aethex.config.json'), JSON.stringify(config, null, 2)); // Create main.aethex based on template const mainAethex = getTemplateContent(template); fs.writeFileSync(path.join(projectDir, 'src', 'main.aethex'), mainAethex); // Create README const readme = `# ${name} An AeThex cross-platform metaverse project. ## Getting Started \`\`\`bash # Install dependencies npm install # Build for JavaScript npm run build # Build for Roblox npm run build:roblox # Watch mode npm run watch \`\`\` ## Learn More - [AeThex Documentation](https://aethex.dev/docs) - [GitHub](https://github.com/AeThex-Corporation/AeThex-OS) `; fs.writeFileSync(path.join(projectDir, 'README.md'), readme); console.log(chalk_1.default.green(`\nāœ… Project created successfully!`)); console.log(chalk_1.default.blue(`\nNext steps:`)); console.log(` cd ${name}`); console.log(` npm install`); console.log(` npm run build`); } function initProject() { console.log(chalk_1.default.blue('šŸš€ Initializing AeThex project...')); if (!fs.existsSync('src')) { fs.mkdirSync('src', { recursive: true }); } if (!fs.existsSync('build')) { fs.mkdirSync('build', { recursive: true }); } // Create aethex.config.json if it doesn't exist if (!fs.existsSync('aethex.config.json')) { const config = { targets: ['javascript', 'roblox'], srcDir: 'src', outDir: 'build', stdlib: true, compliance: { coppa: true, ferpa: true, piiDetection: true } }; fs.writeFileSync('aethex.config.json', JSON.stringify(config, null, 2)); console.log(chalk_1.default.green('āœ… Created aethex.config.json')); } console.log(chalk_1.default.green('\nāœ… Initialization complete!')); } function getTemplateContent(template) { switch (template) { case 'passport': return `import { Passport, DataSync } from "@aethex.os/core" reality AuthSystem { platforms: [roblox, web] } journey Login(username, password) { platform: all let passport = new Passport(username) when passport.verify() { sync passport across [roblox, web] notify "Login successful!" reveal passport } otherwise { notify "Login failed" } } `; case 'game': return `import { SafeInput, Compliance } from "@aethex.os/core" reality MyGame { platforms: [roblox, uefn, web] type: "multiplayer" } journey ProcessScore(player, score) { platform: all when Compliance.isCOPPACompliant(player.age) { let validation = SafeInput.validate(score) when validation.valid { notify "Score: " + score } } } `; default: // basic return `reality HelloWorld { platforms: all } journey Greet(name) { platform: all notify "Hello, " + name + " from AeThex!" } `; } } //# sourceMappingURL=index.js.map