update: 优化部署
This commit is contained in:
		| @@ -1,6 +1,6 @@ | ||||
| { | ||||
|   "name": "@kevisual/cli", | ||||
|   "version": "0.0.56-beta.4", | ||||
|   "version": "0.0.56", | ||||
|   "description": "envision command tools", | ||||
|   "main": "dist/app.mjs", | ||||
|   "type": "module", | ||||
|   | ||||
| @@ -91,7 +91,7 @@ const command = new Command('deploy') | ||||
|       if (stat.isDirectory()) { | ||||
|         isDirectory = true; | ||||
|         const gPath = path.join(directory, '**/*'); | ||||
|         const files = await glob(gPath, { cwd: pwd, ignore: ['node_modules/**/*'], onlyFiles: true, dot }); | ||||
|         const files = await glob(gPath, { cwd: pwd, ignore: ['node_modules/**/*', '.git/**/*', '.DS_Store'], onlyFiles: true, dot }); | ||||
|         _relativeFiles = files.map((file) => path.relative(directory, file)); | ||||
|       } else if (stat.isFile()) { | ||||
|         const filename = path.basename(directory); | ||||
|   | ||||
| @@ -349,11 +349,26 @@ const deployLoadFn = async (id: string, fileKey: string, force = false, install | ||||
|   //   devDependencies: [Object], | ||||
|   //   dependencies: [Object] | ||||
|   // }, | ||||
|   let appKey = ''; | ||||
|   let version = ''; | ||||
|   if (id && id.includes('/')) { | ||||
|     const [a, b] = id.split('/'); | ||||
|     if (a) { | ||||
|       appKey = b || '1.0.0'; | ||||
|       version = a; | ||||
|       id = ''; | ||||
|     } else { | ||||
|       console.error(chalk.red('id format error, please use "version/appKey" format')); | ||||
|       return; | ||||
|     } | ||||
|   } | ||||
|   const res = await query.post({ | ||||
|     path: 'micro-app', | ||||
|     key: 'deploy', | ||||
|     data: { | ||||
|       id: id, | ||||
|       version: version, | ||||
|       appKey: appKey, | ||||
|       key: fileKey, | ||||
|       force: force, | ||||
|       install: !!install, | ||||
|   | ||||
| @@ -20,7 +20,7 @@ const syncUpload = new Command('upload') | ||||
|   .option('-d --dir <dir>', '配置目录') | ||||
|   .option('-c --config <config>', '配置文件的名字', 'kevisual.json') | ||||
|   .option('-f --file <file>', '操作的对应的文件名') | ||||
|   .description('上传项目') | ||||
|   .description('上传项目, 上传需要和registry的地址同步。') | ||||
|   .action(async (opts) => { | ||||
|     console.log('上传项目'); | ||||
|     const sync = new SyncBase({ dir: opts.dir, baseURL: baseURL, configFilename: opts.config }); | ||||
| @@ -32,6 +32,8 @@ const syncUpload = new Command('upload') | ||||
|       ...sync.config.metadata, | ||||
|     }; | ||||
|     const filepath = sync.getRelativePath(opts.file); | ||||
|     const newInfos = []; | ||||
|  | ||||
|     for (const item of syncList) { | ||||
|       if (!item.auth || !item.exist) { | ||||
|         nodonwArr.push(item); | ||||
| @@ -54,15 +56,22 @@ const syncUpload = new Command('upload') | ||||
|       }); | ||||
|       if (res.code === 200) { | ||||
|         if (res.data?.isNew) { | ||||
|           logger.info('上传成功', item.key, chalk.green(item.url), chalk.green('文件上传')); | ||||
|           newInfos.push(['上传成功', item.key, chalk.green(item.url), chalk.green('文件上传')]); | ||||
|         } else if (res.data?.isNewMeta) { | ||||
|           logger.info('上传成功', item.key, chalk.green(item.url), chalk.green('元数据更新')); | ||||
|           newInfos.push(['上传成功', item.key, chalk.green(item.url), chalk.green('元数据更新')]); | ||||
|         } else { | ||||
|           // 文件未更新 | ||||
|           logger.info('上传成功', item.key, chalk.green(item.url), chalk.blue('文件未更新')); | ||||
|         } | ||||
|       } | ||||
|       logger.debug(res); | ||||
|     } | ||||
|     if (newInfos.length) { | ||||
|       logger.info('上传成功的文件\n'); | ||||
|       newInfos.forEach((item) => { | ||||
|         logger.info(...item); | ||||
|       }); | ||||
|     } | ||||
|     if (nodonwArr.length && !filepath) { | ||||
|       logger.warn('以下文件未上传\n', nodonwArr.map((item) => item.key).join(',')); | ||||
|     } | ||||
|   | ||||
| @@ -31,11 +31,12 @@ type Options = { | ||||
|   hash?: string; | ||||
|   [key: string]: any; | ||||
| }; | ||||
| export const fetchLink = async (url: string, opts?: Options) => { | ||||
| export const fetchLink = async (url: string = '', opts?: Options) => { | ||||
|   const token = process.env.KEVISUAL_TOKEN || storage.getItem('token'); | ||||
|   const fetchURL = new URL(url); | ||||
|   const check = opts?.check ?? false; | ||||
|   const setToken = opts?.setToken ?? true; | ||||
|   const isKevisual = !!url.includes('kevisual'); | ||||
|   const setToken = opts?.setToken ?? isKevisual; | ||||
|   if (check) { | ||||
|     if (!url.startsWith(baseURL)) { | ||||
|       throw new Error('url must start with ' + baseURL); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user