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

turbo-daemon

v1.1.0

Published

A tool for running turbo locally as a demon that can be integrated with monorepo scripts.

Downloads

15,948

Readme

Turbo Daemon

A tool for running turbo locally as a demon that can be integrated with monorepo scripts.

Features

  • no money paid to Vercel
    (they do good work tho, It's just that I'm cheap)
  • doesn't use pm2 (turbo-daemon is released under the MIT license)
  • wrapper around the highly tried and tested turborepo-remote-cache server
  • idempotent
    (call as many times as you want, only one server will run)
  • automatically shuts down after inactivity
  • CLI available for debugging

Installation

pnpm add turbo-daemon

Or from git: In your package.json:

"devDependencies": {
    "turbo-daemon": "github:NullVoxPopuli/turbo-daemon"
}

To test out a specific branch / tag:

"devDependencies": {
    "turbo-daemon": "github:NullVoxPopuli/turbo-daemon#branch-name"
}

Usage

In your tooling that wraps turbo commands, add a function that determines what the turbo environment variables should be.

For example:

import { execa } from 'execa';
import { createDaemon, TURBO_TOKEN } from 'turbo-daemon';
import ci from 'ci-info';

const daemon = createDaemon();
const TURBO_TEAM = 'team_your_team_name_here';

async function getServer() {
	if (ci.isCI) {
		return {
			TURBO_API: 'https://turborepo.your-domain-here.com',
			TURBO_TEAM,
			TURBO_TOKEN: process.env['TURBO_TOKEN'],
		}
	}

    /**
     * Environment variables from 
     * https://ducktors.github.io/turborepo-remote-cache/environment-variables.html
     *
     * These environment variables are required for the daemon to have 
     * access to remote storage.
     * If these are omitted, turbo will still work, but fallback to local, in-repo cache.
     */
    Object.assign(process.env, {
      TURBO_TEAM,
      /* ... */
    });

	await daemon.ensureStarted();
	return {
		TURBO_API: `http://localhost:${daemon.info.data.port}`,
		TURBO_TEAM,
		TURBO_TOKEN,
	}
}

/**
 * have your package.json scripts call this instead of turbo directly
 */
export async function wrappedTurbo(args) {
	const connectionInfo = await getServer();

	await execa(`pnpm`, [`turbo`, ...args], {
		env: {
			...connectionInfo,
		}
	})
}

Debugging

This project stores files in <git root>/node_modules/.turbo-daemon/

Start

pnpm turbo-daemon start

or when working in this project:

pnpm cli start

Restart

pnpm turbo-daemon restart

or when working in this project:

pnpm cli restart

Stop

pnpm turbo-daemon stop

or when working in this project:

pnpm cli stop

Status

pnpm turbo-daemon status

or when working in this project:

pnpm cli status

Logs

pnpm turbo-daemon logs

or when working in this project:

pnpm logs

Watching for the pid file:

watch -n 2 "cat node_modules/.turbo-daemon/.turbo.pid"

Debugging why the daemon isn't starting from other tools

in this project, run:

node ./src/run-turbo.js

and observe the output, logs, and pidfile.

If that's fine, try the daemonized version:

pnpm cli start

Debugging what is in the turbo daemon folder

ls -la node_modules/.turbo-daemon/**

This may require

shopt -s globstar

and to watch for changes:

watch -n 2 "ls -la node_modules/.turbo-daemon/**"

Clearing local cache to test remote speed

find . -name '.turbo' -type d -prune -exec rm -rf '{}' +

.turbo folders are in each package's node_modules directory.

Debugging S3 Access

Testing access to the cache bucket

To see if your local credentials have access to the s3 bucket, run:

❯ aws s3 ls $NAME_OF_BUCKET
# output doesn't matter
❯ echo $?
0 # this is what you're looking for