1
- /* eslint-disable no-console, @typescript-eslint/no-var-requires */
2
- 'use strict' ;
3
- const fse = require ( 'fs-extra' ) ;
4
- const path = require ( 'path' ) ;
5
- const AdmZip = require ( 'adm-zip' ) ;
1
+ /* eslint-disable no-console */
2
+ import fse from 'fs-extra' ;
3
+ import path from 'path' ;
4
+ import AdmZip from 'adm-zip' ;
6
5
7
6
function buildAll ( ) {
8
7
build ( prepareZip ( ) ) ;
@@ -13,7 +12,7 @@ function buildAll() {
13
12
14
13
function build ( zip , name = '' ) {
15
14
if ( name ) { name = '-' + name ; }
16
- let packagePath = `./extension${ name } .zip` ;
15
+ const packagePath = `./extension${ name } .zip` ;
17
16
console . log ( `Building ${ packagePath } ` ) ;
18
17
fse . removeSync ( packagePath ) ;
19
18
zip . writeZip ( packagePath ) ;
@@ -24,21 +23,20 @@ function buildBookmarklet() {
24
23
}
25
24
26
25
function buildEdgeLegacy ( manifest , zip ) {
27
- let packagePath = './extension-edge-legacy.zip' ;
26
+ const packagePath = './extension-edge-legacy.zip' ;
28
27
console . log ( `Building ${ packagePath } ` ) ;
29
28
30
29
if ( ! fse . existsSync ( './store/edge' ) ) {
31
30
console . log ( 'Error! Missing Edge legacy polyfills.' ) ;
32
31
return false ;
33
32
}
34
33
35
- let msPreload = {
34
+ const msPreload = {
36
35
backgroundScript : 'backgroundScriptsAPIBridge.js' ,
37
36
contentScript : 'contentScriptsAPIBridge.js'
38
37
} ;
39
38
40
39
// Fix options_page
41
- // eslint-disable-next-line @typescript-eslint/camelcase
42
40
manifest . options_page = manifest . options_ui . page ;
43
41
delete manifest . options_ui ;
44
42
@@ -52,9 +50,9 @@ function buildEdgeLegacy(manifest, zip) {
52
50
}
53
51
54
52
function buildFirefox ( manifest , zip ) {
55
- let packagePath = './extension-firefox.zip' ;
53
+ const packagePath = './extension-firefox.zip' ;
56
54
console . log ( `Building ${ packagePath } ` ) ;
57
- let firefoxManifest = {
55
+ const firefoxManifest = {
58
56
applications : {
59
57
gecko : {
60
58
id : '{853d1586-e2ab-4387-a7fd-1f7f894d2651}'
@@ -78,8 +76,8 @@ function packageSource() {
78
76
console . log ( 'Building ./extension-source.zip' ) ;
79
77
console . log ( 'Build from source: npm install && npm run package' ) ;
80
78
81
- let sourceZip = new AdmZip ( ) ;
82
- let files = [
79
+ const sourceZip = new AdmZip ( ) ;
80
+ const files = [
83
81
'LICENSE' ,
84
82
'package.json' ,
85
83
'package-lock.json' ,
@@ -89,23 +87,23 @@ function packageSource() {
89
87
sourceZip . addLocalFolder ( './bin' , 'bin' ) ;
90
88
sourceZip . addLocalFolder ( './src' , 'src' ) ;
91
89
sourceZip . addLocalFolder ( './test' , 'test' ) ;
92
- files . forEach ( file => { sourceZip . addLocalFile ( path . join ( './' , file ) , null ) ; } ) ;
90
+ files . forEach ( ( file ) => { sourceZip . addLocalFile ( path . join ( './' , file ) , null ) ; } ) ;
93
91
sourceZip . writeZip ( './extension-source.zip' ) ;
94
92
}
95
93
96
94
function prepareZip ( ) {
97
- let zip = new AdmZip ( ) ;
95
+ const zip = new AdmZip ( ) ;
98
96
zip . addLocalFolder ( dist , null ) ;
99
97
return zip ;
100
98
}
101
99
102
100
function updateManifestFile ( file , obj ) {
103
- let content = JSON . stringify ( obj , null , 2 ) ;
101
+ const content = JSON . stringify ( obj , null , 2 ) ;
104
102
fse . writeFileSync ( file , content ) ;
105
103
}
106
104
107
105
function updateManifestFileInZip ( zip , obj ) {
108
- let content = JSON . stringify ( obj , null , 2 ) ;
106
+ const content = JSON . stringify ( obj , null , 2 ) ;
109
107
zip . updateFile ( 'manifest.json' , Buffer . alloc ( content . length , content ) ) ;
110
108
}
111
109
@@ -117,12 +115,12 @@ function updateManifestVersion(manifest, newVersion) {
117
115
}
118
116
119
117
function updateOptionPageVersion ( newVersion ) {
120
- let filename = 'optionPage.html' ;
121
- let optionPage = path . join ( staticDir , filename ) ;
122
- let optionPageHTML = fse . readFileSync ( optionPage ) . toString ( ) ;
118
+ const filename = 'optionPage.html' ;
119
+ const optionPage = path . join ( staticDir , filename ) ;
120
+ const optionPageHTML = fse . readFileSync ( optionPage ) . toString ( ) ;
123
121
let foundMatch = false ;
124
122
125
- let newOptionPageHTML = optionPageHTML . replace ( / i d = " h e l p V e r s i o n " > .* ?< \/ a > / , function ( match ) {
123
+ const newOptionPageHTML = optionPageHTML . replace ( / i d = " h e l p V e r s i o n " > .* ?< \/ a > / , function ( match ) {
126
124
foundMatch = true ;
127
125
return `id="helpVersion">${ newVersion } </a>` ;
128
126
} ) ;
@@ -137,9 +135,9 @@ function updateOptionPageVersion(newVersion) {
137
135
}
138
136
139
137
function updateVersions ( ) {
140
- let manifest = getManifestJSON ( ) ;
138
+ const manifest = getManifestJSON ( ) ;
141
139
if ( manifest . version != process . env . npm_package_version ) {
142
- let newVersion = process . env . npm_package_version ;
140
+ const newVersion = process . env . npm_package_version ;
143
141
console . log ( 'Version number is being updated: ' + manifest . version + ' -> ' + newVersion ) ;
144
142
updateManifestVersion ( manifest , newVersion ) ;
145
143
updateOptionPageVersion ( newVersion ) ;
@@ -148,6 +146,6 @@ function updateVersions() {
148
146
149
147
const dist = './dist/' ;
150
148
const staticDir = './src/static/' ;
151
- let manifestPath = path . join ( staticDir , 'manifest.json' ) ;
149
+ const manifestPath = path . join ( staticDir , 'manifest.json' ) ;
152
150
updateVersions ( ) ;
153
151
buildAll ( ) ;
0 commit comments