diff --git a/README.md b/README.md index dcd7671..e7c4bbb 100644 --- a/README.md +++ b/README.md @@ -16,10 +16,12 @@ Please visit [this page](http://uku.im/contributors) for an up-to-date list of o ## Development -Update URL and server configs under the folder `src/configs/`. +Update URLs and server configs under the folder `configs/`. Run `npm ci` to install dependencies exactly as they are listed in the package-lock.json file. Run `npm run lint` to check the coding style of all source code. Run `npm run test` to create a zip file for uploading to Chrome Web Store and run tests against it. + +Change `headerless` in `jest-puppeteer.config.js` to `false` to see the browser UI while the tests are running. diff --git a/configs/servers.mjs b/configs/servers.mjs new file mode 100644 index 0000000..6d52031 --- /dev/null +++ b/configs/servers.mjs @@ -0,0 +1,11 @@ +// _PROXY_PROTOCOL can be HTTP, HTTPS, or SOCKS5 +export const DEFAULT_PROXY_PROTOCOL = 'HTTPS'; +export const DEFAULT_PROXY_ADDRESS = 'secure.uku.im:8443'; +export const BACKUP_PROXY_PROTOCOL = 'HTTPS'; +export const BACKUP_PROXY_ADDRESS = 'secure.uku.im:993'; + +// For debugging +// export const DEFAULT_PROXY_PROTOCOL = 'SOCKS5'; +// export const DEFAULT_PROXY_ADDRESS = '127.0.0.1:1086'; +// export const BACKUP_PROXY_PROTOCOL = 'SOCKS5'; +// export const BACKUP_PROXY_ADDRESS = '127.0.0.1:1086'; diff --git a/src/configs/servers.test.mjs b/configs/servers.test.mjs similarity index 100% rename from src/configs/servers.test.mjs rename to configs/servers.test.mjs diff --git a/src/configs/urls.mjs b/configs/urls.mjs similarity index 100% rename from src/configs/urls.mjs rename to configs/urls.mjs diff --git a/src/configs/urls.test.mjs b/configs/urls.test.mjs similarity index 100% rename from src/configs/urls.test.mjs rename to configs/urls.test.mjs diff --git a/jest-puppeteer.config.js b/jest-puppeteer.config.js index a134e3e..1957d30 100644 --- a/jest-puppeteer.config.js +++ b/jest-puppeteer.config.js @@ -5,7 +5,7 @@ const CRX_PATH = path.resolve(__dirname, './dist/unzipped_chrome_extension'); module.exports = { launch: { headless: 'chrome', // Extensions won't load if headerless=true - // headless: false, // Add this to debug + // headless: false, // Use this option for debugging args: [ `--disable-extensions-except=${CRX_PATH}`, `--load-extension=${CRX_PATH}`, diff --git a/src/configs/servers.mjs b/src/configs/servers.mjs deleted file mode 100644 index fb00c5d..0000000 --- a/src/configs/servers.mjs +++ /dev/null @@ -1,4 +0,0 @@ -export const DEFAULT_PROXY_PROTOCOL = 'HTTPS'; // Can be HTTP, HTTPS, SOCKS5 -export const DEFAULT_PROXY_ADDRESS = 'secure.uku.im:8443'; -export const BACKUP_PROXY_PROTOCOL = 'HTTPS'; -export const BACKUP_PROXY_ADDRESS = 'secure.uku.im:993'; diff --git a/src/modules/_header.mjs b/src/modules/_header.mjs index d994b71..3098a29 100644 --- a/src/modules/_header.mjs +++ b/src/modules/_header.mjs @@ -3,7 +3,7 @@ */ -import {HEADER_URLS} from '../configs/urls.mjs'; +import {HEADER_URLS} from '../../configs/urls.mjs'; function newRandomIp() { diff --git a/src/modules/_proxy.mjs b/src/modules/_proxy.mjs index c5eecd3..7567b5d 100644 --- a/src/modules/_proxy.mjs +++ b/src/modules/_proxy.mjs @@ -3,10 +3,10 @@ */ -import {PROXY_BYPASS_URLS, PROXY_URLS} from '../configs/urls.mjs'; +import {PROXY_BYPASS_URLS, PROXY_URLS} from '../../configs/urls.mjs'; import { DEFAULT_PROXY_PROTOCOL, DEFAULT_PROXY_ADDRESS, BACKUP_PROXY_PROTOCOL, BACKUP_PROXY_ADDRESS} - from '../configs/servers.mjs'; + from '../../configs/servers.mjs'; import {urls2pac} from './_url_utils.mjs'; diff --git a/src/modules/settings.mjs b/src/modules/settings.mjs index d97de25..5efe2a9 100644 --- a/src/modules/settings.mjs +++ b/src/modules/settings.mjs @@ -44,8 +44,8 @@ function applyModeSettings(mode) { const setProxy = async () => { const customProxy = await getCustomProxy(); if (typeof customProxy === 'undefined' || - typeof customProxy.proc === 'undefined' || - typeof customProxy.addr === 'undefined') { + typeof customProxy.proc === 'undefined' || + typeof customProxy.addr === 'undefined') { return Proxy.setDefaultProxy(); } else { return Proxy.setCustomProxy(customProxy.proc, customProxy.addr); diff --git a/src/options.mjs b/src/options.mjs index 47fe732..186a6a7 100644 --- a/src/options.mjs +++ b/src/options.mjs @@ -1,7 +1,7 @@ import './modules/crash_report.mjs'; import * as Settings from './modules/settings.mjs'; -import {DEFAULT_PROXY_PROTOCOL, DEFAULT_PROXY_ADDRESS} from './configs/servers.mjs'; +import {DEFAULT_PROXY_PROTOCOL, DEFAULT_PROXY_ADDRESS} from '../configs/servers.mjs'; function showProxyMessage(type, content) { diff --git a/tools/create_zip.js b/tools/create_zip.js index 71c1ea9..b94fbbd 100644 --- a/tools/create_zip.js +++ b/tools/create_zip.js @@ -7,16 +7,14 @@ const archiver = require('archiver'); const TOP_FOLDER_LOCATION = path.join(__dirname, '../'); -const SERVER_CONFIG_FILE_LOCATION = path.join( - TOP_FOLDER_LOCATION, 'src/configs/servers.mjs'); -const OUTPUT_ZIP_FILE_LOCATION = path.join( - TOP_FOLDER_LOCATION, 'dist/upload_to_chrome_store.zip'); +const OUTPUT_ZIP_FILE_LOCATION = path.join(TOP_FOLDER_LOCATION, 'dist/upload_to_chrome_store.zip'); const FILES_TO_BE_ZIPPED = [ 'manifest.json', - 'src', - 'icons', '_locales', + 'configs', + 'icons', + 'src', 'COPYING.txt', ]; const EXCLUDED_FILE_PATTERNS = [ @@ -37,13 +35,6 @@ const EXCLUDED_FILE_PATTERNS = [ ]; -// Do some sanity checks before we start -const serverConfig = fs.readFileSync(SERVER_CONFIG_FILE_LOCATION, 'utf8'); -if (serverConfig.includes('localhost') || serverConfig.includes('127.0.0.1')) { - console.error('ERROR: Remove 127.0.0.1 / localhost from servers.mjs and try again'); - process.exit(-1); -} - // Make sure the output folder exists fs.mkdirSync(path.dirname(OUTPUT_ZIP_FILE_LOCATION), {recursive: true}); // Create output stream diff --git a/tools/produce_regex.mjs b/tools/produce_regex.mjs index 2645da1..f7cf4d7 100644 --- a/tools/produce_regex.mjs +++ b/tools/produce_regex.mjs @@ -1,4 +1,4 @@ -import {PROXY_URLS} from '../src/configs/urls.mjs'; +import {PROXY_URLS} from '../configs/urls.mjs'; import {produceSquidRegexList} from './_regex_utils.mjs'; console.log(produceSquidRegexList(PROXY_URLS).join('\n') + '\n');