From 0d2605717add29556b12ad1145e4457d71f18c18 Mon Sep 17 00:00:00 2001 From: Hugo Pointcheval Date: Tue, 14 Nov 2023 16:36:55 +0100 Subject: [PATCH] feat: upgrade wyatt_package_template --- apps/wyatt_app_template/brickgen.yaml | 2 +- apps/wyatt_app_template/hooks/post_gen.dart | 2 +- .../starting_template/.vscode/settings.json | 29 +++++++------- .../starting_template/analysis_options.yaml | 4 +- .../starting_template/pubspec.yaml | 7 +--- apps/wyatt_package_template/brickgen.yaml | 2 +- .../hooks/post_gen.dart | 12 ++++++ .../.vscode/extensions.json | 24 ------------ .../.vscode/settings.json | 2 +- .../analysis_options.yaml | 8 ++-- .../wyatt_package_template/pubspec.yaml | 8 ++-- .../__brick__/.vscode/settings.json | 29 +++++++------- .../__brick__/analysis_options.yaml | 4 +- .../wyatt_app_template/__brick__/pubspec.yaml | 7 +--- bricks/wyatt_app_template/brick.yaml | 2 +- bricks/wyatt_app_template/hooks/post_gen.dart | 2 +- .../__brick__/.vscode/extensions.json | 24 ------------ .../__brick__/.vscode/settings.json | 2 +- .../__brick__/analysis_options.yaml | 8 ++-- .../__brick__/pubspec.yaml | 7 ++-- bricks/wyatt_package_template/brick.yaml | 2 +- .../hooks/post_gen.dart | 12 ++++++ tools/build.sh | 39 +++++++++++++------ 23 files changed, 113 insertions(+), 125 deletions(-) delete mode 100644 apps/wyatt_package_template/wyatt_package_template/.vscode/extensions.json delete mode 100644 bricks/wyatt_package_template/__brick__/.vscode/extensions.json diff --git a/apps/wyatt_app_template/brickgen.yaml b/apps/wyatt_app_template/brickgen.yaml index e5a5666..9d7c417 100644 --- a/apps/wyatt_app_template/brickgen.yaml +++ b/apps/wyatt_app_template/brickgen.yaml @@ -17,7 +17,7 @@ name: wyatt_app_template description: New app template for Wyatt Studio projects. -version: 0.2.0 +version: 0.2.1 vars: display_name: diff --git a/apps/wyatt_app_template/hooks/post_gen.dart b/apps/wyatt_app_template/hooks/post_gen.dart index d9aa04f..eb54777 100644 --- a/apps/wyatt_app_template/hooks/post_gen.dart +++ b/apps/wyatt_app_template/hooks/post_gen.dart @@ -1,4 +1,4 @@ -// Copyright (C) 2022 WYATT GROUP +// Copyright (C) 2023 WYATT GROUP // Please see the AUTHORS file for details. // // This program is free software: you can redistribute it and/or modify diff --git a/apps/wyatt_app_template/starting_template/.vscode/settings.json b/apps/wyatt_app_template/starting_template/.vscode/settings.json index 364ffbc..05c8272 100644 --- a/apps/wyatt_app_template/starting_template/.vscode/settings.json +++ b/apps/wyatt_app_template/starting_template/.vscode/settings.json @@ -1,15 +1,16 @@ { - "bloc.newCubitTemplate.type": "equatable", - "psi-header.config": { - "blankLinesAfter": 0, - "forceToTop": true, - }, - "psi-header.templates": [ - { - "language": "*", - "template": [ - "Display Name Copyright (c) <>" - ] - } - ], -} \ No newline at end of file + "dart.runPubGetOnPubspecChanges": "never", + "bloc.newCubitTemplate.type": "equatable", + "psi-header.config": { + "blankLinesAfter": 0, + "forceToTop": true, + }, + "psi-header.templates": [ + { + "language": "*", + "template": [ + "Display Name Copyright (c) <>" + ] + } + ], +} diff --git a/apps/wyatt_app_template/starting_template/analysis_options.yaml b/apps/wyatt_app_template/starting_template/analysis_options.yaml index 91179f1..bd347ef 100644 --- a/apps/wyatt_app_template/starting_template/analysis_options.yaml +++ b/apps/wyatt_app_template/starting_template/analysis_options.yaml @@ -2,9 +2,9 @@ include: package:wyatt_analysis/analysis_options.flutter.yaml analyzer: plugins: - - dart_code_metrics + - dart_code_linter -dart_code_metrics: +dart_code_linter: anti-patterns: - long-method - long-parameter-list diff --git a/apps/wyatt_app_template/starting_template/pubspec.yaml b/apps/wyatt_app_template/starting_template/pubspec.yaml index 668d174..4efc88d 100644 --- a/apps/wyatt_app_template/starting_template/pubspec.yaml +++ b/apps/wyatt_app_template/starting_template/pubspec.yaml @@ -45,17 +45,14 @@ dependencies: dev_dependencies: build_runner: ^2.4.6 - dart_code_metrics: - git: - url: ssh://git@git.wyatt-studio.fr:993/Wyatt-FOSS/dart-code-metrics.git - ref: master + dart_code_linter: ^1.1.1 flutter_launcher_icons: ^0.13.1 freezed: ^2.4.2 json_serializable: ^6.7.1 flutter_test: sdk: flutter wyatt_analysis: - version: ^2.5.0 + version: ^2.6.1 hosted: name: wyatt_analysis url: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub/ diff --git a/apps/wyatt_package_template/brickgen.yaml b/apps/wyatt_package_template/brickgen.yaml index 9cd9090..acf3390 100644 --- a/apps/wyatt_package_template/brickgen.yaml +++ b/apps/wyatt_package_template/brickgen.yaml @@ -1,7 +1,7 @@ name: wyatt_package_template description: New package template for Wyatt Studio projects. -version: 0.2.0 +version: 0.2.1 vars: package_name: diff --git a/apps/wyatt_package_template/hooks/post_gen.dart b/apps/wyatt_package_template/hooks/post_gen.dart index babd1b7..0b7573b 100644 --- a/apps/wyatt_package_template/hooks/post_gen.dart +++ b/apps/wyatt_package_template/hooks/post_gen.dart @@ -35,5 +35,17 @@ void removeGitKeepFiles(String targetPath) { Future run(HookContext context) async { final workingDirectory = Directory.current.path; + + /// Remove .gitkeep files + print('Removing .gitkeep files'); removeGitKeepFiles(workingDirectory); + + /// dart pub get + print('Running `dart pub get`'); + await Process.run('dart', ['pub', 'get'], runInShell: true); + + /// dart format . --fix && dart fix . --apply + print('Running `dart format . --fix && dart fix . --apply`'); + await Process.run('dart', ['format', '.', '--fix'], runInShell: true); + await Process.run('dart', ['fix', '.', '--apply'], runInShell: true); } diff --git a/apps/wyatt_package_template/wyatt_package_template/.vscode/extensions.json b/apps/wyatt_package_template/wyatt_package_template/.vscode/extensions.json deleted file mode 100644 index 30cd223..0000000 --- a/apps/wyatt_package_template/wyatt_package_template/.vscode/extensions.json +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (C) 2022 WYATT GROUP - * Please see the AUTHORS file for details. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -{ - "recommendations": [ - "psioniq.psi-header", - "blaugold.melos-code" - ] -} \ No newline at end of file diff --git a/apps/wyatt_package_template/wyatt_package_template/.vscode/settings.json b/apps/wyatt_package_template/wyatt_package_template/.vscode/settings.json index a729c46..a29d370 100644 --- a/apps/wyatt_package_template/wyatt_package_template/.vscode/settings.json +++ b/apps/wyatt_package_template/wyatt_package_template/.vscode/settings.json @@ -69,4 +69,4 @@ ], } ], -} \ No newline at end of file +} diff --git a/apps/wyatt_package_template/wyatt_package_template/analysis_options.yaml b/apps/wyatt_package_template/wyatt_package_template/analysis_options.yaml index 02a0546..f062210 100644 --- a/apps/wyatt_package_template/wyatt_package_template/analysis_options.yaml +++ b/apps/wyatt_package_template/wyatt_package_template/analysis_options.yaml @@ -7,17 +7,17 @@ include: package:wyatt_analysis/analysis_options.yaml analyzer: plugins: - - dart_code_metrics + - dart_code_linter -dart_code_metrics: +dart_code_linter: anti-patterns: - long-method - long-parameter-list metrics: cyclomatic-complexity: 20 maximum-nesting-level: 5 - number-of-parameters: 4 - source-lines-of-code: 50 + number-of-parameters: 10 + source-lines-of-code: 400 metrics-exclude: - test/** rules: diff --git a/apps/wyatt_package_template/wyatt_package_template/pubspec.yaml b/apps/wyatt_package_template/wyatt_package_template/pubspec.yaml index fde17b4..265625b 100644 --- a/apps/wyatt_package_template/wyatt_package_template/pubspec.yaml +++ b/apps/wyatt_package_template/wyatt_package_template/pubspec.yaml @@ -4,7 +4,7 @@ repository: https://git.wyatt-studio.fr/Wyatt-FOSS/wyatt-packages/src/branch/mas version: 1.0.0 environment: - sdk: ">=2.19.0 <3.0.0" + sdk: ">=3.0.0 <4.0.0" dependencies: ### {{#flutter}} @@ -16,16 +16,16 @@ dev_dependencies: ### {{#flutter}} ### flutter_test: { sdk: flutter } ### {{/flutter}} - dart_code_metrics: ^5.5.1 + dart_code_linter: ^1.1.1 ### {{^flutter}} test: ^1.21.0 ### {{/flutter}} wyatt_analysis: hosted: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub - version: ^2.4.0 + version: ^2.6.1 ###{{#flutter}} #### The following section is specific to Flutter. ###flutter: ### uses-material-design: true -###{{/flutter}} \ No newline at end of file +###{{/flutter}} diff --git a/bricks/wyatt_app_template/__brick__/.vscode/settings.json b/bricks/wyatt_app_template/__brick__/.vscode/settings.json index ee6d931..664fe24 100644 --- a/bricks/wyatt_app_template/__brick__/.vscode/settings.json +++ b/bricks/wyatt_app_template/__brick__/.vscode/settings.json @@ -1,15 +1,16 @@ { - "bloc.newCubitTemplate.type": "equatable", - "psi-header.config": { - "blankLinesAfter": 0, - "forceToTop": true, - }, - "psi-header.templates": [ - { - "language": "*", - "template": [ - "{{#titleCase}}{{display_name}}{{/titleCase}} Copyright (c) <>" - ] - } - ], -} \ No newline at end of file + "dart.runPubGetOnPubspecChanges": "never", + "bloc.newCubitTemplate.type": "equatable", + "psi-header.config": { + "blankLinesAfter": 0, + "forceToTop": true, + }, + "psi-header.templates": [ + { + "language": "*", + "template": [ + "{{#titleCase}}{{display_name}}{{/titleCase}} Copyright (c) <>" + ] + } + ], +} diff --git a/bricks/wyatt_app_template/__brick__/analysis_options.yaml b/bricks/wyatt_app_template/__brick__/analysis_options.yaml index 91179f1..bd347ef 100644 --- a/bricks/wyatt_app_template/__brick__/analysis_options.yaml +++ b/bricks/wyatt_app_template/__brick__/analysis_options.yaml @@ -2,9 +2,9 @@ include: package:wyatt_analysis/analysis_options.flutter.yaml analyzer: plugins: - - dart_code_metrics + - dart_code_linter -dart_code_metrics: +dart_code_linter: anti-patterns: - long-method - long-parameter-list diff --git a/bricks/wyatt_app_template/__brick__/pubspec.yaml b/bricks/wyatt_app_template/__brick__/pubspec.yaml index b9be981..2454d01 100644 --- a/bricks/wyatt_app_template/__brick__/pubspec.yaml +++ b/bricks/wyatt_app_template/__brick__/pubspec.yaml @@ -45,17 +45,14 @@ dependencies: dev_dependencies: build_runner: ^2.4.6 - dart_code_metrics: - git: - url: ssh://git@git.wyatt-studio.fr:993/Wyatt-FOSS/dart-code-metrics.git - ref: master + dart_code_linter: ^1.1.1 flutter_launcher_icons: ^0.13.1 freezed: ^2.4.2 json_serializable: ^6.7.1 flutter_test: sdk: flutter wyatt_analysis: - version: ^2.5.0 + version: ^2.6.1 hosted: name: wyatt_analysis url: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub/ diff --git a/bricks/wyatt_app_template/brick.yaml b/bricks/wyatt_app_template/brick.yaml index 284d3e3..d184f99 100644 --- a/bricks/wyatt_app_template/brick.yaml +++ b/bricks/wyatt_app_template/brick.yaml @@ -1,7 +1,7 @@ name: wyatt_app_template description: New app template for Wyatt Studio projects. -version: 0.2.0 +version: 0.2.1 vars: display_name: diff --git a/bricks/wyatt_app_template/hooks/post_gen.dart b/bricks/wyatt_app_template/hooks/post_gen.dart index d9aa04f..eb54777 100644 --- a/bricks/wyatt_app_template/hooks/post_gen.dart +++ b/bricks/wyatt_app_template/hooks/post_gen.dart @@ -1,4 +1,4 @@ -// Copyright (C) 2022 WYATT GROUP +// Copyright (C) 2023 WYATT GROUP // Please see the AUTHORS file for details. // // This program is free software: you can redistribute it and/or modify diff --git a/bricks/wyatt_package_template/__brick__/.vscode/extensions.json b/bricks/wyatt_package_template/__brick__/.vscode/extensions.json deleted file mode 100644 index 30cd223..0000000 --- a/bricks/wyatt_package_template/__brick__/.vscode/extensions.json +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (C) 2022 WYATT GROUP - * Please see the AUTHORS file for details. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -{ - "recommendations": [ - "psioniq.psi-header", - "blaugold.melos-code" - ] -} \ No newline at end of file diff --git a/bricks/wyatt_package_template/__brick__/.vscode/settings.json b/bricks/wyatt_package_template/__brick__/.vscode/settings.json index a729c46..a29d370 100644 --- a/bricks/wyatt_package_template/__brick__/.vscode/settings.json +++ b/bricks/wyatt_package_template/__brick__/.vscode/settings.json @@ -69,4 +69,4 @@ ], } ], -} \ No newline at end of file +} diff --git a/bricks/wyatt_package_template/__brick__/analysis_options.yaml b/bricks/wyatt_package_template/__brick__/analysis_options.yaml index c20b868..f694889 100644 --- a/bricks/wyatt_package_template/__brick__/analysis_options.yaml +++ b/bricks/wyatt_package_template/__brick__/analysis_options.yaml @@ -11,17 +11,17 @@ include: package:wyatt_analysis/analysis_options.yaml analyzer: plugins: - - dart_code_metrics + - dart_code_linter -dart_code_metrics: +dart_code_linter: anti-patterns: - long-method - long-parameter-list metrics: cyclomatic-complexity: 20 maximum-nesting-level: 5 - number-of-parameters: 4 - source-lines-of-code: 50 + number-of-parameters: 10 + source-lines-of-code: 400 metrics-exclude: - test/** rules: diff --git a/bricks/wyatt_package_template/__brick__/pubspec.yaml b/bricks/wyatt_package_template/__brick__/pubspec.yaml index 016bc21..93a689e 100644 --- a/bricks/wyatt_package_template/__brick__/pubspec.yaml +++ b/bricks/wyatt_package_template/__brick__/pubspec.yaml @@ -4,7 +4,7 @@ repository: https://git.wyatt-studio.fr/Wyatt-FOSS/wyatt-packages/src/branch/mas version: 1.0.0 environment: - sdk: ">=2.19.0 <3.0.0" + sdk: ">=3.0.0 <4.0.0" dependencies: {{#flutter}} @@ -20,7 +20,7 @@ dev_dependencies: {{/flutter}} - dart_code_metrics: ^5.5.1 + dart_code_linter: ^1.1.1 {{^flutter}} test: ^1.21.0 @@ -28,7 +28,7 @@ dev_dependencies: wyatt_analysis: hosted: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub - version: ^2.4.0 + version: ^2.6.1 {{#flutter}} # The following section is specific to Flutter. @@ -36,3 +36,4 @@ flutter: uses-material-design: true {{/flutter}} + diff --git a/bricks/wyatt_package_template/brick.yaml b/bricks/wyatt_package_template/brick.yaml index 78317d6..c268787 100644 --- a/bricks/wyatt_package_template/brick.yaml +++ b/bricks/wyatt_package_template/brick.yaml @@ -1,7 +1,7 @@ name: wyatt_package_template description: New package template for Wyatt Studio projects. -version: 0.2.0 +version: 0.2.1 vars: package_name: diff --git a/bricks/wyatt_package_template/hooks/post_gen.dart b/bricks/wyatt_package_template/hooks/post_gen.dart index babd1b7..0b7573b 100644 --- a/bricks/wyatt_package_template/hooks/post_gen.dart +++ b/bricks/wyatt_package_template/hooks/post_gen.dart @@ -35,5 +35,17 @@ void removeGitKeepFiles(String targetPath) { Future run(HookContext context) async { final workingDirectory = Directory.current.path; + + /// Remove .gitkeep files + print('Removing .gitkeep files'); removeGitKeepFiles(workingDirectory); + + /// dart pub get + print('Running `dart pub get`'); + await Process.run('dart', ['pub', 'get'], runInShell: true); + + /// dart format . --fix && dart fix . --apply + print('Running `dart format . --fix && dart fix . --apply`'); + await Process.run('dart', ['format', '.', '--fix'], runInShell: true); + await Process.run('dart', ['fix', '.', '--apply'], runInShell: true); } diff --git a/tools/build.sh b/tools/build.sh index 97b7f51..14a784a 100755 --- a/tools/build.sh +++ b/tools/build.sh @@ -1,31 +1,46 @@ -#!/usr/bin/env sh +#!/usr/bin/env bash # Copyright (C) 2023 WYATT GROUP # Please see the AUTHORS file for details. -# +# # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # any later version. -# +# # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -# +# # You should have received a copy of the GNU General Public License # along with this program. If not, see . -# This tool is used to build all bricks. Execute this script from the -# root of the project. +# This tool is used to build all bricks. + +SCRIPT=$(readlink -f "$0") +SCRIPTPATH=$(dirname "$SCRIPT") + +# Go to the brick generator directory +cd $SCRIPTPATH/brick_generator + +# Build the brick generator +echo "🍺 Building brick generator" +dart pub get +mkdir -p ./build +dart compile exe ./bin/brickgen.dart -o ./build/brickgen + +# Go to the root directory +cd $SCRIPTPATH/.. # List all folders in apps folder -for d in ./apps/*/ -do +app_lst=$(ls -d ./apps/* | cut -f3 -d'/') + +# Build all bricks +for app in $app_lst; do # Get the name of the folder - name=${d%*/} - name=${name##*/} - # Build the brick + name=$(basename $app) echo "🍺 Building $name" - dart ./tools/brick_generator/bin/brickgen.dart ./apps/$name/ ./bricks/ + # Build the brick + ./tools/brick_generator/build/brickgen ./apps/$name/ ./bricks/ done