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

nav-new-publication-cli

v0.5.4

Published

Add new publication to the navigator web project

Downloads

82

Readme

nav-new-publication-cli

This CLI tool is designed to automate the process of adding new publications to the Navigator web project. It collects user input, validates it, and updates or creates the necessary configuration files in the web repository.

Features

  • Interactive Prompts: Collects details such as platform, publication title, domain, AWS certificate ARNs, and autoscaling configurations.
  • Validation: Ensures input is valid and publication names are unique.
  • File Updates: Automatically updates or creates files like drone/publication.json, storybook/preview.js, and infrastructure configurations.
  • Template-Based File Creation: Uses a predefined template to generate infrastructure configuration files.
  • Error Handling: Logs errors and provides feedback during the process.

Installation

  1. Clone the repository:

    git clone [email protected]:trinitymirror-ondemand/nav-new-publication-cli.git
    cd nav-new-publication-cli
  2. Install dependencies:

    yarn install
  3. Build the project:

    yarn build
  4. Link the CLI globally (optional):

    yarn link

Usage

Run the CLI using the following command:

node dist/index.js

Alternatively, if linked globally:

create-nav-publication

Options

  • -p, --platform <type>: Specify the platform (e.g., nationals, regionals).
  • -t, --title <type>: Set the publication title.
  • -c, --cue-name <type>: Specify the name in the cue.
  • --vr, --vr-steps <type>: Number of VR steps.
  • -f, --func-steps <type>: Number of functional steps.
  • -d, --domain <type>: Domain of the site.
  • --db, --debug: Output extra debugging information.

Example

create-nav-publication -p nationals -t "New Publication" -d "newpublication.co.uk"

File Updates

The CLI updates or creates the following files in the web repository:

  1. drone/publication.json:

    • Purpose: Stores the list of publications categorized by platform.
    • Update Logic: Finds the appropriate platform array (e.g., "nationals": [) and appends the new publication as a JSON object.
    • Insertion Point: The insertion point is determined by locating the platform key in the JSON structure.
  2. storybook/preview.js:

    • Purpose: Manages CSS imports and configurations for Storybook.
    • Update Logic: Adds new import statements for the publication's CSS and updates the cssList and cssVariables.files sections.
    • Insertion Point: The last import statement or specific sections like cssList and cssVariables.files.
  3. Infrastructure Configurations:

    • Purpose: Defines infrastructure settings for the publication.
    • Creation Logic: Uses the template/infrastucture.txt file to generate a new configuration file in infrastructure/configs/publications/.
    • Template Replacement: Replaces placeholders in the template with publication-specific details.
  4. localProxy.config.js:

    • Purpose: Configures local proxy settings for the publication.
    • Update Logic: Adds a new entry to the domainName object.
    • Insertion Point: The closing brace of the domainName object.
  5. web-fargate.ts:

    • Purpose: Configures AWS Fargate settings for the publication.
    • Update Logic: Adds a new entry for the publication's Fargate configuration.
    • Insertion Point: Determined by scanning for the appropriate section in the file.
  6. Constants Files:

    • Purpose: Stores constants related to the publication.
    • Update Logic: Adds new constants for the publication.
    • Insertion Point: The end of the constants section.
  7. utils.ts:

    • Purpose: Provides utility functions for logging, error handling, and other common tasks.
    • Update Logic: Adds new utility functions as required by the CLI.
    • Insertion Point: Functions are added at the end of the file or grouped logically with similar utilities.
  8. constants.ts:

    • Purpose: Stores reusable constants used across the CLI.
    • Update Logic: Adds new constants for publications or other configurations as needed.
    • Insertion Point: The end of the constants section or a specific category of constants.
  9. tsconfig.json:

    • Purpose: Configures TypeScript compilation settings for the project.
    • Update Logic: Rarely updated, but may include new paths or compiler options if additional files or features are added.
    • Insertion Point: Determined by the structure of the JSON file.
  10. infrastucture.txt:

    • Purpose: Serves as a template for generating infrastructure configuration files.
    • Update Logic: Updated when new placeholders or configurations are required for infrastructure files.
    • Insertion Point: Placeholders are replaced dynamically during file generation.

Development

Project Structure

  • src/: Contains the source code.
    • index.ts: Entry point of the CLI. Handles command-line arguments, initializes prompts, and orchestrates the overall workflow.
    • fileUpdates.ts: Contains logic for updating or creating files. Defines functions to locate insertion points and generate new content.
    • prompts.ts: Manages interactive prompts. Defines the structure and validation of user inputs.
    • readWritePublications.ts: Handles reading and writing of the publication.json file. Ensures data integrity during updates.
    • checkers.ts: Provides validation functions for user inputs, such as checking for valid ARNs, domains, and publication names.
    • utils.ts: Utility functions for logging errors, warnings, and success messages.
  • template/: Contains the template for infrastructure configuration files.
  • drone/: Stores the publication.json file.

Scripts

  • yarn build: Compiles the TypeScript code to JavaScript.
  • yarn build:watch: Watches for changes and rebuilds the project.
  • yarn start: Runs the CLI.

How Insertion Points Are Decided

  • JSON Files: The insertion point is determined by parsing the JSON structure and locating the appropriate key or array.
  • JavaScript Files: The insertion point is identified by scanning for specific patterns, such as the last import statement or a specific object key.
  • Template Files: Placeholders in the template are replaced with publication-specific details, and the file is saved in the appropriate directory.