Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
BernhardBaumrock committed Jan 13, 2025
2 parents 455f973 + 10702f3 commit 55dc2eb
Show file tree
Hide file tree
Showing 27 changed files with 142 additions and 92 deletions.
15 changes: 15 additions & 0 deletions RockMigrations.module.php
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,7 @@ public function basename($file)

protected function beforeModuleInstall(HookEvent $event): void
{
if (wire()->config->noConfigMigrations) return;
$moduleName = $event->arguments(0);
$moduleDir = dirname(wire()->modules->getModuleFile($moduleName));
$migrationsDir = $moduleDir . '/RockMigrations';
Expand Down Expand Up @@ -743,6 +744,20 @@ public function columnWidth(InputfieldWrapper $form, array $fields)
}
}

/**
* Enable/disable config migrations temporarily
*
* This is helpful when installing dependencies causes an endless loop. To
* fix this you can call configMigrations(false) before installing the
* dependency and configMigrations(true) after installing the dependency.
*
* @return void
*/
public function configMigrations(bool $enable): void
{
wire()->config->noConfigMigrations = !$enable;
}

/**
* Thx Adrian
* https://github.com/adrianbj/ProcessAdminActions/blob/master/actions/CopyRepeaterItemsToOtherPage.action.php
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 0 additions & 3 deletions docs/deploy-1/readme.md

This file was deleted.

28 changes: 28 additions & 0 deletions docs/deploy-advanced/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Deployments Advanced

## Customising Deployments

You can customise the deployment process by creating a custom `deploy.php` file in your site directory. This file will be executed instead of the default `deploy.php` file in the `site/modules/RockMigrations` folder.

A good example are translations. ProcessWire stores translations in `/site/assets/files/{languageID}/...`. When having multiple environments (dev/staging/production), where do you translate your translatable strings?

I recommend to handle translations just like code features. This means we work on them on development and then push them to staging or production.

Now we have a problem, because usually during deployments we exclude `/site/assets/files` from the deployment process to not lose any user data. How to solve this?

We can tell RockMigrations to `push` certain directories during the deployment process, which will make sure that if we change translations on development, they are also pushed to staging and production:

```php
<?php

namespace RockMigrations;

$deploy = new Deployment($argv ?? []);

$deploy->push("site/assets/files/1030"); // german translations
$deploy->push("site/assets/files/1031"); // english translations

$deploy->run();
```

This will tell RockMigrations to grab those folders from the checked out repository and push them to the remote server, overwriting any existing files.
6 changes: 3 additions & 3 deletions snippets/RockMigrations/rmf-checkbox.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// rmf-checkbox
$1 => [
return [
'type' => 'checkbox',
'label' => '$2',
],
'label' => '$1',
];
6 changes: 3 additions & 3 deletions snippets/RockMigrations/rmf-datetime.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// Add an image field via RockMigrations
$1 => [
return [
'type' => 'datetime',
'label' => '$2',
'label' => '$1',
'dateOutputFormat' => 'd.m.Y H:i',
'inputType' => 'text',
'dateSelectFormat' => 'yMd',
'datepicker' => InputfieldDatetime::datepickerFocus,
'dateInputFormat' => 'j.n.y',
'timeInputFormat' => 'H:i',
'defaultToday' => 1,
],
];
11 changes: 4 additions & 7 deletions snippets/RockMigrations/rmf-fieldset.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
// Add a fieldset (open+close)
$1 => [
return [
'type' => 'FieldsetOpen',
'label' => '$2',
'icon' => '$3',
],
$1 . "_END" => [
'type' => 'FieldsetClose',
],
'label' => '$1',
'icon' => '$2',
];
4 changes: 2 additions & 2 deletions snippets/RockMigrations/rmf-fieldsetpage.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Add a fieldsetpage field via RockMigrations
$1 => [
return [
'label' => 'FieldsetPage Label',
'type' => 'FieldtypeFieldsetPage',
'fields' => [
Expand All @@ -13,4 +13,4 @@ $1 => [
'tags' => '',
'columnWidth' => 100,
'icon' => 'cubes',
],
];
12 changes: 6 additions & 6 deletions snippets/RockMigrations/rmf-files.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// Add a files field via RockMigrations
$1 => [
return [
'type' => 'file',
'label' => '$2',
'maxFiles' => $4,
'descriptionRows' => $5,
'extensions' => '${6:mp4 pdf xlsx}',
'label' => '$1',
'maxFiles' => $2,
'descriptionRows' => $3,
'extensions' => '${4:mp4 pdf xlsx}',
'icon' => 'files-o',
'outputFormat' => FieldtypeFile::outputFormatArray,
],
];
14 changes: 7 additions & 7 deletions snippets/RockMigrations/rmf-image.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// Add an image field via RockMigrations
$1 => [
return [
'type' => 'image',
'label' => '$2',
'maxFiles' => $4,
'descriptionRows' => $5,
'extensions' => '${6:jpg jpeg gif png svg}',
'maxSize' => ${7:3}, // max 3 megapixels
'label' => '$1',
'maxFiles' => $2,
'descriptionRows' => $3,
'extensions' => '${4:jpg jpeg gif png svg}',
'maxSize' => ${5:3}, // max 3 megapixels
'okExtensions' => ['svg'],
'icon' => 'picture-o',
'outputFormat' => FieldtypeFile::outputFormatSingle,
'gridMode' => 'grid', // grid, left, list
],
];
10 changes: 5 additions & 5 deletions snippets/RockMigrations/rmf-imagepicker.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// rmf-imagepicker
$1 => [
return [
'type' => 'RockImagePicker',
'label' => '$2',
'sourcepage' => ${3:1},
'sourcefield' => '${4:yourfieldname}',
],
'label' => '$1',
'sourcepage' => ${2:1},
'sourcefield' => '${3:yourfieldname}',
];
6 changes: 3 additions & 3 deletions snippets/RockMigrations/rmf-integer.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Add an integer field via RockMigrations
$1 => [
return [
'type' => 'integer',
'label' => '$3',
'label' => '$1',
'icon' => 'list-ol',
],
];
6 changes: 3 additions & 3 deletions snippets/RockMigrations/rmf-money.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Add a RockMoney field via RockMigrations
$1 => [
return [
'type' => 'RockMoney',
'label' => '$2',
'label' => '$1',
'icon' => 'money',
],
];
6 changes: 3 additions & 3 deletions snippets/RockMigrations/rmf-options.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// Add a options field via RockMigrations
$1 => [
return [
'type' => 'options',
'label' => '$2',
'label' => '$1',
'icon' => 'cubes',
'options' => [
1 => 'ONE|This is option one',
2 => 'TWO',
3 => 'THREE',
],
],
];
27 changes: 20 additions & 7 deletions snippets/RockMigrations/rmf-page.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,22 @@
// Add a page field via RockMigrations
$1 => [
return [
'type' => 'page',
'label' => '$2',
'derefAsPage' => ${4:FieldtypePage::derefAsPageOrFalse},
'inputfield' => ${5:'InputfieldPageListSelect'},
'findPagesSelector' => '${6:id>0,template!=admin}',
'labelFieldName' => ${7:'title'},
],
'label' => '$1',
'derefAsPage' => ${2:FieldtypePage::derefAsPageOrFalse},
// inputfield options:
// - InputfieldSelect // Select
// - InputfieldRadios // Radio Buttons
// - InputfieldPageListSelect // Page List Select
// - InputfieldPageAutocomplete // Page Auto Complete (single)
// - InputfieldTextTags // Text Tags (single)
// - InputfieldSelectMultiple // Select Multiple
// - InputfieldCheckboxes // Checkboxes
// - InputfieldAsmSelect // AsmSelect
// - InputfieldPageAutocomplete // Page Auto Complete
// - InputfieldTextTags // Text Tags
// - InputfieldPageListSelectMultiple // Page List Select Multiple
'inputfield' => ${3:'InputfieldPageListSelect'},
'findPagesSelector' => '${4:id>0,template!=admin}',
'labelFieldName' => '${5:title}',
'icon' => '${6:link}',
];
6 changes: 3 additions & 3 deletions snippets/RockMigrations/rmf-repeater.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Add a repeater field via RockMigrations
$1 => [
'label' => '$2',
return [
'label' => '$1',
'type' => 'FieldtypeRepeater',
'fields' => [
'title',
Expand All @@ -13,4 +13,4 @@ $1 => [
'tags' => '',
'repeaterAddLabel' => 'Add New Item',
'columnWidth' => 100,
],
];
10 changes: 5 additions & 5 deletions snippets/RockMigrations/rmf-rockgrid.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Add a RockGrid field via RockMigrations
$1 => [
return [
'type' => 'RockGrid',
'label' => '$3',
'grid' => '$4',
'icon' => '${5:table}',
],
'label' => '$1',
'grid' => '$2',
'icon' => '${3:table}',
];
6 changes: 3 additions & 3 deletions snippets/RockMigrations/rmf-rockicons.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Add a RockIcons field via RockMigrations
$1 => [
return [
'type' => 'text',
'inputfieldClass' => 'InputfieldRockIcons',
'label' => '$2',
],
'label' => '$1',
];
6 changes: 3 additions & 3 deletions snippets/RockMigrations/rmf-rockpagebuilder.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Add a RockPageBuilder field via RockMigrations
$1 => [
return [
'type' => 'RockPageBuilder',
'label' => '$2',
'label' => '$1',
'icon' => 'cubes',
],
];
8 changes: 4 additions & 4 deletions snippets/RockMigrations/rmf-text.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// Add a text field via RockMigrations
$1 => [
'type' => 'text',
'label' => '$3',
return [
'type' => 'text', // use text*Language to create a multi-lang field
'label' => '$1',
'icon' => 'align-left',
'textformatters' => [
'TextformatterEntities',
],
],
];
8 changes: 4 additions & 4 deletions snippets/RockMigrations/rmf-textarea-cke.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Add a CKEditor field via RockMigrations
$1 => [
'type' => 'textarea',
'label' => '$3',
return [
'type' => 'textarea', // use textarea*Language to create a multi-lang field
'label' => '$1',
'inputfieldClass' => 'InputfieldCKEditor',
'contentType' => FieldtypeTextarea::contentTypeHTML,
'rows' => 5,
Expand Down Expand Up @@ -34,4 +34,4 @@ $1 => [
'inlineMode' => true,
// RockPageBuilder no label shortcut
// 'rpb-nolabel' => true,
],
];
12 changes: 6 additions & 6 deletions snippets/RockMigrations/rmf-textarea-tinymce.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// Add a TinyMCE field via RockMigrations
$1 => [
'type' => 'textarea',
return [
'type' => 'textarea', // use textarea*Language to create a multi-lang field
'inputfieldClass' => 'InputfieldTinyMCE',
'contentType' => FieldtypeTextarea::contentTypeHTML,
'label' => '$3',
'rows' => ${4:5},
'icon' => '${5:align-left}',
'label' => '$1',
'rows' => ${2:5},
'icon' => '${3:align-left}',
'inlineMode' => true,
// 'rpb-nolabel' => true, // hide label in backend
'settingsFile' => '/site/modules/RockMigrations/TinyMCE/simple.json',
],
];
12 changes: 6 additions & 6 deletions snippets/RockMigrations/rmf-textarea.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Add a textarea field via RockMigrations
$1 => [
'type' => 'textarea',
'label' => '$3',
'rows' => ${4:5},
'icon' => '${5:align-left}',
],
return [
'type' => 'textarea', // use textarea*Language to create a multi-lang field
'label' => '$1',
'rows' => ${2:5},
'icon' => '${3:align-left}',
];
6 changes: 3 additions & 3 deletions snippets/RockMigrations/rmf-toggle.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// rmf-toggle
$1 => [
return [
'type' => 'toggle',
'label' => '$2',
'label' => '$1',
'formatType' => 0, // integer 0/1
'labelType' => 0, // yes/no
'inputfieldClass' => 0, // toggle buttons
'defaultOption' => 'yes',
],
];
Loading

0 comments on commit 55dc2eb

Please sign in to comment.