-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
177 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import { | ||
$, | ||
DownloadArgs, | ||
dwnUrlOut, | ||
GithubReleasePort, | ||
InstallArgs, | ||
InstallConfigSimple, | ||
osXarch, | ||
} from "../port.ts"; | ||
import { GithubReleasesInstConf, readGhVars } from "../modules/ports/ghrel.ts"; | ||
|
||
const manifest = { | ||
ty: "denoWorker@v1" as const, | ||
name: "fx_ghrel", | ||
version: "0.1.0-alpha", | ||
moduleSpecifier: import.meta.url, | ||
platforms: osXarch(["linux", "windows", "darwin"], ["aarch64", "x86_64"]), | ||
}; | ||
|
||
export default function conf( | ||
config: InstallConfigSimple & GithubReleasesInstConf = {}, | ||
) { | ||
return { | ||
...readGhVars(), | ||
...config, | ||
port: manifest, | ||
}; | ||
} | ||
|
||
export class Port extends GithubReleasePort { | ||
repoOwner = "antonmedv"; | ||
repoName = "fx"; | ||
|
||
override downloadUrls(args: DownloadArgs) { | ||
const { installVersion, platform } = args; | ||
let arch; | ||
switch (platform.arch) { | ||
case "x86_64": | ||
arch = "amd64"; | ||
break; | ||
case "aarch64": | ||
arch = "arm64"; | ||
break; | ||
default: | ||
throw new Error(`unsupported: ${platform.arch}`); | ||
} | ||
const os = platform.os; | ||
let ext; | ||
switch (os) { | ||
case "linux": | ||
case "darwin": | ||
ext = ""; | ||
break; | ||
case "windows": | ||
ext = ".exe"; | ||
break; | ||
default: | ||
throw new Error(`unsupported: ${platform.arch}`); | ||
} | ||
return [this.releaseArtifactUrl(installVersion, `fx_${os}_${arch}${ext}`)] | ||
.map(dwnUrlOut) | ||
.map((dwn) => ({ ...dwn, name: `fx${ext}`, mode: 0o700 })); | ||
} | ||
|
||
override async install(args: InstallArgs) { | ||
const installPath = $.path(args.installPath); | ||
if (await installPath.exists()) { | ||
await installPath.remove({ recursive: true }); | ||
} | ||
await $.path(args.downloadPath).copy(installPath.join("bin")); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
import { | ||
$, | ||
DownloadArgs, | ||
dwnUrlOut, | ||
GithubReleasePort, | ||
InstallArgs, | ||
InstallConfigSimple, | ||
osXarch, | ||
std_path, | ||
unarchive, | ||
} from "../port.ts"; | ||
import { GithubReleasesInstConf, readGhVars } from "../modules/ports/ghrel.ts"; | ||
|
||
const manifest = { | ||
ty: "denoWorker@v1" as const, | ||
name: "livekit_cli_ghrel", | ||
version: "0.1.0", | ||
moduleSpecifier: import.meta.url, | ||
// darwin releases only avail on brew | ||
platforms: osXarch(["linux", "windows"], ["aarch64", "x86_64"]), | ||
}; | ||
|
||
export default function conf( | ||
config: InstallConfigSimple & GithubReleasesInstConf = {}, | ||
) { | ||
return { | ||
...readGhVars(), | ||
...config, | ||
port: manifest, | ||
}; | ||
} | ||
|
||
export class Port extends GithubReleasePort { | ||
repoOwner = "livekit"; | ||
repoName = "livekit-cli"; | ||
|
||
override downloadUrls(args: DownloadArgs) { | ||
const { installVersion, platform } = args; | ||
let arch; | ||
switch (platform.arch) { | ||
case "x86_64": | ||
arch = "amd64"; | ||
break; | ||
case "aarch64": | ||
arch = "arm64"; | ||
break; | ||
default: | ||
throw new Error(`unsupported: ${platform.arch}`); | ||
} | ||
const os = platform.os; | ||
let ext; | ||
switch (os) { | ||
case "linux": | ||
ext = "tar.gz"; | ||
break; | ||
case "windows": | ||
ext = "zip"; | ||
break; | ||
default: | ||
throw new Error(`unsupported: ${platform.arch}`); | ||
} | ||
return [ | ||
this.releaseArtifactUrl( | ||
installVersion, | ||
`lk_${installVersion.replace(/^v/, "")}_${os}_${arch}.${ext}`, | ||
), | ||
].map(dwnUrlOut); | ||
} | ||
|
||
override async install(args: InstallArgs) { | ||
const [{ name: fileName }] = this.downloadUrls(args); | ||
|
||
const fileDwnPath = std_path.resolve(args.downloadPath, fileName); | ||
await unarchive(fileDwnPath, args.tmpDirPath); | ||
|
||
const tmpDir = $.path(args.tmpDirPath); | ||
const binDir = await tmpDir.join("bin").ensureDir(); | ||
for (const fileName of ["lk"]) { | ||
await tmpDir | ||
.join(args.platform.os == "windows" ? fileName + ".exe" : fileName) | ||
.renameToDir(binDir); | ||
} | ||
|
||
const installPath = $.path(args.installPath); | ||
if (await installPath.exists()) { | ||
await installPath.remove({ recursive: true }); | ||
} | ||
await tmpDir.rename(installPath); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters