How to modify package that is dependency of other packages - MeteorJS - meteor

So, my problem is that I am trying to add a couple of console.log() to a js file of an already installed package that I have in my project.
The package that I am trying to add these lines to is aldeed:autoform, since I've discovered kind of a bug in a function and I want to contribute with a solution.
In order to modify a package, I have already done the following steps:
Clone the github repo for autoform inside myProject/packages/ folder.
Modified the lines that I wanted to.
Changed the name value inside Package.describe({}) (set to
aldeed-autoform-modified)
Removed aldeed:autoform from my project (meteor remove
aldeed:autoform)
Added my modified version of autoform (meteor add
aldeed:autoform-modified)
The problem is that, since I am also using antoher packages that have aldeed:autoform as a dependency, this package gets automatically installed, and then when I run my project, it trhows an error saying that a template (related to AutoForm) is defined twice, and this makes sense since autoform package and the modified one have this templated defined, and both get included in the project.
What should I do? What is the proper way to modify a package that is a dependency for others?

If you want to modify an existing package, you can use a local version of it.
There is no need to modify its name, and if another package depends on it, changing the name will cause the dependent package not to use your modified version.
Simply clone the package repository into your projects's/packages directory or to the directory denoted by the METEOR_PACKAGE_DIRS environment variable.
You can find more details on the Meteor Guide.

Related

Add a logging entry to appsettings.json via a custom NuGet package

I have a NuGet package that I have created for my company. It works great. But it includes some code in the System.Net.Http.HttpClient.OAuthClient namespace that is very chatty in the logs at the Information level.
I would like to have my NuGet package automatically add the following line:
"System.Net.Http.HttpClient.OAuthClient": "Error"
At the end of the Logging->LogLevel section of the appsettings.json file of the project it is installed in (if its not already there).
Or failing that, is there a way to suppress these logs down to the Error LogLevel in code?
It's just my personal opinion, and it doesn't answer your question directly, but it did not fit into a comment, so posting it here.
I don't think it's up to your package to decide, what will be in the appsettings.json. There may be let's say production and test appsettings, and in test developers of some projects would actually want to see as many logs as possible.
If your package would modify it, you would take away the decision from developers who use your package. Or, imagine, the project that uses your package also used System.Net.Http.HttpClient.OAuthClient namespace, but for its own purposes. And developers again might want to see logs coming from that namespace.
I'd suggest just to put this info into your package's documentation, and than developers of each project shall decide for themselves, whether they want to suppress logs or not.
Update after comment:
Probably this will get you somewhere: http://www.roundcrisis.com/2014/08/03/Nuget-install-tricks/
The basic idea is that you can distribute init.ps1 script together with your nuget package that will run on installation of the package. And with powershell you could do pretty much anything, including replacing strings in text files.
Have a look also at this SO question: Execute an action after my nuget package is installed

Meteor .versions file update

I am developing a small meteor package, and I know that, to be consistent with the builds, meteor will create a .versions file in my package when I publish it.
That's fine, and I understand that, but, as the .versions should go in my version control (git) and I would like to commit the release before publishing it, is there a way to update the .versions package before publishing?
Also, the .versions file has a reference to the package itself. Is this necessary? If I'm developing version x.y.z of a package, why do I need to update both the package.js and the .versions file to reflect x.y.z?
Thanks,
Oliver
I don't think there's a need to add it to version control b/c I don't think the set of calculated versions means anything in a stand-alone package outside of the context of a meteor project. I'm not really sure what the file is used for at all since it doesn't show up in .meteor/packages when you install the package. It might just be nothing more than a by-product of running the solver.
So I never check .versions into version control and I haven't encountered any problems.

How do I customize a meteor package to use it in my project

I am trying to use meteor typeahead package in my project. It has some issues with it, so the developer asked me to create a local PR and use it. The thing is that I don't know how to create a local PR. Do I need to create a local package and then add it to my project, etc. I cloned the repository to my local machine, and changed the code that I need, but I don't know what to do after this. Can somebody help me with this please.
Thanks
After you cloned the package just copy all the files in a packages/name_of_the_package folder of your Meteor project.
You can also create a symbolic link between the package folder and the package folder in the Meteor project. So all changes are automatically reflected.
Then, add it as usual with meteor add name_of_the_package or by modifying the .meteor/packages file. Meteor will look in priority in the local package folder instead of the official repository.
Create a fork of the desired repo.
Clone your fork of the repo as a sub folder of the "packages" folder within your app.
Remove the atmosphere package by performing a meteor remove some:package
Add the package back, just as you normally would, with meteor add some:package. Meteor will find the local copy and use it, instead of downloading the package from Atmosphere.
Make the desired code changes, testing it before you commit.
Commit your changes to Github.
Create a pull request within the fork on Github.

Meteor package file inclusion

I want to build a meteor package to wrap an existing javascript library. I would like to include the library as a git submodule. I only need 2 files from the submodule. If I only include these two in package.js will the rest of the files be ignored by meteor and not built into the package?
The only files that will end up in your package are those that will be explicitly added with api.addFiles routine (look here).
BTW, If you're planning to wrap an existing JavaScript library then you should probably start by getting familiar with autopublish project. For more details watch this video.

Updating Files in Existing Nuget Package

I've got a multi-project ASP.NET Web Forms Application solution. I need to share a master page (3 files), some user controls and some images, scripts and CSS files out to the other projects in the solution.
I have already created a package using the NuGet Package Explorer per the documentation:
http://docs.nuget.org/docs/creating-packages/using-a-gui-to-build-packages
My current problem is this: I have updated the shared files in the root project and now I want to update the package before pulling it into the other projects (package currently in a local folder on my dev machine). How do I do this?
If anyone has some getting-started-quickly NuGet links, please share as the official docs just aren't doing it for me.
create the package again with a new version aka if the orginal is 1.0 make this 1.1 and NuGet will pick up the update.
The NuGet file is ultimately just a zip file. You can update entries using anything that can update a zip file. Such as something like
using System.IO.Compression;
using System.IO.Compression.FileSystem;
// EG: AddOrUpdateZipEntry("mypackage.nupkg", "my.dll", "bin/my.dll")
void AddOrUpdateZipEntry(string zipFilePath, string contentsFilePath, string entryPathInZip)
{
using (var zip = ZipFile.Open(zipFilePath, ZipArchiveMode.Update))
{
zip.GetEntry(entryPathInZip)?.Delete(); // Remove any existing entry first.
zip.CreateEntryFromFile(contentsFilePath, entryPathInZip);
}
}
Are you asking what you need to do to update projects that are already using the package?
The key thing in this kind of scenario is simply versioning. The new version of the file will be sub'd out. Bundle up the package again with a new version number and then run Update-Package from the package manager console in VS.
You may also want to consider a couple of discreet packages, rather than one straight one. If you want to update a couple images or a CSS file, but not the MasterPage, it might work best to have a couple smaller ones.
Use the PM Explorer (from the post you mentioned) to open a couple packages from the NuGet main repository, in particular, jQuery 1.5.1 and 1.6.x and have a look, as these will be doing very similar things. No real magic needed!
Cheers.
I've already done it before. You just have to increment the version of your package, inside metadata of .nuspec file.
In my case, my packages names are '[name].[version].nupkg' so I save my new package as '[name].[version +1].nupkg' as well.
The update apears in 'Manage nuget packages' updates section.

Resources