@@ -6,38 +6,36 @@ import { defaultImgUrl, type InstalledPackage } from "../../svelte/src/libs/type
66import { GUIBaseURL } from "../../svelte/src/libs/constants" ;
77import { mkdirp } from "mkdirp" ;
88import fetch from "node-fetch" ;
9- import { SemVer , semver } from "@teaxyz/lib " ;
9+ import { SemVer , semver } from "libpkgx " ;
1010import chokidar from "chokidar" ;
1111import { MainWindowNotifier } from "./types" ;
12- import { hooks } from "@teaxyz/lib " ;
12+ import { hooks } from "libpkgx " ;
1313
1414type ParsedVersion = { full_name : string ; semVer : SemVer } ;
1515
16- export const getTeaPath = ( ) : string => {
16+ export const getPkgxPath = ( ) : string => {
1717 try {
1818 return hooks . useConfig ( ) . prefix . toString ( ) ;
1919 } catch ( error ) {
2020 const homePath = app . getPath ( "home" ) ;
2121 log . info ( "Could not run tea --prefix. Using default path." ) ;
22- return path . join ( homePath , "./.tea " ) ;
22+ return path . join ( homePath , "./.pkgx " ) ;
2323 }
2424} ;
2525
26- const guiFolder = path . join ( getTeaPath ( ) , "tea.xyz/gui" ) ;
27-
2826export const getGuiPath = ( ) => {
29- return path . join ( getTeaPath ( ) , "tea.xyz/gui " ) ;
27+ return path . join ( getPkgxPath ( ) , "pkgx.app " ) ;
3028} ;
3129
3230export async function getInstalledVersionsForPackage ( fullName : string ) : Promise < InstalledPackage > {
33- const pkgsPath = path . join ( getTeaPath ( ) , fullName ) ;
31+ const pkgsPath = path . join ( getPkgxPath ( ) , fullName ) ;
3432 const result = await findInstalledVersions ( pkgsPath ) ;
3533 const pkg = result . find ( ( v ) => v . full_name === fullName ) ;
3634 return pkg ?? { full_name : fullName , installed_versions : [ ] } ;
3735}
3836
3937export async function getInstalledPackages ( ) : Promise < InstalledPackage [ ] > {
40- return findInstalledVersions ( getTeaPath ( ) ) ;
38+ return findInstalledVersions ( getPkgxPath ( ) ) ;
4139}
4240
4341async function findInstalledVersions ( pkgsPath : string ) : Promise < InstalledPackage [ ] > {
@@ -50,14 +48,14 @@ async function findInstalledVersions(pkgsPath: string): Promise<InstalledPackage
5048 const folders = await deepReadDir ( {
5149 dir : pkgsPath ,
5250 continueDeeper : ( name : string , path : string ) => {
53- return ! semver . isValid ( name ) && ! name . startsWith ( "." ) && ! path . includes ( "tea.xyz/var" ) ;
51+ return ! semver . isValid ( name ) && ! name . startsWith ( "." ) ;
5452 } ,
55- filter : ( name : string ) => semver . isValid ( name ) && name !== ".tea " ,
53+ filter : ( name : string ) => semver . isValid ( name ) && name !== ".pkgx " ,
5654 maxDepth : 5
5755 } ) ;
5856
5957 const bottles = folders
60- . map ( ( p : string ) => p . split ( ".tea /" ) [ 1 ] )
58+ . map ( ( p : string ) => p . split ( ".pkgx /" ) [ 1 ] )
6159 . map ( parseVersionFromPath )
6260 . filter ( ( v ) : v is ParsedVersion => ! ! v )
6361 . sort ( ( a , b ) => b . semVer . compare ( a . semVer ) ) ;
@@ -144,7 +142,7 @@ export const getPackagesInstalledList = async (): Promise<InstalledPackage[]> =>
144142 list = JSON . parse ( listBuffer . toString ( ) ) as InstalledPackage [ ] ;
145143 } else {
146144 log . info ( "gui/installed.json does not exists!" ) ;
147- await mkdirp ( guiFolder ) ;
145+ await mkdirp ( getGuiPath ( ) ) ;
148146 await updatePackageInstalledList ( [ ] ) ;
149147 }
150148 } catch ( error ) {
@@ -156,7 +154,7 @@ export const getPackagesInstalledList = async (): Promise<InstalledPackage[]> =>
156154export async function updatePackageInstalledList ( list : InstalledPackage [ ] ) {
157155 try {
158156 log . info ( "creating:" , listFilePath ) ;
159- await mkdirp ( guiFolder ) ;
157+ await mkdirp ( getGuiPath ( ) ) ;
160158 await fs . writeFileSync ( listFilePath , JSON . stringify ( list ) , {
161159 encoding : "utf-8"
162160 } ) ;
@@ -167,7 +165,7 @@ export async function updatePackageInstalledList(list: InstalledPackage[]) {
167165
168166export async function deletePackageFolder ( fullName , version ) {
169167 try {
170- const foldPath = path . join ( getTeaPath ( ) , fullName , `v${ version } ` ) ;
168+ const foldPath = path . join ( getPkgxPath ( ) , fullName , `v${ version } ` ) ;
171169 log . info ( "rm:" , foldPath ) ;
172170 fs . rmSync ( foldPath , { recursive : true } ) ;
173171 } catch ( error ) {
@@ -240,7 +238,7 @@ export async function startMonitoringTeaDir(mainWindowNotifier: MainWindowNotifi
240238 return ;
241239 }
242240
243- const dir = path . join ( getTeaPath ( ) , "**/v*" ) ;
241+ const dir = path . join ( getPkgxPath ( ) , "**/v*" ) ;
244242 log . info ( `Start monitoring tea dir: ${ dir } }` ) ;
245243
246244 watcher = chokidar . watch ( dir , {
@@ -256,7 +254,7 @@ export async function startMonitoringTeaDir(mainWindowNotifier: MainWindowNotifi
256254 const dir = path . dirname ( pth ) ;
257255 const version = path . basename ( pth ) ;
258256 if ( semver . isValid ( version ) && ! fs . lstatSync ( pth ) . isSymbolicLink ( ) ) {
259- const full_name = dir . split ( ".tea /" ) [ 1 ] ;
257+ const full_name = dir . split ( ".pkgx /" ) [ 1 ] ;
260258 log . info ( `Monitor - Added Package: ${ full_name } v${ version } ` ) ;
261259 mainWindowNotifier ( "pkg-modified" , { full_name, version, type : "add" } ) ;
262260 }
@@ -266,7 +264,7 @@ export async function startMonitoringTeaDir(mainWindowNotifier: MainWindowNotifi
266264 const dir = path . dirname ( pth ) ;
267265 const version = path . basename ( pth ) ;
268266 if ( semver . isValid ( version ) ) {
269- const full_name = dir . split ( ".tea /" ) [ 1 ] ;
267+ const full_name = dir . split ( ".pkgx /" ) [ 1 ] ;
270268 log . info ( `Monitor - Removed Package: ${ full_name } v${ version } ` ) ;
271269 mainWindowNotifier ( "pkg-modified" , {
272270 full_name,
0 commit comments