forked from scrat-team/scrat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
118 lines (111 loc) · 2.97 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
var fis = module.exports = require('fis');
fis.require.prefixes = [ 'scrat', 'fis' ];
fis.cli.name = 'scrat';
fis.cli.info = fis.util.readJSON(__dirname + '/package.json');
fis.cli.version = require('./version.js');
fis.cli.help.commands = [ 'release', 'install', 'server', 'init' ];
var defaultConfig = require('./configs/default.js');
fis.config.merge(defaultConfig);
fis.olpm = function(info){
if(typeof info === 'string') {
info = {
code : info,
pack : arguments[1]
};
}
info.pack = info.pack || fis.olpm.PACK_TYPE_EXTERNAL;
fis.config.set('olpm', info);
var domain = 'http://image.uc.cn';
if(info.hasOwnProperty('domain') && info.domain){
domain = info.domain.replace(/\/$/, '');
}
fis.config.set('roadmap.domain', domain);
fis.config.set('roadmap.path', require('./configs/olpm.js'));
fis.config.set('modules.prepackager', require('./plugins/prepackager/olpm-pack.js'));
fis.config.set('modules.postpackager', require('./plugins/postpackager/olpm-release.js'));
};
fis.olpm.PACK_TYPE_INLINE = 1;
fis.olpm.PACK_TYPE_EXTERNAL = 2;
//fis.olpm.PACK_TYPE_COMBO = 3;
fis.seo = function(name){
if(typeof name === 'object'){
fis.config.merge(name);
} else {
fis.config.set('name', name || '');
}
fis.config.set('roadmap.path', [
{
reg: 'map.json',
release: 'config/map.json'
},
{
reg: /\/(components|views)(?=\/).*\/_[^\/]+\.tpl$/,
isHtmlLike: true,
isJsLike: false,
isSwig: true,
release: false
},
{
reg: /\/(components|views)(?=\/).*\/_[^\/]+$/,
release: false
},
{
reg: /\/readme\.md$/i,
release: false
},
{
reg: /^\/components\/(.*\.tpl)$/i,
isHtmlLike: true,
isJsLike: false,
isSwig: true,
useMap: true,
useDomain: false,
url: 'views/c/$1',
release: '/views/c/$1'
},
{
reg: /^\/components\/(.*\.(js|css))$/i,
isMod: true,
useSprite: true,
release: '/public/c/$1'
},
{
reg: /^\/components\/(.*)$/i,
useSprite: true,
release: '/public/c/$1'
},
{
reg: /^\/views\/(.*\.tpl)$/i,
isHtmlLike: true,
useMap: true,
isSwig: true,
useDomain: false,
url: 'views/$1',
release: '/views/$1'
},
{
reg: /^\/views\/(.*)$/i,
useSprite: true,
release: '/public/v/$1'
},
{
reg: '**',
useMap: false,
useHash: false,
useCompile: false
}
]);
fis.config.set('modules.packager', 'map');
fis.config.set('modules.preprocessor.tpl', require('./plugins/preprocessor/swig.js'));
fis.config.set('modules.postpackager', require('./plugins/postpackager/seo.js'));
};
//register command plugins
['publish'].forEach(function(name){
fis.require._cache['command-' + name] = require('./plugins/command/' + name);
});
//alias
Object.defineProperty(global, 'scrat', {
enumerable : true,
writable : false,
value : fis
});