Skip to content

Commit

Permalink
Compile templates
Browse files Browse the repository at this point in the history
  • Loading branch information
ferrarafer committed Apr 10, 2023
1 parent ca24dfd commit 6daecf3
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 163 deletions.
121 changes: 73 additions & 48 deletions lib/src/templates/compiled_template_map.dart
Original file line number Diff line number Diff line change
Expand Up @@ -281,18 +281,21 @@ Map<String, Map<String, StackedTemplate>> kCompiledStackedTemplates = {
relativeModificationPath: 'lib/app/app.dart',
modificationIdentifier: '// @stacked-dialog',
modificationTemplate: '''StackedDialog(classType: {{dialogName}}),''',
modificationProblemError: 'The dialog registration should be stored in lib/app/app.dart',
modificationName: 'Add \'{{dialogName}}\' dependency to StackedApp annotations file',
modificationProblemError:
'The dialog registration should be stored in lib/app/app.dart',
modificationName:
'Add \'{{dialogName}}\' dependency to StackedApp annotations file',
),

ModificationFile(
relativeModificationPath: 'lib/app/app.dart',
modificationIdentifier: '// @stacked-import',
modificationTemplate: '''import \'package:{{packageName}}/{{{dialogsPath}}}/{{dialogFolderName}}/{{dialogFilename}}\';''',
modificationProblemError: 'The dialog registration should be stored in lib/app/app.dart',
modificationTemplate:
'''import \'package:{{packageName}}/{{{dialogsPath}}}/{{dialogFolderName}}/{{dialogFilename}}\';''',
modificationProblemError:
'The dialog registration should be stored in lib/app/app.dart',
modificationName: 'Add import for \'{{dialogName}}\' class',
),
],
],
),
},
'view': {
Expand Down Expand Up @@ -320,18 +323,22 @@ Map<String, Map<String, StackedTemplate>> kCompiledStackedTemplates = {
relativeModificationPath: 'lib/app/app.dart',
modificationIdentifier: '// @stacked-route',
modificationTemplate: '''MaterialRoute(page: {{viewName}}),''',
modificationProblemError: 'The structure of your stacked application is invalid. The app.dart file should be located in lib/app/',
modificationName: 'Add {{viewName}} route where @StackedApp annotation is located',
modificationProblemError:
'The structure of your stacked application is invalid. The app.dart file should be located in lib/app/',
modificationName:
'Add {{viewName}} route where @StackedApp annotation is located',
),

ModificationFile(
relativeModificationPath: 'lib/app/app.dart',
modificationIdentifier: '// @stacked-import',
modificationTemplate: '''import \'package:{{packageName}}/{{{viewImportPath}}}/{{viewFolderName}}/{{viewFileName}}\';''',
modificationProblemError: 'The structure of your stacked application is invalid. The app.dart file should be located in lib/app/',
modificationName: 'Add {{viewName}} route import where @StackedApp annotation is located',
modificationTemplate:
'''import \'package:{{packageName}}/{{{viewImportPath}}}/{{viewFolderName}}/{{viewFileName}}\';''',
modificationProblemError:
'The structure of your stacked application is invalid. The app.dart file should be located in lib/app/',
modificationName:
'Add {{viewName}} route import where @StackedApp annotation is located',
),
],
],
),
'web': StackedTemplate(
templateFiles: [
Expand Down Expand Up @@ -365,18 +372,22 @@ Map<String, Map<String, StackedTemplate>> kCompiledStackedTemplates = {
relativeModificationPath: 'lib/app/app.dart',
modificationIdentifier: '// @stacked-route',
modificationTemplate: '''CustomRoute(page: {{viewName}}),''',
modificationProblemError: 'The structure of your stacked application is invalid. The app.dart file should be located in lib/app/',
modificationName: 'Add {{viewName}} route where @StackedApp annotation is located',
modificationProblemError:
'The structure of your stacked application is invalid. The app.dart file should be located in lib/app/',
modificationName:
'Add {{viewName}} route where @StackedApp annotation is located',
),

ModificationFile(
relativeModificationPath: 'lib/app/app.dart',
modificationIdentifier: '// @stacked-import',
modificationTemplate: '''import \'package:{{packageName}}/{{{viewImportPath}}}/{{viewFolderName}}/{{viewFileName}}\';''',
modificationProblemError: 'The structure of your stacked application is invalid. The app.dart file should be located in lib/app/',
modificationName: 'Add {{viewName}} route import where @StackedApp annotation is located',
modificationTemplate:
'''import \'package:{{packageName}}/{{{viewImportPath}}}/{{viewFolderName}}/{{viewFileName}}\';''',
modificationProblemError:
'The structure of your stacked application is invalid. The app.dart file should be located in lib/app/',
modificationName:
'Add {{viewName}} route import where @StackedApp annotation is located',
),
],
],
),
},
'service': {
Expand All @@ -395,71 +406,81 @@ Map<String, Map<String, StackedTemplate>> kCompiledStackedTemplates = {
ModificationFile(
relativeModificationPath: 'test/helpers/test_helpers.dart',
modificationIdentifier: '// @stacked-mock-create',
modificationTemplate: '''Mock{{serviceName}} getAndRegister{{serviceName}}() {
modificationTemplate:
'''Mock{{serviceName}} getAndRegister{{serviceName}}() {
_removeRegistrationIfExists<{{serviceName}}>();
final service = Mock{{serviceName}}();
{{locatorName}}.registerSingleton<{{serviceName}}>(service);
return service;
}''',
modificationProblemError: 'The test mocks and helpers should be stored in test/helpers/test_helpers.dart',
modificationProblemError:
'The test mocks and helpers should be stored in test/helpers/test_helpers.dart',
modificationName: 'Add {{serviceName}} mock to test helpers',
),

ModificationFile(
relativeModificationPath: 'lib/app/app.dart',
modificationIdentifier: '// @stacked-service',
modificationTemplate: '''LazySingleton(classType: {{serviceName}}),''',
modificationProblemError: 'The service registration should be stored in lib/app/app.dart',
modificationName: 'Add {{serviceName}} dependency to StackedApp annotations file',
modificationTemplate:
'''LazySingleton(classType: {{serviceName}}),''',
modificationProblemError:
'The service registration should be stored in lib/app/app.dart',
modificationName:
'Add {{serviceName}} dependency to StackedApp annotations file',
),

ModificationFile(
relativeModificationPath: 'lib/app/app.dart',
modificationIdentifier: '// @stacked-import',
modificationTemplate: '''import \'package:{{packageName}}/{{{serviceImportPath}}}/{{serviceFilename}}\';''',
modificationProblemError: 'The service registration should be stored in lib/app/app.dart',
modificationName: 'Add {{serviceName}} import to StackedApp annotations file',
modificationTemplate:
'''import \'package:{{packageName}}/{{{serviceImportPath}}}/{{serviceFilename}}\';''',
modificationProblemError:
'The service registration should be stored in lib/app/app.dart',
modificationName:
'Add {{serviceName}} import to StackedApp annotations file',
),

ModificationFile(
relativeModificationPath: 'test/helpers/test_helpers.dart',
modificationIdentifier: '// @stacked-mock-spec',
modificationTemplate: '''MockSpec<{{serviceName}}>(onMissingStub: OnMissingStub.returnDefault),''',
modificationProblemError: 'The test mocks and helpers should be stored in test/helpers/test_helpers.dart',
modificationTemplate:
'''MockSpec<{{serviceName}}>(onMissingStub: OnMissingStub.returnDefault),''',
modificationProblemError:
'The test mocks and helpers should be stored in test/helpers/test_helpers.dart',
modificationName: 'Create {{serviceName}} mock to test helpers',
),

ModificationFile(
relativeModificationPath: 'test/helpers/test_helpers.dart',
modificationIdentifier: '// @stacked-mock-register',
modificationTemplate: '''getAndRegister{{serviceName}}();''',
modificationProblemError: 'The test mocks and helpers should be stored in test/helpers/test_helpers.dart',
modificationProblemError:
'The test mocks and helpers should be stored in test/helpers/test_helpers.dart',
modificationName: 'Add {{serviceName}} register to test helpers',
),

ModificationFile(
relativeModificationPath: 'test/helpers/test_helpers.dart',
modificationIdentifier: '// @stacked-import',
modificationTemplate: '''import \'package:{{packageName}}/{{{serviceImportPath}}}/{{serviceFilename}}\';''',
modificationProblemError: 'It seems your test_helpers.dart file is not in test/helpers/test_helpers.dart. Add a stacked.json file and set the path for \'test_helpers_path\' to the folder we can locate your test_helpers.dart file',
modificationTemplate:
'''import \'package:{{packageName}}/{{{serviceImportPath}}}/{{serviceFilename}}\';''',
modificationProblemError:
'It seems your test_helpers.dart file is not in test/helpers/test_helpers.dart. Add a stacked.json file and set the path for \'test_helpers_path\' to the folder we can locate your test_helpers.dart file',
modificationName: 'Add {{serviceName}} import to test helpers',
),
],
],
),
},
'bottom_sheet': {
'empty': StackedTemplate(
templateFiles: [
TemplateFile(
relativeOutputPath: kBottomSheetEmptyTemplateGenericSheetModelTestPath,
relativeOutputPath:
kBottomSheetEmptyTemplateGenericSheetModelTestPath,
content: kBottomSheetEmptyTemplateGenericSheetModelTestContent,
fileType: FileType.text),
TemplateFile(
relativeOutputPath: kBottomSheetEmptyTemplateGenericSheetModelPath,
content: kBottomSheetEmptyTemplateGenericSheetModelContent,
fileType: FileType.text),
TemplateFile(
relativeOutputPath: kBottomSheetEmptyTemplateGenericSheetUseModelPath,
relativeOutputPath:
kBottomSheetEmptyTemplateGenericSheetUseModelPath,
content: kBottomSheetEmptyTemplateGenericSheetUseModelContent,
fileType: FileType.text),
TemplateFile(
Expand All @@ -471,19 +492,23 @@ return service;
ModificationFile(
relativeModificationPath: 'lib/app/app.dart',
modificationIdentifier: '// @stacked-bottom-sheet',
modificationTemplate: '''StackedBottomsheet(classType: {{sheetName}}),''',
modificationProblemError: 'The bottom sheet registration should be stored in lib/app/app.dart',
modificationName: 'Add \'{{sheetName}}\' dependency to StackedApp annotations file',
modificationTemplate:
'''StackedBottomsheet(classType: {{sheetName}}),''',
modificationProblemError:
'The bottom sheet registration should be stored in lib/app/app.dart',
modificationName:
'Add \'{{sheetName}}\' dependency to StackedApp annotations file',
),

ModificationFile(
relativeModificationPath: 'lib/app/app.dart',
modificationIdentifier: '// @stacked-import',
modificationTemplate: '''import \'package:{{packageName}}/{{{bottomSheetsPath}}}/{{sheetFolderName}}/{{sheetFilename}}\';''',
modificationProblemError: 'The bottom sheet registration should be stored in lib/app/app.dart',
modificationTemplate:
'''import \'package:{{packageName}}/{{{bottomSheetsPath}}}/{{sheetFolderName}}/{{sheetFilename}}\';''',
modificationProblemError:
'The bottom sheet registration should be stored in lib/app/app.dart',
modificationName: 'Add import for \'{{sheetName}}\' class',
),
],
],
),
},
};
Loading

0 comments on commit 6daecf3

Please sign in to comment.