npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@mongosh/build

v0.4.0

Published

MongoDB Shell Build Tools

Downloads

50

Readme

The Mongo Shell Build System

Evergreen Build

This package contains all the tools needed to build and release mongosh.

Build process is done on Evergreen and is triggered with every commit. Releases are triggered by a git tag when ran with npm run publish-npm from the root of the project.

Current build and release flow is as follows:

  • `npm run evergreen-release package
    • A commit triggers an evergreen build based on currently available build variants: MacOS, Windows, Linux, Debian, and RedHat.
    • MacOS, Linux and Windows run three tasks: check, test, and release. Debian and Redhat run two tasks: check and release. Debian and Redhat also depend on tests to pass on Linux.
    • Identical bundle and binary are built on all five variants.
    • Each variant creates its own tarball (.zip, .tgz, .deb, .rpm). Type of tarball is determined by the current build variant.
    • Each variant uploads its own tarball to Evergreen’s AWS.
    • MacOS build variant uploads config file with information about the new version for each platform to Downloads Centre. This only happens on a tagged commit.
    • MacOS build variant creates a github release. This only happens on a tagged commit.
    • The five build variants run in parallel.
  • npm run evergreen-release publish
    • All the previous build steps succeeded.
    • A separate MacOS build variant (darwin_publish_release) uploads config file with information about the new version for each platform to Downloads Centre. This only happens on a tagged commit.
    • A separate MacOS build variant (darwin_publish_release) promotes the draft github release to public. This only happens on a tagged commit.

build flow

Usage

const release = require('@mongosh/build');

const config = {
  version: '0.0.1',
  bundleId: 'bundleId',
  input: 'input',
  execInput: 'execInput',
  outputDir: 'outputDir',
  analyticsConfig: 'analyticsConfig',
  project: 'project',
  revision: 'revision',
  branch: 'branch',
  evgAwsKey: 'evgAwsKey',
  evgAwsSecret: 'evgAwsSecret',
  downloadCenterAwsKey: 'downloadCenterAwsKey',
  downloadCenterAwsSecret: 'downloadCenterAwsSecret',
  githubToken: 'githubToken',
  segmentKey: 'segmentKey',
  appleUser: 'appleUser',
  applePassword: 'applePassword',
  appleAppIdentity: 'appleAppIdentity',
  isCi: true,
  platform: 'platform',
  buildVariant: 'linux',
  repo: {
    owner: 'owner',
    repo: 'repo',
  },
  dryRun: false
}

const command = 'package'; // or 'publish'

const runRelease = async() => {
  await release(command, config);
};

runRelease().then(() => {
  process.exit(0);
});

API

await release(command, config)

Run a complete release of mongosh. This will bundle, create the binary and package a tarball for the current build variant. Running a release requires a config object which is usually obtained from evergreen. For current config, see [build.conf.js][build-url]

config: config object necessary for release.

const release = require('@mongosh/build');
const configObject = {};
await release(command, config);

If config.dryRun is set, this will only package a tarball and skip all later steps.

await compileExec()

Create a compiled down binary. Binary is created for the provided platform (e.g. windows will build mongosh.exe). Before we compile the binary, we bundle execInput into a single .js file.

input: path to build input. execInput: path to compiled executive input. outputDir: path to where the compiled binary will live. platform: platform to run compileExec on. linux, darwin, and win32 are accepted options. analyticsConfig: path to analytics config for telemetry. segmentKey: segment api key for telemetry.

const compileexec = require('@mongosh/build').compileexec;

const config = {
  input: 'path/to/input',
  execInput: 'path/to/exec/input',
  outputDir: 'path/to/output/directory',
  analyticsConfig: 'path/to/analytics/config',
  segmentKey: 'SEGMENT_API_KEY_23481k',
}
await compileExec(
  config.input,
  config.execInput,
  config.outputDir,
  os.platform(),
  config.analyticsConfig,
  config.segmentKey
);

createDownloadCenterConfig()

Output Download Centre config json given a particular version. This json is sent over to Mongodb Downloads Centre to notify of updated package versions.

version: version of the current package to update.

const createDownloadCenterConfig = require('@mongosh/build').createDownloadCenterConfig;

const downloadCentreConfig = createDownloadCenterConfig('1.3.2')

await createTarball(input, outputDir, buildVariant, version, rootDir)

Creates a tarball for a given binary and build variant. Different build variants will create different tarballs - .tgz, .zip, or .deb.

input: path to binary file. outputDir: path to where the compiled tarball will live. buildVariant: build variant to create a tarball for. macos, ubuntu, windows_ps , or debian` are currently available. version: version for the tarball. rootDir: path to root project directory.

const tarball = require('@mongosh/build').tarball;

const executable = 'path/to/executable'
const config = {
  outputDir: 'path/to/output/directory',
  buildVariant: 'windows_ps',
  version: '0.2.0',
  rootDir: 'path/to/root/directory',
}

const artifact = await createTarball(
  executable,
  config.outputDir,
  config.buildVariant,
  config.version,
  config.rootDir
);

Installation

npm install --save @mongosh/build