Skip to content

Commit

Permalink
chore: do not package native sdk into napi.zip, download native sdk w…
Browse files Browse the repository at this point in the history
…hen npm install
  • Loading branch information
夏羊群 committed Dec 16, 2024
1 parent 9a24f58 commit 154309d
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
17 changes: 17 additions & 0 deletions scripts/downloadPrebuild.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,30 @@ const getDownloadURL = () => {
return downloadUrl;
};

// If native_stk_url is not defined in app/packaging.json,
// it will be read from agora-electron-sdk/packaging.json
const getNativeDownloadURL = () => {
let downloadUrl = '';
if (platform === 'win32') {
downloadUrl = native_sdk_win;
} else if (platform === 'darwin') {
downloadUrl = native_sdk_mac;
}

if (!downloadUrl) {
const {
agora_electron: {
native_sdk_win,
native_sdk_mac,
}
} = require("../package.json");
if (platform === 'win32') {
downloadUrl = native_sdk_win;
} else if (platform === 'darwin') {
downloadUrl = native_sdk_mac;
}
}

return downloadUrl;
};

Expand Down
25 changes: 25 additions & 0 deletions scripts/zipBuild.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,31 @@ const { exec } = require('shelljs');

const logger = require('./logger');
const { getOS } = require('./util');
const fs = require('fs');


const keepList = [
'AgoraRtcWrapper',
'agora_node_ext'
];

const filesMove = (src, dest, keepList) => {
fs.readdirSync(src).forEach(file => {
const filePath = path.join(src, file);
const shouldKeep = keepList.some(pattern => file.includes(pattern));
if (!shouldKeep) {
const destPath = path.join(dest, file);
fs.renameSync(filePath, destPath);
}
});
};

const zipBuild = async () => {
const temp_native = path.join(__dirname, '..', 'build', 'temp_native');
const build_release = path.join(__dirname, '..', 'build', 'Release');
fs.mkdirSync(temp_native);
filesMove(build_release, temp_native, keepList);

const isMac = getOS() === 'mac';
const fileListStr = ` build${path.sep}Release js types package.json`;
const shellStr =
Expand All @@ -14,6 +37,8 @@ const zipBuild = async () => {
if (code !== 0) {
logger.error(stderr);
}
filesMove(temp_native, build_release, []);
fs.rmdirSync(temp_native, { recursive: true });
};

module.exports = zipBuild;

0 comments on commit 154309d

Please sign in to comment.