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

itg-cli-functions

v0.0.1

Published

A CLI for itg.cognite.ai

Downloads

2

Readme

itg - A CLI for https://itg.cognite.ai

Install

npm install -g @cognite/itg-cli

Commands

# Creates a new project and dumps details in .itgrc
itg init

itg schema view
# Also includes all generated types and queries
itg schema view --full
itg schema view --type=Equipment

# Check if a schema is valid graphql and fits ITG requirements
itg schema validate -f mymodel.graphql

# For CI/CD, add flag to fail when invalid schema detected
itg schema validate --fail-on-invalid -f mymodel.graphql

# Add and replace a schema in itg
itg schema update -f mymodel.graphql

itg nodes add --type Equipment -f equipment.csv
itg nodes add --type Document -f documents.csv

itg relations add Equipment.documents -f relations.csv

# Delete the project, including the .itgrc
itg prune

# Deploying a function requires the dir folder to have a file called handler.js
itg functions deploy \
  --dir      my-function \
  --name     look-at-assets \
  --tenant   cognite

# Create a schedule for a function. The external id is returned from functions deploy
itg functions schedule create \
  --name     night-job \
  --cron     "0 3 * * *" \
  --extid    function-external-id \
  --tenant   cognite

Global variables

Set the COGNITE_CREDENTIALS variable with an api key for the respective cdf project to get access

CI/CD

We expect the main use of the CLI for CI/CD will be validating and updating schemas. The validate step should be added to the create pr workflow, while the update step should be added to the merge to master workflow. Remember to include the --fail-on-invalid flag in the validate command to avoid false positives in the workflow.

Options:
  --api-key                                      [default: $COGNITE_CREDENTIALS]
  --base-url                                 [default: "https://itg.cognite.ai"]

Functions

The function file in the folder needs to be named handler.js, and has the following structure

async function handle({ client, data, secrets }) {
  const assets = await client.assets.list().autoPagingToArray();
  console.log(`Got ${assets.length} assets: `);

  return { status: 'success' };
}

module.exports = handle;

Example:

$ ls
my-function
$ ls my-function
handler.js   package.json