Skip to content

Commit 3b82911

Browse files
CopilotLipata
andcommitted
Integrate vite.config.ts support from PR #1410 into workspace glob pattern fix
Co-authored-by: Lipata <[email protected]>
1 parent a1dc7e2 commit 3b82911

File tree

4 files changed

+207
-22
lines changed

4 files changed

+207
-22
lines changed

package-lock.json

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/core/update/Update.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,14 @@ export async function updateWorkspace(rootPath: string): Promise<boolean> {
132132
pkgJsonFiles.push(...fs.glob(workspace, `**/package.json`));
133133
}
134134

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+
135143
updateFileImports(logicFiles, styleFiles, upgradeable, fs);
136144
if (shouldUpgradeHTML) {
137145
updateHTMLImports(htmlFiles, upgradeable, fs);

spec/unit/update-spec.ts

Lines changed: 183 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,7 @@ title = 'igniteui-angular example';
545545
}
546546
}));
547547
expect(fsSpy.writeFile).toHaveBeenCalledTimes(1);
548-
expect(fsSpy.glob).toHaveBeenCalledTimes(5);
548+
expect(fsSpy.glob).toHaveBeenCalledTimes(6);
549549
});
550550

551551
it("Should update import paths in files correctly", async () => {
@@ -713,7 +713,7 @@ export default function Home() {
713713
for (const fileEntry of mockFileArray) {
714714
expect((fsSpy.writeFile as jasmine.Spy)).toHaveBeenCalledWith(fileEntry.path, fileEntry.expected);
715715
}
716-
expect(fsSpy.glob).toHaveBeenCalledTimes(5);
716+
expect(fsSpy.glob).toHaveBeenCalledTimes(6);
717717
});
718718

719719
it("Should update package.json files from workspaces with glob patterns", async () => {
@@ -842,7 +842,94 @@ export default function Home() {
842842
for (const fileEntry of mockFileArray) {
843843
expect((fsSpy.writeFile as jasmine.Spy)).toHaveBeenCalledWith(fileEntry.path, fileEntry.expected);
844844
}
845-
// Expect: 1 for projects/*, 1 for package.json files at root, 1 for logic files, 1 for style files, 1 for package.json in workspace
845+
// Expect: 1 for projects/*, 1 for package.json files at root, 1 for logic files, 1 for style files, 1 for package.json in workspace, 1 for vite.config.ts
846+
expect(fsSpy.glob).toHaveBeenCalledTimes(7);
847+
});
848+
849+
it("Should update vite.config.ts file correctly", async () => {
850+
const mockFileArray: MockFile[] = [
851+
{
852+
path: "package.json",
853+
content:
854+
`{
855+
"dependencies": {
856+
"igniteui-react-grids": "^18.5.1",
857+
"some-package": "^0.0.0"
858+
}
859+
}
860+
`,
861+
expected:
862+
`{
863+
"dependencies": {
864+
"@infragistics/igniteui-react-grids": "^18.5.1",
865+
"some-package": "^0.0.0"
866+
}
867+
}
868+
`
869+
},
870+
{
871+
path: "vite.config.ts",
872+
content:
873+
`import { defineConfig } from 'vite';
874+
import { viteStaticCopy } from 'vite-plugin-static-copy';
875+
876+
export default defineConfig({
877+
plugins: [
878+
viteStaticCopy({
879+
targets: [
880+
{
881+
src: "node_modules/igniteui-react-grids/grids/themes/light/bootstrap.css",
882+
dest: "themes",
883+
},
884+
{
885+
src: "node_modules/igniteui-react-grids/grids/themes/light/fluent.css",
886+
dest: "themes",
887+
},
888+
],
889+
}),
890+
],
891+
});`,
892+
expected:
893+
`import { defineConfig } from 'vite';
894+
import { viteStaticCopy } from 'vite-plugin-static-copy';
895+
896+
export default defineConfig({
897+
plugins: [
898+
viteStaticCopy({
899+
targets: [
900+
{
901+
src: "node_modules/@infragistics/igniteui-react-grids/grids/themes/light/bootstrap.css",
902+
dest: "themes",
903+
},
904+
{
905+
src: "node_modules/@infragistics/igniteui-react-grids/grids/themes/light/fluent.css",
906+
dest: "themes",
907+
},
908+
],
909+
}),
910+
],
911+
});`
912+
}];
913+
(fsSpy.glob as jasmine.Spy).and.returnValues // per workspace
914+
([ "package.json" ], // root package.json
915+
[], // html file
916+
[ "src/home.tsx" ], // logic files
917+
[], // for each style extension
918+
[], // inner package.json files
919+
["vite.config.ts"]); // vite config files
920+
(fsSpy.readFile as jasmine.Spy).and.callFake((filePath: string) => {
921+
if (filePath.indexOf("package.json") > -1) {
922+
return mockFileArray.find(entry => entry.path === "package.json").content;
923+
}
924+
const fileEntry = mockFileArray.find(entry => entry.path === filePath);
925+
return fileEntry ? fileEntry.content : "";
926+
});
927+
(fsSpy.fileExists as jasmine.Spy).and.returnValue(true);
928+
spyOn(PackageManager, "ensureRegistryUser").and.returnValue(true);
929+
expect(await updateWorkspace("")).toEqual(true);
930+
for (const fileEntry of mockFileArray) {
931+
expect((fsSpy.writeFile as jasmine.Spy)).toHaveBeenCalledWith(fileEntry.path, fileEntry.expected);
932+
}
846933
expect(fsSpy.glob).toHaveBeenCalledTimes(6);
847934
});
848935
});
@@ -931,7 +1018,7 @@ export default function Home() {
9311018
}
9321019
}));
9331020
expect(fsSpy.writeFile).toHaveBeenCalledTimes(2);
934-
expect(fsSpy.glob).toHaveBeenCalledTimes(4);
1021+
expect(fsSpy.glob).toHaveBeenCalledTimes(5);
9351022
});
9361023

9371024
it("Should update import paths in files correctly", async () => {
@@ -1086,7 +1173,7 @@ export default class App extends LitElement {
10861173
for (const fileEntry of mockFileArray) {
10871174
expect((fsSpy.writeFile as jasmine.Spy)).toHaveBeenCalledWith(fileEntry.path, fileEntry.expected);
10881175
}
1089-
expect(fsSpy.glob).toHaveBeenCalledTimes(4);
1176+
expect(fsSpy.glob).toHaveBeenCalledTimes(5);
10901177
});
10911178

10921179
it("Should update package.json files from workspaces", async () => {
@@ -1201,7 +1288,97 @@ export default class App extends LitElement {
12011288
for (const fileEntry of mockFileArray) {
12021289
expect((fsSpy.writeFile as jasmine.Spy)).toHaveBeenCalledWith(fileEntry.path, fileEntry.expected);
12031290
}
1204-
expect(fsSpy.glob).toHaveBeenCalledTimes(6);
1291+
expect(fsSpy.glob).toHaveBeenCalledTimes(7);
1292+
});
1293+
1294+
it("Should update vite.config.ts file correctly", async () => {
1295+
const mockFileArray: MockFile[] = [
1296+
{
1297+
path: "package.json",
1298+
content:
1299+
`{
1300+
"dependencies": {
1301+
"igniteui-webcomponents-grids": "^4.7.0",
1302+
"some-package": "^0.0.0"
1303+
}
1304+
}
1305+
`,
1306+
expected:
1307+
`{
1308+
"dependencies": {
1309+
"@infragistics/igniteui-webcomponents-grids": "^4.7.0",
1310+
"some-package": "^0.0.0"
1311+
}
1312+
}
1313+
`
1314+
},
1315+
{
1316+
path: "vite.config.ts",
1317+
content:
1318+
`import { defineConfig } from 'vite';
1319+
import { viteStaticCopy } from 'vite-plugin-static-copy';
1320+
1321+
export default defineConfig(({ mode }) => {
1322+
return {
1323+
plugins: [
1324+
viteStaticCopy({
1325+
targets: [
1326+
{
1327+
src: "node_modules/igniteui-webcomponents-grids/grids/themes/light/bootstrap.css",
1328+
dest: "themes",
1329+
},
1330+
{
1331+
src: "node_modules/igniteui-webcomponents-grids/grids/themes/light/fluent.css",
1332+
dest: "themes",
1333+
},
1334+
],
1335+
}),
1336+
],
1337+
};
1338+
});`,
1339+
expected:
1340+
`import { defineConfig } from 'vite';
1341+
import { viteStaticCopy } from 'vite-plugin-static-copy';
1342+
1343+
export default defineConfig(({ mode }) => {
1344+
return {
1345+
plugins: [
1346+
viteStaticCopy({
1347+
targets: [
1348+
{
1349+
src: "node_modules/@infragistics/igniteui-webcomponents-grids/grids/themes/light/bootstrap.css",
1350+
dest: "themes",
1351+
},
1352+
{
1353+
src: "node_modules/@infragistics/igniteui-webcomponents-grids/grids/themes/light/fluent.css",
1354+
dest: "themes",
1355+
},
1356+
],
1357+
}),
1358+
],
1359+
};
1360+
});`
1361+
}];
1362+
(fsSpy.glob as jasmine.Spy).and.returnValues // per workspace
1363+
([ "package.json" ], // root package.json
1364+
[], // html file
1365+
["src/app.ts"], // logic files
1366+
[], // inner package.json files
1367+
["vite.config.ts"]); // vite config files
1368+
(fsSpy.readFile as jasmine.Spy).and.callFake((filePath: string) => {
1369+
if (filePath.indexOf("package.json") > -1) {
1370+
return mockFileArray.find(entry => entry.path === "package.json").content;
1371+
}
1372+
const fileEntry = mockFileArray.find(entry => entry.path === filePath);
1373+
return fileEntry ? fileEntry.content : "";
1374+
});
1375+
(fsSpy.fileExists as jasmine.Spy).and.returnValue(true);
1376+
spyOn(PackageManager, "ensureRegistryUser").and.returnValue(true);
1377+
expect(await updateWorkspace("")).toEqual(true);
1378+
for (const fileEntry of mockFileArray) {
1379+
expect((fsSpy.writeFile as jasmine.Spy)).toHaveBeenCalledWith(fileEntry.path, fileEntry.expected);
1380+
}
1381+
expect(fsSpy.glob).toHaveBeenCalledTimes(5);
12051382
});
12061383
});
12071384
});

yarn.lock

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@
341341
integrity sha512-H9XAx3hc0BQHY6l+IFSWHDySypcXsvsuLhgYLUGywmJ5pswRVQJUHpOsobnLYp2ZUaUlKiKDrgWWhosOwAEM8Q==
342342

343343
"@igniteui/angular-schematics@file:/home/runner/work/igniteui-cli/igniteui-cli/packages/ng-schematics":
344-
version "20.0.1454"
344+
version "20.0.1455-beta.0"
345345
resolved "file:packages/ng-schematics"
346346
dependencies:
347347
"@angular-devkit/core" "^19.0.0"
@@ -352,15 +352,15 @@
352352
minimatch "^10.0.1"
353353
rxjs "^7.8.1"
354354

355-
"@igniteui/angular-templates@~20.0.1454", "@igniteui/angular-templates@file:/home/runner/work/igniteui-cli/igniteui-cli/packages/igx-templates":
356-
version "20.0.1454"
355+
"@igniteui/angular-templates@~20.0.1455-beta.0", "@igniteui/angular-templates@file:/home/runner/work/igniteui-cli/igniteui-cli/packages/igx-templates":
356+
version "20.0.1455-beta.0"
357357
resolved "file:packages/igx-templates"
358358
dependencies:
359-
"@igniteui/cli-core" "~14.5.4"
359+
"@igniteui/cli-core" "~14.5.5-beta.0"
360360
typescript "~5.5.4"
361361

362-
"@igniteui/cli-core@~14.5.4", "@igniteui/cli-core@file:/home/runner/work/igniteui-cli/igniteui-cli/packages/core":
363-
version "14.5.4"
362+
"@igniteui/cli-core@~14.5.5-beta.0", "@igniteui/cli-core@file:/home/runner/work/igniteui-cli/igniteui-cli/packages/core":
363+
version "14.5.5-beta.0"
364364
resolved "file:packages/core"
365365
dependencies:
366366
"@inquirer/prompts" "~5.4.0"
@@ -3868,7 +3868,7 @@ ieee754@^1.1.13:
38683868
integrity sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==
38693869

38703870
"igniteui-cli@file:/home/runner/work/igniteui-cli/igniteui-cli/packages/cli":
3871-
version "14.5.4"
3871+
version "14.5.5-beta.0"
38723872
resolved "file:packages/cli"
38733873
dependencies:
38743874
"@igniteui/angular-templates" "~20.0.1454"

0 commit comments

Comments
 (0)