Unity3D - Using different dependencies in different environments - unity3d

I aum using Unity 2019.3
I have my dependencies defined in my manifest.json like this:
{
"dependencies": {
"com.emt.foo1": "https://github.com/emt/foo1.git",
"com.emt.foo2": "https://github.com/emt/foo2.git",
...
}
}
But when I am developing locally, I would like to use a different version, maybe a local version, like for instance this:
{
"dependencies": {
"com.emt.foo1": "file:/home/emt/packages/foo1",
"com.emt.foo2": "https://github.com/emt/foo2.git",
...
}
}
Is there a way to define different packages for different environments?

Yes, you can define local dependencies. Here is Unity Documentation about it.

Related

How to use (environment) variables for a package.json dependency in npm?

In npm, I want to be able to install a package from a private GitHub repo as a dependency through the git+https way without having to hardcode the actual github_username:personal_access_token, but rather plug them into the dependency string as (environment) variables.
So instead of
package.json:
...
"dependencies": {
...
"my-private-github-repo": "git+https://<github_username>:<personal_access_token>#github.com/some/package.git",
...
}
I would like something like this:
package.json:
...
"dependencies": {
...
"my-private-github-repo": "git+https://${github_username}:${personal_access_token}#github.com/some/package.git",
...
}
Hardcoding credentials is a major no-no when applying version control to package.json which I'd like to be able to do.
What is the best way to do this?
Create .env file at the same directory level where package.json resides.
Mention PERSONAL_ACCESS_TOKEN=******************************* into .env file
Don't forget to add .env into .gitingore list which will prevent exposing key to outside world while you make git commit to your repo.
Now you can add your dependency in package.json as below,
"dependencies": {
...
"my-private-github-repo": "git+https://${ENV.PERSONAL_ACCESS_TOKEN}#github.com/USER/abcd-repo-3.4.0.git",
...
}
There are other ways using 'DOTENV' npm package, but it could not do much when we are trying to resolve "Github" package dependency. Above seems to be straight forward solution.

How to exclude certain files from a package managed by jspm and systemjs?

For instance with bower I could do something like this to get only the scss files (excluding js):
{
"dependencies": {
"bootstrap-sass": "~3.3.5"
},
"overrides": {
"bootstrap-sass": {
"main": [
"assets/stylesheets/_bootstrap.scss"
]
}
}
}
I am having an hard time understanding how to do it with systemjs. in the config.js file I guess but even reading the docs I could not figure it out.
My use case is: while developing I am loading Material angular with systemjs but I want to load only the js files, not the css, which I want to manage indenpdently in my scss. Instead systemjs keep loading the file angular-material.css. I just started with systemjs and jspm, hope you can help.
nb: my problem is not related to the jspm build or bundle process but to the development time with these tools.
JSPM supports overrides as well. See https://github.com/jspm/registry/wiki/Configuring-Packages-for-jspm#testing-configuration for configuration options.
Using JSPM overrides you can easily override the main file and directories and files that you need from a module.
Upd. The css dependency is defined in the registry: https://github.com/jspm/registry/blob/974beb8b6520f4c1b3c6373db32ad05da5c82446/package-overrides/github/angular/bower-material%400.4.0.json It needs to be overwritten with the local override.

using non-modular libraries with SystemJs and jspm

To include ngDraggable into a project using systemJs and jspm, we need to add an override in package.json as below:
"overrides": {
"github:fatlinesofcode/ngDraggable#0.1.8": {
"dependencies": {
"angular": "jspm:angular#1.5.3"
},
"shim": {
"ngDraggable": [
"angular"
]
}
}
}
It's twice that we are mentioning that ngDraggable has a dependency on angular.. moreover the config.js file created by jspm also mentions this
"github:fatlinesofcode/ngDraggable#0.1.8": {
"angular": "github:angular/bower-angular#1.5.3"
},
Why do systemJs and jspm need this mentioned in so many different places ?
It's not twice since dependencies and shim.deps do different stuff.
The shim deps actually modifies the ngDraggable file and adds a "deps angular" statement. This allows you to specify each file dependency separately.

Building Google Analytics package in ASP.NET Core 5.0

I am trying to include Google Analytics API package in my MVC 6 application. I've tried to include all the dependencies or to let it install trough NuGet Package Manager. In either case, when i build the solution, I get an error: Error CS0246 The type or namespace name 'Google' could not be found (are you missing a using directive or an assembly reference?) ProjectName.ASP.NET Core 5.0
Any idea what dependencies I need to include for it to build in ASP.Net Core 5.0?
Here is what i have in my project.json file:
"dependencies": {
...
"Microsoft.Net.Http": "2.2.28.0",
"Microsoft.Bcl": "1.1.9.0",
"Microsoft.Bcl.Build": "1.0.21.0",
"Microsoft.Bcl.Async": "1.0.168.0",
"Google.Apis.Analytics.v3": "1.9.0.1100"
},
...
"frameworks": {
"aspnet50": {
"dependencies": {
}
},
"aspnetcore50": {
"dependencies": {
"Newtonsoft.Json": "6.0.8.0"
}
}
},
Similar issue to the one described here: Problems with RavenDB.Client reference in asp.net 5.0 project.json
Adapting my answer from there:
The problem is that you referencing Google.Apis.Analytics.v3 in the top level dependencies node in project.json. That means that those dependencies are applicable to both Desktop CLR (aspnet50) and CoreCLR (aspnetcore50).
When you build an ASPNET 5 project, all configurations are built, not just the "active" one. Mostly sure Google.Apis.Analytics.v3 works only with the Desktop CLR so move it under a dependencies node under that configuration.
"dependencies": {
....
},
"frameworks": {
"aspnet50": {
"dependencies" : {
"Google.Apis.Analytics.v3": "1.9.0.1100"
}
},
"aspnetcore50": {}
}
Then you might have to either use some conditional blocks in your code (#if ASPNET50) or remove CoreCLR all together.
Then you might have to either use some conditional blocks in your code (#if ASPNET50) or remove CoreCLR all together.

Dummy app dependencies

I'd like the dummy app to have some dependencies that are not shared for the addon itself,
Is it possible at all?
For now, I do some workarounds in index.js such:
var isDummy = app.project.pkg.name === 'ember-idx-forms'
if (isDummy) {
app.import('...');
}
Is there a better approach?
Thanks.
The addon contains it's own Brocfile.js that is used for exactly this. Simply import whatever you want in there. It is not used in the consuming applications.
See here for docs on this
Should be added to Broccoli.js as stated in ember-cli docs:
The addon’s Brocfile.js is only used to configure the dummy application found in tests/dummy/. It is never referenced by applications which include the addon.
For that you use the dependencies and devDependencies sections in your package.json:
{
"dependencies": {
"some-package": "v1"
},
"devDependencies": {
"some-test-package": "v1"
}
}
https://docs.npmjs.com/files/package.json