Skip to content

Commit

Permalink
chore: setting turborepo & tsup (#11)
Browse files Browse the repository at this point in the history
* refactor: separate YLS demo

* remove: lint-config package

* chore: install turbo & migration vite -> tsup

* config: setting tsup in yls

- 환경 변수 관련 이슈 추후 해결할 예정

* config: setting tsup & utils test

- 패키지 단위 테스트 적용, package.json 설정

* chore: update lock file
  • Loading branch information
Hanna922 authored May 31, 2024
1 parent 6171a65 commit b757f61
Show file tree
Hide file tree
Showing 34 changed files with 871 additions and 326 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,7 @@ dist-ssr
*.sw?

# Output of 'npm pack'
*.tgz
*.tgz

# Turborepo
.turbo
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import { useState } from 'react';

import { LogClick, LogScreen } from '@yourssu/logging-system-react';
import { useLocation } from 'react-router-dom';

import { LogClick } from '../components/LogClick';
import { LogScreen } from '../components/LogScreen';

export const Drawer = () => {
const [count, setCount] = useState(0);
const router = useLocation();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import { useState } from 'react';

import { LogClick, LogScreen } from '@yourssu/logging-system-react';
import { useLocation } from 'react-router-dom';

import { LogClick } from '../components/LogClick';
import { LogScreen } from '../components/LogScreen';

export const Home = () => {
const [count, setCount] = useState(0);
const router = useLocation();
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/demo/main.tsx"></script>
<script type="module" src="./main.tsx"></script>
</body>
</html>
File renamed without changes.
14 changes: 14 additions & 0 deletions apps/demo/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "@yourssu/demo",
"version": "0.1.0",
"type": "module",
"scripts": {
"dev": "vite"
},
"devDependencies": {
"@yourssu/logging-system-react": "workspace:*",
"react-router-dom": "^6.21.3",
"vite": "^4.4.5",
"vite-plugin-dts": "^3.5.3"
}
}
3 changes: 3 additions & 0 deletions apps/demo/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "../../tsconfig.json"
}
24 changes: 10 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"name": "@yourssu/yrano",
"packageManager": "pnpm@8.15.4",
"packageManager": "pnpm@8.9.0",
"workspaces": [
"apps/*",
"packages/*"
],
"repository": {
Expand All @@ -10,17 +11,15 @@
},
"type": "module",
"scripts": {
"dev": "vite",
"build": "pnpm -r run build",
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0 --fix",
"dev": "turbo dev",
"build": "turbo build",
"lint": "turbo lint",
"lint-staged": "lint-staged",
"prepublishOnly": "npm run build",
"preview": "vite preview",
"format": "prettier --write \"**/*.{ts,tsx,md}\"",
"ci:version": "changeset version",
"ci:publish": "pnpm publish -r",
"ci:publish": "pnpm publish -r --access public",
"logging-system": "pnpm --filter @yourssu/logging-system-react",
"utils": "pnpm --filter @yourssu/utils",
"lint-config": "pnpm --filter @yourssu/lint-config",
"prepare": "husky",
"test": "vitest",
"test:ui": "vitest --ui"
Expand All @@ -41,7 +40,6 @@
"@types/react-dom": "^18.2.7",
"@typescript-eslint/eslint-plugin": "^6.0.0",
"@typescript-eslint/parser": "^6.0.0",
"@vitejs/plugin-react-swc": "^3.3.2",
"@vitest/ui": "^1.6.0",
"eslint": "^8.45.0",
"eslint-config-prettier": "^9.0.0",
Expand All @@ -57,11 +55,9 @@
"prettier": "^3.0.3",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"tsup": "^8.0.2",
"turbo": "latest",
"typescript": "^5.0.2",
"vite": "^4.4.5",
"vite-plugin-dts": "^3.5.3",
"vite-tsconfig-paths": "^4.2.0",
"vitest": "^1.6.0",
"xmldom": "^0.6.0"
"vitest": "^1.6.0"
}
}
5 changes: 0 additions & 5 deletions packages/lint-config/package.json

This file was deleted.

Empty file removed packages/lint-config/src/index.ts
Empty file.
1 change: 0 additions & 1 deletion packages/lint-config/src/vite-env.d.ts

This file was deleted.

12 changes: 0 additions & 12 deletions packages/lint-config/tsconfig.json

This file was deleted.

1 change: 0 additions & 1 deletion packages/lint-config/vite.config.ts

This file was deleted.

24 changes: 13 additions & 11 deletions packages/logging-system/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,28 @@
],
"repository": {
"type": "git",
"url": "git+https://github.com/yourssu/YLS-Web.git"
"url": "https://github.com/yourssu/Yrano",
"directory": "packages/logging-system"
},
"author": "",
"license": "MIT",
"type": "module",
"types": "./dist/index.d.ts",
"main": "./dist/index.cjs.js",
"module": "./dist/index.es.js",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.es.js",
"require": "./dist/index.cjs.js"
"import": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
},
"require": {
"types": "./dist/index.d.cts",
"default": "./dist/index.cjs"
}
}
},
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"preview": "vite preview"
"build": "tsc && tsup"
},
"peerDependencies": {
"axios": "^1.6.4",
Expand Down
4 changes: 2 additions & 2 deletions packages/logging-system/src/Logger.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import CryptoJS from 'crypto-js';
import SHA256 from 'crypto-js/sha256';

import { SetLocalStorage, SetLocalStorageClear } from './SetLocalStorage';
import { postLog } from './apis/postLog';
Expand Down Expand Up @@ -29,7 +29,7 @@ const createHashedID = (userId: string) => {
userId = createRandomId();
}

hashedId = CryptoJS.SHA256(userId).toString(CryptoJS.enc.Base64);
hashedId = SHA256(userId).toString(CryptoJS.enc.Base64);

return localHashedId ? localHashedId : hashedId;
};
Expand Down
3 changes: 2 additions & 1 deletion packages/logging-system/src/apis/customedAxios.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import axios from 'axios';

export const customedAxios = axios.create({
baseURL: import.meta.env.VITE_API_YLS_URL,
// baseURL: import.meta.env.VITE_API_YLS_URL,
baseURL: '',
headers: {
'Content-Type': 'application/json',
withCredentials: true,
Expand Down
3 changes: 2 additions & 1 deletion packages/logging-system/src/components/LogScreen.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { useYLSLogger } from '..';
import { useEffect } from 'react';

import { useYLSLogger } from '..';
import { LogPayloadParams } from '../types/LogType';

interface Props {
Expand Down
1 change: 0 additions & 1 deletion packages/logging-system/src/vite-env.d.ts

This file was deleted.

2 changes: 1 addition & 1 deletion packages/logging-system/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
"@/*": ["./src/*"]
}
},
"include": ["./src"]
"include": ["src"]
}
19 changes: 19 additions & 0 deletions packages/logging-system/tsup.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { defineConfig } from 'tsup';

export default defineConfig({
entry: ['./src/index.ts'],
format: ['cjs', 'esm'],
dts: {
entry: './src/index.ts',
resolve: true,
},
external: ['react', 'react-dom'],
noExternal: ['crypto-js/sha256'],
splitting: false,
clean: true,
sourcemap: true,
minify: true,
treeshake: true,
skipNodeModulesBundle: true,
outDir: './dist',
});
38 changes: 0 additions & 38 deletions packages/logging-system/vite.config.ts

This file was deleted.

33 changes: 32 additions & 1 deletion packages/utils/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,36 @@
{
"name": "@yourssu/utils",
"private": false,
"version": "0.1.0"
"version": "0.1.0",
"description": "Yourssu Utils Package",
"keywords": [
"yourssu",
"utils"
],
"repository": {
"type": "git",
"url": "https://github.com/yourssu/Yrano",
"directory": "packages/utils"
},
"license": "MIT",
"type": "module",
"types": "./dist/index.d.ts",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
"exports": {
".": {
"import": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
},
"require": {
"types": "./dist/index.d.cts",
"default": "./dist/index.cjs"
}
}
},
"scripts": {
"build": "tsc && tsup",
"test": "vitest"
}
}
1 change: 0 additions & 1 deletion packages/utils/src/vite-env.d.ts

This file was deleted.

2 changes: 1 addition & 1 deletion packages/utils/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
"@/*": ["./src/*"]
}
},
"include": ["./src"]
"include": ["src"]
}
18 changes: 18 additions & 0 deletions packages/utils/tsup.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { defineConfig } from 'tsup';

export default defineConfig({
entry: ['./src/index.ts'],
format: ['cjs', 'esm'],
dts: {
entry: './src/index.ts',
resolve: true,
},
external: ['react', 'react-dom'],
splitting: false,
clean: true,
sourcemap: true,
minify: true,
treeshake: true,
skipNodeModulesBundle: true,
outDir: './dist',
});
1 change: 0 additions & 1 deletion packages/utils/vite.config.ts

This file was deleted.

9 changes: 9 additions & 0 deletions packages/utils/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { defineConfig } from 'vitest/config';

export default defineConfig({
test: {
dir: './src',
globals: true,
environment: 'jsdom',
},
});
Loading

0 comments on commit b757f61

Please sign in to comment.