@igniteui/angular-schematics 21.1.1490 → 21.1.1492

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@igniteui/angular-schematics",
3
- "version": "21.1.1490",
3
+ "version": "21.1.1492",
4
4
  "description": "Ignite UI for Angular Schematics for ng new and ng generate",
5
5
  "repository": {
6
6
  "type": "git",
@@ -22,8 +22,8 @@
22
22
  "dependencies": {
23
23
  "@angular-devkit/core": "^21.0.0",
24
24
  "@angular-devkit/schematics": "^21.0.0",
25
- "@igniteui/angular-templates": "~21.1.1490",
26
- "@igniteui/cli-core": "~14.9.0",
25
+ "@igniteui/angular-templates": "~21.1.1492",
26
+ "@igniteui/cli-core": "~14.9.2",
27
27
  "@schematics/angular": "^21.0.0",
28
28
  "minimatch": "^10.0.1",
29
29
  "rxjs": "~7.8.1"
@@ -148,7 +148,7 @@ function newProject(options) {
148
148
  installChain.push(installTask);
149
149
  }
150
150
  if (!options.skipGit) {
151
- const gitTask = context.addTask(new tasks_1.RepositoryInitializerTask(options.name, { message: `Initial commit for project: ${options.name}` }), [...installChain] //copy
151
+ const gitTask = context.addTask(new tasks_1.RepositoryInitializerTask(options.name, { message: `Initial commit for project` }), [...installChain] //copy
152
152
  );
153
153
  installChain.push(gitTask);
154
154
  }
@@ -149,7 +149,7 @@ describe("Schematics ng-new", () => {
149
149
  authorEmail: undefined,
150
150
  authorName: undefined,
151
151
  commit: true,
152
- message: `Initial commit for project: ${workingDirectory}`
152
+ message: `Initial commit for project`
153
153
  };
154
154
  const expectedStart = {
155
155
  collection: null,
@@ -199,7 +199,7 @@ describe("Schematics ng-new", () => {
199
199
  authorEmail: undefined,
200
200
  authorName: undefined,
201
201
  commit: true,
202
- message: `Initial commit for project: ${workingDirectory}`
202
+ message: `Initial commit for project`
203
203
  };
204
204
  expect(taskOptions.length).toBe(2);
205
205
  expect(mockProject.upgradeIgniteUIPackages).toHaveBeenCalled();
@@ -39,7 +39,9 @@ class NgTreeFileSystem {
39
39
  return (this.tree.read(filePath) || "").toString();
40
40
  }
41
41
  writeFile(filePath, text) {
42
- return this.tree.overwrite(filePath, text);
42
+ this.tree.exists(filePath)
43
+ ? this.tree.overwrite(filePath, text)
44
+ : this.tree.create(filePath, text);
43
45
  }
44
46
  directoryExists(dirPath) {
45
47
  const dir = this.tree.getDir(dirPath);
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,95 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const schematics_1 = require("@angular-devkit/schematics");
4
+ const testing_1 = require("@angular-devkit/schematics/testing");
5
+ const NgFileSystem_1 = require("./NgFileSystem");
6
+ describe("NgTreeFileSystem", () => {
7
+ let tree;
8
+ let fs;
9
+ beforeEach(() => {
10
+ tree = new testing_1.UnitTestTree(new schematics_1.EmptyTree());
11
+ fs = new NgFileSystem_1.NgTreeFileSystem(tree);
12
+ });
13
+ describe("fileExists", () => {
14
+ it("should return true when the file exists in the tree", () => {
15
+ tree.create("/src/app/app.component.ts", "content");
16
+ expect(fs.fileExists("/src/app/app.component.ts")).toBeTrue();
17
+ });
18
+ it("should return false when the file does not exist in the tree", () => {
19
+ expect(fs.fileExists("/src/missing.ts")).toBeFalse();
20
+ });
21
+ });
22
+ describe("readFile", () => {
23
+ it("should return the file content as a string", () => {
24
+ tree.create("/src/app/app.component.ts", "export class AppComponent {}");
25
+ expect(fs.readFile("/src/app/app.component.ts")).toBe("export class AppComponent {}");
26
+ });
27
+ it("should return an empty string when the file does not exist", () => {
28
+ expect(fs.readFile("/src/nonexistent.ts")).toBe("");
29
+ });
30
+ it("should ignore the encoding parameter and still return the content", () => {
31
+ tree.create("/src/file.txt", "hello");
32
+ expect(fs.readFile("/src/file.txt", "utf-8")).toBe("hello");
33
+ });
34
+ });
35
+ describe("writeFile", () => {
36
+ it("should create a new file when it does not exist", () => {
37
+ fs.writeFile("/src/new-file.ts", "new content");
38
+ expect(tree.readContent("/src/new-file.ts")).toBe("new content");
39
+ });
40
+ it("should overwrite an existing file", () => {
41
+ tree.create("/src/existing.ts", "original content");
42
+ fs.writeFile("/src/existing.ts", "updated content");
43
+ expect(tree.readContent("/src/existing.ts")).toBe("updated content");
44
+ });
45
+ });
46
+ describe("directoryExists", () => {
47
+ it("should return true when the directory contains files", () => {
48
+ tree.create("/src/app/app.component.ts", "");
49
+ expect(fs.directoryExists("/src/app")).toBeTrue();
50
+ });
51
+ it("should return true when the directory contains subdirectories", () => {
52
+ tree.create("/src/app/nested/file.ts", "");
53
+ expect(fs.directoryExists("/src/app")).toBeTrue();
54
+ });
55
+ it("should return false for an empty or non-existent directory", () => {
56
+ expect(fs.directoryExists("/src/nonexistent")).toBeFalse();
57
+ });
58
+ });
59
+ describe("glob", () => {
60
+ beforeEach(() => {
61
+ tree.create("/src/app/app.component.ts", "");
62
+ tree.create("/src/app/app.module.ts", "");
63
+ tree.create("/src/app/shared/shared.component.ts", "");
64
+ tree.create("/src/environments/environment.ts", "");
65
+ tree.create("/src/environments/environment.prod.ts", "");
66
+ });
67
+ it("should return all files matching the pattern", () => {
68
+ const results = fs.glob("/src", "**/*.ts");
69
+ expect(results).toContain("/src/app/app.component.ts");
70
+ expect(results).toContain("/src/app/app.module.ts");
71
+ expect(results).toContain("/src/app/shared/shared.component.ts");
72
+ expect(results).toContain("/src/environments/environment.ts");
73
+ expect(results).toContain("/src/environments/environment.prod.ts");
74
+ });
75
+ it("should return only files matching a specific pattern", () => {
76
+ const results = fs.glob("/src", "**/environment*.ts");
77
+ expect(results).toContain("/src/environments/environment.ts");
78
+ expect(results).toContain("/src/environments/environment.prod.ts");
79
+ expect(results).not.toContain("/src/app/app.component.ts");
80
+ });
81
+ it("should return an empty array when no files match the pattern", () => {
82
+ const results = fs.glob("/src", "**/*.html");
83
+ expect(results).toEqual([]);
84
+ });
85
+ it("should skip subdirectories matching ignorePatterns", () => {
86
+ tree.create("/src/node_modules/lib/index.ts", "");
87
+ const results = fs.glob("/src", "**/*.ts", ["node_modules"]);
88
+ expect(results.some(r => r.includes("node_modules"))).toBeFalse();
89
+ });
90
+ it("should return an empty array when dirPath does not exist", () => {
91
+ const results = fs.glob("/nonexistent", "**/*.ts");
92
+ expect(results).toEqual([]);
93
+ });
94
+ });
95
+ });