forked from EngForDev/socketstream
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheck_version.js
47 lines (40 loc) · 2.55 KB
/
check_version.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
// Temporary code to update existing 0.3 alpha projects
// REMOVE_BEFORE_0.3.0
require('colors');
var pathlib = require('path')
, bar = "\n\n*************************************************************************\n\n".cyan;
// Upgrade project to new directory format introduced in 0.3 alpha3
if (pathlib.existsSync('server/rpc/middleware')) {
console.log(bar +
"Thanks for upgrading to the latest SocketStream 0.3 alpha.\nWe've decided to move the following directories\n\n" +
" /server/rpc/middleware to /server/middleware\n\n" +
" /server/rpc/actions to /server/rpc\n\n" +
"so that websocket middleware can be used by other websocket responders (including forthcoming models).\n" +
"Please make this change to your existing project now then restart the server. Pasting this line into a UNIX-based shell should do the trick:\n\n" +
" mv server/rpc/middleware server && mv server/rpc/actions/* server/rpc/ && rm -fr server/rpc/actions\n" + bar);
throw new Error("Please paste the line above into the shell then restart the server");
}
// Delete 'console.js' file if it exists (no longer needed from 0.3 alpha4)
if (pathlib.existsSync('console.js')) require('fs').unlinkSync('console.js');
// Notify of changes to client code when upgrading to 0.3 alpha5
if (pathlib.existsSync('client/code/modules')) {
console.log(bar +
"Thanks for upgrading to the latest SocketStream 0.3 alpha.\n\n" +
"We've made some major improvements to client-side code which will require\na few changes on your part. Please read:\n\n" +
"https://github.com/socketstream/socketstream/blob/master/doc/guide/en/client_side_code.md\n\n".yellow +
"then generate a new project to see the new format.\n\n" +
"This message will go away when /client/code/modules has been renamed to\nsomething else (we suggest 'app') so we know you've upgraded your code" + bar);
throw new Error("Please update your /client/code with the latest changes (see above)");
}
// Ensure two hogan-template.js files are not served together
var hoganFile = 'client/code/libs/hogan-template.js';
if (pathlib.existsSync(hoganFile)) {
require('fs').unlinkSync(hoganFile);
console.log(bar +
"Thanks for upgrading to the latest SocketStream 0.3 beta.\n\n" +
"SocketStream now allows Template Engine modules to deliver client-side code.\n\n" +
"We've deleted " + hoganFile + " from your project as it is\n" +
"no longer required. Please ensure you have ss-hogan 0.1.3 installed by running:\n\n" +
" sudo npm update" + bar);
throw new Error("Please run 'sudo npm update'");
}