Permalink
Browse files

Add script to build offline installer

  • Loading branch information...
1 parent 2c6c105 commit 9ff6a799f6459bb8ad4825b30f558153ed15c812 @jcheng5 jcheng5 committed Jan 17, 2013
Showing with 74 additions and 4 deletions.
  1. +68 −0 tools/bundle-offline-installer.js
  2. +6 −4 {lib → tools}/makedocs.js
@@ -0,0 +1,68 @@
+#!/usr/bin/env node
+
+/*
+ * bundle-offline-installer.js
+ *
+ * Copyright (C) 2009-13 by RStudio, Inc.
+ *
+ * This program is licensed to you under the terms of version 3 of the
+ * GNU Affero General Public License. This program is distributed WITHOUT
+ * ANY EXPRESS OR IMPLIED WARRANTY, INCLUDING THOSE OF NON-INFRINGEMENT,
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Please refer to the
+ * AGPL (http://www.gnu.org/licenses/agpl-3.0.txt) for more details.
+ *
+ */
+
+var fs = require('fs');
+var path = require('path');
+var child_process = require('child_process');
+
+var packageJson = path.join(__dirname, '../package.json');
+var packageJsonContents = fs.readFileSync(packageJson, 'utf-8')
+var package = JSON.parse(packageJsonContents);
+var deps = package.dependencies;
+var depnames = [];
+for (dep in deps) {
+ if (deps.hasOwnProperty(dep))
+ depnames.push(dep);
+}
+
+package.bundledDependencies = depnames;
+
+var contents = JSON.stringify(package, null, ' ');
+
+fs.writeFileSync(packageJson, contents, 'utf-8');
+function restoreContents() {
+ fs.writeFileSync(packageJson, packageJsonContents, 'utf-8');
+}
+process.on('exit', function() {
+ restoreContents();
+});
+process.on('uncaughtException', function(err) {
+ restoreContents();
+ console.log('ERROR: ' + err.message);
+ process.exit(1);
+});
+
+var cp = child_process.spawn(
+ 'sh',
+ ['-c', 'npm install && echo Building package... && npm pack'],
+ {
+ cwd: path.join(__dirname, '..'),
+ stdio: 'inherit'
+ }
+);
+
+cp.on('exit', function(code) {
+ if (code) {
+ process.stderr.write('Bundling failed!\n');
+ process.exit(code);
+ } else {
+ var filename = 'shiny-server-' + package.version + '.tgz';
+
+ console.log('\n');
+ console.log('Your package has been built. To install, call this command as root or sudo:');
+ console.log(' npm install --no-registry -g ' + filename);
+ console.log('\n');
+ }
+});
@@ -1,3 +1,5 @@
+#!/usr/bin/env node
+
/*
* makedocs.js
*
@@ -24,9 +26,9 @@ var util = require('util');
var htmlEscape = require('connect/lib/utils').escape;
var Handlebars = require('handlebars');
var _ = require('underscore');
-var map = require('./core/map');
-var config = require('./config/config');
-var schema = require('./config/schema');
+var map = require('../lib/core/map');
+var config = require('../lib/config/config');
+var schema = require('../lib/config/schema');
function filterDesc(desc) {
if (!desc)
@@ -74,7 +76,7 @@ var packageInfo =
JSON.parse(fs.readFileSync(path.join(__dirname, '../package.json')));
var version = packageInfo['version'];
-var rulesPath = path.join(__dirname, 'router/shiny-server-rules.config');
+var rulesPath = path.join(__dirname, '../lib/router/shiny-server-rules.config');
var ruleConfig = config.parse(fs.readFileSync(rulesPath, 'utf-8'), rulesPath);
var rules = _.map(ruleConfig.children, function(child) {

0 comments on commit 9ff6a79

Please sign in to comment.