Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions .github/workflows/analyze.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Analyze

on:
push:
branches:
- main
pull_request:
workflow_call:
inputs:
artifact:
description: Artifact to analyze instead of checking out the repository.
required: false
type: string
default: ''

concurrency:
group: ${{ github.repository == 'vrchatapi/vrchatapi-dart' && format('{0}-{1}', github.workflow, github.ref) || format('analyze-{0}', github.run_id) }}
cancel-in-progress: true

jobs:
analyze:
runs-on: ubuntu-latest
strategy:
matrix:
package: [vrchat_dart, vrchat_dart_generated]
defaults:
run:
working-directory: ${{ matrix.package }}
steps:
- if: ${{ inputs.artifact }}
uses: actions/download-artifact@v8
with:
name: ${{ inputs.artifact }}
- if: ${{ !inputs.artifact }}
uses: actions/checkout@v7
- uses: dart-lang/setup-dart@v1.8.0
- name: Pub cache
uses: actions/cache@v6
env:
cache-name: ${{ matrix.package }}
with:
path: ${{ env.PUB_CACHE }}
key: ${{ env.cache-name }}-${{ hashFiles('**/pubspec.lock') }}
restore-keys: ${{ env.cache-name }}-
- run: |
dart pub get
if [ -d example_flutter ]; then
dart pub get --directory=example_flutter
fi
- run: dart analyze --fatal-infos
- run: dart pub publish --dry-run
- run: |
dart pub global activate pana
pana --no-warning --exit-code-threshold 0
54 changes: 5 additions & 49 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
name: CI

on:
push:
branches:
- '**'
pull_request:
workflow_call:
inputs:
ref:
Expand All @@ -11,8 +9,6 @@ on:
type: string
default: main

name: CI

jobs:
generate:
runs-on: ubuntu-latest
Expand All @@ -21,21 +17,15 @@ jobs:
with:
repository: vrchatapi/vrchatapi-dart
ref: ${{ inputs.ref || github.ref }}

- uses: dart-lang/setup-dart@v1.8.0

- uses: vrchatapi/specification/.github/actions/setup-generator@main

- uses: vrchatapi/specification/.github/actions/download@main
with:
bundle: openapi-3.0.yaml

- run: |
mkdir -p ../vrchatapi-specification/dist
mv openapi-3.0.yaml ../vrchatapi-specification/dist/

- run: ./generate.sh local

- uses: actions/upload-artifact@v7
with:
name: dart-generated
Expand All @@ -46,40 +36,6 @@ jobs:

analyze:
needs: generate
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v8
with:
name: dart-generated

- uses: dart-lang/setup-dart@v1.8.0

- run: dart pub get
working-directory: vrchat_dart_generated

- run: dart analyze
working-directory: vrchat_dart_generated

pana:
needs: generate
runs-on: ubuntu-latest
strategy:
matrix:
package: [vrchat_dart, vrchat_dart_generated]
defaults:
run:
working-directory: ${{ matrix.package }}
steps:
- uses: actions/download-artifact@v8
with:
name: dart-generated

- uses: dart-lang/setup-dart@v1.8.0

- run: dart pub get

- run: dart pub publish --dry-run

- run: |
dart pub global activate pana
pana --no-warning --exit-code-threshold 0
uses: vrchatapi/vrchatapi-dart/.github/workflows/analyze.yaml@main
with:
artifact: dart-generated
16 changes: 14 additions & 2 deletions .github/workflows/generate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ on:
repository_dispatch:
types: [release]
workflow_dispatch:
inputs:
url:
description: OpenAPI bundle URL. Release dispatches use the triggering release instead.
required: false
type: string
default: https://github.com/vrchatapi/specification/releases/download/nightly/openapi-3.0.yaml

jobs:
generate:
Expand All @@ -24,9 +30,15 @@ jobs:
restore-keys: ${{ env.cache-name }}-

- uses: vrchatapi/specification/.github/actions/setup-generator@main

- uses: vrchatapi/specification/.github/actions/download@main
with:
bundle: openapi-3.0.yaml
url: ${{ github.event_name == 'workflow_dispatch' && inputs.url || '' }}
- run: |
mkdir -p ../vrchatapi-specification/dist
mv openapi-3.0.yaml ../vrchatapi-specification/dist/
- name: Generate
run: ./generate.sh
run: ./generate.sh local

- name: Check for CHANGELOG changes
id: changelog
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Test
on:
push:
branches:
- '**'
- main
pull_request:

concurrency:
Expand All @@ -29,7 +29,7 @@ jobs:
env:
SECRET_FILE_CONTENT: ${{ secrets.TEST_CREDENTIALS_FILE }}
run: |
echo $SECRET_FILE_CONTENT | base64 -d > vrchat_dart/example/bin/credentials.dart
echo $SECRET_FILE_CONTENT | base64 -d > vrchat_dart/example/bin/credentials.json
- name: Run example
run: |
cd vrchat_dart/example
Expand Down
2 changes: 1 addition & 1 deletion vrchat_dart/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,4 @@ build/
.cookies/

# Credentials
credentials.dart
credentials.json
25 changes: 25 additions & 0 deletions vrchat_dart/example/bin/credentials.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import 'package:meta/meta.dart';

@immutable
class Credentials {
const Credentials({
required this.username,
required this.password,
required this.contactInfo,
required this.otpSecret,
});

factory Credentials.fromJson(Map<String, dynamic> json) {
return Credentials(
username: json['username'] as String,
password: json['password'] as String,
contactInfo: json['contactInfo'] as String,
otpSecret: json['otpSecret'] as String,
);
}

final String username;
final String password;
final String contactInfo;
final String otpSecret;
}
24 changes: 16 additions & 8 deletions vrchat_dart/example/bin/main.dart
Original file line number Diff line number Diff line change
@@ -1,27 +1,35 @@
import 'dart:convert';
import 'dart:io';
import 'dart:io' as io;

import 'package:otp/otp.dart';
import 'package:vrchat_dart/vrchat_dart.dart';

/// Create the file `lib/credentials.dart` with the fields required to make
/// this file happy
import 'credentials.dart';

const tupperUid = 'usr_c1644b5b-3ca4-45b4-97c6-a2a0de70d469';

void main() async {
// Create `bin/credentials.json` with username, password, contactInfo, and
// otpSecret.
final credentials = Credentials.fromJson(
jsonDecode(
await io.File.fromUri(
io.Platform.script.resolve('credentials.json'),
).readAsString(),
) as Map<String, dynamic>,
);

final api = VrchatDart(
userAgent: VrchatUserAgent(
applicationName: 'vrchat_dart_example',
version: '0.0.0',
contactInfo: Credentials.contactInfo,
contactInfo: credentials.contactInfo,
),
);

final (loginSuccess, loginFailure) = await api.auth.login(
username: Credentials.username,
password: Credentials.password,
username: credentials.username,
password: credentials.password,
);

if (loginSuccess == null) {
Expand All @@ -44,7 +52,7 @@ void main() async {
// scripts. To get around this, enable 2FA on your account and generate
// codes in your script.
final code = OTP.generateTOTPCodeString(
Credentials.otpSecret,
credentials.otpSecret,
DateTime.timestamp().millisecondsSinceEpoch,
algorithm: Algorithm.SHA1,
isGoogle: true,
Expand Down Expand Up @@ -125,7 +133,7 @@ void main() async {
print(worldSuccess.data.name);

// Do not start websocket streaming if this code is running in CI
if (Platform.environment.containsKey('GITHUB_ACTIONS')) return;
if (io.Platform.environment.containsKey('GITHUB_ACTIONS')) return;

// Listen for updates
api.streaming.vrcEventStream.listen(handleVrcEvent);
Expand Down
1 change: 1 addition & 0 deletions vrchat_dart/example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ dependencies:
vrchat_dart:
path: ../

meta: ^1.16.0
otp: ^3.1.3

dev_dependencies:
Expand Down
45 changes: 0 additions & 45 deletions vrchat_dart/example_flutter/.metadata

This file was deleted.

4 changes: 0 additions & 4 deletions vrchat_dart/example_flutter/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
include: package:rexios_lints/flutter/core_extra.yaml

analyzer:
exclude:
- build/**
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
import 'package:package_info_plus/package_info_plus.dart';
import 'package:path_provider/path_provider.dart';
import 'package:vrchat_dart/vrchat_dart.dart';
import 'package:vrchat_dart_example_flutter/vrc_api_container_impl_base.dart';

/// Initialize VrchatDart on a native platform
class VrcApiContainerImpl extends VrcApiContainerImplBase {
@override
Future<VrchatDart> create() async {
final packageInfo = await PackageInfo.fromPlatform();
final appDocDir = await getApplicationDocumentsDirectory();
final appDocPath = appDocDir.path;
// In a real app, use package_info_plus.
const version = '0.0.0';
// In a real app, use path_provider.
const appDocPath = 'path/to/application/documents';

return VrchatDart(
userAgent: VrchatUserAgent(
userAgent: const VrchatUserAgent(
applicationName: 'vrchat_dart_example',
version: packageInfo.version,
version: version,
contactInfo: 'TODO',
),
cookiePath: appDocPath,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import 'package:package_info_plus/package_info_plus.dart';
import 'package:vrchat_dart/vrchat_dart.dart';
import 'package:vrchat_dart_example_flutter/vrc_api_container_impl_base.dart';

/// Initialize VrchatDart on a web platform
class VrcApiContainerImpl extends VrcApiContainerImplBase {
@override
Future<VrchatDart> create() async {
final packageInfo = await PackageInfo.fromPlatform();
// In a real app, use package_info_plus.
const version = '0.0.0';
return VrchatDart(
userAgent: VrchatUserAgent(
userAgent: const VrchatUserAgent(
applicationName: 'vrchat_dart_example',
version: packageInfo.version,
version: version,
contactInfo: 'TODO',
),
// See nginx.conf for an example nginx configuration
Expand Down
Loading
Loading