-
Notifications
You must be signed in to change notification settings - Fork 61
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
10 changed files
with
829 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
LICENSE |
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 @@ | ||
README.md |
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,20 @@ | ||
#!/usr/bin/env node | ||
import { execFileSync } from "node:child_process"; | ||
|
||
import { pkgForCurrentPlatform } from "./package-helpers.js"; | ||
|
||
const pkg = pkgForCurrentPlatform(); | ||
|
||
let location; | ||
try { | ||
// Check for the binary package from our "optionalDependencies". This | ||
// package should have been installed alongside this package at install time. | ||
location = (await import(pkg)).default; | ||
} catch (e) { | ||
throw new Error(`The package "${pkg}" could not be found, and is needed by @fastly/cli. | ||
If you are installing @fastly/cli with npm, make sure that you don't specify the | ||
"--no-optional" flag. The "optionalDependencies" package.json feature is used | ||
by @fastly/cli to install the correct binary executable for your current platform.`); | ||
} | ||
|
||
execFileSync(location, process.argv.slice(2), { stdio: "inherit" }); |
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,17 @@ | ||
import { pkgForCurrentPlatform } from "./package-helpers.js"; | ||
|
||
const pkg = pkgForCurrentPlatform(); | ||
|
||
let location; | ||
try { | ||
// Check for the binary package from our "optionalDependencies". This | ||
// package should have been installed alongside this package at install time. | ||
location = (await import(pkg)).default; | ||
} catch (e) { | ||
throw new Error(`The package "${pkg}" could not be found, and is needed by @fastly/cli. | ||
If you are installing @fastly/cli with npm, make sure that you don't specify the | ||
"--no-optional" flag. The "optionalDependencies" package.json feature is used | ||
by @fastly/cli to install the correct binary executable for your current platform.`); | ||
} | ||
|
||
export default location; |
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,22 @@ | ||
import { platform, arch } from "node:process"; | ||
|
||
const knownPackages = { | ||
"darwin arm64": "@fastly/cli-darwin-arm64", | ||
"darwin x64": "@fastly/cli-darwin-x64", | ||
"linux arm64": "@fastly/cli-linux-arm64", | ||
"linux x64": "@fastly/cli-linux-x64", | ||
"linux x64": "@fastly/cli-linux-386", | ||
"win32 arm64": "@fastly/cli-win32-arm64", | ||
"win32 x64": "@fastly/cli-win32-x64", | ||
"win32 x32": "@fastly/cli-win32-386", | ||
}; | ||
|
||
export function pkgForCurrentPlatform() { | ||
let platformKey = `${platform} ${arch}`; | ||
if (platformKey in knownPackages) { | ||
return knownPackages[platformKey]; | ||
} | ||
throw new Error( | ||
`Unsupported platform: "${platformKey}". "@bytecodealliance/wizer does not have a precompiled binary for the platform/architecture you are using. You can open an issue on https://github.com/bytecodealliance/wizer/issues to request for your platform/architecture to be included."` | ||
); | ||
} |
Oops, something went wrong.