frozen-express
Advanced tools
Comparing version 0.4.0 to 0.5.0
@@ -0,3 +1,8 @@ | ||
# 0.5.0 | ||
Fix binary file contents. | ||
Remove server options, see a portent project instead. | ||
# 0.4.0 | ||
Now encodes URLs |
@@ -15,9 +15,1 @@ Thank you for your intention to contribute! | ||
avoid doing work that I will be hesitant to merge in for whatever reason. | ||
### Server configuration | ||
If you work on anything related to serving the resulting files, such as `.htaccess` files, you need server tests on a real Apache: | ||
1. Build a test app using `node src/bin.js --server SERVER test/server/app.js <path>`; | ||
2. Serve it using the server; | ||
3. Run `FROZEN_TEST_URL=http://localhost/ npm run test-server-run`. |
{ | ||
"name": "frozen-express", | ||
"version": "0.4.0", | ||
"version": "0.5.0", | ||
"description": "Freeze an Express.js application into a set of static files", | ||
"main": "src/frozen.js", | ||
"scripts": { | ||
"report-coverage": "istanbul cover --report lcovonly _mocha test test/functional && coveralls < coverage/lcov.info", | ||
"coverage": "istanbul cover _mocha test test/functional", | ||
"report-coverage": "istanbul cover --report lcovonly _mocha test && coveralls < coverage/lcov.info", | ||
"coverage": "istanbul cover _mocha test test", | ||
"lint": "eslint src", | ||
"test": "mocha test test/functional && npm run lint", | ||
"test-server-run": "mocha ./test/server/run.js" | ||
"test": "mocha test && npm run lint" | ||
}, | ||
@@ -13,0 +12,0 @@ "bin": "src/bin.js", |
@@ -55,18 +55,2 @@ # Frozen Express | ||
var stream = frozen(app, { | ||
// Apache specific settings | ||
// Use only if server is set to apache | ||
apache: { | ||
// Any custom .htaccess content to append to the generated file | ||
extraHtaccess: '', | ||
} | ||
// Base URL for the website relative to domain root | ||
// Required if server is set to apache | ||
// Use a single slash if the website will be hosted in the domain root | ||
base: '/subdir/', | ||
// Add control files for serving the application with a particular server | ||
// Valid options: 'apache' | ||
server: false, | ||
// A list of URLs to freeze | ||
@@ -73,0 +57,0 @@ // By default Frozen will try to detect the URLs itself |
@@ -15,9 +15,2 @@ 'use strict'; | ||
}); | ||
argparser.addArgument(['--base'], { | ||
help: 'Set a base URL relative to the domain root. Required with --server=apache.' | ||
}); | ||
argparser.addArgument(['--server'], { | ||
choices: ['apache'], | ||
help: 'Add control files for serving the application with a particular server' | ||
}); | ||
argparser.addArgument(['app'], { | ||
@@ -34,4 +27,3 @@ help: '.js file exporting your Express application' | ||
var pipe = frozen(app, { | ||
base: args.base, | ||
server: args.server | ||
base: args.base | ||
}); | ||
@@ -38,0 +30,0 @@ pipe.pipe(gulp.dest(args.path)); |
@@ -8,5 +8,2 @@ 'use strict'; | ||
var errors = require('./errors.js'); | ||
var servers = { | ||
apache: require('./servers/apache.js') | ||
}; | ||
var routes = require('./lib/routes.js'); | ||
@@ -19,4 +16,2 @@ var urlToFile = require('./lib/urlToFile.js'); | ||
options = options || {}; | ||
if (options.server && !(options.server in servers)) | ||
throw new errors.ConfigurationError('Invalid server setting'); | ||
options.urls = options.urls || routes.detectUrls(app); | ||
@@ -32,9 +27,4 @@ | ||
// The following line is untested. | ||
// However, npm package portent tests fail on Node 3+ without it with | ||
// TypeError: must start with number, buffer, array or string | ||
f.contents = f.contents.toString(); | ||
pipe.push(new File({ | ||
contents: new Buffer(f.contents), | ||
contents: f.contents, | ||
path: process.cwd() + path, | ||
@@ -74,15 +64,2 @@ base: process.cwd() | ||
if (options.server) { | ||
promises.push(servers[options.server]({ | ||
addFile: addFile, | ||
base: options.base, | ||
options: options[options.server] || {} | ||
})); | ||
promises.push(urlToFile(app, '/.frozen_express_404', { | ||
expectedStatus: [404, 405] | ||
}).then(function(f){ | ||
addFile(f); | ||
}).catch(function(){ return; })); | ||
} | ||
Promise.all(promises).then(function(){ | ||
@@ -89,0 +66,0 @@ pipe.end(); |
@@ -22,3 +22,19 @@ 'use strict'; | ||
return new Promise(function(resolve, reject){ | ||
supertest(app).get(encodeURI(url)).end(function(err, res){ | ||
var request = supertest(app).get(encodeURI(url)); | ||
// The following is a dumb parser that ensures superagent does not | ||
// decode binary data such as webfonts. | ||
// Unfortunately, there is no good test case that covers this. | ||
request.parse(function(res, done) { | ||
res.text = ''; | ||
res.setEncoding('binary'); | ||
res.on('data', function(chunk){ | ||
res.text += chunk; | ||
}); | ||
res.on('end', function() { | ||
done(); | ||
}); | ||
}); | ||
request.end(function(err, res){ | ||
if (err && err.status !== 404) return reject(err); | ||
@@ -41,3 +57,3 @@ var correctStatus = options.expectedStatus[0] <= res.statusCode && | ||
path: path, | ||
contents: res.text || res.body | ||
contents: new Buffer(res.text, 'binary') | ||
}); | ||
@@ -44,0 +60,0 @@ }); |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
2
20022
21
555
60
1