fix bugs for query -app
This commit is contained in:
parent
552653c8f7
commit
0507163248
@ -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",
|
||||||
|
@ -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) {
|
||||||
|
@ -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');
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -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
13
src/scripts/get-app.ts
Normal 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();
|
Loading…
x
Reference in New Issue
Block a user