Skip to content

Commit

Permalink
Merge pull request #507 from VitNode/perf/plugins
Browse files Browse the repository at this point in the history
perf: Improve plugins upload
  • Loading branch information
aXenDeveloper authored Sep 12, 2024
2 parents 61fafd7 + 3f8de87 commit 46610ca
Show file tree
Hide file tree
Showing 20 changed files with 85 additions and 66 deletions.
6 changes: 3 additions & 3 deletions apps/backend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "backend",
"version": "0.0.9-canary.48",
"version": "0.0.9-canary.49",
"license": "MIT",
"scripts": {
"drizzle-kit": "drizzle-kit",
Expand All @@ -24,8 +24,8 @@
"@nestjs/schedule": "^4.1.0",
"@nestjs/serve-static": "^4.0.2",
"pg": "^8.12.0",
"react": "19.0.0-rc-e56f4ae3-20240830",
"react-dom": "19.0.0-rc-e56f4ae3-20240830",
"react": "^19.0.0-rc-d6cb4e77-20240911",
"react-dom": "^19.0.0-rc-d6cb4e77-20240911",
"reflect-metadata": "^0.2.2",
"rxjs": "^7.8.1"
},
Expand Down
6 changes: 3 additions & 3 deletions apps/frontend/global.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type core from '@/src/plugins/core/langs/en.json';
import type admin from '@/src/plugins/admin/langs/en.json';
import type welcome from '@/src/plugins/welcome/langs/en.json';
import type core from '@/plugins/core/langs/en.json';
import type admin from '@/plugins/admin/langs/en.json';
import type welcome from '@/plugins/welcome/langs/en.json';

// ! === IMPORT ===

Expand Down
6 changes: 3 additions & 3 deletions apps/frontend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "frontend",
"version": "0.0.9-canary.48",
"version": "0.0.9-canary.49",
"author": "Maciej Piotr (aXenDev) Balcerzak",
"license": "GPL-3.0 license",
"scripts": {
Expand All @@ -20,8 +20,8 @@
"lucide-react": "^0.437.0",
"next": "15.0.0-canary.146",
"next-intl": "^3.19.1",
"react": "19.0.0-rc-e56f4ae3-20240830",
"react-dom": "19.0.0-rc-e56f4ae3-20240830",
"react": "^19.0.0-rc-d6cb4e77-20240911",
"react-dom": "^19.0.0-rc-d6cb4e77-20240911",
"vitnode-frontend": "workspace:*"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/backend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vitnode-backend",
"version": "0.0.9-canary.48",
"version": "0.0.9-canary.49",
"description": "Backend wrapper for VitNode projects",
"author": "VitNode Team",
"license": "MIT",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ export const createInfoJSON = ({
name,
nav,
support_url,
version,
version_code,
}: PluginInfoJSONType): string => {
const json = {
name,
Expand All @@ -52,6 +54,8 @@ export const createInfoJSON = ({
support_url,
allow_default,
nav,
version,
version_code,
};

return JSON.stringify(json, null, 2);
Expand Down
15 changes: 9 additions & 6 deletions packages/create-vitnode-app/helpers/create-packages-json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,12 @@ export const createPackagesJSON = ({
: {},
devDependencies: {
...(eslint
? { prettier: '^3.3.3', 'prettier-plugin-tailwindcss': '^0.6.6' }
? {
'eslint-config-typescript-vitnode': `^${pkg.version}`,
prettier: '^3.3.3',
'prettier-plugin-tailwindcss': '^0.6.6',
}
: {}),
'eslint-config-typescript-vitnode': `^${pkg.version}`,
turbo: '^2.1.1',
},
packageManager,
Expand All @@ -83,24 +86,24 @@ export const createPackagesJSON = ({
'lint:fix': 'eslint . --fix',
},
dependencies: {
'@hookform/resolvers': '^3.9.0',
geist: '^1.3.1',
'lucide-react': '^0.439.0',
next: '15.0.0-canary.146',
react: '^19.0.0-rc.0',
'react-dom': '^19.0.0-rc.0',
'next-intl': '^3.19.1',
react: '^19.0.0-rc-d6cb4e77-20240911',
'react-dom': '^19.0.0-rc-d6cb4e77-20240911',
'react-hook-form': '^7.53.0',
'@hookform/resolvers': '^3.9.0',
'vitnode-frontend': `^${pkg.version}`,
},
devDependencies: {
'@types/node': '^22.5.4',
'@types/react': '^18.3.5',
'@types/react-dom': '^18.3.0',
autoprefixer: '^10.4.20',
'graphql-tag': '^2.12.6',
...(eslint ? { eslint: '^9.10.0' } : {}),
'eslint-config-typescript-vitnode': `^${pkg.version}`,
'graphql-tag': '^2.12.6',
postcss: '^8.4.45',
tailwindcss: '^3.4.10',
typescript: '^5.6.2',
Expand Down
2 changes: 1 addition & 1 deletion packages/create-vitnode-app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "create-vitnode-app",
"version": "0.0.9-canary.48",
"version": "0.0.9-canary.49",
"description": "Create a new VitNode app in seconds.",
"author": "VitNode Team",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-config-typescript-vitnode/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eslint-config-typescript-vitnode",
"version": "0.0.9-canary.48",
"version": "0.0.9-canary.49",
"description": "ESLint, TypeScript (TSConfig), Prettier config for VitNode",
"author": "VitNode Team",
"license": "MIT",
Expand Down
6 changes: 3 additions & 3 deletions packages/frontend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vitnode-frontend",
"version": "0.0.9-canary.48",
"version": "0.0.9-canary.49",
"description": "Frontend wrapper for VitNode projects",
"author": "VitNode Team",
"license": "MIT",
Expand Down Expand Up @@ -90,8 +90,8 @@
"next": "15.0.0-canary.137",
"next-intl": "^3.19.0",
"postcss": "^8.4.42",
"react": "^19",
"react-dom": "^19",
"react": "^19.0.0-rc-d6cb4e77-20240911",
"react-dom": "^19.0.0-rc-d6cb4e77-20240911",
"react-hook-form": "^7.53.0",
"tailwindcss": "^3.4.10",
"typescript": "^5.5.4"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { LogoVitNode } from '@/components/logo-vitnode';
import { LanguageSwitcher } from '@/components/switchers/language-switcher';
import { ThemeSwitcher } from '@/components/switchers/theme-switcher';
import { ScrollArea } from '@/components/ui/scroll-area';
import { CONFIG } from '@/helpers/config-with-env';
import { Link } from '@/navigation';

Expand Down Expand Up @@ -39,11 +38,7 @@ export const AsideAuthAdmin = () => {
<SearchAsideAuthAdmin />
</div>

<ScrollArea className="flex-1">
<div className="px-3 py-6">
<NavAdmin />
</div>
</ScrollArea>
<NavAdmin />
</aside>
);
};
35 changes: 20 additions & 15 deletions packages/frontend/src/views/admin/layout/auth/nav/nav-admin.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { ScrollArea } from '@/components/ui/scroll-area';
import { getSessionAdminData } from '@/graphql/get-session-admin';

import { ItemNavAdmin } from './item/item';
Expand All @@ -7,20 +8,24 @@ export const NavAdmin = async () => {
const data = await getSessionAdminData();

return (
<NavAdminWrapper>
{data.admin__nav__show.map(item => (
<ItemNavAdmin
id={item.code}
items={item.nav.map(navItem => ({
id: navItem.code,
icon: navItem.icon ?? undefined,
children: navItem.children?.map(child => ({
id: child.code,
})),
}))}
key={item.code}
/>
))}
</NavAdminWrapper>
<ScrollArea className="flex-1">
<div className="px-3 py-6">
<NavAdminWrapper>
{data.admin__nav__show.map(item => (
<ItemNavAdmin
id={item.code}
items={item.nav.map(navItem => ({
id: navItem.code,
icon: navItem.icon ?? undefined,
children: navItem.children?.map(child => ({
id: child.code,
})),
}))}
key={item.code}
/>
))}
</NavAdminWrapper>
</div>
</ScrollArea>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
Admin__Core_Plugins__CreateMutation,
Admin__Core_Plugins__CreateMutationVariables,
} from '@/graphql/mutations/admin/plugins/admin__core_plugins__create.generated';
import { CONFIG } from '@/helpers/config-with-env';
import { revalidatePath } from 'next/cache';

export const mutationCreateApi = async (
Expand All @@ -20,19 +19,17 @@ export const mutationCreateApi = async (
query: Admin__Core_Plugins__Create,
variables,
});
} catch (error) {
const e = error as Error;

return { error: e.message };
}

if (CONFIG.node_development) {
// Revalidate after 3 seconds in promise. Wait for fast refresh to compilation files.
await new Promise<void>(resolve =>
setTimeout(() => {
revalidatePath('/', 'layout');
resolve();
}, 3000),
);
} catch (error) {
const e = error as Error;

return { error: e.message };
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ export const mutationEditApi = async (
query: Admin__Core_Plugins__Edit,
variables,
});

revalidatePath('/', 'layout');
} catch (error) {
const e = error as Error;

return { error: e.message };
}

revalidatePath('/', 'layout');
};
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
Admin__Core_Plugins__DeleteMutation,
Admin__Core_Plugins__DeleteMutationVariables,
} from '@/graphql/mutations/admin/plugins/admin__core_plugins__delete.generated';
import { revalidatePath } from 'next/cache';

export const mutationApi = async (
variables: Admin__Core_Plugins__DeleteMutationVariables,
Expand All @@ -18,7 +19,13 @@ export const mutationApi = async (
query: Admin__Core_Plugins__Delete,
variables,
});
} catch (e) {
if (typeof e === 'string') return { error: e };
} catch (error) {
const e = error as Error;

if (e.message !== 'fetch failed') {
return { error: e.message };
}
}

revalidatePath('/', 'layout');
};
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
Admin__Core_Plugins__UploadMutation,
Admin__Core_Plugins__UploadMutationVariables,
} from '@/graphql/mutations/admin/plugins/admin__core_plugins__upload.generated';
import { revalidatePath } from 'next/cache';

export const mutationApi = async (formData: FormData) => {
const files = formData.get('file') as File;
Expand All @@ -26,7 +27,13 @@ export const mutationApi = async (formData: FormData) => {
},
],
});
} catch (e) {
if (typeof e === 'string') return { error: e };
} catch (error) {
const e = error as Error;

if (e.message !== 'fetch failed') {
return { error: e.message };
}
}

revalidatePath('/', 'layout');
};
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ export const createMutationApi = async (
query: Admin__Core_Plugins__Nav__Create,
variables,
});

revalidatePath('/', 'layout');
} catch (error) {
const e = error as Error;

return { error: e.message };
}

revalidatePath('/[locale]/admin/(auth)/(vitnode)', 'layout');
};
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ export const editMutationApi = async (variables: Args) => {
query: Admin__Core_Plugins__Nav__Edit,
variables,
});

revalidatePath('/', 'layout');
} catch (error) {
const e = error as Error;

return { error: e.message };
}

revalidatePath('/[locale]/admin/(auth)/(vitnode)', 'layout');
};
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ export const mutationApi = async (variables: Args) => {
query: Admin__Core_Plugins__Nav__Delete,
variables,
});

revalidatePath('/', 'layout');
} catch (error) {
const e = error as Error;

return { error: e.message };
}

revalidatePath('/[locale]/admin/(auth)/(vitnode)', 'layout');
};
3 changes: 2 additions & 1 deletion packages/frontend/src/views/theme/layout/header/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { UserBar } from './user-bar/user-bar';
export const Header = async ({ className }: { className?: string }) => {
const {
core_sessions__authorization: { user },
core_nav__show: { edges },
} = await getSessionData();

return (
Expand All @@ -23,7 +24,7 @@ export const Header = async ({ className }: { className?: string }) => {
>
<div className="container flex h-16 items-center gap-5 px-5">
<LogoHeader />
<Nav />
{edges.length > 0 && <Nav />}

<div className="ml-auto hidden gap-2 sm:flex">
<LanguageSwitcher />
Expand Down
8 changes: 4 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 46610ca

Please sign in to comment.