-
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
Conversation
a317537
to
743b428
Compare
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 comment
The reason will be displayed to describe this comment to others. Learn more.
You caн use getDefaultProject
here.
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 comment
The reason will be displayed to describe this comment to others. Learn more.
You can use getDefaultProject
here.
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 comment
The reason will be displayed to describe this comment to others. Learn more.
You can use getDefaultProject
here.
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 comment
The reason will be displayed to describe this comment to others. Learn more.
You can use getDefaultProject
here.
} | ||
|
||
export function getDefaultProjectBuildOptions(tree: Tree) { | ||
return getTargetedProjectOptions(getDefaultProject(tree), "build"); | ||
export async function getDefaultProject(tree: Tree): Promise<workspaces.ProjectDefinition> { |
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.
How about we mode this one to a util file where we can access it anywhere we need it. core/util/Schematics.ts
could be a good place for the time being, no?
We could also create a function that returns not only the default project but all projects in a workspace, with the default project being one of them, this should prove a tiny bit more robust.
workspace.projects[projectName].architect[key].options.styles.push(cssImport); | ||
return true; | ||
} | ||
const project = workspace.extensions.defaultProject ? |
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.
|
||
const target = project?.targets.get(key); | ||
if (!target) { | ||
// TODO: Log target not found |
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.
Should we log it? Can project.targets
be undefined
?
Closes # .
Additional information related to this pull request: