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
8 changes: 4 additions & 4 deletions .github/workflows/build_linux_macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ jobs:
run: dart pub get

- name: Prepare pubspec
run: dart run scripts/prepare_pubspec.dart --version ${{ env.version }}
run: dart scripts/prepare_pubspec.dart --version ${{ env.version }}

- name: Run build runner
run: dart run build_runner build -r -v --low-resources-mode

- name: Generate docs
run: dart run scripts/docs/generate.dart
run: dart scripts/docs/generate.dart

- name: Dart format
run: |
Expand Down Expand Up @@ -99,13 +99,13 @@ jobs:
run: dart pub get

- name: Prepare pubspec
run: dart run scripts/prepare_pubspec.dart --version ${{ env.version }}
run: dart scripts/prepare_pubspec.dart --version ${{ env.version }}

- name: Run build runner
run: dart run build_runner build -r -v --low-resources-mode

- name: Generate docs
run: dart run scripts/docs/generate.dart
run: dart scripts/docs/generate.dart

- name: Dart format
run: |
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/build_windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ jobs:
run: dart pub get

- name: Prepare pubspec
run: dart run scripts/prepare_pubspec.dart --version ${{ env.version }}
run: dart scripts/prepare_pubspec.dart --version ${{ env.version }}

- name: Run build runner
run: dart run build_runner build -r -v --low-resources-mode
Expand Down Expand Up @@ -102,10 +102,10 @@ jobs:
run: dart pub get

- name: Prepare inno setup
run: dart run scripts/prepare_inno_setup.dart --version ${{ env.version }}
run: dart scripts/prepare_inno_setup.dart --version ${{ env.version }}

- name: Generate docs
run: dart run scripts/docs/generate.dart
run: dart scripts/docs/generate.dart

- name: Get artifacts
uses: actions/download-artifact@v8
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/update_docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
run: dart run build_runner build -r -v --low-resources-mode

- name: Generate docs
run: dart run scripts/docs/generate.dart
run: dart scripts/docs/generate.dart

- name: Git config
run: |
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,13 @@ For details see [CONTRIBUTING.md](CONTRIBUTING.md).
- You can perform the test manually by running the command below.

```sh
dart run lib/main.dart
dart lib/main.dart
```

- Try adding arguments.

```sh
dart run lib/main.dart --version
dart lib/main.dart --version
```

## LICENSE
Expand Down
4 changes: 2 additions & 2 deletions lib/cli/context.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import "dart:io";
import "package:discloud/cli/disposable.dart";
import "package:discloud/cli/printer/console_printer.dart";
import "package:discloud/cli/printer/iprinter.dart";
import "package:discloud/cli/spin/cli_spin.dart";
import "package:discloud/cli/spin/ispin.dart";
import "package:discloud/extensions/duration.dart";
import "package:discloud/extensions/list.dart";
import "package:discloud/services/discloud/api_client.dart";
Expand Down Expand Up @@ -64,7 +64,7 @@ class CliContext implements Disposable {
final bool debug;
final DiscloudApiClient api;
final LocalStore store;
final IPrinter<CLISpin> printer;
final IPrinter<ISpin> printer;

String get locale => localeName;

Expand Down
9 changes: 5 additions & 4 deletions lib/cli/printer/console_printer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,27 @@ import "dart:io";

import "package:discloud/cli/printer/iprinter.dart";
import "package:discloud/cli/spin/cli_spin.dart";
import "package:discloud/cli/spin/ispin.dart";

part "debug_console_printer.dart";

class ConsolePrinter implements IPrinter<CLISpin> {
class ConsolePrinter implements IPrinter<ISpin> {
factory ConsolePrinter._debug() = _DebugConsolePrinter;

factory ConsolePrinter({bool isDebug = false}) => isDebug ? ._debug() : ._();

ConsolePrinter._();

CLISpin? _spin;
ISpin? _spin;

@override
void dispose() {
_spin?.stop();
}

@override
CLISpin spin({String? text, bool start = true, bool showDuration = true}) {
final spin = _spin ??= .new(text: text, showDuration: showDuration);
ISpin spin({String? text, bool start = true, bool showDuration = true}) {
final spin = _spin ??= CLISpin(text: text, showDuration: showDuration);
if (start) spin.start();
return spin;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/cli/printer/debug_console_printer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ part of "console_printer.dart";
class _DebugConsolePrinter extends ConsolePrinter {
_DebugConsolePrinter() : super._();

void _debugSpin(CLISpin spin, Object? object) {
void _debugSpin(ISpin spin, Object? object) {
spin.stop();
stderr.writeln(object);
spin.start();
Expand Down
4 changes: 2 additions & 2 deletions lib/commands/init.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ final class InitCommand extends Command<void> {

@override
Future<void> run() async {
final file = File(DiscloudConfig.filename);
final File file = .new(DiscloudConfig.filename);

final args = _InitArgs(argResults);
final _InitArgs args = .new(argResults);

if (!args.force && await file.exists()) {
throw Exception("${DiscloudConfig.filename} already exists!");
Expand Down
11 changes: 11 additions & 0 deletions lib/utils/bytes.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class Bytes<N extends num> {

Bytes operator +(Object? other) {
return switch (other) {
final _Bits other => .new(other.n / 8 + n),
final Bytes other => .new(other.n + n),
final num other => .new(other + n),
_ => this,
Expand All @@ -63,6 +64,7 @@ class Bytes<N extends num> {

Bytes operator -(Object? other) {
return switch (other) {
final _Bits other => .new(other.n / 8 - n),
final Bytes other => .new(other.n - n),
final num other => .new(other - n),
_ => this,
Expand All @@ -71,6 +73,7 @@ class Bytes<N extends num> {

Bytes operator *(Object? other) {
return switch (other) {
final _Bits other => .new(other.n / 8 * n),
final Bytes other => .new(other.n * n),
final num other => .new(other * n),
_ => this,
Expand All @@ -79,6 +82,7 @@ class Bytes<N extends num> {

Bytes operator /(Object? other) {
return switch (other) {
final _Bits other => .new(other.n / 8 / n),
final Bytes other => .new(other.n / n),
final num other => .new(other / n),
_ => this,
Expand All @@ -87,6 +91,7 @@ class Bytes<N extends num> {

Bytes operator ~/(Object? other) {
return switch (other) {
final _Bits other => .new(other.n / 8 ~/ n),
final Bytes other => .new(other.n ~/ n),
final num other => .new(other ~/ n),
_ => this,
Expand All @@ -95,6 +100,7 @@ class Bytes<N extends num> {

Bytes operator %(Object? other) {
return switch (other) {
final _Bits other => .new(other.n / 8 % n),
final Bytes other => .new(other.n % n),
final num other => .new(other % n),
_ => this,
Expand All @@ -103,6 +109,7 @@ class Bytes<N extends num> {

bool operator >(Object? other) {
return switch (other) {
final _Bits other => other.n / 8 > n,
final Bytes other => other.n > n,
final num other => other > n,
_ => false,
Expand All @@ -111,6 +118,7 @@ class Bytes<N extends num> {

bool operator >=(Object? other) {
return switch (other) {
final _Bits other => other.n / 8 >= n,
final Bytes other => other.n >= n,
final num other => other >= n,
_ => false,
Expand All @@ -119,6 +127,7 @@ class Bytes<N extends num> {

bool operator <(Object? other) {
return switch (other) {
final _Bits other => other.n / 8 < n,
final Bytes other => other.n < n,
final num other => other < n,
_ => false,
Expand All @@ -127,6 +136,7 @@ class Bytes<N extends num> {

bool operator <=(Object? other) {
return switch (other) {
final _Bits other => other.n / 8 <= n,
final Bytes other => other.n <= n,
final num other => other <= n,
_ => false,
Expand All @@ -136,6 +146,7 @@ class Bytes<N extends num> {
@override
bool operator ==(other) {
return switch (other) {
final _Bits other => other.n / 8 == n,
final Bytes other => other.n == n,
final num other => other == n,
_ => false,
Expand Down
4 changes: 3 additions & 1 deletion modules/glob_zipper/lib/src/exception.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
part of "glob_zipper.dart";

class ZipException implements Exception {}
class ZipException implements Exception {
const ZipException();
}
16 changes: 9 additions & 7 deletions modules/glob_zipper/lib/src/glob_zipper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,9 @@ class GlobZipper {
Stream<File> Function() fileStreamFactory, [
OnErrorCallback? onError,
]) async {
onError ??= _noop;
await for (final file in fileStreamFactory().handleError(onError)) {
await for (final file in fileStreamFactory().handleError(
onError ?? _noop,
)) {
final aFile = await _toArchiveFile(file, root: directory);

encoder.addArchiveFile(aFile);
Expand All @@ -113,16 +114,17 @@ class GlobZipper {
ZipCallback onData, [
OnErrorCallback? onError,
]) async {
onError ??= _noop;
int processed = 0, i = 1;
await for (final file in fileStreamFactory().handleError(onError)) {
int processed = 0, i = 0;
await for (final file in fileStreamFactory().handleError(
onError ?? _noop,
)) {
final stat = await file.stat();

onData(
.new(
file: file,
stat: stat,
current: i++,
current: ++i,
processed: processed,
compressed: await zipfile.length(),
),
Expand All @@ -145,7 +147,7 @@ class GlobZipper {

final filename = relative(file.path, from: root.path);

final fileStream = InputFileStream(file.path);
final InputFileStream fileStream = .new(file.path);

return .stream(filename, fileStream)
..compressionLevel = level
Expand Down
4 changes: 2 additions & 2 deletions modules/glob_zipper/lib/src/isolated.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Future<void> _zipInIsolate({
ZipCallback? onData,
OnErrorCallback? onError,
}) async {
final mainPort = ReceivePort();
final ReceivePort mainPort = .new();

final mainPortBroadcast = mainPort.asBroadcastStream();

Expand Down Expand Up @@ -58,7 +58,7 @@ Future<void> _zipInIsolate({
}

Future<void> _isolatedZip(SendPort mainSendPort) async {
final isolatedPort = ReceivePort();
final ReceivePort isolatedPort = .new();

final isolatePortBroadcast = isolatedPort.asBroadcastStream();

Expand Down
2 changes: 1 addition & 1 deletion modules/glob_zipper/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: A starting point for Dart libraries or applications.
version: 1.0.0

environment:
sdk: ^3.11.5
sdk: ^3.12.2

dependencies:
archive: any
Expand Down
2 changes: 1 addition & 1 deletion modules/interact/lib/interact.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ export "src/spinner.dart";
export "src/theme/theme.dart";

/// Resets the Terminal to default values.
void Function() reset = Context.reset;
const void Function() reset = Context.reset;
2 changes: 1 addition & 1 deletion modules/interact/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version: 2.2.0
publish_to: none

environment:
sdk: ^3.11.5
sdk: ^3.12.2

dependencies:
dart_console: any
Expand Down
4 changes: 1 addition & 3 deletions modules/local_store/lib/src/json_local_store.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ class _JSONLocalStore implements LocalStore {
.fuse(base64.encoder)
.fuse(utf8.encoder);

_JSONLocalStore(this.path) : _cache = .new(), _file = .new(path);

final String path;
_JSONLocalStore(String path) : _cache = .new(), _file = .new(path);

final Map<String, dynamic> _cache;
final File _file;
Expand Down
2 changes: 1 addition & 1 deletion modules/local_store/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version: 1.0.0
publish_to: none

environment:
sdk: ^3.11.5
sdk: ^3.12.2

dependencies:
nested_map:
Expand Down
2 changes: 1 addition & 1 deletion modules/nested_map/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version: 1.0.0
publish_to: none

environment:
sdk: ^3.11.5
sdk: ^3.12.2

dev_dependencies:
lints: any
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ publish_to: none
repository: https://github.com/discloud/cli-dart

environment:
sdk: ^3.12.0
sdk: ^3.12.2

dependencies:
glob_zipper:
Expand Down
2 changes: 2 additions & 0 deletions scripts/upgrade_pubspec_sdk.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// dart scripts/upgrade_pubspec_sdk.dart

import "dart:io";

import "package:path/path.dart";
Expand Down
Loading