From 9cda3125230444d610029c73add99350cc07fe40 Mon Sep 17 00:00:00 2001 From: Huakun Shen Date: Mon, 13 Jan 2025 16:14:42 -0500 Subject: [PATCH] fix: identifier conflict for dev and prod ext during installation dev and prod environment could have the same identifier. If a dev ext is installed, user gets a warning prompt when installing from store, saying there is an existing extension. The dev extension will be removed from DB. In this commit we filter out dev extension --- apps/create-kunkun/package.json | 2 +- packages/extension/src/db.ts | 1 + packages/extension/src/install.ts | 4 +++- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/apps/create-kunkun/package.json b/apps/create-kunkun/package.json index 1f408e5..dc4eda4 100644 --- a/apps/create-kunkun/package.json +++ b/apps/create-kunkun/package.json @@ -1,7 +1,7 @@ { "name": "create-kunkun", "type": "module", - "version": "0.1.38", + "version": "0.1.39", "bin": { "create-kunkun": "dist/index.mjs" }, diff --git a/packages/extension/src/db.ts b/packages/extension/src/db.ts index b76d7e4..fabc869 100644 --- a/packages/extension/src/db.ts +++ b/packages/extension/src/db.ts @@ -8,6 +8,7 @@ import { QuickLinkCmd } from "@kksh/api/models" import * as v from "valibot" +import { isExtPathInDev } from "./utils" export async function upsertExtension(extPkgJson: ExtPackageJson, extFullPath: string) { const extInDb = await db.getUniqueExtensionByIdentifier(extPkgJson.kunkun.identifier) diff --git a/packages/extension/src/install.ts b/packages/extension/src/install.ts index 62eedfe..1ff4ffd 100644 --- a/packages/extension/src/install.ts +++ b/packages/extension/src/install.ts @@ -14,6 +14,7 @@ import { download } from "@tauri-apps/plugin-upload" import { v4 as uuidv4 } from "uuid" import { z, ZodError } from "zod" import { loadExtensionManifestFromDisk } from "./load" +import { isExtPathInDev } from "./utils" /** * @@ -58,7 +59,8 @@ export async function installTarball( // find extension in db, if exists, ask user if they want to overwrite it const exts = await db.getAllExtensionsByIdentifier(manifest.kunkun.identifier) - if (exts.length > 0) { + const storeExts = exts.filter((ext) => ext.path && !isExtPathInDev(extsDir, ext.path)) + if (storeExts.length > 0) { const overwrite = await dialog.ask( `Extension ${manifest.kunkun.identifier} already exists in database (but not on disk), do you want to overwrite it?` )