datai/datai-scenes/datai-scene-salesforce/scripts/auto-commit.ps1

203 lines
4.5 KiB
PowerShell
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env pwsh
# 自动提交脚本 - 基于 SSOT 2.0 规则
# 配置变量
$ProjectRoot = "$PSScriptRoot\.."
$DocsDir = "$ProjectRoot\docs"
$IndexFile = "$DocsDir\index.md"
$SessionsDir = "$DocsDir\sessions"
$ChangelogDir = "$DocsDir\changelog"
$CurrentDate = Get-Date -Format "yyyyMMdd"
$SessionFile = "$SessionsDir\$CurrentDate-session.md"
# 函数:更新文档索引
function Update-Index {
Write-Host "正在更新文档索引..."
# 获取所有文档文件
$DocFiles = Get-ChildItem -Path $DocsDir -Recurse -File | Where-Object { $_.Extension -eq ".md" -or $_.Extension -eq ".canvas" }
# 读取当前索引文件内容
$IndexContent = Get-Content -Path $IndexFile -Raw
# 这里可以添加更复杂的索引更新逻辑
# 例如:自动添加新文件到索引
Write-Host "文档索引更新完成"
}
# 函数:创建会话记录
function Create-Session {
Write-Host "正在创建会话记录..."
# 检查会话目录是否存在
if (!(Test-Path $SessionsDir)) {
New-Item -ItemType Directory -Path $SessionsDir -Force | Out-Null
}
# 创建会话记录内容
$SessionContent = @"
#
##
[]
##
[]
##
- [](https://example.com) -
- [](https://example.com) -
- [](https://example.com) -
## Prompt
- [Prompt ](https://example.com) - 使
## Context Snapshot
Canvas
- [Authentication.canvas](../Authentication.canvas) -
- ****: []() -
- ****: $(Get-Date -Format "yyyy-MM-dd HH:mm:ss")
##
1.
2.
3.
4. 线
##
-
-
-
-
##
- []
- []
- []
##
-
-
-
-
## Design Update
- [ ] Canvas?
- [ ] Authentication.canvas
- [ ] Canvas : ____________________
##
1. [ 1 ]
2. [ 2 ]
3. [ 3 ]
4. []
"@
# 写入会话记录文件
$SessionContent | Out-File -FilePath $SessionFile -Encoding UTF8
Write-Host "会话记录已创建: $SessionFile"
}
# 函数:创建变更记录
function Create-Changelog {
Write-Host "正在创建变更记录..."
# 检查变更日志目录是否存在
if (!(Test-Path $ChangelogDir)) {
New-Item -ItemType Directory -Path $ChangelogDir -Force | Out-Null
}
# 创建变更记录内容
$ChangelogContent = @"
# - $CurrentDate
##
- [ 1] -
- [ 2] -
- [ 3] -
##
- 1
- 2
- 3
##
- []
##
$CurrentDate
"@
# 写入变更记录文件
$ChangelogFile = "$ChangelogDir\$CurrentDate-changelog.md"
$ChangelogContent | Out-File -FilePath $ChangelogFile -Encoding UTF8
Write-Host "变更记录已创建: $ChangelogFile"
}
# 函数:执行 git 提交
function Execute-GitCommit {
Write-Host "正在执行 git 提交..."
# 切换到项目根目录
Set-Location -Path $ProjectRoot
# 添加所有变更
git add .
# 提交变更
$CommitMessage = "chore: auto-commit - $(Get-Date -Format "yyyy-MM-dd HH:mm:ss")"
git commit -m $CommitMessage
Write-Host "git 提交完成"
}
# 主函数
function Main {
Write-Host "开始执行自动提交脚本..."
# 更新文档索引
Update-Index
# 创建会话记录
Create-Session
# 创建变更记录
Create-Changelog
# 执行 git 提交
Execute-GitCommit
Write-Host "自动提交脚本执行完成!"
}
# 执行主函数
Main