Checking constraints for a Meteor package - meteor

In order to customize a third-party Meteor package, I copied the package folder from /Users/<name>/.meteor/packages/accounts-ui-unstyled/.1.1.8.cfkrwq++os+web.browser+web.cordova/ and pasted it into the packages folder at the root of my app as accounts-ui-unstyled/.
Now when the app compiles, I get this error:
Errors prevented startup:
While selecting package versions:
error: No version of accounts-ui-unstyled satisfies all constraints: #=0.0.0, #=1.1.8
Constraints on package "accounts-ui-unstyled":
* accounts-ui-unstyled#=0.0.0 <- top level
* accounts-ui-unstyled#=1.1.8 <- top level
* accounts-ui-unstyled#1.1.8 <- accounts-ui 1.1.6
Your application has errors. Waiting for file change.
Where are these constraints being declared, and what do I need to change to get the accounts-ui-unstyled/ folder in the packages folder to be correctly identified?

Normally you would like to create a local copy of a package by cloning its repository from GitHub (provided the source is available), and not from your local file system (which holds pre-built versions of the packages).
Sometimes (as it is the case with the core Meteor packages), they are "hidden" in sub-directories of the repository.
A neat trick is to use SVN in order to quickly get a snapshot of that sub-directory:
$ mkdir packages && cd packages
$ svn export https://github.com/meteor/meteor/trunk/packages/accounts-ui-unstyled
If you want to pull from a specific branch, use
$ svn export https://github.com/meteor/meteor/branches/<branch_name>/packages/<package-name>
The constraints will be specified in the package.js file, as expected.
Note: MDG are planning to move the core packages into their own repository/repositories, so those instructions may not be valid for the core packages in the future.

Related

How to Disable download missing package each time in meteor?

I tried to create meteor web application, but meteor download missing package each time when I change my code, and it was unnecessary.
So, can I config it only runs at the first time?
Thanks!
Could you add the actual message on the package it tries to download? Anyway, there are two potential locations where meteor looks for packages that need to be installed.
This is which each Meteor application and it's using Meteor Atmosphere packages. You can find these at .meteor folder in your project root file called packages path ./meteor/packages
Other potential place is packages.json in project root. It exists if you have used npm install or meteor npm install within the project.
Deleting unnecessary packages from these files should do the trick.

Hot swap of local Meteor package

I am using local Meteor package for my app (not posted on Atmosphere.js).
When I update this package elsewhere, I proceed with the following:
Update version of the package.
Delete old package from /packages/ directory of the live app.
See my program search for packages 3(?) times and then crash:
Your app is crashing. Here's the latest log:
Errors prevented startup:
While selecting package versions:
error: unknown package in top-level dependencies: vladimir3000:testpack
Your application has errors. Waiting for file change.
Copy new package with new version.
See my app picking up the changes and going live again:
vladimir3000:testpack upgraded from 0.0.2 to 0.0.3
=>Meteor server restarted
Is there a way to avoid step 3 and more elegantly instruct meteor to replace one package with another. Meteor update would not work as the package is not on atmosphere.js. Or hot swap is something from SOA world not from blood and fibers of Meteor javascript?
You can simply paste over the files for the package.
When you delete the old package, Meteor sees a file change and rebuilds the app. Since the package no longer exists in the packages directory, Meteor will try to pull it down from Atmosphere since it sees that there is a dependency on vladimir3000:testpack in .meteor/packages.
It will attempt to resolve this dependency a few times, with each build failing because the package you are referencing is unknown.
You can stop meteor and delete and replace the folder. Or you can copy and paste over the folder. The second method is preferable because Meteor will simply rebuild with all of the new files, rather than rebuilding and trying to resolve the dependency using Atmosphere.

How To modify quantmod package with GIT

I currently have quantmod installed. I would like to modify the source code.
Do I need to uninstall the current version?
I currently was trying
(1) Installed GIT
(2) then I went to New Project>> Version Control >>create a new project form version control GIT and when I click that I get this error
"Git was not detected in the system path. to create projects from GIT repositories you should install GIT and then restart Rstudio. Not tha tif GIT is installed an not on the path then you can specify its location using the options dialog."
(3) So I went to the global options>>GIT/SVN>>Git executable and put this path
C:\Users\me\AppData\Local\Programs\Git\bin\git.exe
(4) then I restarted RSTUDIO and now I get further so when I go to
New Project>> Version Control >>create a new project form version control GIT>>CLONE GIT REPISITORY
Here it asks for a Repository URL, Project Directory name, and Create project as subdirectory of. Here is where I am unsure where I need to put this project so that the modification I make to the quantmod package will be picked up by my version of R
For Repository URL I was going ot put:
https://github.com/joshuaulrich/quantmod
For Project Directory I am unsure: can you advise??
For Create project as sub directory I am unsure: can you advise??
My R libraries are here: C:\Users\me\Documents\R-3.1.2\library
Also currently I have quantmod installed here:
C:\Users\me\Documents\R-3.1.2\library\quantmod
Do I need to uninstall that current version?
Appendix:
On My computer GIT is here: C:\Users\Me\AppData\Local\Programs\Git
On My computer R is here: C:\Users\Me\Documents\R-3.1.2
The project directory is just the name of the folder you will be putting the repo inside. Generally it is the name of package to make things clear. In your case quantmod.
The sub directory you can ignore unless you want to choose some other location (besides the current directory) for you code.
You don't need to uninstall the current version. My usual recommendation is to just increment the subversion of the package in the DESCRIPTION file. For example, increment:
Version: 1.0.1
to
Version: 1.0.2
Now when you rebuild and install you will have the new version. If you need the original again, you can just reinstall the old one (i.e. install.packages). Having both installed at the same time would likely result in conflicts between the packages and just causing a headache.

How to re-use an already installed package in Meteor?

I installed couple of packages for 'Project A' (e.g bootstrap) assuming that it will be available for all subsequent projects. But when a new meteor project 'Project B' was created, meteor list showed only default packages. So my assumption that meteor packages are like ruby gems available globally is incorrect. As I work offline every now and then, Is there a way I can manually copy/re-use installed packages?
Yes they are similar to gems. Packages are installed in ~/.meteor/packages, in precompiled form. They can be installed globally this way.
When you add a package to your project it will essentially copy the package from there into your build-cache directory hidden in the .meteor directory of your project.
To install a package locally where you can easily re-use it you would have to clone the github repository of the package and place the output in the /packages directory of your Meteor app.
For example for bootstrap, twbs:bootstrap you would clone this reposistory: https://github.com/twbs/bootstrap, into a directory like /packages/twbs:bootstrap (name doesn't matter if its defined in the package.js file on the repository.
In general you can easily re-use a package without the hassle of adding it in manually like so. It's better to use the global packages which are kept up to date.
The trouble comes with being offline. If you use a local package its nearly guaranteed to always work. Whereas the global ones can give a bit of trouble once in a while when you try to add a package in as meteor tries to check the package is up to date, especially where npm packages are involved with the package.
To keep it short if you added a package in using meteor add twbs:bootstrap you should most likely be able to add it to another project using the same command. Only if you keep your packages & meteor up to date.

Where does meteor stores its packages?

I have a meteor 1.0 app. I've added a bunch of packages, for example: meteor add kevohagan:ramda. But I cannot find it anywhere. I can't even find it on my system.
In my project:
$> meteor list
kevohagan:ramda 0.1.2 A practical functional library for Javascript programmers.
meteor-platform 1.2.0 Include a standard set of Meteor packages in your app
...
$> ls packages
ls: packages: No such file or directory
$> mdfind ramda.js # file added by the package
# no results
Where are they ?
If you add a package via meteor add author:pkg it will be added to the meteor installation (e.g. ~/.meteor/packages); here you can find different versions of the package. In your project home, the package name will be added to the .meteor/packages file.
Later, if run your project, the package will be added to the build directory (and of course only one version can be found here).
I think that they all are in
.meteor/local/build/programs/server/packages
but they are ninified, and the file names are changed, like "kevohagan_ramda.js" or "meteor-platform.js"
If you check out your project folder then you'll find two 'packages' folders. One at the root of your project and the other deep down inside .meteor. Below I've listed both of them.
.meteor/packages //this consist of the packages that you built yourself or other top-level packages like spinner & iron:router
.meteor/local/build/programs/server/packages //other packages

Resources