Skip to content

Commit

Permalink
feat: Separates core framework and cli (#161)
Browse files Browse the repository at this point in the history
* feat: Separates core framework and cli
  • Loading branch information
j4qfrost committed Dec 28, 2022
1 parent b9d82dd commit 28445bb
Show file tree
Hide file tree
Showing 403 changed files with 1,469 additions and 758 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
runner_args: [dart test -j1 -t cli test/*, melos test-unit-scoped, dart tool/generated_test_runner.dart]
runner_args: [melos test-unit, dart tool/generated_test_runner.dart]
env:
TEST_DIR: packages/conduit
TEST_DIR: packages/core
services:
postgres:
image: postgres:14.5
Expand All @@ -39,8 +39,8 @@ jobs:
- name: Get Dependencies
run: |
dart pub global activate melos
melos cache-source
melos bootstrap
melos cache-source
dart pub get --directory=packages/isolate_exec_test_packages/test_package --offline
dart pub get --directory=packages/runtime_test_packages/application --offline
dart pub get --directory=packages/runtime_test_packages/dependency --offline
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ jobs:
runs-on: macos-latest
strategy:
matrix:
runner_args: [dart test -j1 -t cli test/*, melos test-unit-scoped, dart tool/generated_test_runner.dart]
runner_args: [melos test-unit, dart tool/generated_test_runner.dart]
env:
TEST_DIR: packages/conduit
TEST_DIR: packages/core
POSTGRES_HOST: localhost
POSTGRES_PORT: 15432
POSTGRES_USER: conduit_test_user
Expand Down Expand Up @@ -50,8 +50,8 @@ jobs:
- name: Get Dependencies
run: |
dart pub global activate melos
melos cache-source
melos bootstrap
melos cache-source
dart pub get --directory=packages/isolate_exec_test_packages/test_package --offline
dart pub get --directory=packages/runtime_test_packages/application --offline
dart pub get --directory=packages/runtime_test_packages/dependency --offline
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- uses: actions/checkout@v3
- uses: dart-lang/setup-dart@v1
with:
sdk: dev
sdk: stable
- name: Prepare pub credentials
run: |
mkdir "$XDG_CONFIG_HOME/dart"
Expand All @@ -35,7 +35,7 @@ jobs:
- name: Uptick versions
run: melos version --yes
- name: Changelog
run: git diff --unified=0 $GITHUB_SHA packages/conduit/CHANGELOG.md | tail +6 | sed -e 's/^\+//' > CHANGES.txt
run: git diff --unified=0 $GITHUB_SHA packages/cli/CHANGELOG.md | tail +6 | sed -e 's/^\+//' > CHANGES.txt
- name: Cache Source
run: melos cache-source
- name: Publish package
Expand All @@ -48,7 +48,7 @@ jobs:
branch: master
- name: Compute the release tag
run: |
echo "release_tag=v`cat packages/conduit/pubspec.yaml | sed -nre 's/^version: [^0-9]*(([0-9]+\.)*[0-9]+).*/\1/p'`" >> $GITHUB_ENV
echo "release_tag=v`cat packages/cli/pubspec.yaml | sed -nre 's/^version: [^0-9]*(([0-9]+\.)*[0-9]+).*/\1/p'`" >> $GITHUB_ENV
- name: Release
uses: softprops/action-gh-release@v1
with:
Expand Down
12 changes: 4 additions & 8 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ jobs:
runs-on: windows-latest
strategy:
matrix:
runner_args: [dart test -j1 -t cli test/, melos test-unit, dart tool/generated_test_runner.dart]
runner_args: [melos test-unit, dart tool/generated_test_runner.dart]
env:
TEST_DIR: packages/conduit
TEST_DIR: packages/core
POSTGRES_HOST: localhost
POSTGRES_PORT: 15432
POSTGRES_USER: conduit_test_user
Expand All @@ -29,7 +29,6 @@ jobs:
TEST_DB_ENV_VAR: postgres://user:password@host:5432/dbname
TEST_VALUE: 1
TEST_BOOL: true
PUB_CACHE: C:\.pub_cache
steps:
- name: Start PostgreSQL
run: |
Expand All @@ -46,22 +45,19 @@ jobs:
& $env:PGBIN\psql --command="ALTER USER ${{ env.POSTGRES_USER }} WITH PASSWORD '${{ env.POSTGRES_PASSWORD }}'"
& $env:PGBIN\createdb --owner=${{ env.POSTGRES_USER }} ${{ env.POSTGRES_DB }}
- uses: actions/checkout@v3
- name: Make pub cache
run: |
mkdir C:\.pub_cache
icacls "C:\.pub_cache" /grant Users:F /T
- uses: dart-lang/setup-dart@v1
with:
sdk: dev
- name: Get Dependencies
run: |
choco install yq
dart pub global activate melos
dart pub global run melos:melos cache-source-win
dart pub global run melos:melos bootstrap
dart pub global run melos:melos cache-source-win
dart pub get --directory=packages/isolate_exec_test_packages/test_package --offline
dart pub get --directory=packages/runtime_test_packages/application --offline
dart pub get --directory=packages/runtime_test_packages/dependency --offline
- name: Run tests
env:
CONDUIT_CI_DIR_LOCATION: ${{ github.workspace }}\ci\
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Currently there are three tests that need to be run to hit all the tests:
```bash
melos test-unit
# These two need to be run inside packages/conduit
dart test -j1 -t cli test/* # use dart test -j1 -t cli for windows and macos
dart test -j1 test/* # use dart test -j1 for windows and macos
dart tool/generated_test_runner.dart
```
The first will run all the unit tests in conduit and all its dependencies. The last two test cli components and string-compiled code respectively.
Expand Down
10 changes: 5 additions & 5 deletions docs/auth/server.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ An `AuthServer` must persist the data it uses and creates - like client identifi
This concrete implementation is named `ManagedAuthDelegate<T>`. It exists in a sub-package of Conduit and must be explicitly imported. Here's an example of creating an `AuthServer` and `ManagedAuthDelegate<T>`:

```dart
import 'package:conduit/conduit.dart';
import 'package:conduit/managed_auth.dart';
import 'package:conduit_core/conduit_core.dart';
import 'package:conduit_core/managed_auth.dart';
class MyApplicationChannel extends ApplicationChannel {
AuthServer authServer;
Expand All @@ -37,8 +37,8 @@ class MyApplicationChannel extends ApplicationChannel {
While `AuthServer` has methods for handling authorization tasks, it is rarely used directly. Instead, `AuthCodeController` and `AuthController` are hooked up to routes to grant authorization tokens through your application's HTTP API. Instances of `Authorizer` secure routes in channels. All of these types invoke the appropriate methods on the `AuthServer`. Here's an example `ApplicationChannel` subclass that sets up and uses authorization:

```dart
import 'package:conduit/conduit.dart';
import 'package:conduit/managed_auth.dart';
import 'package:conduit_core/conduit_core.dart';
import 'package:conduit_core/managed_auth.dart';
class MyApplicationChannel extends ApplicationChannel {
AuthServer authServer;
Expand Down Expand Up @@ -76,7 +76,7 @@ For more details on authorization controllers like `AuthController`, see [Author

## Using ManagedAuthDelegate

`ManagedAuthDelegate<T>` is a concrete implementation of `AuthServerDelegate`, providing storage of authorization tokens and clients for an `AuthServer`. Storage is accomplished by Conduit's ORM. `ManagedAuthDelegate<T>`, by default, is not part of the standard `conduit` library. To use this class, an application must import `package:conduit/managed_auth.dart`.
`ManagedAuthDelegate<T>` is a concrete implementation of `AuthServerDelegate`, providing storage of authorization tokens and clients for an `AuthServer`. Storage is accomplished by Conduit's ORM. `ManagedAuthDelegate<T>`, by default, is not part of the standard `conduit` library. To use this class, an application must import `package:conduit_core/managed_auth.dart`.

The type argument to `ManagedAuthDelegate<T>` represents the application's concept of a 'user' or 'account' - OAuth 2.0 terminology would refer to this type as a _resource owner_. A resource owner must be a `ManagedObject<T>` subclass that is specific to your application. Its table definition _must extend_ `ResourceOwnerTableDefinition` and the instance type must implement `ManagedAuthResourceOwner<T>`, where `T` is the table definition. A basic definition may look like this:

Expand Down
12 changes: 6 additions & 6 deletions docs/core_concepts/tour.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ conduit serve
A Conduit application starts at an [ApplicationChannel](../application/channel.md). You subclass it once per application to handle initialization tasks like setting up routes and database connections. An example application looks like this:

```dart
import 'package:conduit/conduit.dart';
import 'package:conduit_core/conduit_core.dart';
class TodoApp extends ApplicationChannel {
ManagedContext context;
Expand Down Expand Up @@ -96,7 +96,7 @@ All controllers execute their code in an exception handler. If an exception is t
[ResourceControllers](../http/resource_controller.md) are the most often used controller. Each operation - e.g. `POST /projects`, `GET /projects` and `GET /projects/1` - is mapped to methods in a subclass. Parameters of those methods are annotated to bind the values of the request when the method is invoked.

```dart
import 'package:conduit/conduit.dart'
import 'package:conduit_core/conduit_core.dart'
class ProjectController extends ResourceController {
@Operation.get('id')
Expand Down Expand Up @@ -159,7 +159,7 @@ class TodoConfig extends Configuration {
The default name of your configuration file is `config.yaml`, but can be changed at the command-line. You create an instance of your configuration from the configuration file path from your application options:

```dart
import 'package:conduit/conduit.dart';
import 'package:conduit_core/conduit_core.dart';
class TodoApp extends ApplicationChannel {
@override
Expand All @@ -185,7 +185,7 @@ Conduit applications are multi-isolate \(multi-threaded\). Each isolate runs a r
The `Query<T>` class configures and executes database queries. Its type argument determines what table is to be queried and the type of object you will work with in your code.

```dart
import 'package:conduit/conduit.dart'
import 'package:conduit_core/conduit_core.dart'
class ProjectController extends ResourceController {
ProjectController(this.context);
Expand Down Expand Up @@ -312,8 +312,8 @@ You can edit migration files by hand to alter any assumptions or enter required
An OAuth 2.0 server implementation handles authentication and authorization for Conduit applications. You create an `AuthServer` and its delegate as services in your application. The delegate is configurable and manages how tokens are generated and stored. By default, access tokens are a random 32-byte string and client identifiers, tokens and access codes are stored in your database using the ORM.

```dart
import 'package:conduit/conduit.dart';
import 'package:conduit/managed_auth.dart';
import 'package:conduit_core/conduit_core.dart';
import 'package:conduit_core/managed_auth.dart';
class AppApplicationChannel extends ApplicationChannel {
AuthServer authServer;
Expand Down
2 changes: 1 addition & 1 deletion docs/deploy/deploy_heroku.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ git push heroku master

This command pushes your code to a remote git server hosted by Heroku, which triggers your application to run its release script.

Now that your application's database schema has been uploaded, you can configure your OAuth 2 server with client identifiers if you are using `package:conduit/managed_auth`. The following command will run within your application's remote environment.
Now that your application's database schema has been uploaded, you can configure your OAuth 2 server with client identifiers if you are using `package:conduit_core/managed_auth`. The following command will run within your application's remote environment.

```bash
heroku run /app/dart-sdk/bin/pub global run conduit:conduit auth add-client --id com.app.standard --secret secret --connect \$DATABASE_URL
Expand Down
2 changes: 1 addition & 1 deletion docs/deploy/deploy_local.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ conduit db upgrade --connect postgres://app_name_user:yourpassword@localhost:543

## Step 3: Add an OAuth 2.0 client.

If you are using `package:conduit/managed_auth`, you'll want to create an OAuth2 client identifier. From the command line, run the following, ensuring that the values for the option `--connect` match the recently created database.
If you are using `package:conduit_core/managed_auth`, you'll want to create an OAuth2 client identifier. From the command line, run the following, ensuring that the values for the option `--connect` match the recently created database.

```bash
conduit auth add-client --id com.app_name.standard --secret abcdefghi --connect postgres://app_name_user:yourpassword@localhost:5432/app_name
Expand Down
2 changes: 1 addition & 1 deletion docs/deploy/script.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ A sample script looks like this:
import 'dart:async';
import 'dart:io';
import 'package:conduit/conduit.dart';
import 'package:conduit_core/conduit_core.dart';
import 'package:my_application/my_application.dart';
Future main() async {
Expand Down
2 changes: 1 addition & 1 deletion docs/http/file_upload.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ dependencies:
By default, resource controllers only accept `application/json` requests and must be configured to accept `multipart/form-data` requests. To read each part, create a `MimeMultipartTransformer` and stream the body into it. The following shows an example:

```dart
import 'package:conduit/conduit.dart';
import 'package:conduit_core/conduit_core.dart';
import 'package:mime/mime.dart';
class MyController extends ResourceController {
Expand Down
14 changes: 7 additions & 7 deletions docs/snippets/auth.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
## Enable OAuth 2.0

```dart
import 'package:conduit/conduit.dart';
import 'package:conduit/managed_auth.dart';
import 'package:conduit_core/conduit_core.dart';
import 'package:conduit_core/managed_auth.dart';
class AppChannel extends ApplicationChannel {
AuthServer authServer;
Expand Down Expand Up @@ -48,8 +48,8 @@ conduit auth add-client \
## Require OAuth 2.0 Scope to Access Routes

```dart
import 'package:conduit/conduit.dart';
import 'package:conduit/managed_auth.dart';
import 'package:conduit_core/conduit_core.dart';
import 'package:conduit_core/managed_auth.dart';
class AppChannel extends ApplicationChannel {
AuthServer authServer;
Expand Down Expand Up @@ -101,7 +101,7 @@ class ProfileController extends ResourceController {
## Basic Authentication

```dart
import 'package:conduit/conduit.dart';
import 'package:conduit_core/conduit_core.dart';
class AppChannel extends ApplicationChannel {
@override
Expand Down Expand Up @@ -131,8 +131,8 @@ class PasswordVerifier extends AuthValidator {
## Add OAuth 2.0 Authorization Code Flow

```dart
import 'package:conduit/conduit.dart';
import 'package:conduit/managed_auth.dart';
import 'package:conduit_core/conduit_core.dart';
import 'package:conduit_core/managed_auth.dart';
class AppChannel extends ApplicationChannel {
AuthServer authServer;
Expand Down
2 changes: 1 addition & 1 deletion docs/testing/mixins.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ conduit db upgrade --connect postgres://my_app_user:mypassword@localhost:5432/my

Applications that use OAuth 2.0 should mixin `TestHarnessAuthMixin`. This mixin adds methods for registering a client identifier and authenticating a user. Both methods return an `Agent` with default headers with authorization information for the client identifier or user.

Most often, you use `package:conduit/managed_auth` for an ORM-driven OAuth2 delegate. You must also mixin `TestHarnessORMMixin` when using this mixin.
Most often, you use `package:conduit_core/managed_auth` for an ORM-driven OAuth2 delegate. You must also mixin `TestHarnessORMMixin` when using this mixin.

```dart
class Harness extends TestHarness<AppChannel> with TestHarnessAuthMixin<AppChannel>, TestHarnessORMMixin {
Expand Down
2 changes: 1 addition & 1 deletion docs/testing/mock.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ You may also subclass `MockHTTPServer` and override its `open` method to add log
A `MockHTTPServer` is created when setting up tests. It must be closed when tearing down tests. If you use the same mock server to across all tests \(e.g., open it in `setUpAll`\), make sure to clear it after each test:

```dart
import 'package:conduit/test.dart';
import 'package:conduit_core/test.dart';
void main() {
var mockServer = new MockHTTPServer(4000);
Expand Down
12 changes: 6 additions & 6 deletions docs/tour.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ conduit serve
A Conduit application starts at an [ApplicationChannel](application/channel.md). You subclass it once per application to handle initialization tasks like setting up routes and database connections. An example application looks like this:

```dart
import 'package:conduit/conduit.dart';
import 'package:conduit_core/conduit_core.dart';
class TodoApp extends ApplicationChannel {
ManagedContext context;
Expand Down Expand Up @@ -96,7 +96,7 @@ All controllers execute their code in an exception handler. If an exception is t
[ResourceControllers](http/resource_controller.md) are the most often used controller. Each operation - e.g. `POST /projects`, `GET /projects` and `GET /projects/1` - is mapped to methods in a subclass. Parameters of those methods are annotated to bind the values of the request when the method is invoked.

```dart
import 'package:conduit/conduit.dart'
import 'package:conduit_core/conduit_core.dart'
class ProjectController extends ResourceController {
@Operation.get('id')
Expand Down Expand Up @@ -159,7 +159,7 @@ class TodoConfig extends Configuration {
The default name of your configuration file is `config.yaml`, but can be changed at the command-line. You create an instance of your configuration from the configuration file path from your application options:

```dart
import 'package:conduit/conduit.dart';
import 'package:conduit_core/conduit_core.dart';
class TodoApp extends ApplicationChannel {
@override
Expand All @@ -185,7 +185,7 @@ Conduit applications are multi-isolate \(multi-threaded\). Each isolate runs a r
The `Query<T>` class configures and executes database queries. Its type argument determines what table is to be queried and the type of object you will work with in your code.

```dart
import 'package:conduit/conduit.dart'
import 'package:conduit_core/conduit_core.dart'
class ProjectController extends ResourceController {
ProjectController(this.context);
Expand Down Expand Up @@ -312,8 +312,8 @@ You can edit migration files by hand to alter any assumptions or enter required
An OAuth 2.0 server implementation handles authentication and authorization for Conduit applications. You create an `AuthServer` and its delegate as services in your application. The delegate is configurable and manages how tokens are generated and stored. By default, access tokens are a random 32-byte string and client identifiers, tokens and access codes are stored in your database using the ORM.

```dart
import 'package:conduit/conduit.dart';
import 'package:conduit/managed_auth.dart';
import 'package:conduit_core/conduit_core.dart';
import 'package:conduit_core/managed_auth.dart';
class AppApplicationChannel extends ApplicationChannel {
AuthServer authServer;
Expand Down
2 changes: 1 addition & 1 deletion docs/tut/executing-queries.md
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ conduit db generate
This command will create a new _migration file_. A migration file is a Dart script that runs a series of SQL commands to alter a database's schema. It is created in a new directory in your project named `migrations/`. Open `migrations/00000001_initial.migration.dart`, it should look like this:

```dart
import 'package:conduit/conduit.dart';
import 'package:conduit_core/conduit_core.dart';
import 'dart:async';
class Migration1 extends Migration {
Expand Down
2 changes: 1 addition & 1 deletion docs/tut/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ You use the `route` method on a router to attach a controller to a _route_. A ro
We need to route the path `/heroes` to a controller of our own, so we can control what happens. Let's create a `HeroesController`. Create a new file in `lib/controller/heroes_controller.dart` and add the following code \(you will need to create the subdirectory `lib/controller/`\):

```dart
import 'package:conduit/conduit.dart';
import 'package:conduit_core/conduit_core.dart';
import 'package:heroes/heroes.dart';
class HeroesController extends Controller {
Expand Down
Loading

0 comments on commit 28445bb

Please sign in to comment.