# smartuxdeploy

Latest version **2.0.0** (published 2020-12-15) · ISC license · 0 weekly downloads

## Install

```sh
npm install smartuxdeploy
pnpm add smartuxdeploy
yarn add smartuxdeploy
bun add smartuxdeploy
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2020-12-15 |
| First published | 2020-08-04 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 5 |
| Unpacked size | 37.2 KB |
| Known vulnerabilities | 0 (+2 in 2 direct dependencies) |
| Install scripts | no |
| Author | Richa |
| Maintainers | sundrani |

## Links

- npm: https://www.npmjs.com/package/smartuxdeploy
- npm.io page: https://npm.io/package/smartuxdeploy

## Dependencies (5)

- [fs](https://npm.io/package/fs.md) 0.0.1-security
- [http](https://npm.io/package/http.md) 0.0.1-security
- [https](https://npm.io/package/https.md) ^1.0.0
- [crypto](https://npm.io/package/crypto.md) ^1.0.1
- [form-data](https://npm.io/package/form-data.md) ^3.0.0

## Recent versions

- 2.0.0 (latest) — 2020-12-15
- 1.0.42 — 2020-10-17
- 1.0.41 — 2020-10-09
- 1.0.40 — 2020-10-06
- 1.0.39 — 2020-10-01
- 1.0.38 — 2020-08-31
- 1.0.37 — 2020-08-28
- 1.0.36 — 2020-08-27
- 1.0.35 — 2020-08-27
- 1.0.34 — 2020-08-26
- 1.0.33 — 2020-08-26
- 1.0.32 — 2020-08-26
- 1.0.31 — 2020-08-25
- 1.0.30 — 2020-08-25
- 1.0.29 — 2020-08-25
- … 29 more at https://npm.io/package/smartuxdeploy/versions

## README

## SmartUX Studio application deployment to SmartUX runtime 


###  Overview
<p> The npm package contains all the method for SmartUX application deploy process from SmartUX Studio. These methods makes API calls to the SmartUX runtime environment and publishe the application files downloaded from SmartUX Studio environment.  </p>

###  Requirements
NodeJS 

<p><b> npm modules preinstalled in the package </b></p>
http </br>
https </br>
fs </br>
form-data </br>
zip-local </br>
path </br>

###   Installation
     $ npm install smartuxdeploy

##  Usage

### input parameters:
| Parameter  |  Description                              | Example value | Data type                    
|------------|-------------------------------------------|---------------|-----------|
| protocol   | protocol of the smartUX studio environment | 'http' or 'https' | String |
| hostURL    | URL of the SmartUX Studio (do not include http:// or https://) | studio.smartux.com | String |
| username   | username to log in to SmartUX Studio | admin | String |                         
| encryptedPassword | encrypted password | Click here for details | String |

### import the required npm modules in your file
  ```javascript
    const smartuxdeploy = require('smartuxdeploy');
    const fs = require('fs');
    const zipper = require('zip-local');
    const path = require('path');
    const FormData = require('form-data');
  ```
### example usage:

```javascript
// Set the enviroment variables
    const protocol = "<http or https>";
    const hostURL = "<YOUR STUDIO URL>";
    const username = "<STUDIO USERNAME>";
    const encryptedPassword = "<ENCRYPTED PASSWORD>";
// deployAll method calls the getZipFilesToDeploy which results the list of published apps from the smartUx build process.
// next it chceks if there are already files from previously unzipped applications and makes sure that the unzip directory is empty.
// next it unzips the first application from list of published apps and calls the publishZipFile method. 
// All the above steps are repeated for all the applications from published app list from the smartUX build process.
async function deployAll() {
    var appZipDir = './smartUXPublishedApps/';
    var unzipDir = './tempunzipdir';
    var zipFilesToDeploy;
    try {
        zipFilesToDeploy = await smartuxdeploy.getZipFilesToDeploy(appZipDir);
        console.log(zipFilesToDeploy);
    } catch (error) {
        console.error(error);
    }

    for (file of zipFilesToDeploy) {
        // Emptying the unzip directory or create unzipDir if does not exists
        if (fs.existsSync(unzipDir)) {
            for (const file of fs.readdirSync(unzipDir)) {
                fs.unlinkSync(path.join(unzipDir, file));
            }
        } else {
            fs.mkdirSync(unzipDir);
        }
        console.log(file);
        // unzip the zipfile to get smartuxapp.json
        zipper.sync.unzip(appZipDir + file).save(unzipDir);
        var smartuxAppJson = await smartuxdeploy.readSmartUXAppJs(unzipDir, file);
        let appZipFile = appZipDir + file;
        var appNameFromZipFile = smartuxAppJson.name;
        console.log("Calling runtime publish for app : " + appNameFromZipFile);
        try {
            await smartuxdeploy.publishZipFile(protocol, hostURL, username, encryptedPassword, appZipFile, smartuxAppJson, file);
        } catch (error) {
            console.error(error);
        }

        console.log("Runtime publish completed for app : " + appNameFromZipFile);
    }
}
try {
    deployAll();
} catch (error) {
    console.error(error);
}
```

## publishZipFile
<p> This method calls all the methods requires to make the API calls for the deploy process for example login method. </p>

 ### input parameters:
| Parameter  |  Description                              | Example value | Data type                    
|------------|-------------------------------------------|---------------|-----------|
| protocol   | protocol of the smartUX studio environment | 'http' or 'https' | String |
| hostURL    | URL of the SmartUX dashboard (do not include http:// or https://) | smartuxdashboard.com | String |
| username   | username to log in to SmartUX dashboard | user | String |                         
| encryptedPassword | encrypted password | Click here for details | String |

---
_Source: https://npm.io/package/smartuxdeploy · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
