1.6.5 • Published 11 months ago

@backpackjs/cli v1.6.5

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

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

defaultoptionsdescription
verbosetruetrue or falseenable/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

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
resolveFirst120nthe number of json product items that should be pre-loaded on collections. i.e In a collection of 50 products, this would mean that 38 products would have to be lazy loaded. 12 is a good number as that's usually the number of products (max) that would be above the fold on a collection.
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

1.6.5

11 months ago

1.6.4

1 year ago

1.6.3

1 year ago

1.6.2

2 years ago

1.6.0

2 years ago

1.4.1

2 years ago

1.4.0

2 years ago

1.3.0

2 years ago

1.2.5

2 years ago

1.2.4

2 years ago

1.2.3

2 years ago

1.2.2

2 years ago

1.2.1

2 years ago

1.1.19

2 years ago

1.1.18

2 years ago

1.1.17

2 years ago

1.1.22

2 years ago

1.1.20

2 years ago

0.1.102

2 years ago

0.1.101

2 years ago

0.1.100

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.1.9

2 years ago

1.1.8

2 years ago

1.1.7

2 years ago

1.1.6

2 years ago

1.1.5

2 years ago

1.1.4

2 years ago

1.1.3

2 years ago

1.1.2

2 years ago

1.1.12

2 years ago

1.1.11

2 years ago

1.1.10

2 years ago

1.1.16

2 years ago

1.1.15

2 years ago

1.1.14

2 years ago

1.1.13

2 years ago

1.0.2

2 years ago

0.1.96

2 years ago

1.0.1

2 years ago

0.1.97

2 years ago

1.0.0

2 years ago

0.1.98

2 years ago

0.1.99

2 years ago

0.1.90

2 years ago

0.1.91

2 years ago

0.1.92

2 years ago

0.1.93

2 years ago

0.1.94

2 years ago

1.0.3

2 years ago

0.1.95

2 years ago

0.1.85

2 years ago

0.1.86

2 years ago

0.1.87

2 years ago

0.1.88

2 years ago

0.1.89

2 years ago

0.1.81

2 years ago

0.1.82

2 years ago

0.1.83

2 years ago

0.1.84

2 years ago

0.1.75

2 years ago

0.1.77

2 years ago

0.1.78

2 years ago

0.1.79

2 years ago

0.1.70

2 years ago

0.1.71

2 years ago

0.1.72

2 years ago

0.1.73

2 years ago

0.1.69

2 years ago

0.2.0

2 years ago

0.1.52

2 years ago

0.1.53

2 years ago

0.1.54

2 years ago

0.1.55

2 years ago

0.1.56

2 years ago

0.1.57

2 years ago

0.1.58

2 years ago

0.1.59

2 years ago

0.1.50

2 years ago

0.1.51

2 years ago

0.1.49

2 years ago

0.1.43

2 years ago

0.1.44

2 years ago

0.1.45

2 years ago

0.1.46

2 years ago

0.1.47

2 years ago

0.1.48

2 years ago

0.1.63

2 years ago

0.1.64

2 years ago

0.1.65

2 years ago

0.1.66

2 years ago

0.1.67

2 years ago

0.1.68

2 years ago

0.1.60

2 years ago

0.1.62

2 years ago

0.1.41

2 years ago

0.1.42

2 years ago

0.1.40

2 years ago

0.1.38

2 years ago

0.1.39

2 years ago

0.1.30

2 years ago

0.1.31

2 years ago

0.1.32

2 years ago

0.1.33

2 years ago

0.1.34

2 years ago

0.1.35

2 years ago

0.1.36

2 years ago

0.1.37

2 years ago

0.1.27

2 years ago

0.1.28

2 years ago

0.1.29

2 years ago

0.1.20

2 years ago

0.1.21

2 years ago

0.1.22

2 years ago

0.1.23

2 years ago

0.1.24

2 years ago

0.1.25

2 years ago

0.1.26

2 years ago

0.1.17

2 years ago

0.1.18

2 years ago

0.1.19

2 years ago

0.1.16

2 years ago

0.1.10

2 years ago

0.1.11

2 years ago

0.1.12

2 years ago

0.1.13

2 years ago

0.1.14

2 years ago

0.1.15

2 years ago

0.1.8

2 years ago

0.1.9

2 years ago

0.1.7

3 years ago

0.1.6

3 years ago

0.1.5

3 years ago

0.1.4

3 years ago

0.0.225

3 years ago

0.0.224

3 years ago

0.0.223

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.1.3

3 years ago

0.0.221

3 years ago

0.0.220

3 years ago

0.0.219

3 years ago

0.0.218

3 years ago

0.0.216

3 years ago

0.0.217

3 years ago

0.0.215

3 years ago

0.0.214

3 years ago

0.0.213

3 years ago

0.0.212

3 years ago

0.0.211

3 years ago

0.0.210

3 years ago

0.0.209

3 years ago

0.0.208

3 years ago

0.0.207

3 years ago

0.0.206

3 years ago

0.0.205

3 years ago

0.0.204

3 years ago

0.0.203

3 years ago

0.0.202

3 years ago

0.0.201

3 years ago

0.0.200

3 years ago

0.0.199

3 years ago

0.0.198

3 years ago

0.0.197

3 years ago

0.0.196

3 years ago

0.0.195

3 years ago

0.0.194

3 years ago

0.0.193

3 years ago

0.0.192

3 years ago

0.0.191

3 years ago

0.0.190

3 years ago

0.0.189

3 years ago

0.0.188

3 years ago

0.0.187

3 years ago

0.0.186

3 years ago

0.0.185

3 years ago

0.0.184

3 years ago

0.0.183

3 years ago

0.0.182

3 years ago

0.0.181

3 years ago

0.0.180

3 years ago

0.0.179

3 years ago

0.0.178

3 years ago

0.0.177

3 years ago

0.0.176

3 years ago

0.0.175

3 years ago

0.0.174

3 years ago

0.0.173

3 years ago

0.0.172

3 years ago

0.0.171

3 years ago

0.0.170

3 years ago

0.0.169

3 years ago

0.0.168

3 years ago

0.0.167

3 years ago

0.0.166

3 years ago

0.0.165

3 years ago

0.0.164

3 years ago

0.0.163

3 years ago

0.0.162

3 years ago

0.0.161

3 years ago

0.0.160

3 years ago

0.0.159

3 years ago

0.0.158

3 years ago

0.0.157

3 years ago

0.0.156

3 years ago

0.0.155

3 years ago

0.0.154

3 years ago

0.0.153

3 years ago

0.0.152

3 years ago

0.0.151

3 years ago

0.0.150

3 years ago

0.0.149

3 years ago

0.0.148

3 years ago

0.0.147

3 years ago

0.0.146

3 years ago

0.0.145

3 years ago

0.0.144

3 years ago

0.0.142

3 years ago

0.0.141

3 years ago

0.0.140

3 years ago

0.0.139

3 years ago

0.0.138

3 years ago

0.0.137

3 years ago

0.0.136

3 years ago

0.0.135

3 years ago

0.0.134

3 years ago

0.0.133

3 years ago

0.0.132

3 years ago

0.0.130

3 years ago

0.0.129

3 years ago

0.0.128

3 years ago

0.0.127

3 years ago

0.0.126

3 years ago

0.0.125

3 years ago

0.0.124

3 years ago

0.0.123

3 years ago

0.0.122

3 years ago

0.0.121

3 years ago

0.0.120

3 years ago

0.0.119

3 years ago

0.0.118

3 years ago

0.0.117

3 years ago

0.0.116

3 years ago

0.0.115

3 years ago

0.0.114

3 years ago

0.0.113

3 years ago

0.0.112

3 years ago

0.0.111

3 years ago

0.0.110

3 years ago

0.0.109

3 years ago

0.0.108

3 years ago

0.0.107

3 years ago

0.0.106

3 years ago

0.0.105

3 years ago

0.0.104

3 years ago

0.0.103

3 years ago

0.0.102

3 years ago

0.0.101

3 years ago

0.0.100

3 years ago

0.0.45

3 years ago

0.0.44

3 years ago

0.0.43

3 years ago

0.0.37

3 years ago

0.0.36

3 years ago

0.0.34

3 years ago

0.0.33

3 years ago

0.0.32

3 years ago

0.0.31

3 years ago

0.0.30

3 years ago

0.0.29

3 years ago

0.0.28

3 years ago

0.0.27

3 years ago

0.0.26

3 years ago

0.0.25

3 years ago

0.0.24

3 years ago

0.0.23

3 years ago

0.0.22

3 years ago

0.0.21

3 years ago

0.0.20

3 years ago

0.0.19

3 years ago

0.0.18

3 years ago

0.0.17

3 years ago

0.0.16

3 years ago

0.0.15

3 years ago

0.0.14

3 years ago

0.0.13

3 years ago

0.0.12

3 years ago

0.0.11

3 years ago

0.0.10

3 years ago

0.0.9

3 years ago

0.0.8

3 years ago

0.0.7

3 years ago

0.0.6

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago