-
Notifications
You must be signed in to change notification settings - Fork 61
/
build.js
93 lines (76 loc) · 2.11 KB
/
build.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
'use strict';
const fs = require( 'node:fs' );
const path = require( 'node:path' );
const archiver = require( 'archiver' );
const manifest = require( './manifest.json' );
const version = manifest.version.replace( /\./g, '_' );
( async() =>
{
await ArchiveChromium();
await ArchiveFirefox();
} )();
function ArchiveChromium()
{
const zipPath = path.join( __dirname, `steamdb_ext_${version}.zip` );
const archive = PrepareArchive( zipPath );
archive.file( path.join( __dirname, 'manifest.json' ), { name: 'manifest.json' } );
return archive.finalize();
}
function ArchiveFirefox()
{
const zipPath = path.join( __dirname, `steamdb_ext_${version}_firefox.zip` );
const archive = PrepareArchive( zipPath );
const ffManifest = manifest;
ffManifest.background =
{
scripts:
[
'scripts/background.js',
],
};
ffManifest.browser_specific_settings =
{
gecko:
{
id: '[email protected]',
strict_min_version: '109.0',
},
gecko_android:
{
strict_min_version: '120.0',
},
};
for( const web_accessible_resources of ffManifest.web_accessible_resources )
{
delete web_accessible_resources.use_dynamic_url; // Unsupported
}
const json = JSON.stringify( ffManifest, null, '\t' );
archive.append( json, { name: 'manifest.json' } );
return archive.finalize();
}
function PrepareArchive( zipPath )
{
console.log( `Packaging to ${zipPath}` );
const output = fs.createWriteStream( zipPath );
const archive = archiver( 'zip' );
output.on( 'close', () =>
{
console.log( `Written ${archive.pointer()} total bytes to ${zipPath}` );
} );
archive.on( 'warning', err =>
{
throw err;
} );
archive.on( 'error', err =>
{
throw err;
} );
archive.pipe( output );
archive.file( path.join( __dirname, 'LICENSE' ), { name: 'LICENSE' } );
archive.directory( path.join( __dirname, 'icons/' ), 'icons' );
archive.directory( path.join( __dirname, 'options/' ), 'options' );
archive.directory( path.join( __dirname, 'scripts/' ), 'scripts' );
archive.directory( path.join( __dirname, 'styles/' ), 'styles' );
archive.directory( path.join( __dirname, '_locales/' ), '_locales' );
return archive;
}