fix: change to release script to config directory

This commit is contained in:
熊潇 2025-02-27 00:00:38 +08:00
parent 3477d098b7
commit 2b90bbab6f
8 changed files with 57 additions and 36 deletions

View File

@ -22,7 +22,7 @@ const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
const releasePath = path.join(cwd, 'release'); const releasePath = path.join(cwd, 'release');
const distPath = path.join(cwd, 'dist'); const distPath = path.join(cwd, 'dist');
const scriptPath = path.join(cwd, 'script');
const zip = archiver('zip', { const zip = archiver('zip', {
zlib: { level: 9 }, zlib: { level: 9 },
}); });
@ -68,9 +68,15 @@ const getZip = async () => {
npm i -g pnpm npm i -g pnpm
pnpm install --prod pnpm install --prod
`; `;
zip.append(sh, { name: 'start.sh' }); zip.append(sh, {
name: 'start.sh',
//类型是可执行文件
mode: 0o755,
});
// 把dist目录下的文件添加到zip中 // 把dist目录下的文件添加到zip中
zip.directory(distPath, 'dist'); zip.directory(distPath, 'dist');
zip.directory(scriptPath, 'script');
// 把README.md添加到zip中 // 把README.md添加到zip中
zip.file(path.join(cwd, 'README.md'), { name: 'README.md' }); zip.file(path.join(cwd, 'README.md'), { name: 'README.md' });
// 把package.json添加到zip中 // 把package.json添加到zip中
@ -92,15 +98,15 @@ const getZip = async () => {
} }
`; `;
zip.append(ecosystemContent, { name: 'ecosystem.config.cjs' }); zip.append(ecosystemContent, { name: 'ecosystem.config.cjs' });
const json5Content = fs.readFileSync(path.join(cwd, 'app.config.json5.example'), 'utf8'); let json5Content = fs.readFileSync(path.join(cwd, 'app.config.json5.example'), 'utf8');
// tokenSecret 是一个随机字符串,用于生成 token // tokenSecret 是一个随机字符串,用于生成 token
const tokenSecret = 'XX' + nanoid(39); let tokenSecret = 'XX' + nanoid(39);
json5Content.replace('<TOKEN_SECRET>', tokenSecret); json5Content = json5Content.replace('<TOKEN_SECRET>', tokenSecret);
// tokenSecret // tokenSecret
// 把app.config.json5.example添加到zip中 // 把app.config.json5.example添加到zip中
// zip.file(path.join(cwd, 'app.config.json5.example'), { name: 'app.config.json5.example' }); // zip.file(path.join(cwd, 'app.config.json5.example'), { name: 'app.config.json5.example' });
zip.append(json5Content, { name: 'app.config.json5.example' }); zip.append(json5Content, { name: 'app.config.json5.example' });
zip.append('version-check', { name: `version-check-${pkg.version}` });
// 结束归档(必须调用,否则 zip 文件无法完成) // 结束归档(必须调用,否则 zip 文件无法完成)
zip.finalize(); zip.finalize();
}); });
@ -112,5 +118,4 @@ getZip().then(() => {
console.log(`envision switch system && envision deploy ./release/${zipName} -v 1.0.0 -k code-center -y y -u`); console.log(`envision switch system && envision deploy ./release/${zipName} -v 1.0.0 -k code-center -y y -u`);
console.log(`download zip:\n\ncurl -O https://kevisual.xiongxiao.me/system/code-center/${zipName} && unzip ${zipName}`); console.log(`download zip:\n\ncurl -O https://kevisual.xiongxiao.me/system/code-center/${zipName} && unzip ${zipName}`);
}); });

View File

@ -1,6 +1,6 @@
{ {
"name": "@kevisual/code-center", "name": "@kevisual/code-center",
"version": "0.0.4", "version": "0.0.5-alpha.2",
"description": "code center", "description": "code center",
"type": "module", "type": "module",
"main": "index.js", "main": "index.js",
@ -16,7 +16,7 @@
"reload": "ssh light pm2 restart codecenter", "reload": "ssh light pm2 restart codecenter",
"pub": "npm run build && npm run deploy && npm run reload", "pub": "npm run build && npm run deploy && npm run reload",
"start": "pm2 start dist/app.mjs --name codecenter", "start": "pm2 start dist/app.mjs --name codecenter",
"release": "node ./script/release/index.mjs" "release": "node ./config/release/index.mjs"
}, },
"keywords": [], "keywords": [],
"types": "types/index.d.ts", "types": "types/index.d.ts",
@ -29,7 +29,7 @@
"dependencies": { "dependencies": {
"@kevisual/auth": "1.0.5", "@kevisual/auth": "1.0.5",
"@kevisual/local-app-manager": "0.1.9", "@kevisual/local-app-manager": "0.1.9",
"@kevisual/router": "^0.0.6", "@kevisual/router": "^0.0.7",
"@kevisual/use-config": "^1.0.8", "@kevisual/use-config": "^1.0.8",
"@types/semver": "^7.5.8", "@types/semver": "^7.5.8",
"archiver": "^7.0.1", "archiver": "^7.0.1",

28
pnpm-lock.yaml generated
View File

@ -18,13 +18,13 @@ importers:
version: 1.0.5 version: 1.0.5
'@kevisual/local-app-manager': '@kevisual/local-app-manager':
specifier: 0.1.9 specifier: 0.1.9
version: 0.1.9(@kevisual/router@0.0.6)(@kevisual/types@0.0.6)(@kevisual/use-config@1.0.7)(pm2@5.4.3) version: 0.1.9(@kevisual/router@0.0.7)(@kevisual/types@0.0.6)(@kevisual/use-config@1.0.8)(pm2@5.4.3)
'@kevisual/router': '@kevisual/router':
specifier: ^0.0.6 specifier: ^0.0.7
version: 0.0.6 version: 0.0.7
'@kevisual/use-config': '@kevisual/use-config':
specifier: ^1.0.7 specifier: ^1.0.8
version: 1.0.7 version: 1.0.8
'@types/semver': '@types/semver':
specifier: ^7.5.8 specifier: ^7.5.8
version: 7.5.8 version: 7.5.8
@ -356,14 +356,14 @@ packages:
'@kevisual/use-config': ^1.0.5 '@kevisual/use-config': ^1.0.5
pm2: ^5.4.3 pm2: ^5.4.3
'@kevisual/router@0.0.6': '@kevisual/router@0.0.7':
resolution: {integrity: sha512-7FQUY87Zy5A4V30OAggRbGpO/Asd7SUpnhHv8mlxnSFFTto25xpXmjHYp12mu/HJTsHM7RTaxVEyD1DeP44D2A==} resolution: {integrity: sha512-4n1Tp4YLoraJv7jtfy7jbuLGyAj0B2QkTlnlEDHCUTlEUOvOkjtf7DHAe2SL92fTgXhSbod0I/0vUcDF85oj/w==}
'@kevisual/types@0.0.6': '@kevisual/types@0.0.6':
resolution: {integrity: sha512-7yxe1QmuC5g7lI/1Hm+zXly8if0z+ZqGM1SVOVv2VNRwRAVYBJDc365zWCCfRwE+5YaB2daWTe5zBOU4EkltkQ==} resolution: {integrity: sha512-7yxe1QmuC5g7lI/1Hm+zXly8if0z+ZqGM1SVOVv2VNRwRAVYBJDc365zWCCfRwE+5YaB2daWTe5zBOU4EkltkQ==}
'@kevisual/use-config@1.0.7': '@kevisual/use-config@1.0.8':
resolution: {integrity: sha512-Ft1NICwj4NonnAnmEUMlh3tWi1GTcEtWaybg6Kv0j3+ZSp6d1v1HEXmiZvotGHkCQm6X8JSYdOeqILjOZYpERg==} resolution: {integrity: sha512-eobq7Ex61dV7k9buKIaBffoUgBwWSZu4/LBlAVS611spVqugQDrl8fx/F3tG3obNjKtMSNRkwrn78L9SIEuFJA==}
'@ljharb/resumer@0.1.3': '@ljharb/resumer@0.1.3':
resolution: {integrity: sha512-d+tsDgfkj9X5QTriqM4lKesCkMMJC3IrbPKHvayP00ELx2axdXvDfWkqjxrLXIzGcQzmj7VAUT1wopqARTvafw==} resolution: {integrity: sha512-d+tsDgfkj9X5QTriqM4lKesCkMMJC3IrbPKHvayP00ELx2axdXvDfWkqjxrLXIzGcQzmj7VAUT1wopqARTvafw==}
@ -2562,14 +2562,14 @@ snapshots:
'@kevisual/auth@1.0.5': {} '@kevisual/auth@1.0.5': {}
'@kevisual/local-app-manager@0.1.9(@kevisual/router@0.0.6)(@kevisual/types@0.0.6)(@kevisual/use-config@1.0.7)(pm2@5.4.3)': '@kevisual/local-app-manager@0.1.9(@kevisual/router@0.0.7)(@kevisual/types@0.0.6)(@kevisual/use-config@1.0.8)(pm2@5.4.3)':
dependencies: dependencies:
'@kevisual/router': 0.0.6 '@kevisual/router': 0.0.7
'@kevisual/types': 0.0.6 '@kevisual/types': 0.0.6
'@kevisual/use-config': 1.0.7 '@kevisual/use-config': 1.0.8
pm2: 5.4.3 pm2: 5.4.3
'@kevisual/router@0.0.6': '@kevisual/router@0.0.7':
dependencies: dependencies:
path-to-regexp: 8.2.0 path-to-regexp: 8.2.0
selfsigned: 2.4.1 selfsigned: 2.4.1
@ -2580,7 +2580,7 @@ snapshots:
'@kevisual/types@0.0.6': {} '@kevisual/types@0.0.6': {}
'@kevisual/use-config@1.0.7': {} '@kevisual/use-config@1.0.8': {}
'@ljharb/resumer@0.1.3': '@ljharb/resumer@0.1.3':
dependencies: dependencies:

5
scripts/update.sh Normal file
View File

@ -0,0 +1,5 @@
#!/bin/bash
pnpm i -g npm-check-updates
ncu -u
pnpm install

View File

@ -15,10 +15,15 @@ app
path: 'auth', path: 'auth',
key: 'admin', key: 'admin',
id: 'auth-admin', id: 'auth-admin',
isDebug: true,
middleware: ['auth'], middleware: ['auth'],
}) })
.define(async (ctx) => { .define(async (ctx) => {
const tokenUser = ctx.state.tokenUser; const tokenUser = ctx.state.tokenUser;
if (!tokenUser) {
ctx.throw(401, 'No User For authorized');
}
try {
const user = await User.findOne({ const user = await User.findOne({
where: { where: {
id: tokenUser.id, id: tokenUser.id,
@ -27,13 +32,19 @@ app
if (!user) { if (!user) {
ctx.throw(404, 'user not found'); ctx.throw(404, 'user not found');
} }
user.setTokenUser(tokenUser);
const orgs = await user.getOrgs(); const orgs = await user.getOrgs();
if (orgs.includes('admin')) { if (orgs.includes('admin')) {
ctx.body = 'admin'; ctx.body = 'admin';
ctx.nextQuery = ctx.query;
} else { } else {
ctx.throw(403, 'forbidden'); ctx.throw(403, 'forbidden');
} }
} catch (e) {
console.error('auth-admin error', e);
ctx.throw(500, e.message);
}
}) })
.addTo(app); .addTo(app);