Skip to content

Commit

Permalink
Merge branch 'rainlab:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
mediaclinic authored Feb 26, 2024
2 parents 0ea75bc + f6808ef commit 980012a
Show file tree
Hide file tree
Showing 56 changed files with 372 additions and 168 deletions.
42 changes: 3 additions & 39 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,41 +1,5 @@
Copyright (c) 2013-2021 Alexey Bobkov, Samuel Georges
# License

This End User License Agreement (hereinafter EULA) is a legal agreement between you and October CMS (Alexey Bobkov, Samuel Georges, hereinafter Author). The EULA applies to all distributed versions and modifications of October CMS and related software (hereinafter Software) from the Author. This EULA may be changed at any time by the Author, by substituting a new version of this EULA found on this website (octobercms.com). By installing, copying, or otherwise using the Software, you agree to be bound by the terms (hereinafter Terms) of this EULA.
This plugin is an official extension of the October CMS platform and is free to use if you have a platform license.

1. October CMS Software is a set of source code files (PHP scripts and associated materials like SQL scripts, reference manual and the text of this Agreement) designed to implement online (web-based) solutions and reproduced either in files or on paper including soft and/or hard copies.

2. By downloading the Software you acknowledge that you have read the EULA, and that you agree to the content of the EULA, and agree to use the Software in compliance with all of these terms and fully understand that these terms may be modified at any time by the Author.

3. The EULA comes into legal force at the moment you download this Software from our website or receive it through email or on data medium at the Author's discretion.

4. The Author is the copyright holder of the Software. The Software or a portion of it is a copyrightable matter and is liable to protection by the law. Any activity that infringes on these terms violates copyright law and will be prosecuted according to the current law.

5. The Software is distributed "AS IS" without warranties as to performance, merchantability, data integrity, and warranty of any kind, either expressed or implied. The Author is not liable for any damage or possible damage caused to you, your information and your business arising out of the use or inability to use this Software.

6. This EULA gives you the right to use only one licensed copy of the Software for a single website. A separate License should be acquired for each separate Software installation or website. A website is defined as a single installation of the Software that is accessible from a single platform and is controlled by a single back-end administration area and is operated by a single organization or person. Additionally, separate websites must have a corresponding Software license.

7. A Software installation can be accessed by multiple domain names, but accessing the website from these alternate domain names shall not vary the website's design, content or direct to a section of the website that is operated by a different organization or person. An alternately accessible domain can be used to initially develop the website, develop and test new features to the website, determine language translation or currency display or direct to a microsite as long as it is not operated as a separate website and does not violate any of the Terms of this EULA.

8. Any distribution of the Software without preliminary Author's consent, including noncommercial distribution, is regarded as a violation of this EULA and entails liability, according to the current law.

9. You have the right to make any changes to the initial code of the Software at your discretion. On condition that further on the Software is used in compliance with this EULA on condition of copyright reservation.

10. The Author is not liable to you for prosecution arising from the use of the Software against law (including, but not limited, selling prohibited products or products acquired as a result of criminal activity exasperating interracial or international antagonism and etc.).

11. Unlicensed Software installations are intended for evaluation and testing purposes only. An unlicensed Software installation cannot be used for any publicly accessible website except the case when the installation is intended to demonstrate an October CMS Plugin or Theme, so long as the demonstration is not used to sell or accept payment for any product or service, or promote any product or service unrelated to October CMS Plugins and Themes.

12. Sharing, distributing or transferring the Software or any portion of the Software to any third party is prohibited. It is strictly prohibited that any derivative works are distributed that are in any way based on the code within the original Software.

13. This EULA may be terminated in case you delete all received files, associated databases, documents and their copies and completely uninstall the Software. Termination of this Agreement does not bind the Author over to return you the funds spent for the purchase of the Software.

14. The Author reserves the right to deny any and all technical support if any core, original files that are part of the Software have been modified. The Author can deny technical support for any other breach of these Terms.

15. Copyright notices or text may not be removed from the administration area of the Software.

16. No person, company or organization is allowed to claim ownership, explicitly or implied that they are the authors or distributors of the Software.

17. The Author reserves the right to update and modify these Terms at any time without notice. New features that may be added to the Software shall be subject to the EULA. Should you continue to use the Software after any such modifications have been made, this shall constitute your agreement to such modifications. You may always view the most recent copy of the EULA here: https://octobercms.com/eula/

18. Ontario provincial law and any controlling Canadian federal law govern any action relating to these Terms. You agree to bring any and all such disputes (and irrevocably submit to personal jurisdiction and venue) in the province and federal courts located within the province of Ontario, Canada.

Violation of this EULA can result in prosecution according to the law, loss of rights to use the Software, denied technical or customer support or other results as deemed appropriate by the Author.
See End User License Agreement at https://octobercms.com/eula for more details.
12 changes: 0 additions & 12 deletions Plugin.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?php namespace RainLab\Deploy;

use System\Classes\PluginBase;
use System\Classes\CombineAssets;

/**
* Plugin
Expand All @@ -18,7 +17,6 @@ class Plugin extends PluginBase
*/
public function register()
{
$this->registerAssetBundles();
}

/**
Expand All @@ -27,14 +25,4 @@ public function register()
public function boot()
{
}

/**
* registerAssetBundles for compiling assets
*/
protected function registerAssetBundles()
{
CombineAssets::registerCallback(function ($combiner) {
$combiner->registerBundle('$/rainlab/deploy/assets/less/deploy.less');
});
}
}
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,15 @@ A simple way to deploy your application to a remote location.
- PHP openssl extension
- PHP eval function

### Installation

```
php artisan plugin:install rainlab.deploy
```

### Why is This Plugin Needed?

This plugin helps in cases where your remote server (production, staging, etc) does not have the ability to run the standard deployment workflow, either due to lack of computational resources or lack of service by the hosting provider. An example of this is shared hosting, where shell access is limited or composer does not have enough memory to execute.
This plugin helps in cases where your remote server (production, staging, etc) cannot use composer or where shell access is limited, an example of this is shared hosting.

### How It Works

Expand All @@ -20,8 +26,8 @@ The Deploy plugin works by creating a secure channel between your local develope

You may use this plugin as a solution to upgrading your website to a newer version of October CMS, for example, if want to upgrade a v1 website to use v2. Always **take a complete site backup** before performing these steps.

1. Install or upgrade to October CMS v2 locally on your machine
2. Deploy the Beacon files to the v1 site you want to upgrade
1. Install or upgrade to the latest October CMS version locally on your machine
2. Deploy the Beacon files to the older site you want to upgrade
3. The Deploy plugin will attempt to upgrade the site during its first deployment

If you need support with this process, feel free to [send an email to the helpdesk](https://octobercms.com/contact).
Expand Down
5 changes: 1 addition & 4 deletions assets/css/deploy.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion assets/less/deploy.less
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
.deploy-action {
border-bottom: 1px solid #d7e1ea;
border-bottom: 1px solid var(--bs-border-color, #d7e1ea);
padding: 10px 0 5px;
margin-top: -20px;

h5 {
margin-top: 0.75rem;
font-weight: 400;
font-size: 14px;
}

p {
color: #999;
}
Expand Down
20 changes: 9 additions & 11 deletions beacon/templates/app/.env.stub
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,21 @@ APP_URL={app_url}
APP_LOCALE=en

ACTIVE_THEME=demo
LINK_POLICY=detect

CMS_ROUTES_CACHE=false
CMS_ASSET_CACHE=false
CMS_DB_TEMPLATES=false

BACKEND_URI={backend_uri}

LOG_CHANNEL=single
CMS_ROUTE_CACHE=false
CMS_ASSET_CACHE=false
LINK_POLICY=detect
DEFAULT_FILE_MASK=775
DEFAULT_FOLDER_MASK=775

DB_CONNECTION={db_type}
DB_HOST={db_host}
DB_PORT={db_port}
DB_DATABASE={db_name}
DB_USERNAME={db_user}
DB_PASSWORD={db_pass}
DB_DATABASE="{db_name}"
DB_USERNAME="{db_user}"
DB_PASSWORD="{db_pass}"

LOG_CHANNEL=single
BROADCAST_DRIVER=log
CACHE_DRIVER=file
QUEUE_CONNECTION=sync
Expand Down
2 changes: 1 addition & 1 deletion beacon/templates/app/bootstrap/beacon.stub
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ function ocDeployScript($beaconVersion, $pubKey) {
$closure->execute();

$outputCode = $output->fetch();
$outputCode = preg_replace('/(?s)(<aside.*?<\/aside>)|Exit: Ctrl\+D/ms', '$2', $outputCode);
$outputCode = preg_replace('/(?s)(<aside.*?<\/aside>)|<whisper.*?<\/whisper>|Exit: Ctrl\+D/ms', '$2', $outputCode);

return trim($outputCode);
}
Expand Down
28 changes: 21 additions & 7 deletions beacon/templates/app/index.stub
Original file line number Diff line number Diff line change
@@ -1,11 +1,27 @@
<?php

/**
* October - The PHP platform that gets back to basics.
* October CMS - a Laravel-based platform engineered for simplicity.
*
* @package october/october
* @author Alexey Bobkov, Samuel Georges
*/

/*
|--------------------------------------------------------------------------
| Check If The Application Is Under Maintenance
|--------------------------------------------------------------------------
|
| If the application is in maintenance / demo mode via the "down" command
| we will load this file so that any pre-rendered content can be shown
| instead of starting the framework, which could cause an exception.
|
*/

if (file_exists($maintenance = __DIR__ . '/storage/framework/maintenance.php')) {
require $maintenance;
}

/*
|--------------------------------------------------------------------------
| Load deployment beacon
Expand All @@ -26,7 +42,7 @@ require __DIR__.'/bootstrap/beacon.php';
|
*/

require __DIR__.'/bootstrap/autoload.php';
require __DIR__ . '/bootstrap/autoload.php';

/*
|--------------------------------------------------------------------------
Expand All @@ -37,7 +53,7 @@ require __DIR__.'/bootstrap/autoload.php';
|
*/

$app = require_once __DIR__.'/bootstrap/app.php';
$app = require_once __DIR__ . '/bootstrap/app.php';

/*
|--------------------------------------------------------------------------
Expand All @@ -51,9 +67,7 @@ $app = require_once __DIR__.'/bootstrap/app.php';
$kernel = $app->make(\Illuminate\Contracts\Http\Kernel::class);

$response = $kernel->handle(
$request = Illuminate\Http\Request::capture()
);

$response->send();
$request = \Illuminate\Http\Request::capture()
)->send();

$kernel->terminate($request, $response);
30 changes: 30 additions & 0 deletions classes/ArchiveBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,36 @@ public function buildConfigFiles(string $outputFilePath)
]);
}

/**
* buildAppFiles builds the application files
*/
public function buildAppFiles(string $outputFilePath)
{
$this->buildArchive($outputFilePath, [
'dirs' => [
'app'
],
'dirsSrc' => [
'app' => base_path('app'),
]
]);
}

/**
* buildMediaFiles builds the media files in the storage directory
*/
public function buildMediaFiles(string $outputFilePath)
{
$this->buildArchive($outputFilePath, [
'dirs' => [
'storage/app/media'
],
'dirsSrc' => [
'storage/app/media' => base_path('storage/app/media'),
]
]);
}

/**
* buildCoreModules builds the core modules
*/
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "A simple way to deploy your application to a remote location.",
"license": "proprietary",
"require": {
"october/system": ">=2.1.20",
"october/rain": ">=2.1.20",
"composer/installers": "~1.0"
}
}
47 changes: 42 additions & 5 deletions controllers/Servers.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
use Db;
use Str;
use Flash;
use System;
use Config;
use Backend;
use Redirect;
use Response;
Expand Down Expand Up @@ -139,7 +141,7 @@ public function download($recordId = null)
}

$fileId = md5(uniqid());
$filePath = temp_path("ocbl-${fileId}.arc");
$filePath = temp_path("ocbl-{$fileId}.arc");

ArchiveBuilder::instance()->buildBeaconFiles($filePath, $pubKey);

Expand Down Expand Up @@ -312,6 +314,14 @@ public function manage_onSaveDeployToServer($serverId)
$useFiles[] = $this->buildArchiveDeployStep($deployActions, 'Config', 'buildConfigFiles');
}

if (post('deploy_app')) {
$useFiles[] = $this->buildArchiveDeployStep($deployActions, 'App', 'buildAppFiles');
}

if (post('deploy_media')) {
$useFiles[] = $this->buildArchiveDeployStep($deployActions, 'Media', 'buildMediaFiles');
}

if ($plugins = post('plugins')) {
$useFiles[] = $this->buildArchiveDeployStep($deployActions, 'Plugins', 'buildPluginsBundle', [(array) $plugins]);
}
Expand Down Expand Up @@ -536,7 +546,7 @@ public function manage_onRunUpgradeLegacy($serverId)
protected function buildArchiveDeployStep(&$steps, string $typeLabel, string $buildFunc, array $funcArgs = []): string
{
$fileId = md5(uniqid());
$filePath = temp_path("ocbl-${fileId}.arc");
$filePath = temp_path("ocbl-{$fileId}.arc");

$steps[] = [
'label' => __('Building :type Archive', ['type' => $typeLabel]),
Expand Down Expand Up @@ -588,16 +598,43 @@ protected function makeAllFormWidgets()

foreach ($this->formWidgetDefinitions as $key => $definition) {
$config = $this->makeConfig(base_path($definition));

$config->model = $server;

$config->alias = Str::camel($key);

$widget = $this->makeWidget(\Backend\Widgets\Form::class, $config);

$widget->bindToController();

$this->applyFormWidgetFilter($key, $widget);
$this->formWidgetInstances[$key] = $widget;
}

// Remove themes without module
if (!System::hasModule('Cms')) {
$deployWidget = $this->formWidgetInstances['deploy'];
$deployWidget->removeField('themes');
}
}

/**
* applyFormWidgetFilter
*/
protected function applyFormWidgetFilter($key, $widget)
{
// Hide the App Files field if no app directory is found
if (
$key === 'deploy' &&
!is_dir(app_path()) &&
($appField = $widget->getField('deploy_app'))
) {
$appField->hidden = true;
}

// Hide the media field is media storage is not local
if (
Config::get('filesystems.disks.media.driver') !== 'local' &&
($mediaField = $widget->getField('deploy_media'))
) {
$mediaField->hidden = true;
}
}
}
2 changes: 1 addition & 1 deletion controllers/servers/_action_form.htm
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<input type="hidden" name="server_id" value="<?= post('server_id') ?>" />

<div class="modal-header">
<div class="modal-header flex-row-reverse">
<button type="button" class="close" data-dismiss="popup">&times;</button>
<h4 class="modal-title"><?= e(__($actionTitle)) ?></h4>
</div>
Expand Down
2 changes: 1 addition & 1 deletion controllers/servers/_field_privatekey.htm
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
placeholder="<?= e(trans($field->placeholder)) ?>"
<?= $field->getAttributes() ?>><?= e($field->value) ?></textarea>

<p class="help-block">
<p class="help-block form-text">
<?= __("Paste an existing RSA private key in here or :action.", [
'action' => '<a href="javascript:generatePrivateKey()">'.__("generate a new one").'</a>'
]) ?>
Expand Down
2 changes: 1 addition & 1 deletion controllers/servers/_manage_scoreboard.htm
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ <h4><?= __("Beacon Status") ?></h4>
<?php if ($formModel->last_deploy_at): ?>
<div class="scoreboard-item title-value">
<h4><?= __("Current Version") ?></h4>
<p>v<?= $formModel->last_version ?: __('Unknown') ?></p>
<p><?= $formModel->last_version ? 'v'.$formModel->last_version : __('Unknown') ?></p>
<p class="description" title="<?= $formModel->last_deploy_at->diffForHumans() ?>">
<?= __("updated") ?>: <?= $formModel->last_deploy_at->toFormattedDateString() ?>
</p>
Expand Down
2 changes: 1 addition & 1 deletion controllers/servers/_shell_form.htm
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<input type="hidden" name="server_id" value="<?= post('server_id') ?>" />

<div class="modal-header">
<div class="modal-header flex-row-reverse">
<button type="button" class="close" data-dismiss="popup">&times;</button>
<h4 class="modal-title"><?= e(__($actionTitle)) ?></h4>
</div>
Expand Down
Loading

0 comments on commit 980012a

Please sign in to comment.