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

Use extension storeName to get store and data location

This commit is contained in:
Antti Lustila 2023-01-31 12:58:04 +02:00
parent a73f166f1f
commit 95b83b1ce6
3 changed files with 22 additions and 2 deletions

View File

@ -18,6 +18,7 @@ describe("lens extension", () => {
name: "foo-bar", name: "foo-bar",
version: "0.1.1", version: "0.1.1",
engines: { lens: "^5.5.0" }, engines: { lens: "^5.5.0" },
storeName: "foo-bar-store",
}, },
id: "/this/is/fake/package.json", id: "/this/is/fake/package.json",
absolutePath: "/absolute/fake/", absolutePath: "/absolute/fake/",
@ -33,4 +34,10 @@ describe("lens extension", () => {
expect(ext.name).toBe("foo-bar"); expect(ext.name).toBe("foo-bar");
}); });
}); });
describe("storeName", () => {
it("returns storeName", () => {
expect(ext.storeName).toBe("foo-bar-store");
});
});
}); });

View File

@ -92,6 +92,6 @@ export abstract class ExtensionStore<T extends object> extends BaseStore<T> {
protected cwd() { protected cwd() {
assert(this.extension, "must call this.load() first"); assert(this.extension, "must call this.load() first");
return path.join(super.cwd(), "extension-store", this.extension.name); return path.join(super.cwd(), "extension-store", this.extension.storeLocation);
} }
} }

View File

@ -27,6 +27,7 @@ export interface LensExtensionManifest extends PackageJson {
npm?: string; npm?: string;
node?: string; node?: string;
}; };
storeName?: string;
} }
export const lensExtensionDependencies = Symbol("lens-extension-dependencies"); export const lensExtensionDependencies = Symbol("lens-extension-dependencies");
@ -80,6 +81,18 @@ export class LensExtension<
return this.manifest.description; return this.manifest.description;
} }
get storeName() {
return this.manifest.storeName;
}
get dataLocation() {
return this.storeName || this.id;
}
get storeLocation() {
return this.storeName || this.name;
}
/** /**
* @ignore * @ignore
*/ */
@ -93,7 +106,7 @@ export class LensExtension<
* folder name. * folder name.
*/ */
async getExtensionFileFolder(): Promise<string> { async getExtensionFileFolder(): Promise<string> {
return this[lensExtensionDependencies].fileSystemProvisionerStore.requestDirectory(this.id); return this[lensExtensionDependencies].fileSystemProvisionerStore.requestDirectory(this.dataLocation);
} }
@action @action