-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathupdate-extensions-webpack.ps1
More file actions
42 lines (35 loc) · 1.81 KB
/
Copy pathupdate-extensions-webpack.ps1
File metadata and controls
42 lines (35 loc) · 1.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# Update extension package.json files to use webpack
$extensions = @(
'health-data-api-builder',
'start-data-api-builder',
'validate-data-api-builder',
'visualize-data-api-builder',
'agent-data-api-builder'
)
foreach ($ext in $extensions) {
$pkgPath = Join-Path $ext "package.json"
if (Test-Path $pkgPath) {
$content = Get-Content $pkgPath -Raw
# Update main entry point
$content = $content -replace '"main":\s*"\./out/extension\.js"', '"main": "./dist/extension.js"'
# Update scripts
$content = $content -replace '"vscode:prepublish":\s*"npm run compile"', '"vscode:prepublish": "npm run package"'
$content = $content -replace '"compile":\s*"tsc -p \./"|"compile":\s*"tsc"', '"compile": "webpack"'
$content = $content -replace '"watch":\s*"tsc -watch -p \./"|"watch":\s*"tsc --watch"', '"watch": "webpack --watch"'
# Add package script after watch
if ($content -notmatch '"package":') {
$packageScript = ',\n "package": "webpack --mode production --devtool hidden-source-map"'
$content = $content -replace '("watch":\s*"[^"]+")','$1' + $packageScript
}
# Add webpack dependencies
if ($content -notmatch 'ts-loader') {
$webpackDeps = ',\n "ts-loader": "^9.5.1",\n "webpack": "^5.94.0",\n "webpack-cli": "^5.1.4"'
$content = $content -replace '("@types/node":\s*"[^"]+")','$1' + $webpackDeps
}
Set-Content $pkgPath $content -NoNewline
Write-Host "Updated $ext/package.json" -ForegroundColor Green
}
}
Write-Host ""
Write-Host "All package.json files updated!" -ForegroundColor Cyan
Write-Host "Run npm install in each extension folder to install webpack dependencies." -ForegroundColor Yellow