@kumologica/sdk 3.0.27-beta5 → 3.0.27-beta7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli/commands/export-commands/cloudformation.js +16 -1
- package/cli/commands/export-commands/utils/validator.js +17 -0
- package/package.json +6 -4
- package/src/app/main-process/main-window.js +1 -1
- package/src/app/main-process/menu.js +1 -1
- package/src/app/main.js +2 -2
- package/src/app/preload.js +5 -7
- package/src/app/ui/editor-api/lib/editor/comms.js +3 -3
- package/src/app/ui/editor-client/public/red/red.js +310 -5
- package/src/app/ui/editor-client/public/red/red.min.js +1 -1
- package/src/app/ui/editor-client/public/red/style.min.css +1 -1
- package/src/app/ui/editor-client/public/vendor/simplemde/simplemde.min.css +0 -7
- package/src/app/ui/editor-client/public/vendor/simplemde/simplemde.min.js +0 -15
- package/src/app/ui/editor-client/public/vendor/xterm/lib/xterm.js +0 -2
- package/src/app/ui/editor-client/src/js/ui/sidebar.js +2 -0
- package/src/app/ui/editor-client/src/js/ui/tab-git.js +307 -0
- package/src/app/ui/editor-client/src/js/ui/tab-test.js +2 -5
- package/src/app/ui/editor-client/src/sass/style.scss +1 -0
- package/src/app/ui/editor-client/src/sass/tab-git.scss +54 -0
|
@@ -125,6 +125,11 @@ exports.builder = {
|
|
|
125
125
|
type: 'string',
|
|
126
126
|
nargs: 1
|
|
127
127
|
},
|
|
128
|
+
"layers": {
|
|
129
|
+
describe: `\nList of arn of lambda layers to be added.`,
|
|
130
|
+
type: 'string',
|
|
131
|
+
nargs: 1
|
|
132
|
+
},
|
|
128
133
|
"policy": {
|
|
129
134
|
describe: `\nAdditional iam policy to add to the role. It must be in valid aws policy format, for example: '{"Effect": "Allow", "Resource": ["*"],"Action": ["sns:Publish"]}'. if policy is invalid, cloudformation stack will fail. The value can be single policy statement or array of statements if required. This parameter is ignored if role-arn is provided.`,
|
|
130
135
|
type: 'string',
|
|
@@ -156,12 +161,18 @@ Examples:
|
|
|
156
161
|
3. Creates event trigger using rate expression that runs every minute for event listener with reference "cleanup":\n
|
|
157
162
|
{"event": {"expression": "rate(1 minute)", "reference": "cleanup"}}\n
|
|
158
163
|
|
|
164
|
+
SNS:\n----
|
|
165
|
+
* topicArn - the ARN of sns topic, required
|
|
166
|
+
|
|
167
|
+
Example:
|
|
168
|
+
{"sns": {"topicArn": "arn:aws:sns: ..."}}
|
|
169
|
+
|
|
159
170
|
SQS:\n----
|
|
160
171
|
* queueArn - the ARN of sqs queue, required
|
|
161
172
|
* batchSize - the size of batch, optional
|
|
162
173
|
|
|
163
174
|
Example:
|
|
164
|
-
{"sqs": {"queueArn": "arn:aws: ..."}}
|
|
175
|
+
{"sqs": {"queueArn": "arn:aws:sqs: ..."}}
|
|
165
176
|
|
|
166
177
|
DynamoDB Stream:\n----
|
|
167
178
|
* streamArn - the ARN of dynamodb stream, required
|
|
@@ -265,6 +276,7 @@ function display(argv) {
|
|
|
265
276
|
console.log(' log-retention-days: %s', argv["log-retention-days"]||'');
|
|
266
277
|
console.log(' role-arn: %s', argv["role-arn"]||'');
|
|
267
278
|
console.log(' policy: %s', argv["policy"] || '');
|
|
279
|
+
console.log(' layers: %s', argv["layers"] || '');
|
|
268
280
|
console.log(` strict-mode: ${argv["strict-mode"]}`);
|
|
269
281
|
console.log(' triggers: %s', argv.triggers||'');
|
|
270
282
|
}
|
|
@@ -309,6 +321,9 @@ function validate(argv) {
|
|
|
309
321
|
if (argv["file-system-configs"]) {
|
|
310
322
|
validateJson("file-system-configs", argv["file-system-configs"]);
|
|
311
323
|
}
|
|
324
|
+
if (argv["layers"]) {
|
|
325
|
+
validateJson("layers", argv["layers"]);
|
|
326
|
+
}
|
|
312
327
|
if (argv.triggers) {
|
|
313
328
|
validateJson("triggers", argv.triggers);
|
|
314
329
|
validator.validate("triggers", JSON.parse(argv.triggers));
|
|
@@ -58,6 +58,23 @@ const triggersSchema = {
|
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
60
|
},
|
|
61
|
+
"sns": {
|
|
62
|
+
"$id": "#root/items/sns",
|
|
63
|
+
"title": "Sns",
|
|
64
|
+
"type": "object",
|
|
65
|
+
"required": [
|
|
66
|
+
"topicArn"
|
|
67
|
+
],
|
|
68
|
+
additionalProperties: false,
|
|
69
|
+
"properties": {
|
|
70
|
+
"topicArn": {
|
|
71
|
+
"$id": "#root/items/sns/topicArn",
|
|
72
|
+
"title": "Topicarn",
|
|
73
|
+
"type": "string",
|
|
74
|
+
"pattern": "^.*$"
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
},
|
|
61
78
|
"api": {
|
|
62
79
|
"$id": "#root/items/api",
|
|
63
80
|
"title": "Api",
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"productName": "Kumologica Designer",
|
|
4
4
|
"copyright": "Copyright 2020 Kumologica Pty Ltd, All Rights Reserved.",
|
|
5
5
|
"author": "Kumologica Pty Ltd <contact@kumologica.com>",
|
|
6
|
-
"version": "3.0.27-
|
|
6
|
+
"version": "3.0.27-beta7",
|
|
7
7
|
"description": "Kumologica Designer, harnessing Serverless for your cloud integration needs",
|
|
8
8
|
"main": "src/app/main.js",
|
|
9
9
|
"files": [
|
|
@@ -65,9 +65,9 @@
|
|
|
65
65
|
"license": "Proprietary",
|
|
66
66
|
"dependencies": {
|
|
67
67
|
"@electron/remote": "^2.0.8",
|
|
68
|
-
"@kumologica/builder": "3.0.27-
|
|
69
|
-
"@kumologica/devkit": "3.0.27-
|
|
70
|
-
"@kumologica/runtime": "3.0.27-
|
|
68
|
+
"@kumologica/builder": "3.0.27-beta7",
|
|
69
|
+
"@kumologica/devkit": "3.0.27-beta7",
|
|
70
|
+
"@kumologica/runtime": "3.0.27-beta7",
|
|
71
71
|
"adm-zip": "0.4.13",
|
|
72
72
|
"ajv": "8.10.0",
|
|
73
73
|
"aws-sdk": "2.513.0",
|
|
@@ -111,12 +111,14 @@
|
|
|
111
111
|
"request": "2.88.0",
|
|
112
112
|
"rimraf": "3.0.0",
|
|
113
113
|
"shell-path": "2.1.0",
|
|
114
|
+
"simple-git": "^3.14.1",
|
|
114
115
|
"simplemde": "1.11.2",
|
|
115
116
|
"smoketail": "0.2.2",
|
|
116
117
|
"socket.io": "2.3.0",
|
|
117
118
|
"tcp-port-used": "1.0.2",
|
|
118
119
|
"util": "0.12.1",
|
|
119
120
|
"when": "3.7.8",
|
|
121
|
+
"wide-align": "^1.1.5",
|
|
120
122
|
"wildcard-match": "^5.1.2",
|
|
121
123
|
"ws": "7.1.1",
|
|
122
124
|
"xterm": "4.1.0",
|
|
@@ -85,7 +85,7 @@ class MainWindow {
|
|
|
85
85
|
|
|
86
86
|
this.window.webContents.on('did-finish-load', () => {
|
|
87
87
|
// this.checkForUpdates();
|
|
88
|
-
this.updateProjectInfo(this.lastUserProjectDir, this.lastFlowfile || "
|
|
88
|
+
this.updateProjectInfo(this.lastUserProjectDir, this.lastFlowfile || "__untitled__");
|
|
89
89
|
this.emitter.emit('did-load', null);
|
|
90
90
|
|
|
91
91
|
if (this.startupErrorEvent) {
|
package/src/app/main.js
CHANGED
|
@@ -75,7 +75,7 @@ ipcMain.on('modal-welcome:show-dialog-newproject', async () => {
|
|
|
75
75
|
|
|
76
76
|
let userDir = codegen.generateInitialCode(
|
|
77
77
|
userPrefStore.getUserDataPath(),
|
|
78
|
-
'
|
|
78
|
+
'__untitled__',
|
|
79
79
|
null,
|
|
80
80
|
version
|
|
81
81
|
);
|
|
@@ -477,7 +477,7 @@ async function openWelcomePage() {
|
|
|
477
477
|
|
|
478
478
|
let userDir = codegen.generateInitialCode(
|
|
479
479
|
userPrefStore.getUserDataPath(),
|
|
480
|
-
'
|
|
480
|
+
'__untitled__',
|
|
481
481
|
null,
|
|
482
482
|
version
|
|
483
483
|
);
|
package/src/app/preload.js
CHANGED
|
@@ -11,7 +11,7 @@ const { AppServer, lambdify } = require('./lib/runtime-loader');
|
|
|
11
11
|
const { Terminal } = require('xterm');
|
|
12
12
|
const { FitAddon } = require('xterm-addon-fit');
|
|
13
13
|
const electron = require('electron');
|
|
14
|
-
const remote = require('@electron/remote')
|
|
14
|
+
const remote = require('@electron/remote');
|
|
15
15
|
|
|
16
16
|
// Parse arguments from: webPreferences.additionalArguments
|
|
17
17
|
const argv = require('yargs/yargs')(process.argv.slice(2)).parse();
|
|
@@ -22,6 +22,7 @@ const debounce = require('debounce');
|
|
|
22
22
|
const { promisify } = require('util');
|
|
23
23
|
|
|
24
24
|
const dagre = require('dagre');
|
|
25
|
+
const simpleGit = require('simple-git');
|
|
25
26
|
const request = require('request');
|
|
26
27
|
const requestAsync = promisify(request);
|
|
27
28
|
|
|
@@ -168,7 +169,7 @@ async function getRegion(profile) {
|
|
|
168
169
|
return region;
|
|
169
170
|
}
|
|
170
171
|
|
|
171
|
-
async function testFlow(testEvent, targetNode, environmentVariables
|
|
172
|
+
async function testFlow(testEvent, targetNode, environmentVariables) {
|
|
172
173
|
|
|
173
174
|
let event;
|
|
174
175
|
|
|
@@ -185,10 +186,6 @@ async function testFlow(testEvent, targetNode, environmentVariables, traceabilit
|
|
|
185
186
|
|
|
186
187
|
headers = { ...headers, 'x-kumologica-testcasenode': targetNode };
|
|
187
188
|
|
|
188
|
-
if (traceabilityEnabled === true){
|
|
189
|
-
headers = { ...headers, 'x-kumologica-traceability': true}
|
|
190
|
-
}
|
|
191
|
-
|
|
192
189
|
if (environmentVariables) {
|
|
193
190
|
if (Object.keys(environmentVariables).length > 0) {
|
|
194
191
|
headers = {
|
|
@@ -536,6 +533,7 @@ async function azureLogin(profile) {
|
|
|
536
533
|
await azure.login(alias);
|
|
537
534
|
return {alias: alias};
|
|
538
535
|
}
|
|
536
|
+
|
|
539
537
|
/**
|
|
540
538
|
* Dispatch an action from the ipcRenderer to the main process
|
|
541
539
|
* @param {string} type
|
|
@@ -622,7 +620,7 @@ window.__kumologica.libs.testFlow = testFlow;
|
|
|
622
620
|
window.__kumologica.libs.openFileOnEditor = openFileOnEditor;
|
|
623
621
|
window.__kumologica.libs.openFolder = openFolder;
|
|
624
622
|
window.__kumologica.libs.dagre = dagre;
|
|
625
|
-
|
|
623
|
+
window.__kumologica.libs.simpleGit = simpleGit;
|
|
626
624
|
|
|
627
625
|
// Node Library
|
|
628
626
|
window.__kumologica.nodeLibrary = {};
|
|
@@ -57,7 +57,7 @@ function CommsConnection(ws) {
|
|
|
57
57
|
var self = this;
|
|
58
58
|
|
|
59
59
|
log.audit({ event: 'comms.open' });
|
|
60
|
-
log.trace('comms.open ' + self.session);
|
|
60
|
+
// log.trace('comms.open ' + self.session);
|
|
61
61
|
var pendingAuth = settings.adminAuth != null;
|
|
62
62
|
|
|
63
63
|
if (!pendingAuth) {
|
|
@@ -65,7 +65,7 @@ function CommsConnection(ws) {
|
|
|
65
65
|
}
|
|
66
66
|
ws.on('close', function () {
|
|
67
67
|
log.audit({ event: 'comms.close', user: self.user, session: self.session });
|
|
68
|
-
log.trace('comms.close ' + self.session);
|
|
68
|
+
// log.trace('comms.close ' + self.session);
|
|
69
69
|
removeActiveConnection(self);
|
|
70
70
|
});
|
|
71
71
|
ws.on('message', function (data, flags) {
|
|
@@ -73,7 +73,7 @@ function CommsConnection(ws) {
|
|
|
73
73
|
try {
|
|
74
74
|
msg = JSON.parse(data);
|
|
75
75
|
} catch (err) {
|
|
76
|
-
log.trace('comms received malformed message : ' + err.toString());
|
|
76
|
+
// log.trace('comms received malformed message : ' + err.toString());
|
|
77
77
|
return;
|
|
78
78
|
}
|
|
79
79
|
if (!pendingAuth) {
|
|
@@ -21235,11 +21235,13 @@ RED.view.tools = (function() {
|
|
|
21235
21235
|
RED.sidebar.nodeinfo.init();
|
|
21236
21236
|
RED.sidebar.info.init();
|
|
21237
21237
|
RED.sidebar.test.init();
|
|
21238
|
+
RED.sidebar.git.init();
|
|
21238
21239
|
RED.sidebar.kumohub.init();
|
|
21239
21240
|
RED.sidebar.azure.init();
|
|
21240
21241
|
RED.sidebar.awsDeploy.init();
|
|
21241
21242
|
|
|
21242
21243
|
|
|
21244
|
+
|
|
21243
21245
|
// hide info bar at start if screen rather narrow...
|
|
21244
21246
|
// if ($(window).width() < 600) {
|
|
21245
21247
|
// RED.menu.setSelected('menu-item-sidebar', false);
|
|
@@ -24849,9 +24851,6 @@ RED.sidebar.nodeinfo = (function(){
|
|
|
24849
24851
|
// Clear the cache of debug messages
|
|
24850
24852
|
$('#test-debug-messages-caches').empty();
|
|
24851
24853
|
|
|
24852
|
-
// Check if traceability is enabled
|
|
24853
|
-
let traceabilityEnabled = $('#isTraceabilitySelected').is(':checked');
|
|
24854
|
-
|
|
24855
24854
|
// Run the selected case
|
|
24856
24855
|
// - check whether there is only one test case to run or we should run all of them
|
|
24857
24856
|
if (testCaseIdSelected) {
|
|
@@ -24868,7 +24867,7 @@ RED.sidebar.nodeinfo = (function(){
|
|
|
24868
24867
|
createDebugMessageCache(testNodes[i].id);
|
|
24869
24868
|
try{
|
|
24870
24869
|
// console.log(`[tab-test] Running testcase: ${testNodes[i].id} ...`, )
|
|
24871
|
-
await window.__kumologica.libs.testFlow('{}', testNodes[i].id, environment
|
|
24870
|
+
await window.__kumologica.libs.testFlow('{}', testNodes[i].id, environment);
|
|
24872
24871
|
}catch(err){
|
|
24873
24872
|
console.log('[tab-test] error found: ', err);
|
|
24874
24873
|
}
|
|
@@ -24876,7 +24875,7 @@ RED.sidebar.nodeinfo = (function(){
|
|
|
24876
24875
|
} else {
|
|
24877
24876
|
try {
|
|
24878
24877
|
createDebugMessageCache(testCaseIdSelected);
|
|
24879
|
-
await window.__kumologica.libs.testFlow('{}', testCaseIdSelected, environment
|
|
24878
|
+
await window.__kumologica.libs.testFlow('{}', testCaseIdSelected, environment);
|
|
24880
24879
|
} catch(err) {
|
|
24881
24880
|
console.log('[tab-test] error found: ', err);
|
|
24882
24881
|
//App.notify(`Error found: ${JSON.stringify(err)}`, { type: 'error'});
|
|
@@ -26088,6 +26087,312 @@ RED.sidebar.nodeinfo = (function(){
|
|
|
26088
26087
|
init: init,
|
|
26089
26088
|
show: show,
|
|
26090
26089
|
};
|
|
26090
|
+
})();;RED.sidebar.git = (function(){
|
|
26091
|
+
|
|
26092
|
+
let tabContent;
|
|
26093
|
+
let sections;
|
|
26094
|
+
let stackContainer;
|
|
26095
|
+
const PUSHING_LABEL = 'Pushing...';
|
|
26096
|
+
const COMMIT_MESSAGE_LABEL = `Commit message... (ctrl+enter to commit)`;
|
|
26097
|
+
let initalizationRequired = true;
|
|
26098
|
+
|
|
26099
|
+
const simpleGit = window.__kumologica.libs.simpleGit;
|
|
26100
|
+
|
|
26101
|
+
function getGitOptions() {
|
|
26102
|
+
return {
|
|
26103
|
+
baseDir: window.__kumologica.settings.projectDir,
|
|
26104
|
+
binary: 'git',
|
|
26105
|
+
maxConcurrentProcesses: 6,
|
|
26106
|
+
trimmed: false,
|
|
26107
|
+
// config: ['http.proxy=someproxy']
|
|
26108
|
+
}
|
|
26109
|
+
}
|
|
26110
|
+
|
|
26111
|
+
function initHTML() {
|
|
26112
|
+
tabContent = document.createElement('div');
|
|
26113
|
+
tabContent.className = 'sidebar-git';
|
|
26114
|
+
|
|
26115
|
+
RED.actions.add('core:show-git-tab', show);
|
|
26116
|
+
|
|
26117
|
+
stackContainer = $('<div>', {
|
|
26118
|
+
class: 'sidebar-node-info-stack',
|
|
26119
|
+
}).appendTo(tabContent);
|
|
26120
|
+
|
|
26121
|
+
// Append the header
|
|
26122
|
+
let headerContentHtml = `
|
|
26123
|
+
<div class="sidebar-title-wrapper">
|
|
26124
|
+
<div style="display:flex;flex-direction:column;padding-right:10px; width:100%">
|
|
26125
|
+
<div id="sidebar-title-wrapper-left" style="display:flex">
|
|
26126
|
+
<span>Source Control</span>
|
|
26127
|
+
</div>
|
|
26128
|
+
|
|
26129
|
+
<div id="sidebar-git-body">
|
|
26130
|
+
<div id="sidebar-git-error-wrapper" style="display:none">
|
|
26131
|
+
<span><b>The directoryLocal is not under git source control</b>
|
|
26132
|
+
<span>The project {projectDir} is not a git repository</span>
|
|
26133
|
+
</div>
|
|
26134
|
+
<div id="sidebar-git-general-options-wrapper">
|
|
26135
|
+
<div id="sidebar-git-general-pullpush-wrapper">
|
|
26136
|
+
<a id="sidebar-git-push-btn" class="sidebar-header-button" href="#" style="display:flex; margin-right: 5px;">
|
|
26137
|
+
<span id="git-ahead" style="display:none"><i class="icofont-arrow-up"></i><span id="git-ahead-value" style="margin-right:4px"></span></span>
|
|
26138
|
+
<span id="git-behind" style="display:none"><i class="icofont-arrow-down"></i><span id="git-behind-value" style="margin-right:4px"></span></span>
|
|
26139
|
+
<span id="git-push-label">Push</span>
|
|
26140
|
+
</a>
|
|
26141
|
+
<!-- reload btn -->
|
|
26142
|
+
<a id="sidebar-git-reload-btn" class="sidebar-header-button" href="#">
|
|
26143
|
+
<i id="git-reload-icon" class="fa fa-refresh" aria-hidden="true"></i>
|
|
26144
|
+
</a>
|
|
26145
|
+
</div>
|
|
26146
|
+
</div>
|
|
26147
|
+
|
|
26148
|
+
<div id="pending-commit-wrapper">
|
|
26149
|
+
<div id="sidebar-git-commit-msg-wrapper">
|
|
26150
|
+
<textarea id="sidebar-git-commit-msg" rows="4" placeholder="${COMMIT_MESSAGE_LABEL}" style="min-height:130px"></textarea>
|
|
26151
|
+
</div>
|
|
26152
|
+
<div id="sidebar-git-commit-options-wrapper">
|
|
26153
|
+
<div id="sidebar-git-branch-info-wrapper">
|
|
26154
|
+
Commit to
|
|
26155
|
+
<div id="sidebar-git-branch"></div>
|
|
26156
|
+
branch
|
|
26157
|
+
</div>
|
|
26158
|
+
<div id="sidebar-git-commit-wrapper">
|
|
26159
|
+
<!-- commit btn -->
|
|
26160
|
+
<a id="sidebar-git-commit-btn" class="sidebar-header-button" href="#" style="width: 70px; color: white !important; background: #2979ff; margin-right:5px">
|
|
26161
|
+
Commit
|
|
26162
|
+
</a>
|
|
26163
|
+
<!-- commit & push btn -->
|
|
26164
|
+
<a id="sidebar-git-commitpush-btn" class="sidebar-header-button" href="#" style="width: 140px;">
|
|
26165
|
+
Commit and Push...
|
|
26166
|
+
</a>
|
|
26167
|
+
</div>
|
|
26168
|
+
</div>
|
|
26169
|
+
</div>
|
|
26170
|
+
</div>
|
|
26171
|
+
<div id="git-not-initialized" style="display:none">
|
|
26172
|
+
<div style="display:flex; flex-direction: column; align-items: center; margin-top: 150px">
|
|
26173
|
+
<div><i class="fa fa-code-fork" style="font-size: 56px; color: lightgrey;"></i></div>
|
|
26174
|
+
<div style="font-weight: bold; font-size: 22px; margin-top: 15px;color: grey;">Unversioned project</div>
|
|
26175
|
+
<div style="margin-top: 5px; color: grey;font-weight: 400; font-size: 13px;">Git repository not found on project directory</div>
|
|
26176
|
+
</div>
|
|
26177
|
+
</div>
|
|
26178
|
+
</div>
|
|
26179
|
+
</div>
|
|
26180
|
+
`;
|
|
26181
|
+
|
|
26182
|
+
$(headerContentHtml).appendTo(stackContainer);
|
|
26183
|
+
|
|
26184
|
+
RED.sidebar.addTab({
|
|
26185
|
+
id: 'git',
|
|
26186
|
+
label: ' Git',
|
|
26187
|
+
name: 'Source Control',
|
|
26188
|
+
iconClass: 'fa fa-code-fork',
|
|
26189
|
+
action: 'core:show-git-tab',
|
|
26190
|
+
content: tabContent,
|
|
26191
|
+
pinned: true,
|
|
26192
|
+
enableOnEdit: true,
|
|
26193
|
+
onchange: refreshTab,
|
|
26194
|
+
onsame: onsame
|
|
26195
|
+
})
|
|
26196
|
+
}
|
|
26197
|
+
|
|
26198
|
+
function reloading(){
|
|
26199
|
+
$('#git-reload-icon').addClass('fa-spin');
|
|
26200
|
+
}
|
|
26201
|
+
|
|
26202
|
+
function resetReload(){
|
|
26203
|
+
$('#git-reload-icon').removeClass('fa-spin');
|
|
26204
|
+
}
|
|
26205
|
+
|
|
26206
|
+
function initJS() {
|
|
26207
|
+
$('#sidebar-git-commit-msg').keydown(e => {
|
|
26208
|
+
if ((e.ctrlKey || e.metaKey) && (e.keyCode == 13 || e.keyCode == 10)) {
|
|
26209
|
+
$('#sidebar-git-commit-btn').click();
|
|
26210
|
+
}
|
|
26211
|
+
})
|
|
26212
|
+
$('#sidebar-git-commit-btn').click(async e => {
|
|
26213
|
+
let commitMessage = $('#sidebar-git-commit-msg').val();
|
|
26214
|
+
addAllAndCommit(commitMessage);
|
|
26215
|
+
await wait(2000);
|
|
26216
|
+
checkGitStatus();
|
|
26217
|
+
});
|
|
26218
|
+
|
|
26219
|
+
$('#sidebar-git-commitpush-btn').click(async e => {
|
|
26220
|
+
let commitMessage = $('#sidebar-git-commit-msg').val();
|
|
26221
|
+
addAllAndCommit(commitMessage);
|
|
26222
|
+
await wait(3000);
|
|
26223
|
+
pushChanges();
|
|
26224
|
+
});
|
|
26225
|
+
|
|
26226
|
+
$('#sidebar-git-reload-btn').click(async e => {
|
|
26227
|
+
reloading();
|
|
26228
|
+
checkGitStatus();
|
|
26229
|
+
await wait(1000);
|
|
26230
|
+
resetReload();
|
|
26231
|
+
});
|
|
26232
|
+
|
|
26233
|
+
$('#sidebar-git-push-btn').click(e => {
|
|
26234
|
+
if ($('#sidebar-git-push-btn').html() !== PUSHING_LABEL){
|
|
26235
|
+
pushChanges();
|
|
26236
|
+
}
|
|
26237
|
+
});
|
|
26238
|
+
}
|
|
26239
|
+
|
|
26240
|
+
function renderInitializationRequired() {
|
|
26241
|
+
$('#sidebar-git-body').hide();
|
|
26242
|
+
$('#git-not-initialized').show();
|
|
26243
|
+
initalizationRequired = true;
|
|
26244
|
+
}
|
|
26245
|
+
|
|
26246
|
+
function renderGitInitialized() {
|
|
26247
|
+
$('#sidebar-git-body').show();
|
|
26248
|
+
$('#git-not-initialized').hide();
|
|
26249
|
+
initalizationRequired = false;
|
|
26250
|
+
}
|
|
26251
|
+
|
|
26252
|
+
async function checkGitStatus(){
|
|
26253
|
+
if (initalizationRequired) {
|
|
26254
|
+
$('#sidebar-git-body').hide();
|
|
26255
|
+
$('#git-not-initialized').hide();
|
|
26256
|
+
}
|
|
26257
|
+
const git = simpleGit(getGitOptions());
|
|
26258
|
+
try{
|
|
26259
|
+
// ==> Compare with stage
|
|
26260
|
+
const status = await git.status()
|
|
26261
|
+
if ( status.not_added.length > 0 ||
|
|
26262
|
+
status.created.length > 0 ||
|
|
26263
|
+
status.deleted.length > 0 ||
|
|
26264
|
+
status.modified.length > 0 ||
|
|
26265
|
+
status.renamed.length > 0 ) {
|
|
26266
|
+
allowCommits();
|
|
26267
|
+
} else {
|
|
26268
|
+
disallowCommits()
|
|
26269
|
+
}
|
|
26270
|
+
let newStatus = await git.status(['-','sb']); // newStatus = {ahead, behind, current, tracking};
|
|
26271
|
+
renderGitInitialized();
|
|
26272
|
+
$('#sidebar-git-branch').html(newStatus.current);
|
|
26273
|
+
renderAhead(newStatus.ahead);
|
|
26274
|
+
renderBehind(newStatus.behind);
|
|
26275
|
+
}catch(err){
|
|
26276
|
+
renderInitializationRequired();
|
|
26277
|
+
}
|
|
26278
|
+
}
|
|
26279
|
+
|
|
26280
|
+
async function wait(msecs){
|
|
26281
|
+
await sleep(msecs);
|
|
26282
|
+
}
|
|
26283
|
+
|
|
26284
|
+
function sleep(ms) {
|
|
26285
|
+
return new Promise((resolve) => {
|
|
26286
|
+
setTimeout(resolve, ms);
|
|
26287
|
+
});
|
|
26288
|
+
}
|
|
26289
|
+
|
|
26290
|
+
function renderAhead(numCommits){
|
|
26291
|
+
if (numCommits === 0){
|
|
26292
|
+
$('#git-ahead').hide();
|
|
26293
|
+
} else {
|
|
26294
|
+
$('#git-ahead-value').html(numCommits);
|
|
26295
|
+
$('#git-ahead').show();
|
|
26296
|
+
}
|
|
26297
|
+
}
|
|
26298
|
+
|
|
26299
|
+
function renderBehind(numCommits){
|
|
26300
|
+
if (numCommits === 0){
|
|
26301
|
+
$('#git-behind').hide();
|
|
26302
|
+
} else {
|
|
26303
|
+
$('#git-behind-value').html(numCommits);
|
|
26304
|
+
$('#git-behind').show();
|
|
26305
|
+
}
|
|
26306
|
+
}
|
|
26307
|
+
|
|
26308
|
+
function showPushing() {
|
|
26309
|
+
$('#git-ahead').hide();
|
|
26310
|
+
$('#git-behind').hide();
|
|
26311
|
+
$('#git-push-label').html(PUSHING_LABEL);
|
|
26312
|
+
}
|
|
26313
|
+
|
|
26314
|
+
function resetPushButton() {
|
|
26315
|
+
$('#git-push-label').html('Push');
|
|
26316
|
+
}
|
|
26317
|
+
|
|
26318
|
+
async function pushChanges() {
|
|
26319
|
+
const git = simpleGit(getGitOptions());
|
|
26320
|
+
try{
|
|
26321
|
+
let currentBranch = await readCurrentBranch();
|
|
26322
|
+
showPushing();
|
|
26323
|
+
const result = await git.push('origin', currentBranch);
|
|
26324
|
+
RED.notify(`Changes pushed successfully`, 'success', undefined, 800);
|
|
26325
|
+
} catch(e) {
|
|
26326
|
+
RED.notify(`<strong>Error</strong>: ${e.message}`, 'error');
|
|
26327
|
+
} finally {
|
|
26328
|
+
resetPushButton();
|
|
26329
|
+
checkGitStatus();
|
|
26330
|
+
}
|
|
26331
|
+
}
|
|
26332
|
+
|
|
26333
|
+
async function addAllAndCommit(message){
|
|
26334
|
+
const git = simpleGit(getGitOptions());
|
|
26335
|
+
try{
|
|
26336
|
+
await git.add('./*').commit(message);
|
|
26337
|
+
disallowCommits();
|
|
26338
|
+
RED.notify(`Changed committed successfully`, 'success', undefined, 800);
|
|
26339
|
+
} catch(e) {
|
|
26340
|
+
RED.notify(`<strong>Error</strong>: ${e.message}`, 'error');
|
|
26341
|
+
clearCommitMessage();
|
|
26342
|
+
}
|
|
26343
|
+
}
|
|
26344
|
+
|
|
26345
|
+
async function readCurrentBranch(){
|
|
26346
|
+
const git = simpleGit(getGitOptions());
|
|
26347
|
+
try{
|
|
26348
|
+
const localBranches = await git.branchLocal();
|
|
26349
|
+
return localBranches.current;
|
|
26350
|
+
}catch(e){
|
|
26351
|
+
RED.notify(`<strong>Error</strong>: ${e.message}`, 'error');
|
|
26352
|
+
return ''
|
|
26353
|
+
}
|
|
26354
|
+
|
|
26355
|
+
}
|
|
26356
|
+
function allowCommits() {
|
|
26357
|
+
$("#sidebar-git-commit-msg").attr("placeholder", `${COMMIT_MESSAGE_LABEL}`).val("");
|
|
26358
|
+
$("#sidebar-git-commit-msg").attr("disabled", false);
|
|
26359
|
+
$('#sidebar-git-commit-wrapper').show();
|
|
26360
|
+
}
|
|
26361
|
+
function disallowCommits() {
|
|
26362
|
+
$("#sidebar-git-commit-msg").attr("placeholder", "Nothing to commit").val("").focus().blur();
|
|
26363
|
+
$("#sidebar-git-commit-msg").attr("disabled", true)
|
|
26364
|
+
$('#sidebar-git-commit-wrapper').hide();
|
|
26365
|
+
}
|
|
26366
|
+
|
|
26367
|
+
function clearCommitMessage() {
|
|
26368
|
+
$('#sidebar-git-commit-msg').val('');
|
|
26369
|
+
}
|
|
26370
|
+
|
|
26371
|
+
function init() {
|
|
26372
|
+
initHTML();
|
|
26373
|
+
initJS();
|
|
26374
|
+
}
|
|
26375
|
+
|
|
26376
|
+
function show() {
|
|
26377
|
+
RED.sidebar.show('git');
|
|
26378
|
+
checkGitStatus();
|
|
26379
|
+
}
|
|
26380
|
+
|
|
26381
|
+
function refreshTab(silently){
|
|
26382
|
+
if (!silently) {
|
|
26383
|
+
RED.actions.invoke('core:show-sidebar');
|
|
26384
|
+
}
|
|
26385
|
+
checkGitStatus();
|
|
26386
|
+
}
|
|
26387
|
+
|
|
26388
|
+
function onsame(){
|
|
26389
|
+
RED.actions.invoke('core:hide-sidebar');
|
|
26390
|
+
}
|
|
26391
|
+
|
|
26392
|
+
return {
|
|
26393
|
+
init: init,
|
|
26394
|
+
show: show,
|
|
26395
|
+
}
|
|
26091
26396
|
})();;
|
|
26092
26397
|
RED.sidebar.azure = (function () {
|
|
26093
26398
|
marked.setOptions({
|