@promakeai/cli 0.9.15 → 0.10.1
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.
- package/README.md +111 -111
- package/dist/index.js +142 -142
- package/dist/registry/about-page.json +3 -3
- package/dist/registry/about-section.json +4 -4
- package/dist/registry/animations.json +2 -2
- package/dist/registry/announcement-bar.json +4 -4
- package/dist/registry/api.json +1 -1
- package/dist/registry/auth-core.json +2 -2
- package/dist/registry/bento-grid-section.json +4 -4
- package/dist/registry/blog-core.json +5 -5
- package/dist/registry/blog-list-page.json +4 -4
- package/dist/registry/blog-section.json +4 -4
- package/dist/registry/cards-carousel-section.json +4 -4
- package/dist/registry/cart-drawer.json +4 -4
- package/dist/registry/cart-page.json +4 -4
- package/dist/registry/case-study-page.json +3 -3
- package/dist/registry/category-section.json +4 -4
- package/dist/registry/checkout-page.json +4 -4
- package/dist/registry/coming-soon-page-minimal.json +4 -4
- package/dist/registry/coming-soon-page.json +4 -4
- package/dist/registry/contact-info-grid.json +4 -4
- package/dist/registry/contact-page-centered.json +4 -4
- package/dist/registry/contact-page-map-overlay.json +3 -3
- package/dist/registry/contact-page-map-split.json +3 -3
- package/dist/registry/contact-page-split.json +4 -4
- package/dist/registry/contact-page.json +4 -4
- package/dist/registry/content-section.json +4 -4
- package/dist/registry/cookie-consent.json +4 -4
- package/dist/registry/cookies-page.json +3 -3
- package/dist/registry/cta-section.json +3 -3
- package/dist/registry/ecommerce-core.json +8 -8
- package/dist/registry/empty-page.json +3 -3
- package/dist/registry/faq-categorized.json +4 -4
- package/dist/registry/faq-simple.json +4 -4
- package/dist/registry/favorites-blog-block.json +1 -1
- package/dist/registry/favorites-blog-page.json +4 -4
- package/dist/registry/favorites-ecommerce-block.json +1 -1
- package/dist/registry/favorites-ecommerce-page.json +4 -4
- package/dist/registry/feature-section.json +3 -3
- package/dist/registry/featured-products.json +4 -4
- package/dist/registry/footer-detailed.json +4 -4
- package/dist/registry/footer-minimal.json +3 -3
- package/dist/registry/footer.json +3 -3
- package/dist/registry/forgot-password-page-split.json +4 -4
- package/dist/registry/forgot-password-page.json +4 -4
- package/dist/registry/google-adsense.json +4 -4
- package/dist/registry/google-map.json +2 -2
- package/dist/registry/header-centered-pill.json +4 -4
- package/dist/registry/header-ecommerce.json +4 -4
- package/dist/registry/header-mega.json +4 -4
- package/dist/registry/header-minimal.json +4 -4
- package/dist/registry/header-simple.json +3 -3
- package/dist/registry/hero-carousel.json +3 -3
- package/dist/registry/hero-cta.json +4 -4
- package/dist/registry/hero-gradient.json +4 -4
- package/dist/registry/hero-grid.json +4 -4
- package/dist/registry/hero-profile.json +3 -3
- package/dist/registry/hero.json +3 -3
- package/dist/registry/index.json +103 -103
- package/dist/registry/landing-page-app.json +3 -3
- package/dist/registry/landing-page-saas.json +3 -3
- package/dist/registry/login-page-split.json +4 -4
- package/dist/registry/login-page.json +4 -4
- package/dist/registry/logo-cloud.json +4 -4
- package/dist/registry/masonry-grid.json +3 -3
- package/dist/registry/my-orders-page.json +4 -4
- package/dist/registry/newsletter-section.json +4 -4
- package/dist/registry/order-card-compact.json +3 -3
- package/dist/registry/order-confirmation-page.json +4 -4
- package/dist/registry/order-detail-block.json +1 -1
- package/dist/registry/orders-list-block.json +1 -1
- package/dist/registry/payment-success-block.json +2 -2
- package/dist/registry/portfolio-page.json +4 -4
- package/dist/registry/post-card.json +4 -4
- package/dist/registry/post-detail-block.json +4 -4
- package/dist/registry/post-detail-page.json +4 -4
- package/dist/registry/pricing-card.json +3 -3
- package/dist/registry/pricing-page.json +4 -4
- package/dist/registry/pricing-section.json +4 -4
- package/dist/registry/privacy-page.json +3 -3
- package/dist/registry/product-card-detailed.json +4 -4
- package/dist/registry/product-card-hover.json +4 -4
- package/dist/registry/product-card.json +4 -4
- package/dist/registry/product-detail-block.json +2 -2
- package/dist/registry/product-detail-page.json +4 -4
- package/dist/registry/product-detail-section.json +4 -4
- package/dist/registry/product-quick-view.json +4 -4
- package/dist/registry/products-page.json +4 -4
- package/dist/registry/reading-progress.json +4 -4
- package/dist/registry/register-page-split.json +4 -4
- package/dist/registry/register-page.json +4 -4
- package/dist/registry/related-posts-block.json +1 -1
- package/dist/registry/related-products-block.json +2 -2
- package/dist/registry/reset-password-page-split.json +4 -4
- package/dist/registry/reset-password-page.json +4 -4
- package/dist/registry/service-card.json +1 -1
- package/dist/registry/share-buttons.json +4 -4
- package/dist/registry/skill-card.json +1 -1
- package/dist/registry/team-page.json +4 -4
- package/dist/registry/terms-page.json +3 -3
- package/dist/registry/testimonials-carousel.json +4 -4
- package/dist/registry/testimonials-grid.json +4 -4
- package/dist/registry/timeline-section.json +4 -4
- package/dist/registry/verify-email-page.json +4 -4
- package/dist/registry/video-hero.json +4 -4
- package/dist/registry/youtube-embed.json +4 -4
- package/package.json +58 -58
- package/template/.env +5 -5
- package/template/README.md +54 -54
- package/template/eslint.config.js +41 -41
- package/template/index.html +237 -237
- package/template/package.json +96 -96
- package/template/public/_redirects +1 -1
- package/template/public/robots.txt +14 -14
- package/template/scripts/init-db.ts +18 -18
- package/template/src/App.tsx +21 -21
- package/template/src/components/FormField.tsx +48 -48
- package/template/src/components/FormFileInput.tsx +75 -75
- package/template/src/components/GoogleAnalytics.tsx +34 -34
- package/template/src/components/LanguageSwitcher.tsx +53 -53
- package/template/src/components/MetriaAnalytics.tsx +68 -68
- package/template/src/components/PasswordInput.tsx +60 -60
- package/template/src/components/ScriptInjector.tsx +62 -62
- package/template/src/components/Stack.tsx +39 -39
- package/template/src/constants/constants.json +71 -71
- package/template/src/db/index.ts +21 -21
- package/template/src/db/provider.tsx +152 -114
- package/template/src/db/schema.json +278 -278
- package/template/src/db/types.ts +195 -195
- package/template/src/hooks/use-debounced-value.ts +12 -12
- package/template/src/hooks/use-page-title.ts +55 -55
- package/template/src/lang/index.ts +90 -90
- package/template/src/lib/api.ts +345 -345
- package/template/src/lib/env.ts +19 -19
- package/template/src/router.tsx +14 -14
- package/template/src/vite-env.d.ts +1 -1
- package/template/vite.config.ts +225 -243
package/template/src/lib/env.ts
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
// Environment değişkenlerini window'a export et
|
|
2
|
-
declare global {
|
|
3
|
-
interface Window {
|
|
4
|
-
ENV: {
|
|
5
|
-
[key: string]: any;
|
|
6
|
-
};
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
window.ENV = {
|
|
11
|
-
...Object.keys(import.meta.env)
|
|
12
|
-
.filter((key) => key.startsWith('VITE_'))
|
|
13
|
-
.reduce(
|
|
14
|
-
(acc, key) => ({
|
|
15
|
-
...acc,
|
|
16
|
-
[key]: import.meta.env[key],
|
|
17
|
-
}),
|
|
18
|
-
{},
|
|
19
|
-
),
|
|
1
|
+
// Environment değişkenlerini window'a export et
|
|
2
|
+
declare global {
|
|
3
|
+
interface Window {
|
|
4
|
+
ENV: {
|
|
5
|
+
[key: string]: any;
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
window.ENV = {
|
|
11
|
+
...Object.keys(import.meta.env)
|
|
12
|
+
.filter((key) => key.startsWith('VITE_'))
|
|
13
|
+
.reduce(
|
|
14
|
+
(acc, key) => ({
|
|
15
|
+
...acc,
|
|
16
|
+
[key]: import.meta.env[key],
|
|
17
|
+
}),
|
|
18
|
+
{},
|
|
19
|
+
),
|
|
20
20
|
};
|
package/template/src/router.tsx
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { BrowserRouter, Routes, Route } from "react-router";
|
|
2
|
-
import Index from "./pages/Index";
|
|
3
|
-
import NotFound from "./pages/NotFound";
|
|
4
|
-
|
|
5
|
-
export const Router = () => {
|
|
6
|
-
return (
|
|
7
|
-
<BrowserRouter>
|
|
8
|
-
<Routes>
|
|
9
|
-
<Route path="/" element={<Index />} />
|
|
10
|
-
<Route path="*" element={<NotFound />} />
|
|
11
|
-
</Routes>
|
|
12
|
-
</BrowserRouter>
|
|
13
|
-
);
|
|
14
|
-
};
|
|
1
|
+
import { BrowserRouter, Routes, Route } from "react-router";
|
|
2
|
+
import Index from "./pages/Index";
|
|
3
|
+
import NotFound from "./pages/NotFound";
|
|
4
|
+
|
|
5
|
+
export const Router = () => {
|
|
6
|
+
return (
|
|
7
|
+
<BrowserRouter>
|
|
8
|
+
<Routes>
|
|
9
|
+
<Route path="/" element={<Index />} />
|
|
10
|
+
<Route path="*" element={<NotFound />} />
|
|
11
|
+
</Routes>
|
|
12
|
+
</BrowserRouter>
|
|
13
|
+
);
|
|
14
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
/// <reference types="vite/client" />
|
|
1
|
+
/// <reference types="vite/client" />
|
package/template/vite.config.ts
CHANGED
|
@@ -1,243 +1,225 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
|
-
import { createRequire } from 'module';
|
|
3
|
-
import path from 'path';
|
|
4
|
-
import { execSync } from 'child_process';
|
|
5
|
-
import tailwindcss from '@tailwindcss/vite';
|
|
6
|
-
import react from '@vitejs/plugin-react';
|
|
7
|
-
import type { Connect } from 'vite';
|
|
8
|
-
import { defineConfig, loadEnv, type Plugin } from 'vite';
|
|
9
|
-
import { inspectorDebugger } from '@promakeai/inspector/plugin';
|
|
10
|
-
import type { IncomingMessage } from 'http';
|
|
11
|
-
|
|
12
|
-
// Plugin: Restart dev server when lang files are added or changed
|
|
13
|
-
function langWatchPlugin(): Plugin {
|
|
14
|
-
return {
|
|
15
|
-
name: 'lang-watch',
|
|
16
|
-
configureServer(server) {
|
|
17
|
-
const handleLangFile = (file: string, event: string) => {
|
|
18
|
-
const normalizedPath = file.replace(/\\/g, '/');
|
|
19
|
-
const isModuleLang = normalizedPath.includes('/modules/') && normalizedPath.includes('/lang/');
|
|
20
|
-
const isGlobalLang = normalizedPath.includes('/src/lang/');
|
|
21
|
-
|
|
22
|
-
if ((isModuleLang || isGlobalLang) && file.endsWith('.json')) {
|
|
23
|
-
const label = event === 'add' ? 'New translation file detected' : 'Translation file changed';
|
|
24
|
-
console.log(`\n🌐 ${label}!`);
|
|
25
|
-
console.log('🔄 Restarting server to load translations...\n');
|
|
26
|
-
server.restart();
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
server.watcher.on('add', (file) => handleLangFile(file, 'add'));
|
|
31
|
-
server.watcher.on('change', (file) => handleLangFile(file, 'change'));
|
|
32
|
-
},
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
//
|
|
37
|
-
function
|
|
38
|
-
return {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
},
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
interval: 500,
|
|
227
|
-
},
|
|
228
|
-
headers: {
|
|
229
|
-
'Cache-Control': 'no-cache, no-store, must-revalidate',
|
|
230
|
-
},
|
|
231
|
-
},
|
|
232
|
-
preview: {
|
|
233
|
-
port: 4173,
|
|
234
|
-
},
|
|
235
|
-
build: {
|
|
236
|
-
rollupOptions: {
|
|
237
|
-
output: {
|
|
238
|
-
manualChunks: undefined,
|
|
239
|
-
},
|
|
240
|
-
},
|
|
241
|
-
},
|
|
242
|
-
};
|
|
243
|
-
});
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import { createRequire } from 'module';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import { execSync } from 'child_process';
|
|
5
|
+
import tailwindcss from '@tailwindcss/vite';
|
|
6
|
+
import react from '@vitejs/plugin-react';
|
|
7
|
+
import type { Connect } from 'vite';
|
|
8
|
+
import { defineConfig, loadEnv, type Plugin } from 'vite';
|
|
9
|
+
import { inspectorDebugger } from '@promakeai/inspector/plugin';
|
|
10
|
+
import type { IncomingMessage } from 'http';
|
|
11
|
+
|
|
12
|
+
// Plugin: Restart dev server when lang files are added or changed
|
|
13
|
+
function langWatchPlugin(): Plugin {
|
|
14
|
+
return {
|
|
15
|
+
name: 'lang-watch',
|
|
16
|
+
configureServer(server) {
|
|
17
|
+
const handleLangFile = (file: string, event: string) => {
|
|
18
|
+
const normalizedPath = file.replace(/\\/g, '/');
|
|
19
|
+
const isModuleLang = normalizedPath.includes('/modules/') && normalizedPath.includes('/lang/');
|
|
20
|
+
const isGlobalLang = normalizedPath.includes('/src/lang/');
|
|
21
|
+
|
|
22
|
+
if ((isModuleLang || isGlobalLang) && file.endsWith('.json')) {
|
|
23
|
+
const label = event === 'add' ? 'New translation file detected' : 'Translation file changed';
|
|
24
|
+
console.log(`\n🌐 ${label}!`);
|
|
25
|
+
console.log('🔄 Restarting server to load translations...\n');
|
|
26
|
+
server.restart();
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
server.watcher.on('add', (file) => handleLangFile(file, 'add'));
|
|
31
|
+
server.watcher.on('change', (file) => handleLangFile(file, 'change'));
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// Helper: Read request body
|
|
37
|
+
function readBody(req: IncomingMessage): Promise<string> {
|
|
38
|
+
return new Promise((resolve) => {
|
|
39
|
+
let data = '';
|
|
40
|
+
req.on('data', (chunk: string) => (data += chunk));
|
|
41
|
+
req.on('end', () => resolve(data));
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// Plugin: Expose API for running promake commands from the panel
|
|
46
|
+
function promakeApiPlugin(secret?: string): Plugin {
|
|
47
|
+
const ALLOWED_COMMANDS = ['seo', 'theme'];
|
|
48
|
+
const BASE_PATH = secret ? `/__promake/${secret}` : '/__promake';
|
|
49
|
+
|
|
50
|
+
const handler: Connect.NextHandleFunction = async (req, res, next) => {
|
|
51
|
+
const rawUrl = req.url || '';
|
|
52
|
+
const [pathname, queryString] = rawUrl.split('?');
|
|
53
|
+
if (!pathname.startsWith(`${BASE_PATH}/run`)) {
|
|
54
|
+
next();
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
const origin = req.headers.origin || '*';
|
|
58
|
+
res.setHeader('Access-Control-Allow-Origin', origin);
|
|
59
|
+
res.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS');
|
|
60
|
+
res.setHeader('Access-Control-Allow-Headers', 'Content-Type, Authorization, X-Requested-With, Accept, Origin');
|
|
61
|
+
res.setHeader('Access-Control-Allow-Credentials', 'true');
|
|
62
|
+
res.setHeader('Access-Control-Max-Age', '86400');
|
|
63
|
+
|
|
64
|
+
if (req.method === 'OPTIONS') {
|
|
65
|
+
res.statusCode = 204;
|
|
66
|
+
res.end();
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
try {
|
|
71
|
+
let command: string;
|
|
72
|
+
let args: string[] = [];
|
|
73
|
+
|
|
74
|
+
if (req.method === 'GET') {
|
|
75
|
+
const params = new URLSearchParams(queryString || '');
|
|
76
|
+
command = params.get('command') || '';
|
|
77
|
+
const argsParam = params.get('args');
|
|
78
|
+
if (argsParam) {
|
|
79
|
+
try { args = JSON.parse(argsParam); } catch { args = []; }
|
|
80
|
+
}
|
|
81
|
+
} else if (req.method === 'POST') {
|
|
82
|
+
const body = await readBody(req);
|
|
83
|
+
const parsed = JSON.parse(body);
|
|
84
|
+
command = parsed.command;
|
|
85
|
+
args = parsed.args || [];
|
|
86
|
+
} else {
|
|
87
|
+
res.statusCode = 405;
|
|
88
|
+
res.end();
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if (!ALLOWED_COMMANDS.includes(command)) {
|
|
93
|
+
res.statusCode = 400;
|
|
94
|
+
res.setHeader('Content-Type', 'application/json');
|
|
95
|
+
res.end(JSON.stringify({ error: `Command not allowed: ${command}` }));
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const safeArgs = args.map((a: string) => `'${a.replace(/'/g, "'\\''")}'`).join(' ');
|
|
100
|
+
const output = execSync(`promake ${command} ${safeArgs}`, {
|
|
101
|
+
cwd: process.cwd(),
|
|
102
|
+
encoding: 'utf-8',
|
|
103
|
+
timeout: 15000,
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
res.setHeader('Content-Type', 'application/json');
|
|
107
|
+
res.end(JSON.stringify({ ok: true, output }));
|
|
108
|
+
} catch (e: any) {
|
|
109
|
+
res.statusCode = 500;
|
|
110
|
+
res.setHeader('Content-Type', 'application/json');
|
|
111
|
+
res.end(JSON.stringify({ ok: false, error: e.message }));
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
return {
|
|
116
|
+
name: 'promake-api',
|
|
117
|
+
configureServer(server) {
|
|
118
|
+
server.middlewares.use(handler);
|
|
119
|
+
},
|
|
120
|
+
configurePreviewServer(server) {
|
|
121
|
+
server.middlewares.use(handler);
|
|
122
|
+
},
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// Plugin: Write installed package versions to src/constants/versions.json on dev server start
|
|
127
|
+
function packageVersionsPlugin(): Plugin {
|
|
128
|
+
return {
|
|
129
|
+
name: 'package-versions',
|
|
130
|
+
configureServer() {
|
|
131
|
+
const root = process.cwd();
|
|
132
|
+
const pkgJsonPath = path.join(root, 'package.json');
|
|
133
|
+
|
|
134
|
+
if (!fs.existsSync(pkgJsonPath)) return;
|
|
135
|
+
|
|
136
|
+
const pkgJson = JSON.parse(fs.readFileSync(pkgJsonPath, 'utf-8'));
|
|
137
|
+
|
|
138
|
+
const require = createRequire(pkgJsonPath);
|
|
139
|
+
|
|
140
|
+
const resolveVersions = (deps: Record<string, string> | undefined): Record<string, string> => {
|
|
141
|
+
if (!deps) return {};
|
|
142
|
+
const resolved: Record<string, string> = {};
|
|
143
|
+
for (const name of Object.keys(deps)) {
|
|
144
|
+
if (!name.startsWith('@promakeai/')) continue;
|
|
145
|
+
try {
|
|
146
|
+
const depPkgPath = require.resolve(`${name}/package.json`);
|
|
147
|
+
const depPkg = JSON.parse(fs.readFileSync(depPkgPath, 'utf-8'));
|
|
148
|
+
resolved[name] = depPkg.version;
|
|
149
|
+
} catch {
|
|
150
|
+
resolved[name] = deps[name];
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
return resolved;
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
const versions = {
|
|
157
|
+
generatedAt: new Date().toISOString(),
|
|
158
|
+
packages: {
|
|
159
|
+
...resolveVersions(pkgJson.dependencies),
|
|
160
|
+
...resolveVersions(pkgJson.devDependencies),
|
|
161
|
+
},
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
const outPath = path.join(root, 'versions.json');
|
|
165
|
+
fs.writeFileSync(outPath, JSON.stringify(versions, null, 2) + '\n');
|
|
166
|
+
console.log(`📦 Package versions written to versions.json`);
|
|
167
|
+
},
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// https://vite.dev/config/
|
|
172
|
+
export default defineConfig(({ mode }) => {
|
|
173
|
+
const env = loadEnv(mode, process.cwd(), 'PROMAKE_');
|
|
174
|
+
|
|
175
|
+
return {
|
|
176
|
+
cacheDir: '/tmp/.vite-cache',
|
|
177
|
+
optimizeDeps: {
|
|
178
|
+
force: true,
|
|
179
|
+
},
|
|
180
|
+
plugins: [
|
|
181
|
+
inspectorDebugger({ enabled: mode === 'development' }),
|
|
182
|
+
react(),
|
|
183
|
+
tailwindcss(),
|
|
184
|
+
mode === 'development' && langWatchPlugin(),
|
|
185
|
+
mode === 'development' && promakeApiPlugin(env.PROMAKE_SECRET),
|
|
186
|
+
mode === 'development' && packageVersionsPlugin(),
|
|
187
|
+
].filter(Boolean),
|
|
188
|
+
resolve: {
|
|
189
|
+
alias: {
|
|
190
|
+
'@': path.resolve(__dirname, './src'),
|
|
191
|
+
},
|
|
192
|
+
preserveSymlinks: true,
|
|
193
|
+
},
|
|
194
|
+
server: {
|
|
195
|
+
fs: {
|
|
196
|
+
allow: ['/shared'],
|
|
197
|
+
},
|
|
198
|
+
cors: {
|
|
199
|
+
preflightContinue: true,
|
|
200
|
+
origin: true,
|
|
201
|
+
},
|
|
202
|
+
host: '0.0.0.0',
|
|
203
|
+
allowedHosts: true,
|
|
204
|
+
hmr: false,
|
|
205
|
+
port: 5174,
|
|
206
|
+
watch: {
|
|
207
|
+
usePolling: true,
|
|
208
|
+
interval: 500,
|
|
209
|
+
},
|
|
210
|
+
headers: {
|
|
211
|
+
'Cache-Control': 'no-cache, no-store, must-revalidate',
|
|
212
|
+
},
|
|
213
|
+
},
|
|
214
|
+
preview: {
|
|
215
|
+
port: 4173,
|
|
216
|
+
},
|
|
217
|
+
build: {
|
|
218
|
+
rollupOptions: {
|
|
219
|
+
output: {
|
|
220
|
+
manualChunks: undefined,
|
|
221
|
+
},
|
|
222
|
+
},
|
|
223
|
+
},
|
|
224
|
+
};
|
|
225
|
+
});
|