From 7cea909470ce75b91840f479649b93f953ded596 Mon Sep 17 00:00:00 2001 From: Hugo Pointcheval Date: Fri, 10 Feb 2023 10:12:03 +0100 Subject: [PATCH] feat: add new brick for ui_component --- apps/wyatt_component_template/brickgen.yaml | 25 +++++++ .../hooks/post_gen.dart | 39 +++++++++++ .../hooks/pubspec.yaml | 7 ++ .../wyatt_component_template/README.md | 3 + .../lib/ui_kit_component_name.dart | 20 ++++++ .../lib/ui_kit_component_name.g.dart | 70 +++++++++++++++++++ .../wyatt_component_template/pubspec.yaml | 30 ++++++++ ...{{ui_kit_component_name.snakeCase()}}.dart | 20 ++++++ bricks/wyatt_component_template/brick.yaml | 18 +++++ .../hooks/post_gen.dart | 39 +++++++++++ .../hooks/pubspec.yaml | 7 ++ mason.yaml | 4 +- 12 files changed, 281 insertions(+), 1 deletion(-) create mode 100644 apps/wyatt_component_template/brickgen.yaml create mode 100644 apps/wyatt_component_template/hooks/post_gen.dart create mode 100644 apps/wyatt_component_template/hooks/pubspec.yaml create mode 100644 apps/wyatt_component_template/wyatt_component_template/README.md create mode 100644 apps/wyatt_component_template/wyatt_component_template/lib/ui_kit_component_name.dart create mode 100644 apps/wyatt_component_template/wyatt_component_template/lib/ui_kit_component_name.g.dart create mode 100644 apps/wyatt_component_template/wyatt_component_template/pubspec.yaml create mode 100644 bricks/wyatt_component_template/__brick__/{{ui_kit_component_name.snakeCase()}}.dart create mode 100644 bricks/wyatt_component_template/brick.yaml create mode 100644 bricks/wyatt_component_template/hooks/post_gen.dart create mode 100644 bricks/wyatt_component_template/hooks/pubspec.yaml diff --git a/apps/wyatt_component_template/brickgen.yaml b/apps/wyatt_component_template/brickgen.yaml new file mode 100644 index 0000000..ceb8648 --- /dev/null +++ b/apps/wyatt_component_template/brickgen.yaml @@ -0,0 +1,25 @@ +name: wyatt_component_template +description: Component with Copy-with annotation. + +version: 0.1.0 + +vars: + ui_kit_component_name: + compilable: UiKitComponentName + type: string + description: The name used in this UI Kit. + default: UiKitComponentName + prompt: "What is the name used in this UI Kit?" + + wyatt_ui_component_name: + compilable: InformationCardComponent + type: string + description: The name of the parent widget defined in `wyatt_ui_component` + default: InformationCardComponent + prompt: "What is the name of the parent widget defined in `wyatt_ui_component`?" + +brickgen: + path_to_brickify: wyatt_component_template/lib + hooks: true + ignore: + - ui_kit_component_name.g.dart \ No newline at end of file diff --git a/apps/wyatt_component_template/hooks/post_gen.dart b/apps/wyatt_component_template/hooks/post_gen.dart new file mode 100644 index 0000000..c37101c --- /dev/null +++ b/apps/wyatt_component_template/hooks/post_gen.dart @@ -0,0 +1,39 @@ +// 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 . + +import 'dart:io'; + +import 'package:mason/mason.dart'; + +void removeGitKeepFiles(String targetPath) { + if (!FileSystemEntity.isDirectorySync(targetPath)) { + throw ArgumentError('Target must be a directory', 'targetPath'); + } + + Directory(targetPath) + .listSync(recursive: true) + .whereType() + .forEach((file) { + if (file.path.contains('.gitkeep')) { + file.deleteSync(recursive: true); + } + }); +} + +Future run(HookContext context) async { + final workingDirectory = Directory.current.path; + removeGitKeepFiles(workingDirectory); +} diff --git a/apps/wyatt_component_template/hooks/pubspec.yaml b/apps/wyatt_component_template/hooks/pubspec.yaml new file mode 100644 index 0000000..454f6df --- /dev/null +++ b/apps/wyatt_component_template/hooks/pubspec.yaml @@ -0,0 +1,7 @@ +name: hooks + +environment: + sdk: ">=2.18.0 <3.0.0" + +dependencies: + mason: any \ No newline at end of file diff --git a/apps/wyatt_component_template/wyatt_component_template/README.md b/apps/wyatt_component_template/wyatt_component_template/README.md new file mode 100644 index 0000000..8c74374 --- /dev/null +++ b/apps/wyatt_component_template/wyatt_component_template/README.md @@ -0,0 +1,3 @@ +# display_name + +Brick generated with `Brickgen`. \ No newline at end of file diff --git a/apps/wyatt_component_template/wyatt_component_template/lib/ui_kit_component_name.dart b/apps/wyatt_component_template/wyatt_component_template/lib/ui_kit_component_name.dart new file mode 100644 index 0000000..2e941b9 --- /dev/null +++ b/apps/wyatt_component_template/wyatt_component_template/lib/ui_kit_component_name.dart @@ -0,0 +1,20 @@ +import 'package:flutter/widgets.dart'; +import 'package:wyatt_component_copy_with_extension/component_copy_with_extension.dart'; +import 'package:wyatt_ui_components/wyatt_wyatt_ui_components.dart'; + +part 'ui_kit_component_name.g.dart'; + +@ComponentCopyWithExtension() +class UiKitComponentName extends InformationCardComponent + with $UiKitComponentNameCWMixin { + + const UiKitComponentName({ + super.key, + }); + + @override + Widget build(BuildContext context) { + // TODO: implement build + throw UnimplementedError(); + } +} diff --git a/apps/wyatt_component_template/wyatt_component_template/lib/ui_kit_component_name.g.dart b/apps/wyatt_component_template/wyatt_component_template/lib/ui_kit_component_name.g.dart new file mode 100644 index 0000000..ad4e719 --- /dev/null +++ b/apps/wyatt_component_template/wyatt_component_template/lib/ui_kit_component_name.g.dart @@ -0,0 +1,70 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'ui_kit_component_name.dart'; + +// ************************************************************************** +// ComponentCopyWithGenerator +// ************************************************************************** + +class $UiKitComponentNameCWProxyImpl + implements $InformationCardComponentCWProxy { + const $UiKitComponentNameCWProxyImpl(this._value); + final UiKitComponentName _value; + @override + UiKitComponentName icons(List? icons) => this(icons: icons); + @override + UiKitComponentName title(TextWrapper? title) => this(title: title); + @override + UiKitComponentName subtitle(TextWrapper? subtitle) => + this(subtitle: subtitle); + @override + UiKitComponentName body(TextWrapper? body) => this(body: body); + @override + UiKitComponentName axis(Axis? axis) => this(axis: axis); + @override + UiKitComponentName radius(double? radius) => this(radius: radius); + @override + UiKitComponentName padding(double? padding) => this(padding: padding); + @override + UiKitComponentName borderColors(List? borderColors) => + this(borderColors: borderColors); + @override + UiKitComponentName backgroundColor(Color? backgroundColor) => + this(backgroundColor: backgroundColor); + @override + UiKitComponentName minSize(Size? minSize) => this(minSize: minSize); + @override + UiKitComponentName maxSize(Size? maxSize) => this(maxSize: maxSize); + @override + UiKitComponentName shadow(BoxShadow? shadow) => this(shadow: shadow); + @override + UiKitComponentName background(Widget? background) => + this(background: background); + @override + UiKitComponentName key(Key? key) => this(key: key); + @override + UiKitComponentName call({ + List? icons, + TextWrapper? title, + TextWrapper? subtitle, + TextWrapper? body, + Axis? axis, + double? radius, + double? padding, + List? borderColors, + Color? backgroundColor, + Size? minSize, + Size? maxSize, + BoxShadow? shadow, + Widget? background, + Key? key, + }) => + UiKitComponentName( + key: key ?? _value.key, + ); +} + +mixin $UiKitComponentNameCWMixin on Component { + $InformationCardComponentCWProxy get copyWith => + $UiKitComponentNameCWProxyImpl(this as UiKitComponentName); +} diff --git a/apps/wyatt_component_template/wyatt_component_template/pubspec.yaml b/apps/wyatt_component_template/wyatt_component_template/pubspec.yaml new file mode 100644 index 0000000..d5f3b34 --- /dev/null +++ b/apps/wyatt_component_template/wyatt_component_template/pubspec.yaml @@ -0,0 +1,30 @@ +name: wyatt_component_template +description: Component with Copy-with annotation. + +version: 1.0.0 + +publish_to: none + +environment: + sdk: ">=2.19.0 <3.0.0" + +dependencies: + flutter: { sdk: flutter } + wyatt_component_copy_with_extension: + git: + url: ssh://git@git.wyatt-studio.fr:993/Wyatt-FOSS/wyatt-packages.git + path: packages/wyatt_component_copy_with_extension + wyatt_ui_components: + git: + url: ssh://git@git.wyatt-studio.fr:993/Wyatt-FOSS/wyatt-packages.git + path: packages/wyatt_ui_components + +dev_dependencies: + build_runner: ^2.3.3 + wyatt_analysis: + hosted: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub + version: ^2.4.0 + wyatt_component_copy_with_gen: + git: + url: ssh://git@git.wyatt-studio.fr:993/Wyatt-FOSS/wyatt-packages.git + path: packages/wyatt_component_copy_with_gen diff --git a/bricks/wyatt_component_template/__brick__/{{ui_kit_component_name.snakeCase()}}.dart b/bricks/wyatt_component_template/__brick__/{{ui_kit_component_name.snakeCase()}}.dart new file mode 100644 index 0000000..f7f41f2 --- /dev/null +++ b/bricks/wyatt_component_template/__brick__/{{ui_kit_component_name.snakeCase()}}.dart @@ -0,0 +1,20 @@ +import 'package:flutter/widgets.dart'; +import 'package:wyatt_component_copy_with_extension/component_copy_with_extension.dart'; +import 'package:wyatt_ui_components/wyatt_wyatt_ui_components.dart'; + +part '{{#snakeCase}}{{ui_kit_component_name}}{{/snakeCase}}.g.dart'; + +@ComponentCopyWithExtension() +class {{#pascalCase}}{{ui_kit_component_name}}{{/pascalCase}} extends {{#pascalCase}}{{wyatt_ui_component_name}}{{/pascalCase}} + with ${{#pascalCase}}{{ui_kit_component_name}}{{/pascalCase}}CWMixin { + + const {{#pascalCase}}{{ui_kit_component_name}}{{/pascalCase}}({ + super.key, + }); + + @override + Widget build(BuildContext context) { + // TODO: implement build + throw UnimplementedError(); + } +} diff --git a/bricks/wyatt_component_template/brick.yaml b/bricks/wyatt_component_template/brick.yaml new file mode 100644 index 0000000..ee9c9ed --- /dev/null +++ b/bricks/wyatt_component_template/brick.yaml @@ -0,0 +1,18 @@ +name: wyatt_component_template +description: Component with Copy-with annotation. + +version: 0.1.0 + +vars: + ui_kit_component_name: + type: string + description: The name used in this UI Kit. + default: UiKitComponentName + prompt: What is the name used in this UI Kit? + + wyatt_ui_component_name: + type: string + description: The name of the parent widget defined in `wyatt_ui_component` + default: InformationCardComponent + prompt: What is the name of the parent widget defined in `wyatt_ui_component`? + diff --git a/bricks/wyatt_component_template/hooks/post_gen.dart b/bricks/wyatt_component_template/hooks/post_gen.dart new file mode 100644 index 0000000..c37101c --- /dev/null +++ b/bricks/wyatt_component_template/hooks/post_gen.dart @@ -0,0 +1,39 @@ +// 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 . + +import 'dart:io'; + +import 'package:mason/mason.dart'; + +void removeGitKeepFiles(String targetPath) { + if (!FileSystemEntity.isDirectorySync(targetPath)) { + throw ArgumentError('Target must be a directory', 'targetPath'); + } + + Directory(targetPath) + .listSync(recursive: true) + .whereType() + .forEach((file) { + if (file.path.contains('.gitkeep')) { + file.deleteSync(recursive: true); + } + }); +} + +Future run(HookContext context) async { + final workingDirectory = Directory.current.path; + removeGitKeepFiles(workingDirectory); +} diff --git a/bricks/wyatt_component_template/hooks/pubspec.yaml b/bricks/wyatt_component_template/hooks/pubspec.yaml new file mode 100644 index 0000000..454f6df --- /dev/null +++ b/bricks/wyatt_component_template/hooks/pubspec.yaml @@ -0,0 +1,7 @@ +name: hooks + +environment: + sdk: ">=2.18.0 <3.0.0" + +dependencies: + mason: any \ No newline at end of file diff --git a/mason.yaml b/mason.yaml index 62dd13f..20ae928 100644 --- a/mason.yaml +++ b/mason.yaml @@ -6,4 +6,6 @@ bricks: wyatt_app_template: path: bricks/wyatt_app_template wyatt_package_template: - path: bricks/wyatt_package_template \ No newline at end of file + path: bricks/wyatt_package_template + wyatt_component_template: + path: bricks/wyatt_component_template \ No newline at end of file