mirror of
https://github.com/Kilo-Org/kilocode.git
synced 2026-08-28 19:11:03 +08:00
Merge pull request #12047 from Kilo-Org/dark-shield
feat(jetbrains): add repo CLI dev mode
This commit is contained in:
@@ -42,6 +42,9 @@ if (kind === "stable" && !/^\d+\.\d+\.\d+$/.test(ver)) throw new Error("Stable v
|
||||
if (!semver.valid(ver)) throw new Error(`Invalid semver: ${ver}`)
|
||||
|
||||
await $`git fetch origin main --tags`
|
||||
if (!(await pinned())) {
|
||||
throw new Error("packages/kilo-jetbrains/gradle.properties has kilo.cli.pinned=false; JetBrains releases require kilo.cli.pinned=true")
|
||||
}
|
||||
|
||||
const tag = `jetbrains/v${ver}`
|
||||
const branch = `jetbrains/release/v${ver}`
|
||||
@@ -161,7 +164,7 @@ async function release(from: string, tag: string, sha: string) {
|
||||
}
|
||||
|
||||
async function label(name: string, color: string, desc: string) {
|
||||
const labels = (await $`gh label list --repo ${repo} --json name --limit 1000`.json()) as { name: string }[]
|
||||
const labels: { name: string }[] = await $`gh label list --repo ${repo} --json name --limit 1000`.json()
|
||||
if (labels.some((item) => item.name === name)) return
|
||||
await $`gh label create ${name} --repo ${repo} --color ${color} --description ${desc}`
|
||||
}
|
||||
@@ -214,6 +217,16 @@ async function writeprops(ver: string) {
|
||||
await Bun.write(props, next.endsWith("\n") ? next : `${next}\n`)
|
||||
}
|
||||
|
||||
async function pinned() {
|
||||
const text = await Bun.file(props).text()
|
||||
const value = text.split(/\r?\n/).flatMap((line) => {
|
||||
const [key, raw] = line.split("=", 2)
|
||||
if (key.trim() !== "kilo.cli.pinned") return []
|
||||
return [raw?.trim().toLowerCase()]
|
||||
})[0]
|
||||
return value == null || value === "true"
|
||||
}
|
||||
|
||||
async function writelog(ver: string, entry: string) {
|
||||
const current = await Bun.file(log)
|
||||
.text()
|
||||
|
||||
@@ -39,8 +39,8 @@ type Pull = {
|
||||
state: string
|
||||
}
|
||||
|
||||
const data =
|
||||
(await $`gh pr view ${pr} --repo ${repo} --json body,headRefName,isCrossRepository,labels,mergedAt,mergeCommit,state`.json()) as Pull
|
||||
const data: Pull =
|
||||
await $`gh pr view ${pr} --repo ${repo} --json body,headRefName,isCrossRepository,labels,mergedAt,mergeCommit,state`.json()
|
||||
const labels = new Set(data.labels.map((item) => item.name))
|
||||
if (!labels.has("jetbrains-release")) throw new Error("PR is missing jetbrains-release label")
|
||||
if (data.isCrossRepository) throw new Error("JetBrains release PR must come from this repository")
|
||||
@@ -73,6 +73,9 @@ if (sha !== commit) throw new Error(`${tag} points at ${sha}, expected ${commit}
|
||||
const prop = await props()
|
||||
if (prop !== ver)
|
||||
throw new Error(`packages/kilo-jetbrains/gradle.properties kilo.jetbrains.version is ${prop}, expected ${ver}`)
|
||||
if (!(await pinned())) {
|
||||
throw new Error("packages/kilo-jetbrains/gradle.properties has kilo.cli.pinned=false; JetBrains releases require kilo.cli.pinned=true")
|
||||
}
|
||||
|
||||
const changelog = await Bun.file("packages/kilo-jetbrains/CHANGELOG.md").text()
|
||||
if (!changelog.includes(`## [${ver}]`)) throw new Error(`CHANGELOG.md is missing section for ${ver}`)
|
||||
@@ -117,3 +120,13 @@ async function props() {
|
||||
if (!value) throw new Error("packages/kilo-jetbrains/gradle.properties is missing kilo.jetbrains.version")
|
||||
return value
|
||||
}
|
||||
|
||||
async function pinned() {
|
||||
const text = await Bun.file("packages/kilo-jetbrains/gradle.properties").text()
|
||||
const value = text.split(/\r?\n/).flatMap((line) => {
|
||||
const [key, raw] = line.split("=", 2)
|
||||
if (key.trim() !== "kilo.cli.pinned") return []
|
||||
return [raw?.trim().toLowerCase()]
|
||||
})[0]
|
||||
return value == null || value === "true"
|
||||
}
|
||||
|
||||
@@ -6,6 +6,11 @@ import { fileURLToPath } from "url"
|
||||
|
||||
console.log("=== publishing ===\n")
|
||||
|
||||
// kilocode_change start - keep JetBrains CLI pin reviewable outside CLI release commits
|
||||
const jetbrainsPkg = fileURLToPath(new URL("../packages/kilo-jetbrains/package.json", import.meta.url))
|
||||
const jetbrainsPin = await Bun.file(jetbrainsPkg).text()
|
||||
// kilocode_change end
|
||||
|
||||
// kilocode_change start - consume changesets on the publish runner so changelog
|
||||
// changes are included in the release commit. Previously this ran in the
|
||||
// version job on a separate runner whose workspace was discarded.
|
||||
@@ -42,6 +47,13 @@ const pkgjsons = await Array.fromAsync(
|
||||
).then((arr) => arr.filter((x) => !x.includes("node_modules") && !x.includes("dist")))
|
||||
|
||||
for (const file of pkgjsons) {
|
||||
// kilocode_change start - create a follow-up PR for JetBrains CLI pin bumps
|
||||
if (file === jetbrainsPkg) {
|
||||
console.log("preserved JetBrains CLI pin:", file)
|
||||
await Bun.file(file).write(jetbrainsPin)
|
||||
continue
|
||||
}
|
||||
// kilocode_change end
|
||||
let pkg = await Bun.file(file).text()
|
||||
pkg = pkg.replaceAll(/"version": "[^"]+"/g, `"version": "${Script.version}"`)
|
||||
console.log("updated:", file)
|
||||
@@ -122,3 +134,34 @@ await import(`../packages/kilo-vscode/script/publish.ts`)
|
||||
|
||||
const dir = fileURLToPath(new URL("..", import.meta.url))
|
||||
process.chdir(dir)
|
||||
|
||||
// kilocode_change start - non-blocking JetBrains CLI pin bump PR after stable CLI release
|
||||
await createJetbrainsPinPr()
|
||||
// kilocode_change end
|
||||
|
||||
// kilocode_change start
|
||||
async function createJetbrainsPinPr() {
|
||||
console.log("\n=== jetbrains cli pin bump pr ===\n")
|
||||
if (!Script.release) {
|
||||
console.log("Skipping JetBrains CLI pin bump PR: not a release build")
|
||||
return
|
||||
}
|
||||
if (Script.preview) {
|
||||
console.log(`Skipping JetBrains CLI pin bump PR for pre-release v${Script.version}`)
|
||||
return
|
||||
}
|
||||
const result = await $`bun .kilo/skills/release-jetbrains/script/set-pin.ts --version ${Script.version} --pr`.nothrow()
|
||||
const out = result.stdout.toString().trim()
|
||||
const err = result.stderr.toString().trim()
|
||||
if (result.exitCode === 0) {
|
||||
if (out) console.log(out)
|
||||
const url = out.match(/https:\/\/github\.com\/\S+\/pull\/\d+/)?.[0]
|
||||
if (url) console.log(`::notice title=JetBrains CLI pin bump PR::${url}`)
|
||||
return
|
||||
}
|
||||
console.warn("JetBrains CLI pin bump PR creation failed; release will continue.")
|
||||
if (out) console.warn(out)
|
||||
if (err) console.warn(err)
|
||||
console.warn("::warning title=JetBrains CLI pin bump PR failed::Release completed, but the JetBrains CLI pin bump PR was not created. Check the logs above and create it manually if needed.")
|
||||
}
|
||||
// kilocode_change end
|
||||
|
||||
Reference in New Issue
Block a user