Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 15 additions & 8 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,34 +1,41 @@
def tag = input message: 'Tag', parameters: [string(defaultValue: '', description: 'Tag', name: 'TAG')]
node {
stage('Checkout Git'){
git url: 'git@github.com:MaxxtonGroup/microdocs.git', branch: 'master'
checkout([$class: 'GitSCM', branches: [[name: '*/master']], doGenerateSubmoduleConfigurations: false, submoduleCfg: [], userRemoteConfigs: [[url: 'https://github.com/MaxxtonGroup/microdocs', branch: 'master']]])

//git url: 'git@github.com:MaxxtonGroup/microdocs.git', branch: 'master'
stash name: 'source'
}
stage('Build microdocs-server'){
unstash name: 'source'
dir ('microdocs-server'){
sh 'npm install'
sh 'npm version ' + tag
sh 'npm run prepublish'
sh 'cp .npmrc dist/.npmrc'
dir ('dist'){
sh 'npm install --prod'
stash name: 'server-dist'
}
}
}
stage('Build microdocs-ui'){
unstash name: 'source'
dir ('microdocs-ui'){
sh 'npm install'
sh 'npm version ' + tag
sh './node_modules/.bin/ng build --prod'
dir('dist') {
stash name: 'ui-dist'
}
}
}
stage('Build microdocs-ui'){
dir ('microdocs-ui'){
sh 'npm install'
sh 'npm version ' + tag
sh 'ng build --prod'
}
}

stage('Build docker image'){
unstash name: 'source'
unstash name: 'server-dist'
unstash name: 'ui-dist'

sh 'bash docker rmi maxxton/microdocs:' + tag + ' || true'
sh 'bash docker rmi maxxton/microdocs:latest || true'
sh 'docker build --tag=maxxton/microdocs:' + tag + ' --no-cache .'
Expand Down
7 changes: 7 additions & 0 deletions microdocs-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,16 @@
"uuid": "^2.0.2"
},
"devDependencies": {
"@types/body-parser": "0.0.33",
"@types/chai": "^3.4.34",
"@types/express": "^4.0.35",
"@types/express-handlebars": "0.0.29",
"@types/handlebars": "^4.0.31",
"@types/helmet": "0.0.33",
"@types/jasmine": "^2.5.40",
"@types/multer": "0.0.33",
"@types/node": "^7.0.0",
"@types/uuid": "^2.0.29",
"async": "^2.0.1",
"chai": "^3.5.0",
"del": "^2.2.2",
Expand Down
1 change: 0 additions & 1 deletion microdocs-server/src/_all.d.ts

This file was deleted.

7 changes: 3 additions & 4 deletions microdocs-server/src/app.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/// <reference path="_all.d.ts" />
"use strict";

import * as bodyParser from "body-parser";
Expand Down Expand Up @@ -124,7 +123,7 @@ class Server {
*/
private routes() {
//get router
let router:express.Router;
let router:any;
router = express.Router();

//create routes
Expand Down Expand Up @@ -168,5 +167,5 @@ class Server {
}
}

var server = Server.bootstrap();
export = server.app;
const app = Server.bootstrap().app;
export = app;
85 changes: 42 additions & 43 deletions microdocs-server/src/config.ts
Original file line number Diff line number Diff line change
@@ -1,55 +1,54 @@
/// <reference path="_all.d.ts" />
"use strict";

import * as yamlConfig from "node-yaml-config";
const yamlConfig = require( 'node-yaml-config' );

/**
* Server configuration
*/
export class Config {

/**
* Location of the config.yml
* @type {string}
*/
private static configFile : string = __dirname + '/../config.yml';
private static config : {};

/**
* (re)load the configuration
*/
public static reload(){
console.info("load config");
Config.config = (<any>yamlConfig).load(Config.configFile);
}

/**
* Get a configuration property
* @param path path of the property, eg. "foo.bar"
* @returns {any} the value of the property or undefined
*/
public static get(path:string):any {
var paths = path.split('.');
var current = Config.config;

for (var i = 0; i < paths.length; ++i) {
if (current[paths[i]] == undefined) {
return undefined;
} else {
current = current[paths[i]];
}
}
return current;
}

/**
* Check if a configuration property exists
* @param path path of the property, eg. "foo.bar"
* @returns {boolean} true/false
*/
public static has(path:string):any{
return Config.get(path) != undefined;
/**
* Location of the config.yml
* @type {string}
*/
private static configFile: string = __dirname + '/../config.yml';
private static config: {};

/**
* (re)load the configuration
*/
public static reload() {
console.info( "load config" );
Config.config = (<any>yamlConfig).load( Config.configFile );
}

/**
* Get a configuration property
* @param path path of the property, eg. "foo.bar"
* @returns {any} the value of the property or undefined
*/
public static get( path: string ): any {
var paths = path.split( '.' );
var current:any = Config.config;

for ( var i = 0; i < paths.length; ++i ) {
if ( current[ paths[ i ] ] == undefined ) {
return undefined;
} else {
current = current[ paths[ i ] ];
}
}
return current;
}

/**
* Check if a configuration property exists
* @param path path of the property, eg. "foo.bar"
* @returns {boolean} true/false
*/
public static has( path: string ): any {
return Config.get( path ) != undefined;
}

}

Expand Down
5 changes: 2 additions & 3 deletions microdocs-server/src/repositories/json/project-json.repo.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/// <reference path="../../_all.d.ts" />
import * as fs from 'fs';
import * as path from 'path';
import * as mkdir from 'mkdir-p';
const mkdir = require('mkdir-p');

import {Config} from "../../config";
import {ProjectRepository} from "../project.repo";
Expand Down Expand Up @@ -55,7 +54,7 @@ export class ProjectJsonRepository implements ProjectRepository {
if (fs.existsSync(storeFile)) {
var string = fs.readFileSync(storeFile).toString();
var json = JSON.parse(string);
var project:Project = json;
var project:any = json;
if(project.dependencies) {
let convertedDependencies:{[key: string]:Dependency} = {};
for(let key in project.dependencies){
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/// <reference path="../../_all.d.ts" />

import * as fs from 'fs';
import * as path from 'path';
import * as fsHelper from '../../helpers/file.helper';
Expand Down
3 changes: 1 addition & 2 deletions microdocs-server/src/repositories/json/report-json.repo.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
/// <reference path="../../_all.d.ts" />
import * as fs from 'fs';
import * as path from 'path';

import {Config} from "../../config";
import {ReportRepository} from "../report.repo";
import {Project, ProjectInfo} from "@maxxton/microdocs-core/domain";
import * as mkdir from 'mkdir-p';
const mkdir = require('mkdir-p');
import * as fsHelper from '../../helpers/file.helper';
import { Dependency } from "@maxxton/microdocs-core/domain/dependency/dependency.model";

Expand Down
1 change: 0 additions & 1 deletion microdocs-server/src/routes/check.route.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/// <reference path="../_all.d.ts" />

import * as express from "express";

Expand Down
1 change: 0 additions & 1 deletion microdocs-server/src/routes/edit-project.route.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/// <reference path="../_all.d.ts" />

import * as express from "express";

Expand Down
1 change: 0 additions & 1 deletion microdocs-server/src/routes/env.route.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/// <reference path="../_all.d.ts" />

import * as express from "express";

Expand Down
1 change: 0 additions & 1 deletion microdocs-server/src/routes/project.route.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/// <reference path="../_all.d.ts" />

import * as express from "express";

Expand Down
1 change: 0 additions & 1 deletion microdocs-server/src/routes/projects.route.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/// <reference path="../_all.d.ts" />

import * as express from "express";

Expand Down
9 changes: 6 additions & 3 deletions microdocs-server/src/routes/publish.route.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/// <reference path="../_all.d.ts" />

import * as express from "express";

Expand Down Expand Up @@ -101,10 +100,14 @@ export class PublishRoute extends BaseRoute {
handler.handleBadRequest( req, res, "Missing group parameter" );
return;
}
let links = report.info && report.info.links;
let description = report.info && report.info.description;
let sourceLink = report.info && report.info.sourceLink;
let color = report.info && report.info.color;


//set group and version in the report
report.info = new ProjectInfo(title, group, version, [version], report.info.links, report.info.description, report.info.sourceLink);
report.info.publishTime = new Date().toISOString();
report.info = new ProjectInfo(title, group, version, [version], links, description, sourceLink, new Date().toISOString(), undefined, color);

var aggregationService = scope.injection.AggregationService();

Expand Down
1 change: 0 additions & 1 deletion microdocs-server/src/routes/reindex.route.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/// <reference path="../_all.d.ts" />

import * as express from "express";

Expand Down
1 change: 0 additions & 1 deletion microdocs-server/src/routes/remove-project.route.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/// <reference path="../_all.d.ts" />

import * as express from "express";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as express from "express";
import {ProjectTree, Problem, Project, ProblemResponse, ProblemLevels} from '@maxxton/microdocs-core/domain';
import * as yaml from 'js-yaml';
import * as xml from 'jsontoxml';
const yaml = require('js-yaml');
const xml = require('jsontoxml');
import {Injection} from "../../injections";

export class BaseResponseHandler {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export class MicroDocsResponseHandler extends BaseResponseHandler {

protected getGlobalInfo():Project {
var project:Project = {};
project.info = <ProjectInfo>{
project.info = <any>{
title: Config.get( 'application-name' ),
group: undefined,
version: Config.get( 'application-version' ).toString(),
Expand Down
24 changes: 12 additions & 12 deletions microdocs-server/src/routes/responses/postman-response.handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ export class PostmanResponseHandler extends MicroDocsResponseHandler {
}

postmans(projectTree: ProjectTree, env:string):{}{
var collection = this.getPostmanBase();
var collection:any = this.getPostmanBase();

projectTree.projects.forEach(projectNode => {
var project = this.injection.ProjectRepository().getAggregatedProject(env, projectNode.title, projectNode.version);
var subCollection = this.getPostmanItems(project);
collection['item'].push({
collection.item.push({
name: projectNode.title,
description: project.info && project.info.description ? project.info.description : 'Folder for ' + projectNode.title,
item: subCollection
Expand All @@ -51,8 +51,8 @@ export class PostmanResponseHandler extends MicroDocsResponseHandler {
}

postman(project: Project): {} {
var collection = this.getPostmanBase(project);
collection['item'] = this.getPostmanItems(project);
var collection:any = this.getPostmanBase(project);
collection.item = this.getPostmanItems(project);

return collection;
}
Expand Down Expand Up @@ -110,18 +110,18 @@ export class PostmanResponseHandler extends MicroDocsResponseHandler {
if(endpoint.responses != undefined){
var defaultResponse = endpoint.responses['default'];
if(Object.keys(endpoint.responses).length == 1 && defaultResponse != undefined){
var response:{} = {};
var response:any = {};
if(defaultResponse.schema != undefined && defaultResponse.schema.default != undefined){
response['body'] = JSON.stringify(defaultResponse.schema.default, null, ' ');
response.body = JSON.stringify(defaultResponse.schema.default, null, ' ');
}
responses.push(response);
}else{
for(var status in endpoint.responses){
var response:{} = {status: status};
var response:any = {status: status};
if(endpoint.responses[status].schema != undefined && endpoint.responses[status].schema.default != undefined){
response['body'] = JSON.stringify(endpoint.responses[status].schema.default, null, ' ');
response.body = JSON.stringify(endpoint.responses[status].schema.default, null, ' ');
}else if(defaultResponse.schema != undefined && defaultResponse.schema.default != undefined){
response['body'] = JSON.stringify(defaultResponse.schema.default, null, ' ');
response.body = JSON.stringify(defaultResponse.schema.default, null, ' ');
}
responses.push(response);
}
Expand All @@ -141,7 +141,7 @@ export class PostmanResponseHandler extends MicroDocsResponseHandler {
}

getPostmanBase(project?:Project): {} {
var collection:{item:any[], info:{}} = {item: [], info:{}};
var collection:any = {item: [], info:{}};
if(project){
collection['info'] = {
name: project.info.title,
Expand All @@ -155,8 +155,8 @@ export class PostmanResponseHandler extends MicroDocsResponseHandler {
description: Config.get('application-description')
};
}
collection.info['schema'] = "https://schema.getpostman.com/json/collection/v2.0.0/collection.json";
collection.info['_postman_id'] = uuid['v4']();
collection.info.schema = "https://schema.getpostman.com/json/collection/v2.0.0/collection.json";
collection.info._postman_id = uuid['v4']();

// get base url
var schema:string = Config.get('application-schema');
Expand Down
Loading