mirror of
https://github.com/usebruno/bruno.git
synced 2026-07-07 22:18:33 +00:00
Now added the ability to import and export js and json values. changes made in item schema. (#2296)
* Now added the ability to import and export js values. changes made in item schema. * Improvements upon review * Fixes. * refactor: removed the copyRequest function and wrote the logic directly inside the copyItems function. * refactor: Update getBrunoJsonConfig function to remove unnecessary parameter * refactor: Update getBrunoJsonConfig function to remove unnecessary parameter and handle auth object dynamically * refactor: Update OAuth2 grantType handling in transformCollectionToSaveToExportAsFile function * refactor: Update getBrunoJsonConfig function to remove unnecessary async
This commit is contained in:
@@ -428,6 +428,11 @@ const registerRendererEventHandlers = (mainWindow, watcher, lastOpenedCollection
|
||||
parseCollectionItems(item.items, folderPath);
|
||||
}
|
||||
}
|
||||
// Handle items of type 'js'
|
||||
if (item.type === 'js') {
|
||||
const filePath = path.join(currentPath, `${item.name}.js`);
|
||||
fs.writeFileSync(filePath, item.raw);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@@ -444,17 +449,29 @@ const registerRendererEventHandlers = (mainWindow, watcher, lastOpenedCollection
|
||||
});
|
||||
};
|
||||
|
||||
const getBrunoJsonConfig = (collection) => {
|
||||
let brunoConfig = collection.brunoConfig;
|
||||
|
||||
if (!brunoConfig) {
|
||||
brunoConfig = {
|
||||
version: '1',
|
||||
name: collection.name,
|
||||
type: 'collection',
|
||||
ignore: ['node_modules', '.git']
|
||||
};
|
||||
}
|
||||
|
||||
return brunoConfig;
|
||||
};
|
||||
|
||||
await createDirectory(collectionPath);
|
||||
|
||||
const uid = generateUidBasedOnHash(collectionPath);
|
||||
const brunoConfig = {
|
||||
version: '1',
|
||||
name: collectionName,
|
||||
type: 'collection',
|
||||
ignore: ['node_modules', '.git']
|
||||
};
|
||||
const content = await stringifyJson(brunoConfig);
|
||||
await writeFile(path.join(collectionPath, 'bruno.json'), content);
|
||||
const brunoConfig = getBrunoJsonConfig(collection);
|
||||
const stringifiedBrunoConfig = await stringifyJson(brunoConfig);
|
||||
|
||||
// Write the Bruno configuration to a file
|
||||
await writeFile(path.join(collectionPath, 'bruno.json'), stringifiedBrunoConfig);
|
||||
|
||||
mainWindow.webContents.send('main:collection-opened', collectionPath, uid, brunoConfig);
|
||||
ipcMain.emit('main:collection-opened', mainWindow, collectionPath, uid, brunoConfig);
|
||||
|
||||
Reference in New Issue
Block a user