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

@golem-sdk/cli

v2.11.0

Published

CLI for Golem SDK

Downloads

63

Readme

Golem SDK CLI

Golem SDK CLI is a companion tool for the Golem SDK. It accelerates the creation and management of Golem JS projects.

Installing / Getting started

Golem SDK CLI is available as an NPM package.

Install using npm:

npm install -g @golem-sdk/cli

Install using yarn:

yarn global add @golem-sdk/cli

To check if the installation was successful, run:

golem-sdk --version

After installation, the CLI is ready to be used.

Developing

If you want to install from source code or you would like to develop Golem SDK CLI, you can clone the repository and install dependencies:

git clone [email protected]:golemfactory/golem-sdk-cli.git
cd golem-sdk-cli/
npm install

Building

To build the CLI, run:

npm run build

To make the CLI available in your system, run:

npm link

Now, the golem-sdk command should be available in your system.

Features

Golem SDK CLI is a companion tool for the Golem SDK. It is developed in parallel with the SDK, and new features are added as the SDK evolves or new use cases emerge

If you see a feature missing or a possible Golem SDK user experience improvement we could implement, please open an issue or a pull request.

Create a new Golem Application

The fastest way to get started with Golem Network is to use golem-sdk new to create a new application from a template.

golem-sdk new

You will be asked a series of questions about your application and the CLI will use your answers to generate a new Golem Application.

The first question will be the project name. The CLI will use it to create a new directory for your application in the current directory. You can use the --path option to override this behaviour.

Note: The command will abort if the directory already exists.

You can provide all the needed information from command line too. Type golem-sdk new --help to see the list of available options.

Golem Manifest

Golem Manifest is a JSON document that describes your Golem application. While it is not necessary for simple applications, you will need it if you want to access advanced features of the Golem SDK, like access to the Internet (outbound).

The golem-sdk CLI allows users to create and update the manifest file. By default, it assumes the manifest is available in a manifest.json file in the current folder. If you want to point to a different file, use the --manifest (or -m) option.

Creating a Golem Manifest

To create a new Golem Manifest with the golem-sdk CLI, run:

golem-sdk manifest create <image> [--image-hash hash]

The image argument should identify the GVMI image used by your application. The tools accept a few formats which are explained in the table below. You can learn more about Golem images here.

If you have a package.json file in your project, the tool will use the name, version, and description fields from the file to fill in the fields in the manifest. Otherwise, you will need to provide them manually.

Image

The manifest needs to contain the image URL pointing to the GVMI download location and its hash to validate its integrity. To facilitate the process of creating a manifest, golem-sdk accepts multiple forms of image argument, where some of them will automatically resolve the URL and/or hash. Please consult the table below for more details:

| Argument format | Example | Is --image-hash required? | Notes | | ---------------------------------- | --------------------------------------------------------------------------------------------- | ------------------------------------------- | ------------------------------------------------------------------------------------------ | | Image tag | golem/node:latest | No, it will be automatically resolved. | Image hash is fetched from [https://registry.golem.network]. It is the recommended method. | | Image hash | 3d6c48bb4c192708168d53cee4f36876b263b7745c3a3c239c6749cd | No, it is resolved from the image argument. | Image URL will point to [https://registry.golem.network] | | URL to registry.golem.network | https://registry.golem.network/v1/image/download?tag=golem-examples/blender:2.80&https=true | No, it is automatically resolved. | | | URL to arbitrary download location | https://example.com/my-image | Yes, image-hash is required. | Image is calculated by the gvmkit-build conversion tool. |

If the hash is not provided or resolved, you will get a warning that the manifest will not be usable until you provide it manually.

Adding outbound URLs

For your application to access the Internet from the Golem network, the manifest must include the outbound URLs the application will be using.

The default set of URLs that providers may allow your application to use is available (here). Note providers can modify the content of the list.

Example: Simple use

This command will update the manifest file with the provided URL:

golem-sdk manifest net add-outbound https://golem.network

You can use this command multiple times to add additional URLs to the manifest or pass many URLs in a single run:

Example: Multiple URLs

This command will update the manifest file with all the URLs provided.

golem-sdk manifest net add-outbound https://golem.network https://github.com https://example.com

Signing the manifest

If the provider has set up an audited-payload rule for URLs not on the whitelist, you can gain access to these URLs. However, they must be declared in the manifest, and the manifest is signed by the key linked with the certificate accepted by the provider.

To sign the manifest, run:

golem-sdk manifest sign -k <private-key>

If your private key is encrypted, you will need to provide the correct passphrase (-p or --passphrase option). This command will produce a signature file (by default manifest.sig) that you will need to use in your application.

Verifying the signature

You can verify the manifest signature with your certificate using the following command:

golem-sdk manifest verify

By default, it will use manifest.pem as the certificate file and manifest.sig as the signature file. You can change that by using the --certificate-file and --signature-file options.

On success, it will print the following message:

Manifest matches signature.

It is important to use this command to make sure the key you are using is compatible with your certificate.

Run-on-golem

The run-on-golem command allows you to run an image on the Golem Network without the need to create a full Golem application. Now you can test, debug and validate images without having to writing a single line of code.

By default, run-on-golem will try to use your manifest file from the current directory. You can override this behaviour by using the --manifest option or by providing the --image option.

Example:

golem-sdk run-on-golem --image=golem/node:20-alpine

Once you run the command, the CLI will deploy the image to one of the providers and you will be presented with an interactive shell. You can type ? in order to get a list of all available commands.

Within the shell, you can quickly test your application by running commands on the image, as well as uploading and downloading files.

You can run commands without an interactive shell ether by passing the commands you want to run using the --execute option or using a batch file:

Examples:

golem-sdk run-on-golem --execute "upload localfile.txt /golem/input; run 'ls /golem/input'"
golem-sdk run-on-golem batchfile.txt

Contributing

If you'd like to contribute to the project, you can fork the repository and create a Pull Request. Code contributions are warmly welcomed.

Please make sure the code follows the coding style as configured in .eslintrc and .prettierrc.

The Pull Request should describe what changes you've made, what's the purpose of them and how to use them.

Links

  • Project homepage: https://github.com/golemfactory/golem-sdk-cli
  • Repository: https://github.com/golemfactory/golem-sdk-cli
  • Issue tracker: https://github.com/golemfactory/golem-sdk-cli/issues
    • In case of sensitive bugs like security vulnerabilities, please contact us directly through our contact form instead of using the issue tracker. We value your effort to improve the security and privacy of this project!
  • Golem, a global, open-source, decentralized supercomputer that anyone can access.
  • Golem Image Registry
  • Golem Discord
  • Documentation:
  • Related projects:
    • Golem SDK - Typescript + NodeJS API for Golem.
    • Yagna - An open platform and marketplace for distributed computations.
    • yapapi - Python high-level API for Golem.

Licensing

The code in this project is licensed under the GPL-3 license.

See LICENSE for more information.