From 27c33c76614d2650d60dff695b8b89790660ae35 Mon Sep 17 00:00:00 2001 From: Mauricio Siu <47042324+Siumauricio@users.noreply.github.com> Date: Sat, 26 Oct 2024 15:48:30 -0600 Subject: [PATCH] fix(server): update build paths --- apps/api/src/types.ts | 16 ----------- apps/api/src/utils.ts | 35 +------------------------ apps/schedules/src/utils.ts | 2 +- packages/server/package.json | 12 --------- packages/server/scripts/switchToDist.js | 14 ++++++++++ packages/server/scripts/switchToSrc.js | 15 ++--------- 6 files changed, 18 insertions(+), 76 deletions(-) delete mode 100644 apps/api/src/types.ts diff --git a/apps/api/src/types.ts b/apps/api/src/types.ts deleted file mode 100644 index 2547432b..00000000 --- a/apps/api/src/types.ts +++ /dev/null @@ -1,16 +0,0 @@ -export interface LemonSqueezyLicenseResponse { - valid: boolean; - error?: string; - meta?: { - store_id: string; - order_id: number; - order_item_id: number; - product_id: number; - product_name: string; - variant_id: number; - variant_name: string; - customer_id: number; - customer_name: string; - customer_email: string; - }; -} diff --git a/apps/api/src/utils.ts b/apps/api/src/utils.ts index 5d776a5c..03c836e0 100644 --- a/apps/api/src/utils.ts +++ b/apps/api/src/utils.ts @@ -1,45 +1,12 @@ import { - deployApplication, - deployCompose, deployRemoteApplication, deployRemoteCompose, - rebuildApplication, - rebuildCompose, rebuildRemoteApplication, rebuildRemoteCompose, updateApplicationStatus, updateCompose, -} from "@dokploy/server/dist"; +} from "@dokploy/server"; import type { DeployJob } from "./schema"; -import type { LemonSqueezyLicenseResponse } from "./types"; - -// const LEMON_SQUEEZY_API_KEY = process.env.LEMON_SQUEEZY_API_KEY; -// const LEMON_SQUEEZY_STORE_ID = process.env.LEMON_SQUEEZY_STORE_ID; -// export const validateLemonSqueezyLicense = async ( -// licenseKey: string, -// ): Promise => { -// try { -// const response = await fetch( -// "https://api.lemonsqueezy.com/v1/licenses/validate", -// { -// method: "POST", -// headers: { -// "Content-Type": "application/json", -// "x-api-key": LEMON_SQUEEZY_API_KEY as string, -// }, -// body: JSON.stringify({ -// license_key: licenseKey, -// store_id: LEMON_SQUEEZY_STORE_ID as string, -// }), -// }, -// ); - -// return response.json(); -// } catch (error) { -// console.error("Error validating license:", error); -// return { valid: false, error: "Error validating license" }; -// } -// }; export const deploy = async (job: DeployJob) => { try { diff --git a/apps/schedules/src/utils.ts b/apps/schedules/src/utils.ts index 07cefeef..65f3cbda 100644 --- a/apps/schedules/src/utils.ts +++ b/apps/schedules/src/utils.ts @@ -8,7 +8,7 @@ import { runMongoBackup, runMySqlBackup, runPostgresBackup, -} from "@dokploy/server/dist"; +} from "@dokploy/server"; import { db } from "@dokploy/server/dist/db"; import { backups, server } from "@dokploy/server/dist/db/schema"; import { eq } from "drizzle-orm"; diff --git a/packages/server/package.json b/packages/server/package.json index 6772f035..e9064582 100644 --- a/packages/server/package.json +++ b/packages/server/package.json @@ -16,18 +16,6 @@ "./constants": { "import": "./src/constants/index.ts", "require": "./dist/constants.cjs.js" - }, - "./dist": { - "import": "./dist/index.js", - "require": "./dist/index.cjs.js" - }, - "./dist/db": { - "import": "./dist/db/index.js", - "require": "./dist/db/*.cjs" - }, - "./dist/db/schema": { - "import": "./dist/db/schema/index.js", - "require": "./dist/db/schema/*.cjs" } }, "scripts": { diff --git a/packages/server/scripts/switchToDist.js b/packages/server/scripts/switchToDist.js index 12f5625a..67c9f411 100644 --- a/packages/server/scripts/switchToDist.js +++ b/packages/server/scripts/switchToDist.js @@ -8,6 +8,8 @@ const __dirname = path.dirname(__filename); const packagePath = path.resolve(__dirname, "../package.json"); const pkg = JSON.parse(fs.readFileSync(packagePath, "utf-8")); +pkg.main = "./dist/index.js"; + pkg.exports = { ".": { import: "./dist/index.js", @@ -21,6 +23,18 @@ pkg.exports = { import: "./dist/*", require: "./dist/*.cjs", }, + "./dist": { + import: "./dist/index.js", + require: "./dist/index.cjs.js", + }, + "./dist/db": { + import: "./dist/db/index.js", + require: "./dist/db/index.cjs.js", + }, + "./dist/db/schema": { + import: "./dist/db/schema/index.js", + require: "./dist/db/schema/index.cjs.js", + }, }; fs.writeFileSync(packagePath, JSON.stringify(pkg, null, 2)); diff --git a/packages/server/scripts/switchToSrc.js b/packages/server/scripts/switchToSrc.js index 9387cd15..b18c2d15 100644 --- a/packages/server/scripts/switchToSrc.js +++ b/packages/server/scripts/switchToSrc.js @@ -10,6 +10,8 @@ const packagePath = path.resolve(__dirname, "../package.json"); // Leer el archivo package.json const pkg = JSON.parse(fs.readFileSync(packagePath, "utf-8")); +pkg.main = "./src/index.ts"; + // Modificar los exports pkg.exports = { ".": "./src/index.ts", @@ -25,19 +27,6 @@ pkg.exports = { import: "./src/constants/index.ts", require: "./dist/constants.cjs.js", }, - "./dist": { - import: "./dist/index.js", - require: "./dist/index.cjs.js", - }, - - "./dist/db": { - import: "./dist/db/index.js", - require: "./dist/db/*.cjs", - }, - "./dist/db/schema": { - import: "./dist/db/schema/index.js", - require: "./dist/db/schema/*.cjs", - }, }; // Guardar los cambios en package.json