From 8b7329060333c222888d60a86f4a76e91a2701b6 Mon Sep 17 00:00:00 2001 From: iyifr Date: Sun, 8 Dec 2024 15:45:00 +0100 Subject: [PATCH] update cli --- README.md | 9 +++++---- bin/init.dart | 17 ++++++++--------- pubspec.yaml | 2 +- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 84046a2..a302cf0 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ ![og](/lib/assets/H4-banne.png) -A sleek and powerful HTTP framework that makes Dart API development a breeze. - + +**A sleek and powerful HTTP framework that makes Dart API development a breeze** + Inspired by [unjs H3](https://h3.unjs.io). **This is a new project under active development**, production use is not advised. @@ -108,8 +109,8 @@ The client recieves this json payload - ```json { - "status": 400, - "message": "Womp Womp" + "status": 400, + "message": "Womp Womp" } ``` diff --git a/bin/init.dart b/bin/init.dart index 0730df7..f1f02c8 100644 --- a/bin/init.dart +++ b/bin/init.dart @@ -4,7 +4,6 @@ import 'dart:async'; import 'dart:io'; import 'package:console/console.dart'; import 'dart:convert'; -import 'package:path/path.dart' as path; void main(List arguments) async { if (!await _isH4Installed()) { @@ -70,8 +69,6 @@ Future _createAppFiles(String appName, Console.setBold(true); Console.write('\n\nInstalling necessary dependencies...\n'.toUpperCase()); File mainFile; - File defaultFile = - File('lib/${path.basename(Directory.current.path)}.dart'); if (inCurrentDir) { Process.runSync('dart', ['pub', 'add', 'h4'], @@ -80,7 +77,6 @@ Future _createAppFiles(String appName, Console.setBlink(false); } else { mainFile = File('$appName/lib/index.dart'); - defaultFile = File('$appName/lib/$appName.dart'); await runProcessInDirectory(appName, ['dart', 'pub', 'add', 'h4']) .then((value) => Console.setBlink(false)); } @@ -88,14 +84,17 @@ Future _createAppFiles(String appName, Console.setBold(false); await _writeMainFile(mainFile); - if (await defaultFile.exists()) { - await defaultFile.delete(); + if (File('$appName/lib/${appName.replaceAll('-', '_')}.dart') + .existsSync()) { + await File('$appName/lib/${appName.replaceAll('-', '_')}.dart').delete(); + } else { + Console.write('---Failed to clear appName file'); } Console.setBold(true); Console.write('\nH4 initialized successfully'.toUpperCase()); - } catch (e) { - Console.write('\nFailed to create H4 app. Error: $e'); + } catch (e, stacktrace) { + Console.write('\nFailed to create H4 app. Error: $e /n $stacktrace'); return; } } @@ -149,7 +148,7 @@ Future _promptAppName() async { '\nEnter a name for your app (or press Enter to skip and set default): '); final name = stdin.readLineSync(encoding: utf8) ?? ''; Console.resetAll(); - return name.isNotEmpty ? name : 'my-app'; + return name.isNotEmpty ? name : 'h4-server'; } Future _writeMainFile(File mainFile) async { diff --git a/pubspec.yaml b/pubspec.yaml index 3d9dd98..63c58e2 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: h4 description: A minimal framework for building elegant server applications. -version: 0.3.1 +version: 0.3.2 repository: https://github.com/iyifr/h4 environment: