install-rynude 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.js +128 -0
  2. package/package.json +28 -0
package/index.js ADDED
@@ -0,0 +1,128 @@
1
+ #!/usr/bin/env node
2
+ import fs from 'fs-extra';
3
+ import path from 'path';
4
+ import os from 'os';
5
+ import { execSync } from 'child_process';
6
+ import prompts from 'prompts';
7
+ import ora from 'ora';
8
+ import chalk from 'chalk';
9
+
10
+ const REPO_URL = 'https://github.com/flustratech-dev/rynude_ai.git';
11
+ const INSTALL_DIR = path.join(os.homedir(), '.rynude_ai');
12
+
13
+ async function checkRequirements() {
14
+ const reqs = ['git', 'php', 'composer', 'npm'];
15
+ for (const req of reqs) {
16
+ try {
17
+ execSync(`${req} --version`, { stdio: 'ignore' });
18
+ } catch (e) {
19
+ console.error(chalk.red(`\nāŒ Error: Program '${req}' tidak ditemukan di sistem Anda.`));
20
+ console.error(chalk.yellow(`Silakan install ${req} terlebih dahulu sebelum menginstal Rynude AI.\n`));
21
+ process.exit(1);
22
+ }
23
+ }
24
+ }
25
+
26
+ async function run() {
27
+ console.log(chalk.cyan.bold('\nšŸš€ Selamat datang di Rynude AI Auto-Installer\n'));
28
+
29
+ await checkRequirements();
30
+
31
+ if (fs.existsSync(INSTALL_DIR)) {
32
+ const response = await prompts({
33
+ type: 'confirm',
34
+ name: 'overwrite',
35
+ message: `Folder instalasi ${chalk.yellow(INSTALL_DIR)} sudah ada. Apakah Anda ingin menginstal ulang (menghapus instalasi yang lama)?`,
36
+ initial: false
37
+ });
38
+
39
+ if (!response.overwrite) {
40
+ console.log(chalk.yellow('Instalasi dibatalkan.'));
41
+ process.exit(0);
42
+ }
43
+
44
+ const spinner = ora('Menghapus instalasi lama...').start();
45
+ fs.removeSync(INSTALL_DIR);
46
+ spinner.succeed('Instalasi lama berhasil dihapus.');
47
+ }
48
+
49
+ console.log(chalk.gray(`\nMenginstal Rynude AI ke folder tersembunyi: ${INSTALL_DIR}`));
50
+
51
+ // 1. Clone
52
+ const cloneSpinner = ora('Mengunduh Rynude AI (Clone)...').start();
53
+ try {
54
+ execSync(`git clone --depth=1 ${REPO_URL} "${INSTALL_DIR}"`, { stdio: 'ignore' });
55
+ cloneSpinner.succeed('Berhasil mengunduh source code.');
56
+ } catch (e) {
57
+ cloneSpinner.fail('Gagal mengunduh source code.');
58
+ console.error(chalk.red(e.message));
59
+ process.exit(1);
60
+ }
61
+
62
+ // 2. Composer
63
+ const composerSpinner = ora('Menginstal dependensi backend (Composer)...').start();
64
+ try {
65
+ execSync('composer install --no-interaction --optimize-autoloader', { cwd: INSTALL_DIR, stdio: 'ignore' });
66
+ composerSpinner.succeed('Dependensi backend terinstal.');
67
+ } catch (e) {
68
+ composerSpinner.fail('Gagal menginstal dependensi backend.');
69
+ process.exit(1);
70
+ }
71
+
72
+ // 3. NPM
73
+ const npmSpinner = ora('Menginstal dependensi frontend (NPM)...').start();
74
+ try {
75
+ execSync('npm install', { cwd: INSTALL_DIR, stdio: 'ignore' });
76
+ npmSpinner.succeed('Dependensi frontend terinstal.');
77
+ } catch (e) {
78
+ npmSpinner.fail('Gagal menginstal dependensi frontend.');
79
+ process.exit(1);
80
+ }
81
+
82
+ // 4. ENV Setup
83
+ const envSpinner = ora('Menyiapkan database bawaan (SQLite)...').start();
84
+ try {
85
+ fs.copySync(path.join(INSTALL_DIR, '.env.example'), path.join(INSTALL_DIR, '.env'));
86
+
87
+ // Ubah koneksi ke sqlite agar zero-config
88
+ let envContent = fs.readFileSync(path.join(INSTALL_DIR, '.env'), 'utf-8');
89
+ envContent = envContent.replace(/DB_CONNECTION=.*/, 'DB_CONNECTION=sqlite');
90
+ fs.writeFileSync(path.join(INSTALL_DIR, '.env'), envContent);
91
+
92
+ // Buat file database
93
+ fs.ensureFileSync(path.join(INSTALL_DIR, 'database', 'database.sqlite'));
94
+
95
+ execSync('php artisan key:generate', { cwd: INSTALL_DIR, stdio: 'ignore' });
96
+ execSync('php artisan migrate:fresh --seed', { cwd: INSTALL_DIR, stdio: 'ignore' });
97
+ envSpinner.succeed('Konfigurasi dan database siap.');
98
+ } catch (e) {
99
+ envSpinner.fail('Gagal menyiapkan database.');
100
+ console.error(chalk.red(e.message));
101
+ process.exit(1);
102
+ }
103
+
104
+ // 5. Global Command Setup
105
+ const globalSpinner = ora('Mengatur global command (rynude)...').start();
106
+ try {
107
+ const isWindows = os.platform() === 'win32';
108
+ if (isWindows) {
109
+ execSync('cmd.exe /c setup-global.bat', { cwd: INSTALL_DIR, stdio: 'ignore' });
110
+ } else {
111
+ execSync('bash setup-global.sh', { cwd: INSTALL_DIR, stdio: 'ignore' });
112
+ }
113
+ globalSpinner.succeed('Global command berhasil diatur.');
114
+ } catch (e) {
115
+ globalSpinner.fail('Gagal mengatur global command.');
116
+ console.error(chalk.yellow(`Silakan jalankan setup-global secara manual di folder: ${INSTALL_DIR}`));
117
+ }
118
+
119
+ console.log(chalk.green.bold('\nšŸŽ‰ Instalasi Rynude AI Berhasil Selesai!\n'));
120
+ console.log(`Sekarang Anda tidak perlu lagi masuk ke folder project untuk menjalankan aplikasi.`);
121
+ console.log(`Silakan buka terminal baru dari folder mana saja (misal di Desktop), lalu ketik:`);
122
+ console.log(chalk.magenta.bold(' rynude\n'));
123
+ }
124
+
125
+ run().catch(e => {
126
+ console.error(chalk.red('\nTerjadi kesalahan fatal:'), e);
127
+ process.exit(1);
128
+ });
package/package.json ADDED
@@ -0,0 +1,28 @@
1
+ {
2
+ "name": "install-rynude",
3
+ "version": "1.0.0",
4
+ "description": "Auto-installer for Rynude AI",
5
+ "main": "index.js",
6
+ "type": "module",
7
+ "bin": {
8
+ "install-rynude": "index.js"
9
+ },
10
+ "scripts": {
11
+ "test": "echo \"Error: no test specified\" && exit 1"
12
+ },
13
+ "keywords": [
14
+ "rynude",
15
+ "ai",
16
+ "claude",
17
+ "clone",
18
+ "laravel"
19
+ ],
20
+ "author": "Flustratech",
21
+ "license": "ISC",
22
+ "dependencies": {
23
+ "chalk": "^5.3.0",
24
+ "fs-extra": "^11.2.0",
25
+ "ora": "^8.0.1",
26
+ "prompts": "^2.4.2"
27
+ }
28
+ }