Skip to content

Commit be3bc86

Browse files
committed
feat: update package dependencies and scripts
- Renamed "format" script to "pretty" and added new scripts for asset and i18n generation. - Added "antd" and "react-i18next" as dependencies. - Added "tailwindcss" and "@tailwindcss/postcss" as dev dependencies. refactor: modify environment variable handling - Replaced envVar with envConfig for better structure and clarity in configuration. - Updated rsbuild configuration to use envConfig. fix: update routing and component structure - Refactored routing to use new route tree generation. - Updated App component to utilize envConfig for base path. - Removed unused route files and endpoints. style: integrate Tailwind CSS - Added Tailwind CSS imports and utility classes in global styles. - Updated components to use Ant Design for UI elements. chore: remove deprecated axios instance and constants - Deleted axiosInstance and constants.ts files. - Integrated axios instance directly with improved error handling and toast notifications. feat: implement localization support - Added i18n setup with dynamic loading of translation files. - Created hooks for toast notifications and API interactions. test: add types for todos and token storage - Defined TodoDto interface for todo items. - Created TokenStorageType enum for token management. docs: update .env.example and postcss configuration - Added example environment variables for development. - Created postcss configuration for Tailwind CSS integration. build: auto-generate assets and format source files - Implemented scripts for generating asset indexes and formatting source code.
1 parent 5088851 commit be3bc86

40 files changed

Lines changed: 899 additions & 148 deletions

.env.example

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
PUBLIC_BUN_ENV=development
2+
PUBLIC_BASE=''
3+
PUBLIC_API=https://jsonplaceholder.typicode.com
4+
PUBLIC_API_TIMEOUT=10000

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Lock files
22
package-lock.json
3+
bun.lock
34
pnpm-lock.yaml
45
yarn.lock

.vscode/settings.json

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
{
22
"files.readonlyInclude": {
3-
"**/routeTree.gen.ts": true
3+
"**/route-tree.gen.ts": true
44
},
55
"files.watcherExclude": {
6-
"**/routeTree.gen.ts": true
6+
"**/route-tree.gen.ts": true
77
},
88
"search.exclude": {
9-
"**/routeTree.gen.ts": true
10-
}
9+
"**/route-tree.gen.ts": true
10+
},
11+
"css.lint.unknownAtRules": "ignore",
12+
"scss.lint.unknownAtRules": "ignore"
1113
}

bun.lock

Lines changed: 226 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,33 @@
77
"build": "rsbuild build",
88
"check": "biome check --write",
99
"dev": "rsbuild dev --open",
10-
"format": "prettier --write .",
10+
"pretty": "prettier --write .",
1111
"preview": "rsbuild preview",
12-
"env:up": "gh secret set -f .env"
12+
"env:up": "gh secret set -f .env",
13+
"assets:gen": "bun scripts/assets-gen.ts",
14+
"i18n:gen": "bun scripts/i18n-gen.ts",
15+
"format": "bun scripts/format-src.ts"
1316
},
1417
"dependencies": {
1518
"@tanstack/react-query": "^5.90.12",
1619
"@tanstack/react-router": "^1.141.6",
20+
"antd": "^6.1.2",
1721
"axios": "^1.13.2",
1822
"react": "^19.2.3",
19-
"react-dom": "^19.2.3"
23+
"react-dom": "^19.2.3",
24+
"react-i18next": "^16.5.0"
2025
},
2126
"devDependencies": {
2227
"@biomejs/biome": "2.3.8",
2328
"@rsbuild/core": "^1.6.14",
2429
"@rsbuild/plugin-react": "^1.4.2",
30+
"@tailwindcss/postcss": "^4.1.18",
2531
"@tanstack/router-plugin": "^1.141.7",
2632
"@types/node": "^25.0.3",
2733
"@types/react": "^19.2.7",
2834
"@types/react-dom": "^19.2.3",
2935
"prettier": "^3.7.3",
36+
"tailwindcss": "^4.1.18",
3037
"typescript": "^5.9.3"
3138
}
3239
}

postcss.config.mjs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export default {
2+
plugins: {
3+
'@tailwindcss/postcss': {},
4+
},
5+
};

public/index.html

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,14 @@
1515
// When the single page app is loaded further down in this file,
1616
// the correct url will be waiting in the browser's history for
1717
// the single page app to route accordingly.
18-
(function (l) {
18+
(((l) => {
1919
if (l.search[1] === '/') {
20-
var decoded = l.search.slice(1).split('&').map(function (s) {
21-
return s.replace(/~and~/g, '&')
22-
}).join('?');
20+
var decoded = l.search.slice(1).split('&').map((s) => s.replace(/~and~/g, '&')).join('?');
2321
window.history.replaceState(null, null,
2422
l.pathname.slice(0, -1) + decoded + l.hash
2523
);
2624
}
27-
}(window.location))
25+
})(window.location))
2826
</script>
2927
<!-- End Single Page Apps for GitHub Pages -->
3028

public/manifest.json

Whitespace-only changes.

rsbuild.config.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { defineConfig } from '@rsbuild/core';
22
import { pluginReact } from '@rsbuild/plugin-react';
33
import { tanstackRouter } from '@tanstack/router-plugin/rspack';
4-
import { envVar } from './src/helpers/constants';
4+
import { envConfig } from './src/helpers/constants/env-config';
55

66
// Docs: https://rsbuild.rs/config/
77
export default defineConfig({
@@ -12,6 +12,7 @@ export default defineConfig({
1212
tanstackRouter({
1313
target: 'react',
1414
autoCodeSplitting: true,
15+
generatedRouteTree: 'src/route-tree.gen.ts',
1516
}),
1617
],
1718
},
@@ -21,8 +22,8 @@ export default defineConfig({
2122
title: 'Waheim',
2223
},
2324
server: {
24-
port: 3000,
25-
base: envVar.isProd ? envVar.base : '',
25+
port: envConfig.port,
26+
base: envConfig.base,
2627
historyApiFallback: true,
2728
},
2829
});

scripts/assets-gen.ts

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
#!/usr/bin/env node
2+
3+
/**
4+
* Auto-generate assets index.js from all files in this directory and subdirectories
5+
*
6+
* ?Usage:
7+
* node generate_assets_index.js
8+
* (or: bun generate_assets_index.js)
9+
*
10+
* !Requirements:
11+
* - Run this script in the src/assets directory
12+
* - All asset files (images, sounds, videos, etc.) should be placed in this directory or its subfolders
13+
* - Asset files should not be named index.* or generate_assets_index.*
14+
* - The script will ignore .DS_Store and similar system files
15+
* - The generated index.js will export an Assets object with all assets imported and mapped by PascalCase name
16+
*
17+
* @example
18+
* import Assets from './assets/index.js';
19+
* Usage: Assets.VueSvg, Assets.NavMenuClickMp3, etc.
20+
*
21+
* @author ThinhPhoenix
22+
* @version 1.0.0
23+
*/
24+
const fs = require('fs');
25+
const path = require('path');
26+
27+
const assetsDir = path.join(__dirname, '../src/assets');
28+
const indexPath = path.join(assetsDir, 'index.ts');
29+
30+
function toExportName(filePath: any) {
31+
let name = path.basename(filePath, path.extname(filePath));
32+
const rel = path.relative(assetsDir, filePath).split(path.sep);
33+
if (rel.length > 1) {
34+
name = rel.slice(0, -1).concat(name).join('_');
35+
}
36+
return name.replace(/(^|[-_])(\w)/g, (_: string, __: string, c: string) =>
37+
c.toUpperCase(),
38+
);
39+
}
40+
41+
function walk(dir: any) {
42+
let results: any = [];
43+
const list = fs.readdirSync(dir);
44+
list.forEach((file: any) => {
45+
const filePath = path.join(dir, file);
46+
const stat = fs.statSync(filePath);
47+
if (stat && stat.isDirectory()) {
48+
results = results.concat(walk(filePath));
49+
} else if (
50+
!file.startsWith('index.') &&
51+
!file.startsWith('generate-assets-index')
52+
) {
53+
results.push(filePath);
54+
}
55+
});
56+
return results;
57+
}
58+
59+
const files = walk(assetsDir).filter((f: any) => !f.endsWith('.DS_Store'));
60+
61+
const importLines = files.map((f: any) => {
62+
const relPath = './' + path.relative(assetsDir, f).replace(/\\/g, '/');
63+
const exportName = toExportName(f);
64+
return `import ${exportName} from '${relPath}';`;
65+
});
66+
67+
const assetObjectLines = files.map((f: any) => {
68+
const exportName = toExportName(f);
69+
return ` ${exportName},`;
70+
});
71+
72+
const output = [
73+
'//! ⚠️ THIS FILE IS AUTO-GENERATED. DO NOT EDIT DIRECTLY. RUN generate_index.js TO UPDATE. ⚠️',
74+
...importLines,
75+
'',
76+
'const Assets = {',
77+
...assetObjectLines,
78+
'};',
79+
'',
80+
'export default Assets;',
81+
'',
82+
].join('\n');
83+
84+
fs.writeFileSync(indexPath, output);

0 commit comments

Comments
 (0)