Add script to easily update version

This commit is contained in:
Saoud Rizwan
2024-08-03 15:05:49 -04:00
parent 7989410696
commit 2d37c290fa
4 changed files with 43 additions and 6 deletions

View File

@@ -105,7 +105,8 @@
"install:all": "npm install && cd webview-ui && npm install",
"start:webview": "cd webview-ui && npm run start",
"build:webview": "cd webview-ui && npm run build",
"test:webview": "cd webview-ui && npm run test"
"test:webview": "cd webview-ui && npm run test",
"upver": "tsx scripts/update-version.ts"
},
"devDependencies": {
"@types/diff": "^5.2.1",

35
scripts/update-version.ts Normal file
View File

@@ -0,0 +1,35 @@
import * as fs from "fs"
import * as path from "path"
const newVersion = process.argv[2]
if (!newVersion) {
console.error("Please provide a version number")
process.exit(1)
}
// Update root package.json
const rootPackagePath = path.join(__dirname, "..", "package.json")
const rootPackage = JSON.parse(fs.readFileSync(rootPackagePath, "utf8"))
rootPackage.version = newVersion
fs.writeFileSync(rootPackagePath, JSON.stringify(rootPackage, null, 2))
// Update webview package.json
const webviewPackagePath = path.join(__dirname, "..", "webview-ui", "package.json")
const webviewPackage = JSON.parse(fs.readFileSync(webviewPackagePath, "utf8"))
webviewPackage.version = newVersion
fs.writeFileSync(webviewPackagePath, JSON.stringify(webviewPackage, null, 2))
// Update Announcement.tsx
const announcementPath = path.join(__dirname, "..", "webview-ui", "src", "components", "Announcement.tsx")
let announcementContent = fs.readFileSync(announcementPath, "utf8")
announcementContent = announcementContent.replace(/New in v[\d.]+<\/h3>/, `New in v${newVersion}</h3>`)
fs.writeFileSync(announcementPath, announcementContent)
// Update SettingsView.tsx
const settingsViewPath = path.join(__dirname, "..", "webview-ui", "src", "components", "SettingsView.tsx")
let settingsViewContent = fs.readFileSync(settingsViewPath, "utf8")
settingsViewContent = settingsViewContent.replace(/>v[\d.]+<\/p>/, `>v${newVersion}</p>`)
fs.writeFileSync(settingsViewPath, settingsViewContent)
console.log(`Version updated to ${newVersion}`)

View File

@@ -12,7 +12,7 @@
"noImplicitReturns": true,
"noUnusedLocals": false,
"resolveJsonModule": true,
"rootDir": "src",
"rootDir": ".",
"skipLibCheck": true,
"sourceMap": true,
"strict": true,
@@ -20,5 +20,6 @@
"useDefineForClassFields": true,
"useUnknownInCatchVariables": false
},
"include": ["src/**/*", "scripts/**/*"],
"exclude": ["node_modules", ".vscode-test", "webview-ui"]
}
}

View File

@@ -5,17 +5,17 @@ export function validateApiConfiguration(apiConfiguration?: ApiConfiguration): s
switch (apiConfiguration.apiProvider) {
case "anthropic":
if (!apiConfiguration.apiKey) {
return "API Key cannot be empty. You must provide an API key to use Claude Dev."
return "You must provide a valid API key or choose a different provider."
}
break
case "bedrock":
if (!apiConfiguration.awsAccessKey || !apiConfiguration.awsSecretKey || !apiConfiguration.awsRegion) {
return "AWS credentials are incomplete. You must provide an AWS access key, secret key, and region."
return "You must provide a valid AWS access key, secret key, and region."
}
break
case "openrouter":
if (!apiConfiguration.openRouterApiKey) {
return "API Key cannot be empty. You must provide an API key to use Claude Dev."
return "You must provide a valid API key or choose a different provider."
}
break
}