### Manually Install Giter8 Source: https://github.com/foundweekends/giter8/blob/develop/docs/01.md Manually download and install giter8 by fetching the bootstrap script from Maven Central. Make sure the installation directory is in your system's PATH. ```bash curl https://repo1.maven.org/maven2/org/foundweekends/giter8/giter8-bootstrap_3/$version$/giter8-bootstrap_3-$version$.sh > ~/bin/g8 chmod +x ~/bin/g8 ``` -------------------------------- ### Install Local giter8 Version Source: https://github.com/foundweekends/giter8/wiki/Installing-local-version-of-giter8 To install a local snapshot version of giter8, modify the version in build.sbt, publish locally using sbt, and then install the snapshot using cs. ```bash cs --local foundweekends/giter8/0.7.1-SNAPSHOT ``` -------------------------------- ### Install giter8 with Conscript Source: https://github.com/foundweekends/giter8/blob/develop/notes/0.2.1.markdown Use conscript to install and upgrade giter8. Ensure conscript is set up before running this command. ```bash cs n8han/giter8 ``` -------------------------------- ### Template Build SBT File Source: https://context7.com/foundweekends/giter8/llms.txt Example build.sbt file for a giter8 template, using template parameters. ```scala // src/main/g8/build.sbt name := "$name$" organization := "$organization$" version := "0.1.0-SNAPSHOT" scalaVersion := "$scala_version$" ``` -------------------------------- ### Install Giter8 with Coursier Source: https://github.com/foundweekends/giter8/blob/develop/docs/01.md Use this command to install the giter8 tool via Coursier. Ensure 'cs' is on your PATH. ```bash cs install giter8 ``` -------------------------------- ### Verify Giter8 Installation Source: https://github.com/foundweekends/giter8/blob/develop/docs/01.md Run this command after installation to verify that giter8 is working correctly. It should output an error message indicating a missing argument. ```bash g8 ``` -------------------------------- ### Template Expansion Example Source: https://github.com/foundweekends/giter8/blob/develop/notes/0.2.0.markdown Demonstrates how giter8 performs template expansion within file and directory names. Ensure your template is correctly configured for this feature. ```shell src/main/g8/src/main/scala/$MainClass$.scala ``` -------------------------------- ### Giter8 Interactive Mode Example Source: https://github.com/foundweekends/giter8/blob/develop/docs/03/00.md Example of how Giter8 prompts for input during interactive mode, based on the defined template fields and their defaults. ```text name [URL Builder]: my-proj github_id [githubber]: n8han project_url [https://github.com/n8han/my-proj]: developer_url [https://github.com/n8han]: ``` -------------------------------- ### Manual Giter8 Installation Source: https://context7.com/foundweekends/giter8/llms.txt Manually installs giter8 by downloading a bootstrap script from Maven Central. This method requires adding the script to your system's PATH. ```bash # Manual installation from Maven Central $ curl https://repo1.maven.org/maven2/org/foundweekends/giter8/giter8-bootstrap_3/0.18.0/giter8-bootstrap_3-0.18.0.sh > ~/bin/g8 $ chmod +x ~/bin/g8 ``` -------------------------------- ### Install Giter8 using Coursier Source: https://context7.com/foundweekends/giter8/llms.txt Installs or updates the giter8 command-line tool using the Coursier package manager. Ensure Coursier is installed and in your PATH. ```bash # Install giter8 using Coursier $ cs install giter8 ``` ```bash # Update giter8 to the latest version $ cs update g8 ``` -------------------------------- ### Install Local giter8 with Conscript Source: https://github.com/foundweekends/giter8/blob/develop/docs/05.md Installs a local version of giter8 using the conscript tool. Ensure you have updated the version in build.sbt and run publishLocal first. ```shell cs --local foundweekends/giter8/ ``` -------------------------------- ### Template Default Properties Source: https://context7.com/foundweekends/giter8/llms.txt Example default properties file for a giter8 template. ```properties # src/main/g8/default.properties name = My Web App organization = com.example package = $organization$.$name;format="word,lower"$ scala_version = 2.13.12 ``` -------------------------------- ### Generated Template Structure Source: https://context7.com/foundweekends/giter8/llms.txt Example structure of a template project generated by giter8. ```tree # Generated template structure scala-web-app.g8/ ├── build.sbt ├── project/ │ ├── build.properties │ └── plugins.sbt ├── src/ │ └── main/ │ └── g8/ │ ├── default.properties │ ├── build.sbt │ └── src/ │ └── main/ │ └── scala/ │ └── $package$/ │ └── Main.scala └── LICENSE ``` -------------------------------- ### Apply Template from Generic Git URL Source: https://github.com/foundweekends/giter8/blob/develop/notes/0.5.0.markdown Giter8 can apply templates from any Git URL. This example shows using a generic Git URL. ```bash g8 git@github.com:unfiltered/unfiltered.g8.git ``` -------------------------------- ### Refresh Local giter8 Version Source: https://github.com/foundweekends/giter8/wiki/Installing-local-version-of-giter8 To refresh your local giter8 installation after making changes, run publishLocal from sbt and then clean the boot cache using cs --clean-boot. ```bash cs --clean-boot ``` -------------------------------- ### Publish Local Version with SBT Source: https://github.com/foundweekends/giter8/blob/develop/docs/05.md Publishes the local version of giter8 to your sbt repository. This is a prerequisite for installing the local version using conscript. ```shell publishLocal ``` -------------------------------- ### Format Directory Name for Package Structure Source: https://github.com/foundweekends/giter8/blob/develop/docs/03/a.md Use the '__packaged' suffix with a format option to transform directory names. For example, 'organization__packaged' with 'org.somewhere' will result in 'org/somewhere', similar to the built-in 'package' format. ```giter8 $organization__packaged$ ``` -------------------------------- ### Apply Formatting to Template Fields Source: https://context7.com/foundweekends/giter8/llms.txt Use the `format` option to transform template field values. Multiple formats can be chained using commas. Examples include upper, lower, cap, Camel, camel, normalize, snake, and package. ```Scala // Template file: src/main/scala/$name__Camel$.scala // With name = "my project" // Basic formatting examples $name$ // "my project" $name;format="upper"$ // "MY PROJECT" $name;format="lower"$ // "my project" $name;format="cap"$ // "My project" $name;format="Camel"$ // "MyProject" $name;format="camel"$ // "myProject" $name;format="normalize"$ // "my-project" $name;format="snake"$ // "my_project" $name;format="package"$ // "my.project" // Package directory expansion // $package$ = "com.example.myapp" becomes "com/example/myapp" $package;format="packaged"$ // Dot reverse for domain names // "scala-lang.org" becomes "org.scala-lang" $organization;format="dotReverse"$ // Chain multiple formats $name;format="lower,hyphen"$ // "my-project" $name;format="upper,snake"$ // "MY_PROJECT" // File/directory name formatting (double underscore syntax) // Directory: $organization__packaged$/ // File: $name__Camel$.scala ``` -------------------------------- ### Mill Plugin for Giter8 Template Testing Source: https://github.com/foundweekends/giter8/blob/develop/docs/03/b.md Configure the Mill plugin for Giter8 template testing. This setup supports `src` layouts and provides targets like `g8.validate`. ```scala import $ivy.`io.chris-kipp::mill-giter8::0.2.0` import io.kipp.mill.giter8.G8Module object g8 extends G8Module { override def validationTargets = Seq("example.compile", "example.fix", "example.reformat") } ``` -------------------------------- ### Git Configuration for SSH Source: https://github.com/foundweekends/giter8/blob/develop/docs/02.md Configure Git to use SSH URLs instead of HTTPS for GitHub. This is part of the setup for accessing private repositories via SSH. ```gitconfig [url "ssh://git@github.com"] insteadOf = https://github.com ``` -------------------------------- ### Conditional Fields in Giter8 Source: https://github.com/foundweekends/giter8/blob/develop/notes/0.10.0.markdown Use the `truthy` property for conditional expressions in Giter8 templates starting from version 0.10.0. Values like 'y', 'yes', and 'true' evaluate to true; others to false. ```Giter8 Template $if(scala212.truthy)$ scalaVersion := "2.12.3" $elseif(scala211.truthy)$ scalaVersion := "2.11.11" $else$ scalaVersion := "2.10.6" $endif$ ``` -------------------------------- ### Configure SSH Agent Source: https://context7.com/foundweekends/giter8/llms.txt Sets up the SSH agent by exporting the socket path and launching gpg-agent. ```bash # Configure SSH agent (e.g., with gpg-agent) # ~/.profile export SSH_AUTH_SOCK="$(gpgconf --list-dirs agent-ssh-socket)" gpgconf --launch gpg-agent ``` -------------------------------- ### Apply Local Template Source: https://github.com/foundweekends/giter8/blob/develop/docs/02.md Use the 'file://' protocol to apply a template from a local directory. Ensure the path to the template is correct. ```bash $ g8 file://path/to/template ``` -------------------------------- ### Apply Template with Parameters Source: https://github.com/foundweekends/giter8/blob/develop/docs/02.md Provide template parameters directly on the command line to skip interactive prompts. Unsupplied parameters will use their default values. ```bash $ g8 unfiltered/unfiltered.g8 --name=my-new-website ``` -------------------------------- ### Giter8 Template Project Initialization Source: https://github.com/foundweekends/giter8/blob/develop/docs/03/00.md Initialize a new Giter8 template project using the giter8 command. This command creates an sbt project with stub template sources. ```bash $ g8 foundweekends/giter8.g8 ``` -------------------------------- ### Apply Giter8 Template with Command-line Parameters Source: https://context7.com/foundweekends/giter8/llms.txt Applies a GitHub template and provides parameters directly on the command line, bypassing interactive prompts. Use this for automation or when parameter values are known. ```bash # Apply template with parameters on command line (skip interactive prompts) $ g8 unfiltered/unfiltered.g8 --name=my-new-website ``` -------------------------------- ### Apply Public GitHub Template Source: https://github.com/foundweekends/giter8/blob/develop/notes/0.5.0.markdown Use this command to discover and apply a public template served by GitHub. It anonymously accesses the repository. ```bash g8 unfiltered/unfiltered ``` -------------------------------- ### Apply GitHub Template Source: https://github.com/foundweekends/giter8/blob/develop/docs/02.md Use this command to apply a template from a GitHub repository. Giter8 will resolve the repository and prompt for template parameters. ```bash $ g8 unfiltered/unfiltered.g8 ``` -------------------------------- ### Apply Scala Seed Template with sbt Source: https://context7.com/foundweekends/giter8/llms.txt Uses sbt's `new` command to apply a Scala seed template, integrating Giter8 scaffolding into the Scala build process. ```bash # Apply Scala seed template using sbt new integration $ sbt new scala/scala-seed.g8 ``` -------------------------------- ### Discover Available Scaffolds with TAB Completion Source: https://github.com/foundweekends/giter8/blob/develop/docs/04/00.md Use TAB completion in the sbt shell after running g8Scaffold to see available templates. ```bash > g8Scaffold controller global model ``` -------------------------------- ### Apply Template from Directory Source: https://context7.com/foundweekends/giter8/llms.txt Applies a template from a specified directory to a working directory with given arguments. Handles success and error cases. ```scala import giter8.{G8, G8TemplateRenderer} import java.io.File // Apply template from directory val result = G8.fromDirectory( templateDirectory = new File("/path/to/template"), workingDirectory = new File("/path/to/output"), arguments = Seq("--name=my-project", "--organization=com.example"), forceOverwrite = false, outputDirectory = None ) result match { case Right(message) => println(s"Success: $message") case Left(error) => println(s"Error: $error") } ``` -------------------------------- ### Bootstrap New Template Project Source: https://context7.com/foundweekends/giter8/llms.txt Creates a new template project using the official giter8 template for creating templates. ```bash # Create new template project $ g8 foundweekends/giter8.g8 name [My Template]: scala-web-app ``` -------------------------------- ### Apply Giter8 Template from GitHub (Shorthand) Source: https://context7.com/foundweekends/giter8/llms.txt Applies a template from a GitHub repository using the shorthand `owner/repo.g8` notation. Giter8 will prompt for template parameters interactively. ```bash # Apply template from GitHub (shorthand notation) $ g8 unfiltered/unfiltered.g8 name [My Web Project]: my-awesome-app ``` -------------------------------- ### List Scaffolds Stored in .g8 Directory Source: https://github.com/foundweekends/giter8/blob/develop/docs/04/00.md This command shows the structure of scaffolds stored in the .g8 directory after a template has been used. ```bash $ ls sample/.g8 total 0 drwxr-xr-x 5 jtournay staff 170B Aug 6 03:21 . drwxr-xr-x 11 jtournay staff 374B Aug 6 05:29 .. drwxr-xr-x 4 jtournay staff 136B Aug 6 03:21 controller drwxr-xr-x 4 jtournay staff 136B Aug 6 03:21 global drwxr-xr-x 4 jtournay staff 136B Aug 6 03:21 model ``` -------------------------------- ### Use Custom Known Hosts File Source: https://context7.com/foundweekends/giter8/llms.txt Applies a giter8 template from a private repository using a custom known hosts file for SSH. ```bash # Use custom known hosts file $ g8 private/repo.g8 --known-hosts ~/.ssh/custom_known_hosts ``` -------------------------------- ### Apply Git Repository Template Source: https://github.com/foundweekends/giter8/blob/develop/docs/02.md Apply a template from a full Git repository URL. This is useful for repositories not hosted on GitHub or for specific Git hosting services. ```bash $ g8 https://gitlab.com/unfiltered/unfiltered-gitlab.g8.git ``` -------------------------------- ### Format File Name with Combined Options Source: https://github.com/foundweekends/giter8/blob/develop/docs/03/a.md Demonstrates using multiple comma-separated formatting options for file names. '$name__lower,hyphen$.scala' with 'Awesome Project' will produce 'awesome-project.scala'. ```giter8 $name__lower,hyphen$.scala ``` -------------------------------- ### List giter8 templates Source: https://github.com/foundweekends/giter8/blob/develop/notes/0.4.1.markdown Use the -l flag to list available giter8 templates. This command helps in discovering and selecting project templates. ```bash $ g8 -l tjweir/LiftProject giter8 template for a Lift 2.2 application typesafehub/akka-first-tutorial-java giter8 template for first Akka 2.0 tu [...] ``` -------------------------------- ### Apply Local Giter8 Template with Overwrite and Output Directory Source: https://context7.com/foundweekends/giter8/llms.txt Applies a local template, forcing overwrite of existing files and specifying a custom output directory. Use `--force` to overwrite and `-o` to set the output path. ```bash # Apply local template with force overwrite $ g8 file://unfiltered.g8/ --name=uftest --force ``` ```bash # Specify output directory $ g8 unfiltered/unfiltered.g8 -o /path/to/output ``` -------------------------------- ### Apply Template from Local Git Repository Source: https://github.com/foundweekends/giter8/blob/develop/notes/0.5.0.markdown Giter8 recognizes file URLs for local Git repositories, eliminating the need for the giter8 sbt plugin for testing templates. Specify the absolute path to the project directory. ```bash g8 file:///home/nathan/Programming/unfiltered.g8 ``` -------------------------------- ### Apply Giter8 Template from Git URL Source: https://context7.com/foundweekends/giter8/llms.txt Applies a template from any Git repository using its full URL. This supports various Git hosting services like GitLab, Bitbucket, or self-hosted servers. ```bash # Apply template from GitLab $ g8 https://gitlab.com/unfiltered/unfiltered-gitlab.g8.git ``` -------------------------------- ### Apply Giter8 Template from Local Directory Source: https://context7.com/foundweekends/giter8/llms.txt Applies a template directly from a local filesystem path. This is useful for developing or testing templates without pushing them to a remote repository. ```bash # Apply local template $ g8 file://path/to/template ``` -------------------------------- ### Specify Template Tag Source: https://github.com/foundweekends/giter8/blob/develop/docs/02.md Fetch a template from a specific tag in a remote or local repository using the --tag option. ```bash -t, --tag Resolve a template within a given tag ``` -------------------------------- ### Apply Public GitHub Template via Git Protocol Source: https://github.com/foundweekends/giter8/blob/develop/notes/0.5.0.markdown This command applies a public template from GitHub using the git protocol directly. It's a generic way to access templates. ```bash g8 git://github.com/unfiltered/unfiltered.g8.git ``` -------------------------------- ### Apply Template String with Parameters Source: https://context7.com/foundweekends/giter8/llms.txt Applies a template defined as a string with provided parameters, performing string formatting. ```scala // Apply template string with parameters val template = "class $name;format=\"Camel\"$ extends App" val parameters = Map("name" -> "my project") val output = G8.applyTemplate(template, parameters) // Result: "class MyProject extends App" ``` -------------------------------- ### Use Giter8 with sbt new Source: https://github.com/foundweekends/giter8/blob/develop/docs/00.md Integrates Giter8 with sbt's 'new' command for project scaffolding. Ensure sbt version is 0.13.13 or higher. ```bash $ sbt new scala/scala-seed.g8 ``` -------------------------------- ### Render Template Fields with Different Formats Source: https://github.com/foundweekends/giter8/blob/develop/docs/03/a.md Demonstrates various formatting options for a 'name' field with the value 'My Project'. Shows default rendering, lower camel case, upper camel case, normalization, and combined lowercasing with hyphenation. ```giter8 $name$ -> "My Project" ``` ```giter8 $name;format="camel"$ -> "myProject" ``` ```giter8 $name;format="Camel"$ -> "MyProject" ``` ```giter8 $name;format="normalize"$ -> "my-project" ``` ```giter8 $name;format="lower,hyphen"$ -> "my-project" ``` -------------------------------- ### Authenticate with GitHub using g8 Source: https://github.com/foundweekends/giter8/blob/develop/notes/0.4.5.markdown Use this command to authenticate with GitHub using your username and password, separated by a colon. This is useful for private repositories or switching from password authentication. The access token is stored in `~/.g8/config` for future use. ```bash g8 --auth yourname:yourpass ``` -------------------------------- ### Fetch Template from Default Branch Source: https://github.com/foundweekends/giter8/blob/develop/notes/0.2.2.markdown Fetches a template from the master branch of the specified GitHub repository. ```bash g8 user/repo ``` -------------------------------- ### Fetch Template from Specific Branch Source: https://github.com/foundweekends/giter8/blob/develop/notes/0.2.2.markdown Fetches a template from a specific branch (e.g., 'foo') of the specified GitHub repository. ```bash g8 user/repo -b foo ``` -------------------------------- ### Verify SSH Connection to GitHub Source: https://github.com/foundweekends/giter8/blob/develop/docs/02.md Test your SSH connection to GitHub to ensure your SSH keys are set up correctly and your public key is in your GitHub account. This is a prerequisite for accessing private repositories via SSH. ```bash $ ssh -T git@github.com ``` -------------------------------- ### Add GitHub to Known Hosts Source: https://context7.com/foundweekends/giter8/llms.txt Tests the SSH connection to GitHub and adds it to the known hosts file. ```bash # Add GitHub to known hosts $ ssh -T git@github.com ``` -------------------------------- ### Search GitHub Repositories with giter8 Source: https://github.com/foundweekends/giter8/blob/develop/notes/0.6.4.markdown Use the `search` command to find repositories on GitHub that match a given string and end with ".g8". ```bash g8 search unfiltered ``` -------------------------------- ### Specify Output Directory Source: https://github.com/foundweekends/giter8/blob/develop/docs/02.md Specify an output directory for the generated project files using the --out option. This overrides the default behavior of using the 'name' parameter or the current directory. ```bash -o, --out Output directory ``` -------------------------------- ### Specify Template Branch Source: https://github.com/foundweekends/giter8/blob/develop/docs/02.md Fetch a template from a specific branch in a remote or local repository using the --branch option. ```bash -b, --branch Resolve a template within a given branch ``` -------------------------------- ### Login with Password for Giter8 Authentication Source: https://github.com/foundweekends/giter8/blob/develop/notes/0.4.4.markdown Initiates the Giter8 authentication process using a username and password. This method stores an OAuth access token in `~/.g8/config`. ```bash g8 --auth login password ``` -------------------------------- ### List Available giter8 Templates Source: https://github.com/foundweekends/giter8/blob/develop/notes/0.2.0.markdown Query GitHub for available giter8 templates using the `--list` or `-l` flag. This feature was contributed by softprops. ```shell g8 --list ``` -------------------------------- ### SSH Agent Configuration Source: https://github.com/foundweekends/giter8/blob/develop/docs/02.md Set up the SSH_AUTH_SOCK environment variable to use gpg-agent as an SSH agent. This allows giter8 to access private repositories using your SSH keys managed by gpg-agent. ```bash export SSH_AUTH_SOCK="$(gpgconf --list-dirs agent-ssh-socket)" gpgconf --launch gpg-agent ``` -------------------------------- ### Specify Template Subdirectory Source: https://github.com/foundweekends/giter8/blob/develop/docs/02.md Resolve a template located within a specific subdirectory of a remote or local repository using the --directory option. ```bash -d, --directory Resolve a template within the given subdirectory in the repo ``` -------------------------------- ### Prompt for Scaffold Properties Source: https://github.com/foundweekends/giter8/blob/develop/docs/04/00.md The giter8 scaffold plugin will prompt for necessary properties to complete the scaffolding process, as shown when using 'g8Scaffold controller'. ```bash > g8Scaffold controller className [Application]: ``` -------------------------------- ### Apply Giter8 Template from Subdirectory Source: https://context7.com/foundweekends/giter8/llms.txt Applies a template located in a subdirectory of a Git repository. Use the `-d` flag to specify the path to the template directory within the repository. ```bash # Apply template from a subdirectory in the repo $ g8 foundweekends/giter8.g8 -d templates/basic ``` -------------------------------- ### String Formatting Utilities Source: https://context7.com/foundweekends/giter8/llms.txt Provides various string formatting utilities for template parameter processing. ```scala // String formatting utilities G8.upperCamel("my project") // "MyProject" G8.lowerCamel("my project") // "myProject" G8.normalize("My Project") // "my-project" G8.snakeCase("my project") // "my_project" G8.packageDir("com.example") // "com/example" G8.dotReverse("scala.org") // "org.scala" ``` -------------------------------- ### sbt-giter8-scaffold Plugin for Project Scaffolding Source: https://context7.com/foundweekends/giter8/llms.txt Use the sbt-giter8-scaffold plugin to generate boilerplate files in existing projects from local templates. It supports discovering and applying scaffolds. ```Scala // project/scaffold.sbt addSbtPlugin("org.foundweekends.giter8" % "sbt-giter8-scaffold" % "0.18.0") ``` ```Bash # In sbt shell - discover available scaffolds > g8Scaffold controller global model # Apply a scaffold template > g8Scaffold controller className [Application]: UserController # Force overwrite existing files > g8Scaffold model --force # Scaffold templates are stored in .g8 directory project-root/ ├── .g8/ │ ├── controller/ │ │ ├── default.properties │ │ └── app/controllers/$className$.scala │ ├── model/ │ │ ├── default.properties │ │ └── app/models/$className$.scala │ └── global/ │ └── ... ``` -------------------------------- ### Format File Name with Upper Camel Case Source: https://github.com/foundweekends/giter8/blob/develop/docs/03/a.md Apply formatting options to file names using the '__' separator. For instance, '$name__Camel$.scala' with the name 'awesome project' will create 'AwesomeProject.scala'. ```giter8 $name__Camel$.scala ``` -------------------------------- ### Force Overwrite Existing Files Source: https://github.com/foundweekends/giter8/blob/develop/docs/02.md Use the --force option to overwrite any existing files in the destination folder during template generation. ```bash -f, --force Force overwrite of any existing files in output directory ``` -------------------------------- ### Giter8 Template Properties Configuration Source: https://context7.com/foundweekends/giter8/llms.txt Defines template parameters, default values, and conditional logic within the `default.properties` file. Supports variable substitution, formatting, and Maven version lookups. ```properties # default.properties - Define template fields and defaults name = My Project organization = com.example package = $organization$.$name;format="norm"$ version = 0.1.0-SNAPSHOT scala_version = 2.13.12 # Reference other fields in defaults github_id = githubber developer_url = https://github.com/$github_id$ project_url = https://github.com/$github_id$/$name;format="norm"$ # Conditional flags (truthy values: "y", "yes", "true") scala3 = yes include_tests = yes # Maven version lookup - fetches latest version from Maven Central unfiltered_version = maven(ws.unfiltered, unfiltered_2.13) # Maven stable version lookup - excludes milestones and RCs scalatest_version = maven(org.scalatest, scalatest_2.13, stable) # Verbatim files - excluded from template processing verbatim = *.html *.js *.css images/* ``` -------------------------------- ### Add Giter8 sbt Plugin Source: https://github.com/foundweekends/giter8/blob/develop/docs/03/b.md Add the Giter8 sbt plugin as a source dependency in `project/giter8.sbt` to upgrade an existing template project. ```scala addSbtPlugin("org.foundweekends.giter8" % "sbt-giter8" % "$version$") ``` -------------------------------- ### Configure GitHub Username Source: https://github.com/foundweekends/giter8/blob/develop/notes/0.4.3.markdown Set your GitHub username globally for giter8. This is required for accessing private repositories. ```bash git config --global github.user your-user-name ``` -------------------------------- ### Fetching Latest Maven Versions Source: https://github.com/foundweekends/giter8/blob/develop/docs/03/00.md Use the `maven(groupId, artifactId)` format to automatically fetch the latest version of a library from Maven Central. This avoids hardcoding versions. ```properties name = My Template Project description = Creates a giter8 project template. unfiltered_version = maven(ws.unfiltered, unfiltered_2.11) ``` -------------------------------- ### Add Giter8 Scaffold Plugin to sbt Source: https://github.com/foundweekends/giter8/blob/develop/docs/04/00.md Add this line to your project/scaffold.sbt file to enable the giter8 scaffold plugin. ```scala addSbtPlugin("org.foundweekends.giter8" % "sbt-giter8-scaffold" % "$version$") ``` -------------------------------- ### Verbatim Arguments with .gitignore Format Source: https://github.com/foundweekends/giter8/blob/develop/notes/0.10.0.markdown Giter8 0.10.0 supports .gitignore format for verbatim fields, allowing patterns like '/foo/**/*.html'. ```Giter8 Configuration /foo/**/*.html ``` -------------------------------- ### Use TemplateRenderer Interface Source: https://context7.com/foundweekends/giter8/llms.txt Utilizes the G8TemplateRenderer interface to render a template from a directory to a specified output directory. ```scala // Use TemplateRenderer interface val renderer = G8TemplateRenderer val rendered = renderer.render( templateDirectory = new File("./my-template.g8"), workingDirectory = new File("."), arguments = Seq("--name=example"), forceOverwrite = true, outputDirectory = Some(new File("./output")) ) ``` -------------------------------- ### Configure Git for SSH Source: https://context7.com/foundweekends/giter8/llms.txt Configures Git to use SSH for GitHub connections by setting up an 'insteadOf' URL in .gitconfig. ```bash # Configure git to use SSH for GitHub # ~/.gitconfig [url "ssh://git@github.com"] insteadOf = https://github.com ``` -------------------------------- ### Force Overwrite Existing Files with Giter8 Scaffold Source: https://github.com/foundweekends/giter8/blob/develop/docs/04/00.md Pass the --force flag after the template name to overwrite existing files when using g8Scaffold. ```bash > g8Scaffold model --force ``` -------------------------------- ### sbt-giter8 Plugin for Template Testing Source: https://context7.com/foundweekends/giter8/llms.txt Integrate the sbt-giter8 plugin to test templates locally within an sbt environment. This allows for running templates and scripted tests. ```Scala // project/giter8.sbt addSbtPlugin("org.foundweekends.giter8" % "sbt-giter8" % "0.18.0") ``` ```Bash # In sbt shell - apply template with defaults to target/g8 > g8 # Run scripted test (applies template and runs test script) > g8Test # Template project structure my-template.g8/ ├── project/ │ ├── giter8.sbt # Plugin declaration │ └── default.properties # Alternative location for properties ├── src/ │ ├── main/ │ │ └── g8/ # Template source files │ │ ├── default.properties │ │ ├── build.sbt │ │ └── src/main/scala/$package$/Main.scala │ └── test/ │ └── g8/ │ └── test # Scripted test file (e.g., ">test") └── build.sbt ``` -------------------------------- ### Revert to Normal giter8 Version Source: https://github.com/foundweekends/giter8/wiki/Installing-local-version-of-giter8 To revert to the normal, stable version of giter8, simply run cs foundweekends/giter8 from your shell. ```bash cs foundweekends/giter8 ``` -------------------------------- ### Apply Giter8 Template from Specific Branch or Tag Source: https://context7.com/foundweekends/giter8/llms.txt Applies a template from a specific branch or tag within a Git repository. Use the `-b` flag for branches and `-t` for tags. ```bash # Apply template from a specific branch $ g8 unfiltered/unfiltered.g8 -b develop ``` ```bash # Apply template from a specific tag $ g8 unfiltered/unfiltered.g8 -t v1.0.0 ``` -------------------------------- ### Resolve Latest Library Version with ls.implicit.ly Source: https://github.com/foundweekends/giter8/blob/develop/notes/0.3.2.markdown Use 'ls' to specify a library name and authoritative GitHub account to resolve the latest published version. This is useful for giter8 templates to dynamically fetch the newest plugin versions. ```scala name = My Template Project giter8_version = ls(giter8-plugin, n8han) description = Creates a giter8 project template. ``` -------------------------------- ### Template License Text Source: https://github.com/foundweekends/giter8/blob/develop/docs/03/00.md Use this CC0 1.0 public domain dedication for your template license. It waives all copyright and related rights. ```text Template license ---------------- Written in by [other author/contributor lines as appropriate] To the extent possible under law, the author(s) have dedicated all copyright and related and neighboring rights to this template to the public domain worldwide. This template is distributed without any warranty. See . ``` -------------------------------- ### Configure GitHub Password Source: https://github.com/foundweekends/giter8/blob/develop/notes/0.4.3.markdown Set your GitHub password globally for giter8. This is required for accessing private repositories. Note: The password is stored in clear text in ~/.gitconfig. ```bash git config --global github.password your-password ``` -------------------------------- ### Escaping Dollar Signs in Giter8 Templates Source: https://github.com/foundweekends/giter8/blob/develop/docs/03/00.md Demonstrates how to escape dollar signs using double backslashes to prevent StringTemplate from interpreting them as variable substitutions. ```scala val foo = "foo" val bar = "bar" println(s"\$foo\$bar") ``` -------------------------------- ### Mill Plugin for Template Testing Source: https://context7.com/foundweekends/giter8/llms.txt Utilize the external Mill plugin as an alternative to sbt for testing giter8 templates. It allows defining validation targets to run after template generation. ```Scala // build.sc import $ivy.`io.chris-kipp::mill-giter8::0.2.0` import io.kipp.mill.giter8.G8Module object g8 extends G8Module { // Define targets to run after template generation override def validationTargets = Seq("example.compile", "example.fix", "example.reformat") } ``` ```Bash # Validate template generation and run targets $ mill g8.validate ``` -------------------------------- ### Update Giter8 with Coursier Source: https://github.com/foundweekends/giter8/blob/develop/docs/01.md Use this command to update giter8 to the latest version using Coursier. ```bash cs update g8 ``` -------------------------------- ### Fetching Latest Stable Maven Versions Source: https://github.com/foundweekends/giter8/blob/develop/docs/03/00.md Specify `stable` as the third argument in `maven(groupId, artifactId, stable)` to retrieve only the latest stable release, excluding milestones and release candidates. ```properties name = My Template Project description = Creates a giter8 project template. scalatest_version = maven(org.scalatest, scalatest_2.11, stable) ``` -------------------------------- ### Giter8 Template Comment Syntax Source: https://github.com/foundweekends/giter8/blob/develop/docs/03/00.md Use $! and !$ delimiters to create comments within Giter8 templates that will not be included in the generated output. ```java $! This comment won't appear in the output !$ // This comment will appear in the output $! This multiline comment won't appear either No matter how long it is Internal $substitutions$ are ignored. Even $invalid$ ones. ! /* * This comment is output and can contain $substitutions$ */ ``` -------------------------------- ### Skipping Folders Conditionally in Giter8 Source: https://github.com/foundweekends/giter8/blob/develop/docs/03/00.md Demonstrates how to skip a folder while preserving its nested structure by using a conditional expression. The `.` character is used to denote skipping. ```giter8 src/main/g8 ├── parent_folder │   ├── $if(cond.truthy)$skip_folder$else$.$endif$ | | └── child_file ``` -------------------------------- ### Conditional Rendering in Giter8 Templates Source: https://github.com/foundweekends/giter8/blob/develop/docs/03/00.md Use `.truthy` on fields to enable conditional rendering of Scala versions in build files. Ensure the field is defined in the template's properties. ```properties scala212 = yes scala211 = no ``` ```stringtemplate $if(scala212.truthy)$ scalaVersion := "2.12.3" $elseif(scala211.truthy)$ scalaVersion := "2.11.11" $else$ scalaVersion := "2.10.6" $endif$ ``` -------------------------------- ### Giter8 Template Field Substitution Source: https://github.com/foundweekends/giter8/blob/develop/docs/03/00.md Define template fields using bracketed syntax like $fieldname$. These fields are processed by the StringTemplate engine. ```properties name = URL Builder github_id=githubber developer_url=https://github.com/$github_id$ project_url=https://github.com/$github_id$/$name;format="norm"$ ``` -------------------------------- ### Override SSH Known Hosts File Source: https://github.com/foundweekends/giter8/blob/develop/docs/02.md Specify a custom SSH known hosts file using the --known-hosts option. If unset, giter8 will attempt to guess the location. ```bash -h, --known-hosts SSH known hosts file. If unset the location will be guessed. ``` -------------------------------- ### Conditional Directory Inclusion in Giter8 Source: https://github.com/foundweekends/giter8/blob/develop/docs/03/00.md Conditionally include or exclude directories and their contents within the template structure. Use `endif` to close conditional blocks. ```bash src/main/g8 ├── $name__normalize$ │   ├── $if(jvm.truthy)$jvm$endif$ │   │   └── src │   │   └── main │   │   └── scala │   │   └── $organization__packaged$ │   │   └── $name;format="Camel"$.scala ``` -------------------------------- ### Define Latest Maven Artifact Version in giter8 Source: https://github.com/foundweekends/giter8/blob/develop/notes/0.6.7.markdown Use the `maven(groupId, artifactId)` syntax in `default.properties` to automatically resolve the latest version of a Maven artifact. This is particularly useful for libraries published with Scala version identifiers in their artifact IDs. ```properties unfiltered_version = maven(net.databinder, unfiltered_2.11) ``` -------------------------------- ### Format Template Field to Upper Camel Case Source: https://github.com/foundweekends/giter8/blob/develop/docs/03/a.md Use the 'format="Camel"' option to format a template field into upper camel case. This is useful for generating class names or identifiers. ```giter8 $name;format="Camel"$ ``` -------------------------------- ### Conditional Template Content Source: https://context7.com/foundweekends/giter8/llms.txt Include or exclude content based on template field values using `$if`, `$elseif`, and `$else$` directives. Fields with 'y', 'yes', or 'true' evaluate to truthy. ```Properties # default.properties scala3 = yes scala212 = no include_circe = yes ``` ```Scala // In template files - conditional content $if(scala3.truthy)$ scalaVersion := "3.3.1" $elseif(scala212.truthy)$ scalaVersion := "2.12.18" $else$ scalaVersion := "2.13.12" $endif$ $if(include_circe.truthy)$ libraryDependencies ++= Seq( "io.circe" %% "circe-core" % "0.14.6", "io.circe" %% "circe-parser" % "0.14.6" ) $endif$ ``` ```Bash # Conditional directories and files in template structure src/main/g8/ ├── $name__normalize$/ │ ├── $if(jvm.truthy)$jvm$endif$/ │ │ └── src/main/scala/$organization__packaged$/ │ │ └── $name;format="Camel"$.scala # Skip directory but keep nested content (use "." as placeholder) src/main/g8/ ├── parent_folder/ │ ├── $if(cond.truthy)$skip_folder$else$.$endif$/ │ │ └── child_file ``` -------------------------------- ### Template Comments Source: https://context7.com/foundweekends/giter8/llms.txt Add comments to templates that are excluded from the generated output using `$!` and `!$` delimiters. These comments can be single or multi-line. ```Scala $! This comment won't appear in the output ולא$ // This comment will appear in the output $! This multiline comment won't appear either. Internal $substitutions$ are ignored. Even $invalid$ ones. !$ /* * This comment is output and can contain $name$ substitutions */ ``` -------------------------------- ### Access Private GitHub Repository via SSH Source: https://github.com/foundweekends/giter8/blob/develop/notes/0.5.0.markdown If a private GitHub repository cannot be accessed anonymously, giter8 will attempt to use an SSH endpoint. Ensure your SSH keys are configured correctly for access. ```bash git@github.com:unfiltered/unfiltered.g8.git ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.