@mostajs/setup 2.1.29 → 2.1.31
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.
|
@@ -9,8 +9,9 @@ import { runInstall } from '../lib/setup.js';
|
|
|
9
9
|
export function createInstallHandler(needsSetup, setupConfig) {
|
|
10
10
|
async function POST(req) {
|
|
11
11
|
const body = await req.json();
|
|
12
|
-
//
|
|
13
|
-
|
|
12
|
+
// In NET mode, skip needsSetup check — the admin may already exist from dashboard seed
|
|
13
|
+
// or from a previous partial install. The wizard controls the flow.
|
|
14
|
+
if (body.mode !== 'net' && !body.skipCheck && !(await needsSetup())) {
|
|
14
15
|
return Response.json({ ok: false, error: 'Installation deja effectuee' }, { status: 400 });
|
|
15
16
|
}
|
|
16
17
|
const result = await runInstall(body, setupConfig);
|
|
@@ -876,25 +876,34 @@ export default function SetupWizard({ t: tProp, onComplete, endpoints = {}, dbNa
|
|
|
876
876
|
setSchemaUploadStatus({ phase: `❌ ${err.message}`, color: '#dc2626' });
|
|
877
877
|
}
|
|
878
878
|
e.target.value = '';
|
|
879
|
-
} }), _jsx("span", { style: { fontSize: 12, color: schemaUploadStatus?.color || '#94a3b8' }, children: schemaUploadStatus?.phase || ((netTestResult.entities?.length ?? 0) > 0 ? `✅ ${netTestResult.entities.length} schemas` : 'Aucun schema') })] }), _jsxs("div", { style: { display: 'flex', gap: 8, alignItems: 'center', marginBottom: 12, flexWrap: 'wrap' }, children: [_jsx("span", { style: { fontSize: 13, fontWeight: 600, color: '#64748b', minWidth: 65 }, children: "Etape 2:" }), _jsx("button", { style: { ...S.btn('primary'), fontSize: 13, backgroundColor: '#
|
|
880
|
-
setSchemaUploadStatus({ phase: '
|
|
879
|
+
} }), _jsx("span", { style: { fontSize: 12, color: schemaUploadStatus?.color || '#94a3b8' }, children: schemaUploadStatus?.phase || ((netTestResult.entities?.length ?? 0) > 0 ? `✅ ${netTestResult.entities.length} schemas` : 'Aucun schema') })] }), _jsxs("div", { style: { display: 'flex', gap: 8, alignItems: 'center', marginBottom: 12, flexWrap: 'wrap' }, children: [_jsx("span", { style: { fontSize: 13, fontWeight: 600, color: '#64748b', minWidth: 65 }, children: "Etape 2:" }), _jsx("button", { style: { ...S.btn('primary'), fontSize: 13, backgroundColor: '#22c55e' }, disabled: (netTestResult.entities?.length ?? 0) === 0, onClick: async () => {
|
|
880
|
+
setSchemaUploadStatus({ phase: 'Enregistrement...', color: '#2563eb' });
|
|
881
881
|
try {
|
|
882
|
-
const res = await fetch(netUrl + '/api/
|
|
882
|
+
const res = await fetch(netUrl + '/api/save-config', { method: 'POST' });
|
|
883
883
|
const data = await res.json();
|
|
884
|
-
|
|
884
|
+
if (data.ok) {
|
|
885
|
+
setSchemaUploadStatus({ phase: '✅ Config enregistree', color: '#16a34a' });
|
|
886
|
+
setSchemasReady(true);
|
|
887
|
+
}
|
|
888
|
+
else {
|
|
889
|
+
setSchemaUploadStatus({ phase: `❌ ${data.error || data.message}`, color: '#dc2626' });
|
|
890
|
+
}
|
|
885
891
|
}
|
|
886
892
|
catch (err) {
|
|
887
893
|
setSchemaUploadStatus({ phase: `❌ ${err.message}`, color: '#dc2626' });
|
|
888
894
|
}
|
|
889
|
-
}, children: "
|
|
890
|
-
setSchemaUploadStatus({ phase: '
|
|
895
|
+
}, children: "Enregistrer la config" })] }), _jsxs("div", { style: { display: 'flex', gap: 8, alignItems: 'center', marginBottom: 8, flexWrap: 'wrap' }, children: [_jsx("span", { style: { fontSize: 13, fontWeight: 600, color: '#64748b', minWidth: 65 }, children: "Etape 3:" }), _jsx("button", { style: { ...S.btn('primary'), fontSize: 13, backgroundColor: '#f59e0b', color: '#000' }, disabled: (netTestResult.entities?.length ?? 0) === 0, onClick: async () => {
|
|
896
|
+
setSchemaUploadStatus({ phase: 'Application du schema...', color: '#2563eb' });
|
|
891
897
|
try {
|
|
892
|
-
const res = await fetch(netUrl + '/api/
|
|
898
|
+
const res = await fetch(netUrl + '/api/apply-schema', { method: 'POST' });
|
|
893
899
|
const data = await res.json();
|
|
894
900
|
if (data.ok) {
|
|
895
|
-
setSchemaUploadStatus({ phase:
|
|
901
|
+
setSchemaUploadStatus({ phase: `✅ ${data.message || 'Schema applique'}`, color: '#16a34a' });
|
|
896
902
|
setSchemasReady(true);
|
|
897
903
|
}
|
|
904
|
+
else if (data.needsCreateDb) {
|
|
905
|
+
setSchemaUploadStatus({ phase: `⚠️ ${data.error} — creez la base depuis le dashboard OctoNet`, color: '#d97706' });
|
|
906
|
+
}
|
|
898
907
|
else {
|
|
899
908
|
setSchemaUploadStatus({ phase: `❌ ${data.error || data.message}`, color: '#dc2626' });
|
|
900
909
|
}
|
|
@@ -902,7 +911,7 @@ export default function SetupWizard({ t: tProp, onComplete, endpoints = {}, dbNa
|
|
|
902
911
|
catch (err) {
|
|
903
912
|
setSchemaUploadStatus({ phase: `❌ ${err.message}`, color: '#dc2626' });
|
|
904
913
|
}
|
|
905
|
-
}, children: "
|
|
914
|
+
}, children: "Appliquer le schema" })] }), schemaUploadStatus && (_jsx("div", { style: { fontSize: 13, fontWeight: 500, color: schemaUploadStatus.color, marginTop: 4 }, children: schemaUploadStatus.phase }))] })), _jsxs("div", { style: S.navRow, children: [_jsxs("button", { style: S.btn('outline'), onClick: goBack, children: ["\u2190 ", t('setup.back')] }), _jsxs("button", { style: S.btn('primary', !canGoNext()), onClick: goNext, disabled: !canGoNext(), children: [t('setup.next'), " \u2192"] })] })] })), step === 'admin' && (_jsxs("div", { children: [_jsxs("div", { style: S.sectionHeader, children: [_jsx("span", { style: S.sectionIcon, children: "\uD83D\uDC64" }), _jsxs("div", { children: [_jsx("div", { style: S.sectionTitle, children: t('setup.admin.title') }), _jsx("div", { style: S.sectionDesc, children: t('setup.admin.description') })] })] }), _jsxs("div", { style: S.formRow, children: [_jsxs("div", { style: S.formGroup, children: [_jsx("label", { style: S.label, children: t('setup.admin.firstName') }), _jsx("input", { style: S.input, value: adminConfig.firstName, onChange: e => setAdminConfig({ ...adminConfig, firstName: e.target.value }) })] }), _jsxs("div", { style: S.formGroup, children: [_jsx("label", { style: S.label, children: t('setup.admin.lastName') }), _jsx("input", { style: S.input, value: adminConfig.lastName, onChange: e => setAdminConfig({ ...adminConfig, lastName: e.target.value }) })] })] }), _jsxs("div", { style: S.formGroup, children: [_jsx("label", { style: S.label, children: t('setup.admin.email') }), _jsx("input", { style: S.input, type: "email", value: adminConfig.email, onChange: e => setAdminConfig({ ...adminConfig, email: e.target.value }), placeholder: "admin@example.com" })] }), _jsxs("div", { style: S.formRow, children: [_jsxs("div", { style: S.formGroup, children: [_jsx("label", { style: S.label, children: t('setup.admin.password') }), _jsx("input", { style: S.input, type: "password", value: adminConfig.password, onChange: e => setAdminConfig({ ...adminConfig, password: e.target.value }) })] }), _jsxs("div", { style: S.formGroup, children: [_jsx("label", { style: S.label, children: t('setup.admin.confirmPassword') }), _jsx("input", { style: S.input, type: "password", value: adminConfig.confirmPassword, onChange: e => setAdminConfig({ ...adminConfig, confirmPassword: e.target.value }) })] })] }), adminConfig.password && adminConfig.confirmPassword && adminConfig.password !== adminConfig.confirmPassword && (_jsx("p", { style: { fontSize: 13, color: '#dc2626' }, children: t('setup.admin.passwordMismatch') })), setupMode === 'net' && (_jsxs("div", { style: { marginTop: 16, marginBottom: 16 }, children: [_jsx("button", { style: { ...S.btn('primary'), backgroundColor: '#16a34a' }, disabled: adminSaving || !adminConfig.email || !adminConfig.password || !adminConfig.firstName || adminConfig.password !== adminConfig.confirmPassword, onClick: async () => {
|
|
906
915
|
setAdminSaving(true);
|
|
907
916
|
setAdminSaveResult(null);
|
|
908
917
|
try {
|
package/package.json
CHANGED