From eefe8cb1715b9c01f0e0e3f351e03156be578430 Mon Sep 17 00:00:00 2001 From: Bryan Figueroa Date: Mon, 2 May 2022 17:49:01 -0600 Subject: [PATCH 01/24] Removed subsemantic field --- .../entities/layouts/group/frame_group.g.dart | 2 -- lib/interpret_and_optimize/entities/layouts/row.g.dart | 2 -- lib/interpret_and_optimize/entities/pb_shared_instance.g.dart | 2 -- .../entities/pb_shared_master_node.g.dart | 2 -- .../entities/subclasses/pb_intermediate_node.g.dart | 3 --- 5 files changed, 11 deletions(-) diff --git a/lib/interpret_and_optimize/entities/layouts/group/frame_group.g.dart b/lib/interpret_and_optimize/entities/layouts/group/frame_group.g.dart index 12844a62..f9c363e8 100644 --- a/lib/interpret_and_optimize/entities/layouts/group/frame_group.g.dart +++ b/lib/interpret_and_optimize/entities/layouts/group/frame_group.g.dart @@ -18,7 +18,6 @@ FrameGroup _$FrameGroupFromJson(Map json) { : PBIntermediateConstraints.fromJson( json['constraints'] as Map), ) - ..subsemantic = json['subsemantic'] as String ..layoutMainAxisSizing = _$enumDecodeNullable( _$ParentLayoutSizingEnumMap, json['layoutMainAxisSizing']) ..layoutCrossAxisSizing = _$enumDecodeNullable( @@ -32,7 +31,6 @@ FrameGroup _$FrameGroupFromJson(Map json) { Map _$FrameGroupToJson(FrameGroup instance) => { - 'subsemantic': instance.subsemantic, 'UUID': instance.UUID, 'constraints': instance.constraints, 'layoutMainAxisSizing': diff --git a/lib/interpret_and_optimize/entities/layouts/row.g.dart b/lib/interpret_and_optimize/entities/layouts/row.g.dart index 2cc89cb5..ec5de067 100644 --- a/lib/interpret_and_optimize/entities/layouts/row.g.dart +++ b/lib/interpret_and_optimize/entities/layouts/row.g.dart @@ -11,7 +11,6 @@ PBIntermediateRowLayout _$PBIntermediateRowLayoutFromJson( return PBIntermediateRowLayout( name: json['name'] as String, ) - ..subsemantic = json['subsemantic'] as String ..constraints = json['constraints'] == null ? null : PBIntermediateConstraints.fromJson( @@ -39,7 +38,6 @@ PBIntermediateRowLayout _$PBIntermediateRowLayoutFromJson( Map _$PBIntermediateRowLayoutToJson( PBIntermediateRowLayout instance) => { - 'subsemantic': instance.subsemantic, 'constraints': instance.constraints, 'layoutMainAxisSizing': _$ParentLayoutSizingEnumMap[instance.layoutMainAxisSizing], diff --git a/lib/interpret_and_optimize/entities/pb_shared_instance.g.dart b/lib/interpret_and_optimize/entities/pb_shared_instance.g.dart index c712029a..063737c0 100644 --- a/lib/interpret_and_optimize/entities/pb_shared_instance.g.dart +++ b/lib/interpret_and_optimize/entities/pb_shared_instance.g.dart @@ -22,7 +22,6 @@ PBSharedInstanceIntermediateNode _$PBSharedInstanceIntermediateNodeFromJson( name: json['name'] as String, sharedNodeSetID: json['sharedNodeSetID'] as String, ) - ..subsemantic = json['subsemantic'] as String ..constraints = json['constraints'] == null ? null : PBIntermediateConstraints.fromJson( @@ -41,7 +40,6 @@ PBSharedInstanceIntermediateNode _$PBSharedInstanceIntermediateNodeFromJson( Map _$PBSharedInstanceIntermediateNodeToJson( PBSharedInstanceIntermediateNode instance) => { - 'subsemantic': instance.subsemantic, 'UUID': instance.UUID, 'constraints': instance.constraints?.toJson(), 'layoutMainAxisSizing': diff --git a/lib/interpret_and_optimize/entities/pb_shared_master_node.g.dart b/lib/interpret_and_optimize/entities/pb_shared_master_node.g.dart index a39ac5e3..09277749 100644 --- a/lib/interpret_and_optimize/entities/pb_shared_master_node.g.dart +++ b/lib/interpret_and_optimize/entities/pb_shared_master_node.g.dart @@ -21,7 +21,6 @@ PBSharedMasterNode _$PBSharedMasterNodeFromJson(Map json) { componentSetName: json['componentSetName'] as String, sharedNodeSetID: json['sharedNodeSetID'] as String, ) - ..subsemantic = json['subsemantic'] as String ..layoutMainAxisSizing = _$enumDecodeNullable( _$ParentLayoutSizingEnumMap, json['layoutMainAxisSizing']) ..layoutCrossAxisSizing = _$enumDecodeNullable( @@ -35,7 +34,6 @@ PBSharedMasterNode _$PBSharedMasterNodeFromJson(Map json) { Map _$PBSharedMasterNodeToJson(PBSharedMasterNode instance) => { - 'subsemantic': instance.subsemantic, 'UUID': instance.UUID, 'constraints': instance.constraints?.toJson(), 'layoutMainAxisSizing': diff --git a/lib/interpret_and_optimize/entities/subclasses/pb_intermediate_node.g.dart b/lib/interpret_and_optimize/entities/subclasses/pb_intermediate_node.g.dart index 2d452eca..671d8efd 100644 --- a/lib/interpret_and_optimize/entities/subclasses/pb_intermediate_node.g.dart +++ b/lib/interpret_and_optimize/entities/subclasses/pb_intermediate_node.g.dart @@ -8,7 +8,6 @@ part of 'pb_intermediate_node.dart'; Map _$PBIntermediateNodeToJson(PBIntermediateNode instance) => { - 'subsemantic': instance.subsemantic, 'UUID': instance.UUID, 'constraints': instance.constraints?.toJson(), 'layoutMainAxisSizing': @@ -18,8 +17,6 @@ Map _$PBIntermediateNodeToJson(PBIntermediateNode instance) => 'boundaryRectangle': Rectangle3D.toJson(instance.frame), 'style': instance.auxiliaryData?.toJson(), 'name': instance.name, - 'hashCode': instance.hashCode, - 'id': instance.id, }; const _$ParentLayoutSizingEnumMap = { From 326d966eaedcb8da982fae2b2710a8f2b2e464aa Mon Sep 17 00:00:00 2001 From: Bryan Figueroa Date: Mon, 2 May 2022 17:49:22 -0600 Subject: [PATCH 02/24] Added alignment --- lib/interpret_and_optimize/entities/layouts/column.g.dart | 2 ++ .../entities/layouts/group/base_group.g.dart | 2 ++ 2 files changed, 4 insertions(+) diff --git a/lib/interpret_and_optimize/entities/layouts/column.g.dart b/lib/interpret_and_optimize/entities/layouts/column.g.dart index 2e933d6a..16df64d6 100644 --- a/lib/interpret_and_optimize/entities/layouts/column.g.dart +++ b/lib/interpret_and_optimize/entities/layouts/column.g.dart @@ -28,6 +28,7 @@ PBIntermediateColumnLayout _$PBIntermediateColumnLayoutFromJson( ..prototypeNode = json['prototypeNode'] == null ? null : PrototypeNode.fromJson(json['prototypeNode'] as Map) + ..alignment = json['alignment'] as Map ..layoutProperties = json['autoLayoutOptions'] == null ? null : LayoutProperties.fromJson( @@ -48,6 +49,7 @@ Map _$PBIntermediateColumnLayoutToJson( 'style': instance.auxiliaryData, 'name': instance.name, 'prototypeNode': instance.prototypeNode, + 'alignment': instance.alignment, 'autoLayoutOptions': instance.layoutProperties, 'type': instance.type, }; diff --git a/lib/interpret_and_optimize/entities/layouts/group/base_group.g.dart b/lib/interpret_and_optimize/entities/layouts/group/base_group.g.dart index fcd3d25b..23fc0dec 100644 --- a/lib/interpret_and_optimize/entities/layouts/group/base_group.g.dart +++ b/lib/interpret_and_optimize/entities/layouts/group/base_group.g.dart @@ -27,6 +27,7 @@ BaseGroup _$BaseGroupFromJson(Map json) { ? null : IntermediateAuxiliaryData.fromJson( json['style'] as Map) + ..alignment = json['alignment'] as Map ..type = json['type'] as String; } @@ -41,6 +42,7 @@ Map _$BaseGroupToJson(BaseGroup instance) => { 'boundaryRectangle': Rectangle3D.toJson(instance.frame), 'style': instance.auxiliaryData, 'name': instance.name, + 'alignment': instance.alignment, 'prototypeNodeUUID': instance.prototypeNode, 'type': instance.type, }; From 30ab334037e94e56be13ea9f50c4f7a1c8020104 Mon Sep 17 00:00:00 2001 From: Bryan Figueroa Date: Mon, 2 May 2022 17:49:39 -0600 Subject: [PATCH 03/24] Added folderArchitecture field --- lib/configurations/configurations.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/configurations/configurations.json b/lib/configurations/configurations.json index 0fe1183e..71bda2b8 100644 --- a/lib/configurations/configurations.json +++ b/lib/configurations/configurations.json @@ -4,5 +4,6 @@ "tablet": 600, "desktop": 1280 }, - "componentIsolation": "widgetbook" + "componentIsolation": "widgetbook", + "folderArchitecture": "domain" } From 219dbbed555fb037e4b5102b668374d9f73a1b37 Mon Sep 17 00:00:00 2001 From: Bryan Figueroa Date: Mon, 2 May 2022 17:49:49 -0600 Subject: [PATCH 04/24] Added getIt as dependency --- pubspec.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/pubspec.yaml b/pubspec.yaml index 260f1fcb..48c722a6 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -23,6 +23,7 @@ dependencies: tuple: ^2.0.0 path: ^1.6.0 file: ^6.1.2 + get_it: ^7.2.0 pbdl: git: url: https://github.com/Parabeac/pbdl.git From b137df91a6adb28cb5098d0769f0d5fddbb51d26 Mon Sep 17 00:00:00 2001 From: Bryan Figueroa Date: Mon, 2 May 2022 17:50:04 -0600 Subject: [PATCH 05/24] Added fodler architecture to configuration --- lib/interpret_and_optimize/helpers/pb_configuration.dart | 6 ++++++ lib/interpret_and_optimize/helpers/pb_configuration.g.dart | 2 ++ 2 files changed, 8 insertions(+) diff --git a/lib/interpret_and_optimize/helpers/pb_configuration.dart b/lib/interpret_and_optimize/helpers/pb_configuration.dart index 0f82d4aa..375fc260 100644 --- a/lib/interpret_and_optimize/helpers/pb_configuration.dart +++ b/lib/interpret_and_optimize/helpers/pb_configuration.dart @@ -55,6 +55,11 @@ class PBConfiguration { @JsonKey(defaultValue: 'None') final String componentIsolation; + /// The type of folder architecture that Parabeac-Core should follow + /// It will be domain, as default + @JsonKey(defaultValue: 'domain') + final String folderArchitecture; + PBConfiguration( // this.widgetStyle, // this.widgetType, @@ -65,6 +70,7 @@ class PBConfiguration { this.scaling, this.enablePrototyping, this.componentIsolation, + this.folderArchitecture, ); /// Converting the [json] into a [PBConfiguration] object. diff --git a/lib/interpret_and_optimize/helpers/pb_configuration.g.dart b/lib/interpret_and_optimize/helpers/pb_configuration.g.dart index e364051f..56cfcbc4 100644 --- a/lib/interpret_and_optimize/helpers/pb_configuration.g.dart +++ b/lib/interpret_and_optimize/helpers/pb_configuration.g.dart @@ -12,6 +12,7 @@ PBConfiguration _$PBConfigurationFromJson(Map json) { json['scaling'] as bool ?? true, json['enablePrototyping'] as bool ?? false, json['componentIsolation'] as String ?? 'None', + json['folderArchitecture'] as String ?? 'domain', ); } @@ -21,4 +22,5 @@ Map _$PBConfigurationToJson(PBConfiguration instance) => 'breakpoints': instance.breakpoints, 'enablePrototyping': instance.enablePrototyping, 'componentIsolation': instance.componentIsolation, + 'folderArchitecture': instance.folderArchitecture, }; From 23140e8e62ceb70eec46107ce45103134a36873c Mon Sep 17 00:00:00 2001 From: Bryan Figueroa Date: Mon, 2 May 2022 17:50:33 -0600 Subject: [PATCH 06/24] Clean mainInfo collecting information being done inside mainInfo --- lib/controllers/main_info.dart | 77 +++++++++++++++++++++++++++++- lib/main.dart | 85 ++++------------------------------ 2 files changed, 86 insertions(+), 76 deletions(-) diff --git a/lib/controllers/main_info.dart b/lib/controllers/main_info.dart index 62c179a9..c480ca27 100644 --- a/lib/controllers/main_info.dart +++ b/lib/controllers/main_info.dart @@ -1,7 +1,9 @@ +import 'dart:convert'; import 'dart:io'; - +import 'package:args/args.dart'; import 'package:parabeac_core/interpret_and_optimize/helpers/pb_configuration.dart'; import 'package:path/path.dart' as p; +import 'package:sentry/sentry.dart'; class MainInfo { static final MainInfo _singleton = MainInfo._internal(); @@ -96,6 +98,79 @@ class MainInfo { return p.normalize(p.absolute(path)); } + /// Populates the corresponding fields of the [MainInfo] object with the + /// corresponding [arguments]. + /// + /// Remember that [MainInfo] is a Singleton, therefore, nothing its going to + /// be return from the function. When you use [MainInfo] again, its going to + /// contain the proper values from [arguments] + void collectArguments(ArgResults arguments) { + var info = MainInfo(); + + info.configuration = + generateConfiguration(p.normalize(arguments['config-path'])); + + /// Detect platform + info.platform = Platform.operatingSystem; + + info.figmaOauthToken = arguments['oauth']; + info.figmaKey = arguments['figKey']; + info.figmaProjectID = arguments['fig']; + + info.designFilePath = arguments['path']; + if (arguments['pbdl-in'] != null) { + info.pbdlPath = arguments['pbdl-in']; + } + + info.designType = determineDesignTypeFromArgs(arguments); + info.exportStyles = !arguments['exclude-styles']; + info.projectName ??= arguments['project-name']; + + /// If outputPath is empty, assume we are outputting to design file path + info.outputPath = arguments['out'] ?? + p.dirname(info.designFilePath ?? Directory.current.path); + + info.exportPBDL = arguments['export-pbdl'] ?? false; + + /// In the future when we are generating certain dart files only. + /// At the moment we are only generating in the flutter project. + info.pngPath = p.join(info.genProjectPath, 'lib/assets/images'); + } + + /// Generating the [PBConfiguration] based in the configuration file in [path] + PBConfiguration generateConfiguration(String path) { + var configuration; + try { + ///SET CONFIGURATION + // Setting configurations globally + configuration = + PBConfiguration.fromJson(json.decode(File(path).readAsStringSync())); + } catch (e, stackTrace) { + Sentry.captureException(e, stackTrace: stackTrace); + } + configuration ??= PBConfiguration.genericConfiguration(); + return configuration; + } + + /// Determine the [MainInfo.designType] from the [arguments] + /// + /// If [arguments] include `figKey` or `fig`, that implies that [MainInfo.designType] + /// should be [DesignType.FIGMA]. If there is a `path`, then the [MainInfo.designType] + /// should be [DesignType.SKETCH]. Otherwise, if it includes the flag `pndl-in`, the type + /// is [DesignType.PBDL].Finally, if none of the [DesignType] applies, its going to default + /// to [DesignType.UNKNOWN]. + DesignType determineDesignTypeFromArgs(ArgResults arguments) { + if ((arguments['figKey'] != null || arguments['oauth'] != null) && + arguments['fig'] != null) { + return DesignType.FIGMA; + } else if (arguments['path'] != null) { + return DesignType.SKETCH; + } else if (arguments['pbdl-in'] != null) { + return DesignType.PBDL; + } + return DesignType.UNKNOWN; + } + factory MainInfo() { return _singleton; } diff --git a/lib/main.dart b/lib/main.dart index f0ce2b10..9270ba67 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,17 +1,18 @@ import 'dart:async'; import 'dart:convert'; import 'dart:io'; +import 'package:get_it/get_it.dart'; import 'package:parabeac_core/analytics/analytics_constants.dart'; import 'package:parabeac_core/analytics/sentry_analytics_service.dart'; import 'package:parabeac_core/generation/flutter_project_builder/post_gen_tasks/comp_isolation/isolation_post_gen_task.dart'; import 'package:parabeac_core/generation/generators/util/pb_generation_view_data.dart'; +import 'package:parabeac_core/generation/generators/value_objects/file_structure_strategy/path_service.dart'; import 'package:parabeac_core/interpret_and_optimize/entities/pb_shared_master_node.dart'; import 'package:parabeac_core/controllers/main_info.dart'; import 'package:parabeac_core/generation/flutter_project_builder/file_system_analyzer.dart'; import 'package:parabeac_core/generation/flutter_project_builder/flutter_project_builder.dart'; import 'package:parabeac_core/interpret_and_optimize/entities/subclasses/pb_intermediate_constraints.dart'; import 'package:parabeac_core/interpret_and_optimize/helpers/component_isolation_configuration.dart'; -import 'package:parabeac_core/interpret_and_optimize/helpers/pb_configuration.dart'; import 'package:parabeac_core/interpret_and_optimize/helpers/pb_context.dart'; import 'package:parabeac_core/interpret_and_optimize/helpers/pb_intermediate_node_tree.dart'; import 'package:parabeac_core/interpret_and_optimize/helpers/pb_plugin_list_helper.dart'; @@ -127,7 +128,14 @@ ${parser.usage} 'Too many arguments: Please provide either the path to Sketch file or the Figma File ID and API Key'); } - collectArguments(argResults); + /// Pass MainInfo the argument results + /// so it can interpret and store them for later use + MainInfo().collectArguments(argResults); + + /// Register the PathService singleton + /// for PBC to know in the future the type of architecture + GetIt.I.registerSingleton(PathService.fromConfiguration( + MainInfo().configuration.folderArchitecture)); var processInfo = MainInfo(); if (processInfo.designType == DesignType.UNKNOWN) { @@ -351,64 +359,6 @@ Future> treeHasMaster(PBIntermediateTree tree) async { return forest; } -/// Populates the corresponding fields of the [MainInfo] object with the -/// corresponding [arguments]. -/// -/// Remember that [MainInfo] is a Singleton, therefore, nothing its going to -/// be return from the function. When you use [MainInfo] again, its going to -/// contain the proper values from [arguments] -void collectArguments(ArgResults arguments) { - var info = MainInfo(); - - info.configuration = - generateConfiguration(p.normalize(arguments['config-path'])); - - /// Detect platform - info.platform = Platform.operatingSystem; - - info.figmaOauthToken = arguments['oauth']; - info.figmaKey = arguments['figKey']; - info.figmaProjectID = arguments['fig']; - - info.designFilePath = arguments['path']; - if (arguments['pbdl-in'] != null) { - info.pbdlPath = arguments['pbdl-in']; - } - - info.designType = determineDesignTypeFromArgs(arguments); - info.exportStyles = !arguments['exclude-styles']; - info.projectName ??= arguments['project-name']; - - /// If outputPath is empty, assume we are outputting to design file path - info.outputPath = arguments['out'] ?? - p.dirname(info.designFilePath ?? Directory.current.path); - - info.exportPBDL = arguments['export-pbdl'] ?? false; - - /// In the future when we are generating certain dart files only. - /// At the moment we are only generating in the flutter project. - info.pngPath = p.join(info.genProjectPath, 'lib/assets/images'); -} - -/// Determine the [MainInfo.designType] from the [arguments] -/// -/// If [arguments] include `figKey` or `fig`, that implies that [MainInfo.designType] -/// should be [DesignType.FIGMA]. If there is a `path`, then the [MainInfo.designType] -/// should be [DesignType.SKETCH]. Otherwise, if it includes the flag `pndl-in`, the type -/// is [DesignType.PBDL].Finally, if none of the [DesignType] applies, its going to default -/// to [DesignType.UNKNOWN]. -DesignType determineDesignTypeFromArgs(ArgResults arguments) { - if ((arguments['figKey'] != null || arguments['oauth'] != null) && - arguments['fig'] != null) { - return DesignType.FIGMA; - } else if (arguments['path'] != null) { - return DesignType.SKETCH; - } else if (arguments['pbdl-in'] != null) { - return DesignType.PBDL; - } - return DesignType.UNKNOWN; -} - /// Checks whether a configuration file is made already, /// and makes one if necessary Future checkConfigFile() async { @@ -432,21 +382,6 @@ Future checkConfigFile() async { addToAmplitude(); } -/// Generating the [PBConfiguration] based in the configuration file in [path] -PBConfiguration generateConfiguration(String path) { - var configuration; - try { - ///SET CONFIGURATION - // Setting configurations globally - configuration = - PBConfiguration.fromJson(json.decode(File(path).readAsStringSync())); - } catch (e, stackTrace) { - Sentry.captureException(e, stackTrace: stackTrace); - } - configuration ??= PBConfiguration.genericConfiguration(); - return configuration; -} - /// Gets the homepath of the user according to their OS String getHomePath() { var envvars = Platform.environment; From 621bb451178bbc73ddf7d327d4d0bf4309d8d02e Mon Sep 17 00:00:00 2001 From: Bryan Figueroa Date: Mon, 2 May 2022 17:50:46 -0600 Subject: [PATCH 07/24] Created PathService abstract class --- .../file_structure_strategy/path_service.dart | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 lib/generation/generators/value_objects/file_structure_strategy/path_service.dart diff --git a/lib/generation/generators/value_objects/file_structure_strategy/path_service.dart b/lib/generation/generators/value_objects/file_structure_strategy/path_service.dart new file mode 100644 index 00000000..5429c36f --- /dev/null +++ b/lib/generation/generators/value_objects/file_structure_strategy/path_service.dart @@ -0,0 +1,21 @@ +abstract class PathService { + PathService(); + + factory PathService.fromConfiguration(String architecture) { + if (architecture.toLowerCase() == 'domain') { + return DomainPathService(); + } + + /// If no architecture is set + /// we will return DomainPathService as default + return DomainPathService(); + } +} + +class DomainPathService extends PathService { + static final String viewsRelativePath = 'lib/views'; + static final String widgetsRelativePath = 'lib/widgets'; + static final String customrelativePath = '$widgetsRelativePath/custom'; + + DomainPathService() : super(); +} From ecb3eec2d0f9aa922f151b023ad4879ec921b1ad Mon Sep 17 00:00:00 2001 From: Bryan Figueroa Date: Mon, 2 May 2022 18:10:35 -0600 Subject: [PATCH 08/24] Redesign path service --- .../file_structure_strategy/path_service.dart | 30 +++++++++++++++---- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/lib/generation/generators/value_objects/file_structure_strategy/path_service.dart b/lib/generation/generators/value_objects/file_structure_strategy/path_service.dart index 5429c36f..040ab7b5 100644 --- a/lib/generation/generators/value_objects/file_structure_strategy/path_service.dart +++ b/lib/generation/generators/value_objects/file_structure_strategy/path_service.dart @@ -1,5 +1,12 @@ abstract class PathService { - PathService(); + final String viewsRelativePath; + final String widgetsRelativePath; + final String customRelativePath; + PathService( + this.viewsRelativePath, + this.widgetsRelativePath, + this.customRelativePath, + ); factory PathService.fromConfiguration(String architecture) { if (architecture.toLowerCase() == 'domain') { @@ -13,9 +20,22 @@ abstract class PathService { } class DomainPathService extends PathService { - static final String viewsRelativePath = 'lib/views'; - static final String widgetsRelativePath = 'lib/widgets'; - static final String customrelativePath = '$widgetsRelativePath/custom'; + static String viewsPath = 'lib/views'; - DomainPathService() : super(); + @override + final String viewsRelativePath = '$viewsPath'; + @override + final String widgetsRelativePath = 'lib/widgets'; + @override + final String customRelativePath = '$viewsPath/custom'; + + DomainPathService({ + String viewsRelativePath, + String widgetsRelativePath, + String customRelativePath, + }) : super( + viewsRelativePath, + widgetsRelativePath, + customRelativePath, + ); } From 41e26c180e19e19043ac5b1374a05ca96d0c6869 Mon Sep 17 00:00:00 2001 From: Bryan Figueroa Date: Tue, 3 May 2022 13:25:09 -0600 Subject: [PATCH 09/24] Changed writeSymbol command default path --- .../commands/write_symbol_command.dart | 26 +++++++++++-------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/lib/generation/generators/value_objects/file_structure_strategy/commands/write_symbol_command.dart b/lib/generation/generators/value_objects/file_structure_strategy/commands/write_symbol_command.dart index 42ebca2d..b2236467 100644 --- a/lib/generation/generators/value_objects/file_structure_strategy/commands/write_symbol_command.dart +++ b/lib/generation/generators/value_objects/file_structure_strategy/commands/write_symbol_command.dart @@ -1,35 +1,39 @@ +import 'package:get_it/get_it.dart'; import 'package:parabeac_core/generation/generators/value_objects/file_structure_strategy/file_ownership_policy.dart'; +import 'package:parabeac_core/generation/generators/value_objects/file_structure_strategy/path_service.dart'; import 'package:path/path.dart' as p; import 'package:parabeac_core/generation/generators/value_objects/file_structure_strategy/commands/node_file_structure_command.dart'; import 'package:parabeac_core/generation/generators/value_objects/file_structure_strategy/pb_file_structure_strategy.dart'; /// Command that writes a `symbol` to the project. class WriteSymbolCommand extends NodeFileStructureCommand { - static const String DEFAULT_SYMBOL_PATH = 'lib/widgets'; + static String DEFAULT_SYMBOL_PATH = + GetIt.I.get().widgetsRelativePath; - final String symbolPath; + String symbolPath; String fileName; /// The [relativePath] within the [symbolPath] /// /// For example, you are looking for `lib/widgets/some_element/element.dart`, /// then the [relativePath] would be `some_element/` and the [fileName] would be `element.dart`. - String relativePath; + // String relativePath; - WriteSymbolCommand(String UUID, this.fileName, String code, - {this.relativePath = '', - this.symbolPath = DEFAULT_SYMBOL_PATH, - FileOwnership ownership = FileOwnership.PBC}) - : super(UUID, code, ownership); + WriteSymbolCommand( + String UUID, + this.fileName, + String code, { + this.symbolPath = '', + FileOwnership ownership = FileOwnership.PBC, + }) : super(UUID, code, ownership); /// Writes a symbol file containing [generationViewData] with [fileName] as its filename. /// /// Returns path to the file that was created. @override Future write(FileStructureStrategy strategy) { - var absPath = relativePath.isEmpty - ? p.join(strategy.GENERATED_PROJECT_PATH, symbolPath) - : p.join(strategy.GENERATED_PROJECT_PATH, symbolPath, relativePath); + symbolPath = symbolPath.isEmpty ? DEFAULT_SYMBOL_PATH : symbolPath; + var absPath = p.join(strategy.GENERATED_PROJECT_PATH, symbolPath); strategy.writeDataToFile(code, absPath, fileName, UUID: UUID, ownership: ownership); From 48f08d01e3b3f3bca4a883f59c5c2ef1cf2d0b51 Mon Sep 17 00:00:00 2001 From: Bryan Figueroa Date: Tue, 3 May 2022 13:25:30 -0600 Subject: [PATCH 10/24] Updated affected middleware directories --- .../middleware/command_gen_middleware.dart | 2 +- .../state_management/bloc_middleware.dart | 4 ++-- .../state_management/provider_middleware.dart | 14 +++++++++----- .../state_management/riverpod_middleware.dart | 14 +++++++++----- .../state_management/stateful_middleware.dart | 3 ++- 5 files changed, 23 insertions(+), 14 deletions(-) diff --git a/lib/generation/generators/middleware/command_gen_middleware.dart b/lib/generation/generators/middleware/command_gen_middleware.dart index 827593af..05023f72 100644 --- a/lib/generation/generators/middleware/command_gen_middleware.dart +++ b/lib/generation/generators/middleware/command_gen_middleware.dart @@ -75,7 +75,7 @@ class CommandGenMiddleware extends Middleware tree.UUID, tree.identifier, generationManager.generate(tree.rootNode, context), - relativePath: relativePath, + symbolPath: WriteSymbolCommand.DEFAULT_SYMBOL_PATH + relativePath, ); } if (command != null) { diff --git a/lib/generation/generators/middleware/state_management/bloc_middleware.dart b/lib/generation/generators/middleware/state_management/bloc_middleware.dart index dfd3047e..3a4fa6e1 100644 --- a/lib/generation/generators/middleware/state_management/bloc_middleware.dart +++ b/lib/generation/generators/middleware/state_management/bloc_middleware.dart @@ -193,14 +193,14 @@ class BLoCMiddleware extends StateManagementMiddleware { tree.UUID, state.name.snakeCase, tree.context.generationManager.generate(state, tree.context), - relativePath: generalName, + symbolPath: WriteSymbolCommand.DEFAULT_SYMBOL_PATH + generalName, )); }); // Generate default node's view page fileStrategy.commandCreated(WriteSymbolCommand('${context.tree.UUID}', node.name.snakeCase, generationManager.generate(node, context), - relativePath: generalName)); + symbolPath: WriteSymbolCommand.DEFAULT_SYMBOL_PATH + generalName)); /// Creates cubit page context.managerData.addImport(FlutterImport('meta.dart', 'meta')); diff --git a/lib/generation/generators/middleware/state_management/provider_middleware.dart b/lib/generation/generators/middleware/state_management/provider_middleware.dart index 7e3e82da..5a15cd5e 100644 --- a/lib/generation/generators/middleware/state_management/provider_middleware.dart +++ b/lib/generation/generators/middleware/state_management/provider_middleware.dart @@ -105,7 +105,8 @@ class ProviderMiddleware extends StateManagementMiddleware { } watcherName = getNameOfNode(node); - var parentDirectory = ImportHelper.getName(node.name).snakeCase; + var parentDirectory = WriteSymbolCommand.DEFAULT_SYMBOL_PATH + + ImportHelper.getName(node.name).snakeCase; // Generate model's imports var modelGenerator = PBFlutterGenerator(ImportHelper(), @@ -125,9 +126,12 @@ class ProviderMiddleware extends StateManagementMiddleware { ownership: FileOwnership.DEV, ), // Generate default node's view page - WriteSymbolCommand(context.tree.UUID, node.name.snakeCase, - generationManager.generate(node, context), - relativePath: parentDirectory), + WriteSymbolCommand( + context.tree.UUID, + node.name.snakeCase, + generationManager.generate(node, context), + symbolPath: parentDirectory, + ), ].forEach(fileStrategy.commandCreated); (configuration as ProviderGenerationConfiguration) @@ -150,7 +154,7 @@ class ProviderMiddleware extends StateManagementMiddleware { tree.UUID, state.name.snakeCase, tree.context.generationManager.generate(state, tree.context), - relativePath: parentDirectory, + symbolPath: parentDirectory, )); }); diff --git a/lib/generation/generators/middleware/state_management/riverpod_middleware.dart b/lib/generation/generators/middleware/state_management/riverpod_middleware.dart index ffa21312..aca6ce2c 100644 --- a/lib/generation/generators/middleware/state_management/riverpod_middleware.dart +++ b/lib/generation/generators/middleware/state_management/riverpod_middleware.dart @@ -89,7 +89,8 @@ class RiverpodMiddleware extends StateManagementMiddleware { } watcherName = getNameOfNode(node); - var parentDirectory = ImportHelper.getName(node.name).snakeCase; + var parentDirectory = WriteSymbolCommand.DEFAULT_SYMBOL_PATH + + ImportHelper.getName(node.name).snakeCase; // Generate model's imports var modelGenerator = PBFlutterGenerator(ImportHelper(), @@ -109,9 +110,12 @@ class RiverpodMiddleware extends StateManagementMiddleware { ownership: FileOwnership.DEV, ), // Generate default node's view page - WriteSymbolCommand(context.tree.UUID, node.name.snakeCase, - generationManager.generate(node, context), - relativePath: parentDirectory), + WriteSymbolCommand( + context.tree.UUID, + node.name.snakeCase, + generationManager.generate(node, context), + symbolPath: parentDirectory, + ), ].forEach(fileStrategy.commandCreated); var nodeStateGraph = stmgHelper.getStateGraphOfNode(node); @@ -129,7 +133,7 @@ class RiverpodMiddleware extends StateManagementMiddleware { tree.UUID, state.name.snakeCase, tree.context.generationManager.generate(state, tree.context), - relativePath: parentDirectory, + symbolPath: parentDirectory, )); }); diff --git a/lib/generation/generators/middleware/state_management/stateful_middleware.dart b/lib/generation/generators/middleware/state_management/stateful_middleware.dart index 94900125..ecd9db97 100644 --- a/lib/generation/generators/middleware/state_management/stateful_middleware.dart +++ b/lib/generation/generators/middleware/state_management/stateful_middleware.dart @@ -71,7 +71,8 @@ class StatefulMiddleware extends StateManagementMiddleware { tree.UUID, state.name.snakeCase, tree.context.generationManager.generate(state, tree.context), - relativePath: ImportHelper.getName(node.name).snakeCase, + symbolPath: WriteSymbolCommand.DEFAULT_SYMBOL_PATH + + ImportHelper.getName(node.name).snakeCase, )); }); From 7b1013685a3c636a460e67ab222191b5af77e57f Mon Sep 17 00:00:00 2001 From: Bryan Figueroa Date: Tue, 3 May 2022 13:25:58 -0600 Subject: [PATCH 11/24] Update path services --- .../file_structure_strategy/path_service.dart | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/generation/generators/value_objects/file_structure_strategy/path_service.dart b/lib/generation/generators/value_objects/file_structure_strategy/path_service.dart index 040ab7b5..8e71efc1 100644 --- a/lib/generation/generators/value_objects/file_structure_strategy/path_service.dart +++ b/lib/generation/generators/value_objects/file_structure_strategy/path_service.dart @@ -2,10 +2,12 @@ abstract class PathService { final String viewsRelativePath; final String widgetsRelativePath; final String customRelativePath; + final String constantsRelativePath; PathService( this.viewsRelativePath, this.widgetsRelativePath, this.customRelativePath, + this.constantsRelativePath, ); factory PathService.fromConfiguration(String architecture) { @@ -20,22 +22,26 @@ abstract class PathService { } class DomainPathService extends PathService { - static String viewsPath = 'lib/views'; + static final String _widgetsPath = 'lib/widgets'; @override - final String viewsRelativePath = '$viewsPath'; + final String viewsRelativePath = 'lib/views'; @override - final String widgetsRelativePath = 'lib/widgets'; + final String widgetsRelativePath = '$_widgetsPath'; @override - final String customRelativePath = '$viewsPath/custom'; + final String customRelativePath = '$_widgetsPath/custom'; + @override + final String constantsRelativePath = 'lib/constants'; DomainPathService({ String viewsRelativePath, String widgetsRelativePath, String customRelativePath, + String constantsRelativePath, }) : super( viewsRelativePath, widgetsRelativePath, customRelativePath, + constantsRelativePath, ); } From d65de035c2febd2b839563b2da23c6ae04d8edd4 Mon Sep 17 00:00:00 2001 From: Bryan Figueroa Date: Tue, 3 May 2022 13:26:42 -0600 Subject: [PATCH 12/24] Updated custom tag directory --- lib/tags/custom_tag/custom_tag.dart | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/lib/tags/custom_tag/custom_tag.dart b/lib/tags/custom_tag/custom_tag.dart index 5cc84c59..b78403c0 100644 --- a/lib/tags/custom_tag/custom_tag.dart +++ b/lib/tags/custom_tag/custom_tag.dart @@ -1,3 +1,4 @@ +import 'package:get_it/get_it.dart'; import 'package:parabeac_core/controllers/main_info.dart'; import 'package:parabeac_core/generation/generators/import_generator.dart'; import 'package:parabeac_core/generation/generators/pb_generator.dart'; @@ -6,6 +7,7 @@ import 'package:parabeac_core/generation/generators/symbols/pb_instancesym_gen.d import 'package:parabeac_core/generation/generators/util/pb_input_formatter.dart'; import 'package:parabeac_core/generation/generators/value_objects/file_structure_strategy/commands/write_symbol_command.dart'; import 'package:parabeac_core/generation/generators/value_objects/file_structure_strategy/file_ownership_policy.dart'; +import 'package:parabeac_core/generation/generators/value_objects/file_structure_strategy/path_service.dart'; import 'package:parabeac_core/interpret_and_optimize/entities/interfaces/pb_injected_intermediate.dart'; import 'package:parabeac_core/interpret_and_optimize/entities/subclasses/pb_intermediate_constraints.dart'; import 'package:parabeac_core/interpret_and_optimize/entities/pb_shared_instance.dart'; @@ -73,17 +75,19 @@ class CustomTag extends PBTag implements PBInjectedIntermediate { layoutCrossAxisSizing: originalRef.layoutCrossAxisSizing, layoutMainAxisSizing: originalRef.layoutMainAxisSizing, isComponent: originalRef is PBSharedMasterNode && - originalRef.componentSetName == null, //Variable used to add extra info. to custom file. + originalRef.componentSetName == + null, //Variable used to add extra info. to custom file. ); } } class CustomTagGenerator extends PBGenerator { /// Variable that dictates in what directory the tag will be generated. - static const DIRECTORY_GEN = 'controller/tag'; + static String DIRECTORY_GEN = GetIt.I.get().customRelativePath; @override String generate(PBIntermediateNode source, PBContext context) { + var customDirectory = DIRECTORY_GEN + '/' + context.tree.name; var children = context.tree.childrenOf(source); var titleName = PBInputFormatter.formatLabel( source.name, @@ -94,7 +98,7 @@ class CustomTagGenerator extends PBGenerator { // TODO: correct import context.managerData.addImport(FlutterImport( - '$DIRECTORY_GEN/$cleanName.dart', + '$customDirectory/$cleanName.dart', MainInfo().projectName, )); @@ -109,8 +113,7 @@ class CustomTagGenerator extends PBGenerator { context, source, ), - relativePath: '$DIRECTORY_GEN', - symbolPath: 'lib', + symbolPath: '$customDirectory', ownership: FileOwnership.DEV, ), ); @@ -155,6 +158,7 @@ class CustomTagGenerator extends PBGenerator { /// Import variable in case we need to import /// component file inside custom file var import = ''; + /// Suffix to be appended after `widget.child`. /// The '!' is for null safety. Optionally, /// we can also add reference to the component. @@ -162,8 +166,11 @@ class CustomTagGenerator extends PBGenerator { if (source.isComponent) { var baseCompName = className.replaceAll('Custom', ''); import = FlutterImport( - path.join(WriteSymbolCommand.DEFAULT_SYMBOL_PATH, context.tree.name, - '${baseCompName.snakeCase}.g.dart'), + path.join( + WriteSymbolCommand.DEFAULT_SYMBOL_PATH, + context.tree.name, + '${baseCompName.snakeCase}.g.dart', + ), MainInfo().projectName, ).toString(); suffix = From 4159962a79c56afaea458c436cedc36ef7b29699 Mon Sep 17 00:00:00 2001 From: Bryan Figueroa Date: Tue, 3 May 2022 13:27:02 -0600 Subject: [PATCH 13/24] Update command directories to use path service --- .../commands/add_constant_command.dart | 5 ++++- .../commands/export_platform_command.dart | 5 ++++- .../commands/orientation_builder_command.dart | 5 ++++- .../commands/responsive_layout_builder_command.dart | 5 ++++- .../commands/write_screen_command.dart | 4 +++- .../pb_file_structure_strategy.dart | 8 ++++++-- 6 files changed, 25 insertions(+), 7 deletions(-) diff --git a/lib/generation/generators/value_objects/file_structure_strategy/commands/add_constant_command.dart b/lib/generation/generators/value_objects/file_structure_strategy/commands/add_constant_command.dart index 5f68fdea..6046b674 100644 --- a/lib/generation/generators/value_objects/file_structure_strategy/commands/add_constant_command.dart +++ b/lib/generation/generators/value_objects/file_structure_strategy/commands/add_constant_command.dart @@ -1,4 +1,6 @@ +import 'package:get_it/get_it.dart'; import 'package:parabeac_core/generation/generators/value_objects/file_structure_strategy/file_ownership_policy.dart'; +import 'package:parabeac_core/generation/generators/value_objects/file_structure_strategy/path_service.dart'; import 'package:path/path.dart' as p; import 'package:parabeac_core/generation/generators/value_objects/file_structure_strategy/commands/file_structure_command.dart'; @@ -9,7 +11,8 @@ class AddConstantCommand extends FileStructureCommand { String name; String type; String value; - final String CONST_DIR_PATH = 'lib/constants/'; + final String CONST_DIR_PATH = + GetIt.I.get().constantsRelativePath; final String CONST_FILE_NAME = 'constants.dart'; AddConstantCommand(String UUID, this.name, this.type, this.value) diff --git a/lib/generation/generators/value_objects/file_structure_strategy/commands/export_platform_command.dart b/lib/generation/generators/value_objects/file_structure_strategy/commands/export_platform_command.dart index b0796bea..2eead933 100644 --- a/lib/generation/generators/value_objects/file_structure_strategy/commands/export_platform_command.dart +++ b/lib/generation/generators/value_objects/file_structure_strategy/commands/export_platform_command.dart @@ -1,4 +1,6 @@ +import 'package:get_it/get_it.dart'; import 'package:parabeac_core/generation/generators/value_objects/file_structure_strategy/file_ownership_policy.dart'; +import 'package:parabeac_core/generation/generators/value_objects/file_structure_strategy/path_service.dart'; import 'package:path/path.dart' as p; import 'package:parabeac_core/generation/generators/value_objects/file_structure_strategy/commands/node_file_structure_command.dart'; import 'package:parabeac_core/generation/generators/value_objects/file_structure_strategy/pb_file_structure_strategy.dart'; @@ -9,7 +11,8 @@ class ExportPlatformCommand extends NodeFileStructureCommand { PLATFORM platform; String fileName; String folderName; - static final String WIDGET_PATH = 'lib/screens'; + static final String WIDGET_PATH = + GetIt.I.get().viewsRelativePath; ExportPlatformCommand( String UUID, this.platform, this.folderName, this.fileName, String code, diff --git a/lib/generation/generators/value_objects/file_structure_strategy/commands/orientation_builder_command.dart b/lib/generation/generators/value_objects/file_structure_strategy/commands/orientation_builder_command.dart index 9d1e4834..a13c636f 100644 --- a/lib/generation/generators/value_objects/file_structure_strategy/commands/orientation_builder_command.dart +++ b/lib/generation/generators/value_objects/file_structure_strategy/commands/orientation_builder_command.dart @@ -1,3 +1,5 @@ +import 'package:get_it/get_it.dart'; +import 'package:parabeac_core/generation/generators/value_objects/file_structure_strategy/path_service.dart'; import 'package:path/path.dart' as p; import 'package:parabeac_core/generation/generators/value_objects/file_structure_strategy/commands/file_structure_command.dart'; import 'package:parabeac_core/generation/generators/value_objects/file_structure_strategy/pb_file_structure_strategy.dart'; @@ -5,7 +7,8 @@ import 'package:parabeac_core/generation/generators/value_objects/file_structure import '../file_ownership_policy.dart'; class OrientationBuilderCommand extends FileStructureCommand { - static final DIR_TO_ORIENTATION_BUILDER = 'lib/widgets/'; + static final DIR_TO_ORIENTATION_BUILDER = + GetIt.I.get().widgetsRelativePath; static final NAME_TO_ORIENTAION_BUILDER = 'responsive_orientation_builder.dart'; diff --git a/lib/generation/generators/value_objects/file_structure_strategy/commands/responsive_layout_builder_command.dart b/lib/generation/generators/value_objects/file_structure_strategy/commands/responsive_layout_builder_command.dart index 41151292..81dae481 100644 --- a/lib/generation/generators/value_objects/file_structure_strategy/commands/responsive_layout_builder_command.dart +++ b/lib/generation/generators/value_objects/file_structure_strategy/commands/responsive_layout_builder_command.dart @@ -1,5 +1,7 @@ import 'dart:collection'; +import 'package:get_it/get_it.dart'; import 'package:parabeac_core/generation/generators/value_objects/file_structure_strategy/file_ownership_policy.dart'; +import 'package:parabeac_core/generation/generators/value_objects/file_structure_strategy/path_service.dart'; import 'package:path/path.dart' as p; import 'package:parabeac_core/controllers/main_info.dart'; import 'package:parabeac_core/generation/generators/value_objects/file_structure_strategy/commands/file_structure_command.dart'; @@ -7,7 +9,8 @@ import 'package:parabeac_core/generation/generators/value_objects/file_structure import 'package:parabeac_core/interpret_and_optimize/services/pb_platform_orientation_linker_service.dart'; class ResponsiveLayoutBuilderCommand extends FileStructureCommand { - static final DIR_TO_RESPONSIVE_LAYOUT = 'lib/widgets/'; + static final DIR_TO_RESPONSIVE_LAYOUT = + GetIt.I.get().widgetsRelativePath; static final NAME_TO_RESPONSIVE_LAYOUT = 'responsive_layout_builder.dart'; ResponsiveLayoutBuilderCommand(String UUID) : super(UUID); diff --git a/lib/generation/generators/value_objects/file_structure_strategy/commands/write_screen_command.dart b/lib/generation/generators/value_objects/file_structure_strategy/commands/write_screen_command.dart index 6c8a9bf5..df87ed27 100644 --- a/lib/generation/generators/value_objects/file_structure_strategy/commands/write_screen_command.dart +++ b/lib/generation/generators/value_objects/file_structure_strategy/commands/write_screen_command.dart @@ -1,4 +1,6 @@ +import 'package:get_it/get_it.dart'; import 'package:parabeac_core/generation/generators/value_objects/file_structure_strategy/file_ownership_policy.dart'; +import 'package:parabeac_core/generation/generators/value_objects/file_structure_strategy/path_service.dart'; import 'package:path/path.dart' as p; import 'package:parabeac_core/generation/generators/value_objects/file_structure_strategy/commands/node_file_structure_command.dart'; import 'package:parabeac_core/generation/generators/value_objects/file_structure_strategy/pb_file_structure_strategy.dart'; @@ -9,7 +11,7 @@ class WriteScreenCommand extends NodeFileStructureCommand { String relativePath; String fileExtension; - static final SCREEN_PATH = 'lib/screens'; + static final SCREEN_PATH = GetIt.I.get().viewsRelativePath; WriteScreenCommand(String UUID, this.name, this.relativePath, String code, {FileOwnership ownership = FileOwnership.PBC, diff --git a/lib/generation/generators/value_objects/file_structure_strategy/pb_file_structure_strategy.dart b/lib/generation/generators/value_objects/file_structure_strategy/pb_file_structure_strategy.dart index 6189ae61..1e4fb056 100644 --- a/lib/generation/generators/value_objects/file_structure_strategy/pb_file_structure_strategy.dart +++ b/lib/generation/generators/value_objects/file_structure_strategy/pb_file_structure_strategy.dart @@ -1,6 +1,8 @@ import 'dart:io'; +import 'package:get_it/get_it.dart'; import 'package:parabeac_core/generation/flutter_project_builder/file_system_analyzer.dart'; import 'package:parabeac_core/generation/generators/value_objects/file_structure_strategy/file_ownership_policy.dart'; +import 'package:parabeac_core/generation/generators/value_objects/file_structure_strategy/path_service.dart'; import 'package:parabeac_core/interpret_and_optimize/helpers/pb_context.dart'; import 'package:path/path.dart' as p; @@ -28,10 +30,12 @@ abstract class FileStructureStrategy implements CommandInvoker { /// ///The views is anything that is not a screen, for example, symbol masters ///are going to be generated in this folder if not specified otherwise. - static final RELATIVE_VIEW_PATH = 'lib/widgets/'; + static final RELATIVE_VIEW_PATH = + GetIt.I.get().viewsRelativePath; ///The `default` path of where all the screens are going to be generated. - static final RELATIVE_SCREEN_PATH = 'lib/screens/'; + static final RELATIVE_SCREEN_PATH = + GetIt.I.get().widgetsRelativePath; ///Path of where the project is generated final String GENERATED_PROJECT_PATH; From 0f3cfaa34f39b7c6a7e3cda50d7af2a149dde71c Mon Sep 17 00:00:00 2001 From: Bryan Figueroa Date: Tue, 3 May 2022 13:27:27 -0600 Subject: [PATCH 14/24] Changed master node to actual tree name --- lib/main.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/main.dart b/lib/main.dart index 9270ba67..8b954dfa 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -318,7 +318,7 @@ Future> treeHasMaster(PBIntermediateTree tree) async { /// Since this is now a [PBSharedMasterNode], we need to remove the constraints /// and pass them on to the instance. element.constraints = PBIntermediateConstraints.defaultConstraints(); - var tempTree = PBIntermediateTree(name: element.name) + var tempTree = PBIntermediateTree(name: tree.name) ..rootNode = element ..tree_type = TREE_TYPE.VIEW ..generationViewData = PBGenerationViewData(); From edb22c3deaccbd4c6589fb38cf7013c9909e5f1b Mon Sep 17 00:00:00 2001 From: Bryan Figueroa Date: Tue, 3 May 2022 13:28:25 -0600 Subject: [PATCH 15/24] Removed relative path, not needed anymore --- lib/tags/injected_app_bar.dart | 1 - lib/tags/injected_tab_bar.dart | 1 - 2 files changed, 2 deletions(-) diff --git a/lib/tags/injected_app_bar.dart b/lib/tags/injected_app_bar.dart index 3b09f767..ea51e5c6 100644 --- a/lib/tags/injected_app_bar.dart +++ b/lib/tags/injected_app_bar.dart @@ -153,7 +153,6 @@ class PBAppBarGenerator extends PBGenerator { className.snakeCase, appBarBody(className, buffer.toString(), generatorContext.managerData.importsList), - relativePath: 'controller', symbolPath: 'lib', ownership: FileOwnership.DEV, )); diff --git a/lib/tags/injected_tab_bar.dart b/lib/tags/injected_tab_bar.dart index b7f8a5a3..4718133e 100644 --- a/lib/tags/injected_tab_bar.dart +++ b/lib/tags/injected_tab_bar.dart @@ -171,7 +171,6 @@ class PBTabBarGenerator extends PBGenerator { className.snakeCase, tabBarBody( className, buffer.toString(), context.managerData.importsList), - relativePath: 'controller', symbolPath: 'lib', ownership: FileOwnership.DEV, )); From 7c232d28e046804ae3988720297ca420bf1f88a5 Mon Sep 17 00:00:00 2001 From: Bryan Figueroa Date: Tue, 3 May 2022 16:34:02 -0600 Subject: [PATCH 16/24] Fixed path for command gen --- .../generators/middleware/command_gen_middleware.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/generation/generators/middleware/command_gen_middleware.dart b/lib/generation/generators/middleware/command_gen_middleware.dart index 05023f72..aa90893f 100644 --- a/lib/generation/generators/middleware/command_gen_middleware.dart +++ b/lib/generation/generators/middleware/command_gen_middleware.dart @@ -75,7 +75,7 @@ class CommandGenMiddleware extends Middleware tree.UUID, tree.identifier, generationManager.generate(tree.rootNode, context), - symbolPath: WriteSymbolCommand.DEFAULT_SYMBOL_PATH + relativePath, + symbolPath: WriteSymbolCommand.DEFAULT_SYMBOL_PATH + '/' + relativePath, ); } if (command != null) { From 16a5d2de6f8b8f0fb319b876ca0464c72af47e8e Mon Sep 17 00:00:00 2001 From: Bryan Figueroa Date: Tue, 3 May 2022 16:34:14 -0600 Subject: [PATCH 17/24] Makde path service more flexible --- .../value_objects/file_structure_strategy/path_service.dart | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/generation/generators/value_objects/file_structure_strategy/path_service.dart b/lib/generation/generators/value_objects/file_structure_strategy/path_service.dart index 8e71efc1..814002f7 100644 --- a/lib/generation/generators/value_objects/file_structure_strategy/path_service.dart +++ b/lib/generation/generators/value_objects/file_structure_strategy/path_service.dart @@ -22,14 +22,12 @@ abstract class PathService { } class DomainPathService extends PathService { - static final String _widgetsPath = 'lib/widgets'; - @override final String viewsRelativePath = 'lib/views'; @override - final String widgetsRelativePath = '$_widgetsPath'; + final String widgetsRelativePath = 'lib/widgets'; @override - final String customRelativePath = '$_widgetsPath/custom'; + final String customRelativePath = 'custom'; @override final String constantsRelativePath = 'lib/constants'; From 8d620ea6c8e1835c3723409920177049fbfcc3ac Mon Sep 17 00:00:00 2001 From: Bryan Figueroa Date: Tue, 3 May 2022 16:34:34 -0600 Subject: [PATCH 18/24] Made custom folder flexible --- lib/tags/custom_tag/custom_tag.dart | 7 +++++-- lib/tags/custom_tag/custom_tag_bloc_generator.dart | 12 +++++------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/lib/tags/custom_tag/custom_tag.dart b/lib/tags/custom_tag/custom_tag.dart index b78403c0..f933e199 100644 --- a/lib/tags/custom_tag/custom_tag.dart +++ b/lib/tags/custom_tag/custom_tag.dart @@ -83,11 +83,14 @@ class CustomTag extends PBTag implements PBInjectedIntermediate { class CustomTagGenerator extends PBGenerator { /// Variable that dictates in what directory the tag will be generated. - static String DIRECTORY_GEN = GetIt.I.get().customRelativePath; + static String DIRECTORY_GEN = GetIt.I.get().widgetsRelativePath; + static String DIRECTORY_CUSTOM = + GetIt.I.get().customRelativePath; @override String generate(PBIntermediateNode source, PBContext context) { - var customDirectory = DIRECTORY_GEN + '/' + context.tree.name; + var customDirectory = + DIRECTORY_GEN + '/' + context.tree.name + '/' + DIRECTORY_CUSTOM; var children = context.tree.childrenOf(source); var titleName = PBInputFormatter.formatLabel( source.name, diff --git a/lib/tags/custom_tag/custom_tag_bloc_generator.dart b/lib/tags/custom_tag/custom_tag_bloc_generator.dart index 687445be..c3cb65a3 100644 --- a/lib/tags/custom_tag/custom_tag_bloc_generator.dart +++ b/lib/tags/custom_tag/custom_tag_bloc_generator.dart @@ -27,7 +27,8 @@ class CustomTagBlocGenerator extends CustomTagGenerator { var cleanName = PBInputFormatter.formatLabel(source.name.snakeCase); var packageName = MainInfo().projectName; - var blocRelativePath = p.join('bloc', '$cleanName'); + var blocRelativePath = + p.join(WriteSymbolCommand.DEFAULT_SYMBOL_PATH, 'bloc', '$cleanName'); // TODO: correct import context.managerData.addImport(FlutterImport( @@ -63,8 +64,7 @@ class CustomTagBlocGenerator extends CustomTagGenerator { Uuid().v4(), stateName, _generateStateBoilerplate(titleName, initialStates), - relativePath: blocRelativePath, - symbolPath: 'lib', + symbolPath: blocRelativePath, ownership: FileOwnership.DEV, ), ); @@ -80,8 +80,7 @@ class CustomTagBlocGenerator extends CustomTagGenerator { Uuid().v4(), cubitName, _generateCubitBoilerplate(titleName, stateImport), - relativePath: blocRelativePath, - symbolPath: 'lib', + symbolPath: blocRelativePath, ownership: FileOwnership.DEV, ), ); @@ -96,8 +95,7 @@ class CustomTagBlocGenerator extends CustomTagGenerator { Uuid().v4(), cleanName, _customBoilerPlate(titleName, cubitImport, stateImport), - relativePath: CustomTagGenerator.DIRECTORY_GEN, - symbolPath: 'lib', + symbolPath: CustomTagGenerator.DIRECTORY_GEN, ownership: FileOwnership.DEV, ), ); From bdf349b17d7bbd7185cf94ef68626e15595360fd Mon Sep 17 00:00:00 2001 From: Bryan Figueroa Date: Wed, 4 May 2022 15:08:38 -0600 Subject: [PATCH 19/24] Added comments --- .../commands/write_symbol_command.dart | 5 ++--- .../file_structure_strategy/path_service.dart | 7 +++++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/generation/generators/value_objects/file_structure_strategy/commands/write_symbol_command.dart b/lib/generation/generators/value_objects/file_structure_strategy/commands/write_symbol_command.dart index b2236467..45bd8fc3 100644 --- a/lib/generation/generators/value_objects/file_structure_strategy/commands/write_symbol_command.dart +++ b/lib/generation/generators/value_objects/file_structure_strategy/commands/write_symbol_command.dart @@ -13,11 +13,10 @@ class WriteSymbolCommand extends NodeFileStructureCommand { String symbolPath; String fileName; - /// The [relativePath] within the [symbolPath] + /// The [symbolPath] has the relative path within /// /// For example, you are looking for `lib/widgets/some_element/element.dart`, - /// then the [relativePath] would be `some_element/` and the [fileName] would be `element.dart`. - // String relativePath; + /// then the [symbolPath] would be `lib/widgets/some_element/` WriteSymbolCommand( String UUID, diff --git a/lib/generation/generators/value_objects/file_structure_strategy/path_service.dart b/lib/generation/generators/value_objects/file_structure_strategy/path_service.dart index 814002f7..b8678f86 100644 --- a/lib/generation/generators/value_objects/file_structure_strategy/path_service.dart +++ b/lib/generation/generators/value_objects/file_structure_strategy/path_service.dart @@ -1,3 +1,9 @@ +/// PathService class helps file writers commands to determine +/// the right path for their views, widgets, custom and constants +/// by centralizing the path to this class +/// +/// The class can be extended to create different types of PathService +/// by default we made [DomainPathService] abstract class PathService { final String viewsRelativePath; final String widgetsRelativePath; @@ -11,6 +17,7 @@ abstract class PathService { ); factory PathService.fromConfiguration(String architecture) { + // TODO: Once we add more if statements, we can declare `domain` case as the else statement if (architecture.toLowerCase() == 'domain') { return DomainPathService(); } From 35a6c754a92dde86ef01941d62f4e628e2dec50f Mon Sep 17 00:00:00 2001 From: Bryan Figueroa Date: Wed, 4 May 2022 16:04:02 -0600 Subject: [PATCH 20/24] Use path packages to join paths --- .../generators/middleware/command_gen_middleware.dart | 7 +++++-- lib/tags/custom_tag/custom_tag.dart | 3 ++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/generation/generators/middleware/command_gen_middleware.dart b/lib/generation/generators/middleware/command_gen_middleware.dart index aa90893f..713be089 100644 --- a/lib/generation/generators/middleware/command_gen_middleware.dart +++ b/lib/generation/generators/middleware/command_gen_middleware.dart @@ -15,6 +15,7 @@ import 'package:parabeac_core/interpret_and_optimize/helpers/pb_state_management import 'package:parabeac_core/interpret_and_optimize/services/pb_platform_orientation_linker_service.dart'; import 'package:parabeac_core/interpret_and_optimize/state_management/directed_state_graph.dart'; import 'package:recase/recase.dart'; +import 'package:path/path.dart' as p; class CommandGenMiddleware extends Middleware with PBPlatformOrientationGeneration { @@ -68,14 +69,16 @@ class CommandGenMiddleware extends Middleware var componentSetName = (tree.rootNode as PBSharedMasterNode).componentSetName; relativePath = componentSetName != null - ? relativePath + '/' + componentSetName.snakeCase + ? p.join(relativePath, componentSetName.snakeCase) : relativePath; } + command = WriteSymbolCommand( tree.UUID, tree.identifier, generationManager.generate(tree.rootNode, context), - symbolPath: WriteSymbolCommand.DEFAULT_SYMBOL_PATH + '/' + relativePath, + symbolPath: + p.join(WriteSymbolCommand.DEFAULT_SYMBOL_PATH, relativePath), ); } if (command != null) { diff --git a/lib/tags/custom_tag/custom_tag.dart b/lib/tags/custom_tag/custom_tag.dart index f933e199..0318439f 100644 --- a/lib/tags/custom_tag/custom_tag.dart +++ b/lib/tags/custom_tag/custom_tag.dart @@ -90,7 +90,8 @@ class CustomTagGenerator extends PBGenerator { @override String generate(PBIntermediateNode source, PBContext context) { var customDirectory = - DIRECTORY_GEN + '/' + context.tree.name + '/' + DIRECTORY_CUSTOM; + path.join(DIRECTORY_GEN, context.tree.name, DIRECTORY_CUSTOM); + var children = context.tree.childrenOf(source); var titleName = PBInputFormatter.formatLabel( source.name, From 6aed4c439b91ce9c1646e116bd15c678cd34860c Mon Sep 17 00:00:00 2001 From: Bryan Figueroa Date: Wed, 4 May 2022 17:08:21 -0600 Subject: [PATCH 21/24] Updated tests to use path service --- test/golden/auto_layout_test.dart | 6 ++++-- test/golden/styling_test.dart | 15 ++++++++++++--- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/test/golden/auto_layout_test.dart b/test/golden/auto_layout_test.dart index 1d64972b..cfcaf277 100644 --- a/test/golden/auto_layout_test.dart +++ b/test/golden/auto_layout_test.dart @@ -1,11 +1,13 @@ import 'dart:io'; +import 'package:parabeac_core/generation/generators/value_objects/file_structure_strategy/path_service.dart'; import 'package:path/path.dart' as path; import 'package:test/test.dart'; void main() { final projectName = 'golden_auto_layout_testing_project'; final basePath = path.join(path.current, 'test', 'golden'); - final runtimeFilePath = path.join(basePath, projectName, 'lib'); + final runtimeFilePath = + path.join(basePath, projectName, DomainPathService().viewsRelativePath); final goldenFilesPath = path.join(basePath, 'golden_files', 'auto_layout'); group('Auto Layout Golden Test', () { setUp(() async { @@ -38,7 +40,7 @@ void main() { goldenFiles.add( File(path.join(goldenFilesPath, '${fileNamesLines[i]}.golden'))); - runtimeFiles.add(File(path.join(runtimeFilePath, 'screens', + runtimeFiles.add(File(path.join(runtimeFilePath, 'auto_layout_permutations', '${fileNamesLines[i]}.g.dart'))); } diff --git a/test/golden/styling_test.dart b/test/golden/styling_test.dart index f033eb5a..2e0244a0 100644 --- a/test/golden/styling_test.dart +++ b/test/golden/styling_test.dart @@ -1,4 +1,5 @@ import 'dart:io'; +import 'package:parabeac_core/generation/generators/value_objects/file_structure_strategy/path_service.dart'; import 'package:path/path.dart' as path; import 'package:test/test.dart'; @@ -6,7 +7,7 @@ import 'package:test/test.dart'; void main() { final projectName = 'golden_testing_project'; final basePath = path.join(path.current, 'test', 'golden'); - final runtimeFilePath = path.join(basePath, projectName, 'lib'); + final runtimeFilePath = path.join(basePath, projectName); final goldenFilesPath = path.join(basePath, 'golden_files', 'styling'); group('Styling Golden Test', () { setUp(() async { @@ -51,9 +52,17 @@ void main() { ]; /// Runtime files corresponding to the above golden files - final widgetPath = path.join(runtimeFilePath, 'widgets', 'styling'); + final widgetPath = path.join( + runtimeFilePath, + DomainPathService().widgetsRelativePath, + 'styling', + ); final runtimeFile = File(path.join( - runtimeFilePath, 'screens', 'styling', 'styling_screen.g.dart')); + runtimeFilePath, + DomainPathService().viewsRelativePath, + 'styling', + 'styling_screen.g.dart', + )); final helloWorldRuntimeFile = File(path.join(widgetPath, 'helloworld.g.dart')); final primaryButtonRuntimeFile = From 3f6098c6f27f71024f0925ae15e8d10b47299382 Mon Sep 17 00:00:00 2001 From: Bryan Figueroa Date: Wed, 4 May 2022 17:44:47 -0600 Subject: [PATCH 22/24] Updated golden file test --- test/golden/golden_files/styling/styling.golden | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/golden/golden_files/styling/styling.golden b/test/golden/golden_files/styling/styling.golden index 3b135c39..9faf6123 100644 --- a/test/golden/golden_files/styling/styling.golden +++ b/test/golden/golden_files/styling/styling.golden @@ -307,6 +307,7 @@ class _StylingScreen extends State { top: 754.0, height: 118.0, child: Container( + clipBehavior: Clip.hardEdge, width: 154.000, height: 118.000, decoration: BoxDecoration( @@ -341,6 +342,7 @@ class _StylingScreen extends State { top: 3.0, height: 118.0, child: Container( + clipBehavior: Clip.hardEdge, width: 154.000, height: 118.000, decoration: BoxDecoration( From 70e1eb1700492675acb166ec8f126b246d511d75 Mon Sep 17 00:00:00 2001 From: Ivan <42812006+ivan-015@users.noreply.github.com> Date: Thu, 5 May 2022 11:39:40 -0600 Subject: [PATCH 23/24] Fix RELATIVE_WIDGET_PATH name --- .../middleware/state_management/bloc_middleware.dart | 2 +- .../state_management/provider_middleware.dart | 2 +- .../state_management/stateful_middleware.dart | 2 +- .../pb_file_structure_strategy.dart | 10 +++++----- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/generation/generators/middleware/state_management/bloc_middleware.dart b/lib/generation/generators/middleware/state_management/bloc_middleware.dart index 3a4fa6e1..fd07d854 100644 --- a/lib/generation/generators/middleware/state_management/bloc_middleware.dart +++ b/lib/generation/generators/middleware/state_management/bloc_middleware.dart @@ -66,7 +66,7 @@ class BLoCMiddleware extends StateManagementMiddleware { PBSymbolStorage().getSharedMasterNodeBySymbolID(node.SYMBOL_ID); return p.join( fileStrategy.GENERATED_PROJECT_PATH, - FileStructureStrategy.RELATIVE_VIEW_PATH, + FileStructureStrategy.RELATIVE_WIDGET_PATH, '${generalStateName.snakeCase}_bloc', '${ImportHelper.getName(symbolMaster.name).snakeCase}_bloc', ); diff --git a/lib/generation/generators/middleware/state_management/provider_middleware.dart b/lib/generation/generators/middleware/state_management/provider_middleware.dart index 5a15cd5e..d465526a 100644 --- a/lib/generation/generators/middleware/state_management/provider_middleware.dart +++ b/lib/generation/generators/middleware/state_management/provider_middleware.dart @@ -39,7 +39,7 @@ class ProviderMiddleware extends StateManagementMiddleware { ? p.join(fileStrategy.RELATIVE_MODEL_PATH, ImportHelper.getName(symbolMaster.name).snakeCase) : p.join( - FileStructureStrategy.RELATIVE_VIEW_PATH, + FileStructureStrategy.RELATIVE_WIDGET_PATH, ImportHelper.getName(symbolMaster.name).snakeCase, node.functionCallName.snakeCase); return p.join(fileStrategy.GENERATED_PROJECT_PATH, import); diff --git a/lib/generation/generators/middleware/state_management/stateful_middleware.dart b/lib/generation/generators/middleware/state_management/stateful_middleware.dart index ecd9db97..f3cd4f1b 100644 --- a/lib/generation/generators/middleware/state_management/stateful_middleware.dart +++ b/lib/generation/generators/middleware/state_management/stateful_middleware.dart @@ -27,7 +27,7 @@ class StatefulMiddleware extends StateManagementMiddleware { PBSymbolStorage().getSharedMasterNodeBySymbolID(node.SYMBOL_ID); var path = p.join( fileStrategy.GENERATED_PROJECT_PATH, - FileStructureStrategy.RELATIVE_VIEW_PATH, + FileStructureStrategy.RELATIVE_WIDGET_PATH, ImportHelper.getName(symbolMaster.name).snakeCase, node.functionCallName.snakeCase); return path; diff --git a/lib/generation/generators/value_objects/file_structure_strategy/pb_file_structure_strategy.dart b/lib/generation/generators/value_objects/file_structure_strategy/pb_file_structure_strategy.dart index 1e4fb056..5a59f954 100644 --- a/lib/generation/generators/value_objects/file_structure_strategy/pb_file_structure_strategy.dart +++ b/lib/generation/generators/value_objects/file_structure_strategy/pb_file_structure_strategy.dart @@ -30,12 +30,12 @@ abstract class FileStructureStrategy implements CommandInvoker { /// ///The views is anything that is not a screen, for example, symbol masters ///are going to be generated in this folder if not specified otherwise. - static final RELATIVE_VIEW_PATH = - GetIt.I.get().viewsRelativePath; + static final RELATIVE_WIDGET_PATH = + GetIt.I.get().widgetsRelativePath; ///The `default` path of where all the screens are going to be generated. static final RELATIVE_SCREEN_PATH = - GetIt.I.get().widgetsRelativePath; + GetIt.I.get().viewsRelativePath; ///Path of where the project is generated final String GENERATED_PROJECT_PATH; @@ -107,12 +107,12 @@ abstract class FileStructureStrategy implements CommandInvoker { ///Setting up the required directories for the [FileStructureStrategy] to write the corresponding files. /// ///Default directories that are going to be generated is the - ///[RELATIVE_VIEW_PATH] and [RELATIVE_SCREEN_PATH]. + ///[RELATIVE_WIDGET_PATH] and [RELATIVE_SCREEN_PATH]. Future setUpDirectories() async { if (!isSetUp) { _screenDirectoryPath = p.join(GENERATED_PROJECT_PATH, RELATIVE_SCREEN_PATH); - _viewDirectoryPath = p.join(GENERATED_PROJECT_PATH, RELATIVE_VIEW_PATH); + _viewDirectoryPath = p.join(GENERATED_PROJECT_PATH, RELATIVE_WIDGET_PATH); // _pbProject.forest.forEach((dir) { // if (dir.rootNode != null) { // addImportsInfo(dir, context); From 50c40e44e563947d8541b6bae3def01c0755c4ea Mon Sep 17 00:00:00 2001 From: Ivan <42812006+ivan-015@users.noreply.github.com> Date: Sun, 8 May 2022 14:05:07 -0600 Subject: [PATCH 24/24] Increase version to `3.0.0` * Breaking change: Add domain-layered architecture. This has the potential to break previous projects. --- pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pubspec.yaml b/pubspec.yaml index 48c722a6..98c4758d 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: parabeac_core description: Continuous Design / Continuous Integration for Figma-to-Flutter -version: 2.8.2 +version: 3.0.0 # homepage: https://www.example.com environment: