Skip to content
Project skeleton
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
gulp
images
src
.gitignore
LICENSE
build.bat
changelog.md
composer.json
gulpfile.js
package.json
post-composer.bat
readme.md

readme.md

Banner

Project skeleton

This project contains scripts to start more quickly a project. The gulp folder contains a lot of scripts that will allow to beautify, lint, minify, ... files and generate the dist folder.

How to use

  1. Copy this repository on your hard disk, in a new folder (for a new project) or into an existing folder (existing project)
  2. For an existing project, copy your existing sources into the src folder of this skeleton (see "Your project structure" here below)
  3. Edit files composer.json and packages.json and fill in your project name, description, version, ...
  4. Open a command prompt ( cmd.exe) and go to the folder of your project (f.i. cd c:\christophe\repository\project_name\)
  5. Install gulp : type npm install gulp
  6. Then update dependencies : type npm update. This step will take time and will install every libraries used by in tasks.
  7. You're ready. To build your package, still in the command prompt, just type build to launch the build.bat script. Every tasks can be disable by just editing your package.json file, see the doit property in each gulp tasks node. See below...

package.json

The package.json file is used by the GULP scripts so that file should exists.

package.json should be edited and the gulp node should be created like illustrated below.

Each task defined in the gulp folder will read their own configuration from package.json.

{
  "name": "project_name",
  "version": "1.0.0",
  "description": "small description of the project",
  "main": "index.php",
  "devDependencies": {
    "csslint-stylish": "0.0.5",
    "del": "^2.2.2",
    "gulp": "^3.9.1",
    "gulp-batch-replace": "0.0.0",
    "gulp-clean-css": "^2.3.2",
    "gulp-cssbeautify": "^0.1.3",
    "gulp-csslint": "^1.0.0",
    "gulp-header": "^1.8.8",
    "gulp-html-replace": "^1.6.2",
    "gulp-htmlhint": "^0.3.1",
    "gulp-htmlmin": "^3.0.0",
    "gulp-if": "^2.0.2",
    "gulp-jshint": "^2.0.4",
    "gulp-json-format": "^1.0.0",
    "gulp-jsonlint": "^1.2.0",
    "gulp-minify-css": "^1.2.4",
    "gulp-phplint": "^0.3.4",
    "gulp-remove-html-comments": "^1.0.1",
    "gulp-shell": "^0.5.2",
    "gulp-uglify": "^2.0.1",
    "gulp-zip": "^4.0.0",
    "gutil": "^1.6.4",
    "jshint": "^2.9.4",
    "jshint-stylish": "^2.2.1",
    "phplint": "^1.7.1",
    "require-dir": "^0.3.1",
    "run-sequence": "^1.2.2"
  },
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "repository": {
    "type": "git",
    "url": "git+https://github.com/cavo789/PROJECT_NAME.git"
  },
  "keywords": [],
  "author": "christophe@aesecure.com",
  "license": "MIT",
  "bugs": {
    "url": "https://github.com/cavo789/PROJECT_NAME/issues"
  },
  "homepage": "https://github.com/cavo789/PROJECT_NAME#readme",
  "gulp": {
    "editor": {
      "tab_size": 3,
      "encoding": "utf-8"
    },
    "paths": {
      "archives": "backups",
      "exclude": "libs",
      "logging": "logs",
      "source": "src",
      "target": "dist"
    },
    "tasks": {
      "backup": {
        "doit": 1
      },
      "source": {
        "code_quality": {
          "sniffer": {
            "doit": 1
          },
          "mess_detector": {
            "doit": 1
          }
        },
        "lint": {
          "css": {
            "doit": 1
          },
          "js": {
            "doit": 1
          },
          "json": {
            "doit": 1
          },
          "php": {
            "doit": 1
          }
        },
        "beautifier": {
          "css": {
            "doit": 1
          },
          "js": {
            "doit": 1
          },
          "json": {
            "doit": 1
          },
          "php": {
            "doit": 1
          }
        }
      },
      "dist": {
        "delete": {
          "doit": 1
        },
        "copy": {
          "doit": 1
        },
        "removedebug": {
          "js": {
            "doit": 1
          },
          "php": {
            "doit": 1
          }
        },
        "minify": {
          "css": {
            "doit": 1
          },
          "js": {
            "doit": 1
          }
        },
        "banner": {
          "header": [
            "<?php",
            "/**",
            "* <%= info.name %> - <%= info.description %>",
            "* @version   : <%= info.version %>",
            "* @author    : <%= info.author %>",
            "* @license   : <%= info.license %>",
            "* @url       : <%= info.homepage %>",
            "* @package   : <%= new Date().toISOString() %>",
            "*/",
            "?>",
            ""
          ],
          "js": {
            "doit": 1
          },
          "php": {
            "doit": 1
          }
        },
        "chmod": {
          "doit": 1
        }
      }
    }
  }
}

Your project structure (at least) :

| -- backups  <== will contains backups of your files before gulp tasks will be fired
| -- dist     <== will be filled in by your source files once processed
| -- gulp     <== will contains files from this repo
| -- logs     <== will contains logs generated by gulp tasks
| -- src      <== PUT YOUR SOURCE CODE HERE

Building

Use build.bat to run each tasks in the predefined order.

Tasks order

1. Main
  1. backup : take a backup of all files under the source folder (called src). The zip file will derived from the package.json file, use name and version and create f.i. project_v1.0-20170203.zip)
2. SRC
  1. phpcs : run PHP code sniffer to check the quality of the code
  2. phpmd : run PHP Mess Detector to check the quality of the code
  3. csslint : run css linting (check syntax)
  4. jslint : run js linting (check syntax)
  5. jsonlint : run json linting (check syntax)
  6. phplint : run php linting (check syntax)
  7. csscbf : run css code beautifier
  8. jscbf : run js code beautifier
  9. jsoncbf : run json code beautifier
  10. phpcbf : run php code beautifier
3. DIST
  1. delete : kill the dist folder, remove the previous generated files
  2. copy : copy files from the src folder to the dist folder
  3. js_removedebug : remove debug infos in javascript files
  4. php_removedebug : remove debug infos in php files
  5. cssmin : minify the css files
  6. jsmin : minify the js files
  7. jsbanner : add a banner to .js files
  8. phpbanner : add a banner to .php files
  9. chmod : set the dist folder read-only

Credits

Christophe Avonture | https://www.aesecure.com

You can’t perform that action at this time.