@jsonpages/cli 3.0.50 β 3.0.52
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/assets/src_tenant_alpha.sh +33 -33
- package/package.json +1 -1
|
@@ -53,6 +53,7 @@ import tenantCss from './index.css?inline';
|
|
|
53
53
|
// Cloud Configuration (Injected by Vercel/Netlify Env Vars)
|
|
54
54
|
const CLOUD_API_URL = import.meta.env.VITE_JSONPAGES_CLOUD_URL;
|
|
55
55
|
const CLOUD_API_KEY = import.meta.env.VITE_JSONPAGES_API_KEY;
|
|
56
|
+
const CLOUD_SAVE_ENABLED = Boolean(CLOUD_API_URL && CLOUD_API_KEY);
|
|
56
57
|
|
|
57
58
|
const themeConfig = themeData as unknown as ThemeConfig;
|
|
58
59
|
const menuConfig = menuData as unknown as MenuConfig;
|
|
@@ -78,11 +79,7 @@ function App() {
|
|
|
78
79
|
.then((list: LibraryImageEntry[]) => setAssetsManifest(Array.isArray(list) ? list : []))
|
|
79
80
|
.catch(() => setAssetsManifest([]));
|
|
80
81
|
}, []);
|
|
81
|
-
|
|
82
|
-
console.log("π DEBUG ENV:", {
|
|
83
|
-
URL: import.meta.env.VITE_JSONPAGES_CLOUD_URL,
|
|
84
|
-
KEY: import.meta.env.VITE_JSONPAGES_API_KEY ? "PRESENT" : "MISSING"
|
|
85
|
-
});
|
|
82
|
+
|
|
86
83
|
const config: JsonPagesConfig = {
|
|
87
84
|
tenantId: TENANT_ID,
|
|
88
85
|
registry: ComponentRegistry as JsonPagesConfig['registry'],
|
|
@@ -95,34 +92,7 @@ console.log("π DEBUG ENV:", {
|
|
|
95
92
|
addSection: addSectionConfig,
|
|
96
93
|
persistence: {
|
|
97
94
|
async saveToFile(state: ProjectState, slug: string): Promise<void> {
|
|
98
|
-
|
|
99
|
-
// βοΈ SCENARIO A: CLOUD BRIDGE (Production)
|
|
100
|
-
if (CLOUD_API_URL && CLOUD_API_KEY) {
|
|
101
|
-
console.log(`βοΈ Saving ${slug} via Cloud Bridge...`);
|
|
102
|
-
|
|
103
|
-
const res = await fetch(`${CLOUD_API_URL}/save`, {
|
|
104
|
-
method: 'POST',
|
|
105
|
-
headers: {
|
|
106
|
-
'Content-Type': 'application/json',
|
|
107
|
-
'Authorization': `Bearer ${CLOUD_API_KEY}`
|
|
108
|
-
},
|
|
109
|
-
body: JSON.stringify({
|
|
110
|
-
// Mapping logical slug to physical path in repo
|
|
111
|
-
path: `src/data/pages/${slug}.json`,
|
|
112
|
-
// We save the page config specifically
|
|
113
|
-
content: state.page,
|
|
114
|
-
message: `Content update for ${slug} via Visual Editor`
|
|
115
|
-
}),
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
if (!res.ok) {
|
|
119
|
-
const err = await res.json().catch(() => ({}));
|
|
120
|
-
throw new Error(err.error || `Cloud save failed: ${res.status}`);
|
|
121
|
-
}
|
|
122
|
-
return;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
// π» SCENARIO B: LOCAL FILESYSTEM (Development)
|
|
95
|
+
// Local only (cloud uses saveToFileStream and Coreβs SaveProgressDrawer)
|
|
126
96
|
console.log(`π» Saving ${slug} to Local Filesystem...`);
|
|
127
97
|
const res = await fetch('/api/save-to-file', {
|
|
128
98
|
method: 'POST',
|
|
@@ -133,6 +103,36 @@ console.log("π DEBUG ENV:", {
|
|
|
133
103
|
const body = (await res.json().catch(() => ({}))) as { error?: string };
|
|
134
104
|
if (!res.ok) throw new Error(body.error ?? `Save to file failed: ${res.status}`);
|
|
135
105
|
},
|
|
106
|
+
...(CLOUD_SAVE_ENABLED
|
|
107
|
+
? {
|
|
108
|
+
saveToFileStream: async (state: ProjectState, slug: string): Promise<Response> => {
|
|
109
|
+
const url = `${CLOUD_API_URL}/save-stream`;
|
|
110
|
+
try {
|
|
111
|
+
const res = await fetch(url, {
|
|
112
|
+
method: 'POST',
|
|
113
|
+
headers: {
|
|
114
|
+
'Content-Type': 'application/json',
|
|
115
|
+
Authorization: `Bearer ${CLOUD_API_KEY}`,
|
|
116
|
+
},
|
|
117
|
+
body: JSON.stringify({
|
|
118
|
+
path: `src/data/pages/${slug}.json`,
|
|
119
|
+
content: state.page,
|
|
120
|
+
message: `Content update for ${slug} via Visual Editor`,
|
|
121
|
+
}),
|
|
122
|
+
});
|
|
123
|
+
return res;
|
|
124
|
+
} catch (err) {
|
|
125
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
126
|
+
if (/fetch|network|Failed to fetch/i.test(msg)) {
|
|
127
|
+
throw new Error(
|
|
128
|
+
'Impossibile contattare il server di salvataggio. Verifica che VITE_JSONPAGES_CLOUD_URL sia corretto (es. https://tua-piattaforma.vercel.app/api/v1) e che la piattaforma sia online, poi riprova.'
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
throw err;
|
|
132
|
+
}
|
|
133
|
+
},
|
|
134
|
+
}
|
|
135
|
+
: {}),
|
|
136
136
|
},
|
|
137
137
|
assets: {
|
|
138
138
|
assetsBaseUrl: '/assets',
|