running nx:affected with an xplat workspace - nrwl-nx

I would like to use the nx:affected:build command to only build the apps that are affected by the last commit in an nx/xplat workspace.
Let's say I have 2 angular web apps web-app1 and web-app2.
.
├── apps
│ ├── web-app1
│ └── web-app2
├── libs
│ ├── core
│ └── features
│ └── app1
│ └── app2
└── xplat
└── web
└── features
└── app1
└── app2
When I make a change to /xplat/web/app1 I would expect the nx:affected:apps command to only show the web-app1 app. However nx thinks that the commit affects both apps. (**web-app2 ** does not import the app1 feature.)
nx affected:apps --base=head~1 --head=head
I've created a sample repo to demostrate: https://github.com/barryajones/workspace-affected-test

Related

Can an utils.py file be used in more than one module?

I am working in a somewhat substantial application, and there is some common logic that I've put in an utils.py (you can tell where this is going).
I am not sure where I should put utils.py, or if I should have more than one copy of it, or if I should install it as a module itself.
Consider this simplified application layout from realpython.com
helloworld/
│
├── helloworld/
│ ├── __init__.py
│ ├── runner.py
│ ├── hello/
│ │ ├── __init__.py
│ │ ├── hello.py
│ │ └── helpers.py
│ │
│ └── world/
│ ├── __init__.py
│ ├── helpers.py
│ └── world.py
│
└── README.md
You have the two main files hello.py and world.py, and there is some hello.py specific helper functions in the adjacent helpers.py.
However, what if there is a substantial amount of logic that is common to both helpers.py; say a sqlalchemy connection or some dataclasses that are endemic across the application.
To make the conversation concrete, suppose I have a dataclass User that is needed pretty much everywhere. Where should I put the file that defines User so that it is available in all the other .py files?
On the one hand I understand the idea behind a directory tree (it's not a tree if the leafs all import utils.py). But what's the alternative? To copy that logic everywhere?

Need order and action of pytest hooks execution

Can anyone clarify how pytest hooks executes and what it does in each step?
Mainly, could you please tell me why pytest_plugin_registered is repeated under pytest_sessionstart?. I checked pytestdebug.log and it repeats the same plugins' registration.
root
└── pytest_cmdline_main
├── pytest_plugin_registered
├── pytest_configure
│ └── pytest_plugin_registered <-------- registers all _pytest plugins, conftest, setup tools plugins
├── pytest_sessionstart
│ ├── pytest_plugin_registered <-------- again registers all same above _pytest plugins, conftest, setup tools plugins
│ └── pytest_report_header
https://github.com/pytest-dev/pytest/issues/3261#issuecomment-755461808

Adding a custom resource directory to SBT's default unmanagedResourceDirectories

I have two SBT projects as outlined below.
├── Project 1
│ │
│ └── src
│ └── main
│ ├── scala
│ │ └── com
│ │ └── xyz
│ │ └── <*.scala>
│ └── resources
│ └── <Typesafe & Log4J config files>
│
│
└── Project 2
│
├── src
│ └── main
│ ├── scala
│ │ └── com
│ │ └── xyz
│ │ └── <*.scala>
│ └── resources
│ └── <Typesafe & Log4J config files>
│
├── resources
│ └── <JS, HTML, Image files etc.>
├── other-dir-1
│
├── other-dir-2
│
└── other-dir-3
Compiling Project 1 (actually running SBT exportedProducts task) produces the following directory structure. unmanagedResourceDirectories points to Project1/src/main/resources. I believe this is the default resourceDirectory (as mentioned in Customizing Paths). In other words, files in default resource directory are automatically added by exportedProducts
├── Project 1
└── target
└── scala-2.10
└── classes
├── com
│ └── xyz
│ └── <*.class>
└── <Typesafe & Log4J config files>
For Project 2, I want the following directory structure to be produced by exportedProducts.
├── Project 2
└── target
└── scala-2.10
└── classes
├── com
│ └── xyz
│ └── <*.class>
├── <Typesafe & Log4J config files>
│
└── resources
└── <JS, HTML, Image files etc.>
To do this I added the following to SBT build file in the appropriate project definition.
unmanagedResourceDirectories in Compile += baseDirectory.value
excludeFilter in unmanagedResources := HiddenFileFilter || "other-dir-*"
includeFilter in unmanagedResources :=
new SimpleFileFilter(_.getCanonicalPath.startsWith((baseDirectory.value / "resources").getCanonicalPath))
This correctly includes resources directory but doesn't include the files from Project2\src\main\resources. The target directory looks like the
├── Project 2
└── target
└── scala-2.10
└── classes
├── com
│ └── xyz
│ └── <*.class>
└── resources
└── <JS, HTML, Image files etc.>
Adding a custom resource directory in some way masks the content of the default resource directory. I tried something along the lines of what was mentioned in this SO post but wasn't successful.
The other thing that I tried was to set unmanagedResourceDirectories in Compile += baseDirectory.value / "resources" and remove both includeFilter and excludeFilter. This adds the files from Project2\src\main\resources correctly but adds the files & directories from Project2\resources directly to Project2\target\scala-2.10\classes. The target directory looks like the following
├── Project 2
└── target
└── scala-2.10
└── classes
├── com
│ └── xyz
│ └── <*.class>
├── <Typesafe & Log4J config files>
│
└── <JS, HTML, Image files etc.>

Standard CoffeeScript output layout

Is there any de facto standard for the filesystem output layout of compiled CoffeeScript output?
Or: where should the .js and .map files end up?
I currently have a file watcher1 compiling the output to ./grounds/[whatever] to keep the source folder clean, so I end up with something like:
index.html
/js
├──foo.js
├──bar.js
/coffee
├──a.coffee
├──b.coffee
├──/grounds
│ ├──a.js
│ ├──a.map
│ ├──b.js
│ ├──b.map
├──/some-module
│ ├──c.coffee
│ ├──/grounds
│ │ ├──c.js
│ │ ├──c.map
Just curious if I missed the boat on some existing standard for the output file layout, or if folks generally just let them all be siblings in the same folder and are happy with that.
1: Pycharm
I don't think they is any standard, but for development, I use the same structure for the JS than for the coffee:
eg:
coffee
├── AdvancedStatsModule.coffee
├── board
│   ├── Board.coffee
│   ├── Card.coffee
├── controllers
│   ├── directives.coffee
│   ├── factory.coffee
│   ├── filters.coffee
│   ├── ListController.coffee
public/js
├── AdvancedStatsModule.js
├── board
│   ├── Board.js
│   ├── Card.js
├── controllers
│   ├── directives.js
│   ├── factory.js
│   ├── filters.js
│   ├── ListController.js
Advantages for this:
JS and coffee are not mixed
The coffee directory is not public
For production, I usually concat and minify my files anyway.
Update:
I use gulp for that. My Gulpfile:
var watch= require('gulp-watch');
var coffee= require('gulp-coffee');
gulp.src(paths.coffee)
.pipe(watch(function(files) {
return files.pipe(coffee())
.pipe(gulp.dest(paths.js));
}));

Folder structure in ASP.NET MVC2

I have a problem with folder structure of MVC2
How can I use that way:
Folder:
├── Controllers
│ └── Portal
│ ├── Accounting
│ │ ├── CashController.cs
│ │ └── BankController.cs
│ └── HR
│ └── EmployeesController.cs Models
└── Views
└── Portal
└── Accounting
├── Cash
│ ├── Index.aspx
│ └── List.aspx
├── Bank
│ └── Index.aspx
└── HR
├── Index.aspx
└── Employee.aspx
How can I use folder structure like that and how can I route the URL with the right form.
Many Thanks
You might want to consider using Areas and dropping the Portal folder since it's just a wrapper.
So you will end up with something like this :
Areas
├── Accounting
│ ├── Controllers
│ │ ├── CashController.cs
│ │ └── BankController.cs
│ └── Views
│ ├── Cash
│ │ ├── Index.aspx
│ │ └── List.aspx
│ └── Bank
│ └── Index.aspx
└── HR
├── Controllers
│   └── EmployeesController.cs
└── Views
└── Employees
├── Index.aspx
└── Employee.aspx
More on Areas here
Or just use any structure you want and change the namesspaces to match the default (not recommended).