Skip to content

Commit 96c1d0a

Browse files
committed
feat: support quick install
1 parent b08f3e6 commit 96c1d0a

File tree

25 files changed

+2673
-101
lines changed

25 files changed

+2673
-101
lines changed

client/dev-server.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const { config } = require('@reactpress/config');
1+
const { config } = require('@fecommunity/reactpress-config');
22
const cli = require('next/dist/cli/next-dev');
33

44
const port = config.CLIENT_PORT || 3001;

client/next-sitemap.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const { config } = require('@reactpress/config');
1+
const { config } = require('@fecommunity/reactpress-config');
22

33
module.exports = {
44
siteUrl: config.CLIENT_SITE_URL,

client/next.config.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
33
const withPlugins = require('next-compose-plugins');
44
const withLess = require('next-with-less');
55
const withPWA = require('next-pwa');
6-
const { config, locales, defaultLocale } = require('@reactpress/config');
6+
const { config, locales, defaultLocale } = require('@fecommunity/reactpress-config');
77
const antdVariablesFilePath = path.resolve(__dirname, './antd-custom.less');
88

99
const getServerApiUrl = () => {
@@ -18,8 +18,8 @@ const getServerApiUrl = () => {
1818
const nextConfig = {
1919
assetPrefix: config.CLIENT_ASSET_PREFIX || '/',
2020
i18n: {
21-
locales,
22-
defaultLocale,
21+
locales: locales && locales.length > 0 ? locales : ['zh', 'en'],
22+
defaultLocale: defaultLocale || 'zh',
2323
},
2424
env: {
2525
SERVER_API_URL: getServerApiUrl(),

client/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
{
2-
"name": "@reactpress/client",
3-
"version": "1.0.0",
2+
"name": "@fecommunity/reactpress-client",
3+
"version": "1.0.1-beta.3",
44
"scripts": {
55
"prebuild": "rimraf .next",
66
"build": "next build",
77
"postbuild": "next-sitemap",
88
"dev": "node dev-server.js",
99
"start": "cross-env NODE_ENV=production node prod-server.js",
10-
"pm2": "pm2 start npm --name @reactpress/client -- start"
10+
"pm2": "pm2 start npm --name @fecommunity/reactpress-client -- start"
1111
},
1212
"dependencies": {
1313
"@ant-design/compatible": "^1.1.0",
1414
"@ant-design/cssinjs": "^1.22.0",
1515
"@ant-design/icons": "^4.7.0",
1616
"@ant-design/pro-layout": "7.19.11",
1717
"@monaco-editor/react": "^4.6.0",
18-
"@reactpress/config": "workspace:^1.0.0",
18+
"@fecommunity/reactpress-config": "workspace:^1.0.0",
1919
"antd": "^5.24.4",
2020
"array-move": "^3.0.1",
2121
"axios": "^0.23.0",

client/prod-server.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const { config } = require('@reactpress/config');
1+
const { config } = require('@fecommunity/reactpress-config');
22
const cli = require('next/dist/cli/next-start');
33

44
const port = config.CLIENT_PORT || 3001;

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-01-05T15:47:23.248Z</lastmod></url>
4-
<url><loc>http://localhost:3001/archives</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2025-01-05T15:47:23.248Z</lastmod></url>
5-
<url><loc>http://localhost:3001/knowledge</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2025-01-05T15:47:23.248Z</lastmod></url>
6-
<url><loc>http://localhost:3001/login</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2025-01-05T15:47:23.248Z</lastmod></url>
7-
<url><loc>http://localhost:3001/nav</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2025-01-05T15:47:23.248Z</lastmod></url>
8-
<url><loc>http://localhost:3001/rss</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2025-01-05T15:47:23.248Z</lastmod></url>
3+
<url><loc>http://localhost:3001</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2025-09-14T15:50:54.017Z</lastmod></url>
4+
<url><loc>http://localhost:3001/archives</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2025-09-14T15:50:54.018Z</lastmod></url>
5+
<url><loc>http://localhost:3001/knowledge</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2025-09-14T15:50:54.018Z</lastmod></url>
6+
<url><loc>http://localhost:3001/login</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2025-09-14T15:50:54.018Z</lastmod></url>
7+
<url><loc>http://localhost:3001/nav</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2025-09-14T15:50:54.018Z</lastmod></url>
8+
<url><loc>http://localhost:3001/rss</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2025-09-14T15:50:54.018Z</lastmod></url>
99
</urlset>

config/package.json

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
{
2-
"name": "@reactpress/config",
3-
"version": "1.0.0",
2+
"name": "@fecommunity/reactpress-config",
3+
"version": "1.0.0-beta.11",
4+
"description": "ReactPress Configuration - Environment and i18n configuration for ReactPress",
5+
"author": "fecommunity",
46
"main": "./lib/index.js",
57
"types": "./lib/index.d.ts",
68
"exports": {
@@ -11,6 +13,14 @@
1113
},
1214
"sideEffects": false,
1315
"license": "MIT",
16+
"repository": {
17+
"type": "git",
18+
"url": "https://github.com/fecommunity/reactpress.git",
19+
"directory": "config"
20+
},
21+
"publishConfig": {
22+
"access": "public"
23+
},
1424
"scripts": {
1525
"build": "tsc --outDir lib --skipLibCheck --declaration"
1626
},
@@ -19,9 +29,11 @@
1929
"src"
2030
],
2131
"dependencies": {
22-
"dotenv": "^8.2.0"
32+
"dotenv": "^8.2.0",
33+
"fs-extra": "^10.0.0"
2334
},
2435
"devDependencies": {
25-
"@types/node": "^12.7.5"
36+
"@types/node": "^12.7.5",
37+
"@types/fs-extra": "^9.0.0"
2638
}
27-
}
39+
}

config/src/env.ts

Lines changed: 40 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,26 +10,52 @@ interface EnvConfig {
1010
}
1111

1212
function parseEnv(): EnvConfig {
13-
const localenv = path.resolve(__dirname, '../../.env');
14-
const prodenv = path.resolve(__dirname, '../../.env.prod');
15-
16-
const envFiles = [
17-
{ path: prodenv, isProd: true },
18-
{ path: localenv, isProd: false }
13+
// Try multiple possible paths for environment files
14+
const possibleBasePaths = [
15+
path.resolve(__dirname, '../../'), // From config/lib to project root
16+
path.resolve(__dirname, '../../../'), // From node_modules to project root
17+
path.resolve(__dirname, '../'), // From client directory to project root
18+
process.cwd(), // Current working directory
19+
path.resolve(process.cwd(), '../'), // From client directory to project root
1920
];
20-
21-
const availableEnvFiles = envFiles.filter(({ path: envPath }) => fs.existsSync(envPath));
2221

23-
if (availableEnvFiles.length === 0) {
22+
let foundEnvFiles: Array<{ path: string, isProd: boolean }> = [];
23+
24+
// Search for .env files in all possible locations
25+
for (const basePath of possibleBasePaths) {
26+
const localenv = path.join(basePath, '.env');
27+
const prodenv = path.join(basePath, '.env.prod');
28+
29+
const envFiles = [
30+
{ path: prodenv, isProd: true },
31+
{ path: localenv, isProd: false }
32+
];
33+
34+
const availableEnvFiles = envFiles.filter(({ path: envPath }) => fs.existsSync(envPath));
35+
36+
if (availableEnvFiles.length > 0) {
37+
foundEnvFiles = availableEnvFiles;
38+
break; // Use the first location where we find env files
39+
}
40+
}
41+
42+
if (foundEnvFiles.length === 0) {
43+
// Show all possible paths in error message for debugging
44+
const allPossiblePaths: string[] = [];
45+
for (const basePath of possibleBasePaths) {
46+
allPossiblePaths.push(path.join(basePath, '.env'));
47+
allPossiblePaths.push(path.join(basePath, '.env.prod'));
48+
}
49+
2450
throw new Error(
25-
`No environment file found. Expected one of:\n` +
26-
`- ${localenv}\n` +
27-
`- ${prodenv}`
51+
`No environment file found. Searched in these locations:\n` +
52+
allPossiblePaths.map((p: string) => `- ${p}`).join('\n') +
53+
`\n\nPlease create a .env file in your project root directory.`
2854
);
2955
}
3056

31-
const file = availableEnvFiles.find(({ isProd: prod }) => isProd === prod)?.path ||
32-
availableEnvFiles[0].path;
57+
const file = foundEnvFiles.find(({ isProd: prod }) => isProd === prod)?.path ||
58+
foundEnvFiles[0].path;
3359
try {
3460
const envContent = fs.readFileSync(file, 'utf8');
3561
const config = dotenv.parse(envContent);

config/src/i18n.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ function parseI18n(): I18nResult {
2020
}
2121

2222
const files = fs.readdirSync(localesDir);
23-
const messages = files.reduce((i18n, file) => {
23+
const messages: I18nMessages = files.reduce((i18n, file) => {
2424
const language = file.replace(path.extname(file), '');
2525
const json = fs.readJsonSync(path.join(localesDir, file));
2626
i18n[language] = json;
2727
return i18n;
28-
}, {});
28+
}, {} as I18nMessages);
2929
const locales = Object.keys(messages);
3030
const defaultLocale = 'zh' in messages ? 'zh' : locales[0];
3131

docs/i18n/en/docusaurus-plugin-content-docs/current/tutorial-basics/deploy-your-site.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ pnpm install
4545
pnpm run build
4646
#Start process
4747
pm2 delete @reactpress/server
48-
pm2 delete @reactpress/client
48+
pm2 delete @fecommunity/reactpress-client
4949
pnpm run pm2
5050
#Power on and start up
5151
pm2 startup

0 commit comments

Comments
 (0)