Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More β†’
Socket
Sign inDemoInstall
Socket

@backpackjs/cli

Package Overview
Dependencies
Maintainers
11
Versions
325
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@backpackjs/cli

Backpack CLI is a NodeJs command line interface responsible for initializing a backpack storefront.

  • 1.6.5
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
11
Created
Source

Backpackjs CLI

Backpack CLI is a NodeJs command line interface responsible for initializing a backpack storefront.

Commands

  • backpack build: initializes a storefront build
  • backpack dev: initializes storefront in local development mode on port 8080. http://localhost:8080

Overview

backpack dev|build are executed every time that an npm script such as yarn build or yarn dev is run. At its core, the backpack cli command is responsible for orchestrating all storefront's init lifecycle modules.

Storefront Init Lifecycle

The storefront initialization lifecycle is comprised of the following steps:

  1. 🌎 Getting or setting the CMS environment branch that will act as content source for the build (CMS_ENV).
  2. πŸ›« Validating all required storefront env vars are present.
  3. πŸ”„ Synchronizing Shopify products and collections.
  4. 🚸 Creating redirects.
  5. πŸ”Ž Creating fuse search indexes for all articles, blogs, pages, products and collections.
  6. πŸ› Creating an xml products feed.
  7. πŸ•Έ Creating the sitemap.
  8. πŸ—Ώ Generating metas, styles, fonts and scripts <head/> tags.
  9. πŸŽ’ Initializing nextjs with backpack's custom nextjs plugin.
  10. πŸŽ’ Passing the active CMS env branch CMS_ENV into nextjs. i.e Executing nextjs as:
    • CMS_ENV=main next dev - When executing yarn dev within git's main branch
    • CMS_ENV=staging next build - When executing yarn build within git's staging branch
    • CMS_ENV=my-feature next dev - When executing yarn dev within git's my-feature branch
    • or any other combination...

Storefront init config

Each storefront's init sequence can be customized by adding a backpack.init.js config file at the root of the project. If no config is provided, the storefront will fallback to its default init configuration file.

Here is a list of all available settings:

backpack.init.js (default)

export const config = {
  verbose: false,

  dev: {
    port: 8080,
  },

  cms: {
    enabled: true,
    create: true,
    delete: true,
    forceEnv: false,
    maxBranches: 7,
    customizeToolbar: true,
    branchSwitching: true,
    publishing: true,
    drafting: true,
    verbose: false,
  },

  preflight: {
    enabled: true,
    validateEnVars: true,
    verbose: false,
  },

  sync: {
    enabled: true,
    resolveFirst: 12, // Todo: Doc internal - 0 resolves all products with "Product Item" versions
    verbose: false,
  },

  redirects: {
    enabled: true,
    verbose: false,
  },

  search: {
    enabled: true,
    indexes: ['pages', 'blogs', 'articles', 'products', 'collections'],
    verbose: false,
  },

  feed: {
    enabled: true,
    verbose: false,
  },

  sitemap: {
    enabled: true,
    verbose: false,
  },

  head: {
    enabled: true,
    verbose: false,
  },

  next: {
    enabled: true,
    customEnvVars: null,
    verbose: false,
  },
};


πŸ§‘πŸ½β€πŸ’» Cli options

| default | options | description :--- | --- | --- | --- | verbose | true | true or false | enable/disable additional backpack cli logging information



πŸ§‘πŸ½β€πŸ’» Dev options

devdefaultoptionsdescription
port8080a valid portThe port backpack dev should run on.


🌎 CMS env options

cmsdefaultoptionsdescription
enabledtruetrue or falseenable or disable cms environment detection (CMS_ENV)
forcefalsefalse or "branch-name"bypass the automatic CMS_ENV detection by forcing a valid CMS content branch as default. i.e: "staging"
createtruetrue or falseenable content branches creation
deletetruetrue or falseenable content branches deletion
maxBranches71-7Limit the number of cms environments a given project can have
customizeToolbartruetrue or falseenable the toolbar that shows the branch being previewed and to easily access customize mode from development mode
branchSwitchingtruetrue or falseenable the branches switching selector inside the customizer. Other conditions may also determine wether branch switching is allowed.
publishingtruetrue or falseglobally enable or disable content publishing inside the customizer. Other conditions may also determine wether publishing is allowed or not.
draftingtruetrue or falseglobally enable or disable draft content saving inside the customizer. Other conditions may also determine wether publishing is allowed or not.
verbosefalsetrue or falseenable additional console logs for debugging cms-env

Verbose enabled example

cms
CMS init with default values on a "config-docs" branch

cms verbose
CMS init with verbose enabled on a "config-docs" branch



πŸ›« Pre-flight options

preflightdefaultoptionsdescription
enabledtruetrue or falseenable or disable the pre-flight module
validateEnVarstruetrue or falseenable required environment variables validation
verbosefalsetrue or falselog all available environment variables


πŸ”„ Sync options (initialization)

syncdefaultoptionsdescription
enabledtruetrue or falseenable the synchronization module
resolveFirst120n
verbosefalsetrue or falseenable additional console logs for debugging sync

For additional runtime sync options see @backpackjs/sync configuration backpack.sync.default.js



🚸 Redirects options (initialization)

redirectsdefaultoptionsdescription
enabledtruetrue or falseenable the redirects creation module
verbosefalsetrue or falseenable additional console logs for debugging redirects

Redirects can be create via the backpack admin

For additional information on redirects see @backpackjs/build-scripts



πŸ”Ž Search options (initialization)

redirectsdefaultoptionsdescription
enabledtruetrue or falseenable search indexes creation module
indexes['pages', 'blogs', 'articles', 'products', 'collections'][...'endpoint']List of endpoints you want a fuse search index created for at build time. Indexes are available as json endpoints at i.e /json/articles-index.json & /json/articles-list.json
verbosefalsetrue or falseenable additional console logs for debugging search indexes

For additional information on search indexes see @backpackjs/build-scripts



πŸ› Products Feed options (initialization)

redirectsdefaultoptionsdescription
enabledtruetrue or falseenable the products feed creation module
verbosefalsetrue or falseenable additional console logs for debugging the products feed

For additional runtime product feeds options see @backpackjs/products-feed configuration file backpack.feed.js



πŸ•Έ Sitemap options (initialization)

redirectsdefaultoptionsdescription
enabledtruetrue or falseenable the sitemap module
verbosefalsetrue or falseenable additional console logs for debugging the sitemap

For additional runtime sitemap options see @backpackjs/sitemap configuration file backpack.sitemap.js



πŸ—Ώ Head options (initialization)

headdefaultoptionsdescription
enabledtruetrue or falseenable the head generation module
verbosefalsetrue or falseenable additional console logs for debugging head

For additional runtime head options see @backpackjs/head configuration file backpack.head.js



πŸŽ’ Next options (initialization) [todo]

nextdefaultoptionsdescription
enabledtruetrue or falseenable nextjs initialization
customEnvVarsnullnull or
{ ANALYZE: true, ...}
provide custom env vars to nextjs
verbosefalsetrue or falseenable additional console logs for debugging next

For additional runtime backpack nextjs options see @backpackjs/nextjs-backpack configuration backpack.next.js

FAQs

Package last updated on 27 Jun 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚑️ by Socket Inc