npm package diff

Package: @forge/tunnel

Versions: 5.3.3-next.0-experimental-10722bc - 5.5.0-next.13

File: package/out/command/start-tunnel-command.js

Index: package/out/command/start-tunnel-command.js
===================================================================
--- package/out/command/start-tunnel-command.js
+++ package/out/command/start-tunnel-command.js
@@ -4,8 +4,9 @@
 const tslib_1 = require("tslib");
 const cli_shared_1 = require("@forge/cli-shared");
 const runtime_1 = require("@forge/runtime");
 const node_cache_1 = tslib_1.__importDefault(require("node-cache"));
+const portfinder_1 = require("portfinder");
 const servers_1 = require("../servers");
 const index_1 = require("../index");
 class StartTunnelCommand {
     getAppConfig;
@@ -38,15 +39,14 @@
             ...Object.values(this.tunnelServers).map((server) => server.stop()),
             this.cspReporterServer?.stop()
         ]);
     };
-    startFaaSTunnelServer = async ({ port, tunnelConfigPath, appId, environmentKey }) => {
+    startFaaSTunnelServer = async ({ port, appId, environmentKey }) => {
         const { permissions = {}, remotes = [] } = await this.configFile.readConfig();
         const serverInfo = await this.devServer.start(port, permissions, remotes);
         const { id, token, url } = await this.tunnelClient.setupTunnel(appId, environmentKey);
         const faasTunnelUrl = await this.tunnelFactory.establishTunnel({
             port: serverInfo.port,
-            tunnelConfigPath,
             id,
             token,
             tunnelUrl: url
         });
@@ -56,10 +56,11 @@
         };
     };
     startResourceBasedTunnelsServers = async (resourceDetails, options) => {
         const portMap = options.resourcePortMap ?? JSON.parse(process.env.RESOURCE_PORT_MAP ?? '{}');
-        const { permissions = {}, remotes = [] } = await this.configFile.readConfig();
-        const cspReporterPort = parseInt(process.env.CSP_REPORTER_PORT ?? '4000', 10);
+        const { permissions = {}, remotes = [], translations: i18nConfig } = await this.configFile.readConfig();
+        const availablePort = await (0, portfinder_1.getPortPromise)({ port: 4000 });
+        const cspReporterPort = process.env.CSP_REPORTER_PORT ? parseInt(process.env.CSP_REPORTER_PORT, 10) : availablePort;
         if (resourceDetails.length === 0)
             return [];
         this.cspReporterServer = new servers_1.CspReporterServer(cspReporterPort, this.logger, new node_cache_1.default());
         await this.cspReporterServer.start();
@@ -73,9 +74,10 @@
                 host: options.host,
                 logger: this.logger,
                 cspReporterServerPort: cspReporterPort,
                 permissions,
-                remotes
+                remotes,
+                i18nConfig
             });
             return this.tunnelServers[key].start();
         }));
     };
@@ -85,9 +87,8 @@
         const allResources = await this.configFile.getResources();
         try {
             const faasTunnelServer = await this.startFaaSTunnelServer({
                 port,
-                tunnelConfigPath: options.ngrokConfig,
                 appId,
                 environmentKey
             });
             const customUITunnelsServers = await this.startResourceBasedTunnelsServers(allResources, options);