Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@
This is a template/skeleton for JSO packages.
It should be used for new packages, and as a reference for changes in existing packages.

## Things to change
## How to use

- Project.toml: name and uuid
- LICENSE.md: Check if MPL-v2 is the correct choice
- Click on the button "Use template".
- Clone.
- Run `julia run-me.jl` and enter the new package name.
- Check if MPL-v2 is the correct choice.
- Update this README.
52 changes: 52 additions & 0 deletions run-me.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
using UUIDs

print("Thanks for using JSOTemplate. What's your intended package name?: \n")
pkgname = readline()

green(msg) = "\033[0;32m$msg\033[0m"
yellow(msg) = "\033[0;33m$msg\033[0m"

println("""
This script will help using JSOTemplate by performing the following steps:
- Change $(green("JSOTemplate")) to $(green("$pkgname")) wherever it is found
- Change the $(green("UUID")) of the package
- Change file $(green("src/JSOTemplate.jl")) to $(green("src/$pkgname.jl"))
- $(yellow("Remove this script"))
- Create a $(yellow("commit")) with the change
""")


files = readdir()
deleteat!(files, findfirst(files .== ".git"))
while !all(isfile.(files))
idx = findall(.!isfile.(files))
for dir in files[idx]
append!(files, readdir(dir, join=true))
end
deleteat!(files, idx)
end
run(`sed -i "s/JSOTemplate/$pkgname/g" $files`)
println(green("✓ All occurrences of JSOTemplate should have been changed to $pkgname"))

lines = readlines("Project.toml")
uuid = ""
for line in lines
if line[1:4] == "uuid"
global uuid = split(line, "\"")[2]
break
end
end
new_uuid = string(uuid4())
files = ["Project.toml", "test/Project.toml", "docs/Project.toml"] |> x -> filter(isfile, x)
run(`sed -i "s/$uuid/$new_uuid/g" $files`)
println(green("✓ UUID has been updated in $files"))

mv("src/JSOTemplate.jl", "src/$pkgname.jl")
println(green("✓ src/JSOTemplate.jl ⟶ src/$pkgname.jl"))

rm("run-me.jl")
println(green("✓ run-me.jl was removed"))

run(`git add src/$pkgname.jl`)
run(`git commit -am ":robot: [run-me.jl] Change JSOTemplate to $pkgname"`)
println(green("✓ commit was created"))