Refactor to typescript (config part)

pull/226/head
Webber Takken 2021-03-08 00:57:41 +01:00
parent 0934b3f408
commit 6d3fde10d7
17 changed files with 1914 additions and 1847 deletions

View File

@ -2,4 +2,4 @@
* *
# Files required for the action # Files required for the action
!action/ !dist/

View File

@ -6,7 +6,7 @@ end_of_line = lf
indent_size = 2 indent_size = 2
indent_style = space indent_style = space
insert_final_newline = true insert_final_newline = true
max_line_length = 100 max_line_length = 120
tab_width = 2 tab_width = 2
trim_trailing_whitespace = true trim_trailing_whitespace = true

View File

@ -1,2 +1,4 @@
**/node_modules/** dist/
**/action/** lib/
node_modules/
jest.config.js

View File

@ -1,21 +1,20 @@
{ {
"parser": "babel-eslint", "plugins": ["jest", "@typescript-eslint", "prettier", "unicorn"],
"extends": ["plugin:unicorn/recommended", "plugin:github/recommended", "prettier"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 9,
"sourceType": "module",
"project": "./tsconfig.json"
},
"env": { "env": {
"node": true, "node": true,
"es6": true, "es6": true,
"jest": true "jest/globals": true
}, },
"parserOptions": {
"ecmaVersion": 2020,
"ecmaFeatures": {
"impliedStrict": true
}
},
"extends": ["airbnb", "plugin:unicorn/recommended", "prettier"],
"plugins": ["react", "jsx-a11y", "import", "prettier", "flowtype", "unicorn"],
"settings": { "react": { "version": "latest" } },
"rules": { "rules": {
"prettier/prettier": "error", "prettier/prettier": "error",
"import/no-extraneous-dependencies": 0 "import/no-extraneous-dependencies": 0,
"import/no-namespace": "off"
} }
} }

3
.gitattributes vendored 100644
View File

@ -0,0 +1,3 @@
dist/index* -diff linguist-generated=true
dist/licenses* -diff linguist-generated=true
dist/sourcemap* -diff linguist-generated=true

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
.idea .idea
node_modules node_modules
coverage/ coverage/
lib/

View File

@ -1,2 +1,2 @@
**/node_modules/** **/node_modules/**
**/action/** **/dist/**

View File

@ -2,5 +2,5 @@
"semi": true, "semi": true,
"singleQuote": true, "singleQuote": true,
"trailingComma": "all", "trailingComma": "all",
"printWidth": 100 "printWidth": 120
} }

View File

@ -1,3 +1,3 @@
save-prefix "" save-prefix "^"
--install.audit true --install.audit true
--add.audit true --add.audit true

View File

@ -117,4 +117,4 @@ branding:
color: 'gray-dark' color: 'gray-dark'
runs: runs:
using: 'node12' using: 'node12'
main: 'action/index.js' main: 'dist/index.js'

View File

@ -1,15 +0,0 @@
const esModules = ['lodash-es'].join('|');
module.exports = {
ignore: [`/node_modules/(?!${esModules})`],
presets: [
[
'@babel/preset-env',
{
targets: {
node: true,
},
},
],
],
};

View File

@ -1,9 +1,12 @@
const esModules = ['lodash-es'].join('|');
module.exports = { module.exports = {
clearMocks: true,
moduleFileExtensions: ['js', 'ts'],
testEnvironment: 'node', testEnvironment: 'node',
moduleFileExtensions: ['js', 'jsx', 'json', 'vue'], testMatch: ['**/*.test.ts'],
transform: { '^.+\\.(js|jsx)?$': 'babel-jest' }, testRunner: 'jest-circus/runner',
transformIgnorePatterns: [`/node_modules/(?!${esModules})`], transform: {
setupFilesAfterEnv: ['./src/jest.setup.js'], '^.+\\.ts$': 'ts-jest'
}; },
setupFilesAfterEnv: ['./src/jest.setup.ts'],
verbose: true
}

View File

@ -1,54 +1,55 @@
{ {
"name": "unity-builder", "name": "unity-builder",
"version": "0.5.0", "version": "2.0.0",
"description": "Build Unity projects for different platforms.", "description": "Build Unity projects for different platforms.",
"main": "action/index.js", "main": "dist/index.js",
"repository": "git@github.com:webbertakken/unity-builder.git", "repository": "git@github.com:webbertakken/unity-builder.git",
"author": "Webber <webber@takken.io>", "author": "Webber <webber@takken.io>",
"license": "MIT", "license": "MIT",
"scripts": { "scripts": {
"prebuild": "yarn", "prebuild": "yarn",
"build": "ncc build src --out action --minify", "build": "tsc && ncc build --source-map --license licenses.txt",
"lint": "prettier --check \"src/**/*.js\" && eslint src", "lint": "prettier --check \"src/**/*.{js,ts}\" && eslint src/**/*.ts",
"format": "prettier --write \"src/**/*.js\"", "format": "prettier --write \"src/**/*.{js,ts}\"",
"test": "jest" "test": "jest"
}, },
"dependencies": { "dependencies": {
"@actions/core": "^1.2.6", "@actions/core": "^1.2.6",
"@actions/exec": "1.0.4", "@actions/exec": "^1.0.4",
"@actions/github": "^2.1.1", "@actions/github": "^2.2.0",
"base-64": "^0.1.0", "base-64": "^1.0.0",
"kubernetes-client": "^9.0.0", "kubernetes-client": "^9.0.0",
"semver": "^7.3.2" "semver": "^7.3.2"
}, },
"devDependencies": { "devDependencies": {
"@babel/cli": "7.8.4", "@types/jest": "^26.0.15",
"@babel/core": "7.9.6", "@types/node": "^14.14.9",
"@babel/preset-env": "7.9.6", "@types/semver": "^7.3.4",
"@zeit/ncc": "0.22.1", "@typescript-eslint/parser": "^4.8.1",
"babel-eslint": "10.1.0", "@vercel/ncc": "^0.25.1",
"eslint": "6.8.0", "eslint": "^7.17.0",
"eslint-config-airbnb": "18.1.0", "eslint-config-prettier": "^8.1.0",
"eslint-config-prettier": "6.11.0", "eslint-plugin-github": "^4.1.1",
"eslint-plugin-flowtype": "4.7.0", "eslint-plugin-jest": "^24.1.3",
"eslint-plugin-import": "2.20.2", "eslint-plugin-prettier": "^3.3.1",
"eslint-plugin-jsx-a11y": "6.2.3", "eslint-plugin-unicorn": "^28.0.2",
"eslint-plugin-prettier": "3.1.3",
"eslint-plugin-react": "7.19.0",
"eslint-plugin-unicorn": "19.0.1",
"husky": "4.2.5", "husky": "4.2.5",
"jest": "25.5.3", "jest": "^26.6.3",
"lint-staged": "10.2.2", "jest-circus": "^26.6.3",
"lodash-es": "4.17.15", "js-yaml": "^3.14.0",
"prettier": "2.0.5" "lint-staged": "^10.5.4",
"lodash-es": "^4.17.21",
"prettier": "^2.2.1",
"ts-jest": "^26.4.4",
"typescript": "^4.1.3"
}, },
"husky": { "husky": {
"hooks": { "hooks": {
"pre-commit": "lint-staged && yarn build && git add action/index.js" "pre-commit": "lint-staged && yarn build && git add dist/index.*"
} }
}, },
"lint-staged": { "lint-staged": {
"*.{js,jsx}": [ "*.{js,jsx,ts,tsx}": [
"prettier --write", "prettier --write",
"eslint", "eslint",
"git add", "git add",

View File

@ -1,8 +1,9 @@
import * as core from '@actions/core';
// @ts-ignore
import { Action, BuildParameters, Cache, Docker, ImageTag, Kubernetes, Output } from './model'; import { Action, BuildParameters, Cache, Docker, ImageTag, Kubernetes, Output } from './model';
const core = require('@actions/core'); async function run() {
async function action() {
Action.checkCompatibility(); Action.checkCompatibility();
Cache.verify(); Cache.verify();
@ -24,6 +25,6 @@ async function action() {
await Output.setBuildVersion(buildParameters.buildVersion); await Output.setBuildVersion(buildParameters.buildVersion);
} }
action().catch((error) => { run().catch((error) => {
core.setFailed(error.message); core.setFailed(error.message);
}); });

12
tsconfig.json 100644
View File

@ -0,0 +1,12 @@
{
"compilerOptions": {
"target": "es6", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
"outDir": "./lib", /* Redirect output structure to the directory. */
"rootDir": "./src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
"strict": true, /* Enable all strict type-checking options. */
"noImplicitAny": false, /* Re-enable after fixing compatibility */ /* Raise error on expressions and declarations with an implied 'any' type. */
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
},
"exclude": ["node_modules", "**/*.test.ts"]
}

3606
yarn.lock

File diff suppressed because it is too large Load Diff