Skip to content

Commit

Permalink
feat: Caporal v2 (#179)
Browse files Browse the repository at this point in the history
Caporal v2

BREAKING CHANGE: Caporal v2 is not backward compatible with 1.x.
v2 is a full rewrite with Typescript which brings a lot of features and fixes to v1.
  • Loading branch information
mattallty authored May 20, 2020
1 parent 8cb180e commit 5e3eb2f
Show file tree
Hide file tree
Showing 229 changed files with 56,081 additions and 13,292 deletions.
12 changes: 3 additions & 9 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
insert_final_newline = true

[*.js]
indent_size = 2
continuation_indent_size = 2
charset = utf-8
trim_trailing_whitespace = true

[*.md]
indent_size = 4
3 changes: 3 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
dist
coverage
40 changes: 40 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
module.exports = {
root: true,
env: {
node: true,
es6: true,
jest: true,
},
parser: "@typescript-eslint/parser",
parserOptions: {
ecmaVersion: 2018,
sourceType: "module",
},
extends: ["eslint:recommended", "plugin:prettier/recommended"],
overrides: [
{
files: ["**/*.ts"],
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"prettier/@typescript-eslint",
"plugin:jest/recommended",
],
plugins: ["@typescript-eslint", "jest"],
rules: {
"@typescript-eslint/explicit-function-return-type": [
"warn",
{
allowExpressions: true,
},
],
"@typescript-eslint/no-unused-vars": "warn",
"@typescript-eslint/no-use-before-define": "off",
"no-console": "error",
// nededed for mixins to avoid unecessary warnings
"@typescript-eslint/no-empty-interface": "off",
},
},
],
}
26 changes: 0 additions & 26 deletions .eslintrc.json

This file was deleted.

1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text=auto eol=lf
21 changes: 12 additions & 9 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
title: ""
labels: ""
assignees: mattallty

---

**Describe the bug**
Expand All @@ -13,18 +12,22 @@ A clear and concise description of what the bug is.
**To Reproduce**
Steps to reproduce the behavior:

```js
// Javascript code to reproduce bug
```ts
// Javascript or Typescript code to reproduce bug
```

**Expected behavior**
A clear and concise description/output of what you expected to happen.

**Actual behavior**
A clear and concise description/output of what actually happens.

**Environment informations (please complete the following information):**
- OS: [e.g. Linux, Mac]
- OS version:
- Shell: [e.g. bash, zsh, fish]
- Caporal version: [e.g. 1.0.1]

- OS: [e.g. Linux, Mac]
- OS version:
- Shell: [e.g. bash, zsh, fish]
- Caporal version: [e.g. 1.0.1]

**Additional context**
Add any other context about the problem here.
8 changes: 4 additions & 4 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: ''
assignees: ''

title: ""
labels: ""
assignees: ""
---

**Is your feature request related to a problem? Please describe.**
Expand All @@ -22,3 +21,4 @@ Add any other context or screenshots about the feature request here.
**Would you be able to work on it and provide a pull request ?**

- [ ] Yes
- [ ] No
128 changes: 128 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
name: "Continous integration"

on:
pull_request:
branches:
- "**"

jobs:
run-tests:
runs-on: ${{ matrix.os }}

strategy:
matrix:
node: ["10", "12", "14"]
os: ["macos-latest", "ubuntu-latest", "windows-latest"]

name: "node ${{ matrix.node }} / ${{ matrix.os }}"
steps:
- uses: actions/checkout@v2

- name: Get npm cache directory
id: npm-cache
run: |
echo "::set-output name=dir::$(npm config get cache)"
# See https://github.com/actions/cache/blob/master/examples.md#node---npm
- name: Cache node modules
uses: actions/cache@v1
env:
cache-name: cache-node-modules
with:
path: ${{ steps.npm-cache.outputs.dir }}
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Setup Node.js v${{ matrix.node }} on ${{ matrix.os }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node }}

- name: Install dependencies
run: npm ci

# build before testing as some tests actually test the build
- name: Build
run: npm run build

- name: Lint
run: npm run lint

- name: Run tests
run: npm test

- name: Run dist tests
run: npm run test:dist

- name: Jest Annotations & Coverage
if: ${{ matrix.node == '12' && matrix.os == 'ubuntu-latest' }}
uses: mattallty/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

deploy-preview:
name: "Deploy preview website"
runs-on: ubuntu-latest
needs: run-tests
continue-on-error: true
if: ${{ github.event_name == 'pull_request' || github.ref != 'master' }}
steps:
- uses: actions/checkout@v2
- uses: amondnet/now-deployment@v2
id: now-deploy
with:
github-comment: false
zeit-token: ${{ secrets.ZEIT_TOKEN }}
now-args: ""
now-org-id: ${{ secrets.ZEIT_ORG_ID}}
now-project-id: ${{ secrets.ZEIT_PROJECT_ID}}

- uses: actions/setup-node@v1
with:
node-version: 12

- name: Install dependencies
run: npm ci

- name: Alias
id: caporal-preview
env:
NOW_ORG_ID: ${{ secrets.ZEIT_ORG_ID}}
NOW_PROJECT_ID: ${{ secrets.ZEIT_PROJECT_ID}}
run: |
clean_url=$(echo "${{ steps.now-deploy.outputs.preview-url }}" | cut -c9-)
clean_ref=$(basename "${{ github.head_ref }}")
clean_sha=$(echo "${{ github.sha }}" | cut -c1-7)
npm run now -- alias -A now.preview.json --token ${{ secrets.ZEIT_TOKEN }} set $clean_url ${clean_ref}.caporal.run
npm run now -- alias -A now.preview.json --token ${{ secrets.ZEIT_TOKEN }} set $clean_url ${clean_sha}.caporal.run
echo "::set-output name=url_ref::https://${clean_ref}.caporal.run"
echo "::set-output name=url_sha::https://${clean_sha}.caporal.run"
- uses: chrnorm/deployment-action@releases/v1
name: Create GitHub deployment for commit
id: commit-deployment
if: ${{ success() }}
with:
initial_status: success
token: ${{ secrets.GITHUB_TOKEN }}
target_url: ${{ steps.caporal-preview.outputs.url_sha }}
environment: Commit-preview

- uses: chrnorm/deployment-action@releases/v1
name: Create GitHub deployment for branch
id: branch-deployment
if: ${{ success() }}
with:
initial_status: success
token: ${{ secrets.GITHUB_TOKEN }}
target_url: ${{ steps.caporal-preview.outputs.url_ref }}
environment: Branch-preview

- name: comment PR
uses: unsplash/comment-on-pr@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
msg: ":rocket: Caporal website preview available at: ${{ steps.caporal-preview.outputs.url_ref }}"
check_for_duplicate_msg: true
15 changes: 15 additions & 0 deletions .github/workflows/cleanup.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: "Cleanup Duplicate CI workflows"
on:
schedule:
- cron: "*/15 * * * *"

jobs:
cancel-runs:
# Prevent forks from running this to be nice
if: ${{ github.repository == 'mattallty/Caporal.js' }}
runs-on: ubuntu-latest
steps:
- uses: n1hility/cancel-previous-runs@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
workflow: ci.yml
54 changes: 54 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Release
on:
push:
branches:
- master
- beta
- alpha
- next
- next-major
- 1.x
- 1.4.x
jobs:
release:
name: Release
runs-on: ubuntu-latest
needs: run-tests
steps:
- name: Checkout
uses: actions/checkout@v1
- name: Setup Node.js
uses: actions/setup-node@v1
with:
node-version: 12

- name: Get npm cache directory
id: npm-cache
run: |
echo "::set-output name=dir::$(npm config get cache)"
# See https://github.com/actions/cache/blob/master/examples.md#node---npm
- name: Cache node modules
uses: actions/cache@v1
env:
cache-name: cache-node-modules
with:
path: ${{ steps.npm-cache.outputs.dir }}
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install dependencies
run: npm ci

- name: Build
run: npm run build

- name: Test
run: npm run test

- name: Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npx semantic-release
13 changes: 11 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,16 @@ coverage
.idea/workspace.xml
.idea/tasks.xml
.idea/watcherTasks.xml
docs
docs-src
.DS_Store
docs/.vuepress/dist
docs/.vuepress/api-sidebar-relative.json
docs/.vuepress/api-sidebar.json
docs/.vuepress/public/assets/js/caporal.d.ts
docs/.vuepress/public/assets/js/@caporal
docs/api
local_tests
.idea
dist
*.tgz
.secret.md
.now
16 changes: 0 additions & 16 deletions .npmignore

This file was deleted.

1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
examples/hello.js
6 changes: 6 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
trailingComma: "all",
tabWidth: 2,
semi: false,
printWidth: 90,
}
Loading

0 comments on commit 5e3eb2f

Please sign in to comment.