1.0.2 • Published 3 years ago

felfire v1.0.2

Weekly downloads
23
License
MIT
Repository
-
Last release
3 years ago

Felfire

One bolt of powerful magic to improves your development workflow

❌ Sorry, but this library is no longer maintained. Please find an alternative.

Getting started

Run local configuration

felfire start

Felfire compiles sources into buildDir, then it starts a Node server in watch mode using this compiled source. File changes would trigger a sources recompilation and server restart.

It also runs a proxy, in order to share your website in development to any coworkers within your local network.

Run distribution compilation

felfire build

Felfire will compile sources into the build directory as well. In addition, it will perform many optimization to turn the app distribution-ready. You can just now take the content of the build directory, deploy it, and you're in business.

Philosophy

  • One dependency: there is just one dependency. It provides a cohesive curated experience on top of powerful Open Source tools.
  • Zero configuration: there are no configuration files or command line options. Configuring both local and distribution builds is handled for you so you can focus on writing code. You can however use custom options to amplify your experience.
  • Extensible: with the powerful Felfire plugins system, you can plug your custom library to the compiler to extend the final Felfire capacities (e.q. a deployment plugin to Google App Engine).
  • Mutable: Felfire can mute into three states to support websites, web apps, and servers, on demand.

Why Felfire?

Every modern JavaScript environment today uses a compiler. That's can be only a Babel, Gulp, or even Webpack stack.

To materialize compilation intelligence in order to improve developer experience, Felfire was built.

Modes

Felfire comes with three modes that support three types of software: websites, web apps, and servers. Each type needs different architecture and compiler behaviour.

See the corresponding documentation about Felfire's modes.

Commands

# Runs the development compilation
felfire start [--env-file=.env] [--no-proxy] [--key=my-key]

# Runs the distribution compilation
felfire build [--env-file=.env] [--key=my-key]

# Encrypt the `./.env.plain` file to the `./.env.encrypted`
# Encrypted environment file can be read by Felfire with the `--key` argument
felfire encrypt [--key=my-key]

# Extract app's local and external dependencies into `./dependencies-map.json`
felfire extract

Options

  • --env-file: specify an environment file to inject environment variables into Felfire and the product (e.q. --env-file=.env).
  • --no-proxy: tells Felfire to not use his proxy for development purpose.
  • --key: specify a key for decrypt the encrypted environment file.

Features

Modules resolution

Felfire resolves modules the same way that Node resolves the node_modules directory. It has 2 levels of resolution, in the following order:

  • node_modules directory at the repository root.
  • src directory, for application's sources.

This feature provides clear imports segmentation:

// External module
import { withRouter, Route, Switch } from 'react-router-dom';

// App module
import Config from './config';

Environment files

Felfire resolves environment variables on runtime, but this behaviour changes relative to the mode.

In universal and static modes, Felfire resolves environment variables in development and distribution builds. In default mode, Felfire only does it on development build.

An example of environment file:

API_ENDPOINT=https://api.mydomain.com
ENVIRONMENT=staging

By default, Felfire looks for a .env file into the root, but it will ignore resolution if there is no environment file. You can specify it when running a command with the --env-file argument.

Environment files is used to replace process.env object values into the source code:

// https://api.mydomain.com
const apiEndpoint = process.env.API_ENDPOINT;

In default mode, Felfire doesn't resolve environment variables on distribution builds.

Custom configuration

Felfire uses a default configuration but you can override it by using a felfire key into the package.json (by default) or by a .felfirerc's file into the root.

Here are the full options explained:

{
  "port": 3000,
  "buildDir": "./build",
  "sourceDir": "./src",
  "cacheDir": "./.cache",
  "openOnStart": false,
  "locales": ["en"],
  "autoprefixerBrowsers": [
    "Android 2.3",
    "Android >= 4",
    "Chrome >= 35",
    "Firefox >= 31",
    "Explorer >= 9",
    "iOS >= 7",
    "Opera >= 12",
    "Safari >= 7.1"
  ],
  "filesToCopy": [
    {
      "source": "./sitemap.xml",
      "destination": "./sitemap.xml"
    },
    {
      "source": "./robots.txt",
      "destination": "./robots.txt"
    },
    {
      "source": "./favicon.ico",
      "destination": "./favicon.ico"
    }
  ],
  "cdnEndpoint": "/",
  "mode": "server",
  "locales": ["en"],
  "stats":  {
    "colors": true,
    "hash": false,
    "version": false,
    "timings": false,
    "assets": false,
    "chunks": false,
    "modules": false,
    "reasons": false,
    "children": false,
    "source": false,
    "errors": false,
    "errorDetails": false,
    "warnings": false,
    "publicPath": false
  },
  "plugins": []
}

Also, Felfire injects its configuration into the global scope as felfire. Example:

const { buildDir } = felfire.config;

Plugins

Mandatory criterions

Felfire authorizes plugins to extend its capacities. Plugins need to follow a specific nomenclature to be recognized: they needs to be prefixed by felfire- (e.q. felfire-aws-s3).

Plugin architecture

A plugin architecture needs to export a default function on its main module, then Felfire will inject some parameters to expend the plugin capacities. Example:

export default function ({ compiler, commander }) {}

There are two parameters injected:

  • compiler, corresponds to the Felfire instance. It contains a log function and the full Felfire configuration.
  • commander, corresponds to the Commander instance. Commander is used by Felfire to provide a clear interface for its commands.

Using custom arguments into a plugin

You can use custom arguments into a plugin by exporting a function named init.

AWS S3 plugin example:

export function init(commander) {
  commander.option('--env <env>', 'the AWS S3 environment that Felfire must deploys to');

  return commander;
}

commander is the instance of Felfire's interface. Specifying an option property permits to use argument with the plugin command (e.q. felfire aws-s3 --env=staging).

Finally, retrieve your argument value using the commander instance on your default exported function:

const args = _.find(commander.commands, command => command._name === 'aws-s3');
const env = args.env;

aws-s3 is the felfire-aws-s3 suffix in this context.

Felfire plugin's ecosystem

Thanks to

Blizzard, and Warcraft, for the entire inspiration on the Felfire's name!

Felfire is a corrupted magic in the Warcraft universe.

License

The MIT License (MIT)

Copyright (c) 2018 Nicolas Cava

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

1.0.2

3 years ago

1.0.1

3 years ago

4.0.0

7 years ago

3.1.0

7 years ago

3.0.0

7 years ago

2.0.0

7 years ago

1.0.0-alpha.65

7 years ago

1.0.0-alpha.64

7 years ago

1.0.0-alpha.63

8 years ago

1.0.0-alpha.62

8 years ago

1.0.0-alpha.61

8 years ago

1.0.0-alpha.60

8 years ago

1.0.0-alpha.59

8 years ago

1.0.0-alpha.58

8 years ago

1.0.0-alpha.57

8 years ago

1.0.0-alpha.56

8 years ago

1.0.0-alpha.55

8 years ago

1.0.0-alpha.54

8 years ago

1.0.0-alpha.53

8 years ago

1.0.0-alpha.52

8 years ago

1.0.0-alpha.51

8 years ago

1.0.0-alpha.50

8 years ago

1.0.0-alpha.49

8 years ago

1.0.0-alpha.48

8 years ago

1.0.0-alpha.47

8 years ago

1.0.0-alpha.46

8 years ago

1.0.0-alpha.45

8 years ago

1.0.0-alpha.44

8 years ago

1.0.0-alpha.43

8 years ago

1.0.0-alpha.42

8 years ago

1.0.0-alpha.41

8 years ago

1.0.0-alpha.40

8 years ago

1.0.0-alpha.39

8 years ago

1.0.0-alpha.38

8 years ago

1.0.0-alpha.37

8 years ago

1.0.0-alpha.35

8 years ago

1.0.0-alpha.34

8 years ago

1.0.0-alpha.33

8 years ago

1.0.0-alpha.31

8 years ago

1.0.0-alpha.30

8 years ago

1.0.0-alpha.29

8 years ago

1.0.0-alpha.28

8 years ago

1.0.0-alpha.27

8 years ago

1.0.0-alpha.26

8 years ago

1.0.0-alpha.25

8 years ago

1.0.0-alpha.24

8 years ago

1.0.0-alpha.23

8 years ago

1.0.0-alpha.22

8 years ago

1.0.0-alpha.21

8 years ago

1.0.0-alpha.20

8 years ago

1.0.0-alpha.19

8 years ago

1.0.0-alpha.18

8 years ago

1.0.0-alpha.17

8 years ago

1.0.0-alpha.16

8 years ago

1.0.0-alpha.15

8 years ago

1.0.0-alpha.14

8 years ago

1.0.0-alpha.13

8 years ago

1.0.0-alpha.12

8 years ago

1.0.0-alpha.11

8 years ago

1.0.0-alpha10

8 years ago

1.0.0-alpha9

8 years ago

1.0.0-alpha8

8 years ago

1.0.0-alpha7

8 years ago

1.0.0-alpha6

8 years ago

1.0.0-alpha5

8 years ago

1.0.0-alpha4

8 years ago

1.0.0-alpha3

8 years ago

1.0.0-alpha2

8 years ago

1.0.0-alpha1

8 years ago