Skip to content
This repository has been archived by the owner on Jan 25, 2024. It is now read-only.

Commit

Permalink
Merge branch 'stable' into release/2.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ivan-015 committed Mar 13, 2022
2 parents c1ade51 + b498860 commit bc7b649
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 14 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ The best way to run and test a component package is to use tools like Storybook.

_Be sure to use Figma Components_

To run the widgetbook, instead of running the normal `flutter run`, you want to run `flutter run lib/main_widgetbook.g.dart`.

# What's Next?
Be sure to complete our [Hello World Guide](https://docs.parabeac.com/docs/hello-world-guide) or read the [docs](https://docs.parabeac.com/) so you know how to handle the code generated.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ class EntryFileCommand extends NodeFileStructureCommand {
this.projectName = 'Parabeac-Core Generated Project',
this.mainCode = 'runApp(MyApp());',
FileOwnership ownership = FileOwnership.DEV})
: super('ENTRY_FILE', '''
: super(
'ENTRY_FILE',
'''
import 'package:flutter/material.dart';
$entryScreenImport
Expand All @@ -55,7 +57,8 @@ class MyApp extends StatelessWidget {
}
}
''', ownership) {
''',
ownership) {
if ((entryScreenImport == null && entryScreenName != null) ||
(entryScreenName == null && entryScreenName != null)) {
throw NullThrownError();
Expand All @@ -66,7 +69,6 @@ class MyApp extends StatelessWidget {
Future write(FileStructureStrategy strategy) {
strategy.writeDataToFile(
code, strategy.GENERATED_PROJECT_PATH, p.join('lib', mainFileName),
UUID: UUID,
ownership: ownership);
UUID: UUID, ownership: ownership);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,9 @@ class ExportPlatformCommand extends NodeFileStructureCommand {
static final String WIDGET_PATH = 'lib/screens';

ExportPlatformCommand(
String UUID,
this.platform,
this.folderName,
this.fileName,
String code,
{FileOwnership ownership = FileOwnership.PBC}
) : super(UUID, code, ownership);
String UUID, this.platform, this.folderName, this.fileName, String code,
{FileOwnership ownership = FileOwnership.PBC})
: super(UUID, code, ownership);

@override
Future write(FileStructureStrategy strategy) async {
Expand All @@ -28,6 +24,7 @@ class ExportPlatformCommand extends NodeFileStructureCommand {
folderName,
platform.toString().toLowerCase().replaceAll('platform.', ''),
);
strategy.writeDataToFile(code, path, fileName, UUID: UUID, ownership: ownership);
strategy.writeDataToFile(code, path, fileName,
UUID: UUID, ownership: ownership);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
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/file_ownership_policy.dart';
import 'package:path/path.dart';

/// Class that relies on `code` to implement its `write` method.
abstract class NodeFileStructureCommand extends FileStructureCommand {
Expand All @@ -9,7 +10,6 @@ abstract class NodeFileStructureCommand extends FileStructureCommand {
/// through [write]
FileOwnership ownership;

NodeFileStructureCommand(String UUID, this.code,
this.ownership)
NodeFileStructureCommand(String UUID, this.code, this.ownership)
: super(UUID);
}
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,10 @@ abstract class FileStructureStrategy implements CommandInvoker {
p.setExtension(
name, fileOwnershipPolicy.getFileExtension(ownership, ext)));

if (FileOwnership.PBC == ownership) {
data = _setHeader(data);
}

if (_fileSystemAnalyzer.containsFile(file.path) &&
ownership == FileOwnership.DEV) {
/// file is going to be ignored
Expand Down Expand Up @@ -248,6 +252,18 @@ abstract class FileStructureStrategy implements CommandInvoker {
}
}

String _setHeader(String code) {
return '''
// *********************************************************************************
// PARABEAC-GENERATED CODE. DO NOT MODIFY.
//
// FOR MORE INFORMATION ON HOW TO USE PARABEAC, PLEASE VISIT docs.parabeac.com
// *********************************************************************************
''' +
'\n\n' +
code;
}

File getFile(String directory, String name) => File(p.join(directory, name));
}

Expand Down

0 comments on commit bc7b649

Please sign in to comment.