Skip to content

Commit

Permalink
Merge branch 'release/1.1.2' into v1
Browse files Browse the repository at this point in the history
  • Loading branch information
khalwat committed Sep 7, 2024
2 parents b0fce43 + 60ddb4b commit 7305c2a
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
Changelog
=========

## 1.1.2 - 2024.09.07
### Added
* Added support for the `TEMPLATES_VENDOR_DIR` environment variable, either defined in the environment itself, or in a `.env` file if [Dotenv](https://github.com/vlucas/phpdotenv)) is used

## 1.1.1 - 2024.04.16
### Added
* Add `phpstan` and `ecs` code linting
Expand Down
20 changes: 20 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
MAJOR_VERSION?=5
PLUGINDEV_PROJECT_DIR?=/Users/andrew/webdev/sites/plugindev/cms_v${MAJOR_VERSION}/
VENDOR?=nystudio107
PROJECT_PATH?=${VENDOR}/$(shell basename $(CURDIR))

.PHONY: dev docs release

# Start up the buildchain dev server
dev:
# Start up the docs dev server
docs:
# Run code quality tools, tests, and build the buildchain & docs in preparation for a release
release: --code-quality --code-tests --buildchain-clean-build --docs-clean-build
# The internal targets used by the dev & release targets
--buildchain-clean-build:
--code-quality:
${MAKE} -C ${PLUGINDEV_PROJECT_DIR} -- ecs check vendor/${PROJECT_PATH}/src --fix
${MAKE} -C ${PLUGINDEV_PROJECT_DIR} -- phpstan analyze -c vendor/${PROJECT_PATH}/phpstan.neon
--code-tests:
--docs-clean-build:
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ Example including a template from a Twig Bundle:
Since Twig Bundle Installer is looking for a directory in your project root named `templates/` that points to your Twig templates directory:

* You should treat the `templates/vendor/` directory as **read only** just like you do the `vendor/` directory
* If you store your templates somewhere else, for now you must create a symlink or alias from `templates/` to where you store your templates
* If you exclude your `vendor/` directory from your Git repo, you probably would want to add `templates/vendor/` to your `.gitignore` as well
* If you store your templates somewhere else, you can create a symlink or alias from `templates/` to where you store your templates, or you can set the `TEMPLATES_VENDOR_DIR` environment variable (either in the environment itself, or in your `.env` file in your project root if you're using [Dotenv](https://github.com/vlucas/phpdotenv))
* If you exclude your `vendor/` directory from your Git repo, you probably would want to add `templates/vendor/` to your `.gitignore` as well. Twig Bundle Installer will automatically put `.gitignore` file in the `templates/vendor/` directory for you

Example `.gitignore` file:
```
Expand Down Expand Up @@ -189,7 +189,6 @@ This project is usable as-is, but it's also very much in the germination phase.

Some ideas:

* The templates directory shouldn't be hard-coded
* Bundles could include CSS and JavaScript that the installer builds a `manifest.json` for something else to consume
* Framework specific tools could compliment Twig Bundle Installer by automatically publishing bundles on the frontend
* Technically, the technique described here would work fine for [Antlers](https://docs.statamic.com/antlers) or [Blade](https://laravel.com/docs/5.8/blade) and other templating systems as well.
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "nystudio107/twig-bundle-installer",
"description": "Install, update, and manage Twig template bundles via Composer",
"version": "1.1.1",
"version": "1.1.2",
"keywords": [
"twig",
"composer",
Expand Down
10 changes: 8 additions & 2 deletions src/Installer.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
use Composer\Package\PackageInterface;
use Composer\Repository\InstalledRepositoryInterface;
use Composer\Util\Filesystem;
use Dotenv\Dotenv;
use React\Promise\PromiseInterface;
use RuntimeException;

/**
* Class Installer
Expand Down Expand Up @@ -43,7 +45,11 @@ class Installer extends BaseLibraryInstaller
public function __construct(IOInterface $io, Composer $composer, $type = self::TWIG_BUNDLE_PACKAGE_TYPE, Filesystem $filesystem = null, BinaryInstaller $binaryInstaller = null)
{
parent::__construct($io, $composer, $type, $filesystem, $binaryInstaller);
$this->vendorDir = rtrim(self::TEMPLATES_VENDOR_DIR, '/');
// Load dotenv?
if (class_exists('Dotenv\Dotenv')) {
Dotenv::createUnsafeMutable(__DIR__)->safeLoad();
}
$this->vendorDir = rtrim(getenv('TEMPLATES_VENDOR_DIR') ?: self::TEMPLATES_VENDOR_DIR, '/');
$this->type = self::TWIG_BUNDLE_PACKAGE_TYPE;
}

Expand Down Expand Up @@ -101,7 +107,7 @@ protected function writeGitIgnore(): void
$dir = self::TEMPLATES_VENDOR_DIR;
if (!file_exists($dir)) {
if (!mkdir($dir, 0777, true) && !is_dir($dir)) {
throw new \RuntimeException(sprintf('Directory "%s" was not created', $dir));
throw new RuntimeException(sprintf('Directory "%s" was not created', $dir));
}
}
// Create the .gitignore file if it doesn't exist
Expand Down

0 comments on commit 7305c2a

Please sign in to comment.