@iksdev/shard-cli 0.1.43 → 0.1.44

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/bin/shard.js +54 -26
  2. package/package.json +1 -1
package/bin/shard.js CHANGED
@@ -48,9 +48,9 @@ async function promptUpdate(latestVersion) {
48
48
  const msg = [
49
49
  '',
50
50
  '╔════════════════════════════════════════════════════╗',
51
- `║ 🚀 Mise à jour disponible : v${pkgLocal.version} → v${latestVersion}`.padEnd(52) + '║',
51
+ `║ 🚀 Mise à jour disponible : v${pkgLocal.version} → v${latestVersion}`.padEnd(52) + ' ║',
52
52
  '╠════════════════════════════════════════════════════╣',
53
- `║ npm i -g ${pkgLocal.name}@latest`.padEnd(52) + '║',
53
+ `║ npm i -g ${pkgLocal.name}@latest`.padEnd(52) + ' ║',
54
54
  '╚════════════════════════════════════════════════════╝',
55
55
  '',
56
56
  ' Mettre à jour maintenant ? [y/n] : ',
@@ -88,29 +88,32 @@ function printHelp() {
88
88
  ║ Shard ║
89
89
  ╚══════════════════════════════════════════════════╝
90
90
 
91
- Commandes disponibles:
92
- shard login Se connecter au serveur
93
- shard whoami Afficher l'utilisateur connecte
94
- shard sync <dossier> Synchroniser un dossier local
95
- shard share <fichier> Partager un fichier via relay
96
- shard logout Se deconnecter
91
+ Commandes disponibles:
92
+ shard login Se connecter au serveur
93
+ shard whoami Afficher l'utilisateur connecte
94
+ shard account Afficher username, email et plan
95
+ shard sync <dossier> Synchroniser un dossier local
96
+ shard share <fichier> Partager un fichier via relay
97
+ shard logout Se deconnecter
97
98
  shard config show Afficher la configuration
98
99
  shard config set-server <url> Changer de serveur
99
100
 
100
101
  Mode interactif:
101
102
  Lance une commande sans arguments et la CLI te guidera etape par etape.
102
103
 
103
- Options avancees:
104
- login --username <n> --password <pass> [--server <url>]
105
- whoami [--server <url>]
106
- sync <dossier> [--server <url>] [--dry-run] [--force] [--once] [--interval-ms <n>]
107
- share <fichier> [--server <url>] [--limits <n>] [--temps <jours>] [--upload]
104
+ Options avancees:
105
+ login --username <n> --password <pass> [--server <url>]
106
+ whoami [--server <url>]
107
+ account [--server <url>]
108
+ sync <dossier> [--server <url>] [--dry-run] [--force] [--once] [--interval-ms <n>]
109
+ share <fichier> [--server <url>] [--limits <n>] [--temps <jours>] [--upload]
108
110
 
109
111
  Exemples:
110
- shard login
111
- shard sync ./MonDossier
112
- shard sync ./MonDossier --once
113
- shard share ./MonFichier.mp4
112
+ shard login
113
+ shard account
114
+ shard sync ./MonDossier
115
+ shard sync ./MonDossier --once
116
+ shard share ./MonFichier.mp4
114
117
  shard share ./MonFichier.mp4 --upload
115
118
 
116
119
  Serveur par defaut: https://shard-0ow4.onrender.com
@@ -297,7 +300,7 @@ async function login(flags) {
297
300
  }
298
301
  }
299
302
 
300
- async function whoami(flags) {
303
+ async function whoami(flags) {
301
304
  const config = await readConfig();
302
305
  const server = getServer(flags, config);
303
306
  const token = getToken(config);
@@ -313,8 +316,28 @@ async function whoami(flags) {
313
316
  const user = data.user || {};
314
317
  console.log(`Server: ${server}`);
315
318
  console.log(`User: ${user.username || user.userId || 'inconnu'}`);
316
- if (user.email) console.log(`Email: ${user.email}`);
317
- }
319
+ if (user.email) console.log(`Email: ${user.email}`);
320
+ }
321
+
322
+ async function account(flags) {
323
+ const config = await readConfig();
324
+ const server = getServer(flags, config);
325
+ const token = getToken(config);
326
+ if (!token) {
327
+ throw new Error('Non connecte. Lance: shard login --username ... --password ...');
328
+ }
329
+
330
+ const data = await httpJson(`${server}/api/auth/profile`, {
331
+ method: 'GET',
332
+ headers: { Authorization: `Bearer ${token}` }
333
+ });
334
+
335
+ const user = data.user || {};
336
+ const plan = String(user.billing_plan || 'free').toLowerCase();
337
+ console.log(`Username: ${user.username || 'inconnu'}`);
338
+ console.log(`Email: ${user.email || 'inconnu'}`);
339
+ console.log(`Plan: ${plan}`);
340
+ }
318
341
 
319
342
  async function logout() {
320
343
  const config = await readConfig();
@@ -1151,11 +1174,16 @@ async function main() {
1151
1174
  return;
1152
1175
  }
1153
1176
 
1154
- if (command === 'whoami') {
1155
- await whoami(flags);
1156
- return;
1157
- }
1158
-
1177
+ if (command === 'whoami') {
1178
+ await whoami(flags);
1179
+ return;
1180
+ }
1181
+
1182
+ if (command === 'account') {
1183
+ await account(flags);
1184
+ return;
1185
+ }
1186
+
1159
1187
  if (command === 'logout') {
1160
1188
  await logout();
1161
1189
  return;
@@ -1190,4 +1218,4 @@ async function main() {
1190
1218
  main().catch((error) => {
1191
1219
  console.error(`Erreur: ${error.message}`);
1192
1220
  process.exitCode = 1;
1193
- });
1221
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iksdev/shard-cli",
3
- "version": "0.1.43",
3
+ "version": "0.1.44",
4
4
  "description": "CLI pour synchroniser un dossier local avec Shard",
5
5
  "bin": {
6
6
  "shard": "bin/shard.js"