| 1 | #!/usr/local/bin/perl | ||
| 2 | use FindBin; | ||
| 3 | BEGIN { unshift @INC, "$FindBin::Bin/../lib" } | ||
| 4 | |||
| 5 | use v5.40; | ||
| 6 | use Moo; | ||
| 7 | use MooX::Options; | ||
| 8 | use Cwd; | ||
| 9 | |||
| 10 | use feature 'say'; | ||
| 11 | use feature 'signatures'; | ||
| 12 | use Daje::Workflow::Database; | ||
| 13 | use Daje::Workflow::Loader; | ||
| 14 | use Daje::Workflow; | ||
| 15 | use Mojo::Pg; | ||
| 16 | use Daje::Workflow::Errors::Error; | ||
| 17 | |||
| 18 | use namespace::clean -except => [qw/_options_data _options_config/]; | ||
| 19 | |||
| 20 | sub run_workflow() { | ||
| 21 | |||
| 22 | my $pg = Mojo::Pg->new()->dsn( | ||
| 23 | "dbi:Pg:dbname=Workflowtest;host=database;port=54321;user=test;password=test" | ||
| 24 | ); | ||
| 25 | |||
| 26 | my $migrations; | ||
| 27 | push @{$migrations}, { | ||
| 28 | class => 'Daje::Workflow::Database', name => 'workflow', migration => 3 | ||
| 29 | }; | ||
| 30 | push @{$migrations}, { | ||
| 31 | class => 'Daje::Workflow::FileChanged::Database::DB', | ||
| 32 | name => 'file_changed', | ||
| 33 | migration => 1 | ||
| 34 | }; | ||
| 35 | |||
| 36 | Daje::Workflow::Database->new( | ||
| 37 | pg => $pg, | ||
| 38 | migrations => $migrations, | ||
| 39 | )->migrate(); | ||
| 40 | |||
| 41 | my $loader = Daje::Workflow::Loader->new( | ||
| 42 | path => '/home/jan/Project/Daje-Workflow-Workflows/Workflows', | ||
| 43 | type => 'workflow', | ||
| 44 | ); | ||
| 45 | $loader->load(); | ||
| 46 | my $context->{context}->{sql_path} = '/home/jan/Project/SyntaxSorcery/Tools/Generate/conf/generate_sql.ini'; | ||
| 47 | $context->{context}->{perl_path} = '/home/jan/Project/SyntaxSorcery/Tools/Generate/conf/generate_perl.ini'; | ||
| 48 | $context->{context}->{source_dir} = '/home/jan/Project/Daje-Schema/Users/'; | ||
| 49 | $context->{context}->{sql_target_dir} = '/home/jan/Project/SyntaxSorcery/Tools/Generate/Sql/'; | ||
| 50 | $context->{context}->{data_dir} = '/home/jan/Project/SyntaxSorcery/Tools/Generate/schema/'; | ||
| 51 | $context->{context}->{target_dir} = '/home/jan/Project/SyntaxSorcery/Tools/Generate/schema/'; | ||
| 52 | $context->{context}->{dbconn} = "dbi:Pg:dbname=DB;host=database;port=54321;user=test;password=test"; | ||
| 53 | |||
| 54 | |||
| 55 | $context->{context}->{schema_dir}="/home/jan/Project/Daje-Database/schema/"; | ||
| 56 | $context->{context}->{perl}->{name_space_dir}="/home/jan/Project/Daje-Database-Model/lib/Daje/Database/Model/Super/"; | ||
| 57 | $context->{context}->{perl}->{view_name_space_dir}="/home/jan/Project/Daje-Database-Model/lib/Daje/Database/View/Super/"; | ||
| 58 | $context->{context}->{perl}->{base_space_dir}="/home/jan/Project/Daje-Database-Model/lib/Daje/Database/Model/Super/Common/"; | ||
| 59 | $context->{context}->{perl}->{interface_space_dir}="/home/jan/Project/Daje-Database/lib/Daje/Database/Model/"; | ||
| 60 | $context->{context}->{perl}->{view_interface_space_dir}="/home/jan/Project/Daje-Database-Model/lib/Daje/Database/View/"; | ||
| 61 | |||
| 62 | $context->{context}->{perl}->{name_space}="Daje::Database::Model::Super::"; | ||
| 63 | $context->{context}->{perl}->{view_name_space}="Daje::Database::View::Super::"; | ||
| 64 | $context->{context}->{perl}->{base_name_space}="Daje::Database::Model::Super::Common::"; | ||
| 65 | $context->{context}->{perl}->{name_interface}="Daje::Database::Model::"; | ||
| 66 | $context->{context}->{perl}->{view_name_interface}="Daje::Database::View::"; | ||
| 67 | |||
| 68 | # my $context; | ||
| 69 | my $workflow = Daje::Workflow->new( | ||
| 70 | pg => $pg, | ||
| 71 | loader => $loader->loader, | ||
| 72 | workflow_name => 'generate', | ||
| 73 | workflow_pkey => '15', | ||
| 74 | context => $context, | ||
| 75 | ); | ||
| 76 | # changed_files | ||
| 77 | # generate_sql | ||
| 78 | # save_sql_file | ||
| 79 | # generate_schema | ||
| 80 | # save_schema_file | ||
| 81 | # generate_perl | ||
| 82 | # save_perl_file | ||
| 83 | # | ||
| 84 | # generatePerl | ||
| 85 | # | ||
| 86 | $workflow->process("save_perl_file"); | ||
| 87 | say $workflow->error->error if $workflow->error->has_error() ; | ||
| 88 | |||
| 89 | } | ||
| 90 | |||
| 91 | run_workflow(); | ||
| 92 | |||
| 93 | 1; |