Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 6 additions & 14 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -355,22 +355,14 @@
"type": "node",

// "cwd": "<absolute directory of the project, created with ng cli, on which the 'ng' schematic is applied>"
"cwd": "C:\\Users\\User\\Desktop\\ng_test\\test_proj",
"cwd": "${workspaceFolder}/output/test_proj",
"program": "${env:AppData}/npm/node_modules/@angular/cli/bin/ng",
"preLaunchTask": "build",
"args": [
"-r",

// you need to install ts-node for the test project
"ts-node/register",

// "<path/to/ng>", "g",
"${env:AppData}/npm/node_modules/@angular/cli/bin/ng", "g",

"g",
// "<../../relative/path/from/cwd/to>/igniteui-cli/packages/ng-schematics/src/collection.json:cli-config"
"../../../../../work/git/igniteui-cli/packages/ng-schematics/src/collection.json:cli-config"
],
"env": {
"TS_NODE_PROJECT": "${workspaceFolder}/packages/ng-schematics/tsconfig.json"
}
"../../packages/ng-schematics/src/collection.json:cli-config"
]
},
{
// in order to test schematics, you need to have ignitui-angular package already installed in the test project
Expand Down
20 changes: 12 additions & 8 deletions packages/core/util/ai-skills.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { FS_TOKEN, IFileSystem } from "../types/FileSystem";
import { NPM_ANGULAR, NPM_REACT, NPM_WEBCOMPONENTS, resolvePackage, UPGRADEABLE_PACKAGES } from "../update/package-resolve";
import { App } from "./App";
import { detectFrameworkFromPackageJson } from "./detect-framework";
import { FsFileSystem } from "./FileSystem";
import { TEMPLATE_MANAGER } from "./GlobalConstants";
import { ProjectConfig } from "./ProjectConfig";
import { Util } from "./Util";
Expand Down Expand Up @@ -73,11 +74,14 @@ function resolveSkillsRoots(): string[] {

/**
* Copies skill files from the installed Ignite UI package(s) into .claude/skills/.
* Works with both real FS (CLI) and virtual Tree FS (schematics) through IFileSystem.
*/
export function copyAISkillsToProject(): AISkillsCopyResult {
const result: AISkillsCopyResult = { found: 0, skipped: 0, failed: 0 };
const fs = App.container.get<IFileSystem>(FS_TOKEN);
// Source reads (glob + readFile) always use physical FS - skill files can
// come from sources outside the project virtual tree (external/global package):
const srcFs = new FsFileSystem();
// Destination writes respect the App FS (which may be virtual):
const destFs = App.container.get<IFileSystem>(FS_TOKEN);
const skillsRoots = resolveSkillsRoots();

Comment thread
damyanpetev marked this conversation as resolved.
if (!skillsRoots.length) {
Expand All @@ -87,7 +91,7 @@ export function copyAISkillsToProject(): AISkillsCopyResult {
const multiRoot = skillsRoots.length > 1;

for (const skillsRoot of skillsRoots) {
const rawPaths = fs.glob(skillsRoot, "**/*");
const rawPaths = srcFs.glob(skillsRoot, "**/*");
const pkgDirName = multiRoot ? path.basename(path.dirname(skillsRoot)) : "";

for (const p of rawPaths) {
Expand All @@ -101,18 +105,18 @@ export function copyAISkillsToProject(): AISkillsCopyResult {
? `${CLAUDE_SKILLS_DIR}/${pkgDirName}/${rel}`
: `${CLAUDE_SKILLS_DIR}/${rel}`;

const newContent = fs.readFile(p);
const newContent = srcFs.readFile(p);
try {
if (fs.fileExists(dest)) {
const existingContent = fs.readFile(dest);
if (destFs.fileExists(dest)) {
const existingContent = destFs.readFile(dest);
if (existingContent === newContent) {
result.skipped++;
continue;
}
fs.writeFile(dest, newContent);
destFs.writeFile(dest, newContent);
Util.log(`${Util.greenCheck()} Updated ${dest}`);
} else {
fs.writeFile(dest, newContent);
destFs.writeFile(dest, newContent);
Util.log(`${Util.greenCheck()} Created ${dest}`);
}
} catch {
Expand Down
17 changes: 16 additions & 1 deletion spec/unit/ai-config-spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as path from "path";
import { App, Config, FS_TOKEN, GoogleAnalytics, IFileSystem, ProjectConfig, TEMPLATE_MANAGER, Util } from "@igniteui/cli-core";
import { App, Config, FS_TOKEN, FsFileSystem, GoogleAnalytics, IFileSystem, ProjectConfig, TEMPLATE_MANAGER, Util } from "@igniteui/cli-core";
import { configureMCP, configureSkills } from "../../packages/cli/lib/commands/ai-config";
import * as aiConfig from "../../packages/cli/lib/commands/ai-config";

Expand Down Expand Up @@ -180,6 +180,11 @@ describe("Unit - ai-config command", () => {
} as unknown as IFileSystem;

spyOn(App.container, "get").and.returnValue(mockFs);
// srcFs reads (FsFileSystem.prototype) for source content
spyOn(FsFileSystem.prototype, "glob").and.callFake((d: string) =>
d === angularSkillsDir ? [skillFile] : []
);
spyOn(FsFileSystem.prototype, "readFile").and.returnValue("skill content");
setupAngularConfig();

configureSkills();
Expand Down Expand Up @@ -207,6 +212,11 @@ describe("Unit - ai-config command", () => {
} as unknown as IFileSystem;

spyOn(App.container, "get").and.returnValue(mockFs);
// srcFs reads (FsFileSystem.prototype) for source content
spyOn(FsFileSystem.prototype, "glob").and.callFake((d: string) =>
d === angularSkillsDir ? [skillFile] : []
);
spyOn(FsFileSystem.prototype, "readFile").and.returnValue(content);
setupAngularConfig();

configureSkills();
Expand All @@ -232,6 +242,11 @@ describe("Unit - ai-config command", () => {
} as unknown as IFileSystem;

spyOn(App.container, "get").and.returnValue(mockFs);
// srcFs reads (FsFileSystem.prototype) for source content
spyOn(FsFileSystem.prototype, "glob").and.callFake((d: string) =>
d === angularSkillsDir ? [skillFile] : []
);
spyOn(FsFileSystem.prototype, "readFile").and.returnValue("skill content");
setupAngularConfig();

configureSkills();
Expand Down
Loading
Loading