Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
tree: 97408bacbf
Fetching contributors…

Cannot retrieve contributors at this time

executable file 242 lines (197 sloc) 6.847 kB
#!/bin/bash
#
# NAME
# create-new-project - a project stubber for proto
#
# SYNOPSIS
#
# # Create project for installation by proto: (without leading '# ')
# read -p "Git username: " GITUSER
# read -p "Project name: " PROJECT
# export GITUSER PROJECT
# cd /tmp # (or your preferred directory)
# git clone git://github.com/masak/proto.git proto
# cd proto
# ./proto
# ./create-new-project
# ./proto install $PROJECT
# ./proto test $PROJECT
# ./proto update $PROJECT
#
# DESCRIPTION
# Implements proto's PIONEER plan in code
#
# BUGS
# 1. The 'cat >>modules.list <<EOF' causes two problems:
# 1a. Subsequent 'git pull' in proto cannot merge remote modules.list
# changes with the local change, needing manual intervention.
# 1b. Creating the same project multiple times also appends the project
# information to modules.list multiple times, needing manual fixing.
cat <<EOF
Hi, this is 'create-new-project', a project stubber for the 'proto' installer.
Choose the collaboration site you would like to use.
1. Github (http://github.com)
2. Gitorious (http://gitorious.org)
3. GoogleCode (TODO)
4. CPAN (TODO)
EOF
read -p "Your choice (1 or 2): " SITE
if [ "$SITE" == "1" ] ; then
CREATEURL=https://github.com/signup/free
LOGINURL=https://github.com/login
NEWREPOURL=http://github.com/repositories/new
HOMENICK=github
elif [ "$SITE" == "2" ] ; then
CREATEURL=http://gitorious.org/users/new
LOGINURL=http://gitorious.org/login
NEWREPOURL=http://gitorious.org/projects/new
HOMENICK=gitorious
else
echo -e "\nYou managed to not select either 1 or 2, so I give up.\n"
exit 1;
fi
cat <<EOF
You first need to have done the following:
1. Create a collaboration account <$CREATEURL>
2. Log in <$LOGINURL>
3. Create a project repository <$NEWREPOURL>
4. Enter your Project Name,
Description, Homepage etc
and click Create.
This script will then take care of the next steps.
If 'Create' worked, continue here, otherwise type Control-C to exit.
EOF
# Skip these reads if they were already done as in SYNOPSIS above.
if [ -z "$GITUSER" -a -z "$PROJECT" ]
then
read -p "Username used in steps 1..4 above: " GITUSER
read -p "Project : " PROJECT
export GITUSER PROJECT
else
echo "Using '$GITUSER' as username and '$PROJECT' as project."
read -p "After you've followed the steps above, press Enter..."
fi
if [ "$SITE" == "1" ] ; then
REMOTEURL=git@github.com:$GITUSER/$PROJECT.git
PUBLICURL=http://github.com/$GITUSER/$PROJECT/tree/master
elif [ "$SITE" == "2" ] ; then
REMOTEURL=git@gitorious.org:$PROJECT/mainline.git
PUBLICURL=http://gitorious.org/projects/$PROJECT
fi
# Begin with some steps from "Create New Repository" at github.com
PROJECTBASE=/tmp/$PROJECT
rm -rf $PROJECTBASE # ensure a clean start every time
#mkdir $PROJECTBASE
mkdir -p $PROJECTBASE/lib/Example $PROJECTBASE/t
#git init
#GIT_DIR=$PROJECTBASE/.git git init
# The project should consist mainly of Perl modules.
# Module files contain classes, roles, grammars and documentation.
#mkdir lib/Example
#mkdir $PROJECTBASE/lib/Example
#cat >lib/Example/Hello.pm <<EOF
cat >$PROJECTBASE/lib/Example/Hello.pm <<EOF
class Example::Hello
{
method greet { return "hello" }
method place { return "world" }
}
=begin pod
=head1 NAME
Example::Hello - canonical "hello, world!" example for proto
=head1 AUTHOR
$GITUSER ($GITUSER at $HOMENICK and @example.com)
=end pod
EOF
# Include a test suite to improve your karma (and your code quality)
# Beware the \ escapes for bash:
cat >$PROJECTBASE/t/01-simple.t <<EOF
use Example::Hello;
use Test;
plan 3;
my Example::Hello \$greeter .= new;
isa_ok( \$greeter, 'Example::Hello', 'create object' );
is( \$greeter.greet, 'hello', 'greet' );
is( \$greeter.place, 'world', 'place' );
EOF
# Create a Makefile.in like this example from mathw's form project.
# note the \$ escaping to play nicely with bash.
cat >$PROJECTBASE/Makefile.in <<EOF
PERL6=<PERL6>
PERL6LIB=<PERL6LIB>
SOURCES=lib/Example/Hello.pm
PIRS=\$(SOURCES:.pm=.pir)
all: \$(PIRS) lib/Test.pir
%.pir: %.pm
\$(PERL6) --target=pir --output=\$@ \$<
clean:
rm -f \$(PIRS)
realclean: clean
rm Makefile
test: all
PERL6LIB=\$(PERL6LIB) prove -e '\$(PERL6)' -r --nocolor t/
help:
@echo ''
@echo 'You can make the following targets:'
@echo ''
@echo 'all - default, precompile .pm to .pir for speed'
@echo 'clean - removes .pir and backup~ files'
@echo 'realclean - clean and also remove Makefile'
@echo 'test - verify that the code works as specified'
@echo 'help - this text.'
@echo ''
EOF
# The above 'Makefile.in' needs something active to transform it into
# a Makefile. Copy the Configure.pm6 from proto and invoke it by the
# following Configure (Perl 6) script:
cp lib/Configure.pm6 $PROJECTBASE/lib
cat >$PROJECTBASE/Configure <<EOF
# Configure - Makefile builder - see documentation in lib/Configure.pm6
use v6; BEGIN { @*INC.unshift('lib'); }; use Configure;
EOF
# Notify proto about dependencies on other modules. The installer will
# ensure that PERL6LIB can also find the content of their lib
# directories so that 'use thatmodule;' Just Works.
#cat >deps.proto <<EOF
cat >$PROJECTBASE/deps.proto <<EOF
# project dependencies
EOF
# Some steps from "New Project" guidelines at github or gitorious.
(
cd $PROJECTBASE
git init
git add deps.proto Makefile.in Configure.pl lib/Configure.pm
git add lib/Example/* t/*
git commit -m "created by proto's create-new-project"
git remote add origin $REMOTEURL
git push origin master
)
if [ "$?" != "0" ]; then echo 'Cannot git push. Start again.'; exit 1; fi
# Add these lines to proto's modules.list
cat >>projects.list <<EOF
$PROJECT:
home: $HOMENICK
owner: $GITUSER
EOF
cat <<EOF
5. If there were NO errors above, your repository on $HOMENICK should be
ready. In your browser click on the repository link or
$PUBLICURL
6. Ask a proto maintainer to add these lines to 'modules.list', or simply
edit your local copy:
$PROJECT:
home: $HOMENICK
owner: $GITUSER
7. Then you should be able to install and test your project:
./proto install $PROJECT
./proto test $PROJECT
Now create-new-project is finished, and your work really starts :)
8. Replace $PROJECT/lib/Example/Hello.pm with your module file(s)
and update SOURCES in $PROJECT/Makefile.in accordingly.
Run 'perl6 Configure.pl' after each change to Makefile.in.
9. Add README, LICENCE and other instructions.
10. Revise and extend $PROJECT/t/01-simple.t as well, and run
'make test' after every change that affects execution of your code.
11. Use 'git push' early and often.
On behalf of the 'proto' developers, this script wishes you a good day.
EOF
Jump to Line
Something went wrong with that request. Please try again.