# netsuite-uploader-util

> Helper library for uploading files from your local computer into the NetSuite File Cabinet from nodejs.

Latest version **1.1.6** (published 2018-04-02) · MIT license · 0 weekly downloads

## Install

```sh
npm install netsuite-uploader-util
pnpm add netsuite-uploader-util
yarn add netsuite-uploader-util
bun add netsuite-uploader-util
```

## 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 | 1.1.6 |
| Published | 2018-04-02 |
| First published | 2017-05-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 6 |
| Unpacked size | 48.6 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 4 |
| Author | Brendon Parker |
| Maintainers | brendonparker, kaeal |
| Keywords | netsuite, nodejs, upload |

## Links

- npm: https://www.npmjs.com/package/netsuite-uploader-util
- Repository: https://github.com/icsfl/netsuite-uploader-util
- Homepage: https://github.com/icsfl/netsuite-uploader-util#readme
- Issues: https://github.com/icsfl/netsuite-uploader-util/issues
- npm.io page: https://npm.io/package/netsuite-uploader-util

## Dependencies (6)

- [q](https://npm.io/package/q.md) ^1.4.1
- [oauth](https://npm.io/package/oauth.md) ^0.9.15
- [upath](https://npm.io/package/upath.md) ^1.0.2
- [request](https://npm.io/package/request.md) ^2.83.0
- [readline-sync](https://npm.io/package/readline-sync.md) ^1.4.2
- [string-template](https://npm.io/package/string-template.md) ^1.0.0

## Recent versions

- 1.1.6 (latest) — 2018-04-02
- 1.1.5 — 2018-02-08
- 1.1.4 — 2017-12-07
- 1.1.3 — 2017-07-13
- 1.1.2 — 2017-05-10
- 1.1.1 — 2017-05-10
- 1.0.0 — 2017-05-10

## README

[![devDependencies Status](https://david-dm.org/cancerberosgx/netsuite-uploader-util/status.svg)](https://david-dm.org/cancerberosgx/netsuite-uploader-util)

# netsuite-uploader-util

Helper library for uploading files from your local computer into the NetSuite File Cabinet from nodejs.

# Install

```
 $ npm install netsuite-uploader-util 
```

# Usage

Simple using SuiteTalk 2015_1 so you dont need application ID: 

```javascript
// Constants: - change according to your needs
var account = 'TSTDRV1234567';
var role = 3;
var localfile = '/home/me/script1.js' // the local file to upload
var remoteFile = 'SuiteScripts/script1.js' // the path to file cabinet path to update or create. You can pass non-existing folders - in that case they will be created recursively, like mkdir -p

var nsutil = require('netsuite-uploader-util');

var client = new nsutil.SuiteTalk();
var creds = nsutil.Credentials;
client.init(creds.email, creds.password, account, role).then(() => {
    client.upload(file.path, suiteScriptPath).then(r=>{
            console.log('  Uploaded File: ' + suiteScriptPath);
        }, err => {
            console.log('  Failed to Upload File: ' + err);
        });
    });
});

```

Or you can use latest SuiteTalk versions, currently 2017_2. For this you need an application ID which you can create in Setup->Integration->Manage Integrations menu. Is the same as before but we pass extra two parameters to client.init(). `nsVersion` parameter is optional. Example: 

```javascript
var applicationId = 'E296719E-C000-4719-B60A-89B72FB65E88';
var nsVersion = '2017_2';
client.init(creds.email, creds.password, account, role, applicationId, nsVersion)....
```

# Sample gulpfile.js task that leverages this utility:

```javascript
var gulp = require('gulp'),
    watch = require('gulp-watch'),
    nsutil = require('netsuite-uploader-util');

// "Constants"
var watchFilter = 'netsuite_code/**/*.js';
var account = 'TSTDRV1234567';
var role = 3;

gulp.task('default', () => {
    var client = new nsutil.SuiteTalk();
    var creds = nsutil.Credentials;

    console.log('Configuring SuiteTalk client...');
    client.init(creds.email, creds.password, account, role).then(() => {
        console.log('SuiteTalk client configured.');
        console.log('Watching: ' + watchFilter);

        watch(watchFilter, file => {
            console.log(`File changed. Uploading File: ${file.path}...`);
            var pathParts = file.path.split(/\\|\//);
            var idx = pathParts.indexOf('netsuite_code')+1;
            
            var filename = pathParts.slice(idx).join('/');

            var suiteScriptPath = `SuiteScripts/My App/${filename}`;

            client.upload(file.path, suiteScriptPath).then(r=>{
                console.log('  Uploaded File: ' + suiteScriptPath);
            }, err => {
                console.log('  Failed to Upload File: ' + err);
            });
        });
    });
});
```

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