Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function exportDatabases(): Promise {
const zip = new JSZip();
await addDatabaseToZip(zip);
// eslint-disable-next-line newline-per-chained-call
const now = new Date().toISOString().replace(/:/g, '-');
const defaultFilename = `database-backup-${now}.zip`;
const pathToSaveTo: string = await getPathToSaveTo(defaultFilename);
if (!pathToSaveTo) {
return;
}
zip.generateAsync({type: 'nodebuffer'}).then((content) => {
fs.writeFileSync(pathToSaveTo, content);
});
function loadZipContent(zipContent, container) {
const fileContents = { state: null, arrays: {} };
function getArray(hash, binary) {
return Promise.resolve(fileContents.arrays[hash]);
}
const zip = new JSZip();
zip.loadAsync(zipContent).then(() => {
let workLoad = 0;
function done() {
if (workLoad !== 0) {
return;
}
// Synchronize context
const synchronizerContext = vtkSynchronizableRenderWindow.getSynchronizerContext(
CONTEXT_NAME
);
synchronizerContext.setFetchArrayFunction(getArray);
// openGLRenderWindow
const openGLRenderWindow = vtkOpenGLRenderWindow.newInstance();
function createZipFile(siteId, site, user, images, imagesData) {
/* Creating the zip file */
const zip = new JSZip();
const www = zip.folder('www');
/* Generate index.html file */
www.file('index.html', indexHtml);
/* Generate config.xml file */
const configParams = {
appId: generateAppId(site.url),
appName: site.name,
siteURL: site.url,
userEmail: user.email,
userName: user.name,
siteId,
};
const xmlFile = generateConfigXML(configParams);
www.file('config.xml', xmlFile);
const generateEPUB = function(State) {
const Zip = new JSZip();
const UUID = State.mangaInfo.bookInfo.id.trim() === "" ? generateRandomUUID() : State.mangaInfo.bookInfo.id;
Zip.folder("META-INF");
Zip.folder("OEBPS/image");
Zip.folder("OEBPS/text");
Zip.folder("OEBPS/style");
// render toc.xhtml file
let file_navigation_documents_xhtml = Template["navigation-documents.xhtml"];
const navigationList = State.mangaInfo.contents.map(navPointInfo => {
if (navPointInfo.refindex === 1)
return '<li><a href="text/p_cover.xhtml">' + htmlToEscape(navPointInfo.text) + '</a></li>';
return '<li><a href="text/p_' + counter(navPointInfo.refindex - 2, 4) + '.xhtml">' + htmlToEscape(navPointInfo.text) + '</a></li>';
export default function performThemeExport({
name = "Default Name",
// TODO: Need other manifest attributes?
store,
bgImages
}) {
log("performThemeExport");
reset();
const zip = new JSZip();
const state = store.getState();
const themeData = selectors.theme(state);
const customBackgrounds = selectors.themeCustomImages(state);
const theme = convertToBrowserTheme(themeData, bgImages, customBackgrounds);
if (theme.images) {
const { images } = theme;
const { additional_backgrounds } = images;
if (images.theme_frame) {
images.theme_frame = addImage(zip, images.theme_frame);
}
if (additional_backgrounds) {
for (let idx = 0; idx < additional_backgrounds.length; idx++) {
additional_backgrounds[idx] = addImage(
zip,
additional_backgrounds[idx]
exportAsZip() {
const zip = new JSZip();
const comps = this.props.components;
const config = this.props.config;
comps.forEach(function(comp) {
if(!comp.name){
return;
}
const file1 = `components/${comp.name}/${comp.name}.${config.markup}`;
const file2 = `components/${comp.name}/${comp.name}.${config.styling}`;
zip.file(file1, comp.html);
zip.file(file2, comp.css);
});
zip.file("package.json", getPackage());
zip.generateAsync({
type: "blob"
}).then((content) => {
FileSaver.saveAs(content, "atomic-lab.zip");
export default (config) => {
if (!validator(config)) {
throw new Error('Validation failed.');
}
const zip = new JSZip();
const xl = zip.folder('xl');
xl.file('workbook.xml', workbookXML);
xl.file('_rels/workbook.xml.rels', workbookXMLRels);
zip.file('_rels/.rels', rels);
zip.file('[Content_Types].xml', contentTypes);
const worksheet = generateXMLWorksheet(config.sheet.data);
xl.file('worksheets/sheet1.xml', worksheet);
return zip.generateAsync({
type: 'blob',
mimeType:
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
}).then((blob) => {
FileSaver.saveAs(blob, `${config.filename}.xlsx`);
});
async function getZip(data, fileName) {
const zip = new JSZip();
zip.file(fileName, data);
return (await zip.generateAsync({
compression: 'DEFLATE',
compressionOptions: {
level: 9
},
type: 'blob'
}));
}
const formatAndCompressModels = (models, config) => {
const zip = new JSZip()
zipFile(zip, {
name: '_db.js',
content: serialize.dbFile,
config
})
zipFile(zip, {
name: 'index.js',
content: serialize.associationFile(models),
config
})
for (let x of models) {
zipFile(zip, {
name: `${Case.snake(x.name)}.js`,
async function createFeedbackZip(feedbackData: FeedbackData): Promise {
const zip = new JSZip();
const zipFolder = zip.folder('feedback');
if (feedbackData.attachInternalDatabases) {
await addDatabaseToZip(zipFolder);
}
const bugsProvided: boolean = feedbackData.bugs.trim() !== '';
if (bugsProvided) {
zipFolder.file('Bugs.txt', feedbackData.bugs);
}
const suggestionsProvided: boolean = feedbackData.suggestions.trim() !== '';
if (suggestionsProvided) {
zipFolder.file('Suggestions.txt', feedbackData.suggestions);
}