Rename terminology to industry standard terms

- Grove → Project
- Tree → Package
- Fruit → Artifact
- Graft → Tag
- Cultivate → Upload
- Harvest → Download

Updated across:
- Backend models, schemas, and routes
- Frontend types, API client, and components
- README documentation
- API endpoints now use /project/:project/packages pattern
This commit is contained in:
Mondo Diaz
2025-12-08 10:38:44 -06:00
parent 386ea0df4d
commit ff7df9eb3f
12 changed files with 470 additions and 485 deletions

View File

@@ -0,0 +1,160 @@
import { useState, useEffect, useRef } from 'react';
import { useParams, Link } from 'react-router-dom';
import { Tag } from '../types';
import { listTags, uploadArtifact, getDownloadUrl } from '../api';
import './Home.css';
import './PackagePage.css';
function PackagePage() {
const { projectName, packageName } = useParams<{ projectName: string; packageName: string }>();
const [tags, setTags] = useState<Tag[]>([]);
const [loading, setLoading] = useState(true);
const [error, setError] = useState<string | null>(null);
const [uploading, setUploading] = useState(false);
const [uploadResult, setUploadResult] = useState<string | null>(null);
const [tag, setTag] = useState('');
const fileInputRef = useRef<HTMLInputElement>(null);
useEffect(() => {
if (projectName && packageName) {
loadTags();
}
}, [projectName, packageName]);
async function loadTags() {
try {
setLoading(true);
const data = await listTags(projectName!, packageName!);
setTags(data);
setError(null);
} catch (err) {
setError(err instanceof Error ? err.message : 'Failed to load tags');
} finally {
setLoading(false);
}
}
async function handleUpload(e: React.FormEvent) {
e.preventDefault();
const file = fileInputRef.current?.files?.[0];
if (!file) {
setError('Please select a file');
return;
}
try {
setUploading(true);
setError(null);
const result = await uploadArtifact(projectName!, packageName!, file, tag || undefined);
setUploadResult(`Uploaded successfully! Artifact ID: ${result.artifact_id}`);
setTag('');
if (fileInputRef.current) {
fileInputRef.current.value = '';
}
loadTags();
} catch (err) {
setError(err instanceof Error ? err.message : 'Upload failed');
} finally {
setUploading(false);
}
}
if (loading) {
return <div className="loading">Loading...</div>;
}
return (
<div className="home">
<nav className="breadcrumb">
<Link to="/">Projects</Link> / <Link to={`/project/${projectName}`}>{projectName}</Link> / <span>{packageName}</span>
</nav>
<div className="page-header">
<h1>{packageName}</h1>
</div>
{error && <div className="error-message">{error}</div>}
{uploadResult && <div className="success-message">{uploadResult}</div>}
<div className="upload-section card">
<h3>Upload Artifact</h3>
<form onSubmit={handleUpload} className="upload-form">
<div className="form-group">
<label htmlFor="file">File</label>
<input
id="file"
type="file"
ref={fileInputRef}
required
/>
</div>
<div className="form-group">
<label htmlFor="tag">Tag (optional)</label>
<input
id="tag"
type="text"
value={tag}
onChange={(e) => setTag(e.target.value)}
placeholder="v1.0.0, latest, stable..."
/>
</div>
<button type="submit" className="btn btn-primary" disabled={uploading}>
{uploading ? 'Uploading...' : 'Upload'}
</button>
</form>
</div>
<h2>Tags / Versions</h2>
{tags.length === 0 ? (
<div className="empty-state">
<p>No tags yet. Upload an artifact with a tag to create one!</p>
</div>
) : (
<div className="tags-table">
<table>
<thead>
<tr>
<th>Tag</th>
<th>Artifact ID</th>
<th>Created</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
{tags.map((t) => (
<tr key={t.id}>
<td><strong>{t.name}</strong></td>
<td className="artifact-id">{t.artifact_id.substring(0, 12)}...</td>
<td>{new Date(t.created_at).toLocaleString()}</td>
<td>
<a
href={getDownloadUrl(projectName!, packageName!, t.name)}
className="btn btn-secondary btn-small"
download
>
Download
</a>
</td>
</tr>
))}
</tbody>
</table>
</div>
)}
<div className="usage-section card">
<h3>Usage</h3>
<p>Download artifacts using:</p>
<pre>
<code>curl -O {window.location.origin}/api/v1/project/{projectName}/{packageName}/+/latest</code>
</pre>
<p>Or with a specific tag:</p>
<pre>
<code>curl -O {window.location.origin}/api/v1/project/{projectName}/{packageName}/+/v1.0.0</code>
</pre>
</div>
</div>
);
}
export default PackagePage;