Skip to content

Commit

Permalink
Merge pull request #2 from Neosoulink/dev
Browse files Browse the repository at this point in the history
chore: setup & configs
  • Loading branch information
Neosoulink authored Jul 15, 2024
2 parents 068744c + 95d9cf1 commit bb27828
Show file tree
Hide file tree
Showing 116 changed files with 3,323 additions and 4,166 deletions.
8 changes: 8 additions & 0 deletions .changeset/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Changesets

Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
with multi-package repos, or single-package repos to help you version and publish your code. You can
find the full documentation for it [in our repository](https://github.com/changesets/changesets)

We have a quick list of common questions to get you started engaging with this project in
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)
11 changes: 11 additions & 0 deletions .changeset/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json",
"changelog": "@changesets/cli/changelog",
"commit": false,
"fixed": [],
"linked": [],
"access": "restricted",
"baseBranch": "master",
"updateInternalDependencies": "patch",
"ignore": []
}
8 changes: 8 additions & 0 deletions .changeset/famous-penguins-battle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"@chess-d/configs": minor
"@chess-d/api": minor
"api": minor
"web": minor
---

Base stable version with safe configs
10 changes: 0 additions & 10 deletions .eslintrc.js

This file was deleted.

5 changes: 5 additions & 0 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Summary

## Steps to reproduce

## Expected behavior
1 change: 1 addition & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Summary
12 changes: 12 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Please see the documentation for all configuration options:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: "npm"
directory: "/" # Location of package manifests
schedule:
interval: "weekly"
target-branch: "dev"
reviewers:
- "Neosoulink"
37 changes: 37 additions & 0 deletions .github/workflows/lint-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: "Lint PR"

on:
pull_request:
types:
- opened
- edited
- synchronize

jobs:
lint-title:
name: Validate PR Title
runs-on: ubuntu-latest
steps:
- uses: amannn/action-semantic-pull-request@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

check-scope:
name: Validate PR Scope
runs-on: ubuntu-latest

steps:
- name: Wrong Branch Scope
run: |
echo "Checking PR source and target branches"
PR_BASE_BRANCH=$(jq -r .pull_request.base.ref < "${GITHUB_EVENT_PATH}")
PR_HEAD_BRANCH=$(jq -r .pull_request.head.ref < "${GITHUB_EVENT_PATH}")
echo "PR Base Branch: $PR_BASE_BRANCH"
echo "PR Head Branch: $PR_HEAD_BRANCH"
if [ "$PR_BASE_BRANCH" == "master" ] && [ "$PR_HEAD_BRANCH" != "dev" ]; then
echo "Error: The branch '$PR_HEAD_BRANCH' should not point to the 'master' branch."
echo "Error: Please change the base branch to 'dev'."
exit 1
else
echo "Branch check passed."
fi
41 changes: 41 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Lint

on:
push:
branches:
- "**"

jobs:
lint:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Cache turbo build setup
uses: actions/cache@v4
with:
path: .turbo
key: ${{ runner.os }}-turbo-${{ github.sha }}
restore-keys: |
${{ runner.os }}-turbo-
- name: "Install PNPM"
uses: pnpm/action-setup@v4
with:
run_install: false

- name: Setup Node.js v20
uses: actions/setup-node@v4
with:
node-version: 20
registry-url: https://registry.npmjs.org
cache: "pnpm"

- name: "Install Dependencies"
shell: bash
run: pnpm install --frozen-lockfile

- name: Lint project
run: pnpm run lint && pnpm run build
55 changes: 55 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Releases

on:
workflow_run:
workflows: [Lint]
branches: [master]
types: [completed]

concurrency: ${{ github.workflow }}-${{ github.ref }}

permissions:
contents: write
pull-requests: write

jobs:
release:
if: ${{ github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-latest

steps:
- name: Checkout Repository Workflow
uses: actions/checkout@v4

- name: Cache turbo build setup
uses: actions/cache@v4
with:
path: .turbo
key: ${{ runner.os }}-turbo-${{ github.sha }}
restore-keys: |
${{ runner.os }}-turbo-
- name: "Install PNPM"
uses: pnpm/action-setup@v4
with:
run_install: false

- name: Setup Node.js v20
uses: actions/setup-node@v4
with:
node-version: 20
registry-url: https://registry.npmjs.org
cache: "pnpm"

- name: "Install Dependencies"
shell: bash
run: pnpm install --frozen-lockfile

- name: Create Release Pull Request or Release
uses: changesets/action@v1
with:
commit: "chore(version): upgrade packages"
title: "chore(version): upgrade packages"
createGithubReleases: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1 change: 1 addition & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
npx --no-install commitlint --edit "$1"
1 change: 1 addition & 0 deletions .husky/post-merge
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pnpm i
1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pnpm run format && pnpm run lint
11 changes: 11 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Testing
coverage

# Build Outputs
.next/
out/
build
dist
dist-ssr
lib
*.d.ts
2 changes: 1 addition & 1 deletion .prettierrc.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** @type {import("prettier").Config} */
module.exports = {
...require('@repo/eslint-config/prettier-base'),
...require('@chess-d/configs/prettier/base'),
};
9 changes: 0 additions & 9 deletions apps/api/.eslintrc.js

This file was deleted.

4 changes: 0 additions & 4 deletions apps/api/.prettierrc.js

This file was deleted.

27 changes: 27 additions & 0 deletions apps/api/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import path from "node:path";
import { fileURLToPath } from "node:url";
import js from "@eslint/js";
import { FlatCompat } from "@eslint/eslintrc";

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all
});

/** @type {import("eslint").Linter.Config} */
const configs = {
parserOptions: {
project: true
},
};

export default [
...compat.extends("./node_modules/@chess-d/configs/eslint/nest.js"),
{
files: ["./src/**/*.js?(x)", "./src/**/*.ts?(x)"],
languageOptions: configs
}
];
6 changes: 6 additions & 0 deletions apps/api/jest.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import configs from "@chess-d/configs/jest/nest.js";

/** @type {import('jest').Config} */
export default {
...configs
};
75 changes: 32 additions & 43 deletions apps/api/package.json
Original file line number Diff line number Diff line change
@@ -1,45 +1,34 @@
{
"name": "api",
"version": "0.0.0",
"private": true,
"scripts": {
"dev": "nest start --watch",
"build": "nest build",
"start": "nest start",
"start:debug": "nest start --debug --watch",
"start:prod": "node dist/main",
"test": "jest",
"test:watch": "jest --watch",
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
"test:e2e": "jest --config ./test/jest-e2e.json",
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\""
},
"dependencies": {
"@nestjs/common": "^10.0.0",
"@nestjs/core": "^10.0.0",
"@nestjs/platform-express": "^10.0.0",
"@repo/api": "workspace:*",
"reflect-metadata": "^0.2.0",
"rxjs": "^7.8.1"
},
"devDependencies": {
"@nestjs/cli": "^10.0.0",
"@nestjs/schematics": "^10.0.0",
"@nestjs/testing": "^10.0.0",
"@repo/eslint-config": "workspace:*",
"@repo/jest-config": "workspace:*",
"@repo/typescript-config": "workspace:*",
"@types/express": "^4.17.17",
"@types/jest": "^29.5.2",
"@types/node": "^20.3.1",
"@types/supertest": "^6.0.0",
"jest": "^29.5.0",
"source-map-support": "^0.5.21",
"supertest": "^6.3.3",
"ts-jest": "^29.1.0",
"ts-loader": "^9.4.3",
"ts-node": "^10.9.1",
"tsconfig-paths": "^4.2.0",
"typescript": "^5.1.3"
}
"name": "api",
"version": "0.0.0",
"private": true,
"scripts": {
"dev": "nest start --watch",
"build": "nest build",
"start": "nest start",
"start:debug": "nest start --debug --watch",
"start:prod": "node dist/main",
"test": "jest",
"test:watch": "jest --watch",
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
"test:e2e": "jest --config ./test/jest-e2e.json",
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\""
},
"dependencies": {
"@nestjs/common": "^10.0.0",
"@nestjs/core": "^10.0.0",
"@nestjs/platform-express": "^10.0.0",
"@chess-d/api": "workspace:*",
"reflect-metadata": "^0.2.0",
"rxjs": "^7.8.1"
},
"devDependencies": {
"@chess-d/configs": "workspace:*",
"@nestjs/cli": "^10.0.0",
"@nestjs/schematics": "^10.0.0",
"@nestjs/testing": "^10.0.0",
"source-map-support": "^0.5.21",
"supertest": "^6.3.3",
"tsconfig-paths": "^4.2.0"
}
}
34 changes: 17 additions & 17 deletions apps/api/src/app.controller.spec.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
import { Test, TestingModule } from '@nestjs/testing';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { Test, TestingModule } from "@nestjs/testing";
import { AppController } from "./app.controller";
import { AppService } from "./app.service";

describe('AppController', () => {
let appController: AppController;
describe("AppController", () => {
let appController: AppController;

beforeEach(async () => {
const app: TestingModule = await Test.createTestingModule({
controllers: [AppController],
providers: [AppService],
}).compile();
beforeEach(async () => {
const app: TestingModule = await Test.createTestingModule({
controllers: [AppController],
providers: [AppService]
}).compile();

appController = app.get<AppController>(AppController);
});
appController = app.get<AppController>(AppController);
});

describe('root', () => {
it('should return "Hello World!"', () => {
expect(appController.getHello()).toBe('Hello World!');
});
});
describe("root", () => {
it("should return 'Hello World!'", () => {
expect(appController.getHello()).toBe("Hello World!");
});
});
});
Loading

0 comments on commit bb27828

Please sign in to comment.