forked from Gitlink/gitlink-cli
fix(workflows): 修复项目初始化/多仓库协同 + 公共库
This commit is contained in:
parent
0b6d176a45
commit
8ecbf8a203
|
|
@ -1,4 +1,4 @@
|
|||
# ----------------------------------------------------------------
|
||||
# ----------------------------------------------------------------
|
||||
# Scenario 3: One-Click Project Initialization
|
||||
# Flow: Input description -> Create repo -> README/CONTRIBUTING/CI config ->
|
||||
# Initial Issues -> Branch protection -> Initial Release
|
||||
|
|
@ -92,7 +92,7 @@ $readmeContent += "This project is licensed under the MIT License."
|
|||
|
||||
$wikiOk = $false
|
||||
for ($attempt = 1; $attempt -le 3; $attempt++) {
|
||||
$wikiResult = Invoke-GL wiki,+create,--owner,$Owner,--repo,$Name,--title,"README",--body,$readmeContent
|
||||
$wikiResult = Invoke-GL wiki,+create,--owner,$Owner,--repo,$Name,--title,"README",--content,$readmeContent
|
||||
if ($wikiResult -and (Get-JsonOk ($wikiResult | ConvertFrom-Json))) {
|
||||
Log-Ok "README created"
|
||||
$wikiOk = $true
|
||||
|
|
@ -127,7 +127,7 @@ $contribContent += "- Include environment details"
|
|||
|
||||
$wikiOk = $false
|
||||
for ($attempt = 1; $attempt -le 3; $attempt++) {
|
||||
$wikiContrib = Invoke-GL wiki,+create,--owner,$Owner,--repo,$Name,--title,"CONTRIBUTING",--body,$contribContent
|
||||
$wikiContrib = Invoke-GL wiki,+create,--owner,$Owner,--repo,$Name,--title,"CONTRIBUTING",--content,$contribContent
|
||||
if ($wikiContrib -and (Get-JsonOk ($wikiContrib | ConvertFrom-Json))) {
|
||||
Log-Ok "CONTRIBUTING guide created"
|
||||
$wikiOk = $true
|
||||
|
|
@ -150,7 +150,7 @@ $ciContent += "3. **Deploy**: Deploy to staging (master branch only)" + "`n`n"
|
|||
$ciContent += "### Configuration" + "`n`n"
|
||||
$ciContent += "Create a ``.gitlink-ci.yml`` file in the repository root."
|
||||
|
||||
Invoke-GL wiki,+create,--owner,$Owner,--repo,$Name,--title,"CI/CD Configuration",--body,$ciContent | Out-Null
|
||||
Invoke-GL wiki,+create,--owner,$Owner,--repo,$Name,--title,"CI/CD Configuration",--content,$ciContent | Out-Null
|
||||
Log-Ok "CI/CD configuration guide created"
|
||||
|
||||
# -- Step 5: Create Initial Issues --
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
# ----------------------------------------------------------------
|
||||
# ----------------------------------------------------------------
|
||||
# Scenario 4: Multi-Repo Collaboration
|
||||
# Flow: Cross-repo issue tracking -> PR status dashboard -> Coordinated release
|
||||
#
|
||||
|
|
|
|||
|
|
@ -1,5 +1,10 @@
|
|||
# Common utilities for gitlink-cli workflow scripts (PowerShell 5.1+)
|
||||
|
||||
# CRITICAL: gitlink-cli outputs UTF-8 JSON, but PS 5.1 on Chinese Windows
|
||||
# defaults to GBK (codepage 936) for decoding external program output.
|
||||
# Without this, multi-byte UTF-8 chars get garbled and JSON parsing fails.
|
||||
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
|
||||
|
||||
$Script:GL = "gitlink-cli"
|
||||
|
||||
# -- Logging --
|
||||
|
|
@ -31,25 +36,31 @@ function Check-Auth {
|
|||
|
||||
# -- CLI Wrapper --
|
||||
function Invoke-GL {
|
||||
param([string[]]$Args)
|
||||
$output = & $Script:GL @Args --format json 2>&1
|
||||
return ($output -join "`n")
|
||||
param([string[]]$Arguments)
|
||||
# Suppress stderr to keep JSON output clean (errors go to console via error stream)
|
||||
$output = & $Script:GL @Arguments --format json 2>$null
|
||||
if ($output) { return ($output -join "`n") }
|
||||
return ""
|
||||
}
|
||||
|
||||
function Invoke-GLCheck {
|
||||
param([string[]]$Args)
|
||||
$output = Invoke-GL $Args
|
||||
param([string[]]$Arguments)
|
||||
$output = Invoke-GL $Arguments
|
||||
if (-not $output) {
|
||||
Log-Err "Command returned no output: $Script:GL $($Arguments -join ' ')"
|
||||
return $null
|
||||
}
|
||||
try {
|
||||
$json = $output | ConvertFrom-Json
|
||||
if (-not $json.ok) {
|
||||
$errMsg = if ($json.error.message) { $json.error.message } else { "unknown error" }
|
||||
Log-Err "Command failed: $Script:GL $($Args -join ' ')"
|
||||
Log-Err "Command failed: $Script:GL $($Arguments -join ' ')"
|
||||
Log-Err $errMsg
|
||||
return $null
|
||||
}
|
||||
return $json
|
||||
} catch {
|
||||
Log-Err "Command failed (non-JSON): $Script:GL $($Args -join ' ')"
|
||||
Log-Err "Command failed (non-JSON response): $Script:GL $($Arguments -join ' ')"
|
||||
Log-Err $output
|
||||
return $null
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue