mirror of
https://github.com/S2-/gitlit
synced 2025-08-02 20:30:05 +02:00
!
This commit is contained in:
78
.jscsrc
Normal file
78
.jscsrc
Normal file
@@ -0,0 +1,78 @@
|
||||
{
|
||||
"requireCurlyBraces": [
|
||||
"if",
|
||||
"else",
|
||||
"for",
|
||||
"while",
|
||||
"do",
|
||||
"try",
|
||||
"catch"
|
||||
],
|
||||
"requireSpaceAfterKeywords": [
|
||||
"if",
|
||||
"else",
|
||||
"for",
|
||||
"while",
|
||||
"do",
|
||||
"switch",
|
||||
"case",
|
||||
"return",
|
||||
"try"
|
||||
],
|
||||
"requireSpaceBeforeKeywords": [
|
||||
"else",
|
||||
"catch"
|
||||
],
|
||||
"disallowSpaceAfterKeywords": [
|
||||
"catch"
|
||||
],
|
||||
"requireSpaceBeforeBlockStatements": true,
|
||||
"requireParenthesesAroundIIFE": true,
|
||||
"requireSpacesInConditionalExpression": true,
|
||||
"disallowSpacesInNamedFunctionExpression": {
|
||||
"beforeOpeningRoundBrace": true
|
||||
},
|
||||
"disallowSpacesInFunctionDeclaration": {
|
||||
"beforeOpeningRoundBrace": true
|
||||
},
|
||||
"disallowSpacesInFunctionExpression": {
|
||||
"beforeOpeningRoundBrace": true
|
||||
},
|
||||
"requireSpaceBetweenArguments": true,
|
||||
"disallowMultipleVarDecl": true,
|
||||
"requireVarDeclFirst": false,
|
||||
"requireBlocksOnNewline": false,
|
||||
"disallowEmptyBlocks": true,
|
||||
"disallowSpacesInsideArrayBrackets": true,
|
||||
"disallowSpacesInsideObjectBrackets": true,
|
||||
"disallowSpacesInsideParentheses": true,
|
||||
"disallowDanglingUnderscores": false,
|
||||
"requireCommaBeforeLineBreak": true,
|
||||
"disallowSpaceAfterPrefixUnaryOperators": true,
|
||||
"disallowSpaceBeforePostfixUnaryOperators": true,
|
||||
"disallowSpaceBeforeBinaryOperators": [
|
||||
","
|
||||
],
|
||||
"requireSpacesInForStatement": true,
|
||||
"requireSpacesInAnonymousFunctionExpression": {
|
||||
"beforeOpeningCurlyBrace": true
|
||||
},
|
||||
"requireSpaceBeforeBinaryOperators": true,
|
||||
"requireSpaceAfterBinaryOperators": true,
|
||||
"disallowKeywords": [
|
||||
"with"
|
||||
],
|
||||
"validateIndentation": "\t",
|
||||
"disallowMixedSpacesAndTabs": true,
|
||||
"disallowTrailingWhitespace": true,
|
||||
"disallowTrailingComma": true,
|
||||
"disallowKeywordsOnNewLine": [
|
||||
"else"
|
||||
],
|
||||
"requireLineFeedAtFileEnd": true,
|
||||
"requireCapitalizedConstructors": true,
|
||||
"requireDotNotation": false,
|
||||
"disallowNewlineBeforeBlockStatements": true,
|
||||
"disallowMultipleLineStrings": true,
|
||||
"requireSpaceBeforeObjectValues": true
|
||||
}
|
@@ -14,9 +14,8 @@
|
||||
<link href="node_modules/bootstrap/dist/css/bootstrap.css" rel="stylesheet">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<script>
|
||||
$('body').html(gitlit.templates.main());
|
||||
</script>
|
||||
<div class="alert alert-primary" role="alert">
|
||||
Getting file list...
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
@@ -1,5 +1,6 @@
|
||||
(function($) {
|
||||
require('electron').ipcRenderer.on('ping', (event, message) => {
|
||||
console.log(message) // Prints 'whoooooooh!'
|
||||
})
|
||||
let ipcRenderer = require('electron').ipcRenderer;
|
||||
ipcRenderer.on('fileList', (event, files) => {
|
||||
$('body').html(gitlit.templates.main({files: files}));
|
||||
});
|
||||
})(jQuery);
|
||||
|
@@ -1,17 +1,26 @@
|
||||
window.gitlit = window.gitlit || {};
|
||||
gitlit.templates = {
|
||||
main: ejs.compile(`
|
||||
<table class="table table-striped">
|
||||
<table class="table">
|
||||
<tr>
|
||||
<th>file</th>
|
||||
<th>status</th>
|
||||
<th>action</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>ciccio.txt</td>
|
||||
<td>locked</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
|
||||
<% files.forEach((file) => { %>
|
||||
<tr class="<%= file.lockedBy ? 'alert alert-danger' : '' %>">
|
||||
<td><%= file.file %></td>
|
||||
<td><%= file.lockedBy ? file.lockedBy + ' (id: ' + file.id + ')' : 'not locked' %></td>
|
||||
<td>
|
||||
<a class="btn btn-<%= file.lockedBy ? 'danger' : 'primary' %>"
|
||||
href="javascript:///">
|
||||
<%= file.lockedBy ? 'Unlock' : 'Lock' %>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
<% }); %>
|
||||
|
||||
</table>
|
||||
`)
|
||||
};
|
||||
|
92
app/main.js
92
app/main.js
@@ -2,9 +2,79 @@ const {app, BrowserWindow} = require('electron');
|
||||
const path = require('path');
|
||||
const url = require('url');
|
||||
const electronLocalshortcut = require('electron-localshortcut');
|
||||
const exec = require('child_process').exec;
|
||||
const args = require('minimist')(process.argv.slice(2), {
|
||||
default: {
|
||||
_: process.cwd()
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
function createWindow () {
|
||||
function getLfsFileList(dir, cb) {
|
||||
exec('git lfs ls-files', {
|
||||
cwd: dir
|
||||
},
|
||||
(error, stdout, stderr) => {
|
||||
if (error) {
|
||||
cb(error);
|
||||
return;
|
||||
}
|
||||
if (stdout) {
|
||||
let files = stdout.split('\n');
|
||||
let parsedFiles = [];
|
||||
files.forEach((file) => {
|
||||
file = file.split(' * ');
|
||||
if (file[1]) {
|
||||
parsedFiles.push(file[1].trim());
|
||||
}
|
||||
});
|
||||
|
||||
cb(null, parsedFiles);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
function getLfsLocks(dir, cb) {
|
||||
exec('git lfs locks', {
|
||||
cwd: dir
|
||||
},
|
||||
(error, stdout, stderr) => {
|
||||
if (error) {
|
||||
cb(error);
|
||||
return;
|
||||
}
|
||||
if (stdout) {
|
||||
let files = stdout.split('\n');
|
||||
let parsedFiles = [];
|
||||
files.forEach((file) => {
|
||||
if (file) {
|
||||
let fileName = file.split('\t')[0].trim();
|
||||
let lockedBy = file.split('\t')[1].trim();
|
||||
let id = file.split('ID:')[1].trim();
|
||||
parsedFiles.push({
|
||||
file: fileName,
|
||||
lockedBy: lockedBy,
|
||||
id: id
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
cb(null, parsedFiles);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
function getArrayObjectByKey(array, key, value, defaultKeyValue) {
|
||||
let o = array.filter((e) => {
|
||||
return e[key] === value;
|
||||
});
|
||||
if (o.length > 0) {
|
||||
return defaultKeyValue ? o[0][defaultKeyValue] : o[0];
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function createWindow() {
|
||||
// Create the browser window.
|
||||
win = new BrowserWindow({width: 800, height: 600});
|
||||
win.setMenu(null);
|
||||
@@ -21,7 +91,25 @@ function createWindow () {
|
||||
});
|
||||
|
||||
win.webContents.on('did-finish-load', () => {
|
||||
win.webContents.send('ping', 'whoooooooh!')
|
||||
console.log('getting file list and lock status...');
|
||||
|
||||
getLfsFileList(args._.join(' '), (err, files) => {
|
||||
getLfsLocks(args._.join(' '), (err, lockedFiles) => {
|
||||
let allFiles = [];
|
||||
|
||||
files.forEach((file) => {
|
||||
const t = {
|
||||
file: file,
|
||||
lockedBy: getArrayObjectByKey(lockedFiles, 'file', file, 'lockedBy'),
|
||||
id: getArrayObjectByKey(lockedFiles, 'file', file, 'id')
|
||||
};
|
||||
|
||||
allFiles.push(t);
|
||||
});
|
||||
|
||||
win.webContents.send('fileList', allFiles);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
16
app/node_modules/minimist/package.json
generated
vendored
16
app/node_modules/minimist/package.json
generated
vendored
@@ -1,21 +1,23 @@
|
||||
{
|
||||
"_from": "minimist@^1.2.0",
|
||||
"_from": "minimist",
|
||||
"_id": "minimist@1.2.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=",
|
||||
"_location": "/minimist",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"type": "tag",
|
||||
"registry": true,
|
||||
"raw": "minimist@^1.2.0",
|
||||
"raw": "minimist",
|
||||
"name": "minimist",
|
||||
"escapedName": "minimist",
|
||||
"rawSpec": "^1.2.0",
|
||||
"rawSpec": "",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^1.2.0"
|
||||
"fetchSpec": "latest"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"#USER",
|
||||
"/",
|
||||
"/electron-download",
|
||||
"/meow",
|
||||
"/nugget",
|
||||
@@ -23,8 +25,8 @@
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz",
|
||||
"_shasum": "a35008b20f41383eec1fb914f4cd5df79a264284",
|
||||
"_spec": "minimist@^1.2.0",
|
||||
"_where": "E:\\projects\\p\\gitlit\\app\\node_modules\\electron-download",
|
||||
"_spec": "minimist",
|
||||
"_where": "E:\\projects\\p\\gitlit\\app",
|
||||
"author": {
|
||||
"name": "James Halliday",
|
||||
"email": "mail@substack.net",
|
||||
|
3
app/package-lock.json
generated
3
app/package-lock.json
generated
@@ -761,8 +761,7 @@
|
||||
"minimist": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz",
|
||||
"integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=",
|
||||
"dev": true
|
||||
"integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ="
|
||||
},
|
||||
"mkdirp": {
|
||||
"version": "0.5.0",
|
||||
|
@@ -7,7 +7,8 @@
|
||||
"bootstrap": "^4.1.1",
|
||||
"ejs": "^2.6.1",
|
||||
"electron-localshortcut": "^3.1.0",
|
||||
"jquery": "^3.3.1"
|
||||
"jquery": "^3.3.1",
|
||||
"minimist": "^1.2.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"electron": "^2.0.1"
|
||||
|
Reference in New Issue
Block a user