ponzu-cms / ponzu

Headless CMS with automatic JSON API. Featuring auto-HTTPS from Let's Encrypt, HTTP/2 Server Push, and flexible server framework written in Go.
https://docs.ponzu-cms.org
BSD 3-Clause "New" or "Revised" License
5.7k stars 385 forks source link

Regression bug in Gen. #111

Closed ghost closed 7 years ago

ghost commented 7 years ago

This uses the code on the wiki.

The bug is with the "item" field name :)

this script fails:


REPO_TARGET=github.com/ponzu-cms/test03
GO_TARGET=$GOPATH/src/$REPO_TARGET

echo "REPO_TARGET: " $REPO_TARGET
echo "GO_TARGET: " $GO_TARGET

# Check paths are good before deleting stuff !
read -p "This wil delete any existing project at this location. Are you sure? (y/n)" -n 1 -r
echo    # (optional) move to a new line
if [[ $REPLY =~ ^[Nn]$ ]]
then
    exit
fi

echo "Creating new Project at: " $GO_TARGET
rm -R $GO_TARGET
ponzu new $REPO_TARGET

echo "Creating Content Types at: " $GO_TARGET
cd $GO_TARGET

ponzu gen content review title:"string" author:"string" rating:"float64" body:"string" website_url:"string" item:"[]string" photos:"[]string"

# Build & Run
cd $GO_TARGET
ponzu build 
ponzu run

# Lets add content :)
#https://github.com/ponzu-cms/ponzu/wiki/API

you get :


x-MacBook-Pro:03 apple$ ./t-run.sh 
REPO_TARGET:  github.com/ponzu-cms/test03
GO_TARGET:  /Users/apple/workspace/go/src/github.com/ponzu-cms/test03
This wil delete any existing project at this location. Are you sure? (y/n)y
Creating new Project at:  /Users/apple/workspace/go/src/github.com/ponzu-cms/test03
rm: /Users/apple/workspace/go/src/github.com/ponzu-cms/test03: No such file or directory
Cloning into '/Users/apple/workspace/go/src/github.com/ponzu-cms/test03'...

done.
New ponzu project created at /Users/apple/workspace/go/src/github.com/ponzu-cms/test03
Creating Content Types at:  /Users/apple/workspace/go/src/github.com/ponzu-cms/test03
# github.com/ponzu-cms/test03/cmd/ponzu/vendor/github.com/ponzu-cms/ponzu/content
cmd/ponzu/vendor/github.com/ponzu-cms/ponzu/content/review.go:18: duplicate field Item
Ponzu build step failed. Please try again. 
exit status 2
fork/exec ./ponzu-server: no such file or directory
ghost commented 7 years ago

Got it working with this approach.

looks like item is a reserved word ...

If i replace "item" with "itemitem" is works :)

ponzu gen content review title:"string" author:"string" rating:"float64" body:"string" website_url:"string" itemitem:"[]string" photos:"[]string"

SO, maybe add a preflight check for reserved words ?

nilslice commented 7 years ago

Ah, good catch... tests are sorely needed :-/

I will add item and think of other possible reserved words to add before generate-time.. if you come across any others, please add them here!

ghost commented 7 years ago

will leave open for now for you ...