skyfire 0.1.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2515c91100fd3b1c8346ade82c53084bfaf96af6
4
- data.tar.gz: 2e0ce80fe5d792560353fde338c8f0d81ee56d42
3
+ metadata.gz: 4645e9ec2b2dac694f5a67b597dc26b74b0235c2
4
+ data.tar.gz: ef49995995ae9e274eb40e5e587e295c1e9d802e
5
5
  SHA512:
6
- metadata.gz: 9ca23ce0105c89129fceedff9c2bf92bcf9dd1b882cc103a7b913af3e3596c666e79bbce4c59bac211f7f1da79a6683bdde21c2fb3a881231fd9f691eed83fc1
7
- data.tar.gz: 1cdc1c9c6b21ab65b5214f09ddc0d2fb6ba2b223f9934d2cfce6dbf7c93c504a604e8e86ba8e9667072a217b9c3fd48fd26a1141518272382610f8aed2a3b176
6
+ metadata.gz: 7767fb1325d16c1b83f24fc45a383cf44c50467931c699fbc3a4594360d09a1d2d744f3ea004e4e20e6cf48b3f979a6d099e1a55cfbc9d4e4c370d8a0f3f11b7
7
+ data.tar.gz: 9e9a5149812a07e26c31d1e45978277499f7fe11d1141991bcdf5ab2913f319b47b3bdeb41b322048633ee3e38a66d47eea5eaef3b91681c7546eccfe140c0bc
data/LICENSE.txt ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2015 JobReady
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
data/README.md CHANGED
@@ -1,8 +1,27 @@
1
- # Npm::Assets
1
+ # Skyfire
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/npm/assets`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ Skyfire is a ruby gem (and node package) that replaces the asset pipeline in Ruby On Rails applications.
4
4
 
5
- TODO: Delete this and the text above, and describe your gem
5
+ It uses node utilities (npm, browserify) to manage assets and js/css packages.
6
+
7
+ ## Rationale
8
+
9
+ ### Language
10
+
11
+ We love ES6 and integration into the existing asset pipeline can be a bit hit and miss.
12
+
13
+ We aim to avoid mixing import concepts between files and standardising on a common approach to developing javascript applications.
14
+
15
+ ### Packages
16
+
17
+ We build a lot of reusable javascript libraries, and distribution with npm is increasingly becoming the defacto standard
18
+ for deploying packages.
19
+
20
+ We tried Bower, it has its own issues.
21
+
22
+ ### Testing
23
+
24
+ Testing javascript in javascript.
6
25
 
7
26
  ## Installation
8
27
 
@@ -22,7 +41,7 @@ Or install it yourself as:
22
41
 
23
42
  ## Usage
24
43
 
25
- TODO: Write usage instructions here
44
+ see `doc/usage.md`
26
45
 
27
46
  ## Development
28
47
 
@@ -32,5 +51,5 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
32
51
 
33
52
  ## Contributing
34
53
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/skyfire.
54
+ Bug reports and pull requests are welcome on GitHub at https://github.com/jobready/skyfire.
36
55
 
data/gulp/config.js ADDED
@@ -0,0 +1,29 @@
1
+ require('shelljs/global');
2
+ var rootDir = exec('git rev-parse --show-toplevel', {silent:true}).output.replace(/\n$/, '');
3
+ var publicAssets = rootDir+"/public/assets";
4
+ var sourceFiles = rootDir+"/app/assets";
5
+
6
+ module.exports = {
7
+ publicAssets: publicAssets,
8
+ sass: {
9
+ src: sourceFiles + "/stylesheets/**/*.{css,sass,scss}",
10
+ dest: publicAssets + "/stylesheets",
11
+ settings: {
12
+ sourceComments: true,
13
+ indentedSyntax: true, // Enable .sass syntax!
14
+ imagePath: '/assets/images' // Used by the image-url helper
15
+ }
16
+ },
17
+ images: {
18
+ src: sourceFiles + "/images/**",
19
+ dest: publicAssets + "/images"
20
+ },
21
+ browserify: {
22
+ bundleConfigs: [{
23
+ entries: sourceFiles + '/javascripts/application.js',
24
+ dest: publicAssets + '/javascripts',
25
+ outputName: 'bundle.js',
26
+ extensions: ['.js','.jsx']
27
+ }]
28
+ }
29
+ };
data/gulp/rev/index.js ADDED
@@ -0,0 +1,10 @@
1
+ var config = require('../../config');
2
+ var gulp = require('gulp');
3
+ var revCollector = require('gulp-rev-collector');
4
+
5
+ // Replace asset references in compiled css and js files
6
+ gulp.task('rev', ['rev-assets'], function() {
7
+ return gulp.src([config.publicAssets + '/rev-manifest.json', config.publicAssets + '/**/*.{css,js}'])
8
+ .pipe(revCollector())
9
+ .pipe(gulp.dest(config.publicAssets));
10
+ });
@@ -0,0 +1,12 @@
1
+ var config = require('../../config');
2
+ var gulp = require('gulp');
3
+ var rev = require('gulp-rev');
4
+
5
+ // Add md5 hashes to assets
6
+ gulp.task('rev-assets', function(){
7
+ return gulp.src(config.publicAssets + '/**/**.!(css|js|eot|woff|ttf)')
8
+ .pipe(rev())
9
+ .pipe(gulp.dest(config.publicAssets))
10
+ .pipe(rev.manifest())
11
+ .pipe(gulp.dest(config.publicAssets));
12
+ });
@@ -0,0 +1,64 @@
1
+ var _ = require('lodash');
2
+ var browserify = require('browserify');
3
+ var browserSync = require('browser-sync');
4
+ var bundleLogger = require('../util/bundleLogger');
5
+ var config = require('../config').browserify;
6
+ var gulp = require('gulp');
7
+ var handleErrors = require('../util/handleErrors');
8
+ var source = require('vinyl-source-stream');
9
+ var watchify = require('watchify');
10
+
11
+ var browserifyTask = function(callback, devMode) {
12
+
13
+ var bundleQueue = config.bundleConfigs.length;
14
+
15
+ var browserifyThis = function(bundleConfig) {
16
+
17
+ if(devMode) {
18
+ _.extend(bundleConfig, watchify.args, { debug: true });
19
+ bundleConfig = _.omit(bundleConfig, ['external', 'require']);
20
+ }
21
+
22
+ var b = browserify(bundleConfig);
23
+
24
+ var bundle = function() {
25
+ bundleLogger.start(bundleConfig.outputName);
26
+
27
+ return b
28
+ .bundle()
29
+ .on('error', handleErrors)
30
+ .pipe(source(bundleConfig.outputName))
31
+ .pipe(gulp.dest(bundleConfig.dest))
32
+ .on('end', reportFinished)
33
+ .pipe(browserSync.reload({stream:true}));
34
+ };
35
+
36
+ if(devMode) {
37
+ b = watchify(b);
38
+ b.on('update', bundle);
39
+ bundleLogger.watch(bundleConfig.outputName);
40
+ } else {
41
+ if(bundleConfig.require) b.require(bundleConfig.require);
42
+ if(bundleConfig.external) b.external(bundleConfig.external);
43
+ }
44
+
45
+ var reportFinished = function() {
46
+ bundleLogger.end(bundleConfig.outputName);
47
+
48
+ if(bundleQueue) {
49
+ bundleQueue--;
50
+ if(bundleQueue === 0) {
51
+ callback();
52
+ }
53
+ }
54
+ };
55
+
56
+ return bundle();
57
+ };
58
+
59
+ config.bundleConfigs.forEach(browserifyThis);
60
+ };
61
+
62
+ gulp.task('browserify', browserifyTask);
63
+
64
+ module.exports = browserifyTask;
@@ -0,0 +1,9 @@
1
+ var gulp = require('gulp');
2
+ var gulpSequence = require('gulp-sequence')
3
+
4
+ gulp.task('build', function(cb) {
5
+ var tasks = ['clean', ['sass', 'browserify']];
6
+ if(process.env.RAILS_ENV === 'production') tasks.push('rev');
7
+ tasks.push(cb);
8
+ gulpSequence.apply(this, tasks);
9
+ });
@@ -0,0 +1,7 @@
1
+ var gulp = require('gulp');
2
+ var del = require('del');
3
+ var config = require('../config');
4
+
5
+ gulp.task('clean', function (cb) {
6
+ del([config.publicAssets], cb);
7
+ });
@@ -0,0 +1,3 @@
1
+ var gulp = require('gulp');
2
+
3
+ gulp.task('default', ['sass', 'watch']);
@@ -0,0 +1,18 @@
1
+ var gulp = require('gulp');
2
+ var browserSync = require('browser-sync');
3
+ var sass = require('gulp-sass');
4
+ var sourcemaps = require('gulp-sourcemaps');
5
+ var handleErrors = require('../util/handleErrors');
6
+ var config = require('../config').sass;
7
+ var autoprefixer = require('gulp-autoprefixer');
8
+
9
+ gulp.task('sass', function () {
10
+ return gulp.src(config.src)
11
+ .pipe(sourcemaps.init())
12
+ .pipe(sass(config.settings))
13
+ .on('error', handleErrors)
14
+ .pipe(sourcemaps.write())
15
+ .pipe(autoprefixer({ browsers: ['last 2 version'] }))
16
+ .pipe(gulp.dest(config.dest))
17
+ .pipe(browserSync.reload({stream:true}));
18
+ });
@@ -0,0 +1,15 @@
1
+ /* Notes:
2
+ - gulp/tasks/browserify.js handles js recompiling with watchify
3
+ - gulp/tasks/browserSync.js watches and reloads compiled files
4
+ */
5
+
6
+ var gulp = require('gulp');
7
+ var config = require('../config');
8
+ var watch = require('gulp-watch');
9
+
10
+ gulp.task('watch', ['watchify'], function(callback) {
11
+ watch(config.sass.src, function() { gulp.start('sass'); });
12
+ //watch(config.images.src, function() { gulp.start('images'); });
13
+ //watch(config.iconFont.src, function() { gulp.start('iconFont'); });
14
+ // Watchify will watch and recompile our JS, so no need to gulp.watch it
15
+ });
@@ -0,0 +1,7 @@
1
+ var gulp = require('gulp');
2
+ var browserifyTask = require('./browserify');
3
+
4
+ gulp.task('watchify', function(callback) {
5
+ // Start browserify task with devMode === true
6
+ browserifyTask(callback, true);
7
+ });
@@ -0,0 +1,25 @@
1
+ /* bundleLogger
2
+ ------------
3
+ Provides gulp style logs to the bundle method in browserify.js
4
+ */
5
+
6
+ var gutil = require('gulp-util');
7
+ var prettyHrtime = require('pretty-hrtime');
8
+ var startTime;
9
+
10
+ module.exports = {
11
+ start: function(filepath) {
12
+ startTime = process.hrtime();
13
+ gutil.log('Bundling', gutil.colors.green(filepath) + '...');
14
+ },
15
+
16
+ watch: function(bundleName) {
17
+ gutil.log('Watching files required by', gutil.colors.yellow(bundleName));
18
+ },
19
+
20
+ end: function(filepath) {
21
+ var taskTime = process.hrtime(startTime);
22
+ var prettyTime = prettyHrtime(taskTime);
23
+ gutil.log('Bundled', gutil.colors.green(filepath), 'in', gutil.colors.magenta(prettyTime));
24
+ }
25
+ };
@@ -0,0 +1,15 @@
1
+ var notify = require("gulp-notify");
2
+
3
+ module.exports = function() {
4
+
5
+ var args = Array.prototype.slice.call(arguments);
6
+
7
+ // Send error to notification center with gulp-notify
8
+ notify.onError({
9
+ title: "Compile Error",
10
+ message: "<%= error %>"
11
+ }).apply(this, args);
12
+
13
+ // Keep gulp from hanging on this task
14
+ this.emit('end');
15
+ };
@@ -6,6 +6,11 @@ module Skyfire
6
6
  desc "Copy Skyfire package manifest."
7
7
  source_root File.expand_path(File.join(File.dirname(__FILE__), 'templates'))
8
8
 
9
+
10
+ def copy_build_script
11
+ template 'gulpfile.js', 'gulpfile.js'
12
+ end
13
+
9
14
  def copy_package_json
10
15
  template 'package.json', 'package.json'
11
16
  in_root do
@@ -0,0 +1,2 @@
1
+ var requireDir = require('require-dir');
2
+ requireDir('node_modules/skyfire/gulp/tasks', {recurse: true});
@@ -1,10 +1,35 @@
1
1
  {
2
2
  "scripts": {
3
- "build": "skyfire build",
4
- "build-min": "skyfire build-min",
5
- "build-dist": "skyfire build-dist"
3
+ "gulp": "gulp"
6
4
  },
7
- "dependencies": {
5
+ "devDependencies": {
6
+ "gulp-watch": "^4.1.1",
7
+ "browser-sync": "~2.4.0",
8
+ "browserify": "^8.0.2",
9
+ "coffeeify": "~0.7.0",
10
+ "del": "^1.1.1",
11
+ "gulp": "^3.8.7",
12
+ "gulp-autoprefixer": "^2.0.0",
13
+ "gulp-changed": "^0.4.1",
14
+ "gulp-filesize": "0.0.6",
15
+ "gulp-iconfont": "^3.0.0",
16
+ "gulp-imagemin": "^0.6.2",
17
+ "gulp-notify": "^1.4.2",
18
+ "gulp-rename": "^1.2.0",
19
+ "gulp-rev": "^3.0.1",
20
+ "gulp-rev-collector": "^0.1.3",
21
+ "gulp-sass": "~1.3.1",
22
+ "gulp-sequence": "^0.3.2",
23
+ "gulp-sourcemaps": "^1.2.8",
24
+ "gulp-swig": "^0.7.4",
25
+ "gulp-util": "^3.0.0",
26
+ "lodash": "^2.4.1",
27
+ "merge-stream": "^0.1.7",
28
+ "pretty-hrtime": "~0.2.1",
29
+ "require-dir": "^0.1.0",
30
+ "vinyl-source-stream": "~0.1.1",
31
+ "shelljs": "^0.5.1",
32
+ "watchify": "^2.2.1",
8
33
  "private": "jobready/skyfire.git#feature/asset-scripts"
9
34
  }
10
35
  }
@@ -1,5 +1,5 @@
1
1
  module Skyfire
2
- module ApplicationHelper
2
+ module AssetsHelper
3
3
  extend ::ActiveSupport::Concern
4
4
 
5
5
  included do
@@ -1,3 +1,3 @@
1
1
  module Skyfire
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.1"
3
3
  end
data/package.json CHANGED
@@ -3,19 +3,22 @@
3
3
  "version": "1.0.0",
4
4
  "description": "NPM rails assets pipeline CLI",
5
5
  "main": "index.js",
6
- "bin": {
7
- "skyfire" : "bin/assets/skyfire"
8
- },
9
6
  "scripts": {
10
- "test": "echo \"Error: no test specified\" && exit 1"
7
+ "build": "gulp"
11
8
  },
12
- "dependencies": {
9
+ "devDependencies": {
13
10
  "babelify": "^6.1.3",
14
- "browserify": "^11.0.0",
15
- "nodemon": "^1.3.8",
16
- "uglify-js": "^2.4.23",
17
- "uglifyify": "^3.0.1",
18
- "node-sass": "^3.2.0"
11
+ "browserify": "^10.2.6",
12
+ "classnames": "^2.1.3",
13
+ "del": "^1.2.0",
14
+ "gulp": "^3.9.0",
15
+ "gulp-rename": "^1.2.2",
16
+ "gulp-rev": "^3.0.1",
17
+ "gulp-rev-collector": "^0.1.3",
18
+ "gulp-uglify": "^1.2.0",
19
+ "path": "^0.11.14",
20
+ "shelljs": "^0.5.1",
21
+ "vinyl-source-stream": "^1.1.0"
19
22
  },
20
23
  "author": "",
21
24
  "license": "ISC",
data/skyfire-0.2.0.gem ADDED
Binary file
data/skyfire.gemspec CHANGED
@@ -12,6 +12,7 @@ Gem::Specification.new do |spec|
12
12
  spec.summary = %q{Rails asset pipeline replacement}
13
13
  spec.description = %q{Rails asset pipeline replacement.}
14
14
  spec.homepage = "https://github.com/jobready/skyfire"
15
+ spec.licenses = ['MIT']
15
16
 
16
17
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
18
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: skyfire
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew McNamara
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-23 00:00:00.000000000 Z
11
+ date: 2015-07-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -64,28 +64,38 @@ files:
64
64
  - ".rspec"
65
65
  - ".travis.yml"
66
66
  - Gemfile
67
+ - LICENSE.txt
67
68
  - README.md
68
69
  - Rakefile
69
- - bin/assets/css/build.sh
70
- - bin/assets/includes/common.sh
71
- - bin/assets/js/build-debug.sh
72
- - bin/assets/js/build-dist.sh
73
- - bin/assets/js/build-min.sh
74
- - bin/assets/js/build.sh
75
- - bin/assets/skyfire
76
70
  - bin/console
77
71
  - bin/setup
72
+ - doc/usage.md
73
+ - gulp/config.js
74
+ - gulp/rev/index.js
75
+ - gulp/rev/rev-assets.js
76
+ - gulp/tasks/browserify.js
77
+ - gulp/tasks/build.js
78
+ - gulp/tasks/clean.js
79
+ - gulp/tasks/default.js
80
+ - gulp/tasks/sass.js
81
+ - gulp/tasks/watch.js
82
+ - gulp/tasks/watchify.js
83
+ - gulp/util/bundleLogger.js
84
+ - gulp/util/handleErrors.js
78
85
  - index.js
79
86
  - lib/generators/skyfire/install/install_generator.rb
87
+ - lib/generators/skyfire/install/templates/gulpfile.js
80
88
  - lib/generators/skyfire/install/templates/package.json
81
89
  - lib/skyfire.rb
82
90
  - lib/skyfire/asset_manifest.rb
83
91
  - lib/skyfire/assets_helper.rb
84
92
  - lib/skyfire/version.rb
85
93
  - package.json
94
+ - skyfire-0.2.0.gem
86
95
  - skyfire.gemspec
87
96
  homepage: https://github.com/jobready/skyfire
88
- licenses: []
97
+ licenses:
98
+ - MIT
89
99
  metadata: {}
90
100
  post_install_message:
91
101
  rdoc_options: []
@@ -1,4 +0,0 @@
1
- #!/usr/bin/env bash -e
2
- source $(dirname $BASH_SOURCE)/../includes/common.sh
3
- echo "Building CSS"
4
-
@@ -1,6 +0,0 @@
1
- #!/usr/bin/env bash
2
- export ROOT_PATH=$(git rev-parse --show-toplevel)
3
- export ASSETS_PATH=${ROOT_PATH}/assets
4
- export JAVASCRIPTS_PATH=${ASSETS_PATH}/javascripts
5
- export CSS_PATH=${ASSETS_PATH}/stylesheets
6
- export DIST_PATH=${ROOT_PATH}/public/vendor
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env bash
2
- browserify index.js -d --s pizza > dist/pizza.js
@@ -1 +0,0 @@
1
- #!/usr/bin/env bash
@@ -1 +0,0 @@
1
- #!/usr/bin/env bash
@@ -1,5 +0,0 @@
1
- #!/usr/bin/env bash -e
2
- source $(dirname $BASH_SOURCE)/../includes/common.sh
3
-
4
- echo "Building JS"
5
- browserify -d -t babelify -g uglifyify -e ${JAVASCRIPTS_PATH}/application.js | uglifyjs --compress > ${DIST_PATH}/bundle.min.js
data/bin/assets/skyfire DELETED
@@ -1,12 +0,0 @@
1
- #!/usr/bin/env bash -e
2
- export ROOT_PATH=$(git rev-parse --show-toplevel)
3
- export ASSETS_PATH=${ROOT_PATH}/assets
4
- export JAVASCRIPTS_PATH=${ASSETS_PATH}/javascripts
5
- export CSS_PATH=${ASSETS_PATH}/stylesheets
6
- export DIST_PATH=${ROOT_PATH}/public/vendor
7
-
8
- BIN_DIR=$(dirname $BASH_SOURCE)
9
-
10
- echo "Building Javascripts"
11
-
12
- browserify -d -t babelify -g uglifyify -e ${JAVASCRIPTS_PATH}/application.js | uglifyjs --compress > ${DIST_PATH}/bundle.min.js