diff --git a/mate-scripts/configs/reactTypescript/.github/workflows/check-types.yml-template b/mate-scripts/configs/reactTypescript/.github/workflows/check-types.yml-template new file mode 100644 index 0000000..ebb671c --- /dev/null +++ b/mate-scripts/configs/reactTypescript/.github/workflows/check-types.yml-template @@ -0,0 +1,23 @@ +name: Check Types + +on: + pull_request: + branches: [ master ] + +jobs: + run_linter: + + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [20.x] + + steps: + - uses: actions/checkout@v2 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node-version }} + - run: npm install + - run: npm run check:types diff --git a/mate-scripts/configs/typescript/.github/workflows/check-types.yml-template b/mate-scripts/configs/typescript/.github/workflows/check-types.yml-template new file mode 100644 index 0000000..ebb671c --- /dev/null +++ b/mate-scripts/configs/typescript/.github/workflows/check-types.yml-template @@ -0,0 +1,23 @@ +name: Check Types + +on: + pull_request: + branches: [ master ] + +jobs: + run_linter: + + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [20.x] + + steps: + - uses: actions/checkout@v2 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node-version }} + - run: npm install + - run: npm run check:types diff --git a/mate-scripts/configs/vueTypescript/workflows/check-types.yml-template b/mate-scripts/configs/vueTypescript/workflows/check-types.yml-template new file mode 100644 index 0000000..ebb671c --- /dev/null +++ b/mate-scripts/configs/vueTypescript/workflows/check-types.yml-template @@ -0,0 +1,23 @@ +name: Check Types + +on: + pull_request: + branches: [ master ] + +jobs: + run_linter: + + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [20.x] + + steps: + - uses: actions/checkout@v2 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node-version }} + - run: npm install + - run: npm run check:types diff --git a/mate-scripts/package.json b/mate-scripts/package.json index 38e4d67..3d94de8 100644 --- a/mate-scripts/package.json +++ b/mate-scripts/package.json @@ -8,6 +8,7 @@ "lint": "eslint ./src", "test": "echo \"Error: no test specified\" && exit 1", "build": "rm -rf ./bin && rollup -c && node ./shebangify.js && chmod +x ./bin/mateScripts.js", + "build:windows": "rollup -c && node ./shebangify.js", "prepublishOnly": "npm run build", "postpublish": "rm -rf ./bin", "patch": "npm version patch && npm publish", diff --git a/mate-scripts/src/commands/CheckTypes.command.ts b/mate-scripts/src/commands/CheckTypes.command.ts new file mode 100644 index 0000000..e434a31 --- /dev/null +++ b/mate-scripts/src/commands/CheckTypes.command.ts @@ -0,0 +1,31 @@ +import { Command } from './Command'; +import {execBashCodeSilent} from "../tools"; + +export type CheckTypesOptions = Record; + +export class CheckTypesCommand extends Command { + protected common(): void { + // do nothing + } + + protected reactTypescript = (options: CheckTypesOptions) => { + this.checkTypes(); + }; + + + protected vueTypescript = (options: CheckTypesOptions) => { + this.checkTypes(); + }; + + + protected typescript = (options: CheckTypesOptions) => { + this.checkTypes(); + }; + + private checkTypes() { + execBashCodeSilent( + `${this.binDir}tsc --no-emit`, + ); + } + +} diff --git a/mate-scripts/src/commands/index.ts b/mate-scripts/src/commands/index.ts index 9b86791..1fa7260 100644 --- a/mate-scripts/src/commands/index.ts +++ b/mate-scripts/src/commands/index.ts @@ -7,3 +7,4 @@ export * from './Build.command'; export * from './Deploy.command'; export * from './Update.command'; export * from './Migrate.command'; +export * from './CheckTypes.command'; diff --git a/mate-scripts/src/index.ts b/mate-scripts/src/index.ts index 7e92048..d61a44a 100644 --- a/mate-scripts/src/index.ts +++ b/mate-scripts/src/index.ts @@ -10,6 +10,7 @@ import { TestCommand, UpdateCommand, MigrateCommand, + CheckTypesCommand, } from './commands'; import { deployController, @@ -50,6 +51,11 @@ program .description('lint html, css and js files') .action(commandFactory.make(LintCommand, lintController)); +program + .command('check:types') + .description('validates TS types') + .action(commandFactory.make(CheckTypesCommand)); + program .command('test') .option('-n, --not-open', 'should open test report in browser', false)