-
-
Save sdondley/5831d2c1ccd5c82241686015791b561b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
use JSON; | |
use Carp; | |
my $name = $ARGV[0]; | |
if ($name =~ /:/) { | |
croak 'Use dashes to separate module paths not colons'; | |
} | |
croak "Is this a public or private repo? Supply '1' arg for public, 0 for private" if !$ARGV[1]; | |
my $git_visibility = $ARGV[1] ? 'public' : 'private'; | |
croak 'No name supplied as argument' if !$name; | |
my $error = system "mi6 new --zef $name"; | |
croak "There was an error trying to create the project: $!" if $error; | |
chdir $name; | |
#$error = system 'tail -n 2 "META6.json" | wc -c | xargs -I {} truncate "META6.json" -s -{}'; | |
#croak "Unable to remove last line of META6.json file: $!" if $error; | |
# | |
#$error = system 'echo ",\n\"auth\": \"zef:sdondley\"\n}" >> META6.json'; | |
#croak "Could not modify META6.json file: $!" if $error; | |
$error = system 'echo "*.iml\n*.idea\n" >> .gitignore'; | |
croak "Could not modify .gitignore: $!" if $error; | |
mkdir "xt"; | |
my $test_file = 'xt/Author-Tests.rakutest'; | |
$error = system "touch $test_file"; | |
croak "Could not add author test file: $!" if $error; | |
my $author_test = <<"CONTENT"; | |
#!/usr/bin/env raku | |
use v6.d; | |
use lib '../'; | |
use Test; | |
use Test::Output; | |
plan 1; | |
when !%*ENV<AUTHOR_TESTING> { skip 'skipping author tests' } | |
plan 1; | |
# put author tests here | |
CONTENT | |
$error = system "echo \"$author_test\" >> $test_file"; | |
croak "Could not add content to author test file: $!" if $error; | |
open(my $META6, '<', "META6.json") or croak 'cannot open'; | |
my $json = do { local $/; <$META6> }; | |
close $META6; | |
my $perl = decode_json $json; | |
$perl->{'source-url'} = "https://github.com/sdondley/$name.git"; | |
$json = to_json($perl, {utf8 => 1, pretty => 1}); | |
open my $META, '>', 'META6.json' or croak 'cannot open'; | |
print $META $json; | |
close $META; | |
$error = system "git add ."; | |
croak "Could not add git files: $!" if $error; | |
$error = system "git commit . -m 'initial commit'"; | |
croak "Could not commit git files: $!" if $error; | |
$error = system "gh repo create --source=. --$git_visibility --remote=origin --push"; | |
croak "Could not push git repo: $!" if $error; | |
$error = system "git co -b devel"; | |
croak "Could not create devel branch: $!" if $error; | |
$error = system "git push --set-upstream origin devel"; | |
croak "Could not push devel branch: $!" if $error; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment