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

fix(@schematics/angular): add appDir option #17816

Draft

Conversation

@santoshyadavdev
Copy link
Contributor

@santoshyadavdev santoshyadavdev commented May 28, 2020

fixes #17813

@googlebot googlebot added the cla: yes label May 28, 2020
@santoshyadavdev santoshyadavdev marked this pull request as draft May 28, 2020
const sourceRoot = clientProject.sourceRoot || 'src';
const serverPath = options.appDir ?
`${sourceRoot}/${options.appDir}` :
sourceRoot;

This comment has been minimized.

@SchnWalter

SchnWalter May 28, 2020
Contributor

L.E. Sorry, I've mistaken this for a schematic that adds an app-shell model from the Android world for the application, not for the server side. You can ignore most of what I've wrote here.


This change needs a more thorough analysis. I think that appDir option should be removed - it didn't work in the first place, so just deprecate it now and remove it later, and there is no harm done.

In other schematics, buildDefaultPath() is used to hardcode an app or lib sub-directory (depending on the project type) and it will come into conflict with this; you want other schematics to also work for projects that have used the app-shell schematics.

Alternatively, this could be implemented for all schematics, and have it fallback to the current behavior of buildDefaultPath(). I've actually submitted a similar feature suggestion, but for removing the sub-directory for all schematics, see #17598.

But I'm not sure if either of these should be implemented, we need to make sure that existing tutorials on how to generate components will continue to work in the future (including for projects that have used app-shell).

@santoshyadavdev santoshyadavdev force-pushed the santoshyadavdev:fix--add-appDir-option-in-appShell branch 4 times, most recently from 5fe0bf3 to e437829 Jun 1, 2020
@santoshyadavdev santoshyadavdev marked this pull request as ready for review Jun 1, 2020
@santoshyadavdev
Copy link
Contributor Author

@santoshyadavdev santoshyadavdev commented Jun 1, 2020

@alan-agius4 it's open for review.

@alan-agius4 alan-agius4 self-requested a review Jun 1, 2020
@alan-agius4 alan-agius4 self-assigned this Jun 1, 2020
@alan-agius4
Copy link
Collaborator

@alan-agius4 alan-agius4 commented Jun 1, 2020

@santoshyadav198613, I’ll review it tomorrow. Thanks.

Copy link
Collaborator

@alan-agius4 alan-agius4 left a comment

Hi @santoshyadav198613,

Firstly thanks for the PR 👍.

This changes however doesn't seem to be addressed the problem in the right place. The problem with appDir is actually located in the universal schematic.

In fact, it's right that the app-shell schematic is failing, because app.server.module.ts is not being placed in the specified directory when the appDir is used.

At the very least there are two places that you need to change.

@@ -10,6 +10,21 @@ import { Schema as ApplicationOptions } from '../application/schema';
import { Schema as WorkspaceOptions } from '../workspace/schema';
import { Schema as AppShellOptions } from './schema';

function createServerFile(appTree: UnitTestTree): void {

This comment has been minimized.

@alan-agius4

alan-agius4 Jun 2, 2020
Collaborator

This is not needed.

This comment has been minimized.

@santoshyadavdev

santoshyadavdev Jun 2, 2020
Author Contributor

Ohh got it, So my impression was incorrect, I will make the changes.

@@ -33,8 +33,7 @@
"appDir": {
"type": "string",
"format": "path",
"description": "The name of the application directory.",
"default": "app"

This comment has been minimized.

@alan-agius4

alan-agius4 Jun 2, 2020
Collaborator

Please revert this.

@santoshyadavdev
Copy link
Contributor Author

@santoshyadavdev santoshyadavdev commented Jun 2, 2020

Hi @alan-agius4 ,
So let me understand this correctly, we can use appDir option in appShell only if while running universal schematics we used appDir option, is my understanding correct?

@alan-agius4
Copy link
Collaborator

@alan-agius4 alan-agius4 commented Jun 2, 2020

@santoshyadav198613, yes I believe so. The appDir is primarily used by the universal schematic.

We might need to use the path option in the component schematic, but I guess this will be uncovered when creating the UT.

@santoshyadavdev santoshyadavdev force-pushed the santoshyadavdev:fix--add-appDir-option-in-appShell branch from e437829 to 2924bc7 Jun 2, 2020
@santoshyadavdev santoshyadavdev marked this pull request as draft Jun 2, 2020
@santoshyadavdev santoshyadavdev force-pushed the santoshyadavdev:fix--add-appDir-option-in-appShell branch 6 times, most recently from 344e6fd to 4ec8641 Jun 2, 2020
@santoshyadavdev santoshyadavdev marked this pull request as ready for review Jun 3, 2020
@santoshyadavdev santoshyadavdev marked this pull request as draft Jun 3, 2020
@santoshyadavdev santoshyadavdev force-pushed the santoshyadavdev:fix--add-appDir-option-in-appShell branch 3 times, most recently from 4fb9216 to a5fa1ec Jun 3, 2020
@santoshyadavdev santoshyadavdev force-pushed the santoshyadavdev:fix--add-appDir-option-in-appShell branch 10 times, most recently from 664dbf4 to 1b41589 Jun 7, 2020
fixes #17813
@santoshyadavdev santoshyadavdev force-pushed the santoshyadavdev:fix--add-appDir-option-in-appShell branch from 1b41589 to ba44abc Jun 8, 2020
@santoshyadavdev
Copy link
Contributor Author

@santoshyadavdev santoshyadavdev commented Jun 9, 2020

Hi @alan-agius4 ,
Need one help app-shell test case fails it, I thought app-shell runs universal schematics.

it('should create the shell component with appDir option provided', async () => {
const defaultOptions: AppShellOptions = {
clientProject: 'bar',
appDir: '/projects/bar/src/app/server',

This comment has been minimized.

@alan-agius4

alan-agius4 Jun 10, 2020
Collaborator

appDir should be a directory example myApp and not a path in the workspace.

Also, expect(tree.exists('/projects/bar/src/app/app-shell/app-shell.component.ts')).toBe(true); doesn't seem good, because the app-shell should be created in the provided appDir.

@alan-agius4
Copy link
Collaborator

@alan-agius4 alan-agius4 commented Jun 10, 2020

@santoshyadav198613, will try to look at this in the coming days.

@alan-agius4
Copy link
Collaborator

@alan-agius4 alan-agius4 commented Jun 17, 2020

@santoshyadav198613, just to let you know that I didn’t forget about this! Apologies for taking so long to look at this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

4 participants
You can’t perform that action at this time.