-
Notifications
You must be signed in to change notification settings - Fork 318
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a729a4f
commit 6c54b58
Showing
10 changed files
with
203 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
pnpm-debug.log* | ||
lerna-debug.log* | ||
|
||
node_modules | ||
.DS_Store | ||
dist | ||
data | ||
|
||
|
||
/cypress/videos/ | ||
/cypress/screenshots/ | ||
|
||
# Editor directories and files | ||
.idea | ||
*.suo | ||
*.ntvs* | ||
*.njsproj | ||
*.sln | ||
*.sw? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# pnpm 依赖安装方式 | ||
node-linker=hoisted |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"files.associations": { | ||
"*.config": "xml", | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# twikoo 可执行文件 | ||
|
||
## 打包命令 | ||
|
||
```sh | ||
npm run build | ||
``` | ||
|
||
## 可执行文件下载地址 | ||
|
||
[latest](https://github.com/kongxiangyiren/twikoo-pkg/releases/latest) | ||
|
||
## window iis 启动 | ||
|
||
1、[下载安装 aspNetCore](https://dotnet.microsoft.com/zh-cn/download/dotnet/thank-you/runtime-aspnetcore-8.0.0-windows-hosting-bundle-installer) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>twikoo demo</title> | ||
</head> | ||
<body> | ||
<style> | ||
#twikoo{ | ||
min-height: 90vh; | ||
} | ||
</style> | ||
<div id="tcomment"></div> | ||
<script src="https://cdn.staticfile.org/twikoo/1.6.29/twikoo.all.min.js"></script> | ||
<script> | ||
twikoo.init({ | ||
envId: 'http://127.0.0.1:8080', // 腾讯云环境填 envId;Vercel 环境填地址(https://xxx.vercel.app) | ||
el: '#tcomment', // 容器元素 | ||
// region: 'ap-guangzhou', // 环境地域,默认为 ap-shanghai,腾讯云环境填 ap-shanghai 或 ap-guangzhou;Vercel 环境不填 | ||
// path: location.pathname, // 用于区分不同文章的自定义 js 路径,如果您的文章路径不是 location.pathname,需传此参数 | ||
// lang: 'zh-CN', // 用于手动设定评论区语言,支持的语言列表 https://github.com/twikoojs/twikoo/blob/main/src/client/utils/i18n/index.js | ||
}) | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
const { program } = require('commander'); | ||
const { join } = require('path'); | ||
const { existsSync, writeFileSync, readFileSync } = require('fs'); | ||
|
||
program | ||
.name(require('./package.json').name) | ||
.version(require('./package.json').dependencies.tkserver, '-v, --version') | ||
.description( | ||
`DESCRIPTION: | ||
Official website: https://twikoo.js.org/` | ||
) | ||
.addHelpCommand(false); | ||
|
||
program.parse(process.argv); | ||
|
||
// 创建.env文件 | ||
if ( | ||
process.pkg && | ||
!existsSync(join(process.execPath, '..', '.env')) && | ||
existsSync(join(__dirname, '.env')) | ||
) { | ||
writeFileSync( | ||
join(process.execPath, '..', '.env'), | ||
readFileSync(join(__dirname, '.env'), 'utf-8') | ||
); | ||
} | ||
|
||
// 适配iis | ||
if ( | ||
process.pkg && | ||
process.platform === 'win32' && | ||
!existsSync(join(process.execPath, '..', './web.config')) && | ||
existsSync(join(__dirname, './web.config')) | ||
) { | ||
writeFileSync( | ||
join(process.execPath, '..', './web.config'), | ||
readFileSync(join(__dirname, './web.config'), 'utf-8') | ||
); | ||
} | ||
|
||
// 获取env | ||
require('dotenv').config({ | ||
path: | ||
process.pkg && existsSync(join(process.execPath, '..', '.env')) | ||
? join(process.execPath, '..', '.env') | ||
: existsSync(join(__dirname, '.env')) | ||
? join(__dirname, '.env') | ||
: void 0 | ||
}); | ||
|
||
// 匹配iis | ||
if (process.env.ASPNETCORE_PORT) { | ||
process.env.TWIKOO_PORT = process.env.ASPNETCORE_PORT; | ||
process.env.TWIKOO_LOCALHOST_ONLY = null; | ||
} | ||
|
||
require('tkserver'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{ | ||
"name": "twikoo", | ||
"version": "1.0.0", | ||
"main": "index.js", | ||
"license": "MIT", | ||
"bin": "index.js", | ||
"scripts": { | ||
"start": "node index.js", | ||
"postinstall": "patch-package", | ||
"build": "rimraf ./dist && pkg . -C GZip --no-bytecode --public-packages \"*\" --public" | ||
}, | ||
"pkg": { | ||
"scripts": [], | ||
"assets": [ | ||
"./node_modules/axios/dist/node/axios.cjs", | ||
"./node_modules/@imaegoo/node-ip2region/data/ip2region.db", | ||
"./web.config", | ||
"./.env" | ||
], | ||
"targets": [ | ||
"node18-win-x64", | ||
"node18-linux-x64", | ||
"node18-macos-x64" | ||
], | ||
"outputPath": "dist" | ||
}, | ||
"dependencies": { | ||
"commander": "^11.1.0", | ||
"dotenv": "^16.3.1", | ||
"tkserver": "1.6.29" | ||
}, | ||
"devDependencies": { | ||
"patch-package": "^8.0.0", | ||
"pkg": "5.8.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
diff --git a/node_modules/pkg-fetch/lib-es5/index.js b/node_modules/pkg-fetch/lib-es5/index.js | ||
index 4b1339e..08d09ee 100644 | ||
--- a/node_modules/pkg-fetch/lib-es5/index.js | ||
+++ b/node_modules/pkg-fetch/lib-es5/index.js | ||
@@ -79,7 +79,7 @@ function download(_a, local) { | ||
return __generator(this, function (_c) { | ||
switch (_c.label) { | ||
case 0: | ||
- url = "https://github.com/vercel/pkg-fetch/releases/download/" + tag + "/" + name; | ||
+ url = "https://mirror.ghproxy.com/https://github.com/vercel/pkg-fetch/releases/download/" + tag + "/" + name; | ||
_c.label = 1; | ||
case 1: | ||
_c.trys.push([1, 4, , 5]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
diff --git a/node_modules/tkserver/index.js b/node_modules/tkserver/index.js | ||
index d1fb7c9..a0972a2 100644 | ||
--- a/node_modules/tkserver/index.js | ||
+++ b/node_modules/tkserver/index.js | ||
@@ -210,7 +210,7 @@ function anonymousSignIn (request) { | ||
|
||
async function connectToDatabase () { | ||
if (db) return db | ||
- const dataDir = path.resolve(process.cwd(), process.env.TWIKOO_DATA || './data') | ||
+ const dataDir = path.resolve(process.pkg ? path.join(process.execPath, '..') : process.cwd(), process.env.TWIKOO_DATA || './data') | ||
if (!fs.existsSync(dataDir)) { | ||
fs.mkdirSync(dataDir) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<configuration> | ||
<location path="." inheritInChildApplications="false"> | ||
<system.webServer> | ||
<handlers> | ||
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" /> | ||
</handlers> | ||
<aspNetCore processPath=".\twikoo-win.exe" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" hostingModel="outofprocess" /> | ||
</system.webServer> | ||
</location> | ||
</configuration> |