Skip to content

Commit

Permalink
Fix support for custom Argon paths, remove customPath setting
Browse files Browse the repository at this point in the history
  • Loading branch information
DervexDev committed Sep 9, 2024
1 parent 861ea44 commit fbce030
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 65 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),

### Added

- Proper support for custom Argon installations
- Completion for `line_ending` and `rename_instances` settings

### Changed

- Removed `customPath` setting as it's no longer needed

## [2.0.12] - 2024-08-21

### Added
Expand Down
8 changes: 1 addition & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -125,17 +125,11 @@
},
"order": 6
},
"argon.customPath": {
"type": "string",
"default": "",
"description": "The custom path to the Argon CLI",
"order": 7
},
"argon.verbose": {
"type": "boolean",
"default": false,
"description": "Whether Argon should log verbose tracing to the output panel",
"order": 8
"order": 7
}
}
},
Expand Down
4 changes: 0 additions & 4 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,6 @@ export function defaultPort(): number {
return config().get("defaultPort")!
}

export function customPath(): string {
return config().get("customPath")!
}

export function verbose(): boolean {
return config().get("verbose")!
}
Expand Down
35 changes: 11 additions & 24 deletions src/extension.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import * as vscode from "vscode"
import * as commands from "./commands"
import * as installer from "./installer"
import * as logger from "./logger"
import * as config from "./config"
import * as argon from "./argon"
import * as menu from "./menu"
Expand All @@ -16,32 +15,20 @@ let state: State
export async function activate(context: vscode.ExtensionContext) {
console.log("Argon activated")

switch (installer.verify()) {
case "Installed":
// Do nothing
break
let version = getVersion()

case "NotInstalled":
logger.info("Installing Argon...")

try {
await installer.install()
} catch (err) {
return openMenuError(context, `Argon failed to install: ${err}`)
}

break

case "Unknown":
return openMenuError(
context,
"Argon failed to install because custom path is set. Please install Argon manually or remove the custom path",
)
if (version) {
argon.update("all", true)
} else {
try {
await installer.install()
version = getVersion()!
} catch (err) {
return openMenuError(context, `Argon failed to install: ${err}`)
}
}

argon.update("all", true)

state = new State(context, getVersion())
state = new State(context, version)

Object.values(commands).forEach((command) => {
context.subscriptions.push(command(state))
Expand Down
31 changes: 3 additions & 28 deletions src/installer.ts
Original file line number Diff line number Diff line change
@@ -1,39 +1,14 @@
import * as os from "os"
import * as fs from "fs"
import * as path from "path"
import * as config from "./config"
import * as childProcess from "child_process"
import { downloadRelease } from "@terascope/fetch-github-release"

type InstallationState = "Installed" | "NotInstalled" | "Unknown"

function getExecPath(): [string, boolean] {
const customPath = config.customPath()

if (customPath.length > 0) {
return [customPath, true]
}

return [
export async function install() {
const execPath =
path.join(os.homedir(), ".argon", "bin", "argon") +
(os.platform() === "win32" ? ".exe" : ""),
false,
]
}
(os.platform() === "win32" ? ".exe" : "")

export function verify(): InstallationState {
const [execPath, isCustom] = getExecPath()
const exists = fs.existsSync(execPath)

if (exists) {
return "Installed"
}

return isCustom ? "Unknown" : "NotInstalled"
}

export async function install() {
const [execPath] = getExecPath()
let versionIndex = 0

fs.mkdirSync(path.dirname(execPath), { recursive: true })
Expand Down
6 changes: 4 additions & 2 deletions src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ export function getProjectAddress(project: string): {
}
}

export function getVersion(): string {
return argon.version().replace("argon-rbx ", "").trim()
export function getVersion(): string | undefined {
try {
return argon.version().replace("argon-rbx ", "").trim()
} catch {}
}

0 comments on commit fbce030

Please sign in to comment.