Skip to content

Commit bcd62be

Browse files
authored
fix(wc): enhance upgrade-packages to support workspace glob patterns and vite.config.ts files (#1408)
1 parent 61e3eca commit bcd62be

File tree

2 files changed

+250
-28
lines changed

2 files changed

+250
-28
lines changed

packages/core/update/Update.ts

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,23 @@ export async function updateWorkspace(rootPath: string): Promise<boolean> {
9797
case "webcomponents":
9898
if (pkgJSON.workspaces) {
9999
pkgJSON.workspaces.forEach(w => {
100-
workspaces.push(path.join(rootPath, w));
100+
// Handle workspace patterns that may contain globs
101+
if (w.includes("*")) {
102+
// Use glob to expand the workspace pattern
103+
const expandedWorkspaces = fs.glob(rootPath, w);
104+
expandedWorkspaces.forEach(expandedWorkspace => {
105+
// Only add if it's a directory
106+
if (fs.directoryExists(expandedWorkspace)) {
107+
workspaces.push(expandedWorkspace);
108+
}
109+
});
110+
} else {
111+
// Direct workspace path
112+
const workspacePath = path.join(rootPath, w);
113+
if (fs.directoryExists(workspacePath)) {
114+
workspaces.push(workspacePath);
115+
}
116+
}
101117
});
102118
} else {
103119
workspaces.push(path.join(rootPath, "src"));
@@ -116,6 +132,14 @@ export async function updateWorkspace(rootPath: string): Promise<boolean> {
116132
pkgJsonFiles.push(...fs.glob(workspace, `**/package.json`));
117133
}
118134

135+
// For React and WebComponents projects, also include vite.config.ts files
136+
if (framework.toLowerCase() === "react" || framework.toLowerCase() === "webcomponents") {
137+
const viteConfigFiles = fs.glob(rootPath, `vite.config.ts`, ['node_modules', 'dist']);
138+
if (viteConfigFiles && viteConfigFiles.length > 0) {
139+
logicFiles.push(...viteConfigFiles);
140+
}
141+
}
142+
119143
updateFileImports(logicFiles, styleFiles, upgradeable, fs);
120144
if (shouldUpgradeHTML) {
121145
updateHTMLImports(htmlFiles, upgradeable, fs);

0 commit comments

Comments
 (0)