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/src/extensions/extension-manager.ts b/src/extensions/extension-manager.ts index eb4bad08fb..be1cf322a4 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) @@ -61,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) @@ -79,7 +82,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 +98,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])); } @@ -110,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) @@ -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 } @@ -131,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) @@ -141,7 +145,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; } 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