Skip to content

Commit

Permalink
Ship It script setup and ready to help push builds to production envi…
Browse files Browse the repository at this point in the history
…ronments
  • Loading branch information
BMO-tech committed Jan 6, 2018
1 parent 1d4d946 commit 193f8b6
Show file tree
Hide file tree
Showing 16 changed files with 433 additions and 0 deletions.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2018 SkyPress, LLC

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Customer Experience API
This repo holds the build and local development functions for the CX API

v0.1.0-alpha

Requires:

* Node
* NPM
* Yarn
* NG-CLI
* Composer
* Docker
* Docker Compose

## First steps

* Clone this repo
* Run `docker-compose up -d`
* `composer install` in `/wordpress/wp-content/plugins/cx-api`
* `composer install` in `/wordpress/wp-content/themes/cx-ng-theme`
83 changes: 83 additions & 0 deletions angular/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# NG WAR Theme
This is the pre-build structure of an Angular project. The following adjustments compliment our workflow for creating a WordPress theme based on Angular.

## First Steps

### Install additional packages

```
ng new [name]
ng set --global packageManager=yarn
yarn add @skypress/wp-client@latest
```

Optional

```
yarn add ng-packagr@latest --dev
yarn add @ng-bootstrap/ng-bootstrap
```

### Edit Config Files

Edit the value of `outDir` in your new `.angular-cli.json`:

```
"outDir": "../../wordpress/wp-content/themes/ng-war-theme/src",
```

Optional:

You can change the `prefix` as well to something other than `app`.

Set these `ng-cli` defaults if you'd like:

```
"defaults": {
"styleExt": "css",
"component": {
"spec": false,
"inlineStyle": true,
"inlineTemplate": true
},
"directive": {
"spec": false
},
"module": {
"spec": false
},
"service": {
"spec": false
},
"class": {
"spec": false
}
}
```

If you installed `ng-packagr` then add new scripts to your `package.json`:

```
"build:<package name>": "ng-packagr -p src/app/<package name>/package.json"
```

Then, in `src/app/<package name>` make sure to have a `package.json` file:

```
{
"name": "",
"version": "",
"keywords": [],
"author": "",
"license": "",
"$schema": "../../../node_modules/ng-packagr/ng-package.schema.json",
"ngPackage": {
"lib": {
"entryFile": "index.ts"
},
"dest": "<path relative to>/<package.json>"
}
}
```

See https://www.npmjs.com/package/ng-packagr for more help
36 changes: 36 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
version: '3'

services:
wordpress:
image: wordpress:latest
links:
- mysqldb:mysql
volumes:
- ./wordpress/wp-content:/var/www/html/wp-content
ports:
- 8080:80
environment:
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: wordpress

mysqldb:
image: mysql:latest
volumes:
- db_data:/var/lib/mysql
environment:
MYSQL_ROOT_PASSWORD: secretpress
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: wordpress

phpmyadmin:
image: phpmyadmin/phpmyadmin:latest
links:
- mysqldb:mysql
ports:
- 8181:80
environment:
PMA_HOST: mysql

volumes:
db_data:
24 changes: 24 additions & 0 deletions shipit.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash
#Author: BMO
#Version: 0.1.0-alpha

if [[ -n ${2} ]]; then
root=${2}
else
root="/usr/local/bin/composer"
fi

if [[ -n ${1} ]]; then
current_branch=$(git rev-parse --abbrev-ref HEAD)
echo -e "Splitting out WordPress into temporary branch"
git subtree split --prefix=wordpress -b shipit && git checkout shipit
echo -e "Running composer install for plugins and themes"
find wp-content -maxdepth 3 -iname "composer.json" -type f -execdir php ${root} install --no-dev --prefer-source -o \;
find wp-content -iname ".git" -type d -exec rm -rf "{}" \;
echo -e "Pushing temporary branc"
git add . --all && git commit -am "Pre-ship commit" && git push -f ${1} shipit:master
echo -e "Cleaning up after ourselves"
git checkout ${current_branch} && git branch -D shipit
rm -rf ./wp-content
exit 0
fi
6 changes: 6 additions & 0 deletions wordpress/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
wp-content/**/.git*
**/.git
**/.git*
!.gitignore
angular
wordpress
5 changes: 5 additions & 0 deletions wordpress/wp-content/plugins/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# CUSTOM WAR PLUGIN

* Rename plugin directory and `my-api.php` file
* Edit description block in (new) `my-api.php` file
* `composer install`
6 changes: 6 additions & 0 deletions wordpress/wp-content/plugins/my-api/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"minimum-stability": "dev",
"require": {
"skypress/war-api-plugin": "dev-master"
}
}
104 changes: 104 additions & 0 deletions wordpress/wp-content/plugins/my-api/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions wordpress/wp-content/plugins/my-api/my-api.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php
/**
* Plugin Name: My Api
* Plugin URI: PLUGIN SITE HERE
* Description: PLUGIN DESCRIPTION HERE
* Author: YOUR NAME HERE
* Author URI: YOUR SITE HERE
* Text Domain: my-api
* Domain Path: /languages
* Version: 0.1.0
*
* @package My_Api
*/

require_once __DIR__ . '/vendor/autoload.php';

use WAR\Api as WAR_Api;

function my_init(){
// Init the WAR Api
$war_api = new WAR_Api;
$war_api->init();
}

// Extend the War API
add_action( 'plugins_loaded', 'my_init' );
5 changes: 5 additions & 0 deletions wordpress/wp-content/themes/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# CUSTOM WAR THEME

* Rename theme directory
* Edit description block in `style.css`
* `composer install`
6 changes: 6 additions & 0 deletions wordpress/wp-content/themes/my-theme/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"minimum-stability": "alpha",
"require": {
"skypress/war-ng-theme": "^0.1.0@alpha"
}
}
Loading

0 comments on commit 193f8b6

Please sign in to comment.