Code Monkey home page Code Monkey logo

amble's Introduction

amble

CI Build Status Release Tag Build Status License Docs Latest Version rustc 1.70+

First class, scalable rust project generator with batteries included. Amble is stable

Install | User Docs | Crate Docs | Reference | Contributing | License

What is amble?

amble is a cli application for generating rust projects with batteries included. By using a workspace and sub-crates, amble scales to any number of crates.

You can think of amble as an extension of cargo init. Cargo provides convenience methods for generating new project structures, the two primary types being a library or a binary project. Below is an example of the directory structure generated by cargo init --lib. (A binary project would only differ in having a main.rs file instead of lib.rs).

project
├─ Cargo.toml
└─ src
   └─ lib.rs

amble provides a more extensive cli command for generating project directory structures with workspaces. Library sub-crates are nested inside the cannonical crates/ directory, while binary crates are nested inside the bin/ directory. A top-level Cargo.toml file defines a workspace including the binaries and libraries as well as shared package metadata and dependencies, minimizing inconsistencies across the sub-crates. amble also exposes the --lib and --bin flags which fallback to cargo init and create the default cargo init file structure with all amble batteries included and available through cli flags.

Below is an example waterfall directory structure output for when amble is run with the argument project as the project name.

project
├─ Cargo.toml
├─ bin
│  └─ example
│     ├─ Cargo.toml
│     └─ src
│        └─ main.rs
└─ crates
   └─ common
      ├─ Cargo.toml
      └─ src
         └─ lib.rs

As detailed in Usage below, this output is generated by running amble project --dry-run.

Usage

Install amble using cargo.

cargo install amble

Alternatively, amble can be built from source.

git clone [email protected]:refcell/amble.git && cd amble
cargo build --release

To run amble, it is recommended to first run it in dry mode which will print a waterfall directory structure for the files that would be created when run without dry mode. Simply run amble <project_name> --dry-run, where <project_name> is the name of the project/directory you want to create.

By default, amble uses the current directory for the project name, so it is perfectly acceptable to run amble --dry-run, which will just use . as the project path. Note, amble will exit if it finds cargo artifacts in the directory you chose to execute in.

To run amble out of dry mode, just run amble!

A pre-defined github action ci workflow can be automatically generated by passing in the --with-ci flag to amble. This would generate a directory structure as follows (amble --dry-run --with-ci).

.
├─ Cargo.toml
├─ bin
│  └─ example
│     ├─ Cargo.toml
│     └─ src
│        └─ main.rs
├─ crates
│  └─ common
│     ├─ Cargo.toml
│     └─ src
│        └─ lib.rs
└─ .github
   └─ workflows
      └─ ci.yml

Amble also provides fallthrough methods for generating cargo init library and binary projects with batteries such as a templated readme, github action ci workflows, and licensing. The flags to pass through to cargo init operations are injective, meaning amble --bin will pass through to cargo init --bin and amble --lib will pass through to cargo init --lib. As usual, any other valid amble flag can be provided along with the --lib and --bin flags.

CLI Flags

Below is an inexhaustive list of the main cli flags. These are subject to change and new ones can be added. To view a more up-to-date list, run the amble --help command locally.

First class, scalable rust project generator with batteries included.

Usage: amble [OPTIONS] [PROJECT_DIR]

Arguments:
  [PROJECT_DIR]  The path to the project directory. By default, the current working directory is used. If any rust artifacts are detected in the specified or unspecified directory, an error will be thrown [default: .]

Options:
  -v, --v...                         Verbosity level (0-4)
      --dry-run                      Dry run mode. If this flag is provided, the cli will not execute commands, printing the directories and files that would be created instead
      --overwrite                    Overwrite existing files. If this flag is provided, the cli will overwrite existing files
      --bare                         Bare mode. Only for `--bin` and `--lib` flags. If specified, generated files will be the basic `cargo init` files
  -n, --name <NAME>                  The project name. This will be used for the binary application name [default: example]
  -w, --with-ci                      Add github actions ci workflow
  -c, --ci-yml <CI_YML>              Copy the specified ci workflow file to the project's `.github/workflows/` directory
  -a, --authors <AUTHORS>            Override the project authors
  -b, --bin                          Builds a cargo binary project
  -l, --lib                          Builds a cargo library project
      --without-readme               Prevents a readme from being generated
      --full                         Full generates a full project structure including license, ci, gitignore, etc
      --etc                          Adds an `etc/` directory to the project. This _Et Cetera_ directory is used for storing miscellaneous files
      --assets                       Adds template assets to the `etc/` directory of the generate project. Will be run automatically if the `--full` flag is provided
      --license                      Adds an MIT License to the project. The MIT License type can be overridden with the `--with-license` flag
      --gitignore                    Adds a Gitignore file to the project
  -d, --description <DESCRIPTION>    Specifies the description of the project in the top-level `Cargo.toml` workspace
      --dependencies <DEPENDENCIES>  Adds these dependencies to the top-level `Cargo.toml` workspace alongside the default dependencies
      --list                         Lists the default dependencies
      --with-license <WITH_LICENSE>  License Override. This will override the default MIT License. The license type must be a valid SPDX license identifier
  -h, --help                         Print help
  -V, --version                      Print version

You can generate this output by running amble --help.

Contributing

All contributions are welcome! Experimentation is highly encouraged and new issues are welcome.

Troubleshooting & Bug Reports

Please check existing issues for similar bugs or open an issue if no relevant issue already exists.

License

This project is licensed under the MIT License. Free and open-source, forever. All our rust are belong to you.

amble's People

Contributors

quangkeu95 avatar refcell avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

quangkeu95

amble's Issues

feat: Hat Tip Mode

Description

Find a cool directory structure you like, such as amble itself?

This mode should enable amble to pull down a specified github repo and try to build a similar structure using it's components.

This may require refactoring of core amble modules and commit-execute scheme to allow for changes to dynamically be "rolled back" if needed.

This would be called hat tip mode and should also provide a hat tip at the bottom of the generated readme.

fix(gitignore): Dedup Gitignore Values

Description

Writing to the .gitignore file in append mode can wind up duplicating a bunch of values.

Instead, the contents of the gitignore file should be properly parsed and their values deduped with the additional gitignore contents.

feat: Refactor Crate

Description

Refactor out amble modules into a separate library crate. This would allow amble to generate projects that import amble's library crate itself for utility functions such as telemetry and other future added helpers, especially for binary apps.

A follow-on issue should split out the work to add this library to binary projects and automatically construct a cli application using clap and amble telemetry.

amble's minor version can be bumped following the refactor done here. This should be a sizable change.

feat(cli): Full Flag

Description

As the number of graceful and prompt-fallible flags grow, it becomes cumbersome to run amble without forgetting flags.

This ticket is to introduce a --full flag that will automatically enable common flags including (but not limited too):

  • ci
  • gitignore
  • licensing

chore(amble): Readme Doc Comment

Description

Since crate doc comments were inlined, doc comments in the README.md are no longer run. Use the doc comment crate to execute these doc comments in lib.rs.

chore(root): Fetch or Construct Repository and Homepage Manifest Fields Dynamically

Description

Currently the repository and homepage manifest fields are empty in the top-level Cargo.toml.

These could be populated by constructing urls using the project name and author like so:

https://github.com/{author}/{project}

There should also be cli flags to allow the user to override this construction with --repository and --homepage fields.

feat(root): Graceful Gitignore Generation

Description

Often, .gitignore files will be pre-generated by github or other project initializers.

amble should have a --gitignore bool flag that either creates the default rust .gitignore file or gracefully appends rust gitignore entries to an existing .gitignore file.

feat(git): Create Labels

Description

Follows #55

Add a --with-labels flag that tells amble to post labels to the project git repository.

When --full is passed, this should happen automatically.

If the directory is not a git repo, use inquire to generate a confirmation for amble to init the directory as a git repo.

fix(cargo): Fallthrough Cargo TOML Stubs

Description

When using the fall through cargo init binary and library creation methods, the generated Cargo.tomls are defaults with minimal info.

Workspace-level package metadata should be applied to the Cargo.toml manifests for these fall through amble --lib and --bin flags, as well as dependencies.

feat(root): Description Override

Description

Add a --description flag to amble that allows the user to override the top-level workspace package description.

This issue should not touch the binary description - that should be artificially enhanced and will be tackled in another issue.

chore(root): Allow Dependency Overrides

Description

Currently, dependencies are hardcoded in the root module.

There should be a cli argument that allows the user to override the dependencies with a list of dependency crate names as a list of strings. Their versions should then be fetched dynamically following #2.

feat(bin): CLI Stub and Telemetry Setup

Description

Following a refactor in #30, the binary crate stub should optionally create a cli application (maybe by default and require --bare for a blank/empty binary app?) using clap and amble telemetry. This should also apply to the cargo init fallthrough.

fix(root): Prompt User on CI Overwrite

Description

Currently, amble only checks if a Cargo.toml exists in the directory and then prompts the user if they want to proceed and overwrite the file unless the --overwrite flag was passed into amble.

If the --with-ci flag is passed and --overwrite is not, amble should prompt the user if ci is present and it didn't already prompt the user if a Cargo.toml exists.

fix(ci): Graceful Release on Duplicate Version

Description

Currently the release workflow will fail if the crate version is already published.

This should change so that crate publishing only happens if the semver is bumped, and allow the ci job to pass if not.

feat(git): Create Git Repository

Description

Adds a --git flag to amble that allows amble to automatically create a github repo under the user's username.

The --git flag should be of type Option<Option<String>> where the inner string is the user's github username. If it is not specified, amble should try to grab the username like done for the cargo toml repository url field.

When the --full flag is provided, git repo generation should be enabled by default.

feat(root): Generate Templated Readme

Description

Generate a readme similar to that of amble itself.

This should be done with a --with-readme flag. If the readme file already exists, amble should prompt the user if they want to overwrite it unless the --overwrite flag is passed into amble.

fix(license): Dynamic License Imputation

Description

Dynamically fetched licenses from spdx use a host of template string styles for substitution.

Currently, amble only imputes the MIT License <year> and <copyright holders> template strings, but a more clever heuristic should be used to impute other template strings. An example for this is running amble with --with-license apache, which fails to substitute the values [yyyy] and [name of copyright owner] for the chrono year and fetched username.

feat(git): Branch Protection Rules

Description

Automatically created main branch protection rule if a git repository is generated or the project directory is detected to be a git repo.

This should behave similarly to labels.

fix(ci): Workspace Release Flow

Description

amble currently copies over github action workflow files to the generated project.

When this project is a workspace, the release workflow won't work since publishing a workflow isn't supported natively.

Instead of manually running cargo publish inside a bash shell in the github action, we could use something like cargo release --workspace to achieve workspace publishing.

Alternatively, we could also support a release pr workflow with something like release-plz.

This would probably be best done after the amble refactor in #30.

fix(ci): Github Release Descriptions

Description

Update the Github Release workflow to provide verbose and meaningful release descriptions.

Is it possible to use an llm for auto-generating this? Maybe there's already a published llm github action helper?

The downside of depending on more external github action workflows like an llm is we would need to add another repo secret, which generated projects won't have.

fix(preamble): Decolor License Fetching + Async Feature

Description

Expose decolored license fetching with blocking calls. This prevents downstream preamble library users from silent coloring, making the call explicitly blocking. Optionally, an async feature should be added that enables colored function calls.

Since preamble's pipeline is executed synchronously, the async feature should not be enabled so that preamble's license fetching is performed synchronously. This should reduce additional tokio runtime overhead.

feat(root): Mock Assets

Description

Following #19, mock assets like a mock project logo and banner should be optionally generated and placed inside the et cetera, etc/, directory.

This should be performed via a --assets flag and also be done by default when the --full flag is specified.

feat(root): License Generation

Description

Automatically generate an MIT LICENSE file at the root. If it already exists and the user didn't pass --overwrite, prompt the user for confirmation to overwrite the file.

feat(root): Et Cetera Directory

Description

Create an etc (et cetera) directory to hold things like a project logo, banner, et cetera.

This should automatically be created when the --full flag is provided.

feat(root): License Override

Description

Following #10, amble has a --with-license flag to allow the user to specify the type of license to use, overriding the default MIT selection.

Even though a different, valid spdx license identifier can be specified, amble doesn't support dynamic license fetching and requires the mit license, prompting the user to "fallback" on this license type. This issue is to add support for fetching licenses in a dynamic way, or if not possible, supporting license generation for a host of popular, widely used licenses.

Note, the github rest api requires a bearer token to auth license requests. There may be a clean ux approach to querying github through gh or some other local user-level config if available.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.