Skip to content

Commit

Permalink
Configure project (#2)
Browse files Browse the repository at this point in the history
* Add chakra-ui
* Add build workflow
* Add prettier and audit workflow
* Add test
* Update setup-node version
* Move test folder to the right place
* Add components and test
  • Loading branch information
sboh1214 authored Sep 6, 2021
1 parent 719c961 commit a671ac0
Show file tree
Hide file tree
Showing 18 changed files with 6,818 additions and 1,786 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module.exports = {
extends: "next/core-web-vitals",
extends: ["next/core-web-vitals", "prettier"],
};
40 changes: 40 additions & 0 deletions .github/workflows/audit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Audit

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
audit:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Use Node.js LTS
uses: actions/setup-node@v2
with:
node-version: lts/*

- name: Get npm cache directory
id: npm-cache-dir
run: |
echo "::set-output name=dir::$(npm config get cache)"
- uses: actions/cache@v2
id: npm-cache # use this to check for `cache-hit` ==> if: steps.npm-cache.outputs.cache-hit != 'true'
with:
path: ${{ steps.npm-cache-dir.outputs.dir }}
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install
run: npm install

- name: Format
run: npm run format:check

- name: Lint
run: npm run lint
41 changes: 41 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Build

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [12.x, 14.x, 16.x]

steps:
- uses: actions/checkout@v2

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}

- name: Get npm cache directory
id: npm-cache-dir
run: |
echo "::set-output name=dir::$(npm config get cache)"
- uses: actions/cache@v2
id: npm-cache # use this to check for `cache-hit` ==> if: steps.npm-cache.outputs.cache-hit != 'true'
with:
path: ${{ steps.npm-cache-dir.outputs.dir }}
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install
run: npm install

- name: Build
run: npm run build
37 changes: 37 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Test

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
test:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Use Node.js LTS
uses: actions/setup-node@v2
with:
node-version: lts/*

- name: Get npm cache directory
id: npm-cache-dir
run: |
echo "::set-output name=dir::$(npm config get cache)"
- uses: actions/cache@v2
id: npm-cache # use this to check for `cache-hit` ==> if: steps.npm-cache.outputs.cache-hit != 'true'
with:
path: ${{ steps.npm-cache-dir.outputs.dir }}
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install
run: npm install

- name: Test
run: npm run test
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.next
coverage
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<img src="./public/logo.png" width=256 height=256 />

[![License](https://img.shields.io/badge/Licence-GPLv3-blue.svg)](https://github.com/utilForever/Cubby/blob/main/LICENSE)
[![License](https://img.shields.io/badge/Licence-GPLv3-blue.svg)](https://github.com/utilForever/Cubby/blob/main/LICENSE)

CubbyAdmin is a voxel-based MMORPG admin web page using Next.js.

Expand Down Expand Up @@ -34,9 +34,9 @@ The class is licensed under the [GNU General Public License v3.0 License](http:/

Copyright &copy; 2021 Cubby Team

* [Chris Ohk](https://github.com/utilForever)
* [Seungoh Han](https://github.com/h5jam)
* [Jaeyong Sung](https://github.com/buttercrab)
* [Seungbin Oh](https://github.com/sboh1214)
- [Chris Ohk](https://github.com/utilForever)
- [Seungoh Han](https://github.com/h5jam)
- [Jaeyong Sung](https://github.com/buttercrab)
- [Seungbin Oh](https://github.com/sboh1214)

CubbyAdmin is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. CubbyServer is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
CubbyAdmin is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. CubbyServer is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
1 change: 1 addition & 0 deletions __mocks__/fileMock.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = "test-file-stub";
1 change: 1 addition & 0 deletions __mocks__/styleMock.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = {};
8 changes: 8 additions & 0 deletions __tests__/components.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { render } from "@testing-library/react";
import Layout from "../components/layout";

describe("Components", () => {
it("renders Layout", () => {
render(<Layout>Hello</Layout>);
});
});
8 changes: 8 additions & 0 deletions __tests__/pages.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { render } from "@testing-library/react";
import Index from "../pages/index";

describe("Pages", () => {
it("renders Index", () => {
render(<Index />);
});
});
7 changes: 7 additions & 0 deletions components/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
type Props = {
children: React.ReactNode;
};

export default function Layout({ children }: Props) {
return <>{children}</>;
}
30 changes: 30 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
module.exports = {
collectCoverageFrom: [
"**/*.{js,jsx,ts,tsx}",
"!**/*.d.ts",
"!**/node_modules/**",
],
moduleNameMapper: {
/* Handle CSS imports (with CSS modules)
https://jestjs.io/docs/webpack#mocking-css-modules */
"^.+\\.module\\.(css|sass|scss)$": "identity-obj-proxy",

// Handle CSS imports (without CSS modules)
"^.+\\.(css|sass|scss)$": "<rootDir>/__mocks__/styleMock.js",

/* Handle image imports
https://jestjs.io/docs/webpack#handling-static-assets */
"^.+\\.(jpg|jpeg|png|gif|webp|svg)$": "<rootDir>/__mocks__/fileMock.js",
},
testPathIgnorePatterns: ["<rootDir>/node_modules/", "<rootDir>/.next/"],
testEnvironment: "jsdom",
transform: {
/* Use babel-jest to transpile tests with the next/babel preset
https://jestjs.io/docs/configuration#transform-objectstring-pathtotransformer--pathtotransformer-object */
"^.+\\.(js|jsx|ts|tsx)$": ["babel-jest", { presets: ["next/babel"] }],
},
transformIgnorePatterns: [
"/node_modules/",
"^.+\\.module\\.(css|sass|scss)$",
],
};
2 changes: 1 addition & 1 deletion next.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** @type {import('next').NextConfig} */
module.exports = {
reactStrictMode: true,
}
};
Loading

0 comments on commit a671ac0

Please sign in to comment.