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

castleblock

v2.6.1

Published

CLI Program for the CastleBlock service.

Downloads

5

Readme

castleblock

The castleblock-cli interfaces with the castleblock-service API and deploys apps via a command line interface.

CLI Usage

$ castleblock
Usage:
  castleblock [OPTIONS] <command> [ARGS]

Options:
  -d, --dist [FILE]      Directory containing the built assets (Default is ./build)
  -u, --url [STRING]     URL to castleblock service (Default is http://localhost:3000)
  -e, --env FILE         Include env file in deployment (accessible from
                         ./env.json when deployed)
  -b, --build [STRING]   Build command that is run before deployment (Default is npm run build)
  -s, --src [FILE]       Source directory to watch for changes (Default is ./src)
  -f, --file FILE        Deploy an existing package
  -p, --pack BOOL        Save deployment package to disk
  -t, --token STRING     Authorization Token
  -j, --jwtSecret STRING JWT Secret Key for generating a token on the fly
  -r, --remote STRING    Deploy a remote git repo or tarball
  -h, --help             Display help and usage details

Commands:
  deploy, list, login, remove, version, watch

Manifest.json

Castleblock relies on your app's manifest.json file to deploy your app.

  • short_name - (required) Used in the url <castleblock-service-url>/ui/<short_name>/<version>/
  • version - (required) Used in the url <castleblock-service-url>/ui/<short_name>/<version>/. The version must follow the semver standard
  • name - Used in castleblock-ui app cards
  • description - Used in castleblock-ui
  • webcomponent - Set to "true" if the deployment is a web component
  • icons

Example:

{
  "short_name": "my-app",
  "version": "1.2.5",
  "name": "My Application",
  "description": "A description of the application.",
  "webcomponent": false,
  "icons": [{ "src": "./my-app-icon.png" }]
}

Deploying an app

First make sure you have the service running. In this example the service is running at http://localhost:3000

$ castleblock deploy -d ./dist
INFO: Building Project: npm run build
INFO: Compressing public/ into deployment.tar.gz
INFO: Uploading deployment.tar.gz
INFO: SHA512:
      4585948608622f9399389f651b5f14b1c286a3418fb6da0f24b2137ebb81092bd4542b9e959ee8f9ba3b4532ee11dd569b721bfdb269f3f70bfe82efe9e540f5
INFO: URL: http://localhost:3000/ui/my-app/1.2.3

Removing an app

$ castleblock remove http://localhost:3000/ui/my-app/1.2.3/

Ad hoc Deployments

The watch command allows you to deploy an adhoc version of your application to a randomly generated URL. Castleblock will watch your files for changes, rebuild, and deploy anytime you make a change. This allows you to share or demo a feature currently in development and test it directly against your microservices in your deployment environment..

$ castleblock watch -d public/
{
  dist: 'public/',
  url: 'http://localhost:3000',
  env: null,
  build: 'npm run build',
  src: './src',
  file: null,
  pack: false,
  token: null,
  jwtSecret: null
}
INFO: Watching For Changes
      Source Directory: "./src"
      Build Command: "npm run build"
INFO: Compressing public/
INFO: Building Project: npm run build

src/main.js → public/build/bundle.js...
created public/build/bundle.js in 429ms
INFO: SHA512:
      c2e2840f8a1c1b290c240ae5b15037eaf47807830862622a5d8292cc51db1c9ab51d088d33791c2414920b08303af93c81b4158d643377f7156470a21363c3fe
INFO: Uploading Package
INFO: URL: http://localhost:3000/ui/my-app/adhoc-vdzitr33w7g

Environmental Variable Injection

Sometimes your application needs to be configurable after it has already been bundled. CastleBlock provides a mechanism to include an additional json file alongside your bundled application. e the --env option to include configurations at runtime.

castleblock deploy --env mysettings.json

Accessing env.json from your App

Castleblock will inject the env.json file into your deployment, so your application can fetch(./env.json) to load custom configuration values when the application first loads. The file is always env.json, regardless of what the original filename was.

Default CLI Options

Castleblock allows you to save your own default options in a .castleblock.json file either in your home directory (globally) or in your project directory. Any of the CLI options can be set to alternative default values. See below for an example.

{
  "config": {
    "dist":"./public",
    "url":"http://myproductionsite.xyz"
    "env":"productionsettings.json",
    "build":"npm run build -- --prod",
    "src":"./src",
    "pack":true
  }
}