Skip to content

Commit

Permalink
Merge pull request #86 from uasoft-indonesia/develop
Browse files Browse the repository at this point in the history
Prepare release alpha.33
  • Loading branch information
rizkiheryandi authored May 11, 2021
2 parents 79adcc3 + 586c4e2 commit 884cce5
Show file tree
Hide file tree
Showing 81 changed files with 5,131 additions and 1,475 deletions.
6 changes: 5 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,16 @@
"larapack/doctrine-support": "~0.1.4",
"arcanedev/log-viewer": "4.2.1",
"spatie/laravel-activitylog": "3.2.2",
"spatie/laravel-analytics": "^3.11",
"spatie/laravel-backup": "5.12.1",
"spatie/flysystem-dropbox": "1.2.2",
"nao-pon/flysystem-google-drive": "1.1.13",
"league/flysystem-aws-s3-v3": "1.0.28",
"guzzlehttp/guzzle": "6.5.5",
"unisharp/laravel-filemanager": "2.2"
"unisharp/laravel-filemanager": "2.2",
"darkaonline/l5-swagger": "5.8.*",
"zircote/swagger-php": "3.*",
"symfony/var-exporter": "5.2"
},
"authors": [
{
Expand Down
2 changes: 1 addition & 1 deletion src/Badaso.php
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ public function getSupportedTableRelations()

public function getProtectedTables()
{
return config('badaso.hidden_tables', []);
return config('hidden-tables', []);
}

public function getBadasoCloudApi()
Expand Down
2 changes: 1 addition & 1 deletion src/Commands/BadasoFirebaseCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class BadasoFirebaseCommand extends Command
*
* @var string
*/
protected $name = 'badaso:firebase publish';
protected $name = 'badaso:firebase-sw';

/**
* The console command description.
Expand Down
160 changes: 156 additions & 4 deletions src/Commands/BadasoSetup.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Str;
use Symfony\Component\VarExporter\VarExporter;
use Uasoft\Badaso\Helpers\Firebase\FirebasePublishFile;

class BadasoSetup extends Command
{
Expand Down Expand Up @@ -53,13 +55,17 @@ public function handle()
{
$this->force = $this->options()['force'] == 'true' || $this->options()['force'] == null;

$this->addingBadasoEnv();
$this->updatePackageJson();
$this->updateWebpackMix();
$this->publishBadasoProvider();
$this->publishLaravelBackupProvider();
$this->publishLaravelActivityLogProvider();
$this->publishLaravelFileManager();
$this->publishLaravelAnalytics();
$this->publicFileFirebaseServiceWorker();
$this->uploadDefaultUserImage();
$this->addingBadasoAuthConfig();
}

protected function updatePackageJson()
Expand All @@ -68,6 +74,7 @@ protected function updatePackageJson()
$decoded_json = json_decode($package_json, true);
$decoded_json['devDependencies']['axios'] = '^0.18';
$decoded_json['devDependencies']['bootstrap'] = '^4.0.0';
$decoded_json['devDependencies']['copy-files-from-to'] = '^3.2.0';
$decoded_json['devDependencies']['popper.js'] = '^1.12';
$decoded_json['devDependencies']['cross-env'] = '^5.1';
$decoded_json['devDependencies']['jquery'] = '^3.2';
Expand All @@ -76,17 +83,20 @@ protected function updatePackageJson()
$decoded_json['devDependencies']['vue'] = '^2.5.7';

$decoded_json['dependencies']['@johmun/vue-tags-input'] = '^2.1.0';
$decoded_json['dependencies']['@tinymce/tinymce-vue'] = '^3';
$decoded_json['dependencies']['chart.js'] = '^2.8.0';
$decoded_json['dependencies']['jspdf'] = '^2.3.1';
$decoded_json['dependencies']['jspdf-autotable'] = '^3.5.14';
$decoded_json['dependencies']['luxon'] = '^1.25.0';
$decoded_json['dependencies']['moment'] = '^2.29.1';
$decoded_json['dependencies']['material-icons'] = '^0.3.1';
$decoded_json['dependencies']['prismjs'] = '^1.17.1';
$decoded_json['dependencies']['tinymce'] = '^5.7.1';
$decoded_json['dependencies']['vue-chartjs'] = '^3.4.2';
$decoded_json['dependencies']['vue-color'] = '^2.7.1';
$decoded_json['dependencies']['vue-datetime'] = '^1.0.0-beta.14';
$decoded_json['dependencies']['vue-draggable-nested-tree'] = '^3.0.0-beta2';
$decoded_json['dependencies']['vue-gtag'] = '^1.16.1';
$decoded_json['dependencies']['vue-i18n'] = '^8.22.4';
$decoded_json['dependencies']['vue-json-excel'] = '^0.3.0';
$decoded_json['dependencies']['uuid'] = '^8.3.2';
Expand All @@ -99,6 +109,13 @@ protected function updatePackageJson()
$decoded_json['dependencies']['vuex'] = '^3.1.1';
$decoded_json['dependencies']['vuex-persistedstate'] = '^4.0.0-beta.1';
$decoded_json['dependencies']['weekstart'] = '^1.0.1';
$decoded_json['dependencies']['firebase'] = '^8.4.2';

$decoded_json['scripts']['postinstall'] = 'copy-files-from-to';
$decoded_json['copyFiles'][0] = (object) [
'from' => 'node_modules/tinymce/**/*',
'to' => 'public/js/',
];

$encoded_json = json_encode($decoded_json, JSON_PRETTY_PRINT);
file_put_contents(base_path('package.json'), $encoded_json);
Expand Down Expand Up @@ -165,7 +182,7 @@ protected function publishLaravelActivityLogProvider()
{
$command_params = [
'--provider' => "Spatie\Activitylog\ActivitylogServiceProvider",
'--tag' => 'config',
'--tag' => 'config',
];
if ($this->force) {
$command_params['--force'] = true;
Expand All @@ -177,8 +194,12 @@ protected function publishLaravelActivityLogProvider()

protected function uploadDefaultUserImage()
{
$img = file_get_contents(public_path('/badaso-images/default-user.png'));
Storage::disk(config('badaso.storage.disk', 'public'))->put('users/default.png', $img);
try {
$img = file_get_contents(public_path('/badaso-images/default-user.png'));
Storage::disk(config('badaso.storage.disk', 'public'))->put('users/default.png', $img);
} catch (\Exception $e) {
$this->error('uploadDefaultImage '.$e->getMessage());
}
}

protected function publishLaravelFileManager()
Expand All @@ -189,6 +210,137 @@ protected function publishLaravelFileManager()
}
Artisan::call('vendor:publish', $command_params);

$this->info('Fime Manager provider published');
$this->info('File Manager provider published');
}

protected function publicFileFirebaseServiceWorker()
{
FirebasePublishFile::publishNow();
}

protected function addingBadasoAuthConfig()
{
try {
$path_config_auth = config_path('auth.php');
$config_auth = require $path_config_auth;

$config_auth['defaults'] = [
'guard' => 'badaso_guard',
'passwords' => 'users',
];
$config_auth['guards']['badaso_guard'] = [
'driver' => 'jwt',
'provider' => 'badaso_users',
];
$config_auth['providers']['badaso_users'] = [
'driver' => 'eloquent',
'model' => \Uasoft\Badaso\Models\User::class,
];

$exported_config_auth = VarExporter::export($config_auth);
$exported_config_auth = <<<PHP
<?php
return {$exported_config_auth} ;
PHP;
file_put_contents($path_config_auth, $exported_config_auth);
$this->info('Adding badaso auth config');
} catch (\Exception $e) {
$this->error('Failed adding badaso auth config ', $e->getMessage());
}
}

protected function envListUpload()
{
return [
'JWT_SECRET' => '',
'BADASO_AUTH_TOKEN_LIFETIME' => '',
'BADASO_LICENSE_KEY' => '',
'ARCANEDEV_LOGVIEWER_MIDDLEWARE' => '',
'MIX_DEFAULT_MENU' => 'admin',
'MIX_ADMIN_PANEL_ROUTE_PREFIX' => 'dashboard',
'MIX_API_ROUTE_PREFIX' => '',
'MIX_LOG_VIEWER_ROUTE' => '"log-viewer"',
'MIX_API_ROUTE_PREFIX' => 'admin',
'MIX_FIREBASE_API_KEY' => '',
'MIX_FIREBASE_AUTH_DOMAIN' => '',
'MIX_FIREBASE_PROJECT_ID' => '',
'MIX_FIREBASE_STORAGE_BUCKET' => '',
'MIX_FIREBASE_MESSAGE_SEENDER' => '',
'MIX_FIREBASE_APP_ID' => '',
'MIX_FIREBASE_MEASUREMENT_ID' => '',
'MIX_FIREBASE_WEB_PUSH_CERTIFICATES' => '',
'MIX_FIREBASE_SERVER_KEY' => '',
'FILESYSTEM_DRIVER' => 'public',
'AWS_ACCESS_KEY_ID' => '',
'AWS_SECRET_ACCESS_KEY' => '',
'AWS_DEFAULT_REGION' => '',
'AWS_BUCKET' => '',
'AWS_URL' => '',
'GOOGLE_DRIVE_CLIENT_ID' => '',
'GOOGLE_DRIVE_CLIENT_SECRET' => '',
'GOOGLE_DRIVE_REFRESH_TOKEN' => '',
'GOOGLE_DRIVE_FOLDER_ID' => '',
'DROPBOX_AUTH_TOKEN' => '',
'BACKUP_TARGET' => '',
'BACKUP_DISK' => '',
'MIX_DATE_FORMAT' => '',
'MIX_DATETIME_FORMAT' => '',
'MIX_TIME_FORMAT' => '',
'ANALYTICS_VIEW_ID' => '',
'MIX_ANALYTICS_TRACKING_ID' => '',
'MIX_API_DOCUMENTATION_ANNOTATION_ROUTE' => 'api-annotation',
'MIX_API_DOCUMENTATION_ROUTE' => 'api-docs',
];
}

protected function addingBadasoEnv()
{
try {
$env_path = base_path('.env');

$env_file = file_get_contents($env_path);
$arr_env_file = explode("\n", $env_file);

$env_will_adding = $this->envListUpload();

$new_env_adding = [];
foreach ($env_will_adding as $key_add_env => $val_add_env) {
$status_adding = true;
foreach ($arr_env_file as $key_env_file => $val_env_file) {
$val_env_file = trim($val_env_file);
if (substr($val_env_file, 0, 1) != '#' && $val_env_file != '' && strstr($val_env_file, $key_add_env)) {
$status_adding = false;
break;
}
}
if ($status_adding) {
$new_env_adding[] = "{$key_add_env}={$val_add_env}";
}
}

foreach ($new_env_adding as $index_env_add => $val_env_add) {
$arr_env_file[] = $val_env_add;
}

$env_file = join("\n", $arr_env_file);
file_put_contents($env_path, $env_file);

$this->info('Adding badaso env');
} catch (\Exception $e) {
$this->error('Failed adding badaso env '.$e->getMessage());
}
}

protected function publishLaravelAnalytics()
{
$command_params = [
'--provider' => "Spatie\Analytics\AnalyticsServiceProvider",
];
if ($this->force) {
$command_params['--force'] = true;
}
Artisan::call('vendor:publish', $command_params);

$this->info('Laravel analytics provider published');
}
}
33 changes: 33 additions & 0 deletions src/Config/analytics.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

return [

/*
* The view id of which you want to display data.
*/
'view_id' => env('ANALYTICS_VIEW_ID'),

/*
* Path to the client secret json file. Take a look at the README of this package
* to learn how to get this file. You can also pass the credentials as an array
* instead of a file path.
*/
'service_account_credentials_json' => storage_path('app/analytics/service-account-credentials.json'),

/*
* The amount of minutes the Google API responses will be cached.
* If you set this to zero, the responses won't be cached at all.
*/
'cache_lifetime_in_minutes' => 60 * 24,

/*
* Here you may configure the "store" that the underlying Google_Client will
* use to store it's data. You may also add extra parameters that will
* be passed on setCacheConfig (see docs for google-api-php-client).
*
* Optional parameters: "lifetime", "prefix"
*/
'cache' => [
'store' => 'file',
],
];
34 changes: 14 additions & 20 deletions src/Config/badaso.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,6 @@
'storage' => [
'disk' => env('FILESYSTEM_DRIVER', 'public'),
],
'hidden_tables' => [ // this table will not shown on CRUD generator
'activity_log',
'data_rows',
'data_types',
'migrations',
'password_resets',
'menus',
'menu_items',
'users',
'roles',
'permissions',
'configurations',
'role_permissions',
'user_roles',
'user_verifications',
'email_resets',
'f_c_m_messages',
'firebase_cloud_messages',
'firebase_services',
],
'watch_tables' => [
// table names for generating CRUD_DATA seeders.
],
Expand All @@ -40,4 +20,18 @@
'Uasoft\\Badaso\\Widgets\\RoleWidget',
'Uasoft\\Badaso\\Widgets\\PermissionWidget',
],
'whitelist' => [
'web' => [],
'badaso' => [
'/maintenance',
'/login',
],
'api' => [
'/v1/verify-badaso',
'/v1/configurations/applyable',
'/v1/maintenance',
'/v1/auth/login',
'/v1/file/*',
],
],
];
21 changes: 21 additions & 0 deletions src/Config/hidden-tables.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

return [
'activity_log',
'data_rows',
'data_types',
'migrations',
'password_resets',
'menus',
'menu_items',
'users',
'roles',
'permissions',
'configurations',
'role_permissions',
'user_roles',
'user_verifications',
'email_resets',
'f_c_m_messages',
'firebase_cloud_messages',
];
Loading

0 comments on commit 884cce5

Please sign in to comment.