@mostajs/setup 2.1.34 → 2.1.36
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.
|
@@ -15,8 +15,14 @@ export function createSetupJsonHandler(needsSetup) {
|
|
|
15
15
|
const setupJsonPath = () => path.resolve(process.cwd(), 'setup.json');
|
|
16
16
|
async function GET() {
|
|
17
17
|
const filePath = setupJsonPath();
|
|
18
|
+
// Always include env vars for NET config
|
|
19
|
+
const env = {
|
|
20
|
+
netUrl: process.env.MOSTA_NET_URL || '',
|
|
21
|
+
netTransport: process.env.MOSTA_NET_TRANSPORT || 'rest',
|
|
22
|
+
dataMode: process.env.MOSTA_DATA || '',
|
|
23
|
+
};
|
|
18
24
|
if (!fs.existsSync(filePath)) {
|
|
19
|
-
return Response.json({ exists: false });
|
|
25
|
+
return Response.json({ exists: false, env });
|
|
20
26
|
}
|
|
21
27
|
try {
|
|
22
28
|
const raw = fs.readFileSync(filePath, 'utf-8');
|
|
@@ -37,6 +43,7 @@ export function createSetupJsonHandler(needsSetup) {
|
|
|
37
43
|
})),
|
|
38
44
|
modules: json.modules ?? [],
|
|
39
45
|
},
|
|
46
|
+
env,
|
|
40
47
|
});
|
|
41
48
|
}
|
|
42
49
|
catch (err) {
|
|
@@ -379,6 +379,7 @@ export default function SetupWizard({ t: tProp, onComplete, endpoints = {}, dbNa
|
|
|
379
379
|
const [adminConfig, setAdminConfig] = useState({ firstName: '', lastName: '', email: '', password: '', confirmPassword: '' });
|
|
380
380
|
const [seedOptions, setSeedOptions] = useState({});
|
|
381
381
|
const [availableSeeds, setAvailableSeeds] = useState([]);
|
|
382
|
+
const [seedStatus, setSeedStatus] = useState({});
|
|
382
383
|
const [availableModules, setAvailableModules] = useState([]);
|
|
383
384
|
const [selectedModules, setSelectedModules] = useState([]);
|
|
384
385
|
const [detectedModules, setDetectedModules] = useState([]);
|
|
@@ -445,6 +446,13 @@ export default function SetupWizard({ t: tProp, onComplete, endpoints = {}, dbNa
|
|
|
445
446
|
fetch(ep.setupJson)
|
|
446
447
|
.then(r => r.json())
|
|
447
448
|
.then((data) => {
|
|
449
|
+
// Pre-fill NET URL from server env if not already set by props
|
|
450
|
+
if (data.env?.netUrl && netUrl === 'http://localhost:4488') {
|
|
451
|
+
setNetUrl(data.env.netUrl);
|
|
452
|
+
}
|
|
453
|
+
if (data.env?.netTransport && netTransport === 'rest') {
|
|
454
|
+
setNetTransport(data.env.netTransport);
|
|
455
|
+
}
|
|
448
456
|
const seeds = data.config?.seeds ?? [];
|
|
449
457
|
setAvailableSeeds(seeds);
|
|
450
458
|
// Initialize seedOptions from defaults
|
|
@@ -952,7 +960,49 @@ export default function SetupWizard({ t: tProp, onComplete, endpoints = {}, dbNa
|
|
|
952
960
|
fontSize: 12, backgroundColor: '#f0f9ff', color: '#0369a1',
|
|
953
961
|
border: '1px solid #bae6fd', borderRadius: 16, padding: '4px 10px',
|
|
954
962
|
}, children: [mod.icon, " ", mod.label] }, key)) : null;
|
|
955
|
-
}) })] }), availableSeeds.length > 0 && (_jsxs("div", { style: S.summaryCard, children: [_jsx("div", { style: S.summaryTitle, children: t('setup.summary.seedTitle') }), _jsx("p", { style: { ...S.summaryText, marginBottom: 12 }, children: t('setup.summary.seedInfo') }), availableSeeds.map(seed => (_jsxs("div", { style: S.checkRow, children: [_jsx("input", { type: "checkbox", style: S.checkbox, checked: seedOptions[seed.key] ?? false, onChange: e => setSeedOptions({ ...seedOptions, [seed.key]: e.target.checked }), disabled: installing || !!installResult?.ok }), _jsxs("div", {
|
|
963
|
+
}) })] }), availableSeeds.length > 0 && (_jsxs("div", { style: S.summaryCard, children: [_jsx("div", { style: S.summaryTitle, children: t('setup.summary.seedTitle') }), _jsx("p", { style: { ...S.summaryText, marginBottom: 12 }, children: t('setup.summary.seedInfo') }), availableSeeds.map(seed => (_jsxs("div", { style: { ...S.checkRow, alignItems: 'center' }, children: [_jsx("input", { type: "checkbox", style: S.checkbox, checked: seedOptions[seed.key] ?? false, onChange: e => setSeedOptions({ ...seedOptions, [seed.key]: e.target.checked }), disabled: installing || !!installResult?.ok }), _jsxs("div", { style: { flex: 1 }, children: [_jsx("div", { style: { fontSize: 13, fontWeight: 500 }, children: seed.label }), _jsx("div", { style: { fontSize: 12, color: '#9ca3af' }, children: seed.description })] }), setupMode === 'net' && (_jsxs("div", { style: { display: 'flex', alignItems: 'center', gap: 6 }, children: [_jsx("button", { style: {
|
|
964
|
+
padding: '3px 10px', borderRadius: 4, border: 'none', cursor: 'pointer',
|
|
965
|
+
fontSize: 12, fontWeight: 600,
|
|
966
|
+
backgroundColor: seedStatus[seed.key]?.ok ? '#d1fae5' : '#6366f1',
|
|
967
|
+
color: seedStatus[seed.key]?.ok ? '#065f46' : '#fff',
|
|
968
|
+
opacity: seedStatus[seed.key]?.sending ? 0.6 : 1,
|
|
969
|
+
}, disabled: seedStatus[seed.key]?.sending || !netUrl, onClick: async () => {
|
|
970
|
+
setSeedStatus(prev => ({ ...prev, [seed.key]: { sending: true } }));
|
|
971
|
+
try {
|
|
972
|
+
// Fetch the full seed definition from setup.json
|
|
973
|
+
const sjRes = await fetch(ep.setupJson);
|
|
974
|
+
const sjData = await sjRes.json();
|
|
975
|
+
const setupJson = sjData.config ? sjData : null;
|
|
976
|
+
// Find the seed in the raw setup.json
|
|
977
|
+
const rawRes = await fetch('/setup.json');
|
|
978
|
+
const rawJson = await rawRes.json();
|
|
979
|
+
const seedDef = (rawJson.seeds || []).find((s) => s.key === seed.key);
|
|
980
|
+
if (!seedDef) {
|
|
981
|
+
setSeedStatus(prev => ({ ...prev, [seed.key]: { sending: false, result: 'Seed non trouve dans setup.json', ok: false } }));
|
|
982
|
+
return;
|
|
983
|
+
}
|
|
984
|
+
// Send as seed-file format with just this one seed
|
|
985
|
+
const payload = { seeds: [seedDef] };
|
|
986
|
+
// Include RBAC if this is the first seed (roles/permissions needed)
|
|
987
|
+
if (rawJson.rbac)
|
|
988
|
+
payload.rbac = rawJson.rbac;
|
|
989
|
+
const res = await fetch(netUrl + '/api/seed-file', {
|
|
990
|
+
method: 'POST',
|
|
991
|
+
headers: { 'Content-Type': 'application/json' },
|
|
992
|
+
body: JSON.stringify(payload),
|
|
993
|
+
});
|
|
994
|
+
const data = await res.json();
|
|
995
|
+
if (data.ok) {
|
|
996
|
+
setSeedStatus(prev => ({ ...prev, [seed.key]: { sending: false, result: data.message, ok: true } }));
|
|
997
|
+
}
|
|
998
|
+
else {
|
|
999
|
+
setSeedStatus(prev => ({ ...prev, [seed.key]: { sending: false, result: data.error || 'Erreur', ok: false } }));
|
|
1000
|
+
}
|
|
1001
|
+
}
|
|
1002
|
+
catch (err) {
|
|
1003
|
+
setSeedStatus(prev => ({ ...prev, [seed.key]: { sending: false, result: err.message, ok: false } }));
|
|
1004
|
+
}
|
|
1005
|
+
}, children: seedStatus[seed.key]?.sending ? '...' : seedStatus[seed.key]?.ok ? '✓' : 'Envoyer' }), seedStatus[seed.key]?.result && (_jsx("span", { style: { fontSize: 11, color: seedStatus[seed.key]?.ok ? '#059669' : '#dc2626' }, children: seedStatus[seed.key]?.result }))] }))] }, seed.key)))] })), installResult && (_jsx("div", { style: S.alert(installResult.ok ? 'success' : 'error'), children: installResult.ok ? (_jsxs(_Fragment, { children: [_jsxs("div", { style: { fontWeight: 600, marginBottom: 4 }, children: ["\u2705 ", t('setup.summary.success')] }), _jsx("div", { children: t('setup.summary.successDesc') }), installResult.needsRestart && (_jsx("div", { style: { color: '#92400e', fontWeight: 500, marginTop: 8 }, children: t('setup.summary.needsRestart') }))] })) : (_jsxs("div", { children: ["\u274C ", installResult.error] })) })), installResult?.ok && (_jsxs("div", { style: { ...S.summaryCard, marginTop: 16 }, children: [_jsxs("div", { style: { display: 'flex', alignItems: 'center', gap: 8, marginBottom: 12 }, children: [_jsx("span", { style: { fontSize: 18 }, children: "\uD83D\uDD0C" }), _jsx("div", { style: S.summaryTitle, children: "Cablage des modules" })] }), _jsx("div", { style: { fontSize: 13, color: '#6b7280', marginBottom: 12 }, children: "Cablez les modules pour injecter schemas, routes API, pages et permissions dans l'application." }), wireMessage && (_jsx("div", { style: S.alert(wireMessage.type), children: wireMessage.text })), wireLoading ? (_jsx("div", { style: { textAlign: 'center', padding: 12, color: '#6b7280' }, children: "Chargement..." })) : wireModules.length === 0 ? (_jsx("div", { style: { textAlign: 'center', padding: 12, color: '#9ca3af' }, children: "Aucun manifeste de cablage trouve" })) : (_jsx("div", { style: S.wireGrid, children: wireModules.map((mod) => (_jsxs("div", { style: S.wireCard(mod.installed), children: [_jsxs("div", { style: { display: 'flex', alignItems: 'center', justifyContent: 'space-between' }, children: [_jsxs("div", { style: { display: 'flex', alignItems: 'center', gap: 8 }, children: [_jsx("span", { style: S.wireStatus(mod.installed) }), _jsxs("span", { style: { fontWeight: 700, fontSize: 14 }, children: ["@mostajs/", mod.name] })] }), _jsx("span", { style: {
|
|
956
1006
|
fontSize: 10, fontWeight: 600, padding: '2px 6px', borderRadius: 4,
|
|
957
1007
|
backgroundColor: mod.type === 'business' ? '#dbeafe' : '#f3e8ff',
|
|
958
1008
|
color: mod.type === 'business' ? '#1e40af' : '#6b21a8',
|
package/package.json
CHANGED