mystyk 2026.5.0 → 2026.7.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/package.json +1 -1
- package/src/ui/ascii-art.js +6 -2
- package/src/utils/version-check.js +36 -47
package/package.json
CHANGED
package/src/ui/ascii-art.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import gradient from 'gradient-string';
|
|
2
|
+
import { createRequire } from 'module';
|
|
2
3
|
import { gradients } from './colors.js';
|
|
3
4
|
|
|
5
|
+
const require = createRequire(import.meta.url);
|
|
6
|
+
const pkg = require('../../package.json');
|
|
7
|
+
|
|
4
8
|
// Main MỴSTỴK logo
|
|
5
9
|
export const logo = `
|
|
6
10
|
╔╦╗╦ ╦╔═╗╔╦╗╦ ╦╦╔═
|
|
@@ -103,8 +107,8 @@ export const phaseSymbols = {
|
|
|
103
107
|
reflect: '◎',
|
|
104
108
|
};
|
|
105
109
|
|
|
106
|
-
// Version string
|
|
107
|
-
export const version =
|
|
110
|
+
// Version string - from package.json
|
|
111
|
+
export const version = `v${pkg.version}`;
|
|
108
112
|
|
|
109
113
|
export default {
|
|
110
114
|
logo,
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { promisify } from 'util';
|
|
1
|
+
import { spawn } from 'child_process';
|
|
3
2
|
import chalk from 'chalk';
|
|
4
3
|
|
|
5
|
-
const execAsync = promisify(exec);
|
|
6
|
-
|
|
7
4
|
const PACKAGE_NAME = 'mystyk';
|
|
8
5
|
|
|
9
6
|
/**
|
|
@@ -20,15 +17,6 @@ async function getLatestVersion() {
|
|
|
20
17
|
}
|
|
21
18
|
}
|
|
22
19
|
|
|
23
|
-
/**
|
|
24
|
-
* Get current installed version
|
|
25
|
-
*/
|
|
26
|
-
function getCurrentVersion() {
|
|
27
|
-
// Import package.json dynamically
|
|
28
|
-
const url = new URL('../../package.json', import.meta.url);
|
|
29
|
-
return fetch(url).then(r => r.json()).then(p => p.version).catch(() => null);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
20
|
/**
|
|
33
21
|
* Compare semver versions
|
|
34
22
|
* Returns: 1 if a > b, -1 if a < b, 0 if equal
|
|
@@ -46,60 +34,61 @@ function compareVersions(a, b) {
|
|
|
46
34
|
return 0;
|
|
47
35
|
}
|
|
48
36
|
|
|
49
|
-
/**
|
|
50
|
-
* Auto-update to latest version
|
|
51
|
-
*/
|
|
52
|
-
async function autoUpdate() {
|
|
53
|
-
console.log(chalk.cyan('\n Actualizando MYSTYK...\n'));
|
|
54
|
-
|
|
55
|
-
try {
|
|
56
|
-
// Clear npx cache and run latest
|
|
57
|
-
await execAsync('npx clear-npx-cache 2>/dev/null || true');
|
|
58
|
-
|
|
59
|
-
console.log(chalk.green(' ✓ Actualizado. Ejecuta el comando de nuevo.\n'));
|
|
60
|
-
process.exit(0);
|
|
61
|
-
} catch (error) {
|
|
62
|
-
console.log(chalk.red(' ✗ Error actualizando. Intenta: npx mystyk@latest\n'));
|
|
63
|
-
return false;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
37
|
/**
|
|
68
38
|
* Check version and auto-update if needed
|
|
69
39
|
* Returns true if should continue, false if updating
|
|
70
40
|
*/
|
|
71
41
|
export async function checkVersionAndUpdate(currentVersion) {
|
|
42
|
+
// Check if we just updated (env flag from previous run)
|
|
43
|
+
if (process.env.MYSTYK_JUST_UPDATED) {
|
|
44
|
+
const fromVersion = process.env.MYSTYK_UPDATED_FROM || '?';
|
|
45
|
+
console.log();
|
|
46
|
+
console.log(chalk.bgGreen.black(' ✓ ACTUALIZADO ') + chalk.green(` ${fromVersion} → ${currentVersion}`));
|
|
47
|
+
console.log();
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
|
+
|
|
72
51
|
try {
|
|
73
52
|
const latestVersion = await getLatestVersion();
|
|
74
53
|
|
|
75
54
|
if (!latestVersion) {
|
|
76
|
-
// Can't check, continue anyway
|
|
77
55
|
return true;
|
|
78
56
|
}
|
|
79
57
|
|
|
80
58
|
if (compareVersions(latestVersion, currentVersion) > 0) {
|
|
81
|
-
|
|
82
|
-
console.log(
|
|
59
|
+
// Show update banner
|
|
60
|
+
console.log();
|
|
61
|
+
console.log(chalk.bgYellow.black(' ↻ UPDATE ') + chalk.yellow(` Descargando v${latestVersion}...`));
|
|
62
|
+
console.log(chalk.gray(` (tienes v${currentVersion})`));
|
|
63
|
+
console.log();
|
|
83
64
|
|
|
84
|
-
// Re-run with @latest
|
|
85
|
-
const { spawn } = await import('child_process');
|
|
86
65
|
const args = process.argv.slice(2);
|
|
87
66
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
67
|
+
return new Promise((resolve) => {
|
|
68
|
+
const child = spawn('npx', [`${PACKAGE_NAME}@${latestVersion}`, ...args], {
|
|
69
|
+
stdio: 'inherit',
|
|
70
|
+
shell: true,
|
|
71
|
+
env: {
|
|
72
|
+
...process.env,
|
|
73
|
+
MYSTYK_JUST_UPDATED: '1',
|
|
74
|
+
MYSTYK_UPDATED_FROM: currentVersion
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
child.on('error', () => {
|
|
79
|
+
console.log(chalk.red(` ✗ Error. Ejecuta: npx ${PACKAGE_NAME}@latest`));
|
|
80
|
+
resolve(true);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
child.on('close', (code) => {
|
|
84
|
+
process.exit(code || 0);
|
|
85
|
+
});
|
|
95
86
|
});
|
|
96
|
-
|
|
97
|
-
return false; // Don't continue, we're re-running
|
|
98
87
|
}
|
|
99
88
|
|
|
100
|
-
return true;
|
|
89
|
+
return true;
|
|
101
90
|
} catch {
|
|
102
|
-
return true;
|
|
91
|
+
return true;
|
|
103
92
|
}
|
|
104
93
|
}
|
|
105
94
|
|