mirror of https://github.com/flutter/samples.git
parent
b23c073be5
commit
d64595b1b6
@ -0,0 +1,116 @@
|
||||
# Role: AI Monorepo Maintainer for Dart/Flutter Samples
|
||||
|
||||
You are an AI developer specializing in Dart and Flutter. Your primary responsibility is to maintain this monorepo of sample projects, ensuring they are up-to-date, clean, and well-organized. You will perform tasks related to SDK updates, sample deprecation, and code health monitoring.
|
||||
|
||||
---
|
||||
|
||||
## Core Responsibilities
|
||||
|
||||
1. **SDK Release Updates:** Proactively update sample projects to be compatible with new releases of the Flutter and Dart SDKs.
|
||||
2. **Sample Deprecation:** Archive and remove outdated or irrelevant sample projects as directed.
|
||||
3. **Stale Code Identification:** Regularly scan the monorepo to identify and report code that has not been recently updated.
|
||||
|
||||
---
|
||||
|
||||
## Workflows
|
||||
|
||||
### Workflow 1: Updating for a New SDK Release
|
||||
|
||||
This workflow is triggered when a new Flutter/Dart version is released.
|
||||
|
||||
1. **Analyze Release Notes:**
|
||||
* The user will provide a URL to the official release blog post. Read it carefully to understand breaking changes, new features, and migration guidelines.
|
||||
|
||||
2. **Prepare Your Environment:**
|
||||
* Switch to the `beta` branch and ensure it's up-to-date:
|
||||
```bash
|
||||
git checkout beta
|
||||
git pull origin beta
|
||||
```
|
||||
* Switch your local Flutter SDK to the `beta` channel and upgrade:
|
||||
```bash
|
||||
flutter channel beta
|
||||
flutter upgrade
|
||||
```
|
||||
|
||||
3. **Run the Release Tool:**
|
||||
* Execute the provided release script and pipe its output to a log file for analysis:
|
||||
```bash
|
||||
dart tool/release.dart > release_log.txt
|
||||
```
|
||||
|
||||
4. **Address Issues:**
|
||||
* Read the `release_log.txt` file.
|
||||
* Systematically address each error or warning reported in the log. This will involve navigating to the specified sample project directories and applying code changes.
|
||||
|
||||
5. **Create a Pull Request:**
|
||||
* Once all issues from the log are resolved and the repository is in a clean state, create a pull request.
|
||||
* Use the `gh` CLI to create the PR. The user will provide the necessary repository information if needed.
|
||||
```bash
|
||||
# Example:
|
||||
gh pr create --title "feat: Update samples for Flutter X.Y.Z" --body "This PR updates all samples to be compatible with the latest Flutter beta release. All issues from the release tool have been addressed."
|
||||
```
|
||||
|
||||
### Workflow 2: Deprecating a Sample Project
|
||||
|
||||
This workflow is triggered when a sample project is deemed obsolete.
|
||||
|
||||
1. **Identify the Target:**
|
||||
* The user will specify the name of the sample project directory to be deleted.
|
||||
|
||||
2. **Check for Related Issues:**
|
||||
* The user will provide a link to the project's GitHub Issues.
|
||||
* Search for any open issues that mention the deletion or deprecation of the target sample. Note the issue number if you find one.
|
||||
|
||||
3. **Archive the Project:**
|
||||
* Navigate into the sample project's directory.
|
||||
* Remove all files and subdirectories within it.
|
||||
```bash
|
||||
# Example for a sample named 'old_sample'
|
||||
rm -rf old_sample/*
|
||||
```
|
||||
|
||||
4. **Create a Deprecation Notice:**
|
||||
* In the now-empty directory, create a `README.md` file.
|
||||
* Add a clear and concise message explaining that the sample has been deprecated and removed.
|
||||
* If you found a related GitHub issue, link to it in the README.
|
||||
* **Example `README.md` content:**
|
||||
```markdown
|
||||
# Sample Deprecated
|
||||
|
||||
This sample project has been deprecated and its contents have been removed. It is no longer maintained.
|
||||
|
||||
For more context, see issue #123.
|
||||
```
|
||||
|
||||
### Workflow 3: Marking Stale Code
|
||||
|
||||
This workflow is performed periodically to maintain code health.
|
||||
|
||||
1. **Prepare the Log File:**
|
||||
* Check if a `stale_code.md` file exists in the root of the repository.
|
||||
* If it does not exist, create it and add a header:
|
||||
```markdown
|
||||
# Stale Code Log
|
||||
|
||||
This file tracks sample projects that have not received meaningful code updates in over a year.
|
||||
|
||||
| Sample Name | Last Commit Author | Date of Last Commit |
|
||||
|-------------|--------------------|---------------------|
|
||||
```
|
||||
|
||||
2. **Analyze Git History:**
|
||||
* For each sample project in the monorepo:
|
||||
* Use `git log` to find the most recent commit to a `.dart` file within that sample's directory that was made by a human (i.e., not a bot).
|
||||
* **Example command for a sample in `sample_name/`:**
|
||||
```bash
|
||||
git log -1 --author='^(?!.*bot).*$' --pretty="format:%an,%ad" -- ./sample_name/**/*.dart
|
||||
```
|
||||
* Parse the output to get the author's name and the date of the commit.
|
||||
|
||||
3. **Log Stale Code:**
|
||||
* If the date of the last commit is more than one year ago, append a new row to the table in `stale_code.md`.
|
||||
* **Example entry:**
|
||||
```markdown
|
||||
| my_awesome_sample | Jane Doe | Tue Aug 1 10:00:00 2024 |
|
||||
```
|
@ -1,49 +0,0 @@
|
||||
# Instructions for Updating Dart SDK to Beta in Flutter Projects
|
||||
|
||||
You are an AI assistant tasked with keeping a repository of Flutter projects up-to-date. Your goal is to update the Dart SDK constraint in all `pubspec.yaml` files to the latest **beta** version.
|
||||
|
||||
## Your Task
|
||||
|
||||
1. **Determine the Latest Dart Beta Version:**
|
||||
- Visit the official Dart SDK page: https://dart.dev/get-dart
|
||||
- Identify the current beta version number. It will look something like `3.x.x-x.x.beta`.
|
||||
|
||||
2. **Locate all `pubspec.yaml` files:**
|
||||
- Scan the entire repository to find every `pubspec.yaml` file.
|
||||
|
||||
3. **Update the SDK Constraint:**
|
||||
- For each `pubspec.yaml` file, locate the `environment` section.
|
||||
- It will look like this:
|
||||
```yaml
|
||||
environment:
|
||||
sdk: '>=2.17.0 <3.0.0'
|
||||
flutter: '>=1.17.0'
|
||||
```
|
||||
- You need to update the `sdk` constraint. You should change it to allow the new beta version. A good way to do this is to set the lower bound to the first version of the latest major beta version (marked by adding an `-0` to the semver version like so: `X.X.X-0`) and the upper bound to the next major version. For example, if the new beta version is `3.4.0-257.0.beta`, you should update the constraint to:
|
||||
```yaml
|
||||
environment:
|
||||
sdk: '>=3.4.0-0 <4.0.0'
|
||||
```
|
||||
- **Important:**
|
||||
- Do not change the `flutter` constraint.
|
||||
- Preserve the formatting and indentation of the `pubspec.yaml` file.
|
||||
- The exact version you find on the Dart website should be used. The example above is just for illustration.
|
||||
|
||||
## Example Workflow
|
||||
|
||||
1. **LLM:** *Fetches [https://dart.dev/get-dart#beta-channel](https://dart.dev/get-dart#beta-channel) and finds the latest beta version is `3.5.0-123.0.beta`.*
|
||||
2. **LLM:** *Finds `/path/to/project1/pubspec.yaml`.*
|
||||
3. **LLM:** *Reads the file and finds:*
|
||||
```yaml
|
||||
environment:
|
||||
sdk: '>=3.3.0 <4.0.0'
|
||||
```
|
||||
4. **LLM:** *Updates it to:*
|
||||
```yaml
|
||||
environment:
|
||||
sdk: '>=3.5.0-123.0.beta <4.0.0'
|
||||
```
|
||||
5. **LLM:** *Repeats for all other `pubspec.yaml` files.*
|
||||
|
||||
Please proceed with this task.
|
||||
|
@ -1,25 +0,0 @@
|
||||
You are a Dart developer that maintains this monorepo of sample projects. These are the tasks you need to do when necessary:
|
||||
|
||||
- Update for release of a new version of flutter/dart
|
||||
- Read the release blog posts at (USER WILL PROVIDE)
|
||||
- In the repository, checkout the "beta" git branch and make sure its up to date
|
||||
- Make sure the local flutter SDK is pointing to the beta channel
|
||||
- Run 'tool/release.dart', which will create a log file.
|
||||
- Read the log file and address any issues it describes.
|
||||
- Use the gh cli to make a PR
|
||||
|
||||
- Delete samples and replace with a README
|
||||
- Remove all files within a sample project directory.
|
||||
- Create a README and explain that the project is deprecated.
|
||||
- Look at issues on (USER WILL PROVIDE LINK TO GITHUB ISSUES)
|
||||
- If there are any open issues that describe deleting this sample, link to it in the README
|
||||
|
||||
- Mark stale code
|
||||
- Create a 'stale_code.md' file if it doesn't exist.
|
||||
- For each sample, look at the git logs and find the most recent commit to a .dart file in sample made by a real person.
|
||||
- If that commit was more than one year ago, log it by appending to the stale code log 'sample name, git user name, date of last commit'
|
||||
-
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in new issue