Skip to content

Commit a52f603

Browse files
committed
feat: add auto release
1 parent 2e61524 commit a52f603

24 files changed

+3642
-156
lines changed

.eslintrc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"extends": ["@rpidanny/eslint-config-typescript"],
3+
"rules": {
4+
"simple-import-sort/imports": "error",
5+
"simple-import-sort/exports": "error",
6+
"arrow-parens": "off"
7+
},
8+
"parserOptions": {
9+
"ecmaFeatures": {
10+
"jsx": true,
11+
"tsx": true
12+
}
13+
}
14+
}

.eslintrc.js

Lines changed: 0 additions & 28 deletions
This file was deleted.

.github/workflows/ci.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches-ignore:
6+
- 'main'
7+
workflow_dispatch:
8+
9+
jobs:
10+
build-and-test:
11+
name: Build and Test
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- uses: actions/checkout@v3
16+
17+
- uses: actions/setup-node@v3
18+
with:
19+
node-version: 18
20+
cache: 'npm'
21+
22+
- name: Install
23+
run: yarn install --frozen-lockfile
24+
25+
- name: Lint
26+
run: yarn lint
27+
28+
- name: Build
29+
run: yarn build
30+
31+
- name: Test
32+
run: yarn test

.github/workflows/release.yml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: 'Release'
2+
3+
on:
4+
push:
5+
branches:
6+
- 'main'
7+
8+
env:
9+
NODE_VERSION: 18
10+
11+
jobs:
12+
build-test:
13+
name: Build and Test
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Clone Repo
17+
uses: actions/checkout@v3
18+
19+
- uses: actions/setup-node@v3
20+
with:
21+
node-version: ${{env.NODE_VERSION}}
22+
cache: 'npm'
23+
24+
- name: Install
25+
run: yarn install --frozen-lockfile
26+
27+
- name: Lint
28+
run: yarn lint
29+
30+
- name: Build
31+
run: yarn build
32+
33+
- name: Test
34+
run: yarn test
35+
36+
newRelease:
37+
name: Create New Release
38+
needs: [build-test]
39+
runs-on: ubuntu-latest
40+
permissions:
41+
contents: write
42+
issues: write
43+
pull-requests: write
44+
steps:
45+
- uses: actions/checkout@v3
46+
47+
- uses: actions/setup-node@v3
48+
with:
49+
node-version: ${{env.NODE_VERSION}}
50+
cache: 'npm'
51+
52+
- name: Install
53+
run: yarn install --frozen-lockfile
54+
55+
- name: Lint
56+
run: yarn lint
57+
58+
- name: Build
59+
run: yarn build
60+
61+
- name: Release
62+
run: yarn release
63+
env:
64+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
65+
NPM_TOKEN: ${{secrets.GITHUB_TOKEN}}
66+
CI: true

.husky/commit-msg

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env sh
2+
. "$(dirname -- "$0")/_/husky.sh"
3+
4+
npx --no-install commitlint --edit "$1"

.husky/pre-commit

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env sh
2+
. "$(dirname -- "$0")/_/husky.sh"
3+
4+
npx lint-staged

.releaserc

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
{
2+
"branches": [
3+
"main",
4+
{
5+
"name": "beta",
6+
"prerelease": true
7+
},
8+
{
9+
"name": "alpha",
10+
"prerelease": true
11+
}
12+
],
13+
"plugins": [
14+
[
15+
"@semantic-release/commit-analyzer",
16+
{
17+
"preset": "conventionalcommits",
18+
"releaseRules": [
19+
{
20+
"type": "docs",
21+
"scope": "README",
22+
"release": "patch"
23+
},
24+
{
25+
"type": "refactor",
26+
"release": "patch"
27+
},
28+
{
29+
"type": "style",
30+
"release": "patch"
31+
}
32+
],
33+
"parserOpts": {
34+
"noteKeywords": [
35+
"BREAKING CHANGE",
36+
"BREAKING CHANGES"
37+
]
38+
}
39+
}
40+
],
41+
[
42+
"@semantic-release/release-notes-generator",
43+
{
44+
"preset": "conventionalcommits"
45+
}
46+
],
47+
"@semantic-release/changelog",
48+
[
49+
"@semantic-release/npm",
50+
{
51+
"npmPublish": false
52+
}
53+
],
54+
[
55+
"@semantic-release/github",
56+
{
57+
"assets": []
58+
}
59+
],
60+
[
61+
"@semantic-release/git",
62+
{
63+
"assets": [
64+
"docs",
65+
"CHANGELOG",
66+
"CHANGELOG.md",
67+
"package.json",
68+
"yarn.lock",
69+
"README.md"
70+
],
71+
"message": "chore(release): ${nextRelease.version} \n\n${nextRelease.notes}"
72+
}
73+
]
74+
]
75+
}

commitlint.config.cjs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
'use strict';
2+
3+
module.exports = { extends: ['@commitlint/config-conventional'] };

jest.config.ts

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
// import type { Config } from 'jest';
2+
import { defaults } from 'jest-config';
3+
import type { JestConfigWithTsJest } from 'ts-jest';
4+
5+
const config: JestConfigWithTsJest = {
6+
preset: 'ts-jest/presets/default-esm',
7+
extensionsToTreatAsEsm: ['.ts'],
8+
moduleNameMapper: {
9+
'^(\\.{1,2}/.*)\\.js$': '$1',
10+
},
11+
moduleFileExtensions: ['js', 'json', 'ts'],
12+
rootDir: '.',
13+
testRegex: defaults.testRegex,
14+
transform: {
15+
'^.+\\.(t|j)s$': [
16+
'ts-jest',
17+
{
18+
useESM: true,
19+
tsconfig: '<rootDir>/test/tsconfig.json',
20+
},
21+
],
22+
},
23+
testEnvironment: 'jest-environment-node',
24+
testPathIgnorePatterns: [
25+
'<rootDir>/src/client',
26+
'<rootDir>/dist/',
27+
'<rootDir>/tmp/',
28+
'<rootDir>/node_modules/',
29+
'<rootDir>/local_tests/',
30+
],
31+
testTimeout: 20_000,
32+
// setupFiles: ['<rootDir>/test/helpers/init.js'],
33+
// collectCoverageFrom: ['**/*.(t|j)s'],
34+
collectCoverageFrom: ['<rootDir>/src/**/*.(t|j)s'],
35+
coverageDirectory: '<rootDir>/coverage',
36+
coverageReporters: [['lcov', { projectRoot: './' }], 'text'],
37+
coveragePathIgnorePatterns: [
38+
'<rootDir>/node_modules/',
39+
'<rootDir>/test/',
40+
'<rootDir>/dist/',
41+
'<rootDir>/tmp/',
42+
'<rootDir>/local_tests/',
43+
'<rootDir>/coverage/',
44+
'<rootDir>/src/utils/ui/',
45+
'<rootDir>/src/client/',
46+
],
47+
coverageThreshold: {
48+
global: {
49+
statements: 82,
50+
branches: 62,
51+
functions: 77,
52+
lines: 82,
53+
},
54+
},
55+
};
56+
57+
export default config;

package.json

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
{
22
"name": "chatgpt-browser-api-proxy",
3-
"version": "0.0.1",
4-
"description": "",
5-
"author": "",
3+
"version": "0.0.0",
4+
"description": "A powerful API proxy that seamlessly integrates ChatGPT unofficial browser API with OpenAI, bypassing CloudFlare's anti-bot detection for uninterrupted access.",
5+
"author": "abhishek <@rpidanny>",
66
"private": true,
7-
"license": "UNLICENSED",
7+
"license": "MIT",
88
"type": "module",
9+
"lint-staged": {
10+
"*.ts": [
11+
"yarn lint"
12+
]
13+
},
914
"scripts": {
1015
"build": "nest build",
1116
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
@@ -18,7 +23,8 @@
1823
"test:watch": "jest --watch",
1924
"test:cov": "jest --coverage",
2025
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
21-
"test:e2e": "jest --config ./test/jest-e2e.json"
26+
"test:e2e": "jest --config ./test/jest-e2e.json",
27+
"release": "semantic-release"
2228
},
2329
"dependencies": {
2430
"@nestjs/common": "^9.0.0",
@@ -33,45 +39,40 @@
3339
"rxjs": "^7.2.0"
3440
},
3541
"devDependencies": {
42+
"@commitlint/cli": "^17.6.3",
43+
"@commitlint/config-conventional": "^17.6.3",
3644
"@nestjs/cli": "^9.0.0",
3745
"@nestjs/schematics": "^9.0.0",
3846
"@nestjs/testing": "^9.0.0",
3947
"@rpidanny/eslint-config-typescript": "^1.1.0",
48+
"@semantic-release/changelog": "^6.0.3",
49+
"@semantic-release/commit-analyzer": "^9.0.2",
50+
"@semantic-release/git": "^10.0.1",
51+
"@semantic-release/github": "^8.0.7",
52+
"@semantic-release/npm": "^10.0.3",
53+
"@semantic-release/release-notes-generator": "^11.0.1",
4054
"@types/express": "^4.17.13",
4155
"@types/jest": "29.5.0",
4256
"@types/node": "18.15.11",
4357
"@types/supertest": "^2.0.11",
4458
"@typescript-eslint/eslint-plugin": "^5.0.0",
4559
"@typescript-eslint/parser": "^5.0.0",
60+
"commitlint": "^17.6.3",
4661
"eslint": "^8.0.1",
4762
"eslint-config-prettier": "^8.3.0",
4863
"eslint-plugin-prettier": "^4.0.0",
4964
"eslint-plugin-simple-import-sort": "^10.0.0",
65+
"husky": "^8.0.3",
5066
"jest": "29.5.0",
67+
"lint-staged": "^13.2.2",
5168
"prettier": "^2.3.2",
69+
"semantic-release": "^21.0.2",
5270
"source-map-support": "^0.5.20",
5371
"supertest": "^6.1.3",
5472
"ts-jest": "29.0.5",
5573
"ts-loader": "^9.2.3",
5674
"ts-node": "^10.0.0",
5775
"tsconfig-paths": "4.2.0",
5876
"typescript": "^4.7.4"
59-
},
60-
"jest": {
61-
"moduleFileExtensions": [
62-
"js",
63-
"json",
64-
"ts"
65-
],
66-
"rootDir": "src",
67-
"testRegex": ".*\\.spec\\.ts$",
68-
"transform": {
69-
"^.+\\.(t|j)s$": "ts-jest"
70-
},
71-
"collectCoverageFrom": [
72-
"**/*.(t|j)s"
73-
],
74-
"coverageDirectory": "../coverage",
75-
"testEnvironment": "node"
7677
}
7778
}

src/app.module.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import {
66
} from '@nestjs/common';
77
import { ConfigModule } from '@nestjs/config';
88

9-
import { CompletionModule } from './completion/completion.module.js';
109
import { ChatModule } from './chat/chat.module.js';
10+
import { CompletionModule } from './completion/completion.module.js';
1111
import { GlobalModule } from './global/global.module.js';
1212
import { RequestLoggerMiddleware } from './global/middlewares/request-logger.js';
1313

src/chat/chat.controller.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Test, TestingModule } from '@nestjs/testing';
2+
23
import { ChatController } from './chat.controller.js';
34
import { ChatService } from './chat.service.js';
45

0 commit comments

Comments
 (0)