@maiyunnet/kebab 9.29.0 → 9.29.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/abox/session-login.js +4 -1
- package/doc/kebab-rag.md +206 -182
- package/index.d.ts +1 -1
- package/index.js +1 -2
- package/lib/core.js +4 -1
- package/lib/session/login.d.ts +4 -2
- package/lib/session/login.js +1 -1
- package/package.json +1 -1
- package/sys/master.js +30 -11
package/index.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/naming-convention */
|
|
2
1
|
/**
|
|
3
2
|
* Project: Kebab, User: JianSuoQiYue
|
|
4
3
|
* Date: 2019-3-30 12:46:41
|
|
5
4
|
* --- 本文件用来定义每个目录实体地址的常量 ---
|
|
6
5
|
*/
|
|
7
6
|
/** --- 当前系统版本号 --- */
|
|
8
|
-
export const VER = '9.29.
|
|
7
|
+
export const VER = '9.29.2';
|
|
9
8
|
// --- 服务端用的路径 ---
|
|
10
9
|
const imu = decodeURIComponent(import.meta.url).replace('file://', '').replace(/^\/(\w:)/, '$1');
|
|
11
10
|
/** --- /xxx/xxx --- */
|
package/lib/core.js
CHANGED
|
@@ -880,7 +880,10 @@ export async function updateCode(sourcePath, path, hosts, config = true, strict
|
|
|
880
880
|
}
|
|
881
881
|
const bodyHash = await rpc.hashFile(sourcePath);
|
|
882
882
|
if (bodyHash === false) {
|
|
883
|
-
return {
|
|
883
|
+
return Object.fromEntries(hosts.map(host => [host, {
|
|
884
|
+
'result': false,
|
|
885
|
+
'return': 'Failed to read deployment archive',
|
|
886
|
+
}]));
|
|
884
887
|
}
|
|
885
888
|
/** --- 各主机使用独立上传流并行部署,结果保持输入顺序 --- */
|
|
886
889
|
const results = await Promise.all(hosts.map(async (host) => {
|
package/lib/session/login.d.ts
CHANGED
|
@@ -25,8 +25,10 @@ export interface ILoginRecord {
|
|
|
25
25
|
'scope': string;
|
|
26
26
|
/** --- 业务授权版本,框架不查询业务数据验证此值 --- */
|
|
27
27
|
'version': string;
|
|
28
|
-
/** --- 登录时间,Redis 服务端 UTC Unix
|
|
28
|
+
/** --- 登录时间,Redis 服务端 UTC Unix 秒,0 表示未记录 --- */
|
|
29
29
|
'timeAdd': number;
|
|
30
|
+
/** --- 最后访问时间,创建及成功 touch 时更新;Redis 服务端 UTC Unix 秒,0 表示未记录 --- */
|
|
31
|
+
'timeLast': number;
|
|
30
32
|
/** --- 登录时保存的附加信息 --- */
|
|
31
33
|
'data': Record<string, LoginValue>;
|
|
32
34
|
}
|
|
@@ -81,7 +83,7 @@ export declare class Login {
|
|
|
81
83
|
*/
|
|
82
84
|
get(): Promise<ILoginRecord | null | false>;
|
|
83
85
|
/**
|
|
84
|
-
* ---
|
|
86
|
+
* --- 更新仍与本次请求读取的登录 UID 匹配的授权访问时间,并延长有效期 ---
|
|
85
87
|
* @param uid get 返回的登录 UID
|
|
86
88
|
* @returns true 成功,null 已失效或被替换,false 输入无效或存储失败
|
|
87
89
|
*/
|
package/lib/session/login.js
CHANGED
package/package.json
CHANGED
package/sys/master.js
CHANGED
|
@@ -486,7 +486,10 @@ function createRpcListener() {
|
|
|
486
486
|
res.end(`[code][0] [${msg.strict}] Path not found: ${to}`);
|
|
487
487
|
return;
|
|
488
488
|
}
|
|
489
|
-
await lFs.mkdir(to)
|
|
489
|
+
if (!await lFs.mkdir(to)) {
|
|
490
|
+
res.end(`Failed to create directory: ${to}`);
|
|
491
|
+
return;
|
|
492
|
+
}
|
|
490
493
|
}
|
|
491
494
|
const buf = await lFs.getContent(body.file);
|
|
492
495
|
if (!buf) {
|
|
@@ -667,7 +670,10 @@ function createRpcListener() {
|
|
|
667
670
|
res.end(`[code][1] [${msg.strict}] Path not found: ${targetDir}`);
|
|
668
671
|
return;
|
|
669
672
|
}
|
|
670
|
-
await lFs.mkdir(targetDir)
|
|
673
|
+
if (!await lFs.mkdir(targetDir)) {
|
|
674
|
+
res.end(`Failed to create directory: ${targetDir}`);
|
|
675
|
+
return;
|
|
676
|
+
}
|
|
671
677
|
}
|
|
672
678
|
const targetFile = await resolvePathInside(to, pat + fname);
|
|
673
679
|
if (!targetFile) {
|
|
@@ -679,7 +685,10 @@ function createRpcListener() {
|
|
|
679
685
|
res.end(`[code][2] [${msg.strict}] Path not found: ${targetFile}`);
|
|
680
686
|
return;
|
|
681
687
|
}
|
|
682
|
-
await lFs.putContent(targetFile, ls[archivePath])
|
|
688
|
+
if (!await lFs.putContent(targetFile, ls[archivePath])) {
|
|
689
|
+
res.end(`Failed to write file: ${targetFile}`);
|
|
690
|
+
return;
|
|
691
|
+
}
|
|
683
692
|
}
|
|
684
693
|
// --- 检查是否更新 config ---
|
|
685
694
|
const configType = msg.config;
|
|
@@ -693,25 +702,35 @@ function createRpcListener() {
|
|
|
693
702
|
}
|
|
694
703
|
const projectContent = await lFs.getContent(projectFile, 'utf8');
|
|
695
704
|
if (!projectContent) {
|
|
696
|
-
|
|
705
|
+
res.end(`Failed to read file: ${projectFile}`);
|
|
706
|
+
return;
|
|
697
707
|
}
|
|
698
708
|
const projectJson = lText.parseJson(projectContent);
|
|
699
709
|
if (!projectJson) {
|
|
700
|
-
|
|
710
|
+
res.end(`Invalid config: ${projectFile}`);
|
|
711
|
+
return;
|
|
701
712
|
}
|
|
702
713
|
projectJson.set ??= {};
|
|
703
714
|
projectJson.set.staticVer = staticVer;
|
|
704
|
-
await lFs.putContent(projectFile, lText.stringifyJson(projectJson, 4), {
|
|
715
|
+
if (!await lFs.putContent(projectFile, lText.stringifyJson(projectJson, 4), {
|
|
705
716
|
'encoding': 'utf8'
|
|
706
|
-
})
|
|
717
|
+
})) {
|
|
718
|
+
res.end(`Failed to write file: ${projectFile}`);
|
|
719
|
+
return;
|
|
720
|
+
}
|
|
707
721
|
}
|
|
708
722
|
}
|
|
709
723
|
else if (configType === '2') {
|
|
710
724
|
const configContent = await lFs.getContent(kebab.CONF_CWD + 'config.json', 'utf8');
|
|
711
|
-
if (configContent) {
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
725
|
+
if (!configContent) {
|
|
726
|
+
res.end(`Failed to read file: ${kebab.CONF_CWD}config.json`);
|
|
727
|
+
return;
|
|
728
|
+
}
|
|
729
|
+
if (!await lFs.putContent(kebab.CONF_CWD + 'config.json', configContent.replace(/"staticVer": ".+?"/, `"staticVer": "${lTime.format(null, 'YmdHis')}"`), {
|
|
730
|
+
'encoding': 'utf8'
|
|
731
|
+
})) {
|
|
732
|
+
res.end(`Failed to write file: ${kebab.CONF_CWD}config.json`);
|
|
733
|
+
return;
|
|
715
734
|
}
|
|
716
735
|
}
|
|
717
736
|
break;
|