@swell/cli
#We're in beta: commands and arguments can still change.#
Install with:
npm install -g @swell/cli
If you are using tools for version managing like asdf, make sure you reshim after install:
asdf reshim
Commands
General options
Commands tend to support the following helper options:
- --quiet (-q): Boolean, quiets the progress indicator and output of intermediary commands
- --verbose (-v): Boolean, outputs all commands
- --dry-run: Boolean, dry runs requests that delete data, but doesn't run them
- --yes (-y): Boolean, answers all confirmation questions with yes.
Login
The admin login
command authenticates and stores a user's session locally. Saved sessions can/will be used by other commands, unless a secret key is specified.
swell login [--username (-u) String] [--password (-p) String] [--set-default Boolean]
Examples
swell login
swell login --set-default
Storefronts
List all storefronts associated to logged in user:
swell storefronts list
Retrieves storefront configuration data from the server and writes it to a file if specified or stdout by default. It requires a type to run. Configuration types allowed are "editor", "menus" and "settings":
swell storefronts pull --id String --type (-t) String [--file (-f) String]
Send storefront configuration data to the server. Configuration types allowed are "editor", "menus" and "settings":
swell storefronts push --id String --type (-t) String [--file (-f) String] [--strategy (-i) String]
Examples
swell storefronts pull --id P5OzfzLD -t editor
swell storefronts pull --id P5OzfzLD -t menus -f menus.json
swell storefronts push --id P5OzfzLD -t editor -s set -f ../origin-storefront/config/editor.json
Without logging in
swell storefronts pull --id P5OzfzLD -t editor --store my-test-store --secret-key my-dev-secret-key
swell storefronts pull --id P5OzfzLD -t menus -f menus.json --store my-test-store --secret-key my-dev-secret-key
swell storefronts push --id P5OzfzLD -t editor -s set -f ../origin-storefront/config/editor.json --store my-test-store --secret-key my-dev-secret-key
Model
Push or pull model definitions, including namespaced models (e.g. content models), abstract content models and content fields.
# pull => retrieves a model from the server and tries to merge and/or write to a specified JSON file or stdout (by default)
# --content flag toggles between base models and abstract content models or content fields
swell model pull -m MODEL_ID [--file (-f) String] [--strategy (-s) String] [--content Boolean]
# push => send a model definition from a JSON file or stdin to the server
swell model push [--file (-f) String] [--input (-i) stdin] [--content Boolean]
It is important that the model definition includes some fields depending on the type/source of the model.
Basic model
{
"name": "Test", // slug will be assumed from this field
"slug": "test_model", // or you can define one explicitly
"fields": { ... }
}
Namespaced model
{
"name": "Page", // slug will be assumed from this field
"namespace": "content",
"fields": { ... }
}
Theme content (abstract) model/fields (use with --content flag)
{
"name": "Test", // slug will be assumed from this field
"fields": { ... },
"source_type": "theme",
"source_id": "origin"
}
Examples
swell model pull -m products # pull products model and display in stdout
swell model pull -m theme.origin.page --content -f models/page.json # pull a content model and save it to a file
swell model push -f models/orders.json
swell model push -c -f models/page.json # push a content model
Without logging in
swell model pull -m products --store my-test-store --secret-key my-dev-secret-key
swell model pull -m theme.origin.page --content -f models/page.json --store my-test-store --secret-key my-dev-secret-key
swell model push -f models/orders.json --store my-test-store --secret-key my-dev-secret-key
swell model push -c -f models/page.json --store my-test-store --secret-key my-dev-secret-key