Skip to content

Commit

Permalink
feat: Dart CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
Soap-141 committed Jun 3, 2024
1 parent ca91b59 commit 7c2a9b7
Show file tree
Hide file tree
Showing 44 changed files with 1,429 additions and 576 deletions.
7 changes: 6 additions & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,12 @@ No matter your changes, these checks always apply.
- Create a new Major.Minor.X header if you do a **Minor** or **Major** change.
- If you create a new header, it aligns with the **Impact on version** section and matches what is generated in the build pipeline.
- [ ] Documentation files were updated according with the changes.
- [ ] Images about the template are referenced from the [wiki](https://github.com/nventive/UnoApplicationTemplate/wiki/Images) and added as images in this git.
- Update `README.md` and `src/cli/CLI.md` if you made changes to **templating**.
- Update `AzurePipelines.md` and `src/app/README.md` if you made changes to **pipelines**.
- Update `Diagnostics.md` if you made changes to **diagnostic tools**.
- Update `Architecture.md` and its diagrams if you made **architecture decisions** or if you introduced new **recipes**.
- ...and so forth: Make sure you update the documentation files associated to the recipes you changed. Review the topics by looking at the content of the `doc/` folder.
- [ ] Images about the template are referenced from the [wiki](https://github.com/nventive/FlutterApplicationTemplate/wiki/Images) and added as images in this git.
- [ ] TODO comments are hints for next steps for users of the template and not planned work.

### Contextual
Expand Down
19 changes: 14 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
# Generated dart files
/src/app/lib/**/*.g.dart
# Files and directories created by pub.
.dart_tool/
.packages
pubspec.lock

# Flutter code coverage
/src/app/coverage
# Files generated during tests.
.test_coverage.dart
coverage/
.test_runner.dart

# Android studio and IntelliJ.
.idea

# Generated Dart files.
*.g.dart

# Mockito generated files.
*.mocks.dart

6 changes: 6 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Flutter Application Generator",
"program": "src/cli/bin/flutter_application_generator.dart",
"request": "launch",
"type": "dart"
},
{
"name": "ApplicationTemplate - Debug",
"request": "launch",
Expand Down
81 changes: 0 additions & 81 deletions APP_README.md

This file was deleted.

2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ can build and all tests pass, as well as follow the current coding guidelines.
When submitting a pull request, please use our [pull request
template](.github/PULL_REQUEST_TEMPLATE.md).

Pull requests should all be done to the **master** branch.
Pull requests should all be done to the **main** branch.

---

Expand Down
28 changes: 10 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,35 +12,27 @@ This template largely relies on Flutter, if you want to make sure you got everyt

## Getting Started

We use a custom PowerShell script and a Dart package to easily create new projects. It simplifies the **project renaming**.
We use a Dart CLI application to easily create new projects.

### Generate a new project

1. Make sure you cloned the latest version of this repository.
1. Install the CLI using this command.

2. Make sure you have PowerShell installed.
`dart pub global activate flutter_application_generator`

> 💡 For Windows, you can run `powershell` to verify. You can install it with the command `winget install --id Microsoft.Powershell --source winget`.
2. Create a new project using this command.

> 💡 For Mac, you can run `pwsh` to verify. You can install it with Homebrew `brew install powershell/tap/powershell`.
3. Make sure you have GitVersion installed.

> 💡 For Windows, you can run `dotnet-gitversion` to verify. You can install it with the command `dotnet tool install --global GitVersion.Tool`.
> 💡 For Mac, you can run `gitversion` to verify. You can install it with Homebrew `brew install gitversion`.
4. To run the script and create a new project, run the following command in the cloned `FlutterApplicationTemplate` repository.

`powershell -File ".\tools\copyApplicationTemplate.ps1" -sourceProjectDir C:\P\FlutterApplicationTemplate -destDir C:\P -projectName MyProjectName -appName MyAppName -packageName com.example.myAppName -organization MyOrg`

> 💡 For Mac, you can use `pwsh` instead of `powershell`.
`flutter_application_generator create --destinationDirectory C:\P --projectName MyProjectName --applicationName MyAppName --packageName com.example.myAppName --organizationName MyOrg`

> 💡 The organization parameter is optional (Only used for the Windows platform).
> 💡 You'll need internet access to create new projects.
The following options are available when running the command.

- To get help: `Get-Help .\tools\copyApplicationTemplate.ps1`
- To get help: `flutter_application_generator --help`

- To show version: `flutter_application_generator --version`

### Next Steps

Expand Down
16 changes: 14 additions & 2 deletions build/azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,17 @@ trigger:
- main

variables:
#-if false
- name: IsReleaseBranch
value: $[eq(variables['Build.SourceBranch'], 'refs/heads/main')]
#-endif
- template: variables.yml

stages:
#-if false
- stage: CopyTool_GeneratedApp
jobs:
- template: stage-copytool.yaml
- template: ../src/cli/.azuredevops/stage-test-cli.yaml

- stage: Build_Staging_GeneratedApp
dependsOn: CopyTool_GeneratedApp
Expand All @@ -48,8 +52,16 @@ stages:
iosExportOptionsFile: $(InternalExportOptions)
iosCertificateFile: $(InternalCertificate)
iosVariableGroup: 'FlutterApplicationTemplate.Distribution.Internal.iOS'
#-endif

- stage: Publish_Template_Package
condition: and(succeeded(), eq(variables['IsLightBuild'], 'false'), eq(variables['IsReleaseBranch'], 'true'))
dependsOn:
- CopyTool_GeneratedApp
- Build_Staging_GeneratedApp
jobs:
- template: ../src/cli/.azuredevops/stage-publish-cli.yml

#-endif
- stage: Build_Staging
#-if false
dependsOn: [] # This removes the implicit dependency on previous stage and causes this to run in parallel.
Expand Down
21 changes: 0 additions & 21 deletions build/stage-copytool.yaml

This file was deleted.

19 changes: 7 additions & 12 deletions build/steps-build-android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,9 @@ steps:
Copy-Item -Path '$(keyStore.secureFilePath)' -Destination '${{ parameters.pathToSrc }}\app\android\app\${{ parameters.androidKeystoreFile }}'
Write-Host 'Key store copied to ${{ parameters.pathToSrc }}/app/android/app/${{ parameters.androidKeystoreFile }}.'
- task: FlutterCommand@0
displayName: "Run Flutter Pub Get"
inputs:
- template: templates/flutter-prepare.yml
parameters:
projectDirectory: '${{ parameters.pathToSrc }}/app'
arguments: 'pub get'

- task: PowerShell@2
displayName: 'Execute Package Rename'
Expand All @@ -71,14 +69,6 @@ steps:
Set-Location '${{ parameters.pathToSrc }}/app'
dart run package_rename -f Production
- task: PowerShell@2
displayName: 'Execute Build Runner'
inputs:
targetType: 'inline'
script: |
Set-Location '${{ parameters.pathToSrc }}/app'
$(DartToolPath)/dart run build_runner build --delete-conflicting-outputs
- task: FlutterBuild@0
displayName: Build Project for Release
inputs:
Expand All @@ -91,6 +81,11 @@ steps:
verboseMode: true
dartDefine: ENV=$(applicationEnvironment)

- template: templates/flutter-diagnostics.yml
parameters:
projectDirectory: '${{ parameters.pathToSrc }}/app'
condition: failed()

- task: CopyFiles@2
displayName: 'Copy Binary Files'
inputs:
Expand Down
19 changes: 7 additions & 12 deletions build/steps-build-ios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,9 @@ steps:
inputs:
secureFile: '${{ parameters.iosExportOptionsFile }}'

- task: FlutterCommand@0
displayName: "Run Flutter Pub Get"
inputs:
- template: templates/flutter-prepare.yml
parameters:
projectDirectory: '${{ parameters.pathToSrc }}/app'
arguments: 'pub get'

- task: PowerShell@2
displayName: 'Execute Package Rename'
Expand All @@ -78,14 +76,6 @@ steps:
bannerVersionNumberPosition: 'top'
bannerVersionNumberText: '$(MajorMinorPatch)'

- task: PowerShell@2
displayName: 'Execute Build Runner'
inputs:
targetType: 'inline'
script: |
Set-Location '${{ parameters.pathToSrc }}/app'
$(DartToolPath)/dart run build_runner build --delete-conflicting-outputs
- task: FlutterBuild@0
displayName: Build Project for Release
inputs:
Expand All @@ -100,6 +90,11 @@ steps:
exportOptionsPlist: '$(exportOptions.secureFilePath)'
dartDefine: ENV=$(applicationEnvironment)

- template: templates/flutter-diagnostics.yml
parameters:
projectDirectory: '${{ parameters.pathToSrc }}/app'
condition: failed()

- task: Xcode@5
condition: and(succeeded(), eq(variables['IsLightBuild'], 'false'))
displayName: 'Xcode Archive iOS'
Expand Down
27 changes: 8 additions & 19 deletions build/steps-build-tests.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
parameters:
- name: pathToSrc
type: string
default: ''
default: '$(Build.SourcesDirectory)/src'
- name: projectName
type: string
default: ''
Expand All @@ -18,25 +18,9 @@ steps:
artifact: GeneratedApp
#-endif

- task: FlutterCommand@0
displayName: "Run Flutter Clean"
inputs:
- template: templates/flutter-prepare.yml
parameters:
projectDirectory: '${{ parameters.pathToSrc }}/app'
arguments: 'clean'

- task: FlutterCommand@0
displayName: "Run Flutter Pub Get"
inputs:
projectDirectory: '${{ parameters.pathToSrc }}/app'
arguments: 'pub get'

- task: PowerShell@2
displayName: 'Execute Build Runner'
inputs:
targetType: 'inline'
script: |
Set-Location '${{ parameters.pathToSrc }}/app'
$(DartToolPath)/dart run build_runner build --delete-conflicting-outputs

- task: FlutterTest@0
displayName: "Run Tests"
Expand All @@ -50,6 +34,11 @@ steps:
projectDirectory: '${{ parameters.pathToSrc }}/app'
arguments: test integration_test/integration_test.dart --dart-define ENV=${{ parameters.applicationEnvironment }} -d all

- template: templates/flutter-diagnostics.yml
parameters:
projectDirectory: '${{ parameters.pathToSrc }}/app'
condition: failed()

- script: |
set PATH=%PATH%;C:\Users\VssAdministrator\AppData\Local\Pub\Cache\bin
dart pub global activate cobertura
Expand Down
Loading

0 comments on commit 7c2a9b7

Please sign in to comment.