Skip to content

Commit 1ded40c

Browse files
author
Rafael Grigorian
committed
Version 1.0.0 Released
0 parents  commit 1ded40c

File tree

279 files changed

+33080
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

279 files changed

+33080
-0
lines changed

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
.DS_Store
2+
/.docker-sync/
3+
/node_modules/
4+
/build/
5+
/dist/
6+
/public_html/
7+
/Gemfile.lock
8+
/_*/
9+
/.sass-cache/

LICENSE.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# The MIT License (MIT)
2+
Copyright 2018-present JetRails®
3+
4+
* * *
5+
6+
Permission is hereby granted, free of charge, to any person obtaining a copy of
7+
this software and associated documentation files (the "Software"), to deal in
8+
the Software without restriction, including without limitation the rights to
9+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
10+
the Software, and to permit persons to whom the Software is furnished to do so,
11+
subject to the following conditions:
12+
13+
The above copyright notice and this permission notice shall be included in all
14+
copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
18+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
19+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
20+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Magento 2 — Cloudflare
2+
> Interact with popular Cloudflare features though Magento's backend portal
3+
4+
![](https://img.shields.io/badge/License-MIT-orange.svg?style=for-the-badge)
5+
![](https://img.shields.io/badge/Version-1.0.0-orange.svg?style=for-the-badge)
6+
![](https://img.shields.io/badge/Stability-Stable-orange.svg?style=for-the-badge)
7+
![](https://img.shields.io/badge/Magento-2-orange.svg?style=for-the-badge)
8+
9+
<p align="center" >
10+
<img src="https://jetrails.github.io/magento2-cloudflare/assets/images/static/screenshot.png" width="100%" />
11+
</p>
12+
13+
## Documentation
14+
The user guide can be found in the [docs](docs) folder. The user guide goes through the installation process as well as explains all the features that comes with this plugin. For furthur support, please email [development@jetrails.com](mailto://development@jetrails.com).
15+
16+
## Build System
17+
This extension uses __Gulp__ as it's build system. Gulp is a package that can be easily downloaded using __NPM__ or __Yarn__. Once this repository is cloned, run `npm install gulp -g` followed by `npm install` or `yarn install` to install Gulp and all Gulp modules used within this build system. Please refer to the following table for a description of some useful Gulp commands. A typical Gulp command takes the following form: `gulp <command>`.
18+
19+
| Command | Description |
20+
|-----------|-----------------------------------------------------------------------------------------|
21+
| `init` | Creates build, staging, and distribution directories |
22+
| `clean` | Deletes build and distribution directories |
23+
| `bump` | Bumps version number in source files to reflect version found in package.json |
24+
| `build` | Builds and copies files from source directory to the build directory |
25+
| `deploy` | Copies files from build directory to the staging directory |
26+
| `watch` | Watches files in source directory and executes `deploy` on file change |
27+
| `package` | Updates package.xml with file hashes and packages extension into distribution directory |
28+
29+
## Docker Environment
30+
This project comes with a [docker-compose.yml](docker-compose.yml) and a [docker-sync.yml](docker-sync.yml) file, which can be used to spin up a Magento 1 development environment. In order to use docker, please make sure you have **Docker**, **Docker Compose**, and **Docker Sync** installed. For information about configuring this docker environment, please refer to it's Github repository which can be found [here](https://github.com/jetrails/docker-magento-alpine).

composer.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"name": "jetrails/magento2-cloudflare",
3+
"description": "Interact with popular Cloudflare features though Magento's backend portal",
4+
"type": "magento2-module",
5+
"version": "1.0.0",
6+
"license": "MIT",
7+
"authors": [
8+
{
9+
"name": "Rafael Grigorian",
10+
"email": "me@raffi.io"
11+
}
12+
],
13+
"repositories": [
14+
{
15+
"type": "composer",
16+
"url": "https://composer.magerepo.com/"
17+
}
18+
],
19+
"require": {
20+
"magento/magento-composer-installer": "*"
21+
},
22+
"autoload": {
23+
"psr-4": { "JetRails\\Cloudflare\\": "src/app/code/JetRails/Cloudflare" },
24+
"files": [ "src/app/code/JetRails/Cloudflare/registration.php" ]
25+
}
26+
}

docker-compose.yml

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
version: "2"
2+
3+
volumes:
4+
database:
5+
app-sync:
6+
external: true
7+
networks:
8+
default:
9+
driver: bridge
10+
ipam:
11+
config:
12+
- subnet: "192.168.7.0/28"
13+
services:
14+
php-fpm:
15+
image: jetrails/magento-alpine:php-fpm-7.1
16+
restart: unless-stopped
17+
volumes:
18+
- app-sync:/var/www/html:rw
19+
networks:
20+
default:
21+
aliases:
22+
- php-fpm.docker.internal
23+
environment:
24+
- VERBOSE=true
25+
links:
26+
- mysql
27+
- redis
28+
php-cli:
29+
image: jetrails/magento-alpine:php-cli-7.1
30+
volumes:
31+
- app-sync:/var/www/html:rw
32+
networks:
33+
default:
34+
aliases:
35+
- php-cli.docker.internal
36+
links:
37+
- mysql
38+
- redis
39+
php-cron:
40+
image: jetrails/magento-alpine:php-cron-7.1
41+
restart: unless-stopped
42+
volumes:
43+
- app-sync:/var/www/html:rw
44+
networks:
45+
default:
46+
aliases:
47+
- php-cron.docker.internal
48+
environment:
49+
- VERBOSE=false
50+
links:
51+
- mysql
52+
- redis
53+
nginx:
54+
image: jetrails/magento-alpine:nginx
55+
restart: unless-stopped
56+
volumes:
57+
- app-sync:/var/www/html:rw
58+
networks:
59+
default:
60+
aliases:
61+
- nginx.docker.internal
62+
environment:
63+
- VERBOSE=true
64+
links:
65+
- php-fpm
66+
ports:
67+
- "443:443"
68+
mysql:
69+
image: jetrails/magento-alpine:mysql
70+
restart: unless-stopped
71+
volumes:
72+
- database:/var/lib/mysql
73+
networks:
74+
default:
75+
aliases:
76+
- localhost
77+
- mysql.docker.internal
78+
environment:
79+
- VERBOSE=false
80+
- MYSQL_ROOT_PASSWORD=magento
81+
- MYSQL_USER_NAME=magento
82+
- MYSQL_USER_PASSWORD=magento
83+
- MYSQL_DATABASE=magento
84+
varnish:
85+
image: jetrails/magento-alpine:varnish
86+
restart: unless-stopped
87+
environment:
88+
- VERBOSE=false
89+
networks:
90+
default:
91+
aliases:
92+
- varnish.docker.internal
93+
links:
94+
- nginx
95+
ports:
96+
- "80:80"
97+
redis:
98+
image: jetrails/magento-alpine:redis
99+
restart: unless-stopped
100+
networks:
101+
default:
102+
aliases:
103+
- redis.docker.internal
104+
environment:
105+
- VERBOSE=false

docker-sync.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
version: "2"
2+
3+
syncs:
4+
app-sync:
5+
src: "./public_html"
6+
sync_userid: 1000
7+
sync_groupid: 1000

gulpfile.js

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
const gulp = require ("gulp")
2+
const concat = require ("gulp-concat")
3+
const gzip = require ("gulp-gzip")
4+
const magepack = require ("gulp-magepack")
5+
const minify = require ("gulp-minify-css")
6+
const minifyJs = require ("gulp-minify")
7+
const replace = require ("gulp-replace")
8+
const sass = require ("gulp-sass")
9+
const tar = require ("gulp-tar")
10+
const fs = require ("fs")
11+
const fse = require ("fs-extra")
12+
const path = require ("path")
13+
const webpack = require ("webpack")
14+
const webpackStream = require ("webpack-stream")
15+
16+
const PACKAGE_NAMESPACE = require ("./package.json").namespace
17+
const PACKAGE_VERSION = require ("./package.json").version
18+
const PACKAGE_PATH = PACKAGE_NAMESPACE.replace ( /_/g, "/" )
19+
20+
const SOURCE_DIR = "src"
21+
const BUILD_DIR = "build"
22+
const STAGING_DIR = "public_html"
23+
const PACKAGE_DIR = "dist"
24+
25+
gulp.task ( "init", [], ( callback ) => {
26+
let mkdirNotExists = ( name ) => {
27+
if ( !fs.existsSync ( name ) ) {
28+
fs.mkdirSync ( name )
29+
}
30+
}
31+
mkdirNotExists ( BUILD_DIR )
32+
mkdirNotExists ( PACKAGE_DIR )
33+
mkdirNotExists ( STAGING_DIR )
34+
callback ()
35+
})
36+
37+
gulp.task ( "clean", [], ( callback ) => {
38+
let unlinkExists = ( name ) => {
39+
if ( fs.existsSync ( name ) ) {
40+
fse.removeSync ( name )
41+
}
42+
}
43+
unlinkExists ( BUILD_DIR )
44+
unlinkExists ( PACKAGE_DIR )
45+
callback ()
46+
})
47+
48+
gulp.task ( "bump", [], ( callback ) => {
49+
return gulp.src (`${SOURCE_DIR}/**/*`)
50+
.pipe ( replace ( /(^.*\*\s+@version\s+)(.+$)/gm, "$1" + PACKAGE_VERSION ) )
51+
.pipe ( gulp.dest ( SOURCE_DIR ) )
52+
.on ( "done", callback )
53+
})
54+
55+
gulp.task ( "build-styles", ["init"], ( callback ) => {
56+
return gulp.src (`${SOURCE_DIR}/app/code/${PACKAGE_PATH}/view/adminhtml/web/scss/index.scss`)
57+
.pipe ( sass ({ includePaths: `${SOURCE_DIR}/app/code/${PACKAGE_PATH}/view/adminhtml/web/scss` }) )
58+
.pipe ( minify () )
59+
.pipe ( concat ("bundle.min.css") )
60+
.pipe ( gulp.dest (`${BUILD_DIR}/app/code/${PACKAGE_PATH}/view/adminhtml/web/css`) )
61+
.pipe ( gulp.dest (`${SOURCE_DIR}/app/code/${PACKAGE_PATH}/view/adminhtml/web/css`) )
62+
.on ( "done", callback )
63+
})
64+
65+
gulp.task ( "build-scripts", ["init"], ( callback ) => {
66+
return gulp.src (`${SOURCE_DIR}/app/code/${PACKAGE_PATH}/view/adminhtml/web/js/index.js`)
67+
.pipe ( webpackStream ( require ("./webpack.config.js") ), webpack )
68+
.pipe ( minifyJs ({ ext: { min: ".min.js" } }) )
69+
.pipe ( gulp.dest (`${BUILD_DIR}/app/code/${PACKAGE_PATH}/view/adminhtml/web/js`) )
70+
.pipe ( gulp.dest (`${SOURCE_DIR}/app/code/${PACKAGE_PATH}/view/adminhtml/web/js`) )
71+
.on ( "done", callback )
72+
})
73+
74+
gulp.task ( "build", [ "build-styles", "build-scripts" ], ( callback ) => {
75+
let ignoreJs = [
76+
`!${SOURCE_DIR}/app/code/${PACKAGE_PATH}/view/adminhtml/web/js`,
77+
`!${SOURCE_DIR}/app/code/${PACKAGE_PATH}/view/adminhtml/web/js/**/*`,
78+
]
79+
let ignoreCss = [
80+
`!${SOURCE_DIR}/app/code/${PACKAGE_PATH}/view/adminhtml/web/scss`,
81+
`!${SOURCE_DIR}/app/code/${PACKAGE_PATH}/view/adminhtml/web/scss/**/*`,
82+
`${SOURCE_DIR}/app/code/${PACKAGE_PATH}/view/adminhtml/web/scss/fonts/**/*`
83+
]
84+
return gulp.src ( [`${SOURCE_DIR}/**`].concat ( ignoreJs ).concat ( ignoreCss ) )
85+
.pipe ( gulp.dest ( BUILD_DIR ) )
86+
.on ( "end", () => {
87+
fse.copySync (
88+
`${SOURCE_DIR}/app/code/${PACKAGE_PATH}/view/adminhtml/web/scss/fonts`,
89+
`${BUILD_DIR}/app/code/${PACKAGE_PATH}/view/adminhtml/web/css/fonts`
90+
)
91+
fse.copySync (
92+
`${SOURCE_DIR}/app/code/${PACKAGE_PATH}/view/adminhtml/web/scss/fonts`,
93+
`${SOURCE_DIR}/app/code/${PACKAGE_PATH}/view/adminhtml/web/css/fonts`
94+
)
95+
})
96+
.on ( "done", callback )
97+
})
98+
99+
gulp.task ( "deploy", ["build"], ( callback ) => {
100+
return gulp.src (`${BUILD_DIR}/**/*`)
101+
.pipe ( gulp.dest ( STAGING_DIR ) )
102+
.on ( "done", callback )
103+
})
104+
105+
gulp.task ( "watch", ["deploy"], () => {
106+
return gulp.watch ( `${SOURCE_DIR}/**/*`, ["deploy"] )
107+
})
108+
109+
gulp.task ( "package", [ "clean", "bump", "build" ], ( callback ) => {
110+
let options = {
111+
"template": "conf/package.xml",
112+
"version": PACKAGE_VERSION
113+
}
114+
gulp.src (`${BUILD_DIR}/**/*`)
115+
.pipe ( magepack ( options ) )
116+
.pipe ( tar (`${PACKAGE_NAMESPACE}-${PACKAGE_VERSION}`) )
117+
.pipe ( gzip ({ extension: "tgz" }) )
118+
.pipe ( gulp.dest ( PACKAGE_DIR ) )
119+
.on ( "done", callback )
120+
})

package.json

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"version": "1.0.0",
3+
"name": "magento2-cloudflare",
4+
"description": "Interact with popular Cloudflare features though Magento's backend portal",
5+
"author": "Rafael Grigorian",
6+
"company": "JetRails®",
7+
"license": "MIT",
8+
"namespace": "JetRails_Cloudflare",
9+
"repository": {
10+
"type": "git",
11+
"url": "https://github.com/jetrails/magento2-cloudflare.git"
12+
},
13+
"devDependencies": {
14+
"extract-text-webpack-plugin": "^3.0.2",
15+
"fs-extra": "^7.0.0",
16+
"gulp": "^3.9.1",
17+
"gulp-concat": "^2.6.1",
18+
"gulp-gzip": "^1.4.2",
19+
"gulp-magepack": "^1.0.3",
20+
"gulp-minify": "^2.1.0",
21+
"gulp-minify-css": "^1.2.4",
22+
"gulp-replace": "^1.0.0",
23+
"gulp-sass": "^3.2.1",
24+
"gulp-tar": "^2.1.0",
25+
"gulp-uglify": "^3.0.0",
26+
"webpack": "^3.12.0",
27+
"webpack-stream": "^4.0.3"
28+
},
29+
"dependencies": {
30+
"jquery": "^3.2.1",
31+
"jquery-ui": "^1.12.1"
32+
}
33+
}

0 commit comments

Comments
 (0)