openkbs 0.0.47 → 0.0.50
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/actions.js +11 -86
- package/version.json +2 -2
package/package.json
CHANGED
package/src/actions.js
CHANGED
|
@@ -651,12 +651,19 @@ async function updateCliAction() {
|
|
|
651
651
|
if (compareVersions(currentVersion, remoteVersion) < 0) {
|
|
652
652
|
cliUpdateAvailable = true;
|
|
653
653
|
console.log(`New CLI version available: ${remoteVersion}`);
|
|
654
|
-
console.log('
|
|
654
|
+
console.log('Updating automatically...');
|
|
655
655
|
|
|
656
|
-
//
|
|
657
|
-
|
|
656
|
+
// Spawn npm update as detached child process
|
|
657
|
+
const { spawn } = require('child_process');
|
|
658
|
+
const updateProcess = spawn('npm', ['update', '-g', 'openkbs'], {
|
|
659
|
+
detached: true,
|
|
660
|
+
stdio: 'inherit'
|
|
661
|
+
});
|
|
662
|
+
|
|
663
|
+
updateProcess.unref(); // Allow parent to exit
|
|
658
664
|
|
|
659
|
-
console.green(`
|
|
665
|
+
console.green(`Update started! OpenKBS CLI will be updated to version ${remoteVersion}.`);
|
|
666
|
+
console.log('The update will complete in the background.');
|
|
660
667
|
} else {
|
|
661
668
|
console.green('OpenKBS CLI is already up to date.');
|
|
662
669
|
}
|
|
@@ -667,10 +674,6 @@ async function updateCliAction() {
|
|
|
667
674
|
// Also update knowledge base silently if it exists
|
|
668
675
|
await updateKnowledgeAction(true);
|
|
669
676
|
|
|
670
|
-
if (cliUpdateAvailable) {
|
|
671
|
-
console.log('Please restart your terminal or run `source ~/.bashrc` to use the updated CLI version.');
|
|
672
|
-
}
|
|
673
|
-
|
|
674
677
|
} catch (error) {
|
|
675
678
|
console.red('Error updating CLI:', error.message);
|
|
676
679
|
}
|
|
@@ -691,84 +694,6 @@ function compareVersions(version1, version2) {
|
|
|
691
694
|
return 0;
|
|
692
695
|
}
|
|
693
696
|
|
|
694
|
-
async function downloadAndInstallCli() {
|
|
695
|
-
const platform = os.platform();
|
|
696
|
-
const arch = os.arch();
|
|
697
|
-
let url = '';
|
|
698
|
-
|
|
699
|
-
if (platform === 'linux' && arch === 'x64') {
|
|
700
|
-
url = 'https://downloads.openkbs.com/cli/linux/openkbs';
|
|
701
|
-
} else if (platform === 'darwin' && arch === 'arm64') {
|
|
702
|
-
url = 'https://downloads.openkbs.com/cli/macos/openkbs';
|
|
703
|
-
} else if (platform === 'darwin' && arch === 'x64') {
|
|
704
|
-
url = 'https://downloads.openkbs.com/cli/macos/openkbs-x64';
|
|
705
|
-
} else if (platform === 'win32' && arch === 'x64') {
|
|
706
|
-
url = 'https://downloads.openkbs.com/cli/windows/openkbs.exe';
|
|
707
|
-
} else if (platform === 'win32' && arch === 'arm64') {
|
|
708
|
-
url = 'https://downloads.openkbs.com/cli/windows/openkbs-arm64.exe';
|
|
709
|
-
} else if (platform === 'linux' && arch === 'arm64') {
|
|
710
|
-
url = 'https://downloads.openkbs.com/cli/linux/openkbs-arm64';
|
|
711
|
-
} else {
|
|
712
|
-
throw new Error(`Unsupported platform: ${platform} ${arch}`);
|
|
713
|
-
}
|
|
714
|
-
|
|
715
|
-
const tempPath = path.join(os.tmpdir(), 'openkbs-update');
|
|
716
|
-
|
|
717
|
-
return new Promise((resolve, reject) => {
|
|
718
|
-
const file = fs.createWriteStream(tempPath);
|
|
719
|
-
|
|
720
|
-
https.get(url, (response) => {
|
|
721
|
-
if (response.statusCode !== 200) {
|
|
722
|
-
reject(new Error(`Failed to download binary: HTTP ${response.statusCode}`));
|
|
723
|
-
return;
|
|
724
|
-
}
|
|
725
|
-
|
|
726
|
-
response.pipe(file);
|
|
727
|
-
|
|
728
|
-
file.on('finish', () => {
|
|
729
|
-
file.close(async () => {
|
|
730
|
-
try {
|
|
731
|
-
// Make executable
|
|
732
|
-
if (platform !== 'win32') {
|
|
733
|
-
fs.chmodSync(tempPath, '755');
|
|
734
|
-
}
|
|
735
|
-
|
|
736
|
-
// Find the current binary location
|
|
737
|
-
const currentBinaryPath = process.argv[0] === 'node' ? process.argv[1] : process.argv[0];
|
|
738
|
-
let targetPath;
|
|
739
|
-
|
|
740
|
-
// If we're running through npm, find the global bin path
|
|
741
|
-
if (currentBinaryPath.includes('node_modules')) {
|
|
742
|
-
targetPath = currentBinaryPath;
|
|
743
|
-
} else {
|
|
744
|
-
// Try to find in common global locations
|
|
745
|
-
const globalPaths = [
|
|
746
|
-
'/usr/local/bin/openkbs',
|
|
747
|
-
path.join(os.homedir(), '.npm-global', 'bin', 'openkbs'),
|
|
748
|
-
path.join(os.homedir(), '.yarn', 'bin', 'openkbs')
|
|
749
|
-
];
|
|
750
|
-
|
|
751
|
-
targetPath = globalPaths.find(p => fs.existsSync(p)) || currentBinaryPath;
|
|
752
|
-
}
|
|
753
|
-
|
|
754
|
-
// Replace the binary
|
|
755
|
-
fs.copyFileSync(tempPath, targetPath);
|
|
756
|
-
|
|
757
|
-
// Clean up temp file
|
|
758
|
-
fs.unlinkSync(tempPath);
|
|
759
|
-
|
|
760
|
-
resolve();
|
|
761
|
-
} catch (error) {
|
|
762
|
-
reject(error);
|
|
763
|
-
}
|
|
764
|
-
});
|
|
765
|
-
});
|
|
766
|
-
}).on('error', (err) => {
|
|
767
|
-
fs.unlink(tempPath, () => {});
|
|
768
|
-
reject(err);
|
|
769
|
-
});
|
|
770
|
-
});
|
|
771
|
-
}
|
|
772
697
|
|
|
773
698
|
async function downloadKnowledgeFromS3(targetDir) {
|
|
774
699
|
const https = require('https');
|
package/version.json
CHANGED