Support parameterize packaging
This commit is contained in:
parent
cc35fd3380
commit
6ba62c44bf
7
.env.example
Normal file
7
.env.example
Normal file
@ -0,0 +1,7 @@
|
||||
EXTENSION_NAME=devchat
|
||||
PUBLISHER=merico
|
||||
ASSISTANT_NAME_EN=DevChat
|
||||
ASSISTANT_NAME_ZH=DevChat
|
||||
EXTENSION_ICON=/path/to/extension_icon.png
|
||||
SIDEBAR_ICON=/path/to/sidebar_icon.svg
|
||||
DIFF_APPLY_ICON=/path/to/diff_apply_icon.svg
|
52
package.json
52
package.json
@ -1,13 +1,17 @@
|
||||
{
|
||||
"name": "devchat",
|
||||
"displayName": "DevChat",
|
||||
"name": "${EXTENSION_NAME}",
|
||||
"displayName": "${ASSISTANT_NAME_ZH}",
|
||||
"description": "Write prompts, not code",
|
||||
"version": "0.1.74",
|
||||
"icon": "assets/devchat.png",
|
||||
"publisher": "merico",
|
||||
"publisher": "${PUBLISHER}",
|
||||
"engines": {
|
||||
"vscode": "^1.75.0"
|
||||
},
|
||||
"assistantNames": {
|
||||
"ASSISTANT_NAME_EN": "${ASSISTANT_NAME_EN}",
|
||||
"ASSISTANT_NAME_ZH": "${ASSISTANT_NAME_ZH}"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/devchat-ai/devchat-vscode.git"
|
||||
@ -72,7 +76,7 @@
|
||||
"activitybar": [
|
||||
{
|
||||
"id": "devchat-sidebar",
|
||||
"title": "DevChat",
|
||||
"title": "${ASSISTANT_NAME_ZH}",
|
||||
"icon": "assets/devchat_icon.svg"
|
||||
}
|
||||
]
|
||||
@ -82,7 +86,7 @@
|
||||
{
|
||||
"type": "webview",
|
||||
"id": "devchat-view",
|
||||
"name": "DevChat"
|
||||
"name": "${ASSISTANT_NAME_ZH}"
|
||||
}
|
||||
]
|
||||
},
|
||||
@ -103,27 +107,27 @@
|
||||
},
|
||||
{
|
||||
"command": "devchat.addContext",
|
||||
"title": "Devchat:Add to DevChat"
|
||||
"title": "${ASSISTANT_NAME_EN}:Add to ${ASSISTANT_NAME_EN}"
|
||||
},
|
||||
{
|
||||
"command": "devchat.askForCode",
|
||||
"title": "Devchat:Add to DevChat"
|
||||
"title": "${ASSISTANT_NAME_EN}:Add to ${ASSISTANT_NAME_EN}"
|
||||
},
|
||||
{
|
||||
"command": "devchat.askForFile",
|
||||
"title": "Devchat:Add to DevChat"
|
||||
"title": "${ASSISTANT_NAME_EN}:Add to ${ASSISTANT_NAME_EN}"
|
||||
},
|
||||
{
|
||||
"command": "devchat.addConext_chinese",
|
||||
"title": "Devchat:添加到DevChat"
|
||||
"title": "${ASSISTANT_NAME_ZH}:添加到${ASSISTANT_NAME_ZH}"
|
||||
},
|
||||
{
|
||||
"command": "devchat.askForCode_chinese",
|
||||
"title": "Devchat:添加到DevChat"
|
||||
"title": "${ASSISTANT_NAME_ZH}:添加到${ASSISTANT_NAME_ZH}"
|
||||
},
|
||||
{
|
||||
"command": "devchat.askForFile_chinese",
|
||||
"title": "Devchat:添加到DevChat"
|
||||
"title": "${ASSISTANT_NAME_ZH}:添加到${ASSISTANT_NAME_ZH}"
|
||||
},
|
||||
{
|
||||
"command": "DevChat.InstallCommands",
|
||||
@ -137,32 +141,32 @@
|
||||
},
|
||||
{
|
||||
"command": "DevChat.Chat",
|
||||
"title": "Chat with DevChat",
|
||||
"title": "Chat with ${ASSISTANT_NAME_EN}",
|
||||
"category": "DevChat"
|
||||
},
|
||||
{
|
||||
"command": "devchat.explain",
|
||||
"title": "Devchat:Generate Explain"
|
||||
"title": "${ASSISTANT_NAME_EN}:Generate Explain"
|
||||
},
|
||||
{
|
||||
"command": "devchat.explain_chinese",
|
||||
"title": "Devchat:代码解释"
|
||||
"title": "${ASSISTANT_NAME_ZH}:代码解释"
|
||||
},
|
||||
{
|
||||
"command": "devchat.comments",
|
||||
"title": "Devchat:Generate Comments"
|
||||
"title": "${ASSISTANT_NAME_EN}:Generate Comments"
|
||||
},
|
||||
{
|
||||
"command": "devchat.comments_chinese",
|
||||
"title": "Devchat:生成注释"
|
||||
"title": "${ASSISTANT_NAME_ZH}:生成注释"
|
||||
},
|
||||
{
|
||||
"command": "devchat.fix",
|
||||
"title": "Devchat:Fix this"
|
||||
"title": "${ASSISTANT_NAME_EN}:Fix this"
|
||||
},
|
||||
{
|
||||
"command": "devchat.fix_chinese",
|
||||
"title": "Devchat:修复此"
|
||||
"title": "${ASSISTANT_NAME_ZH}:修复此"
|
||||
},
|
||||
{
|
||||
"command": "DevChat.codecomplete_callback",
|
||||
@ -171,12 +175,12 @@
|
||||
},
|
||||
{
|
||||
"command": "DevChat.quickFixAskDevChat",
|
||||
"title": "Ask DevChat",
|
||||
"title": "Ask ${ASSISTANT_NAME_EN}",
|
||||
"category": "DevChat"
|
||||
},
|
||||
{
|
||||
"command": "DevChat.quickFixUsingDevChat",
|
||||
"title": "Ask DevChat",
|
||||
"title": "Ask ${ASSISTANT_NAME_EN}",
|
||||
"category": "DevChat"
|
||||
}
|
||||
],
|
||||
@ -344,10 +348,14 @@
|
||||
"vscode:uninstall": "node ./dist/uninstall",
|
||||
"vscode:prepublish": "npm run package",
|
||||
"compile": "webpack",
|
||||
"watch": "webpack --watch",
|
||||
"watch": "node prebuild.js && webpack --watch",
|
||||
"prebuild": "node prebuild.js",
|
||||
"postbuild": "git checkout -- assets package.json",
|
||||
"prepackage": "node prebuild.js",
|
||||
"postpackage": "git checkout -- assets package.json",
|
||||
"package": "webpack --mode production --devtool hidden-source-map",
|
||||
"compile-tests": "tsc -p . --outDir out",
|
||||
"watch-tests": "tsc -p . -w --outDir out",
|
||||
"watch-tests": "npm run prebuild && tsc -p . -w --outDir out",
|
||||
"pretest": "npm run compile-tests && npm run compile && npm run lint",
|
||||
"lint": "eslint src --ext ts",
|
||||
"test": "mocha",
|
||||
|
49
prebuild.js
Normal file
49
prebuild.js
Normal file
@ -0,0 +1,49 @@
|
||||
require('dotenv').config()
|
||||
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
|
||||
function copyIcon(src, dst) {
|
||||
if (!src) {
|
||||
console.warn(`Icon path for ${dst} is not defined in your environment variables`)
|
||||
return
|
||||
}
|
||||
if (!fs.existsSync(src)) {
|
||||
console.warn(`Icon file ${src} does not exist.`)
|
||||
return
|
||||
}
|
||||
|
||||
const destPath = path.join(__dirname, 'assets', dst)
|
||||
|
||||
try {
|
||||
fs.copyFileSync(src, destPath)
|
||||
fs.chmodSync(destPath, 0o644)
|
||||
} catch(e) {
|
||||
console.warn(`Failed to copy logo ${e}`)
|
||||
}
|
||||
}
|
||||
|
||||
function updatePackageJson() {
|
||||
const placeholders = {
|
||||
EXTENSION_NAME: process.env.EXTENSION_NAME || "devchat",
|
||||
PUBLISHER: process.env.PUBLISHER || "merico",
|
||||
ASSISTANT_NAME_EN: process.env.ASSISTANT_NAME_EN || "DevChat",
|
||||
ASSISTANT_NAME_ZH: process.env.ASSISTANT_NAME_ZH || "DevChat"
|
||||
}
|
||||
|
||||
let packageJson = fs.readFileSync('package.json', 'utf8');
|
||||
|
||||
// Replace placeholders
|
||||
Object.entries(placeholders).forEach(([key, value]) => {
|
||||
const regex = new RegExp(`\\$\\{${key}\\}`, 'g');
|
||||
packageJson = packageJson.replace(regex, value);
|
||||
});
|
||||
|
||||
fs.writeFileSync('package.json', packageJson);
|
||||
}
|
||||
|
||||
copyIcon(process.env.EXTENSION_ICON, 'devchat.png')
|
||||
copyIcon(process.env.SIDEBAR_ICON, 'devchat_icon.svg')
|
||||
copyIcon(process.env.DIFF_APPLY_ICON, 'devchat_apply.svg')
|
||||
|
||||
updatePackageJson()
|
Loading…
x
Reference in New Issue
Block a user