Skip to content

Commit 78f2052

Browse files
author
Jeffrey Way
committed
Working on Elixir rewrite
1 parent 9850d8b commit 78f2052

Some content is hidden

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

45 files changed

+1414
-1169
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
.idea/
22
node_modules/
3-
npm-debug.log
3+
npm-debug.log
4+
todo.txt

Config.js

+115-63
Original file line numberDiff line numberDiff line change
@@ -1,89 +1,141 @@
1-
var util = require('gulp-util');
2-
var fs = require('fs');
3-
var _ = require('underscore');
1+
var p = require('path');
2+
var gutils = require('gulp-util');
3+
4+
/*
5+
|----------------------------------------------------------------
6+
| Master Configuration
7+
|----------------------------------------------------------------
8+
|
9+
| This file contains the proper paths and options for each and
10+
| and every Gulp task that Elixir wraps up. To override any
11+
| setting, reference elixir.config.* from your Gulpfile.
12+
|
13+
| Alternatively you may create an elixir.json file within your
14+
| project root. As JSON, modify any settings contained here
15+
| and they'll take precedence over these defaults. Easy!
16+
|
17+
*/
418

519
var config = {
6-
production: !! util.env.production,
7-
srcDir: 'app',
8-
publicDir: 'public',
9-
assetsDir: 'resources/assets/',
10-
cssOutput: 'public/css',
11-
jsOutput: 'public/js',
12-
sourcemaps: ! util.env.production,
13-
autoprefix: true,
14-
tasks: [],
15-
collections: [],
16-
watchers: { default: {} },
17-
babelOptions: {
18-
stage: 2,
19-
compact: false
20+
21+
tasks: [],
22+
23+
assetsPath: 'resources/assets',
24+
25+
publicPath: 'public',
26+
27+
appPath: 'app',
28+
29+
production: !! gutils.env.production,
30+
31+
sourcemaps: true,
32+
33+
css: {
34+
folder: 'css',
35+
36+
outputFolder: 'css',
37+
38+
autoprefix: {
39+
enabled: true,
40+
41+
options: {
42+
browsers: ['last 2 versions'],
43+
cascade: false
44+
}
45+
},
46+
47+
sass: {
48+
folder: 'sass',
49+
50+
pluginOptions: {
51+
outputStyle: !! gutils.env.production
52+
? 'compressed'
53+
: 'nested'
54+
}
55+
},
56+
57+
less: {
58+
folder: 'less',
59+
60+
pluginOptions: {}
61+
}
2062
},
21-
autoprefixerOptions: {
22-
browsers: ['last 2 versions'],
23-
cascade: false
24-
}
25-
};
2663

64+
js: {
65+
folder: 'js',
2766

28-
/**
29-
* Designate that the given task should be watched.
30-
*
31-
* @param {string} task
32-
* @param {string} search
33-
* @param {string} group
34-
*/
35-
config.registerWatcher = function(task, search, group) {
36-
group = group || 'default';
67+
outputFolder: 'js',
3768

38-
this.watchers[group] = this.watchers[group] || {};
69+
babel: {
70+
options: {
71+
stage: 2,
72+
compact: false
73+
}
74+
},
3975

40-
this.watchers[group][task] = search;
76+
browserify: {
77+
options: {}
78+
},
4179

42-
return this;
43-
};
80+
coffee: {
81+
folder: 'coffee',
4482

83+
options: {}
84+
}
85+
},
4586

46-
/**
47-
* Register the given task to be triggered by Gulp.
48-
*
49-
* @param {string} task
50-
*/
51-
config.queueTask = function(task) {
52-
if (! _.contains(this.tasks, task)) {
53-
this.tasks.push(task);
87+
testing: {
88+
phpUnit: {
89+
path: 'tests',
90+
91+
options: {
92+
debug: true,
93+
notify: true
94+
}
95+
},
96+
97+
phpSpec: {
98+
path: 'spec',
99+
100+
options: {
101+
verbose: 'v',
102+
notify: true
103+
}
104+
}
105+
},
106+
107+
versioning: {
108+
buildFolder: 'build'
54109
}
55110

56-
return this;
57111
};
58112

59113

60114
/**
61-
* Set the default directory paths.
115+
* Fetch a config item, using a string dot-notation.
62116
*
63-
* @param {string} file
117+
* @param {string} path
118+
* @return {mixed}
64119
*/
65-
config.setDefaultsFrom = function(file) {
66-
var defaults;
120+
config.get = function(path) {
121+
var basePath;
122+
var current = config;
67123

68-
if (fs.existsSync(file)) {
69-
defaults = JSON.parse(fs.readFileSync(file, 'utf8'));
124+
var segments = path.split('.');
70125

71-
_.extend(this, defaults);
126+
// If the path begins with "assets" or "public," then
127+
// we can assume that the user wants to prefix the
128+
// a base path to the given option they request.
129+
if (segments[0] == 'assets' || segments[0] == 'public') {
130+
basePath = config[segments.shift()+'Path'];
72131
}
73-
};
74132

133+
segments.forEach(function(segment) {
134+
current = current[segment];
135+
});
75136

76-
/**
77-
* Store a set of data in a collection.
78-
*
79-
* @param {string} key
80-
* @param {object} data
81-
*/
82-
config.saveTask = function(key, data) {
83-
this.collections[key] = this.collections[key] || [];
84-
85-
this.collections[key].push(data);
86-
}
137+
return p.join(basePath, current);
138+
};
87139

88140

89141
module.exports = config;

GulpPaths.js

+123
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
var p = require('path');
2+
var gutils = require('gulp-util');
3+
var parsePath = require('parse-filepath');
4+
5+
6+
/**
7+
* Create a new GulpPaths constructor.
8+
*
9+
* @param {string|array} path
10+
* @param {string} defaultName
11+
*/
12+
var GulpPaths = function() {};
13+
14+
15+
/**
16+
* Set the Gulp src file(s) and path prefix.
17+
*
18+
* @param {string|array} src
19+
* @param {string} prefix
20+
*/
21+
GulpPaths.prototype.src = function(src, prefix) {
22+
src = this.prefix(src, prefix);
23+
24+
if (Array.isArray(src)) {
25+
this.src = { path: src, baseDir: prefix };
26+
} else {
27+
this.src = this.parse(src);
28+
29+
// If a directory is provided as the Gulp src,
30+
// the user probably wants everything in it.
31+
this.src.isDir && (this.src.path += '/**/*');
32+
}
33+
34+
return this;
35+
}
36+
37+
38+
/**
39+
* Set the Gulp output path.
40+
*
41+
* @param {string} src
42+
* @param {string} prefix
43+
*/
44+
GulpPaths.prototype.output = function(output, defaultName) {
45+
this.output = this.parse(output);
46+
47+
// If the user didn't provide a path AND file name
48+
// then we'll do our best to choose a default.
49+
if ( ! this.output.name && defaultName) {
50+
// We'll check to see if the provided src is not
51+
// an array. If so, we'll use that single file
52+
// name as the output name. But we must also
53+
// change the extension (.sass -> .css).
54+
if ( ! Array.isArray(this.src.path) && this.src.name.indexOf('*') == -1) {
55+
defaultName = this.changeExtension(
56+
this.src.name,
57+
this.parse(defaultName).extension
58+
);
59+
}
60+
61+
this.output = this.parse(p.join(output, defaultName));
62+
}
63+
64+
return this;
65+
}
66+
67+
68+
/**
69+
* Change the file extension for a path.
70+
*
71+
* @param {string} path
72+
* @param {string} newExtension
73+
*/
74+
GulpPaths.prototype.changeExtension = function(path, newExtension) {
75+
return gutils.replaceExtension(path, newExtension);
76+
};
77+
78+
79+
/**
80+
* Apply a path prefix to the path(s).
81+
*
82+
* @param {string} prefix
83+
* @return {string|array}
84+
*/
85+
GulpPaths.prototype.prefix = function(path, prefix) {
86+
if ( ! prefix) return path;
87+
88+
var prefixOne = function(path) {
89+
return p.join(prefix, path)
90+
.replace(/\/\//g, '/')
91+
.replace(p.join(prefix, prefix), prefix);
92+
};
93+
94+
if (Array.isArray(path)) {
95+
return path.map(prefixOne);
96+
}
97+
98+
return prefixOne(path);
99+
};
100+
101+
102+
/**
103+
* Parse the given file path.
104+
*
105+
* @param {string} path
106+
* @return {object}
107+
*/
108+
GulpPaths.prototype.parse = function(path) {
109+
var segments = parsePath(path);
110+
111+
return {
112+
path : path,
113+
name : segments.extname ? segments.basename : '',
114+
extension : segments.extname,
115+
isDir : ! (!! segments.extname),
116+
baseDir : segments.extname
117+
? segments.dirname
118+
: p.join(segments.dirname, segments.basename)
119+
};
120+
};
121+
122+
123+
module.exports = GulpPaths;

Gulpfile.example.js

-17
This file was deleted.

0 commit comments

Comments
 (0)