Skip to content

Commit

Permalink
chore: migrate very_good_dart_cli (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
alestiago authored Feb 19, 2024
1 parent 0c350d2 commit 8a43eed
Show file tree
Hide file tree
Showing 43 changed files with 1,703 additions and 3 deletions.
68 changes: 68 additions & 0 deletions .github/workflows/very_good_dart_cli.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: very_good_dart_cli

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

on:
push:
paths:
- .github/workflows/very_good_dart_cli.yaml
- "very_good_dart_cli/**"
branches:
- main
pull_request:
paths:
- .github/workflows/very_good_dart_cli.yaml
- "very_good_dart_cli/**"
branches:
- main

jobs:
brick:
runs-on: ubuntu-latest

strategy:
matrix:
dart-version:
# The minimum Dart SDK version supported by the package,
# refer to https://docs.flutter.dev/development/tools/sdk/releases.
- "3.1.0"
- "stable"

steps:
- name: 📚 Git Checkout
uses: actions/checkout@v4

- name: 🎯 Setup Dart
uses: dart-lang/setup-dart@v1
with:
sdk: ${{ matrix.dart-version }}

- name: 🧱 Mason Make
run: |
dart pub global activate mason_cli
mason get
mason make very_good_dart_cli -c very_good_dart_cli/config.json -o output --on-conflict overwrite
- name: 📦 Install Dependencies
run: dart pub get --directory output/test_cli

- name: ✨ Check Formatting
run: dart format --set-exit-if-changed output/test_cli

- name: 🕵️ Analyze
run: dart analyze --fatal-infos --fatal-warnings output/test_cli

- name: 🧪 Run Tests
run: |
dart pub global activate coverage 1.2.0
cd output/test_cli
dart test -j 4 --coverage=coverage
dart pub global run coverage:format_coverage --lcov --check-ignore --in=coverage --out=coverage/lcov.info --packages=.dart_tool/package_config.json --report-on="lib"
cd ../../
- name: 📊 Check Code Coverage
uses: VeryGoodOpenSource/very_good_coverage@v2
with:
path: output/test_cli/coverage/lcov.info
21 changes: 21 additions & 0 deletions .github/workflows/very_good_dart_cli_hooks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: very_good_dart_cli_hooks

on:
pull_request:
paths:
- ".github/workflows/very_good_dart_cli_hooks.yaml"
- "very_good_dart_cli/hooks/**"
push:
branches:
- main
paths:
- ".github/workflows/very_good_dart_cli_hooks.yaml"
- "very_good_dart_cli/hooks/**"

jobs:
build:
uses: VeryGoodOpenSource/very_good_workflows/.github/workflows/dart_package.yml@v1
with:
working_directory: "very_good_dart_cli/hooks"
analyze_directories: "test"
report_on: "post_gen.dart"
4 changes: 3 additions & 1 deletion mason.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@ bricks:
very_good_core:
path: very_good_core
very_good_wear_app:
path: very_good_wear_app
path: very_good_wear_app
very_good_dart_cli:
path: very_good_dart_cli
3 changes: 2 additions & 1 deletion very_good_core/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
analyzer:
exclude: [brick/__brick__/**]
exclude:
- __brick__/**
15 changes: 15 additions & 0 deletions very_good_dart_cli/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Files and directories created by pub
.dart_tool/
.packages
pubspec.lock

# Android studio and IntelliJ
.idea

# Files and directories created by mason
.mason/
mason-lock.json
output/

# Files and directories created by MacOS
.DS_Store
73 changes: 73 additions & 0 deletions very_good_dart_cli/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# 0.5.1

- feat: upgrade to very_good_analysis ^5.1.0

# 0.5.0

- feat: update very good analysis to v5 and fix patch
- feat: bump Dart SDK to >=3.0.0 <4.0.0

# 0.4.0

- feat!: bump min Dart SDK to 2.19.0

# 0.3.3

- chore: support dart sdk 2.18.0

# 0.3.2

- feat: update workflows, add spellcheck
- fix: remove unused pub updater from test

# 0.3.1

- feat: upgrade to `very_good_analysis 4.0.0`

# 0.3.0

- feat: add completion

# 0.2.3

- feat: upgrade to Dart 2.19

# 0.2.2

- fix: update silently fails when the sdk doesnt support most recent version

# 0.2.1

- fix: windows path resolution
- feat: add ci concurrency group to workflow

# 0.2.0

- **BREAKING** feat: add `publishable` flag (defaults to `false`)

# 0.1.4

- docs: remove copyright header and license from generated code

# 0.1.3

- fix: update prompt on update

# 0.1.2

- chore(deps): upgrade to mason_logger 0.2.0
- fix: use available global constant for executable name

# 0.1.1

- feat: upgrade to very_good_analysis 3.1.0

# 0.1.0

- feat: upgrade to Dart 2.18
- feat: upgrade to very_good_analysis 3.0.2
- feat: add dependabot integration

# 0.0.1

- feat: initial release 🎉
110 changes: 110 additions & 0 deletions very_good_dart_cli/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
# 🦄 Contributing to Very Good Dart CLI

This CONTRIBUTING file is for a developer that wants to modify or contribute to the Very Good Dart CLI template. If you are interested in solely generating a project using Very Good Dart CLI, please refer to the [README](README.md) file.

## Opening an issue

We highly recommend [creating an issue][bug_report_link] if you have found a bug, want to suggest a feature, or recommend a change. Please do not immediately open a pull request. Opening an issue first allows us to reach an agreement on a fix before you put significant effort into a pull request.

When reporting a bug, please use the built-in [Bug Report](https://github.com/VeryGoodOpenSource/very_good_dart_cli/issues/new/choose) template and provide as much information as possible including detailed reproduction steps. Once one of the package maintainers has reviewed the issue and we reach an agreement on the fix, open a pull request.

[bug_report_link]: https://github.com/VeryGoodOpenSource/very_good_dart_cli/issues

## Developing for Very Good Dart CLI

To develop for Very Good Dart CLI you will need to become familiar with Very Good Ventures processes and conventions:

### Setting up your local development environment

1. Install a valid [Dart SDK](https://dart.dev/get-dart) in your local environment. If you have Flutter installed you'll have the Dart SDK. Compatible Flutter SDK versions with Very Good Dart CLI can be found within the [Flutter release archive](https://docs.flutter.dev/release/archive), ensure it has a Dart version compatible with [Very Good Dart CLI's Dart version constraint](<brick/__brick__/{{project_name.snakeCase()}}/pubspec.yaml>).

2. Install [Mason](https://github.com/felangel/mason/tree/master/packages/mason_cli#installation) in your local environment:

```sh
# 🎯 Activate Mason from https://pub.dev
dart pub global activate mason_cli
```

💡 **Note**: If you're not familiar with Mason, read its [documentation](https://docs.brickhub.dev/) or watch our [Mason Demonstration](https://www.youtube.com/watch?v=G4PTjA6tpTU).

3. Get all bricks in Very Good Dart CLI's `mason.yaml`:

```sh
# 📂 Get all bricks in Very Good Dart CLI (from project root):
mason get
```

4. Generate the template locally:

```sh
# 🧱 Generate a project using the local Very Good Dart CLI version
mason make very_good_dart_cli --config-path brick/config.json --output-dir output --watch
```

This will generate a project using Very Good Dart CLI under [`output`](output) with the variables specified by the [configuration](brick/config.json) file. When any file under [`__brick__`](brick/__brick__/) is changed the project will be regenerated.

### Creating a Pull Request

Before creating a Pull Request please:

1. [Fork](https://docs.github.com/en/get-started/quickstart/contributing-to-projects) the [GitHub repository](https://github.com/VeryGoodOpenSource/very_good_dart_cli) and create your branch from `main`:

```sh
# 🪵 Branch from `main`
git branch <branch-name>
git checkout <branch-name>
```

Where `<branch-name>` is an appropriate name describing your change.

2. Get all bricks in Very Good Dart CLI's `mason.yaml`:

```sh
# 📂 Get all bricks in Very Good Dart CLI (from project root):
mason get
```

3. Generate the template locally:

```sh
# 🧱 Generate a project using the local Very Good Dart CLI brick (from project root)
mason make very_good_dart_cli --config-path brick/config.json --output-dir output
```

4. Add tests! Pull Requests without 100% test coverage will **not** be merged. If you're unsure on how to do so watch our [Testing Fundamentals Course](https://www.youtube.com/watch?v=M_eZg-X789w&list=PLprI2satkVdFwpxo_bjFkCxXz5RluG8FY).

```sh
# 📊 Generate coverage report (from output/test_cli)
dart test -j 4 --coverage=coverage --platform="vm"
dart pub global run coverage:format_coverage --lcov --check-ignore --in=coverage --out=coverage/lcov.info --package="." --report-on="lib"

# 🕸️ Generate a readable HTML website (from output/test_cli)
genhtml -o coverage/html coverage/lcov.info

# 👀 Open the coverage report HTML website (from output/test_cli)
open coverage/html/index.html
```

5. Ensure the generated project is well formatted:

```sh
# 🧼 Run Dart's formatter (from output/test_cli)
dart format lib test --set-exit-if-changed
```

6. Ensure the generated project has no analysis issues:

```sh
# 🔍 Run Dart's analyzer (from output/test_cli)
dart analyze --fatal-infos --fatal-warnings .
```

💡 **Note**: Our repositories use [Very Good Analysis](https://github.com/VeryGoodOpenSource/very_good_analysis).

7. Ensure you have a meaningful [semantic](https://www.conventionalcommits.org/en/v1.0.0) commit message.

8. Create the Pull Request with a meaningful description, linking to the original issue where possible.

9. Verify that all [status checks](https://github.com/VeryGoodOpenSource/very_good_dart_cli /actions/) are passing for your Pull Request once they have been approved to run by a maintainer.

💡 **Note**: While the prerequisites above must be satisfied prior to having your pull request reviewed, the reviewer(s) may ask you to complete additional work, tests, or other changes before your pull request can be accepted.
21 changes: 21 additions & 0 deletions very_good_dart_cli/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2022 Very Good Ventures

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
67 changes: 67 additions & 0 deletions very_good_dart_cli/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# Very Good Dart CLI

[![Very Good Ventures][logo_white]][very_good_ventures_link_dark]

Developed with 💙 by [Very Good Ventures][very_good_ventures_link] 🦄

[![License: MIT][license_badge]][license_link]
[![Powered by Mason](https://img.shields.io/endpoint?url=https%3A%2F%2Ftinyurl.com%2Fmason-badge)](https://github.com/felangel/mason)

A Very Good Dart CLI created by Very Good Ventures 🦄.

## What's Included ✨

- ✅ Argument parsing
- ✅ A sample command
- ✅ Colorful logging
- ✅ Automatic update prompts
- ✅ Tab completion for bash and zsh
- ✅ GitHub Workflow powered by [Very Good Workflows][very_good_workflows_link]
- ✅ Strict lint rules powered by [Very Good Analysis][very_good_analysis_link]
- ✅ Dependabot Integration
- ✅ 100% Test Coverage
- ✅ Fully Documented Public API
- ✅ MIT License
- ✅ Changelog

## Output 📦

```sh
├── .github
│ ├── dependabot.yaml
│ └── workflows
│ └── my_cli.yaml
├── .gitignore
├── LICENSE
├── README.md
├── analysis_options.yaml
├── bin
│ └── my_cli.dart
├── coverage_badge.svg
├── dart_test.yaml
├── lib
│ ├── my_cli.dart
│ └── src
│ ├── command_runner.dart
│ ├── commands
│ │ ├── commands.dart
│ │ ├── sample_command.dart
│ │ └── update_command.dart
│ └── version.dart
├── pubspec.yaml
└── test
├── ensure_build_test.dart
└── src
├── command_runner_test.dart
└── commands
├── sample_command_test.dart
└── update_command_test.dart
```

[license_badge]: https://img.shields.io/badge/license-MIT-blue.svg
[license_link]: https://opensource.org/licenses/MIT
[logo_white]: https://raw.githubusercontent.com/VGVentures/very_good_brand/main/styles/README/vgv_logo_white.png#gh-dark-mode-only
[very_good_analysis_link]: https://pub.dev/packages/very_good_analysis
[very_good_ventures_link_dark]: https://verygood.ventures#gh-dark-mode-only
[very_good_ventures_link]: https://verygood.ventures
[very_good_workflows_link]: https://github.com/VeryGoodOpenSource/very_good_workflows
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
blank_issues_enabled: false
Loading

0 comments on commit 8a43eed

Please sign in to comment.