A client for Meteor Package Server API.
Creates and syncs all data about packages to local MongoDB collections and keeps them in sync.
This project has been setup with eslint, prettier and editorconfig configurations to ensure clean, consistent, error free code.
meteor add peerlibrary:meteor-packagesOn the server-side, you initialize it like this:
import { Meteor } from "meteor/meteor";
import { PackageServer } from "meteor/peerlibrary:meteor-packages";
Meteor.startup(function() {
PackageServer.startSyncing({
//options - the following are the defaults if not passed
logging: false, // When true, informational log messages will be printed to the console
batchSize: 500, // Number of packages to process per batch (lower = less memory usage)
sync: {
builds: true, // Should information about package builds be stored
releases: true, // Should information about Meteor releases and release tracks be stored
stats: true, // Should package stats be fetched and stored
}
});
});Initial syncing might take quite some time.
The sync process has been optimized for memory efficiency. If you're running on a system with limited memory:
- Reduce
batchSize(e.g.,batchSize: 100) to process fewer packages at a time - Enable
logging: trueto monitor progress - The sync uses cursor-based pagination and processes packages in chunks to avoid loading all data into memory at once
Then on the server you can register code that will only run after the initial data sync has completed with PackageServer.runIfSyncFinished . For example it will run directly after the sync completes, and then again subsequently at starup when PackageServer.startSyncing() is called. This allows you add things such as collection-hooks that shouldn't run while the initial sync is happening.
import { Meteor } from "meteor/meteor";
import { PackageServer } from "meteor/peerlibrary:meteor-packages";
PackageServer.runIfSyncFinished(() => {
PackageServer.ReleaseVersions.after.insert((userId, doc) => {
Feed.addEvent('Meteor Release', doc.version);
})
});The following collections can be accessed on the server or client. For the client you'll of course need to publish the necessary data.
PackageServer.PackagesPackageServer.VersionsPackageServer.BuildsPackageServer.ReleaseTracksPackageServer.ReleaseVersionsPackageServer.LatestPackagesPackageServer.Stats
LatestPackagescollection is the same asVersions, except that it contains only the latest versions of packages.
Schema of documents is the same as described in the documentation with a couple exceptions.
-
Versionscollection'sdependenciesfield is represented as an array of objects where package name is stored aspackageNamekey. This is to support package names with.in the name without any problems. -
Packagescollection will contain 2 additional fields,directAdds, andtotalAddswhich are the direct and total install counts for the corresponding package. -
Statscollection adds the date field to the document for ease of querying chronologically.
While this package isn't currently implemented in Typescript, there are type definitions provided for your convenience in the typings.d.ts file in the root of this project.