@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.
Files changed (98) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +186 -203
  3. package/dist/cli.js +34 -46
  4. package/dist/commands/backup.d.ts +2 -2
  5. package/dist/commands/backup.js +23 -24
  6. package/dist/commands/config.d.ts +1 -1
  7. package/dist/commands/config.js +60 -61
  8. package/dist/commands/console.d.ts +2 -2
  9. package/dist/commands/console.js +98 -99
  10. package/dist/commands/doctor.d.ts +2 -2
  11. package/dist/commands/doctor.js +97 -98
  12. package/dist/commands/info.d.ts +2 -2
  13. package/dist/commands/info.js +41 -42
  14. package/dist/commands/init.d.ts +2 -2
  15. package/dist/commands/init.js +87 -66
  16. package/dist/commands/install.js +45 -0
  17. package/dist/commands/logs.d.ts +2 -2
  18. package/dist/commands/logs.js +60 -61
  19. package/dist/commands/menu.js +94 -86
  20. package/dist/commands/plugin/index.d.ts +2 -2
  21. package/dist/commands/plugin/index.js +13 -13
  22. package/dist/commands/plugin/info.d.ts +2 -2
  23. package/dist/commands/plugin/info.js +39 -40
  24. package/dist/commands/plugin/install.d.ts +2 -2
  25. package/dist/commands/plugin/install.js +56 -57
  26. package/dist/commands/plugin/installed.d.ts +2 -2
  27. package/dist/commands/plugin/installed.js +41 -42
  28. package/dist/commands/plugin/list.d.ts +2 -2
  29. package/dist/commands/plugin/list.js +47 -49
  30. package/dist/commands/plugin/remove.d.ts +2 -2
  31. package/dist/commands/plugin/remove.js +44 -45
  32. package/dist/commands/plugin/search.d.ts +2 -2
  33. package/dist/commands/plugin/search.js +11 -12
  34. package/dist/commands/plugin/update.d.ts +2 -2
  35. package/dist/commands/plugin/update.js +52 -53
  36. package/dist/commands/start.d.ts +2 -2
  37. package/dist/commands/start.js +74 -75
  38. package/dist/commands/stop.d.ts +2 -2
  39. package/dist/commands/stop.js +26 -27
  40. package/dist/commands/update.d.ts +2 -2
  41. package/dist/commands/update.js +34 -35
  42. package/dist/commands/use.d.ts +2 -2
  43. package/dist/commands/use.js +39 -40
  44. package/dist/infra/http.js +119 -121
  45. package/dist/infra/paths.js +15 -20
  46. package/dist/infra/store.js +24 -27
  47. package/dist/services/backup.js +34 -40
  48. package/dist/services/plugins.js +139 -111
  49. package/dist/services/process.js +41 -43
  50. package/dist/services/release.js +51 -38
  51. package/dist/services/server.js +81 -89
  52. package/dist/ui/output.js +67 -71
  53. package/dist/ui/prompts.js +26 -30
  54. package/dist/ui/theme.js +16 -18
  55. package/package.json +44 -46
  56. package/dist/bundle.js +0 -18
  57. package/dist/commands/cfg.d.ts +0 -2
  58. package/dist/commands/cfg.js +0 -61
  59. package/dist/commands/lang.d.ts +0 -2
  60. package/dist/commands/lang.js +0 -28
  61. package/dist/commands/plugin.d.ts +0 -1
  62. package/dist/commands/plugin.js +0 -1
  63. package/dist/core/config.d.ts +0 -13
  64. package/dist/core/config.js +0 -31
  65. package/dist/core/network.d.ts +0 -13
  66. package/dist/core/network.js +0 -139
  67. package/dist/core/output.d.ts +0 -33
  68. package/dist/core/output.js +0 -75
  69. package/dist/core/process.d.ts +0 -10
  70. package/dist/core/process.js +0 -53
  71. package/dist/i18n/en.json +0 -174
  72. package/dist/i18n/fr.json +0 -174
  73. package/dist/i18n/index.js +0 -58
  74. package/dist/index.d.ts +0 -1
  75. package/dist/index.js +0 -1
  76. package/dist/lang/en.json +0 -146
  77. package/dist/lang/fr.json +0 -146
  78. package/dist/lang/index.d.ts +0 -7
  79. package/dist/lang/index.js +0 -83
  80. package/dist/main.d.ts +0 -2
  81. package/dist/main.js +0 -28
  82. package/dist/plugins.json +0 -66
  83. package/dist/types.d.ts +0 -61
  84. package/dist/types.js +0 -1
  85. package/dist/utils/api.d.ts +0 -9
  86. package/dist/utils/api.js +0 -24
  87. package/dist/utils/github.d.ts +0 -20
  88. package/dist/utils/github.js +0 -60
  89. package/dist/utils/logger.d.ts +0 -15
  90. package/dist/utils/logger.js +0 -72
  91. package/dist/utils/pause.d.ts +0 -1
  92. package/dist/utils/pause.js +0 -6
  93. package/dist/utils/plugins.d.ts +0 -4
  94. package/dist/utils/plugins.js +0 -34
  95. package/dist/utils/server.d.ts +0 -3
  96. package/dist/utils/server.js +0 -32
  97. package/dist/utils/updater.d.ts +0 -1
  98. package/dist/utils/updater.js +0 -86
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 AzaleeX
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,203 +1,186 @@
1
- # pnx-cli
2
-
3
- **PowerNukkitX CLI** outil en ligne de commande pour gérer un serveur **Minecraft Bedrock** propulsé par [PowerNukkitX](https://github.com/PowerNukkitX/PowerNukkitX).
4
-
5
- Créez, démarrez, mettez à jour et diagnostiquez votre serveur, gérez les plugins depuis la marketplace, le tout avec une interface soignée et un menu interactif — en français ou en anglais.
6
-
7
- ## Sommaire
8
-
9
- - [Installation](#installation)
10
- - [Prérequis](#prérequis)
11
- - [Démarrage rapide](#démarrage-rapide)
12
- - [Commandes](#commandes)
13
- - [Mode interactif](#mode-interactif)
14
- - [Options globales](#options-globales)
15
- - [Architecture](#architecture)
16
- - [Développement](#développement)
17
- - [Exécutables autonomes](#exécutables-autonomes-sea)
18
- - [Liens](#liens-utiles)
19
- - [Licence](#licence)
20
-
21
- ## Installation
22
-
23
- ```bash
24
- npm install -g @powernukkitx/cli
25
- ```
26
-
27
- La commande `pnx` devient alors disponible.
28
-
29
- Alternativement, téléchargez un exécutable autonome (voir [Exécutables autonomes](#exécutables-autonomes-sea)) — aucun Node.js requis pour l'utiliser.
30
-
31
- ## Prérequis
32
-
33
- - **Node.js 20.12+** (pour l'installation via npm ; inutile pour les binaires autonomes)
34
- - **Java 21+** pour lancer le serveur ([Adoptium Temurin](https://adoptium.net/) recommandé)
35
-
36
- ## Démarrage rapide
37
-
38
- ```bash
39
- # Menu interactif contextuel
40
- pnx
41
-
42
- # Créer un serveur puis le démarrer
43
- pnx init --dir ./pnx-server
44
- pnx start --memory 4G
45
-
46
- # Aide
47
- pnx --help
48
- pnx <commande> --help
49
- ```
50
-
51
- ## Commandes
52
-
53
- ### `init` — créer un serveur
54
-
55
- Télécharge le dernier `powernukkitx.jar` et les scripts de démarrage.
56
-
57
- ```bash
58
- pnx init --dir ./pnx-server
59
- ```
60
-
61
- | Option | Description |
62
- |---|---|
63
- | `--dir <path>` | Dossier cible (sinon demandé) |
64
- | `--dev` | Version de développement |
65
-
66
- ### `start` — démarrer le serveur
67
-
68
- Vérifie Java, construit les arguments JVM optimisés (ZGC générationnel, UTF-8) et lance le serveur.
69
-
70
- ```bash
71
- pnx start --memory 4G --restart
72
- ```
73
-
74
- | Option | Description |
75
- |---|---|
76
- | `--dir <path>` | Dossier du serveur |
77
- | `--memory <taille>` | Mémoire allouée, ex. `2G`, `4G` (défaut `2G`) |
78
- | `--restart` | Redémarrage automatique en cas de crash |
79
- | `--dry-run` | Affiche la commande sans l'exécuter |
80
-
81
- ### `stop` — arrêter le serveur
82
-
83
- Arrête le serveur démarré via son PID mémorisé.
84
-
85
- ```bash
86
- pnx stop
87
- ```
88
-
89
- ### `update` — mettre à jour le core
90
-
91
- Sauvegarde l'ancien jar en `.old` puis télécharge la dernière version.
92
-
93
- ```bash
94
- pnx update --force
95
- ```
96
-
97
- | Option | Description |
98
- |---|---|
99
- | `--force` | Force le re-téléchargement (ignore le cache) |
100
- | `--dev` | Version de développement |
101
-
102
- ### `plugin` — gérer les plugins
103
-
104
- Marketplace officielle + suivi local des versions installées.
105
-
106
- ```bash
107
- pnx plugin list # catalogue
108
- pnx plugin search essentials # recherche
109
- pnx plugin info <slug> # fiche détaillée
110
- pnx plugin install <slug|url.jar> # installer (marketplace ou URL .jar)
111
- pnx plugin installed # plugins locaux
112
- pnx plugin update [slug] # mettre à jour
113
- pnx plugin remove [nom] # supprimer
114
- ```
115
-
116
- Sans argument, `install`, `update` et `remove` proposent une sélection interactive.
117
-
118
- ### Diagnostics & utilitaires
119
-
120
- ```bash
121
- pnx doctor # Java, RAM, disque, port 19132, plugins/mondes
122
- pnx info # état, chemin, plugins, mondes, RAM
123
- pnx backup # sauvegarde horodatée du serveur
124
- pnx config # affiche pnx.yml / server.properties (coloré)
125
- pnx use ./serveur # définit le serveur par défaut
126
- pnx logs # derniers logs (avec suivi live)
127
- pnx console # console RCON attachée au serveur
128
- pnx lang --set fr # langue (fr / en)
129
- ```
130
-
131
- `doctor` et `info` acceptent `--json` pour une sortie machine.
132
-
133
- ## Mode interactif
134
-
135
- Lancée sans sous-commande, `pnx` ouvre un **menu contextuel** qui :
136
-
137
- - détecte l'état (serveur présent, démarré, PID) ;
138
- - ne propose que les actions pertinentes (créer si absent, démarrer si arrêté, arrêter si en cours…) ;
139
- - route vers les commandes existantes.
140
-
141
- ```bash
142
- pnx
143
- ```
144
-
145
- ## Options globales
146
-
147
- | Option | Description |
148
- |---|---|
149
- | `--json` | Sortie JSON machine (désactive le rendu décoratif) |
150
- | `--lang <fr\|en>` | Force la langue pour cette exécution |
151
- | `--no-color` | Désactive les couleurs |
152
-
153
- Résolution de la langue : `--lang` > configuration sauvegardée > variable d'environnement > **français** par défaut.
154
-
155
- L'état du CLI est stocké dans `~/.pnx-cli/` (config, PID, plugins installés, cache des versions). Variables d'environnement : `PNX_API_URL` (base de l'API marketplace), `PNX_HOME` (répertoire d'état).
156
-
157
- ## Architecture
158
-
159
- Le code suit une architecture en couches — commandes minces, logique métier isolée et testable :
160
-
161
- ```
162
- src/
163
- cli.ts point d'entrée (citty) + options globales
164
- commands/ parse des arguments appel service rendu
165
- plugin/ sous-commandes plugin
166
- services/ logique métier pure (release, server, process, plugins, backup)
167
- infra/ http, store JSON (~/.pnx-cli), constantes/endpoints
168
- ui/ système d'affichage unique (clack + chalk), prompts
169
- i18n/ traductions fr / en
170
- ```
171
-
172
- Règles : les commandes ne font aucun accès réseau/fichier direct (tout passe par `services`/`infra`) ; les services ne rendent rien (ils renvoient des données).
173
-
174
- **Stack** : TypeScript, [citty](https://github.com/unjs/citty) (routing), [@clack/prompts](https://github.com/bombshell-dev/clack) (prompts), [chalk](https://github.com/chalk/chalk) (couleurs).
175
-
176
- ## Développement
177
-
178
- ```bash
179
- npm install # dépendances
180
- npm run build # compile TypeScript → dist/ (+ copie des assets i18n)
181
- npm run dev # compilation en watch
182
- npm start # lance dist/cli.js
183
- npm test # tests des services (node:test + tsx)
184
- ```
185
-
186
- ## Exécutables autonomes (SEA)
187
-
188
- Le projet génère un binaire natif via **[Node Single Executable Applications](https://nodejs.org/api/single-executable-applications.html)** (bundling esbuild + injection `postject`) :
189
-
190
- ```bash
191
- npm run build:sea
192
- ```
193
-
194
- Produit `pnx` (ou `pnx.exe` sous Windows) pour **la plateforme hôte**. SEA ne cross-compile pas : lancez la commande sur chaque système cible (Windows / Linux / macOS) pour obtenir son binaire.
195
-
196
- ## Liens utiles
197
-
198
- - Documentation PowerNukkitX : https://docs.powernukkitx.org
199
- - Dépôt PowerNukkitX : https://github.com/PowerNukkitX/PowerNukkitX
200
-
201
- ## Licence
202
-
203
- MIT
1
+ # pnx-cli
2
+
3
+ **PowerNukkitX CLI** - command line tool to manage a **Minecraft Bedrock** server powered by [PowerNukkitX](https://github.com/PowerNukkitX/PowerNukkitX).
4
+
5
+ Create, start, update and diagnose your server, manage plugins from the marketplace, all with a clean interface and an interactive menu.
6
+
7
+ ## Contents
8
+
9
+ - [Installation](#installation)
10
+ - [Requirements](#requirements)
11
+ - [Quick start](#quick-start)
12
+ - [Commands](#commands)
13
+ - [Interactive mode](#interactive-mode)
14
+ - [Global options](#global-options)
15
+ - [Architecture](#architecture)
16
+ - [Development](#development)
17
+ - [Links](#links)
18
+ - [License](#license)
19
+
20
+ ## Installation
21
+
22
+ ```bash
23
+ npm install -g @powernukkitx/cli
24
+ ```
25
+
26
+ The `pnx` command becomes available.
27
+
28
+ ## Requirements
29
+
30
+ - **Node.js 20.12+**
31
+ - **Java 21+** to run the server ([Adoptium Temurin](https://adoptium.net/) recommended)
32
+
33
+ ## Quick start
34
+
35
+ ```bash
36
+ # Contextual interactive menu
37
+ pnx
38
+
39
+ # Create a server then start it
40
+ pnx init --dir ./pnx-server
41
+ pnx start --memory 4G
42
+
43
+ # Help
44
+ pnx --help
45
+ pnx <command> --help
46
+ ```
47
+
48
+ ## Commands
49
+
50
+ ### `init` - create a server
51
+
52
+ Downloads the latest `powernukkitx.jar` and the start scripts.
53
+
54
+ ```bash
55
+ pnx init --dir ./pnx-server
56
+ ```
57
+
58
+ | Option | Description |
59
+ |---|---|
60
+ | `--dir <path>` | Target directory (prompted otherwise) |
61
+ | `--dev` | Development build |
62
+
63
+ ### `start` - start the server
64
+
65
+ Checks Java, builds optimized JVM arguments (generational ZGC, UTF-8) and launches the server.
66
+
67
+ ```bash
68
+ pnx start --memory 4G --restart
69
+ ```
70
+
71
+ | Option | Description |
72
+ |---|---|
73
+ | `--dir <path>` | Server directory |
74
+ | `--memory <size>` | Allocated memory, e.g. `2G`, `4G` (default `2G`) |
75
+ | `--restart` | Auto restart on crash |
76
+ | `--dry-run` | Print the command without running it |
77
+
78
+ ### `stop` - stop the server
79
+
80
+ Stops the server started through its stored PID.
81
+
82
+ ```bash
83
+ pnx stop
84
+ ```
85
+
86
+ ### `update` - update the core
87
+
88
+ Backs up the old jar as `.old` then downloads the latest version.
89
+
90
+ ```bash
91
+ pnx update --force
92
+ ```
93
+
94
+ | Option | Description |
95
+ |---|---|
96
+ | `--force` | Force re-download (ignore cache) |
97
+ | `--dev` | Development build |
98
+
99
+ ### `plugin` - manage plugins
100
+
101
+ Official marketplace plus local tracking of installed versions.
102
+
103
+ ```bash
104
+ pnx plugin list # catalog
105
+ pnx plugin search essentials # search
106
+ pnx plugin info <slug> # details
107
+ pnx plugin install <slug|url.jar> # install (marketplace or .jar URL)
108
+ pnx plugin installed # local plugins
109
+ pnx plugin update [slug] # update
110
+ pnx plugin remove [name] # remove
111
+ ```
112
+
113
+ Without an argument, `install`, `update` and `remove` offer an interactive selection.
114
+
115
+ ### Diagnostics and utilities
116
+
117
+ ```bash
118
+ pnx doctor # Java, RAM, disk, port 19132, plugins/worlds
119
+ pnx info # status, path, plugins, worlds, RAM
120
+ pnx backup # timestamped server backup
121
+ pnx config # print pnx.yml / server.properties (colored)
122
+ pnx use ./server # set the default server
123
+ pnx logs # latest logs (with live follow)
124
+ pnx console # RCON console attached to the server
125
+ ```
126
+
127
+ `doctor` and `info` accept `--json` for machine output.
128
+
129
+ ## Interactive mode
130
+
131
+ Launched without a subcommand, `pnx` opens a **contextual menu** that:
132
+
133
+ - detects state (server present, running, PID);
134
+ - only offers relevant actions (create if missing, start if stopped, stop if running...);
135
+ - routes to the existing commands.
136
+
137
+ ```bash
138
+ pnx
139
+ ```
140
+
141
+ ## Global options
142
+
143
+ | Option | Description |
144
+ |---|---|
145
+ | `--json` | Machine JSON output (disables decorative rendering) |
146
+ | `--no-color` | Disable colors |
147
+
148
+ CLI state is stored in `~/.pnx-cli/` (config, PID, installed plugins, version cache). Environment variables: `PNX_API_URL` (marketplace API base), `PNX_HOME` (state directory).
149
+
150
+ ## Architecture
151
+
152
+ The code follows a layered architecture - thin commands, isolated business logic:
153
+
154
+ ```
155
+ dist/
156
+ cli.js entry point (citty) + global options
157
+ commands/ parse arguments -> call service -> render
158
+ plugin/ plugin subcommands
159
+ services/ pure business logic (release, server, process, plugins, backup)
160
+ infra/ http, JSON store (~/.pnx-cli), constants/endpoints
161
+ ui/ single output system (clack + chalk), prompts
162
+ ```
163
+
164
+ Rules: commands do no direct network/file access (everything goes through `services`/`infra`); services render nothing (they return data).
165
+
166
+ **Stack**: [citty](https://github.com/unjs/citty) (routing), [@clack/prompts](https://github.com/bombshell-dev/clack) (prompts), [chalk](https://github.com/chalk/chalk) (colors).
167
+
168
+ ## Development
169
+
170
+ The shipped code lives in `dist/` (plain ES modules, no build step).
171
+
172
+ ```bash
173
+ npm install # dependencies
174
+ npm start # run dist/cli.js
175
+ npm run check # syntax check every file
176
+ npm run smoke # run pnx --help
177
+ ```
178
+
179
+ ## Links
180
+
181
+ - PowerNukkitX documentation: https://docs.powernukkitx.org
182
+ - PowerNukkitX repository: https://github.com/PowerNukkitX/PowerNukkitX
183
+
184
+ ## License
185
+
186
+ MIT
package/dist/cli.js CHANGED
@@ -1,46 +1,34 @@
1
- #!/usr/bin/env node
2
- import { defineCommand, runMain } from 'citty';
3
- import { initLang } from './i18n/index.js';
4
- import { setColorEnabled } from './ui/theme.js';
5
- // Flags globaux traités avant le routing citty.
6
- const argv = process.argv.slice(2);
7
- const langFlag = (() => {
8
- const i = argv.findIndex(a => a === '--lang');
9
- if (i >= 0 && argv[i + 1])
10
- return argv[i + 1];
11
- const eq = argv.find(a => a.startsWith('--lang='));
12
- return eq ? eq.split('=')[1] : undefined;
13
- })();
14
- if (argv.includes('--no-color'))
15
- setColorEnabled(false);
16
- initLang(langFlag);
17
- const main = defineCommand({
18
- meta: {
19
- name: 'pnx',
20
- version: '1.0.0',
21
- description: 'PowerNukkitX CLI Manage your Minecraft Bedrock servers',
22
- },
23
- subCommands: {
24
- init: () => import('./commands/init.js').then(m => m.initCmd),
25
- start: () => import('./commands/start.js').then(m => m.startCmd),
26
- stop: () => import('./commands/stop.js').then(m => m.stopCmd),
27
- update: () => import('./commands/update.js').then(m => m.updateCmd),
28
- info: () => import('./commands/info.js').then(m => m.infoCmd),
29
- doctor: () => import('./commands/doctor.js').then(m => m.doctorCmd),
30
- backup: () => import('./commands/backup.js').then(m => m.backupCmd),
31
- config: () => import('./commands/config.js').then(m => m.configCmd),
32
- use: () => import('./commands/use.js').then(m => m.useCmd),
33
- lang: () => import('./commands/lang.js').then(m => m.langCmd),
34
- logs: () => import('./commands/logs.js').then(m => m.logsCmd),
35
- console: () => import('./commands/console.js').then(m => m.consoleCmd),
36
- plugin: () => import('./commands/plugin/index.js').then(m => m.pluginCmd),
37
- },
38
- async run({ args }) {
39
- // Aucune sous-commande → menu interactif.
40
- if (args._.length === 0) {
41
- const { runMenu } = await import('./commands/menu.js');
42
- await runMenu();
43
- }
44
- },
45
- });
46
- runMain(main);
1
+ #!/usr/bin/env node
2
+ import { defineCommand, runMain } from 'citty';
3
+ import { setColorEnabled } from './ui/theme.js';
4
+ if (process.argv.slice(2).includes('--no-color'))
5
+ setColorEnabled(false);
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
+ install: () => import('./commands/install.js').then(m => m.installCmd),
15
+ start: () => import('./commands/start.js').then(m => m.startCmd),
16
+ stop: () => import('./commands/stop.js').then(m => m.stopCmd),
17
+ update: () => import('./commands/update.js').then(m => m.updateCmd),
18
+ info: () => import('./commands/info.js').then(m => m.infoCmd),
19
+ doctor: () => import('./commands/doctor.js').then(m => m.doctorCmd),
20
+ backup: () => import('./commands/backup.js').then(m => m.backupCmd),
21
+ config: () => import('./commands/config.js').then(m => m.configCmd),
22
+ use: () => import('./commands/use.js').then(m => m.useCmd),
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
+ async run({ args }) {
28
+ if (args._.length === 0) {
29
+ const { runMenu } = await import('./commands/menu.js');
30
+ await runMenu();
31
+ }
32
+ },
33
+ });
34
+ runMain(main);
@@ -1,2 +1,2 @@
1
- import type { CommandDef } from 'citty';
2
- export declare const backupCmd: CommandDef;
1
+ import type { CommandDef } from 'citty';
2
+ export declare const backupCmd: CommandDef;
@@ -1,24 +1,23 @@
1
- import { defineCommand } from 'citty';
2
- import { intro, outro, log, spin } from '../ui/output.js';
3
- import { resolveServerDir } from '../services/server.js';
4
- import { createBackup, dirSize, fmtSize } from '../services/backup.js';
5
- import { t } from '../i18n/index.js';
6
- export async function runBackup() {
7
- intro(`💾 ${t('backup.title')}`);
8
- const serverPath = await resolveServerDir();
9
- if (!serverPath) {
10
- log.error(t('backup.noServer'));
11
- process.exit(1);
12
- }
13
- const sp = spin(t('backup.collecting'));
14
- sp.stop(t('backup.size', fmtSize(dirSize(serverPath))));
15
- const sp2 = spin(t('backup.copying'));
16
- const { path, size } = await createBackup(serverPath);
17
- sp2.stop(t('backup.done', path, fmtSize(size)));
18
- outro(t('backup.done', path, fmtSize(size)));
19
- }
20
- export const backupCmd = defineCommand({
21
- meta: { description: 'Create a server backup' },
22
- args: {},
23
- run: () => runBackup(),
24
- });
1
+ import { defineCommand } from 'citty';
2
+ import { intro, outro, log, spin } from '../ui/output.js';
3
+ import { resolveServerDir } from '../services/server.js';
4
+ import { createBackup, dirSize, fmtSize } from '../services/backup.js';
5
+ export async function runBackup() {
6
+ intro(`💾 ${"Backup"}`);
7
+ const serverPath = await resolveServerDir();
8
+ if (!serverPath) {
9
+ log.error("No server detected");
10
+ process.exit(1);
11
+ }
12
+ const sp = spin("Collecting files...");
13
+ sp.stop(`Estimated size: ${fmtSize(dirSize(serverPath))}`);
14
+ const sp2 = spin("Copying files...");
15
+ const { path, size } = await createBackup(serverPath);
16
+ sp2.stop(`Backup created: ${path} (${fmtSize(size)})`);
17
+ outro(`Backup created: ${path} (${fmtSize(size)})`);
18
+ }
19
+ export const backupCmd = defineCommand({
20
+ meta: { description: 'Create a server backup' },
21
+ args: {},
22
+ run: () => runBackup(),
23
+ });
@@ -1 +1 @@
1
- export declare function configCmd(): Promise<void>;
1
+ export declare function configCmd(): Promise<void>;