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" } 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/generation/generators/middleware/command_gen_middleware.dart b/lib/generation/generators/middleware/command_gen_middleware.dart index 827593af..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), - relativePath: relativePath, + symbolPath: + p.join(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..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', ); @@ -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..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); @@ -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..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; @@ -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, )); }); 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/commands/write_symbol_command.dart b/lib/generation/generators/value_objects/file_structure_strategy/commands/write_symbol_command.dart index 42ebca2d..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 @@ -1,35 +1,38 @@ +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] + /// 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, 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); 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..b8678f86 --- /dev/null +++ b/lib/generation/generators/value_objects/file_structure_strategy/path_service.dart @@ -0,0 +1,52 @@ +/// 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; + final String customRelativePath; + final String constantsRelativePath; + PathService( + this.viewsRelativePath, + this.widgetsRelativePath, + this.customRelativePath, + this.constantsRelativePath, + ); + + 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(); + } + + /// If no architecture is set + /// we will return DomainPathService as default + return DomainPathService(); + } +} + +class DomainPathService extends PathService { + @override + final String viewsRelativePath = 'lib/views'; + @override + final String widgetsRelativePath = 'lib/widgets'; + @override + final String customRelativePath = 'custom'; + @override + final String constantsRelativePath = 'lib/constants'; + + DomainPathService({ + String viewsRelativePath, + String widgetsRelativePath, + String customRelativePath, + String constantsRelativePath, + }) : super( + viewsRelativePath, + widgetsRelativePath, + customRelativePath, + constantsRelativePath, + ); +} 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..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 @@ -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_WIDGET_PATH = + GetIt.I.get().widgetsRelativePath; ///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().viewsRelativePath; ///Path of where the project is generated final String GENERATED_PROJECT_PATH; @@ -103,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); 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, }; 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 = { 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, }; diff --git a/lib/main.dart b/lib/main.dart index f0ce2b10..8b954dfa 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) { @@ -310,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(); @@ -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; diff --git a/lib/tags/custom_tag/custom_tag.dart b/lib/tags/custom_tag/custom_tag.dart index 5cc84c59..0318439f 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,23 @@ 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().widgetsRelativePath; + static String DIRECTORY_CUSTOM = + GetIt.I.get().customRelativePath; @override String generate(PBIntermediateNode source, PBContext context) { + var customDirectory = + path.join(DIRECTORY_GEN, context.tree.name, DIRECTORY_CUSTOM); + var children = context.tree.childrenOf(source); var titleName = PBInputFormatter.formatLabel( source.name, @@ -94,7 +102,7 @@ class CustomTagGenerator extends PBGenerator { // TODO: correct import context.managerData.addImport(FlutterImport( - '$DIRECTORY_GEN/$cleanName.dart', + '$customDirectory/$cleanName.dart', MainInfo().projectName, )); @@ -109,8 +117,7 @@ class CustomTagGenerator extends PBGenerator { context, source, ), - relativePath: '$DIRECTORY_GEN', - symbolPath: 'lib', + symbolPath: '$customDirectory', ownership: FileOwnership.DEV, ), ); @@ -155,6 +162,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 +170,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 = 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, ), ); 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, )); diff --git a/pubspec.yaml b/pubspec.yaml index 260f1fcb..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: @@ -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 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/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( 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 =