mirror of
https://github.com/ivabus/gui
synced 2025-04-23 22:17:18 +03:00
#183 default README
This commit is contained in:
parent
a33cb2396d
commit
a2929cc1be
4 changed files with 21 additions and 15 deletions
|
@ -113,15 +113,12 @@ ipcMain.on('to-main', (event, count) => {
|
||||||
});
|
});
|
||||||
|
|
||||||
ipcMain.handle('get-installed-packages', async () => {
|
ipcMain.handle('get-installed-packages', async () => {
|
||||||
console.log('get installed pkgs: ipc');
|
|
||||||
const pkgs = await getInstalledPackages();
|
const pkgs = await getInstalledPackages();
|
||||||
return pkgs;
|
return pkgs;
|
||||||
});
|
});
|
||||||
|
|
||||||
ipcMain.handle('get-session', async () => {
|
ipcMain.handle('get-session', async () => {
|
||||||
console.log('get session');
|
|
||||||
const session = await readSessionData();
|
const session = await readSessionData();
|
||||||
console.log('session:', session);
|
|
||||||
return session;
|
return session;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -95,8 +95,16 @@ export async function getDeviceAuth(deviceId: string): Promise<DeviceAuth> {
|
||||||
|
|
||||||
export async function getPackageBottles(packageName: string): Promise<Bottle[]> {
|
export async function getPackageBottles(packageName: string): Promise<Bottle[]> {
|
||||||
console.log('getting bottles for ', packageName);
|
console.log('getting bottles for ', packageName);
|
||||||
const req = await axios.get(`https://app.tea.xyz/api/bottles/${packageName}`);
|
const pkg: Package = await apiGet<Package>(`packages/${packageName.replaceAll('/', ':')}`);
|
||||||
return req.data as Bottle[];
|
return pkg.bottles || [];
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getPackage(packageName: string): Promise<Partial<Package>> {
|
||||||
|
console.log('getting package:', packageName);
|
||||||
|
const pkg: Partial<Package> = await apiGet<Partial<Package>>(
|
||||||
|
`packages/${packageName.replaceAll('/', ':')}`
|
||||||
|
);
|
||||||
|
return pkg;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function registerDevice(): Promise<string> {
|
export async function registerDevice(): Promise<string> {
|
||||||
|
|
|
@ -2,7 +2,7 @@ import { writable } from 'svelte/store';
|
||||||
import type { GUIPackage } from '../types';
|
import type { GUIPackage } from '../types';
|
||||||
import { getPackages } from '@api';
|
import { getPackages } from '@api';
|
||||||
import Fuse from 'fuse.js';
|
import Fuse from 'fuse.js';
|
||||||
import { getPackageBottles } from '@api';
|
import { getPackage } from '@api';
|
||||||
|
|
||||||
import { getGithubOwnerRepo, getReadme } from '$libs/github';
|
import { getGithubOwnerRepo, getReadme } from '$libs/github';
|
||||||
|
|
||||||
|
@ -61,17 +61,21 @@ export default function initPackagesStore() {
|
||||||
// getReadmeRaw('');
|
// getReadmeRaw('');
|
||||||
|
|
||||||
if (!foundPackage.bottles) {
|
if (!foundPackage.bottles) {
|
||||||
getPackageBottles(foundPackage.full_name).then((bottles) => {
|
getPackage(foundPackage.full_name).then((pkg) => {
|
||||||
updatePackageProp(foundPackage.full_name, { bottles });
|
updatePackageProp(foundPackage.full_name, pkg);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
console.log(foundPackage);
|
|
||||||
if (!foundPackage.readme_md && foundPackage.package_yml_url) {
|
if (!foundPackage.readme_md && foundPackage.package_yml_url) {
|
||||||
getGithubOwnerRepo(foundPackage.package_yml_url).then(async ({ owner, repo }) => {
|
getGithubOwnerRepo(foundPackage.package_yml_url).then(async ({ owner, repo }) => {
|
||||||
|
const defaultReadme = `# ${foundPackage.full_name} #
|
||||||
|
To read more about this package go to [${foundPackage.homepage}](${foundPackage.homepage}).
|
||||||
|
`;
|
||||||
if (owner && repo) {
|
if (owner && repo) {
|
||||||
const readme_md = await getReadme(owner, repo);
|
const readme = await getReadme(owner, repo);
|
||||||
console.log(readme_md);
|
updatePackageProp(foundPackage.full_name, { readme_md: readme || defaultReadme });
|
||||||
updatePackageProp(foundPackage.full_name, { readme_md });
|
} else {
|
||||||
|
updatePackageProp(foundPackage.full_name, { readme_md: defaultReadme });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,9 +4,6 @@
|
||||||
|
|
||||||
import './styles.css';
|
import './styles.css';
|
||||||
|
|
||||||
// TODO: rm sample
|
|
||||||
// import { md } from './sample';
|
|
||||||
|
|
||||||
export let source: string;
|
export let source: string;
|
||||||
|
|
||||||
const renderers = {
|
const renderers = {
|
||||||
|
|
Loading…
Reference in a new issue