-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Effekt Version Manager: automatic installer and updater #20
Conversation
src/effektManager.ts
Outdated
/** | ||
* Locates the Effekt executable. | ||
*/ | ||
public async getEffektExecutable(): Promise<EffektExecutableInfo> { | ||
const customPath = this.config.get<string>("executable"); | ||
if (customPath) { | ||
try { | ||
const version = await this.execCommand(`"${customPath}" --version`); | ||
return { path: customPath, version }; | ||
} catch (error) { | ||
this.showErrorWithLogs(`Custom Effekt executable not working: ${customPath}. ${error}`); | ||
} | ||
} | ||
|
||
for (const name of this.possibleEffektExecutables) { | ||
try { | ||
const version = await this.execCommand(`${name} --version`); | ||
return { path: name, version }; | ||
} catch { | ||
// Try next option | ||
} | ||
} | ||
|
||
throw new Error('Effekt executable not found'); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically in case --version
fails, we also might want to try --help
as that ought to work universally across all Effekt versions, whereas --version
is only being added as of writing this comment (effekt-lang/effekt#556).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks beautiful! The implementation is exemplary!
One thing that I noticed is that we check for node, but not the JVM. Maybe checking and reporting: "Hey, maybe you want to install a JVM > X" would help some users?
] | ||
} | ||
"configurations": [ | ||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does everybody suddenly start to use tabs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually took these files from the VSCode template extension, just to update the structure :)
} | ||
} | ||
|
||
private handleInstallationResult(result: InstallationResult, action: 'install' | 'update'): void { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is funny how stringly typed things become ok with singleton types and unions...
Thanks! I'll forward the praise to Claude 3.5 Sonnet ;)
I used to have the check there, it should be easy to re-add. :) |
a390c14
to
236de6f
Compare
Rebased on current |
236de6f
to
af3a587
Compare
af3a587
to
79e0e0b
Compare
Rebased on current |
"scripts": { | ||
"vscode:prepublish": "npm run compile", | ||
"compile": "tsc -p ./", | ||
"watch": "tsc -watch -p ./", | ||
"postinstall": "node ./node_modules/vscode/bin/install", | ||
"test": "npm run compile && node ./node_modules/vscode/bin/test" | ||
"compile": "tsc -b", | ||
"watch": "tsc -b -w", | ||
"lint": "eslint ./client/src ./server/src --ext .ts,.tsx" | ||
}, | ||
"dependencies": { | ||
"compare-versions": "^6.1.1", | ||
"vscode-languageclient": "^5.2.1" | ||
}, | ||
"devDependencies": { | ||
"typescript": "^2.6.1", | ||
"vscode": "^1.1.37", | ||
"tslint": "^5.8.0", | ||
"@types/node": "^7.0.43", | ||
"@types/mocha": "^2.2.42" | ||
"@types/mocha": "^10.0.6", | ||
"@types/node": "^18.14.6", | ||
"@types/vscode": "^1.30.0", | ||
"@typescript-eslint/eslint-plugin": "^7.1.0", | ||
"@typescript-eslint/parser": "^7.1.0", | ||
"eslint": "^8.57.0", | ||
"mocha": "^10.3.0", | ||
"typescript": "^5.3.3" | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to be clear, the changes here and in .vscode
are taken directly from the official VSCode extension template https://github.com/microsoft/vscode-extension-samples (from the LSP sample)
I added some code to detect the JRE version, not sure it works too well (can't test it properly right now). |
This comment was marked as resolved.
This comment was marked as resolved.
private async runNpmInstall(): Promise<void> { | ||
// 1) Check if the npm root is managed by Nix in order to produce a better error | ||
const npmRoot = await this.execCommand('npm root -g'); | ||
if (npmRoot.startsWith("/nix/store")) { | ||
this.logMessage('ERROR', 'NPM root is in the read-only Nix store. Installation is not possible.') | ||
throw new Error('Detected Nix environment: NPM global modules are stored in a read-only directory managed by Nix. Installation cannot proceed.'); | ||
} | ||
|
||
// 2) Actually run `npm install -g ...` | ||
const npmInstallCommand = `npm install -g ${this.effektNPMPackage}@latest`; | ||
const npmOutput = await this.execCommand(npmInstallCommand); | ||
|
||
this.logMessage('INFO', `Ran '${npmInstallCommand}'; stdout: ${npmOutput}`); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Current state of testing: seems to work for all Linux (N ≥ 4) and MacOS (N = 2) testers so far. From feedback: It would be nice to display the full path to the Effekt executable in the status bar on hover ( |
This is a somewhat rough draft of an automatic installer & updater for Effekt (addresses effekt-lang/effekt#289)
I cannot test this locally, my local setup is quite weird and I can't really use
npm
for Effekt distribution.This PR will require extensive testing on various platforms.
Features
npm
)effekt
binary:npm
effekt
, take a look at its version: if it's older than the latest version onnpm
, offer updating to a newer version of Effekt vianpm
effekt
isn't found after installation, check the placesnpm
installs into if the binary is there and if it works (in order to debug PATH issues)Problems
mostly untested!EDIT: Tested somewhat extensively now, see below.requires AddEDIT: merged, tested--version
CLI flag effekt#540should also be tested with rolling release (Move to a weekly release scheme effekt#538)EDIT: merged, testedthe EffektEDIT: fixed via Move to a weekly release scheme effekt#538npm
package(s) are really out of date (!) -- we can of course also check via GitHub API and take the tgz from the release directly (https://api.github.com/repos/effekt-lang/effekt/releases), but that's a bit cumbersome and complicates the installationScreenshots
Status bar
Installation pop-ups