Skip to content
This repository was archived by the owner on Jan 15, 2025. It is now read-only.

Commit 14049e2

Browse files
authored
change paths from .tea -> .pkgx (#814)
1 parent 52a4295 commit 14049e2

18 files changed

Lines changed: 77 additions & 80 deletions

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ jobs:
8484
MAC_BUILD_TARGET: "dir"
8585
- name: setup dev
8686
run: |
87-
mkdir -p /Users/runner/.tea/tea.xyz/gui
88-
touch /Users/runner/.tea/tea.xyz/gui/dev
87+
mkdir -p /Users/runner/.pkgx/pkgx.app
88+
touch /Users/runner/.pkgx/pkgx.app/dev
8989
- name: e2e test
9090
run: xc e2e
9191

electron-builder.config.cjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,6 @@ module.exports = {
7979
// this determines the configuration of the auto-update feature
8080
publish: {
8181
provider: "generic",
82-
url: process.env.PUBLISH_URL || "https://gui.tea.xyz/release"
82+
url: process.env.PUBLISH_URL || "https://gui.pkgx.dev/release"
8383
}
8484
};

electron/libs/auth.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { mkdirp } from "mkdirp";
22
import path from "path";
33
import fs from "fs";
4-
import { getTeaPath } from "./tea-dir";
4+
import { getPkgxPath } from "./pkgx-dir";
55
import { app } from "electron";
66
import log from "./logger";
77
import axios from "axios";
@@ -12,8 +12,8 @@ import { InitWatcher } from "./initialize";
1212
import { baseURL } from "./v1-client";
1313
import { isDev } from "./auto-updater";
1414

15-
const sessionFilePath = path.join(getTeaPath(), `tea.xyz/gui/${isDev() ? "dev.dat" : "tmp.dat"}`);
16-
const sessionFolder = path.join(getTeaPath(), "tea.xyz/gui");
15+
const sessionFilePath = path.join(getPkgxPath(), isDev() ? "dev.dat" : "tmp.dat");
16+
const sessionFolder = getPkgxPath();
1717

1818
export interface Session {
1919
device_id?: string;

electron/libs/auto-updater.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { type AppUpdater, autoUpdater } from "electron-updater";
22
import log from "./logger";
33
import { MainWindowNotifier } from "./types";
4-
import { getTeaPath } from "./tea-dir";
4+
import { getGuiPath, getPkgxPath } from "./pkgx-dir";
55
import path from "path";
66
import fs from "fs";
77

@@ -109,14 +109,13 @@ autoUpdater.on("update-downloaded", (info) => {
109109
sendStatusToWindow({ status: "ready", version: info.version });
110110
});
111111

112-
export const isDev = () => fs.existsSync(path.join(getTeaPath(), "tea.xyz/gui/dev"));
113-
export const isForceUpdate = () =>
114-
fs.existsSync(path.join(getTeaPath(), "tea.xyz/gui/force-auto-update"));
112+
export const isDev = () => fs.existsSync(path.join(getPkgxPath(), "tea.xyz/gui/dev"));
113+
export const isForceUpdate = () => fs.existsSync(path.join(getGuiPath(), "force-auto-update"));
115114

116115
async function setPublishURL() {
117116
try {
118117
const folder = isForceUpdate() ? "auto-update-test" : isDev() ? "dev" : "release";
119-
const feedUrl = `https://gui.tea.xyz/${folder}`;
118+
const feedUrl = `https://gui.pkgx.dev/${folder}`;
120119
log.info(`feedUrl$: ${feedUrl}`);
121120
autoUpdater.setFeedURL(feedUrl);
122121
} catch (error) {

electron/libs/cli.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { hooks } from "@teaxyz/lib";
1+
import { hooks } from "libpkgx";
22

33
import log from "./logger";
44
import { MainWindowNotifier } from "./types";
5-
import * as tea from "@teaxyz/lib";
6-
import { Installation } from "@teaxyz/lib";
7-
import type { Resolution } from "@teaxyz/lib/script/src/plumbing/resolve";
5+
import * as pkgx from "libpkgx";
6+
import { Installation } from "libpkgx";
7+
import type { Resolution } from "libpkgx/script/src/plumbing/resolve";
88

99
export async function installPackage(
1010
full_name: string,
@@ -15,7 +15,7 @@ export async function installPackage(
1515

1616
const qualifedPackage = `${full_name}@${version}`;
1717
log.info(`installing package ${qualifedPackage}`);
18-
const result = await tea.porcelain.install(qualifedPackage, notifier);
18+
const result = await pkgx.porcelain.install(qualifedPackage, notifier);
1919
log.info(`successfully installed ${qualifedPackage}`, result);
2020
}
2121

electron/libs/entrypoints.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ import pty from "node-pty";
22

33
import log from "./logger";
44
import { MainWindowNotifier } from "./types";
5-
import * as tea from "@teaxyz/lib";
5+
import * as pkgx from "libpkgx";
66
import { GUIPackage } from "../../svelte/src/libs/types";
77
import { getPantryDetails } from "./pantry";
88
import { ipcMain } from "electron";
99

1010
// the tea cli package is needed to open any other package in the terminal, so make sure it's installed and return the path
1111
async function installTeaCli() {
12-
const installations = await tea.porcelain.install("tea.xyz");
12+
const installations = await pkgx.porcelain.install("tea.xyz");
1313
const install = installations.find((i) => i.pkg.project === "tea.xyz");
1414
if (!install) {
1515
throw new Error("installing tea/cli failed");
@@ -59,13 +59,13 @@ export async function openPackageEntrypointInTerminal(
5959

6060
notifyMainWindow("pty.out", { project, type: "reset" });
6161

62-
const installation = await tea.hooks
62+
const installation = await pkgx.hooks
6363
.useCellar()
64-
.resolve({ project, constraint: new tea.semver.Range("*") });
64+
.resolve({ project, constraint: new pkgx.semver.Range("*") });
6565
const shell =
6666
process.platform === "win32" ? "powershell.exe" : process.platform == "darwin" ? "zsh" : "bash";
67-
const wet = await tea.plumbing.hydrate(installation.pkg);
68-
const gas = await tea.plumbing.resolve(wet.pkgs);
67+
const wet = await pkgx.plumbing.hydrate(installation.pkg);
68+
const gas = await pkgx.plumbing.resolve(wet.pkgs);
6969
if (gas.pending.length) throw new Error("pkg dependencies not installed");
7070
const cwd = installation.path.string;
7171

@@ -76,8 +76,8 @@ export async function openPackageEntrypointInTerminal(
7676
installations.push(cli);
7777
}
7878

79-
const rawenv = await tea.hooks.useShellEnv().map({ installations });
80-
const env = tea.hooks.useShellEnv().flatten(rawenv);
79+
const rawenv = await pkgx.hooks.useShellEnv().map({ installations });
80+
const env = pkgx.hooks.useShellEnv().flatten(rawenv);
8181
env.PATH += ":/usr/bin:/bin";
8282
env.TMPDIR ??= process.env.TMPDIR ?? "error";
8383
env.HOME ??= process.env.HOME ?? "error";

electron/libs/ipc.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
cacheImage,
77
startMonitoringTeaDir,
88
stopMonitoringTeaDir
9-
} from "./tea-dir";
9+
} from "./pkgx-dir";
1010
import { readSessionData, writeSessionData, pollAuth } from "./auth";
1111
import type { Packages, Session, GUIPackage } from "../../svelte/src/libs/types";
1212
import log from "./logger";
@@ -246,7 +246,7 @@ export default function initializeHandlers({ notifyMainWindow }: HandlerOptions)
246246
}
247247
});
248248

249-
ipcMain.handle("monitor-tea-dir", async () => {
249+
ipcMain.handle("monitor-pkgx-dir", async () => {
250250
try {
251251
await startMonitoringTeaDir(notifyMainWindow);
252252
} catch (err) {
@@ -255,7 +255,7 @@ export default function initializeHandlers({ notifyMainWindow }: HandlerOptions)
255255
}
256256
});
257257

258-
ipcMain.handle("stop-monitor-tea-dir", async () => {
258+
ipcMain.handle("stop-monitor-pkgx-dir", async () => {
259259
try {
260260
await stopMonitoringTeaDir();
261261
} catch (err) {

electron/libs/package.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ import path from "path";
22
import { mkdirp } from "mkdirp";
33
import fs from "fs";
44
import log from "./logger";
5-
import { getTeaPath } from "./tea-dir";
5+
import { getPkgxPath } from "./pkgx-dir";
66
import { GUIPackage, Packages } from "../../svelte/src/libs/types";
77
import { GUIBaseURL } from "../../svelte/src/libs/constants";
88
import { isDev } from "./auto-updater";
99

10-
const pkgsFilePath = path.join(getTeaPath(), "tea.xyz/gui/pkgs.json");
11-
const pkgsFolder = path.join(getTeaPath(), "tea.xyz/gui");
10+
const pkgsFilePath = path.join(getPkgxPath(), "tea.xyz/gui/pkgs.json");
11+
const pkgsFolder = path.join(getPkgxPath(), "tea.xyz/gui");
1212
const dev = isDev();
1313

1414
export async function writePackageCache(pkgs: Packages) {
@@ -70,7 +70,7 @@ export const nameToSlug = (name: string) => {
7070

7171
export async function isInstalled(project: string, version?: string) {
7272
if (!version) {
73-
const folderPath = path.join(getTeaPath(), project);
73+
const folderPath = path.join(getPkgxPath(), project);
7474
return fs.existsSync(folderPath);
7575
} else {
7676
const cache = await loadPackageCache();

electron/libs/pantry.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { hooks } from "@teaxyz/lib";
1+
import { hooks } from "libpkgx";
22

33
// Fetches the details for a package from the local pantry
44
export async function getPantryDetails(full_name: string) {
Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,38 +6,36 @@ import { defaultImgUrl, type InstalledPackage } from "../../svelte/src/libs/type
66
import { GUIBaseURL } from "../../svelte/src/libs/constants";
77
import { mkdirp } from "mkdirp";
88
import fetch from "node-fetch";
9-
import { SemVer, semver } from "@teaxyz/lib";
9+
import { SemVer, semver } from "libpkgx";
1010
import chokidar from "chokidar";
1111
import { MainWindowNotifier } from "./types";
12-
import { hooks } from "@teaxyz/lib";
12+
import { hooks } from "libpkgx";
1313

1414
type 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-
2826
export const getGuiPath = () => {
29-
return path.join(getTeaPath(), "tea.xyz/gui");
27+
return path.join(getPkgxPath(), "pkgx.app");
3028
};
3129

3230
export 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

3937
export async function getInstalledPackages(): Promise<InstalledPackage[]> {
40-
return findInstalledVersions(getTeaPath());
38+
return findInstalledVersions(getPkgxPath());
4139
}
4240

4341
async 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[]> =>
156154
export 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

168166
export 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

Comments
 (0)