From 6d87904d1857c65cbda1f6f56a0612ee86d4c9b9 Mon Sep 17 00:00:00 2001 From: Mikunj Date: Thu, 26 Mar 2020 15:22:46 +1100 Subject: [PATCH] Clean up config files. Removed unused scripts. Removed unused files. --- CONTRIBUTING.md | 4 +-- config/default.json | 1 - config/development-1.json | 15 +------- config/development-2.json | 16 --------- config/staging.json | 4 --- config/swarm-testing-2.json | 3 ++ config/swarm-testing2.json | 11 ------ main.js | 1 - package.json | 28 +++++---------- preload.js | 2 -- prepare_beta_build.js | 66 ----------------------------------- prepare_import_build.js | 69 ------------------------------------- 12 files changed, 14 insertions(+), 206 deletions(-) delete mode 100644 config/development-2.json delete mode 100644 config/staging.json create mode 100644 config/swarm-testing-2.json delete mode 100644 config/swarm-testing2.json delete mode 100644 prepare_beta_build.js delete mode 100644 prepare_import_build.js diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 04557db73..61cd4f4d6 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -95,8 +95,7 @@ yarn start-multi ``` For more than 2 clients, you can setup additional storage profiles and switch -between them using the `NODE_APP_INSTANCE` environment variable and specifying a -new localServerPort in the config. +between them using the `NODE_APP_INSTANCE` environment variable. For example, to create an 'alice' profile, put a file called `local-alice.json` in the `config` directory: @@ -104,7 +103,6 @@ For example, to create an 'alice' profile, put a file called `local-alice.json` ``` { "storageProfile": "aliceProfile", - "localServerPort": "8082", } ``` diff --git a/config/default.json b/config/default.json index b08784f25..b8a2dcc33 100644 --- a/config/default.json +++ b/config/default.json @@ -3,7 +3,6 @@ "localUrl": "localhost.loki", "cdnUrl": "random.snode", "contentProxyUrl": "", - "localServerPort": "8081", "defaultPoWDifficulty": "1", "seedNodeList": [ { diff --git a/config/development-1.json b/config/development-1.json index 2ff930238..0cccc8bd9 100644 --- a/config/development-1.json +++ b/config/development-1.json @@ -1,16 +1,3 @@ { - "storageProfile": "development1", - "localServerPort": "8082", - "seedNodeList": [ - { - "ip": "public.loki.foundation", - "port": "38157" - }, - { - "ip": "storage.testnetseed1.loki.network", - "port": "38157" - } - ], - "openDevTools": true, - "defaultPublicChatServer": "https://chat-dev.lokinet.org/" + "storageProfile": "development1" } diff --git a/config/development-2.json b/config/development-2.json deleted file mode 100644 index bf4c93258..000000000 --- a/config/development-2.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "storageProfile": "development2", - "localServerPort": "8083", - "seedNodeList": [ - { - "ip": "public.loki.foundation", - "port": "38157" - }, - { - "ip": "storage.testnetseed1.loki.network", - "port": "38157" - } - ], - "openDevTools": true, - "defaultPublicChatServer": "https://chat-dev.lokinet.org/" -} diff --git a/config/staging.json b/config/staging.json deleted file mode 100644 index f74f4b48e..000000000 --- a/config/staging.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "storageProfile": "staging", - "openDevTools": true -} diff --git a/config/swarm-testing-2.json b/config/swarm-testing-2.json new file mode 100644 index 000000000..0c69c0be1 --- /dev/null +++ b/config/swarm-testing-2.json @@ -0,0 +1,3 @@ +{ + "storageProfile": "swarm-testing2" +} diff --git a/config/swarm-testing2.json b/config/swarm-testing2.json deleted file mode 100644 index 5469d9dab..000000000 --- a/config/swarm-testing2.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "storageProfile": "swarm-testing2", - "seedNodeList": [ - { - "ip": "localhost", - "port": "22129" - } - ], - "openDevTools": true, - "defaultPublicChatServer": "https://team-chat.lokinet.org/" -} diff --git a/main.js b/main.js index 3c0943e6d..c32457be9 100644 --- a/main.js +++ b/main.js @@ -155,7 +155,6 @@ function prepareURL(pathSegments, moreKeys) { serverUrl: config.get('serverUrl'), localUrl: config.get('localUrl'), cdnUrl: config.get('cdnUrl'), - localServerPort: config.get('localServerPort'), defaultPoWDifficulty: config.get('defaultPoWDifficulty'), seedNodeList: JSON.stringify(config.get('seedNodeList')), certificateAuthority: config.get('certificateAuthority'), diff --git a/package.json b/package.json index e6bfcf6ca..9ba68d708 100644 --- a/package.json +++ b/package.json @@ -20,21 +20,15 @@ "start-multi2": "cross-env NODE_APP_INSTANCE=2 electron .", "start-prod": "cross-env NODE_ENV=production NODE_APP_INSTANCE=devprod LOKI_DEV=1 electron .", "start-prod-multi": "cross-env NODE_ENV=production NODE_APP_INSTANCE=devprod1 LOKI_DEV=1 electron .", - "start-swarm-test": "cross-env NODE_ENV=swarm-testing NODE_APP_INSTANCE=test1 LOKI_DEV=1 electron .", - "start-swarm-test-2": "cross-env NODE_ENV=swarm-testing2 NODE_APP_INSTANCE=test2 LOKI_DEV=1 electron .", + "start-swarm-test": "cross-env NODE_ENV=swarm-testing NODE_APP_INSTANCE=1 LOKI_DEV=1 electron .", + "start-swarm-test-2": "cross-env NODE_ENV=swarm-testing NODE_APP_INSTANCE=2 LOKI_DEV=1 electron .", "grunt": "grunt", "icon-gen": "electron-icon-maker --input=images/icon_1024.png --output=./build", "generate": "yarn icon-gen && yarn grunt", - "build": "electron-builder --config.extraMetadata.environment=$SIGNAL_ENV", - "build-release": "cross-env SIGNAL_ENV=production npm run build -- --config.directories.output=release", - "make:linux:x64:appimage": "electron-builder build --linux appimage --x64", "build-module-protobuf": "pbjs --target static-module --wrap commonjs --out ts/protobuf/compiled.js protos/*.proto && pbts --out ts/protobuf/compiled.d.ts ts/protobuf/compiled.js", "clean-module-protobuf": "rm -f ts/protobuf/compiled.d.ts ts/protobuf/compiled.js", "build-protobuf": "yarn build-module-protobuf", "clean-protobuf": "yarn clean-module-protobuf", - "prepare-beta-build": "node prepare_beta_build.js", - "prepare-import-build": "node prepare_import_build.js", - "publish-to-apt": "NAME=$npm_package_name VERSION=$npm_package_version ./aptly.sh", "test": "yarn test-node && yarn test-electron", "test-view": "NODE_ENV=test yarn run start", "test-lib-view": "NODE_ENV=test-lib yarn run start", @@ -42,24 +36,20 @@ "test-electron": "yarn grunt test", "test-integration-session": "ELECTRON_DISABLE_SANDBOX=1 mocha --exit --timeout 5000 integration_test/integration_test.js", "test-node": "mocha --recursive --exit test/app test/modules ts/test libloki/test/node", - "test-node-coverage": "nyc --reporter=lcov --reporter=text mocha --recursive test/app test/modules ts/test libloki/test/node", - "test-node-coverage-html": "nyc --reporter=lcov --reporter=html mocha --recursive test/a/* */pp test/modules ts/test libloki/test/node", "eslint": "eslint --cache .", "eslint-fix": "eslint --fix .", "eslint-full": "eslint .", - "lint": "yarn format --list-different && yarn lint-windows", - "lint-full": "yarn format-full --list-different; yarn lint-windows-full", - "dev-lint": "yarn format --list-different; yarn lint-windows", - "lint-windows": "yarn eslint && yarn tslint", - "lint-windows-full": "yarn eslint-full && yarn tslint", + "lint": "yarn format && yarn lint-files", + "lint-full": "yarn format-full && yarn lint-files-full", + "dev-lint": "yarn format && yarn lint-files", + "lint-files": "yarn eslint && yarn tslint", + "lint-files-full": "yarn eslint-full && yarn tslint", "lint-deps": "node ts/util/lint/linter.js", "tslint": "tslint --format stylish --project .", - "format": "prettier --write `git ls-files --modified *.{css,js,json,md,scss,ts,tsx}` `git ls-files --modified ./**/*.{css,js,json,md,scss,ts,tsx}`", - "format-full": "prettier --write \"*.{css,js,json,md,scss,ts,tsx}\" \"./**/*.{css,js,json,md,scss,ts,tsx}\"", + "format": "prettier --list-different --write `git ls-files --modified *.{css,js,json,md,scss,ts,tsx}` `git ls-files --modified ./**/*.{css,js,json,md,scss,ts,tsx}`", + "format-full": "prettier --list-different --write \"*.{css,js,json,md,scss,ts,tsx}\" \"./**/*.{css,js,json,md,scss,ts,tsx}\"", "transpile": "tsc", "clean-transpile": "rimraf ts/**/*.js && rimraf ts/*.js", - "open-coverage": "open coverage/lcov-report/index.html", - "styleguide": "styleguidist server", "pow-metrics": "node metrics_app.js localhost 9000", "ready": "yarn clean-transpile && yarn grunt && yarn lint-full && yarn test-node && yarn test-electron && yarn lint-deps" }, diff --git a/preload.js b/preload.js index 4b1e6220d..6232c2cd5 100644 --- a/preload.js +++ b/preload.js @@ -317,8 +317,6 @@ window.LokiFileServerAPI = require('./js/modules/loki_file_server_api'); window.LokiRssAPI = require('./js/modules/loki_rss_api'); -window.localServerPort = config.localServerPort; - window.mnemonic = require('./libloki/modules/mnemonic'); const WorkerInterface = require('./js/modules/util_worker_interface'); diff --git a/prepare_beta_build.js b/prepare_beta_build.js deleted file mode 100644 index 13e297297..000000000 --- a/prepare_beta_build.js +++ /dev/null @@ -1,66 +0,0 @@ -/* eslint-disable no-console */ - -const fs = require('fs'); -const _ = require('lodash'); - -const packageJson = require('./package.json'); - -const { version } = packageJson; -const beta = /beta/; - -// You might be wondering why this file is necessary. It comes down to our desire to allow -// side-by-side installation of production and beta builds. Electron-Builder uses -// top-level data from package.json for many things, like the executable name, the -// debian package name, the install directory under /opt on linux, etc. We tried -// adding the ${channel} macro to these values, but Electron-Builder didn't like that. - -if (!beta.test(version)) { - process.exit(); -} - -console.log('prepare_beta_build: updating package.json'); - -// ------- - -const NAME_PATH = 'name'; -const PRODUCTION_NAME = 'loki-messenger-desktop'; -const BETA_NAME = 'loki-messenger-desktop-beta'; - -const PRODUCT_NAME_PATH = 'productName'; -const PRODUCTION_PRODUCT_NAME = 'Session'; -const BETA_PRODUCT_NAME = 'Session Beta'; - -const APP_ID_PATH = 'build.appId'; -const PRODUCTION_APP_ID = 'com.loki-project.messenger-desktop'; -const BETA_APP_ID = 'com.loki-project.messenger-desktop-beta'; - -const STARTUP_WM_CLASS_PATH = 'build.linux.desktop.StartupWMClass'; -const PRODUCTION_STARTUP_WM_CLASS = 'Session'; -const BETA_STARTUP_WM_CLASS = 'Session Beta'; - -// ------- - -function checkValue(object, objectPath, expected) { - const actual = _.get(object, objectPath); - if (actual !== expected) { - throw new Error(`${objectPath} was ${actual}; expected ${expected}`); - } -} - -// ------ - -checkValue(packageJson, NAME_PATH, PRODUCTION_NAME); -checkValue(packageJson, PRODUCT_NAME_PATH, PRODUCTION_PRODUCT_NAME); -checkValue(packageJson, APP_ID_PATH, PRODUCTION_APP_ID); -checkValue(packageJson, STARTUP_WM_CLASS_PATH, PRODUCTION_STARTUP_WM_CLASS); - -// ------- - -_.set(packageJson, NAME_PATH, BETA_NAME); -_.set(packageJson, PRODUCT_NAME_PATH, BETA_PRODUCT_NAME); -_.set(packageJson, APP_ID_PATH, BETA_APP_ID); -_.set(packageJson, STARTUP_WM_CLASS_PATH, BETA_STARTUP_WM_CLASS); - -// ------- - -fs.writeFileSync('./package.json', JSON.stringify(packageJson, null, ' ')); diff --git a/prepare_import_build.js b/prepare_import_build.js deleted file mode 100644 index e74a168ed..000000000 --- a/prepare_import_build.js +++ /dev/null @@ -1,69 +0,0 @@ -/* eslint-disable no-console */ - -const fs = require('fs'); -const _ = require('lodash'); - -const packageJson = require('./package.json'); -const defaultConfig = require('./config/default.json'); - -function checkValue(object, objectPath, expected) { - const actual = _.get(object, objectPath); - if (actual !== expected) { - throw new Error(`${objectPath} was ${actual}; expected ${expected}`); - } -} - -// You might be wondering why this file is necessary. We have some very specific -// requirements around our import-flavor builds. They need to look exactly the same as -// normal builds, but they must immediately open into import mode. So they need a -// slight config tweak, and then a change to the .app/.exe name (note: we do NOT want to -// change where data is stored or anything, since that would make these builds -// incompatible with the mainline builds) So we just change the artifact name. -// -// Another key thing to know about these builds is that we should not upload the -// latest.yml (windows) and latest-mac.yml (mac) that go along with the executables. -// This would interrupt the normal install flow for users installing from -// signal.org/download. So any release script will need to upload these files manually -// instead of relying on electron-builder, which will upload everything. - -// ------- - -console.log('prepare_import_build: updating config/default.json'); - -const IMPORT_PATH = 'import'; -const IMPORT_START_VALUE = false; -const IMPORT_END_VALUE = true; - -checkValue(defaultConfig, IMPORT_PATH, IMPORT_START_VALUE); - -_.set(defaultConfig, IMPORT_PATH, IMPORT_END_VALUE); - -// ------- - -console.log('prepare_import_build: updating package.json'); - -const MAC_ASSET_PATH = 'build.mac.artifactName'; -// eslint-disable-next-line no-template-curly-in-string -const MAC_ASSET_START_VALUE = '${name}-mac-${version}.${ext}'; -// eslint-disable-next-line no-template-curly-in-string -const MAC_ASSET_END_VALUE = '${name}-mac-${version}-import.${ext}'; - -const WIN_ASSET_PATH = 'build.win.artifactName'; -// eslint-disable-next-line no-template-curly-in-string -const WIN_ASSET_START_VALUE = '${name}-win-${version}.${ext}'; -// eslint-disable-next-line no-template-curly-in-string -const WIN_ASSET_END_VALUE = '${name}-win-${version}-import.${ext}'; - -checkValue(packageJson, MAC_ASSET_PATH, MAC_ASSET_START_VALUE); -checkValue(packageJson, WIN_ASSET_PATH, WIN_ASSET_START_VALUE); - -_.set(packageJson, MAC_ASSET_PATH, MAC_ASSET_END_VALUE); -_.set(packageJson, WIN_ASSET_PATH, WIN_ASSET_END_VALUE); - -// --- - -fs.writeFileSync( - './config/default.json', - JSON.stringify(defaultConfig, null, ' ') -); -fs.writeFileSync('./package.json', JSON.stringify(packageJson, null, ' '));