@powernukkitx/cli 1.0.0 → 1.0.1
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/LICENSE +21 -0
- package/README.md +186 -203
- package/dist/cli.js +34 -46
- package/dist/commands/backup.d.ts +2 -2
- package/dist/commands/backup.js +23 -24
- package/dist/commands/config.d.ts +1 -1
- package/dist/commands/config.js +60 -61
- package/dist/commands/console.d.ts +2 -2
- package/dist/commands/console.js +98 -99
- package/dist/commands/doctor.d.ts +2 -2
- package/dist/commands/doctor.js +97 -98
- package/dist/commands/info.d.ts +2 -2
- package/dist/commands/info.js +41 -42
- package/dist/commands/init.d.ts +2 -2
- package/dist/commands/init.js +87 -66
- package/dist/commands/install.js +45 -0
- package/dist/commands/logs.d.ts +2 -2
- package/dist/commands/logs.js +60 -61
- package/dist/commands/menu.js +94 -86
- package/dist/commands/plugin/index.d.ts +2 -2
- package/dist/commands/plugin/index.js +13 -13
- package/dist/commands/plugin/info.d.ts +2 -2
- package/dist/commands/plugin/info.js +39 -40
- package/dist/commands/plugin/install.d.ts +2 -2
- package/dist/commands/plugin/install.js +56 -57
- package/dist/commands/plugin/installed.d.ts +2 -2
- package/dist/commands/plugin/installed.js +41 -42
- package/dist/commands/plugin/list.d.ts +2 -2
- package/dist/commands/plugin/list.js +47 -49
- package/dist/commands/plugin/remove.d.ts +2 -2
- package/dist/commands/plugin/remove.js +44 -45
- package/dist/commands/plugin/search.d.ts +2 -2
- package/dist/commands/plugin/search.js +11 -12
- package/dist/commands/plugin/update.d.ts +2 -2
- package/dist/commands/plugin/update.js +52 -53
- package/dist/commands/start.d.ts +2 -2
- package/dist/commands/start.js +74 -75
- package/dist/commands/stop.d.ts +2 -2
- package/dist/commands/stop.js +26 -27
- package/dist/commands/update.d.ts +2 -2
- package/dist/commands/update.js +34 -35
- package/dist/commands/use.d.ts +2 -2
- package/dist/commands/use.js +39 -40
- package/dist/infra/http.js +119 -121
- package/dist/infra/paths.js +15 -20
- package/dist/infra/store.js +24 -27
- package/dist/services/backup.js +34 -40
- package/dist/services/plugins.js +139 -111
- package/dist/services/process.js +41 -43
- package/dist/services/release.js +51 -38
- package/dist/services/server.js +81 -89
- package/dist/ui/output.js +67 -71
- package/dist/ui/prompts.js +26 -30
- package/dist/ui/theme.js +16 -18
- package/package.json +44 -46
- package/dist/bundle.js +0 -18
- package/dist/commands/cfg.d.ts +0 -2
- package/dist/commands/cfg.js +0 -61
- package/dist/commands/lang.d.ts +0 -2
- package/dist/commands/lang.js +0 -28
- package/dist/commands/plugin.d.ts +0 -1
- package/dist/commands/plugin.js +0 -1
- package/dist/core/config.d.ts +0 -13
- package/dist/core/config.js +0 -31
- package/dist/core/network.d.ts +0 -13
- package/dist/core/network.js +0 -139
- package/dist/core/output.d.ts +0 -33
- package/dist/core/output.js +0 -75
- package/dist/core/process.d.ts +0 -10
- package/dist/core/process.js +0 -53
- package/dist/i18n/en.json +0 -174
- package/dist/i18n/fr.json +0 -174
- package/dist/i18n/index.js +0 -58
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/lang/en.json +0 -146
- package/dist/lang/fr.json +0 -146
- package/dist/lang/index.d.ts +0 -7
- package/dist/lang/index.js +0 -83
- package/dist/main.d.ts +0 -2
- package/dist/main.js +0 -28
- package/dist/plugins.json +0 -66
- package/dist/types.d.ts +0 -61
- package/dist/types.js +0 -1
- package/dist/utils/api.d.ts +0 -9
- package/dist/utils/api.js +0 -24
- package/dist/utils/github.d.ts +0 -20
- package/dist/utils/github.js +0 -60
- package/dist/utils/logger.d.ts +0 -15
- package/dist/utils/logger.js +0 -72
- package/dist/utils/pause.d.ts +0 -1
- package/dist/utils/pause.js +0 -6
- package/dist/utils/plugins.d.ts +0 -4
- package/dist/utils/plugins.js +0 -34
- package/dist/utils/server.d.ts +0 -3
- package/dist/utils/server.js +0 -32
- package/dist/utils/updater.d.ts +0 -1
- package/dist/utils/updater.js +0 -86
package/dist/lang/en.json
DELETED
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"cli": { "description": "PowerNukkitX CLI — Manage your Minecraft Bedrock servers" },
|
|
3
|
-
"init": {
|
|
4
|
-
"title": "Create a PowerNukkitX server",
|
|
5
|
-
"promptDir": "Server directory?",
|
|
6
|
-
"alreadyExists": "A server already exists here",
|
|
7
|
-
"fetchingInfo": "Fetching latest version...",
|
|
8
|
-
"latestVersion": "Latest version",
|
|
9
|
-
"downloading": "Downloading",
|
|
10
|
-
"downloaded": "Downloaded ({0} MB)",
|
|
11
|
-
"downloadingScripts": "Downloading start scripts...",
|
|
12
|
-
"scriptsDownloaded": "Start scripts downloaded",
|
|
13
|
-
"success": "Server ready!",
|
|
14
|
-
"launchPrompt": "Start the server now?"
|
|
15
|
-
},
|
|
16
|
-
"start": {
|
|
17
|
-
"title": "Start server",
|
|
18
|
-
"notFound": "No server found here",
|
|
19
|
-
"createPrompt": "Create a server now?",
|
|
20
|
-
"checkingJava": "Checking Java...",
|
|
21
|
-
"javaOk": "Java {0} detected",
|
|
22
|
-
"javaNotFound": "Java 21+ required — https://adoptium.net/",
|
|
23
|
-
"starting": "Starting...",
|
|
24
|
-
"running": "Server running (PID {0})",
|
|
25
|
-
"stopped": "Server stopped (code {0})",
|
|
26
|
-
"restarting": "Restarting..."
|
|
27
|
-
},
|
|
28
|
-
"stop": {
|
|
29
|
-
"title": "Stop server",
|
|
30
|
-
"notRunning": "No server running",
|
|
31
|
-
"killing": "Stopping server (PID {0})...",
|
|
32
|
-
"done": "Server stopped"
|
|
33
|
-
},
|
|
34
|
-
"update": {
|
|
35
|
-
"title": "Update PowerNukkitX",
|
|
36
|
-
"checking": "Checking for updates...",
|
|
37
|
-
"notFound": "No server found",
|
|
38
|
-
"available": "New version available: {0}",
|
|
39
|
-
"upToDate": "Already up to date ({0})",
|
|
40
|
-
"saving": "Backing up old version...",
|
|
41
|
-
"downloading": "Downloading...",
|
|
42
|
-
"done": "Update complete!",
|
|
43
|
-
"restart": "Restart the server to apply changes"
|
|
44
|
-
},
|
|
45
|
-
"doctor": {
|
|
46
|
-
"title": "Server diagnostics",
|
|
47
|
-
"checking": "Running diagnostics...",
|
|
48
|
-
"java": "Java",
|
|
49
|
-
"server": "Server",
|
|
50
|
-
"system": "System",
|
|
51
|
-
"plugins": "Plugins & Worlds",
|
|
52
|
-
"network": "Network",
|
|
53
|
-
"done": "Diagnostics complete"
|
|
54
|
-
},
|
|
55
|
-
"info": {
|
|
56
|
-
"title": "Server info",
|
|
57
|
-
"server": "Server",
|
|
58
|
-
"system": "System",
|
|
59
|
-
"status": "Status",
|
|
60
|
-
"installed": "Installed",
|
|
61
|
-
"notInstalled": "Not installed",
|
|
62
|
-
"path": "Path",
|
|
63
|
-
"plugins": "Plugins",
|
|
64
|
-
"worlds": "Worlds",
|
|
65
|
-
"ram": "Free RAM",
|
|
66
|
-
"ready": "Ready to start with 'pnx start'",
|
|
67
|
-
"notReady": "Run 'pnx init' to create a server"
|
|
68
|
-
},
|
|
69
|
-
"backup": {
|
|
70
|
-
"title": "Backup",
|
|
71
|
-
"noServer": "No server detected",
|
|
72
|
-
"collecting": "Collecting files...",
|
|
73
|
-
"size": "Estimated size: {0}",
|
|
74
|
-
"copying": "Copying files...",
|
|
75
|
-
"done": "Backup created: {0} ({1})"
|
|
76
|
-
},
|
|
77
|
-
"config": {
|
|
78
|
-
"title": "Configuration",
|
|
79
|
-
"noServer": "No server detected",
|
|
80
|
-
"notFound": "No config file found",
|
|
81
|
-
"editHint": "Edit {0} to change these values"
|
|
82
|
-
},
|
|
83
|
-
"use": {
|
|
84
|
-
"title": "Default server",
|
|
85
|
-
"prompt": "Select a server:",
|
|
86
|
-
"pathPrompt": "Server path:",
|
|
87
|
-
"set": "Default server set: {0}",
|
|
88
|
-
"cleared": "Default server cleared",
|
|
89
|
-
"notFound": "powernukkitx.jar not found in: {0}"
|
|
90
|
-
},
|
|
91
|
-
"lang": {
|
|
92
|
-
"title": "Language",
|
|
93
|
-
"prompt": "Choose your language",
|
|
94
|
-
"set": "Language set to {0}",
|
|
95
|
-
"menu": "What do you want to do?",
|
|
96
|
-
"exit": "Exit",
|
|
97
|
-
"back": "Back"
|
|
98
|
-
},
|
|
99
|
-
"logs": {
|
|
100
|
-
"title": "Server logs",
|
|
101
|
-
"noServer": "No server detected",
|
|
102
|
-
"noLogs": "No log files found",
|
|
103
|
-
"watching": "Reading {0}",
|
|
104
|
-
"liveMode": "Live mode (Ctrl+C to quit)"
|
|
105
|
-
},
|
|
106
|
-
"console": {
|
|
107
|
-
"title": "Server console",
|
|
108
|
-
"noServer": "No server running",
|
|
109
|
-
"rconDisabled": "RCON disabled in server.properties",
|
|
110
|
-
"rconEnable": "Enable enable-rcon=true in server.properties",
|
|
111
|
-
"connecting": "Connecting via RCON...",
|
|
112
|
-
"connected": "Connected — type commands (exit to quit)",
|
|
113
|
-
"prompt": "> "
|
|
114
|
-
},
|
|
115
|
-
"plugin": {
|
|
116
|
-
"titleList": "Plugin catalog",
|
|
117
|
-
"titleInstall": "Install plugins",
|
|
118
|
-
"titleInstalled": "Installed plugins",
|
|
119
|
-
"titleRemove": "Remove plugins",
|
|
120
|
-
"titleInfo": "Plugin info",
|
|
121
|
-
"titleSearch": "Search plugins",
|
|
122
|
-
"titleUpdate": "Update plugins",
|
|
123
|
-
"fetching": "Fetching from marketplace...",
|
|
124
|
-
"fetchError": "Error: {0}",
|
|
125
|
-
"notFound": "Plugin not found: {0}",
|
|
126
|
-
"noPlugins": "No plugins installed",
|
|
127
|
-
"noPluginsDir": "No plugins/ directory",
|
|
128
|
-
"selectInstall": "Select plugins to install:",
|
|
129
|
-
"selectRemove": "Select plugins to remove:",
|
|
130
|
-
"selectUpdate": "Select plugins to update:",
|
|
131
|
-
"installSuccess": "{0} installed",
|
|
132
|
-
"installError": "Error installing {0}",
|
|
133
|
-
"removeConfirm": "Remove {0}?",
|
|
134
|
-
"removed": "{0} removed",
|
|
135
|
-
"alreadyLatest": "{0} is already up to date (v{1})",
|
|
136
|
-
"updated": "{0} updated to v{1}",
|
|
137
|
-
"noRelease": "No release available for {0}",
|
|
138
|
-
"urlInvalid": "URL must point to a .jar file",
|
|
139
|
-
"restartHint": "Restart the server to load plugins",
|
|
140
|
-
"count": "{0} plugin(s)"
|
|
141
|
-
},
|
|
142
|
-
"errors": {
|
|
143
|
-
"timeout": "Request timed out",
|
|
144
|
-
"network": "Network error: {0}"
|
|
145
|
-
}
|
|
146
|
-
}
|
package/dist/lang/fr.json
DELETED
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"cli": { "description": "PowerNukkitX CLI — Gérez vos serveurs Minecraft Bedrock" },
|
|
3
|
-
"init": {
|
|
4
|
-
"title": "Créer un serveur PowerNukkitX",
|
|
5
|
-
"promptDir": "Répertoire du serveur ?",
|
|
6
|
-
"alreadyExists": "Un serveur existe déjà ici",
|
|
7
|
-
"fetchingInfo": "Récupération de la dernière version...",
|
|
8
|
-
"latestVersion": "Dernière version",
|
|
9
|
-
"downloading": "Téléchargement",
|
|
10
|
-
"downloaded": "Téléchargé ({0} Mo)",
|
|
11
|
-
"downloadingScripts": "Téléchargement des scripts...",
|
|
12
|
-
"scriptsDownloaded": "Scripts téléchargés",
|
|
13
|
-
"success": "Serveur prêt !",
|
|
14
|
-
"launchPrompt": "Démarrer le serveur maintenant ?"
|
|
15
|
-
},
|
|
16
|
-
"start": {
|
|
17
|
-
"title": "Démarrage du serveur",
|
|
18
|
-
"notFound": "Aucun serveur trouvé ici",
|
|
19
|
-
"createPrompt": "Créer un serveur maintenant ?",
|
|
20
|
-
"checkingJava": "Vérification de Java...",
|
|
21
|
-
"javaOk": "Java {0} détecté",
|
|
22
|
-
"javaNotFound": "Java 21+ requis — https://adoptium.net/",
|
|
23
|
-
"starting": "Démarrage...",
|
|
24
|
-
"running": "Serveur en cours d'exécution (PID {0})",
|
|
25
|
-
"stopped": "Serveur arrêté (code {0})",
|
|
26
|
-
"restarting": "Redémarrage..."
|
|
27
|
-
},
|
|
28
|
-
"stop": {
|
|
29
|
-
"title": "Arrêt du serveur",
|
|
30
|
-
"notRunning": "Aucun serveur en cours d'exécution",
|
|
31
|
-
"killing": "Arrêt du serveur (PID {0})...",
|
|
32
|
-
"done": "Serveur arrêté"
|
|
33
|
-
},
|
|
34
|
-
"update": {
|
|
35
|
-
"title": "Mise à jour PowerNukkitX",
|
|
36
|
-
"checking": "Vérification des mises à jour...",
|
|
37
|
-
"notFound": "Aucun serveur trouvé",
|
|
38
|
-
"available": "Nouvelle version disponible : {0}",
|
|
39
|
-
"upToDate": "Déjà à jour ({0})",
|
|
40
|
-
"saving": "Sauvegarde de l'ancienne version...",
|
|
41
|
-
"downloading": "Téléchargement...",
|
|
42
|
-
"done": "Mise à jour terminée !",
|
|
43
|
-
"restart": "Redémarrez le serveur pour appliquer les changements"
|
|
44
|
-
},
|
|
45
|
-
"doctor": {
|
|
46
|
-
"title": "Diagnostic du serveur",
|
|
47
|
-
"checking": "Analyse en cours...",
|
|
48
|
-
"java": "Java",
|
|
49
|
-
"server": "Serveur",
|
|
50
|
-
"system": "Système",
|
|
51
|
-
"plugins": "Plugins & Mondes",
|
|
52
|
-
"network": "Réseau",
|
|
53
|
-
"done": "Diagnostic terminé"
|
|
54
|
-
},
|
|
55
|
-
"info": {
|
|
56
|
-
"title": "Informations du serveur",
|
|
57
|
-
"server": "Serveur",
|
|
58
|
-
"system": "Système",
|
|
59
|
-
"status": "Statut",
|
|
60
|
-
"installed": "Installé",
|
|
61
|
-
"notInstalled": "Non installé",
|
|
62
|
-
"path": "Chemin",
|
|
63
|
-
"plugins": "Plugins",
|
|
64
|
-
"worlds": "Mondes",
|
|
65
|
-
"ram": "RAM libre",
|
|
66
|
-
"ready": "Prêt à démarrer avec 'pnx start'",
|
|
67
|
-
"notReady": "Exécutez 'pnx init' pour créer un serveur"
|
|
68
|
-
},
|
|
69
|
-
"backup": {
|
|
70
|
-
"title": "Sauvegarde",
|
|
71
|
-
"noServer": "Aucun serveur détecté",
|
|
72
|
-
"collecting": "Collecte des fichiers...",
|
|
73
|
-
"size": "Taille estimée : {0}",
|
|
74
|
-
"copying": "Copie en cours...",
|
|
75
|
-
"done": "Sauvegarde créée : {0} ({1})"
|
|
76
|
-
},
|
|
77
|
-
"config": {
|
|
78
|
-
"title": "Configuration",
|
|
79
|
-
"noServer": "Aucun serveur détecté",
|
|
80
|
-
"notFound": "Aucun fichier de config trouvé",
|
|
81
|
-
"editHint": "Modifiez {0} pour changer ces valeurs"
|
|
82
|
-
},
|
|
83
|
-
"use": {
|
|
84
|
-
"title": "Serveur par défaut",
|
|
85
|
-
"prompt": "Sélectionnez un serveur :",
|
|
86
|
-
"pathPrompt": "Chemin du serveur :",
|
|
87
|
-
"set": "Serveur par défaut défini : {0}",
|
|
88
|
-
"cleared": "Serveur par défaut supprimé",
|
|
89
|
-
"notFound": "powernukkitx.jar introuvable dans : {0}"
|
|
90
|
-
},
|
|
91
|
-
"lang": {
|
|
92
|
-
"title": "Langue",
|
|
93
|
-
"prompt": "Choisissez votre langue",
|
|
94
|
-
"set": "Langue définie sur {0}",
|
|
95
|
-
"menu": "Que voulez-vous faire ?",
|
|
96
|
-
"exit": "Quitter",
|
|
97
|
-
"back": "Retour"
|
|
98
|
-
},
|
|
99
|
-
"logs": {
|
|
100
|
-
"title": "Logs du serveur",
|
|
101
|
-
"noServer": "Aucun serveur détecté",
|
|
102
|
-
"noLogs": "Aucun fichier de logs trouvé",
|
|
103
|
-
"watching": "Lecture de {0}",
|
|
104
|
-
"liveMode": "Mode live (Ctrl+C pour quitter)"
|
|
105
|
-
},
|
|
106
|
-
"console": {
|
|
107
|
-
"title": "Console du serveur",
|
|
108
|
-
"noServer": "Aucun serveur en cours d'exécution",
|
|
109
|
-
"rconDisabled": "RCON désactivé dans server.properties",
|
|
110
|
-
"rconEnable": "Activez enable-rcon=true dans server.properties",
|
|
111
|
-
"connecting": "Connexion RCON...",
|
|
112
|
-
"connected": "Connecté — tapez des commandes (exit pour quitter)",
|
|
113
|
-
"prompt": "> "
|
|
114
|
-
},
|
|
115
|
-
"plugin": {
|
|
116
|
-
"titleList": "Catalogue de plugins",
|
|
117
|
-
"titleInstall": "Installation de plugins",
|
|
118
|
-
"titleInstalled": "Plugins installés",
|
|
119
|
-
"titleRemove": "Suppression de plugins",
|
|
120
|
-
"titleInfo": "Informations du plugin",
|
|
121
|
-
"titleSearch": "Recherche de plugins",
|
|
122
|
-
"titleUpdate": "Mise à jour des plugins",
|
|
123
|
-
"fetching": "Récupération depuis la marketplace...",
|
|
124
|
-
"fetchError": "Erreur : {0}",
|
|
125
|
-
"notFound": "Plugin introuvable : {0}",
|
|
126
|
-
"noPlugins": "Aucun plugin installé",
|
|
127
|
-
"noPluginsDir": "Aucun répertoire plugins/",
|
|
128
|
-
"selectInstall": "Sélectionnez les plugins à installer :",
|
|
129
|
-
"selectRemove": "Sélectionnez les plugins à supprimer :",
|
|
130
|
-
"selectUpdate": "Sélectionnez les plugins à mettre à jour :",
|
|
131
|
-
"installSuccess": "{0} installé",
|
|
132
|
-
"installError": "Erreur lors de l'installation de {0}",
|
|
133
|
-
"removeConfirm": "Supprimer {0} ?",
|
|
134
|
-
"removed": "{0} supprimé",
|
|
135
|
-
"alreadyLatest": "{0} est déjà à jour (v{1})",
|
|
136
|
-
"updated": "{0} mis à jour vers v{1}",
|
|
137
|
-
"noRelease": "Aucune version disponible pour {0}",
|
|
138
|
-
"urlInvalid": "L'URL doit pointer vers un .jar",
|
|
139
|
-
"restartHint": "Redémarrez le serveur pour charger les plugins",
|
|
140
|
-
"count": "{0} plugin(s)"
|
|
141
|
-
},
|
|
142
|
-
"errors": {
|
|
143
|
-
"timeout": "Délai dépassé",
|
|
144
|
-
"network": "Erreur réseau : {0}"
|
|
145
|
-
}
|
|
146
|
-
}
|
package/dist/lang/index.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export type LanguageCode = 'en' | 'fr';
|
|
2
|
-
export declare function saveLanguage(code: LanguageCode): void;
|
|
3
|
-
export declare function hasSavedLanguage(): boolean;
|
|
4
|
-
export declare function setLanguage(code: LanguageCode): void;
|
|
5
|
-
export declare function initLanguage(cliLang?: string): LanguageCode;
|
|
6
|
-
export declare function getLanguage(): LanguageCode;
|
|
7
|
-
export declare function t(key: string, ...args: any[]): string;
|
package/dist/lang/index.js
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import { readFileSync, existsSync, mkdirSync, writeFileSync } from 'node:fs';
|
|
2
|
-
import { homedir } from 'node:os';
|
|
3
|
-
import { join } from 'node:path';
|
|
4
|
-
import en from './en.json' with { type: 'json' };
|
|
5
|
-
import fr from './fr.json' with { type: 'json' };
|
|
6
|
-
const translations = { en, fr };
|
|
7
|
-
const CONFIG_DIR = join(homedir(), '.pnx-cli');
|
|
8
|
-
const CONFIG_FILE = join(CONFIG_DIR, 'config.json');
|
|
9
|
-
let _code = 'en';
|
|
10
|
-
let _strings = translations.en;
|
|
11
|
-
function detectLanguage() {
|
|
12
|
-
const envLang = process.env.PNX_LANG || process.env.LANG || '';
|
|
13
|
-
if (envLang.startsWith('fr'))
|
|
14
|
-
return 'fr';
|
|
15
|
-
return 'en';
|
|
16
|
-
}
|
|
17
|
-
function loadSavedLanguage() {
|
|
18
|
-
try {
|
|
19
|
-
if (existsSync(CONFIG_FILE)) {
|
|
20
|
-
const raw = readFileSync(CONFIG_FILE, 'utf-8');
|
|
21
|
-
const cfg = JSON.parse(raw);
|
|
22
|
-
if (cfg.lang === 'en' || cfg.lang === 'fr')
|
|
23
|
-
return cfg.lang;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
catch { /* ignore */ }
|
|
27
|
-
return null;
|
|
28
|
-
}
|
|
29
|
-
export function saveLanguage(code) {
|
|
30
|
-
try {
|
|
31
|
-
if (!existsSync(CONFIG_DIR))
|
|
32
|
-
mkdirSync(CONFIG_DIR, { recursive: true });
|
|
33
|
-
const existing = existsSync(CONFIG_FILE) ? JSON.parse(readFileSync(CONFIG_FILE, 'utf-8')) : {};
|
|
34
|
-
existing.lang = code;
|
|
35
|
-
writeFileSync(CONFIG_FILE, JSON.stringify(existing, null, 2), 'utf-8');
|
|
36
|
-
}
|
|
37
|
-
catch { /* ignore */ }
|
|
38
|
-
}
|
|
39
|
-
export function hasSavedLanguage() {
|
|
40
|
-
return loadSavedLanguage() !== null;
|
|
41
|
-
}
|
|
42
|
-
export function setLanguage(code) {
|
|
43
|
-
_code = code;
|
|
44
|
-
_strings = translations[code] || translations.en;
|
|
45
|
-
}
|
|
46
|
-
export function initLanguage(cliLang) {
|
|
47
|
-
const code = (cliLang ||
|
|
48
|
-
loadSavedLanguage() ||
|
|
49
|
-
detectLanguage());
|
|
50
|
-
setLanguage(code);
|
|
51
|
-
return _code;
|
|
52
|
-
}
|
|
53
|
-
export function getLanguage() {
|
|
54
|
-
return _code;
|
|
55
|
-
}
|
|
56
|
-
export function t(key, ...args) {
|
|
57
|
-
const keys = key.split('.');
|
|
58
|
-
let value = _strings;
|
|
59
|
-
for (const k of keys) {
|
|
60
|
-
if (value && typeof value === 'object' && k in value) {
|
|
61
|
-
value = value[k];
|
|
62
|
-
}
|
|
63
|
-
else {
|
|
64
|
-
value = undefined;
|
|
65
|
-
break;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
if (typeof value === 'string') {
|
|
69
|
-
return value.replace(/{(\d+)}/g, (_, i) => String(args[parseInt(i)] ?? `{${i}}`));
|
|
70
|
-
}
|
|
71
|
-
// fallback to English
|
|
72
|
-
let fallback = translations.en;
|
|
73
|
-
for (const k of keys) {
|
|
74
|
-
if (fallback && typeof fallback === 'object' && k in fallback) {
|
|
75
|
-
fallback = fallback[k];
|
|
76
|
-
}
|
|
77
|
-
else {
|
|
78
|
-
fallback = undefined;
|
|
79
|
-
break;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
return typeof fallback === 'string' ? fallback : key;
|
|
83
|
-
}
|
package/dist/main.d.ts
DELETED
package/dist/main.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { defineCommand, runMain } from 'citty';
|
|
3
|
-
import { initLanguage } from './lang/index.js';
|
|
4
|
-
// Init language before anything
|
|
5
|
-
initLanguage();
|
|
6
|
-
const main = defineCommand({
|
|
7
|
-
meta: {
|
|
8
|
-
name: 'pnx',
|
|
9
|
-
version: '1.0.0',
|
|
10
|
-
description: 'PowerNukkitX CLI — Manage your Minecraft Bedrock servers',
|
|
11
|
-
},
|
|
12
|
-
subCommands: {
|
|
13
|
-
init: () => import('./commands/init.js').then(m => m.initCmd),
|
|
14
|
-
start: () => import('./commands/start.js').then(m => m.startCmd),
|
|
15
|
-
stop: () => import('./commands/stop.js').then(m => m.stopCmd),
|
|
16
|
-
update: () => import('./commands/update.js').then(m => m.updateCmd),
|
|
17
|
-
info: () => import('./commands/info.js').then(m => m.infoCmd),
|
|
18
|
-
doctor: () => import('./commands/doctor.js').then(m => m.doctorCmd),
|
|
19
|
-
backup: () => import('./commands/backup.js').then(m => m.backupCmd),
|
|
20
|
-
config: () => import('./commands/cfg.js').then(m => m.configCmd),
|
|
21
|
-
use: () => import('./commands/use.js').then(m => m.useCmd),
|
|
22
|
-
lang: () => import('./commands/lang.js').then(m => m.langCmd),
|
|
23
|
-
logs: () => import('./commands/logs.js').then(m => m.logsCmd),
|
|
24
|
-
console: () => import('./commands/console.js').then(m => m.consoleCmd),
|
|
25
|
-
plugin: () => import('./commands/plugin/index.js').then(m => m.pluginCmd),
|
|
26
|
-
},
|
|
27
|
-
});
|
|
28
|
-
runMain(main);
|
package/dist/plugins.json
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"essentials": {
|
|
3
|
-
"name": "EssentialsPNX",
|
|
4
|
-
"description": "Essential commands pour votre serveur PNX (tpa, warp, home, etc.)",
|
|
5
|
-
"author": "PowerNukkitX",
|
|
6
|
-
"source": "github",
|
|
7
|
-
"repo": "PowerNukkitX/EssentialsPNX",
|
|
8
|
-
"asset": "EssentialsPNX.jar"
|
|
9
|
-
},
|
|
10
|
-
"economyapi": {
|
|
11
|
-
"name": "EconomyAPI",
|
|
12
|
-
"description": "Système économique complet pour votre serveur",
|
|
13
|
-
"author": "onebone",
|
|
14
|
-
"source": "github",
|
|
15
|
-
"repo": "onebone/EconomyAPI",
|
|
16
|
-
"asset": "EconomyAPI.jar"
|
|
17
|
-
},
|
|
18
|
-
"lands": {
|
|
19
|
-
"name": "Lands",
|
|
20
|
-
"description": "Système de protection de terrains et claims",
|
|
21
|
-
"author": "Angelic47",
|
|
22
|
-
"source": "github",
|
|
23
|
-
"repo": "Angelic47/Lands",
|
|
24
|
-
"asset": "Lands.jar"
|
|
25
|
-
},
|
|
26
|
-
"worldprotect": {
|
|
27
|
-
"name": "WorldProtect",
|
|
28
|
-
"description": "Protection et gestion avancée des mondes",
|
|
29
|
-
"author": "PowerNukkitX",
|
|
30
|
-
"source": "github",
|
|
31
|
-
"repo": "PowerNukkitX/WorldProtect",
|
|
32
|
-
"asset": "WorldProtect.jar"
|
|
33
|
-
},
|
|
34
|
-
"motd": {
|
|
35
|
-
"name": "MOTD",
|
|
36
|
-
"description": "Personnalisation du message du jour sur votre serveur",
|
|
37
|
-
"author": "PowerNukkitX",
|
|
38
|
-
"source": "github",
|
|
39
|
-
"repo": "PowerNukkitX/MOTD",
|
|
40
|
-
"asset": "MOTD.jar"
|
|
41
|
-
},
|
|
42
|
-
"fawe": {
|
|
43
|
-
"name": "FastAsyncWorldEdit",
|
|
44
|
-
"description": "WorldEdit ultra-rapide pour PNX",
|
|
45
|
-
"author": "IntellectualSites",
|
|
46
|
-
"source": "github",
|
|
47
|
-
"repo": "IntellectualSites/FastAsyncWorldEdit",
|
|
48
|
-
"asset": "FastAsyncWorldEdit-Bukkit.jar"
|
|
49
|
-
},
|
|
50
|
-
"tpsoptimizer": {
|
|
51
|
-
"name": "TPSOptimizer",
|
|
52
|
-
"description": "Optimise les performances et le TPS de votre serveur",
|
|
53
|
-
"author": "Creeperface01",
|
|
54
|
-
"source": "github",
|
|
55
|
-
"repo": "Creeperface01/TPSOptimizer",
|
|
56
|
-
"asset": "TPSOptimizer.jar"
|
|
57
|
-
},
|
|
58
|
-
"pets": {
|
|
59
|
-
"name": "Pets",
|
|
60
|
-
"description": "Ajoute des animaux de compagnie personnalisés",
|
|
61
|
-
"author": "PetteriM1",
|
|
62
|
-
"source": "github",
|
|
63
|
-
"repo": "PetteriM1/Pets",
|
|
64
|
-
"asset": "Pets.jar"
|
|
65
|
-
}
|
|
66
|
-
}
|
package/dist/types.d.ts
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
export interface PluginListItem {
|
|
2
|
-
name: string;
|
|
3
|
-
slug: string;
|
|
4
|
-
description: string;
|
|
5
|
-
tags: string[];
|
|
6
|
-
version: string;
|
|
7
|
-
downloads: number;
|
|
8
|
-
stars: number;
|
|
9
|
-
author: string;
|
|
10
|
-
}
|
|
11
|
-
export interface PluginFile {
|
|
12
|
-
id: string;
|
|
13
|
-
name: string;
|
|
14
|
-
url: string;
|
|
15
|
-
size: number;
|
|
16
|
-
}
|
|
17
|
-
export interface PluginRelease {
|
|
18
|
-
id: string;
|
|
19
|
-
version: string;
|
|
20
|
-
is_stable: boolean;
|
|
21
|
-
created_at: string;
|
|
22
|
-
tag: string;
|
|
23
|
-
files: PluginFile[];
|
|
24
|
-
}
|
|
25
|
-
export interface PluginDetail {
|
|
26
|
-
name: string;
|
|
27
|
-
slug: string;
|
|
28
|
-
description: string;
|
|
29
|
-
long_description: string;
|
|
30
|
-
tags: string[];
|
|
31
|
-
downloads: number;
|
|
32
|
-
stars: number;
|
|
33
|
-
author: string;
|
|
34
|
-
author_id: string;
|
|
35
|
-
icon_url: string | null;
|
|
36
|
-
banner_url: string | null;
|
|
37
|
-
repository_url: string | null;
|
|
38
|
-
documentation_url: string | null;
|
|
39
|
-
license_url: string | null;
|
|
40
|
-
website_url: string | null;
|
|
41
|
-
created_at: string;
|
|
42
|
-
updated_at: string;
|
|
43
|
-
latest_version: string;
|
|
44
|
-
releases: PluginRelease[];
|
|
45
|
-
}
|
|
46
|
-
export interface PluginListResponse {
|
|
47
|
-
plugins: PluginListItem[];
|
|
48
|
-
count: number;
|
|
49
|
-
}
|
|
50
|
-
export interface ServerConfig {
|
|
51
|
-
jarPath: string;
|
|
52
|
-
javaArgs: string[];
|
|
53
|
-
autoRestart: boolean;
|
|
54
|
-
}
|
|
55
|
-
export interface InstalledPlugin {
|
|
56
|
-
slug: string;
|
|
57
|
-
name: string;
|
|
58
|
-
version: string;
|
|
59
|
-
installedAt: string;
|
|
60
|
-
fileName: string;
|
|
61
|
-
}
|
package/dist/types.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/utils/api.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { PluginListResponse, PluginDetail } from '../types.js';
|
|
2
|
-
export declare function fetchPluginsList(params?: {
|
|
3
|
-
sort?: string;
|
|
4
|
-
limit?: number;
|
|
5
|
-
page?: number;
|
|
6
|
-
q?: string;
|
|
7
|
-
}): Promise<PluginListResponse>;
|
|
8
|
-
export declare function fetchPluginDetail(slug: string): Promise<PluginDetail>;
|
|
9
|
-
export declare function proxyDownloadUrl(slug: string, version?: string): string;
|
package/dist/utils/api.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { fetchJSON } from '../core/network.js';
|
|
2
|
-
let API_BASE = (process.env.PNX_API_URL ?? 'https://api.powernukkitx.org').replace(/\/$/, '');
|
|
3
|
-
export async function fetchPluginsList(params) {
|
|
4
|
-
const qs = new URLSearchParams();
|
|
5
|
-
if (params?.sort)
|
|
6
|
-
qs.set('sort', params.sort);
|
|
7
|
-
if (params?.limit)
|
|
8
|
-
qs.set('limit', String(params.limit));
|
|
9
|
-
if (params?.page)
|
|
10
|
-
qs.set('page', String(params.page));
|
|
11
|
-
if (params?.q)
|
|
12
|
-
qs.set('q', params.q);
|
|
13
|
-
const q = qs.toString();
|
|
14
|
-
return fetchJSON(`${API_BASE}/api/plugins/cli${q ? `?${q}` : ''}`);
|
|
15
|
-
}
|
|
16
|
-
export async function fetchPluginDetail(slug) {
|
|
17
|
-
return fetchJSON(`${API_BASE}/api/plugins/cli/${encodeURIComponent(slug)}`);
|
|
18
|
-
}
|
|
19
|
-
export function proxyDownloadUrl(slug, version) {
|
|
20
|
-
const qs = new URLSearchParams({ proxy: '1' });
|
|
21
|
-
if (version)
|
|
22
|
-
qs.set('version', version);
|
|
23
|
-
return `${API_BASE}/api/plugins/${encodeURIComponent(slug)}/download?${qs}`;
|
|
24
|
-
}
|
package/dist/utils/github.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
interface GitHubAsset {
|
|
2
|
-
name: string;
|
|
3
|
-
browser_download_url: string;
|
|
4
|
-
size: number;
|
|
5
|
-
}
|
|
6
|
-
interface GitHubRelease {
|
|
7
|
-
tag_name: string;
|
|
8
|
-
assets: GitHubAsset[];
|
|
9
|
-
published_at: string;
|
|
10
|
-
body: string;
|
|
11
|
-
}
|
|
12
|
-
export declare function getLatestRelease(): Promise<GitHubRelease>;
|
|
13
|
-
export declare function findAsset(release: GitHubRelease, name: string): GitHubAsset | undefined;
|
|
14
|
-
export declare function getStartScripts(): {
|
|
15
|
-
url: string;
|
|
16
|
-
name: string;
|
|
17
|
-
}[];
|
|
18
|
-
export declare function getDefaultJavaArgs(): string[];
|
|
19
|
-
export declare function getJavaEnv(): NodeJS.ProcessEnv;
|
|
20
|
-
export {};
|
package/dist/utils/github.js
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { fetchJSON } from '../core/network.js';
|
|
2
|
-
import { platform } from 'node:os';
|
|
3
|
-
import { existsSync } from 'node:fs';
|
|
4
|
-
import { readFile, writeFile, mkdir } from 'node:fs/promises';
|
|
5
|
-
import { homedir } from 'node:os';
|
|
6
|
-
import { join } from 'node:path';
|
|
7
|
-
const CACHE_DIR = join(homedir(), '.pnx-cli');
|
|
8
|
-
const CACHE_FILE = join(CACHE_DIR, 'latest-release.json');
|
|
9
|
-
const CACHE_TTL = 3_600_000;
|
|
10
|
-
async function getCached() {
|
|
11
|
-
try {
|
|
12
|
-
if (existsSync(CACHE_FILE)) {
|
|
13
|
-
const c = JSON.parse(await readFile(CACHE_FILE, 'utf-8'));
|
|
14
|
-
if (Date.now() - c.fetchedAt < CACHE_TTL)
|
|
15
|
-
return c.data;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
catch { }
|
|
19
|
-
return null;
|
|
20
|
-
}
|
|
21
|
-
async function setCache(data) {
|
|
22
|
-
try {
|
|
23
|
-
await mkdir(CACHE_DIR, { recursive: true });
|
|
24
|
-
await writeFile(CACHE_FILE, JSON.stringify({ fetchedAt: Date.now(), data }), 'utf-8');
|
|
25
|
-
}
|
|
26
|
-
catch { }
|
|
27
|
-
}
|
|
28
|
-
export async function getLatestRelease() {
|
|
29
|
-
const cached = await getCached();
|
|
30
|
-
if (cached)
|
|
31
|
-
return cached;
|
|
32
|
-
const data = await fetchJSON('https://api.github.com/repos/PowerNukkitX/PowerNukkitX/releases/latest');
|
|
33
|
-
await setCache(data);
|
|
34
|
-
return data;
|
|
35
|
-
}
|
|
36
|
-
export function findAsset(release, name) {
|
|
37
|
-
return release.assets.find(a => a.name === name);
|
|
38
|
-
}
|
|
39
|
-
export function getStartScripts() {
|
|
40
|
-
const base = 'https://raw.githubusercontent.com/PowerNukkitX/scripts/master';
|
|
41
|
-
if (platform() === 'win32')
|
|
42
|
-
return [
|
|
43
|
-
{ url: `${base}/start.bat`, name: 'start.bat' },
|
|
44
|
-
{ url: `${base}/start.ps1`, name: 'start.ps1' },
|
|
45
|
-
];
|
|
46
|
-
return [{ url: `${base}/start.sh`, name: 'start.sh' }];
|
|
47
|
-
}
|
|
48
|
-
export function getDefaultJavaArgs() {
|
|
49
|
-
return [
|
|
50
|
-
'-Dfile.encoding=UTF-8', '-Dstdout.encoding=UTF-8', '-Dstderr.encoding=UTF-8',
|
|
51
|
-
'-Djansi.passthrough=true', '-Dterminal.ansi=true',
|
|
52
|
-
'-XX:+UseZGC', '-XX:+ZGenerational', '-XX:+UseStringDeduplication',
|
|
53
|
-
'--add-opens', 'java.base/java.lang=ALL-UNNAMED',
|
|
54
|
-
'--add-opens', 'java.base/java.io=ALL-UNNAMED',
|
|
55
|
-
'--add-opens', 'java.base/java.net=ALL-UNNAMED',
|
|
56
|
-
];
|
|
57
|
-
}
|
|
58
|
-
export function getJavaEnv() {
|
|
59
|
-
return { ...process.env, JAVA_TOOL_OPTIONS: '-Dfile.encoding=UTF-8', LANG: process.env.LANG ?? 'en_US.UTF-8' };
|
|
60
|
-
}
|