Skip to content

Commit

Permalink
move src/configs/ to configs/ so it's easier to change them
Browse files Browse the repository at this point in the history
  • Loading branch information
zhuzhuor committed Jul 4, 2022
1 parent 6b1f8ab commit d09e9aa
Show file tree
Hide file tree
Showing 13 changed files with 26 additions and 26 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
11 changes: 11 additions & 0 deletions configs/servers.mjs
Original file line number Diff line number Diff line change
@@ -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';
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion jest-puppeteer.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`,
Expand Down
4 changes: 0 additions & 4 deletions src/configs/servers.mjs

This file was deleted.

2 changes: 1 addition & 1 deletion src/modules/_header.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*/


import {HEADER_URLS} from '../configs/urls.mjs';
import {HEADER_URLS} from '../../configs/urls.mjs';


function newRandomIp() {
Expand Down
4 changes: 2 additions & 2 deletions src/modules/_proxy.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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';


Expand Down
4 changes: 2 additions & 2 deletions src/modules/settings.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/options.mjs
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down
17 changes: 4 additions & 13 deletions tools/create_zip.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tools/produce_regex.mjs
Original file line number Diff line number Diff line change
@@ -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');
Expand Down

0 comments on commit d09e9aa

Please sign in to comment.