Skip to content

Commit

Permalink
build指令增加参数确认环节
Browse files Browse the repository at this point in the history
  • Loading branch information
saqqdy committed Jan 31, 2024
1 parent 6c7dbdd commit e61e891
Show file tree
Hide file tree
Showing 9 changed files with 59 additions and 13 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# 更新日志

## 2024.01.31 v6.1.0

1. build指令增加参数确认环节
2. 移除构建参数转码
3. 升级依赖包

## 2024.01.08 v6.0.0

1. 移除 `server` `ui` 两个子项目
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": [
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/build/runJenkins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/docs/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@gitmars/docs",
"description": "gitmars文档库",
"version": "6.0.0",
"version": "6.1.0-beta.1",
"private": false,
"files": [
"dist",
Expand Down
2 changes: 1 addition & 1 deletion packages/gitmars/package.json
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
37 changes: 31 additions & 6 deletions packages/gitmars/src/gitm-build.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -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 {
Expand All @@ -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 <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<void> => {
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 {}
10 changes: 9 additions & 1 deletion packages/gitmars/src/locales/en-US.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)'
}
9 changes: 8 additions & 1 deletion packages/gitmars/src/locales/zh-CN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)': '清理安装包(慎用)'
}

0 comments on commit e61e891

Please sign in to comment.