Skip to content

Commit

Permalink
Merge pull request #18 from wedevelopnl/master
Browse files Browse the repository at this point in the history
V3
  • Loading branch information
Dennisprins93 committed Jan 30, 2023
2 parents 03a779b + 57a32ad commit c2e70fd
Show file tree
Hide file tree
Showing 34 changed files with 375 additions and 18,507 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@
/**/*.css.map
/vendor/
/resources/
.idea
composer.lock
.php-cs-fixer.cache
25 changes: 25 additions & 0 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

$finder = PhpCsFixer\Finder::create()
->in(__DIR__ . '/src')
;

$config = new PhpCsFixer\Config();
$config
->setRules([
'@PHP81Migration' => true,
'@PSR12' => true,
'array_push' => true,
'no_unused_imports' => true,
// TODO: Add PHPStan and enable declare_strict_Types
'declare_strict_types' => false,
'strict_comparison' => true,
'strict_param' => true,
'cast_spaces' => ['space' => 'none'],
'array_syntax' => ['syntax' => 'short'],
])
->setRiskyAllowed(true)
->setFinder($finder)
;

return $config;
17 changes: 0 additions & 17 deletions .php_cs

This file was deleted.

31 changes: 31 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
ARG ALPINE_VERSION=3.16

ARG NODE_VERSION=10.24.1

FROM node:$NODE_VERSION-alpine AS node
FROM php:8.1-cli-alpine$ALPINE_VERSION AS php-cli

RUN apk add php yarn make perl git --no-cache

WORKDIR /app

RUN apk add --no-cache libstdc++
COPY --from=node /usr/local/bin/node /usr/local/bin/node
COPY --from=node /usr/local/lib/node_modules /usr/local/lib/node_modules
RUN ln -s ../lib/node_modules/npm/bin/npm-cli.js /usr/local/bin/npm

COPY package.json yarn.lock webpack.config.js .eslintrc.js ./
RUN yarn install
RUN rm -rf node_modules

COPY --from=composer:2 /usr/bin/composer /usr/bin/composer
COPY composer.json ./
ENV COMPOSER_ALLOW_SUPERUSER 1
RUN composer install --prefer-install=source --no-progress --no-suggest --no-interaction --no-plugins --ignore-platform-reqs

COPY dev/docker/docker-entrypoint.sh /usr/local/bin/docker-entrypoint
RUN chmod +x /usr/local/bin/docker-entrypoint

ENTRYPOINT ["docker-entrypoint"]

CMD ["php"]
40 changes: 40 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
.PHONY: *

.DEFAULT_GOAL := help
docker := $(shell if [ `pwd` != "/app" ]; then echo 'docker compose exec php'; fi;)

HELP_FUNCTION = \
%help; \
while(<>) { push @{$$help{$$2 // 'options'}}, [$$1, $$3] if /^(.+)\s*:.*\#\#(?:@(\w+))?\s(.*)$$/ }; \
print "usage: make [target]\n\n"; \
for (keys %help) { \
print "\033[33m $$_:\n"; \
printf " \033[32m%-30s\033[0m %s\n", $$_->[0], $$_->[1] for @{$$help{$$_}} \
}

help: ##@develop Show this help.
@perl -e '$(HELP_FUNCTION)' $(MAKEFILE_LIST)

build: ##@develop Build docker container and detach
docker compose up --build -d

up: ##@develop Docker compose up
docker compose up -d

down: ##@develop Docker compose down
docker compose down

test: ##@develop Run code style test
${docker} ./vendor/bin/php-cs-fixer fix --diff --dry-run

fix-cs: ##@develop Fix code styling
${docker} ./vendor/bin/php-cs-fixer fix

sh: ##@develop Open shell in container
${docker} sh

yarn-watch: ##@yarn Watch for changes in front-end files
${docker} yarn run watch

yarn-build: ##@yarn Build production assets
${docker} yarn run build
25 changes: 23 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,41 @@ This module converts the elemental module (https://github.com/silverstripe/silve

## Installation
```
composer require thewebmen/silverstripe-elemental-grid
composer require wedevelopnl/silverstripe-elemental-grid
```

## Further configuration
For more information about configuration, check out the documentation in the `docs` directory.

* [Configuration](docs/configuration.md)
* [Upgrade v2 => v3](docs/UPGRADE_V2_V3.md)

# License
See [License](LICENSE)

## Maintainers
* [Webmen](https://www.webmen.nl/) <development@webmen.nl>
* [WeDevelop](https://www.wedevelop.nl/) <development@wedevelop.nl>

## Development and contribution
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.\
See read our [contributing](CONTRIBUTING.md) document for more information.

### Getting started
We advise to use [Docker](https://docker.com)/[Docker compose](https://docs.docker.com/compose/) for development.\
We also included a [Makefile](https://www.gnu.org/software/make/) to simplify some commands

Our development container contains some built-in tools like `PHPCSFixer` and `yarn`.

#### Getting development container up
`make build` to build the Docker container and then run detached.\
If you want to only get the container up, you can simply type `make up`.

You can SSH into the container using `make sh`.

#### Front-end
Webpack and yarn are used to compile front-end assets.

If you use the Docker environment, you can just run `make yarn-watch` to watch for changes or run `make yarn-build` to build assets (minified and production ready!)

#### All make commands
You can run `make help` to get a list with all available `make` commands.
49 changes: 49 additions & 0 deletions Tasks/MigrateNamespaceTask.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php

namespace WeDevelop\ElementalGrid\Tasks;

use DNADesign\Elemental\Models\BaseElement;
use SilverStripe\Dev\BuildTask;
use SilverStripe\ORM\Queries\SQLSelect;
use SilverStripe\ORM\Queries\SQLUpdate;
use WeDevelop\ElementalGrid\Models\ElementRow;

class MigrateNamespaceTask extends BuildTask
{
protected $title = 'Elemental grid namespace migration';

protected $description = 'Migrate elemental grid TheWebmen namespace to WeDevelop namespace';

private static $segment = 'migrate-elemental-grid-namespace';

public function run($request)
{
$elements = BaseElement::get()
->where([
'ClassName' => 'TheWebmen\ElementalGrid\Models\ElementRow'
]);

$counter = 0;
$totalElements = $elements->count();

print_r(sprintf("Starting migration of %s elements\n\n", $totalElements));

/** @var BaseElement $element */
foreach ($elements as $element) {
$isPublished = $element->isPublished();

$element->setField('ClassName', 'WeDevelop\ElementalGrid\Models\ElementRow');
$element->write();

if ($isPublished) {
$element->publishSingle();
}

$counter++;

print_r(sprintf("Migrated %s of %s elements\n", $counter, $totalElements));
}

print_r(sprintf("\n\nMigration done for %s elements!", $counter));
}
}
12 changes: 6 additions & 6 deletions _config/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,25 @@ After:
---
SilverStripe\Core\Manifest\ModuleManifest:
module_priority:
- thewebmen/silverstripe-elemental-grid
- wedevelopnl/silverstripe-elemental-grid
- dnadesign/silverstripe-elemental

SilverStripe\Admin\LeftAndMain:
extra_requirements_javascript:
- 'thewebmen/silverstripe-elemental-grid:client/dist/js/bundle.js'
- 'wedevelopnl/silverstripe-elemental-grid:client/dist/js/bundle.js'
extra_requirements_css:
- 'thewebmen/silverstripe-elemental-grid:client/dist/styles/bundle.css'
- 'wedevelopnl/silverstripe-elemental-grid:client/dist/styles/bundle.css'

DNADesign\Elemental\Models\ElementalArea:
extensions:
- TheWebmen\ElementalGrid\Extensions\ElementalAreaExtension
- WeDevelop\ElementalGrid\Extensions\ElementalAreaExtension

DNADesign\Elemental\Models\BaseElement:
inline_editable: false
extensions:
- TheWebmen\ElementalGrid\Extensions\BaseElementExtension
- WeDevelop\ElementalGrid\Extensions\BaseElementExtension

TheWebmen\ElementalGrid\ElementalConfig:
WeDevelop\ElementalGrid\ElementalConfig:
default_viewport: 'MD'
css_framework: 'bulma'
enable_custom_title_classes: true
Expand Down
Loading

0 comments on commit c2e70fd

Please sign in to comment.