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

@senchou/cli

v1.1.5

Published

Generate TypeScript for Kubernetes resources.

Downloads

4

Readme

@senchou/cli

Generate TypeScript for Kubernetes resources.

Installation

# Using npm.
npm install --global @senchou/cli

# Using yarn.
yarn add --global @senchou/cli

# Or run directly with npx.
npx @senchou/cli

Usage

# Print the help message.
senchou --help
DESCRIPTION

    Manage Kubernetes manifests with TypeScript.

USAGE

    $ senchou <command> [options]

COMMANDS

    k8s                       Import types for a Kubernetes release
    crd                       Import types for a CustomResourceDefinition

OPTIONS

    --help, -h                Show this help message
    --verbose, -v             Set logging verbosity

EXAMPLE

    $ # Get help for commands.
    $ senchou k8s --help
    $ senchou crd --help

    $ # Run Senchou with verbose logging.
    $ senchou -v
    $ senchou -vv
    $ senchou -vvv

    $ # Run Senchou with no logging.
    $ LOG_LEVEL=SILENT senchou

    $ # Run Senchou with timestamps.
    $ LOG_TIMESTAMP=TRUE senchou

    $ # Filter logs from Senchou (based on log prefix).
    $ DEBUG="^some-regex$" senchou

Before You Start

Senchou makes use of a few other projects to implement its functionality. Here are the libraries that Senchou makes use of under the hood.

Of particular note is @littlethings/log which can be configured with environment variables like DEBUG to modify how Senchou logs things.

Generate Kubernetes Types

Senchou can generate types for a given Kubernetes release.

# For help with the `k8s` command.
senchou k8s --help
DESCRIPTION

    Import types for a Kubernetes release.

USAGE

    $ senchou k8s [version]

OPTIONS

    --help, -h                Show this help message
    --output, -o              Set the output directory (default: ./senchou)
    --force, -f               Remove any conflicting files before writing

EXAMPLE

    $ # Import the default Kubernetes release's types.
    $ senchou k8s

    $ # Import a specific Kubernetes release's types.
    $ senchou k8s 1.20.0

    $ # Import to a custom directory.
    $ senchou k8s --output ./my-code

    $ # Overwrite an existing "k8s.ts" file.
    $ senchou k8s --force

Generate CustomResourceDefinition Types

Senchou can generate types for CRDs from supported sources.

# For help with the `crd` command.
senchou crd --help
DESCRIPTION

    Import types for a CustomResourceDefinition.

USAGE

    $ senchou crd <protocol>:<specifier>

OPTIONS

    --help, -h                Show this help message
    --output, -o              Set the output directory (default: ./senchou)
    --force, -f               Remove any conflicting files before writing
    --name, -n                Set the name of the output file (appended with ".ts")

PROTOCOLS

    github

        CRDs can be imported from GitHub using the "github"
        protocol. To fetch from GitHub, you must supply an
        owner and repository name like the following.

        $ # github:owner/repo
        $ senchou crd github:traefik/traefik-helm-chart

        Tags can also be used to fetch CRDs from a specific
        release.

        $ # github:owner/repo@tag
        $ senchou crd github:traefik/[email protected]

EXAMPLE

    $ # Import types for Traefik from GitHub.
    $ senchou crd github:traefik/traefik-helm-chart

    $ # Import a specific version's types.
    $ senchou crd github:traefik/[email protected]

    $ # Import to a custom directory.
    $ senchou crd github:traefik/traefik-helm-chart --output ./my-code

    $ # Name the output file.
    $ senchou crd github:traefik/traefik-helm-chart --name traefik

    $ # Overwrite an existing file.
    $ senchou crd github:traefik/traefik-helm-chart --force

Examples

Kubernetes

In this example, we will generate types for a Kubernetes release and use them to create a new Deployment.

First, let Senchou generate types for the release.

senchou k8s

Then, we can create a TypeScript file.

// my-deployment.ts
import { Deployment } from "./senchou/k8s";

const deployment = Deployment({
	metadata: {
		name: "my-deployment",
	},
	spec: {
		template: {
			spec: {
				containers: [
					{
						name: "my-container",
						image: "myimage",
					},
				],
			},
		},
	},
});

Tada! Kubernetes manifests can now be created with full TypeScript support.

CustomResourceDefinitions

In this example, we will generate types for CRDs from GitHub. Specifically, we will be loading the types for Traefik and creating an IngressRoute resource.

First, let Senchou generate types for the CRDs.

senchou crd github:traefik/traefik-helm-chart --name traefik

Then, we can create a TypeScript file.

// my-ingress-route.ts
import {
	IngressRoute,
	IngressRoutePropsSpecRoutesKind,
	IngressRoutePropsSpecRoutesServicesKind,
} from "./senchou/traefik";

const route = IngressRoute({
	metadata: {
		name: "my-route",
	},
	spec: {
		routes: [
			{
				kind: IngressRoutePropsSpecRoutesKind.Rule,
				match: "Host(`example.com`)",
				services: [
					{
						name: "my-service",
						kind: IngressRoutePropsSpecRoutesServicesKind.Service,
						port: 80,
					},
				],
			},
		],
	},
});

Tada! CRD manifests can now be created with full TypeScript support.