@akaanakbaik/pterodactyl-gateway 0.3.0 → 0.4.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.
- package/README.md +239 -293
- package/add-promt.md +119 -52
- package/dist/cli-entry.d.ts +3 -0
- package/dist/cli-entry.d.ts.map +1 -0
- package/dist/cli-entry.js +179 -0
- package/dist/cli-entry.js.map +1 -0
- package/dist/cli.js +45 -10
- package/dist/cli.js.map +1 -1
- package/package.json +6 -6
package/add-promt.md
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
# Add Prompt Integrasi Akadev Pterodactyl Gateway
|
|
2
2
|
|
|
3
|
-
Gunakan dokumen ini sebagai prompt tambahan saat meminta AI mengintegrasikan package `@
|
|
3
|
+
Gunakan dokumen ini sebagai prompt tambahan saat meminta AI mengintegrasikan package `@akaanakbaik/pterodactyl-gateway` ke project Node.js, bot, dashboard, atau backend API.
|
|
4
4
|
|
|
5
5
|
## Prompt siap pakai
|
|
6
6
|
|
|
7
|
-
Tolong integrasikan package `@
|
|
7
|
+
Tolong integrasikan package `@akaanakbaik/pterodactyl-gateway` ke project saya dengan aman, rapi, dan mudah dipahami pemula.
|
|
8
8
|
|
|
9
|
-
Package ini adalah SDK TypeScript untuk Pterodactyl Panel. Gunakan untuk koneksi panel, membuat user, membuat server, preview create server, dry
|
|
9
|
+
Package ini adalah SDK TypeScript dan CLI untuk Pterodactyl Panel. Gunakan untuk koneksi panel, membuat user, membuat server, preview create server, dry-run, kontrol server, file manager, startup variables, backup, schedule, network/ports, lifecycle server, dan raw request.
|
|
10
10
|
|
|
11
11
|
Gunakan env berikut:
|
|
12
12
|
|
|
@@ -18,10 +18,24 @@ PTERO_PTLC=isi_client_api_key
|
|
|
18
18
|
|
|
19
19
|
Jangan hardcode API key atau password di source code.
|
|
20
20
|
|
|
21
|
+
## Install
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
npm i @akaanakbaik/pterodactyl-gateway
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Untuk CLI global:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
npm i -g @akaanakbaik/pterodactyl-gateway
|
|
31
|
+
ptero-gateway help
|
|
32
|
+
ptg help
|
|
33
|
+
```
|
|
34
|
+
|
|
21
35
|
## Cara koneksi
|
|
22
36
|
|
|
23
37
|
```ts
|
|
24
|
-
import { createPtero } from "@
|
|
38
|
+
import { createPtero } from "@akaanakbaik/pterodactyl-gateway";
|
|
25
39
|
|
|
26
40
|
const ptero = createPtero.fromEnv();
|
|
27
41
|
await ptero.connect();
|
|
@@ -37,7 +51,7 @@ const ptero = createPtero({
|
|
|
37
51
|
});
|
|
38
52
|
```
|
|
39
53
|
|
|
40
|
-
## Fitur utama
|
|
54
|
+
## Fitur utama SDK
|
|
41
55
|
|
|
42
56
|
- `ptero.connect()` untuk cek koneksi.
|
|
43
57
|
- `ptero.doctor()` untuk diagnosa konfigurasi.
|
|
@@ -46,20 +60,97 @@ const ptero = createPtero({
|
|
|
46
60
|
- `ptero.servers.previewCreate()` untuk melihat payload final sebelum create server.
|
|
47
61
|
- `ptero.servers.createSmart()` untuk create server dengan auto docker image, startup, environment, default allocation, dan additional allocation.
|
|
48
62
|
- `ptero.servers.createFromPreset()` untuk create server dari preset spek.
|
|
49
|
-
- `ptero.server(identifier).
|
|
50
|
-
- `ptero.server(identifier).
|
|
51
|
-
- `ptero.server(identifier).restart()` untuk
|
|
52
|
-
- `ptero.server(identifier).kill()` untuk kill server.
|
|
63
|
+
- `ptero.server(identifier).probe()` untuk cek endpoint client secara read-only.
|
|
64
|
+
- `ptero.server(identifier).resources()` untuk resource server.
|
|
65
|
+
- `ptero.server(identifier).start()`, `stop()`, `restart()`, `kill()` untuk power control.
|
|
53
66
|
- `ptero.server(identifier).command("npm start")` untuk kirim command.
|
|
54
|
-
- `ptero.server(identifier).
|
|
67
|
+
- `ptero.server(identifier).files.*` untuk file manager.
|
|
68
|
+
- `ptero.server(identifier).startup.*` untuk startup variables.
|
|
69
|
+
- `ptero.server(identifier).network.*` untuk allocation/ports.
|
|
70
|
+
- `ptero.server(identifier).databases.*` untuk database manager.
|
|
71
|
+
- `ptero.server(identifier).backups.*` untuk backup manager.
|
|
72
|
+
- `ptero.server(identifier).schedules.*` untuk schedule manager.
|
|
55
73
|
- `ptero.raw.application` dan `ptero.raw.client` untuk endpoint yang belum tersedia wrapper.
|
|
56
74
|
|
|
75
|
+
## Fitur CLI penting
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
ptero-gateway doctor
|
|
79
|
+
ptero-gateway connect
|
|
80
|
+
ptero-gateway ids
|
|
81
|
+
ptero-gateway ids --nest 5
|
|
82
|
+
ptero-gateway admin users
|
|
83
|
+
ptero-gateway admin servers
|
|
84
|
+
ptero-gateway servers
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Create server dry-run:
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
ptero-gateway admin create-server \
|
|
91
|
+
--name "aka test" \
|
|
92
|
+
--email "user@example.com" \
|
|
93
|
+
--username "aka_test" \
|
|
94
|
+
--password "password aman" \
|
|
95
|
+
--node 1 \
|
|
96
|
+
--nest 5 \
|
|
97
|
+
--egg 18 \
|
|
98
|
+
--memory 1GB \
|
|
99
|
+
--disk 2GB \
|
|
100
|
+
--cpu 100% \
|
|
101
|
+
--databases 0 \
|
|
102
|
+
--allocations 1 \
|
|
103
|
+
--backups 0 \
|
|
104
|
+
--dry-run
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
Create server asli:
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
ptero-gateway admin create-server \
|
|
111
|
+
--name "aka test" \
|
|
112
|
+
--email "user@example.com" \
|
|
113
|
+
--username "aka_test" \
|
|
114
|
+
--password "password aman" \
|
|
115
|
+
--node 1 \
|
|
116
|
+
--nest 5 \
|
|
117
|
+
--egg 18 \
|
|
118
|
+
--memory 1GB \
|
|
119
|
+
--disk 2GB \
|
|
120
|
+
--cpu 100% \
|
|
121
|
+
--databases 0 \
|
|
122
|
+
--allocations 1 \
|
|
123
|
+
--backups 0 \
|
|
124
|
+
--yes
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
Kontrol server:
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
ptero-gateway probe 311d56b7
|
|
131
|
+
ptero-gateway server 311d56b7 summary
|
|
132
|
+
ptero-gateway server 311d56b7 resources
|
|
133
|
+
ptero-gateway server 311d56b7 files /
|
|
134
|
+
ptero-gateway server 311d56b7 env
|
|
135
|
+
ptero-gateway server 311d56b7 ports
|
|
136
|
+
ptero-gateway server 311d56b7 start --yes
|
|
137
|
+
ptero-gateway server 311d56b7 stop --yes
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
Template Node alive:
|
|
141
|
+
|
|
142
|
+
```bash
|
|
143
|
+
ptero-gateway server 311d56b7 stop --yes
|
|
144
|
+
ptero-gateway server 311d56b7 init-node-alive --yes
|
|
145
|
+
ptero-gateway server 311d56b7 start --yes
|
|
146
|
+
```
|
|
147
|
+
|
|
57
148
|
## Create user
|
|
58
149
|
|
|
59
150
|
```ts
|
|
60
151
|
const user = await ptero.users.createSmart({
|
|
61
|
-
username: "
|
|
62
|
-
email: "
|
|
152
|
+
username: "aka_test",
|
|
153
|
+
email: "user@example.com",
|
|
63
154
|
password: "auto",
|
|
64
155
|
administrator: "no"
|
|
65
156
|
});
|
|
@@ -72,18 +163,21 @@ Jika `password` diisi `auto`, package membuat password aman dan mengembalikannya
|
|
|
72
163
|
```ts
|
|
73
164
|
const server = await ptero.servers.createSmart({
|
|
74
165
|
name: "Bot WhatsApp Aka",
|
|
75
|
-
email: "
|
|
166
|
+
email: "user@example.com",
|
|
167
|
+
username: "aka_test",
|
|
168
|
+
password: "password aman",
|
|
169
|
+
autoCreateUser: true,
|
|
76
170
|
description: "Server bot WhatsApp untuk Aka",
|
|
77
171
|
nodeId: 1,
|
|
78
172
|
nestId: 5,
|
|
79
|
-
eggId:
|
|
173
|
+
eggId: 18,
|
|
80
174
|
specs: {
|
|
81
|
-
memory: "
|
|
82
|
-
disk: "
|
|
175
|
+
memory: "1GB",
|
|
176
|
+
disk: "2GB",
|
|
83
177
|
cpu: "100%",
|
|
84
|
-
databases:
|
|
178
|
+
databases: 0,
|
|
85
179
|
allocations: 1,
|
|
86
|
-
backups:
|
|
180
|
+
backups: 0
|
|
87
181
|
}
|
|
88
182
|
});
|
|
89
183
|
```
|
|
@@ -114,9 +208,8 @@ const server = await ptero.servers.createSmart({
|
|
|
114
208
|
- block IO default `500`
|
|
115
209
|
- CPU pinning default kosong
|
|
116
210
|
- OOM disabled default `false`
|
|
117
|
-
- start on completion default `true`
|
|
118
211
|
|
|
119
|
-
## Preview dan dry
|
|
212
|
+
## Preview dan dry-run
|
|
120
213
|
|
|
121
214
|
```ts
|
|
122
215
|
const preview = await ptero.servers.previewCreate(input);
|
|
@@ -128,39 +221,10 @@ const result = await ptero.servers.createSmart(input, { dryRun: true });
|
|
|
128
221
|
console.log(result.payload);
|
|
129
222
|
```
|
|
130
223
|
|
|
131
|
-
## Preset paket
|
|
132
|
-
|
|
133
|
-
```ts
|
|
134
|
-
const ptero = createPtero({
|
|
135
|
-
domain: process.env.PTERO_DOMAIN,
|
|
136
|
-
ptla: process.env.PTERO_PTLA,
|
|
137
|
-
ptlc: process.env.PTERO_PTLC,
|
|
138
|
-
presets: {
|
|
139
|
-
basic: {
|
|
140
|
-
memory: "2GB",
|
|
141
|
-
disk: "5GB",
|
|
142
|
-
cpu: "100%",
|
|
143
|
-
databases: 1,
|
|
144
|
-
allocations: 1,
|
|
145
|
-
backups: 1
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
});
|
|
149
|
-
|
|
150
|
-
await ptero.servers.createFromPreset("basic", {
|
|
151
|
-
name: "Bot Aka",
|
|
152
|
-
email: "aka@example.com",
|
|
153
|
-
description: "Paket Basic",
|
|
154
|
-
nodeId: 1,
|
|
155
|
-
nestId: 5,
|
|
156
|
-
eggId: 15
|
|
157
|
-
});
|
|
158
|
-
```
|
|
159
|
-
|
|
160
224
|
## Error handling
|
|
161
225
|
|
|
162
226
|
```ts
|
|
163
|
-
import { explainError } from "@
|
|
227
|
+
import { explainError } from "@akaanakbaik/pterodactyl-gateway";
|
|
164
228
|
|
|
165
229
|
try {
|
|
166
230
|
await ptero.servers.createSmart(input);
|
|
@@ -187,6 +251,9 @@ await ptero.raw.client.post("/servers/abc123/command", {
|
|
|
187
251
|
- Gunakan `previewCreate()` atau `dryRun` sebelum create server final.
|
|
188
252
|
- Gunakan `explainError()` untuk pesan error yang mudah dipahami.
|
|
189
253
|
- Create server wajib memakai `nodeId`, `nestId`, dan `eggId` berupa angka.
|
|
190
|
-
- Jika ID node, nest, atau egg salah, arahkan user untuk cek
|
|
254
|
+
- Jika ID node, nest, atau egg salah, arahkan user untuk cek `ptero-gateway ids` atau Admin Panel Pterodactyl.
|
|
191
255
|
- Jika allocation kosong, arahkan user menambah allocation di Admin Panel > Nodes > Allocations.
|
|
192
|
-
-
|
|
256
|
+
- Semua aksi yang mengubah server via CLI wajib memakai `--yes`.
|
|
257
|
+
- Write file via CLI default hanya boleh ke `/tmp`; untuk path lain wajib `--allow-any-path`.
|
|
258
|
+
- Jangan menjalankan command berisiko tanpa izin jelas dari user.
|
|
259
|
+
- Delete server/user permanen belum dibuka di v0.3.0 dan perlu guard tambahan.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-entry.d.ts","sourceRoot":"","sources":["../src/cli-entry.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
const rawArgs = process.argv.slice(2);
|
|
3
|
+
const command = rawArgs[0] ?? "help";
|
|
4
|
+
const jsonMode = rawArgs.includes("--json");
|
|
5
|
+
const EXPLAINS = {
|
|
6
|
+
DOMAIN_REQUIRED: {
|
|
7
|
+
title: "Domain panel belum diisi",
|
|
8
|
+
reason: "Env PTERO_DOMAIN belum tersedia atau config createPtero belum berisi domain/panelUrl.",
|
|
9
|
+
fix: [
|
|
10
|
+
"export PTERO_DOMAIN=\"https://panel.example.com\"",
|
|
11
|
+
"pastikan tidak ada spasi/kutip rusak pada env",
|
|
12
|
+
"jalankan ulang: ptero-gateway doctor"
|
|
13
|
+
]
|
|
14
|
+
},
|
|
15
|
+
PTLA_REQUIRED: {
|
|
16
|
+
title: "Application API Key belum diisi",
|
|
17
|
+
reason: "Aksi admin membutuhkan PTERO_PTLA.",
|
|
18
|
+
fix: [
|
|
19
|
+
"buat Application API Key di panel admin Pterodactyl",
|
|
20
|
+
"export PTERO_PTLA=\"ptla_xxx\"",
|
|
21
|
+
"jalankan: ptero-gateway doctor"
|
|
22
|
+
]
|
|
23
|
+
},
|
|
24
|
+
PTLC_REQUIRED: {
|
|
25
|
+
title: "Client API Key belum diisi",
|
|
26
|
+
reason: "Aksi client server membutuhkan PTERO_PTLC.",
|
|
27
|
+
fix: [
|
|
28
|
+
"buat Client API Key dari account panel",
|
|
29
|
+
"export PTERO_PTLC=\"ptlc_xxx\"",
|
|
30
|
+
"jalankan: ptero-gateway doctor"
|
|
31
|
+
]
|
|
32
|
+
},
|
|
33
|
+
DOCKER_IMAGE_NOT_FOUND: {
|
|
34
|
+
title: "Docker image egg tidak ditemukan",
|
|
35
|
+
reason: "Egg tidak mengirim docker_image/docker_images yang bisa dipilih otomatis.",
|
|
36
|
+
fix: [
|
|
37
|
+
"cek egg ID dengan: ptero-gateway ids --nest <nestId>",
|
|
38
|
+
"pastikan egg punya Docker Images di panel",
|
|
39
|
+
"atau isi manual: --docker-image ghcr.io/parkervcp/yolks:nodejs_22"
|
|
40
|
+
]
|
|
41
|
+
},
|
|
42
|
+
STARTUP_VARIABLE_NOT_FOUND: {
|
|
43
|
+
title: "Startup variable tidak ditemukan",
|
|
44
|
+
reason: "Nama variable yang di-set tidak cocok dengan env_variable pada egg/server.",
|
|
45
|
+
fix: [
|
|
46
|
+
"lihat variable: ptero-gateway server <identifier> env",
|
|
47
|
+
"salin nama variable dari kolom variable",
|
|
48
|
+
"jalankan: ptero-gateway server <identifier> set-env KEY VALUE --yes"
|
|
49
|
+
]
|
|
50
|
+
},
|
|
51
|
+
VALIDATION_ERROR: {
|
|
52
|
+
title: "Payload ditolak panel",
|
|
53
|
+
reason: "Ada field yang tidak sesuai validasi Pterodactyl.",
|
|
54
|
+
fix: [
|
|
55
|
+
"jalankan create-server dengan --dry-run dulu",
|
|
56
|
+
"cek node, nest, egg, allocation, dan feature limits",
|
|
57
|
+
"pakai --json untuk melihat payload lengkap"
|
|
58
|
+
]
|
|
59
|
+
},
|
|
60
|
+
REQUEST_FAILED: {
|
|
61
|
+
title: "Request ke panel gagal",
|
|
62
|
+
reason: "Panel mengembalikan error HTTP atau response tidak sesuai.",
|
|
63
|
+
fix: [
|
|
64
|
+
"cek domain dan API key dengan: ptero-gateway doctor",
|
|
65
|
+
"pastikan endpoint didukung versi panel",
|
|
66
|
+
"coba ulang dengan --json untuk melihat response mentah"
|
|
67
|
+
]
|
|
68
|
+
},
|
|
69
|
+
BACKUP_LIMIT: {
|
|
70
|
+
title: "Limit backup habis",
|
|
71
|
+
reason: "Server tidak punya jatah backup atau sudah mencapai limit.",
|
|
72
|
+
fix: [
|
|
73
|
+
"cek: ptero-gateway admin server <id> limits",
|
|
74
|
+
"update: ptero-gateway admin server <id> update-limits --backups 1 --yes",
|
|
75
|
+
"lalu ulangi create-backup"
|
|
76
|
+
]
|
|
77
|
+
},
|
|
78
|
+
EEXIST: {
|
|
79
|
+
title: "Binary global sudah ada",
|
|
80
|
+
reason: "File /usr/bin/ptero-gateway atau /usr/bin/ptg masih ada dari npm link/install lama.",
|
|
81
|
+
fix: [
|
|
82
|
+
"npm unlink -g @akaanakbaik/pterodactyl-gateway 2>/dev/null || true",
|
|
83
|
+
"rm -f /usr/bin/ptero-gateway /usr/bin/ptg",
|
|
84
|
+
"npm i -g @akaanakbaik/pterodactyl-gateway"
|
|
85
|
+
]
|
|
86
|
+
},
|
|
87
|
+
E404: {
|
|
88
|
+
title: "Package atau endpoint tidak ditemukan",
|
|
89
|
+
reason: "NPM/package/endpoint belum tersedia atau nama salah.",
|
|
90
|
+
fix: [
|
|
91
|
+
"cek nama package atau identifier server",
|
|
92
|
+
"untuk npm: npm view @akaanakbaik/pterodactyl-gateway@latest",
|
|
93
|
+
"untuk server: ptero-gateway servers lalu salin identifier"
|
|
94
|
+
]
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
if (command === "help" || command === "--help" || command === "-h") {
|
|
98
|
+
printHelp();
|
|
99
|
+
}
|
|
100
|
+
else if (command === "env-template") {
|
|
101
|
+
const content = [
|
|
102
|
+
"PTERO_DOMAIN=https://panel.example.com",
|
|
103
|
+
"PTERO_PTLA=ptla_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
|
|
104
|
+
"PTERO_PTLC=ptlc_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
|
|
105
|
+
].join("\n");
|
|
106
|
+
console.log(content);
|
|
107
|
+
}
|
|
108
|
+
else if (command === "explain") {
|
|
109
|
+
const code = (rawArgs[1] ?? "").toUpperCase();
|
|
110
|
+
const result = EXPLAINS[code];
|
|
111
|
+
if (jsonMode) {
|
|
112
|
+
console.log(JSON.stringify(result ?? { error: "UNKNOWN_EXPLAIN", code }, null, 2));
|
|
113
|
+
}
|
|
114
|
+
else if (!code || !result) {
|
|
115
|
+
console.log(`Kode error tersedia:\n${Object.keys(EXPLAINS).map(item => `- ${item}`).join("\n")}\n\nContoh: ptero-gateway explain DOMAIN_REQUIRED`);
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
console.log(`${result.title}\n\nPenyebab:\n${result.reason}\n\nCara perbaikan:\n${result.fix.map((item, index) => `${index + 1}. ${item}`).join("\n")}`);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
await import("./cli.js");
|
|
123
|
+
}
|
|
124
|
+
function printHelp() {
|
|
125
|
+
console.log(`Akadev Pterodactyl Gateway
|
|
126
|
+
|
|
127
|
+
Perintah:
|
|
128
|
+
ptero-gateway presets [--json]
|
|
129
|
+
ptero-gateway explain <ERROR_CODE> [--json]
|
|
130
|
+
ptero-gateway env-template
|
|
131
|
+
ptero-gateway doctor [--json]
|
|
132
|
+
ptero-gateway connect [--json]
|
|
133
|
+
ptero-gateway ids [--nest <nestId>] [--json]
|
|
134
|
+
ptero-gateway servers [--json]
|
|
135
|
+
ptero-gateway admin users [--json]
|
|
136
|
+
ptero-gateway admin servers [--json]
|
|
137
|
+
ptero-gateway admin create-user --username aka_test --email user@example.com --password "secret" --yes
|
|
138
|
+
ptero-gateway admin create-server --name "aka test" --email user@example.com --node 1 --nest 5 --egg 18 --preset basic --dry-run
|
|
139
|
+
ptero-gateway admin create-server --name "aka test" --email user@example.com --node 1 --nest 5 --egg 18 --preset standard --yes
|
|
140
|
+
ptero-gateway admin server <serverId> detail [--json]
|
|
141
|
+
ptero-gateway admin server <serverId> limits [--json]
|
|
142
|
+
ptero-gateway admin server <serverId> update-limits --backups 1 --yes
|
|
143
|
+
ptero-gateway admin server <serverId> suspend --yes
|
|
144
|
+
ptero-gateway admin server <serverId> unsuspend --yes
|
|
145
|
+
ptero-gateway admin server <serverId> reinstall --yes
|
|
146
|
+
ptero-gateway probe <identifier> [--json]
|
|
147
|
+
ptero-gateway server <identifier> summary [--json]
|
|
148
|
+
ptero-gateway server <identifier> resources [--json]
|
|
149
|
+
ptero-gateway server <identifier> files [directory] [--json]
|
|
150
|
+
ptero-gateway server <identifier> read <file>
|
|
151
|
+
ptero-gateway server <identifier> startup|env [--json]
|
|
152
|
+
ptero-gateway server <identifier> network|ports [--json]
|
|
153
|
+
ptero-gateway server <identifier> databases [--json]
|
|
154
|
+
ptero-gateway server <identifier> backups [--json]
|
|
155
|
+
ptero-gateway server <identifier> backup <uuid> [--json]
|
|
156
|
+
ptero-gateway server <identifier> delete-backup <uuid> --yes
|
|
157
|
+
ptero-gateway server <identifier> schedules [--json]
|
|
158
|
+
ptero-gateway server <identifier> write /tmp/test.txt "isi file" --yes
|
|
159
|
+
ptero-gateway server <identifier> write /index.js "isi file" --yes --allow-any-path
|
|
160
|
+
ptero-gateway server <identifier> init-node-alive --yes
|
|
161
|
+
ptero-gateway server <identifier> set-env KEY VALUE --yes
|
|
162
|
+
ptero-gateway server <identifier> create-backup --name "backup-name" --yes
|
|
163
|
+
ptero-gateway server <identifier> start --yes
|
|
164
|
+
ptero-gateway server <identifier> stop --yes
|
|
165
|
+
ptero-gateway server <identifier> restart --yes
|
|
166
|
+
ptero-gateway server <identifier> kill --yes
|
|
167
|
+
ptero-gateway server <identifier> command "npm start" --yes
|
|
168
|
+
|
|
169
|
+
Preset:
|
|
170
|
+
mini, basic, standard, premium, unlimited
|
|
171
|
+
Spek preset bisa dioverride dengan --memory, --disk, --cpu, --databases, --allocations, --backups.
|
|
172
|
+
|
|
173
|
+
Env:
|
|
174
|
+
PTERO_DOMAIN=https://panel.example.com
|
|
175
|
+
PTERO_PTLA=ptla_xxx
|
|
176
|
+
PTERO_PTLC=ptlc_xxx`);
|
|
177
|
+
}
|
|
178
|
+
export {};
|
|
179
|
+
//# sourceMappingURL=cli-entry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-entry.js","sourceRoot":"","sources":["../src/cli-entry.ts"],"names":[],"mappings":";AAEA,MAAM,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AACtC,MAAM,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC;AACrC,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;AAE5C,MAAM,QAAQ,GAAqE;IACjF,eAAe,EAAE;QACf,KAAK,EAAE,0BAA0B;QACjC,MAAM,EAAE,uFAAuF;QAC/F,GAAG,EAAE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AAC,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,GAAG,KAAK,GAAG,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC3J,CAAC;AACH,CAAC;KAAM,CAAC;IACN,MAAM,MAAM,CAAC,UAAU,CAAC,CAAC;AAC3B,CAAC;AAED,SAAS,SAAS;IAChB,OAAO,CAAC,GAAG,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;sBAmDQ,CAAC,CAAC;AACxB,CAAC"}
|
package/dist/cli.js
CHANGED
|
@@ -7,11 +7,23 @@ const dryRunMode = rawArgs.includes("--dry-run");
|
|
|
7
7
|
const allowAnyPath = rawArgs.includes("--allow-any-path");
|
|
8
8
|
const args = rawArgs.filter(arg => arg !== "--json" && arg !== "--yes" && arg !== "-y" && arg !== "--dry-run" && arg !== "--allow-any-path");
|
|
9
9
|
const command = args[0] ?? "help";
|
|
10
|
+
const SERVER_PRESETS = {
|
|
11
|
+
mini: { memory: "512MB", disk: "1GB", cpu: "50%", databases: 0, allocations: 1, backups: 0, swap: 0, io: 500, description: "Ringan untuk bot kecil atau testing." },
|
|
12
|
+
basic: { memory: "1GB", disk: "2GB", cpu: "100%", databases: 0, allocations: 1, backups: 0, swap: 0, io: 500, description: "Default aman untuk bot Node.js sederhana." },
|
|
13
|
+
standard: { memory: "2GB", disk: "5GB", cpu: "200%", databases: 1, allocations: 1, backups: 1, swap: 0, io: 500, description: "Untuk bot/API sedang dan project aktif." },
|
|
14
|
+
premium: { memory: "4GB", disk: "10GB", cpu: "300%", databases: 2, allocations: 2, backups: 2, swap: 0, io: 500, description: "Untuk project lebih berat dan butuh backup." },
|
|
15
|
+
unlimited: { memory: "0", disk: "0", cpu: "0", databases: 5, allocations: 3, backups: 3, swap: 0, io: 500, description: "Resource unlimited sesuai aturan Pterodactyl." }
|
|
16
|
+
};
|
|
10
17
|
async function main() {
|
|
11
18
|
if (command === "help" || command === "--help" || command === "-h") {
|
|
12
19
|
printHelp();
|
|
13
20
|
return;
|
|
14
21
|
}
|
|
22
|
+
if (command === "presets") {
|
|
23
|
+
const rows = formatPresetRows();
|
|
24
|
+
output(rows, table(rows, ["name", "memory", "disk", "cpu", "databases", "allocations", "backups", "description"]));
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
15
27
|
const ptero = createPtero.fromEnv();
|
|
16
28
|
if (command === "doctor") {
|
|
17
29
|
const report = await ptero.doctor();
|
|
@@ -294,6 +306,7 @@ function errorResult(error) {
|
|
|
294
306
|
function buildCreateServerInput() {
|
|
295
307
|
const username = getOption("--username");
|
|
296
308
|
const password = getOption("--password");
|
|
309
|
+
const preset = getServerPreset(getOption("--preset") ?? "basic");
|
|
297
310
|
return {
|
|
298
311
|
name: getRequiredOption("--name"),
|
|
299
312
|
email: getRequiredOption("--email"),
|
|
@@ -307,17 +320,34 @@ function buildCreateServerInput() {
|
|
|
307
320
|
dockerImage: getOption("--docker-image") ?? "auto",
|
|
308
321
|
startup: getOption("--startup") ?? "auto",
|
|
309
322
|
specs: {
|
|
310
|
-
memory: getOption("--memory") ??
|
|
311
|
-
disk: getOption("--disk") ??
|
|
312
|
-
cpu: getOption("--cpu") ??
|
|
313
|
-
databases: getNumberOption("--databases",
|
|
314
|
-
allocations: getNumberOption("--allocations",
|
|
315
|
-
backups: getNumberOption("--backups",
|
|
316
|
-
swap: getNumberOption("--swap",
|
|
317
|
-
io: getNumberOption("--io",
|
|
323
|
+
memory: getOption("--memory") ?? preset.memory,
|
|
324
|
+
disk: getOption("--disk") ?? preset.disk,
|
|
325
|
+
cpu: getOption("--cpu") ?? preset.cpu,
|
|
326
|
+
databases: getNumberOption("--databases", preset.databases),
|
|
327
|
+
allocations: getNumberOption("--allocations", preset.allocations),
|
|
328
|
+
backups: getNumberOption("--backups", preset.backups),
|
|
329
|
+
swap: getNumberOption("--swap", preset.swap),
|
|
330
|
+
io: getNumberOption("--io", preset.io)
|
|
318
331
|
}
|
|
319
332
|
};
|
|
320
333
|
}
|
|
334
|
+
function getServerPreset(name) {
|
|
335
|
+
if (!(name in SERVER_PRESETS))
|
|
336
|
+
throw new Error(`Preset tidak dikenal: ${name}. Jalankan: ptero-gateway presets`);
|
|
337
|
+
return SERVER_PRESETS[name];
|
|
338
|
+
}
|
|
339
|
+
function formatPresetRows() {
|
|
340
|
+
return Object.entries(SERVER_PRESETS).map(([name, preset]) => ({
|
|
341
|
+
name,
|
|
342
|
+
memory: preset.memory,
|
|
343
|
+
disk: preset.disk,
|
|
344
|
+
cpu: preset.cpu,
|
|
345
|
+
databases: String(preset.databases),
|
|
346
|
+
allocations: String(preset.allocations),
|
|
347
|
+
backups: String(preset.backups),
|
|
348
|
+
description: preset.description
|
|
349
|
+
}));
|
|
350
|
+
}
|
|
321
351
|
function buildLimitPayload(raw) {
|
|
322
352
|
const attributes = getAttributes(raw);
|
|
323
353
|
const limits = asRecord(attributes.limits);
|
|
@@ -626,6 +656,7 @@ function printHelp() {
|
|
|
626
656
|
console.log(`Akadev Pterodactyl Gateway
|
|
627
657
|
|
|
628
658
|
Perintah:
|
|
659
|
+
ptero-gateway presets [--json]
|
|
629
660
|
ptero-gateway doctor [--json]
|
|
630
661
|
ptero-gateway connect [--json]
|
|
631
662
|
ptero-gateway ids [--nest <nestId>] [--json]
|
|
@@ -633,8 +664,8 @@ Perintah:
|
|
|
633
664
|
ptero-gateway admin users [--json]
|
|
634
665
|
ptero-gateway admin servers [--json]
|
|
635
666
|
ptero-gateway admin create-user --username aka_test --email user@example.com --password "secret" --yes
|
|
636
|
-
ptero-gateway admin create-server --name "aka test" --email user@example.com --node 1 --nest 5 --egg 18 --dry-run
|
|
637
|
-
ptero-gateway admin create-server --name "aka test" --email user@example.com --node 1 --nest 5 --egg 18 --yes
|
|
667
|
+
ptero-gateway admin create-server --name "aka test" --email user@example.com --node 1 --nest 5 --egg 18 --preset basic --dry-run
|
|
668
|
+
ptero-gateway admin create-server --name "aka test" --email user@example.com --node 1 --nest 5 --egg 18 --preset standard --yes
|
|
638
669
|
ptero-gateway admin server <serverId> detail [--json]
|
|
639
670
|
ptero-gateway admin server <serverId> limits [--json]
|
|
640
671
|
ptero-gateway admin server <serverId> update-limits --backups 1 --yes
|
|
@@ -664,6 +695,10 @@ Perintah:
|
|
|
664
695
|
ptero-gateway server <identifier> kill --yes
|
|
665
696
|
ptero-gateway server <identifier> command "npm start" --yes
|
|
666
697
|
|
|
698
|
+
Preset:
|
|
699
|
+
mini, basic, standard, premium, unlimited
|
|
700
|
+
Spek preset bisa dioverride dengan --memory, --disk, --cpu, --databases, --allocations, --backups.
|
|
701
|
+
|
|
667
702
|
Env:
|
|
668
703
|
PTERO_DOMAIN=https://panel.example.com
|
|
669
704
|
PTERO_PTLA=ptla_xxx
|