Skip to content

Commit

Permalink
styra-link: correct Styra CLI download links (#79)
Browse files Browse the repository at this point in the history
Styra CLI download links were outdated. Updated and added one new choice
now available, too.
  • Loading branch information
msorens authored Apr 17, 2024
1 parent a8a9c0e commit 43fc7c2
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 12 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Check that downloaded CLI binary is an actual binary (not a 404 page) instead of assuming it is.
With a bad download URL this caused a cryptic "Error spawn Unknown system error -8" message.
- Fixed download URLs for auto-installing Styra CLI.
- Optimized vsix package, making the plugin binary 80% smaller!

## [2.0.0] - 2023-09-25

Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"url": "https://github.com/StyraInc/vscode-styra/issues"
},
"publisher": "styra",
"version": "2.0.1-next.2",
"version": "2.0.1-next.3",
"private": true,
"main": "./out/main.js",
"engines": {
Expand Down
27 changes: 18 additions & 9 deletions src/lib/styra-install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,18 +146,27 @@ export class StyraInstall {
return styraPathInPath && styraExeExists;
}

private static getDownloadUrl(): string {
// references:
// https://nodejs.org/api/process.html#processarch
// https://nodejs.org/api/process.html#processplatform
// https://docs.styra.com/das/reference/cli (make sure stay in sync with this!)
const prefix = 'https://dl.styra.com/release/styra-cli/latest';
return process.platform === 'win32'
? `${prefix}/windows/amd64/styra.exe`
: process.platform === 'darwin'
? process.arch === 'arm64'
? `${prefix}/darwin/arm64/styra`
: `${prefix}/darwin/amd64/styra` // otherwise target "x64"
: process.arch === 'arm64'
? `${prefix}/linux/arm64/styra`
: `${prefix}/linux/amd64/styra`;
}

private static async installStyra(): Promise<void> {

const tempFileLocation = path.join(os.homedir(), this.BinaryFile);

const url =
process.platform === 'win32'
? 'https://docs.styra.com/v1/docs/bin/windows/amd64/styra.exe'
: process.platform !== 'darwin'
? 'https://docs.styra.com/v1/docs/bin/linux/amd64/styra'
: process.arch === 'arm64'
? 'https://docs.styra.com/v1/docs/bin/darwin/arm64/styra'
: 'https://docs.styra.com/v1/docs/bin/darwin/amd64/styra'; // otherwise target "x64"
const url = this.getDownloadUrl();

return await IDE.withProgress({
location: IDE.ProgressLocation.Notification,
Expand Down

0 comments on commit 43fc7c2

Please sign in to comment.