This repository has been archived by the owner on Feb 20, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
143 lines (139 loc) · 5.5 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
'use strict';
var typeScriptGenerator = require('onejs-compiler').TypeScriptGenerator;
var typeScriptViewModelGenerator = require('onejs-compiler').TypeScriptViewModelGenerator;
var devTasks = require('./tasks/dev.js');
var releaseTasks = require('./tasks/release.js');
var testTasks = require('./tasks/test.js');
var _ = require('lodash');
var fs = require('fs');
module.exports = {
gulpTasks: {
paths: {
// The common directory structure OneJS uses along with some helpful glob patterns
app: {
// A website would consume files in this dir
root: 'app/',
jsGlob: 'app/**/**/**/!*.test.js',
cssGlob: 'app/**/**/**/*.css.js',
htmlGlob: 'app/**/**/**/*.html.js',
test: 'app/test/',
distGlob: 'app/**/**/**/*.js',
min: {
root: 'app-min/'
}
},
deps: {
// OneJS files that will need to be copied during build process
'bower_components/onejs/dist/amd/*.d.ts': 'temp/',
'bower_components/onejs/dist/amd/*.js': 'app/onejs/',
'typings/**/*.d.ts': 'temp/',
},
dist: {
// Distributable structure
root: 'dist/',
amd: 'dist/amd/',
commonjs: 'dist/commonjs/',
glob: 'dist/**/**/**/*',
metaGlob: ['package.json', 'bower.json'],
gitGlob: 'dist/*'
},
src: {
// The (non-test) source will live here
root: 'src/',
htmlGlob: 'src/**/**/**/*.html',
lessGlob: 'src/**/**/**/*.less',
tsGlob: 'src/**/**/**/*.ts',
glob: 'src/**/**/**/*'
},
staticFiles: {
// Static files that may need to be copied/referenced
js: [
'node_modules/requirejs/require.js'
],
npmPackage: 'package.json',
bowerPackage: 'bower.json'
},
release: {
// These are temp directories that are only used when
// publishing to a dist branch
root: 'releaseTemp/',
dist: 'releaseTemp/dist/',
distGlob: 'releaseTemp/dist/**/**/**/*',
metaGlob: 'releaseTemp/*.json',
},
temp: {
// Temp staging dir for building
root: 'temp/',
test: 'temp/test/',
testGlob: 'temp/(*.test.ts|*.Test.ts)',
typings: 'temp/typings/',
typingsGlob: 'temp/typings/**/*.d.ts',
tsGlob: 'temp/**/**/*.ts',
srcGlob: 'temp/**/**/**/!(*.test.ts|*.js)',
},
test: {
// Test files will live here
root: 'test/',
unit: {
root: 'test/unit/',
glob: 'test/unit/*.ts'
},
functional: {
root: 'test/functional/',
glob: 'test/functional/*.ts'
},
glob: 'test/**/*.ts',
karmaConf: 'karma.conf.js'
},
typings: {
// This dir is to match up with the structure of tsd: https://github.com/DefinitelyTyped/tsd
root: 'typings/',
glob: 'typings/**/*.d.ts'
}
},
dev: function(options) {
// Registers the gulp tasks found in tasks/dev.js
devTasks(this.mixOptions(options));
},
release: function(options) {
// Registers the gulp tasks found in tasks/release.js and dev.js
var mixedOptions = this.mixOptions(options);
devTasks(mixedOptions);
releaseTasks(mixedOptions);
},
test: function(options) {
// Registers the gulp tasks found in tasks/test.js and dev.js
var mixedOptions = this.mixOptions(options);
devTasks(mixedOptions);
testTasks(mixedOptions);
},
all: function(options) {
// Registers all the gulp tasks found in tasks/*.js
this.dev(options);
this.release(options);
this.test(options);
},
mixOptions: function(options) {
if (!options.gulp || !options.rootDir) {
console.log('Please provide your gulp and rootDir in the options!');
}
// Mix in path options
this.paths.deps = _.merge(this.paths.deps, options.deps);
return {
gulp: options.gulp,
rootDir: options.rootDir || __dirname,
paths: options.paths || this.paths,
karma: options.karma,
karmaOptions: options.karmaOptions || {},
autoprefixerOptions: options.autoprefixerOptions || {},
// Set our default to target ES5, but allow overrides from the user
tscOptions: _.merge({target: 'ES5'}, options.tscOptions),
tsLintOptions: options.tsLintOptions || {
// Use the default tslint we have set up if no options passed
configuration: JSON.parse(fs.readFileSync(__dirname + '/tslint.json'))
},
gulpTaskOptions: options.gulpTaskOptions || {},
}
}
}
};