Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions fastapps/cli/commands/init.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ def init_project(project_name: str, python_version: str = None):
console.print(f"Using Python version: {python_version}")

# Use uv init --bare to create a project with pyproject.toml
run_uv_command(uv_init_args, cwd=project_path.parent)
run_uv_command(uv_init_args, cwd=Path.cwd())

# Add FastApps dependency using uv add with version pinning
console.print("Adding FastApps dependency...")
Expand All @@ -339,13 +339,13 @@ def init_project(project_name: str, python_version: str = None):

# Create empty __init__.py files
console.print("Creating Python modules...")
(project_path / "server" / "__init__.py").write_text("")
(project_path / "server" / "tools" / "__init__.py").write_text("")
(project_path / "server" / "api" / "__init__.py").write_text("")
(project_path / "server" / "__init__.py").write_text("", encoding="utf-8")
(project_path / "server" / "tools" / "__init__.py").write_text("", encoding="utf-8")
(project_path / "server" / "api" / "__init__.py").write_text("", encoding="utf-8")

# Create server/main.py
console.print("Creating server...")
(project_path / "server" / "main.py").write_text(SERVER_MAIN_TEMPLATE)
(project_path / "server" / "main.py").write_text(SERVER_MAIN_TEMPLATE, encoding="utf-8")

except FileNotFoundError as exc:
console.print(f"[red][ERROR] {exc}[/red]")
Expand All @@ -358,16 +358,16 @@ def init_project(project_name: str, python_version: str = None):

# Create package.json
console.print("Creating package.json...")
(project_path / "package.json").write_text(get_package_json(project_name))
(project_path / "package.json").write_text(get_package_json(project_name), encoding="utf-8")

# Create README.md
console.print("Creating README.md...")
readme_content = PROJECT_README.format(project_name=project_name)
(project_path / "README.md").write_text(readme_content)
(project_path / "README.md").write_text(readme_content, encoding="utf-8")

# Create .gitignore
console.print("Creating .gitignore...")
(project_path / ".gitignore").write_text(GITIGNORE)
(project_path / ".gitignore").write_text(GITIGNORE, encoding="utf-8")

# Create fastapps.json with default CSP
console.print("Creating fastapps.json...")
Expand All @@ -381,7 +381,7 @@ def init_project(project_name: str, python_version: str = None):
}
}
(project_path / "fastapps.json").write_text(
json.dumps(fastapps_config, indent=2)
json.dumps(fastapps_config, indent=2), encoding="utf-8"
)

console.print(
Expand Down
12 changes: 6 additions & 6 deletions fastapps/templates/albums/widget/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import AlbumCard from "./AlbumCard";
import "./index.css";

function AlbumsCarousel({ onSelect }) {
const widgetProps = useWidgetProps();
const albums = widgetProps?.albums || [];
const { structuredContent } = useWidgetProps();
const albums = structuredContent?.albums || [];
const [emblaRef, emblaApi] = useEmblaCarousel({
align: "center",
loop: false,
Expand Down Expand Up @@ -117,16 +117,16 @@ function AlbumsCarousel({ onSelect }) {
}

function {ClassName}() {
const widgetProps = useWidgetProps();
const { structuredContent, isError } = useWidgetProps();
const displayMode = useOpenAiGlobal("displayMode");
const [selectedAlbum, setSelectedAlbum] = React.useState(null);
const maxHeight = useMaxHeight() ?? undefined;

useEffect(() => {
if (widgetProps) {
console.log('Albums widget props:', widgetProps);
if (structuredContent) {
console.log('Albums widget props:', structuredContent);
}
}, [widgetProps]);
}, [structuredContent]);

const handleSelectAlbum = (album) => {
setSelectedAlbum(album);
Expand Down
10 changes: 5 additions & 5 deletions fastapps/templates/carousel/widget/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ import Card from "./Card";
import "./index.css";

function {ClassName}() {
const widgetProps = useWidgetProps();
const cards = widgetProps?.cards || [];
const { structuredContent, isError } = useWidgetProps();
const cards = structuredContent?.cards || [];

useEffect(() => {
if (widgetProps) {
console.log('Carousel widget props:', widgetProps);
if (structuredContent) {
console.log('Carousel widget props:', structuredContent);
}
}, [widgetProps]);
}, [structuredContent]);

const [emblaRef, emblaApi] = useEmblaCarousel({
align: "center",
Expand Down
4 changes: 2 additions & 2 deletions fastapps/templates/default/widget/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import { useWidgetProps } from 'fastapps';

export default function {ClassName}() {
const props = useWidgetProps();
const { structuredContent, isError } = useWidgetProps();

return (
<div style={{
Expand All @@ -13,7 +13,7 @@ export default function {ClassName}() {
borderRadius: '8px',
fontFamily: 'monospace'
}}>
<h1>{props?.message || 'Welcome to FastApps'}</h1>
<h1>{structuredContent?.message || 'Welcome to FastApps'}</h1>
</div>
);
}
14 changes: 7 additions & 7 deletions fastapps/templates/list/widget/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import { PlusCircle, Star } from "lucide-react";
import "./index.css";

function {ClassName}() {
const widgetProps = useWidgetProps();
const items = widgetProps?.items || [];
const { structuredContent, isError } = useWidgetProps();
const items = structuredContent?.items || [];

useEffect(() => {
if (widgetProps) {
console.log('List widget props:', widgetProps);
if (structuredContent) {
console.log('List widget props:', structuredContent);
}
}, [widgetProps]);
}, [structuredContent]);

return (
<div className="antialiased w-full text-black px-4 pb-2 border border-black/10 rounded-2xl sm:rounded-3xl overflow-hidden bg-white">
Expand All @@ -26,10 +26,10 @@ function {ClassName}() {
></div>
<div>
<div className="text-base sm:text-xl font-medium">
{widgetProps?.title || "List Title"}
{structuredContent?.title || "List Title"}
</div>
<div className="text-sm text-black/60">
{widgetProps?.description || "A list of items"}
{structuredContent?.description || "A list of items"}
</div>
</div>
<div className="flex-auto hidden sm:flex justify-end pr-2">
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "fastapps"
version = "1.4.0"
version = "1.4.1"
description = "A zero-boilerplate framework for building interactive ChatGPT widgets"
readme = "README.md"
requires-python = ">=3.11"
Expand Down
2 changes: 1 addition & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading