Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide default options when adding a template #1070

Merged
merged 5 commits into from
Oct 18, 2022
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
8 changes: 8 additions & 0 deletions packages/cli/lib/commands/add.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,14 @@ command = {
}
},
async addTemplate(fileName: string, template: Template, options?: AddTemplateArgs): Promise<boolean> {
if (!options) {
options = {
parentName: "app",
parentRoutingModulePath: "src/app/app-routing.ts",
selector: "app-" + template.id
};
}

fileName = fileName.trim();
const name = Util.nameFromPath(fileName);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class IgcDateTimeInputTemplate extends IgniteUIForWebComponentsTemplate {
this.listInComponentTemplates = true;
this.id = "date-time-input";
this.projectType = "igc-ts";
this.name = "DateTime Input";
this.name = "Date Time Input";
this.description = "basic IgcDateTimeInput";
}
protected addClassDeclaration(mainModule: TypeScriptFileUpdate, projPath: string, name: string, modulePath: string) {
Expand Down
4 changes: 2 additions & 2 deletions spec/unit/add-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ describe("Unit - Add command", () => {

for (const item of validCombos) {
await addCmd.addTemplate(item.name, mockTemplate);
expect(mockTemplate.generateConfig).toHaveBeenCalledWith(item.valid, {});
expect(mockTemplate.generateConfig).toHaveBeenCalledWith(item.valid, { parentName: "app", parentRoutingModulePath: "src/app/app-routing.ts", selector: "app-undefined" });
expect(Util.processTemplates).toHaveBeenCalledWith("test", "Mock directory", mockConfig, mockDelimiters);
}

Expand Down Expand Up @@ -289,7 +289,7 @@ describe("Unit - Add command", () => {
spyOn(ProjectConfig, "getConfig").and.returnValue(mockProjectConfig);

const mockTemplate = jasmine.createSpyObj("Template", {
generateConfig: { test: "test" }, registerInProject: null
generateConfig: { test: "test", parentName: "app", parentRoutingModulePath: "src/app/app-routing.ts", selector: "app-test" }, registerInProject: null
});
mockTemplate.templatePaths = ["test"];
mockTemplate.packages = [];
Expand Down