Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

fh-fhc

Package Overview
Dependencies
Maintainers
2
Versions
121
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fh-fhc - npm Package Compare versions

Comparing version 0.7.29-192 to 0.7.30-193

77

lib/local.js
"use strict";
module.exports = local;
local.usage = ["",
"fhc local <appid>",
""].join("\n");
" fhc local <appID>",
" This command (or the equivalent 'fhc initlocal <appID>') must be run at least",
" once to initialize the local service. Note : this call will start the local",
" client and cloud with the default host(127.0.0.1) and ports(8000/8001)",
"",
" fhc local <appID>* <cloudHost=host> <cloudPort=port> <port=port> ",
" where <appID> is the application id (aside from the initial call this parameter is optional)",
" where <cloudHost> is the ip address or hostname you want to listen",
" on (additionally we will generate urls with this host). Normally you ",
" would want to set this value if you want to access the cloud/client from ",
" a mobile device over your local router or through a public address. Note :",
" this address is used for bloth your cloud and client urls.",
" where <cloudPort> is the port that your cloud code uses for act calls (default : 8001). You ",
" would only need to change this from the default if it clashes with" ,
" another service",
" where <port> is the port that serves your client content.(default : 8000). You would normally ",
" only need to change this port if it clashes with another service. Or ",
" you want to run another package",
""
].join("\n");

@@ -22,12 +41,3 @@ var http = require("http"),

async = require('async'),
mimeTypes = {
json: "application/json",
js: "text/javascript",
css: "text/css",
html: "text/html",
xml: "text/xml",
txt: "text/plain",
woff: "font/opentype"
};
mime = require("mime");
var packages = [];

@@ -39,2 +49,3 @@ var defaultPackage = 'default';

var cloudAddress = "http://127.0.0.1:8001";
var localAddress = "http://127.0.0.1:8000";

@@ -125,2 +136,3 @@ fs.exists = fs.exists || path.exists;

currentArg = args[i];
if(args[i] === undefined) {

@@ -215,15 +227,33 @@ if(defaultArg.required) {

try {
appid = args.splice(0,1);
// I'm going to assume the appId can't have a '=' and all the
// command line args do have '='
if(args.length && !args[0].match(/=/)) {
appid = args.splice(0,1);
}
argObj = common.parseArgs(args);
validateArgs(argObj);
argObj.appid = appid;
if(!argObj.cloudHost.match(/^http:/)) {
argObj.cloudHost = "http://" + argObj.cloudHost;
}
cloudAddress = argObj.cloudHost + ":" + argObj.cloudPort;
localAddress = argObj.cloudHost + ":" + argObj.port;
} catch (x) {
return cb("Error processing args: " + x + "\nUsage: " + local.usage);
}
if(!fs.existsSync(fhcLocalDir)) {
if(!argObj.appid) {
return cb("Error : 'fhc initlocal <appId>' or 'fhc local <appId>' never called, see the usage for an explanation.\n\nUsage: " + local.usage);
}
}
async.series([
function(callback) {
if(!fs.existsSync(fhcLocalDir)) {
console.log("Please wait while the local directory is initialized");
initlocal.initlocal(argObj.appid, function(err, message) {
if(!err){
console.log("One time initialization complete.\nLaunching local services.");
} else {
console.log("Unexpected error during initialization. Is the guid '" + argObj.appid + "' correct?");
}
return callback(err);

@@ -299,3 +329,3 @@ });

console.log("Serving App files on port: " + argObj.port);
console.log("go to http://127.0.0.1:" + argObj.port + "/ in your browser");
console.log("go to " + argObj.cloudHost + ":" + argObj.port + "/ in your browser");

@@ -308,14 +338,4 @@ }], function(err, results) {

function getMimeType(fileName) {
var retVal = mimeTypes.txt;
var fileExtension = path.extname(fileName);
if (fileExtension) {
var len = fileExtension.length;
if (len > 0) {
if (fileExtension.substring(0,1) === '.') {
fileExtension = fileExtension.substring(1, len);
}
retVal = mimeTypes[fileExtension] || mimeTypes.txt
}
}
log.silly('mimetype for ' + fileName + ' is ' + retVal + ', fileExtension was: ' + fileExtension);
var retVal = mime.lookup(fileName) || "text/plain";
log.silly('mimetype for ' + fileName + ' is ' + retVal);
return retVal;

@@ -410,2 +430,3 @@ }

var container = fs.readFileSync(path.join(".fhclocal", "container.html"), "utf8");
container = container.replace(/http:\/\/127\.0\.0\.1:8000/g, localAddress);
container = container.replace("REPLACE_BODY_HERE", appIndex);

@@ -416,3 +437,3 @@ log.silly("App index.html inserted into container");

var initResp = fs.readFileSync(path.join(".fhclocal", "initResponse.json"), "utf8");
initResp = initResp.replace("REPLACE_CLOUD_HOST", cloudAddress).replace("REPLACE_CLOUD_HOST", cloudAddress);;
initResp = initResp.replace(/REPLACE_CLOUD_HOST/g, cloudAddress);
log.silly("Using " + cloudAddress + " as cloud host");

@@ -419,0 +440,0 @@ response.end(initResp);

@@ -5,3 +5,3 @@ {

"keywords" : [ "cli", "feedhenry" ],
"version": "0.7.29-192",
"version": "0.7.30-193",
"preferGlobal" : true,

@@ -29,3 +29,4 @@ "homepage" : "http://git.io/fh-fhc",

"moment": "*",
"cli-table" : "0.0.2"
"cli-table" : "0.0.2",
"mime": "*"
},

@@ -32,0 +33,0 @@ "devDependencies" : {

@@ -1,1 +0,1 @@

0.7.29-192
0.7.30-193
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc