Skip to content

A CLI tool for boostrapping your favourite tools with your custom configurations

License

Notifications You must be signed in to change notification settings

OlaoluwaM/scaffy

Repository files navigation

Scaffy

Scaffy - Aggregated custom configs with dependencies | Product Hunt

Logo

Description

Configuring tools can suck. That's why we customize them once, then store them in some repo for reuse. This works, but most tools require a set of dependencies, alongside your custom configurations, to work. This can be a pain, but scaffy is here to help.

I built scaffy because I didn't enjoy constantly browsing for the right combination of dependencies to get my configurations to work. Furthermore, I'd sometimes use other people's configs but they would almost always get buried in my abyss of Github stars/bookmarks which would make searching for them such a hassle.

But with scaffy, I can aggregate all related dependencies and configurations under an alias and, with that alias, bootstrap my projects with a single command.

Demo

Built with 🥊

Scaffy is built with Typescript and it is meant to be used as a standalone CLI utility

Perquisites

Scaffy doesn't ask much 😄. All it needs is for node (v16+) and npm to be installed

Installation

  npm i -g @olaolum/scaffy

Configuration

Taking inspiration from the tsconfig.json, any json file that ends in .scaffy.json is a valid configuration file.

Scaffy will search the root of your project directory for a your configuration file. If it stumbles upon many, it will give you the option to choose.

The schema for the configuration file is as follows:

interface ConfigSchema {
  [name: string]: {
    readonly extends:
      | string
      | {
          readonly from: string;
          readonly merge: (
            | 'depNames'
            | 'devDepNames'
            | 'remoteConfigurationUrls'
            | 'localConfigurationPaths'
          )[];
        };
    depNames?: string[];
    devDepNames?: string[];
    remoteConfigurationUrls?: string[];
    localConfigurationPaths?: string[];
  };
}

The schema above states that each entry in the scaffy configuration file must be given a name. This name can be anything you desire, literally anything-you-desire. The names are naught but a means by which scaffy groups dependencies and configuration files.

All entry members are optional, but at least one member must be valid for the entry to not be ignored.

Here is an example scaffy config entry

{
  "some-other-config": {
    "devDepNames": ["eslint@latest", "[email protected]"]
  },
  "cra-eslint": {
    "extends": "some-other-config",
    "devDepNames": ["eslint-plugin-better-styled-components", "eslint-plugin-prettier"],
    "remoteConfigurationUrls": [
      "https://raw.githubusercontent.com/OlaoluwaM/planets-facts-challenge/main/.eslintrc.js",
      "https://raw.githubusercontent.com/OlaoluwaM/planets-facts-challenge/main/.prettierrc"
    ]
  }
}

You can also add version information like @latest or specific version number like @7.3.0 to any of the dependencies listed in the depNames or devDepNames options

Additionally, in the spirit of DRY, scaffy allows you to extend other configs in whole or in part. When extending one entry from another, a merge will occur with all properties of the entries involved (excluding the merging of the extends property of course).

To have an entry extend from another, simply add an extends key to the extending entry with the value being the name of the entry to be extended from. An example has been provided above

For more specific extensions, where you only wish to extend part of an entry, scaffy's got your back with that too! Here is an example

{
  "sample-parent": {
    "devDepNames": ["eslint", "jest"],
    "remoteConfigurationUrls": [
      "https://raw.githubusercontent.com/OlaoluwaM/configs-deperacated-/master/jsconfig.json"
    ]
  },

  "extending-entry": {
    "extends": {
      "from": "sample-parent",
      "merge": ["devDepNames", "remoteConfigurationUrls"]
    },
    "devDepNames": ["zod"],
    "depNames": ["eslint-plugin-react", "emotion", "yup"],
    "remoteConfigurationUrls": [
      "https://raw.githubusercontent.com/OlaoluwaM/configs/old-do-not-delete/typescript/.eslintrc.js"
    ],
    "localConfigurationPaths": ["../local-configs/.prettierrc"]
  }
}

Here, we have the entry extending-entry extending only the devDepNames and remoteConfigurationUrls from the sample-parent entry

Usage

With the example configuration above, here is how scaffy is used

  # To bootstrap cra-eslint we can do
  scaffy bootstrap cra-eslint

  # If we feel cra-eslint doesn't do what we want we can remove it using
  scaffy remove cra-eslint

  # For the version
  scaffy -v

  # You can also specify a config file with the following option
  scaffy bootstrap cra-eslint -c ./example.scaffy.json

  # You can get more info run
  scaffy -h

LICENSE

Copyright © 2022 Olaoluwa Mustapha Released under the MIT license.

About

A CLI tool for boostrapping your favourite tools with your custom configurations

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published