acadex-cli 1.0.3 → 1.0.5
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/acadex +56 -0
- package/acadex.ps1 +52 -0
- package/bin/acadex.js +41 -21
- package/package.json +1 -1
package/acadex
CHANGED
|
@@ -69,6 +69,7 @@ show_help() {
|
|
|
69
69
|
echo -e " ${GREEN}phpmyadmin${NC} Start Apache & open phpMyAdmin (port 8080)"
|
|
70
70
|
echo -e " ${GREEN}phpmyadmin:stop${NC} Stop Apache"
|
|
71
71
|
echo -e " ${GREEN}docs${NC} Open ACADEX documentation"
|
|
72
|
+
echo -e " ${GREEN}uninstall${NC} Uninstall ACADEX CLI globally"
|
|
72
73
|
echo ""
|
|
73
74
|
echo -e "${YELLOW}Examples:${NC}"
|
|
74
75
|
echo -e " acadex setup # First-time installation"
|
|
@@ -495,6 +496,61 @@ case "$1" in
|
|
|
495
496
|
echo -e "${GREEN}Opening ACADEX documentation...${NC}"
|
|
496
497
|
open "https://xaviworks.github.io/AcadexV3/"
|
|
497
498
|
;;
|
|
499
|
+
uninstall)
|
|
500
|
+
echo -e "${BLUE}╔══════════════════════════════════════════════════════════╗${NC}"
|
|
501
|
+
echo -e "${BLUE}║${NC} ${YELLOW}Uninstalling ACADEX CLI${NC} ${BLUE}║${NC}"
|
|
502
|
+
echo -e "${BLUE}╚══════════════════════════════════════════════════════════╝${NC}"
|
|
503
|
+
echo ""
|
|
504
|
+
echo -e "${YELLOW}This will remove ACADEX CLI from your system.${NC}"
|
|
505
|
+
echo ""
|
|
506
|
+
read -p "Are you sure you want to uninstall? (y/n): " -n 1 -r
|
|
507
|
+
echo ""
|
|
508
|
+
|
|
509
|
+
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
|
510
|
+
echo ""
|
|
511
|
+
echo -e "${BLUE}→${NC} Uninstalling npm package..."
|
|
512
|
+
npm uninstall -g acadex-cli
|
|
513
|
+
|
|
514
|
+
# Remove from /usr/local/bin if exists
|
|
515
|
+
if [ -f /usr/local/bin/acadex ]; then
|
|
516
|
+
echo -e "${BLUE}→${NC} Removing from /usr/local/bin..."
|
|
517
|
+
sudo rm -f /usr/local/bin/acadex
|
|
518
|
+
fi
|
|
519
|
+
|
|
520
|
+
# Remove from /opt/homebrew/bin if exists
|
|
521
|
+
if [ -f /opt/homebrew/bin/acadex ]; then
|
|
522
|
+
echo -e "${BLUE}→${NC} Removing from /opt/homebrew/bin..."
|
|
523
|
+
sudo rm -f /opt/homebrew/bin/acadex
|
|
524
|
+
fi
|
|
525
|
+
|
|
526
|
+
# Remove shell aliases
|
|
527
|
+
if [ -n "$ZSH_VERSION" ]; then
|
|
528
|
+
CONFIG_FILE="$HOME/.zshrc"
|
|
529
|
+
else
|
|
530
|
+
CONFIG_FILE="$HOME/.bashrc"
|
|
531
|
+
fi
|
|
532
|
+
|
|
533
|
+
if grep -q "alias acadex=" "$CONFIG_FILE" 2>/dev/null; then
|
|
534
|
+
echo -e "${BLUE}→${NC} Removing shell alias from $CONFIG_FILE..."
|
|
535
|
+
if [[ "$OSTYPE" == "darwin"* ]]; then
|
|
536
|
+
sed -i '' '/alias acadex=/d' "$CONFIG_FILE"
|
|
537
|
+
sed -i '' '/# ACADEX CLI/d' "$CONFIG_FILE"
|
|
538
|
+
else
|
|
539
|
+
sed -i '/alias acadex=/d' "$CONFIG_FILE"
|
|
540
|
+
sed -i '/# ACADEX CLI/d' "$CONFIG_FILE"
|
|
541
|
+
fi
|
|
542
|
+
fi
|
|
543
|
+
|
|
544
|
+
echo ""
|
|
545
|
+
echo -e "${GREEN}✓ ACADEX CLI has been uninstalled successfully!${NC}"
|
|
546
|
+
echo ""
|
|
547
|
+
echo -e "${YELLOW}Note: You may need to restart your terminal or run:${NC}"
|
|
548
|
+
echo -e " source ~/.zshrc ${YELLOW}(or ~/.bashrc)${NC}"
|
|
549
|
+
else
|
|
550
|
+
echo ""
|
|
551
|
+
echo -e "${YELLOW}Uninstall cancelled.${NC}"
|
|
552
|
+
fi
|
|
553
|
+
;;
|
|
498
554
|
help|--help|-h|"")
|
|
499
555
|
show_help
|
|
500
556
|
;;
|
package/acadex.ps1
CHANGED
|
@@ -100,6 +100,8 @@ function Show-Help {
|
|
|
100
100
|
Write-Host "Stop Apache (Windows)"
|
|
101
101
|
Write-Host " docs " -ForegroundColor Green -NoNewline
|
|
102
102
|
Write-Host "Open ACADEX documentation"
|
|
103
|
+
Write-Host " uninstall " -ForegroundColor Green -NoNewline
|
|
104
|
+
Write-Host "Uninstall ACADEX CLI globally"
|
|
103
105
|
Write-Host ""
|
|
104
106
|
Write-Host "Examples:" -ForegroundColor Yellow
|
|
105
107
|
Write-Host " acadex setup # First-time installation"
|
|
@@ -587,6 +589,56 @@ switch ($Command) {
|
|
|
587
589
|
Start-Process "https://xaviworks.github.io/AcadexV3/"
|
|
588
590
|
}
|
|
589
591
|
|
|
592
|
+
"uninstall" {
|
|
593
|
+
Write-Host "===========================================================" -ForegroundColor Cyan
|
|
594
|
+
Write-Host " Uninstalling ACADEX CLI " -ForegroundColor Yellow
|
|
595
|
+
Write-Host "===========================================================" -ForegroundColor Cyan
|
|
596
|
+
Write-Host ""
|
|
597
|
+
Write-Host "This will remove ACADEX CLI from your system." -ForegroundColor Yellow
|
|
598
|
+
Write-Host ""
|
|
599
|
+
|
|
600
|
+
$confirmation = Read-Host "Are you sure you want to uninstall? (y/n)"
|
|
601
|
+
|
|
602
|
+
if ($confirmation -eq "y" -or $confirmation -eq "Y") {
|
|
603
|
+
Write-Host ""
|
|
604
|
+
Write-Host " -> Uninstalling npm package..." -ForegroundColor Cyan
|
|
605
|
+
npm uninstall -g acadex-cli
|
|
606
|
+
|
|
607
|
+
# Remove PowerShell profile function if exists
|
|
608
|
+
if (Test-Path $PROFILE) {
|
|
609
|
+
$profileContent = Get-Content $PROFILE -Raw
|
|
610
|
+
if ($profileContent -match "function acadex") {
|
|
611
|
+
Write-Host " -> Removing from PowerShell profile..." -ForegroundColor Cyan
|
|
612
|
+
$newContent = $profileContent -replace "(?ms)# ACADEX CLI.*?^}", ""
|
|
613
|
+
$newContent = $newContent -replace "(?ms)function acadex.*?^}", ""
|
|
614
|
+
$newContent = $newContent.Trim()
|
|
615
|
+
Set-Content -Path $PROFILE -Value $newContent
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
# Remove from common Windows paths
|
|
620
|
+
$commonPaths = @(
|
|
621
|
+
"$env:ProgramFiles\acadex",
|
|
622
|
+
"$env:LOCALAPPDATA\Programs\acadex"
|
|
623
|
+
)
|
|
624
|
+
|
|
625
|
+
foreach ($path in $commonPaths) {
|
|
626
|
+
if (Test-Path $path) {
|
|
627
|
+
Write-Host " -> Removing from $path..." -ForegroundColor Cyan
|
|
628
|
+
Remove-Item -Path $path -Recurse -Force -ErrorAction SilentlyContinue
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
Write-Host ""
|
|
633
|
+
Write-Host "[OK] ACADEX CLI has been uninstalled successfully!" -ForegroundColor Green
|
|
634
|
+
Write-Host ""
|
|
635
|
+
Write-Host "Note: You may need to restart PowerShell for changes to take effect." -ForegroundColor Yellow
|
|
636
|
+
} else {
|
|
637
|
+
Write-Host ""
|
|
638
|
+
Write-Host "Uninstall cancelled." -ForegroundColor Yellow
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
|
|
590
642
|
{ $_ -in @("help", "--help", "-h", "", $null) } {
|
|
591
643
|
Show-Help
|
|
592
644
|
}
|
package/bin/acadex.js
CHANGED
|
@@ -6,56 +6,64 @@ const os = require('os');
|
|
|
6
6
|
const fs = require('fs');
|
|
7
7
|
|
|
8
8
|
const platform = os.platform();
|
|
9
|
-
// Use parent directory to access the scripts
|
|
10
9
|
const scriptDir = path.join(__dirname, '..');
|
|
11
10
|
|
|
12
11
|
let scriptPath;
|
|
13
12
|
let shell;
|
|
14
13
|
let shellArgs;
|
|
15
14
|
|
|
15
|
+
// Detect platform and select appropriate script
|
|
16
16
|
if (platform === 'win32') {
|
|
17
17
|
// Windows - use PowerShell script
|
|
18
18
|
scriptPath = path.join(scriptDir, 'acadex.ps1');
|
|
19
19
|
|
|
20
|
-
// Check if script exists
|
|
21
20
|
if (!fs.existsSync(scriptPath)) {
|
|
22
|
-
console.error(
|
|
23
|
-
console.error(
|
|
21
|
+
console.error('Error: ACADEX CLI is not properly installed for Windows.');
|
|
22
|
+
console.error(`Missing: ${scriptPath}`);
|
|
23
|
+
console.error('Please reinstall: npm install -g acadex-cli');
|
|
24
24
|
process.exit(1);
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
shell = 'powershell.exe';
|
|
28
|
-
shellArgs = [
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
28
|
+
shellArgs = [
|
|
29
|
+
'-NoProfile',
|
|
30
|
+
'-ExecutionPolicy', 'Bypass',
|
|
31
|
+
'-File', scriptPath,
|
|
32
|
+
...process.argv.slice(2)
|
|
33
|
+
];
|
|
34
|
+
} else if (platform === 'darwin' || platform === 'linux') {
|
|
35
|
+
// macOS and Linux - use bash script
|
|
33
36
|
scriptPath = path.join(scriptDir, 'acadex');
|
|
34
37
|
|
|
35
|
-
// Check if script exists
|
|
36
38
|
if (!fs.existsSync(scriptPath)) {
|
|
37
|
-
console.error(
|
|
38
|
-
console.error(
|
|
39
|
+
console.error('Error: ACADEX CLI is not properly installed for Unix systems.');
|
|
40
|
+
console.error(`Missing: ${scriptPath}`);
|
|
41
|
+
console.error('Please reinstall: npm install -g acadex-cli');
|
|
39
42
|
process.exit(1);
|
|
40
43
|
}
|
|
41
44
|
|
|
42
|
-
//
|
|
45
|
+
// Ensure script is executable
|
|
43
46
|
try {
|
|
44
|
-
fs.chmodSync(scriptPath,
|
|
47
|
+
fs.chmodSync(scriptPath, 0o755);
|
|
45
48
|
} catch (err) {
|
|
46
|
-
//
|
|
49
|
+
// Silent fail - may not have permissions or already executable
|
|
47
50
|
}
|
|
48
51
|
|
|
49
52
|
shell = 'bash';
|
|
50
53
|
shellArgs = [scriptPath, ...process.argv.slice(2)];
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
console.
|
|
54
|
+
} else {
|
|
55
|
+
// Unsupported platform
|
|
56
|
+
console.error(`Error: Unsupported platform: ${platform}`);
|
|
57
|
+
console.error('ACADEX CLI supports: Windows (win32), macOS (darwin), Linux (linux)');
|
|
58
|
+
console.error('Please report this issue if you believe this is an error.');
|
|
59
|
+
process.exit(1);
|
|
54
60
|
}
|
|
55
61
|
|
|
62
|
+
// Spawn the platform-specific script
|
|
56
63
|
const child = spawn(shell, shellArgs, {
|
|
57
64
|
stdio: 'inherit',
|
|
58
|
-
shell: false
|
|
65
|
+
shell: false,
|
|
66
|
+
windowsHide: true // Hide console window on Windows for cleaner experience
|
|
59
67
|
});
|
|
60
68
|
|
|
61
69
|
child.on('exit', (code) => {
|
|
@@ -63,8 +71,20 @@ child.on('exit', (code) => {
|
|
|
63
71
|
});
|
|
64
72
|
|
|
65
73
|
child.on('error', (err) => {
|
|
66
|
-
console.error('Failed to
|
|
74
|
+
console.error('\nError: Failed to execute ACADEX CLI');
|
|
75
|
+
console.error(`Reason: ${err.message}`);
|
|
67
76
|
console.error(`Platform: ${platform}`);
|
|
68
|
-
console.error(`Script
|
|
77
|
+
console.error(`Script: ${scriptPath}`);
|
|
78
|
+
console.error('\nTroubleshooting:');
|
|
79
|
+
|
|
80
|
+
if (platform === 'win32') {
|
|
81
|
+
console.error(' - Ensure PowerShell is installed and in PATH');
|
|
82
|
+
console.error(' - Try running PowerShell as Administrator');
|
|
83
|
+
} else {
|
|
84
|
+
console.error(' - Ensure bash is installed: which bash');
|
|
85
|
+
console.error(' - Check script permissions: ls -la $(which acadex)');
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
console.error('\nReinstall: npm uninstall -g acadex-cli && npm install -g acadex-cli');
|
|
69
89
|
process.exit(1);
|
|
70
90
|
});
|