diff --git a/.gitignore b/.gitignore index 3c3629e..a63f278 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ node_modules +releases diff --git a/bun.lock b/bun.lock index 2f835b8..d3d04c1 100644 --- a/bun.lock +++ b/bun.lock @@ -238,7 +238,7 @@ }, }, "overrides": { - "@tensamin/ttp-core": "https://git.methanium.net/tensamin/ttp/archive/0.0.3.tar.gz", + "@tensamin/ttp-core": "https://git.methanium.net/tensamin/ttp/archive/0.0.4.tar.gz", "@tensamin/ui": "https://git.methanium.net/tensamin/ui/archive/0.0.25.tar.gz", }, "packages": { @@ -690,7 +690,7 @@ "@tensamin/ttp": ["@tensamin/ttp@workspace:packages/ttp"], - "@tensamin/ttp-core": ["@tensamin/ttp-core@https://git.methanium.net/tensamin/ttp/archive/0.0.3.tar.gz", { "dependencies": { "@eslint/js": "^10.0.1", "@typescript-eslint/parser": "^8.58.1", "globals": "^17.5.0", "typescript": "^6.0.2", "typescript-eslint": "^8.58.1", "zod": "^4.3.6" } }, "sha512-fqpT3W/QeTULDYaZI2uXMHQ+6NUnNa4XTVbbl1k84vnwdzyQgdhezQUzjgXL1XrjEImb5CWosFNvcrzuIfwlfQ=="], + "@tensamin/ttp-core": ["@tensamin/ttp-core@https://git.methanium.net/tensamin/ttp/archive/0.0.4.tar.gz", { "dependencies": { "@eslint/js": "^10.0.1", "@typescript-eslint/parser": "^8.58.1", "globals": "^17.5.0", "typescript": "^6.0.2", "typescript-eslint": "^8.58.1", "zod": "^4.3.6" } }, "sha512-FVtxXH9DBwHz2GpuFZFO2KifWefBOoK4/dv6yH4xyvDIS0PIVRc7UrBAgf2HQ3+N9jWaDw9FwyJkZJCAdVCNJQ=="], "@tensamin/ui": ["@tensamin/ui@https://git.methanium.net/tensamin/ui/archive/0.0.25.tar.gz", { "dependencies": { "@base-ui/react": "^1.3.0", "@fontsource-variable/inter": "^5.2.6", "@tauri-apps/api": "^2", "class-variance-authority": "^0.7.1", "clsx": "^2.1.1", "cmdk": "^1.1.1", "date-fns": "^4.1.0", "embla-carousel-react": "^8.6.0", "input-otp": "^1.4.2", "lucide-react": "^1.8.0", "next-themes": "^0.4.6", "react-day-picker": "^9.14.0", "react-resizable-panels": "^4.10.0", "recharts": "3.8.0", "shadcn": "^3.5.0", "sonner": "^2.0.7", "tailwind-merge": "^3.5.0", "tw-animate-css": "^1.3.0", "vaul": "^1.1.2" }, "peerDependencies": { "react": "^19.2.0", "react-dom": "^19.2.0" } }, "sha512-pYkl4quhAhV/l/j1Yy5m4DDV5fh42H4G8v+FE6qEMCcJIOeA1LU7brIG7X9zURe7F4gyn1LQxMf2yABuV/NsMQ=="], diff --git a/package.json b/package.json index e7b61bb..8dc1e52 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "tensamin", - "version": "0.1", + "version": "0.0.1", "private": true, "workspaces": [ "packages/*", @@ -10,7 +10,8 @@ "scripts": { "format": "bunx prettier --write .", "lint": "bun scripts/lint-packages.ts", - "build:all": "bun run build:packages && bun run build:web && bun run build:mobile && bun run build:desktop", + "copy-releases": "bun scripts/copy-releases.ts", + "build:all": "bun run build:packages && bun run build:web && bun run build:mobile && bun run build:desktop && bun --bun run copy-releases", "build:packages": "bun scripts/build-packages.ts", "dev:web": "cd apps/web && bun dev", "build:web": "bun run build:packages && cd apps/web && bun run build", @@ -35,7 +36,7 @@ }, "overrides": { "@tensamin/ui": "https://git.methanium.net/tensamin/ui/archive/0.0.25.tar.gz", - "@tensamin/ttp-core": "https://git.methanium.net/tensamin/ttp/archive/0.0.3.tar.gz" + "@tensamin/ttp-core": "https://git.methanium.net/tensamin/ttp/archive/0.0.4.tar.gz" }, "dependencies": { "@tensamin/ui": "*", diff --git a/scripts/copy-releases.ts b/scripts/copy-releases.ts new file mode 100644 index 0000000..2aa93ab --- /dev/null +++ b/scripts/copy-releases.ts @@ -0,0 +1,80 @@ +import { + existsSync, + mkdirSync, + readdirSync, + renameSync, + rmSync, + statSync, +} from "node:fs"; +import { join } from "node:path"; +import packageJson from "../package.json" with { type: "json" }; + +const { version } = packageJson; +const releasesDir = join("releases"); + +// directory +rmSync(releasesDir, { recursive: true, force: true }); +mkdirSync(releasesDir, { recursive: true }); + +// apk +const apkSrc = + "apps/tauri/src-tauri/gen/android/app/build/outputs/apk/universal/release/app-universal-release.apk"; +if (existsSync(apkSrc)) { + renameSync(apkSrc, join(releasesDir, `Tensamin-${version}.apk`)); +} else { + console.warn(`Skipping .apk: ${apkSrc} does not exist.`); +} + +// deb & rpm +const debDir = "apps/tauri/src-tauri/target/release/bundle/deb"; +const rpmDir = "apps/tauri/src-tauri/target/release/bundle/rpm"; + +const moveBundleArtifact = ( + sourceDir: string, + extension: ".deb" | ".rpm", + destinationFileName: string, +) => { + if (!existsSync(sourceDir)) { + console.warn(`Skipping ${extension}: ${sourceDir} does not exist.`); + return; + } + + const candidates = readdirSync(sourceDir) + .filter((file) => file.endsWith(extension)) + .map((file) => { + const filePath = join(sourceDir, file); + + return { + file, + filePath, + matchesVersion: file.includes(version), + modifiedAt: statSync(filePath).mtimeMs, + }; + }) + .sort((a, b) => { + if (a.matchesVersion !== b.matchesVersion) { + return Number(b.matchesVersion) - Number(a.matchesVersion); + } + + return b.modifiedAt - a.modifiedAt; + }); + + const selected = candidates[0]; + if (!selected) { + console.warn(`Skipping ${extension}: no files found in ${sourceDir}.`); + return; + } + + if (!selected.matchesVersion) { + console.warn( + `Using ${selected.file} for ${extension} even though it does not include version ${version}.`, + ); + } + + renameSync(selected.filePath, join(releasesDir, destinationFileName)); +}; + +moveBundleArtifact(debDir, ".deb", `Tensamin-${version}.deb`); +moveBundleArtifact(rpmDir, ".rpm", `Tensamin-${version}.rpm`); + +console.log("Releases copied successfully."); \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..0096dc3 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,17 @@ +{ + "compilerOptions": { + "target": "ES2020", + "module": "nodenext", + "lib": ["ES2020"], + "rootDir": "./scripts", + "strict": true, + "esModuleInterop": true, + "skipLibCheck": true, + "forceConsistentCasingInFileNames": true, + "resolveJsonModule": true, + "moduleResolution": "nodenext", + "types": ["node"] + }, + "include": ["scripts"], + "exclude": ["node_modules", "dist"] +}