-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add husky with hooks for pre-commit (lint-staged) & commit-msg * add lint-staged for eslint & prettier * add commitlint * add typescript with @warungpintar/warpin-script (migration to typescript)
- Loading branch information
R Adysurya A
committed
Feb 18, 2021
1 parent
a2cccc2
commit 87f3bfe
Showing
40 changed files
with
3,989 additions
and
452 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/sh | ||
. "$(dirname "$0")/_/husky.sh" | ||
|
||
npx --no-install commitlint --edit $1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/sh | ||
. "$(dirname "$0")/_/husky.sh" | ||
|
||
yarn lint-staged |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/node_modules | ||
.*.js | ||
*.config.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = require('@warungpintar/warpin-scripts/config/eslint.config'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,5 @@ | ||
node_modules | ||
node_modules/ | ||
/lib | ||
|
||
dist/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
module.exports = { | ||
'src/**/*.{js?(x),ts?(x)}': [ | ||
'eslint --fix', | ||
'prettier --write', | ||
// @TODO: {jest} 'yarn test --findRelatedTests', | ||
], | ||
'**/*.ts?(x)': () => 'tsc -p tsconfig.json --noEmit', | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
package.json | ||
/lib |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = require("@warungpintar/warpin-scripts/config/prettier.config.js"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"editor.tabSize": 2, | ||
"editor.rulers": [80], | ||
"editor.wordWrapColumn": 80, | ||
"files.trimTrailingWhitespace": true, | ||
"files.insertFinalNewline": true, | ||
"editor.formatOnSave": true, | ||
"eslint.validate": [ | ||
"javascript", | ||
"javascriptreact", | ||
{ | ||
"language": "typescript", | ||
"autoFix": true | ||
}, | ||
{ | ||
"language": "typescriptreact", | ||
"autoFix": true | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
const BABEL_ENV = process.env.BABEL_ENV; | ||
const isCommonJS = BABEL_ENV !== undefined && BABEL_ENV === "cjs"; | ||
const isESM = BABEL_ENV !== undefined && BABEL_ENV === "esm"; | ||
const BASE = require("@warungpintar/warpin-scripts/config/babel.config"); | ||
|
||
module.exports = function(api) { | ||
const base = BASE(api); | ||
const overrides = [ | ||
{ | ||
presets: [ | ||
[ | ||
"@babel/env", | ||
{ | ||
loose: true, | ||
modules: isCommonJS ? "commonjs" : false, | ||
targets: { | ||
esmodules: isESM ? true : undefined, | ||
}, | ||
}, | ||
], | ||
], | ||
}, | ||
]; | ||
return { | ||
...base, | ||
overrides, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = {extends: ['@commitlint/config-conventional']} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
const CONFIG = {}; | ||
|
||
export default CONFIG; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import faker from 'faker'; | ||
import R from 'ramda'; | ||
|
||
const resolver = (_: any, args: { props: string }) => { | ||
const fakerProps = args.props?.split('.') ?? []; | ||
const fakerFn = R.path<() => string>(fakerProps)(faker); | ||
return fakerFn?.(); | ||
}; | ||
|
||
export default resolver; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import fakerResolver from './faker'; | ||
|
||
export default { | ||
faker: fakerResolver, | ||
}; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* eslint-disable */ | ||
// @ts-nocheck | ||
// @TODO: use express | ||
import fs from 'fs'; | ||
import Koa from 'koa'; | ||
import Router from 'koa-router'; | ||
import bodyParser from 'koa-bodyparser'; | ||
// import yaml from 'js-yaml'; | ||
// import configContext from "./middleware/configContext"; | ||
// import errorHandler from "./middleware/errorHandler"; | ||
// import proxy from "./proxy.js"; | ||
|
||
try { | ||
// @TODO: {parser-config} | ||
// @TODO: change passing config path by envar to cli arg | ||
// const configFile = process.env.CONFIG_PATH ?? '.warmock.yaml'; | ||
// const configContent = fs.readFileSync(configFile, 'utf8'); | ||
// const config = yaml.load(configContent); | ||
const router = new Router(); | ||
router.use(bodyParser()); | ||
// @TODO {proxy} need following @types/koa-bodyparser | ||
// router.use(proxy); | ||
const app = new Koa(); | ||
// app.use(errorHandler); | ||
// app.use(configContext(config)); | ||
app.use(router.routes()); | ||
app.listen(3001); | ||
} catch (error) { | ||
if ( | ||
error.message && | ||
error.message.includes('ENOENT: no such file or directory') | ||
) { | ||
console.error('Config file not found'); | ||
} else { | ||
console.error(error); | ||
} | ||
|
||
process.exit(1); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
type statusCode = number; | ||
|
||
class ServerError extends Error { | ||
statusCode: statusCode; | ||
constructor(statusCode: statusCode, message: string) { | ||
super(message); | ||
this.statusCode = statusCode; | ||
} | ||
} | ||
|
||
export default ServerError; |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.