From 0d12b508b3b5de73dedd0cfc12b25111ab08f4dc Mon Sep 17 00:00:00 2001 From: artem-zakharchenko Date: Tue, 1 Oct 2019 14:42:53 +0200 Subject: [PATCH] feat: adds basic typescript setup --- .circleci/config.yml | 12 +++++------- .gitignore | 1 + appveyor.yml | 15 ++++++++------- bin/dredd | 2 +- package.json | 9 ++++++--- tsconfig.json | 17 +++++++++++++++++ 6 files changed, 38 insertions(+), 18 deletions(-) create mode 100644 tsconfig.json diff --git a/.circleci/config.yml b/.circleci/config.yml index cebedecf3..1a3d298a8 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,6 +1,5 @@ version: 2.1 - commands: npm-install: steps: @@ -18,7 +17,7 @@ commands: - run: echo $(python --version) > .python-version - restore_cache: key: py-deps-{{ checksum ".python-version" }}-{{ checksum "docs/requirements.txt" }} - - run: "if [ ! -d ./venv ]; then python -m venv ./venv; fi" + - run: 'if [ ! -d ./venv ]; then python -m venv ./venv; fi' - run: echo "source $(pwd)/venv/bin/activate" >> $BASH_ENV - run: pip install -r ./docs/requirements.txt - save_cache: @@ -26,22 +25,20 @@ commands: paths: - ./venv - aliases: - &node12 image: circleci/node:12 - - &python-docs - # using Python 3.6 as that's the version ReadTheDocs is running + - &python-docs # using Python 3.6 as that's the version ReadTheDocs is running image: circleci/python:3.6-node - &test-steps steps: - checkout - npm-install + - run: npm run build - run: npm run ci:test - jobs: test-node12: docker: [<<: *node12] @@ -60,6 +57,7 @@ jobs: steps: - checkout - npm-install + - run: npm run build - run: npm run e2e:apib test-e2e-openapi2: @@ -67,6 +65,7 @@ jobs: steps: - checkout - npm-install + - run: npm run build - run: npm run e2e:openapi2 quality-checks: @@ -112,7 +111,6 @@ jobs: - npm-install - run: npm run ci:release - workflows: version: 2 test-and-release: diff --git a/.gitignore b/.gitignore index 373a7c54c..f12ca33a2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ package-lock.json npm-shrinkwrap.json +/build /coverage /docs/_build node_modules diff --git a/appveyor.yml b/appveyor.yml index 85f3a4dd7..eb2365aad 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,15 +1,16 @@ environment: - nodejs_version: "12" + nodejs_version: '12' install: - ps: Install-Product node 12 - - "npm -g install npm@6" + - 'npm -g install npm@6' - "set PATH=%APPDATA%\\npm;%PATH%" - - "npm install" + - 'npm install' cache: - - "node_modules -> package.json" + - 'node_modules -> package.json' - "%APPDATA%\\npm-cache -> package.json" build: off test_script: - - "node --version" - - "npm --version" - - "npm test" + - 'node --version' + - 'npm --version' + - 'npm run build' + - 'npm test' diff --git a/bin/dredd b/bin/dredd index fb0b7965f..2de61a380 100755 --- a/bin/dredd +++ b/bin/dredd @@ -8,7 +8,7 @@ } }); -const CLI = require('../lib/CLI'); +const CLI = require('../build/CLI'); const dreddCli = new CLI({ custom: { diff --git a/package.json b/package.json index aa465e2f7..69f38001b 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "dredd", "version": "0.0.0-semantically-released", "description": "HTTP API Testing Framework", - "main": "lib/Dredd.js", + "main": "build/Dredd.js", "bin": { "dredd": "bin/dredd" }, @@ -10,6 +10,8 @@ "node": ">=8" }, "scripts": { + "start": "npm run build -- --watch", + "build": "tsc --build tsconfig.json", "docs:lint": "sphinx-build -nW -b linkcheck ./docs ./docs/_build", "docs:test-extensions": "python -m unittest docs/_extensions/*.py --verbose", "docs:build": "sphinx-build -nW -b html ./docs ./docs/_build", @@ -26,7 +28,8 @@ "ci:docs": "npm run docs:build", "ci:test": "npm test", "ci:smoke": "bash ./scripts/smoke.sh", - "ci:release": "semantic-release && npm dist-tag add \"dredd@$(npm view dredd version)\" stable" + "ci:release": "semantic-release && npm dist-tag add \"dredd@$(npm view dredd version)\" stable", + "prepack": "npm run build" }, "repository": { "type": "git", @@ -34,7 +37,7 @@ }, "files": [ "bin", - "lib", + "build", "options.json", "README.md" ], diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 000000000..be7fece56 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,17 @@ +{ + "compileOnSave": true, + "compilerOptions": { + "module": "commonjs", + "target": "es2017", + "lib": ["es2017"], + "typeRoots": ["node_modules/@types"], + "rootDir": "./lib", + "outDir": "./build", + "moduleResolution": "node", + "esModuleInterop": true, + "allowJs": true, + "allowSyntheticDefaultImports": true + }, + "include": ["./lib/**/*.ts", "./lib/**/*.js"], + "exclude": ["node_modules", "build"] +}