فهرست منبع

Add script to easily update version

Saoud Rizwan 1 سال پیش
والد
کامیت
2d37c290fa
4فایلهای تغییر یافته به همراه43 افزوده شده و 6 حذف شده
  1. 2 1
      package.json
  2. 35 0
      scripts/update-version.ts
  3. 3 2
      tsconfig.json
  4. 3 3
      webview-ui/src/utilities/validate.ts

+ 2 - 1
package.json

@@ -105,7 +105,8 @@
     "install:all": "npm install && cd webview-ui && npm install",
     "install:all": "npm install && cd webview-ui && npm install",
     "start:webview": "cd webview-ui && npm run start",
     "start:webview": "cd webview-ui && npm run start",
     "build:webview": "cd webview-ui && npm run build",
     "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": {
   "devDependencies": {
     "@types/diff": "^5.2.1",
     "@types/diff": "^5.2.1",

+ 35 - 0
scripts/update-version.ts

@@ -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}`)

+ 3 - 2
tsconfig.json

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

+ 3 - 3
webview-ui/src/utilities/validate.ts

@@ -5,17 +5,17 @@ export function validateApiConfiguration(apiConfiguration?: ApiConfiguration): s
 		switch (apiConfiguration.apiProvider) {
 		switch (apiConfiguration.apiProvider) {
 			case "anthropic":
 			case "anthropic":
 				if (!apiConfiguration.apiKey) {
 				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
 				break
 			case "bedrock":
 			case "bedrock":
 				if (!apiConfiguration.awsAccessKey || !apiConfiguration.awsSecretKey || !apiConfiguration.awsRegion) {
 				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
 				break
 			case "openrouter":
 			case "openrouter":
 				if (!apiConfiguration.openRouterApiKey) {
 				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
 				break
 		}
 		}