Skip to content

update gulp #1275

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 23 commits into from
Mar 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 18 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -131,20 +131,32 @@
"dependencies": {
"buffer": "^6.0.3",
"cross-env": "^7.0.3",
"download": "^8.0.0",
"node-fetch": "^2.7.0",
"extract-zip": "^2.0.1",
"eventemitter3": "^5.0.1",
"fs-extra": "^11.1.1",
"gulp": "^4.0.2",
"gulp": "^5.0.0",
"json-bigint": "^1.0.0",
"jsonfile": "^6.1.0",
"lodash.isequal": "^4.5.0",
"minimist": "^1.2.5",
"minimist": "^1.2.8",
"shelljs": "^0.8.5",
"semver": "^7.6.0",
"shelljs": "^0.8.4",
"ts-interface-checker": "^1.0.2",
"winston": "^3.3.3",
"winston": "^3.11.0",
"yuv-buffer": "1.0.0",
"yuv-canvas": "1.2.6"
"yuv-canvas": "1.2.6",
"archive-type": "^4.0.0",
"content-disposition": "^0.5.2",
"decompress": "^4.2.1",
"ext-name": "^5.0.0",
"file-type": "^11.1.0",
"filenamify": "^3.0.0",
"get-stream": "^4.1.0",
"got": "^11.8.5",
"make-dir": "^4.0.0",
"p-event": "^2.1.0",
"pify": "^4.0.1"
},
"agora_electron": {
"iris_sdk_win": "https://download.agora.io/sdk/release/iris_4.5.1-build.1_DCG_Windows_Video_Standalone_20250305_1103_622.zip",
Expand Down
6 changes: 4 additions & 2 deletions scripts/checkElectron.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const path = require('path');

const download = require('download');

const { cleanDir } = require('./clean');
const download = require('./download');

const getConfig = require('./getConfig');
const logger = require('./logger');

Expand Down Expand Up @@ -30,9 +30,11 @@ const checkElectron = async (cb) => {
let downloadUrl = `https://download.agora.io/sdk/release/electron-v${electron_version}-${platform}-${arch}.zip`;
logger.info(`Downloading:${downloadUrl}`);
await cleanDir(tp);

await download(downloadUrl, tp, {
extract: true,
});

logger.info(`Finish download:${downloadUrl}`);
logger.info(`sync electron success`);
cb();
Expand Down
102 changes: 102 additions & 0 deletions scripts/download.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
'use strict';
const fs = require('fs');
const path = require('path');
const { URL } = require('url');

const archiveType = require('archive-type');
const contentDisposition = require('content-disposition');
const decompress = require('decompress');
const extName = require('ext-name');
const fileType = require('file-type');
const filenamify = require('filenamify');
const getStream = require('get-stream');
const got = require('got');
const makeDir = require('make-dir');
const pEvent = require('p-event');
const pify = require('pify');

const fsP = pify(fs);
const filenameFromPath = (res) =>
path.basename(new URL(res.requestUrl).pathname);

const getExtFromMime = (res) => {
const header = res.headers['content-type'];

if (!header) {
return null;
}

const exts = extName.mime(header);

if (exts.length !== 1) {
return null;
}

return exts[0].ext;
};

const getFilename = (res, data) => {
const header = res.headers['content-disposition'];

if (header) {
const parsed = contentDisposition.parse(header);

if (parsed.parameters && parsed.parameters.filename) {
return parsed.parameters.filename;
}
}

let filename = filenameFromPath(res);

if (!path.extname(filename)) {
const ext = (fileType(data) || {}).ext || getExtFromMime(res);

if (ext) {
filename = `${filename}.${ext}`;
}
}

return filename;
};

module.exports = (uri, output, opts) => {
opts = {
...opts,
encoding: null,
responseType: 'buffer',
rejectUnauthorized: process.env.npm_config_strict_ssl !== 'false',
};

const stream = got.stream(uri);

const promise = pEvent(stream, 'response')
.then((res) => {
const encoding = opts.encoding === null ? 'buffer' : opts.encoding;
return Promise.all([getStream(stream, { encoding }), res]);
})
.then((result) => {
const [data, res] = result;

if (!output) {
return opts.extract && archiveType(data)
? decompress(data, opts)
: data;
}

const filename = opts.filename || filenamify(getFilename(res, data));
const outputFilepath = path.join(output, filename);

if (opts.extract && archiveType(data)) {
return decompress(data, path.dirname(outputFilepath), opts);
}

return makeDir(path.dirname(outputFilepath))
.then(() => fsP.writeFile(outputFilepath, data))
.then(() => data);
});

stream.then = promise.then.bind(promise);
stream.catch = promise.catch.bind(promise);

return stream;
};
3 changes: 2 additions & 1 deletion scripts/downloadPrebuild.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
const path = require('path');

const download = require('download');
const fs = require('fs-extra');

const { cleanDir, buildDir } = require('./clean');
const download = require('./download');

const getConfig = require('./getConfig');
const logger = require('./logger');
const { getOS } = require('./util');
Expand Down
4 changes: 2 additions & 2 deletions scripts/synclib.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const path = require('path');

const download = require('download');

const { destIrisSDKDir, cleanDir, destNativeSDKDir } = require('./clean');
const download = require('./download');

const getConfig = require('./getConfig');
const logger = require('./logger');
const { getOS, moveFile, getIrisStandAlone } = require('./util');
Expand Down
6 changes: 3 additions & 3 deletions ts/Utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,14 @@ export function classMix(...mixins: any[]): any {
class MixClass {
constructor() {
for (let mixin of mixins) {
copyProperties(this, new mixin()); // 拷贝实例属性
copyProperties(this, new mixin()); // Copy instance properties
}
}
}

for (let mixin of mixins) {
copyProperties(MixClass, mixin); // 拷贝静态属性
copyProperties(MixClass.prototype, mixin.prototype); // 拷贝原型属性
copyProperties(MixClass, mixin); // Copy static properties
copyProperties(MixClass.prototype, mixin.prototype); // Copy prototype properties
}

return MixClass;
Expand Down
Loading
Loading