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

redhead

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

redhead - npm Package Compare versions

Comparing version 0.3.3 to 0.4.0

src/config-reader.js

2

oclif.manifest.json

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

{"version":"0.3.3","commands":{"build":{"id":"build","description":"Generate the platform specific files based on the configuration","pluginName":"redhead","pluginType":"core","aliases":[],"flags":{"output":{"name":"output","type":"option","char":"o","description":"Folder where the generated files should be saved.","default":"."}},"args":[]},"init":{"id":"init","description":"Initialize the required files\n\nGenerates files for handling your headers and/or redirects configuration.\n","pluginName":"redhead","pluginType":"core","aliases":[],"flags":{"no-headers":{"name":"no-headers","type":"boolean","char":"h","description":"Whether or not to handle headers with redhead","allowNo":false},"no-redirects":{"name":"no-redirects","type":"boolean","char":"r","description":"Whether or not to handle redirects with redhead","allowNo":false}},"args":[]}}}
{"version":"0.4.0","commands":{"build":{"id":"build","description":"Generate the platform specific files based on the configuration","pluginName":"redhead","pluginType":"core","aliases":[],"flags":{"output":{"name":"output","type":"option","char":"o","description":"Folder where the generated files should be saved.","default":"."},"platform":{"name":"platform","type":"option","char":"p","description":"The target platform for the generated files","options":["netlify","firebase"],"default":"netlify"}},"args":[]},"init":{"id":"init","description":"Initialize the required files\n\nGenerates files for handling your headers and/or redirects configuration.\n","pluginName":"redhead","pluginType":"core","aliases":[],"flags":{"no-headers":{"name":"no-headers","type":"boolean","char":"h","description":"Whether or not to handle headers with redhead","allowNo":false},"no-redirects":{"name":"no-redirects","type":"boolean","char":"r","description":"Whether or not to handle redirects with redhead","allowNo":false}},"args":[]}}}
{
"name": "redhead",
"description": "Dynamically setup headers and redirects for you static deployments",
"version": "0.3.3",
"version": "0.4.0",
"bin": {

@@ -21,3 +21,3 @@ "redhead": "./bin/run"

"chai": "^4",
"eslint": "5.3.0",
"eslint": "5.16.0",
"eslint-config-airbnb": "17.1.0",

@@ -30,2 +30,3 @@ "eslint-config-oclif": "^3.1",

"mocha": "^6",
"mock-fs": "^4.8.0",
"nyc": "^13"

@@ -32,0 +33,0 @@ },

@@ -41,3 +41,3 @@ RedHead

After that, we noticed that many static deployment sites have similar limitations, that lead us to creating [RedHead](https://github.com/streaver/readhead), and now you can simply do:
After that, we noticed that many static deployment sites have similar limitations, that lead us to creating [RedHead](https://github.com/streaver/redhead), and now you can simply do:

@@ -49,3 +49,5 @@ ```sh-session

## Table of content
* [Installation](#installation)
* [Supported Platforms](#supported-platforms)
* [Usage](#usage)

@@ -78,3 +80,3 @@ * [Commands](#commands)

$ redhead (-v|--version|version)
redhead/0.3.3 darwin-x64 node-v10.15.1
redhead/0.4.0 darwin-x64 node-v11.9.0
$ redhead --help [COMMAND]

@@ -87,2 +89,17 @@ USAGE

## Supported Platforms
We currently two static deployments, but we plan on adding more (contributions are welcome):
### Currently supported
* [Netlify](https://www.netlify.com/)
* [Firebase Hosting](https://firebase.google.com/docs/hosting/)
### Plan on supporting
* [Heroku](https://elements.heroku.com/buildpacks/heroku/heroku-buildpack-static)
## Commands
<!-- commands -->

@@ -102,6 +119,7 @@ * [`redhead build`](#redhead-build)

OPTIONS
-o, --output=output [default: .] Folder where the generated files should be saved.
-o, --output=output [default: .] Folder where the generated files should be saved.
-p, --platform=netlify|firebase [default: netlify] The target platform for the generated files
```
_See code: [src/commands/build.js](https://github.com/streaver/redhead/blob/v0.3.3/src/commands/build.js)_
_See code: [src/commands/build.js](https://github.com/streaver/redhead/blob/v0.4.0/src/commands/build.js)_

@@ -141,3 +159,3 @@ ## `redhead help [COMMAND]`

_See code: [src/commands/init.js](https://github.com/streaver/redhead/blob/v0.3.3/src/commands/init.js)_
_See code: [src/commands/init.js](https://github.com/streaver/redhead/blob/v0.4.0/src/commands/init.js)_
<!-- commandsstop -->

@@ -144,0 +162,0 @@

const { Command, flags: option } = require('@oclif/command');
const fs = require('fs');
const path = require('path');
const headersWriter = require('../config-writers/headers');
const redirectsWriter = require('../config-writers/redirects');
const { configFilePath } = require('../helpers/path-generator.js');
const {
REDHEAD_DIRECTORY,
HEADERS_FILE,
REDIRECTS_FILE,
} = require('../helpers/path-constants');
const { NetlifyWriter, FirebaseWriter } = require('../config-writers/platforms');
const CONFIG_MAPPING = [
{
configFile: HEADERS_FILE,
outputFile: '_headers',
writer: headersWriter,
},
{
configFile: REDIRECTS_FILE,
outputFile: '_redirects',
writer: redirectsWriter,
},
];
const platformMapping = {
netlify: NetlifyWriter,
firebase: FirebaseWriter,
};

@@ -29,29 +12,12 @@ class BuildCommand extends Command {

const { flags } = this.parse(BuildCommand);
const { output } = flags;
const { output, platform } = flags;
BuildCommand.writeConfig(output);
BuildCommand.writeConfig(output, platform);
}
static writeConfig(outputFolder) {
CONFIG_MAPPING.forEach((mapping) => {
const configPath = configFilePath(REDHEAD_DIRECTORY, mapping.configFile);
const pathExists = fs.existsSync(configPath);
static writeConfig(outputFolder, platform) {
const PlatformWriter = platformMapping[platform];
const platformWriterInstance = new PlatformWriter({ outputFolder });
if (pathExists) {
if (!fs.existsSync(outputFolder)) {
fs.mkdirSync(outputFolder);
}
// eslint-disable-next-line global-require, import/no-dynamic-require
const config = require(path.join(process.cwd(), configPath));
const configOutputPath = path.join(
process.cwd(),
outputFolder,
mapping.outputFile,
);
fs.writeFileSync(configOutputPath, mapping.writer(config));
}
});
platformWriterInstance.write();
}

@@ -68,4 +34,10 @@ }

}),
platform: option.string({
char: 'p',
description: 'The target platform for the generated files',
options: ['netlify', 'firebase'],
default: 'netlify',
}),
};
module.exports = BuildCommand;
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