diff --git a/package.json b/package.json index a49e3e0..ebb09f3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@kevisual/cli", - "version": "0.0.55-beta", + "version": "0.0.55-beta-1", "description": "envision command tools", "main": "dist/app.mjs", "type": "module", diff --git a/src/command/deploy.ts b/src/command/deploy.ts index 36b98ef..d9867c2 100644 --- a/src/command/deploy.ts +++ b/src/command/deploy.ts @@ -11,6 +11,7 @@ import chalk from 'chalk'; import { installDeps } from '@/uitls/npm.ts'; import { upload } from '@/module/download/upload.ts'; import { getHash } from '@/uitls/hash.ts'; +import { queryAppVersion } from '@/query/app-manager/query-app.ts'; /** * 获取package.json 中的 basename, version, user, appKey * @returns @@ -117,7 +118,15 @@ const command = new Command('deploy') res.data?.upload?.map?.((d) => { 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) { console.log(chalk.green('id: '), id); if (!org) { @@ -159,7 +168,6 @@ type UploadFileOptions = { }; const uploadFiles = async (files: string[], directory: string, opts: UploadFileOptions): Promise => { const { key, version, username } = opts || {}; - const config = await getConfig(); const form = new FormData(); const data: Record = { files: [] }; for (const file of files) { diff --git a/src/module/query.ts b/src/module/query.ts index 7f86600..55eebb6 100644 --- a/src/module/query.ts +++ b/src/module/query.ts @@ -42,7 +42,7 @@ query.afterResponse = async (response, ctx) => { export const queryLogin = new QueryLoginNode({ query: query as any, onLoad: async () => { - // console.log('onLoad'); + console.log('onLoad'); }, }); diff --git a/src/query/app-manager/query-app.ts b/src/query/app-manager/query-app.ts index 9160887..18c40c3 100644 --- a/src/query/app-manager/query-app.ts +++ b/src/query/app-manager/query-app.ts @@ -1,10 +1,17 @@ import { query } from '@/module/query.ts'; +import { DataOpts } from '@kevisual/query'; type QueryAppParams = { id?: string; user?: string; key?: string; }; +/** + * 获取公共的应用信息 + * @param params + * @param opts + * @returns + */ export const queryApp = async (params: QueryAppParams, opts?: any) => { return await query.post( { @@ -17,3 +24,16 @@ export const queryApp = async (params: QueryAppParams, opts?: any) => { 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, + ); +}; diff --git a/src/scripts/get-app.ts b/src/scripts/get-app.ts new file mode 100644 index 0000000..21330c1 --- /dev/null +++ b/src/scripts/get-app.ts @@ -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();