Comparing version 0.0.2 to 1.0.0-beta.1
@@ -37,3 +37,8 @@ 'use strict'; | ||
this.hostWhitelist = config.hostWhitelist; | ||
this.appConfig = config.appConfig; | ||
if (process.env.APP_CONFIG) { | ||
this.appConfig = JSON.parse(process.env.APP_CONFIG); | ||
} | ||
this.html = fs.readFileSync(config.htmlFile, 'utf8'); | ||
@@ -56,2 +61,6 @@ | ||
let sandboxRequire = this.buildWhitelistedRequire(this.moduleWhitelist, distPath); | ||
let config = this.appConfig; | ||
function appConfig() { | ||
return { default: config }; | ||
} | ||
@@ -61,3 +70,6 @@ return new Sandbox({ | ||
najax: najax, | ||
FastBoot: { require: sandboxRequire } | ||
FastBoot: { | ||
require: sandboxRequire, | ||
config: appConfig | ||
} | ||
} | ||
@@ -246,3 +258,4 @@ }); | ||
moduleWhitelist: pkg.fastboot.moduleWhitelist, | ||
hostWhitelist: pkg.fastboot.hostWhitelist | ||
hostWhitelist: pkg.fastboot.hostWhitelist, | ||
appConfig: pkg.fastboot.appConfig | ||
}; | ||
@@ -249,0 +262,0 @@ } |
{ | ||
"name": "fastboot", | ||
"version": "0.0.2", | ||
"version": "1.0.0-beta.1", | ||
"description": "Library for rendering Ember apps in node.js", | ||
@@ -10,3 +10,3 @@ "scripts": { | ||
"type": "git", | ||
"url": "git+https://github.com/ember-fastboot/ember-fastboot-server.git" | ||
"url": "git+https://github.com/ember-fastboot/fastboot.git" | ||
}, | ||
@@ -20,5 +20,5 @@ "keywords": [ | ||
"bugs": { | ||
"url": "https://github.com/ember-fastboot/ember-fastboot-server/issues" | ||
"url": "https://github.com/ember-fastboot/fastboot-fastboot-server/issues" | ||
}, | ||
"homepage": "https://github.com/ember-fastboot/ember-fastboot-server#readme", | ||
"homepage": "https://github.com/ember-fastboot/fastboot#readme", | ||
"dependencies": { | ||
@@ -25,0 +25,0 @@ "chalk": "^0.5.1", |
'use strict'; | ||
const expect = require('chai').expect; | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
@@ -92,2 +93,88 @@ const request = require('request-promise'); | ||
}); | ||
it("reads the config from package.json", function() { | ||
var fastboot = new FastBoot({ | ||
distPath: fixture('config-app') | ||
}); | ||
return fastboot.visit('/') | ||
.then(r => r.html()) | ||
.then(html => expect(html).to.match(/Config foo: bar/)); | ||
}); | ||
it("prefers APP_CONFIG environment variable", function() { | ||
var config = { | ||
modulePrefix: "fastboot-test", | ||
environment: "development", | ||
baseURL: "/", | ||
locationType: "auto", | ||
EmberENV: { "FEATURES":{} }, | ||
APP: { | ||
name: "fastboot-test", | ||
version: "0.0.0+3e9fe92d", | ||
autoboot: false, | ||
foo: "baz" | ||
}, | ||
exportApplicationGlobal:true | ||
}; | ||
process.env.APP_CONFIG = JSON.stringify(config); | ||
var fastboot = new FastBoot({ | ||
distPath: fixture('config-app') | ||
}); | ||
delete process.env.APP_CONFIG; | ||
return fastboot.visit('/') | ||
.then(r => r.html()) | ||
.then(html => expect(html).to.match(/Config foo: baz/)); | ||
}); | ||
it("handles apps with config defined in app.js", function() { | ||
var fastboot = new FastBoot({ | ||
distPath: fixture('config-not-in-meta-app') | ||
}); | ||
return fastboot.visit('/') | ||
.then(r => r.html()) | ||
.then(html => expect(html).to.match(/Welcome to Ember/)); | ||
}); | ||
it("reloads the config when package.json changes", function() { | ||
var distPath = fixture('config-swap-app'); | ||
var packagePath = path.join(distPath, 'package.json'); | ||
var package1Path = path.join(distPath, 'package-1.json'); | ||
var package2Path = path.join(distPath, 'package-2.json'); | ||
copyPackage(package1Path); | ||
var fastboot = new FastBoot({ | ||
distPath: distPath | ||
}); | ||
return fastboot.visit('/') | ||
.then(r => r.html()) | ||
.then(html => expect(html).to.match(/Config foo: bar/)) | ||
.then(() => deletePackage()) | ||
.then(() => copyPackage(package2Path)) | ||
.then(hotReloadApp) | ||
.then(() => fastboot.visit('/')) | ||
.then(r => r.html()) | ||
.then(html => expect(html).to.match(/Config foo: boo/)) | ||
.finally(() => deletePackage()); | ||
function hotReloadApp() { | ||
fastboot.reload({ | ||
distPath: distPath | ||
}); | ||
} | ||
function copyPackage(sourcePackage) { | ||
fs.symlinkSync(sourcePackage, packagePath); | ||
} | ||
function deletePackage() { | ||
fs.unlinkSync(packagePath); | ||
} | ||
}); | ||
}); | ||
@@ -94,0 +181,0 @@ |
@@ -331,3 +331,3 @@ "use strict"; | ||
define('fastboot-test/config/environment', ['ember'], function(Ember) { | ||
return { 'default': {"modulePrefix":"fastboot-test","environment":"development","baseURL":"/","locationType":"auto","EmberENV":{"FEATURES":{}},"APP":{"name":"fastboot-test","version":"0.0.0+3e9fe92d","autoboot":false},"exportApplicationGlobal":true}}; | ||
return FastBoot.config(); | ||
}); | ||
@@ -334,0 +334,0 @@ |
@@ -9,4 +9,5 @@ { | ||
"vendorFile": "assets/vendor.js" | ||
} | ||
}, | ||
"appConfig": {"modulePrefix":"fastboot-test","environment":"development","baseURL":"/","locationType":"auto","EmberENV":{"FEATURES":{}},"APP":{"name":"fastboot-test","version":"0.0.0+3e9fe92d","autoboot":false},"exportApplicationGlobal":true} | ||
} | ||
} | ||
} |
@@ -329,3 +329,3 @@ "use strict"; | ||
define('fastboot-test/config/environment', ['ember'], function(Ember) { | ||
return { 'default': {"modulePrefix":"fastboot-test","environment":"development","baseURL":"/","locationType":"auto","EmberENV":{"FEATURES":{}},"APP":{"name":"fastboot-test","version":"0.0.0+3e9fe92d","autoboot":false},"exportApplicationGlobal":true}}; | ||
return FastBoot.config(); | ||
}); | ||
@@ -351,2 +351,2 @@ | ||
/* jshint ignore:end */ | ||
//# sourceMappingURL=fastboot-test.map | ||
//# sourceMappingURL=fastboot-test.map |
@@ -9,4 +9,5 @@ { | ||
"vendorFile": "assets/vendor.js" | ||
} | ||
}, | ||
"appConfig": {"modulePrefix":"fastboot-test","environment":"development","baseURL":"/","locationType":"auto","EmberENV":{"FEATURES":{}},"APP":{"name":"fastboot-test","version":"0.0.0+3e9fe92d","autoboot":false},"exportApplicationGlobal":true} | ||
} | ||
} | ||
} |
@@ -329,3 +329,3 @@ "use strict"; | ||
define('fastboot-test/config/environment', ['ember'], function(Ember) { | ||
return { 'default': {"modulePrefix":"fastboot-test","environment":"development","baseURL":"/","locationType":"auto","EmberENV":{"FEATURES":{}},"APP":{"name":"fastboot-test","version":"0.0.0+3e9fe92d","autoboot":false},"exportApplicationGlobal":true}}; | ||
return FastBoot.config(); | ||
}); | ||
@@ -332,0 +332,0 @@ |
@@ -9,4 +9,5 @@ { | ||
"vendorFile": "assets/vendor.js" | ||
} | ||
}, | ||
"appConfig": {"modulePrefix":"fastboot-test","environment":"development","baseURL":"/","locationType":"auto","EmberENV":{"FEATURES":{}},"APP":{"name":"fastboot-test","version":"0.0.0+3e9fe92d","autoboot":false},"exportApplicationGlobal":true} | ||
} | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
26030212
65
426714
1
9