This repository has been archived by the owner on Apr 26, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.js
89 lines (82 loc) · 3.45 KB
/
main.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
var path = require('path');
const fsNew = require('fs-extra')
const git = require('./src/git/git');
const transport = require('./src/transport/transport');
const transportNew = require('./src/transport/transportNew');
const prefs = require('./src/preference/prefs') ;
const os = require('os');
const baseDirName = require('./package.json').name;
/**
* @function _projectSaved
* @description this method calls when user save changes in model file
*/
function _projectSaved() {
console.log("project saved");
git.projectLoaded();
}
/**
* @function _projectClosed
* @description this method calls when user close model file
*/
function _projectClosed() {
console.log("project closed");
}
/**
* @function init
* @description function will be called when the extension is loaded
*/
function init() {
/* Register preference for repository url */
app.preferences.register(prefs);
app.commands.register('tool.transport:import', transport.importModel);
app.commands.register('tool.transport:export', transport.exportModel);
app.commands.register('tool.transport:exportNew', transportNew.exportNewModel);
app.commands.register('tool.transport:importNew', transportNew.importNewModel);
app.commands.register('tool.git:initclone', git.initClone);
app.commands.register('tool.git:sync', git.sync);
/* Enable below line when git feature to enable
app.project.on('projectLoaded', git.projectLoaded);
*/
/* app.commands.register('tool.git:init', git.getInit);
app.commands.register('tool.git:addremote', git.getAddRemote);
app.commands.register('tool.git:commit', git.getCommit);
app.commands.register('tool.git:addconfig', git.getAddConfig);
app.commands.register('tool.git:configlist', git.getConfigList);
app.commands.register('tool.git:push', git.getPush);
app.commands.register('tool.git:pull', git.getPull);
app.commands.register('tool.git:log', git.getLog);
app.commands.register('tool.git:status', git.getStatus);
app.commands.register('tool.git:diff', git.getDiff);
app.commands.register('tool.git:clone', git.gitClone);
app.project.on('projectClosed', _projectClosed);
app.project.on('projectSaved', _projectSaved); */
/* app.project.on('projectCreated', _projectCreated); */
app.project.on('projectSaved', _projectSaved);
}
/**
* @function runStarUML
* @description This is script to run staruml project for Windows and Linux OS. This function will copy all project files in staruml installed directory
*/
function runStarUML(){
/* possible values of os 'aix', 'darwin', 'freebsd', 'linux', 'openbsd', 'sunos', 'win32' */
let homeDirectory = os.homedir();
let dest = '';
let src = __dirname+path.sep;
if(os.platform == 'win32') {
dest = homeDirectory+path.sep+'AppData'+path.sep+'Roaming'+path.sep+'StarUML'+path.sep+'extensions'+path.sep+'user'+path.sep+baseDirName+path.sep;
}
else if(os.platform == 'linux') {
dest = homeDirectory+'.config'+path.sep+'StarUML'+path.sep+'extensions'+path.sep+'user'+path.sep+baseDirName+path.sep;
}
console.log("platform : ",os.platform);
console.log("base : ",baseDirName);
console.log("src : ",src);
console.log("dest : ",dest);
console.log("Coping files..!")
fsNew.copy(src, dest)
.then(() => console.log('success!'))
.catch(err => console.error(err));
return '';
}
exports.init = init
exports.runStarUML = runStarUML