1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Fix bundled extension install on Linux/AppImage (#1163)

Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
This commit is contained in:
Jari Kolehmainen 2020-10-28 10:16:52 +02:00 committed by GitHub
parent bfdbf02830
commit c3bde1ad00
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -25,10 +25,18 @@ export class ExtensionManager {
return extensionPackagesRoot() return extensionPackagesRoot()
} }
get inTreeTargetPath() {
return path.join(this.extensionPackagesRoot, "extensions")
}
get inTreeFolderPath(): string { get inTreeFolderPath(): string {
return path.resolve(__static, "../extensions"); return path.resolve(__static, "../extensions");
} }
get nodeModulesPath(): string {
return path.join(this.extensionPackagesRoot, "node_modules")
}
get localFolderPath(): string { get localFolderPath(): string {
return path.join(os.homedir(), ".k8slens", "extensions"); return path.join(os.homedir(), ".k8slens", "extensions");
} }
@ -39,7 +47,13 @@ export class ExtensionManager {
async load() { async load() {
logger.info("[EXTENSION-MANAGER] loading extensions from " + this.extensionPackagesRoot) logger.info("[EXTENSION-MANAGER] loading extensions from " + this.extensionPackagesRoot)
await fs.ensureDir(path.join(this.extensionPackagesRoot, "node_modules")) if (this.inTreeFolderPath !== this.inTreeTargetPath) {
// we need to copy in-tree extensions so that we can symlink them properly on "npm install"
await fs.remove(this.inTreeTargetPath)
await fs.ensureDir(this.inTreeTargetPath)
await fs.copy(this.inTreeFolderPath, this.inTreeTargetPath)
}
await fs.ensureDir(this.nodeModulesPath)
await fs.ensureDir(this.localFolderPath) await fs.ensureDir(this.localFolderPath)
return await this.loadExtensions(); return await this.loadExtensions();
} }
@ -55,7 +69,7 @@ export class ExtensionManager {
id: manifestJson.name, id: manifestJson.name,
version: manifestJson.version, version: manifestJson.version,
name: manifestJson.name, name: manifestJson.name,
manifestPath: path.join(this.extensionPackagesRoot, "node_modules", manifestJson.name, "package.json"), manifestPath: path.join(this.nodeModulesPath, manifestJson.name, "package.json"),
manifest: manifestJson manifest: manifestJson
} }
} catch (err) { } catch (err) {
@ -87,7 +101,7 @@ export class ExtensionManager {
async loadBundledExtensions() { async loadBundledExtensions() {
const extensions: InstalledExtension[] = [] const extensions: InstalledExtension[] = []
const folderPath = this.inTreeFolderPath const folderPath = this.inTreeTargetPath
const bundledExtensions = getBundledExtensions() const bundledExtensions = getBundledExtensions()
const paths = await fs.readdir(folderPath); const paths = await fs.readdir(folderPath);
for (const fileName of paths) { for (const fileName of paths) {