@jsonpages/cli 3.0.52 β 3.0.53
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 +2 -3
- package/src/index.js +0 -6
- package/assets/vercel.json +0 -1
|
@@ -53,7 +53,6 @@ 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);
|
|
57
56
|
|
|
58
57
|
const themeConfig = themeData as unknown as ThemeConfig;
|
|
59
58
|
const menuConfig = menuData as unknown as MenuConfig;
|
|
@@ -79,7 +78,11 @@ function App() {
|
|
|
79
78
|
.then((list: LibraryImageEntry[]) => setAssetsManifest(Array.isArray(list) ? list : []))
|
|
80
79
|
.catch(() => setAssetsManifest([]));
|
|
81
80
|
}, []);
|
|
82
|
-
|
|
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
|
+
});
|
|
83
86
|
const config: JsonPagesConfig = {
|
|
84
87
|
tenantId: TENANT_ID,
|
|
85
88
|
registry: ComponentRegistry as JsonPagesConfig['registry'],
|
|
@@ -92,7 +95,34 @@ function App() {
|
|
|
92
95
|
addSection: addSectionConfig,
|
|
93
96
|
persistence: {
|
|
94
97
|
async saveToFile(state: ProjectState, slug: string): Promise<void> {
|
|
95
|
-
|
|
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)
|
|
96
126
|
console.log(`π» Saving ${slug} to Local Filesystem...`);
|
|
97
127
|
const res = await fetch('/api/save-to-file', {
|
|
98
128
|
method: 'POST',
|
|
@@ -103,36 +133,6 @@ function App() {
|
|
|
103
133
|
const body = (await res.json().catch(() => ({}))) as { error?: string };
|
|
104
134
|
if (!res.ok) throw new Error(body.error ?? `Save to file failed: ${res.status}`);
|
|
105
135
|
},
|
|
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',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsonpages/cli",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.53",
|
|
4
4
|
"description": "The Sovereign CLI Engine for JsonPages.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -8,8 +8,7 @@
|
|
|
8
8
|
},
|
|
9
9
|
"files": [
|
|
10
10
|
"src",
|
|
11
|
-
"assets/src_tenant_alpha.sh"
|
|
12
|
-
"assets/vercel.json"
|
|
11
|
+
"assets/src_tenant_alpha.sh"
|
|
13
12
|
],
|
|
14
13
|
"author": "JsonPages Team",
|
|
15
14
|
"license": "MIT",
|
package/src/index.js
CHANGED
|
@@ -335,12 +335,6 @@ async function injectInfraFiles(targetDir, name) {
|
|
|
335
335
|
}
|
|
336
336
|
};
|
|
337
337
|
await fs.writeJson(path.join(targetDir, 'components.json'), shadcnConfig, { spaces: 2 });
|
|
338
|
-
|
|
339
|
-
// Vercel deploy config (SPA rewrites + asset cache)
|
|
340
|
-
const vercelJsonPath = path.resolve(__dirname, '../assets/vercel.json');
|
|
341
|
-
if (fs.existsSync(vercelJsonPath)) {
|
|
342
|
-
await fs.copy(vercelJsonPath, path.join(targetDir, 'vercel.json'));
|
|
343
|
-
}
|
|
344
338
|
}
|
|
345
339
|
|
|
346
340
|
program.parse();
|
package/assets/vercel.json
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"rewrites":[{"source":"/(.*)","destination":"/index.html"}],"headers":[{"source":"/assets/(.*)","headers":[{"key":"Cache-Control","value":"public, max-age=31536000, immutable"}]}]}
|