Skip to content

Commit

Permalink
feat: use adm-zip instead of 'zip' command
Browse files Browse the repository at this point in the history
  • Loading branch information
boazpoolman committed Nov 11, 2024
1 parent 79ca64a commit c1ad39d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
"@strapi/design-system": "2.0.0-rc.11",
"@strapi/icons": "2.0.0-rc.11",
"@strapi/utils": "5.2.0",
"adm-zip": "^0.5.16",
"chalk": "^4.1.2",
"cli-table": "^0.3.6",
"commander": "^8.3.0",
Expand Down
16 changes: 8 additions & 8 deletions server/services/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
import isEmpty from 'lodash/isEmpty';
import fs from 'fs';
import util from 'util';
import childProcess from "child_process";
import AdmZip from 'adm-zip';

import difference from '../utils/getObjectDiff';
import { logMessage } from '../utils';

Expand Down Expand Up @@ -73,13 +74,12 @@ export default () => ({
* @returns {void}
*/
zipConfigFiles: async () => {
const fileName = `config-${new Date().toJSON()}.zip`;
childProcess.execSync(`zip -r ${fileName} *`, {
cwd: strapi.config.get('plugin.config-sync.syncDir'),
});
const fullFilePath = `${strapi.config.get('plugin.config-sync.syncDir')}${fileName}`;
const base64Data = fs.readFileSync(fullFilePath, { encoding: 'base64' });
fs.unlinkSync(fullFilePath);
const fileName = `config-sync-${new Date().toJSON()}.zip`;

const zip = new AdmZip();
zip.addLocalFolder(strapi.config.get('plugin.config-sync.syncDir'));
const base64Data = zip.toBuffer().toString('base64');

return { base64Data, name: fileName, message: 'Success' };
},

Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3913,6 +3913,11 @@ [email protected]:
resolved "https://registry.yarnpkg.com/addressparser/-/addressparser-1.0.1.tgz#47afbe1a2a9262191db6838e4fd1d39b40821746"
integrity sha512-aQX7AISOMM7HFE0iZ3+YnD07oIeJqWGVnJ+ZIKaBZAk03ftmVYVqsGas/rbXKR21n4D/hKCSHypvcyOkds/xzg==

adm-zip@^0.5.16:
version "0.5.16"
resolved "https://registry.yarnpkg.com/adm-zip/-/adm-zip-0.5.16.tgz#0b5e4c779f07dedea5805cdccb1147071d94a909"
integrity sha512-TGw5yVi4saajsSEgz25grObGHEUaDrniwvA2qwSC060KfqGPdglhvPMA2lPIoxs3PQIItj2iag35fONcQqgUaQ==

aggregate-error@^3.0.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/aggregate-error/-/aggregate-error-3.1.0.tgz#92670ff50f5359bdb7a3e0d40d0ec30c5737687a"
Expand Down

0 comments on commit c1ad39d

Please sign in to comment.