Skip to content

Commit

Permalink
add release action
Browse files Browse the repository at this point in the history
  • Loading branch information
DiFuks committed Jun 20, 2024
1 parent 3f18489 commit b1a779c
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 64 deletions.
45 changes: 39 additions & 6 deletions .github/workflows/build-and-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ on: push
jobs:
build-and-publish:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./packages/plugin
env:
NPM_DIFUKS_TOKEN: ${{ secrets.NPM_DIFUKS_TOKEN }}
steps:
Expand All @@ -27,13 +30,10 @@ jobs:
run: yarn

- name: Build plugin
run: yarn build:plugin
run: yarn build

- name: Lint plugin
run: yarn lint:plugin

- name: Run example
run: yarn build:tspc
run: yarn lint

- name: Check packages versions
if: github.ref != 'refs/heads/main'
Expand All @@ -45,12 +45,45 @@ jobs:

- name: Publish package
if: github.ref == 'refs/heads/main'
run: yarn workspace ts-overrides-plugin npm publish --tolerate-republish
run: yarn npm publish --tolerate-republish

- uses: stefanzweifel/git-auto-commit-action@v5
if: github.ref == 'refs/heads/main'
with:
commit_message: |
ci: Release packages
[skip ci]
- name: Get package version
if: github.ref == 'refs/heads/main'
id: package-version
uses: martinbeentjes/[email protected]
with:
path: packages/plugin

- uses: stefanzweifel/git-auto-commit-action@v5
if: github.ref == 'refs/heads/main'
with:
tagging_message: v${{ steps.package-version.outputs.current-version }}
commit_message: |
ci: Release packages
[skip ci]
- name: Get pull request info
if: github.ref == 'refs/heads/main'
id: pull-request-info
uses: actions-ecosystem/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}

- uses: ncipollo/release-action@v1
id: create-release
if: github.ref == 'refs/heads/main'
with:
skipIfReleaseExists: true
makeLatest: true
name: Release ${{ steps.package-version.outputs.current-version }}
body: ${{ steps.pull-request-info.outputs.body }}
tag: v${{ steps.package-version.outputs.current-version }}
Empty file removed README.md
Empty file.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"watch:fork-ts": "yarn workspace example watch:fork-ts"
},
"devDependencies": {
"typescript": "5.2.2"
"typescript": "5.5.1-rc"
},
"packageManager": "[email protected]"
}
74 changes: 38 additions & 36 deletions packages/plugin/README.md
Original file line number Diff line number Diff line change
@@ -1,52 +1,59 @@
# ts-overrides-plugin

Плагин для `TypeScript`, который позволяет переопределять `tsconfig` для определенных файлов
A plugin for `TypeScript` that allows overriding `tsconfig` for specific files

[![typedoc-theme-hierarchy (latest)](https://img.shields.io/npm/v/ts-overrides-plugin)](https://www.npmjs.com/package/ts-overrides-plugin)
[![typedoc-theme-hierarchy (downloads)](https://img.shields.io/npm/dw/ts-overrides-plugin)](https://www.npmjs.com/package/ts-overrides-plugin)
[![typedoc-theme-hierarchy (stars)](https://img.shields.io/github/stars/difuks/ts-overrides-plugin?style=social)](https://github.com/DiFuks/ts-overrides-plugin)

## Зачем нужен?
## Why is it needed?

Самый популярный вариант использования – перевод проекта с `strict: false` на `strict: true`, но также подходит для
любых других случаев, когда нужно переопределить настройки `tsconfig` для определенных файлов.
The most popular use case is transitioning a project from `strict: false` to `strict: true`, but it can also be used for
any other cases where you need to override the `tsconfig` settings for specific files.

## Что умеет?
## What can it do?

- Переопределять диагностику для файлов в `IDE`
- Переопределять подсказки о типах при наведении на переменные в `IDE`
- Переопределять диагностику для файлов в `webpack`, `tsc` и других сборщиках, где можно использовать `ts-patch`
- Override diagnostics for files in the `IDE`
- Override type hints when hovering over variables in the `IDE`
- Override diagnostics for files in `webpack`, `tsc`, and other builders that use `ts-patch`

## Установка и настройка

Примеры можно увидеть в папке [`example`](https://github.com/DiFuks/ts-overrides-plugin/tree/main/packages/example).
## Known issues

### Для использования плагина только в IDE
- Paths in `tsconfig` should not start with `./`
- The plugin does not work in `WebStorm` when using `yarn pnp`
- Some issues may be caused by incompatibility of the latest TypeScript version with ts-patch. For example: [issue](https://github.com/nonara/ts-patch/issues/152), [issue](https://github.com/nonara/ts-patch/issues/140), [issue](https://github.com/nonara/ts-patch/issues/159)

Выполнить в терминале:
## Installation and setup

Examples can be seen in the [`example`](https://github.com/DiFuks/ts-overrides-plugin/tree/main/packages/example) folder.

### For using the plugin only in the IDE

Execute in the terminal:
```bash
yarn add -D ts-overrides-plugin
```

В файле `tsconfig.json` добавить:
In the `tsconfig.json` file, add:
```json5
{
"compilerOptions": {
"strict": false, // Настройки по умолчанию
"strict": false, // Default settings
"plugins": [
{
"name": "ts-overrides-plugin",
"config": {
"overrides": [
{
"files": ["src/modern/**/*.{ts,tsx}"], // Путь к файлам (glob), для которых нужно переопределить настройки. Не должен начинаться с './'
"compilerOptions": { // Настройки для этих файлов
"files": ["src/modern/**/*.{ts,tsx}"], // Path to files (glob) for which settings need to be overridden. Should not start with './'
"compilerOptions": { // Settings for these files
"strict": true
}
},
{
"files": ["src/legacy/**/*.{ts,tsx}"],
"compilerOptions": { // Настройки наследуются только от настроек по умолчанию
"compilerOptions": { // Settings are inherited only from the default settings
"strict": true,
"strictNullChecks": false
}
Expand All @@ -59,37 +66,37 @@ yarn add -D ts-overrides-plugin
}
```

### Для использования в `webpack`, `tsc`
### For use in `webpack`, `tsc`

Для корректной работы плагина в `webpack`, `tsc` необходимо использовать библиотеку [`ts-patch`](https://github.com/nonara/ts-patch).
For the plugin to work correctly in `webpack`, `tsc`, it's necessary to use the [`ts-patch`](https://github.com/nonara/ts-patch) library.

Выполнить в терминале:
Execute in the terminal:

```bash
yarn add -D ts-overrides-plugin ts-patch
```

В файле `tsconfig.json` добавить:
In the `tsconfig.json` file, add:

```json5
{
"compilerOptions": {
"strict": false, // Настройки по умолчанию
"strict": false, // Default settings
"plugins": [
{
"name": "ts-overrides-plugin",
"transform": "ts-overrides-plugin/cli",
"transformProgram": true,
"overrides": [
{
"files": ["src/modern/**/*.{ts,tsx}"], // Путь к файлам (glob), для которых нужно переопределить настройки. Не должен начинаться с './'
"compilerOptions": { // Настройки для этих файлов
"files": ["src/modern/**/*.{ts,tsx}"], // Path to files (glob) for which settings need to be overridden. Should not start with './'
"compilerOptions": { // Settings for these files
"strict": true,
},
},
{
"files": ["src/legacy/**/*.{ts,tsx}"],
"compilerOptions": { // Настройки наследуются только от настроек по умолчанию
"compilerOptions": { // Settings are inherited only from the default settings
"strict": true,
"strictNullChecks": false
}
Expand All @@ -101,11 +108,11 @@ yarn add -D ts-overrides-plugin ts-patch
}
```

Если вы используете [`Persistent Patch`](https://github.com/nonara/ts-patch?tab=readme-ov-file#method-2-persistent-patch)
в `ts-patch`, то больше ничего делать не нужно, если же [`Live Compiler`](https://github.com/nonara/ts-patch?tab=readme-ov-file#method-1-live-compiler), то
необходимо выполнить следующие действия:
If you are using [`Persistent Patch`](https://github.com/nonara/ts-patch?tab=readme-ov-file#method-2-persistent-patch)
with `ts-patch`, then there is nothing more to do. If, however, you are using [`Live Compiler`](https://github.com/nonara/ts-patch?tab=readme-ov-file#method-1-live-compiler), the
following steps are necessary:

Для команды `tsc` – заменить на `tspc` в `package.json`:
For the `tsc` command – replace it with `tspc` in `package.json`:

```json5
{
Expand All @@ -115,7 +122,7 @@ yarn add -D ts-overrides-plugin ts-patch
}
```

Для `ForkTsCheckerWebpackPlugin` в файле `webpack.config.js` добавить:
For `ForkTsCheckerWebpackPlugin` in the `webpack.config.js` file, add:

```js
const path = require('path');
Expand All @@ -131,7 +138,7 @@ module.exports = {
};
```

Для `ts-loader` в файле `webpack.config.js` добавить:
For `ts-loader` in the `webpack.config.js` file, add:

```js
const path = require('path');
Expand All @@ -151,8 +158,3 @@ module.exports = {
},
};
```

## Известные проблемы

- Пути в `tsconfig` не должны начинаться с `./`
- Плагин не работает в `WebStorm` при использовании `yarn pnp`
22 changes: 1 addition & 21 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6721,7 +6721,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "ts-overrides-plugin-sample@workspace:."
dependencies:
typescript: "npm:5.2.2"
typescript: "npm:5.5.1-rc"
languageName: unknown
linkType: soft

Expand Down Expand Up @@ -6865,16 +6865,6 @@ __metadata:
languageName: node
linkType: hard

"typescript@npm:5.2.2":
version: 5.2.2
resolution: "typescript@npm:5.2.2"
bin:
tsc: bin/tsc
tsserver: bin/tsserver
checksum: 10c0/91ae3e6193d0ddb8656d4c418a033f0f75dec5e077ebbc2bd6d76439b93f35683936ee1bdc0e9cf94ec76863aa49f27159b5788219b50e1cd0cd6d110aa34b07
languageName: node
linkType: hard

"typescript@npm:5.5.1-rc":
version: 5.5.1-rc
resolution: "typescript@npm:5.5.1-rc::__archiveUrl=https%3A%2F%2Fregistry.npmjs.org%2Ftypescript%2F-%2Ftypescript-5.5.1-rc.tgz"
Expand All @@ -6885,16 +6875,6 @@ __metadata:
languageName: node
linkType: hard

"typescript@patch:typescript@npm%3A5.2.2#optional!builtin<compat/typescript>":
version: 5.2.2
resolution: "typescript@patch:typescript@npm%3A5.2.2#optional!builtin<compat/typescript>::version=5.2.2&hash=f3b441"
bin:
tsc: bin/tsc
tsserver: bin/tsserver
checksum: 10c0/062c1cee1990e6b9419ce8a55162b8dc917eb87f807e4de0327dbc1c2fa4e5f61bc0dd4e034d38ff541d1ed0479b53bcee8e4de3a4075c51a1724eb6216cb6f5
languageName: node
linkType: hard

"typescript@patch:typescript@npm%3A5.5.1-rc#optional!builtin<compat/typescript>":
version: 5.5.1-rc
resolution: "typescript@patch:typescript@npm%3A5.5.1-rc%3A%3A__archiveUrl=https%253A%252F%252Fregistry.npmjs.org%252Ftypescript%252F-%252Ftypescript-5.5.1-rc.tgz#optional!builtin<compat/typescript>::version=5.5.1-rc&hash=b45daf"
Expand Down

0 comments on commit b1a779c

Please sign in to comment.