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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@digital-herd/content-hub-cli

v1.1.16

Published

CLI tools for managing Sitecore Content Hub external components and scripts

Downloads

2,202

Readme

ContentHub CLI (content-hub-tools)

ContentHub build & utility CLI used to build, watch and manage external components and scripts.

Quick Reference

| Command | Description | |---------|-------------| | create-component | Create a new React component from template | | create-script | Create a new C# script with API auto-fetch | | create-manual-patch | Create a new manual patch from template | | run-manual-patch | Run a manual patch on ContentHub | | build | Build external components for production | | watch | Watch and serve components with HMR | | publish-script | Publish scripts to ContentHub environment | | sync-scripts | Sync scripts from ContentHub to local |

Jump to:

Install

  • From source (recommended during development):
cd contenthub-cli
npm install
npm run build
# make the CLI available locally
npm link

After installation the binary is content-hub-tools.

Config file

The CLI loads its configuration from contenthubConfig.build.config.ts by default. Example shape:

export default {
  componentDir: "external-components/components",
  scriptDir: "scripts",
  port: 5173,
  mainEnvironment: "local",
  environments: [
    { name: "local", domain: "https://localhost", apiToken: "<token>" },
    { name: "staging", domain: "https://staging.example.com", apiToken: "<token>" }
  ]
};

If your config lives in a different path, set NODE_ENV or adjust imports when invoking programmatically or update the getCliConfig call.

Global options

  • -e, --environment <environment>: select which environment (name) from the config to use. If omitted the mainEnvironment from the config is used.

Commands

All commands are exposed via the content-hub-tools binary. Usage:

content-hub-tools <command> [options]
  • create-component — Create a new external component from template (interactive)

    This command will interactively prompt you to:

    1. Select which section (folder) to create the component in
    2. Enter a component name (must start with uppercase and contain only letters/numbers)

    The command copies the template from contenthub-cli/templates/external-components/ and creates the new component with all template files renamed and updated with your component name.

    Examples:

    • Create a new component (interactive prompts):
      content-hub-tools create-component

    The interactive prompts will guide you through:

    • Section selection: Choose from available sections (e.g., asset, general, workflows/cgi)
    • Component name: Enter a PascalCase name (e.g., ProductCard, MyNewWidget)

    After running, the component will be created at:

    external-components/components/<section>/<ComponentName>/
  • create-script — Create a new script from template (interactive)

    This command will interactively prompt you to provide script details. If you provide an identifier that exists in the environment, it will automatically fetch the default values (title, description, execute as user) from the API.

    Examples:

    • Create a new script (interactive prompts):
      content-hub-tools create-script -e local

    The interactive prompts will guide you through:

    1. Identifier: Script identifier (e.g., M.Script.MyNewScript)
    2. Auto-fetch: If the identifier exists in the environment, defaults will be fetched
    3. Title: Script title (pre-filled if fetched from API)
    4. Description: Script description (pre-filled if fetched from API)
    5. Type: Script type (Action or Trigger)
    6. Execute as user: Whether to execute as user (pre-filled if fetched from API)

    After running, the script will be created at:

    action-scripts/scripts/<ScriptName>/

    Files created:

    • <ScriptName>.config.ts - Script configuration with metadata
    • <ScriptName>.cs - C# script implementation file
  • build — Build External component(s)

    Options:

    • -c, --components <comp>: comma-separated component names to build. If omitted, builds all components.
    • -d, --deprecated: build using tsconfig.deprecated.json (TypeScript strict mode disabled) instead of the default tsconfig.json.
    • -p, --publish: after building, publish the built components to the configured ContentHub environment portal asset.

    Examples:

    • Build all components using default tsconfig:

      content-hub-tools build -e local
    • Build all components using mainEnvironment from config:

      content-hub-tools build
    • Build a single component:

      content-hub-tools build -c "ProductCard" -e local
    • Build multiple specific components:

      content-hub-tools build -c "Button,Card,Header" -e staging
    • Build and publish to production:

      content-hub-tools build -c "Button,Card" -p -e production
    • Build all components and publish:

      content-hub-tools build -p -e staging
    • Build using deprecated TS config (compatibility mode):

      content-hub-tools build -d -e local
    • Build specific components with deprecated config and publish:

      content-hub-tools build -c "LegacyComponent" -d -p -e staging
  • watch — Watch and serve External component(s) with HMR (development)

    Options:

    • -c, --components <comp>: comma-separated list of components to watch. If omitted, watches all components.
    • -d, --deprecated: use tsconfig.deprecated.json (TypeScript strict mode disabled) while watching.

    Examples:

    • Watch all components with HMR:

      content-hub-tools watch -e local
    • Watch all components using mainEnvironment:

      content-hub-tools watch
    • Watch a single component for development:

      content-hub-tools watch -c "ProductCard" -e local
    • Watch multiple specific components:

      content-hub-tools watch -c "Button,Card,Header" -e local
    • Watch with deprecated tsconfig:

      content-hub-tools watch -d -e local
    • Watch specific components with deprecated config:

      content-hub-tools watch -c "LegacyComponent,OldCard" -d -e local
  • publish-script — Publish scripts to environment

    Options:

    • -s, --scripts <script>: comma-separated list of script names to publish (required).

    Examples:

    • Publish a single script:

      content-hub-tools publish-script -s "myScript" -e staging
    • Publish multiple scripts:

      content-hub-tools publish-script -s "myScript,anotherScript" -e staging
    • Publish to production environment:

      content-hub-tools publish-script -s "ProductionScript" -e production
    • Publish scripts using mainEnvironment:

      content-hub-tools publish-script -s "myScript,anotherScript"
  • sync-scripts — Sync scripts from environment to local

    Examples:

    • Sync scripts from staging environment:

      content-hub-tools sync-scripts -e staging
    • Sync scripts from production:

      content-hub-tools sync-scripts -e production
    • Sync using mainEnvironment from config:

      content-hub-tools sync-scripts
    • Sync from local development environment:

      content-hub-tools sync-scripts -e local
  • create-manual-patch — Create a new manual patch from template (interactive)

    This command will interactively prompt you to provide a patch name and create a TypeScript patch file that can be used to run one-off data migrations or fixes.

    Examples:

    • Create a new patch (interactive prompts):
      content-hub-tools create-manual-patch

    The interactive prompts will guide you through:

    • Patch name: Enter a PascalCase name (e.g., FixUserIssue, MigrateData)
    • Only letters are allowed in the name
    • The name will be automatically converted to PascalCase if needed

    After running, the patch will be created at:

    patches/<PatchName>.patch.ts

    The generated patch file will contain:

    • PatchParams interface with ContentHub client
    • runPatch<Name> function ready for implementation
  • run-manual-patch — Run a manual patch on ContentHub (interactive)

    This command will display all available patches sorted by last modified date (newest first) and execute the selected patch.

    Examples:

    • Run a patch (interactive selection):

      content-hub-tools run-manual-patch -e staging
    • Run a patch on production:

      content-hub-tools run-manual-patch -e production

    The interactive prompt will show:

    • List of all available .patch.ts files
    • Last modified timestamp for each patch
    • Patches sorted with newest first

    The patch will be executed with:

    • Access to the ContentHub client via PatchParams
    • Connection to the selected environment

Developer notes

  • The CLI is implemented with commander and TypeScript. Entry point: src/bin.ts.
  • Commands are registered from src/modules/* — see src/modules/external-components and src/modules/scripts.
  • The CLI expects a config matching src/types/ContentHubConfig.interface.ts.
  • The binary target is dist/bin.js as defined in package.json's bin field.

Troubleshooting

  • ❌ environment not specified -e or --environment: either pass -e <name> or set mainEnvironment in the config.
  • ❌ Failed to load config: confirm contenthubConfig.build.config.ts path is correct and exports a default config.

License

UNLICENSED - This is proprietary software developed by Digital Herd.

The compiled package is available for use, but the source code is not open source and may not be redistributed or modified. All rights reserved.