Coder Social home page Coder Social logo

cakes's Introduction

cakes

collection of cake files, mainly trying to learn this cool stuff

install

In the root of this repo, run

npm install

It'll get the dependencies as defined in the package.json file (they're quite a few, this may take a while)

[email protected] ./node_modules/mkdirp 
[email protected] ./node_modules/colors 
[email protected] ./node_modules/html-minifier 
[email protected] ./node_modules/coffee-script 
[email protected] ./node_modules/uglify-js 
[email protected] ./node_modules/clean-css 
  └── [email protected]
[email protected] ./node_modules/vows 
  └── [email protected]
[email protected] ./node_modules/connect 
  ├── [email protected]
  └── [email protected]
[email protected] ./node_modules/zombie 
  ├── [email protected]
  ├── [email protected]
  ├── [email protected]
  └── [email protected]
[email protected] ./node_modules/prompt 
  ├── [email protected]
  ├── [email protected]
  └── [email protected]
[email protected] ./node_modules/fileset 
  ├── [email protected]
  └── [email protected]

h5bp

Primary as a learning material, I thought that the h5bp build script could be a great fit to play with coffeescript and cake files

Also a great way to play with Cakefile and EventEmitter to deal with node asynchronicity

cd to h5bp and run cake to get the following output

cake docs                 # Generates the source documentation of this cake script
cake build                # Build with defaults configuration the main tasks: js, css and img optimiaztion
cake js                   # Combines and minifies JS
cake css                  # Combines and minifies CSS
cake img                  # Performs img optimization
cake createproject        # a simple create project task
cake intro                # Kindly inform the developer about the impending magic
cake check                # Performs few validations upon the current repo, outputing errors if any
cake clean                # Wipe the previous build
cake mkdirs               # Create the directory intermediate structure
cake js.main.concat       # Concatenates the JS files in dir.js
cake js.mylibs.concat     # Concatenates the JS files in dir.js.mylibs
cake js.scripts.concat    # Concatenating library file with main script file
cake js.all.minify        # Minifies the *-concat.js files in intermediate/js
cake jshint               # jshint task, run jshint on any non min.js file in dir.js
cake csslint              # csslint task, run csslint on dir.css and ommit *.min.css one
cake css.concat           # Concat the CSS files depending on the @imports in your file.root.stylesheet
cake img.optimize         # Run optipng
cake usemin               # Replaces references to non-minified scripts/styles
cake htmlclean            # Peforms basic to aggresive minification

  -o, --output       directory for the createproject task

This is a quick and dirty implementation, but the following tasks may (or may not) work

  • js: concat libs/mylibs files, calculates a new checksum and uglify the file
  • css: a basic @import inline is made, calculates a new checksum then minify
  • img: execute optipng over the .png files in dir.images
  • lint: jshint/csslint
  • usemin: replaces references to non-minified scripts/styles
  • htmlclean: html minification

test

npm test

it'll trigger a first clone/pull/build if needed, and run the vows/zombie test suite.

Check the tests/build.js file to see the basic asserts

cakes's People

Contributors

mklabs avatar niftylettuce avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

cakes's Issues

sync

since its about build script, we can afford to go sync.

The emitter and (simple) task dependency stuff would remain, but the actual task code may try to use sync methods as much as possible, will drastically cut the overall size and the amount of nested callbacks.

configuration

  • stick with conf/default.coffee, but have to better declare namespace (quite ugly now)
  • using json files
  • using yaml files
  • ini files

Inspiration from:

should be easy to configure assets:

  • each package, order of concat
  • like Jammit, should be a list of glob patterns. This is also the way ant scripts are doing this usually, eg. ant fileset although a bit different)
  • ...

tasks should be split across multiple files / modules

  • Tasks may be created using different modules (css, js, html, img, ...)
  • A module defines a set of tasks
  • A task is simply a function of the form
    • exports.task = function(options, em) {}
  • tasks needs a name/description: name is the fn name, description could be attached to the fn (eg. exports.task.description).

modules would be autoloaded at runtime. The cake script could automatically load modules in a tasks/ folder or something.

probably, a simpler way of doing this would be to rely on vm.createInContext stuff to autoload modules in tasks/ and still use the same cake syntax.

doing this may also allow the use of regular .js files instead of .coffee. Both should work.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.