fix(build): add vscode:prepublish script to ensure compilation before vsce package

This commit is contained in:
Variet Worker
2026-04-08 06:14:05 +09:00
parent d3150bd5d8
commit 49e26eef54
8 changed files with 53 additions and 14 deletions

View File

@@ -105,16 +105,19 @@ function detectProjectName() {
if (folders && folders.length > 0) {
const cwd = folders[0].uri.fsPath;
try {
const remoteUrl = cp.execSync('git remote get-url origin', {
cwd, encoding: 'utf-8', timeout: 2000, windowsHide: true, stdio: ['ignore', 'pipe', 'ignore']
}).toString().trim();
const match = remoteUrl.match(/\/([^\/]+?)(?:\.git)?$/);
if (match && match[1]) {
return match[1].toLowerCase().replace(/[\s\-]+/g, '_');
const gitConfig = path.join(cwd, '.git', 'config');
if (fs.existsSync(gitConfig)) {
const cfg = fs.readFileSync(gitConfig, 'utf-8');
const match = cfg.match(/url\s*=\s*(.*?)\n/);
if (match && match[1]) {
const repo = match[1].trim().match(/\/([^\/]+?)(?:\.git)?$/);
if (repo && repo[1])
return repo[1].toLowerCase().replace(/[\s]+/g, '_');
}
}
}
catch { }
return path.basename(cwd).toLowerCase().replace(/[\s\-]+/g, '_');
return path.basename(cwd).toLowerCase().replace(/[\s]+/g, '_');
}
return 'default';
}
@@ -265,7 +268,7 @@ async function fixLSConnection() {
// Generate the workspace hint the same way SDK does, but we'll match case-insensitively
const folder = folders[0].uri.fsPath;
const parts = folder.replace(/\\/g, '/').split('/');
const hint = parts.slice(-2).join('_').replace(/[-.\s]/g, '_').toLowerCase();
const hint = parts.slice(-2).join('_').replace(/[^a-z0-9]/gi, '').toLowerCase();
if (!hint) {
logToFile('[LS-FIX] skipped: empty hint');
return false;
@@ -300,7 +303,7 @@ async function fixLSConnection() {
// Match workspace_id arg against our hint
const wsMatch = line.match(/--workspace_id[= ](\S+)/i);
if (wsMatch) {
const wsid = wsMatch[1].toLowerCase();
const wsid = wsMatch[1].replace(/[^a-z0-9]/gi, '').toLowerCase();
if (wsid.includes(hint)) {
matchedLine = line;
break;

File diff suppressed because one or more lines are too long