0.0.31 • Published 13 days ago

ecforce-theme-cli v0.0.31

Weekly downloads
-
License
ISC
Repository
-
Last release
13 days ago

Getting started

Installation

npm i -D ecforce-theme-cli

Configuration

Put ecforce.config.json to project root.

{
  "basicAuthUsername": "BASIC_AUTH_USERNAME",
  "basicAuthPassword": "BASIC_AUTH_PASSWORD",
  "username": "USERNAME",
  "password": "PASSWORD",
  "baseUrl": "https://HOSTNAME/",
  "profiles": [
    {
      "type": "theme",
      "name": "THEME_NAME",
      "branch": "BRANCH_NAME",
      "themeId": "THEME_ID",
      "dir": "DIRECTORY_PATH"
    },
    {
      "type": "lp",
      "lpId": "LP_ID",
      "branch": "BRANCH_NAME",
      "dir": "DIRECTORY_PATH"
    }
  ]
}

Commands

Sync

npx ecforce-theme-cli sync

Options

  • -w, --watch
    watch files

Pull

npx ecforce-theme-cli pull

Preview

npx ecforce-theme-cli

Auto reload script

For theme

{% if theme_preview_mode %}
  <script>
    const connectWSServer = () => {
      const ws = new WebSocket('ws://localhost:8080')
      ws.addEventListener('message', message => {
        const data = JSON.parse(message.data)
        if(data.type === 'update'){
          location.reload()
        }
      })
    }

    let localHosted = null
    new MutationObserver((mutations) => {
      for(const mutation of mutations){
        for(const node of mutation.addedNodes){
          if(node.nodeName !== 'SCRIPT') break
          if(node.src.includes('/ec_force/assets/')){
            if(localHosted === null){
              const xhr = new XMLHttpRequest()
              xhr.open('HEAD', 'http://localhost:8088/', false)
              try {
                xhr.send()
                if(xhr.readyState === 4){
                  localHosted = true
                  connectWSServer()
                } else {
                  throw new Error()
                }
              } catch(err) {
                localHosted = false
              }
            }
            if(localHosted){
              node.src = node.src.replace(/.*\/ec_force\/assets\//, 'http://localhost:8088/')
            }
          }
          return
        }
      }
    }).observe(document, {childList: true, subtree: true})
    document.addEventListener('DOMContentLoaded', () => {
      document.querySelectorAll('link').forEach(link => {
        if(localHosted === true && link.rel === 'stylesheet' && link.href.includes('/ec_force/assets/')){
          if(localHosted){
            link.href = link.href.replace(/.*\/ec_force\/assets\//, 'http://localhost:8088/')
          }
        }
      })
    })
  </script>
{% endif %}

For LP

{%%}
<script>
  const connectWSServer = () => {
    const ws = new WebSocket('ws://localhost:8080')
    ws.addEventListener('message', message => {
      const data = JSON.parse(message.data)
      if(data.type === 'update'){
        location.reload()
      }
    })
  }
</script>
0.0.30

17 days ago

0.0.31

13 days ago

0.0.28

17 days ago

0.0.29

17 days ago

0.0.27

1 month ago

0.0.26

3 months ago

0.0.25

8 months ago

0.0.23

9 months ago

0.0.24

9 months ago

0.0.20

10 months ago

0.0.21

10 months ago

0.0.22

10 months ago

0.0.17

10 months ago

0.0.18

10 months ago

0.0.19

10 months ago

0.0.16

10 months ago

0.0.15

10 months ago

0.0.14

1 year ago

0.0.13

1 year ago

0.0.12

1 year ago

0.0.11

1 year ago

0.0.10

1 year ago

0.0.9

1 year ago

0.0.8

1 year ago

0.0.7

1 year ago

0.0.6

1 year ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago