Skip to content

Commit

Permalink
Merge branch 'release/2.2.12' into craft-webpack
Browse files Browse the repository at this point in the history
  • Loading branch information
khalwat committed Jul 19, 2020
2 parents 2e4c9ab + f9b4537 commit c1b83f4
Show file tree
Hide file tree
Showing 27 changed files with 401 additions and 74 deletions.
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
# nystudio107/craft Change Log

## 2.2.12 - 2020.07.18
### Added
* Added TypeScript support
* Use Vue.js 3.0
* Added `buddy.yml` for atomic deployments

### Changed
* Replaced moment with vanilla JavaScript
* Replaced `getenv()` with `App::env()`
* No longer use DSN for db connections
* Switch from TSLint to ESLint

### Fixed
* Fixed config path in the module `helpers/Config.php`

## 2.2.11 - 2020.05.26
### Changed
* Use DSN for database connections
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ The project is based on [Craft CMS](https://CraftCMS.com) using a unique `templa
* [Docker](https://www.docker.com/) Docker is used for local development; see **Setting Up Local Dev** below for details
* A base Twig templating setup as described in [An Effective Twig Base Templating Setup](https://nystudio107.com/blog/an-effective-twig-base-templating-setup)
* [webpack](https://webpack.js.org/) is used for the build system as per [An Annotated webpack 4 Config for Frontend Web Development](https://nystudio107.com/blog/an-annotated-webpack-4-config-for-frontend-web-development)
* [VueJS](https://vuejs.org/) is used for some of the interactive bits on the website as per
* [TypeScript](https://www.typescriptlang.org/) for strictly typed JavaScript code
* [Vue.js 3.0](https://vuejs.org/) is used for some of the interactive bits on the website, and Vue.js 3.x allows us to leverage the [Composition API](https://composition-api.vuejs.org/)
* [Tailwind CSS](https://tailwindcss.com/) for the site-wide CSS
* JSON-LD structured data as per [Annotated JSON-LD Structured Data Examples](https://nystudio107.com/blog/annotated-json-ld-structured-data-examples)
* [Google AMP](https://developers.google.com/amp/) versions of the podcast episode and other pages
Expand All @@ -21,7 +22,7 @@ The project is based on [Craft CMS](https://CraftCMS.com) using a unique `templa
* A custom site module as per [Enhancing a Craft CMS 3 Website with a Custom Module](https://nystudio107.com/blog/enhancing-a-craft-cms-3-website-with-a-custom-module)
* CLI-based queue as per [Robust queue job handling in Craft CMS](https://nystudio107.com/blog/robust-queue-job-handling-in-craft-cms)
* FastCGI Static Cache as per [Static Page Caching with Craft CMS](https://nystudio107.com/blog/static-caching-with-craft-cms)
* [Craft-Scripts](https://github.com/nystudio107/craft-scripts) as described in the [Database & Asset Syncing Between Environments in Craft CMS](https://nystudio107.com/blog/database-asset-syncing-between-environments-in-craft-cms), [Mitigating Disaster via Website Backups](https://nystudio107.com/blog/mitigating-disaster-via-website-backups) & [Hardening Craft CMS Permissions](https://nystudio107.com/blog/hardening-craft-cms-permissions) articles
* [buddy.works](http://buddy.works/) atomic deployments

...and probably a bunch of other stuff too.

Expand Down
134 changes: 134 additions & 0 deletions buddy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
- pipeline: "Build & Deploy to Production"
trigger_mode: "ON_EVERY_PUSH"
ref_name: "master"
ref_type: "BRANCH"
target_site_url: "https://CHANGEME.com/"
trigger_condition: "ALWAYS"
actions:
- action: "Execute: webpack build"
type: "BUILD"
working_directory: "/buddy/$PROJECT_SHORTNAME"
docker_image_name: "nystudio107/webpack-dev-base"
docker_image_tag: "latest"
execute_commands:
- "cd docker-config/webpack-dev-craft"
- "npm ci"
- "npm run build"
volume_mappings:
- "/:/buddy/$PROJECT_SHORTNAME"
trigger_condition: "ALWAYS"
shell: "BASH"
- action: "Execute: composer install"
type: "BUILD"
working_directory: "/buddy/$PROJECT_SHORTNAME"
docker_image_name: "nystudio107/php-dev-base"
docker_image_tag: "latest"
execute_commands:
- "cd cms"
- "composer install --no-scripts --no-interaction --prefer-dist --optimize-autoloader --ignore-platform-reqs"
setup_commands:
- "echo \"memory_limit=-1\" >> /usr/local/etc/php/conf.d/buddy.ini"
- "apt-get update && apt-get install -y git zip"
- "curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer"
- "# php ext pdo_mysql"
- "docker-php-ext-install pdo_pgsql pgsql"
volume_mappings:
- "/:/buddy/$PROJECT_SHORTNAME"
trigger_condition: "ALWAYS"
shell: "BASH"
- action: "Rsync files to production"
type: "RSYNC"
local_path: "cms/"
remote_path: "$REMOTE_PROJECT_ROOT/deploy-cache"
login: "$REMOTE_SSH_USER"
host: "$REMOTE_SSH_HOST"
port: "22"
authentication_mode: "WORKSPACE_KEY"
archive: true
delete_extra_files: true
recursive: true
compress: true
deployment_excludes:
- "/.git/"
trigger_condition: "ALWAYS"
- action: "Atomic deploy"
type: "SSH_COMMAND"
working_directory: "$REMOTE_PROJECT_ROOT"
login: "$REMOTE_SSH_USER"
host: "$REMOTE_SSH_HOST"
port: "22"
authentication_mode: "WORKSPACE_KEY"
commands:
- "if [ -d \"releases/$BUDDY_EXECUTION_REVISION\" ] && [ \"$BUDDY_EXECUTION_REFRESH\" = \"true\" ];"
- "then"
- " echo \"Removing: releases/$BUDDY_EXECUTION_REVISION\""
- " rm -rf releases/$BUDDY_EXECUTION_REVISION;"
- "fi"
- "if [ ! -d \"releases/$BUDDY_EXECUTION_REVISION\" ];"
- "then"
- " echo \"Creating: releases/$BUDDY_EXECUTION_REVISION\""
- " cp -dR deploy-cache releases/$BUDDY_EXECUTION_REVISION;"
- "fi"
- "echo \"Creating: persistent directories\""
- "mkdir -p storage"
- "echo \"Symlinking: persistent files & directories\""
- "ln -nfs $REMOTE_PROJECT_ROOT/.env $REMOTE_PROJECT_ROOT/releases/$BUDDY_EXECUTION_REVISION"
- "ln -nfs $REMOTE_PROJECT_ROOT/storage $REMOTE_PROJECT_ROOT/releases/$BUDDY_EXECUTION_REVISION"
- "ln -nfs $REMOTE_PROJECT_ROOT/transcoder $REMOTE_PROJECT_ROOT/releases/$BUDDY_EXECUTION_REVISION/web"
- "echo \"Linking current to revision: $BUDDY_EXECUTION_REVISION\""
- "rm -f current"
- "ln -s releases/$BUDDY_EXECUTION_REVISION current"
- "echo \"Removing old releases\""
- "cd releases && ls -t | tail -n +11 | xargs rm -rf"
trigger_condition: "ALWAYS"
run_as_script: true
shell: "BASH"
- action: "Prep Craft CMS"
type: "SSH_COMMAND"
working_directory: "$REMOTE_PROJECT_ROOT/current"
login: "$REMOTE_SSH_USER"
host: "$REMOTE_SSH_HOST"
port: "22"
authentication_mode: "WORKSPACE_KEY"
commands:
- "# Ensure the craft script is executable"
- "chmod a+x craft"
- "# Restart our long running queue listener process"
- "echo \"\" | sudo -S supervisorctl restart all"
- "# Backup the database just in case any migrations or Project Config changes have issues"
- "./craft backup/db"
- "# Run pending migrations, sync project config, and clear caches"
- "./craft migrate/all"
- "./craft project-config/sync"
- "./craft clear-caches/all"
trigger_condition: "ALWAYS"
run_as_script: true
shell: "BASH"
- action: "Send notification to nystudio107 channel"
type: "SLACK"
content: "[#$BUDDY_EXECUTION_ID] $BUDDY_EXECUTION_REVISION_SUBJECT - $BUDDY_EXECUTION_REVISION_COMMITTER_NAME"
blocks: "[{\"type\":\"section\",\"fields\":[{\"type\":\"mrkdwn\",\"text\":\"*Successful execution:* <$BUDDY_EXECUTION_URL|Execution #$BUDDY_EXECUTION_ID $BUDDY_EXECUTION_COMMENT>\"},{\"type\":\"mrkdwn\",\"text\":\"*Pipeline:* <$BUDDY_PIPELINE_URL|$BUDDY_PIPELINE_NAME>\"},{\"type\":\"mrkdwn\",\"text\":\"*Branch:* $BUDDY_EXECUTION_BRANCH\"},{\"type\":\"mrkdwn\",\"text\":\"*Project:* <$BUDDY_PROJECT_URL|$BUDDY_PROJECT_NAME>\"}]}]"
channel: "G6AKRT78V"
channel_name: "nystudio107"
trigger_condition: "ALWAYS"
integration_hash: "5ef0d26820cfeb531cb10738"
- action: "Send notification to nystudio107 channel"
type: "SLACK"
trigger_time: "ON_FAILURE"
content: "[#$BUDDY_EXECUTION_ID] $BUDDY_EXECUTION_REVISION_SUBJECT - $BUDDY_EXECUTION_REVISION_COMMITTER_NAME"
blocks: "[{\"type\":\"section\",\"fields\":[{\"type\":\"mrkdwn\",\"text\":\"*Failed execution:* <$BUDDY_EXECUTION_URL|Execution #$BUDDY_EXECUTION_ID $BUDDY_EXECUTION_COMMENT>\"},{\"type\":\"mrkdwn\",\"text\":\"*Pipeline:* <$BUDDY_PIPELINE_URL|$BUDDY_PIPELINE_NAME>\"},{\"type\":\"mrkdwn\",\"text\":\"*Branch:* $BUDDY_EXECUTION_BRANCH\"},{\"type\":\"mrkdwn\",\"text\":\"*Project:* <$BUDDY_PROJECT_URL|$BUDDY_PROJECT_NAME>\"}]}]"
channel: "G6AKRT78V"
channel_name: "nystudio107"
trigger_condition: "ALWAYS"
integration_hash: "5ef0d26820cfeb531cb10738"
variables:
- key: "PROJECT_SHORTNAME"
value: "CHANGEME"
- key: "PROJECT_URL"
value: "https://CHANGEME.com"
- key: "REMOTE_PROJECT_ROOT"
value: "/home/forge/CHANGEME"
- key: "REMOTE_SSH_HOST"
value: "CHANGEME.com"
- key: "REMOTE_SSH_USER"
value: "forge"
2 changes: 2 additions & 0 deletions cms/config/app.console.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,7 @@
* This application config is applied only for *only* console requests
*/

use craft\helpers\App;

return [
];
2 changes: 2 additions & 0 deletions cms/config/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
* your config/ folder, alongside this one.
*/

use craft\helpers\App;

return [
'modules' => [
'site-module' => [
Expand Down
2 changes: 2 additions & 0 deletions cms/config/app.web.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
* This application config is applied only for *only* web requests
*/

use craft\helpers\App;

return [
'components' => [
'session' => [
Expand Down
5 changes: 4 additions & 1 deletion cms/config/db.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@
use craft\helpers\App;

return [
'dsn' => App::env('DB_DSN'),
'driver' => App::env('DB_DRIVER'),
'server' => App::env('DB_SERVER'),
'user' => App::env('DB_USER'),
'password' => App::env('DB_PASSWORD'),
'database' => App::env('DB_DATABASE'),
'schema' => App::env('DB_SCHEMA'),
'tablePrefix' => App::env('DB_TABLE_PREFIX'),
'port' => App::env('DB_PORT'),
];
2 changes: 2 additions & 0 deletions cms/config/fastcgi-cache-bust.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
* @copyright Copyright (c) 2017 nystudio107
*/

use craft\helpers\App;

/**
* FastCGI Cache Bust config.php
*
Expand Down
2 changes: 2 additions & 0 deletions cms/config/general.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
* @see \craft\config\GeneralConfig
*/

use craft\helpers\App;

return [
// Craft config settings from .env variables
'aliases' => [
Expand Down
2 changes: 2 additions & 0 deletions cms/config/twigpack.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
* @copyright Copyright (c) 2018 nystudio107
*/

use craft\helpers\App;

/**
* Twigpack config.php
*
Expand Down
5 changes: 4 additions & 1 deletion cms/example.env
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,14 @@ RUN_QUEUE_AUTOMATICALLY=1
SECURITY_KEY=EOdiVBONceb8zFGJP7InMui2pMkvNACz

# Craft database settings
DB_DSN=mysql:host=mariadb;port=3306;dbname=project
DB_DRIVER=mysql
DB_SERVER=mariadb
DB_USER=project
DB_PASSWORD=project
DB_DATABASE=project
DB_SCHEMA=public
DB_TABLE_PREFIX=
DB_PORT=

# URL & path settings
ASSETS_URL=http://localhost:8000
Expand Down
2 changes: 1 addition & 1 deletion cms/modules/sitemodule/src/helpers/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public static function getConfigFromFile(string $fileName): array
$currentEnv = Craft::$app->getConfig()->env;

// Try craft/config first
$path = Craft::getAlias('@craft/config/'.$fileName, false);
$path = Craft::getAlias('@config/'.$fileName, false);
if ($path === false || !file_exists($path)) {
// Now try our own internal config
$path = Craft::getAlias('@modules/sitemodule/'.$fileName, false);
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": "craftcms/craft",
"description": "nystudio107 Craft 3.4 CMS scaffolding project",
"version": "2.2.11",
"version": "2.2.12",
"keywords": [
"craft",
"cms",
Expand Down
Empty file.
17 changes: 17 additions & 0 deletions docker-config/webpack-dev-craft/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"root": true,
"parser": "vue-eslint-parser",
"parserOptions": {
"parser": "@typescript-eslint/parser",
"ecmaVersion": 2020,
"sourceType": "module"
},
"plugins": [
"@typescript-eslint"
],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:vue/vue3-recommended"
]
}
2 changes: 2 additions & 0 deletions docker-config/webpack-dev-craft/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ FROM nystudio107/webpack-dev-base

WORKDIR /var/www/project/docker-config/webpack-dev-craft/

COPY ./docker-config/webpack-dev-craft/tsconfig.json /var/www/project/tsconfig.json

# Run our webpack build in debug mode

# We'd normally use `npm ci` here, but by using `install`:
Expand Down
33 changes: 26 additions & 7 deletions docker-config/webpack-dev-craft/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
},
"private": true,
"scripts": {
"check-types": "tsc",
"lint": "tsc --noEmit && eslint '../../src/**/*.{js,ts,vue}' --fix",
"debug": "webpack-dev-server --config webpack.dev.js",
"dev": "webpack-dashboard -- webpack-dev-server --config webpack.dev.js",
"build": "webpack --config webpack.prod.js --progress --hide-modules"
Expand Down Expand Up @@ -54,23 +56,37 @@
},
"devDependencies": {
"@babel/core": "^7.1.0",
"@babel/plugin-proposal-class-properties": "7.8.3",
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.10.1",
"@babel/plugin-proposal-object-rest-spread": "7.9.0",
"@babel/plugin-proposal-optional-chaining": "^7.10.1",
"@babel/plugin-syntax-dynamic-import": "^7.0.0",
"@babel/plugin-transform-runtime": "^7.1.0",
"@babel/preset-env": "^7.1.0",
"@babel/register": "^7.0.0",
"@babel/runtime": "^7.0.0",
"@babel/preset-typescript": "^7.9.0",
"@gfx/zopfli": "^1.0.11",
"@types/node": "^14.0.13",
"@types/webpack-env": "^1.15.2",
"@typescript-eslint/eslint-plugin": "^3.6.1",
"@typescript-eslint/parser": "^3.6.1",
"@vue/compiler-sfc": "^3.0.0-beta.2",
"babel-loader": "^8.0.2",
"clean-webpack-plugin": "^3.0.0",
"compression-webpack-plugin": "^2.0.0",
"copy-webpack-plugin": "^4.5.2",
"create-symlink-webpack-plugin": "^1.0.0",
"critical": "^1.3.4",
"critical-css-webpack-plugin": "^0.2.0",
"css-loader": "^2.1.0",
"css-loader": "^3.4.2",
"cssnano": "^4.1.0",
"dotenv": "^6.1.0",
"file-loader": "^2.0.0",
"eslint": "^7.4.0",
"eslint-plugin-vue": "^7.0.0-alpha.10",
"file-loader": "^6.0.0",
"fork-ts-checker-notifier-webpack-plugin": "^3.0.0",
"fork-ts-checker-webpack-plugin": "^5.0.1",
"git-rev-sync": "^1.12.0",
"glob-all": "^3.1.0",
"html-webpack-plugin": "^3.2.0",
Expand All @@ -83,7 +99,7 @@
"imagemin-webp": "^5.0.0",
"imagemin-webp-webpack-plugin": "^3.1.0",
"img-loader": "^3.0.1",
"mini-css-extract-plugin": "^0.4.3",
"mini-css-extract-plugin": "^0.9.0",
"optimize-css-assets-webpack-plugin": "^5.0.1",
"postcss": "^7.0.2",
"postcss-import": "^12.0.0",
Expand All @@ -98,9 +114,12 @@
"style-loader": "^0.23.0",
"symlink-webpack-plugin": "^0.0.4",
"terser-webpack-plugin": "^1.1.0",
"vue-loader": "^15.4.2",
"ts-loader": "^7.0.1",
"tsconfig-paths-webpack-plugin": "^3.2.0",
"typescript": "^3.8.3",
"typings-for-css-modules-loader": "^1.7.0",
"vue-loader": "^16.0.0-alpha.3",
"vue-style-loader": "^4.1.2",
"vue-template-compiler": "^2.5.17",
"webapp-webpack-plugin": "https://github.com/brunocodutra/webapp-webpack-plugin.git",
"webpack": "^4.19.1",
"webpack-bundle-analyzer": "^3.0.2",
Expand All @@ -117,7 +136,7 @@
"core-js": "^3.0.0",
"regenerator-runtime": "^0.13.2",
"tailwindcss": "^1.0.0",
"vue": "^2.5.17",
"vue-confetti": "^0.4.2"
"vue": "^3.0.0-beta.14",
"vue-confetti": "^2.0.8"
}
}
Loading

0 comments on commit c1b83f4

Please sign in to comment.