Skip to content

Commit

Permalink
chore(client/electron): move src/electron into client/src/electron
Browse files Browse the repository at this point in the history
  • Loading branch information
daniellacosse committed Apr 5, 2024
1 parent 341e6d7 commit 049ed5d
Show file tree
Hide file tree
Showing 57 changed files with 44 additions and 46 deletions.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
// limitations under the License.

import minimist from 'minimist';
import {runAction} from '../build/run_action.mjs';
import {getBuildParameters} from '../../client/src/build/get_build_parameters.mjs';
import {runAction} from '../../../src/build/run_action.mjs';
import {getBuildParameters} from '../build/get_build_parameters.mjs';
import electron, {Platform} from 'electron-builder';
import copydir from 'copy-dir';
import fs from 'fs/promises';
import url from 'url';
import {getRootDir} from '../build/get_root_dir.mjs';
import {getRootDir} from '../../../src/build/get_root_dir.mjs';
import path from 'path';

const ELECTRON_BUILD_DIR = 'build';
Expand Down Expand Up @@ -49,16 +49,16 @@ export async function main(...parameters) {
}

await runAction('client/src/www/build', ...parameters);
await runAction('client/src/tun2socks/build', ...parameters);
await runAction('src/electron/build_main', ...parameters);
// await runAction('client/src/tun2socks/build', ...parameters);
await runAction('client/src/electron/build_main', ...parameters);

await copydir.sync(
path.join(getRootDir(), 'src', 'electron', 'icons'),
path.join(getRootDir(), ELECTRON_BUILD_DIR, 'icons')
path.join(getRootDir(), 'client', 'src', 'electron', 'icons'),
path.join(getRootDir(), 'client', ELECTRON_BUILD_DIR, 'icons')
);

const electronConfig = JSON.parse(
await fs.readFile(path.resolve(getRootDir(), 'src', 'electron', 'electron-builder.json'))
await fs.readFile(path.resolve(getRootDir(), 'client', 'src', 'electron', 'electron-builder.json'))
);

// build electron binary
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@
// See the License for the specific language governing permissions and
// limitations under the License.

import {runAction} from '../build/run_action.mjs';
import {getBuildParameters} from '../../client/src/build/get_build_parameters.mjs';
import {getWebpackBuildMode} from '../../client/src/build/get_webpack_build_mode.mjs';
import {runWebpack} from '../../client/src/build/run_webpack.mjs';
import {runAction} from '../../../src/build/run_action.mjs';
import {getBuildParameters} from '../build/get_build_parameters.mjs';
import {getWebpackBuildMode} from '../build/get_webpack_build_mode.mjs';
import {runWebpack} from '../build/run_webpack.mjs';
import electronMainWebpackConfigs from './webpack_electron_main.mjs';
import fs from 'fs/promises';
import path from 'path';
import url from 'url';
import {getRootDir} from '../build/get_root_dir.mjs';
import {getRootDir} from '../../../src/build/get_root_dir.mjs';

const ELECTRON_BUILD_DIR = 'build';
const ELECTRON_PLATFORMS = ['linux', 'windows'];
Expand Down Expand Up @@ -57,7 +57,7 @@ export async function main(...parameters) {
windowsEnvironment += `\n!define SENTRY_URL "<debug>"`;
}

await fs.writeFile(path.resolve(getRootDir(), ELECTRON_BUILD_DIR, 'env.nsh'), windowsEnvironment);
await fs.writeFile(path.resolve(getRootDir(), 'client', ELECTRON_BUILD_DIR, 'env.nsh'), windowsEnvironment);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

import * as dns from 'dns';

import {timeoutPromise} from '../../client/src/infrastructure/timeout_promise';
import * as errors from '../../client/src/www/model/errors';
import {timeoutPromise} from '../infrastructure/timeout_promise';
import * as errors from '../www/model/errors';

const DNS_LOOKUP_TIMEOUT_MS = 10000;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ ${StrRep}

; OutlineService files, stopping the service first in case it's still running.
nsExec::Exec "$SYSDIR\net stop OutlineService"
File "${PROJECT_DIR}\tools\OutlineService\OutlineService\bin\OutlineService.exe"
File "${PROJECT_DIR}\tools\smartdnsblock\bin\smartdnsblock.exe"
File "${PROJECT_DIR}\client\tools\OutlineService\OutlineService\bin\OutlineService.exe"
File "${PROJECT_DIR}\client\tools\smartdnsblock\bin\smartdnsblock.exe"
File "${PROJECT_DIR}\third_party\newtonsoft\Newtonsoft.Json.dll"
File "${PROJECT_DIR}\src\electron\install_windows_service.bat"
File "${PROJECT_DIR}\client\src\electron\install_windows_service.bat"

; ExecToStack captures both stdout and stderr from the script, in the order output.
; Set a (long) timeout in case the device never becomes visible to netsh.
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
import {powerMonitor} from 'electron';
import {platform} from 'os';

import {pathToEmbeddedBinary} from '../../client/src/infrastructure/electron/app_paths';
import {ShadowsocksSessionConfig} from '../../client/src/www/app/tunnel';
import {TunnelStatus} from '../../client/src/www/app/tunnel';
import {ErrorCode, fromErrorCode, UnexpectedPluginError} from '../../client/src/www/model/errors';
import {pathToEmbeddedBinary} from '../infrastructure/electron/app_paths';
import {ShadowsocksSessionConfig} from '../www/app/tunnel';
import {TunnelStatus} from '../www/app/tunnel';
import {ErrorCode, fromErrorCode, UnexpectedPluginError} from '../www/model/errors';

import {ChildProcessHelper, ProcessTerminatedExitCodeError, ProcessTerminatedSignalError} from './process';
import {RoutingDaemon} from './routing_service';
Expand Down
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
6 changes: 3 additions & 3 deletions src/electron/index.ts → client/src/electron/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ import * as process from 'process';
import * as url from 'url';
import autoLaunch = require('auto-launch'); // tslint:disable-line

import * as errors from '../../client/src/www/model/errors';
import * as errors from '../www/model/errors';

import {ShadowsocksSessionConfig} from '../../client/src/www/app/tunnel';
import {TunnelStatus} from '../../client/src/www/app/tunnel';
import {ShadowsocksSessionConfig} from '../www/app/tunnel';
import {TunnelStatus} from '../www/app/tunnel';
import {GoVpnTunnel} from './go_vpn_tunnel';
import {installRoutingServices, RoutingDaemon} from './routing_service';
import {TunnelStore, SerializableTunnel} from './tunnel_store';
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ import {platform, userInfo} from 'os';
import * as path from 'path';
import * as sudo from 'sudo-prompt';

import {getAppPath} from '../../client/src/infrastructure/electron/app_paths';
import {TunnelStatus} from '../../client/src/www/app/tunnel';
import {ErrorCode, SystemConfigurationException} from '../../client/src/www/model/errors';
import {getAppPath} from '../infrastructure/electron/app_paths';
import {TunnelStatus} from '../www/app/tunnel';
import {ErrorCode, SystemConfigurationException} from '../www/model/errors';

const isLinux = platform() === 'linux';
const isWindows = platform() === 'win32';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
import url from 'url';
import electron from 'electron';

import {runAction} from '../../client/src/build/run_action.mjs';
import {getBuildParameters} from '../../client/src/build/get_build_parameters.mjs';
import {getRootDir} from '../../client/src/build/get_root_dir.mjs';
import {spawnStream} from '../../client/src/build/spawn_stream.mjs';
import {runAction} from '../../../src/build/run_action.mjs';
import {getBuildParameters} from '../build/get_build_parameters.mjs';
import {getRootDir} from '../../../src/build/get_root_dir.mjs';
import {spawnStream} from '../../../src/build/spawn_stream.mjs';

/**
* @description Builds and starts the electron application.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../client/src/www/tsconfig.json",
"extends": "../www/tsconfig.json",
"compilerOptions": {
"outDir": "../../build/electron"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import * as fs from 'fs';
import * as path from 'path';

import {ShadowsocksSessionConfig} from '../../client/src/www/app/tunnel';
import {ShadowsocksSessionConfig} from '../www/app/tunnel';

// Format to store a tunnel configuration.
export interface SerializableTunnel {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

import {TunnelStatus} from '../../client/src/www/app/tunnel';
import {TunnelStatus} from '../www/app/tunnel';

// Represents a VPN tunnel to a proxy server.
export interface VpnTunnel {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const __dirname = path.dirname(__filename);

export default ({sentryDsn, appVersion}) => [
{
entry: './src/electron/index.ts',
entry: './client/src/electron/index.ts',
target: 'electron-main',
node: {
__dirname: false,
Expand Down Expand Up @@ -53,7 +53,7 @@ export default ({sentryDsn, appVersion}) => [
},
},
{
entry: './src/electron/preload.ts',
entry: './client/src/electron/preload.ts',
target: 'electron-preload',
devtool: 'inline-source-map',
module: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
* @param {Object} configuration.options a duplication of electron-builder.json
*/
async function electronBuilderEntryPoint(configuration) {
const {runAction} = await import('../../build/run_action.mjs');
const {runAction} = await import('../../../../src/build/run_action.mjs');
await runAction('src/electron/windows/sign_windows_executable',
'--target', configuration.path,
'--algorithm', configuration.hash);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {dirname, resolve} from 'path';
import {fileURLToPath, pathToFileURL} from 'url';
import {format} from 'util';

import {jsign} from '../../../third_party/jsign/index.mjs';
import {jsign} from '../../../../third_party/jsign/index.mjs';

/**
* Get the parent folder path of this script.
Expand Down
2 changes: 1 addition & 1 deletion client/src/www/app/electron_main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

/// <reference path="../../../../src/electron/preload.d.ts" />
/// <reference path="../../electron/preload.d.ts" />

import 'web-animations-js/web-animations-next-lite.min.js';
import '@webcomponents/webcomponentsjs/webcomponents-bundle.js';
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
7 changes: 2 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"action:help": "npm run action list",
"action:list": "npm run action list",
"action": "node ./src/build/run_action.mjs",
"clean": "rimraf client/build client/output node_modules client/node_modules client/www client/platforms client/plugins third_party/jsign/*.jar",
"clean": "rimraf build output client/build client/output node_modules client/node_modules client/www client/platforms client/plugins third_party/jsign/*.jar",
"format:all": "prettier --write \"**/*.{cjs,mjs,html,js,json,md,ts}\"",
"format": "pretty-quick --staged --pattern \"**/*.{cjs,mjs,html,js,json,md,ts}\"",
"lint:ts": "eslint --ext ts,mjs client/src",
Expand All @@ -20,8 +20,5 @@
"server_manager",
"client"
],
"devDependencies": {
"electron-builder": "^24.13.3"
},
"main": "build/electron/electron/index.js"
"main": "client/build/electron/electron/index.js"
}
1 change: 1 addition & 0 deletions www/environment.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"APP_VERSION":"0.0.0-debug","APP_BUILD_NUMBER":475649}

0 comments on commit 049ed5d

Please sign in to comment.