Compare commits
No commits in common. "7bd4224a053a92288ec676f583de161af21c927f" and "c8c57c8772fccf226f0eca8fa1f0a571d649c23e" have entirely different histories.
7bd4224a05
...
c8c57c8772
46
Jenkinsfile
vendored
46
Jenkinsfile
vendored
@ -1,46 +0,0 @@
|
|||||||
pipeline {
|
|
||||||
agent any
|
|
||||||
|
|
||||||
environment {
|
|
||||||
VERSION = VersionNumber([
|
|
||||||
versionNumberString:
|
|
||||||
'${BUILDS_ALL_TIME}',
|
|
||||||
versionPrefix: '1.1.',
|
|
||||||
worstResultForIncrement: 'SUCCESS'
|
|
||||||
])
|
|
||||||
publish = 0
|
|
||||||
}
|
|
||||||
|
|
||||||
stages {
|
|
||||||
stage('Setup') {
|
|
||||||
steps {
|
|
||||||
echo 'Setting up test environment'
|
|
||||||
sh 'npm ci'
|
|
||||||
sh 'nodejs jenkins.js ${VERSION}'
|
|
||||||
script {
|
|
||||||
currentBuild.displayName = env.VERSION
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
stage('Testing') {
|
|
||||||
steps {
|
|
||||||
echo 'Running tests...'
|
|
||||||
sh 'npm test'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
post {
|
|
||||||
success {
|
|
||||||
script {
|
|
||||||
publish = sh script: "git log -1 | grep '\\[no publish\\]'", returnStatus: true
|
|
||||||
if (publish != 0) {
|
|
||||||
echo 'Deploying'
|
|
||||||
sh 'npm publish'
|
|
||||||
} else {
|
|
||||||
echo 'Build successful, Commit not marked for deploying'
|
|
||||||
currentBuild.result = "UNSTABLE"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
4
index.js
4
index.js
@ -8,11 +8,11 @@ const path = require('path');
|
|||||||
* @param {string} modulefolder
|
* @param {string} modulefolder
|
||||||
* @param {any} opts object to pass to the handlers (for example database access)
|
* @param {any} opts object to pass to the handlers (for example database access)
|
||||||
*/
|
*/
|
||||||
module.exports = function (app, modulefolder, opts = {}, subdir = '') {
|
module.exports = function (app, modulefolder, opts) {
|
||||||
for (const f of fs.readdirSync(modulefolder)) {
|
for (const f of fs.readdirSync(modulefolder)) {
|
||||||
const regex = /(.*?)-(.*?)\.js/;
|
const regex = /(.*?)-(.*?)\.js/;
|
||||||
let [, method, url] = regex.exec(f);
|
let [, method, url] = regex.exec(f);
|
||||||
url = '/' + subdir + '/' + url + '/';
|
url = '/' + url + '/';
|
||||||
url = url
|
url = url
|
||||||
.replace(/^\/root/i, '/')
|
.replace(/^\/root/i, '/')
|
||||||
.replace(/\./g, '/')
|
.replace(/\./g, '/')
|
||||||
|
@ -1,5 +0,0 @@
|
|||||||
const fs = require('fs');
|
|
||||||
|
|
||||||
const pkg = JSON.parse(fs.readFileSync('package.json', 'utf-8'));
|
|
||||||
pkg.version = process.argv[2];
|
|
||||||
fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2));
|
|
19
test/main.js
19
test/main.js
@ -28,7 +28,7 @@ describe('requestor', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should detect all requests on root', () => {
|
it('should detect all requests on root', () => {
|
||||||
requestor(mock, './test/root');
|
requestor(mock, './test/root', {});
|
||||||
expect(mock.registered).to.have.all.keys([
|
expect(mock.registered).to.have.all.keys([
|
||||||
'post-/',
|
'post-/',
|
||||||
'get-/',
|
'get-/',
|
||||||
@ -39,7 +39,7 @@ describe('requestor', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should detect requests on root.subfolder', () => {
|
it('should detect requests on root.subfolder', () => {
|
||||||
requestor(mock, './test/root.sub');
|
requestor(mock, './test/root.sub', {});
|
||||||
expect(mock.registered).to.have.all.keys([
|
expect(mock.registered).to.have.all.keys([
|
||||||
'post-/sub/',
|
'post-/sub/',
|
||||||
'get-/sub/',
|
'get-/sub/',
|
||||||
@ -50,7 +50,7 @@ describe('requestor', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should detect requests on subfolder', () => {
|
it('should detect requests on subfolder', () => {
|
||||||
requestor(mock, './test/sub');
|
requestor(mock, './test/sub', {});
|
||||||
expect(mock.registered).to.have.all.keys([
|
expect(mock.registered).to.have.all.keys([
|
||||||
'post-/sub/',
|
'post-/sub/',
|
||||||
'get-/sub/',
|
'get-/sub/',
|
||||||
@ -61,17 +61,4 @@ describe('requestor', () => {
|
|||||||
'all-/sub/root/'
|
'all-/sub/root/'
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should build requests with subdirectory', () => {
|
|
||||||
requestor(mock, './test/sub', {}, 'test');
|
|
||||||
expect(mock.registered).to.have.all.keys([
|
|
||||||
'post-/test/sub/',
|
|
||||||
'get-/test/sub/',
|
|
||||||
'put-/test/sub/',
|
|
||||||
'delete-/test/sub/',
|
|
||||||
'all-/test/sub/',
|
|
||||||
'get-/test/sub/lv1/lv2/lv3/',
|
|
||||||
'all-/test/sub/root/'
|
|
||||||
]);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user