mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-31 14:34:34 -04:00
Upgrade Self Updater (#3646)
* Fixes for createinvoicepdf * Filter properties which can be saved on free accounts * Update laravel self updater version * Upgrade self updater version * Rework Composer upate * Self Update
This commit is contained in:
parent
aa690578e3
commit
820f770ef8
@ -1,77 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Console\Commands;
|
|
||||||
|
|
||||||
use Composer\Composer;
|
|
||||||
use Composer\Factory;
|
|
||||||
use Composer\IO\NullIO;
|
|
||||||
use Composer\Installer;
|
|
||||||
use Illuminate\Console\Command;
|
|
||||||
use Illuminate\Support\Facades\Artisan;
|
|
||||||
use Symfony\Component\Console\Input\ArrayInput;
|
|
||||||
|
|
||||||
class ArtisanUpgrade extends Command
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* The name and signature of the console command.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $signature = 'ninja:post-update';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The console command description.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $description = 'Run basic upgrade commands';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a new command instance.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
parent::__construct();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Execute the console command.
|
|
||||||
*
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public function handle()
|
|
||||||
{
|
|
||||||
set_time_limit(0);
|
|
||||||
|
|
||||||
try {
|
|
||||||
Artisan::call('migrate');
|
|
||||||
} catch (Exception $e) {
|
|
||||||
\Log::error("I wasn't able to migrate the data.");
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
Artisan::call('optimize');
|
|
||||||
} catch (Exception $e) {
|
|
||||||
\Log::error("I wasn't able to optimize.");
|
|
||||||
}
|
|
||||||
|
|
||||||
$composer = Factory::create(new NullIO(), base_path('composer.json'), false);
|
|
||||||
|
|
||||||
$output = Installer::create(new NullIO, $composer)
|
|
||||||
->setVerbose()
|
|
||||||
->setUpdate(true)
|
|
||||||
->run();
|
|
||||||
|
|
||||||
\Log::error(print_r($output, 1));
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// putenv('COMPOSER_HOME=' . __DIR__ . '/vendor/bin/composer');
|
|
||||||
// $input = new ArrayInput(array('command' => 'update'));
|
|
||||||
// $application = new Application();
|
|
||||||
// $application->setAutoExit(true); // prevent `$application->run` method from exitting the script
|
|
||||||
// $application->run($input);
|
|
||||||
}
|
|
||||||
}
|
|
96
app/Console/Commands/PostUpdate.php
Normal file
96
app/Console/Commands/PostUpdate.php
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
|
use Composer\Composer;
|
||||||
|
use Composer\Factory;
|
||||||
|
use Composer\IO\NullIO;
|
||||||
|
use Composer\Installer;
|
||||||
|
use Illuminate\Console\Command;
|
||||||
|
use Illuminate\Support\Facades\Artisan;
|
||||||
|
use Symfony\Component\Console\Input\ArrayInput;
|
||||||
|
use Composer\Console\Application;
|
||||||
|
|
||||||
|
class PostUpdate extends Command
|
||||||
|
{
|
||||||
|
|
||||||
|
protected $name = 'ninja:post-update';
|
||||||
|
/**
|
||||||
|
* The name and signature of the console command.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $signature = 'ninja:post-update';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The console command description.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $description = 'Run basic upgrade commands';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the console command.
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
set_time_limit(0);
|
||||||
|
|
||||||
|
try {
|
||||||
|
Artisan::call('migrate');
|
||||||
|
} catch (Exception $e) {
|
||||||
|
\Log::error("I wasn't able to migrate the data.");
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
Artisan::call('optimize');
|
||||||
|
} catch (Exception $e) {
|
||||||
|
\Log::error("I wasn't able to optimize.");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$composer_data = array(
|
||||||
|
'url' => 'https://getcomposer.org/composer.phar',
|
||||||
|
'dir' => __DIR__.'/.code',
|
||||||
|
'bin' => __DIR__.'/.code/composer.phar',
|
||||||
|
'json' => __DIR__.'/.code/composer.json',
|
||||||
|
'conf' => array(
|
||||||
|
"autoload" => array(
|
||||||
|
"psr-4" => array(
|
||||||
|
"" => "local/"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if(!is_dir($composer_data['dir']))
|
||||||
|
mkdir($composer_data['dir'],0777,true);
|
||||||
|
|
||||||
|
if(!is_dir("{$composer_data['dir']}/local"))
|
||||||
|
mkdir("{$composer_data['dir']}/local",0777,true);
|
||||||
|
|
||||||
|
copy($composer_data['url'],$composer_data['bin']);
|
||||||
|
require_once "phar://{$composer_data['bin']}/src/bootstrap.php";
|
||||||
|
|
||||||
|
$conf_json = json_encode($composer_data['conf'],JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_UNICODE);
|
||||||
|
file_put_contents($composer_data['json'],$conf_json);
|
||||||
|
chdir($composer_data['dir']);
|
||||||
|
putenv("COMPOSER_HOME={$composer_data['dir']}");
|
||||||
|
putenv("OSTYPE=OS400");
|
||||||
|
$app = new \Composer\Console\Application();
|
||||||
|
|
||||||
|
$factory = new \Composer\Factory();
|
||||||
|
$output = $factory->createOutput();
|
||||||
|
|
||||||
|
$input = new \Symfony\Component\Console\Input\ArrayInput(array(
|
||||||
|
'command' => 'update',
|
||||||
|
));
|
||||||
|
$input->setInteractive(false);
|
||||||
|
echo "<pre>";
|
||||||
|
$cmdret = $app->doRun($input,$output);
|
||||||
|
echo "end!";
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
179
app/DataMapper/FreeCompanySettings.php
Normal file
179
app/DataMapper/FreeCompanySettings.php
Normal file
@ -0,0 +1,179 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Invoice Ninja (https://invoiceninja.com)
|
||||||
|
*
|
||||||
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||||
|
*
|
||||||
|
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
|
||||||
|
*
|
||||||
|
* @license https://opensource.org/licenses/AAL
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace App\DataMapper;
|
||||||
|
|
||||||
|
use App\DataMapper\CompanySettings;
|
||||||
|
use App\Utils\Traits\MakesHash;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* FreeCompanySettings
|
||||||
|
*/
|
||||||
|
|
||||||
|
class FreeCompanySettings extends BaseSettings
|
||||||
|
{
|
||||||
|
use MakesHash;
|
||||||
|
/*Group settings based on functionality*/
|
||||||
|
public $credit_design_id = 'VolejRejNm';
|
||||||
|
public $client_number_pattern = '';
|
||||||
|
public $client_number_counter = 1;
|
||||||
|
public $credit_number_pattern = '';
|
||||||
|
public $credit_number_counter = 1;
|
||||||
|
public $currency_id = '1';
|
||||||
|
public $custom_value1 = '';
|
||||||
|
public $custom_value2 = '';
|
||||||
|
public $custom_value3 = '';
|
||||||
|
public $custom_value4 = '';
|
||||||
|
public $date_format_id = '';
|
||||||
|
public $enabled_item_tax_rates = 0;
|
||||||
|
public $expense_number_pattern = '';
|
||||||
|
public $expense_number_counter = 1;
|
||||||
|
public $inclusive_taxes = false;
|
||||||
|
public $invoice_design_id = 'VolejRejNm';
|
||||||
|
public $invoice_number_pattern = '';
|
||||||
|
public $invoice_number_counter = 1;
|
||||||
|
public $invoice_taxes = 0;
|
||||||
|
public $language_id = '';
|
||||||
|
public $military_time = false;
|
||||||
|
public $payment_number_pattern = '';
|
||||||
|
public $payment_number_counter = 1;
|
||||||
|
public $payment_terms = -1;
|
||||||
|
public $payment_type_id = '0';
|
||||||
|
public $portal_design_id = '1';
|
||||||
|
public $quote_design_id = 'VolejRejNm';
|
||||||
|
public $quote_number_pattern = '';
|
||||||
|
public $quote_number_counter = 1;
|
||||||
|
public $timezone_id = '';
|
||||||
|
public $show_currency_code = false;
|
||||||
|
public $company_gateway_ids = '';
|
||||||
|
public $task_number_pattern = '';
|
||||||
|
public $task_number_counter = 1;
|
||||||
|
public $tax_name1 = '';
|
||||||
|
public $tax_rate1 = 0;
|
||||||
|
public $tax_name2 = '';
|
||||||
|
public $tax_rate2 = 0;
|
||||||
|
public $tax_name3 = '';
|
||||||
|
public $tax_rate3 = 0;
|
||||||
|
public $ticket_number_pattern = '';
|
||||||
|
public $ticket_number_counter = 1;
|
||||||
|
public $translations;
|
||||||
|
public $vendor_number_pattern = '';
|
||||||
|
public $vendor_number_counter = 1;
|
||||||
|
|
||||||
|
|
||||||
|
/* Company Meta data that we can use to build sub companies*/
|
||||||
|
|
||||||
|
public $address1 = '';
|
||||||
|
public $address2 = '';
|
||||||
|
public $city = '';
|
||||||
|
public $company_logo = '';
|
||||||
|
public $country_id;
|
||||||
|
public $email = '';
|
||||||
|
public $id_number = '';
|
||||||
|
public $name = '';
|
||||||
|
public $phone = '';
|
||||||
|
public $postal_code = '';
|
||||||
|
public $state = '';
|
||||||
|
public $vat_number = '';
|
||||||
|
public $website = '';
|
||||||
|
|
||||||
|
|
||||||
|
public static $casts = [
|
||||||
|
'portal_design_id' => 'string',
|
||||||
|
'currency_id' => 'string',
|
||||||
|
'task_number_pattern' => 'string',
|
||||||
|
'task_number_counter' => 'int',
|
||||||
|
'expense_number_pattern' => 'string',
|
||||||
|
'expense_number_counter' => 'int',
|
||||||
|
'vendor_number_pattern' => 'string',
|
||||||
|
'vendor_number_counter' => 'int',
|
||||||
|
'ticket_number_pattern' => 'string',
|
||||||
|
'ticket_number_counter' => 'int',
|
||||||
|
'payment_number_pattern' => 'string',
|
||||||
|
'payment_number_counter' => 'int',
|
||||||
|
'company_gateway_ids' => 'string',
|
||||||
|
'address1' => 'string',
|
||||||
|
'address2' => 'string',
|
||||||
|
'city' => 'string',
|
||||||
|
'company_logo' => 'string',
|
||||||
|
'country_id' => 'string',
|
||||||
|
'currency_id' => 'string',
|
||||||
|
'custom_value1' => 'string',
|
||||||
|
'custom_value2' => 'string',
|
||||||
|
'custom_value3' => 'string',
|
||||||
|
'custom_value4' => 'string',
|
||||||
|
'inclusive_taxes' => 'bool',
|
||||||
|
'name' => 'string',
|
||||||
|
'payment_terms' => 'integer',
|
||||||
|
'payment_type_id' => 'string',
|
||||||
|
'phone' => 'string',
|
||||||
|
'postal_code' => 'string',
|
||||||
|
'quote_design_id' => 'string',
|
||||||
|
'credit_design_id' => 'string',
|
||||||
|
'recurring_number_prefix' => 'string',
|
||||||
|
'state' => 'string',
|
||||||
|
'email' => 'string',
|
||||||
|
'vat_number' => 'string',
|
||||||
|
'id_number' => 'string',
|
||||||
|
'tax_name1' => 'string',
|
||||||
|
'tax_name2' => 'string',
|
||||||
|
'tax_name3' => 'string',
|
||||||
|
'tax_rate1' => 'float',
|
||||||
|
'tax_rate2' => 'float',
|
||||||
|
'tax_rate3' => 'float',
|
||||||
|
'timezone_id' => 'string',
|
||||||
|
'date_format_id' => 'string',
|
||||||
|
'military_time' => 'bool',
|
||||||
|
'language_id' => 'string',
|
||||||
|
'show_currency_code' => 'bool',
|
||||||
|
'design' => 'string',
|
||||||
|
'website' => 'string',
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cast object values and return entire class
|
||||||
|
* prevents missing properties from not being returned
|
||||||
|
* and always ensure an up to date class is returned
|
||||||
|
*
|
||||||
|
* @return \stdClass
|
||||||
|
*/
|
||||||
|
public function __construct($obj)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides class defaults on init
|
||||||
|
* @return object
|
||||||
|
*/
|
||||||
|
public static function defaults():\stdClass
|
||||||
|
{
|
||||||
|
$config = json_decode(config('ninja.settings'));
|
||||||
|
|
||||||
|
$data = (object) get_class_vars(CompanySettings::class);
|
||||||
|
|
||||||
|
unset($data->casts);
|
||||||
|
unset($data->protected_fields);
|
||||||
|
|
||||||
|
$data->timezone_id = (string) config('ninja.i18n.timezone_id');
|
||||||
|
$data->currency_id = (string) config('ninja.i18n.currency_id');
|
||||||
|
$data->language_id = (string) config('ninja.i18n.language_id');
|
||||||
|
$data->payment_terms = (int) config('ninja.i18n.payment_terms');
|
||||||
|
$data->military_time = (bool) config('ninja.i18n.military_time');
|
||||||
|
$data->date_format_id = (string) config('ninja.i18n.date_format_id');
|
||||||
|
$data->country_id = (string) config('ninja.i18n.country_id');
|
||||||
|
$data->translations = (object) [];
|
||||||
|
$data->pdf_variables = (object) self::getEntityVariableDefaults();
|
||||||
|
|
||||||
|
return self::setCasts($data, self::$casts);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -66,8 +66,14 @@ class SelfUpdateController extends BaseController
|
|||||||
return response()->json(['message' => 'Self update not available on this system.'], 403);
|
return response()->json(['message' => 'Self update not available on this system.'], 403);
|
||||||
}
|
}
|
||||||
|
|
||||||
$res = $updater->update();
|
// Get the new version available
|
||||||
|
$versionAvailable = $updater->source()->getVersionAvailable();
|
||||||
|
|
||||||
|
// Create a release
|
||||||
|
$release = $updater->source()->fetch($versionAvailable);
|
||||||
|
|
||||||
|
// Run the update process
|
||||||
|
$res = $updater->source()->update($release);
|
||||||
|
|
||||||
return response()->json(['message'=>$res], 200);
|
return response()->json(['message'=>$res], 200);
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
"asgrim/ofxparser": "^1.2",
|
"asgrim/ofxparser": "^1.2",
|
||||||
"ashallendesign/laravel-exchange-rates": "^2.1",
|
"ashallendesign/laravel-exchange-rates": "^2.1",
|
||||||
"cleverit/ubl_invoice": "^1.3",
|
"cleverit/ubl_invoice": "^1.3",
|
||||||
"codedge/laravel-selfupdater": "2.5.1",
|
"codedge/laravel-selfupdater": "~3.0",
|
||||||
"composer/composer": "^1.10",
|
"composer/composer": "^1.10",
|
||||||
"dacastro4/laravel-gmail": "^3.2",
|
"dacastro4/laravel-gmail": "^3.2",
|
||||||
"davejamesmiller/laravel-breadcrumbs": "5.x",
|
"davejamesmiller/laravel-breadcrumbs": "5.x",
|
||||||
|
@ -121,10 +121,13 @@ return [
|
|||||||
],
|
],
|
||||||
'post_update' => [
|
'post_update' => [
|
||||||
'ninja:post-update' => [
|
'ninja:post-update' => [
|
||||||
'class' => \App\Console\Commands\ArtisanUpgrade::class,
|
'class' => \App\Console\Commands\PostUpdate::class,
|
||||||
'params' => [],
|
'params' => [
|
||||||
],
|
'log' => 1,
|
||||||
|
'reset' => false,
|
||||||
|
// etc.
|
||||||
|
] ],
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
|
||||||
];
|
];
|
Loading…
x
Reference in New Issue
Block a user