Skip to content

Commit

Permalink
feat: add typescript compilation utils
Browse files Browse the repository at this point in the history
Release-as: 1.0.0
  • Loading branch information
ValeraS authored Jan 13, 2025
1 parent 6cdd538 commit 2bbd140
Show file tree
Hide file tree
Showing 21 changed files with 8,449 additions and 0 deletions.
17 changes: 17 additions & 0 deletions .editorconfig
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
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist
15 changes: 15 additions & 0 deletions .eslintrc
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"
}
}
28 changes: 28 additions & 0 deletions .github/workflows/ci.yml
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
27 changes: 27 additions & 0 deletions .github/workflows/pr-title.yml
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
15 changes: 15 additions & 0 deletions .github/workflows/release.yml
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
12 changes: 12 additions & 0 deletions .gitignore
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-*
1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
npx nano-staged
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
registry=https://registry.npmjs.org
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
dist
CHANGELOG.md
CONTRIBUTING.md
1 change: 1 addition & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"@gravity-ui/prettier-config"
42 changes: 42 additions & 0 deletions README.md
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);
});
}
```
1 change: 1 addition & 0 deletions commitlint.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = {extends: ['@commitlint/config-conventional']};
Loading

0 comments on commit 2bbd140

Please sign in to comment.