Skip to content

Commit 4ecfa64

Browse files
feat(graphql_common): add common package that contains utils functions
Signed-off-by: Vincenzo Palazzo <[email protected]>
1 parent d7f5403 commit 4ecfa64

File tree

10 files changed

+148
-0
lines changed

10 files changed

+148
-0
lines changed

packages/graphql_common/.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Files and directories created by pub.
2+
.dart_tool/
3+
.packages
4+
5+
# Conventional directory for build outputs.
6+
build/
7+
8+
# Omit committing pubspec.lock for library packages; see
9+
# https://dart.dev/guides/libraries/private-files#pubspeclock.
10+
pubspec.lock
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## 1.0.0
2+
3+
- Initial version.

packages/graphql_common/README.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<!--
2+
This README describes the package. If you publish this package to pub.dev,
3+
this README's contents appear on the landing page for your package.
4+
5+
For information about how to write a good package README, see the guide for
6+
[writing package pages](https://dart.dev/guides/libraries/writing-package-pages).
7+
8+
For general information about developing packages, see the Dart guide for
9+
[creating packages](https://dart.dev/guides/libraries/create-library-packages)
10+
and the Flutter guide for
11+
[developing packages and plugins](https://flutter.dev/developing-packages).
12+
-->
13+
14+
TODO: Put a short description of the package here that helps potential users
15+
know whether this package might be useful for them.
16+
17+
## Features
18+
19+
TODO: List what your package can do. Maybe include images, gifs, or videos.
20+
21+
## Getting started
22+
23+
TODO: List prerequisites and provide or point to information on how to
24+
start using the package.
25+
26+
## Usage
27+
28+
TODO: Include short and useful examples for package users. Add longer examples
29+
to `/example` folder.
30+
31+
```dart
32+
const like = 'sample';
33+
```
34+
35+
## Additional information
36+
37+
TODO: Tell users more about the package: where to find more information, how to
38+
contribute to the package, how to file issues, what response they can expect
39+
from the package authors, and more.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# This file configures the static analysis results for your project (errors,
2+
# warnings, and lints).
3+
#
4+
# This enables the 'recommended' set of lints from `package:lints`.
5+
# This set helps identify many issues that may lead to problems when running
6+
# or consuming Dart code, and enforces writing Dart using a single, idiomatic
7+
# style and format.
8+
#
9+
# If you want a smaller set of lints you can change this to specify
10+
# 'package:lints/core.yaml'. These are just the most critical lints
11+
# (the recommended set includes the core lints).
12+
# The core lints are also what is used by pub.dev for scoring packages.
13+
14+
include: package:lints/recommended.yaml
15+
16+
# Uncomment the following section to specify additional rules.
17+
18+
# linter:
19+
# rules:
20+
# - camel_case_types
21+
22+
# analyzer:
23+
# exclude:
24+
# - path/to/excluded/files/**
25+
26+
# For more information about the core and recommended set of lints, see
27+
# https://dart.dev/go/core-lints
28+
29+
# For additional information about configuring this file, see
30+
# https://dart.dev/guides/language/analysis-options
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
void main() {}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/// Support for doing something awesome.
2+
///
3+
/// More dartdocs go here.
4+
library graphql_common;
5+
6+
export 'src/tracing/tracer.dart';
7+
export 'src/tracing/logger_tracer.dart';
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import 'package:graphql_common/src/tracing/tracer.dart';
2+
import 'package:logger/logger.dart';
3+
4+
class LoggerTracer extends Tracer {
5+
late Logger _logger;
6+
7+
LoggerTracer(
8+
{LogFilter? filter,
9+
LogPrinter? printer,
10+
LogOutput? output,
11+
Level? level}) {
12+
_logger =
13+
Logger(filter: filter, printer: printer, output: output, level: level);
14+
}
15+
16+
@override
17+
Future<void> asyncTrace(String msg, {Map<String, dynamic>? opts}) {
18+
return Future(() => _logger.d(msg));
19+
}
20+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/// Tracer is an abstract class that provide the basic blocs to
2+
/// build an application tracer (aka Logger).
3+
///
4+
/// author: Vincenzo Palazzo <[email protected]>
5+
abstract class Tracer {
6+
/// Async function to start to tracing the library at runtime
7+
/// useful when the user want log the information in an external
8+
/// source, and it is required an async trace!
9+
Future<void> asyncTrace(String msg, {Map<String, dynamic>? opts});
10+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: graphql_common
2+
description: A starting point for Dart libraries or applications.
3+
version: 0.0.1
4+
# homepage: https://www.example.com
5+
6+
environment:
7+
sdk: '>=2.12.6 <3.0.0'
8+
9+
dependencies:
10+
logger: ^1.1.0
11+
12+
13+
dev_dependencies:
14+
lints: ^2.0.0
15+
test: ^1.16.0
16+
graphql:
17+
path: ../graphql
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import 'package:test/test.dart';
2+
3+
void main() {
4+
group('A group of tests', () {
5+
setUp(() {
6+
// Additional setup goes here.
7+
});
8+
9+
test('First Test', () {});
10+
});
11+
}

0 commit comments

Comments
 (0)