-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmakefile.js
163 lines (150 loc) · 7.01 KB
/
makefile.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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
/*!
* FSS release's builder (v1.0.1)
* Copy this script to 'scripts' in editor's main folder. Then just open any source file of FSS and execute script.
*
* @requires YUI Compressor v2.4.7 or newer ('compressor.jar' must be in root folder of this repository)
*
* Script by Grigory Zarubin (http://craigy.ru) for GridinSoft Notepad Pro (http://notepad.gridinsoft.com)
*/
// Îïðåäåëÿåì âñå ïóòè
var PATH = Shell.GetCurrentFolder();
var pathArr = PATH.split('\\');
pathArr.pop();
var ROOT_PATH = pathArr.join('\\');
var COMPRESSOR = ROOT_PATH + '\\compressor.jar';
var VERSION = ROOT_PATH + '\\version.fss';
var SRC_PATH = PATH + '\\';
var HEADER = SRC_PATH + 'header.htm';
var JS_LIBRARY = SRC_PATH + 'include\\suilib_lite.js';
var JS_LIBRARY_MIN = SRC_PATH + 'include\\suilib_lite.min.js';
var STYLES_MAIN = SRC_PATH + 'css\\styles.css';
var STYLES_MAIN_MIN = SRC_PATH + 'css\\styles.min.css';
var STYLES_IE = SRC_PATH + 'css\\styles_ie.css';
var STYLES_IE_MIN = SRC_PATH + 'css\\styles_ie.min.css';
var STYLES_PRINT = SRC_PATH + 'css\\styles_print.css';
var STYLES_PRINT_MIN = SRC_PATH + 'css\\styles_print.min.css';
var FSS_HTML = SRC_PATH + 'fss.htm';
var FSS_CODE = SRC_PATH + 'fss.js';
var FSS_CODE_MIN = SRC_PATH + 'fss.min.js';
var FSS_CODE_TABS = SRC_PATH + 'include\\tabs.js';
var FSS_CODE_TABS_MIN = SRC_PATH + 'include\\tabs.min.js';
var FSS_CODE_OBJ = SRC_PATH + 'include\\objTools.js';
var FSS_CODE_OBJ_MIN = SRC_PATH + 'include\\objTools.min.js';
var FSS_DATA = SRC_PATH + 'input_data.js';
var FOOTER = SRC_PATH + 'footer.htm';
// Âûáèðàåì ðåæèì ñáîðêè, äëÿ óäîáñòâà àâòîìàòîì ïîäñòàâëÿåì âåðñèþ (ïî ñïåöèôèêàöèè Semantic Versioning Specification) è çàïóñêàåì ñáîðêó
var dlg = Application.Dialog;
var currentVersion = Shell.FileTostring(VERSION);
var currentVersionArr = currentVersion.split('.');
var newVersion = currentVersionArr[0] + '.' + currentVersionArr[1] + '.' + (parseInt(currentVersionArr[2], 10) + 1);
dlg.ClearItems();
dlg.AddItem('VERSION_LABEL','10;5;label;Âåðñèÿ ðåëèçà:;no use');
dlg.AddItem('VERSION_VALUE','10;20;edit;'+newVersion+';200');
dlg.AddItem('VERSION_USE','10;45;checkbox;Íå ó÷èòûâàòü;false');
dlg.AddItem('BUILD_MODE_LABEL','10;70;label;Ïðè ñáîðêå:;no use');
dlg.AddItem('BUILD_MODE_VALUE','10;85;combobox;Ñæèìàòü è îáôóñöèðîâàòü|Íå ñæèìàòü;200');
if(dlg.Show('FSS release\'s builder (v1.0.1)', 'Âûáåðèòå ïàðàìåòðû ïåðåä íà÷àëîì:', 300, 195)) {
var result = dlg.Result;
var version_use = result.Item('VERSION_USE')=='False';
var packed = result.Item('BUILD_MODE_VALUE')=='Ñæàòü è îáôóñöèðîâàòü';
var RELEASE = ROOT_PATH + '\\release\\fss' + (packed ? '.htm' : '_full.htm');
if(version_use) {
newVersion = result.Item('VERSION_VALUE');
} else {
newVersion = currentVersion;
}
// Ñîáèðàåì ðåëèç
var all = '';
var file_content = '';
var temp = '';
var temp_ = '';
temp = Shell.FileTostring(HEADER);
temp_ = temp.replace(/%%FSS_VERSION%%/, newVersion);
all += temp_;
if(packed) {
Console.SetVisible(true);
Console.Execute('java -jar "'+COMPRESSOR+'" --type css --charset utf-8 --verbose -o "'+STYLES_MAIN_MIN+'" "'+STYLES_MAIN+'"');
Console.SetVisible(false);
if(Shell.FileExist(STYLES_MAIN_MIN)) {
file_content = Shell.FileTostring(STYLES_MAIN_MIN);
Shell.DeleteFile(STYLES_MAIN_MIN);
}
}
if(file_content=='') file_content = Shell.FileTostring(STYLES_MAIN);
temp = '\r\n<style type="text\/css" media="screen, projection">\r\n' + file_content + '\r\n<\/style>';
file_content = '';
all += temp;
if(packed) {
Console.SetVisible(true);
Console.Execute('java -jar "'+COMPRESSOR+'" --type css --charset utf-8 --verbose -o "'+STYLES_IE_MIN+'" "'+STYLES_IE+'"');
Console.SetVisible(false);
if(Shell.FileExist(STYLES_IE_MIN)) {
file_content = Shell.FileTostring(STYLES_IE_MIN);
Shell.DeleteFile(STYLES_IE_MIN);
}
}
if(file_content=='') file_content = Shell.FileTostring(STYLES_IE);
temp = '\r\n<!--[if lte IE 7]><style type="text\/css" media="screen, projection">\r\n' + file_content + '\r\n<\/style><![endif]-->';
file_content = '';
all += temp;
if(packed) {
Console.SetVisible(true);
Console.Execute('java -jar "'+COMPRESSOR+'" --type css --charset utf-8 --verbose -o "'+STYLES_PRINT_MIN+'" "'+STYLES_PRINT+'"');
Console.SetVisible(false);
if(Shell.FileExist(STYLES_PRINT_MIN)) {
file_content = Shell.FileTostring(STYLES_PRINT_MIN);
Shell.DeleteFile(STYLES_PRINT_MIN);
}
}
if(file_content=='') file_content = Shell.FileTostring(STYLES_PRINT);
temp = '\r\n<style type="text\/css" media="print">\r\n' + file_content + '\r\n<\/style>\r\n';
file_content = '';
all += temp;
if(packed) {
Console.SetVisible(true);
Console.Execute('java -jar "'+COMPRESSOR+'" --type js --charset utf-8 --verbose -o "'+JS_LIBRARY_MIN+'" "'+JS_LIBRARY+'"');
Console.SetVisible(false);
if(Shell.FileExist(JS_LIBRARY_MIN)) {
file_content = Shell.FileTostring(JS_LIBRARY_MIN);
Shell.DeleteFile(JS_LIBRARY_MIN);
}
}
if(file_content=='') file_content = Shell.FileTostring(JS_LIBRARY);
temp = '<script type="text\/javascript">\r\n\/\/<![CDATA[\r\n' + file_content + '\r\n\/\/]]>\r\n<\/script>\r\n';
file_content = '';
all += temp;
temp = Shell.FileTostring(FSS_HTML);
temp_ = temp.replace(/%%FSS_VERSION%%/, newVersion);
all += temp_;
if(packed) {
Console.SetVisible(true);
Console.Execute('java -jar "'+COMPRESSOR+'" --type js --charset utf-8 --verbose -o "'+FSS_CODE_TABS_MIN+'" "'+FSS_CODE_TABS+'"');
Console.Execute('java -jar "'+COMPRESSOR+'" --type js --charset utf-8 --verbose -o "'+FSS_CODE_OBJ_MIN+'" "'+FSS_CODE_OBJ+'"');
Console.Execute('java -jar "'+COMPRESSOR+'" --type js --charset utf-8 --verbose -o "'+FSS_CODE_MIN+'" "'+FSS_CODE+'"');
Console.SetVisible(false);
if(Shell.FileExist(FSS_CODE_TABS_MIN)) {
file_content = Shell.FileTostring(FSS_CODE_TABS_MIN);
Shell.DeleteFile(FSS_CODE_TABS_MIN);
}
if(Shell.FileExist(FSS_CODE_OBJ_MIN)) {
file_content += Shell.FileTostring(FSS_CODE_OBJ_MIN);
Shell.DeleteFile(FSS_CODE_OBJ_MIN);
}
if(Shell.FileExist(FSS_CODE_MIN)) {
file_content += Shell.FileTostring(FSS_CODE_MIN);
Shell.DeleteFile(FSS_CODE_MIN);
}
}
if(file_content=='') file_content = Shell.FileTostring(FSS_CODE_TABS) + '\r\n\r\n' + Shell.FileTostring(FSS_CODE_OBJ) + '\r\n\r\n\r\n' + Shell.FileTostring(FSS_CODE);
temp = '\r\n\r\n<script type="text\/javascript">\r\n\/\/<![CDATA[\r\n' + file_content + '\r\n\r\n\r\n' + Shell.FileTostring(FSS_DATA) + '\r\n\/\/]]>\r\n<\/script>\r\n';
all += temp;
temp = Shell.FileTostring(FOOTER);
all += temp;
if(version_use) {
if(Shell.FileExist(VERSION)) Shell.DeleteFile(VERSION);
Shell.CreateFile(VERSION, newVersion);
}
if(Shell.FileExist(RELEASE)) Shell.DeleteFile(RELEASE);
Shell.CreateFile(RELEASE, all);
Application.Message('FSS release\'s builder (v1.0.1)', 'Ðåëèç ñîáðàí â ôàéë '+RELEASE, 0);
}