npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

nscabinet

v0.5.2

Published

Upload and download files from netsuite.

Downloads

65

Readme

nscabinet NPM version

Upload/download files to a netsuite account, using the included restlet.

PS: This is actually also a gulp plugin.

Required Dependency Status devDependency Status

  • node.js 4+

Quick start

    npm install nscabinet
  • Install the nscabinet restlet bundle in your netsuite account (or manually create the script using the file in the repo) *

  • Create a nsconfig.json file in the root of you project with at least email , password, account, script number and deployment number.

  • Use it with gulp or with the CLI (see CLI section below)

var nscabinet = require('nscabinet');
gulp.src('myProject/dist/**/*.js').pipe(nscabinet({ rootPath : '/Templates' }));

(*) if installing from the bundle, the minor version must match your current version of nscabinet


Accepted input ways

The parameters may be stored in config files, in environment variables, or passed directly as object.

For environment variables, prefix the options with "NSCONF_" and write in uppercase.

The following priority is taken for each parameter (using _.extend)

  1. Options argument nscabinet(options)

  2. ./nsconfig.json, then ../nsconfig.json, up to 5 levels.

  3. ~/.ns/nsconfig.json

  4. Environment variables

For instance, let's say you call nscabinet({ account : '1234' }). Even if no e-mail is supplied, we also look up in the sources listed above for it. You may set a nsconfig.json for the project without the password, setting the latter machine-wise using an environment variable.

Common parameters

The following parameters are common through most of the methods:

Connection

  • realm defaults to netsuite.com.

  • role defaults to the account's default role.

  • account

  • email

  • password

  • script

  • deployment defaults to 1.

  • conffile overrides default nsconfig.json file name, allowing multiple project setting.

Path

  • rootPath sets the root path on the server. Defaults to /SuiteScripts. Must begin with /.

Example: Upload file with path img/image.jpg to rootPath /Templates will "upsert" the file onto '/Templates/img/image.jpg'.

nscabinet.upload


var nscabinet = require('nscabinet') ,
	gulp = require('gulp') //or just vinyl-fs

gulp.src('foo.js')
	.pipe(nscabinet({
		email : '[email protected]' ,
		password : '123456' ,
		account : '123456' ,
		realm : 'sandbox.netsuite.com' ,
		role : 3 ,
		rootPath : '/SuiteScripts/MyProject'
		script : 95 ,
		deployment : 1
	}))
  • isonline (boolean) lets you set the uploaded files to be avaliable without login.

  • flatten all files are uploaded to the root path, regardless of their source path.

nscabinet.download( files , [opts] )

nscabinet.download(['MyProject/*.js','/Web Site Hosting Files/My Site/*.html'])
	.pipe(vinylfs.dest('local'))
  • files file selector (one or many).

    • * is accepted on the file part. The restlet then runs a file search by name in which * is replaced with %.

    • Paths are also relative to opts.rootPath. If a file selector begins with /, files will be queried by absolute path in netsuite, but saved locally inside the cabinet_root folder.

    • If a path has /**/, a recursive search will be done. This can be used to search just by file name, regardless of path.

    • (PS: While the syntax is similar, don't expect full glob funcionality. It's not a glob!)

  • opts Common options.

nscabinet.url ( file : string , [opts] ) : Promise[string]

Get the url (internal or external) of a cabinet file. Returns a promise. Useful for email campaign stuff.

Options: receives the ones which make sense here (ex: rootPath, realm, etc...) in the same fashion.

nscabinet.url('emails/img/header.jpg').then( url => {
    cheerio_img.attr(src,url);
    return cheerio_doc.html();
});

CLI

npm install -g nscabinet
$ nscabinet u "file.txt" --rootpath "/SuiteScripts/MyProject"
$ nscabinet u "file.txt" -p "/SuiteScripts/MyProject"
$ nscabinet u "file.txt"
$ nscabinet d "remote.txt" --rootPath "/Downloads"
$ nscabinet d "remote.txt" -p "/Downloads"
$ nscabinet d "remote.txt"

Takes in the same arguments (always lowercased).

Encase path parameters in string quotes (avoids bash expansion).

As usual, the arguments are defaulted from nsconfig.json.

Sent file paths are taken relative to the config file path. Ex:

$ nscabinet u file.txt
Uploading file.txt to /SuiteScripts
$ cd Views
$ Views nscabinet u view.html
Uploading Views/view.html to /SuiteScripts

Contributing

  • If you add new funcionality, also add a new test!

At the time tests are run locally. To set up the tests:

  • Install the restlet in an available account;

  • Set up nsconfig.json, pointing to that account; Don't forget to set a rootPath to where the tests will play around and create its lots of files;

  • Run 'gulp'