From 37dfdb2b55f24a6cc02c0b3426cbfb857e45b3f2 Mon Sep 17 00:00:00 2001 From: register2019 <51252517+register2019@users.noreply.github.com> Date: Thu, 5 May 2022 15:02:51 +0800 Subject: [PATCH 01/40] Update README-zh_CN.md --- README-zh_CN.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README-zh_CN.md b/README-zh_CN.md index b4c9ec3c..0400b2de 100644 --- a/README-zh_CN.md +++ b/README-zh_CN.md @@ -193,7 +193,7 @@ class AuthController extends GetxController { 在指定目录创建 view -### 生成国家化文件 +### 生成国际化文件 在 assets/locales 目录创建 json 格式的语言文件 From 1c10c61bd891699323db00267acc373153799984 Mon Sep 17 00:00:00 2001 From: register2019 <51252517+register2019@users.noreply.github.com> Date: Thu, 5 May 2022 15:12:01 +0800 Subject: [PATCH 02/40] Update README-zh_CN.md --- README-zh_CN.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README-zh_CN.md b/README-zh_CN.md index b4c9ec3c..2e857e87 100644 --- a/README-zh_CN.md +++ b/README-zh_CN.md @@ -8,7 +8,7 @@ GetX™ 框架的官方 CLI。 ```dart // 安装: pub global activate get_cli -// 使用本命令需要设置系统环境变量: [FlutterSDK安装目录]\bin\cache\dart-sdk\bin +// 使用本命令需要设置系统环境变量: [FlutterSDK安装目录]\bin\cache\dart-sdk\bin 和 [FlutterSDK安装目录]\.pub-cache\bin flutter pub global activate get_cli From e8af9444ae8b868e9f2276d0ce197a82f2aac5e0 Mon Sep 17 00:00:00 2001 From: arjundevlucid Date: Wed, 15 Jun 2022 08:57:32 +0530 Subject: [PATCH 03/40] fixed null check in version pub.dev --- lib/functions/version/version_update.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/functions/version/version_update.dart b/lib/functions/version/version_update.dart index 183b5ec4..1aafbd98 100644 --- a/lib/functions/version/version_update.dart +++ b/lib/functions/version/version_update.dart @@ -20,7 +20,7 @@ void checkForUpdate() async { .then((versionInstalled) async { if (versionInstalled == null) exit(2); - final v1 = Version.parse(versionInPubDev); + final v1 = Version.parse(versionInPubDev!); final v2 = Version.parse(versionInstalled); final needsUpdate = v1.compareTo(v2); // needs update. From 5c08e382bfcdca9f1bc4bb604fd53d8a8533927a Mon Sep 17 00:00:00 2001 From: arjundevlucid Date: Wed, 15 Jun 2022 09:10:02 +0530 Subject: [PATCH 04/40] fixed pub version --- CHANGELOG.md | 4 +++- lib/functions/version/version_update.dart | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 745aba41..fbd624eb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,8 @@ +## [1.8.1] +- Fixed null error in pub version + ## [1.8.0] - Update dependencies, remove pedantic and effective dart from lints options - ## [1.7.1] - Remove unmaintained dependencies diff --git a/lib/functions/version/version_update.dart b/lib/functions/version/version_update.dart index 0c25a131..8e1859eb 100644 --- a/lib/functions/version/version_update.dart +++ b/lib/functions/version/version_update.dart @@ -20,7 +20,7 @@ void checkForUpdate() async { .then((versionInstalled) async { if (versionInstalled == null) exit(2); - final v1 = Version.parse(versionInPubDev); + final v1 = Version.parse(versionInPubDev!); final v2 = Version.parse(versionInstalled); final needsUpdate = v1.compareTo(v2); // needs update. From ebdaaa49cc1d4d417a4480e34990888505ccd4cc Mon Sep 17 00:00:00 2001 From: arjundevlucid Date: Wed, 15 Jun 2022 10:01:17 +0530 Subject: [PATCH 05/40] fixed --- CHANGELOG.md | 1 + lib/samples/impl/get_view.dart | 4 ++-- pubspec.yaml | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fbd624eb..e9de498e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ ## [1.8.1] - Fixed null error in pub version +- Fixed get view by adding const ## [1.8.0] - Update dependencies, remove pedantic and effective dart from lints options diff --git a/lib/samples/impl/get_view.dart b/lib/samples/impl/get_view.dart index 0db612d7..671d2e6e 100644 --- a/lib/samples/impl/get_view.dart +++ b/lib/samples/impl/get_view.dart @@ -30,7 +30,7 @@ class $_viewName extends $_controllerName { Widget build(BuildContext context) { return Scaffold( appBar: AppBar( - title: Text('$_viewName'), + title: const Text('$_viewName'), centerTitle: true, ), body: Center( @@ -50,7 +50,7 @@ class $_viewName extends $_controllerName { class $_viewName extends $_controllerName { @override Widget build(BuildContext context) { - return Text('GetX to Server is working!'); + return const Text('GetX to Server is working!'); } } '''; diff --git a/pubspec.yaml b/pubspec.yaml index 86e31ad0..7b30d800 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: get_cli -version: 1.8.0 +version: 1.8.1 homepage: https://github.com/jonataslaw/get_cli description: Official CLI for GetX™ framework to build Flutter and Server Applications easily environment: From 0e5d1a4f9309ad6935e5773f3bf47f0a7ec6b8d9 Mon Sep 17 00:00:00 2001 From: arjundevlucid Date: Tue, 21 Jun 2022 23:58:59 +0530 Subject: [PATCH 06/40] replaced cli_dialog with dcli --- lib/commands/impl/create/page/page.dart | 13 ++++---- lib/commands/impl/create/project/project.dart | 33 ++++++++++--------- lib/commands/impl/generate/model/model.dart | 12 ++++--- lib/common/menu/menu.dart | 22 +++++++------ pubspec.yaml | 2 +- 5 files changed, 45 insertions(+), 37 deletions(-) diff --git a/lib/commands/impl/create/page/page.dart b/lib/commands/impl/create/page/page.dart index 0ed232bd..d911812a 100644 --- a/lib/commands/impl/create/page/page.dart +++ b/lib/commands/impl/create/page/page.dart @@ -1,6 +1,7 @@ import 'dart:io'; -import 'package:cli_dialog/cli_dialog.dart'; + +import 'package:dcli/dcli.dart'; import 'package:recase/recase.dart'; import '../../../../common/menu/menu.dart'; @@ -62,11 +63,11 @@ class CreatePageCommand extends Command { if (result.index == 0) { _writeFiles(path, name!, overwrite: true); } else if (result.index == 2) { - final dialog = CLI_Dialog(); - dialog.addQuestion(LocaleKeys.ask_new_page_name.tr, 'name'); - name = dialog.ask()['name'] as String?; - - checkForAlreadyExists(name!.trim().snakeCase); + // final dialog = CLI_Dialog(); + // dialog.addQuestion(LocaleKeys.ask_new_page_name.tr, 'name'); + // name = dialog.ask()['name'] as String?; + var name = ask(LocaleKeys.ask_new_page_name.tr); + checkForAlreadyExists(name.trim().snakeCase); } } else { Directory(path).createSync(recursive: true); diff --git a/lib/commands/impl/create/project/project.dart b/lib/commands/impl/create/project/project.dart index 37e0ae1d..bc67f961 100644 --- a/lib/commands/impl/create/project/project.dart +++ b/lib/commands/impl/create/project/project.dart @@ -1,6 +1,6 @@ import 'dart:io'; -import 'package:cli_dialog/cli_dialog.dart'; +import 'package:dcli/dcli.dart'; import 'package:path/path.dart' as p; import 'package:recase/recase.dart'; @@ -27,28 +27,31 @@ class CreateProjectCommand extends Command { final result = menu.choose(); String? nameProject = name; if (name == '.') { - final dialog = CLI_Dialog(questions: [ - [LocaleKeys.ask_name_to_project.tr, 'name'] - ]); - nameProject = dialog.ask()['name'] as String?; + // final dialog = CLI_Dialog(questions: [ + // [LocaleKeys.ask_name_to_project.tr, 'name'] + // ]); + nameProject = ask(LocaleKeys.ask_name_to_project.tr); } var path = Structure.replaceAsExpected( - path: Directory.current.path + p.separator + nameProject!.snakeCase); + path: Directory.current.path + p.separator + nameProject.snakeCase); await Directory(path).create(recursive: true); Directory.current = path; if (result.index == 0) { - final dialog = CLI_Dialog(questions: [ - [ - '${LocaleKeys.ask_company_domain.tr} \x1B[33m ' - '${LocaleKeys.example.tr} com.yourcompany \x1B[0m', - 'org' - ] - ]); - - var org = dialog.ask()['org'] as String?; + // final dialog = CLI_Dialog(questions: [ + // [ + // '${LocaleKeys.ask_company_domain.tr} \x1B[33m ' + // '${LocaleKeys.example.tr} com.yourcompany \x1B[0m', + // 'org' + // ] + // ]); + + var org = ask( + '${LocaleKeys.ask_company_domain.tr} \x1B[33m ' + '${LocaleKeys.example.tr} com.yourcompany \x1B[0m', + ); final iosLangMenu = Menu(['Swift', 'Objective-C'], title: LocaleKeys.ask_ios_lang.tr); diff --git a/lib/commands/impl/generate/model/model.dart b/lib/commands/impl/generate/model/model.dart index e0d40940..83dc8d3c 100644 --- a/lib/commands/impl/generate/model/model.dart +++ b/lib/commands/impl/generate/model/model.dart @@ -1,6 +1,7 @@ import 'dart:io'; -import 'package:cli_dialog/cli_dialog.dart'; + +import 'package:dcli/dcli.dart'; import 'package:http/http.dart'; import 'package:path/path.dart' as p; import 'package:recase/recase.dart'; @@ -23,10 +24,11 @@ class GenerateModelCommand extends Command { Future execute() async { var name = p.basenameWithoutExtension(withArgument).pascalCase; if (withArgument.isEmpty) { - final dialog = CLI_Dialog(questions: [ - [LocaleKeys.ask_model_name.tr, 'name'] - ]); - var result = dialog.ask()['name'] as String; + // final dialog = CLI_Dialog(questions: [ + // [LocaleKeys.ask_model_name.tr, 'name'] + // ]); + // var result = dialog.ask()['name'] as String; + var result = ask(LocaleKeys.ask_model_name.tr); name = result.pascalCase; } diff --git a/lib/common/menu/menu.dart b/lib/common/menu/menu.dart index 4b5e2d7e..084392d8 100644 --- a/lib/common/menu/menu.dart +++ b/lib/common/menu/menu.dart @@ -1,4 +1,5 @@ -import 'package:cli_dialog/cli_dialog.dart'; + +import 'package:dcli/dcli.dart'; class Menu { final List choices; @@ -7,15 +8,16 @@ class Menu { Menu(this.choices, {this.title = ''}); Answer choose() { - final dialog = CLI_Dialog(listQuestions: [ - [ - {'question': title, 'options': choices}, - 'result' - ] - ]); - - final answer = dialog.ask(); - final result = answer['result'] as String; + // final dialog = CLI_Dialog(listQuestions: [ + // [ + // {'question': title, 'options': choices}, + // 'result' + // ] + // ]); + + // final answer = dialog.ask(); + // final result = answer['result'] as String; + final result = menu(prompt: title, options: choices); final index = choices.indexOf(result); return Answer(result: result, index: index); diff --git a/pubspec.yaml b/pubspec.yaml index 7b30d800..e3a0b364 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -16,10 +16,10 @@ dependencies: path: ">=1.8.0 <2.0.0" version: ">=2.0.0 <3.0.0" intl: ">=0.17.0 <1.0.0" - cli_dialog: ">=0.5.0 <1.0.0" dart_style: ">=2.0.1 <3.0.0" yaml: ">=3.1.0 <4.0.0" collection: ">=1.15.0 <2.0.0" + dcli: ^1.31.2 dev_dependencies: test: ^1.5.0 From 89a2c917ab27ed4cb166b5fdc5b04fbd514fe137 Mon Sep 17 00:00:00 2001 From: arjundevlucid Date: Wed, 22 Jun 2022 00:15:01 +0530 Subject: [PATCH 07/40] added default value to menu --- lib/common/menu/menu.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/common/menu/menu.dart b/lib/common/menu/menu.dart index 084392d8..e1370f67 100644 --- a/lib/common/menu/menu.dart +++ b/lib/common/menu/menu.dart @@ -1,4 +1,3 @@ - import 'package:dcli/dcli.dart'; class Menu { @@ -17,7 +16,8 @@ class Menu { // final answer = dialog.ask(); // final result = answer['result'] as String; - final result = menu(prompt: title, options: choices); + final result = + menu(prompt: title, options: choices, defaultOption: choices[0]); final index = choices.indexOf(result); return Answer(result: result, index: index); From 8032148d79b03e492ec84e521ac25f8d24aa9490 Mon Sep 17 00:00:00 2001 From: arjundevlucid Date: Wed, 22 Jun 2022 00:32:02 +0530 Subject: [PATCH 08/40] added create project title --- lib/commands/impl/create/project/project.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/commands/impl/create/project/project.dart b/lib/commands/impl/create/project/project.dart index bc67f961..04c4165c 100644 --- a/lib/commands/impl/create/project/project.dart +++ b/lib/commands/impl/create/project/project.dart @@ -23,7 +23,7 @@ class CreateProjectCommand extends Command { final menu = Menu([ 'Flutter Project', 'Get Server', - ]); + ],title: 'Select which type of project you want to create ?'); final result = menu.choose(); String? nameProject = name; if (name == '.') { From a368b2beb94109ed2ced751a3ab7df6b2573a3c5 Mon Sep 17 00:00:00 2001 From: arjundevlucid Date: Wed, 22 Jun 2022 00:35:14 +0530 Subject: [PATCH 09/40] added consts to views --- lib/samples/impl/arctekko/arc_screen.dart | 8 ++++---- lib/samples/impl/get_view.dart | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/samples/impl/arctekko/arc_screen.dart b/lib/samples/impl/arctekko/arc_screen.dart index 08b0a890..579d4536 100644 --- a/lib/samples/impl/arctekko/arc_screen.dart +++ b/lib/samples/impl/arctekko/arc_screen.dart @@ -23,10 +23,10 @@ class ${fileName.pascalCase}Screen extends GetView<${fileName.pascalCase}Control return Scaffold( appBar: AppBar( - title: Text('${fileName.pascalCase}Screen'), + title:const Text('${fileName.pascalCase}Screen'), centerTitle: true, ), - body: Center( + body:const Center( child: Text( '${fileName.pascalCase}Screen is working', style: TextStyle(fontSize:20), @@ -46,9 +46,9 @@ class CounterScreen extends GetView { Widget build(context) { return Scaffold( appBar: AppBar( - title: Text("Flutter Demo Home Page with GetX"), + title:const Text("Flutter Demo Home Page with GetX"), ), - body: Center( + body:const Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ diff --git a/lib/samples/impl/get_view.dart b/lib/samples/impl/get_view.dart index 671d2e6e..69bb2da0 100644 --- a/lib/samples/impl/get_view.dart +++ b/lib/samples/impl/get_view.dart @@ -33,7 +33,7 @@ class $_viewName extends $_controllerName { title: const Text('$_viewName'), centerTitle: true, ), - body: Center( + body:const Center( child: Text( '$_viewName is working', style: TextStyle(fontSize:20), From 8ead14b1ec5548b3e14671cb0c8d1d499d4a0099 Mon Sep 17 00:00:00 2001 From: arjundevlucid Date: Wed, 22 Jun 2022 00:37:40 +0530 Subject: [PATCH 10/40] updated version dependency --- pubspec.yaml | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/pubspec.yaml b/pubspec.yaml index e3a0b364..20f25b35 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,29 +1,30 @@ name: get_cli version: 1.8.1 homepage: https://github.com/jonataslaw/get_cli -description: Official CLI for GetX™ framework to build Flutter and Server Applications easily +description: Official CLI for GetX™ framework to build Flutter and Server + Applications easily environment: sdk: ">=2.17.0 <3.0.0" dependencies: - pubspec: ">=2.0.1 <3.0.0" - meta: ">=1.7.0 <2.0.0" - recase: ">=4.0.0 <5.0.0" -# archive: ^3.1.2 + # archive: ^3.1.2 ansicolor: ">=2.0.1 <3.0.0" - process_run: ">=0.12.2 <1.0.0" + collection: ">=1.15.0 <2.0.0" + dart_style: ">=2.0.1 <3.0.0" + dcli: ^1.31.2 http: ">=0.13.4 <2.0.0" - path: ">=1.8.0 <2.0.0" - version: ">=2.0.0 <3.0.0" intl: ">=0.17.0 <1.0.0" - dart_style: ">=2.0.1 <3.0.0" + meta: ">=1.7.0 <2.0.0" + path: ">=1.8.0 <2.0.0" + process_run: ">=0.12.2 <1.0.0" + pubspec: ">=2.0.1 <3.0.0" + recase: ">=4.0.0 <5.0.0" + version: ">=2.0.0 <4.0.0" yaml: ">=3.1.0 <4.0.0" - collection: ">=1.15.0 <2.0.0" - dcli: ^1.31.2 dev_dependencies: - test: ^1.5.0 lints: ^2.0.0 + test: ^1.5.0 executables: get: get From 77ada340e0c5f1c680c5105dd46b69ab8b25612f Mon Sep 17 00:00:00 2001 From: arjundevlucid Date: Wed, 22 Jun 2022 00:54:18 +0530 Subject: [PATCH 11/40] adding spaces to menus --- lib/common/menu/menu.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/common/menu/menu.dart b/lib/common/menu/menu.dart index e1370f67..dc590215 100644 --- a/lib/common/menu/menu.dart +++ b/lib/common/menu/menu.dart @@ -16,6 +16,7 @@ class Menu { // final answer = dialog.ask(); // final result = answer['result'] as String; + print(""); final result = menu(prompt: title, options: choices, defaultOption: choices[0]); final index = choices.indexOf(result); From 4d4be0e7704ca964c4a029c3d2566db0c7498400 Mon Sep 17 00:00:00 2001 From: arjundevlucid Date: Wed, 22 Jun 2022 08:19:14 +0530 Subject: [PATCH 12/40] Version updated to 1.8.2 with changelog --- CHANGELOG.md | 6 ++++++ pubspec.yaml | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e9de498e..ae6feb29 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## [1.8.2] +- Replace cli_dialog with dcli +- version dependency updated +- Added dafault value to menu & spaces +- Fixed some lints with views + ## [1.8.1] - Fixed null error in pub version - Fixed get view by adding const diff --git a/pubspec.yaml b/pubspec.yaml index 20f25b35..fe726289 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: get_cli -version: 1.8.1 +version: 1.8.2 homepage: https://github.com/jonataslaw/get_cli description: Official CLI for GetX™ framework to build Flutter and Server Applications easily From b0426dbe7cdbcd8eba0282bb6a2553e3893fe868 Mon Sep 17 00:00:00 2001 From: mohamedvall ibrahim Date: Sun, 26 Jun 2022 06:59:33 -1200 Subject: [PATCH 13/40] i18n: add arabic translation --- translations/ar.json | 88 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 translations/ar.json diff --git a/translations/ar.json b/translations/ar.json new file mode 100644 index 00000000..c62da40e --- /dev/null +++ b/translations/ar.json @@ -0,0 +1,88 @@ +{ + "ask": { + "existing_page": "الصفحة [%s] موجودة بالفعل, هل تريد استبدالها?", + "name_to_project": "ماهو اسم مشروعك?", + "company_domain": "ماهو النطاق الخاص بشركتك?", + "model_name": "لم نتمكن من اختيار اسم الموديل تلقائيا, ماهو الإسم الذى تريد ان تستخدم?", + "package_already_installed": "المكتبة: %s مثبتة سابقا, هل تريد تحديثها?", + "lib_not_empty": "مجلد lib غير فارغ. هل تريد استبداله? \\n تنبيه: لايمكن التراجع عن هذه الخطوة", + "ios_lang": "ماهي اللغة التى تريد استخدامها على ios?", + "android_lang": "ماهي اللغة التى تريد ان تستخدم على android?", + "use_null_safe": "هل تريد استخدام null safe?", + "use_linter": "هل تريد استخدام بعض linter?", + "new_page_name": "ماهو اسم الصفحة الجديد?" + }, + "error": { + "failed_to_connect": "فشل الاتصال مع %s", + "no_valid_file_or_url": "%s ليس ملفا او رابط صحيحا", + "unnecessary_parameter": "%s هذا المعامل ليس الزاميا", + "unnecessary_parameter_plural": "%s معاملات ليست الزامية", + "nonexistent_directory": "%s مجلد غير موجود.", + "empty_directory": "%s فارغ", + "invalid_json": "%s ليس ملف json صحيحا", + "special_characters_in_key": "الرموز ليست مقبولة فى المفتاح. \\n المفتاح: %s", + "required_path": "تحتاج الى ارسال الملف او مسار المجلد", + "invalid_dart": "%s ليس ملف dart صحيحا", + "invalid_file_or_directory": "%s ليس ملفات او مجلدا صحيحا", + "package_not_found": "المكتبة: %s ليست موجودة فى pub.dev", + "cli_version_not_found": "لم يتم العثور على الاصدار الذى قمت بتثبيته.", + "update_cli": "هناك خطأ اثناء تحديث get_cli", + "folder_not_found": "المجلد %s غير موجود", + "file_not_found": "لم يتم العثور على الملف %s", + "access_denied": "اذن الوصول غير مرخص %s", + "unexpected": "حدث خطأ غير متوقع:", + "no_package_to_remove": "ادخل اسم المكتبة التى حذفها" + }, + "example": "مثال:", + "warning": "تنبيه:", + "hint": { + "create": { + "controller": "انشاء Controller", + "page": "يستخدم لإنشاء الصفحات", + "project": "يستخدم لإنشاء مشروع جديد", + "provider": "إنشاء Provider جديد", + "screen": "إنشاء شاشة جديدة", + "view": "إنشاء view" + }, + "generate": { + "locales": "إنشاء ملف الترجمة من ملفات json", + "model": "إنشاء Class Model من json" + }, + "help": "طلب المساعدة", + "init": "إنشاء هيكل المشروع المختار فى مشروع موجود مسبقا:", + "install": "يستخدم لتثبيت مكتبة فى مشروعك (dependencies):", + "remove": "يستخدم لحذف مكتبة من مشروعك (dependencies):", + "sort": "ترتيب (Format) ملفات dart", + "update": "لتحديث GET_CLI", + "version": "اظهار اصدار CLI الحالي'" + }, + "info": { + "unnecessary_flag": "%s ليس ضروريا", + "unnecessary_flag_prural": "%s ليس ضروريا", + "package_not_installed": "المكتبة: %s ليست مثبتة فى تطبيقك", + "cli_last_version_already_installed": "الإصدار الأخير من get_cli مثبت بالفعل", + "no_file_overwritten": "لم يتم استبدال اي ملفات", + "update_available": "هناك تحديث متوفر! الإصدار الحالي: %s", + "update_available2": "الإصدار الجديد: %s يرجى تشغيل:" + }, + "options": { + "yes": "نعم!", + "no": "لا", + "rename": "اريد اعادة التسمية" + }, + "optional_parameters": "معامل اختياري: %s", + "sucess": { + "page_create": "%s تم انشاء الصفحة بنجاح.", + "locale_generate": "تم انشاء الملفات محليا بنجاح.", + "getx_pattern_generated": "GetX Pattern structure تم انشاؤه بنجاح.", + "clean_Pattern_generated": "CLEAN Pattern structure تم انشاؤه بنجاح.", + "file_formatted": " '%s' تم اعادة هيكلته بنجاح", + "package_removed": "تم حذف المكتبة: %s!", + "package_installed": "تم تثبيت المكتبة: %s", + "update_cli": "تم تحديث CLI", + "add_controller_in_bindings": "%s تمت اضافته لل binding فى المسار: %s'", + "navigation_added": "تم انشاء navigation: %s بنجاح.", + "file_created": "تم انشاء الملف: %s بنجاح فى المسار: %s", + "route_created": "تم انشاء route %s بنجاح." + } +} \ No newline at end of file From 13923238e3e0ff1671e2881f846d2d5007fbe1c3 Mon Sep 17 00:00:00 2001 From: Alexandre Richonnier Date: Mon, 12 Dec 2022 14:15:02 +0100 Subject: [PATCH 14/40] Add sub_folder configuration documentation --- README.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/README.md b/README.md index 4ac19d39..1627105d 100644 --- a/README.md +++ b/README.md @@ -356,6 +356,17 @@ get_cli: separator: "." ``` +### Configure Getx directory layout + +When you create a page or screen, each module will have bindings, controllers, views sub directories. + +If you prefer to have a flat file hierarchy, add the following lines to your `pubspec.yaml`: + +```yml +get_cli: + sub_folder: false +``` + ### Are your imports disorganized? To help you organize your imports a new command was created: `get sort`, in addition to organizing your imports the command will also format your dart file. thanks to [dart_style](https://pub.dev/packages/dart_style). From 33147cbb86156f05ef7cb50bd7b47f2e63e8bd60 Mon Sep 17 00:00:00 2001 From: Bunnarith Heang Date: Mon, 10 Apr 2023 00:35:16 +0700 Subject: [PATCH 15/40] Remove empty space in Structure page directory path --- lib/core/structure.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/core/structure.dart b/lib/core/structure.dart index 5155fafb..8275f683 100644 --- a/lib/core/structure.dart +++ b/lib/core/structure.dart @@ -11,7 +11,7 @@ import 'locales.g.dart'; class Structure { static final Map _paths = { 'page': Directory(replaceAsExpected( - path: '${Directory.current.path} /lib/pages/')) + path: '${Directory.current.path}/lib/pages/')) .existsSync() ? replaceAsExpected(path: 'lib/pages') : replaceAsExpected(path: 'lib/app/modules'), From 5d1f21e2645b7b4b7639da97e225476295a3771f Mon Sep 17 00:00:00 2001 From: shinriyo Date: Thu, 4 May 2023 11:35:25 +0900 Subject: [PATCH 16/40] Update project.dart ``` 1) yes 2) no do you want to use some linter? [1] ``` For capitalize. --- lib/commands/impl/create/project/project.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/commands/impl/create/project/project.dart b/lib/commands/impl/create/project/project.dart index 04c4165c..fc65611b 100644 --- a/lib/commands/impl/create/project/project.dart +++ b/lib/commands/impl/create/project/project.dart @@ -73,8 +73,8 @@ class CreateProjectCommand extends Command { var useNullSafe = nullSafeMenuResult.index == 0; final linterMenu = Menu([ - 'yes', - 'no', + 'Yes', + 'No', ], title: LocaleKeys.ask_use_linter.tr); final linterResult = linterMenu.choose(); From de098eeb6939e397b5541486a49b31d49a22c0a2 Mon Sep 17 00:00:00 2001 From: shinriyo Date: Thu, 4 May 2023 11:45:55 +0900 Subject: [PATCH 17/40] Update locales.g.dart Grammar, period, capitalize --- lib/core/locales.g.dart | 46 ++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/lib/core/locales.g.dart b/lib/core/locales.g.dart index 4a73d360..0fcd5858 100644 --- a/lib/core/locales.g.dart +++ b/lib/core/locales.g.dart @@ -336,7 +336,7 @@ class Locales { static const en = { 'ask_existing_page': 'The page [%s] already exists, do you want to overwrite it?', - 'ask_name_to_project': 'what is the name of the project?', + 'ask_name_to_project': 'What is the name of the project?', 'ask_company_domain': 'What is your company\'s domain?', 'ask_model_name': 'Could not set the model name automatically, which name do you want to use?', @@ -344,34 +344,34 @@ class Locales { 'package: %s already installed, do you want to update?', 'ask_lib_not_empty': 'Your lib folder is not empty. Are you sure you want to overwrite your application? \n WARNING: This action is irreversible', - 'ask_ios_lang': 'what language do you want to use on ios?', - 'ask_android_lang': 'what language do you want to use on android?', + 'ask_ios_lang': 'What language do you want to use on ios?', + 'ask_android_lang': 'What language do you want to use on android?', 'ask_use_null_safe': 'Do you want to use null safe?', - 'ask_use_linter': 'do you want to use some linter?', - 'ask_new_page_name': 'what new name for the page?', - 'error_failed_to_connect': 'Failed to connect with %s', - 'error_no_valid_file_or_url': '%s is not a file or valid url', - 'error_unnecessary_parameter': 'the %s parameter is not necessary', - 'error_unnecessary_parameter_plural': 'the %s parameters are not necessary', + 'ask_use_linter': 'Do you want to use some linter?', + 'ask_new_page_name': 'What is the new name for the page?', + 'error_failed_to_connect': 'Failed to connect with %s.', + 'error_no_valid_file_or_url': '%s is not a file or valid url.', + 'error_unnecessary_parameter': 'the %s parameter is not necessary.', + 'error_unnecessary_parameter_plural': 'the %s parameters are not necessary.', 'error_nonexistent_directory': '%s directory does not exist.', - 'error_empty_directory': '%s is empty', - 'error_invalid_json': '%s is not a valid json file', + 'error_empty_directory': '%s is empty.', + 'error_invalid_json': '%s is not a valid json file.', 'error_special_characters_in_key': 'Special characters are not allowed in key. \n key: %s', - 'error_required_path': 'Needed to pass the file or directory path', - 'error_invalid_dart': 'The %s is not a valid dart file', + 'error_required_path': 'Needed to pass the file or directory path.', + 'error_invalid_dart': 'The %s is not a valid dart file.', 'error_invalid_file_or_directory': 'The %s is not a valid file or directory', - 'error_package_not_found': 'Package: %s not found in pub.dev', + 'error_package_not_found': 'Package: %s not found in pub.dev.', 'error_cli_version_not_found': 'failed to find the version you have installed.', - 'error_update_cli': 'There was an error upgrading get_cli', - 'error_folder_not_found': 'Folder %s not found', - 'error_file_not_found': 'File not found in %s', - 'error_access_denied': 'Access denied to %s', + 'error_update_cli': 'There was an error upgrading get_cli.', + 'error_folder_not_found': 'Folder %s not found.', + 'error_file_not_found': 'File not found in %s.', + 'error_access_denied': 'Access denied to %s.', 'error_unexpected': 'Unexpected error occurred:', 'error_no_package_to_remove': - 'Enter the name of the package you wanna remove', + 'Enter the name of the package you wanna remove.', 'example': 'Example:', 'warning': 'Warning:', 'hint_create_controller': 'Generate controller', @@ -390,12 +390,12 @@ class Locales { 'hint_update': 'To update GET_CLI', 'hint_version': 'Shows the current CLI version\'', 'info_unnecessary_flag': 'The %s is not necessary', - 'info_unnecessary_flag_prural': 'The %s are not necessary', + 'info_unnecessary_flag_prural': 'The %s are not necessary.', 'info_package_not_installed': - 'Package: %s is not installed in this application', + 'Package: %s is not installed in this application.', 'info_cli_last_version_already_installed': - 'Latest version of get_cli already installed', - 'info_no_file_overwritten': 'No files were overwritten', + 'Latest version of get_cli already installed.', + 'info_no_file_overwritten': 'No files were overwritten.', 'info_update_available': 'There\'s an update available! Current installed version: %s', 'info_update_available2': 'New version available: %s Please, run:', From 53596750f6acdfe6b0f50eb103288e07d56c5967 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=92=8C=E5=B9=B3=E5=93=A5?= Date: Sun, 14 May 2023 15:27:55 +0800 Subject: [PATCH 18/40] Update README-zh_CN.md Up to date with en_US. --- README-zh_CN.md | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/README-zh_CN.md b/README-zh_CN.md index 6788f1f0..6e70cf8e 100644 --- a/README-zh_CN.md +++ b/README-zh_CN.md @@ -21,11 +21,18 @@ get create project // 在现有项目中生成所选结构: get init -// 创建页面: +// 创建page: // (页面包括 controller, view, 和 binding) // 注: 你可以随便命名, 例如: `get create page:login` +// 注: 选择了 Getx_pattern 结构才用这个选项 get create page:home +// 创建 Screen: +// (Screens 有 controller, view, 和 binding) +// 注: 你可以随便命名,例如: `get screen page:login` +// 注: 选择了 CLEAN 结构才用这个选项 (by Arktekko) +get create screen:home + // 在指定文件夹创建新 controller: // 注: 你无需引用文件夹, Getx 会自动搜索 home 目录, // 并把你的controller放在那儿 @@ -347,6 +354,17 @@ get_cli: separator: "." ``` +### 配置 Getx 路径样式 + +当你创建一个 Page 或 Screen 时,每个模块都会有 binding , controller, view 子目录。 + +如果你更想要一个平级文件结构,添加以下内容到你的`pubspec.yaml`: + +```yml +get_cli: + sub_folder: false +``` + ### 你的 import 乱不乱? 为了帮你管理你的 import 我加了个新命令: `get sort`, 除了帮你排序整理 import, 这条命令还帮你格式化 dart 文件。感谢 [dart_style](https://pub.dev/packages/dart_style). From 87b5dbee23bd7fe4aeb2d1c173e693cda310aef8 Mon Sep 17 00:00:00 2001 From: padukadafa Date: Sun, 2 Jul 2023 22:07:14 +0700 Subject: [PATCH 19/40] deleting dart migrate --- lib/common/utils/shell/shel.utils.dart | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/common/utils/shell/shel.utils.dart b/lib/common/utils/shell/shel.utils.dart index 1a60f762..b62893d8 100644 --- a/lib/common/utils/shell/shel.utils.dart +++ b/lib/common/utils/shell/shel.utils.dart @@ -17,8 +17,6 @@ class ShellUtils { static Future activatedNullSafe() async { await pubGet(); - await run('dart migrate --apply-changes --skip-import-check', - verbose: true); } static Future flutterCreate( From ab985024c4e5a8c68123848257c30dca65e36de3 Mon Sep 17 00:00:00 2001 From: padukadafa Date: Sun, 2 Jul 2023 22:41:38 +0700 Subject: [PATCH 20/40] upgrade flutter version --- analysis_options.yaml | 5 ----- pubspec.yaml | 2 +- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/analysis_options.yaml b/analysis_options.yaml index 41c0057b..1fa64113 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -5,11 +5,6 @@ include: package:lints/recommended.yaml -analyzer: - strong-mode: - implicit-casts: false - linter: rules: constant_identifier_names: false - diff --git a/pubspec.yaml b/pubspec.yaml index fe726289..83e8d1f8 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -4,7 +4,7 @@ homepage: https://github.com/jonataslaw/get_cli description: Official CLI for GetX™ framework to build Flutter and Server Applications easily environment: - sdk: ">=2.17.0 <3.0.0" + sdk: ">=3.0.3 <4.0.0" dependencies: # archive: ^3.1.2 From 89a54b96ec079a731aa5da9719e1423b86d50177 Mon Sep 17 00:00:00 2001 From: padukadafa Date: Sun, 2 Jul 2023 22:47:33 +0700 Subject: [PATCH 21/40] upgrade dcli version --- pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pubspec.yaml b/pubspec.yaml index 83e8d1f8..9fcd4986 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -11,7 +11,7 @@ dependencies: ansicolor: ">=2.0.1 <3.0.0" collection: ">=1.15.0 <2.0.0" dart_style: ">=2.0.1 <3.0.0" - dcli: ^1.31.2 + dcli: ^3.0.3 http: ">=0.13.4 <2.0.0" intl: ">=0.17.0 <1.0.0" meta: ">=1.7.0 <2.0.0" From f2bec58db839cbd0cf724b686f25ffea99e31b74 Mon Sep 17 00:00:00 2001 From: padukadafa Date: Sun, 2 Jul 2023 22:49:29 +0700 Subject: [PATCH 22/40] fixing error while compiling get_cli --- lib/common/menu/menu.dart | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/common/menu/menu.dart b/lib/common/menu/menu.dart index dc590215..b9b3520a 100644 --- a/lib/common/menu/menu.dart +++ b/lib/common/menu/menu.dart @@ -17,8 +17,7 @@ class Menu { // final answer = dialog.ask(); // final result = answer['result'] as String; print(""); - final result = - menu(prompt: title, options: choices, defaultOption: choices[0]); + final result = menu(title, options: choices, defaultOption: choices[0]); final index = choices.indexOf(result); return Answer(result: result, index: index); From 4c0d9baa0336238166bc3d278da3f6039e70aa63 Mon Sep 17 00:00:00 2001 From: padukadafa Date: Sun, 2 Jul 2023 23:20:28 +0700 Subject: [PATCH 23/40] adding nullsafety migration for dart version 3 lower --- lib/commands/impl/create/project/project.dart | 9 +++++---- lib/common/utils/shell/shel.utils.dart | 2 ++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/commands/impl/create/project/project.dart b/lib/commands/impl/create/project/project.dart index 04c4165c..ca1f6bd7 100644 --- a/lib/commands/impl/create/project/project.dart +++ b/lib/commands/impl/create/project/project.dart @@ -23,7 +23,7 @@ class CreateProjectCommand extends Command { final menu = Menu([ 'Flutter Project', 'Get Server', - ],title: 'Select which type of project you want to create ?'); + ], title: 'Select which type of project you want to create ?'); final result = menu.choose(); String? nameProject = name; if (name == '.') { @@ -68,9 +68,10 @@ class CreateProjectCommand extends Command { final nullSafeMenu = Menu( [LocaleKeys.options_yes.tr, LocaleKeys.options_no.tr], title: LocaleKeys.ask_use_null_safe.tr); - final nullSafeMenuResult = nullSafeMenu.choose(); - - var useNullSafe = nullSafeMenuResult.index == 0; + final nullSafeMenuResult = + double.parse(Platform.version.split(' ').first[0]); + print(nullSafeMenuResult); + var useNullSafe = nullSafeMenuResult < 3; final linterMenu = Menu([ 'yes', diff --git a/lib/common/utils/shell/shel.utils.dart b/lib/common/utils/shell/shel.utils.dart index b62893d8..1a60f762 100644 --- a/lib/common/utils/shell/shel.utils.dart +++ b/lib/common/utils/shell/shel.utils.dart @@ -17,6 +17,8 @@ class ShellUtils { static Future activatedNullSafe() async { await pubGet(); + await run('dart migrate --apply-changes --skip-import-check', + verbose: true); } static Future flutterCreate( From 8119d371f5c07d1821a5385a19e1bae12c4d4a61 Mon Sep 17 00:00:00 2001 From: padukadafa Date: Sun, 2 Jul 2023 23:26:36 +0700 Subject: [PATCH 24/40] change dart version --- pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pubspec.yaml b/pubspec.yaml index 9fcd4986..345a36f4 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -4,7 +4,7 @@ homepage: https://github.com/jonataslaw/get_cli description: Official CLI for GetX™ framework to build Flutter and Server Applications easily environment: - sdk: ">=3.0.3 <4.0.0" + sdk: ">=2.17.0 <4.0.0" dependencies: # archive: ^3.1.2 From 41b68b600eb373e790f225c735843c17f86e550e Mon Sep 17 00:00:00 2001 From: padukadafa Date: Sun, 2 Jul 2023 23:33:54 +0700 Subject: [PATCH 25/40] change dcli version to 2.3.0 --- pubspec.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pubspec.yaml b/pubspec.yaml index 345a36f4..7d43e89b 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -4,14 +4,14 @@ homepage: https://github.com/jonataslaw/get_cli description: Official CLI for GetX™ framework to build Flutter and Server Applications easily environment: - sdk: ">=2.17.0 <4.0.0" + sdk: ">=2.19.0 <4.0.0" dependencies: # archive: ^3.1.2 ansicolor: ">=2.0.1 <3.0.0" collection: ">=1.15.0 <2.0.0" dart_style: ">=2.0.1 <3.0.0" - dcli: ^3.0.3 + dcli: ^2.3.0 http: ">=0.13.4 <2.0.0" intl: ">=0.17.0 <1.0.0" meta: ">=1.7.0 <2.0.0" From 471ec678736bd0ef1be2bde3f5bfd2829ae867d8 Mon Sep 17 00:00:00 2001 From: Knot Date: Fri, 5 May 2023 18:34:22 +0700 Subject: [PATCH 26/40] remove dart migrate, fix generate optional double --- lib/common/utils/json_serialize/sintaxe.dart | 5 ++++- lib/common/utils/shell/shel.utils.dart | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/common/utils/json_serialize/sintaxe.dart b/lib/common/utils/json_serialize/sintaxe.dart index a0235547..0a01787c 100644 --- a/lib/common/utils/json_serialize/sintaxe.dart +++ b/lib/common/utils/json_serialize/sintaxe.dart @@ -127,7 +127,10 @@ class TypeDefinition { fixFieldName(key, typeDef: this, privateField: privateField); if (isPrimitive) { if (name == 'List') { - return "$fieldKey = json['$key'].cast<$subtype>();"; + return "$fieldKey = json['$key']?.cast<$subtype>();"; + } + if (name == 'double?') { + return "$fieldKey = (json['$key'] as num?)?.toDouble();"; } return "$fieldKey = json['$key'];"; } else if (name == 'List' && subtype == 'DateTime') { diff --git a/lib/common/utils/shell/shel.utils.dart b/lib/common/utils/shell/shel.utils.dart index 1a60f762..04edb1f4 100644 --- a/lib/common/utils/shell/shel.utils.dart +++ b/lib/common/utils/shell/shel.utils.dart @@ -17,8 +17,8 @@ class ShellUtils { static Future activatedNullSafe() async { await pubGet(); - await run('dart migrate --apply-changes --skip-import-check', - verbose: true); + // await run('dart migrate --apply-changes --skip-import-check', + // verbose: true); } static Future flutterCreate( From da84a97f25ffa659d9e6540a6f71a74af235ff3b Mon Sep 17 00:00:00 2001 From: Siddhartha Sarkar Date: Wed, 23 Aug 2023 01:22:25 +0530 Subject: [PATCH 27/40] fix-typo: update `tranlations` to `translations` --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1627105d..bf73bec2 100644 --- a/README.md +++ b/README.md @@ -381,7 +381,7 @@ CLI now has an internationalization system. to translate the cli into your language: -1. create a new json file with your language, in the [tranlations](/translations) folder +1. create a new json file with your language, in the [translations](/translations) folder 2. Copy the keys from the [file](/translations/en.json), and translate the values 3. send your PR. From 659c20f38a82a3be11f8733ced584720684ae1a9 Mon Sep 17 00:00:00 2001 From: Cristiano Nascimeno Date: Fri, 8 Sep 2023 08:03:05 -0300 Subject: [PATCH 28/40] Changing extesion name for clarity --- lib/cli_config/cli_config.dart | 2 +- lib/core/internationalization.dart | 2 +- lib/extensions.dart | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/cli_config/cli_config.dart b/lib/cli_config/cli_config.dart index e909d450..4c6bf764 100644 --- a/lib/cli_config/cli_config.dart +++ b/lib/cli_config/cli_config.dart @@ -5,7 +5,7 @@ import 'package:path/path.dart'; class CliConfig { static final DateFormat _formatter = DateFormat('yyyy-MM-dd'); - // Em devsevolvimento + static File getFileConfig() { var scriptFile = Platform.script.toFilePath(); var path = join(dirname(scriptFile), '.get_cli.yaml'); diff --git a/lib/core/internationalization.dart b/lib/core/internationalization.dart index 96ed1015..728611b5 100644 --- a/lib/core/internationalization.dart +++ b/lib/core/internationalization.dart @@ -2,7 +2,7 @@ import 'dart:io'; import 'locales.g.dart'; -extension Trans on String { +extension TranslationExt on String { /// Translation String get tr { var translations = AppTranslation.translations; diff --git a/lib/extensions.dart b/lib/extensions.dart index be664747..889d8f9c 100644 --- a/lib/extensions.dart +++ b/lib/extensions.dart @@ -1,5 +1,5 @@ library get_cli.extensions; -export 'package:get_cli/core/internationalization.dart' show Trans; +export 'package:get_cli/core/internationalization.dart' show TranslationExt; export 'package:get_cli/extensions/list.dart'; export 'package:get_cli/extensions/string.dart'; From 7205c1db6963b3484a3de815e1e9f9c5ae7cf8d1 Mon Sep 17 00:00:00 2001 From: Cristiano Nascimeno Date: Fri, 8 Sep 2023 09:09:30 -0300 Subject: [PATCH 29/40] refactor the get_cli --- lib/core/structure.dart | 2 +- lib/extensions.dart | 1 + lib/extensions/dart_code.dart | 54 +++++++++++++++++++++++++ lib/extensions/string.dart | 34 ---------------- lib/functions/routes/get_add_route.dart | 17 +------- 5 files changed, 58 insertions(+), 50 deletions(-) create mode 100644 lib/extensions/dart_code.dart diff --git a/lib/core/structure.dart b/lib/core/structure.dart index 5155fafb..87d0dc66 100644 --- a/lib/core/structure.dart +++ b/lib/core/structure.dart @@ -81,7 +81,7 @@ class Structure { ); } - static String replaceAsExpected({required String path, String? replaceChar}) { + static String replaceAsExpected({required String path}) { if (path.contains('\\')) { if (Platform.isLinux || Platform.isMacOS) { return path.replaceAll('\\', '/'); diff --git a/lib/extensions.dart b/lib/extensions.dart index 889d8f9c..ac5fdb4a 100644 --- a/lib/extensions.dart +++ b/lib/extensions.dart @@ -3,3 +3,4 @@ library get_cli.extensions; export 'package:get_cli/core/internationalization.dart' show TranslationExt; export 'package:get_cli/extensions/list.dart'; export 'package:get_cli/extensions/string.dart'; +export 'package:get_cli/extensions/dart_code.dart'; diff --git a/lib/extensions/dart_code.dart b/lib/extensions/dart_code.dart new file mode 100644 index 00000000..3bef7bc2 --- /dev/null +++ b/lib/extensions/dart_code.dart @@ -0,0 +1,54 @@ +import 'dart:io'; + +import 'package:get_cli/functions/create/create_single_file.dart'; +import 'package:get_cli/functions/formatter_dart_file/frommatter_dart_file.dart'; + +import '../exception_handler/exceptions/cli_exception.dart'; +import 'string.dart'; + +extension DartCodeExt on File { + /// Append the content of dart class + /// ``` dart + /// var newClassContent = '''abstract class Routes { + /// Routes._(); + /// + ///} + /// abstract class _Paths { + /// _Paths._(); + /// }'''.appendClassContent('Routes', 'static const HOME = _Paths.HOME;' ); + /// print(newClassContent); + /// ``` + /// abstract class Routes { + /// Routes._(); + /// static const HOME = _Paths.HOME; + /// } + /// abstract class _Paths { + /// _Paths._(); + /// } + /// + void appendClassContent(String className, String value) { + var content = dartCode; + var matches = + RegExp('class $className {.*?(^})', multiLine: true, dotAll: true) + .allMatches(content); + if (matches.isEmpty) { + throw CliException('The class $className is not found in the file $path'); + } else if (matches.length > 1) { + throw CliException( + 'The class $className is found more than once in the file $path'); + } + var match = matches.first; + content = content.insert(match.end - 1, value); + writeFile( + path, + content, + overwrite: true, + logger: false, + useRelativeImport: true, + ); + } + + String get dartCode { + return formatterDartFile(readAsStringSync()); + } +} diff --git a/lib/extensions/string.dart b/lib/extensions/string.dart index 9e02782c..3f96af5f 100644 --- a/lib/extensions/string.dart +++ b/lib/extensions/string.dart @@ -12,40 +12,6 @@ extension StringExt on String { return newValue; } - /// Append the content of dart class - /// ``` dart - /// var newClassContent = '''abstract class Routes { - /// Routes._(); - /// - ///} - /// abstract class _Paths { - /// _Paths._(); - /// }'''.appendClassContent('Routes', 'static const HOME = _Paths.HOME;' ); - /// print(newClassContent); - /// ``` - /// abstract class Routes { - /// Routes._(); - /// static const HOME = _Paths.HOME; - /// } - /// abstract class _Paths { - /// _Paths._(); - /// } - /// - String appendClassContent(String className, String value) { - var matches = - RegExp('class $className {.*?(^})', multiLine: true, dotAll: true) - .allMatches(this); - //TODO: Add exception in the translations - if (matches.isEmpty) { - throw CliException('The class $className is not found in the file $this'); - } else if (matches.length > 1) { - throw CliException( - 'The class $className is found more than once in the file $this'); - } - var match = matches.first; - return insert(match.end - 1, value); - } - String insert(int index, String value) { var newValue = substring(0, index) + value + substring(index); return newValue; diff --git a/lib/functions/routes/get_add_route.dart b/lib/functions/routes/get_add_route.dart index 0403b188..3cb86555 100644 --- a/lib/functions/routes/get_add_route.dart +++ b/lib/functions/routes/get_add_route.dart @@ -10,23 +10,18 @@ import '../../extensions.dart'; import '../../samples/impl/get_route.dart'; import '../create/create_single_file.dart'; import '../find_file/find_file_by_name.dart'; -import '../formatter_dart_file/frommatter_dart_file.dart'; import 'get_app_pages.dart'; import 'get_support_children.dart'; /// This command will create the route to the new page void addRoute(String nameRoute, String bindingDir, String viewDir) { var routesFile = findFileByName('app_routes.dart'); - //var lines = []; var content = ''; if (routesFile.path.isEmpty) { RouteSample().create(); routesFile = File(RouteSample().path); content = routesFile.readAsStringSync(); - } else { - content = formatterDartFile(routesFile.readAsStringSync()); - //lines = LineSplitter.split(content).toList(); } var pathSplit = viewDir.split('/'); @@ -51,22 +46,14 @@ void addRoute(String nameRoute, String bindingDir, String viewDir) { if (supportChildrenRoutes) { line = '$declareRoute ${_pathsToRoute(pathSplit)};'; var linePath = "$declareRoute '/${pathSplit.last}';"; - content = content.appendClassContent('_Paths', linePath); + routesFile.appendClassContent('_Paths', linePath); } - content = content.appendClassContent('Routes', line); + routesFile.appendClassContent('Routes', line); addAppPage(nameRoute, bindingDir, viewDir); LogService.success( Translation(LocaleKeys.sucess_route_created).trArgs([nameRoute])); - - writeFile( - routesFile.path, - content, - overwrite: true, - logger: false, - useRelativeImport: true, - ); } /// Create routes from the path From 0cbdef3d191a49f371315fb6ab899e32dfc64358 Mon Sep 17 00:00:00 2001 From: Cristiano Nascimeno Date: Fri, 8 Sep 2023 09:34:56 -0300 Subject: [PATCH 30/40] remove nullsafe option --- lib/commands/impl/create/project/project.dart | 11 ----------- lib/common/utils/shell/shel.utils.dart | 6 ------ 2 files changed, 17 deletions(-) diff --git a/lib/commands/impl/create/project/project.dart b/lib/commands/impl/create/project/project.dart index ca1f6bd7..fd48a567 100644 --- a/lib/commands/impl/create/project/project.dart +++ b/lib/commands/impl/create/project/project.dart @@ -65,14 +65,6 @@ class CreateProjectCommand extends Command { var androidLang = androidResult.index == 0 ? 'kotlin' : 'java'; - final nullSafeMenu = Menu( - [LocaleKeys.options_yes.tr, LocaleKeys.options_no.tr], - title: LocaleKeys.ask_use_null_safe.tr); - final nullSafeMenuResult = - double.parse(Platform.version.split(' ').first[0]); - print(nullSafeMenuResult); - var useNullSafe = nullSafeMenuResult < 3; - final linterMenu = Menu([ 'yes', 'no', @@ -83,9 +75,6 @@ class CreateProjectCommand extends Command { File('test/widget_test.dart').writeAsStringSync(''); - if (useNullSafe) { - await ShellUtils.activatedNullSafe(); - } switch (linterResult.index) { case 0: if (PubspecUtils.isServerProject) { diff --git a/lib/common/utils/shell/shel.utils.dart b/lib/common/utils/shell/shel.utils.dart index 04edb1f4..7ca970ae 100644 --- a/lib/common/utils/shell/shel.utils.dart +++ b/lib/common/utils/shell/shel.utils.dart @@ -15,12 +15,6 @@ class ShellUtils { await run('flutter pub get', verbose: true); } - static Future activatedNullSafe() async { - await pubGet(); - // await run('dart migrate --apply-changes --skip-import-check', - // verbose: true); - } - static Future flutterCreate( String path, String? org, From b1ed3db3c565d4cc473b4bab876007dae55b77c6 Mon Sep 17 00:00:00 2001 From: nmartzolff Date: Wed, 14 Feb 2024 14:56:45 +0100 Subject: [PATCH 31/40] add french translations --- translations/fr.json | 88 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 translations/fr.json diff --git a/translations/fr.json b/translations/fr.json new file mode 100644 index 00000000..eaff5a5e --- /dev/null +++ b/translations/fr.json @@ -0,0 +1,88 @@ +{ + "ask": { + "existing_page": "La page [%s] existe déjà, voulez-vous l'écraser?", + "name_to_project": "Quel est le nom de votre projet?", + "company_domain": "Quel est le domaine de votre compagnie?", + "model_name": "Erreur lors de la définition du nom du modèle automatiquement, quel nom voulez-vous utiliser?", + "package_already_installed": "Le package: %s est déjà installé, voulez-vous le mettre à jour?", + "lib_not_empty": "Votre dossier lib n'est pas vide. Etes-vous sûr de vouloir écraser votre application? \\n ATTENTION: Cette action est irréversible", + "ios_lang": "Quel langage voulez-vous utiliser pour ios?", + "android_lang": "Quel langage voulez-vous utiliser pour android?", + "use_null_safe": "Voulez-vous utiliser null safe?", + "use_linter": "Voulez-vous utiliser un linter?", + "new_page_name": "Quel nouveau nom pour la page?" + }, + "error": { + "failed_to_connect": "Echec de la connexion avec %s", + "no_valid_file_or_url": "%s n'est pas un fichier ou une url valide", + "unnecessary_parameter": "Le paramètre %s n'est pas nécessaire", + "unnecessary_parameter_plural": "Les paramètres %s ne sont pas nécessaires", + "nonexistent_directory": "Le dossier %s n'existe pas", + "empty_directory": "%s est vide", + "invalid_json": "%s n'est pas un fichier json valide", + "special_characters_in_key": "Les caractères spéciaux ne sont pas autorisés dans la clé. \\n clé: %s", + "required_path": "Nécessaire pour transmettre le chemin du fichier ou du répertoire", + "invalid_dart": "Le fichier %s n'est pas un fichier dart valide", + "invalid_file_or_directory": "%s n'est pas un fichier ou un dossier valide", + "package_not_found": "Package: %s introuvable sur pub.dev", + "cli_version_not_found": "Echec pour trouver la version que vous avez installée", + "update_cli": "Il y a eu une erreur lors de la mise à niveau de get_cli", + "folder_not_found": "Dossier %s introuvable", + "file_not_found": "Fichier introuvable dans %s", + "access_denied": "Accès refusé à %s", + "unexpected": "Une erreur inattendue s'est produite:", + "no_package_to_remove": "Entrez le nom du package que vous souhaitez retirer" + }, + "example": "Exemple:", + "warning": "Avertissement:", + "hint": { + "create": { + "controller": "Générer un controller", + "page": "Utilisé pour générer des pages", + "project": "Utilisé pour générer un nouveau projet", + "provider": "Créer un nouveau provider", + "screen": "Générer un nouvel écran", + "view": "Générer une vue" + }, + "generate": { + "locales": "Générer le fichier de traduction depuis les fichiers json", + "model": "Générer un modèle depuis un json" + }, + "help": "Afficher cette aide", + "init": "Génère la strucutre choisie dans un project existant:", + "install": "Utilisé pour installer un package dans votre projet (dépendances):", + "remove": "Utilisé pour retirer un package de votre projet(dépendances):", + "sort": "Tri les imports et formate les fichiers dart", + "update": "Pour mettre à jour get_cli", + "version": "Montrer la version actuelle du CLI" + }, + "info": { + "unnecessary_flag": "Le flag %s n'est pas nécessaire", + "unnecessary_flag_prural": "Les flags %s ne sont pas nécessaires", + "package_not_installed": "Package: %s n'est pas installé dans cette application", + "cli_last_version_already_installed": "Dernière version de get_cli déjà installée", + "no_file_overwritten": "Aucun fichier n'a été écrasé", + "update_available": "Une mise à jour est disponible! Version actuellement installée: %s", + "update_available2": "Nouvelle version disponible: %s S'il vous plaît, exécutez:" + }, + "options": { + "yes": "Oui!", + "no": "Non", + "rename": "Je veux renommer" + }, + "optional_parameters": "Paramètres optionnels: %s", + "sucess": { + "page_create": "%s page crée avec succès", + "locale_generate": "Fichiers de locale générés avec succès", + "getx_pattern_generated": "Structure GetX Pattern générée avec succès", + "clean_Pattern_generated": "Structure CLEAN Pattern générée avec succès", + "file_formatted": " '%s' a été formaté avec succès", + "package_removed": "Package: %s retiré!", + "package_installed": "'Package: %s installé!", + "update_cli": "Mise à niveau terminée", + "add_controller_in_bindings": "Le controller %s a été ajouté au binding au chemin: %s'", + "navigation_added": "%s navigation ajouté avec succès", + "file_created": "Fichier: %s créé avec succès au chemin: %s", + "route_created": "%s route créée avec succès" + } +} \ No newline at end of file From 3a65ab9677f185ba9fe259d6cf046f428fa7252f Mon Sep 17 00:00:00 2001 From: Knot Date: Mon, 4 Mar 2024 00:03:02 +0700 Subject: [PATCH 32/40] update dependencies --- pubspec.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pubspec.yaml b/pubspec.yaml index 7d43e89b..c60877ff 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: get_cli -version: 1.8.2 +version: 1.8.4 homepage: https://github.com/jonataslaw/get_cli description: Official CLI for GetX™ framework to build Flutter and Server Applications easily @@ -11,7 +11,7 @@ dependencies: ansicolor: ">=2.0.1 <3.0.0" collection: ">=1.15.0 <2.0.0" dart_style: ">=2.0.1 <3.0.0" - dcli: ^2.3.0 + dcli: ^4.0.1-alpha.8 http: ">=0.13.4 <2.0.0" intl: ">=0.17.0 <1.0.0" meta: ">=1.7.0 <2.0.0" @@ -23,8 +23,8 @@ dependencies: yaml: ">=3.1.0 <4.0.0" dev_dependencies: - lints: ^2.0.0 - test: ^1.5.0 + lints: ^3.0.0 + test: ^1.25.2 executables: get: get From 0d643cb8832483f12ea532ab6e1761d3ca25f15a Mon Sep 17 00:00:00 2001 From: Knot Date: Fri, 5 Apr 2024 08:54:49 +0700 Subject: [PATCH 33/40] update dcli --- pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pubspec.yaml b/pubspec.yaml index c60877ff..924e976b 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -11,7 +11,7 @@ dependencies: ansicolor: ">=2.0.1 <3.0.0" collection: ">=1.15.0 <2.0.0" dart_style: ">=2.0.1 <3.0.0" - dcli: ^4.0.1-alpha.8 + dcli: ^4.0.1-alpha.13 http: ">=0.13.4 <2.0.0" intl: ">=0.17.0 <1.0.0" meta: ">=1.7.0 <2.0.0" From d6e0f6983b7c5d7cfe5d0cdb57ea5efad1104f3e Mon Sep 17 00:00:00 2001 From: Hakim Zulkhibri Date: Wed, 24 Apr 2024 21:30:28 +0800 Subject: [PATCH 34/40] UPDATE: Update impl/get_view.dart to adhere Flutter's - Convert 'key' to a super parameter.dart (use_super_parameters) --- lib/samples/impl/get_view.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/samples/impl/get_view.dart b/lib/samples/impl/get_view.dart index 69bb2da0..c44d4c3e 100644 --- a/lib/samples/impl/get_view.dart +++ b/lib/samples/impl/get_view.dart @@ -25,7 +25,7 @@ import 'package:get/get.dart'; $import class $_viewName extends $_controllerName { - const $_viewName({Key? key}) : super(key: key); + const $_viewName({super.key}); @override Widget build(BuildContext context) { return Scaffold( From 2f8ffc1a4fbf3bf324bbbbcfb58a8aae416cc474 Mon Sep 17 00:00:00 2001 From: openapphub Date: Fri, 2 Aug 2024 11:38:58 +0800 Subject: [PATCH 35/40] Update README-zh_CN.md Fix Chinese translation problems --- README-zh_CN.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/README-zh_CN.md b/README-zh_CN.md index 6e70cf8e..1fb7df88 100644 --- a/README-zh_CN.md +++ b/README-zh_CN.md @@ -121,10 +121,9 @@ get help ```shell get create page:name ``` +该命令允许您创建模块,建议选择使用 getx_pattern 的用户使用, -这条命令允许你创建模块,建议选择getx_pattern的人使用。 - -创建 view, controller 和 binding 文件, 除了自动添加路由。 +创建 view, controller 和 binding 文件, 此外还可以自动添加路由。 你可以在一个模块内创建另一个模块。 From 7356aa372182176599b484004d1fc1a82df31a2d Mon Sep 17 00:00:00 2001 From: Jonny Borges <35742643+jonataslaw@users.noreply.github.com> Date: Tue, 20 Aug 2024 14:27:56 -0300 Subject: [PATCH 36/40] update to 1.9.0 --- CHANGELOG.md | 20 ++- .../json_serialize/json_ast/location.dart | 4 +- .../json_serialize/json_ast/tokenize.dart | 22 ++- .../utils/json_serialize/model_generator.dart | 2 +- lib/common/utils/json_serialize/sintaxe.dart | 4 +- lib/common/utils/pubspec/pubspec_utils.dart | 138 ++++++++++-------- lib/common/utils/shell/shel.utils.dart | 12 +- lib/extensions/string.dart | 2 - lib/functions/routes/get_add_route.dart | 5 +- .../routes/get_support_children.dart | 27 ++-- lib/samples/impl/arctekko/arc_screen.dart | 5 +- lib/samples/impl/get_binding.dart | 5 +- lib/samples/impl/get_controller.dart | 5 +- lib/samples/impl/get_view.dart | 5 +- pubspec.yaml | 33 +++-- 15 files changed, 160 insertions(+), 129 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f19c5bb1..3302c03d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,37 +1,45 @@ +## [1.9.0] + +- Update to dart 3 +- Make null safety mandatory + ## [1.8.2] + - Replace cli_dialog with dcli - version dependency updated - Added dafault value to menu & spaces - Fixed some lints with views ## [1.8.1] + - Fixed null error in pub version - Fixed get view by adding const ## [1.8.0] + - Update dependencies, remove pedantic and effective dart from lints options ## [1.7.1] + - Remove unmaintained dependencies ## [1.7.0] + - Fix Path and null safety errors (@CpdnCristiano) - Translation to Chinese (@iwpz @zhangwanping) -- Update Portugueses docs @ricardodalarme +- Update Portugueses docs @ricardodalarme - Add Italian translation (@giannuzzoexe) - Fix Generate Model null-safety error (@maxzod) - Fixed errors in Arc clean: (@Babar-Bashir, @shawon1fb) - - ## [1.6.0] + - Fix cast error on local dependencies (@ahmednfwela) - Fix null safety model creator (@prabhah) - Fix windows path separator error (@CpdnCristiano) - Added new official linter (@Illusion47586) - Added german language(@ngjoni) - ## [1.5.0] - Add support to null safety @@ -49,11 +57,11 @@ - Add alias for install: `get -i PACKAGE` - Add alias for create: `get -c page:name` - Add alias for generate: `get -g locales` -- add turkish translation by @ahm3tcelik +- add turkish translation by @ahm3tcelik ## [1.4.4] -- Add alias getx: `getx command` +- Add alias getx: `getx command` ## [1.4.3] diff --git a/lib/common/utils/json_serialize/json_ast/location.dart b/lib/common/utils/json_serialize/json_ast/location.dart index 5914d971..b7644292 100644 --- a/lib/common/utils/json_serialize/json_ast/location.dart +++ b/lib/common/utils/json_serialize/json_ast/location.dart @@ -15,7 +15,7 @@ class Segment extends Loc { : super(line: line, column: column); @override - bool operator ==(dynamic other) => + bool operator ==(Object other) => other is Segment && line == other.line && column == other.column && @@ -34,7 +34,7 @@ class Location { const Location(this.start, this.end, [this.source]); @override - bool operator ==(dynamic other) => + bool operator ==(Object other) => other is Location && start == other.start && end == other.end && diff --git a/lib/common/utils/json_serialize/json_ast/tokenize.dart b/lib/common/utils/json_serialize/json_ast/tokenize.dart index 563f5492..02ddfa5a 100644 --- a/lib/common/utils/json_serialize/json_ast/tokenize.dart +++ b/lib/common/utils/json_serialize/json_ast/tokenize.dart @@ -108,7 +108,7 @@ class ValueNode extends Node { }) : super(type, loc); @override - bool operator ==(dynamic other) => + bool operator ==(Object other) => other is ValueNode && type == other.type && loc == other.loc && @@ -148,9 +148,8 @@ class ObjectNode extends Node { final List children; ObjectNode( - [String type = 'Object', Location? loc, List? children]) - : children = children ?? [], - super(type, loc); + [super.type = 'Object', super.loc, List? children]) + : children = children ?? []; ObjectNode copyWith({ String? type, @@ -165,7 +164,7 @@ class ObjectNode extends Node { } @override - bool operator ==(dynamic other) => + bool operator ==(Object other) => other is ObjectNode && type == other.type && loc == other.loc && @@ -179,9 +178,8 @@ class ObjectNode extends Node { class ArrayNode extends Node { final List children; - ArrayNode([String type = 'Array', Location? loc, List? children]) - : children = children ?? [], - super(type, loc); + ArrayNode([super.type = 'Array', super.loc, List? children]) + : children = children ?? []; ArrayNode copyWith({ String? type, @@ -196,7 +194,7 @@ class ArrayNode extends Node { } @override - bool operator ==(dynamic other) => + bool operator ==(Object other) => other is ArrayNode && type == other.type && loc == other.loc && @@ -224,7 +222,7 @@ class PropertyNode extends Node { super(type, loc); @override - bool operator ==(dynamic other) => + bool operator ==(Object other) => other is PropertyNode && type == other.type && index == other.index && @@ -268,7 +266,7 @@ class LiteralNode extends Node { }) : super(type, loc); @override - bool operator ==(dynamic other) => + bool operator ==(Object other) => other is LiteralNode && type == other.type && loc == other.loc && @@ -302,7 +300,7 @@ class ValueIndex { ValueIndex(this.value, this.index); @override - bool operator ==(dynamic other) => + bool operator ==(Object other) => other is ValueIndex && value == other.value && index == other.index; @override diff --git a/lib/common/utils/json_serialize/model_generator.dart b/lib/common/utils/json_serialize/model_generator.dart index 8e447cbc..9b85032e 100644 --- a/lib/common/utils/json_serialize/model_generator.dart +++ b/lib/common/utils/json_serialize/model_generator.dart @@ -9,7 +9,7 @@ import 'json_ast/json_ast.dart' show parse, Settings, Node; import 'sintaxe.dart'; class DartCode extends WithWarning { - DartCode(String result, List warnings) : super(result, warnings); + DartCode(super.result, super.warnings); String get code => result; } diff --git a/lib/common/utils/json_serialize/sintaxe.dart b/lib/common/utils/json_serialize/sintaxe.dart index 0a01787c..743baad9 100644 --- a/lib/common/utils/json_serialize/sintaxe.dart +++ b/lib/common/utils/json_serialize/sintaxe.dart @@ -88,7 +88,7 @@ class TypeDefinition { } @override - bool operator ==(dynamic other) { + bool operator ==(Object other) { if (other is TypeDefinition) { return name == other.name && subtype == other.subtype && @@ -207,7 +207,7 @@ class ClassDefinition { [this._privateFields = false, this._withCopyConstructor = false]); @override - bool operator ==(dynamic other) { + bool operator ==(Object other) { if (other is ClassDefinition) { var otherClassDef = other; return isSubsetOf(otherClassDef) && otherClassDef.isSubsetOf(this); diff --git a/lib/common/utils/pubspec/pubspec_utils.dart b/lib/common/utils/pubspec/pubspec_utils.dart index f95b9868..ef6bf3ad 100644 --- a/lib/common/utils/pubspec/pubspec_utils.dart +++ b/lib/common/utils/pubspec/pubspec_utils.dart @@ -1,28 +1,28 @@ import 'dart:io'; -import 'package:pubspec/pubspec.dart'; -import 'package:version/version.dart' as v; +import 'package:pub_semver/pub_semver.dart'; +import 'package:pubspec_parse/pubspec_parse.dart'; +import 'package:yaml/yaml.dart'; import '../../../core/internationalization.dart'; import '../../../core/locales.g.dart'; -import '../../../exception_handler/exceptions/cli_exception.dart'; import '../../../extensions.dart'; import '../../menu/menu.dart'; import '../logger/log_utils.dart'; -import '../pub_dev/pub_dev_api.dart'; import '../shell/shel.utils.dart'; -import 'yaml_to.string.dart'; // ignore: avoid_classes_with_only_static_members class PubspecUtils { static final _pubspecFile = File('pubspec.yaml'); - static PubSpec get pubSpec => - PubSpec.fromYamlString(_pubspecFile.readAsStringSync()); + static Pubspec get pubSpec => Pubspec.parse(pubspecJson); + + static get pubspecJson => loadYaml(_pubspecFile.readAsStringSync()); /// separtor static final _mapSep = _PubValue(() { - var yaml = pubSpec.unParsedYaml!; + var yaml = pubspecJson; + if (yaml.containsKey('get_cli')) { if ((yaml['get_cli'] as Map).containsKey('separator')) { return (yaml['get_cli']['separator'] as String?) ?? ''; @@ -34,14 +34,14 @@ class PubspecUtils { static String? get separatorFileType => _mapSep.value; - static final _mapName = _PubValue(() => pubSpec.name?.trim() ?? ''); + static final _mapName = _PubValue(() => pubSpec.name.trim()); static String? get projectName => _mapName.value; static final _extraFolder = _PubValue( () { try { - var yaml = pubSpec.unParsedYaml!; + var yaml = pubspecJson; if (yaml.containsKey('get_cli')) { if ((yaml['get_cli'] as Map).containsKey('sub_folder')) { return (yaml['get_cli']['sub_folder'] as bool?); @@ -58,8 +58,6 @@ class PubspecUtils { static Future addDependencies(String package, {String? version, bool isDev = false, bool runPubGet = true}) async { - var pubSpec = PubSpec.fromYamlString(_pubspecFile.readAsStringSync()); - if (containsPackage(package)) { LogService.info( LocaleKeys.ask_package_already_installed.trArgs([package]), @@ -77,36 +75,59 @@ class PubspecUtils { } } - version = version == null || version.isEmpty - ? await PubDevApi.getLatestVersionFromPackage(package) - : '^$version'; - if (version == null) return false; + String packageName = package; + + if (version != null && version.isNotEmpty) { + packageName = '$package:$version'; + } + if (isDev) { - pubSpec.devDependencies[package] = HostedReference.fromJson(version); - } else { - pubSpec.dependencies[package] = HostedReference.fromJson(version); + packageName = 'dev:$packageName'; } - _savePub(pubSpec); + await ShellUtils.addPackage(packageName); + + // version = version == null || version.isEmpty + // ? await PubDevApi.getLatestVersionFromPackage(package) + // : '^$version'; + // if (version == null) return false; + // final dependency = HostedDependency( + // version: VersionConstraint.parse(version), + // ); + + // if (isDev) { + // pubSpec.devDependencies[package] = dependency; + // } else { + // pubSpec.dependencies[package] = dependency; + // } + + // _savePub(pubSpec); if (runPubGet) await ShellUtils.pubGet(); LogService.success(LocaleKeys.sucess_package_installed.trArgs([package])); return true; } - static void removeDependencies(String package, {bool logger = true}) { + static Future removeDependencies(String package, + {bool logger = true}) async { if (logger) LogService.info('Removing package: "$package"'); - if (containsPackage(package)) { - var dependencies = pubSpec.dependencies; - var devDependencies = pubSpec.devDependencies; - - dependencies.removeWhere((key, value) => key == package); - devDependencies.removeWhere((key, value) => key == package); - var newPub = pubSpec.copy( - devDependencies: devDependencies, - dependencies: dependencies, - ); - _savePub(newPub); + await ShellUtils.removePackage(package); + if (!containsPackage(package)) { + // var dependencies = pubSpec.dependencies; + // var devDependencies = pubSpec.devDependencies; + + // dependencies.removeWhere((key, value) => key == package); + // devDependencies.removeWhere((key, value) => key == package); + // pubSpec.dependencies.clear(); + // pubSpec.devDependencies.clear(); + // pubSpec.dependencies.addAll(dependencies); + // pubSpec.devDependencies.addAll(devDependencies); + // var newPub = pubSpec.copy( + // devDependencies: devDependencies, + // dependencies: dependencies, + // ); + + // _savePub(pubSpec); if (logger) { LogService.success(LocaleKeys.sucess_package_removed.trArgs([package])); } @@ -120,8 +141,8 @@ class PubspecUtils { return dependencies.containsKey(package.trim()); } - static bool get nullSafeSupport => !pubSpec.environment!.sdkConstraint! - .allowsAny(HostedReference.fromJson('<2.12.0').versionConstraint); + static bool get nullSafeSupport => !pubSpec.environment!['sdkConstraint']! + .allowsAny(VersionConstraint.parse('<2.12.0')); /// make sure it is a get_server project static bool get isServerProject { @@ -132,30 +153,31 @@ class PubspecUtils { ? "import 'package:get/get.dart';" : "import 'package:get_server/get_server.dart';"; - static v.Version? getPackageVersion(String package) { - if (containsPackage(package)) { - var version = pubSpec.allDependencies[package]!; - try { - final json = version.toJson(); - if (json is String) { - return v.Version.parse(json); - } - return null; - } on FormatException catch (_) { - return null; - } on Exception catch (_) { - rethrow; - } - } else { - throw CliException( - LocaleKeys.info_package_not_installed.trArgs([package])); - } - } - - static void _savePub(PubSpec pub) { - var value = CliYamlToString().toYamlString(pub.toJson()); - _pubspecFile.writeAsStringSync(value); - } + // static v.Version? getPackageVersion(String package) { + // if (containsPackage(package)) { + // pubSpec.dependencies.containsKey(pa) + // var version = pubSpec.allDependencies[package]!; + // try { + // final json = version.toJson(); + // if (json is String) { + // return v.Version.parse(json); + // } + // return null; + // } on FormatException catch (_) { + // return null; + // } on Exception catch (_) { + // rethrow; + // } + // } else { + // throw CliException( + // LocaleKeys.info_package_not_installed.trArgs([package])); + // } + // } + + // static void _savePub(Pubspec pub) { + // var value = CliYamlToString().toYamlString(pub.toJson()); + // _pubspecFile.writeAsStringSync(value); + // } } /// avoids multiple reads in one file diff --git a/lib/common/utils/shell/shel.utils.dart b/lib/common/utils/shell/shel.utils.dart index 7ca970ae..01487545 100644 --- a/lib/common/utils/shell/shel.utils.dart +++ b/lib/common/utils/shell/shel.utils.dart @@ -12,7 +12,17 @@ import '../pubspec/pubspec_lock.dart'; class ShellUtils { static Future pubGet() async { LogService.info('Running `flutter pub get` …'); - await run('flutter pub get', verbose: true); + await run('dart pub get', verbose: true); + } + + static Future addPackage(String package) async { + LogService.info('Adding package $package …'); + await run('dart pub add $package', verbose: true); + } + + static Future removePackage(String package) async { + LogService.info('Removing package $package …'); + await run('dart pub remove $package', verbose: true); } static Future flutterCreate( diff --git a/lib/extensions/string.dart b/lib/extensions/string.dart index 3f96af5f..b083c4e9 100644 --- a/lib/extensions/string.dart +++ b/lib/extensions/string.dart @@ -1,5 +1,3 @@ -import '../exception_handler/exceptions/cli_exception.dart'; - extension StringExt on String { /// Removes all characters. /// ``` diff --git a/lib/functions/routes/get_add_route.dart b/lib/functions/routes/get_add_route.dart index 3cb86555..01744cab 100644 --- a/lib/functions/routes/get_add_route.dart +++ b/lib/functions/routes/get_add_route.dart @@ -8,7 +8,6 @@ import '../../core/internationalization.dart'; import '../../core/locales.g.dart'; import '../../extensions.dart'; import '../../samples/impl/get_route.dart'; -import '../create/create_single_file.dart'; import '../find_file/find_file_by_name.dart'; import 'get_app_pages.dart'; import 'get_support_children.dart'; @@ -16,12 +15,12 @@ import 'get_support_children.dart'; /// This command will create the route to the new page void addRoute(String nameRoute, String bindingDir, String viewDir) { var routesFile = findFileByName('app_routes.dart'); - var content = ''; + // var content = ''; if (routesFile.path.isEmpty) { RouteSample().create(); routesFile = File(RouteSample().path); - content = routesFile.readAsStringSync(); + // content = routesFile.readAsStringSync(); } var pathSplit = viewDir.split('/'); diff --git a/lib/functions/routes/get_support_children.dart b/lib/functions/routes/get_support_children.dart index f889a42b..d1de57a6 100644 --- a/lib/functions/routes/get_support_children.dart +++ b/lib/functions/routes/get_support_children.dart @@ -1,5 +1,3 @@ -import 'package:version/version.dart'; - import '../../common/utils/pubspec/pubspec_utils.dart'; import '../find_file/find_file_by_name.dart'; @@ -8,18 +6,19 @@ bool get supportChildrenRoutes { if (PubspecUtils.isServerProject) { return false; } - var supportChildren = Version.parse('3.21.0').compareTo( - PubspecUtils.getPackageVersion('get') ?? Version.parse('3.21.0')) <= - 0; - if (supportChildren) { - var routesFile = findFileByName('app_routes.dart'); - if (routesFile.path.isNotEmpty) { - supportChildren = - routesFile.readAsLinesSync().contains('abstract class _Paths {') || - routesFile.readAsLinesSync().contains('abstract class _Paths {}'); - } else { - supportChildren = false; - } + var supportChildren = true; + // var supportChildren = Version.parse('3.21.0').compareTo( + // PubspecUtils.getPackageVersion('get') ?? Version.parse('3.21.0')) <= + // 0; + // if (supportChildren) { + var routesFile = findFileByName('app_routes.dart'); + if (routesFile.path.isNotEmpty) { + supportChildren = + routesFile.readAsLinesSync().contains('abstract class _Paths {') || + routesFile.readAsLinesSync().contains('abstract class _Paths {}'); + // } else { + // supportChildren = false; + // } } return supportChildren; } diff --git a/lib/samples/impl/arctekko/arc_screen.dart b/lib/samples/impl/arctekko/arc_screen.dart index 579d4536..5f5307ef 100644 --- a/lib/samples/impl/arctekko/arc_screen.dart +++ b/lib/samples/impl/arctekko/arc_screen.dart @@ -6,9 +6,8 @@ import '../../interface/sample_interface.dart'; class ArcScreenSample extends Sample { late String fileName; bool isExample; - ArcScreenSample(String path, String fileName, - {bool overwrite = false, this.isExample = false}) - : super(path, overwrite: overwrite); + ArcScreenSample(super.path, String fileName, + {super.overwrite, this.isExample = false}); @override String get content => !isExample diff --git a/lib/samples/impl/get_binding.dart b/lib/samples/impl/get_binding.dart index 284ff179..fe2fcd1a 100644 --- a/lib/samples/impl/get_binding.dart +++ b/lib/samples/impl/get_binding.dart @@ -10,10 +10,9 @@ class BindingSample extends Sample { final String _bindingName; final bool _isServer; - BindingSample(String path, this._fileName, this._bindingName, + BindingSample(super.path, this._fileName, this._bindingName, this._controllerDir, this._isServer, - {bool overwrite = false}) - : super(path, overwrite: overwrite); + {super.overwrite}); String get _import => _isServer ? "import 'package:get_server/get_server.dart';" diff --git a/lib/samples/impl/get_controller.dart b/lib/samples/impl/get_controller.dart index 0f6e59e2..1a454720 100644 --- a/lib/samples/impl/get_controller.dart +++ b/lib/samples/impl/get_controller.dart @@ -6,9 +6,8 @@ import '../interface/sample_interface.dart'; class ControllerSample extends Sample { final String _fileName; final bool _isServer; - ControllerSample(String path, this._fileName, this._isServer, - {bool overwrite = false}) - : super(path, overwrite: overwrite); + ControllerSample(super.path, this._fileName, this._isServer, + {super.overwrite}); @override String get content => _isServer ? serverController : flutterController; diff --git a/lib/samples/impl/get_view.dart b/lib/samples/impl/get_view.dart index 69bb2da0..2eef0117 100644 --- a/lib/samples/impl/get_view.dart +++ b/lib/samples/impl/get_view.dart @@ -8,10 +8,9 @@ class GetViewSample extends Sample { final String _controller; final bool _isServer; - GetViewSample(String path, this._viewName, this._controller, + GetViewSample(super.path, this._viewName, this._controller, this._controllerDir, this._isServer, - {bool overwrite = false}) - : super(path, overwrite: overwrite); + {super.overwrite}); String get import => _controllerDir.isNotEmpty ? '''import 'package:${PubspecUtils.projectName}/$_controllerDir';''' diff --git a/pubspec.yaml b/pubspec.yaml index 924e976b..4192937d 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: get_cli -version: 1.8.4 +version: 1.9.0 homepage: https://github.com/jonataslaw/get_cli description: Official CLI for GetX™ framework to build Flutter and Server Applications easily @@ -8,23 +8,24 @@ environment: dependencies: # archive: ^3.1.2 - ansicolor: ">=2.0.1 <3.0.0" - collection: ">=1.15.0 <2.0.0" - dart_style: ">=2.0.1 <3.0.0" - dcli: ^4.0.1-alpha.13 - http: ">=0.13.4 <2.0.0" - intl: ">=0.17.0 <1.0.0" - meta: ">=1.7.0 <2.0.0" - path: ">=1.8.0 <2.0.0" - process_run: ">=0.12.2 <1.0.0" - pubspec: ">=2.0.1 <3.0.0" - recase: ">=4.0.0 <5.0.0" - version: ">=2.0.0 <4.0.0" - yaml: ">=3.1.0 <4.0.0" + ansicolor: ">=2.0.3 <3.0.0" + collection: ">=1.19.0 <2.0.0" + dart_style: ">=2.3.6 <3.0.0" + dcli: ">=6.0.5 <7.0.0" + http: ">=1.2.2 <2.0.0" + intl: ">=0.19.0 <1.0.0" + meta: ">=1.15.0 <2.0.0" + path: ">=1.9.0 <2.0.0" + process_run: ">=1.1.0 <2.0.0" + pubspec_parse: ">=1.3.0 <2.0.0" + pub_semver: ">=2.1.4 <3.0.0" + recase: ">=4.1.0 <5.0.0" + version: ">=3.0.2 <4.0.0" + yaml: ">=3.1.2 <4.0.0" dev_dependencies: - lints: ^3.0.0 - test: ^1.25.2 + lints: ^4.0.0 + test: ^1.25.8 executables: get: get From 1f569e5cc731c4feff9c9adf1a9284a7de80b203 Mon Sep 17 00:00:00 2001 From: Jonny Borges <35742643+jonataslaw@users.noreply.github.com> Date: Tue, 20 Aug 2024 14:30:06 -0300 Subject: [PATCH 37/40] add dart 3 constraint --- pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pubspec.yaml b/pubspec.yaml index 4192937d..e4d273c3 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -4,7 +4,7 @@ homepage: https://github.com/jonataslaw/get_cli description: Official CLI for GetX™ framework to build Flutter and Server Applications easily environment: - sdk: ">=2.19.0 <4.0.0" + sdk: ">=3.0.0 <4.0.0" dependencies: # archive: ^3.1.2 From cd22dc7ab1b4b53d16705d16942400ff2f77af02 Mon Sep 17 00:00:00 2001 From: Jonny Borges <35742643+jonataslaw@users.noreply.github.com> Date: Tue, 20 Aug 2024 14:53:58 -0300 Subject: [PATCH 38/40] fix yaml parser --- CHANGELOG.md | 7 +++++++ lib/common/utils/pubspec/pubspec_utils.dart | 6 ++++-- pubspec.yaml | 2 +- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3302c03d..64bc2389 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,14 @@ +## [1.9.1] + +- Fix yaml parse error + ## [1.9.0] - Update to dart 3 - Make null safety mandatory +- Update impl/get_view.dart to adhere Flutter's - use_super_parameters +- Add support for Flutter 2.10 +- Fix chinese translation ## [1.8.2] diff --git a/lib/common/utils/pubspec/pubspec_utils.dart b/lib/common/utils/pubspec/pubspec_utils.dart index ef6bf3ad..4918dc97 100644 --- a/lib/common/utils/pubspec/pubspec_utils.dart +++ b/lib/common/utils/pubspec/pubspec_utils.dart @@ -15,9 +15,11 @@ import '../shell/shel.utils.dart'; class PubspecUtils { static final _pubspecFile = File('pubspec.yaml'); - static Pubspec get pubSpec => Pubspec.parse(pubspecJson); + static Pubspec get pubSpec => Pubspec.parse(pubspecString); - static get pubspecJson => loadYaml(_pubspecFile.readAsStringSync()); + static String get pubspecString => _pubspecFile.readAsStringSync(); + + static get pubspecJson => loadYaml(pubspecString); /// separtor static final _mapSep = _PubValue(() { diff --git a/pubspec.yaml b/pubspec.yaml index e4d273c3..9c53a6c8 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: get_cli -version: 1.9.0 +version: 1.9.1 homepage: https://github.com/jonataslaw/get_cli description: Official CLI for GetX™ framework to build Flutter and Server Applications easily From 7ef02b391244bd3ef011e9a29137a710c1c4299b Mon Sep 17 00:00:00 2001 From: Knot Date: Wed, 9 Oct 2024 16:17:36 +0700 Subject: [PATCH 39/40] fix generate model --- lib/common/utils/json_serialize/helpers.dart | 45 ++++++-------------- lib/common/utils/json_serialize/sintaxe.dart | 36 ++++++++-------- lib/common/utils/pubspec/pubspec_utils.dart | 2 +- 3 files changed, 32 insertions(+), 51 deletions(-) diff --git a/lib/common/utils/json_serialize/helpers.dart b/lib/common/utils/json_serialize/helpers.dart index ecce6766..ad822297 100644 --- a/lib/common/utils/json_serialize/helpers.dart +++ b/lib/common/utils/json_serialize/helpers.dart @@ -9,21 +9,19 @@ import 'json_ast/json_ast.dart'; import 'sintaxe.dart'; const Map PRIMITIVE_TYPES = { - 'int': true, - 'double': true, + 'num': true, 'String': true, 'bool': true, 'DateTime': false, 'List': false, - 'List': true, - 'List': true, + 'List': true, 'List': true, 'List': true, 'Null': true, 'dynamic': true, }; -enum ListType { Object, String, Double, Int, Null } +enum ListType { Object, String, Num, Null } class MergeableListType { final ListType? listType; @@ -37,10 +35,8 @@ MergeableListType mergeableListType(List list) { var isAmbigous = false; for (var e in list) { ListType? inferredType; - if (e.runtimeType.toString() == 'int') { - inferredType = ListType.Int; - } else if (e.runtimeType.toString() == 'double') { - inferredType = ListType.Double; + if (e.runtimeType.toString() == 'num') { + inferredType = ListType.Num; } else if (e.runtimeType.toString() == 'string') { inferredType = ListType.String; } else if (e is Map) { @@ -92,14 +88,7 @@ WithWarning mergeObj(Map obj, Map other, String path) { final otherType = getTypeName(v); final t = getTypeName(clone[k]); if (t != otherType) { - if (t == 'int' && otherType == 'double') { - // if double was found instead of int, assign the double - clone[k] = v; - } else if (clone[k].runtimeType.toString() != 'double' && - v.runtimeType.toString() != 'int') { - // if types are not equal, then - warnings.add(newAmbiguousType('$path/$k')); - } + warnings.add(newAmbiguousType('$path/$k')); } else if (t == 'List') { var l = List.from(clone[k] as Iterable); l.addAll(other[k] as Iterable); @@ -140,18 +129,12 @@ WithWarning mergeObjectList(List list, String path, } else { final otherType = getTypeName(v); if (t != otherType) { - if (t == 'int' && otherType == 'double') { - // if double was found instead of int, assign the double - obj[k] = v; - } else if (t != 'double' && otherType != 'int') { - // if types are not equal, then - var realIndex = i; - if (idx != -1) { - realIndex = idx - i; - } - final ambiguosTypePath = '$path[$realIndex]/$k'; - warnings.add(newAmbiguousType(ambiguosTypePath)); + var realIndex = i; + if (idx != -1) { + realIndex = idx - i; } + final ambiguosTypePath = '$path[$realIndex]/$k'; + warnings.add(newAmbiguousType(ambiguosTypePath)); } else if (t == 'List') { var l = List.from(obj[k] as Iterable); final beginIndex = l.length; @@ -215,10 +198,8 @@ String fixFieldName(String name, String getTypeName(dynamic obj) { if (obj is String) { return 'String'; - } else if (obj is int) { - return 'int'; - } else if (obj is double) { - return 'double'; + } else if (obj is num) { + return 'num'; } else if (obj is bool) { return 'bool'; } else if (obj == null) { diff --git a/lib/common/utils/json_serialize/sintaxe.dart b/lib/common/utils/json_serialize/sintaxe.dart index 743baad9..84e2fbea 100644 --- a/lib/common/utils/json_serialize/sintaxe.dart +++ b/lib/common/utils/json_serialize/sintaxe.dart @@ -71,9 +71,6 @@ class TypeDefinition { TypeDefinition(this.name, {this.subtype, this.isAmbiguous, Node? astNode}) { if (subtype == null) { _isPrimitive = isPrimitiveType(name); - if (name == 'int' && isASTLiteralDouble(astNode)) { - name = 'double'; - } } else { _isPrimitive = isPrimitiveType('$name<$subtype>'); } @@ -129,8 +126,8 @@ class TypeDefinition { if (name == 'List') { return "$fieldKey = json['$key']?.cast<$subtype>();"; } - if (name == 'double?') { - return "$fieldKey = (json['$key'] as num?)?.toDouble();"; + if (name == 'num?') { + return "$fieldKey = json['$key'] as num?;"; } return "$fieldKey = json['$key'];"; } else if (name == 'List' && subtype == 'DateTime') { @@ -318,22 +315,25 @@ class ClassDefinition { String get _defaultConstructor { final sb = StringBuffer(); - sb.write('\t$name({'); - var i = 0; - var len = fields.keys.length - 1; - for (var key in fields.keys) { - final f = fields[key]; - final fieldName = - fixFieldName(key, typeDef: f, privateField: privateFields); - sb.write('this.$fieldName'); - //sb.write('$fieldName'); - if (i != len) { - sb.write(', '); + sb.write('\t$name('); + + if (fields.keys.isNotEmpty) { + sb.write('{'); + + for (var key in fields.keys) { + final f = fields[key]; + final fieldName = fixFieldName( + key, + typeDef: f, + privateField: privateFields, + ); + sb.write('this.$fieldName,'); } - i++; + + sb.write('}'); } - sb.write('});'); + sb.write(');'); return sb.toString(); } diff --git a/lib/common/utils/pubspec/pubspec_utils.dart b/lib/common/utils/pubspec/pubspec_utils.dart index 4918dc97..304a0749 100644 --- a/lib/common/utils/pubspec/pubspec_utils.dart +++ b/lib/common/utils/pubspec/pubspec_utils.dart @@ -143,7 +143,7 @@ class PubspecUtils { return dependencies.containsKey(package.trim()); } - static bool get nullSafeSupport => !pubSpec.environment!['sdkConstraint']! + static bool get nullSafeSupport => !pubSpec.environment!['sdk']! .allowsAny(VersionConstraint.parse('<2.12.0')); /// make sure it is a get_server project From c39684cd8e5fab724f6abb1583e386d53be5954a Mon Sep 17 00:00:00 2001 From: noblebuildsai Date: Fri, 9 Jan 2026 19:48:41 +0530 Subject: [PATCH 40/40] fix: remove unsupported iOS/Android language flags from flutter create The -i (ios-language) and -a (android-language) flags are only supported for plugin templates, not regular Flutter projects. This was causing the error: The ios-language option is only supported for --template=plugin. Flutter uses Swift/Kotlin by default for regular projects, so these flags are not needed. --- lib/common/utils/shell/shel.utils.dart | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/common/utils/shell/shel.utils.dart b/lib/common/utils/shell/shel.utils.dart index 01487545..c7aba13e 100644 --- a/lib/common/utils/shell/shel.utils.dart +++ b/lib/common/utils/shell/shel.utils.dart @@ -33,9 +33,10 @@ class ShellUtils { ) async { LogService.info('Running `flutter create $path` …'); - await run( - 'flutter create --no-pub -i $iosLang -a $androidLang --org $org' - ' "$path"', + // Note: -i and -a flags are only supported for --template=plugin + // For regular Flutter projects, Flutter uses Swift/Kotlin by default + await run( + 'flutter create --no-pub --org $org "$path"', verbose: true); }