@iksdev/shard-cli 0.1.39 → 0.1.41

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 +23 -9
  2. package/package.json +1 -1
package/bin/shard.js CHANGED
@@ -19,8 +19,8 @@ const IGNORED_DIRS = new Set(['.git', 'node_modules']);
19
19
  async function checkForUpdate() {
20
20
  return new Promise((resolve) => {
21
21
  const https = require('https');
22
- const pkgName = require(path.join(__dirname, '../package.json')).name;
23
- const currentVersion = require(path.join(__dirname, '../package.json')).version;
22
+ const pkgName = require('./package.json').name;
23
+ const currentVersion = require('./package.json').version;
24
24
 
25
25
  const req = https.get(
26
26
  `https://registry.npmjs.org/${pkgName}/latest`,
@@ -42,10 +42,19 @@ async function checkForUpdate() {
42
42
  }
43
43
 
44
44
  async function promptUpdate(latestVersion) {
45
- const pkgName = require(path.join(__dirname, '../package.json')).name;
45
+ const pkgLocal = require(path.join(__dirname, '../package.json'));
46
46
  return new Promise((resolve) => {
47
47
  const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
48
- const msg = `\n⚠️ Nouvelle version disponible : v${latestVersion}\n Lance cette commande pour mettre à jour :\n\n npm i -g ${pkgName}@latest\n\n→ Mettre à jour maintenant ? (y/n) : `;
48
+ const msg = [
49
+ '',
50
+ '╔════════════════════════════════════════════════════╗',
51
+ `║ 🚀 Mise à jour disponible : v${pkgLocal.version} → v${latestVersion}`.padEnd(52) + '║',
52
+ '╠════════════════════════════════════════════════════╣',
53
+ `║ npm i -g ${pkgLocal.name}@latest`.padEnd(52) + '║',
54
+ '╚════════════════════════════════════════════════════╝',
55
+ '',
56
+ ' Mettre à jour maintenant ? [y/n] : ',
57
+ ].join('\n');
49
58
  rl.question(msg, (answer) => {
50
59
  rl.close();
51
60
  resolve(answer.trim().toLowerCase() === 'y');
@@ -55,13 +64,18 @@ async function promptUpdate(latestVersion) {
55
64
 
56
65
  async function runUpdate(latestVersion) {
57
66
  const { execSync } = require('child_process');
58
- const pkgName = require(path.join(__dirname, '../package.json')).name;
59
- console.log(`\n⏳ Mise à jour en cours...`);
67
+ const pkgLocal = require(path.join(__dirname, '../package.json'));
68
+ process.stdout.write('\n Installation en cours');
69
+ const dots = setInterval(() => process.stdout.write('.'), 400);
60
70
  try {
61
- execSync(`npm i -g ${pkgName}@latest`, { stdio: 'inherit' });
62
- console.log(`\n✅ Mis à jour vers v${latestVersion} ! Relance ta commande.`);
71
+ execSync(`npm i -g ${pkgLocal.name}@latest`, { stdio: 'pipe' });
72
+ clearInterval(dots);
73
+ console.log(`\n\n ✅ Mis à jour vers v${latestVersion} avec succès !`);
74
+ console.log(` ↩ Relance ta commande.\n`);
63
75
  } catch {
64
- console.error(`\n❌ Échec de la mise à jour. Lance manuellement :\n npm i -g ${pkgName}@latest`);
76
+ clearInterval(dots);
77
+ console.error(`\n\n ❌ Échec. Lance manuellement :`);
78
+ console.error(` npm i -g ${pkgLocal.name}@latest\n`);
65
79
  }
66
80
  process.exit(0);
67
81
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iksdev/shard-cli",
3
- "version": "0.1.39",
3
+ "version": "0.1.41",
4
4
  "description": "CLI pour synchroniser un dossier local avec Shard",
5
5
  "bin": {
6
6
  "shard": "bin/shard.js"