-
Notifications
You must be signed in to change notification settings - Fork 4
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
refator schematics workspace api #829
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
// tslint:disable:no-implicit-dependencies | ||
import { workspaces } from "@angular-devkit/core"; | ||
import { Rule, SchematicContext, Tree } from "@angular-devkit/schematics"; | ||
// tslint:disable-next-line:no-submodule-imports | ||
import { getWorkspace } from "@schematics/angular/utility/config"; | ||
import { createWorkspaceHost } from "@igniteui/cli-core"; | ||
|
||
const awesomeGridPaginatorStyle = | ||
` .igx-paginator>* {`; | ||
|
@@ -16,13 +16,13 @@ const paginatorStyleReplacement = | |
.igx-paginator>* {`; | ||
|
||
export default function(): Rule { | ||
return (host: Tree, context: SchematicContext) => { | ||
const workspace = getWorkspace(host); | ||
const project = workspace.defaultProject ? | ||
workspace.projects[workspace.defaultProject] : | ||
workspace.projects[0]; | ||
return async (tree: Tree, context: SchematicContext) => { | ||
const { workspace } = await workspaces.readWorkspace("/", createWorkspaceHost(tree)); | ||
const project = workspace.extensions.defaultProject ? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can use |
||
workspace.projects.get(workspace.extensions.defaultProject as string) : | ||
workspace.projects.values().next().value as workspaces.ProjectDefinition; | ||
|
||
const sourceDir = host.getDir(project.sourceRoot || "./src"); | ||
const sourceDir = tree.getDir(project.sourceRoot || "./src"); | ||
const ext = ".scss"; | ||
|
||
context.logger.info(`Applying migration for Ignite UI CLI 4.2.3.`); | ||
|
@@ -32,7 +32,7 @@ export default function(): Rule { | |
let content = entry.content.toString(); | ||
if (content.indexOf(awesomeGridPaginatorStyle) !== -1) { | ||
content = content.replace(awesomeGridPaginatorStyle, paginatorStyleReplacement); | ||
host.overwrite(path, content); | ||
tree.overwrite(path, content); | ||
} | ||
} | ||
}); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,7 @@ | ||
// tslint:disable:no-implicit-dependencies | ||
import { workspaces } from "@angular-devkit/core"; | ||
import { Rule, SchematicContext, Tree } from "@angular-devkit/schematics"; | ||
import { App, FS_TOKEN, FS_TYPE_TOKEN, FsTypes, IFileSystem, TypeScriptFileUpdate } from "@igniteui/cli-core"; | ||
// tslint:disable-next-line:no-submodule-imports | ||
import { getWorkspace } from "@schematics/angular/utility/config"; | ||
import { App, createWorkspaceHost, FS_TOKEN, FS_TYPE_TOKEN, FsTypes, IFileSystem, TypeScriptFileUpdate } from "@igniteui/cli-core"; | ||
|
||
//#region Temp duplicate of schematics pack fs | ||
export class NgTreeFileSystem implements IFileSystem { | ||
|
@@ -36,18 +35,18 @@ export function setVirtual(tree: Tree) { | |
//#endregion | ||
|
||
export default function(): Rule { | ||
return (host: Tree, context: SchematicContext) => { | ||
const workspace = getWorkspace(host); | ||
const project = workspace.defaultProject ? | ||
workspace.projects[workspace.defaultProject] : | ||
workspace.projects[0]; | ||
return async (tree: Tree, context: SchematicContext) => { | ||
const { workspace } = await workspaces.readWorkspace("/", createWorkspaceHost(tree)); | ||
const project = workspace.extensions.defaultProject ? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can use |
||
workspace.projects.get(workspace.extensions.defaultProject as string) : | ||
workspace.projects.values().next().value as workspaces.ProjectDefinition; | ||
|
||
const moduleFile = `${project.sourceRoot}/${project.prefix}/app.module.ts`; | ||
|
||
context.logger.info(`Applying migration for Ignite UI CLI 5.0.0`); | ||
|
||
if (host.exists(moduleFile)) { | ||
setVirtual(host); | ||
if (tree.exists(moduleFile)) { | ||
setVirtual(tree); | ||
const mainModule = new TypeScriptFileUpdate(moduleFile); | ||
mainModule.addNgModuleMeta({ import: "HammerModule", from: "@angular/platform-browser" }); | ||
mainModule.finalize(); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,23 @@ | ||
// tslint:disable:no-implicit-dependencies | ||
import { workspaces } from "@angular-devkit/core"; | ||
import { Rule, SchematicContext, Tree } from "@angular-devkit/schematics"; | ||
// tslint:disable-next-line:no-submodule-imports | ||
import { getWorkspace } from "@schematics/angular/utility/config"; | ||
import { createWorkspaceHost } from "@igniteui/cli-core"; | ||
|
||
export default function(): Rule { | ||
return (host: Tree, context: SchematicContext) => { | ||
const workspace = getWorkspace(host); | ||
const project = workspace.defaultProject ? | ||
workspace.projects[workspace.defaultProject] : | ||
workspace.projects[0]; | ||
return async (tree: Tree, context: SchematicContext) => { | ||
const { workspace } = await workspaces.readWorkspace("/", createWorkspaceHost(tree)); | ||
const project = workspace.extensions.defaultProject ? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You caн use |
||
workspace.projects.get(workspace.extensions.defaultProject as string) : | ||
workspace.projects.values().next().value as workspaces.ProjectDefinition; | ||
|
||
const errorService = `${project.sourceRoot}/${project.prefix}/error-routing/error/global-error-handler.service.ts`; | ||
|
||
context.logger.info(`Applying migration for Ignite UI CLI 5.0.3`); | ||
|
||
if (host.exists(errorService)) { | ||
let fileContents = host.read(errorService).toString(); | ||
if (tree.exists(errorService)) { | ||
let fileContents = tree.read(errorService).toString(); | ||
fileContents = fileContents.replace("throw error;", "console.error(error);"); | ||
host.overwrite(errorService, fileContents); | ||
tree.overwrite(errorService, fileContents); | ||
} | ||
}; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use
getDefaultProject
here.