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

refator schematics workspace api #829

Merged
merged 3 commits into from
Mar 12, 2021
Merged

Conversation

damyanpetev
Copy link
Member

Closes # .

Additional information related to this pull request:

@damyanpetev damyanpetev force-pushed the dpetev/schematics-workspace-api branch from a317537 to 743b428 Compare March 1, 2021 15:28
@coveralls
Copy link

Coverage Status

Coverage increased (+0.07%) to 82.784% when pulling 743b428 on dpetev/schematics-workspace-api into 9646fb6 on master.

workspace.projects[0];
return async (tree: Tree, context: SchematicContext) => {
const { workspace } = await workspaces.readWorkspace("/", createWorkspaceHost(tree));
const project = workspace.extensions.defaultProject ?
Copy link
Member

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 ?
Copy link
Member

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 ?
Copy link
Member

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 ?
Copy link
Member

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> {
Copy link
Member

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 ?
Copy link
Member

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
Copy link
Member

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?

@Lipata Lipata merged commit fb1d1fd into master Mar 12, 2021
@Lipata Lipata deleted the dpetev/schematics-workspace-api branch March 12, 2021 06:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants