This commit is contained in:
2026-01-14 00:14:25 +08:00
parent 4723efbbd2
commit 4f541748da
6 changed files with 30 additions and 13 deletions

View File

@@ -1,5 +1,5 @@
import { program, Command } from '@/program.ts';
import { getConfig } from '@/module/get-config.ts';
import { getConfig, getEnvToken } from '@/module/get-config.ts';
import inquirer from 'inquirer';
import { loginInCommand } from '@/module/login/login-by-web.ts';
import { queryLogin, storage } from '@/module/query.ts';
@@ -75,13 +75,13 @@ const loginCommand = new Command('login')
program.addCommand(loginCommand);
const showMe = async (show = true) => {
const token = process.env.KEVISUAL_TOKEN;
const token = getEnvToken();
const localToken = storage.getItem('token');
if (!token && !localToken) {
console.log('请先登录');
return { code: 40400, message: '请先登录' };
}
let me = await queryLogin.getMe(token);
let me = await queryLogin.getMe(localToken || token);
if (me?.code === 401) {
me = await queryLogin.getMe();
}

View File

@@ -1,5 +1,5 @@
import { program as app, Command } from '@/program.ts';
import { getConfig, writeConfig } from '@/module/index.ts';
import { getConfig, getEnvToken, writeConfig } from '@/module/index.ts';
import { queryLogin, storage } from '@/module/query.ts';
import inquirer from 'inquirer';
import util from 'util';
@@ -23,7 +23,7 @@ const token = new Command('token')
.action(async (opts) => {
const token = storage.getItem('token');
if (opts.env) {
console.log('token in env', process.env.KEVISUAL_TOKEN);
console.log('token in env', getEnvToken());
} else {
console.log('token', token);
}

View File

@@ -103,6 +103,9 @@ export class SyncBase {
const syncList = syncKeys.map((key) => {
const value = sync[key];
const filepath = path.join(this.#dir, key); // 文件的路径
if (filepath.includes('node_modules') || filepath.includes('.git')) {
return null;
}
if (typeof value === 'string') {
const auth = checkAuth(value, baseURL);
const type = auth ? 'sync' : 'none';
@@ -123,11 +126,14 @@ export class SyncBase {
type: value?.type ?? type,
auth: checkAuth(value.url, baseURL),
};
});
}).filter((item) => item);
let resultSyncList: SyncList[] = []
if (opts?.getFile) {
return this.getSyncListFile(syncList);
resultSyncList = await this.getSyncListFile(syncList);
} else {
resultSyncList = syncList;
}
return syncList;
return resultSyncList;
}
async getCheckList() {
const checkDir = this.config?.clone || {};