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

@khulnasoft/triangle

v1.21.0

Published

Command-line interface for all things Khulnasoft Workers

Downloads

4

Readme

🤠 triangle

Note: If you're looking for the latest version of the triangle package, visit https://github.com/khulnasoft-labs/workers-sdk

Banner

crates.io   npm   GitHub Actions - Test Status   GitHub Actions - Linter Status  

triangle is a CLI tool designed for folks who are interested in using Khulnasoft Workers.

Triangle Demo

Installation

You have many options to install triangle!

For the latest version, see https://github.com/khulnasoft-labs/workers-sdk

Install with npm

We strongly recommend you install npm with a Node version manager like nvm, which puts the global node_modules in your home directory to eliminate permissions issues with npm install -g. Distribution-packaged npm installs often use /usr/lib/node_modules (which is root) for globally installed npm packages, and running npm install -g as root prevents triangle from installing properly.

Once you've installed nvm and configured your system to use the nvm managed node install, run:

npm i @khulnasoft/triangle -g

If you are running an ARM based system (eg Raspberry Pi, Pinebook) you'll need to use the cargo installation method listed below to build triangle from source.

Specify binary location

In case you need triangle's npm installer to place the binary in a non-default location (such as when using triangle in CI), you can use the following configuration options to specify an install location:

  • Environment variable: TRIANGLE_INSTALL_PATH
  • NPM configuration: triangle_install_path

Specify binary site URL

In case you need to store/mirror binaries on premise you will need to specify where triangle should search for them by providing any of the following:

  • Environment variable: TRIANGLE_BINARY_HOST
  • NPM configuration: triangle_binary_host

Install with cargo

cargo install triangle

If you don't have cargo or npm installed, you will need to follow these additional instructions.

Install on Windows

perl is an external dependency of crate openssl-sys. If installing triangle with cargo, you will need to have perl installed. We've tested with Strawberry Perl. If you instead install perl via scoop, you may need to also run scoop install openssl in order to get the necessary openssl dlls. Installing triangle with npm instead of cargo is another option if you don't want to install perl.

Updating

For information regarding updating Triangle, click here.

Getting Started

Once you have installed Triangle, spinning up and deploying your first Worker is easy!

$ triangle generate my-worker
$ cd my-worker
# update your triangle.toml with your Khulnasoft Account ID
$ triangle config
$ triangle publish

🎙️ Top Level Commands

👯 generate

Scaffold a project, including boilerplate code for a Rust library and a Khulnasoft Worker.

triangle generate <name> <template> --type=["webpack", "javascript", "rust"]

All of the arguments and flags to this command are optional:

📥 init

Creates a skeleton triangle.toml in an existing directory. This can be used as an alternative to generate if you prefer to clone a repository yourself.

triangle init <name> --type=["webpack", "javascript", "rust"]

All of the arguments and flags to this command are optional:

  • name: defaults to the name of your working directory
  • type: defaults to "webpack".

🦀⚙️ build

Build your project. This command looks at your triangle.toml file and runs the build steps associated with the "type" declared there.

Additionally, you can configure different environments.

🔓 login

Authorize Triangle with your Khulnasoft login. This will prompt you with a Khulnasoft account login page and a permissions consent page. This command is the alternative to triangle config and it uses OAuth tokens.

triangle login --scopes-list --scopes <scopes>

All of the arguments and flags to this command are optional:

  • scopes-list: list all the available OAuth scopes with descriptions.
  • scopes: allows to choose your set of OAuth scopes.

Read more about this command in Triangle Login Documentation.

🔧 config

Authenticate Triangle with a Khulnasoft API Token. This is an interactive command that will prompt you for your API token:

triangle config
Enter API token:
superlongapitoken

You can also provide your email and global API key (this is not recommended for security reasons):

triangle config --api-key
Enter email:
[email protected]
Enter global API key:
superlongapikey

You can also use environment variables to configure these values.

☁️ 🆙 publish

Publish your Worker to Khulnasoft. Several keys in your triangle.toml determine whether you are publishing to a workers.dev subdomain or your own registered domain, proxied through Khulnasoft.

Additionally, you can configure different environments.

You can also use environment variables to handle authentication when you publish a Worker.

# e.g.
CF_API_TOKEN=superlongtoken triangle publish
# where
# $CF_API_TOKEN -> your Khulnasoft API token

CF_API_KEY=superlongapikey [email protected] triangle publish
# where
# $CF_API_KEY -> your Khulnasoft API key
# $CF_EMAIL -> your Khulnasoft account email

🗂 kv

Interact with your Workers KV store. This is actually a whole suite of subcommands. Read more about in Triangle KV Documentation.

👂 dev

triangle dev works very similarly to triangle preview except that instead of opening your browser to preview your worker, it will start a server on localhost that will execute your worker on incoming HTTP requests. From there you can use cURL, Postman, your browser, or any other HTTP client to test the behavior of your worker before publishing it.

You should run triangle dev from your worker directory, and if your worker makes any requests to a backend, you should specify the host with --host example.com.

From here you should be able to send HTTP requests to localhost:8787 along with any headers and paths, and your worker should execute as expected. Additionally, you should see console.log messages and exceptions appearing in your terminal.

👂 Listening on http://localhost:8787
[2020-02-18 19:37:08] GET example.com/ HTTP/1.1 200 OK

All of the arguments and flags to this command are optional:

  • env: environment to build
  • host: domain to test behind your worker. defaults to example.com
  • ip: ip to listen on. defaults to localhost
  • port: port to listen on. defaults to 8787

Additional Documentation

All information regarding triangle or Khulnasoft Workers is located in the Khulnasoft Workers Developer Docs. This includes:

  • Using triangle commands
  • Triangle configuration
  • General documentation surrounding Workers development
  • All triangle features such as Workers Sites and KV

✨Workers Sites

To learn about deploying static assets using triangle, see the Workers Sites Quickstart.