@clawchatsai/connector 0.0.7 → 0.0.9
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/dist/index.js +23 -24
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -521,7 +521,7 @@ async function handleReset() {
|
|
|
521
521
|
console.error(`Reset failed: ${e.message}`);
|
|
522
522
|
}
|
|
523
523
|
}
|
|
524
|
-
async function handleImport(sourcePath
|
|
524
|
+
async function handleImport(sourcePath) {
|
|
525
525
|
const resolvedSource = path.resolve(sourcePath);
|
|
526
526
|
if (!fs.existsSync(resolvedSource)) {
|
|
527
527
|
console.error(`Source path not found: ${resolvedSource}`);
|
|
@@ -547,34 +547,33 @@ async function handleImport(sourcePath, opts) {
|
|
|
547
547
|
for (const file of dbFiles) {
|
|
548
548
|
const src = path.join(resolvedSource, file);
|
|
549
549
|
const dst = path.join(destDataDir, file);
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
550
|
+
fs.copyFileSync(src, dst);
|
|
551
|
+
console.log(` ✓ ${file}`);
|
|
552
|
+
imported++;
|
|
553
|
+
}
|
|
554
|
+
console.log(`Databases: ${imported} imported.`);
|
|
555
|
+
}
|
|
556
|
+
// Import .json config files (workspaces.json, settings.json, etc.)
|
|
557
|
+
const jsonFiles = fs.readdirSync(resolvedSource).filter(f => f.endsWith('.json'));
|
|
558
|
+
if (jsonFiles.length > 0) {
|
|
559
|
+
for (const file of jsonFiles) {
|
|
560
|
+
const src = path.join(resolvedSource, file);
|
|
561
|
+
const dst = path.join(destDataDir, file);
|
|
562
|
+
fs.copyFileSync(src, dst);
|
|
563
|
+
console.log(` ✓ ${file}`);
|
|
559
564
|
}
|
|
560
|
-
console.log(`Databases: ${imported} imported, ${skipped} skipped.`);
|
|
561
565
|
}
|
|
562
566
|
// Also try to migrate config.json from the parent directory
|
|
563
567
|
// e.g. if source is ~/.openclaw/shellchat/data/, config is at ~/.openclaw/shellchat/config.json
|
|
564
568
|
const parentConfigPath = path.join(path.dirname(resolvedSource), 'config.json');
|
|
565
569
|
if (fs.existsSync(parentConfigPath)) {
|
|
566
|
-
|
|
567
|
-
|
|
570
|
+
try {
|
|
571
|
+
fs.mkdirSync(CONFIG_DIR, { recursive: true });
|
|
572
|
+
fs.copyFileSync(parentConfigPath, CONFIG_FILE);
|
|
573
|
+
console.log(' ✓ config.json (plugin credentials migrated)');
|
|
568
574
|
}
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
fs.mkdirSync(CONFIG_DIR, { recursive: true });
|
|
572
|
-
fs.copyFileSync(parentConfigPath, CONFIG_FILE);
|
|
573
|
-
console.log(' ✓ config.json (plugin credentials migrated)');
|
|
574
|
-
}
|
|
575
|
-
catch (e) {
|
|
576
|
-
console.error(` Failed to migrate config.json: ${e.message}`);
|
|
577
|
-
}
|
|
575
|
+
catch (e) {
|
|
576
|
+
console.error(` Failed to migrate config.json: ${e.message}`);
|
|
578
577
|
}
|
|
579
578
|
}
|
|
580
579
|
console.log('Done.');
|
|
@@ -606,8 +605,8 @@ const plugin = {
|
|
|
606
605
|
.description('Disconnect and remove all ShellChats data')
|
|
607
606
|
.action(() => handleReset());
|
|
608
607
|
cmd.command('import <path>')
|
|
609
|
-
.description('Import databases from a folder (e.g. migrate from old data directory)
|
|
610
|
-
.action((srcPath) => handleImport(String(srcPath)
|
|
608
|
+
.description('Import databases and config from a folder (e.g. migrate from old data directory)')
|
|
609
|
+
.action((srcPath) => handleImport(String(srcPath)));
|
|
611
610
|
});
|
|
612
611
|
// Slash command for status from any channel
|
|
613
612
|
api.registerCommand({
|