Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
15 changes: 10 additions & 5 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ export default [
rules: {
'complexity': 'off',
'eslint-plugin-import/no-extraneous-dependencies': 'warn',
'eslint-plugin-import/no-internal-modules': 'warn',
'eslint-plugin-import/order': [
'off',
{
Expand Down Expand Up @@ -132,12 +131,18 @@ export default [
'valid-typeof': 'off',
},
},
{
files: ['**/*.spec.ts', '**/*-spec.ts', 'spec/**/*.ts'],
rules: {
'eslint-plugin-import/no-extraneous-dependencies': 'off',
},
},
Comment thread
damyanpetev marked this conversation as resolved.
{
ignores: [
'/node_modules/**/*',
'/coverage/**/*',
'/output/**/*',
'/packages/cli/templates/**/*',
'node_modules/**/*',
'coverage/**/*',
'output/**/*',
'packages/cli/templates/**/*',
'**/files/**/*'
]
},
Expand Down
4 changes: 1 addition & 3 deletions packages/cli/lib/PromptSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,7 @@ export class PromptSession extends BasePromptSession {

protected async completeAndRun(port?: number) {
await PackageManager.flushQueue(true);
if (true) { // TODO: Make conditional?
await start.start({ port });
}
await start.start({ port });
}

protected async upgradePackages() {
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/scripts/install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { App, GoogleAnalytics } from "@igniteui/cli-core";

function install() {
if (!!process.env.npm_config_global) {
if (process.env.npm_config_global) {
App.initialize();
GoogleAnalytics.post({
t: "screenview",
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/scripts/uninstall.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { App, GoogleAnalytics } from "@igniteui/cli-core";

function uninstall() {
if (!!process.env.npm_config_global) {
if (process.env.npm_config_global) {
App.initialize();
GoogleAnalytics.post({
t: "screenview",
Expand Down
17 changes: 4 additions & 13 deletions packages/core/prompt/BasePromptSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,6 @@ export abstract class BasePromptSession {
* @param framework to get project library for
*/
protected async getProjectLibrary(framework: Framework): Promise<ProjectLibrary> {
let projectLibrary: ProjectLibrary;
const projectLibraries = this.getProjectLibNames(framework);

const projectRes = await this.getUserInput({
Expand All @@ -212,36 +211,29 @@ export abstract class BasePromptSession {
message: "Choose the type of project:",
choices: projectLibraries
});
projectLibrary = this.templateManager.getProjectLibraryByName(framework, projectRes);

return projectLibrary;
return this.templateManager.getProjectLibraryByName(framework, projectRes);
}

/**
* Gets project template from user input, or default if provided `projectLibrary` has a single template
* @param projectLibrary to get theme for
*/
protected async getProjectTemplate(projectLibrary: ProjectLibrary): Promise<ProjectTemplate> {
let projTemplate: ProjectTemplate;

const componentNameRes = await this.getUserInput({
type: "list",
name: "projTemplate",
message: "Choose project template:",
choices: Util.formatChoices(projectLibrary.projects)
});
projTemplate = projectLibrary.projects.find(x => x.name === componentNameRes);

return projTemplate;
return projectLibrary.projects.find(x => x.name === componentNameRes);
}

/**
* Gets the theme from the user input, or default if provided @param projectLibrary has a single theme
* @param projectLibrary to get theme for
*/
protected async getTheme(projectLibrary: ProjectLibrary): Promise<string> {
let theme: string;
theme = await this.getUserInput({
const theme = await this.getUserInput({
type: "list",
name: "theme",
message: "Choose the theme for the project:",
Expand Down Expand Up @@ -500,7 +492,6 @@ export abstract class BasePromptSession {
* @param component to get template for
*/
private getTemplateTask: Task<PromptTaskContext> = async (_runner, context) => {
let selectedTemplate: Template;
const templates: Template[] = context.component.templates;

const templateRes = await this.getUserInput({
Expand All @@ -514,7 +505,7 @@ export abstract class BasePromptSession {
return WIZARD_BACK_OPTION;
}

selectedTemplate = templates.find((value, i, obj) => {
const selectedTemplate = templates.find((value, i, obj) => {
return value.name === templateRes;
});

Expand Down
4 changes: 1 addition & 3 deletions packages/core/templates/BaseProjectLibrary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,8 @@ export class BaseProjectLibrary implements ProjectLibrary {
}

public getComponentGroupNames(): string[] {
let groups: string[];

//poor-man's groupBy reduce
groups = this.components.reduce((prev, current, index, array) => {
const groups = this.components.reduce((prev, current, index, array) => {
if (prev.indexOf(current.group) === -1) {
prev.push(current.group);
}
Expand Down
57 changes: 26 additions & 31 deletions packages/core/templates/BaseTemplateManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export abstract class BaseTemplateManager {
return this.frameworks.map(f => f.id);
}
public getFrameworkNames(): string[] {
// еxclude WebComponents from the Step-By-Step wizard
// exclude WebComponents from the Step-By-Step wizard
return this.frameworks.map(f => f.name);
}
/** Returns framework found by its name or undefined. */
Expand Down Expand Up @@ -106,36 +106,31 @@ export abstract class BaseTemplateManager {
const config = ProjectConfig.getConfig();
const customTemplates: Template[] = [];
for (const entry of config.customTemplates) {
let template: Template;
// tslint:disable-next-line:prefer-const
let [protocol, value] = entry.split(/(^[^:]+):/).filter(x => x);
switch (protocol) {
default:
// in case just path is passed:
value = entry;
case "file":
case "path":
value = value.replace(/template\.json$/, "");
if (Util.directoryExists(value)) {
// try single template
template = this.loadFromConfig(path.join(value, "template.json"));
if (template !== null) {
customTemplates.push(template);
break;
}
// try folder of templates:
for (const folder of Util.getDirectoryNames(value)) {
template = this.loadFromConfig(path.join(value, folder, "template.json"));
if (template !== null) {
customTemplates.push(template);
}
}
} else {
// TODO: Util.log(`Ignored: Incorrect custom template path for "${entry}".`);
}
break;
case "ignored":
break;
const [protocol, value] = entry.split(/(^[^:]+):/).filter(x => x);

let templateDir = protocol === "file" || protocol === "path"
? value
: entry;
templateDir = templateDir.replace(/template\.json$/, "");

if (!Util.directoryExists(templateDir)) {
// TODO: Util.log(`Ignored: Incorrect custom template path for "${entry}".`);
continue;
}

// try single template
let template = this.loadFromConfig(path.join(templateDir, "template.json"));
if (template !== null) {
customTemplates.push(template);
continue;
}

// try folder of templates:
for (const folder of Util.getDirectoryNames(templateDir)) {
template = this.loadFromConfig(path.join(templateDir, folder, "template.json"));
if (template !== null) {
customTemplates.push(template);
}
}
}
this.addTemplates(customTemplates);
Expand Down
2 changes: 1 addition & 1 deletion packages/core/util/Schematics.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// tslint:disable: no-implicit-dependencies
// eslint-disable-next-line eslint-plugin-import/no-extraneous-dependencies
import { workspaces } from "@angular-devkit/core";
import { Tree } from "@angular-devkit/schematics";
Comment thread
damyanpetev marked this conversation as resolved.

Expand Down
6 changes: 2 additions & 4 deletions packages/igx-templates/IgniteUIForAngularTemplate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {
AddTemplateArgs, App, ControlExtraConfiguration, FS_TOKEN, IFileSystem, NPM_ANGULAR,
NPM_DOCK_MANAGER, Template, TemplateDependency, Util, resolvePackage
} from "@igniteui/cli-core";
import { AngularTypeScriptFileUpdate } from "@igniteui/angular-templates";
import type { AngularTypeScriptFileUpdate } from "./AngularTypeScriptFileUpdate";
Comment thread
damyanpetev marked this conversation as resolved.
import * as path from "path";

export class IgniteUIForAngularTemplate implements Template {
Expand Down Expand Up @@ -58,10 +58,8 @@ export class IgniteUIForAngularTemplate implements Template {
// D.P. Don't use the top-level import as that chains import of typescript
// which slows down execution of the entire component noticeably (template loading)
// https://www.typescriptlang.org/docs/handbook/modules.html#dynamic-module-loading-in-nodejs
// tslint:disable-next-line:variable-name
const TsUpdate: typeof AngularTypeScriptFileUpdate =
Comment thread
damyanpetev marked this conversation as resolved.
// tslint:disable-next-line:no-submodule-imports
require("@igniteui/angular-templates").AngularTypeScriptFileUpdate;
require("./AngularTypeScriptFileUpdate").AngularTypeScriptFileUpdate;
Comment thread
damyanpetev marked this conversation as resolved.

const mainModulePath = path.join(projectPath, `src/app/${modulePath}`);
const folderName = this.folderName(name);
Expand Down
2 changes: 1 addition & 1 deletion packages/ng-schematics/scripts/install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { App, GoogleAnalytics } from "@igniteui/cli-core";

function install() {
if (!!process.env.npm_config_global) {
if (process.env.npm_config_global) {
App.initialize("angular-cli");
GoogleAnalytics.post({
t: "screenview",
Expand Down
2 changes: 1 addition & 1 deletion packages/ng-schematics/scripts/uninstall.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { App, GoogleAnalytics } from "@igniteui/cli-core";

function uninstall() {
if (!!process.env.npm_config_global) {
if (process.env.npm_config_global) {
App.initialize("angular-cli");
GoogleAnalytics.post({
t: "screenview",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ describe("Unit - IgniteUIForAngularTemplate Base", () => {
App.initialize();
// spy on require:
spyOn(require("module"), "_load").and.callFake((modulePath: string) => {
if (modulePath.endsWith("@igniteui/angular-templates")) {
if (modulePath.endsWith("./AngularTypeScriptFileUpdate")) {
return helpers;
} else if (modulePath.endsWith("@igniteui/cli-core/packages/components")) {
return { dv: ["igDvWidget"] };
Expand Down
Loading