mirror of
https://gitlab.com/soapbox-pub/shakespeare.git
synced 2026-12-06 00:27:24 +00:00
Add NIP-5A aggregate hash and version snapshots to nsite deploys
Publishes the aggregate `x` tag on every nsite manifest (kind 15128 / 35128). Adds an opt-in per-project `publishSnapshotOnDeploy` flag in `.nsite/config.json` that also publishes a kind 5128 manifest snapshot so older site versions remain reachable. Snapshots are deduplicated: if a snapshot with the same aggregate hash already exists for the site, the publish is skipped. The flag is exposed as a "Publish version history" checkbox in the nsite deploy form and is persisted to `.nsite/config.json` immediately on toggle so the choice survives without a deploy. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
This commit is contained in:
1 parent
0da339c214
commit
d1e71184e6
8 files changed
+619
-96
No files matched your search
@@ -108,6 +108,7 @@ interface NsiteFormData {
|
||||
siteTitle: string;
|
||||
siteDescription: string;
|
||||
dTag: string;
|
||||
publishSnapshotOnDeploy: boolean;
|
||||
}
|
||||
|
||||
interface NetlifyFormData {
|
||||
@@ -177,6 +178,7 @@ export function DeploySteps({ projectId, projectName, onClose }: DeployStepsProp
|
||||
siteTitle: cfg.title ?? '',
|
||||
siteDescription: cfg.description ?? '',
|
||||
dTag: (cfg.id != null && cfg.id !== '') ? cfg.id : '',
|
||||
publishSnapshotOnDeploy: cfg.publishSnapshotOnDeploy ?? false,
|
||||
});
|
||||
setNsiteShowFullForm(false);
|
||||
} else {
|
||||
@@ -194,6 +196,7 @@ export function DeploySteps({ projectId, projectName, onClose }: DeployStepsProp
|
||||
siteTitle: '',
|
||||
siteDescription: '',
|
||||
dTag: '',
|
||||
publishSnapshotOnDeploy: false,
|
||||
});
|
||||
const [netlifyForm, setNetlifyForm] = useState<NetlifyFormData>({
|
||||
siteId: '',
|
||||
@@ -280,6 +283,7 @@ export function DeploySteps({ projectId, projectName, onClose }: DeployStepsProp
|
||||
siteDescription: nsiteForm.siteDescription || undefined,
|
||||
sourceUrl,
|
||||
siteIdentifier: nsiteForm.dTag || undefined,
|
||||
publishSnapshotOnDeploy: nsiteForm.publishSnapshotOnDeploy,
|
||||
});
|
||||
} else if (selectedProvider.type === 'netlify') {
|
||||
const netlifyProvider = selectedProvider;
|
||||
@@ -405,6 +409,7 @@ export function DeploySteps({ projectId, projectName, onClose }: DeployStepsProp
|
||||
description: nsiteForm.siteDescription || undefined,
|
||||
fallback: '/index.html',
|
||||
gatewayHostnames: [nsiteProvider.gateway],
|
||||
publishSnapshotOnDeploy: nsiteForm.publishSnapshotOnDeploy,
|
||||
};
|
||||
await writeNsiteVfsConfig(fs, projectPath, newNsiteVfsConfig);
|
||||
// Update in-memory state so summary view reflects new values immediately
|
||||
@@ -517,7 +522,7 @@ export function DeploySteps({ projectId, projectName, onClose }: DeployStepsProp
|
||||
setError(null);
|
||||
// Reset forms
|
||||
setShakespeareForm({ subdomain: projectId });
|
||||
setNsiteForm({ siteTitle: '', siteDescription: '', dTag: '' });
|
||||
setNsiteForm({ siteTitle: '', siteDescription: '', dTag: '', publishSnapshotOnDeploy: false });
|
||||
setNetlifyForm({ siteId: '', siteName: '' });
|
||||
setVercelForm({ projectName: projectName || projectId, teamId: '' });
|
||||
setCloudflareForm({ projectName: projectName || projectId });
|
||||
@@ -549,6 +554,44 @@ export function DeploySteps({ projectId, projectName, onClose }: DeployStepsProp
|
||||
setNsiteForm(prev => ({ ...prev, siteDescription }));
|
||||
}, []);
|
||||
|
||||
const handleNsitePublishSnapshotOnDeployChange = useCallback(async (publishSnapshotOnDeploy: boolean) => {
|
||||
setNsiteForm(prev => ({ ...prev, publishSnapshotOnDeploy }));
|
||||
|
||||
// Persist immediately so the choice survives closing the dialog without
|
||||
// deploying. We assemble the full config from the currently-selected
|
||||
// provider + form values so the file is valid even on first toggle
|
||||
// (before any deploy has run).
|
||||
if (!projectId) return;
|
||||
if (selectedProvider?.type !== 'nsite') return;
|
||||
|
||||
const projectPath = `${projectsPath}/${projectId}`;
|
||||
const cfg: NsiteVfsConfig = {
|
||||
relays: selectedProvider.relayUrls,
|
||||
servers: selectedProvider.blossomServers,
|
||||
id: nsiteForm.dTag || undefined,
|
||||
title: nsiteForm.siteTitle || undefined,
|
||||
description: nsiteForm.siteDescription || undefined,
|
||||
fallback: '/index.html',
|
||||
gatewayHostnames: [selectedProvider.gateway],
|
||||
publishSnapshotOnDeploy,
|
||||
};
|
||||
|
||||
try {
|
||||
await writeNsiteVfsConfig(fs, projectPath, cfg);
|
||||
setNsiteVfsConfig(cfg);
|
||||
} catch (err) {
|
||||
console.warn('Failed to persist publishSnapshotOnDeploy to .nsite/config.json:', err);
|
||||
}
|
||||
}, [
|
||||
projectId,
|
||||
projectsPath,
|
||||
selectedProvider,
|
||||
fs,
|
||||
nsiteForm.dTag,
|
||||
nsiteForm.siteTitle,
|
||||
nsiteForm.siteDescription,
|
||||
]);
|
||||
|
||||
const handleNetlifySiteChange = useCallback((siteId: string, siteName: string) => {
|
||||
setNetlifyForm({ siteId, siteName });
|
||||
}, []);
|
||||
@@ -621,6 +664,10 @@ export function DeploySteps({ projectId, projectName, onClose }: DeployStepsProp
|
||||
<span className="text-muted-foreground">Blossom servers</span>
|
||||
<span className="font-medium">{serverCount} configured</span>
|
||||
</div>
|
||||
<div className="flex justify-between">
|
||||
<span className="text-muted-foreground">Version history</span>
|
||||
<span className="font-medium">{nsiteVfsConfig.publishSnapshotOnDeploy ? 'Enabled' : 'Disabled'}</span>
|
||||
</div>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
@@ -640,6 +687,7 @@ export function DeploySteps({ projectId, projectName, onClose }: DeployStepsProp
|
||||
// .nsite/config.json wins; .git/shakespeare/deploy.json is the legacy fallback
|
||||
const savedSiteTitle = nsiteVfsConfig?.title ?? legacy?.siteTitle;
|
||||
const savedSiteDescription = nsiteVfsConfig?.description ?? legacy?.siteDescription;
|
||||
const savedPublishSnapshotOnDeploy = nsiteVfsConfig?.publishSnapshotOnDeploy ?? false;
|
||||
|
||||
return (
|
||||
<div className="space-y-3">
|
||||
@@ -649,8 +697,10 @@ export function DeploySteps({ projectId, projectName, onClose }: DeployStepsProp
|
||||
savedNsec={legacy?.nsec}
|
||||
savedSiteTitle={savedSiteTitle}
|
||||
savedSiteDescription={savedSiteDescription}
|
||||
savedPublishSnapshotOnDeploy={savedPublishSnapshotOnDeploy}
|
||||
onSiteTitleChange={handleNsiteSiteTitleChange}
|
||||
onSiteDescriptionChange={handleNsiteSiteDescriptionChange}
|
||||
onPublishSnapshotOnDeployChange={handleNsitePublishSnapshotOnDeployChange}
|
||||
/>
|
||||
{nsiteVfsConfig && (
|
||||
<button
|
||||
|
||||
Reference in new issue
Block a user