Skip to content

Commit

Permalink
chore(force-release): add typescript (#492)
Browse files Browse the repository at this point in the history
  • Loading branch information
SteveBunlon authored Feb 8, 2023
1 parent 659d020 commit 1a1494e
Show file tree
Hide file tree
Showing 8 changed files with 1,796 additions and 1,402 deletions.
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',
},
},
],
};
41 changes: 35 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
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,17 +69,42 @@ 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: 16.14.0
- uses: actions/cache@v3
with:
path: '**/node_modules'
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock', '**/package.json') }}
- name: Build
run: yarn build
- name: Upload build
uses: actions/upload-artifact@v3
with:
name: build
path: |
/dist/*
package.json
/bin
/npm-shrinkwrap.json
/oclif.manifest.json
retention-days: 1

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
with:
ref: ${{ github.ref }}
persist-credentials: false # GITHUB_TOKEN must not be set for the semantic release
- uses: actions/setup-node@v2
with:
node-version: 14.17.6
Expand All @@ -92,6 +117,10 @@ jobs:
run: |
VERSION=`node -p "require('./package.json').devDependencies['semantic-release']"`
echo "::set-output name=version::$VERSION"
- name: Download build
uses: actions/download-artifact@v3
with:
name: build
- name: Semantic Release
uses: cycjimmy/semantic-release-action@767cc0b0cd610ffb1ffee1b36a9b39120adc5f80
id: semantic
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/
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',
};
23 changes: 16 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
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

0 comments on commit 1a1494e

Please sign in to comment.