fix bugs for query -app

This commit is contained in:
熊潇 2025-05-29 04:04:11 +08:00
parent 552653c8f7
commit 0507163248
5 changed files with 45 additions and 4 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "@kevisual/cli", "name": "@kevisual/cli",
"version": "0.0.55-beta", "version": "0.0.55-beta-1",
"description": "envision command tools", "description": "envision command tools",
"main": "dist/app.mjs", "main": "dist/app.mjs",
"type": "module", "type": "module",

View File

@ -11,6 +11,7 @@ import chalk from 'chalk';
import { installDeps } from '@/uitls/npm.ts'; import { installDeps } from '@/uitls/npm.ts';
import { upload } from '@/module/download/upload.ts'; import { upload } from '@/module/download/upload.ts';
import { getHash } from '@/uitls/hash.ts'; import { getHash } from '@/uitls/hash.ts';
import { queryAppVersion } from '@/query/app-manager/query-app.ts';
/** /**
* package.json basename, version, user, appKey * package.json basename, version, user, appKey
* @returns * @returns
@ -117,7 +118,15 @@ const command = new Command('deploy')
res.data?.upload?.map?.((d) => { res.data?.upload?.map?.((d) => {
console.log(chalk.green('uploaded file', d?.name, d?.path)); console.log(chalk.green('uploaded file', d?.name, d?.path));
}); });
const { id, data, ...rest } = res.data?.app || {}; const res2 = await queryAppVersion({
key: key,
version: version,
});
if (res2.code !== 200) {
console.error(chalk.red('查询应用版本失败'), res2.message);
return;
}
const { id, data, ...rest } = res2.data?.app || {};
if (id && !update) { if (id && !update) {
console.log(chalk.green('id: '), id); console.log(chalk.green('id: '), id);
if (!org) { if (!org) {
@ -159,7 +168,6 @@ type UploadFileOptions = {
}; };
const uploadFiles = async (files: string[], directory: string, opts: UploadFileOptions): Promise<any> => { const uploadFiles = async (files: string[], directory: string, opts: UploadFileOptions): Promise<any> => {
const { key, version, username } = opts || {}; const { key, version, username } = opts || {};
const config = await getConfig();
const form = new FormData(); const form = new FormData();
const data: Record<string, any> = { files: [] }; const data: Record<string, any> = { files: [] };
for (const file of files) { for (const file of files) {

View File

@ -42,7 +42,7 @@ query.afterResponse = async (response, ctx) => {
export const queryLogin = new QueryLoginNode({ export const queryLogin = new QueryLoginNode({
query: query as any, query: query as any,
onLoad: async () => { onLoad: async () => {
// console.log('onLoad'); console.log('onLoad');
}, },
}); });

View File

@ -1,10 +1,17 @@
import { query } from '@/module/query.ts'; import { query } from '@/module/query.ts';
import { DataOpts } from '@kevisual/query';
type QueryAppParams = { type QueryAppParams = {
id?: string; id?: string;
user?: string; user?: string;
key?: string; key?: string;
}; };
/**
*
* @param params
* @param opts
* @returns
*/
export const queryApp = async (params: QueryAppParams, opts?: any) => { export const queryApp = async (params: QueryAppParams, opts?: any) => {
return await query.post( return await query.post(
{ {
@ -17,3 +24,16 @@ export const queryApp = async (params: QueryAppParams, opts?: any) => {
opts, opts,
); );
}; };
export const queryAppVersion = async (params: { key?: string; version?: string; id?: string }, opts?: DataOpts) => {
return await query.post(
{
path: 'app',
key: 'get',
data: {
...params,
},
},
opts,
);
};

13
src/scripts/get-app.ts Normal file
View File

@ -0,0 +1,13 @@
import { queryAppVersion } from '@/query/app-manager/query-app.ts';
import { sleep } from 'bun';
await sleep(2000); // Ensure the environment is ready
const main = async () => {
console.log('Fetching app version...');
const res = await queryAppVersion({
key: 'center',
version: '0.0.11',
});
console.log(res);
};
main();