-
Notifications
You must be signed in to change notification settings - Fork 4
/
build.ios.js
75 lines (69 loc) · 1.95 KB
/
build.ios.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
const fs = require('fs-extra');
const path = require('path');
const findRemoveSync = require('find-remove');
const archiver = require('archiver');
const quickjsPath = path.join(
__dirname,
'./packages/webf-0.12.0+1/ios/quickjs.xcframework',
);
const webfBridgePath = path.join(
__dirname,
'./packages/webf-0.12.0+1/ios/webf_bridge.xcframework',
);
const types = ['Debug', 'Release', 'Profile'];
fs.copySync(
path.join(__dirname, './build/ios/framework/'),
path.join(__dirname, './assets/ios/framework/'),
);
for (const key in types) {
zipAssets(types[key]);
}
function zipAssets(type) {
return new Promise((resolve, reject) => {
const quickjsSavePath = path.join(
__dirname,
`./assets/ios/framework/${type}/quickjs.xcframework`,
);
fs.copySync(quickjsPath, quickjsSavePath);
const webfBridgeSavePath = path.join(
__dirname,
`./assets/ios/framework/${type}/webf_bridge.xcframework`,
);
fs.copySync(webfBridgePath, webfBridgeSavePath);
const output = fs.createWriteStream(
path.join(__dirname, `./assets/ios/framework/${type}.zip`),
);
const archive = archiver('zip', {
zlib: {level: 9}, // Sets the compression level.
});
archive.pipe(output);
archive.on('warning', function (err) {
console.error(err);
if (err.code === 'ENOENT') {
// log warning
} else {
// throw error
throw err;
}
});
// good practice to catch this error explicitly
archive.on('error', function (err) {
console.error(err);
throw err;
});
archive.on('end', function () {
console.log('end', type);
findRemoveSync(path.join(__dirname, `./assets/ios/framework/${type}`), {
dir: 'xcframework$',
regex: true,
});
resolve('ok');
});
archive.directory(
path.join(__dirname, `./assets/ios/framework/${type}`),
type,
);
console.log('start', type);
archive.finalize();
});
}