fix(build): add vscode:prepublish script to ensure compilation before vsce package
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user