• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

IgniteUI / igniteui-cli / 26022191364

18 May 2026 08:27AM UTC coverage: 87.368% (+0.1%) from 87.226%
26022191364

Pull #1689

github

web-flow
Merge e86f57bf2 into 2cbc962eb
Pull Request #1689: feat(ai-config): add framework prompt & early detect so command can always run

1075 of 1398 branches covered (76.9%)

Branch coverage included in aggregate %.

76 of 77 new or added lines in 9 files covered. (98.7%)

2 existing lines in 2 files now uncovered.

5440 of 6059 relevant lines covered (89.78%)

84.96 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

83.67
/packages/core/templates/BaseProjectLibrary.ts
1
import * as path from "path";
12✔
2
import { Component, ComponentGroup, ProjectLibrary, ProjectTemplate, Template } from "../types";
3
import { Util } from "../util";
12✔
4

5
export class BaseProjectLibrary implements ProjectLibrary {
12✔
6
        public projectType: string;
7
        public framework: string;
8
        //templates: Template[];
9
        public name: string;
10
        public themes: string[];
11

12
        /** Implementation, not part of the interface */
13
        public groupDescriptions = new Map<string, string>();
72✔
14

15
        /** Used to prefix folders that don't contain usable templates */
16
        protected _ignorePrefix = "_";
72✔
17
        protected _projectsPath: string = "projects";
72✔
18
        protected _customTemplatesPath: string = "custom-templates";
72✔
19
        protected _generateCommandPath: string = "generate";
72✔
20

21
        private _templates: Template[];
22
        public get templates(): Template[] {
23
                let list: Template[] = [];
5,444✔
24
                for (const component of this.components) {
5,444✔
25
                        list = list.concat(component.templates);
185,016✔
26
                }
27
                list = list.concat(this.customTemplates);
5,444✔
28
                return list;
5,444✔
29
        }
30
        private _projectIds: string[] = [];
72✔
31
        public get projectIds(): string[] {
32
                //read projects list
33
                if (!this._projectIds.length) {
103✔
34
                        this._projectIds = Util.getDirectoryNames(path.join(this.rootPath, this._projectsPath));
7✔
35
                        this._projectIds = this._projectIds.filter(x => !x.startsWith(this._ignorePrefix));
26✔
36
                }
37
                return this._projectIds;
103✔
38
        }
39

40
        private _projects: ProjectTemplate[] = [];
72✔
41
        public get projects(): ProjectTemplate[] {
42
                if (!this._projects.length) {
4✔
43
                        this._projects = this.projectIds.map(x => this.getProject(x));
5✔
44
                }
45
                return this._projects;
4✔
46
        }
47

48
        /*        private _customTemplates : string[];
49
                public get customTemplates() : string[] {
50
                        if (!this._customTemplates.length) {
51
                                this._customTemplates = Util.getDirectoryNames(path.join(this.rootPath, this._customTemplatesPath));
52
                        }
53
                        return this._customTemplates;
54
                }*/
55

56
        private _customTemplates: Template[] = [];
72✔
57
        public get customTemplates(): Template[] {
58
                if (!this._customTemplates.length) {
5,448✔
59
                        const customTemplatesFolders: string[] = Util.getDirectoryNames(path.join(this.rootPath, this._customTemplatesPath));
11✔
60

61
                        for (const element of customTemplatesFolders) {
11✔
62
                                this._customTemplates.push(require(path.join(
19✔
63
                                        this.rootPath,
64
                                        this._customTemplatesPath,
65
                                        element)) as Template);
66
                        }
67
                }
68
                return this._customTemplates;
5,448✔
69
        }
70

71
        private _components: Component[] = [];
72✔
72
        public get components(): Component[] {
73
                if (!this._components.length) {
5,461✔
74
                        //read file
75
                        //read components lists
76
                        const componentFolders: string[] = Util.getDirectoryNames(this.rootPath)
12✔
77
                                .filter(
78
                                        x => x !== this._projectsPath &&
146✔
79
                                                x !== this._customTemplatesPath &&
80
                                                x !== this._generateCommandPath);
81

82
                        for (const componentFolder of componentFolders) {
12✔
83

84
                                this._components.push(require(path.join(this.rootPath, componentFolder)) as Component);
134✔
85
                        }
86
                }
87
                return this._components;
5,461✔
88
        }
89

90
        private _generateTemplateFolderPath: string = "";
72✔
91
        public get generateTemplateFolderPath(): string {
92
                if (this._generateTemplateFolderPath === "") {
3✔
93
                        this._generateTemplateFolderPath = path.join(this.rootPath, "generate");
3✔
94
                }
95
                return this._generateTemplateFolderPath;
3✔
96
        }
97

98
        /**
99
         *
100
         */
101
        constructor(private rootPath: string) { }
72✔
102

103
        public getTemplateById(id: string): Template {
104
                return this.templates.find(x => x.id === id);
145✔
105
        }
106
        public getTemplateByName(name: string): Template {
107
                return this.templates.find(x => x.name === name);
10✔
108
        }
109

110
        public registerTemplate(template: Template): void {
111
                if (template) {
1✔
112
                        this.templates.push(template);
1✔
113
                        const newComponents = template.components.filter(x => !this.components.find(f => f.name === x));
2✔
114
                        for (const newComponent of newComponents) {
1✔
115
                                const component: Component = {
1✔
116
                                        name: newComponent,
117
                                        description: "",
118
                                        group: template.controlGroup,
119
                                        groupPriority: 0,
120
                                        templates: []
121
                                };
122
                                this.components.push(component);
1✔
123
                        }
124
                        if (template.listInComponentTemplates) {
1!
125
                                const currentComponents = template.components.filter(x => this.components.find(f => f.name === x));
×
126
                                for (const currentComponent of currentComponents) {
×
127
                                        this.components.find(f => f.name === currentComponent).templates.push(template);
×
128
                                }
129
                        }
130
                        if (template.listInCustomTemplates) {
1!
131
                                this.customTemplates.push(template);
×
132
                        }
133
                }
134
        }
135

136
        public getComponentByName(name: string): Component {
137
                return this.components.find(x => x.name === name);
10✔
138
        }
139

140
        public getCustomTemplates(): Template[] {
141
                return this.customTemplates;
1✔
142
        }
143

144
        public getCustomTemplateNames(): string[] {
145
                const cTemplates: string[] = [];
1✔
146
                for (const customTemplate of this.customTemplates) {
1✔
147
                        //var p: CustomTemplate = this.customTemplates[index] as CustomTemplate;
148
                        cTemplates.push(customTemplate.name);
2✔
149
                }
150
                return cTemplates;
1✔
151
        }
152
        public getCustomTemplateByName(name: string): Template {
153
                return this.customTemplates.find((x, y, z) => x.name === name);
1✔
154
        }
155

156
        public getComponentGroupNames(): string[] {
157
                //poor-man's groupBy reduce
158
                const groups = this.components.reduce((prev, current, index, array) => {
1✔
159
                        if (prev.indexOf(current.group) === -1) {
5✔
160
                                prev.push(current.group);
5✔
161
                        }
162
                        return prev;
5✔
163
                }, []);
164
                return [...this.groupDescriptions.keys()].filter(item => groups.includes(item));
5✔
165
        }
166

167
        public getComponentsByGroup(group: string): Component[] {
168
                return this.components.filter(x => x.group === group)
13✔
169
                        .sort((a, b) => b.groupPriority - a.groupPriority);
15✔
170
        }
171

172
        // /**
173
        //  * Return Component Groups with descriptions
174
        //  */
175
        public getComponentGroups(): ComponentGroup[] {
176
                const groups: ComponentGroup[] = [];
×
177

178
                for (const groupName of this.getComponentGroupNames()) {
×
179
                        groups.push({
×
180
                                name: groupName,
181
                                description: this.groupDescriptions.get(groupName) || ""
×
182
                        });
183
                }
184
                return groups;
×
185
        }
186

187
        public getComponentNamesByGroup(group: string): string[] {
188
                return this.components.filter(x => x.group === group)
×
189
                        .sort((a, b) => b.groupPriority - a.groupPriority)
×
190
                        .map(x => x.name);
×
191
        }
192

193
        /**
194
         * Get project template
195
         * @param id ID of the project template.
196
         */
197
        public getProject(id: string): ProjectTemplate {
198
                if (this.hasProject(id)) {
36✔
199
                        const projModule = require(path.join(this.rootPath, this._projectsPath, id));
36✔
200
                        return projModule.default || projModule as ProjectTemplate;
36✔
201
                }
UNCOV
202
                return null;
×
203
        }
204

205
        public hasProject(id: string): boolean {
206
                return this.projectIds.indexOf(id) > -1;
37✔
207
        }
208
        //abstraction for projects
209

210
        public hasTemplate(id: string): boolean {
211
                return this.templates.find(x => x.id === id) !== undefined;
176✔
212
        }
213
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc