mirror of https://github.com/Requarks/wiki.git
NGPixel
7 years ago
21 changed files with 59663 additions and 217 deletions
Split View
Diff Options
-
15.deployexclude
-
7.eslintignore
-
146.eslintrc.json
-
4.gitignore
-
12.travis.yml
-
59306assets/js/bundle.min.js
-
20client/index.js
-
8client/js/app.js
-
7client/js/components/alerts.js
-
6client/js/configure.js
-
2client/js/login.js
-
2client/scss/app.scss
-
127fuse.js
-
6gulpfile.js
-
62package.json
-
3test/index.js
-
77test/lint.js
-
39test/security.js
-
11views/auth/login.pug
-
11views/configure/index.pug
-
9views/layout.pug
@ -0,0 +1,15 @@ |
|||
client/js |
|||
client/scss |
|||
coverage |
|||
data |
|||
logs |
|||
node_modules |
|||
npm |
|||
repo |
|||
test |
|||
.* |
|||
*.log |
|||
*.tar.gz |
|||
*.zip |
|||
config.yml |
|||
fuse.js |
@ -0,0 +1,7 @@ |
|||
**/node_modules/** |
|||
**/*.min.js |
|||
assets/** |
|||
coverage/** |
|||
repo/** |
|||
data/** |
|||
logs/** |
59306
assets/js/bundle.min.js
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
@ -0,0 +1,20 @@ |
|||
'use strict' |
|||
|
|||
let logic = document.documentElement.dataset.logic |
|||
|
|||
switch (logic) { |
|||
case 'login': |
|||
require('./scss/login.scss') |
|||
require('./js/login.js') |
|||
break |
|||
case 'configure': |
|||
require('./scss/configure.scss') |
|||
require('./js/configure.js') |
|||
break |
|||
default: |
|||
require('./node_modules/highlight.js/styles/tomorrow.css') |
|||
require('./node_modules/simplemde/dist/simplemde.min.css') |
|||
require('./scss/app.scss') |
|||
require('./js/app.js') |
|||
break |
|||
} |
@ -1,6 +1,6 @@ |
|||
'use strict' |
|||
|
|||
/* global jQuery */ |
|||
import jQuery from 'jquery' |
|||
|
|||
jQuery(document).ready(function ($) { |
|||
$('#login-user').focus() |
|||
|
@ -0,0 +1,127 @@ |
|||
'use strict' |
|||
|
|||
/** |
|||
* FUSEBOX |
|||
* |
|||
* Client & Server compiler / watcher |
|||
*/ |
|||
|
|||
const fsbx = require('fuse-box') |
|||
const colors = require('colors/safe') |
|||
const _ = require('lodash') |
|||
|
|||
// Parse cmd arguments
|
|||
|
|||
const args = require('yargs') |
|||
.option('d', { |
|||
alias: 'dev', |
|||
describe: 'Start in Developer mode', |
|||
type: 'boolean' |
|||
}) |
|||
.option('c', { |
|||
alias: 'configure', |
|||
describe: 'Use Configure mode', |
|||
type: 'boolean', |
|||
implies: 'd' |
|||
}) |
|||
.help('h') |
|||
.alias('h', 'help') |
|||
.argv |
|||
|
|||
if (args.d) { |
|||
// =============================================
|
|||
// DEVELOPER MODE
|
|||
// =============================================
|
|||
|
|||
console.info(colors.bgWhite.black(' Starting Fuse in DEVELOPER mode... ')) |
|||
|
|||
const nodemon = require('nodemon') |
|||
|
|||
// Client
|
|||
|
|||
const fuse = fsbx.FuseBox.init({ |
|||
homeDir: './client', |
|||
outFile: './assets/js/bundle.min.js', |
|||
alias: { |
|||
vue: 'vue/dist/vue.js' |
|||
}, |
|||
plugins: [ |
|||
[ fsbx.SassPlugin({ includePaths: ['../core'] }), fsbx.CSSPlugin() ], |
|||
fsbx.BabelPlugin({ comments: false, presets: ['es2015'] }), |
|||
fsbx.JSONPlugin() |
|||
], |
|||
debug: false, |
|||
log: true |
|||
}) |
|||
|
|||
fuse.devServer('>index.js', { |
|||
port: 4444, |
|||
httpServer: false |
|||
}) |
|||
|
|||
// Server
|
|||
|
|||
_.delay(() => { |
|||
if (args.c) { |
|||
nodemon({ |
|||
exec: 'node wiki configure', |
|||
ignore: ['assets/', 'client/', 'data/', 'repo/', 'tests/'], |
|||
ext: 'js json', |
|||
watch: [ |
|||
'configure.js' |
|||
], |
|||
env: { 'NODE_ENV': 'development' } |
|||
}) |
|||
} else { |
|||
nodemon({ |
|||
script: './server.js', |
|||
args: [], |
|||
ignore: ['assets/', 'client/', 'data/', 'repo/', 'tests/'], |
|||
ext: 'js json', |
|||
watch: [ |
|||
'controllers', |
|||
'libs', |
|||
'locales', |
|||
'middlewares', |
|||
'models', |
|||
'agent.js', |
|||
'server.js' |
|||
], |
|||
env: { 'NODE_ENV': 'development' } |
|||
}) |
|||
} |
|||
}, 1000) |
|||
} else { |
|||
// =============================================
|
|||
// BUILD MODE
|
|||
// =============================================
|
|||
|
|||
console.info(colors.bgWhite.black(' Starting Fuse in BUILD mode... ')) |
|||
|
|||
const fuse = fsbx.FuseBox.init({ |
|||
homeDir: './client', |
|||
outFile: './assets/js/bundle.min.js', |
|||
plugins: [ |
|||
[ fsbx.SassPlugin({ outputStyle: 'compressed', includePaths: ['./node_modules/requarks-core'] }), fsbx.CSSPlugin() ], |
|||
fsbx.BabelPlugin({ |
|||
config: { |
|||
comments: false, |
|||
presets: ['es2015'] |
|||
} |
|||
}), |
|||
fsbx.JSONPlugin(), |
|||
fsbx.UglifyJSPlugin({ |
|||
compress: { unused: false } |
|||
}) |
|||
], |
|||
debug: false, |
|||
log: true |
|||
}) |
|||
|
|||
fuse.bundle('>index.js').then(() => { |
|||
console.info(colors.green.bold('Assets compilation + bundling completed.')) |
|||
}).catch(err => { |
|||
console.error(colors.green.red(' X Bundle compilation failed! ' + err.message)) |
|||
process.exit(1) |
|||
}) |
|||
} |
@ -1,3 +0,0 @@ |
|||
'use strict' |
|||
|
|||
// TODO
|
@ -0,0 +1,77 @@ |
|||
'use strict' |
|||
|
|||
const fs = require('fs-extra') |
|||
const colors = require('colors') |
|||
|
|||
expect.extend({ |
|||
/** |
|||
* Expect ESLint results to have no errors |
|||
* @param {*} received ESLint results |
|||
* @param {*} argument Arguments |
|||
* @returns {object} Matcher result |
|||
*/ |
|||
toESLint (received, argument) { |
|||
if (received && received.errorCount > 0) { |
|||
let errorMsgBuf = [] |
|||
for (let i = 0; i < received.results.length; i++) { |
|||
const result = received.results[i] |
|||
if (result.errorCount <= 0) { |
|||
continue |
|||
} |
|||
|
|||
for (let x = 0; x < result.messages.length; x++) { |
|||
const m = result.messages[x] |
|||
errorMsgBuf.push(colors.grey(`└── ${result.filePath}\t${m.line}:${m.column}\t${m.message}`)) |
|||
} |
|||
} |
|||
if (errorMsgBuf.length > 0) { |
|||
return { |
|||
message: () => (errorMsgBuf.join(`\n`)), |
|||
pass: false |
|||
} |
|||
} |
|||
} |
|||
return { |
|||
pass: true |
|||
} |
|||
}, |
|||
/** |
|||
* Expect PugLint results to have no errors |
|||
* @param {*} received PugLint results |
|||
* @param {*} argument Arguments |
|||
* @returns {object} Matcher result |
|||
*/ |
|||
toPugLint (received, argument) { |
|||
if (received && received.length > 0) { |
|||
let errorMsgBuf = [] |
|||
for (let i = 0; i < received.length; i++) { |
|||
errorMsgBuf.push(colors.grey(`└── ${received[i].message}`)) |
|||
} |
|||
return { |
|||
message: () => (errorMsgBuf.join(`\n`)), |
|||
pass: false |
|||
} |
|||
} |
|||
return { |
|||
pass: true |
|||
} |
|||
} |
|||
}) |
|||
|
|||
describe('Code Linting', () => { |
|||
it('should pass ESLint validation', () => { |
|||
const CLIEngine = require('eslint').CLIEngine |
|||
const cli = new CLIEngine() |
|||
let report = cli.executeOnFiles(['**/*.js']) |
|||
expect(report).toESLint() |
|||
}) |
|||
|
|||
it('should pass PugLint validation', () => { |
|||
const PugLint = require('pug-lint') |
|||
const lint = new PugLint() |
|||
const pugConfig = fs.readJsonSync('.pug-lintrc.json') |
|||
lint.configure(pugConfig) |
|||
let report = lint.checkPath('./views') |
|||
expect(report).toPugLint() |
|||
}) |
|||
}) |
@ -0,0 +1,39 @@ |
|||
'use strict' |
|||
|
|||
const colors = require('colors') |
|||
|
|||
expect.extend({ |
|||
/** |
|||
* Expect Snyk results to have no errors |
|||
* @param {*} received Snyk results |
|||
* @param {*} argument Arguments |
|||
* @returns {object} Matcher result |
|||
*/ |
|||
toPassSnyk (received, argument) { |
|||
if (received && received.ok === false) { |
|||
let errorMsgBuf = [] |
|||
for (let i = 0; i < received.vulnerabilities.length; i++) { |
|||
const result = received.vulnerabilities[i] |
|||
let vulnPath = result.from.slice(1).join(' > ') |
|||
errorMsgBuf.push(colors.red(`└──[${result.severity}] ${result.packageName}\t${result.title}`)) |
|||
errorMsgBuf.push(colors.grey(`\t${vulnPath}`)) |
|||
} |
|||
return { |
|||
message: () => (errorMsgBuf.join(`\n`)), |
|||
pass: false |
|||
} |
|||
} |
|||
return { |
|||
pass: true |
|||
} |
|||
} |
|||
}) |
|||
|
|||
describe('Security', () => { |
|||
it('should pass Snyk test', () => { |
|||
const snyk = require('snyk').test |
|||
return snyk('./').then(report => { |
|||
expect(report).toPassSnyk() |
|||
}) |
|||
}, 20000) |
|||
}) |
Write
Preview
Loading…
Cancel
Save