Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "new" command for scaffolding projects #15

Merged
merged 32 commits into from
May 19, 2021

Conversation

mbpolan
Copy link
Member

@mbpolan mbpolan commented Feb 17, 2021

Proposed changes

This PR adds a new command to the CLI. The intent is to quickly scaffold a new runiac project with recommended directory structures. The usage is to run runiac new and let the interactive prompts guide the user. Depending on the choices the user makes, the following actions are done:

  • A new directory is created with the project name
  • git init is run if it is installed and the user chooses to use it
  • If an example or third-party template is used, the CLI will download that template contents
  • If a custom project setup is used, then:
    • A runiac.yml is created
    • An entrypoint.sh is created
  • runiac init is executed in the target directory with the correct base Docker image

Output of a custom scaffold using a single set of steps:

$ runiac new my-project --template simple --primary-region us-central1 --runner terraform --scm none
🍺 Initialized a new project in directory: my-project.
$ tree -a my-project/
my-project/
├── .git
├── .gitignore
└── step1_initial
├── .runiac

Output of a custom scaffold using the tracks template:

$ runiac new my-project --template tracks --primary-region us-central1 --runner terraform --scm none
🍺 Initialized a new project in directory: my-project.
$ tree -a my-project/
my-project/
├── .git
├── .gitignore
└── tracks
    └── initial
        └── step1_initial
├── .runiac

Issues for these changes

N/A

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Refactor (changes to code, which do not change application behavior)

Checklist

  • I have filled out this PR template
  • I have read the CONTRIBUTING doc
  • I have added automated tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (README.md, CHANGELOG.md, etc. - if appropriate)

Dependencies and Blockers

N/A

Relevant Links

N/A

Further comments

Much of this new command takes inspiration from other various CLIs, including expo init and npm init. The idea is to give the user either guided prompts to give answers, or command line arguments for powerusers.

runiac-new

@tiny-dancer
Copy link
Contributor

@mbpolan love it. Can you expand a little on how the templates work? For example, could any of the examples be a template?

@tiny-dancer tiny-dancer self-requested a review February 21, 2021 04:25
@mbpolan
Copy link
Member Author

mbpolan commented Feb 24, 2021

@tiny-dancer The idea with these templates is to set up a "starter" project based on the choices the user makes in the prompts, similar to how CRA/expo will initialize a working project for you to start hacking. Right now, this just creates the necessary runiac config files and skeleton directories.

Ideally I'd like to bootstrap these with something like the examples, just haven't settled on an approach yet. I've looked at a few ideas on how to bundle those static files with our CLI. The most promising feature is the embed package, but that requires Go 1.16. For our version of Go, some possibilities include a packager like rice. Was planning on this being the next iteration of this feature.

@tiny-dancer
Copy link
Contributor

tiny-dancer commented Feb 25, 2021

@mbpolan hugo or gatsby might be a good reference here as well. TL/DR instead of bundling with the cli pull over the wire in a conventionalized way.

that could lead to something like https://www.gatsbyjs.com/starters/

@CLAassistant
Copy link

CLAassistant commented Mar 2, 2021

CLA assistant check
All committers have signed the CLA.

@mbpolan
Copy link
Member Author

mbpolan commented Mar 22, 2021

@tiny-dancer I've reworked this PR a bit to be more general. I also dropped the command line arguments I originally had in favor of interactive prompts. A user can now run runiac new and take one of three options:

  1. Use one of our templates: the CLI will download the contents of the appropriate subdirectory from runiac/examples (see updated gif)
  2. Use a third-party template: the CLI will ask for a URL and download the template as given
  3. Use a custom setup: same as the PR was originally; the CLI will prompt the user and build a scaffolded project directory

@tiny-dancer
Copy link
Contributor

In conjunction with this pull request will also be looking to have the default container be set to a latest-kitchen-sink which has azure, gcp, aws and terraform. It'll be the simplest to get started and then more advanced users can start specificy their desired container/version/etc. @mbpolan thoughts?

@tiny-dancer
Copy link
Contributor

Also take note runiac.io and docs have a repo of their own: https://github.com/runiac/website

@mbpolan
Copy link
Member Author

mbpolan commented Apr 29, 2021

@tiny-dancer Makes sense to me. I swapped the default container to alpine-azure-gcloud for the time being in this PR to account for the various examples we support, but a consolidated "kitchen sink" base image would be a good next step.

@github-actions
Copy link

github-actions bot commented May 17, 2021

Unit Test Results

  1 files  15 suites   0s ⏱️
50 tests 50 ✔️ 0 💤 0 ❌

Results for commit e542a38.

♻️ This comment has been updated with latest results.

@tiny-dancer tiny-dancer merged commit 085c266 into Optum:main May 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants