diff --git a/.github/dependabot.yaml b/.github/dependabot.yaml new file mode 100644 index 00000000..ad6ef734 --- /dev/null +++ b/.github/dependabot.yaml @@ -0,0 +1,13 @@ +# Dependabot configuration file. +version: 2 + +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "monthly" + + - package-ecosystem: "pub" + directory: "/" + schedule: + interval: "monthly" diff --git a/.github/workflows/create_release.yml b/.github/workflows/create_release.yml new file mode 100644 index 00000000..2c071305 --- /dev/null +++ b/.github/workflows/create_release.yml @@ -0,0 +1,16 @@ +name: Create Release +on: + push: + tags: + - '*' +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Create a Release + uses: elgohr/Github-Release-Action@v5 + env: + GITHUB_TOKEN: "${{ secrets.RELEASE_TOKEN }}" + with: + title: ${{ github.ref }} diff --git a/.github/workflows/create_tag.yml b/.github/workflows/create_tag.yml new file mode 100644 index 00000000..c5793f0c --- /dev/null +++ b/.github/workflows/create_tag.yml @@ -0,0 +1,25 @@ +name: Release + +# Runs when a PR merges. +# See https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#running-your-workflow-when-a-pull-request-merges +on: + pull_request: + types: + - closed + +jobs: + release: + if: github.event.pull_request.merged == true + runs-on: ubuntu-latest + container: dart + permissions: + contents: write + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + ref: master + - uses: jacopocarlini/action-autotag@3.0.0 + with: + GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" diff --git a/.github/workflows/dart.yml b/.github/workflows/dart.yml new file mode 100644 index 00000000..63b8adab --- /dev/null +++ b/.github/workflows/dart.yml @@ -0,0 +1,33 @@ +name: Dart Checks + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + build: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest] + # Test with at least the declared minimum Dart version + sdk: ['3.5', stable] + steps: + - uses: actions/checkout@v4 + - uses: dart-lang/setup-dart@v1 + with: + sdk: ${{ matrix.sdk }} + + - name: Install dependencies + run: dart pub get + - name: Dart Analyzer + run: dart analyze + - name: Check Dart Format + if: ${{ matrix.sdk == 'stable' }} + run: dart format --set-exit-if-changed -onone . + - name: Unit tests + run: dart test + - name: Check if Publishable + run: dart pub publish --dry-run diff --git a/.github/workflows/publish_demos.yml b/.github/workflows/publish_demos.yml new file mode 100644 index 00000000..b6b6169e --- /dev/null +++ b/.github/workflows/publish_demos.yml @@ -0,0 +1,30 @@ +name: Publish Demos +on: + push: + branches: + - master +jobs: + build-and-deploy: + runs-on: ubuntu-latest + container: + image: dart + steps: + - name: Checkout 🛎️ + uses: actions/checkout@v4 + + - name: Install rsync 📚 + run: | + apt-get update && apt-get install -y rsync + + - name: Install and Build 🔧 + run: | + dart pub global activate webdev + dart pub get + dart pub global run webdev build -o build -- --delete-conflicting-outputs + rm build/example/packages + + - name: Publish 🚀 + uses: JamesIves/github-pages-deploy-action@v4.6.1 + with: + branch: gh-pages # The branch the action should deploy to. + folder: build/example # The folder the action should deploy. diff --git a/.github/workflows/publish_pubdev.yml b/.github/workflows/publish_pubdev.yml new file mode 100644 index 00000000..336e0cf5 --- /dev/null +++ b/.github/workflows/publish_pubdev.yml @@ -0,0 +1,14 @@ +# .github/workflows/publish.yml +name: Publish to pub.dev + +on: + push: + tags: + - '[0-9]+.[0-9]+.[0-9]+*' + +# Publish using the reusable workflow from dart-lang. +jobs: + publish: + permissions: + id-token: write # Required for authentication using OIDC + uses: dart-lang/setup-dart/.github/workflows/publish.yml@v1 \ No newline at end of file diff --git a/.github/workflows/triage.yml b/.github/workflows/triage.yml new file mode 100644 index 00000000..4d51d30c --- /dev/null +++ b/.github/workflows/triage.yml @@ -0,0 +1,33 @@ +name: Triage Issues +on: + issues: + types: [opened] + +jobs: + assignRob: + name: Assign Rob + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Apply untriaged label + uses: actions/github-script@v7 + with: + github-token: ${{secrets.GITHUB_TOKEN}} + script: | + github.rest.issues.addLabels({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + labels: ['untriaged','unreleased'] + }) + - name: Comment On New Issues + uses: actions/github-script@v7 + with: + github-token: ${{secrets.GITHUB_TOKEN}} + script: | + github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: '👋 Thanks for reporting! @robrbecker will take a look.' + }) diff --git a/.pubignore b/.pubignore new file mode 100644 index 00000000..09134047 --- /dev/null +++ b/.pubignore @@ -0,0 +1,3 @@ +tool +test +integration_test \ No newline at end of file diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index e89347f1..00000000 --- a/.travis.yml +++ /dev/null @@ -1,12 +0,0 @@ -language: dart -sudo: required -addons: - chrome: stable -dart: - - stable -dart_task: - # TODO enable once automated tests are working - # - test: --platform vm - # - test: --platform chrome - - dartanalyzer: lib test # TODO fix examples and add example dir - - dartfmt: true diff --git a/CHANGELOG.md b/CHANGELOG.md index 6e8f54da..8c92ab04 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,16 +1,430 @@ +## 9.25.0 + +* Require Dart 3.5 +* Require `package:http` `^1.0.0`. +* Fix pagination logic to use `next` link. + +## 9.24.0 + +* Bug fixes to the `Issue.isOpen` and `Issue.isClosed` getters. + +## 9.23.0 + +* Require Dart 3.0. +* Update to the latest `package:lints`. + +## 9.22.0 + +* Add support for the `Ghost` user when the Github user is deleted. + +## 9.21.0 + +* Update MiscService.getApiStatus() to use the v2 API + * `APIStatus` has been refactored to match, now exposing `page` and `status` + +## 9.20.0 + +* Add a Changes object to the PullRequestEvent object so we can see what changed in edited PR events by @ricardoamador in https://github.com/SpinlockLabs/github.dart/pull/390 + + +**Full Changelog**: https://github.com/SpinlockLabs/github.dart/compare/9.19.0...9.20.0 + +## 9.19.0 + +* Revert "Add the 'PushEvent' webhook and associated PushCommit object" by @robrbecker in https://github.com/SpinlockLabs/github.dart/pull/387 + + +**Full Changelog**: https://github.com/SpinlockLabs/github.dart/compare/9.18.0...9.19.0 + +## 9.18.0 + +- Bad Release. Was: Add the 'PushEvent' webhook and associated PushCommit + +## 9.17.0 + +* Add bearerToken constructor to Authentication class by @kevmoo in https://github.com/SpinlockLabs/github.dart/pull/381 + + +**Full Changelog**: https://github.com/SpinlockLabs/github.dart/compare/9.16.0...9.17.0 + +## 9.16.0 + +* Fix links and spelling nits in markdown files by @kevmoo in https://github.com/SpinlockLabs/github.dart/pull/379 +* Support latest pkg:http by @kevmoo in https://github.com/SpinlockLabs/github.dart/pull/380 + + +**Full Changelog**: https://github.com/SpinlockLabs/github.dart/compare/9.15.1...9.16.0 + +## 9.15.1 + +* Revert immutable auth by @CaseyHillers in https://github.com/SpinlockLabs/github.dart/pull/378 + + +**Full Changelog**: https://github.com/SpinlockLabs/github.dart/compare/9.15.0...9.15.1 + +## 9.15.0 + +* Implement IssuesService.lock/unlock by @Hixie in https://github.com/SpinlockLabs/github.dart/pull/376 +* Bump JamesIves/github-pages-deploy-action from 4.4.1 to 4.4.2 by @dependabot in https://github.com/SpinlockLabs/github.dart/pull/371 +* Make GitHub.auth non-nullable by @CaseyHillers in https://github.com/SpinlockLabs/github.dart/pull/377 + + +**Full Changelog**: https://github.com/SpinlockLabs/github.dart/compare/9.14.0...9.15.0 + +## 9.14.0 + +* Add optional filter params on Repositories.listCommits by @CaseyHillers in https://github.com/SpinlockLabs/github.dart/pull/368 + + +**Full Changelog**: https://github.com/SpinlockLabs/github.dart/compare/9.13.0...9.14.0 + +## 9.13.0 + +* Add node_id to the pull request model by @ricardoamador in https://github.com/SpinlockLabs/github.dart/pull/367 + + +**Full Changelog**: https://github.com/SpinlockLabs/github.dart/compare/9.12.0...9.13.0 + +## 9.12.0 + +* Add support for issue and PR timeline events via `Issue.listTimeline`. + +## 9.11.0 + +* expose IssueLabel.description; update labels REST APIs by @devoncarew in https://github.com/SpinlockLabs/github.dart/pull/355 + +## 9.10.1 + +* Pass required User-Agent HTTP header on all requests + * If `Authentication.basic` is used, it will be your GitHub username/application + * Otherwise, it will default to `github.dart` + +## 9.10.0-dev + +* Require Dart 2.18 +* Expose `CheckSuitesService` and `ChuckRunsService` classes. + +## 9.9.0 + +* Add "author_association" field to the IssueComment object by @ricardoamador in https://github.com/SpinlockLabs/github.dart/pull/348 + +**Full Changelog**: https://github.com/SpinlockLabs/github.dart/compare/9.8.0...9.9.0 + +## 9.8.0 + +* Add "head_branch" field to CheckSuite object by @nehalvpatel in https://github.com/SpinlockLabs/github.dart/pull/347 + +## New Contributors +* @nehalvpatel made their first contribution in https://github.com/SpinlockLabs/github.dart/pull/347 + +**Full Changelog**: https://github.com/SpinlockLabs/github.dart/compare/9.7.0...9.8.0 + +## 9.7.0 +* Add calendar versioning by @CaseyHillers in https://github.com/SpinlockLabs/github.dart/pull/338 + +**Full Changelog**: https://github.com/SpinlockLabs/github.dart/compare/9.6.0...9.7.0 +## 9.6.0 + +* Require Dart 2.17 +* Update to allow different merge methods in pulls_service by @ricardoamador in https://github.com/SpinlockLabs/github.dart/pull/333 + + +**Full Changelog**: https://github.com/SpinlockLabs/github.dart/compare/9.5.1...9.6.0 + +## 9.5.1 + +* Fix up unit tests & run them in CI by @robrbecker in https://github.com/SpinlockLabs/github.dart/pull/336 + +**Full Changelog**: https://github.com/SpinlockLabs/github.dart/compare/9.5.0...9.5.1 + +## 9.5.0 + +* Add 'commits' member to GitHubComparison object by @fuzzybinary in https://github.com/SpinlockLabs/github.dart/pull/330 + +## New Contributors +* @fuzzybinary made their first contribution in https://github.com/SpinlockLabs/github.dart/pull/330 + +**Full Changelog**: https://github.com/SpinlockLabs/github.dart/compare/9.4.1...9.5.0 + +## 9.4.1 + +* Update to github-script 6 by @robbecker-wf in https://github.com/SpinlockLabs/github.dart/pull/331 + + +**Full Changelog**: https://github.com/SpinlockLabs/github.dart/compare/9.4.0...9.4.1 + +## 9.4.0 + +* Fix publish release workflow by @CaseyHillers in https://github.com/SpinlockLabs/github.dart/pull/316 +* Add support for toString to the Checkrun object. by @ricardoamador in https://github.com/SpinlockLabs/github.dart/pull/318 + + +**Full Changelog**: https://github.com/SpinlockLabs/github.dart/compare/9.3.0...9.4.0 + +## 9.3.0 + +* Added a new conclusion state to support flutter autosubmit bot by @ricardoamador in https://github.com/SpinlockLabs/github.dart/pull/315 + +## New Contributors +* @ricardoamador made their first contribution in https://github.com/SpinlockLabs/github.dart/pull/315 + +**Full Changelog**: https://github.com/SpinlockLabs/github.dart/compare/9.2.0...9.3.0 + +## 9.2.0 + +* test auto-release by @robrbecker in https://github.com/SpinlockLabs/github.dart/pull/307 +* test PR for auto-release by @robrbecker in https://github.com/SpinlockLabs/github.dart/pull/308 +* Added assignees to Issue model for #289 by @sjhorn in https://github.com/SpinlockLabs/github.dart/pull/290 + +## New Contributors +* @sjhorn made their first contribution in https://github.com/SpinlockLabs/github.dart/pull/290 + +**Full Changelog**: https://github.com/SpinlockLabs/github.dart/compare/9.1.1...9.2.0 + +## 9.1.1 + +* Don't add state query param twice by @passsy in https://github.com/SpinlockLabs/github.dart/pull/264 + + +**Full Changelog**: https://github.com/SpinlockLabs/github.dart/compare/9.1.0...9.1.1 + +## 9.1.0 + +* add 'create' github webhook event to hooks.dart by @XilaiZhang in https://github.com/SpinlockLabs/github.dart/pull/304 + +## New Contributors +* @XilaiZhang made their first contribution in https://github.com/SpinlockLabs/github.dart/pull/304 + +**Full Changelog**: https://github.com/SpinlockLabs/github.dart/compare/9.0.3...9.1.0 + +## 9.0.3 + +* Update Language Colors March 13th 2022 by @robrbecker in https://github.com/SpinlockLabs/github.dart/pull/302 + + +**Full Changelog**: https://github.com/SpinlockLabs/github.dart/compare/9.0.2...9.0.3 + +## 9.0.2 +- Switched to use the lints package instead of pedantic https://github.com/SpinlockLabs/github.dart/pull/301 + +## 9.0.1 +- Add `conclusion` property in class `CheckRun` + +## 9.0.0 + +**Breaking change:** In the Gist class, the old type of files was +```dart +List? files; +``` +and the new type is +```dart +Map? files; +``` + +**Breaking change:** In the GistFile class, the name property is now filename + +* Fix getting gists by @robrbecker in https://github.com/SpinlockLabs/github.dart/pull/294 + +**Full Changelog**: https://github.com/SpinlockLabs/github.dart/compare/8.5.0...9.0.0 + +## 8.5.0 + +* Adds listing and creating PR Reviews, listing users in an org by @robrbecker in https://github.com/SpinlockLabs/github.dart/pull/287 + + +**Full Changelog**: https://github.com/SpinlockLabs/github.dart/compare/8.4.0...8.5.0 + +## 8.4.0 +- added `updateComment` to update issue comments https://github.com/SpinlockLabs/github.dart/pull/286 + +## 8.3.0 +- Support `files` field in class `GitHubComparison` + +## 8.2.5 +- no library code changes +- Add auto pub publish on new releases + +## 8.2.4 +- Make CheckRunConclusion nullable + +## 8.2.3 +- Added `generateReleaseNotes` boolean to CreateRelase class to have github auto-create release notes +- Added `generateReleaseNotes` method to RepositoriesService to have github create release notes + between to tags (without creating a release) and return the name and body. This is helpful when you want to add the release notes to a CHANGELOG.md before making the actual release +## 8.2.2 +- Up minimum json_serializable to ^6.0.0, json_annotation to ^4.3.0 +- Cleanup and regenerate generated files +- Require Dart SDK 2.14 + +## 8.2.1 +- Add `CheckSuiteEvent` and `CheckRunEvent` + +## 8.2.0 + - add more fields to the PullRequest class and fixed JSON naming bugs + - Added: + - requestedReviewers + - reviewCommentCount + - milestone + - rebaseable + - mergeableState + - maintainerCanModify + - authorAssociation + - Fixed (these were previously always null) + - commentsCount + - commitsCount + - additionsCount + - deletionsCount + - changedFilesCount + +## 8.1.3 + - Add per page parameter to stars related activities https://github.com/SpinlockLabs/github.dart/pull/265 + +## 8.1.2 + - Fixes `RateLimit.fromRateLimitResponse` to not double cast int + +## 8.1.1 + - Fix up examples and license file https://github.com/SpinlockLabs/github.dart/pull/255 https://github.com/SpinlockLabs/github.dart/pull/254 https://github.com/SpinlockLabs/github.dart/pull/253 + +## 8.1.0 + - `RateLimit` queries `/rate_limit` and no longer uses quota + +## 8.0.1 + - Minor tweaks to improve pub score + +## 8.0.0 + - Allow start page, per_page, number of pages options to pagination helper + - Allow page options for listTags + +## 8.0.0-nullsafe.1 + - Update to null safety + +## 7.0.4 + - Add hasPages attribute to Repository https://github.com/SpinlockLabs/github.dart/pull/238 + +## 7.0.3 + - Export `languageColors` as part of the library. This is the map of github languages to their colors https://github.com/SpinlockLabs/github.dart/pull/232 + +## 7.0.2 + - https://github.com/SpinlockLabs/github.dart/pull/231 + +## 7.0.1 + - Add `getLatestRelease()` to RepositoriesService + - Add `listCurrentUserFollowing()` function to `UsersService` + +## 7.0.0 + - Removed deprecated CloneUrls property on Repository class + +## 6.2.3 + - Add twitter username to User class https://github.com/SpinlockLabs/github.dart/pull/228 + - Improve pub.dev score + +## 6.2.2 + - Fixed typo in documentation + +## 6.2.1 + - Consolidated utils from src/util.dart into src/common/utils/utils.dart + - Added a new top level entry point `hooks.dart` to improve dartdocs and IDE usability when writing hooks + +## 6.2.0 + - Added Checks API https://github.com/SpinlockLabs/github.dart/pull/182 + - Bug fix: Fix setRepositorySubscription to be a PUT instead of a POST https://github.com/SpinlockLabs/github.dart/commit/5b5d7656ce9ce1cb06e15651da06e7e192bc19e1 + - Bug fix: Repository clone URLs were null. DEPRECATED `Repository.cloneUrls` use `cloneUrl`,`gitUrl`,`sshUrl`, or `svnUrl` instead. + - Bug fix: Use a shared json encoder util to remove nulls from maps and lists, encode all dates for github. https://github.com/SpinlockLabs/github.dart/pull/182 + +## 6.1.3 + - Add missing fields for Notification https://github.com/SpinlockLabs/github.dart/pull/210 + - Can now create draft PRs https://github.com/SpinlockLabs/github.dart/pull/212 + +## 6.1.2 + - Update default language color to match github https://github.com/SpinlockLabs/github.dart/pull/208 + +## 6.1.1 + - Use pedantic and address some lint https://github.com/SpinlockLabs/github.dart/pull/205 + - Add missing download url for repos contents https://github.com/SpinlockLabs/github.dart/pull/206 + +## 6.1.0 + - Add (experimental) `listReactions` method to `IssueService`. + +## 6.0.6 + - Clean up lints https://github.com/SpinlockLabs/github.dart/pull/202 + +## 6.0.5 + - Fix null errors issue https://github.com/SpinlockLabs/github.dart/issues/199 + +## 6.0.4 + - This fixes #196 (https://github.com/SpinlockLabs/github.dart/issues/196) + +## 6.0.3 + - Add archived and disabled fields to the Repository class + +## 6.0.2 + - Fixed `GitHubFile.text` to properly decode `content`. + +## 6.0.1 + - Fix https://github.com/SpinlockLabs/github.dart/issues/190 + +## 6.0.0 + +- There's a single entrypoint now: `package:github/github.dart` +- For web: browser specific helper methods have moved. use import `package:github/browser_helper.dart` (renderMarkdown, and createAvatorImage) +- `createGithubClient(...)` has been removed. Just create a GitHub object directly now. +- `findAuthenticationFromEnvironment` now works in both server/flutter and web environments + - On the web, it will check the query string first, then session storage +- all static methods are now factory constructors +- fromJSON is now fromJson everywhere +- toJSON is now toJson everywhere +- Use JsonSerializable everywhere +- removed deprecated items +- renamed some fields with ID at the end to be Id +- most model constructors now have named parameters for all properties +- `GitHubFile.content` is now exactly the content returned from the JSON API + without newlines removed. + +## v5.5.0 + +- Implement markThreadRead https://github.com/SpinlockLabs/github.dart/pull/185 +- Fix for activity service https://github.com/SpinlockLabs/github.dart/issues/187 + +## v5.4.0 + +- Implement rate-limiting https://github.com/SpinlockLabs/github.dart/pull/172 +- Back off when server fails (HTTP 50x) https://github.com/SpinlockLabs/github.dart/pull/173 +- All remaining methods in repos_service.dart (accessible via the getter `repositories` from `GitHub` client class) have been implemented. `isCollaborator`, `listSingleCommitComments`, `listCommitComments`, `createCommitComment`, `getComment`, `updateComment`, `deleteComment` +- Fixed issues.get to correctly return Future https://github.com/SpinlockLabs/github.dart/pull/180 + +## v5.3.0 + +- Add the ability to upload release assets. +- Add the ability to get an existing release by tag name. + +Deprecations: + +- The `draft` and `prerelease` properties in the CreateRelease and Release +- classes have been renamed to `isDraft` and `isPrerelease` for clarity. +- Release.targetCommitsh has been renamed to Release.targetCommitish. +- The `release` parameter in RepositoriesService.createRelease +has been renamed to `createRelease`. +- `RepositoriesService.getRelease` has been renamed to `RepositoriesService.getReleaseById` + +## v5.2.0 + + - Add access to labels on Pull Requests https://github.com/SpinlockLabs/github.dart/pull/163 + - Adding draft property to PR model https://github.com/SpinlockLabs/github.dart/pull/162 + - updateFile request must be a PUT https://github.com/SpinlockLabs/github.dart/pull/160 + ## v5.1.0 - `Repository`: added `updatedAt` and `license` fields. - Require at least Dart `2.3.0`. - Bump version constraint on `json_annotation` - - Add contents_url to PullRequestFile https://github.com/DirectMyFile/github.dart/pull/159 + - Add contents_url to PullRequestFile https://github.com/SpinlockLabs/github.dart/pull/159 ## v5.0.2 - - Fixed pollPublicEventsReceivedByUser to use the correct API URL https://github.com/DirectMyFile/github.dart/pull/150 + - Fixed pollPublicEventsReceivedByUser to use the correct API URL https://github.com/SpinlockLabs/github.dart/pull/150 ## v5.0.1 - - Fixed a runtime exception (https://github.com/DirectMyFile/github.dart/issues/139) - - Added an optional `base` argument when editing a PR (https://github.com/DirectMyFile/github.dart/pull/145) + - Fixed a runtime exception (https://github.com/SpinlockLabs/github.dart/issues/139) + - Added an optional `base` argument when editing a PR (https://github.com/SpinlockLabs/github.dart/pull/145) ## v5.0.0 @@ -109,87 +523,87 @@ - Markdown Generation Library ## v1.3.0 -- [Button Tweaks](https://github.com/DirectMyFile/github.dart/commit/5f4b5caee79758a9a2ea9eeac1521836d95eb9bd) -- [Added Emoji Searches](https://github.com/DirectMyFile/github.dart/commit/8ca46c665f844794dca56aa4eeaab5e2c9d2c245) -- [Combined all Less stylesheets into one](https://github.com/DirectMyFile/github.dart/commit/dd786c4342d70533c2d5446b33888bb42fac40e8) -- [Dates Library Cleanup](https://github.com/DirectMyFile/github.dart/commit/0518a3b0ae072e481fc1579c91c5280ff1978821) -- [String to represent Unix timestamps](https://github.com/DirectMyFile/github.dart/commit/cf93c0fe6790a27c6bbf14f1c7d64f7b6eab5247) -- [Fix date/time parsing](https://github.com/DirectMyFile/github.dart/commit/a6e459ae16a40c2c1f12cace6d84a60dd97b3332) -- [Slack Notifications for TravisCI](https://github.com/DirectMyFile/github.dart/commit/de08f8718d5a90a369cf9edf0d0f90c22ccb1e2a) +- [Button Tweaks](https://github.com/SpinlockLabs/github.dart/commit/5f4b5caee79758a9a2ea9eeac1521836d95eb9bd) +- [Added Emoji Searches](https://github.com/SpinlockLabs/github.dart/commit/8ca46c665f844794dca56aa4eeaab5e2c9d2c245) +- [Combined all Less stylesheets into one](https://github.com/SpinlockLabs/github.dart/commit/dd786c4342d70533c2d5446b33888bb42fac40e8) +- [Dates Library Cleanup](https://github.com/SpinlockLabs/github.dart/commit/0518a3b0ae072e481fc1579c91c5280ff1978821) +- [String to represent Unix timestamps](https://github.com/SpinlockLabs/github.dart/commit/cf93c0fe6790a27c6bbf14f1c7d64f7b6eab5247) +- [Fix date/time parsing](https://github.com/SpinlockLabs/github.dart/commit/a6e459ae16a40c2c1f12cace6d84a60dd97b3332) +- [Slack Notifications for TravisCI](https://github.com/SpinlockLabs/github.dart/commit/de08f8718d5a90a369cf9edf0d0f90c22ccb1e2a) ## v1.0.1 -- [Octicons](https://github.com/DirectMyFile/github.dart/commit/28cff468272066b8f70998ac9235fc6c813a88d5) +- [Octicons](https://github.com/SpinlockLabs/github.dart/commit/28cff468272066b8f70998ac9235fc6c813a88d5) ## v1.0.0 -- [Support for Creating Milestones](https://github.com/DirectMyFile/github.dart/commit/2e613d9ef662da6e5d4adee576ac3c149d15e037) +- [Support for Creating Milestones](https://github.com/SpinlockLabs/github.dart/commit/2e613d9ef662da6e5d4adee576ac3c149d15e037) ## v0.6.7 -- [Hook Server now only handles request at `/hook`](https://github.com/DirectMyFile/github.dart/commit/da0524cd054082bb016193cf167865fd6aeb5631) -- [Octodex Support](https://github.com/DirectMyFile/github.dart/commit/4481f094dca7960268447c579f1745337bbd6c25) -- [Zen API Support](https://github.com/DirectMyFile/github.dart/commit/bcf2ed540a327957485b7e610647f956d02bfa21) -- [Ability to delete issue comments](https://github.com/DirectMyFile/github.dart/commit/2316f5c6af5246d3039fb378fab6c77ac61c5e6b) -- [Client Creation Helper](https://github.com/DirectMyFile/github.dart/commit/2316f5c6af5246d3039fb378fab6c77ac61c5e6b) -- [New Hook Server Middleware](https://github.com/DirectMyFile/github.dart/commit/3af13b647291bc31d644a9ca1554861892ac7b76) -- [Issue Label Management](https://github.com/DirectMyFile/github.dart/commit/8cfe4b318d8683dc6be59ab0c6d5968325a461d9) -- [Ability to change title, body, and state of an issue](https://github.com/DirectMyFile/github.dart/commit/dabc32a66678e92321d017912c9aae60084e908f) -- [Repository Status API Support](https://github.com/DirectMyFile/github.dart/commit/b17da3befae20bbde9b8d8bfd351bf8ff3227fa6) -- [Creating/Deleting/Listing Repository Labels](https://github.com/DirectMyFile/github.dart/commit/2eb1ea81aa3fdfe99c7ed39316a946897c67ebc0) -- [Issue Assignees](https://github.com/DirectMyFile/github.dart/commit/e5e92d2c1d16ab4912522392e84d1e16a2f353ab) +- [Hook Server now only handles request at `/hook`](https://github.com/SpinlockLabs/github.dart/commit/da0524cd054082bb016193cf167865fd6aeb5631) +- [Octodex Support](https://github.com/SpinlockLabs/github.dart/commit/4481f094dca7960268447c579f1745337bbd6c25) +- [Zen API Support](https://github.com/SpinlockLabs/github.dart/commit/bcf2ed540a327957485b7e610647f956d02bfa21) +- [Ability to delete issue comments](https://github.com/SpinlockLabs/github.dart/commit/2316f5c6af5246d3039fb378fab6c77ac61c5e6b) +- [Client Creation Helper](https://github.com/SpinlockLabs/github.dart/commit/2316f5c6af5246d3039fb378fab6c77ac61c5e6b) +- [New Hook Server Middleware](https://github.com/SpinlockLabs/github.dart/commit/3af13b647291bc31d644a9ca1554861892ac7b76) +- [Issue Label Management](https://github.com/SpinlockLabs/github.dart/commit/8cfe4b318d8683dc6be59ab0c6d5968325a461d9) +- [Ability to change title, body, and state of an issue](https://github.com/SpinlockLabs/github.dart/commit/dabc32a66678e92321d017912c9aae60084e908f) +- [Repository Status API Support](https://github.com/SpinlockLabs/github.dart/commit/b17da3befae20bbde9b8d8bfd351bf8ff3227fa6) +- [Creating/Deleting/Listing Repository Labels](https://github.com/SpinlockLabs/github.dart/commit/2eb1ea81aa3fdfe99c7ed39316a946897c67ebc0) +- [Issue Assignees](https://github.com/SpinlockLabs/github.dart/commit/e5e92d2c1d16ab4912522392e84d1e16a2f353ab) ## v0.6.6 -- [Fix Typos](https://github.com/DirectMyFile/github.dart/commit/7b3fd733a306230410a0318abbfc5c15cdd79345) +- [Fix Typos](https://github.com/SpinlockLabs/github.dart/commit/7b3fd733a306230410a0318abbfc5c15cdd79345) ## v0.6.5 -- [Add Issue State Information](https://github.com/DirectMyFile/github.dart/commit/571bb4101f2c90927ecaaab0bb226c277ad7b4be) +- [Add Issue State Information](https://github.com/SpinlockLabs/github.dart/commit/571bb4101f2c90927ecaaab0bb226c277ad7b4be) ## v0.6.4 -- [Pull Request State Information](https://github.com/DirectMyFile/github.dart/commit/fef13177f959903cd1b6b2a3c17f476bea59aeaf) -- [Widen Constraint on yaml](https://github.com/DirectMyFile/github.dart/commit/faa180922b3cd1a21a3b437eb8b590529d529e23) -- [Bug Fixes in Pull Requests](https://github.com/DirectMyFile/github.dart/commit/4b9ec19a2563d4c0bf4220703d11399dee96fbb3) +- [Pull Request State Information](https://github.com/SpinlockLabs/github.dart/commit/fef13177f959903cd1b6b2a3c17f476bea59aeaf) +- [Widen Constraint on yaml](https://github.com/SpinlockLabs/github.dart/commit/faa180922b3cd1a21a3b437eb8b590529d529e23) +- [Bug Fixes in Pull Requests](https://github.com/SpinlockLabs/github.dart/commit/4b9ec19a2563d4c0bf4220703d11399dee96fbb3) ## v0.6.3 -- [Pull Request Manipulation](https://github.com/DirectMyFile/github.dart/commit/37c5323a48a403c5a88300e960e38e773a000d81) -- [Access to Issue Comments](https://github.com/DirectMyFile/github.dart/commit/82020c242998624cac31e0e879c54f63d0cab012) -- [CreateStatus Request](https://github.com/DirectMyFile/github.dart/commit/202bacdd01a132e34d63ff96124f997e6e3c18d5) -- [Widen crypto constraint](https://github.com/DirectMyFile/github.dart/commit/caaa3f9ea14025d4d9c3a966a911489f2deedc26) -- [Team Management](https://github.com/DirectMyFile/github.dart/commit/2a47b14ba975c2396e728ec4260a30dfb8048178) -- [Fix Missing Dependency](https://github.com/DirectMyFile/github.dart/commit/233c4f38f33b1a5e3886e1f4617ca34a66159080) -- [Pull Request Comment Creation](https://github.com/DirectMyFile/github.dart/commit/cab4fa151426e0461ca1ef6ac570ed1e342fe3d8) -- [Fix Bugs in Commit Model](https://github.com/DirectMyFile/github.dart/commit/58a7616baaf4ce963e6e135c2547b9315f0b2e65) -- [Pagination Bug Fix](https://github.com/DirectMyFile/github.dart/commit/b68806939ef9b7d7e5c15983dec2bb6b86343afb) -- [Event Polling](https://github.com/DirectMyFile/github.dart/commit/71d16834b6bdcfd70f9f80ce3f81af9bcabfa066) -- [Octocat Wisdom Support](https://github.com/DirectMyFile/github.dart/commit/6273170787bb2b041c8320afabec304a9f2d6bab) -- [GitHub Blog Posts Support](https://github.com/DirectMyFile/github.dart/commit/845146f5b880ed3dd2b4c73c0a4d568da7b3e2b8) -- [Deploy Key Management](https://github.com/DirectMyFile/github.dart/commit/d72d97127fe96315ae9686daf964000a54ea8806) -- [Public Key Management](https://github.com/DirectMyFile/github.dart/commit/63a0d6b66ae7f5b595979ccdf759fea101607ff1) +- [Pull Request Manipulation](https://github.com/SpinlockLabs/github.dart/commit/37c5323a48a403c5a88300e960e38e773a000d81) +- [Access to Issue Comments](https://github.com/SpinlockLabs/github.dart/commit/82020c242998624cac31e0e879c54f63d0cab012) +- [CreateStatus Request](https://github.com/SpinlockLabs/github.dart/commit/202bacdd01a132e34d63ff96124f997e6e3c18d5) +- [Widen crypto constraint](https://github.com/SpinlockLabs/github.dart/commit/caaa3f9ea14025d4d9c3a966a911489f2deedc26) +- [Team Management](https://github.com/SpinlockLabs/github.dart/commit/2a47b14ba975c2396e728ec4260a30dfb8048178) +- [Fix Missing Dependency](https://github.com/SpinlockLabs/github.dart/commit/233c4f38f33b1a5e3886e1f4617ca34a66159080) +- [Pull Request Comment Creation](https://github.com/SpinlockLabs/github.dart/commit/cab4fa151426e0461ca1ef6ac570ed1e342fe3d8) +- [Fix Bugs in Commit Model](https://github.com/SpinlockLabs/github.dart/commit/58a7616baaf4ce963e6e135c2547b9315f0b2e65) +- [Pagination Bug Fix](https://github.com/SpinlockLabs/github.dart/commit/b68806939ef9b7d7e5c15983dec2bb6b86343afb) +- [Event Polling](https://github.com/SpinlockLabs/github.dart/commit/71d16834b6bdcfd70f9f80ce3f81af9bcabfa066) +- [Octocat Wisdom Support](https://github.com/SpinlockLabs/github.dart/commit/6273170787bb2b041c8320afabec304a9f2d6bab) +- [GitHub Blog Posts Support](https://github.com/SpinlockLabs/github.dart/commit/845146f5b880ed3dd2b4c73c0a4d568da7b3e2b8) +- [Deploy Key Management](https://github.com/SpinlockLabs/github.dart/commit/d72d97127fe96315ae9686daf964000a54ea8806) +- [Public Key Management](https://github.com/SpinlockLabs/github.dart/commit/63a0d6b66ae7f5b595979ccdf759fea101607ff1) ## v0.6.2 -- [Bug Fixes in Organizations](https://github.com/DirectMyFile/github.dart/commit/0cd55093fc3da97cfadc9ffd29e3705a1e25f3ec) -- [Pull Request Comment Model](https://github.com/DirectMyFile/github.dart/commit/611588e76163c17ee4830a9b9e0609ebf5beb165) -- [Moved to Stream-based API](https://github.com/DirectMyFile/github.dart/commit/bd827ffd30a162b4e71f8d12d466e6e24383bf1e) -- [Support for Forking a Repository](https://github.com/DirectMyFile/github.dart/commit/0c61d9a8ca874c23eb4f16dd63db1d53a65f2562) -- [Gist Comments Support](https://github.com/DirectMyFile/github.dart/commit/fc0d690debae4ac857f9021d7d8265ae2e4549be) -- [Merging Support](https://github.com/DirectMyFile/github.dart/commit/56d5e4d05bb3b685cac19c61f91f81f22281bd4a) -- [Emoji Support](https://github.com/DirectMyFile/github.dart/commit/9ac77b3364a060dd2e4e202e4e38f24b2079ff9e) -- [Repository Search Support](https://github.com/DirectMyFile/github.dart/commit/305d1bcb439b188fac9553c6a07ea33f0e3505bd) -- [Notifications API Support](https://github.com/DirectMyFile/github.dart/commit/11398495adebf68958ef3bce20903acd909f514c) +- [Bug Fixes in Organizations](https://github.com/SpinlockLabs/github.dart/commit/0cd55093fc3da97cfadc9ffd29e3705a1e25f3ec) +- [Pull Request Comment Model](https://github.com/SpinlockLabs/github.dart/commit/611588e76163c17ee4830a9b9e0609ebf5beb165) +- [Moved to Stream-based API](https://github.com/SpinlockLabs/github.dart/commit/bd827ffd30a162b4e71f8d12d466e6e24383bf1e) +- [Support for Forking a Repository](https://github.com/SpinlockLabs/github.dart/commit/0c61d9a8ca874c23eb4f16dd63db1d53a65f2562) +- [Gist Comments Support](https://github.com/SpinlockLabs/github.dart/commit/fc0d690debae4ac857f9021d7d8265ae2e4549be) +- [Merging Support](https://github.com/SpinlockLabs/github.dart/commit/56d5e4d05bb3b685cac19c61f91f81f22281bd4a) +- [Emoji Support](https://github.com/SpinlockLabs/github.dart/commit/9ac77b3364a060dd2e4e202e4e38f24b2079ff9e) +- [Repository Search Support](https://github.com/SpinlockLabs/github.dart/commit/305d1bcb439b188fac9553c6a07ea33f0e3505bd) +- [Notifications API Support](https://github.com/SpinlockLabs/github.dart/commit/11398495adebf68958ef3bce20903acd909f514c) ## v0.6.1 -- [Fix Bug in Release API](https://github.com/DirectMyFile/github.dart/commit/64499a376df313f08df1669782f042a912751794) +- [Fix Bug in Release API](https://github.com/SpinlockLabs/github.dart/commit/64499a376df313f08df1669782f042a912751794) ## v0.6.0 -- [Custom HTTP System](https://github.com/DirectMyFile/github.dart/commit/3e1bfe7e45e7b83c32bf0bceb154a791ea3b68d7) -- [Gists Support](https://github.com/DirectMyFile/github.dart/commit/fe733a36ed1cd7cce89d309e61b14b8b7f8666d8) -- [API Status Information](https://github.com/DirectMyFile/github.dart/commit/c790bf9edb8e2fb99d879818a8b2ae77b5325f7c) +- [Custom HTTP System](https://github.com/SpinlockLabs/github.dart/commit/3e1bfe7e45e7b83c32bf0bceb154a791ea3b68d7) +- [Gists Support](https://github.com/SpinlockLabs/github.dart/commit/fe733a36ed1cd7cce89d309e61b14b8b7f8666d8) +- [API Status Information](https://github.com/SpinlockLabs/github.dart/commit/c790bf9edb8e2fb99d879818a8b2ae77b5325f7c) ## v0.5.9 @@ -198,12 +612,12 @@ All the things! ## v0.3.0 - Updated Documentation -- [Better Organization Support](https://github.com/DirectMyFile/github.dart/commit/cc9de92f625918eafd01a72b4e2c0921580075bb) -- [Added Organization Demos](https://github.com/DirectMyFile/github.dart/commit/cc9de92f625918eafd01a72b4e2c0921580075bb) +- [Better Organization Support](https://github.com/SpinlockLabs/github.dart/commit/cc9de92f625918eafd01a72b4e2c0921580075bb) +- [Added Organization Demos](https://github.com/SpinlockLabs/github.dart/commit/cc9de92f625918eafd01a72b4e2c0921580075bb) ## v0.2.0 -- [Organization Support](https://github.com/DirectMyFile/github.dart/commit/3de085c0fa2d629a8bebff89bdaf1a5aaf833195) +- [Organization Support](https://github.com/SpinlockLabs/github.dart/commit/3de085c0fa2d629a8bebff89bdaf1a5aaf833195) ## v0.1.0 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a45a8024..b574e5a8 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -5,9 +5,9 @@ GitHub.dart is of course Open Source! We love it when people contribute! ## Getting Started - Make sure you have a [GitHub Account](https://github.com/signup/free). -- Make sure the [Dart SDK](https://www.dartlang.org/tools/sdk/) is installed on your system. +- Make sure the [Dart SDK](https://dart.dev/tools/sdk) is installed on your system. - Make sure you have [Git](http://git-scm.com/) installed on your system. -- [Fork](https://help.github.com/articles/fork-a-repo) the [repository](https://github.com/DirectMyFile/github.dart) on GitHub. +- [Fork](https://help.github.com/articles/fork-a-repo) the [repository](https://github.com/SpinlockLabs/github.dart) on GitHub. ## Making Changes @@ -15,12 +15,12 @@ GitHub.dart is of course Open Source! We love it when people contribute! - [Commit your code](http://git-scm.com/book/en/Git-Basics-Recording-Changes-to-the-Repository) for each logical change (see [tips for creating better commit messages](http://robots.thoughtbot.com/5-useful-tips-for-a-better-commit-message)). - [Push your change](https://help.github.com/articles/pushing-to-a-remote) to your fork. - [Create a Pull Request](https://help.github.com/articles/creating-a-pull-request) on GitHub for your change. -- Wait for reviewers (usually kaendfinger) to give feedback. +- Wait for reviewers (usually robrbecker) to give feedback. - When the reviewers think that the Pull Request is ready, they will merge it. ## Code Style -GitHub.dart follows the [Dart Style Guide](https://www.dartlang.org/articles/style-guide/). Please note that if your code is not formatted according to the guide as much as possible, we will reject your Pull Request until it is fixed. Some things such as long lines will generally be accepted, however try to make it smaller if possible. +GitHub.dart follows the [Dart Style Guide](https://dart.dev/effective-dart/style). Please note that if your code is not formatted according to the guide as much as possible, we will reject your Pull Request until it is fixed. Some things such as long lines will generally be accepted, however try to make it smaller if possible. ## Efficiency @@ -28,13 +28,38 @@ GitHub.dart is committed to efficiency as much as possible. If your code is not ## Rejections -Pull Request rejections are not a bad thing. It just means you need to fix something. Perhaps it is important to define 'rejection' as it is used in this case. A rejection is when a GitHub.dart committer comments on a Pull Request with a comment like 'rejected due to incorrect formatting'. +Pull Request rejections are not a bad thing. It just means you need to fix something. Perhaps it is important to define 'rejection' as it is used in this case. A rejection is when a `GitHub.dart` committer comments on a Pull Request with a comment like 'rejected due to incorrect formatting'. + +## Generated code + +To regenerate the JSON logic for the models, run: + +```sh +dart run build_runner build -d +``` + +## Tests + +`dart test` will only run the unit tests. + +To run the complete test suite you will need to install +`octokit/fixtures-server`. + +``` +npm install --global @octokit/fixtures-server +``` + +Tests can be run using `make test`, which will start up a local mock +GitHub and execute tests against it using your localhost port 3000. ## Contacting Us -- IRC: `#directcode on irc.esper.net and irc.freenode.net` -- Email: `kaendfinger@gmail.com` +File issues at https://github.com/SpinlockLabs/github.dart/issues + +## Releases -## Becoming a Committer +Merged pull requests that edit the `pubspec.yaml` version will create new releases. +Once CI is green, it will create a tag for that commit based on the version, which +gets published by pub.dev. -If you get on IRC and ask us, we can review your work and add you as a committer if we think you should have it. +If no new version was created, nothing will be published. diff --git a/LICENSE.md b/LICENSE similarity index 99% rename from LICENSE.md rename to LICENSE index 838d36d8..e4f06dbe 100644 --- a/LICENSE.md +++ b/LICENSE @@ -1,4 +1,3 @@ -``` The MIT License (MIT) Copyright (c) 2014 DirectCode @@ -20,4 +19,3 @@ 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. -``` diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..c146167b --- /dev/null +++ b/Makefile @@ -0,0 +1,20 @@ +.DEFAULT_GOAL := help +SHELL=/bin/bash -o pipefail + +# Cite: https://marmelab.com/blog/2016/02/29/auto-documented-makefile.html +.PHONY: help +help: ## Display this help page + @grep -E '^[a-zA-Z0-9/_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' + +.PHONY: fixtures +fixtures: ## Run octokit-fixtures-server for scenario tests + @npx octokit-fixtures-server & + +.PHONY: stop +stop: ## Stop the fixtures server + @killall node + +.PHONY: test +test: fixtures ## Run tests + @dart test -P all + make stop \ No newline at end of file diff --git a/README.md b/README.md index 1d8606f5..08dc8e09 100644 --- a/README.md +++ b/README.md @@ -1,82 +1,38 @@ # GitHub for Dart -[![Build Status](https://travis-ci.org/DirectMyFile/github.dart.svg?branch=master)](https://travis-ci.org/DirectMyFile/github.dart) -[![Pub](https://img.shields.io/pub/v/github.svg)](https://pub.dartlang.org/packages/github) +[![Dart Checks](https://github.com/SpinlockLabs/github.dart/actions/workflows/dart.yml/badge.svg)](https://github.com/SpinlockLabs/github.dart/actions/workflows/dart.yml) +[![Pub](https://img.shields.io/pub/v/github.svg)](https://pub.dev/packages/github) -This is a Client Library for GitHub in Dart. I wrote this out of necessity, and then when I got a great reaction from the Dart community, I decided to put a lot of effort into it. +This is a library for interacting with GitHub in Dart. It works on all platforms including web, server, and Flutter. +Please submit issues and pull requests, help out, or just give encouragement. -Please submit issues and pull requests, join my IRC channel (#directcode on irc.esper.net), help out, or just give me encouragement. - -**Notice**: We are looking for major contributors. Contact us by email or on IRC! - -## Links - -- [Library Demos](http://github.directcode.org/demos/) -- [Pub Package](https://pub.dartlang.org/packages/github) -- [Wiki](https://github.com/DirectMyFile/github.dart/wiki) +**Notice**: This is not an official GitHub project. It is maintained by volunteers. +We are looking for contributors. If you're interested or have questions, head over to discussions https://github.com/SpinlockLabs/github.dart/discussions ## Features -### Current - -- Works on the Server and in the Browser +- Works on the Server, Browser, and Flutter - Really Fast -- Plugable API +- Pluggable API - Supports Authentication - Builtin OAuth2 Flow - Hook Server Helper -### Work in Progress - -- Support all the GitHub APIs (Progress: 98%) - -## Getting Started - -First, add the following to your pubspec.yaml: - -```yaml -dependencies: - github: ^5.0.0 -``` - -Then import the library and use it: - -**For the Server** -```dart -import 'package:github/server.dart'; - -void main() { - /* Creates a GitHub Client */ - var github = createGitHubClient(); - - github.repositories.getRepository(new RepositorySlug("DirectMyFile", "github.dart")).then((Repository repo) { - /* Do Something */ - }); -} -``` +## Links -**For the Browser** -```dart -import 'package:github/browser.dart'; +- [Library Demos](https://spinlocklabs.github.io/github.dart/) (based on the [sample code](https://github.com/SpinlockLabs/github.dart/tree/master/example)) +- [Pub Package](https://pub.dev/packages/github) +- [Wiki](https://github.com/SpinlockLabs/github.dart/wiki) +- [Latest API reference](https://pub.dev/documentation/github/latest/) -void main() { - /* Creates a GitHub Client */ - var github = createGitHubClient(); - - github.repositories.getRepository(new RepositorySlug("DirectMyFile", "github.dart")).then((Repository repo) { - /* Do Something */ - }); -} -``` +## Examples -## Authentication +See the examples in the example directory to learn how to use some of the features! -To use a GitHub token: +## Contacting Us -```dart -var github = createGitHubClient(auth: new Authentication.withToken("YourTokenHere")); -``` +Post a question or idea: https://github.com/SpinlockLabs/github.dart/discussions -## Contacting Us +## Star History -You can find us on `irc.esper.net and irc.freenode.net` at `#directcode`. +[![Star History Chart](https://api.star-history.com/svg?repos=SpinlockLabs/github.dart&type=Date)](https://star-history.com/#SpinlockLabs/github.dart&Date) diff --git a/analysis_options.yaml b/analysis_options.yaml index ebaab926..f2974469 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -1,46 +1,58 @@ -include: package:pedantic/analysis_options.yaml +include: package:lints/recommended.yaml + +analyzer: + language: + #strict-casts: true + linter: rules: - - always_declare_return_types -# - annotate_overrides -# - avoid_as - - avoid_empty_else - - avoid_init_to_null - - avoid_return_types_on_setters - - await_only_futures - - camel_case_types + - always_put_control_body_on_new_line + - always_put_required_named_parameters_first + - avoid_catching_errors + - avoid_classes_with_only_static_members + - avoid_double_and_int_checks + - avoid_field_initializers_in_const_classes + - avoid_implementing_value_types + - avoid_js_rounded_ints + - avoid_private_typedef_functions + - avoid_returning_this + - avoid_setters_without_getters + - avoid_slow_async_io + - avoid_unused_constructor_parameters + - avoid_void_async + - cancel_subscriptions - close_sinks - comment_references -# - constant_identifier_names - - control_flow_in_finally + - diagnostic_describe_all_properties - directives_ordering - - empty_catches - - empty_constructor_bodies - - empty_statements - - hash_and_equals - - implementation_imports - - iterable_contains_unrelated_type - - library_names - - library_prefixes - - list_remove_unrelated_type - - non_constant_identifier_names + - join_return_with_assignment + - literal_only_boolean_expressions + - no_adjacent_strings_in_list + - omit_local_variable_types - one_member_abstracts - - package_api_docs - - package_names - - package_prefixed_library_names - - prefer_equal_for_default_values - - prefer_generic_function_type_aliases - - prefer_is_not_empty - - slash_for_doc_comments + - only_throw_errors + - prefer_asserts_in_initializer_lists + - prefer_const_constructors + - prefer_const_constructors_in_immutables + - prefer_const_declarations + - prefer_const_literals_to_create_immutables + - prefer_constructors_over_static_methods + - prefer_final_in_for_each + - prefer_foreach + - prefer_if_elements_to_conditional_expressions + - prefer_int_literals + - prefer_mixin + - sort_child_properties_last + - sort_pub_dependencies - sort_unnamed_constructors_first - test_types_in_equals - throw_in_finally - type_annotate_public_apis - - type_init_formals - - unawaited_futures - - unnecessary_brace_in_string_interps - - unnecessary_const - - unnecessary_getters_setters - - unnecessary_new - - unrelated_type_equality_checks - - valid_regexps + - unnecessary_await_in_return + - unnecessary_lambdas + - unnecessary_parenthesis + - unnecessary_statements + - use_full_hex_values_for_flutter_colors + - use_setters_to_change_properties + - use_string_buffers + - use_to_and_as_if_applicable diff --git a/build.yaml b/build.yaml new file mode 100644 index 00000000..fdbbd17d --- /dev/null +++ b/build.yaml @@ -0,0 +1,8 @@ +targets: + $default: + builders: + json_serializable: + options: + # Options configure how source code is generated for every + # `@JsonSerializable`-annotated class in the package. + field_rename: snake diff --git a/dart_test.yaml b/dart_test.yaml new file mode 100644 index 00000000..04f3491b --- /dev/null +++ b/dart_test.yaml @@ -0,0 +1,15 @@ +tags: + scenarios: + skip: | + Not run by default when running dart test. To run: + npx octokit-fixtures-server + dart test -P scenarios + or run all tests with: + make test + +presets: + scenarios: + include_tags: scenarios + run_skipped: true + all: + run_skipped: true \ No newline at end of file diff --git a/example/common.dart b/example/common.dart index 74750345..e508d0ee 100644 --- a/example/common.dart +++ b/example/common.dart @@ -1,7 +1,11 @@ -import "dart:async"; -import "dart:html"; +import 'dart:async'; +// ignore: deprecated_member_use +import 'dart:html'; -import "package:github/browser.dart"; +import 'package:github/github.dart'; + +export 'package:github/browser_helper.dart'; +export 'package:github/github.dart'; /// Wires up a listener to a button with an id of view-source, /// if it exists, to show the script source @@ -9,21 +13,23 @@ import "package:github/browser.dart"; /// view source button, then you don't need to call this method Future initViewSourceButton(String script) async { // query the DOM for the view source button, handle clicks - document.querySelector("#view-source")?.onClick?.listen((_) { - var popup = window.open("view_source.html?script=$script", "View Source"); - String code; + document.querySelector('#view-source')?.onClick.listen((_) { + final popup = window.open( + 'https://github.com/SpinlockLabs/github.dart/blob/master/example/$script', + 'View Source'); + String? code; var fetched = false; var ready = false; void sendCode() { popup - .postMessage({"command": "code", "code": code}, window.location.href); + .postMessage({'command': 'code', 'code': code}, window.location.href); } - window.addEventListener("message", (event) { + window.addEventListener('message', (event) { if (event is MessageEvent) { - if (event.data['command'] == "ready") { + if (event.data['command'] == 'ready') { ready = true; if (fetched) { sendCode(); @@ -45,16 +51,4 @@ Future initViewSourceButton(String script) async { Map queryString = Uri.parse(window.location.href).queryParameters; -/// Gets the github token from the "token" query string param, -/// falling back to getting it from session storage. -/// If it is not in either, it will be null -String token = queryString["token"] ?? window.sessionStorage['token']; - -GitHub _createGitHub() { - return GitHub( - auth: token != null - ? Authentication.withToken(token) - : Authentication.anonymous()); -} - -GitHub github = _createGitHub(); +GitHub github = GitHub(auth: findAuthenticationFromEnvironment()); diff --git a/example/emoji.dart b/example/emoji.dart index dd455cd0..663269dd 100644 --- a/example/emoji.dart +++ b/example/emoji.dart @@ -1,50 +1,51 @@ import 'dart:async'; -import "dart:html"; +// ignore: deprecated_member_use +import 'dart:html'; -import "common.dart"; +import 'common.dart'; -DivElement emojiDiv; +Element? emojiDiv; Future main() async { - await initViewSourceButton("emoji.dart"); - emojiDiv = querySelector("#emojis"); + await initViewSourceButton('emoji.dart'); + emojiDiv = querySelector('#emojis'); await loadEmojis(); - var searchBox = querySelector("#search-box") as InputElement; + final searchBox = querySelector('#search-box') as InputElement; searchBox.onKeyUp.listen((event) { filter(searchBox.value); }); } Future loadEmojis() async { - var emojis = await github.misc.listEmojis(); + final emojis = await github.misc.listEmojis(); emojis.forEach((name, url) { - var h = DivElement(); + final h = DivElement(); h.className = 'emojibox'; - h.style.textAlign = "center"; + h.style.textAlign = 'center'; h.append( - ImageElement(src: url, width: 64, height: 64)..classes.add("emoji")); - h.append(ParagraphElement()..text = ":$name:"); - emojiDiv.append(h); + ImageElement(src: url, width: 64, height: 64)..classes.add('emoji')); + h.append(ParagraphElement()..text = ':$name:'); + emojiDiv!.append(h); }); } -String lastQuery; +String? lastQuery; -void filter(String query) { +void filter(String? query) { if (lastQuery != null && lastQuery == query) { return; } lastQuery = query; - var boxes = emojiDiv.children; - for (var box in boxes) { - var boxName = box.querySelector("p"); - var t = boxName.text; - var name = t.substring(1, t.length - 1); - if (name.contains(query)) { - box.style.display = "inline"; + final boxes = emojiDiv!.children; + for (final box in boxes) { + final boxName = box.querySelector('p')!; + final t = boxName.text!; + final name = t.substring(1, t.length - 1); + if (name.contains(query!)) { + box.style.display = 'inline'; } else { - box.style.display = "none"; + box.style.display = 'none'; } } } diff --git a/example/gist.dart b/example/gist.dart new file mode 100755 index 00000000..0541ba58 --- /dev/null +++ b/example/gist.dart @@ -0,0 +1,7 @@ +import 'package:github/github.dart'; + +Future main() async { + final github = GitHub(auth: findAuthenticationFromEnvironment()); + var g = await github.gists.getGist('c14da36c866b9fe6f84f5d774b76570b'); + print(g.files); +} diff --git a/example/gist.html b/example/gist.html new file mode 100755 index 00000000..e25fd0bb --- /dev/null +++ b/example/gist.html @@ -0,0 +1,36 @@ + + + + + + + + Gist + + + + +

Gist

+ + +

+ +
+

+
+
+ + + + + + \ No newline at end of file diff --git a/example/index.dart b/example/index.dart index 8ccf4e8b..535acd07 100644 --- a/example/index.dart +++ b/example/index.dart @@ -1,10 +1,13 @@ +// ignore: deprecated_member_use import 'dart:html'; +import 'common.dart'; + void main() { - InputElement tokenInput = querySelector('#token'); - String token = window.sessionStorage['token']; - tokenInput.value = token; + final tokenInput = querySelector('#token') as InputElement; + tokenInput.value = github.auth.token ?? ''; + window.sessionStorage['GITHUB_TOKEN'] = tokenInput.value!; tokenInput.onKeyUp.listen((_) { - window.sessionStorage['token'] = tokenInput.value; + window.sessionStorage['GITHUB_TOKEN'] = tokenInput.value!; }); } diff --git a/example/index.html b/example/index.html index 16befe79..81e054e8 100644 --- a/example/index.html +++ b/example/index.html @@ -23,7 +23,7 @@

GitHub for Dart - Demos

personal github token, enter it in the input below. It will be saved in session storage, which goes away when you close your browser. Alternatively, you can add a querystring parameter to specify your token on any of the examples like - ?token=[yourtoken] + ?GITHUB_TOKEN=[yourtoken]

Github Token:

@@ -34,6 +34,7 @@

GitHub for Dart - Demos

User Information Language Breakdown Releases + Pull Request Stars Code Search Emoji diff --git a/example/languages.dart b/example/languages.dart index 24abf35c..aa8b7ec1 100644 --- a/example/languages.dart +++ b/example/languages.dart @@ -1,35 +1,26 @@ -import "dart:html"; +// ignore: deprecated_member_use +import 'dart:html'; -import "package:github/browser.dart"; -import "common.dart"; +import 'common.dart'; -DivElement tableDiv; +DivElement? tableDiv; -LanguageBreakdown breakdown; +late LanguageBreakdown breakdown; Future main() async { - await initViewSourceButton("languages.dart"); - tableDiv = querySelector("#table"); + await initViewSourceButton('languages.dart'); + tableDiv = querySelector('#table') as DivElement?; await loadRepository(); } Future loadRepository() async { - var user = "dart-lang"; - var reponame = "sdk"; + final params = queryString; + var user = params['user'] ?? 'dart-lang'; + var reponame = params['repo'] ?? 'sdk'; - var params = queryString; + document.getElementById('name')!.text = '$user/$reponame'; - if (params.containsKey("user")) { - user = params["user"]; - } - - if (params.containsKey("repo")) { - reponame = params["repo"]; - } - - document.getElementById("name").setInnerHtml("$user/$reponame"); - - var repo = RepositorySlug(user, reponame); + final repo = RepositorySlug(user, reponame); breakdown = await github.repositories.listLanguages(repo); reloadTable(); } @@ -42,9 +33,9 @@ void reloadTable({int accuracy = 4}) { } isReloadingTable = true; - String md = generateMarkdown(accuracy); + final md = generateMarkdown(accuracy); github.misc.renderMarkdown(md).then((html) { - tableDiv.setInnerHtml(html, treeSanitizer: NodeTreeSanitizer.trusted); + tableDiv!.setInnerHtml(html, treeSanitizer: NodeTreeSanitizer.trusted); isReloadingTable = false; }); } @@ -54,18 +45,20 @@ int totalBytes(LanguageBreakdown breakdown) { } String generateMarkdown(int accuracy) { - int total = totalBytes(breakdown); - var data = breakdown.toList(); + final total = totalBytes(breakdown); + final data = breakdown.toList(); - String md = '|Name|Bytes|Percentage|\n'; - md += '|-----|-----|-----|\n'; + var md = StringBuffer(''' +|Name|Bytes|Percentage| +|-----|-----|-----| +'''); data.sort((a, b) => b[1].compareTo(a[1])); - data.forEach((info) { - String name = info[0]; - int bytes = info[1]; - num percentage = ((bytes / total) * 100); - md += '|$name|$bytes|${percentage.toStringAsFixed(accuracy)}|\n'; - }); - return md; + for (final info in data) { + final String? name = info[0]; + final int bytes = info[1]; + final num percentage = (bytes / total) * 100; + md.writeln('|$name|$bytes|${percentage.toStringAsFixed(accuracy)}|'); + } + return md.toString(); } diff --git a/example/markdown.dart b/example/markdown.dart index d883ef30..e04150a0 100644 --- a/example/markdown.dart +++ b/example/markdown.dart @@ -1,7 +1,6 @@ -import "package:github/browser.dart"; -import "common.dart"; +import 'common.dart'; Future main() async { - await initViewSourceButton("markdown.dart"); - GitHubBrowserHelper.renderMarkdown(github, "*[markdown]"); + await initViewSourceButton('markdown.dart'); + renderMarkdown(github, '*[markdown]'); } diff --git a/example/markdown.html b/example/markdown.html index f18f75bb..add1371b 100644 --- a/example/markdown.html +++ b/example/markdown.html @@ -16,19 +16,21 @@