VTEX-CMS-Sauce
VTEX CMS Sauce was created to allow a better deploying experience to VTEX stores. You can use it to upload several templates and files in some seconds, as an alternative to the old VTEX portal.
Getting started
-
npm install vtex-cms-sauce
. -
Create your api-sauced cms handler:
const cms = ...
- Insert your VTEX ID authentication cookie when prompted. NOTE: You must have access to the store you're trying to work on.
Methods
Save Template
cms.saveTemplate(templateName, HTML, isSub = false)
- templateName {String} - From this string, the templateId will be created in background.
- HTML {String} - String containing the HTML template.
- isSub {Boolean} - Pass true if subtemplate
Example
const HTML = `<!DOCTYPE html><head> <title>VTEX</title></head><body> <h1>Hello, World!</h1></body>`cms
Save Shelf Template
cms.saveShelfTemplate(templateName, HTML, shelfClass)
- templateName {String} - From this string, the templateId will be created in background.
- HTML {String} - String containing the HTML template.
- shelfClass {String} - Classname of shelf container
Example
const HTML = `<div class="product"> Product</div>`cms
Save File
cms.saveFile(filepath)
- filepath {String} - Path of file to be uploaded
Example
cms
Publish script example
const path = fs = create = create pjson = projectVars = const cms = const appDirectory = fsconst resolveApp = pathconst templatePrefix = projectVarsTEMPLATE_PREFIX const templatesDir = const subtemplatesDir = const shelvesDir = const filesDir = const getFiles = fs const sendFiles = async { try let logs = '' const files = fs for let i = 0; i < fileslength; i++ let log let file = filesi let content = fs if type === 'template' log = await cms else if type === 'subtemplate' log = await cms else if type === 'shelf' log = await cms else if type === 'file' log = await cms logs += `\n` console catcherr console }
License
MIT © Mauricio Alvim