diff --git a/src/logout/logout.ts b/src/logout/logout.ts index 6628bc7..ca07e62 100644 --- a/src/logout/logout.ts +++ b/src/logout/logout.ts @@ -49,7 +49,7 @@ async function logout(): Promise { // Don't fail the action if logout fails - it's just cleanup core.warning(`Failed to logout from Tailscale: ${error}`); core.info( - "Your ephemeral node will eventually be cleaned up by Tailscale" + "Your ephemeral node will eventually be cleaned up by Tailscale", ); } } catch (error) { diff --git a/src/main.ts b/src/main.ts index 99f1aab..e29d699 100644 --- a/src/main.ts +++ b/src/main.ts @@ -92,7 +92,7 @@ async function run(): Promise { config.useCache ) { throw new Error( - "Caching of unstable releases is not supported on macOS runners" + "Caching of unstable releases is not supported on macOS runners", ); } @@ -136,7 +136,7 @@ async function run(): Promise { core.warning(`Failed to get Tailscale status: ${err}`); if (runnerOS === runnerMacOS) { core.setFailed( - `❌ Tailscale status is required in order to configure macOS` + `❌ Tailscale status is required in order to configure macOS`, ); process.exit(2); } @@ -158,8 +158,8 @@ async function pingHostsIfNecessary(config: TailscaleConfig): Promise { core.info( `Will ping hosts ${config.pingHosts.join( - "," - )} up to 3 minutes each (in parallel) in order to check connectivity` + ",", + )} up to 3 minutes each (in parallel) in order to check connectivity`, ); let pings = config.pingHosts.map((host) => pingHost(host)); for (const ping of pings) { @@ -243,7 +243,7 @@ async function getInputs(): Promise { if (config.oauthSecret && !config.tags) { throw new Error( - "the tags parameter is required when using an OAuth client" + "the tags parameter is required when using an OAuth client", ); } @@ -257,7 +257,7 @@ function validateAuth(config: TailscaleConfig): void { (!config.audience || !config.oauthClientId || !config.tags) ) { throw new Error( - "Please provide either an auth key, OAuth secret and tags, or federated identity client ID and audience with tags." + "Please provide either an auth key, OAuth secret and tags, or federated identity client ID and audience with tags.", ); } @@ -267,14 +267,14 @@ function validateAuth(config: TailscaleConfig): void { semver.gt("1.90.0", config.version) ) { throw new Error( - "Workload identity federation requires using tailscale version 1.90.0 or later." + "Workload identity federation requires using tailscale version 1.90.0 or later.", ); } } async function resolveVersion( version: string, - runnerOS: string + runnerOS: string, ): Promise { if (runnerOS === runnerMacOS && version === versionUnstable) { return "main"; @@ -342,7 +342,7 @@ function getTailscaleArch(runnerOS: string): string { async function installTailscale( config: TailscaleConfig, - runnerOS: string + runnerOS: string, ): Promise { const cacheKey = generateCacheKey(config, runnerOS); const toolPath = getToolPath(config, runnerOS); @@ -352,7 +352,7 @@ async function installTailscale( const cacheHit = await cache.restoreCache([toolPath], cacheKey); if (cacheHit) { core.info( - `Found Tailscale ${config.resolvedVersion} in cache: ${toolPath}` + `Found Tailscale ${config.resolvedVersion} in cache: ${toolPath}`, ); // For Windows, install the cached MSI @@ -409,7 +409,7 @@ async function calculateFileSha256(filePath: string): Promise { async function installTailscaleLinux( config: TailscaleConfig, - toolPath: string + toolPath: string, ): Promise { // Determine if stable or unstable const minor = parseInt(config.resolvedVersion.split(".")[1]); @@ -452,18 +452,18 @@ async function installTailscaleLinux( const extractedPath = await tc.extractTar(tarPath, undefined, "xz"); const extractedDir = path.join( extractedPath, - `tailscale_${config.resolvedVersion}_${config.arch}` + `tailscale_${config.resolvedVersion}_${config.arch}`, ); // Create tool directory and copy binaries there for caching fs.mkdirSync(toolPath, { recursive: true }); fs.copyFileSync( path.join(extractedDir, cmdTailscale), - path.join(toolPath, cmdTailscale) + path.join(toolPath, cmdTailscale), ); fs.copyFileSync( path.join(extractedDir, cmdTailscaled), - path.join(toolPath, cmdTailscaled) + path.join(toolPath, cmdTailscaled), ); // Install binaries to /usr/local/bin @@ -490,7 +490,7 @@ async function installTailscaleLinux( async function installTailscaleWindows( config: TailscaleConfig, toolPath: string, - fromCache: boolean = false + fromCache: boolean = false, ): Promise { // Create tool directory fs.mkdirSync(toolPath, { recursive: true }); @@ -576,11 +576,11 @@ async function installTailscaleWindows( async function installTailscaleMacOS( config: TailscaleConfig, - toolPath: string + toolPath: string, ): Promise { if (!(await isHomebrewAvailable())) { core.notice( - "Homebrew not found on macOS runner; installing Tailscale from source." + "Homebrew not found on macOS runner; installing Tailscale from source.", ); await installTailscaleFromSourceOnMacOS(config, toolPath); return "source"; @@ -599,7 +599,7 @@ async function installTailscaleMacOS( } core.notice( - `Homebrew tailscale formula version ${formulaVersion} does not match requested version ${config.resolvedVersion}; installing Tailscale from source.` + `Homebrew tailscale formula version ${formulaVersion} does not match requested version ${config.resolvedVersion}; installing Tailscale from source.`, ); await installTailscaleFromSourceOnMacOS(config, toolPath); return "source"; @@ -629,18 +629,18 @@ async function getHomebrewTailscaleFormulaVersion(): Promise< { silent: true, ignoreReturnCode: true, - } + }, ); } catch (error) { core.notice( - `Unable to inspect Homebrew tailscale formula metadata: ${error}; installing Tailscale from source.` + `Unable to inspect Homebrew tailscale formula metadata: ${error}; installing Tailscale from source.`, ); return undefined; } if (out.exitCode !== 0) { core.notice( - "Unable to inspect Homebrew tailscale formula; installing Tailscale from source." + "Unable to inspect Homebrew tailscale formula; installing Tailscale from source.", ); return undefined; } @@ -650,14 +650,14 @@ async function getHomebrewTailscaleFormulaVersion(): Promise< return info?.formulae?.[0]?.versions?.stable; } catch (error) { core.notice( - `Unable to parse Homebrew tailscale formula metadata: ${error}; installing Tailscale from source.` + `Unable to parse Homebrew tailscale formula metadata: ${error}; installing Tailscale from source.`, ); return undefined; } } async function installTailscaleWithHomebrew( - resolvedVersion: string + resolvedVersion: string, ): Promise { await execSilent("install tailscale via homebrew", "brew", [ "install", @@ -670,7 +670,7 @@ async function installTailscaleWithHomebrew( core.info( `Installed Homebrew tailscale version ${ installedVersion || "unknown" - } does not match requested version ${resolvedVersion}; attempting upgrade.` + } does not match requested version ${resolvedVersion}; attempting upgrade.`, ); await execSilent("upgrade tailscale via homebrew", "brew", [ "upgrade", @@ -684,7 +684,7 @@ async function installTailscaleWithHomebrew( throw new Error( `Homebrew installed tailscale version ${ installedVersion || "unknown" - }, expected ${resolvedVersion}` + }, expected ${resolvedVersion}`, ); } } @@ -700,11 +700,11 @@ async function getHomebrewInstalledTailscaleVersion(): Promise< { silent: true, ignoreReturnCode: true, - } + }, ); } catch (error) { core.debug( - `Unable to inspect installed Homebrew tailscale version: ${error}` + `Unable to inspect installed Homebrew tailscale version: ${error}`, ); return undefined; } @@ -718,7 +718,7 @@ async function getHomebrewInstalledTailscaleVersion(): Promise< return info?.formulae?.[0]?.installed?.[0]?.version; } catch (error) { core.debug( - `Unable to parse installed Homebrew tailscale version: ${error}` + `Unable to parse installed Homebrew tailscale version: ${error}`, ); return undefined; } @@ -726,14 +726,14 @@ async function getHomebrewInstalledTailscaleVersion(): Promise< async function installTailscaleFromSourceOnMacOS( config: TailscaleConfig, - toolPath: string + toolPath: string, ): Promise { core.info("Building tailscale from src on macOS..."); // Clone the repo await execSilent( "clone tailscale repo", - "git clone https://github.com/tailscale/tailscale.git tailscale" + "git clone https://github.com/tailscale/tailscale.git tailscale", ); // Checkout the resolved version @@ -743,7 +743,7 @@ async function installTailscaleFromSourceOnMacOS( [], { cwd: cmdTailscale, - } + }, ); // Create tool directory and copy binaries there for caching @@ -761,7 +761,7 @@ async function installTailscaleFromSourceOnMacOS( ...process.env, TS_USE_TOOLCHAIN: "1", }, - } + }, ); } @@ -790,7 +790,7 @@ async function installTailscaleFromSourceOnMacOS( async function startTailscaleDaemon( config: TailscaleConfig, - installedWith: installMethod + installedWith: installMethod, ): Promise { if (installedWith === "brew") { core.info("Starting Homebrew-installed tailscaled daemon manually..."); @@ -854,7 +854,7 @@ async function waitForDaemonReady(): Promise { // If we get any valid response from the API, the daemon is ready if (status) { core.info( - `Daemon ready! Initial state: ${status.BackendState || "Unknown"}` + `Daemon ready! Initial state: ${status.BackendState || "Unknown"}`, ); return; } @@ -868,13 +868,13 @@ async function waitForDaemonReady(): Promise { } throw new Error( - `tailscaled daemon did not become ready within timeout, last error: ${lastErr}` + `tailscaled daemon did not become ready within timeout, last error: ${lastErr}`, ); } async function connectToTailscale( config: TailscaleConfig, - runnerOS: string + runnerOS: string, ): Promise { // Determine hostname let hostname = config.hostname; @@ -950,13 +950,13 @@ async function connectToTailscale( await Promise.race([ execSilent("tailscale up", execArgs[0], execArgs.slice(1)), new Promise((_, reject) => - setTimeout(() => reject(new Error("Timeout")), timeoutMs) + setTimeout(() => reject(new Error("Timeout")), timeoutMs), ), ]); // Success core.info( - `✅ Tailscale up command completed successfully on attempt ${attempt}` + `✅ Tailscale up command completed successfully on attempt ${attempt}`, ); return; } catch (error) { @@ -997,7 +997,7 @@ function sleep(ms: number): Promise { function generateCacheKey( config: TailscaleConfig, - runnerOS: string + runnerOS: string, ): string | undefined { if (!config.useCache) { return undefined; @@ -1016,13 +1016,13 @@ function getToolPath(config: TailscaleConfig, runnerOS: string): string { cacheDirectory, cmdTailscale, config.resolvedVersion, - `${runnerOS}-${config.arch}` + `${runnerOS}-${config.arch}`, ); } async function installCachedBinaries( toolPath: string, - runnerOS: string + runnerOS: string, ): Promise { if (runnerOS === runnerLinux || runnerOS === runnerMacOS) { // Copy cached binaries to /usr/local/bin @@ -1063,7 +1063,7 @@ async function configureDNSOnMacOS(status: tailscaleStatus): Promise { } core.info( - `Setting system DNS server to 100.100.100.100 and searchdomains to ${status.CurrentTailnet.MagicDNSSuffix}` + `Setting system DNS server to 100.100.100.100 and searchdomains to ${status.CurrentTailnet.MagicDNSSuffix}`, ); try { await execSilent("set dns servers", "networksetup", [ @@ -1100,7 +1100,7 @@ async function execSilent( label: string, cmd: string, args?: string[], - opts?: {} + opts?: {}, ): Promise { core.info(`▶️ ${label}`); const out = await exec.getExecOutput(cmd, args, { @@ -1116,7 +1116,7 @@ async function execSilent( throw new execError( `${cmd} failed with exit code ${out.exitCode}`, out.exitCode, - out.stderr + out.stderr, ); } return out;