Skip to content

Commit 5e5be6a

Browse files
committed
format with more modern prettier
Signed-off-by: Lee Briggs <lee@leebriggs.co.uk>
1 parent 78ee815 commit 5e5be6a

2 files changed

Lines changed: 45 additions & 45 deletions

File tree

src/logout/logout.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ async function logout(): Promise<void> {
4949
// Don't fail the action if logout fails - it's just cleanup
5050
core.warning(`Failed to logout from Tailscale: ${error}`);
5151
core.info(
52-
"Your ephemeral node will eventually be cleaned up by Tailscale"
52+
"Your ephemeral node will eventually be cleaned up by Tailscale",
5353
);
5454
}
5555
} catch (error) {

src/main.ts

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ async function run(): Promise<void> {
9292
config.useCache
9393
) {
9494
throw new Error(
95-
"Caching of unstable releases is not supported on macOS runners"
95+
"Caching of unstable releases is not supported on macOS runners",
9696
);
9797
}
9898

@@ -136,7 +136,7 @@ async function run(): Promise<void> {
136136
core.warning(`Failed to get Tailscale status: ${err}`);
137137
if (runnerOS === runnerMacOS) {
138138
core.setFailed(
139-
`❌ Tailscale status is required in order to configure macOS`
139+
`❌ Tailscale status is required in order to configure macOS`,
140140
);
141141
process.exit(2);
142142
}
@@ -158,8 +158,8 @@ async function pingHostsIfNecessary(config: TailscaleConfig): Promise<void> {
158158

159159
core.info(
160160
`Will ping hosts ${config.pingHosts.join(
161-
","
162-
)} up to 3 minutes each (in parallel) in order to check connectivity`
161+
",",
162+
)} up to 3 minutes each (in parallel) in order to check connectivity`,
163163
);
164164
let pings = config.pingHosts.map((host) => pingHost(host));
165165
for (const ping of pings) {
@@ -243,7 +243,7 @@ async function getInputs(): Promise<TailscaleConfig> {
243243

244244
if (config.oauthSecret && !config.tags) {
245245
throw new Error(
246-
"the tags parameter is required when using an OAuth client"
246+
"the tags parameter is required when using an OAuth client",
247247
);
248248
}
249249

@@ -257,7 +257,7 @@ function validateAuth(config: TailscaleConfig): void {
257257
(!config.audience || !config.oauthClientId || !config.tags)
258258
) {
259259
throw new Error(
260-
"Please provide either an auth key, OAuth secret and tags, or federated identity client ID and audience with tags."
260+
"Please provide either an auth key, OAuth secret and tags, or federated identity client ID and audience with tags.",
261261
);
262262
}
263263

@@ -267,14 +267,14 @@ function validateAuth(config: TailscaleConfig): void {
267267
semver.gt("1.90.0", config.version)
268268
) {
269269
throw new Error(
270-
"Workload identity federation requires using tailscale version 1.90.0 or later."
270+
"Workload identity federation requires using tailscale version 1.90.0 or later.",
271271
);
272272
}
273273
}
274274

275275
async function resolveVersion(
276276
version: string,
277-
runnerOS: string
277+
runnerOS: string,
278278
): Promise<string> {
279279
if (runnerOS === runnerMacOS && version === versionUnstable) {
280280
return "main";
@@ -342,7 +342,7 @@ function getTailscaleArch(runnerOS: string): string {
342342

343343
async function installTailscale(
344344
config: TailscaleConfig,
345-
runnerOS: string
345+
runnerOS: string,
346346
): Promise<installMethod> {
347347
const cacheKey = generateCacheKey(config, runnerOS);
348348
const toolPath = getToolPath(config, runnerOS);
@@ -352,7 +352,7 @@ async function installTailscale(
352352
const cacheHit = await cache.restoreCache([toolPath], cacheKey);
353353
if (cacheHit) {
354354
core.info(
355-
`Found Tailscale ${config.resolvedVersion} in cache: ${toolPath}`
355+
`Found Tailscale ${config.resolvedVersion} in cache: ${toolPath}`,
356356
);
357357

358358
// For Windows, install the cached MSI
@@ -409,7 +409,7 @@ async function calculateFileSha256(filePath: string): Promise<string> {
409409

410410
async function installTailscaleLinux(
411411
config: TailscaleConfig,
412-
toolPath: string
412+
toolPath: string,
413413
): Promise<void> {
414414
// Determine if stable or unstable
415415
const minor = parseInt(config.resolvedVersion.split(".")[1]);
@@ -452,18 +452,18 @@ async function installTailscaleLinux(
452452
const extractedPath = await tc.extractTar(tarPath, undefined, "xz");
453453
const extractedDir = path.join(
454454
extractedPath,
455-
`tailscale_${config.resolvedVersion}_${config.arch}`
455+
`tailscale_${config.resolvedVersion}_${config.arch}`,
456456
);
457457

458458
// Create tool directory and copy binaries there for caching
459459
fs.mkdirSync(toolPath, { recursive: true });
460460
fs.copyFileSync(
461461
path.join(extractedDir, cmdTailscale),
462-
path.join(toolPath, cmdTailscale)
462+
path.join(toolPath, cmdTailscale),
463463
);
464464
fs.copyFileSync(
465465
path.join(extractedDir, cmdTailscaled),
466-
path.join(toolPath, cmdTailscaled)
466+
path.join(toolPath, cmdTailscaled),
467467
);
468468

469469
// Install binaries to /usr/local/bin
@@ -490,7 +490,7 @@ async function installTailscaleLinux(
490490
async function installTailscaleWindows(
491491
config: TailscaleConfig,
492492
toolPath: string,
493-
fromCache: boolean = false
493+
fromCache: boolean = false,
494494
): Promise<void> {
495495
// Create tool directory
496496
fs.mkdirSync(toolPath, { recursive: true });
@@ -576,11 +576,11 @@ async function installTailscaleWindows(
576576

577577
async function installTailscaleMacOS(
578578
config: TailscaleConfig,
579-
toolPath: string
579+
toolPath: string,
580580
): Promise<installMethod> {
581581
if (!(await isHomebrewAvailable())) {
582582
core.notice(
583-
"Homebrew not found on macOS runner; installing Tailscale from source."
583+
"Homebrew not found on macOS runner; installing Tailscale from source.",
584584
);
585585
await installTailscaleFromSourceOnMacOS(config, toolPath);
586586
return "source";
@@ -599,7 +599,7 @@ async function installTailscaleMacOS(
599599
}
600600

601601
core.notice(
602-
`Homebrew tailscale formula version ${formulaVersion} does not match requested version ${config.resolvedVersion}; installing Tailscale from source.`
602+
`Homebrew tailscale formula version ${formulaVersion} does not match requested version ${config.resolvedVersion}; installing Tailscale from source.`,
603603
);
604604
await installTailscaleFromSourceOnMacOS(config, toolPath);
605605
return "source";
@@ -629,18 +629,18 @@ async function getHomebrewTailscaleFormulaVersion(): Promise<
629629
{
630630
silent: true,
631631
ignoreReturnCode: true,
632-
}
632+
},
633633
);
634634
} catch (error) {
635635
core.notice(
636-
`Unable to inspect Homebrew tailscale formula metadata: ${error}; installing Tailscale from source.`
636+
`Unable to inspect Homebrew tailscale formula metadata: ${error}; installing Tailscale from source.`,
637637
);
638638
return undefined;
639639
}
640640

641641
if (out.exitCode !== 0) {
642642
core.notice(
643-
"Unable to inspect Homebrew tailscale formula; installing Tailscale from source."
643+
"Unable to inspect Homebrew tailscale formula; installing Tailscale from source.",
644644
);
645645
return undefined;
646646
}
@@ -650,14 +650,14 @@ async function getHomebrewTailscaleFormulaVersion(): Promise<
650650
return info?.formulae?.[0]?.versions?.stable;
651651
} catch (error) {
652652
core.notice(
653-
`Unable to parse Homebrew tailscale formula metadata: ${error}; installing Tailscale from source.`
653+
`Unable to parse Homebrew tailscale formula metadata: ${error}; installing Tailscale from source.`,
654654
);
655655
return undefined;
656656
}
657657
}
658658

659659
async function installTailscaleWithHomebrew(
660-
resolvedVersion: string
660+
resolvedVersion: string,
661661
): Promise<void> {
662662
await execSilent("install tailscale via homebrew", "brew", [
663663
"install",
@@ -670,7 +670,7 @@ async function installTailscaleWithHomebrew(
670670
core.info(
671671
`Installed Homebrew tailscale version ${
672672
installedVersion || "unknown"
673-
} does not match requested version ${resolvedVersion}; attempting upgrade.`
673+
} does not match requested version ${resolvedVersion}; attempting upgrade.`,
674674
);
675675
await execSilent("upgrade tailscale via homebrew", "brew", [
676676
"upgrade",
@@ -684,7 +684,7 @@ async function installTailscaleWithHomebrew(
684684
throw new Error(
685685
`Homebrew installed tailscale version ${
686686
installedVersion || "unknown"
687-
}, expected ${resolvedVersion}`
687+
}, expected ${resolvedVersion}`,
688688
);
689689
}
690690
}
@@ -700,11 +700,11 @@ async function getHomebrewInstalledTailscaleVersion(): Promise<
700700
{
701701
silent: true,
702702
ignoreReturnCode: true,
703-
}
703+
},
704704
);
705705
} catch (error) {
706706
core.debug(
707-
`Unable to inspect installed Homebrew tailscale version: ${error}`
707+
`Unable to inspect installed Homebrew tailscale version: ${error}`,
708708
);
709709
return undefined;
710710
}
@@ -718,22 +718,22 @@ async function getHomebrewInstalledTailscaleVersion(): Promise<
718718
return info?.formulae?.[0]?.installed?.[0]?.version;
719719
} catch (error) {
720720
core.debug(
721-
`Unable to parse installed Homebrew tailscale version: ${error}`
721+
`Unable to parse installed Homebrew tailscale version: ${error}`,
722722
);
723723
return undefined;
724724
}
725725
}
726726

727727
async function installTailscaleFromSourceOnMacOS(
728728
config: TailscaleConfig,
729-
toolPath: string
729+
toolPath: string,
730730
): Promise<void> {
731731
core.info("Building tailscale from src on macOS...");
732732

733733
// Clone the repo
734734
await execSilent(
735735
"clone tailscale repo",
736-
"git clone https://github.com/tailscale/tailscale.git tailscale"
736+
"git clone https://github.com/tailscale/tailscale.git tailscale",
737737
);
738738

739739
// Checkout the resolved version
@@ -743,7 +743,7 @@ async function installTailscaleFromSourceOnMacOS(
743743
[],
744744
{
745745
cwd: cmdTailscale,
746-
}
746+
},
747747
);
748748

749749
// Create tool directory and copy binaries there for caching
@@ -761,7 +761,7 @@ async function installTailscaleFromSourceOnMacOS(
761761
...process.env,
762762
TS_USE_TOOLCHAIN: "1",
763763
},
764-
}
764+
},
765765
);
766766
}
767767

@@ -790,7 +790,7 @@ async function installTailscaleFromSourceOnMacOS(
790790

791791
async function startTailscaleDaemon(
792792
config: TailscaleConfig,
793-
installedWith: installMethod
793+
installedWith: installMethod,
794794
): Promise<void> {
795795
if (installedWith === "brew") {
796796
core.info("Starting Homebrew-installed tailscaled daemon manually...");
@@ -854,7 +854,7 @@ async function waitForDaemonReady(): Promise<void> {
854854
// If we get any valid response from the API, the daemon is ready
855855
if (status) {
856856
core.info(
857-
`Daemon ready! Initial state: ${status.BackendState || "Unknown"}`
857+
`Daemon ready! Initial state: ${status.BackendState || "Unknown"}`,
858858
);
859859
return;
860860
}
@@ -868,13 +868,13 @@ async function waitForDaemonReady(): Promise<void> {
868868
}
869869

870870
throw new Error(
871-
`tailscaled daemon did not become ready within timeout, last error: ${lastErr}`
871+
`tailscaled daemon did not become ready within timeout, last error: ${lastErr}`,
872872
);
873873
}
874874

875875
async function connectToTailscale(
876876
config: TailscaleConfig,
877-
runnerOS: string
877+
runnerOS: string,
878878
): Promise<void> {
879879
// Determine hostname
880880
let hostname = config.hostname;
@@ -950,13 +950,13 @@ async function connectToTailscale(
950950
await Promise.race([
951951
execSilent("tailscale up", execArgs[0], execArgs.slice(1)),
952952
new Promise<never>((_, reject) =>
953-
setTimeout(() => reject(new Error("Timeout")), timeoutMs)
953+
setTimeout(() => reject(new Error("Timeout")), timeoutMs),
954954
),
955955
]);
956956

957957
// Success
958958
core.info(
959-
`✅ Tailscale up command completed successfully on attempt ${attempt}`
959+
`✅ Tailscale up command completed successfully on attempt ${attempt}`,
960960
);
961961
return;
962962
} catch (error) {
@@ -997,7 +997,7 @@ function sleep(ms: number): Promise<void> {
997997

998998
function generateCacheKey(
999999
config: TailscaleConfig,
1000-
runnerOS: string
1000+
runnerOS: string,
10011001
): string | undefined {
10021002
if (!config.useCache) {
10031003
return undefined;
@@ -1016,13 +1016,13 @@ function getToolPath(config: TailscaleConfig, runnerOS: string): string {
10161016
cacheDirectory,
10171017
cmdTailscale,
10181018
config.resolvedVersion,
1019-
`${runnerOS}-${config.arch}`
1019+
`${runnerOS}-${config.arch}`,
10201020
);
10211021
}
10221022

10231023
async function installCachedBinaries(
10241024
toolPath: string,
1025-
runnerOS: string
1025+
runnerOS: string,
10261026
): Promise<void> {
10271027
if (runnerOS === runnerLinux || runnerOS === runnerMacOS) {
10281028
// Copy cached binaries to /usr/local/bin
@@ -1063,7 +1063,7 @@ async function configureDNSOnMacOS(status: tailscaleStatus): Promise<void> {
10631063
}
10641064

10651065
core.info(
1066-
`Setting system DNS server to 100.100.100.100 and searchdomains to ${status.CurrentTailnet.MagicDNSSuffix}`
1066+
`Setting system DNS server to 100.100.100.100 and searchdomains to ${status.CurrentTailnet.MagicDNSSuffix}`,
10671067
);
10681068
try {
10691069
await execSilent("set dns servers", "networksetup", [
@@ -1100,7 +1100,7 @@ async function execSilent(
11001100
label: string,
11011101
cmd: string,
11021102
args?: string[],
1103-
opts?: {}
1103+
opts?: {},
11041104
): Promise<exec.ExecOutput> {
11051105
core.info(`▶️ ${label}`);
11061106
const out = await exec.getExecOutput(cmd, args, {
@@ -1116,7 +1116,7 @@ async function execSilent(
11161116
throw new execError(
11171117
`${cmd} failed with exit code ${out.exitCode}`,
11181118
out.exitCode,
1119-
out.stderr
1119+
out.stderr,
11201120
);
11211121
}
11221122
return out;

0 commit comments

Comments
 (0)