fix(developer): address review comments

Co-authored-by: Darcy Wong <darcy_wong@sil.org>
Co-authored-by: Eberhard Beilharz <ermshiperete@users.noreply.github.com>
This commit is contained in:
Marc Durdin 2026-03-02 10:31:20 +01:00
parent 058df11f0c
commit b2dbd357b8
3 changed files with 32 additions and 29 deletions

View file

@ -8,7 +8,6 @@ export class Configuration {
public readonly lockFilename: string;
public readonly pidFilename: string;
public readonly configFilename: string;
public readonly ngrokBinPath: string;
/* Configuration values - set in config.json by TIKE */
@ -17,7 +16,6 @@ export class Configuration {
/* ngrok Configuration */
public readonly useNgrok: boolean;
public readonly ngrokControlPort: number;
public readonly ngrokToken: string;
public readonly ngrokVisible: boolean;
@ -42,8 +40,6 @@ export class Configuration {
// ngrok configuration
this.useNgrok = cfg?.useNgrok ?? false;
this.ngrokBinPath = this.appDataPath + 'bin/';
this.ngrokControlPort = cfg?.ngrokControlPort ?? 8009;
this.ngrokToken = cfg?.ngrokToken ?? '';
this.ngrokVisible = cfg?.ngrokVisible ?? false;
}

View file

@ -125,30 +125,36 @@ async function startNGrok() {
return false;
}
let started = false;
const listener = await ngrok.forward({
proto: 'http',
addr: configuration.port,
authtoken: configuration.ngrokToken,
onLogEvent: (msg: string) => {
if(options.ngrokLog) {
console.log(chalk.cyan(('\n'+msg).split('\n').join('\n[ngrok] ').trim()));
try {
let started = false;
const listener = await ngrok.forward({
proto: 'http',
addr: configuration.port,
authtoken: configuration.ngrokToken,
onLogEvent: (msg: string) => {
if(options.ngrokLog) {
console.log(chalk.cyan(('\n'+msg).split('\n').join('\n[ngrok] ').trim()));
}
},
onStatusChange: (state: string) => {
if(state == 'connected' && started) {
// We only announce reconnection after initial start
configuration.ngrokEndpoint = listener.url() ?? '';
console.log(chalk.blueBright('ngrok tunnel reconnected at %s'), configuration.ngrokEndpoint);
} else if(state == 'closed') {
configuration.ngrokEndpoint = '';
console.log(chalk.blueBright('ngrok tunnel closed'));
}
}
},
onStatusChange: (state: string) => {
if(state == 'connected' && started) {
// We only announce reconnection after initial start
configuration.ngrokEndpoint = listener.url();
console.log(chalk.blueBright('ngrok tunnel reconnected at %s'), configuration.ngrokEndpoint);
} else if(state == 'closed') {
configuration.ngrokEndpoint = '';
console.log(chalk.blueBright('ngrok tunnel closed'));
}
}
});
started = true;
configuration.ngrokEndpoint = listener.url();
console.log(chalk.blueBright('ngrok tunnel established at %s'), configuration.ngrokEndpoint);
});
started = true;
configuration.ngrokEndpoint = listener.url();
console.log(chalk.blueBright('ngrok tunnel established at %s'), configuration.ngrokEndpoint);
} catch(e) {
configuration.ngrokEndpoint = '';
console.error(chalk.red('ngrok tunnel failed to connect with an error: %s'), e);
return false;
}
return true;
}

View file

@ -82,7 +82,8 @@ const
SUrlNgrokSignup = 'https://dashboard.ngrok.com/signup';
// Note, we manually update the version of ngrok as required in subsequent
// releases, rather than trying to handle a potentially moving target
// releases, rather than trying to handle a potentially moving target. This
// should match developer/src/server/package.json version for ngrok.
SNgrokVersion = 'v1.7.0';
SUrlNgrokDownload = 'https://github.com/ngrok/ngrok-javascript/releases/download/'+SNgrokVersion+'/ngrok.win32-ia32-msvc.node';
SNgrokNodeModuleFilename = 'ngrok-win32-ia32-msvc.node';
@ -317,7 +318,7 @@ end;
function TfrmServerOptions.RedistInstallerPath: string;
begin
Result := TServerDebugAPI.ServerBinPath + SVCRedistExeFilename;
Result := TServerDebugAPI.ServerBinPath + '\' + SVCRedistExeFilename;
end;
procedure TfrmServerOptions.UpdateVersionLabel;