Skip to content
This repository has been archived by the owner on Nov 8, 2024. It is now read-only.

(Archived) Adopt TypeScript #1497

Closed
wants to merge 12 commits into from
Closed
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
24 changes: 16 additions & 8 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
version: 2.1


commands:
npm-install:
steps:
Expand All @@ -18,31 +17,36 @@ 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:
key: py-deps-{{ checksum "docs/requirements.txt" }}
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the build be an explicit step or should it be implicitly included as something like pretest script?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've tried to perform a build once and store it, but since its quite fast, we've decided with @kylef that such setup may be an overkill (attaching a workspace with the build takes multiple times longer than the build itself). I'm okay to revisit this, if you find it necessary.

- run: npm run ci:test


jobs:
build:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it need to be tested separately if it's a part of all the other jobs?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Besides, this job isn't included in the workflow, so it isn't currently being ran.

docker: [<<: *node12]
steps:
- checkout
- npm-install
- run: npm run build

test-node12:
docker: [<<: *node12]
<<: *test-steps
Expand All @@ -60,13 +64,15 @@ jobs:
steps:
- checkout
- npm-install
- run: npm run build
- run: npm run e2e:apib

test-e2e-openapi2:
docker: [<<: *node12]
steps:
- checkout
- npm-install
- run: npm run build
- run: npm run e2e:openapi2

quality-checks:
Expand Down Expand Up @@ -94,6 +100,7 @@ jobs:
steps:
- checkout
- npm-install
- run: npm run build
- run: npm run ci:smoke

release:
Expand All @@ -103,21 +110,22 @@ jobs:
steps:
- checkout
- npm-install
- run: npm run build
- run: npm run ci:release


workflows:
version: 2
test-and-release:
jobs:
- quality-checks
- docs-dry-run
- test-node12
- test-node10
- test-node8
- test-e2e-apib
- test-e2e-openapi2
- smoke-tests
- docs-dry-run

- release:
requires:
- quality-checks
Expand Down
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
.vscode
coverage
docs
build

# In case Python virtualenv is present in the project directory, this ignores
# its contents (some Python projects vendor JavaScript files, etc.)
Expand Down
20 changes: 6 additions & 14 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,20 @@
module.exports = {
extends: 'airbnb-base',
extends: ['airbnb-base', 'prettier'],
env: {
'node': true
node: true
},
rules: {
// Using 'console' is perfectly okay for a Node.js CLI tool and avoiding
// it only brings unnecessary complexity
'no-console': 'off',

// Node 6 does not support dangling commas in function arguments
'comma-dangle': [
'error',
{
'arrays': 'always-multiline',
'objects': 'always-multiline',
artem-zakharchenko marked this conversation as resolved.
Show resolved Hide resolved
'functions': 'never'
}
],

// This is to allow a convention for exporting functions solely for
// the purpose of the unit tests, see
// https://github.com/apiaryio/dredd-transactions/pull/179#discussion_r206852270
'no-underscore-dangle': 'off',

'import/prefer-default-export': 'off',
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Allows export const a = 'anything' exports from files.

  • Makes internals easier to export for testing
  • Doesn't pollute the default export


// Following rules were introduced to make the decaffeination
// of the codebase possible and are to be removed in the future
'class-methods-use-this': 'off',
Expand All @@ -38,6 +30,6 @@ module.exports = {
'no-plusplus': 'off',
'no-restricted-syntax': 'off',
'no-use-before-define': 'off',
'prefer-destructuring': 'off',
'prefer-destructuring': 'off'
}
};
}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ npm-shrinkwrap.json

/coverage
/docs/_build
build
typings
node_modules
.idea
.vscode
Expand Down
2 changes: 2 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Prevent publishing source code to NPM
lib
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

6 changes: 6 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"semi": false,
"trailingComma": "all",
"singleQuote": true,
"arrowParens": "always"
}
15 changes: 8 additions & 7 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
environment:
nodejs_version: "10"
nodejs_version: '10'
install:
- ps: Install-Product node 10
- "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'
10 changes: 5 additions & 5 deletions bin/dredd
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
}
});

const CLI = require('../lib/CLI');
const CLI = require('../build/CLI').default;

const dreddCli = new CLI({
const dreddCLI = new CLI({
custom: {
cwd: process.cwd(),
argv: process.argv.slice(2),
},
argv: process.argv.slice(2)
}
});

dreddCli.run();
dreddCLI.run();
2 changes: 1 addition & 1 deletion docs/usage-cli.rst
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,4 @@ CLI Options Reference

Remember you can always list all available arguments by ``dredd --help``.

.. cli-options:: ../lib/options.json
.. cli-options:: ../options.json
Loading