Skip to content

Commit dac8441

Browse files
committed
chore: update build script
1 parent d0a95ea commit dac8441

File tree

11 files changed

+66
-67
lines changed

11 files changed

+66
-67
lines changed

client/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
{
22
"name": "@fecommunity/reactpress-client",
3-
"version": "1.0.0-beta.21",
3+
"version": "1.0.0-beta.22",
44
"bin": {
55
"reactpress-client": "./bin/reactpress-client.js"
66
},
77
"files": [
88
".next/**/*",
99
"bin/**/*",
10+
"public/**/*",
1011
"next.config.js",
1112
"server.js"
1213
],
@@ -84,4 +85,4 @@
8485
"tsconfig-paths-webpack-plugin": "^3.5.2",
8586
"typescript": "4.6.2"
8687
}
87-
}
88+
}

client/public/sitemap.xml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:news="http://www.google.com/schemas/sitemap-news/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:mobile="http://www.google.com/schemas/sitemap-mobile/1.0" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1" xmlns:video="http://www.google.com/schemas/sitemap-video/1.1">
3-
<url><loc>http://localhost:3001</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2025-09-20T11:48:06.840Z</lastmod></url>
4-
<url><loc>http://localhost:3001/archives</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2025-09-20T11:48:06.840Z</lastmod></url>
5-
<url><loc>http://localhost:3001/knowledge</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2025-09-20T11:48:06.840Z</lastmod></url>
6-
<url><loc>http://localhost:3001/login</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2025-09-20T11:48:06.840Z</lastmod></url>
7-
<url><loc>http://localhost:3001/nav</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2025-09-20T11:48:06.840Z</lastmod></url>
8-
<url><loc>http://localhost:3001/rss</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2025-09-20T11:48:06.840Z</lastmod></url>
3+
<url><loc>http://localhost:3001</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2025-09-20T12:37:06.121Z</lastmod></url>
4+
<url><loc>http://localhost:3001/archives</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2025-09-20T12:37:06.121Z</lastmod></url>
5+
<url><loc>http://localhost:3001/knowledge</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2025-09-20T12:37:06.121Z</lastmod></url>
6+
<url><loc>http://localhost:3001/login</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2025-09-20T12:37:06.121Z</lastmod></url>
7+
<url><loc>http://localhost:3001/nav</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2025-09-20T12:37:06.121Z</lastmod></url>
8+
<url><loc>http://localhost:3001/rss</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2025-09-20T12:37:06.121Z</lastmod></url>
99
</urlset>

client/server.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,20 @@
11
const { config } = require('@fecommunity/reactpress-config');
2-
const cli = require('next/dist/cli/next-start');
2+
const cliProd = require('next/dist/cli/next-start');
3+
const cliDev = require('next/dist/cli/next-dev');
4+
const open = require('open');
35

46
const port = config.CLIENT_PORT || 3001;
57

68
try {
7-
cli.nextStart(['-p', port]);
8-
console.log(`[reactpress] 客户端已启动,端口:${port}`);
9+
// 这里根据环境判断,如果NODE_ENV=production, 就是生产
10+
if (process.env.NODE_ENV === 'production') {
11+
cliProd.nextStart(['-p', port]);
12+
} else {
13+
cliDev.nextDev(['-p', port]);
14+
}
15+
console.log(`[reactpress] 客户端已启动,端口:${port}`, `访问地址:http://localhost:${port}`);
16+
// 尝试自动打开
17+
open(`http://localhost:${port}`);
918
} catch (err) {
1019
console.log(`[reactpress] 客户端启动失败!${err.message || err}`);
11-
}
20+
}
File renamed without changes.
File renamed without changes.

config/package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@fecommunity/reactpress-config",
3-
"version": "1.0.0-beta.33",
3+
"version": "1.0.0-beta.34",
44
"description": "ReactPress Configuration - Environment and i18n configuration for ReactPress",
55
"author": "fecommunity",
66
"main": "./lib/index.js",
@@ -26,14 +26,16 @@
2626
},
2727
"files": [
2828
"lib",
29-
"src"
29+
"src",
30+
"locales"
3031
],
3132
"dependencies": {
3233
"dotenv": "^8.2.0",
3334
"fs-extra": "^10.0.0"
3435
},
3536
"devDependencies": {
37+
"@types/fs-extra": "^9.0.0",
3638
"@types/node": "^12.7.5",
37-
"@types/fs-extra": "^9.0.0"
39+
"typescript": "^5.9.2"
3840
}
3941
}

config/src/i18n.ts

Lines changed: 3 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -12,35 +12,10 @@ interface I18nResult {
1212
}
1313

1414
function parseI18n(): I18nResult {
15-
// 本地的国际化文案
16-
// 尝试多种路径来确保在不同运行环境下都能找到locales目录
17-
const possiblePaths = [
18-
path.join(__dirname, '../../locales'),
19-
path.join(__dirname, '../../../locales'),
20-
path.join(__dirname, '../locales'),
21-
path.join(process.cwd(), 'locales'),
22-
path.join(process.cwd(), '../locales'),
23-
path.join(process.cwd(), '../../locales')
24-
];
15+
// Locales are now in the config package
16+
const localesDir = path.join(__dirname, '../locales');
2517

26-
let localesDir = '';
27-
for (const possiblePath of possiblePaths) {
28-
if (fs.existsSync(possiblePath)) {
29-
localesDir = possiblePath;
30-
break;
31-
}
32-
}
33-
34-
if (!localesDir) {
35-
// 如果在所有预期路径都找不到,则使用项目根目录的locales
36-
const projectRoot = findProjectRoot();
37-
const fallbackPath = path.join(projectRoot, 'locales');
38-
if (fs.existsSync(fallbackPath)) {
39-
localesDir = fallbackPath;
40-
}
41-
}
42-
43-
if (!localesDir) {
18+
if (!fs.existsSync(localesDir)) {
4419
return { messages: {}, locales: [], defaultLocale: '' };
4520
}
4621

@@ -57,15 +32,4 @@ function parseI18n(): I18nResult {
5732
return { messages, locales, defaultLocale };
5833
}
5934

60-
function findProjectRoot(): string {
61-
// 优先使用通过环境变量传递的原始工作目录
62-
// 这是在 bin/reactpress-server.js 或 client/server.js 中设置的,表示用户执行命令的目录
63-
if (process.env.REACTPRESS_ORIGINAL_CWD) {
64-
return process.env.REACTPRESS_ORIGINAL_CWD;
65-
}
66-
67-
// 如果找不到项目根目录,返回当前工作目录
68-
return process.cwd();
69-
}
70-
7135
export const { messages, locales, defaultLocale } = parseI18n();

config/tsconfig.json

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,19 @@
11
{
2-
"compilerOptions": {
3-
"outDir": "./lib",
4-
"skipLibCheck": true,
5-
"declaration": true
6-
},
7-
"include": ["src/**/*.ts"]
8-
}
2+
"compilerOptions": {
3+
"target": "es2017",
4+
"module": "commonjs",
5+
"lib": ["es2017"],
6+
"outDir": "./lib",
7+
"rootDir": "./src",
8+
"strict": true,
9+
"esModuleInterop": true,
10+
"skipLibCheck": true,
11+
"forceConsistentCasingInFileNames": true,
12+
"resolveJsonModule": true,
13+
"declaration": true,
14+
"declarationMap": true,
15+
"sourceMap": true
16+
},
17+
"include": ["src/**/*"],
18+
"exclude": ["node_modules", "lib"]
19+
}

pnpm-lock.yaml

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

server/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@fecommunity/reactpress-server",
3-
"version": "1.0.0-beta.46",
3+
"version": "1.0.0-beta.47",
44
"description": "ReactPress Server - NestJS-based backend API for ReactPress CMS",
55
"author": "fecommunity",
66
"license": "MIT",

0 commit comments

Comments
 (0)