Introduce ts-lint and clean everything up a bit
This commit is contained in:
parent
e7ecc6574a
commit
75069fab67
10
Makefile
10
Makefile
|
@ -22,10 +22,12 @@ build: depends ## Build all components
|
|||
$(foreach dir, $(SUB_DIRS), $(MAKE) -C $(dir) $@)
|
||||
tsc
|
||||
|
||||
check: depends build ## Run validation tests
|
||||
lint: depends
|
||||
tslint -c tslint.json -t stylish 'lib/**/*.ts' 'services/**/*.ts'
|
||||
|
||||
check: depends lint build ## Run validation tests
|
||||
jest
|
||||
#dredd
|
||||
node parse-test.js
|
||||
dredd
|
||||
|
||||
swagger: depends ## Generate the swagger stubs based on apispecs
|
||||
|
||||
|
@ -40,4 +42,4 @@ clean: ## Clean all temporary/working files
|
|||
################################################################################
|
||||
|
||||
|
||||
.PHONY: all build check clean depends parser
|
||||
.PHONY: all build check clean depends lint swagger
|
||||
|
|
|
@ -3,16 +3,16 @@
|
|||
* services
|
||||
*/
|
||||
|
||||
import { createLogger, format, transports } from 'winston';
|
||||
import { createLogger, format, transports } from 'winston'
|
||||
|
||||
export default createLogger({
|
||||
// To see more detailed errors, change this to 'debug'
|
||||
level: 'info',
|
||||
format: format.combine(
|
||||
format.splat(),
|
||||
format.simple()
|
||||
format.simple(),
|
||||
),
|
||||
level: 'info',
|
||||
transports: [
|
||||
new transports.Console()
|
||||
new transports.Console(),
|
||||
],
|
||||
});
|
||||
})
|
||||
|
|
|
@ -3,9 +3,9 @@
|
|||
* in the project
|
||||
*/
|
||||
|
||||
import logger from '@otto/logger';
|
||||
import logger from '@otto/logger'
|
||||
|
||||
import { Application } from '@feathersjs/express';
|
||||
import { Application } from '@feathersjs/express'
|
||||
|
||||
/**
|
||||
* The serveApp function expects a Feathers application which it can start
|
||||
|
@ -16,14 +16,14 @@ import { Application } from '@feathersjs/express';
|
|||
* @param app An instantiated feathers application
|
||||
*/
|
||||
export function serveApp(app: Application) {
|
||||
const port: Number = app.get('port');
|
||||
const server: any = app.listen(port);
|
||||
const port: Number = app.get('port')
|
||||
const server: any = app.listen(port)
|
||||
|
||||
process.on('unhandledRejection', (reason, p) =>
|
||||
logger.error('Unhandled Rejection at: Promise ', p, reason)
|
||||
);
|
||||
logger.error('Unhandled Rejection at: Promise ', p, reason),
|
||||
)
|
||||
|
||||
server.on('listening', () =>
|
||||
logger.info('Feathers application started on http://%s:%d', app.get('host'), port)
|
||||
);
|
||||
logger.info('Feathers application started on http://%s:%d', app.get('host'), port),
|
||||
)
|
||||
}
|
||||
|
|
|
@ -883,6 +883,58 @@
|
|||
"resolved": "https://registry.npmjs.org/aws4/-/aws4-1.8.0.tgz",
|
||||
"integrity": "sha512-ReZxvNHIOv88FlT7rxcXIIC0fPt4KZqZbOlivyWtXLt8ESx84zd3kMC6iK5jVeS2qt+g7ftS7ye4fi06X5rtRQ=="
|
||||
},
|
||||
"babel-code-frame": {
|
||||
"version": "6.26.0",
|
||||
"resolved": "https://registry.npmjs.org/babel-code-frame/-/babel-code-frame-6.26.0.tgz",
|
||||
"integrity": "sha1-Y/1D99weO7fONZR9uP42mj9Yx0s=",
|
||||
"requires": {
|
||||
"chalk": "^1.1.3",
|
||||
"esutils": "^2.0.2",
|
||||
"js-tokens": "^3.0.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"ansi-regex": {
|
||||
"version": "2.1.1",
|
||||
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz",
|
||||
"integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8="
|
||||
},
|
||||
"ansi-styles": {
|
||||
"version": "2.2.1",
|
||||
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz",
|
||||
"integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4="
|
||||
},
|
||||
"chalk": {
|
||||
"version": "1.1.3",
|
||||
"resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz",
|
||||
"integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=",
|
||||
"requires": {
|
||||
"ansi-styles": "^2.2.1",
|
||||
"escape-string-regexp": "^1.0.2",
|
||||
"has-ansi": "^2.0.0",
|
||||
"strip-ansi": "^3.0.0",
|
||||
"supports-color": "^2.0.0"
|
||||
}
|
||||
},
|
||||
"js-tokens": {
|
||||
"version": "3.0.2",
|
||||
"resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-3.0.2.tgz",
|
||||
"integrity": "sha1-mGbfOVECEw449/mWvOtlRDIJwls="
|
||||
},
|
||||
"strip-ansi": {
|
||||
"version": "3.0.1",
|
||||
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz",
|
||||
"integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=",
|
||||
"requires": {
|
||||
"ansi-regex": "^2.0.0"
|
||||
}
|
||||
},
|
||||
"supports-color": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz",
|
||||
"integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc="
|
||||
}
|
||||
}
|
||||
},
|
||||
"babel-jest": {
|
||||
"version": "24.8.0",
|
||||
"resolved": "https://registry.npmjs.org/babel-jest/-/babel-jest-24.8.0.tgz",
|
||||
|
@ -1785,6 +1837,11 @@
|
|||
"kuler": "1.0.x"
|
||||
}
|
||||
},
|
||||
"diff": {
|
||||
"version": "3.5.0",
|
||||
"resolved": "https://registry.npmjs.org/diff/-/diff-3.5.0.tgz",
|
||||
"integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA=="
|
||||
},
|
||||
"diff-sequences": {
|
||||
"version": "24.3.0",
|
||||
"resolved": "https://registry.npmjs.org/diff-sequences/-/diff-sequences-24.3.0.tgz",
|
||||
|
@ -2420,6 +2477,28 @@
|
|||
"locate-path": "^3.0.0"
|
||||
}
|
||||
},
|
||||
"findup-sync": {
|
||||
"version": "0.3.0",
|
||||
"resolved": "https://registry.npmjs.org/findup-sync/-/findup-sync-0.3.0.tgz",
|
||||
"integrity": "sha1-N5MKpdgWt3fANEXhlmzGeQpMCxY=",
|
||||
"requires": {
|
||||
"glob": "~5.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"glob": {
|
||||
"version": "5.0.15",
|
||||
"resolved": "https://registry.npmjs.org/glob/-/glob-5.0.15.tgz",
|
||||
"integrity": "sha1-G8k2ueAvSmA/zCIuz3Yz0wuLk7E=",
|
||||
"requires": {
|
||||
"inflight": "^1.0.4",
|
||||
"inherits": "2",
|
||||
"minimatch": "2 || 3",
|
||||
"once": "^1.3.0",
|
||||
"path-is-absolute": "^1.0.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"for-in": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/for-in/-/for-in-1.0.2.tgz",
|
||||
|
@ -3185,6 +3264,21 @@
|
|||
"function-bind": "^1.1.1"
|
||||
}
|
||||
},
|
||||
"has-ansi": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz",
|
||||
"integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=",
|
||||
"requires": {
|
||||
"ansi-regex": "^2.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"ansi-regex": {
|
||||
"version": "2.1.1",
|
||||
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz",
|
||||
"integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8="
|
||||
}
|
||||
}
|
||||
},
|
||||
"has-flag": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz",
|
||||
|
@ -6498,11 +6592,38 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"ts-lint": {
|
||||
"version": "4.5.1",
|
||||
"resolved": "https://registry.npmjs.org/ts-lint/-/ts-lint-4.5.1.tgz",
|
||||
"integrity": "sha1-nCK3t7hitnMk3RvSE6hFwDp/uMA=",
|
||||
"requires": {
|
||||
"babel-code-frame": "^6.20.0",
|
||||
"colors": "^1.1.2",
|
||||
"diff": "^3.0.1",
|
||||
"findup-sync": "~0.3.0",
|
||||
"glob": "^7.1.1",
|
||||
"optimist": "~0.6.0",
|
||||
"resolve": "^1.1.7",
|
||||
"tsutils": "^1.1.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"colors": {
|
||||
"version": "1.3.3",
|
||||
"resolved": "https://registry.npmjs.org/colors/-/colors-1.3.3.tgz",
|
||||
"integrity": "sha512-mmGt/1pZqYRjMxB1axhTo16/snVZ5krrKkcmMeVKxzECMMXoCgnvTPp10QgHfcbQZw8Dq2jMNG6je4JlWU0gWg=="
|
||||
}
|
||||
}
|
||||
},
|
||||
"tslib": {
|
||||
"version": "1.10.0",
|
||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-1.10.0.tgz",
|
||||
"integrity": "sha512-qOebF53frne81cf0S9B41ByenJ3/IuH8yJKngAX35CmiZySA0khhkovshKK+jGCaMnVomla7gVlIcc3EvKPbTQ=="
|
||||
},
|
||||
"tsutils": {
|
||||
"version": "1.9.1",
|
||||
"resolved": "https://registry.npmjs.org/tsutils/-/tsutils-1.9.1.tgz",
|
||||
"integrity": "sha1-ufmrROVa+WgYMdXyjQrur1x1DLA="
|
||||
},
|
||||
"tunnel-agent": {
|
||||
"version": "0.6.0",
|
||||
"resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz",
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
"helmet": "^3.18.0",
|
||||
"module-alias": "^2.2.0",
|
||||
"nodemon": "^1.19.1",
|
||||
"ts-lint": "^4.5.1",
|
||||
"tslib": "^1.10.0",
|
||||
"typescript": "^3.5.2",
|
||||
"uuid": "^3.3.2",
|
||||
|
|
|
@ -1,54 +1,54 @@
|
|||
require('module-alias/register');
|
||||
import modalias from 'module-alias'
|
||||
modalias()
|
||||
|
||||
import logger from '@otto/logger';
|
||||
import configuration from '@feathersjs/configuration'
|
||||
import express from '@feathersjs/express'
|
||||
import feathers from '@feathersjs/feathers'
|
||||
|
||||
import logger from '@otto/logger'
|
||||
import { serveApp } from '@otto/server'
|
||||
|
||||
import feathers from '@feathersjs/feathers';
|
||||
import configuration from '@feathersjs/configuration';
|
||||
import express from '@feathersjs/express';
|
||||
|
||||
logger.info('Starting orchestrator');
|
||||
|
||||
const app = express(feathers());
|
||||
logger.info('Starting orchestrator')
|
||||
|
||||
const app = express(feathers())
|
||||
// We need to fish out the orchestrator specific settings
|
||||
const settings = configuration()(app);
|
||||
app.configure((app) => {
|
||||
const settings = configuration()(app)
|
||||
app.configure(() => {
|
||||
// tslint:disable:no-string-literal
|
||||
Object.keys(settings['orchestrator']).forEach((key) => {
|
||||
app.set(key, settings['orchestrator'][key]);
|
||||
});
|
||||
});
|
||||
app.set(key, settings['orchestrator'][key])
|
||||
})
|
||||
// tslint:enable:no-string-literal
|
||||
})
|
||||
|
||||
app.configure(express.rest())
|
||||
|
||||
app.configure(express.rest());
|
||||
|
||||
|
||||
app.configure((app : feathers.Application) => {
|
||||
app.configure(() => {
|
||||
const service = {
|
||||
get: (id : feathers.Id) => {
|
||||
logger.info(`Invoking get for ${id}`);
|
||||
get: (id: feathers.Id) => {
|
||||
logger.info(`Invoking get for ${id}`)
|
||||
const response = {
|
||||
ops: [
|
||||
{
|
||||
context: '0x1',
|
||||
data: {
|
||||
env: {},
|
||||
script: 'echo "Hello World"',
|
||||
timeout_s: 600,
|
||||
},
|
||||
id: '0xdeadbeef',
|
||||
type: 'RUNPROC',
|
||||
},
|
||||
],
|
||||
self: id,
|
||||
services: {
|
||||
datastore: 'http://localhost:3031/',
|
||||
},
|
||||
ops: [
|
||||
{
|
||||
id: '0xdeadbeef',
|
||||
context: '0x1',
|
||||
type: 'RUNPROC',
|
||||
data: {
|
||||
script: 'echo "Hello World"',
|
||||
env: {},
|
||||
timeout_s: 600,
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
return Promise.resolve(response);
|
||||
}
|
||||
return Promise.resolve(response)
|
||||
},
|
||||
};
|
||||
app.use('/v1/manifest', service);
|
||||
});
|
||||
}
|
||||
app.use('/v1/manifest', service)
|
||||
})
|
||||
|
||||
serveApp(app);
|
||||
serveApp(app)
|
||||
|
|
|
@ -5,9 +5,7 @@
|
|||
* See the parser README for more information
|
||||
*/
|
||||
|
||||
|
||||
import {Serialize, SerializeProperty, Serializable} from 'ts-serializer'
|
||||
|
||||
// tslint:disable:max-classes-per-file
|
||||
enum LibraryType {
|
||||
Builtin,
|
||||
FileReference,
|
||||
|
@ -18,14 +16,12 @@ class Library {
|
|||
protected readonly libraryRef: string
|
||||
}
|
||||
|
||||
|
||||
class Setting {
|
||||
protected readonly encrypted: Boolean
|
||||
protected readonly value: any
|
||||
}
|
||||
|
||||
|
||||
class Configuration extends Serializable {
|
||||
class Configuration {
|
||||
protected readonly settings: Map<string, Setting>
|
||||
}
|
||||
|
||||
|
@ -43,9 +39,9 @@ class Stage {
|
|||
protected before: Stage
|
||||
protected after: Stage
|
||||
protected runtime: Runtime
|
||||
protected steps: Array<Step> = []
|
||||
protected steps: Step[] = []
|
||||
protected capture: Map<string, FileCapture>
|
||||
protected restore: Array<string>
|
||||
protected restore: String[]
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -58,7 +54,7 @@ export default class Orf {
|
|||
/**
|
||||
* An array of libraries which must be loaded at runtime
|
||||
*/
|
||||
protected libraries: Array<Library> = []
|
||||
protected libraries: Library[] = []
|
||||
|
||||
/**
|
||||
* A map of configuration objects for configuring arbitrary
|
||||
|
@ -69,13 +65,13 @@ export default class Orf {
|
|||
/**
|
||||
* An ordered array of runtimes which will be used throughout the process
|
||||
*/
|
||||
protected runtimes: Array<Runtime> = []
|
||||
protected runtimes: Runtime[] = []
|
||||
|
||||
/**
|
||||
* An ordered array of stages as they have been parsed, not necessary how
|
||||
* they will be executed which may be more of a directed graph.
|
||||
*/
|
||||
protected stages: Array<Stage> = []
|
||||
protected stages: Stage[] = []
|
||||
|
||||
constructor() {
|
||||
this.configuration = new Map<string, Configuration>()
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
/*
|
||||
* The ParseListener is the initial entrypoint for building the graph
|
||||
*/
|
||||
require('module-alias/register')
|
||||
|
||||
import { Otto } from '@otto/grammar/Otto'
|
||||
import { OttoLexer } from '@otto/grammar/OttoLexer'
|
||||
import { OttoListener } from '@otto/grammar/OttoListener'
|
||||
import { Otto } from '@otto/grammar/Otto'
|
||||
|
||||
export default class ParseListener extends OttoListener {
|
||||
}
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"extends": [
|
||||
"tslint:recommended"
|
||||
],
|
||||
"jsRules": {},
|
||||
"rules": {
|
||||
"semicolon" : false,
|
||||
"quotemark" : false,
|
||||
"interface-name" : false
|
||||
},
|
||||
"rulesDirectory": []
|
||||
}
|
Loading…
Reference in New Issue