@hed-hog/developer-mode 0.0.194 → 0.0.197

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,86 @@
1
+ export type FrameworkType =
2
+ | 'nestjs'
3
+ | 'nextjs'
4
+ | 'angular'
5
+ | 'vue'
6
+ | 'react-native'
7
+ | 'expo';
8
+
9
+ export interface AppInfo {
10
+ name: string;
11
+ path: string;
12
+ framework: FrameworkType;
13
+ database?: string;
14
+ description: string;
15
+ port?: number;
16
+ status: 'running' | 'stopped' | 'error';
17
+ scripts?: string[];
18
+ }
19
+
20
+ export interface LibraryScript {
21
+ name: string;
22
+ command: string;
23
+ }
24
+
25
+ export interface LibraryInfo {
26
+ name: string;
27
+ version: string;
28
+ latestVersion?: string;
29
+ installed: boolean;
30
+ description: string;
31
+ scripts: LibraryScript[];
32
+ }
33
+
34
+ export interface CommitInfo {
35
+ hash: string;
36
+ message: string;
37
+ author: string;
38
+ authorAvatar?: string;
39
+ date: string;
40
+ branch: string;
41
+ }
42
+
43
+ export interface WizardStep {
44
+ id: string;
45
+ title: string;
46
+ description: string;
47
+ type: 'info' | 'form' | 'progress' | 'select';
48
+ }
49
+
50
+ export interface WizardFormField {
51
+ name: string;
52
+ label: string;
53
+ placeholder?: string;
54
+ type?: string;
55
+ required?: boolean;
56
+ }
57
+
58
+ export interface WizardSelectOption {
59
+ value: string;
60
+ label: string;
61
+ description?: string;
62
+ }
63
+
64
+ export interface WizardConfig {
65
+ id: string;
66
+ title: string;
67
+ description?: string;
68
+ icon: React.ReactNode;
69
+ steps: WizardStep[];
70
+ formFields?: WizardFormField[];
71
+ selectOptions?: WizardSelectOption[];
72
+ selectMultiple?: boolean;
73
+ scriptExecution?: {
74
+ targetType: 'app' | 'library';
75
+ targetName: string;
76
+ scriptName: string;
77
+ };
78
+ }
79
+
80
+ export interface QuickAction {
81
+ id: string;
82
+ label: string;
83
+ description: string;
84
+ icon: React.ReactNode;
85
+ variant: 'default' | 'warning' | 'info' | 'accent';
86
+ }
@@ -0,0 +1,10 @@
1
+ import { ReactNode } from 'react';
2
+ import { DeveloperModeProvider } from './provider';
3
+
4
+ export default function DeveloperModeLayout({
5
+ children,
6
+ }: {
7
+ children: ReactNode;
8
+ }) {
9
+ return <DeveloperModeProvider>{children}</DeveloperModeProvider>;
10
+ }
@@ -0,0 +1,247 @@
1
+ 'use client';
2
+
3
+ import { PageHeader } from '@/components/entity-list';
4
+ import { FileCode, Package, RefreshCw } from 'lucide-react';
5
+ import { useTranslations } from 'next-intl';
6
+ import * as React from 'react';
7
+ import { getWizardConfig } from './components/data';
8
+ import {
9
+ AppsGrid,
10
+ DatabaseInfoCard,
11
+ GitInfo,
12
+ LibrariesList,
13
+ QuickActionsBar,
14
+ StatsCards,
15
+ WizardDialog,
16
+ } from './components/sections';
17
+ import { QuickAction, WizardConfig } from './components/types';
18
+ import { useDeveloperMode, type AppInfo, type LibraryInfo } from './provider';
19
+
20
+ export default function DeveloperDashboard() {
21
+ const t = useTranslations('developer-mode.Page');
22
+ const [wizardOpen, setWizardOpen] = React.useState(false);
23
+ const [currentWizard, setCurrentWizard] = React.useState<WizardConfig | null>(
24
+ null
25
+ );
26
+
27
+ // Obter dados do developer-mode
28
+ const { data: developerModeData, isLoading, error } = useDeveloperMode();
29
+
30
+ const openWizard = (config: WizardConfig) => {
31
+ setCurrentWizard(config);
32
+ setWizardOpen(true);
33
+ };
34
+
35
+ const handleAction = (action: QuickAction) => {
36
+ const config = getWizardConfig(action.id, t);
37
+ if (config) openWizard(config);
38
+ };
39
+
40
+ const handleRunScript = (library: LibraryInfo, scriptName: string) => {
41
+ openWizard({
42
+ id: `run-script-${library.name}-${scriptName}`,
43
+ title: t('wizard.runScript.title', { scriptName }),
44
+ icon: <FileCode className="h-5 w-5" />,
45
+ scriptExecution: {
46
+ targetType: 'library',
47
+ targetName: library.name,
48
+ scriptName,
49
+ },
50
+ steps: [
51
+ {
52
+ id: 'progress',
53
+ title: t('wizard.runScript.progressTitle', { scriptName }),
54
+ description: t('wizard.runScript.progressDescription', {
55
+ scriptName,
56
+ libraryName: library.name,
57
+ }),
58
+ type: 'progress',
59
+ },
60
+ ],
61
+ });
62
+ };
63
+
64
+ const handleInstallLibrary = (library: LibraryInfo) => {
65
+ openWizard({
66
+ id: `install-${library.name}`,
67
+ title: t('wizard.installLibrary.title', { libraryName: library.name }),
68
+ icon: <Package className="h-5 w-5" />,
69
+ steps: [
70
+ {
71
+ id: 'info',
72
+ title: t('wizard.installLibrary.infoTitle'),
73
+ description: t('wizard.installLibrary.infoDescription', {
74
+ libraryName: library.name,
75
+ libraryDescription: library.description || '',
76
+ }),
77
+ type: 'info',
78
+ },
79
+ {
80
+ id: 'progress',
81
+ title: t('wizard.installLibrary.progressTitle'),
82
+ description: t('wizard.installLibrary.progressDescription'),
83
+ type: 'progress',
84
+ },
85
+ ],
86
+ });
87
+ };
88
+
89
+ const handleUpdateLibrary = (library: LibraryInfo) => {
90
+ openWizard({
91
+ id: `update-${library.name}`,
92
+ title: t('wizard.updateLibrary.title', { libraryName: library.name }),
93
+ icon: <RefreshCw className="h-5 w-5" />,
94
+ steps: [
95
+ {
96
+ id: 'info',
97
+ title: t('wizard.updateLibrary.infoTitle'),
98
+ description: t('wizard.updateLibrary.infoDescription', {
99
+ libraryName: library.name,
100
+ version: library.version,
101
+ }),
102
+ type: 'info',
103
+ },
104
+ {
105
+ id: 'progress',
106
+ title: t('wizard.updateLibrary.progressTitle'),
107
+ description: t('wizard.updateLibrary.progressDescription'),
108
+ type: 'progress',
109
+ },
110
+ ],
111
+ });
112
+ };
113
+
114
+ const handleAppScript = (app: AppInfo, script: string) => {
115
+ openWizard({
116
+ id: `app-script-${app.name}-${script}`,
117
+ title: t('wizard.appScript.title', { script, appName: app.name }),
118
+ icon: <FileCode className="h-5 w-5" />,
119
+ scriptExecution: {
120
+ targetType: 'app',
121
+ targetName: app.name,
122
+ scriptName: script,
123
+ },
124
+ steps: [
125
+ {
126
+ id: 'progress',
127
+ title: t('wizard.appScript.progressTitle', { script }),
128
+ description: t('wizard.appScript.progressDescription', {
129
+ script,
130
+ appPath: app.path,
131
+ }),
132
+ type: 'progress',
133
+ },
134
+ ],
135
+ });
136
+ };
137
+
138
+ return (
139
+ <div className="flex flex-col h-screen px-4">
140
+ <PageHeader
141
+ title={t('header.title')}
142
+ description={t('header.description')}
143
+ breadcrumbs={[
144
+ { label: t('header.breadcrumbs.home'), href: '/' },
145
+ { label: t('header.breadcrumbs.current') },
146
+ ]}
147
+ />
148
+
149
+ {/* Main Content */}
150
+ <main className="container mx-auto py-6 space-y-6">
151
+ {/* Loading State */}
152
+ {isLoading && (
153
+ <div className="flex items-center justify-center py-12">
154
+ <div className="text-center">
155
+ <div className="inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-primary"></div>
156
+ <p className="mt-4 text-muted-foreground">
157
+ {t('states.loading')}
158
+ </p>
159
+ </div>
160
+ </div>
161
+ )}
162
+
163
+ {/* Error State */}
164
+ {error && (
165
+ <div className="rounded-lg border border-destructive/50 bg-destructive/10 px-4 py-3 text-destructive">
166
+ <p>{t('states.error', { message: error.message })}</p>
167
+ </div>
168
+ )}
169
+
170
+ {/* Content */}
171
+ {developerModeData && !isLoading && (
172
+ <>
173
+ {/* Quick Actions */}
174
+ <QuickActionsBar onAction={handleAction} />
175
+
176
+ {/* Main Grid */}
177
+ <div className="grid grid-cols-1 lg:grid-cols-3 gap-6">
178
+ <div className="lg:col-span-2">
179
+ <AppsGrid
180
+ apps={developerModeData.apps}
181
+ onRunScript={handleAppScript}
182
+ />
183
+ </div>
184
+ <div>
185
+ <DatabaseInfoCard
186
+ name={
187
+ developerModeData.database.database ||
188
+ developerModeData.database.name
189
+ }
190
+ host={`${developerModeData.database.host}:${developerModeData.database.port}`}
191
+ tables={developerModeData.database.tables || 0}
192
+ size={developerModeData.database.size || t('fallback.na')}
193
+ connections={
194
+ developerModeData.database.connections || {
195
+ active: 0,
196
+ max: 0,
197
+ }
198
+ }
199
+ lastMigration={developerModeData.database.lastMigration}
200
+ />
201
+ </div>
202
+ </div>
203
+
204
+ {/* Second Row */}
205
+ <div className="grid grid-cols-1 lg:grid-cols-2 gap-6">
206
+ <div className="lg:col-span-1">
207
+ <LibrariesList
208
+ libraries={developerModeData.libraries}
209
+ onRunScript={handleRunScript}
210
+ onInstall={handleInstallLibrary}
211
+ onUpdate={handleUpdateLibrary}
212
+ onCreateLibrary={() => {
213
+ const config = getWizardConfig('create-module', t);
214
+ if (config) openWizard(config);
215
+ }}
216
+ />
217
+ </div>
218
+ <div className="lg:col-span-1">
219
+ <GitInfo
220
+ repoName={
221
+ developerModeData.git.repoName || t('fallback.repository')
222
+ }
223
+ currentBranch={developerModeData.git.currentBranch}
224
+ totalBranches={developerModeData.git.totalBranches}
225
+ openPRs={developerModeData.git.openPRs}
226
+ recentCommits={developerModeData.git.recentCommits}
227
+ />
228
+ </div>
229
+ </div>
230
+
231
+ {/* Stats (less important, at the bottom) */}
232
+ <StatsCards stats={developerModeData.stats} />
233
+ </>
234
+ )}
235
+ </main>
236
+
237
+ {/* Wizard Dialog */}
238
+ {currentWizard && (
239
+ <WizardDialog
240
+ open={wizardOpen}
241
+ onOpenChange={setWizardOpen}
242
+ config={currentWizard}
243
+ />
244
+ )}
245
+ </div>
246
+ );
247
+ }
@@ -0,0 +1,95 @@
1
+ 'use client';
2
+
3
+ import { useApp, useQuery } from '@hed-hog/next-app-provider';
4
+ import { ReactNode, createContext, useContext } from 'react';
5
+ import type { AppInfo, CommitInfo, LibraryInfo } from './components/types';
6
+
7
+ export interface DatabaseInfo {
8
+ name: string;
9
+ host: string;
10
+ port: number;
11
+ type: 'postgresql' | 'mysql' | 'unknown';
12
+ user?: string;
13
+ database?: string;
14
+ tables?: number;
15
+ size?: string;
16
+ connections?: { active: number; max: number };
17
+ lastMigration?: {
18
+ name: string;
19
+ date: string;
20
+ status: 'success' | 'failed' | 'pending';
21
+ };
22
+ connected?: boolean;
23
+ }
24
+
25
+ export interface ProjectStats {
26
+ nodeVersion: string;
27
+ diskUsage: string;
28
+ totalApps: number;
29
+ totalLibraries: number;
30
+ dbConnections: number;
31
+ gitBranch: string;
32
+ lastCommit: string;
33
+ uptime: string;
34
+ }
35
+
36
+ export interface GitInfo {
37
+ repoName?: string;
38
+ currentBranch: string;
39
+ totalBranches: number;
40
+ openPRs: number;
41
+ recentCommits: CommitInfo[];
42
+ }
43
+
44
+ export interface DeveloperModeData {
45
+ apps: AppInfo[];
46
+ libraries: LibraryInfo[];
47
+ database: DatabaseInfo;
48
+ git: GitInfo;
49
+ stats: ProjectStats;
50
+ }
51
+
52
+ interface DeveloperModeContextType {
53
+ data: DeveloperModeData | null;
54
+ isLoading: boolean;
55
+ error: Error | null;
56
+ }
57
+
58
+ const DeveloperModeContext = createContext<
59
+ DeveloperModeContextType | undefined
60
+ >(undefined);
61
+
62
+ export function DeveloperModeProvider({ children }: { children: ReactNode }) {
63
+ const { request } = useApp();
64
+
65
+ const { data, isLoading, error } = useQuery({
66
+ queryKey: ['developer-mode'],
67
+ queryFn: async () => {
68
+ const response = await request({
69
+ url: '/developer-mode',
70
+ method: 'GET',
71
+ });
72
+ return response.data as DeveloperModeData;
73
+ },
74
+ });
75
+
76
+ return (
77
+ <DeveloperModeContext.Provider
78
+ value={{ data: data || null, isLoading, error }}
79
+ >
80
+ {children}
81
+ </DeveloperModeContext.Provider>
82
+ );
83
+ }
84
+
85
+ export function useDeveloperMode() {
86
+ const context = useContext(DeveloperModeContext);
87
+ if (context === undefined) {
88
+ throw new Error(
89
+ 'useDeveloperMode must be used within a DeveloperModeProvider'
90
+ );
91
+ }
92
+ return context;
93
+ }
94
+
95
+ export type { AppInfo, CommitInfo, LibraryInfo };