-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: 优化 @mango-scripts/dev-scripts 发包脚本逻辑
- Loading branch information
1 parent
90d7c14
commit 70d2dd2
Showing
19 changed files
with
771 additions
and
413 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
75 changes: 75 additions & 0 deletions
75
packages/dev-scripts/src/scripts/releasePackage/confirmEnv.mts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import { | ||
pico, | ||
consola, | ||
inquirer, | ||
getGitRepoInfo, | ||
ora, | ||
} from '@mango-scripts/utils' | ||
|
||
import { run } from '../../utils/index.mjs' | ||
|
||
export const confirmRegistry = async () => { | ||
const registry = ( | ||
await run('npm', ['config', 'get', 'registry'], { stdio: 'pipe' }) | ||
).stdout | ||
|
||
const { yes }: { yes: boolean } = await inquirer.prompt([ | ||
{ | ||
type: 'confirm', | ||
name: 'yes', | ||
message: `当前 npm registry 为: ${pico.yellow(registry)},确定? `, | ||
}, | ||
]) | ||
|
||
return yes | ||
} | ||
|
||
export const confirmGitBranch = async () => { | ||
const { branch } = getGitRepoInfo() | ||
const { yes }: { yes: boolean } = await inquirer.prompt([ | ||
{ | ||
type: 'confirm', | ||
name: 'yes', | ||
message: `当前发布的分支为: ${pico.yellow(branch)},确定?`, | ||
}, | ||
]) | ||
|
||
return yes | ||
} | ||
|
||
export const confirmWorktreeEmpty = async () => { | ||
const isWorktreeEmpty = !( | ||
await run('git', ['status', '--porcelain'], { stdio: 'pipe' }) | ||
)?.stdout | ||
|
||
!isWorktreeEmpty && | ||
consola.error('检测到当前工作区有尚未提交的代码,请先提交代码') | ||
|
||
return isWorktreeEmpty | ||
} | ||
|
||
export const confirmNpmLoggedIn = async () => { | ||
try { | ||
const spinner = ora().start(`获取 npm 登录状态...`) | ||
const user = (await run('npm', ['whoami'], { stdio: 'pipe' })).stdout.trim() | ||
spinner.stop() | ||
|
||
if (!user) { | ||
consola.error('检测到你尚未登录 npm,请使用 `npm login` 登录后再继续。') | ||
return false | ||
} | ||
|
||
const { yes }: { yes: boolean } = await inquirer.prompt([ | ||
{ | ||
type: 'confirm', | ||
name: 'yes', | ||
message: `当前登录的 npm 用户为: ${pico.cyan(user)},确定?`, | ||
}, | ||
]) | ||
|
||
return yes | ||
} catch (error) { | ||
consola.error('检测到您尚未登录 npm,请使用 `npm login` 登录后再继续。') | ||
return false | ||
} | ||
} |
Oops, something went wrong.