Skip to content

feat: add -v command to check info #74

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 24, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
chore: check question store before pull and init if not
  • Loading branch information
wh131462 committed Mar 17, 2024
commit fbe4fbc98158e43a9e15ec557859119bd787a2c2
26 changes: 22 additions & 4 deletions common/view/finder.view.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import { getPlanQuestionList } from '#common/utils/question-getter/getPlanQuesti
import { logger } from '#common/utils/logger/logger.js';
import { getQuestionListCodeBySlug, getQuestionListCodeByTag } from '#common/utils/question-handler/getQuestionListCodeBy.js';
import { getQuestionTagType } from '#common/utils/question-getter/getQuestionTagType.js';
import { getAllQuestion } from '#common/utils/store/controller/allQuestion.js';
import { getAllQuestion, setAllQuestion } from '#common/utils/store/controller/allQuestion.js';
import { getAllQuestionList } from '#common/utils/question-getter/getAllQuestionList.js';

function handleQuestionList(list) {
const questionList = [];
Expand Down Expand Up @@ -126,16 +127,33 @@ async function selectMode(baseDir = process.cwd()) {
};
const chooseTag = await select(tagQuestion);
const allQuestion = await getAllQuestion();
const tagQuestionList = await allQuestion.filter((question) => question.topicTags.some((topic) => topic.slug === chooseTag));

// 未发现题目 所以先自动拉取题目
if (!allQuestion?.length) {
logger.info('本地数据库未初始化,自动执行初始化流程,请稍等~');
try {
const allQuestionData = await getAllQuestionList();
await setAllQuestion(allQuestionData);
const newData = await getAllQuestion();
allQuestion.push(...newData);
} catch (e) {
logger.error('初始化失败!终止.');
process.exit(0);
} finally {
logger.info('本地数据库初始化完成.');
}
}
const tagQuestionList = allQuestion.filter((question) => question.topicTags?.some((topic) => topic.slug === chooseTag));
if (!tagQuestionList?.length) {
logger.info('您选择的类型暂无可拉取题目~');
process.exit(0);
}
const createMode = await select({
message: '拉题模式',
choices: [
{ name: '单个选择(不穩定)', value: 'single' },
{ name: '全部拉取(不穩定)', value: 'all' }
]
});

if (createMode === 'single') {
const singleMode = {
type: 'list',
Expand Down