-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
first commit based on express and nexe, app compilation
- Loading branch information
Tomasz Sapletta
committed
Feb 6, 2020
1 parent
b6ceb37
commit 8f7e1c1
Showing
30 changed files
with
1,507 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,7 @@ | ||
# one | ||
scripts for one project in one folder | ||
|
||
|
||
## compiling code | ||
|
||
npm i nexe -g |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
const createError = require('http-errors'); | ||
const express = require('express'); | ||
const path = require('path'); | ||
const cookieParser = require('cookie-parser'); | ||
const logger = require('morgan'); | ||
const auth = require('./src/auth'); | ||
|
||
//var FileList = []; | ||
const indexRouter = require('./routes/index'); | ||
const batRouter = require('./routes/bat'); | ||
// var batqRouter = require('./routes/batq'); | ||
const projectRouter = require('./routes/project'); | ||
|
||
const app = express(); | ||
|
||
// TODO: load athentication data for API, | ||
app.use(auth); | ||
|
||
// TODO: people accounts skype, email, etc | ||
// TODO: Load environment.js and load Path, and specific | ||
// TODO: load project.js file and load to the projectLIst | ||
|
||
// view engine setup | ||
app.set('views', path.join(__dirname, 'views')); | ||
app.set('view engine', 'pug'); | ||
|
||
app.use(logger('dev')); | ||
app.use(express.json()); | ||
app.use(express.urlencoded({ extended: false })); | ||
app.use(cookieParser()); | ||
app.use(express.static(path.join(__dirname, 'public'))); | ||
|
||
app.use('/', indexRouter); | ||
app.use('/bat', batRouter); | ||
// app.use('/batq', batqRouter); | ||
app.use('/project/', projectRouter); | ||
|
||
|
||
|
||
|
||
// catch 404 and forward to error handler | ||
app.use(function(req, res, next) { | ||
next(createError(404)); | ||
}); | ||
|
||
// error handler | ||
app.use(function(err, req, res, next) { | ||
// set locals, only providing error in development | ||
res.locals.message = err.message; | ||
res.locals.error = req.app.get('env') === 'development' ? err : {}; | ||
|
||
// render the error page | ||
res.status(err.status || 500); | ||
res.render('error'); | ||
}); | ||
|
||
module.exports = app; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
#!/usr/bin/env node | ||
|
||
/** | ||
* Module dependencies. | ||
*/ | ||
|
||
var app = require('../app'); | ||
var debug = require('debug')('devops_gui:server'); | ||
var http = require('http'); | ||
|
||
/** | ||
* Get port from environment and store in Express. | ||
*/ | ||
|
||
var port = normalizePort(process.env.PORT || '3001'); | ||
app.set('port', port); | ||
|
||
/** | ||
* Create HTTP server. | ||
*/ | ||
|
||
var server = http.createServer(app); | ||
|
||
/** | ||
* Listen on provided port, on all network interfaces. | ||
*/ | ||
|
||
server.listen(port); | ||
server.on('error', onError); | ||
server.on('listening', onListening); | ||
|
||
/** | ||
* Normalize a port into a number, string, or false. | ||
*/ | ||
|
||
function normalizePort(val) { | ||
var port = parseInt(val, 10); | ||
|
||
if (isNaN(port)) { | ||
// named pipe | ||
return val; | ||
} | ||
|
||
if (port >= 0) { | ||
// port number | ||
return port; | ||
} | ||
|
||
return false; | ||
} | ||
|
||
/** | ||
* Event listener for HTTP server "error" event. | ||
*/ | ||
|
||
function onError(error) { | ||
if (error.syscall !== 'listen') { | ||
throw error; | ||
} | ||
|
||
var bind = typeof port === 'string' | ||
? 'Pipe ' + port | ||
: 'Port ' + port; | ||
|
||
// handle specific listen errors with friendly messages | ||
switch (error.code) { | ||
case 'EACCES': | ||
console.error(bind + ' requires elevated privileges'); | ||
process.exit(1); | ||
break; | ||
case 'EADDRINUSE': | ||
console.error(bind + ' is already in use'); | ||
process.exit(1); | ||
break; | ||
default: | ||
throw error; | ||
} | ||
} | ||
|
||
/** | ||
* Event listener for HTTP server "listening" event. | ||
*/ | ||
|
||
function onListening() { | ||
var addr = server.address(); | ||
var bind = typeof addr === 'string' | ||
? 'pipe ' + addr | ||
: 'port ' + addr.port; | ||
debug('Listening on ' + bind); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
const osHomedir = require('os-homedir'); | ||
const os = require('os'); | ||
const os_name = os.type(); | ||
|
||
var project_path = '~/devops-gui-projects'; | ||
// console.log(osHomedir()); | ||
project_path = project_path.replace(/^~/, osHomedir()); | ||
// console.log(project_path); | ||
|
||
if(os_name === 'Linux'){ | ||
project_path = '/home/tomaszsapletta/devops-gui-projects'; | ||
} | ||
|
||
|
||
// Create menu from devops - apicra projects | ||
let devops_path = '~\\devops\\windows\\10'; | ||
devops_path = devops_path.replace(/^~/, osHomedir()); | ||
// LINUX | ||
devops_path = devops_path.replace(/^\\/, '/'); | ||
|
||
console.log(devops_path); | ||
projectListPublic = {}; | ||
/* | ||
fs.readdirSync(devops_path).forEach(file => { | ||
console.log(file); | ||
projectListPublic.push({ | ||
'url': 'project/public/' + projectListPublic.length, | ||
'title': file, | ||
'path': devops_path + '\\' + file, | ||
'domain': 'localhost', | ||
'files': [] | ||
}); | ||
}); | ||
*/ | ||
console.log(projectListPublic); | ||
|
||
module.exports = function () { | ||
return { | ||
|
||
username: 'tomaszsapletta', | ||
// base path that will be used to resolve all patterns (eg. files, exclude) | ||
project_path: project_path, | ||
|
||
projectListPublic: projectListPublic, | ||
|
||
|
||
// web server port | ||
port: 3001, | ||
|
||
|
||
// Continuous Integration mode | ||
// if true, Karma captures browsers, runs the tests and exits | ||
singleRun: false, | ||
|
||
// SYSTEM OS | ||
os: os_name, | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"name": "promagen one", | ||
"version": "1.0.1", | ||
"private": true, | ||
"scripts": { | ||
// "start": "node ./bin/www", | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"main": "app.js", | ||
"dependencies": { | ||
"basic-auth": "^2.0.1", | ||
"cookie-parser": "~1.4.3", | ||
"debug": "~2.6.9", | ||
"express": "~4.16.0", | ||
"fs-path": "0.0.24", | ||
"http-errors": "~1.6.2", | ||
"ini": "^1.3.5", | ||
"morgan": "~1.9.0", | ||
"opn": "^5.3.0", | ||
"os-homedir": "^1.0.2", | ||
"pug": "2.0.0-beta11", | ||
"shelljs": "^0.8.2" | ||
} | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
function ie8SafePreventEvent(e) { | ||
e.preventDefault() || (e.returnValue = false) || e.stopPropagation(); | ||
} | ||
|
||
$(document).ready(function () { | ||
//your code here | ||
// $('.projects').load('projects'); | ||
|
||
$('.projects a').click(function (e) { | ||
ie8SafePreventEvent(e); | ||
var url = $(this).attr('href'); | ||
var path = $(this).text(); | ||
//var name = path.replace(/^.*[\\\/]/, ''); | ||
|
||
// console.log(name); | ||
// $('.scripts').load(url); | ||
// $('.scripts').each(function(){ | ||
// $(this).append(); | ||
// }); | ||
|
||
$.getJSON(url, function (data) { | ||
|
||
var domain = ''; | ||
//var items = []; | ||
var item = ""; | ||
var group = {all: []}; | ||
var group_name = ""; | ||
var group_path = ""; | ||
var first = true; | ||
var namen = ""; | ||
var namen_arr = ""; | ||
var namen_str = ""; | ||
|
||
$(".scripts").html(""); | ||
|
||
// $.each(data, function (key, val) { | ||
// var group_name = val.name.split('_', 2); | ||
// items.push(); | ||
// }); | ||
|
||
$.each(data, function (key, val) { | ||
|
||
group_path = val.path_dir; | ||
|
||
if (val.name.split("_", 2)[1] === undefined) { | ||
namen = val.name; | ||
} else { | ||
namen_arr = val.name.split("_", 9).slice(1); | ||
console.log(namen_arr); | ||
namen = namen_arr.join("_"); | ||
} | ||
namen_str = namen.split(".", 9).slice(1); | ||
console.log(namen); | ||
console.log(namen_str); | ||
|
||
item = "<li id='menu_" + key + "'>" | ||
// + val.path_dir | ||
+ "<a href='" + val.url + "'>" + namen_str + "</a>" | ||
+ "</li>"; | ||
|
||
console.log(item); | ||
|
||
// ALL | ||
if (val.name.split("_", 2)[1] === undefined) { | ||
|
||
group_name = 'all'; | ||
console.log(group_name); | ||
group.all.push(item); | ||
} else { | ||
group_name = val.name.split("_", 2)[0]; | ||
|
||
console.log(group_name); | ||
|
||
// Create group | ||
if (group[group_name] === undefined) { | ||
group[group_name] = []; | ||
} | ||
|
||
group[group_name].push(item); | ||
} | ||
|
||
// items.push(); | ||
domain = val.domain; | ||
}); | ||
|
||
// join items | ||
$.each(group, function (key, val) { | ||
|
||
if (first) { | ||
$(".scripts").append("<h2>" + group_path + "</h2>"); | ||
} | ||
first = false; | ||
|
||
var object = $("<ul/>", { | ||
"class": "commands", | ||
html: "<h3>" + key + "</h3>" + group[key].join("") | ||
}).appendTo('.scripts').find('a').click(function (e) { | ||
ie8SafePreventEvent(e); | ||
var url = $(this).attr('href'); | ||
var path = $(this).text(); | ||
var name = path.replace(/^.*[\\\/]/, ''); | ||
|
||
$('.message').load(url); | ||
|
||
if (name === 'build.bat' || name === 'build.sh') { | ||
setTimeout(function () { | ||
console.log(domain); | ||
|
||
var win = window.open('http://' + domain + '/', '_blank'); | ||
if (win) { | ||
//Browser has allowed it to be opened | ||
win.focus(); | ||
} else { | ||
//Browser has blocked it | ||
alert('Please allow popups for this website'); | ||
} | ||
}, 4000); | ||
} | ||
}); | ||
|
||
}); | ||
|
||
|
||
}); | ||
}); | ||
|
||
// $('.scripts a') | ||
|
||
}); |
Oops, something went wrong.