Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

put d/e options back in for upload.js

Mike McGann038c8892d4c9
diff --git a/package.json b/package.json
index c2ff1361e..51ba117a7 100644
--- a/package.json
+++ b/package.json
@@ -27,7 +27,7 @@
},
"scripts": {
"browserstack": "node e2e/browserstack.js -c e2e/browserstack.conf.js -e browserstack ",
- "build": "run-s clean getcapabilities build:config build:js build:css",
+ "build": "run-s clean \"getcapabilities -- {1}\" \"build:config -- {1}\" build:js build:css --",
"build:css": "node ./tasks/buildCSS",
"build:config": "bash -c 'tasks/buildOptions.sh ${1}' 0 && node ./tasks/config.js",
"build:js": "node ./tasks/buildJS",
diff --git a/tasks/upload.js b/tasks/upload.js
index 8d42991e8..51260e2a8 100755
--- a/tasks/upload.js
+++ b/tasks/upload.js
@@ -4,17 +4,29 @@ const fs = require('fs');
const os = require('os');
const path = require('path');
const yargs = require('yargs');
+const shell = require('shelljs');
const NodeSSH = require('node-ssh');
const ssh = new NodeSSH();
-const error = (msg) => {
+function error(msg) {
const prog = path.basename(__filename);
console.error(`${prog}: error: ${msg}`);
process.exit(1);
};
-var argv = yargs
+let argv = yargs
.usage('$0 [options] <name>')
+ .option('d', {
+ alias: 'dist',
+ description: 'do not build, use artifacts found in dist directory',
+ type: 'boolean'
+ })
+ .option('e', {
+ alias: 'env',
+ description: 'configuration environment if not "release"',
+ requiresArg: true,
+ type: 'string'
+ })
.option('h', {
alias: 'host',
description: 'upload to this host',
@@ -54,11 +66,11 @@ if (argv.help) {
process.exit(0);
}
-const baseDir = path.join(__dirname, '..');
-const distDir = path.join(baseDir, 'dist');
-const worldview = 'worldview.tar.gz';
-const distWorldview = path.join(distDir, worldview);
-const configFile = path.join(os.homedir(), '.worldview', 'upload.config');
+let baseDir = path.join(__dirname, '..');
+let distDir = path.join(baseDir, 'dist');
+let worldview = 'worldview.tar.gz';
+let distWorldview = path.join(distDir, worldview);
+let configFile = path.join(os.homedir(), '.worldview', 'upload.config');
let configData = '{}';
try {
@@ -74,10 +86,10 @@ try {
error(`${configFile}:\n${err}`);
}
-const host = argv.host || config.host;
-const root = argv.root || config.root;
-const username = argv.user || config.user || os.userInfo().username;
-const key = argv.key || config.key || path.join(os.homedir(), '.ssh', 'id_rsa');
+let host = argv.host || config.host;
+let root = argv.root || config.root;
+let username = argv.user || config.user || os.userInfo().username;
+let key = argv.key || config.key || path.join(os.homedir(), '.ssh', 'id_rsa');
if (!host) {
error('host not found in config file or command line');
@@ -89,12 +101,13 @@ if (!username) {
error('user not found in config file or command line');
}
-const name = argv._[0];
+let name = argv._[0];
if (!name) {
error('name is required');
}
async function upload() {
+ console.log(`Uploading to ${host}`);
try {
await ssh.connect({ host, username, privateKey: key });
let cmd = `
@@ -112,9 +125,20 @@ async function upload() {
process.stdout.write(result.stdout);
process.stderr.write(result.stderr);
ssh.dispose();
+ console.log('Done');
} catch (err) {
error(err.toString());
}
};
+if (!argv.dist) {
+ shell.exec('npm install');
+ let cmd = 'npm run build';
+ if (argv.env) {
+ cmd = cmd + ' -- ' + argv.env;
+ }
+ shell.exec(cmd);
+ shell.exec('node ./tasks/dist.js');
+}
+
upload();