forked from AmazeeLabs/algm_drutiny
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Tim Clifford
committed
Aug 5, 2020
1 parent
3e5c689
commit ce7b474
Showing
34 changed files
with
1,374 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,5 +4,3 @@ vendor | |
composer.lock | ||
*.phar | ||
.build | ||
|
||
drupal-web |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.git | ||
vendor | ||
web/sites/default/files |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# | ||
# Copy and rename this file to .env at root of this project. | ||
# | ||
|
||
# A common use case is to supply database creds via the environment. Edit settings.php | ||
# like so: | ||
# | ||
# $databases['default']['default'] = [ | ||
# 'database' => getenv('MYSQL_DATABASE'), | ||
# 'driver' => 'mysql', | ||
# 'host' => getenv('MYSQL_HOSTNAME'), | ||
# 'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql', | ||
# 'password' => getenv('MYSQL_PASSWORD'), | ||
# 'port' => getenv('MYSQL_PORT'), | ||
# 'prefix' => '', | ||
# 'username' => getenv('MYSQL_USER'), | ||
# ]; | ||
# | ||
# Uncomment and populate as needed. | ||
# MYSQL_DATABASE= | ||
# MYSQL_HOSTNAME= | ||
# MYSQL_PASSWORD= | ||
# MYSQL_PORT= | ||
# MYSQL_USER= | ||
|
||
# Another common use case is to set Drush's --uri via environment. | ||
# DRUSH_OPTIONS_URI=http://example.com |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Ignore directories generated by Composer | ||
/drush/contrib/ | ||
/vendor/ | ||
/web/core/ | ||
/web/modules/contrib/ | ||
/web/themes/contrib/ | ||
/web/profiles/contrib/ | ||
/web/libraries/ | ||
|
||
# Ingore files that are only for the current local environment | ||
web/sites/*/settings.local.php | ||
web/sites/*/services.local.yml | ||
|
||
# Ignore Drupal's file directory | ||
/web/sites/*/files/ | ||
|
||
# Ignore SimpleTest multi-site environment. | ||
/web/sites/simpletest | ||
|
||
# Ignore files generated by PhpStorm | ||
/.idea/ | ||
|
||
# Ignore .env files as they are personal | ||
/.env | ||
/.editorconfig | ||
/.gitattributes | ||
|
||
/tmp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
language: php | ||
dist: trusty | ||
sudo: false | ||
|
||
php: | ||
- 7.0 | ||
- 7.1 | ||
- 7.2 | ||
- 7.3 | ||
|
||
env: | ||
global: | ||
- SIMPLETEST_DB=sqlite://tmp/site.sqlite | ||
- SIMPLETEST_BASE_URL="http://127.0.0.1:8080" | ||
matrix: | ||
- RELEASE=stable COMPOSER_CHANNEL=stable | ||
- RELEASE=dev COMPOSER_CHANNEL=stable | ||
- RELEASE=stable COMPOSER_CHANNEL=snapshot | ||
|
||
before_install: | ||
- echo 'sendmail_path = /bin/true' >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini | ||
- phpenv config-rm xdebug.ini | ||
- composer --verbose self-update --$COMPOSER_CHANNEL | ||
- composer --version | ||
|
||
install: | ||
- composer --verbose validate | ||
- composer --verbose install | ||
|
||
script: | ||
- if [[ $RELEASE = dev ]]; then composer --verbose remove --no-update drupal/console; fi; | ||
- if [[ $RELEASE = dev ]]; then composer --verbose require --no-update drupal/core:8.8.x-dev; composer --verbose require --no-update --dev drupal/core-dev:8.8.x-dev; fi; | ||
- if [[ $RELEASE = dev ]]; then composer --verbose update; fi; | ||
- ./vendor/bin/drush site-install --verbose --yes --db-url=sqlite://tmp/site.sqlite | ||
- ./vendor/bin/drush runserver $SIMPLETEST_BASE_URL & | ||
- until curl -s $SIMPLETEST_BASE_URL; do true; done > /dev/null | ||
# Run a single unit test to verfiy the testing setup. | ||
- ./vendor/bin/phpunit -c ./web/core ./web/core/modules/system/tests/src/Unit/SystemRequirementsTest.php | ||
- ./vendor/bin/drush | ||
- if [[ $RELEASE = stable ]]; then ./vendor/bin/drupal; fi; |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,174 @@ | ||
# ALGM Drutiny Drupal website example | ||
|
||
* To run drupal instance: | ||
* Docker running | ||
* `pygmy up` | ||
* `docker-compose up -d` | ||
* `docker-compose exec cli bash` | ||
* `COMPOSER_MEMORY_LIMIT=-1 composer install` | ||
* `drush si` | ||
|
||
* Now with the drutiny development: | ||
* `docker-compose exec cli bash` | ||
* `cd /ALGM` | ||
* `composer require bomoko/algm_drutiny_profile:dev-master` | ||
|
||
* At this point you should be able to run the following: | ||
* `cd /ALGM` | ||
* `./vendor/bin/drutiny policy:list` | ||
* `./vendor/bin/drutiny policy:audit Drupal-8:DblogDisabled @self` | ||
* `./vendor/bin/drutiny profile:run ALGMbasicaudit @self` | ||
|
||
* Create a new policy and test it: | ||
* Create a new branch in this repo. | ||
* Create the new policies, profiles, etc (root of the repo) and push the branch up. | ||
* `cd /ALGM` | ||
* `composer require bomoko/algm_drutiny_profile:dev-YOURBRANCH#commit-hash` | ||
* Your changes should now appear in the list of policies or profiles. | ||
|
||
|
||
## Composer template for Drupal projects | ||
|
||
[](https://travis-ci.org/drupal-composer/drupal-project) | ||
|
||
This project template provides a starter kit for managing your site | ||
dependencies with [Composer](https://getcomposer.org/). | ||
|
||
If you want to know how to use it as replacement for | ||
[Drush Make](https://github.com/drush-ops/drush/blob/8.x/docs/make.md) visit | ||
the [Documentation on drupal.org](https://www.drupal.org/node/2471553). | ||
|
||
## Usage | ||
|
||
First you need to [install composer](https://getcomposer.org/doc/00-intro.md#installation-linux-unix-osx). | ||
|
||
> Note: The instructions below refer to the [global composer installation](https://getcomposer.org/doc/00-intro.md#globally). | ||
You might need to replace `composer` with `php composer.phar` (or similar) | ||
for your setup. | ||
|
||
After that you can create the project: | ||
|
||
``` | ||
composer create-project drupal-composer/drupal-project:8.x-dev some-dir --no-interaction | ||
``` | ||
|
||
With `composer require ...` you can download new dependencies to your | ||
installation. | ||
|
||
``` | ||
cd some-dir | ||
composer require drupal/devel:~1.0 | ||
``` | ||
|
||
The `composer create-project` command passes ownership of all files to the | ||
project that is created. You should create a new git repository, and commit | ||
all files not excluded by the .gitignore file. | ||
|
||
## What does the template do? | ||
|
||
When installing the given `composer.json` some tasks are taken care of: | ||
|
||
* Drupal will be installed in the `web`-directory. | ||
* Autoloader is implemented to use the generated composer autoloader in `vendor/autoload.php`, | ||
instead of the one provided by Drupal (`web/vendor/autoload.php`). | ||
* Modules (packages of type `drupal-module`) will be placed in `web/modules/contrib/` | ||
* Theme (packages of type `drupal-theme`) will be placed in `web/themes/contrib/` | ||
* Profiles (packages of type `drupal-profile`) will be placed in `web/profiles/contrib/` | ||
* Creates default writable versions of `settings.php` and `services.yml`. | ||
* Creates `web/sites/default/files`-directory. | ||
* Latest version of drush is installed locally for use at `vendor/bin/drush`. | ||
* Latest version of DrupalConsole is installed locally for use at `vendor/bin/drupal`. | ||
* Creates environment variables based on your .env file. See [.env.example](.env.example). | ||
|
||
## Updating Drupal Core | ||
|
||
This project will attempt to keep all of your Drupal Core files up-to-date; the | ||
project [drupal/core-composer-scaffold](https://github.com/drupal/core-composer-scaffold) | ||
is used to ensure that your scaffold files are updated every time drupal/core is | ||
updated. If you customize any of the "scaffolding" files (commonly .htaccess), | ||
you may need to merge conflicts if any of your modified files are updated in a | ||
new release of Drupal core. | ||
|
||
Follow the steps below to update your core files. | ||
|
||
1. Run `composer update drupal/core drupal/core-dev --with-dependencies` to update Drupal Core and its dependencies. | ||
2. Run `git diff` to determine if any of the scaffolding files have changed. | ||
Review the files for any changes and restore any customizations to | ||
`.htaccess` or `robots.txt`. | ||
1. Commit everything all together in a single commit, so `web` will remain in | ||
sync with the `core` when checking out branches or running `git bisect`. | ||
1. In the event that there are non-trivial conflicts in step 2, you may wish | ||
to perform these steps on a branch, and use `git merge` to combine the | ||
updated core files with your customized files. This facilitates the use | ||
of a [three-way merge tool such as kdiff3](http://www.gitshah.com/2010/12/how-to-setup-kdiff-as-diff-tool-for-git.html). This setup is not necessary if your changes are simple; | ||
keeping all of your modifications at the beginning or end of the file is a | ||
good strategy to keep merges easy. | ||
|
||
## Generate composer.json from existing project | ||
|
||
With using [the "Composer Generate" drush extension](https://www.drupal.org/project/composer_generate) | ||
you can now generate a basic `composer.json` file from an existing project. Note | ||
that the generated `composer.json` might differ from this project's file. | ||
|
||
|
||
## FAQ | ||
|
||
### Should I commit the contrib modules I download? | ||
|
||
Composer recommends **no**. They provide [argumentation against but also | ||
workrounds if a project decides to do it anyway](https://getcomposer.org/doc/faqs/should-i-commit-the-dependencies-in-my-vendor-directory.md). | ||
|
||
### Should I commit the scaffolding files? | ||
|
||
The [Drupal Composer Scaffold](https://github.com/drupal/core-composer-scaffold) plugin can download the scaffold files (like | ||
index.php, update.php, …) to the web/ directory of your project. If you have not customized those files you could choose | ||
to not check them into your version control system (e.g. git). If that is the case for your project it might be | ||
convenient to automatically run the drupal-scaffold plugin after every install or update of your project. You can | ||
achieve that by registering `@composer drupal:scaffold` as post-install and post-update command in your composer.json: | ||
|
||
```json | ||
"scripts": { | ||
"post-install-cmd": [ | ||
"@composer drupal:scaffold", | ||
"..." | ||
], | ||
"post-update-cmd": [ | ||
"@composer drupal:scaffold", | ||
"..." | ||
] | ||
}, | ||
``` | ||
### How can I apply patches to downloaded modules? | ||
|
||
If you need to apply patches (depending on the project being modified, a pull | ||
request is often a better solution), you can do so with the | ||
[composer-patches](https://github.com/cweagans/composer-patches) plugin. | ||
|
||
To add a patch to drupal module foobar insert the patches section in the extra | ||
section of composer.json: | ||
```json | ||
"extra": { | ||
"patches": { | ||
"drupal/foobar": { | ||
"Patch description": "URL or local path to patch" | ||
} | ||
} | ||
} | ||
``` | ||
### How do I switch from packagist.drupal-composer.org to packages.drupal.org? | ||
|
||
Follow the instructions in the [documentation on drupal.org](https://www.drupal.org/docs/develop/using-composer/using-packagesdrupalorg). | ||
|
||
### How do I specify a PHP version ? | ||
|
||
This project supports PHP 7.0 as minimum version (see [Drupal 8 PHP requirements](https://www.drupal.org/docs/8/system-requirements/drupal-8-php-requirements)), however it's possible that a `composer update` will upgrade some package that will then require PHP 7+. | ||
|
||
To prevent this you can add this code to specify the PHP version you want to use in the `config` section of `composer.json`: | ||
```json | ||
"config": { | ||
"sort-packages": true, | ||
"platform": { | ||
"php": "7.0.33" | ||
} | ||
}, | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
FROM algmprivsecops/algmcli:latest as algmtools | ||
|
||
FROM amazeeio/php:7.2-cli-drupal | ||
|
||
COPY composer.json composer.lock /app/ | ||
COPY scripts /app/scripts | ||
# Uncomment if you have a patches directory in your Drupal Installation | ||
# COPY patches /app/patches | ||
RUN composer install | ||
COPY . /app | ||
|
||
COPY --from=algmtools /ALGM /ALGM | ||
|
||
# Define where the Drupal Root is located | ||
ENV WEBROOT=web |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
{ | ||
"name": "drupal-composer/drupal-project", | ||
"description": "Project template for Drupal 8 projects with composer", | ||
"type": "project", | ||
"license": "GPL-2.0-or-later", | ||
"authors": [ | ||
{ | ||
"name": "", | ||
"role": "" | ||
} | ||
], | ||
"repositories": [ | ||
{ | ||
"type": "composer", | ||
"url": "https://packages.drupal.org/8" | ||
} | ||
], | ||
"require": { | ||
"php": ">=7.0.8", | ||
"composer/installers": "^1.2", | ||
"cweagans/composer-patches": "^1.6.5", | ||
"drupal/console": "^1.0.2", | ||
"drupal/core": "^8.8.0", | ||
"drupal/core-composer-scaffold": "^8.8.0", | ||
"vlucas/phpdotenv": "^4.0", | ||
"webflo/drupal-finder": "^1.0.0", | ||
"zaporylie/composer-drupal-optimizations": "^1.0" | ||
}, | ||
"require-dev": { | ||
"drupal/core-dev": "^8.8.0" | ||
}, | ||
"conflict": { | ||
"drupal/drupal": "*" | ||
}, | ||
"minimum-stability": "dev", | ||
"prefer-stable": true, | ||
"config": { | ||
"sort-packages": true | ||
}, | ||
"autoload": { | ||
"classmap": [ | ||
"scripts/composer/ScriptHandler.php" | ||
], | ||
"files": ["load.environment.php"] | ||
}, | ||
"scripts": { | ||
"pre-install-cmd": [ | ||
"DrupalProject\\composer\\ScriptHandler::checkComposerVersion" | ||
], | ||
"pre-update-cmd": [ | ||
"DrupalProject\\composer\\ScriptHandler::checkComposerVersion" | ||
], | ||
"post-install-cmd": [ | ||
"DrupalProject\\composer\\ScriptHandler::createRequiredFiles" | ||
], | ||
"post-update-cmd": [ | ||
"DrupalProject\\composer\\ScriptHandler::createRequiredFiles" | ||
] | ||
}, | ||
"extra": { | ||
"composer-exit-on-patch-failure": true, | ||
"patchLevel": { | ||
"drupal/core": "-p2" | ||
}, | ||
"drupal-scaffold": { | ||
"locations": { | ||
"web-root": "web/" | ||
} | ||
}, | ||
"installer-paths": { | ||
"web/core": ["type:drupal-core"], | ||
"web/libraries/{$name}": ["type:drupal-library"], | ||
"web/modules/contrib/{$name}": ["type:drupal-module"], | ||
"web/profiles/contrib/{$name}": ["type:drupal-profile"], | ||
"web/themes/contrib/{$name}": ["type:drupal-theme"], | ||
"drush/Commands/contrib/{$name}": ["type:drupal-drush"] | ||
} | ||
} | ||
} |
Oops, something went wrong.