Skip to content

Commit

Permalink
Convert to standalone repository
Browse files Browse the repository at this point in the history
  • Loading branch information
akheron committed Jan 10, 2021
1 parent 00be9a1 commit e511ab7
Show file tree
Hide file tree
Showing 14 changed files with 4,740 additions and 9 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist/
39 changes: 39 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
module.exports = {
root: true,
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint', 'prettier'],
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
],
rules: {
'@typescript-eslint/ban-types': [
'error',
{
types: { '{}': false },
extendDefaults: true,
},
],
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/member-delimiter-style': [
'error',
{
singleline: { delimiter: 'semi' },
multiline: { delimiter: 'none' },
},
],
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-namespace': 'off',
'@typescript-eslint/no-unused-vars': [
'warn',
{
argsIgnorePattern: '^_',
},
],
'@typescript-eslint/no-use-before-define': 'off',
'no-inner-declarations': 'off',
'prettier/prettier': 'error',
},
}
25 changes: 25 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: tests

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [12.x, 14.x, 15.x]

steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: yarn
- run: yarn lint
- run: yarn test
14 changes: 14 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.DS_Store
.idea
*.log
tmp/
dist/

*.tern-port
node_modules/
npm-debug.log*
yarn-debug.log*
yarn-error.log*
*.tsbuildinfo
.npm
.eslintcache
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dist/
package.json
7 changes: 7 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"arrowParens": "avoid",
"semi": false,
"singleQuote": true,
"trailingComma": "es5",
"proseWrap": "always"
}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# typera-openapi - typera to OpenAPI generator

![Build](https://github.com/akheron/typera/workflows/Build/badge.svg)
![Build](https://github.com/akheron/typera-openapi/workflows/tests/badge.svg)

`typera-openapi` is an experimental tool that creates [OpenAPI v3] definitions
from a project that uses [typera] for routes.
Expand Down
4 changes: 4 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
}
21 changes: 18 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,40 @@
"version": "0.1.0",
"description": "Generate OpenAPI spec from typera routes",
"main": "index.js",
"repository": "https://github.com/akheron/typera",
"repository": "https://github.com/akheron/typera-openapi",
"author": "Petri Lehtinen <[email protected]>",
"license": "MIT",
"files": ["*.js", "*.d.ts"],
"files": [
"dist"
],
"typings": "./dist/index.d.ts",
"bin": {
"sqltyper": "cli.js"
"sqltyper": "./dist/cli.js"
},
"scripts": {
"build": "tsc",
"lint": "eslint '**/*.ts'",
"test": "jest",
"prepublishOnly": "yarn build"
},
"dependencies": {
"openapi-types": "^7.0.1",
"typescript": "^4.1.3",
"yargs": "^16.2.0"
},
"devDependencies": {
"@types/jest": "^26.0.20",
"@types/node": "*",
"@typescript-eslint/eslint-plugin": "^4.12.0",
"@typescript-eslint/parser": "^4.12.0",
"eslint": "^7.17.0",
"eslint-config-prettier": "^7.1.0",
"eslint-plugin-prettier": "^3.3.1",
"io-ts": "^2.2.13",
"io-ts-types": "^0.5.12",
"jest": "^26.6.3",
"prettier": "^2.2.1",
"ts-jest": "^26.4.4",
"typera-express": "2.0.0-alpha.2"
}
}
4 changes: 2 additions & 2 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const log: Logger = (location, level, ...args) =>
type Format = 'ts' | 'json'

const parseArgs = () =>
yargs.option('format', {
yargs.usage('Usage: $0 [options] FILE...').option('format', {
description: 'Output file format',
choices: ['ts' as const, 'json' as const],
default: 'ts' as Format,
Expand All @@ -22,7 +22,7 @@ const outputFileName = (sourceFileName: string, ext: string): string =>
const main = () => {
const args = parseArgs()

const sourceFiles = args._
const sourceFiles = args._.map(x => x.toString())
const ext = args.format === 'ts' ? '.openapi.ts' : '.json'

const results = generate(sourceFiles, { strict: true }, { log }).map(
Expand Down
2 changes: 1 addition & 1 deletion tests/__snapshots__/generate.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
exports[`generate works 1`] = `
Array [
Object {
"fileName": "packages/typera-openapi/tests/test-routes.ts",
"fileName": "tests/test-routes.ts",
"paths": Object {
"/constant": Object {
"get": Object {
Expand Down
1 change: 1 addition & 0 deletions tests/test-routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ const noExplicitRouteType = route
// The handler's request parameter is unused
const unusedRequest: Route<Response.Ok<string>> = route
.get('/unused-request')
// eslint-disable-next-line @typescript-eslint/no-unused-vars
.handler(async request => {
return Response.ok('xyzzy')
})
Expand Down
7 changes: 5 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": ".",
"outDir": "dist",
"module": "commonjs",
"target": "es6",
"lib": ["es2019"],
"strict": true,
"declaration": true
},
"include": ["src/*.ts"],
Expand Down
Loading

0 comments on commit e511ab7

Please sign in to comment.