Skip to content

Instantly share code, notes, and snippets.

@michoelchaikin
Last active July 26, 2017 21:19
Show Gist options
  • Save michoelchaikin/e84bc97bc51fbe830a1d1273907dc27c to your computer and use it in GitHub Desktop.
Save michoelchaikin/e84bc97bc51fbe830a1d1273907dc27c to your computer and use it in GitHub Desktop.
Gulpfile for Netsuite development
const gulp = require('gulp');
const typescript = require('gulp-typescript');
const del = require('del');
const keepass = require('keepass-http-client');
const spawn = require('child-process-promise').spawn;
const open = require('open');
const PROJECT_NAME = 'XXXX';
const PROJECT_URL = 'https://system.sandbox.netsuite.com/app/site/hosting/scriptlet.nl?script=XXX&deploy=XXXX';
const SDF_CLASSPATH = 'C:\\Users\\michoel\\Desktop\\sdf\\\*';
function deploy(enviroment) {
return keepass.itl({url: `${enviroment}.sdf.netsuite`})
.then((results) => {
if (!results['Entries'] || !results['Entries'].length) {
throw new Error('Unable to retrieve credentials');
} else {
return results['Entries'][0];
}
})
.then((credentials) =>
spawn(
'java', [
'-cp', SDF_CLASSPATH, 'com.netsuite.tools.SDF', 'deploy',
'-url', credentials.StringFields['url'],
'-account', credentials.StringFields['account'],
'-email', credentials.Login,
'-password', credentials.Password,
'-role', credentials.StringFields['role'],
'-project', 'dist\\',
'-np',
],
{stdio: 'inherit'}
)
);
}
gulp.task('scripts', () => {
return gulp.src('src/scripts/*.js')
.pipe(typescript({
target: 'ES5',
allowJs: true,
alwaysStrict: true,
}))
.pipe(gulp.dest(`dist/FileCabinet/SuiteScripts/${PROJECT_NAME}/`));
});
gulp.task('objects', () => {
return gulp.src('src/objects/*.xml')
.pipe(gulp.dest('dist/Objects/'));
});
gulp.task('other', () => {
return gulp.src([
'src/deploy.xml',
'src/manifest.xml',
], {base: 'src'})
.pipe(gulp.dest('dist/'));
});
gulp.task('clean', () => {
return del('dist/');
});
gulp.task('deploy-sandbox', ['scripts', 'objects', 'other'], () => {
return(deploy('sandbox'));
});
gulp.task('deploy-production', ['scripts', 'objects', 'other'], () => {
return(deploy('production'));
});
gulp.task('deploy-reload', ['deploy-sandbox'], () => {
open(PROJECT_URL, 'firefox');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment