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:
Sanjai Kumar
2024-05-22 14:04:52 +05:30
committed by GitHub
parent 4df78910f5
commit 4f115b06fb
3 changed files with 147 additions and 83 deletions

View File

@@ -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);