From e61e891edf3cf08558f7a39271163cae5df97155 Mon Sep 17 00:00:00 2001 From: saqqdy Date: Wed, 31 Jan 2024 17:37:59 +0800 Subject: [PATCH] =?UTF-8?q?build=E6=8C=87=E4=BB=A4=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E5=8F=82=E6=95=B0=E7=A1=AE=E8=AE=A4=E7=8E=AF=E8=8A=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 6 +++++ package.json | 2 +- packages/core/package.json | 2 +- packages/core/src/build/runJenkins.ts | 2 +- packages/docs/package.json | 2 +- packages/gitmars/package.json | 2 +- packages/gitmars/src/gitm-build.ts | 37 ++++++++++++++++++++++----- packages/gitmars/src/locales/en-US.ts | 10 +++++++- packages/gitmars/src/locales/zh-CN.ts | 9 ++++++- 9 files changed, 59 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f583b48a..ea75cea1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # 更新日志 +## 2024.01.31 v6.1.0 + +1. build指令增加参数确认环节 +2. 移除构建参数转码 +3. 升级依赖包 + ## 2024.01.08 v6.0.0 1. 移除 `server` `ui` 两个子项目 diff --git a/package.json b/package.json index e034c7ce..f43c147f 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@gitmars/monorepo", "description": "这是一个git工作流工具", - "version": "6.0.0", + "version": "6.1.0-beta.1", "packageManager": "pnpm@8.7.4", "main": "index.js", "files": [ diff --git a/packages/core/package.json b/packages/core/package.json index 193556d5..8bbbdfc7 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,7 +1,7 @@ { "name": "@gitmars/core", "description": "gitmars核心程序", - "version": "6.0.0", + "version": "6.1.0-beta.1", "private": false, "main": "./lib/index.js", "module": "./lib/index.mjs", diff --git a/packages/core/src/build/runJenkins.ts b/packages/core/src/build/runJenkins.ts index 4f966ab9..40dbfdb0 100644 --- a/packages/core/src/build/runJenkins.ts +++ b/packages/core/src/build/runJenkins.ts @@ -75,7 +75,7 @@ async function runJenkins({ try { const _data = JSON.parse(data) for (const key in _data) { - url.searchParams.append(key, encodeURIComponent(_data[key])) + url.searchParams.append(key, _data[key]) } } catch {} } diff --git a/packages/docs/package.json b/packages/docs/package.json index 8a6a0005..63b4faa8 100644 --- a/packages/docs/package.json +++ b/packages/docs/package.json @@ -1,7 +1,7 @@ { "name": "@gitmars/docs", "description": "gitmars文档库", - "version": "6.0.0", + "version": "6.1.0-beta.1", "private": false, "files": [ "dist", diff --git a/packages/gitmars/package.json b/packages/gitmars/package.json index 5885b033..7de884fb 100644 --- a/packages/gitmars/package.json +++ b/packages/gitmars/package.json @@ -1,7 +1,7 @@ { "name": "gitmars", "description": "这是一个git工作流工具", - "version": "6.0.0", + "version": "6.1.0-beta.1", "private": false, "bin": { "gitm": "lib/gitm.mjs" diff --git a/packages/gitmars/src/gitm-build.ts b/packages/gitmars/src/gitm-build.ts index b932b3c4..1bc392ca 100755 --- a/packages/gitmars/src/gitm-build.ts +++ b/packages/gitmars/src/gitm-build.ts @@ -1,5 +1,7 @@ #!/usr/bin/env ts-node import { program } from 'commander' +import inquirer from 'inquirer' +import chalk from 'chalk' import { createArgs } from '@gitmars/core/lib/utils/command' import runJenkins from '@gitmars/core/lib/build/runJenkins' import { type ApolloBranchList } from '@gitmars/core/typings/core' @@ -8,6 +10,7 @@ import lang from '#lib/common/local' import buildConfig from '#lib/conf/build' const { t } = lang +const { red, yellow } = chalk const { args, options } = buildConfig interface GitmBuildOption { @@ -29,13 +32,35 @@ options.forEach((o: GitmarsOptionOptionsType) => { // .option('-e, --env [env]', t('Environment to be built, optionally dev, prod, bug, all'), 'dev') // .option('-a, --app [app]', t('Application to be built'), 'all') // .option('-d, --data ', t('Other data to be transferred'), '{}') -program.action((project: string, opt: GitmBuildOption): void => { - runJenkins({ - env: opt.env, - project, - app: opt.app, - data: opt.data +program.action(async (project: string, opt: GitmBuildOption): Promise => { + const data = JSON.parse(opt.data || '{}') + let message = `${yellow(t('Please double check the following build parameters'))}\n${t( + 'Project Name' + )}: ${red(project)}\n${t('Code Branch')}: ${red(opt.env)}\n${t('Build Application')}: ${red( + opt.app + )}` + + if ('build_api_env' in data) + message += `\n${t('Interface Environment')}: ${red(data.build_api_env)}` + if ('mini_program' in data) + message += `\n${t('Experience version pushed to')}: ${red(data.mini_program)}` + if ('description' in data) message += `\n${t('Version Description')}: ${red(data.description)}` + if ('clean' in data) + message += `\n${t('Clean node modules (use with caution)')}: ${red(data.clean)}` + + const { confirm } = await inquirer.prompt({ + type: 'confirm', + name: 'confirm', + message }) + + confirm && + runJenkins({ + env: opt.env, + project, + app: opt.app, + data: opt.data + }) }) program.parse(process.argv) export {} diff --git a/packages/gitmars/src/locales/en-US.ts b/packages/gitmars/src/locales/en-US.ts index f5c9d6d7..9b92123e 100644 --- a/packages/gitmars/src/locales/en-US.ts +++ b/packages/gitmars/src/locales/en-US.ts @@ -451,5 +451,13 @@ export default { 'Use strict mode': 'Use strict mode', '--as-feature is only used in the bugfix branch.': '--as-feature is only used in the bugfix branch.', - 'Other data to be transferred': 'Other data to be transferred' + 'Other data to be transferred': 'Other data to be transferred', + 'Please double check the following build parameters': + 'Please double check the following build parameters', + 'Code Branch': 'Code Branch', + 'Build Application': 'Build Application', + 'Interface Environment': 'Interface Environment', + 'Experience version pushed to': 'Experience version pushed to', + 'Version Description': 'Version Description', + 'Clean node modules (use with caution)': 'Clean node modules (use with caution)' } diff --git a/packages/gitmars/src/locales/zh-CN.ts b/packages/gitmars/src/locales/zh-CN.ts index 863cbc81..23753a9b 100644 --- a/packages/gitmars/src/locales/zh-CN.ts +++ b/packages/gitmars/src/locales/zh-CN.ts @@ -411,5 +411,12 @@ export default { '{source} branch has merged {target} branch': '{source}合并过{target}', 'Use strict mode': '使用严格模式', '--as-feature is only used in the bugfix branch.': '--as-feature仅用于bugfix分支', - 'Other data to be transferred': '需要传输的其他数据' + 'Other data to be transferred': '需要传输的其他数据', + 'Please double check the following build parameters': '请仔细确认以下构建参数', + 'Code Branch': '代码分支', + 'Build Application': '构建应用', + 'Interface Environment': '接口环境', + 'Experience version pushed to': '体验版推送至', + 'Version Description': '版本描述', + 'Clean node modules (use with caution)': '清理安装包(慎用)' }