From e933d171a7dee6130f1a50b3cd2f0d886112394d Mon Sep 17 00:00:00 2001 From: Jari Kolehmainen Date: Wed, 28 Oct 2020 14:34:09 +0200 Subject: [PATCH 1/3] Release v4.0.0-alpha.2 (#1168) Signed-off-by: Jari Kolehmainen --- package.json | 2 +- static/RELEASE_NOTES.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 60af35f0ba..f5251d1cba 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "kontena-lens", "productName": "Lens", "description": "Lens - The Kubernetes IDE", - "version": "4.0.0-alpha.1", + "version": "4.0.0-alpha.2", "main": "static/build/main.js", "copyright": "© 2020, Mirantis, Inc.", "license": "MIT", diff --git a/static/RELEASE_NOTES.md b/static/RELEASE_NOTES.md index 37196a413c..dd168092a4 100644 --- a/static/RELEASE_NOTES.md +++ b/static/RELEASE_NOTES.md @@ -2,7 +2,7 @@ Here you can find description of changes we've built into each release. While we try our best to make each upgrade automatic and as smooth as possible, there may be some cases where you might need to do something to ensure the application works smoothly. So please read through the release highlights! -## 4.0.0-alpha.1 (current version) +## 4.0.0-alpha.2 (current version) - Extension API - Improved pod logs From 66d5fdd8b5fa91e526869c355d4f31a62f3e89b1 Mon Sep 17 00:00:00 2001 From: Jari Kolehmainen Date: Thu, 29 Oct 2020 09:53:25 +0200 Subject: [PATCH 2/3] Optimize ExtensionManager#load (#1171) Signed-off-by: Jari Kolehmainen --- src/extensions/extension-manager.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/extensions/extension-manager.ts b/src/extensions/extension-manager.ts index eb4bad08fb..1a07140aea 100644 --- a/src/extensions/extension-manager.ts +++ b/src/extensions/extension-manager.ts @@ -47,7 +47,9 @@ export class ExtensionManager { async load() { logger.info("[EXTENSION-MANAGER] loading extensions from " + this.extensionPackagesRoot) - if (this.inTreeFolderPath !== this.inTreeTargetPath) { + try { + await fs.access(this.inTreeFolderPath, fs.constants.W_OK) + } catch { // 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) @@ -79,7 +81,7 @@ export class ExtensionManager { protected installPackages(): Promise { return new Promise((resolve, reject) => { - const child = child_process.fork(this.npmPath, ["install", "--silent"], { + const child = child_process.fork(this.npmPath, ["install", "--silent", "--no-audit", "--only=prod", "--prefer-offline"], { cwd: extensionPackagesRoot(), silent: true }) @@ -95,6 +97,7 @@ export class ExtensionManager { async loadExtensions() { const bundledExtensions = await this.loadBundledExtensions() const localExtensions = await this.loadFromFolder(this.localFolderPath) + await this.installPackages() const extensions = bundledExtensions.concat(localExtensions) return new Map(extensions.map(ext => [ext.id, ext])); } @@ -118,7 +121,6 @@ export class ExtensionManager { } logger.debug(`[EXTENSION-MANAGER]: ${extensions.length} extensions loaded`, { folderPath, extensions }); await fs.writeFile(path.join(this.extensionPackagesRoot, "package.json"), JSON.stringify(this.packagesJson), {mode: 0o600}) - await this.installPackages() return extensions } @@ -141,7 +143,6 @@ export class ExtensionManager { logger.debug(`[EXTENSION-MANAGER]: ${extensions.length} extensions loaded`, { folderPath, extensions }); await fs.writeFile(path.join(this.extensionPackagesRoot, "package.json"), JSON.stringify(this.packagesJson), {mode: 0o600}) - await this.installPackages() return extensions; } From a583dbe6d3c504b4858880e7d92fd69800ace30f Mon Sep 17 00:00:00 2001 From: Alex Andreev Date: Thu, 29 Oct 2020 11:23:54 +0300 Subject: [PATCH 3/3] Fix: path checks in custom extension loader (#1170) * Check for path existence and directory type Signed-off-by: Alex Andreev * Check for package.json availability Signed-off-by: Alex Andreev --- src/extensions/extension-manager.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/extensions/extension-manager.ts b/src/extensions/extension-manager.ts index 1a07140aea..be1cf322a4 100644 --- a/src/extensions/extension-manager.ts +++ b/src/extensions/extension-manager.ts @@ -63,6 +63,7 @@ export class ExtensionManager { async getExtensionByManifest(manifestPath: string): Promise { let manifestJson: ExtensionManifest; try { + fs.accessSync(manifestPath, fs.constants.F_OK); // check manifest file for existence manifestJson = __non_webpack_require__(manifestPath) this.packagesJson.dependencies[manifestJson.name] = path.dirname(manifestPath) @@ -113,7 +114,6 @@ export class ExtensionManager { } const absPath = path.resolve(folderPath, fileName); const manifestPath = path.resolve(absPath, "package.json"); - await fs.access(manifestPath, fs.constants.F_OK) const ext = await this.getExtensionByManifest(manifestPath).catch(() => null) if (ext) { extensions.push(ext) @@ -133,8 +133,10 @@ export class ExtensionManager { continue } const absPath = path.resolve(folderPath, fileName); + if (!fs.existsSync(absPath) || !fs.lstatSync(absPath).isDirectory()) { // skip non-directories + continue; + } const manifestPath = path.resolve(absPath, "package.json"); - await fs.access(manifestPath, fs.constants.F_OK) const ext = await this.getExtensionByManifest(manifestPath).catch(() => null) if (ext) { extensions.push(ext)