-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add typescript compilation utils
Release-as: 1.0.0
- Loading branch information
Showing
21 changed files
with
8,449 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
indent_size = 4 | ||
indent_style = space | ||
insert_final_newline = true | ||
max_line_length = 100 | ||
trim_trailing_whitespace = true | ||
|
||
[{*.json,*.yaml,*.yml}] | ||
indent_size = 2 | ||
|
||
[*.md] | ||
max_line_length = 0 | ||
trim_trailing_whitespace = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"extends": [ | ||
"@gravity-ui/eslint-config", | ||
"@gravity-ui/eslint-config/server", | ||
"@gravity-ui/eslint-config/prettier", | ||
"@gravity-ui/eslint-config/import-order" | ||
], | ||
"root": true, | ||
"rules": { | ||
"import/consistent-type-specifier-style": ["error", "prefer-top-level"], | ||
"@typescript-eslint/prefer-ts-expect-error": "error", | ||
"@typescript-eslint/consistent-type-imports": ["error", {"prefer": "type-imports", "fixStyle": "separate-type-imports"}], | ||
"complexity": "off" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
name: CI | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
pull_request: | ||
branches: [main] | ||
|
||
jobs: | ||
verify_files: | ||
name: Verify Files | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- name: Setup Node | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20 | ||
cache: 'npm' | ||
- name: Install Packages | ||
run: npm ci | ||
- name: Lint Files | ||
run: npm run lint | ||
- name: Typecheck | ||
run: npm run typecheck |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
name: PR Title | ||
|
||
on: | ||
pull_request: | ||
types: | ||
- opened | ||
- synchronize | ||
- reopened | ||
- edited | ||
|
||
jobs: | ||
verify_title: | ||
name: Verify Title | ||
runs-on: ubuntu-latest | ||
if: ${{github.event.action != 'edited' || github.event.changes.title}} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Setup Node | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20 | ||
cache: npm | ||
- name: Install Packages | ||
run: npm ci | ||
- name: Run Commitlint | ||
run: echo "${{github.event.pull_request.title}}" | npx commitlint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
name: Release | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
|
||
jobs: | ||
release: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: gravity-ui/release-action@v1 | ||
with: | ||
github-token: ${{ secrets.GRAVITY_UI_BOT_GITHUB_TOKEN }} | ||
npm-token: ${{ secrets.GRAVITY_UI_BOT_NPM_TOKEN }} | ||
node-version: 18 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
.idea | ||
.vscode | ||
.history | ||
.DS_Store | ||
*.log | ||
|
||
node_modules | ||
|
||
/dist | ||
.cache* | ||
.tshy | ||
gravity-ui-gulp-utils-* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
npx nano-staged |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
registry=https://registry.npmjs.org |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
dist | ||
CHANGELOG.md | ||
CONTRIBUTING.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
"@gravity-ui/prettier-config" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# gulp-utils · [![npm package](https://img.shields.io/npm/v/@gravity-ui/gulp-utils)](https://www.npmjs.com/package/@gravity-ui/gulp-utils) [![CI](https://img.shields.io/github/actions/workflow/status/gravity-ui/gulp-utils/.github/workflows/ci.yml?label=CI&logo=github)](https://github.com/gravity-ui/gulp-utils/actions/workflows/ci.yml?query=branch:main) [![storybook](https://img.shields.io/badge/Storybook-deployed-ff4685)](https://preview.gravity-ui.com/gulp-utils/) | ||
|
||
Gulp utils for handling typescript compilation workflow. | ||
|
||
## Usage | ||
|
||
```ts | ||
import {src, dest} from 'gulp'; | ||
import {createTypescriptProject, addVirtualFile} from '@gravity-ui/gulp-utils'; | ||
|
||
async function compile() { | ||
const tsProject = await createTypescriptProject({ | ||
projectPath: 'path/to/project', // default, process.cwd | ||
configName: 'tsconfig.build.json', // default, tsconfig.json | ||
compilerOptions: { | ||
// allows rewrite compiler options from tsconfig.json, default {} | ||
declaration: true, | ||
}, | ||
ts: await import('my-typescript-package'), // default, 'typescript' | ||
}); | ||
|
||
return new Promise((resolve) => { | ||
src('src/**/*.ts') | ||
.pipe( | ||
tsProject({ | ||
customTransformers: { | ||
before: [...Object.values(tsProject.customTransformers)], | ||
afterDeclarations: [...Object.values(tsProject.customTransformers)], | ||
}, | ||
}), | ||
) | ||
.pipe( | ||
addVirtualFile({ | ||
fileName: 'package.json', | ||
text: JSON.stringify({type: 'commonjs'}), | ||
}), | ||
) | ||
.pipe(dest('build')) | ||
.on('end', resolve); | ||
}); | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = {extends: ['@commitlint/config-conventional']}; |
Oops, something went wrong.