karnel-termux 4.13.1 → 4.13.2
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/karnel/bin/karnel +19 -3
- package/karnel/utils/env.sh +5 -1
- package/package.json +1 -1
- package/scripts/npm-install.js +44 -1
package/karnel/bin/karnel
CHANGED
|
@@ -23,6 +23,11 @@ source "$KARNEL_PATH/utils/bootstrap.sh"
|
|
|
23
23
|
# cargar entorno
|
|
24
24
|
import "@/utils/env"
|
|
25
25
|
|
|
26
|
+
# ===== SEMVER COMPARISON =====
|
|
27
|
+
_semver_gt() {
|
|
28
|
+
[[ "$(printf '%s\n%s' "$1" "$2" | sort -V | tail -1)" == "$1" ]] && [[ "$1" != "$2" ]]
|
|
29
|
+
}
|
|
30
|
+
|
|
26
31
|
# ===== CHECK UPDATES =====
|
|
27
32
|
check_for_updates() {
|
|
28
33
|
local version_file="$KARNEL_CACHE/last_version_check"
|
|
@@ -42,10 +47,16 @@ check_for_updates() {
|
|
|
42
47
|
echo "$current_time" > "$version_file"
|
|
43
48
|
|
|
44
49
|
(
|
|
45
|
-
local remote_version
|
|
50
|
+
local remote_version
|
|
51
|
+
remote_version=$(timeout 5 npm view karnel-termux version 2>/dev/null | tail -1)
|
|
52
|
+
if [[ -z "$remote_version" ]]; then
|
|
53
|
+
remote_version=$(curl -fsSL --max-time 5 "https://raw.githubusercontent.com/israelmarques1024-dotcom/karnel-termux/main/karnel/utils/env.sh" 2>/dev/null | grep "KARNEL_VERSION=" | cut -d'"' -f2)
|
|
54
|
+
fi
|
|
46
55
|
local local_version="$KARNEL_VERSION"
|
|
47
|
-
if [[ -n "$remote_version" ]] &&
|
|
56
|
+
if [[ -n "$remote_version" ]] && _semver_gt "$remote_version" "$local_version"; then
|
|
48
57
|
echo "$remote_version" > "$KARNEL_CACHE/new_version"
|
|
58
|
+
else
|
|
59
|
+
rm -f "$KARNEL_CACHE/new_version"
|
|
49
60
|
fi
|
|
50
61
|
) &>/dev/null &
|
|
51
62
|
}
|
|
@@ -53,7 +64,12 @@ check_for_updates() {
|
|
|
53
64
|
show_update_notification() {
|
|
54
65
|
local new_version_file="$KARNEL_CACHE/new_version"
|
|
55
66
|
if [[ -f "$new_version_file" ]]; then
|
|
56
|
-
local new_version
|
|
67
|
+
local new_version
|
|
68
|
+
new_version=$(cat "$new_version_file")
|
|
69
|
+
if ! _semver_gt "$new_version" "$KARNEL_VERSION"; then
|
|
70
|
+
rm -f "$new_version_file"
|
|
71
|
+
return 0
|
|
72
|
+
fi
|
|
57
73
|
echo
|
|
58
74
|
separator_section "Update Available"
|
|
59
75
|
echo
|
package/karnel/utils/env.sh
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
2
|
|
|
3
|
-
KARNEL_VERSION="
|
|
3
|
+
KARNEL_VERSION=""
|
|
4
|
+
if [[ -n "$KARNEL_PATH" ]] && [[ -f "$KARNEL_PATH/../package.json" ]]; then
|
|
5
|
+
KARNEL_VERSION=$(grep '"version"' "$KARNEL_PATH/../package.json" | head -1 | sed -E 's/.*"version": "([^"]+)".*/\1/')
|
|
6
|
+
fi
|
|
7
|
+
: "${KARNEL_VERSION:=unknown}"
|
|
4
8
|
|
|
5
9
|
# -------------------------
|
|
6
10
|
# Directorios del usuario
|
package/package.json
CHANGED
package/scripts/npm-install.js
CHANGED
|
@@ -5,6 +5,9 @@
|
|
|
5
5
|
*
|
|
6
6
|
* Runs when `npm install -g karnel` is executed.
|
|
7
7
|
* Detects Termux environment and triggers install.sh if appropriate.
|
|
8
|
+
*
|
|
9
|
+
* This script is OPTIONAL — the `karnel` CLI works from the npm bin symlink
|
|
10
|
+
* without it. The full install clones the repo and sets up dependencies.
|
|
8
11
|
*/
|
|
9
12
|
|
|
10
13
|
const fs = require('fs');
|
|
@@ -19,6 +22,22 @@ const isTermux = () => {
|
|
|
19
22
|
);
|
|
20
23
|
};
|
|
21
24
|
|
|
25
|
+
const npmConfigGet = (key) => {
|
|
26
|
+
try {
|
|
27
|
+
return execSync(`npm config get ${key} 2>/dev/null`, { encoding: 'utf8' }).trim();
|
|
28
|
+
} catch {
|
|
29
|
+
return '';
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const isPostinstallBlocked = () => {
|
|
34
|
+
const ignoreScripts = npmConfigGet('ignore-scripts');
|
|
35
|
+
if (ignoreScripts === 'true') return true;
|
|
36
|
+
const allowScripts = npmConfigGet('allow-scripts');
|
|
37
|
+
if (allowScripts && !allowScripts.includes('karnel-termux')) return true;
|
|
38
|
+
return false;
|
|
39
|
+
};
|
|
40
|
+
|
|
22
41
|
const isAlreadyInstalled = () => {
|
|
23
42
|
try {
|
|
24
43
|
const symlink = process.env.PREFIX + '/bin/karnel';
|
|
@@ -30,6 +49,15 @@ const isAlreadyInstalled = () => {
|
|
|
30
49
|
}
|
|
31
50
|
};
|
|
32
51
|
|
|
52
|
+
const binSymlinkExists = () => {
|
|
53
|
+
try {
|
|
54
|
+
const symlink = process.env.PREFIX + '/bin/karnel';
|
|
55
|
+
return fs.existsSync(symlink);
|
|
56
|
+
} catch {
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
|
|
33
61
|
const main = () => {
|
|
34
62
|
if (!isTermux()) {
|
|
35
63
|
console.log('[karnel] Not a Termux environment — skipping install.');
|
|
@@ -42,7 +70,22 @@ const main = () => {
|
|
|
42
70
|
process.exit(0);
|
|
43
71
|
}
|
|
44
72
|
|
|
45
|
-
|
|
73
|
+
if (isPostinstallBlocked()) {
|
|
74
|
+
console.log('[karnel] Postinstall blocked by npm allow-scripts/ignore-scripts.');
|
|
75
|
+
console.log('[karnel] The karnel CLI is already available via npm bin symlink.');
|
|
76
|
+
console.log('[karnel] Run "karnel --version" to verify it works.');
|
|
77
|
+
console.log('[karnel] For full setup, run:');
|
|
78
|
+
console.log('[karnel] npm install -g --allow-scripts=karnel-termux karnel-termux');
|
|
79
|
+
console.log('[karnel] # or manually: bash install.sh');
|
|
80
|
+
process.exit(0);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (binSymlinkExists()) {
|
|
84
|
+
console.log('[karnel] Updating Karnel for Termux...');
|
|
85
|
+
} else {
|
|
86
|
+
console.log('[karnel] Installing Karnel for Termux...');
|
|
87
|
+
}
|
|
88
|
+
|
|
46
89
|
try {
|
|
47
90
|
execSync('bash install.sh', {
|
|
48
91
|
cwd: path.resolve(__dirname, '..'),
|