Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(typescript): add typescript #511

Merged
merged 10 commits into from
Feb 9, 2023
Merged
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
40 changes: 35 additions & 5 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,39 +1,55 @@
module.exports = {
root: true,
parser: '@typescript-eslint/parser',
settings: {
'import/resolver': {
node: {
extensions: ['.js', '.ts'],
},
},
node: {
tryExtensions: ['.js', '.json', '.node', '.ts'],
},
},
extends: [
'airbnb-base',
'plugin:sonarjs/recommended',
'plugin:jest/all',
'eslint:recommended',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
],
plugins: [
'sonarjs',
'@typescript-eslint',
],
env: {
node: true,
},
ignorePatterns: ["expected"],
ignorePatterns: ['expected'],
rules: {
'jest/valid-describe': 0, // This rule does not exist anymore. It has been replaced by jest/valid-describe-callback
'jest/require-hook': 0, // This rule does not seem to be functional at this time (eslint-plugin-jest-25.2.2)
'jest/no-disabled-tests': 0,
'implicit-arrow-linebreak': 0,
'no-underscore-dangle': 0,
'import/extensions': 0,
'import/no-extraneous-dependencies': [
'error',
{
devDependencies: [
'.eslint-bin/*.js',
'test/**/*.js'
]
'test/**/*.js',
],
},
],
'no-multiple-empty-lines': [
'error',
{
max: 1,
maxBOF: 0,
maxEOF: 0
}
maxEOF: 0,
},
],
'no-console': 0,
'no-param-reassign': 0,
Expand All @@ -47,4 +63,18 @@ module.exports = {
'sonarjs/no-unused-collection': 0,
'sonarjs/prefer-immediate-return': 0,
},
overrides: [
{
files: ['*.js'],
rules: {
'@typescript-eslint/no-var-requires': 'off',
},
},
{
files: ['test/**'],
rules: {
'@typescript-eslint/no-empty-function': 'off',
},
},
],
};
26 changes: 23 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build and Test
name: Build, Test and Deploy
on:
pull_request:
push:
Expand Down Expand Up @@ -36,7 +36,7 @@ jobs:
needs: [lint]
strategy:
matrix:
node: [10, 14]
node: [10, 14, 16]
include:
- node: 14
withCoverage: ${{ true }}
Expand Down Expand Up @@ -69,11 +69,29 @@ jobs:
- name: Test postpack
run: yarn postpack

build:
name: Build
runs-on: ubuntu-latest
needs: [lint]
steps:
- name: Cancel previous running workflows
uses: fkirc/skip-duplicate-actions@master
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 14.17.6
- uses: actions/cache@v3
with:
path: '**/node_modules'
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock', '**/package.json') }}
- name: Build
run: yarn build

deploy:
name: Release package
runs-on: ubuntu-latest
timeout-minutes: 10
needs: [test]
needs: [build, test]
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/beta')
steps:
- uses: actions/checkout@v2
Expand All @@ -87,6 +105,8 @@ jobs:
with:
path: "**/node_modules"
key: ${{ runner.os }}-node_modules-${{ hashFiles('**/yarn.lock') }}
- name: Build
run: yarn build
- name: Get Semantic Release current version
id: semantic_version
run: |
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,6 @@ oclif.manifest.json

test-output/
.generated/

# Typescript
dist/
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## [3.0.12-beta.2](https://github.com/ForestAdmin/toolbelt/compare/v3.0.12-beta.1...v3.0.12-beta.2) (2023-02-08)

## [3.0.12-beta.1](https://github.com/ForestAdmin/toolbelt/compare/v3.0.11...v3.0.12-beta.1) (2023-02-08)

## [3.0.11](https://github.com/ForestAdmin/toolbelt/compare/v3.0.10...v3.0.11) (2023-02-03)


Expand Down
2 changes: 1 addition & 1 deletion bin/run
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env node

require('../src/index').run()
require('../dist/index').run()
.then(require('@oclif/command/flush'))
.catch(require('@oclif/errors/handle'));
4 changes: 4 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,9 @@ module.exports = {
'/.dependency-cruiser.js',
],

transform: {
'^.+\\.tsx?$': '@swc/jest',
},

testEnvironment: 'node',
};
25 changes: 17 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "forest-cli",
"description": "The Lumberjacks' toolbelt is the Forest CLI which makes easy to manage your back office application directly from the terminal.",
"version": "3.0.11",
"version": "3.0.12-beta.2",
"author": "Sandro Munda",
"contributors": [
"Arnaud Valensi <[email protected]>",
Expand Down Expand Up @@ -61,8 +61,12 @@
"@oclif/dev-cli": "1.22.2",
"@semantic-release/changelog": "6.0.1",
"@semantic-release/git": "10.0.1",
"@swc/core": "1.3.34",
"@swc/jest": "0.2.24",
"@types/jest": "27.0.2",
"eslint": "6.8.0",
"@typescript-eslint/eslint-plugin": "^5.9.1",
"@typescript-eslint/parser": "^5.9.1",
"eslint": "^8.6.0",
"eslint-config-airbnb-base": "14.0.0",
"eslint-config-oclif": "3.1.0",
"eslint-plugin-import": "2.25.2",
Expand All @@ -77,7 +81,9 @@
"nock": "13.0.4",
"rimraf": "3.0.2",
"semantic-release": "19.0.3",
"semantic-release-slack-bot": "3.5.2"
"semantic-release-slack-bot": "3.5.2",
"tsc-watch": "6.0.0",
"typescript": "^4.5.4"
},
"engines": {
"node": ">=8.0.0"
Expand All @@ -86,16 +92,16 @@
"/bin",
"/npm-shrinkwrap.json",
"/oclif.manifest.json",
"/src"
"/dist"
],
"homepage": "https://github.com/ForestAdmin/toolbelt",
"keywords": [
"forestadmin"
],
"license": "GPL-3.0",
"main": "src/index.js",
"main": "dist/index.js",
"oclif": {
"commands": "./src/commands",
"commands": "./dist/commands",
"bin": "forest",
"plugins": [
"@oclif/plugin-help",
Expand All @@ -110,11 +116,14 @@
},
"repository": "ForestAdmin/toolbelt",
"scripts": {
"lint": "./node_modules/eslint/bin/eslint.js ./*.js src test",
"lint": "eslint src test",
"prepare": "husky install",
"prepack": "oclif-dev manifest",
"postpack": "rm -f oclif.manifest.json",
"build": "tsc",
"build:watch": "tsc-watch --onSuccess 'yarn postbuild'",
"test": "jest --runInBand",
"test:coverage": "jest --runInBand --coverage"
"test:coverage": "jest --runInBand --coverage",
"postbuild": "cp -R src/services/dumper/templates dist/services/dumper/templates"
}
}
24 changes: 24 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"compilerOptions": {
"experimentalDecorators": true,
"target": "ES2020",
"allowJs": true,
"outDir": "./dist/",
"skipLibCheck": true,
"module": "CommonJS",
"moduleResolution": "Node",
"esModuleInterop": true,
"declaration": true,
"declarationMap": true,
"inlineSourceMap": true,
"noImplicitOverride": true,
"sourceMap": false,
"stripInternal": true
},
"include": ["./src/"],
"exclude": ["node_modules"],

"ts-node": {
"swc": true // For ultra fast compilation in dev mode
}
}
Loading